I would probably do something like
PHP Code:
function onCreated()
{
onTimeOut();
}
function onPlayerEnters()
{
onCreated();
}
function onTimeOut()
{
if ( players.size() <= 0 )
{
return;
}
temp.pl = findNearestPlayer( this.x, this.y );
if ( pl.x in | this.x - 2, this.x + 3 | && pl.y in | this.y - 2, this.y + 2 )
{
pl.attack();
}
setTimer( .3 );
}
You could also have a system weapon like this:
PHP Code:
//#CLIENTSIDE
function onCreated()
{
setTimer( 0.05 );
}
function onTimeOut()
{
temp.ns = findareanpcs( player.x - 1, player.y + 1, 2, 2 );
for ( temp.npc : ns )
{
if ( npc.isSpike )
{
player.attack();
}
}
setTimer( 0.05 );
}
and in the spike
PHP Code:
function onCreated()
{
this.isSpike = true;
}
function onPlayerEnters()
{
player.addWeapon( "-SpikeDetector" );
onCreated();
}