fixed death/despawning kinda (need to figure out why hp wont tick down after respawning)

This commit is contained in:
Tahir Akhlaq
2017-09-03 01:01:19 +01:00
parent c5cc7c2f00
commit 4978813c27
16 changed files with 251 additions and 106 deletions

View File

@@ -33,15 +33,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
public override bool Update(DateTime tick)
{
/*
TryInterrupt();
if (interrupt)
{
OnInterrupt();
return true;
}
*/
if ((target == null || owner.target != target || owner.target?.actorId != owner.currentLockedTarget) && owner.isAutoAttackEnabled)
owner.aiContainer.ChangeTarget(target = owner.zone.FindActorInArea<Character>(owner.currentLockedTarget));
@@ -159,7 +150,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
// todo: shouldnt need to check if owner is dead since all states would be cleared
if (owner.aiContainer.IsDead() || target.aiContainer.IsDead())
{
target = null;
owner.aiContainer.ChangeTarget(null);
return false;
}
else if (!owner.aiContainer.GetTargetFind().CanTarget(target, false, true))

View File

@@ -14,8 +14,8 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
public DeathState(Character owner, DateTime tick, uint timeToFadeOut)
: base(owner, null)
{
owner.ChangeState(SetActorStatePacket.MAIN_STATE_DEAD);
owner.Disengage();
owner.ChangeState(SetActorStatePacket.MAIN_STATE_DEAD);
canInterrupt = false;
startTime = tick;
despawnTime = startTime.AddSeconds(timeToFadeOut);
@@ -23,17 +23,18 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
public override bool Update(DateTime tick)
{
// todo: set a flag on chara for accept raise, play animation and spawn
if (owner.GetMod((uint)Modifier.Raise) > 0)
{
owner.Spawn(tick);
return true;
}
// todo: handle raise etc
if (tick >= despawnTime)
{
if (owner is BattleNpc)
{
owner.Despawn(tick);
}
else
{
// todo: queue a warp for the player
}
// todo: for players, return them to homepoint
owner.Despawn(tick);
return true;
}
return false;

View File

@@ -10,22 +10,21 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
{
class DespawnState : State
{
private DateTime endTime;
public DespawnState(Character owner, Character target, uint despawnTimeSeconds) :
private DateTime respawnTime;
public DespawnState(Character owner, uint respawnTimeSeconds) :
base(owner, null)
{
startTime = Program.Tick;
endTime = startTime.AddSeconds(despawnTimeSeconds);
respawnTime = startTime.AddSeconds(respawnTimeSeconds);
owner.ChangeState(SetActorStatePacket.MAIN_STATE_DEAD2);
owner.OnDespawn();
}
public override bool Update(DateTime tick)
{
if (tick >= endTime)
if (tick >= respawnTime)
{
// todo: send packet to despawn the npc, set it so npc is despawned when requesting spawn packets
owner.zone.BroadcastPacketAroundActor(owner, RemoveActorPacket.BuildPacket(owner.actorId));
owner.QueuePositionUpdate(owner.spawnX, owner.spawnY, owner.spawnZ);
lua.LuaEngine.CallLuaBattleAction(owner, "onDespawn", owner);
owner.Spawn(tick);
return true;
}
return false;