Quote:
Originally Posted by theHAWKER
i was wondering if there was a way to check if the player is still touching the npc after 3 seconds for example.
or like if the player is still firing his weapon.
but i dont want the npc to react untill it checks again.
is this posible?
|
Of course it is.
PHP Code:
if (created)
{
this.w = (NPC Width In Tiles);
this.h = (NPC Height in Tiles);
}
if (playertouchsme)
{
timeout = 3;
}
if (timeout)
{
plX = int(playerx + 1.5 + vecx(playerdir));
plY = int(playery + 2 + vecy(playerdir));
if (plY in |x, x+this.w| && plX in |y, y+this.h|)
{
// Code here. Player is touching the NPC
}
}
Of course, You'll need to measure the NPC's width and height (in tiles, pixel/16). This will probably suit your needs better.