Exemplo n.º 1
0
        public ActionChain GetCreateCorpseChain()
        {
            ActionChain createCorpseChain = new ActionChain(this, () =>
            {
                // Create Corspe and set a location on the ground
                // TODO: set text of killer in description and find a better computation for the location, some corpse could end up in the ground
                var corpse = CorpseObjectFactory.CreateCorpse(this, this.Location);
                // FIXME(ddevec): We don't have a real corpse yet, so these come in null -- this hack just stops them from crashing the game
                corpse.Location.PositionY -= (corpse.ObjScale ?? 0);
                corpse.Location.PositionZ -= (corpse.ObjScale ?? 0) / 2;

                // Corpses stay on the ground for 5 * player level but minimum 1 hour
                // corpse.DespawnTime = Math.Max((int)session.Player.PropertiesInt[Enum.Properties.PropertyInt.Level] * 5, 360) + WorldManager.PortalYearTicks; // as in live
                // corpse.DespawnTime = 20 + WorldManager.PortalYearTicks; // only for testing
                float despawnTime = GetCorpseSpawnTime();

                // Create corpse
                CurrentLandblock.AddWorldObject(corpse);
                // Create corpse decay
                ActionChain despawnChain = new ActionChain();
                despawnChain.AddDelaySeconds(despawnTime);
                despawnChain.AddAction(CurrentLandblock, () => corpse.CurrentLandblock.RemoveWorldObject(corpse.Guid, false));
                despawnChain.EnqueueChain();
            });

            return(createCorpseChain);
        }
Exemplo n.º 2
0
        public void Kill(Session session)
        {
            IsAlive = false;

            // Create and send the death notice
            string killMessage        = $"{session.Player.Name} has killed {Name}.";
            var    creatureDeathEvent = new GameEventDeathNotice(session, killMessage);

            session.Network.EnqueueSend(creatureDeathEvent);

            // MovementEvent: (Hand-)Combat or in the case of smite: from Standing to Death
            // TODO: Check if the duration of the motion can somehow be computed
            GeneralMotion    motionDeath = new GeneralMotion(MotionStance.Standing, new MotionItem(MotionCommand.Dead));
            QueuedGameAction actionDeath = new QueuedGameAction(this.Guid.Full, motionDeath, 2.0f, true, GameActionType.MovementEvent);

            session.Player.AddToActionQueue(actionDeath);

            // Create Corspe and set a location on the ground
            // TODO: set text of killer in description and find a better computation for the location, some corpse could end up in the ground
            var corpse = CorpseObjectFactory.CreateCorpse(this, this.Location);

            corpse.Location.PositionY -= corpse.PhysicsData.ObjScale;
            corpse.Location.PositionZ -= corpse.PhysicsData.ObjScale / 2;

            // Remove Creature from Landblock and add Corpse in that location via the ActionQueue to honor the motion delays
            QueuedGameAction removeCreature = new QueuedGameAction(this.Guid.Full, this, true, true, GameActionType.ObjectDelete);
            QueuedGameAction addCorpse      = new QueuedGameAction(this.Guid.Full, corpse, true, GameActionType.ObjectCreate);

            session.Player.AddToActionQueue(removeCreature);
            session.Player.AddToActionQueue(addCorpse);
        }
Exemplo n.º 3
0
        public virtual void OnKill(Session session)
        {
            IsAlive = false;
            // This will determine if the derived type is a player
            var isDerivedPlayer = Guid.IsPlayer();

            // TODO: Implement some proper respawn timers, check the generators for that
            RespawnTime = WorldManager.PortalYearTicks + 10;

            if (!isDerivedPlayer)
            {
                // Create and send the death notice
                string killMessage        = $"{session.Player.Name} has killed {Name}.";
                var    creatureDeathEvent = new GameEventDeathNotice(session, killMessage);
                session.Network.EnqueueSend(creatureDeathEvent);
            }

            // MovementEvent: (Hand-)Combat or in the case of smite: from Standing to Death
            // TODO: Check if the duration of the motion can somehow be computed
            UniversalMotion  motionDeath = new UniversalMotion(MotionStance.Standing, new MotionItem(MotionCommand.Dead));
            QueuedGameAction actionDeath = new QueuedGameAction(this.Guid.Full, motionDeath, 2.0f, true, GameActionType.MovementEvent);

            session.Player.AddToActionQueue(actionDeath);

            // Create Corspe and set a location on the ground
            // TODO: set text of killer in description and find a better computation for the location, some corpse could end up in the ground
            var corpse = CorpseObjectFactory.CreateCorpse(this, this.Location);

            corpse.Location.PositionY -= corpse.PhysicsData.ObjScale;
            corpse.Location.PositionZ -= corpse.PhysicsData.ObjScale / 2;

            // Corpses stay on the ground for 5 * player level but minimum 1 hour
            // corpse.DespawnTime = Math.Max((int)session.Player.PropertiesInt[Enum.Properties.PropertyInt.Level] * 5, 360) + WorldManager.PortalYearTicks; // as in live
            corpse.DespawnTime = 20 + WorldManager.PortalYearTicks; // only for testing

            // If the object is a creature, Remove it from from Landblock
            if (!isDerivedPlayer)
            {
                QueuedGameAction removeCreature = new QueuedGameAction(this.Guid.Full, this, true, true, GameActionType.ObjectDelete);
                session.Player.AddToActionQueue(removeCreature);
            }

            // Add Corpse in that location via the ActionQueue to honor the motion delays
            QueuedGameAction addCorpse = new QueuedGameAction(this.Guid.Full, corpse, true, GameActionType.ObjectCreate);

            session.Player.AddToActionQueue(addCorpse);
        }