forked from MagicBane/Server
Refactored out garbage variables
This commit is contained in:
@@ -30,12 +30,8 @@ import java.util.concurrent.ThreadLocalRandom;
|
|||||||
public class TransferStatPowerAction extends AbstractPowerAction {
|
public class TransferStatPowerAction extends AbstractPowerAction {
|
||||||
|
|
||||||
protected String effectID;
|
protected String effectID;
|
||||||
protected boolean transferFromHealth = false;
|
public PowerAction powerAction;
|
||||||
protected boolean transferFromMana = false;
|
|
||||||
protected boolean transferFromStamina = false;
|
|
||||||
protected boolean transferToHealth = false;
|
|
||||||
protected boolean transferToMana = false;
|
|
||||||
protected boolean transferToStamina = false;
|
|
||||||
protected float transferAmount;
|
protected float transferAmount;
|
||||||
protected float transferRamp;
|
protected float transferRamp;
|
||||||
protected boolean transferRampAdd;
|
protected boolean transferRampAdd;
|
||||||
@@ -48,22 +44,10 @@ public class TransferStatPowerAction extends AbstractPowerAction {
|
|||||||
|
|
||||||
public TransferStatPowerAction(PowerAction powerAction, HashMap<String, EffectsBase> effects) {
|
public TransferStatPowerAction(PowerAction powerAction, HashMap<String, EffectsBase> effects) {
|
||||||
super(powerAction);
|
super(powerAction);
|
||||||
|
|
||||||
|
this.powerAction = powerAction;
|
||||||
this.effectID = powerAction.effects.get(0).effect_id;
|
this.effectID = powerAction.effects.get(0).effect_id;
|
||||||
|
|
||||||
|
|
||||||
if (powerAction.statTransfer.fromStat.equals(mbEnums.CostType.HEALTH))
|
|
||||||
this.transferFromHealth = true;
|
|
||||||
else if (powerAction.statTransfer.fromStat.equals(mbEnums.CostType.MANA))
|
|
||||||
this.transferFromMana = true;
|
|
||||||
else
|
|
||||||
this.transferFromStamina = true;
|
|
||||||
|
|
||||||
if (powerAction.statTransfer.toStat.equals(mbEnums.CostType.HEALTH))
|
|
||||||
this.transferToHealth = true;
|
|
||||||
else if (powerAction.statTransfer.fromStat.equals(mbEnums.CostType.MANA))
|
|
||||||
this.transferToMana = true;
|
|
||||||
else
|
|
||||||
this.transferToStamina = true;
|
|
||||||
this.transferAmount = powerAction.getFloat("transferAmount");
|
this.transferAmount = powerAction.getFloat("transferAmount");
|
||||||
this.transferRamp = powerAction.getFloat("transferRamp");
|
this.transferRamp = powerAction.getFloat("transferRamp");
|
||||||
this.transferEfficiency = powerAction.getFloat("transferEfficiency");
|
this.transferEfficiency = powerAction.getFloat("transferEfficiency");
|
||||||
@@ -88,29 +72,6 @@ public class TransferStatPowerAction extends AbstractPowerAction {
|
|||||||
return this.effectID;
|
return this.effectID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean transferFromHealth() {
|
|
||||||
return this.transferFromHealth;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean transferFromMana() {
|
|
||||||
return this.transferFromMana;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean transferFromStamina() {
|
|
||||||
return this.transferFromStamina;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean transferToHealth() {
|
|
||||||
return this.transferToHealth;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean transferToMana() {
|
|
||||||
return this.transferToMana;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean transferToStamina() {
|
|
||||||
return this.transferToStamina;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EffectsBase getEffect() {
|
public EffectsBase getEffect() {
|
||||||
return this.effect;
|
return this.effect;
|
||||||
@@ -158,7 +119,6 @@ public class TransferStatPowerAction extends AbstractPowerAction {
|
|||||||
toAwo = awo;
|
toAwo = awo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (AbstractWorldObject.IsAbstractCharacter(fromAwo) && AbstractWorldObject.IsAbstractCharacter(toAwo)) {
|
if (AbstractWorldObject.IsAbstractCharacter(fromAwo) && AbstractWorldObject.IsAbstractCharacter(toAwo)) {
|
||||||
AbstractCharacter from = (AbstractCharacter) fromAwo;
|
AbstractCharacter from = (AbstractCharacter) fromAwo;
|
||||||
AbstractCharacter to = (AbstractCharacter) toAwo;
|
AbstractCharacter to = (AbstractCharacter) toAwo;
|
||||||
@@ -217,25 +177,34 @@ public class TransferStatPowerAction extends AbstractPowerAction {
|
|||||||
float toAmount = fromAmount * (getTransferEfficiency(trains) / 100);
|
float toAmount = fromAmount * (getTransferEfficiency(trains) / 100);
|
||||||
|
|
||||||
//get max amount to transfer, don't give more then the target has
|
//get max amount to transfer, don't give more then the target has
|
||||||
float maxDrain;
|
float maxDrain = 0;
|
||||||
if (this.transferFromHealth)
|
|
||||||
maxDrain = from.getCurrentHitpoints();
|
switch (powerAction.statTransfer.fromStat) {
|
||||||
else if (this.transferFromMana)
|
case HEALTH:
|
||||||
maxDrain = from.getMana();
|
maxDrain = from.getCurrentHitpoints();
|
||||||
else
|
break;
|
||||||
maxDrain = from.getStamina();
|
case MANA:
|
||||||
|
maxDrain = from.getMana();
|
||||||
|
break;
|
||||||
|
case STAMINA:
|
||||||
|
maxDrain = from.getStamina();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (toAmount > maxDrain)
|
if (toAmount > maxDrain)
|
||||||
toAmount = maxDrain;
|
toAmount = maxDrain;
|
||||||
|
|
||||||
//prep messages for transfer
|
//prep messages for transfer
|
||||||
|
|
||||||
int powerID = pb.getToken();
|
int powerID = pb.getToken();
|
||||||
int effectID = 496519310;
|
int effectID = 496519310;
|
||||||
String powerName = pb.getName();
|
String powerName = pb.getName();
|
||||||
ModifyHealthMsg mhmTo;
|
|
||||||
// ModifyHealthMsg mhmFrom;
|
ModifyHealthMsg mhmTo = null;
|
||||||
AbstractNetMsg mhmFrom = null;
|
AbstractNetMsg mhmFrom = null;
|
||||||
|
|
||||||
//stop if target is immune to drains
|
//stop if target is immune to drains
|
||||||
|
|
||||||
if (from.getBonuses().getBool(ModType.ImmuneTo, SourceType.Drain)) {
|
if (from.getBonuses().getBool(ModType.ImmuneTo, SourceType.Drain)) {
|
||||||
ModifyHealthMsg mhm = new ModifyHealthMsg(source, to, 0f, 0f, 0f, powerID, powerName, trains, effectID);
|
ModifyHealthMsg mhm = new ModifyHealthMsg(source, to, 0f, 0f, 0f, powerID, powerName, trains, effectID);
|
||||||
mhm.setUnknown03(5); //set target is immune
|
mhm.setUnknown03(5); //set target is immune
|
||||||
@@ -243,32 +212,40 @@ public class TransferStatPowerAction extends AbstractPowerAction {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//apply transfer bonus
|
switch (powerAction.statTransfer.toStat) {
|
||||||
if (this.transferToHealth) {
|
case HEALTH:
|
||||||
to.modifyHealth(toAmount, source, false);
|
to.modifyHealth(toAmount, source, false);
|
||||||
mhmTo = new ModifyHealthMsg(source, to, toAmount, 0f, 0f, powerID, powerName, trains, effectID);
|
mhmTo = new ModifyHealthMsg(source, to, toAmount, 0f, 0f, powerID, powerName, trains, effectID);
|
||||||
} else if (this.transferToMana) {
|
break;
|
||||||
to.modifyMana(toAmount, source);
|
case MANA:
|
||||||
mhmTo = new ModifyHealthMsg(source, to, 0f, toAmount, 0f, powerID, powerName, trains, effectID);
|
to.modifyMana(toAmount, source);
|
||||||
} else {
|
mhmTo = new ModifyHealthMsg(source, to, 0f, toAmount, 0f, powerID, powerName, trains, effectID);
|
||||||
to.modifyStamina(toAmount, source);
|
break;
|
||||||
mhmTo = new ModifyHealthMsg(source, to, 0f, 0f, toAmount, powerID, powerName, trains, effectID);
|
case STAMINA:
|
||||||
|
to.modifyStamina(toAmount, source);
|
||||||
|
mhmTo = new ModifyHealthMsg(source, to, 0f, 0f, toAmount, powerID, powerName, trains, effectID);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//subtract transfer amount
|
//subtract transfer amount
|
||||||
if (this.transferFromHealth) {
|
|
||||||
float modFrom = from.modifyHealth(-fromAmount, source, false);
|
switch (powerAction.statTransfer.fromStat) {
|
||||||
float cur = from.getHealth();
|
case HEALTH:
|
||||||
if (cur < 0 && modFrom != 0)
|
float modFrom = from.modifyHealth(-fromAmount, source, false);
|
||||||
mhmFrom = new ModifyHealthKillMsg(source, from, -fromAmount, 0f, 0f, powerID, powerName, trains, effectID);
|
float cur = from.getHealth();
|
||||||
else
|
if (cur < 0 && modFrom != 0)
|
||||||
mhmFrom = new ModifyHealthMsg(source, from, -fromAmount, 0f, 0f, powerID, powerName, trains, effectID);
|
mhmFrom = new ModifyHealthKillMsg(source, from, -fromAmount, 0f, 0f, powerID, powerName, trains, effectID);
|
||||||
} else if (this.transferFromMana) {
|
else
|
||||||
from.modifyMana(-fromAmount, source);
|
mhmFrom = new ModifyHealthMsg(source, from, -fromAmount, 0f, 0f, powerID, powerName, trains, effectID);
|
||||||
mhmFrom = new ModifyHealthMsg(source, from, 0f, -fromAmount, 0f, powerID, powerName, trains, effectID);
|
break;
|
||||||
} else {
|
case MANA:
|
||||||
from.modifyStamina(-fromAmount, source);
|
from.modifyMana(-fromAmount, source);
|
||||||
mhmFrom = new ModifyHealthMsg(source, from, 0f, 0f, -fromAmount, powerID, powerName, trains, effectID);
|
mhmFrom = new ModifyHealthMsg(source, from, 0f, -fromAmount, 0f, powerID, powerName, trains, effectID);
|
||||||
|
break;
|
||||||
|
case STAMINA:
|
||||||
|
from.modifyStamina(-fromAmount, source);
|
||||||
|
mhmFrom = new ModifyHealthMsg(source, from, 0f, 0f, -fromAmount, powerID, powerName, trains, effectID);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DispatchManager.sendToAllInRange(to, mhmTo);
|
DispatchManager.sendToAllInRange(to, mhmTo);
|
||||||
|
|||||||
Reference in New Issue
Block a user