forked from MagicBane/Server
immunitiy check compiled to single location
This commit is contained in:
@@ -946,27 +946,11 @@ public enum PowersManager {
|
|||||||
continue;
|
continue;
|
||||||
// If something blocks the action, then stop
|
// If something blocks the action, then stop
|
||||||
|
|
||||||
if (ab.blocked(target, pb, trains)) {
|
if (ab.blocked(target)) {
|
||||||
|
|
||||||
PowersManager.sendEffectMsg(playerCharacter, 5, ab, pb);
|
PowersManager.sendEffectMsg(playerCharacter, 5, ab, pb);
|
||||||
continue;
|
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
|
// TODO handle overwrite stack order here
|
||||||
String stackType = ab.getStackType();
|
String stackType = ab.getStackType();
|
||||||
stackType = (stackType.equals("IgnoreStack")) ? Integer.toString(ab.getUUID()) : stackType;
|
stackType = (stackType.equals("IgnoreStack")) ? Integer.toString(ab.getUUID()) : stackType;
|
||||||
@@ -1137,7 +1121,7 @@ public enum PowersManager {
|
|||||||
continue;
|
continue;
|
||||||
// If something blocks the action, then stop
|
// If something blocks the action, then stop
|
||||||
|
|
||||||
if (ab.blocked(target, pb, trains))
|
if (ab.blocked(target))
|
||||||
continue;
|
continue;
|
||||||
// TODO handle overwrite stack order here
|
// TODO handle overwrite stack order here
|
||||||
String stackType = ab.getStackType();
|
String stackType = ab.getStackType();
|
||||||
@@ -1451,7 +1435,7 @@ public enum PowersManager {
|
|||||||
if (trains < ab.getMinTrains() || trains > ab.getMaxTrains())
|
if (trains < ab.getMinTrains() || trains > ab.getMaxTrains())
|
||||||
continue;
|
continue;
|
||||||
// If something blocks the action, then stop
|
// If something blocks the action, then stop
|
||||||
if (ab.blocked(target, pb, trains))
|
if (ab.blocked(target))
|
||||||
// sendPowerMsg(pc, 5, msg);
|
// sendPowerMsg(pc, 5, msg);
|
||||||
continue;
|
continue;
|
||||||
// TODO handle overwrite stack order here
|
// TODO handle overwrite stack order here
|
||||||
|
|||||||
@@ -11,13 +11,11 @@ package engine.powers;
|
|||||||
|
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.gameManager.PowersManager;
|
import engine.gameManager.PowersManager;
|
||||||
|
import engine.mbEnums;
|
||||||
import engine.mbEnums.ModType;
|
import engine.mbEnums.ModType;
|
||||||
import engine.mbEnums.SourceType;
|
import engine.mbEnums.SourceType;
|
||||||
import engine.mbEnums.StackType;
|
import engine.mbEnums.StackType;
|
||||||
import engine.objects.AbstractCharacter;
|
import engine.objects.*;
|
||||||
import engine.objects.AbstractWorldObject;
|
|
||||||
import engine.objects.PlayerBonuses;
|
|
||||||
import engine.objects.Runegate;
|
|
||||||
import engine.powers.poweractions.AbstractPowerAction;
|
import engine.powers.poweractions.AbstractPowerAction;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
@@ -244,32 +242,20 @@ public class ActionsBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Add blocked types here
|
//Add blocked types here
|
||||||
public boolean blocked(AbstractWorldObject awo, PowersBase pb, int trains) {
|
public boolean blocked(AbstractWorldObject awo) {
|
||||||
if (AbstractWorldObject.IsAbstractCharacter(awo)) {
|
//Check for immunities
|
||||||
AbstractCharacter ac = (AbstractCharacter) awo;
|
if (AbstractCharacter.IsAbstractCharacter(awo)){//awo.getObjectType() == mbEnums.GameObjectType.PlayerCharacter) {
|
||||||
PlayerBonuses bonus = ac.getBonuses();
|
AbstractCharacter pcTarget = (AbstractCharacter) awo;
|
||||||
if (bonus == null)
|
PlayerBonuses tarBonus = pcTarget.getBonuses();
|
||||||
return false;
|
SourceType source = SourceType.GetSourceType(this.stackType);
|
||||||
|
boolean immune = tarBonus.getBool(ModType.ImmuneTo, source);
|
||||||
//TODO make this more efficient then testing strings
|
if(!immune){
|
||||||
if (this.stackType.equals("Stun") && bonus.getBool(ModType.ImmuneTo, SourceType.STUN))
|
mbEnums.DamageType damageType = mbEnums.DamageType.getDamageType(this.stackType);
|
||||||
return true; //Currently stun immune. Skip stun
|
immune = pcTarget.getResists().immuneTo(damageType);
|
||||||
else if (this.stackType.equals("Snare") && bonus.getBool(ModType.ImmuneTo, SourceType.Snare))
|
}
|
||||||
return true; //Currently snare immune. Skip snare
|
if(immune){
|
||||||
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;
|
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))
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return pb.vampDrain() && bonus.getBool(ModType.BlockedPowerType, SourceType.VAMPDRAIN);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user