Beispiel #1
0
        public static void PlayerHurt(ref DamageEvent e)
        {
            HurtEvent he = new HurtEvent(ref e);

            if (!(he.Attacker is NPC) && !(he.Victim is NPC))
            {
                Magma.Player attacker = he.Attacker as Magma.Player;
                Magma.Player victim   = he.Victim as Magma.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;
        }
Beispiel #2
0
 public static void EntityHurt(object entity, ref DamageEvent e)
 {
     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;
         if (OnEntityHurt != null)
         {
             OnEntityHurt(he);
         }
         Zone3D zoned = Zone3D.GlobalContains(he.Entity);
         if (((zoned == null) || !zoned.Protected) && ((he.Entity.GetTakeDamage().health - he.DamageAmount) > 0f))
         {
             TakeDamage damage3 = he.Entity.GetTakeDamage();
             damage3.health -= he.DamageAmount;
         }
     }
     catch (Exception exception)
     {
         Helper.LogError(exception.ToString(), true);
     }
 }
        public static void PlayerHurt(ref DamageEvent e)
        {
            HurtEvent hurtEvent = new HurtEvent(ref e);

            if (!(hurtEvent.Attacker is NPC) && !(hurtEvent.Victim is NPC))
            {
                Player player  = hurtEvent.Attacker as Player;
                Player player2 = hurtEvent.Victim as Player;
                Zone3D zone3D  = Zone3D.GlobalContains(player);
                if (zone3D != null && !zone3D.PVP)
                {
                    player.Message("You are in a PVP restricted area.");
                    hurtEvent.DamageAmount = 0f;
                    e = hurtEvent.DamageEvent;
                    return;
                }
                zone3D = Zone3D.GlobalContains(player2);
                if (zone3D != null && !zone3D.PVP)
                {
                    player.Message(player2.Name + " is in a PVP restricted area.");
                    hurtEvent.DamageAmount = 0f;
                    e = hurtEvent.DamageEvent;
                    return;
                }
            }
            if (Hooks.OnPlayerHurt != null)
            {
                Hooks.OnPlayerHurt(hurtEvent);
            }
            e = hurtEvent.DamageEvent;
        }
 public static void EntityHurt(object entity, ref DamageEvent e)
 {
     try
     {
         HurtEvent hurtEvent = new HurtEvent(ref e, new Entity(entity));
         if (Hooks.decayList.Contains(entity))
         {
             hurtEvent.IsDecay = true;
         }
         if (hurtEvent.Entity.IsStructure() && !hurtEvent.IsDecay)
         {
             StructureComponent structureComponent = entity as StructureComponent;
             if (structureComponent.IsType(StructureComponent.StructureComponentType.Ceiling) || structureComponent.IsType(StructureComponent.StructureComponentType.Foundation) || structureComponent.IsType(StructureComponent.StructureComponentType.Pillar))
             {
                 hurtEvent.DamageAmount = 0f;
             }
         }
         TakeDamage takeDamage = hurtEvent.Entity.GetTakeDamage();
         takeDamage.health += hurtEvent.DamageAmount;
         if (Hooks.OnEntityHurt != null)
         {
             Hooks.OnEntityHurt(hurtEvent);
         }
         Zone3D zone3D = Zone3D.GlobalContains(hurtEvent.Entity);
         if ((zone3D == null || !zone3D.Protected) && hurtEvent.Entity.GetTakeDamage().health - hurtEvent.DamageAmount > 0f)
         {
             TakeDamage takeDamage2 = hurtEvent.Entity.GetTakeDamage();
             takeDamage2.health -= hurtEvent.DamageAmount;
         }
     }
     catch (Exception ex)
     {
         Helper.LogError(ex.ToString(), true);
     }
 }
        public static Zone3D GlobalContains(Player p)
        {
            Hashtable table = DataStore.GetInstance().GetTable("3DZonesList");

            if (table != null)
            {
                IEnumerator enumerator = table.Values.GetEnumerator();
                Zone3D      result;
                try
                {
                    while (enumerator.MoveNext())
                    {
                        object current = enumerator.Current;
                        Zone3D zone3D  = current as Zone3D;
                        if (zone3D.Contains(p))
                        {
                            result = zone3D;
                            return(result);
                        }
                    }
                    goto IL_61;
                }
                finally
                {
                    IDisposable disposable = enumerator as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
                return(result);
            }
IL_61:
            return(null);
        }
        public static Zone3D GlobalContains(Player p)
        {
            Hashtable table = DataStore.GetInstance().GetTable("3DZonesList");
            Zone3D    result;

            if (table != null)
            {
                foreach (object current in table.Values)
                {
                    Zone3D zone3D = current as Zone3D;
                    if (zone3D.Contains(p))
                    {
                        Zone3D zone3D2 = zone3D;
                        result = zone3D2;
                        return(result);
                    }
                }
            }
            result = null;
            return(result);
        }