Thread: checking...
View Single Post
  #4  
Old 05-12-2007, 01:57 PM
godofwarares godofwarares is offline
Webmaster
godofwarares's Avatar
Join Date: Dec 2006
Location: Florida
Posts: 552
godofwarares is on a distinguished road
Send a message via ICQ to godofwarares Send a message via AIM to godofwarares Send a message via MSN to godofwarares Send a message via Yahoo to godofwarares
Quote:
Originally Posted by theHAWKER View Post
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.
__________________
What signature? I see no signature?

Last edited by godofwarares; 05-12-2007 at 02:10 PM..
Reply With Quote