sahisahi
Member
Cant get this to work i wanted to add a check for a item in player backpack so trap dont shot that player, no sucess so far, traps are supposed to attack any player/ controlled creature near them
Current issue;
Player without carrying the item DOESNT get attacked by the trap, if he go offscreen and come back he gets attacked 1 time by the trap. (The trap should attack as soon as someone is near the trap and keep attacking him non stop)
Refres method i added this:
movement method i added this
Sorry for the mess and thanks as always.
Current issue;
Player without carrying the item DOESNT get attacked by the trap, if he go offscreen and come back he gets attacked 1 time by the trap. (The trap should attack as soon as someone is near the trap and keep attacking him non stop)
Code:
public virtual void Refresh()
{
bool foundPlayer = false;
ArrayList list = new ArrayList();
foreach ( Mobile mob in GetMobilesInRange( TrapRange ) )
{
if ( !mob.Alive || mob.AccessLevel > AccessLevel.Player || (mob.Hidden && NoDamageHidden) )
continue;
if ( ( (this.Z + 8) >= mob.Z && (mob.Z + 16) > this.Z ) )
{
if (mob is BaseCreature && (((BaseCreature)mob).Controlled || ((BaseCreature)mob).Summoned ))
list.Add(mob);
#region trap dont attack is player carry X item
PlayerMobile mobile = (PlayerMobile)mob;
Container pack = mob.Backpack;
Item tnd = mob.Backpack.FindItemByType(typeof(trapnodamage));
if (mob.Player && mob != null && tnd != null)
{
foundPlayer = false;
}
#endregion
else if (mob.Player)
list.Add(mob);
foundPlayer = true;
foreach (Mobile mm in list)
{
Effects.SendMovingEffect( this, mm, SpellEffect, 5, 0, false, true );
Effects.PlaySound( Location, Map, Sound );
Spells.SpellHelper.Damage( TimeSpan.FromSeconds( 0.5 ), mm, mm, Utility.RandomMinMax( MinDamage, MaxDamage ), 100, 0, 0, 0, 0 );
}
}
}
}
public override void OnMovement( Mobile m, Point3D oldLocation )
{
base.OnMovement( m, oldLocation );
if ( m.Location == oldLocation || !m.Player || !m.Alive || m.AccessLevel > AccessLevel.Player || m.Hidden )
return;
#region traps dont attack is player carry X items
PlayerMobile mobile = (PlayerMobile)m;
Container pack = m.Backpack;
Item aam = m.Backpack.FindItemByType(typeof(trapnodamage));
if (aam != null)
return;
#endregion
if ( CheckRange( m.Location, oldLocation, TrapRange ) )
{
CheckTimer();
Effects.SendMovingEffect( this, m, SpellEffect, 5, 0, false, true );
Spells.SpellHelper.Damage( TimeSpan.FromSeconds( 0.5 ), m, m, Utility.RandomMinMax( MinDamage, MaxDamage ), 100, 0, 0, 0, 0 );
Effects.PlaySound( Location, Map, Sound );
}
}
Refres method i added this:
Code:
#region trap dont attack is player carry X item
if (mob.Player)
{
PlayerMobile mobile = (PlayerMobile)mob;
Container pack = mob.Backpack;
Item tnd = mob.Backpack.FindItemByType(typeof(trapnodamage));
if (mob.Player && mob != null && tnd != null)
{
foundPlayer = false;
}
}
#endregion
movement method i added this
Code:
#region traps dont attack is player carry X items
PlayerMobile mobile = (PlayerMobile)m;
Container pack = m.Backpack;
Item aam = m.Backpack.FindItemByType(typeof(Keyyew));
if (aam != null)
return;
#endregion
Sorry for the mess and thanks as always.