Browse Source

Refactor skill_used

combat-2
MagicBot 8 months ago
parent
commit
f616937236
  1. 3
      src/engine/gameManager/CombatManager.java
  2. 8
      src/engine/objects/ItemBase.java
  3. 4
      src/engine/objects/ItemFactory.java
  4. 8
      src/engine/objects/Mob.java
  5. 12
      src/engine/objects/PlayerCharacter.java

3
src/engine/gameManager/CombatManager.java

@ -1037,8 +1037,9 @@ public enum CombatManager {
} }
} }
ItemTemplate template = ItemTemplate.itemTemplates.get(wb.getUUID());
String required = wb.getSkillRequired(); String required = template.item_skill_used;
String mastery = wb.getMastery(); String mastery = wb.getMastery();
if (required.equals("Unarmed Combat")) if (required.equals("Unarmed Combat"))

8
src/engine/objects/ItemBase.java

@ -35,8 +35,6 @@ public class ItemBase {
private int hashID; private int hashID;
private final byte useAmount; private final byte useAmount;
// Armor and weapon related values
private final String skillRequired;
private final short percentRequired; private final short percentRequired;
private final short defense; private final short defense;
private final float dexPenalty; private final float dexPenalty;
@ -65,7 +63,6 @@ public class ItemBase {
this.hashID = rs.getInt("itemHashID"); this.hashID = rs.getInt("itemHashID");
this.isConsumable = false; this.isConsumable = false;
this.skillRequired = rs.getString("skillRequired");
this.percentRequired = rs.getShort("percentRequired"); this.percentRequired = rs.getShort("percentRequired");
this.defense = rs.getShort("defense"); this.defense = rs.getShort("defense");
this.dexPenalty = rs.getFloat("dexPenalty"); this.dexPenalty = rs.getFloat("dexPenalty");
@ -248,11 +245,6 @@ public class ItemBase {
public boolean isTwoHanded() { public boolean isTwoHanded() {
return this.twoHanded; return this.twoHanded;
} }
public String getSkillRequired() {
return skillRequired;
}
public String getMastery() { public String getMastery() {
return mastery; return mastery;
} }

4
src/engine/objects/ItemFactory.java

@ -221,7 +221,7 @@ public class ItemFactory {
if (template.item_type.equals(ItemType.WEAPON) && ib.getPercentRequired() == 110) { if (template.item_type.equals(ItemType.WEAPON) && ib.getPercentRequired() == 110) {
switch (ib.getSkillRequired()) { switch (template.item_skill_used) {
case "Bow": case "Bow":
case "Crossbow": case "Crossbow":
case "Spear": case "Spear":
@ -815,7 +815,7 @@ public class ItemFactory {
int wormwoodAmount = 0; int wormwoodAmount = 0;
if (template.item_type.equals(ItemType.WEAPON) && ib.getPercentRequired() == 110) { if (template.item_type.equals(ItemType.WEAPON) && ib.getPercentRequired() == 110) {
switch (ib.getSkillRequired()) { switch (template.item_skill_used) {
case "Bow": case "Bow":
case "Crossbow": case "Crossbow":
case "Spear": case "Spear":

8
src/engine/objects/Mob.java

@ -1243,7 +1243,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
skill = null; skill = null;
mastery = null; mastery = null;
} else { } else {
skill = this.skills.get(wb.getSkillRequired()); skill = this.skills.get(weapon.template.item_skill_used);
mastery = this.skills.get(wb.getMastery()); mastery = this.skills.get(wb.getMastery());
} }
@ -1298,10 +1298,10 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
if (!armor.template.item_type.equals(ItemType.ARMOR)) if (!armor.template.item_type.equals(ItemType.ARMOR))
return 0; return 0;
if (ib.getSkillRequired().isEmpty()) if (armor.template.item_skill_used.isEmpty())
return ib.getDefense(); return ib.getDefense();
CharacterSkill armorSkill = this.skills.get(ib.getSkillRequired()); CharacterSkill armorSkill = this.skills.get(armor.template.item_skill_used);
if (armorSkill == null) if (armorSkill == null)
return ib.getDefense(); return ib.getDefense();
@ -1372,7 +1372,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
else else
this.rangeHandTwo = weapon.getItemBase().getRange() * (1 + (baseStrength / 600.0f)); this.rangeHandTwo = weapon.getItemBase().getRange() * (1 + (baseStrength / 600.0f));
skillPercentage = getModifiedAmount(this.skills.get(wb.getSkillRequired())); skillPercentage = getModifiedAmount(this.skills.get(weapon.template.item_skill_used));
masteryPercentage = getModifiedAmount(this.skills.get(wb.getMastery())); masteryPercentage = getModifiedAmount(this.skills.get(wb.getMastery()));
if (masteryPercentage == 0f) if (masteryPercentage == 0f)

12
src/engine/objects/PlayerCharacter.java

@ -2841,11 +2841,11 @@ public class PlayerCharacter extends AbstractCharacter {
if (ib != null) { if (ib != null) {
if ((item.template.item_type.equals(ItemType.WEAPON)) if ((item.template.item_type.equals(ItemType.WEAPON))
&& (ib.getSkillRequired().equals(type) || ib.getMastery().equals(type))) && (item.template.item_skill_used.equals(type) || ib.getMastery().equals(type)))
return true; return true;
return (item.template.item_type.equals(ItemType.ARMOR)) return (item.template.item_type.equals(ItemType.ARMOR))
&& (ib.getSkillRequired().equals(type)); && (item.template.item_skill_used.equals(type));
} }
return false; return false;
@ -3919,7 +3919,7 @@ public class PlayerCharacter extends AbstractCharacter {
this.rangeHandTwo *= range_bonus; this.rangeHandTwo *= range_bonus;
} }
skillPercentage = getModifiedAmount(this.skills.get(wb.getSkillRequired())); skillPercentage = getModifiedAmount(this.skills.get(weapon.template.item_skill_used));
masteryPercentage = getModifiedAmount(this.skills.get(wb.getMastery())); masteryPercentage = getModifiedAmount(this.skills.get(wb.getMastery()));
if (masteryPercentage == 0f) if (masteryPercentage == 0f)
mastDam = 0f; mastDam = 0f;
@ -4174,10 +4174,10 @@ public class PlayerCharacter extends AbstractCharacter {
if (!armor.template.item_type.equals(ItemType.ARMOR)) if (!armor.template.item_type.equals(ItemType.ARMOR))
return 0; return 0;
if (ib.getSkillRequired().isEmpty()) if (armor.template.item_skill_used.isEmpty())
return ib.getDefense(); return ib.getDefense();
CharacterSkill armorSkill = this.skills.get(ib.getSkillRequired()); CharacterSkill armorSkill = this.skills.get(armor.template.item_skill_used);
if (armorSkill == null) { if (armorSkill == null) {
Logger.error("Player " + this.getObjectUUID() Logger.error("Player " + this.getObjectUUID()
+ " has armor equipped without the nescessary skill to equip it"); + " has armor equipped without the nescessary skill to equip it");
@ -4218,7 +4218,7 @@ public class PlayerCharacter extends AbstractCharacter {
skill = this.skills.get("Unarmed Combat"); skill = this.skills.get("Unarmed Combat");
mastery = this.skills.get("Unarmed Combat Mastery"); mastery = this.skills.get("Unarmed Combat Mastery");
} else { } else {
skill = this.skills.get(wb.getSkillRequired()); skill = this.skills.get(weapon.template.item_skill_used);
mastery = this.skills.get(wb.getMastery()); mastery = this.skills.get(wb.getMastery());
} }
if (skill != null) if (skill != null)

Loading…
Cancel
Save