Browse Source

Start mobequip refactor

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

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

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

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

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

30
src/engine/gameManager/NPCManager.java

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

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

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

Loading…
Cancel
Save