Exemplo n.º 1
0
        /// <summary>
        /// Runs the script event with the given input.
        /// </summary>
        /// <param name="prio">The priority to run with.</param>
        /// <param name="oevt">The details of the script to be ran.</param>
        /// <returns>The event details after firing.</returns>
        public void Run(int prio, PlayerDeathEventArgs oevt)
        {
            PlayerDeathScriptEvent evt = (PlayerDeathScriptEvent)Duplicate();

            evt.Cancelled = oevt.Cancelled;
            evt.Player    = oevt.Player;
            evt.Amount    = oevt.Amount;
            evt.Cause     = oevt.Cause;
            evt.Killer    = oevt.Killer;
            evt.Call(prio);
            oevt.Amount    = evt.Amount;
            oevt.Cancelled = evt.Cancelled;
        }
 /// <summary>
 /// Runs the script event with the given input.
 /// </summary>
 /// <param name="prio">The priority to run with.</param>
 /// <param name="oevt">The details of the script to be ran.</param>
 /// <returns>The event details after firing.</returns>
 public void Run(int prio, PlayerDeathEventArgs oevt)
 {
     PlayerDeathScriptEvent evt = (PlayerDeathScriptEvent)Duplicate();
     evt.Cancelled = oevt.Cancelled;
     evt.Player = oevt.Player;
     evt.Amount = oevt.Amount;
     evt.Cause = oevt.Cause;
     evt.Killer = oevt.Killer;
     evt.Call(prio);
     oevt.Amount = evt.Amount;
     oevt.Cancelled = evt.Cancelled;
 }
 public static bool PlayerDamaged(Player player, ref uint amount, ref Vector3 ragdoll, ref EDeathCause deathCause, ref ELimb limb, CSteamID killer, object attacker, bool fromUFM)
 {
     TemplateObject attackerTag = null;
     if (killer != null && killer != CSteamID.Nil && killer != Provider.server)
     {
         SteamPlayer steamkiller = PlayerTool.getSteamPlayer(killer);
         if (steamkiller != null)
         {
             attackerTag = new PlayerTag(steamkiller);
         }
     }
     else if (attacker != null)
     {
         if (attacker is Animal)
         {
             attackerTag = new AnimalTag((Animal)attacker);
         }
         else if (attacker is Zombie)
         {
             attackerTag = new ZombieTag((Zombie)attacker);
         }
     }
     PlayerTag playerTag = new PlayerTag(player.channel.owner);
     UFMHealthController healthController = player.gameObject.GetComponent<UFMHealthController>();
     uint health = healthController != null ? healthController.health : player.life.health;
     if (amount >= health)
     {
         PlayerDeathEventArgs deathevt = new PlayerDeathEventArgs();
         deathevt.Player = playerTag;
         deathevt.Amount = new NumberTag(amount);
         deathevt.Cause = new TextTag(deathCause.ToString());
         deathevt.Limb = new TextTag(limb.ToString());
         deathevt.Killer = attackerTag;
         UnturnedFreneticEvents.OnPlayerDeath.Fire(deathevt);
         amount = (uint)deathevt.Amount.Internal;
         if (!deathevt.Cancelled && !EntityDeath(playerTag, ref amount) && healthController != null)
         {
             healthController.Damage(amount);
             player.life.ragdoll = ragdoll;
             amount = (uint)(((double)amount / healthController.maxHealth) * 100.0);
             return false;
         }
         return true;
     }
     PlayerDamagedEventArgs evt = new PlayerDamagedEventArgs();
     evt.Player = playerTag;
     evt.Amount = new NumberTag(amount);
     evt.Attacker = attackerTag;
     UnturnedFreneticEvents.OnPlayerDamaged.Fire(evt);
     amount = (uint)evt.Amount.Internal;
     if (!evt.Cancelled && !EntityDamaged(playerTag, ref amount) && healthController != null)
     {
         healthController.Damage(amount);
         player.life.ragdoll = ragdoll;
         amount = (uint)(((double)amount / healthController.maxHealth) * 100.0);
         return false;
     }
     return true;
 }