Browse Source

immunitiy check compiled to single location

postwipe-hostile
FatBoy-DOTC 4 months ago
parent
commit
a42f307a70
  1. 22
      src/engine/gameManager/PowersManager.java
  2. 44
      src/engine/powers/ActionsBase.java

22
src/engine/gameManager/PowersManager.java

@ -946,27 +946,11 @@ public enum PowersManager { @@ -946,27 +946,11 @@ public enum PowersManager {
continue;
// If something blocks the action, then stop
if (ab.blocked(target, pb, trains)) {
if (ab.blocked(target)) {
PowersManager.sendEffectMsg(playerCharacter, 5, ab, pb);
continue;
}
//Check for immunities
if (target.getObjectType() == GameObjectType.PlayerCharacter) {
PlayerCharacter pcTarget = (PlayerCharacter) target;
PlayerBonuses tarBonus = pcTarget.getBonuses();
SourceType source = SourceType.GetSourceType(ab.stackType);
boolean immune = tarBonus.getBool(ModType.ImmuneTo, source);
if(!immune){
DamageType damageType = DamageType.getDamageType(ab.stackType);
immune = pcTarget.getResists().immuneTo(damageType);
}
if(immune){
continue;
}
}
// TODO handle overwrite stack order here
String stackType = ab.getStackType();
stackType = (stackType.equals("IgnoreStack")) ? Integer.toString(ab.getUUID()) : stackType;
@ -1137,7 +1121,7 @@ public enum PowersManager { @@ -1137,7 +1121,7 @@ public enum PowersManager {
continue;
// If something blocks the action, then stop
if (ab.blocked(target, pb, trains))
if (ab.blocked(target))
continue;
// TODO handle overwrite stack order here
String stackType = ab.getStackType();
@ -1451,7 +1435,7 @@ public enum PowersManager { @@ -1451,7 +1435,7 @@ public enum PowersManager {
if (trains < ab.getMinTrains() || trains > ab.getMaxTrains())
continue;
// If something blocks the action, then stop
if (ab.blocked(target, pb, trains))
if (ab.blocked(target))
// sendPowerMsg(pc, 5, msg);
continue;
// TODO handle overwrite stack order here

44
src/engine/powers/ActionsBase.java

@ -11,13 +11,11 @@ package engine.powers; @@ -11,13 +11,11 @@ package engine.powers;
import engine.gameManager.DbManager;
import engine.gameManager.PowersManager;
import engine.mbEnums;
import engine.mbEnums.ModType;
import engine.mbEnums.SourceType;
import engine.mbEnums.StackType;
import engine.objects.AbstractCharacter;
import engine.objects.AbstractWorldObject;
import engine.objects.PlayerBonuses;
import engine.objects.Runegate;
import engine.objects.*;
import engine.powers.poweractions.AbstractPowerAction;
import org.pmw.tinylog.Logger;
@ -244,32 +242,20 @@ public class ActionsBase { @@ -244,32 +242,20 @@ public class ActionsBase {
}
//Add blocked types here
public boolean blocked(AbstractWorldObject awo, PowersBase pb, int trains) {
if (AbstractWorldObject.IsAbstractCharacter(awo)) {
AbstractCharacter ac = (AbstractCharacter) awo;
PlayerBonuses bonus = ac.getBonuses();
if (bonus == null)
return false;
//TODO make this more efficient then testing strings
if (this.stackType.equals("Stun") && bonus.getBool(ModType.ImmuneTo, SourceType.STUN))
return true; //Currently stun immune. Skip stun
else if (this.stackType.equals("Snare") && bonus.getBool(ModType.ImmuneTo, SourceType.Snare))
return true; //Currently snare immune. Skip snare
else if (this.stackType.equals("Blindness") && bonus.getBool(ModType.ImmuneTo, SourceType.Blind))
return true; //Currently blind immune. Skip blind
else if (this.stackType.equals("PowerInhibitor") && bonus.getBool(ModType.ImmuneTo, SourceType.Powerblock))
return true; //Currently power block immune. Skip power block
else if (this.stackType.equals("Root") && bonus.getBool(ModType.ImmuneTo, SourceType.Root))
return true;
// else if (pb.isHeal() && (bonus.getByte("immuneTo.Heal")) >= trains)
// return true; //Currently shadowmantled. Skip heals
else if (this.stackType.equals("Flight") && bonus.getBool(ModType.NoMod, SourceType.Fly))
return true;
else if (this.stackType.equals("Track") && bonus.getBool(ModType.CannotTrack, SourceType.None))
public boolean blocked(AbstractWorldObject awo) {
//Check for immunities
if (AbstractCharacter.IsAbstractCharacter(awo)){//awo.getObjectType() == mbEnums.GameObjectType.PlayerCharacter) {
AbstractCharacter pcTarget = (AbstractCharacter) awo;
PlayerBonuses tarBonus = pcTarget.getBonuses();
SourceType source = SourceType.GetSourceType(this.stackType);
boolean immune = tarBonus.getBool(ModType.ImmuneTo, source);
if(!immune){
mbEnums.DamageType damageType = mbEnums.DamageType.getDamageType(this.stackType);
immune = pcTarget.getResists().immuneTo(damageType);
}
if(immune){
return true;
else
return pb.vampDrain() && bonus.getBool(ModType.BlockedPowerType, SourceType.VAMPDRAIN);
}
}
return false;
}

Loading…
Cancel
Save