mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-05-20 08:26:59 -04:00
fixed death/despawning kinda (need to figure out why hp wont tick down after respawning)
This commit is contained in:
@@ -203,7 +203,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
public bool IsDead()
|
||||
{
|
||||
return owner.currentMainState == SetActorStatePacket.MAIN_STATE_DEAD ||
|
||||
owner.currentMainState == SetActorStatePacket.MAIN_STATE_DEAD2 || owner.GetHP() == 0;
|
||||
owner.currentMainState == SetActorStatePacket.MAIN_STATE_DEAD2;
|
||||
}
|
||||
|
||||
public bool IsRoaming()
|
||||
@@ -262,8 +262,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
|
||||
public void InternalChangeTarget(Character target)
|
||||
{
|
||||
// todo: use invalid target id
|
||||
// todo: this is retarded, call entity's changetarget function
|
||||
// targets are changed in the controller
|
||||
if (IsEngaged() || target == null)
|
||||
{
|
||||
|
||||
@@ -288,7 +287,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
|
||||
if (CanChangeState() || (GetCurrentState() != null && GetCurrentState().IsCompleted()))
|
||||
{
|
||||
ForceChangeState(new AttackState(this.owner, target));
|
||||
ForceChangeState(new AttackState(owner, target));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -301,7 +300,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
|
||||
owner.updateFlags |= ActorUpdateFlags.HpTpMp;
|
||||
ChangeTarget(null);
|
||||
owner.ChangeState(SetActorStatePacket.MAIN_STATE_PASSIVE);
|
||||
|
||||
if (owner.currentMainState == SetActorStatePacket.MAIN_STATE_ACTIVE)
|
||||
owner.ChangeState(SetActorStatePacket.MAIN_STATE_PASSIVE);
|
||||
|
||||
ClearStates();
|
||||
}
|
||||
|
||||
@@ -337,11 +339,18 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
}
|
||||
}
|
||||
|
||||
public void InternalDie(DateTime tick, uint timeToFadeout)
|
||||
public void InternalDie(DateTime tick, uint fadeoutTimerSeconds)
|
||||
{
|
||||
pathFind?.Clear();
|
||||
ClearStates();
|
||||
ForceChangeState(new DeathState(owner, tick, fadeoutTimerSeconds));
|
||||
}
|
||||
|
||||
public void InternalDespawn(DateTime tick, uint respawnTimerSeconds)
|
||||
{
|
||||
ClearStates();
|
||||
Disengage();
|
||||
ForceChangeState(new DeathState(owner, tick, timeToFadeout));
|
||||
ForceChangeState(new DespawnState(owner, respawnTimerSeconds));
|
||||
}
|
||||
|
||||
public void InternalRaise(Character target)
|
||||
|
@@ -384,12 +384,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
// todo: use tick instead of now?
|
||||
this.startTime = DateTime.Now;
|
||||
this.lastTick = startTime;
|
||||
|
||||
// todo: set the effect name to be called by scripts or just lookup effects in db
|
||||
// name = WorldManager.GetEffectInfo(id).Name;
|
||||
// todo: check if can gain effect
|
||||
// todo: call effect's onGain
|
||||
// todo: broadcast effect gain packet
|
||||
}
|
||||
|
||||
public StatusEffect(Character owner, StatusEffect effect)
|
||||
|
@@ -96,6 +96,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
{
|
||||
var target = owner.target;
|
||||
base.Disengage();
|
||||
owner.statusEffects.RemoveStatusEffectsByFlags((uint)StatusEffectFlags.LoseOnDeath, true);
|
||||
// todo:
|
||||
lastActionTime = lastUpdate.AddSeconds(5);
|
||||
owner.isMovingToSpawn = true;
|
||||
@@ -104,7 +105,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
neutralTime = lastActionTime;
|
||||
owner.hateContainer.ClearHate();
|
||||
owner.moveState = 1;
|
||||
lua.LuaEngine.CallLuaBattleAction(owner, "onDisengage", owner, target, Utils.UnixTimeStampUTC(battleStartTime));
|
||||
lua.LuaEngine.CallLuaBattleFunction(owner, "onDisengage", owner, target, Utils.UnixTimeStampUTC(battleStartTime));
|
||||
}
|
||||
|
||||
public override void Cast(Character target, uint spellId)
|
||||
@@ -203,7 +204,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
}
|
||||
|
||||
Move();
|
||||
lua.LuaEngine.CallLuaBattleAction(owner, "onCombatTick", owner, owner.target, Utils.UnixTimeStampUTC());
|
||||
lua.LuaEngine.CallLuaBattleFunction(owner, "onCombatTick", owner, owner.target, Utils.UnixTimeStampUTC(tick));
|
||||
}
|
||||
|
||||
private void Move()
|
||||
@@ -308,6 +309,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
|
||||
public bool CanDetectTarget(Character target, bool forceSight = false)
|
||||
{
|
||||
if (owner.IsDead())
|
||||
return false;
|
||||
|
||||
// todo: this should probably be changed to only allow detection at end of path?
|
||||
if (owner.aiContainer.pathFind.IsFollowingScriptedPath() || owner.aiContainer.pathFind.IsFollowingPath() && !owner.aiContainer.pathFind.AtPoint())
|
||||
{
|
||||
|
@@ -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))
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user