2019-06-18 22:55:32 -04:00
|
|
|
|
/*
|
|
|
|
|
===========================================================================
|
|
|
|
|
Copyright (C) 2015-2019 Project Meteor Dev Team
|
|
|
|
|
|
|
|
|
|
This file is part of Project Meteor Server.
|
|
|
|
|
|
|
|
|
|
Project Meteor Server is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
Project Meteor Server is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
|
|
|
|
===========================================================================
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using System;
|
2019-06-19 01:10:15 -04:00
|
|
|
|
using Meteor.Map.Actors;
|
|
|
|
|
using Meteor.Map.packets.send.actor;
|
2017-08-02 23:06:11 +01:00
|
|
|
|
|
2019-06-19 01:10:15 -04:00
|
|
|
|
namespace Meteor.Map.actors.chara.ai.state
|
2017-08-02 23:06:11 +01:00
|
|
|
|
{
|
|
|
|
|
class DeathState : State
|
|
|
|
|
{
|
|
|
|
|
DateTime despawnTime;
|
|
|
|
|
public DeathState(Character owner, DateTime tick, uint timeToFadeOut)
|
|
|
|
|
: base(owner, null)
|
|
|
|
|
{
|
2017-08-31 05:56:43 +01:00
|
|
|
|
owner.Disengage();
|
2018-02-15 13:20:46 -06:00
|
|
|
|
owner.ChangeState(SetActorStatePacket.MAIN_STATE_DEAD);
|
2019-05-27 23:05:20 -07:00
|
|
|
|
owner.statusEffects.RemoveStatusEffectsByFlags((uint)StatusEffectFlags.LoseOnDeath);
|
2018-02-15 13:20:46 -06:00
|
|
|
|
//var deathStatePacket = SetActorStatePacket.BuildPacket(owner.actorId, SetActorStatePacket.MAIN_STATE_DEAD2, owner.currentSubState);
|
|
|
|
|
//owner.zone.BroadcastPacketAroundActor(owner, deathStatePacket);
|
2017-08-02 23:06:11 +01:00
|
|
|
|
canInterrupt = false;
|
|
|
|
|
startTime = tick;
|
|
|
|
|
despawnTime = startTime.AddSeconds(timeToFadeOut);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Update(DateTime tick)
|
|
|
|
|
{
|
2017-09-03 01:01:19 +01:00
|
|
|
|
// 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;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-02 23:06:11 +01:00
|
|
|
|
// todo: handle raise etc
|
|
|
|
|
if (tick >= despawnTime)
|
|
|
|
|
{
|
2017-09-03 01:01:19 +01:00
|
|
|
|
// todo: for players, return them to homepoint
|
|
|
|
|
owner.Despawn(tick);
|
2017-08-02 23:06:11 +01:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|