mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-05-20 08:26:59 -04:00
Pass BattleCommand to combat functions to prepare for passing
BattleCommand to scripts. Add CommandResultContainer to status update to handle death from dots.
This commit is contained in:
@@ -35,15 +35,16 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
|
||||
public void Update(DateTime tick)
|
||||
{
|
||||
CommandResultContainer resultContainer = new CommandResultContainer();
|
||||
|
||||
//Regen/Refresh/Regain effects tick every 3 seconds
|
||||
if ((DateTime.Now - lastTick).Seconds >= 3)
|
||||
{
|
||||
RegenTick(tick);
|
||||
RegenTick(tick, resultContainer);
|
||||
lastTick = DateTime.Now;
|
||||
}
|
||||
// list of effects to remove
|
||||
|
||||
// if (owner is Player) UpdateTimeAtIndex(4, 4294967295);
|
||||
// list of effects to remove
|
||||
var removeEffects = new List<StatusEffect>();
|
||||
for (int i = 0; i < effects.Values.Count; i++)
|
||||
{
|
||||
@@ -59,15 +60,16 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
RemoveStatusEffect(effect);
|
||||
}
|
||||
|
||||
if (sendUpdate)
|
||||
resultContainer.CombineLists();
|
||||
|
||||
if (resultContainer.GetList().Count > 0)
|
||||
{
|
||||
owner.zone.BroadcastPacketsAroundActor(owner, owner.GetActorStatusPackets());
|
||||
sendUpdate = false;
|
||||
owner.DoBattleAction(0, 0x7c000062, resultContainer.GetList());
|
||||
}
|
||||
}
|
||||
|
||||
//regen/refresh/regain
|
||||
public void RegenTick(DateTime tick)
|
||||
public void RegenTick(DateTime tick, CommandResultContainer resultContainer)
|
||||
{
|
||||
ushort dotTick = (ushort) owner.GetMod(Modifier.RegenDown);
|
||||
ushort regenTick = (ushort) owner.GetMod(Modifier.Regen);
|
||||
@@ -77,18 +79,24 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
//DoTs tick before regen and the full dot damage is displayed, even if some or all of it is nullified by regen. Only effects like stoneskin actually alter the number shown
|
||||
if (dotTick > 0)
|
||||
{
|
||||
CommandResult action = new CommandResult(owner.actorId, 30331, (uint)(HitEffect.HitEffectType | HitEffect.Hit), dotTick);
|
||||
//Unsure why 10105 is the textId used
|
||||
//Also unsure why magicshield is used
|
||||
CommandResult action = new CommandResult(owner.actorId, 10105, (uint)(HitEffect.MagicEffectType | HitEffect.MagicShield | HitEffect.NoResist), dotTick);
|
||||
utils.BattleUtils.HandleStoneskin(owner, action);
|
||||
// todo: figure out how to make red numbers appear for enemies getting hurt by dots
|
||||
//owner.DelHP(action.amount);
|
||||
utils.BattleUtils.DamageTarget(owner, owner, action, null);
|
||||
owner.DoBattleAction(0, 0, action);
|
||||
resultContainer.AddAction(action);
|
||||
owner.DelHP(action.amount, resultContainer);
|
||||
}
|
||||
|
||||
//DoTs are the only effect to show numbers, so that doesnt need to be handled for these
|
||||
owner.AddHP(regenTick);
|
||||
owner.AddMP(refreshtick);
|
||||
owner.AddTP(regainTick);
|
||||
if (regenTick != 0)
|
||||
owner.AddHP(regenTick);
|
||||
|
||||
if (refreshtick != 0)
|
||||
owner.AddMP(refreshtick);
|
||||
|
||||
if (regainTick != 0)
|
||||
owner.AddTP(regainTick);
|
||||
}
|
||||
|
||||
public bool HasStatusEffect(uint id)
|
||||
|
@@ -241,7 +241,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.utils
|
||||
defender.SubtractMod((uint)Modifier.Stoneskin, mitigation);
|
||||
}
|
||||
|
||||
public static void DamageTarget(Character attacker, Character defender, CommandResult action, CommandResultContainer actionContainer= null)
|
||||
public static void DamageTarget(Character attacker, Character defender, BattleCommand skill, CommandResult action, CommandResultContainer actionContainer= null)
|
||||
{
|
||||
if (defender != null)
|
||||
{
|
||||
@@ -254,9 +254,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.utils
|
||||
bnpc.lastAttacker = attacker;
|
||||
}
|
||||
|
||||
defender.DelHP((short)action.amount);
|
||||
attacker.OnDamageDealt(defender, action, actionContainer);
|
||||
defender.OnDamageTaken(attacker, action, actionContainer);
|
||||
defender.DelHP((short)action.amount, actionContainer);
|
||||
attacker.OnDamageDealt(defender, skill, action, actionContainer);
|
||||
defender.OnDamageTaken(attacker, skill, action, actionContainer);
|
||||
|
||||
// todo: other stuff too
|
||||
if (defender is BattleNpc)
|
||||
@@ -272,11 +272,11 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.utils
|
||||
}
|
||||
}
|
||||
|
||||
public static void HealTarget(Character caster, Character target, CommandResult action, CommandResultContainer actionContainer = null)
|
||||
public static void HealTarget(Character caster, Character target, BattleCommand skill, CommandResult action, CommandResultContainer actionContainer = null)
|
||||
{
|
||||
if (target != null)
|
||||
{
|
||||
target.AddHP(action.amount);
|
||||
target.AddHP(action.amount, actionContainer);
|
||||
|
||||
target.statusEffects.CallLuaFunctionByFlag((uint) StatusEffectFlags.ActivateOnHealed, "onHealed", caster, target, action, actionContainer);
|
||||
}
|
||||
@@ -512,8 +512,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.utils
|
||||
|
||||
actionContainer.AddAction(action);
|
||||
action.enmity = (ushort) (action.enmity * (skill != null ? skill.enmityModifier : 1));
|
||||
|
||||
//Damage the target
|
||||
DamageTarget(attacker, defender, action, actionContainer);
|
||||
DamageTarget(attacker, defender, skill, action, actionContainer);
|
||||
}
|
||||
|
||||
public static void FinishActionSpell(Character attacker, Character defender, BattleCommand skill, CommandResult action, CommandResultContainer actionContainer = null)
|
||||
@@ -542,7 +543,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.utils
|
||||
|
||||
actionContainer.AddAction(action);
|
||||
|
||||
DamageTarget(attacker, defender, action, actionContainer);
|
||||
DamageTarget(attacker, defender, skill, action, actionContainer);
|
||||
}
|
||||
|
||||
public static void FinishActionHeal(Character attacker, Character defender, BattleCommand skill, CommandResult action, CommandResultContainer actionContainer = null)
|
||||
@@ -552,7 +553,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.utils
|
||||
|
||||
actionContainer.AddAction(action);
|
||||
|
||||
HealTarget(attacker, defender, action, actionContainer);
|
||||
HealTarget(attacker, defender, skill, action, actionContainer);
|
||||
}
|
||||
|
||||
public static void FinishActionStatus(Character attacker, Character defender, BattleCommand skill, CommandResult action, CommandResultContainer actionContainer = null)
|
||||
|
Reference in New Issue
Block a user