Exemplo n.º 1
0
 public static void PlayerHurt(ref DamageEvent e)
 {
     try
     {
         HurtEvent he = new HurtEvent(ref e);
         if (!(he.Attacker is NPC) && !(he.Victim is NPC))
         {
             Fougerite.Player attacker = he.Attacker as Fougerite.Player;
             Fougerite.Player victim   = he.Victim as Fougerite.Player;
             Zone3D           zoned    = Zone3D.GlobalContains(attacker);
             if ((zoned != null) && !zoned.PVP)
             {
                 attacker.Message("You are in a PVP restricted area.");
                 he.DamageAmount = 0f;
                 e = he.DamageEvent;
                 return;
             }
             zoned = Zone3D.GlobalContains(victim);
             if ((zoned != null) && !zoned.PVP)
             {
                 attacker.Message(victim.Name + " is in a PVP restricted area.");
                 he.DamageAmount = 0f;
                 e = he.DamageEvent;
                 return;
             }
         }
         if (OnPlayerHurt != null)
         {
             OnPlayerHurt(he);
         }
         e = he.DamageEvent;
     }
     catch { }
 }
Exemplo n.º 2
0
        public static void EntityHurt(object entity, ref DamageEvent e)
        {
            Contract.Assume(entity != null);

            try
            {
                HurtEvent he = new HurtEvent(ref e, new Entity(entity));
                if (decayList.Contains(entity))
                {
                    he.IsDecay = true;
                }

                if (he.Entity.IsStructure() && !he.IsDecay)
                {
                    StructureComponent component = entity as StructureComponent;
                    if ((component.IsType(StructureComponent.StructureComponentType.Ceiling) || component.IsType(StructureComponent.StructureComponentType.Foundation)) || component.IsType(StructureComponent.StructureComponentType.Pillar))
                    {
                        he.DamageAmount = 0f;
                    }
                }
                TakeDamage takeDamage = he.Entity.GetTakeDamage();
                takeDamage.health += he.DamageAmount;

                // when entity is destroyed
                if (e.status != LifeStatus.IsAlive)
                {
                    DestroyEvent de = new DestroyEvent(ref e, new Entity(entity), he.IsDecay);
                    if (OnEntityDestroyed != null)
                    {
                        OnEntityDestroyed(de);
                    }
                }
                else if (OnEntityHurt != null)
                {
                    OnEntityHurt(he);
                }

                Zone3D zoned = Zone3D.GlobalContains(he.Entity);
                if ((zoned == null) || !zoned.Protected)
                {
                    if ((he.Entity.GetTakeDamage().health - he.DamageAmount) <= 0f)
                    {
                        he.Entity.Destroy();
                    }
                    else
                    {
                        TakeDamage damage2 = he.Entity.GetTakeDamage();
                        damage2.health -= he.DamageAmount;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }
Exemplo n.º 3
0
        public static Zone3D GlobalContains(Fougerite.Player p)
        {
            Contract.Requires(p != null);

            Hashtable table = DataStore.GetInstance().GetTable("3DZonesList");

            if (table != null)
            {
                foreach (object obj2 in table.Values)
                {
                    Zone3D zoned = obj2 as Zone3D;
                    if (zoned.Contains(p))
                    {
                        return(zoned);
                    }
                }
            }
            return(null);
        }