示例#1
0
        // BaseAnimal.OnAttacked()
        public static void NPCHurt(BaseAnimal animal, HitInfo info)
        {
            // works
            var npc = new NPC(animal);

            if (info.Initiator != null)
            {
                Player      p     = new Player(info.Initiator as BasePlayer);
                PlayerStats stats = new PlayerStats(p.SteamID);
                stats.AddDamageTo(info.damageAmount, false, true, false);
                p.Stats = stats;
            }

            if (!Realm.Server() || (double)animal.myHealth <= 0.0)
            {
                return;
            }

            if ((animal.myHealth - info.damageAmount) > 0.0f)
            {
                OnNPCHurt.OnNext(new Events.NPCHurtEvent(npc, info));
            }

            animal.myHealth -= info.damageAmount;
            if ((double)animal.myHealth > 0.0)
            {
                return;
            }
            animal.Die(info);
        }
示例#2
0
文件: NPC.cs 项目: yohanniii/Pluton
        public void Kill()
        {
            var info = new HitInfo();

            info.damageType = Rust.DamageType.Suicide;
            info.Initiator  = baseAnimal as BaseEntity;
            baseAnimal.Die(info);
        }