Added party to Gridania opening, fixed BattleActionx18 and made it so x18 is used for packets with more than 10 targets. Changed how death works. Added respawn time and roam modifiers. Added TryAggro functions and moved aggroing out of roaming and helpplayers. Fixed high cpu usage in zone's OnUpdate function. Fixed work value in player update

This commit is contained in:
yogurt
2017-12-08 00:58:39 -06:00
parent 520ae7a119
commit 1275c8b5da
61 changed files with 1226 additions and 223 deletions

View File

@@ -230,10 +230,10 @@ namespace FFXIVClassic_Map_Server.Actors
public void DoBattleAction(ushort commandId, uint animationId, BattleAction[] actions)
{
int currentIndex = 0;
//AoE abilities only ever hit 16 people, so we probably won't need this loop anymore
while (true)
{
if (actions.Length - currentIndex >= 18)
if (actions.Length - currentIndex >= 10)
zone.BroadcastPacketAroundActor(this, BattleActionX18Packet.BuildPacket(actorId, animationId, commandId, actions, ref currentIndex));
else if (actions.Length - currentIndex > 1)
zone.BroadcastPacketAroundActor(this, BattleActionX10Packet.BuildPacket(actorId, animationId, commandId, actions, ref currentIndex));
@@ -244,7 +244,9 @@ namespace FFXIVClassic_Map_Server.Actors
}
else
break;
animationId = 0; //If more than one packet is sent out, only send the animation once to avoid double playing.
//I think aoe effects play on all hit enemies. Firaga does at least
//animationId = 0; //If more than one packet is sent out, only send the animation once to avoid double playing.
}
}
@@ -313,7 +315,7 @@ namespace FFXIVClassic_Map_Server.Actors
public virtual void OnPath(Vector3 point)
{
lua.LuaEngine.CallLuaBattleFunction(this, "onPath", this, point);
//lua.LuaEngine.CallLuaBattleFunction(this, "onPath", this, point);
updateFlags |= ActorUpdateFlags.Position;
this.isAtSpawn = false;
@@ -347,7 +349,7 @@ namespace FFXIVClassic_Map_Server.Actors
if ((updateFlags & ActorUpdateFlags.HpTpMp) != 0)
{
var propPacketUtil = new ActorPropertyPacketUtil("charaWork.parameterSave", this);
var propPacketUtil = new ActorPropertyPacketUtil("charaWork/stateAtQuicklyForAll", this);
propPacketUtil.AddProperty("charaWork.parameterSave.mp");
propPacketUtil.AddProperty("charaWork.parameterSave.mpMax");
@@ -470,6 +472,7 @@ namespace FFXIVClassic_Map_Server.Actors
{
// todo: actual despawn timer
aiContainer.InternalDie(tick, 10);
ChangeSpeed(0.0f, 0.0f, 0.0f, 0.0f);
}
public virtual void Despawn(DateTime tick)
@@ -543,6 +546,20 @@ namespace FFXIVClassic_Map_Server.Actors
updateFlags |= ActorUpdateFlags.HpTpMp;
}
public void SetMP(uint mp)
{
charaWork.parameterSave.mpMax = (short)mp;
if (mp > charaWork.parameterSave.hpMax[0])
SetMaxMP(mp);
updateFlags |= ActorUpdateFlags.HpTpMp;
}
public void SetMaxMP(uint mp)
{
charaWork.parameterSave.mp = (short)mp;
updateFlags |= ActorUpdateFlags.HpTpMp;
}
// 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)
{
@@ -562,7 +579,7 @@ namespace FFXIVClassic_Map_Server.Actors
}
}
public short GetJob()
public short GetClass()
{
return charaWork.parameterSave.state_mainSkill[0];
}
@@ -614,8 +631,30 @@ namespace FFXIVClassic_Map_Server.Actors
public void RecalculateStats()
{
if (GetMod((uint)Modifier.Hp) != 0)
uint hpMod = (uint) GetMod((uint)Modifier.Hp);
if (hpMod != 0)
{
SetMaxHP(hpMod);
uint hpp = (uint) GetMod((uint) Modifier.HpPercent);
uint hp = hpMod;
if(hpp != 0)
{
hp = (uint) Math.Ceiling(((float)hpp / 100.0f) * hpMod);
}
SetHP(hp);
}
uint mpMod = (uint)GetMod((uint)Modifier.Mp);
if (mpMod != 0)
{
SetMaxMP(mpMod);
uint mpp = (uint)GetMod((uint)Modifier.MpPercent);
uint mp = mpMod;
if (mpp != 0)
{
mp = (uint)Math.Ceiling(((float)mpp / 100.0f) * mpMod);
}
SetMP(mp);
}
// todo: recalculate stats and crap
updateFlags |= ActorUpdateFlags.HpTpMp;
@@ -650,9 +689,10 @@ namespace FFXIVClassic_Map_Server.Actors
//var packet = BattleActionX01Packet.BuildPacket(owner.actorId, owner.actorId, target.actorId, (uint)0x19001000, (uint)0x8000604, (ushort)0x765D, (ushort)BattleActionX01PacketCommand.Attack, (ushort)damage, (byte)0x1);
}
target.OnDamageTaken(this, action, DamageTakenType.Ability);
// todo: call onAttack/onDamageTaken
target.DelHP(action.amount);
BattleUtils.DamageTarget(this, target, action);
target.OnDamageTaken(this, action, DamageTakenType.Ability);
if (target is BattleNpc)
((BattleNpc)target).lastAttacker = this;
@@ -664,13 +704,26 @@ namespace FFXIVClassic_Map_Server.Actors
{
var spell = ((MagicState)state).GetSpell();
// damage is handled in script
this.DelMP(spell.mpCost); // mpCost can be set in script e.g. if caster has something for free spells
var spellCost = spell.CalculateCost((uint)this.GetLevel());
this.DelMP(spellCost); // mpCost can be set in script e.g. if caster has something for free spells
foreach (var action in actions)
zone.FindActorInArea<Character>(action.targetId).OnDamageTaken(this, action, DamageTakenType.Magic);
foreach (BattleAction action in actions)
{
if (zone.FindActorInArea<Character>(action.targetId) is Character chara)
{
if (chara != null && chara is BattleNpc)
{
((BattleNpc)chara).hateContainer.UpdateHate(this, action.amount);
((BattleNpc)chara).lastAttacker = this;
}
BattleUtils.DamageTarget(this, chara, action);
}
}
if (target is BattleNpc)
((BattleNpc)target).lastAttacker = this;
lua.LuaEngine.GetInstance().OnSignal("spellUsed");
}
public virtual void OnWeaponSkill(State state, BattleAction[] actions, ref BattleAction[] errors)
@@ -679,11 +732,25 @@ namespace FFXIVClassic_Map_Server.Actors
// damage is handled in script
this.DelTP(skill.tpCost);
foreach (var action in actions)
zone.FindActorInArea<BattleNpc>(action.targetId)?.OnDamageTaken(this, action, DamageTakenType.Weaponskill);
foreach (BattleAction action in actions)
{
if (zone.FindActorInArea<Character>(action.targetId) is Character chara)
{
if (chara != null && chara is BattleNpc)
{
((BattleNpc)chara).hateContainer.UpdateHate(this, action.amount);
((BattleNpc)chara).lastAttacker = this;
}
BattleUtils.DamageTarget(this, chara, action);
}
}
if (target is BattleNpc)
((BattleNpc)target).lastAttacker = this;
lua.LuaEngine.GetInstance().OnSignal("weaponskillUsed");
}
public virtual void OnAbility(State state, BattleAction[] actions, ref BattleAction[] errors)
@@ -769,22 +836,22 @@ namespace FFXIVClassic_Map_Server.Actors
public bool IsDiscipleOfWar()
{
return currentJob < CLASSID_THM;
return GetClass() < CLASSID_THM;
}
public bool IsDiscipleOfMagic()
{
return currentJob >= CLASSID_THM && currentJob < CLASSID_CRP;
return GetClass() >= CLASSID_THM && currentJob < CLASSID_CRP;
}
public bool IsDiscipleOfHand()
{
return currentJob >= CLASSID_CRP && currentJob < CLASSID_MIN;
return GetClass() >= CLASSID_CRP && currentJob < CLASSID_MIN;
}
public bool IsDiscipleOfLand()
{
return currentJob >= CLASSID_MIN;
return GetClass() >= CLASSID_MIN;
}
#endregion lua helpers
#endregion ai stuff