Handle dying in AddHP instead of OnDamageTaken.

This commit is contained in:
Yogurt 2019-05-27 17:08:06 -07:00
parent ee1f4b0888
commit 75c6708ac5
2 changed files with 9 additions and 7 deletions

View File

@ -638,8 +638,9 @@ namespace FFXIVClassic_Map_Server.Actors
charaWork.parameterSave.mp = (short)mp; charaWork.parameterSave.mp = (short)mp;
updateFlags |= ActorUpdateFlags.HpTpMp; updateFlags |= ActorUpdateFlags.HpTpMp;
} }
// todo: the following functions are virtuals since we want to check hidden item bonuses etc on player for certain conditions // todo: the following functions are virtuals since we want to check hidden item bonuses etc on player for certain conditions
public virtual void AddHP(int hp) public virtual void AddHP(int hp, CommandResultContainer resultContainer = null)
{ {
// dont wanna die ded, don't want to send update if hp isn't actually changed // dont wanna die ded, don't want to send update if hp isn't actually changed
if (IsAlive() && hp != 0) if (IsAlive() && hp != 0)
@ -651,6 +652,9 @@ namespace FFXIVClassic_Map_Server.Actors
charaWork.parameterSave.hp[0] = (short)addHp; charaWork.parameterSave.hp[0] = (short)addHp;
updateFlags |= ActorUpdateFlags.HpTpMp; updateFlags |= ActorUpdateFlags.HpTpMp;
if (charaWork.parameterSave.hp[0] < 1)
Die(Program.Tick, resultContainer);
} }
} }
@ -692,9 +696,9 @@ namespace FFXIVClassic_Map_Server.Actors
} }
} }
public void DelHP(int hp) public void DelHP(int hp, CommandResultContainer resultContainer = null)
{ {
AddHP((short)-hp); AddHP((short)-hp, resultContainer);
} }
public void DelMP(int mp) public void DelMP(int mp)
@ -883,10 +887,6 @@ namespace FFXIVClassic_Map_Server.Actors
//Don't know if store tp impacts this //Don't know if store tp impacts this
double tpModifier = 5 * Math.Pow(Math.E, (-0.0667 * GetLevel())); double tpModifier = 5 * Math.Pow(Math.E, (-0.0667 * GetLevel()));
AddTP((int)Math.Ceiling(tpModifier * action.amount)); AddTP((int)Math.Ceiling(tpModifier * action.amount));
if (charaWork.parameterSave.hp[0] < 1)
Die(Program.Tick, actionContainer);
} }
public UInt64 GetTempVar(string name) public UInt64 GetTempVar(string name)

View File

@ -287,6 +287,7 @@ namespace FFXIVClassic_Map_Server.Actors
// <actor> defeat/defeats <target> // <actor> defeat/defeats <target>
if (actionContainer != null) if (actionContainer != null)
actionContainer.AddEXPAction(new CommandResult(actorId, 30108, 0)); actionContainer.AddEXPAction(new CommandResult(actorId, 30108, 0));
if (lastAttacker.currentParty != null && lastAttacker.currentParty is Party) if (lastAttacker.currentParty != null && lastAttacker.currentParty is Party)
{ {
foreach (var memberId in ((Party)lastAttacker.currentParty).members) foreach (var memberId in ((Party)lastAttacker.currentParty).members)
@ -310,6 +311,7 @@ namespace FFXIVClassic_Map_Server.Actors
if (positionUpdates != null) if (positionUpdates != null)
positionUpdates.Clear(); positionUpdates.Clear();
aiContainer.InternalDie(tick, despawnTime); aiContainer.InternalDie(tick, despawnTime);
//this.ResetMoveSpeeds(); //this.ResetMoveSpeeds();
// todo: reset cooldowns // todo: reset cooldowns