Browse Source

Start mobequip refactor

combat-2
MagicBot 8 months ago
parent
commit
8f7208ff34
  1. 12
      src/engine/devcmd/cmds/PrintStatsCmd.java
  2. 8
      src/engine/devcmd/cmds/SimulateBootyCmd.java
  3. 24
      src/engine/gameManager/NPCManager.java
  4. 2
      src/engine/net/client/handlers/BuyFromNPCMsgHandler.java
  5. 6
      src/engine/net/client/msg/BuyFromNPCWindowMsg.java

12
src/engine/devcmd/cmds/PrintStatsCmd.java

@ -13,8 +13,6 @@ import engine.Enum; @@ -13,8 +13,6 @@ import engine.Enum;
import engine.devcmd.AbstractDevCmd;
import engine.objects.*;
import java.util.HashMap;
/**
*
*/
@ -66,11 +64,12 @@ public class PrintStatsCmd extends AbstractDevCmd { @@ -66,11 +64,12 @@ public class PrintStatsCmd extends AbstractDevCmd {
}
public void printStatsMob(PlayerCharacter pc, Mob tar) {
MobBase mb = tar.getMobBase();
if (mb == null)
return;
String newline = "\r\n ";
String out = "Server stats for Mob " + mb.getFirstName() + newline;
out += "Stats Base (Modified)" + newline;
@ -86,10 +85,9 @@ public class PrintStatsCmd extends AbstractDevCmd { @@ -86,10 +85,9 @@ public class PrintStatsCmd extends AbstractDevCmd {
out += "Defense: " + tar.getDefenseRating() + newline;
//get weapons
HashMap<Enum.EquipSlotType, Item> equip = tar.getEquip();
if(equip != null){
if (equip.get(2) != null && !ItemTemplate.isShield(equip.get(2).template)) {
if (tar.charItemManager.equipped.isEmpty() == false)
if (tar.charItemManager.equipped.get(Enum.EquipSlotType.LHELD) != null && !ItemTemplate.isShield(tar.charItemManager.equipped.get(Enum.EquipSlotType.LHELD))) {
//off hand weapon
out += "Attack Rating: " + tar.atrHandTwo + newline;
out += "Damage: " + tar.minDamageHandTwo + " - " + tar.maxDamageHandTwo + newline;
@ -101,7 +99,7 @@ public class PrintStatsCmd extends AbstractDevCmd { @@ -101,7 +99,7 @@ public class PrintStatsCmd extends AbstractDevCmd {
out += "Range: " + tar.rangeHandOne + newline;
out += "Attack Speed: " + tar.speedHandOne + newline;
}
}
out += "isAlive: " + tar.isAlive() + ", Combat: " + tar.isCombat() + newline;
throwbackInfo(pc, out);

8
src/engine/devcmd/cmds/SimulateBootyCmd.java

@ -87,14 +87,14 @@ public class SimulateBootyCmd extends AbstractDevCmd { @@ -87,14 +87,14 @@ public class SimulateBootyCmd extends AbstractDevCmd {
} catch (Exception ex) {
failures++;
}
if (mob.getEquip() != null) {
for (Item me : mob.getEquip().values()) {
if (mob.charItemManager.equipped.isEmpty() == false) {
for (Item me : mob.charItemManager.equipped.values()) {
if (me.getDropChance() == 0)
if (me.drop_chance == 0)
continue;
float equipmentRoll = ThreadLocalRandom.current().nextInt(99) + 1;
float dropChance = me.getDropChance() * 100;
float dropChance = me.drop_chance * 100;
if (equipmentRoll > (dropChance))
continue;

24
src/engine/gameManager/NPCManager.java

@ -293,14 +293,14 @@ public enum NPCManager { @@ -293,14 +293,14 @@ public enum NPCManager {
float rankModifier = 1 + (guard.getRank() * 0.1f);
int primaryStat = 0;
if(guard.equip == null) {
if (guard.charItemManager.equipped.isEmpty()) {
guard.minDamageHandOne = (int) ((guard.mobBase.getDamageMin()) * rankModifier);
guard.maxDamageHandOne = (int) ((guard.mobBase.getDamageMax()) * rankModifier);
guard.speedHandOne = 30.0f;
} else {
if (guard.equip.containsKey(Enum.EquipSlotType.RHELD)) {
if (guard.charItemManager.equipped.containsKey(Enum.EquipSlotType.RHELD)) {
//has main hand weapon
Item weapon = guard.equip.get(Enum.EquipSlotType.RHELD);
Item weapon = guard.charItemManager.equipped.get(Enum.EquipSlotType.RHELD);
if (weapon.template.item_primary_attr.equals(Enum.AttributeType.Strength))
primaryStat = guard.getStatStrCurrent();
@ -311,9 +311,9 @@ public enum NPCManager { @@ -311,9 +311,9 @@ public enum NPCManager {
guard.maxDamageHandOne = (int) ((guard.mobBase.getDamageMax() + weapon.template.item_weapon_damage.values().iterator().next()[1]) * rankModifier) + primaryStat;
guard.speedHandOne = weapon.template.item_weapon_wepspeed;
guard.rangeHandOne = weapon.template.item_weapon_max_range;
} else if (guard.equip.containsKey(Enum.EquipSlotType.LHELD) && !ItemTemplate.isShield(guard.equip.get(Enum.EquipSlotType.LHELD).template)) {
} else if (guard.charItemManager.equipped.containsKey(Enum.EquipSlotType.LHELD) && !ItemTemplate.isShield(guard.charItemManager.equipped.get(Enum.EquipSlotType.LHELD).template)) {
//has off hand weapon
Item weapon = guard.equip.get(Enum.EquipSlotType.LHELD);
Item weapon = guard.charItemManager.equipped.get(Enum.EquipSlotType.LHELD);
if (weapon.template.item_primary_attr.equals(Enum.AttributeType.Strength))
primaryStat = guard.getStatStrCurrent();
else
@ -338,7 +338,7 @@ public enum NPCManager { @@ -338,7 +338,7 @@ public enum NPCManager {
dexterity = 1;
int baseDef = guard.mobBase.getDefenseRating();
int armorDefense = 0;
for(Item equipped : guard.equip.values())
for (Item equipped : guard.charItemManager.equipped.values())
if (equipped.template.item_type.equals(Enum.ItemType.ARMOR) || ItemTemplate.isShield(equipped.template))
armorDefense += equipped.template.item_defense_rating;
guard.defenseRating = dexterity + baseDef + armorDefense;
@ -347,10 +347,10 @@ public enum NPCManager { @@ -347,10 +347,10 @@ public enum NPCManager {
public static void setAttackRatingForGuard(Mob guard) {
int strength = guard.getStatStrCurrent();
int baseAtr = guard.mobBase.getAttackRating();
if (guard.equip.get(1) != null)
guard.atrHandOne = baseAtr + (int) ((strength * 0.5f) + (guard.equip.get(Enum.EquipSlotType.RHELD).getItemBase().getPercentRequired() * 4) + (guard.equip.get(Enum.EquipSlotType.RHELD).getItemBase().getPercentRequired() * 3));
else if (guard.equip.get(2) != null && !ItemTemplate.isShield(guard.equip.get(Enum.EquipSlotType.LHELD).template))
guard.atrHandTwo = baseAtr + (int) ((strength * 0.5f) + (guard.equip.get(Enum.EquipSlotType.LHELD).getItemBase().getPercentRequired() * 4) + (guard.equip.get(Enum.EquipSlotType.LHELD).getItemBase().getPercentRequired() * 3));
if (guard.charItemManager.equipped.get(Enum.EquipSlotType.RHELD) != null)
guard.atrHandOne = baseAtr + (int) ((strength * 0.5f) + (guard.charItemManager.equipped.get(Enum.EquipSlotType.RHELD).getItemBase().getPercentRequired() * 4) + (guard.charItemManager.equipped.get(Enum.EquipSlotType.RHELD).getItemBase().getPercentRequired() * 3));
else if (guard.charItemManager.equipped.get(Enum.EquipSlotType.LHELD) != null && !ItemTemplate.isShield(guard.charItemManager.equipped.get(Enum.EquipSlotType.LHELD).template))
guard.atrHandTwo = baseAtr + (int) ((strength * 0.5f) + (guard.charItemManager.equipped.get(Enum.EquipSlotType.LHELD).getItemBase().getPercentRequired() * 4) + (guard.charItemManager.equipped.get(Enum.EquipSlotType.LHELD).getItemBase().getPercentRequired() * 3));
else
guard.atrHandOne = baseAtr;
}
@ -424,10 +424,10 @@ public enum NPCManager { @@ -424,10 +424,10 @@ public enum NPCManager {
public static void applyEquipmentResists(Mob mob){
if (mob.equip == null)
if (mob.charItemManager.equipped.isEmpty())
return;
for (Item equipped : mob.equip.values()) {
for (Item equipped : mob.charItemManager.equipped.values()) {
if (equipped.template.item_type.equals(Enum.ItemType.ARMOR)) {
mob.resists.setResist(Enum.SourceType.SLASHING, mob.resists.getResist(Enum.SourceType.SLASHING, 0) + equipped.template.combat_attack_resist.get("SLASHING"));
mob.resists.setResist(Enum.SourceType.CRUSHING, mob.resists.getResist(Enum.SourceType.CRUSHING, 0) + equipped.template.combat_attack_resist.get("CRUSHING"));

2
src/engine/net/client/handlers/BuyFromNPCMsgHandler.java

@ -115,7 +115,7 @@ public class BuyFromNPCMsgHandler extends AbstractClientMsgHandler { @@ -115,7 +115,7 @@ public class BuyFromNPCMsgHandler extends AbstractClientMsgHandler {
buy = Item.createItemForPlayer(sourcePlayer, me.templateID);
if (buy != null) {
me.transferEnchants(buy);
// me.transferEnchants(buy);
itemMan.addItemToInventory(buy);
//itemMan.updateInventory();
}

6
src/engine/net/client/msg/BuyFromNPCWindowMsg.java

@ -147,10 +147,10 @@ public class BuyFromNPCWindowMsg extends ClientNetMsg { @@ -147,10 +147,10 @@ public class BuyFromNPCWindowMsg extends ClientNetMsg {
//add generic sell inventory from contract
if (sellInventory != null) {
for (Item Item : sellInventory) {
for (Item item : sellInventory) {
try {
Item._serializeForVendor(Item, writer, sellPercent);
} catch (SerializationException se) {
Item.serializeForClientMsgForVendor(item, writer, sellPercent);
} catch (Exception se) {
continue;
}
++total;

Loading…
Cancel
Save