From f354339af14ab90b9411f8722e069be9d1ad6b54 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 3 Sep 2023 20:38:48 -0500 Subject: [PATCH] null checks --- src/engine/objects/CharacterSkill.java | 56 ++++++++++++++------------ 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/src/engine/objects/CharacterSkill.java b/src/engine/objects/CharacterSkill.java index 80dc9150..0a6648ae 100644 --- a/src/engine/objects/CharacterSkill.java +++ b/src/engine/objects/CharacterSkill.java @@ -265,6 +265,9 @@ public class CharacterSkill extends AbstractGameObject { this.ownerUID = mob.getObjectUUID(); this.isMobOwner = true; boolean isGuard = mob.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN) || mob.agentType.equals(Enum.AIAgentType.GUARDMINION); + if(isGuard) { + boolean poop = true; + } calculateMobBaseAmount(isGuard); calculateModifiedAmount(isGuard); this.skillType = CharacterSkills.GetCharacterSkillByToken(this.skillsBase.getToken()); @@ -1036,15 +1039,15 @@ public class CharacterSkill extends AbstractGameObject { //Get any rune bonus float bonus = 0f; //TODO SKILLS RUNES - + float base = 7f; + float statMod = 0.5f; if (CharacterSkill.GetOwner(this) != null && CharacterSkill.GetOwner(this).getBonuses() != null) { //Get bonuses from runes bonus = CharacterSkill.GetOwner(this).getBonuses().getSkillBonus(this.skillsBase.sourceType); - } //Get Base skill for unmodified stats - float base = 7f; - float statMod = 0.5f; + + if (this.skillsBase.getStrMod() > 0) statMod += (float) this.skillsBase.getStrMod() * (float) ((Mob) CharacterSkill.GetOwner(this)).getMobBase().getMobBaseStats().getBaseStr() / 100f; if (this.skillsBase.getDexMod() > 0) @@ -1059,6 +1062,7 @@ public class CharacterSkill extends AbstractGameObject { statMod = 1f; else if (statMod > 600) statMod = 600f; + } base += CharacterSkill.baseSkillValues[(int) statMod]; if (base + bonus < 1f) @@ -1079,35 +1083,37 @@ public class CharacterSkill extends AbstractGameObject { } //Get any rune bonus float bonus = 0f; + float base = 7f; + float statMod = 0.5f; if (CharacterSkill.GetOwner(this) != null && CharacterSkill.GetOwner(this).getBonuses() != null) { //Get bonuses from runes bonus = CharacterSkill.GetOwner(this).getBonuses().getSkillBonus(this.skillsBase.sourceType); - } - //Get Base skill for modified stats - //TODO this fomula needs verified - float base = 7f; - float statMod = 0.5f; - if (this.skillsBase.getStrMod() > 0) - statMod += (float) this.skillsBase.getStrMod() * (float) CharacterSkill.GetOwner(this).getStatStrCurrent() / 100f; - if (this.skillsBase.getDexMod() > 0) - statMod += (float) this.skillsBase.getDexMod() * (float) CharacterSkill.GetOwner(this).getStatDexCurrent() / 100f; - if (this.skillsBase.getConMod() > 0) - statMod += (float) this.skillsBase.getConMod() * (float) CharacterSkill.GetOwner(this).getStatConCurrent() / 100f; - if (this.skillsBase.getIntMod() > 0) - statMod += (float) this.skillsBase.getIntMod() * (float) CharacterSkill.GetOwner(this).getStatIntCurrent() / 100f; - if (this.skillsBase.getSpiMod() > 0) - statMod += (float) this.skillsBase.getSpiMod() * (float) CharacterSkill.GetOwner(this).getStatSpiCurrent() / 100f; - if (statMod < 1) - statMod = 1f; - else if (statMod > 600) - statMod = 600f; + + //Get Base skill for modified stats + //TODO this fomula needs verified + + if (this.skillsBase.getStrMod() > 0) + statMod += (float) this.skillsBase.getStrMod() * (float) CharacterSkill.GetOwner(this).getStatStrCurrent() / 100f; + if (this.skillsBase.getDexMod() > 0) + statMod += (float) this.skillsBase.getDexMod() * (float) CharacterSkill.GetOwner(this).getStatDexCurrent() / 100f; + if (this.skillsBase.getConMod() > 0) + statMod += (float) this.skillsBase.getConMod() * (float) CharacterSkill.GetOwner(this).getStatConCurrent() / 100f; + if (this.skillsBase.getIntMod() > 0) + statMod += (float) this.skillsBase.getIntMod() * (float) CharacterSkill.GetOwner(this).getStatIntCurrent() / 100f; + if (this.skillsBase.getSpiMod() > 0) + statMod += (float) this.skillsBase.getSpiMod() * (float) CharacterSkill.GetOwner(this).getStatSpiCurrent() / 100f; + if (statMod < 1) + statMod = 1f; + else if (statMod > 600) + statMod = 600f; + } base += CharacterSkill.baseSkillValues[(int) statMod]; SourceType sourceType = SourceType.GetSourceType(this.skillsBase.getNameNoSpace()); //Get any rune, effect and item bonus - if (CharacterSkill.GetOwner(this).getBonuses() != null) { + if (CharacterSkill.GetOwner(this) != null && CharacterSkill.GetOwner(this).getBonuses() != null) { //add bonuses from effects/items and runes base += bonus + CharacterSkill.GetOwner(this).getBonuses().getFloat(ModType.Skill, sourceType); } @@ -1119,7 +1125,7 @@ public class CharacterSkill extends AbstractGameObject { float modAmount = this.baseAmount + calculateAmountAfterTrains(); - if (CharacterSkill.GetOwner(this).getBonuses() != null) { + if (CharacterSkill.GetOwner(this) != null && CharacterSkill.GetOwner(this).getBonuses() != null) { //Multiply any percent bonuses modAmount *= (1 + CharacterSkill.GetOwner(this).getBonuses().getFloatPercentAll(ModType.Skill, sourceType)); }