Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   checking... (https://forums.graalonline.com/forums/showthread.php?t=73943)

theHAWKER 05-12-2007 05:09 AM

checking...
 
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?

DustyPorViva 05-12-2007 05:21 AM

Well, 'touching' the NPC is only sent while the player is moving and 'colliding' with the NPC. I suppose what you could do is something like...
PHP Code:

//#CLIENTSIDE
function onCreated() {
  
this.check=0;
}

function 
onPlayertouchsme() {
  if (
this.check==0setTimer(3);
  else {
    
// Do whatever you want if they're still touching it after 3 seconds.
  
}
}

function 
onTimeout() {
  if (
this.check==0) {
    
this.check=1
    
setTimer(.1);
  } else 
this.check=0;


But... they'd still have to be pressing against the NPC, not just standing there next to or in it.
As for the if they're still firing, again, you should use timeouts and variables.

Deadly_Killer 05-12-2007 05:46 AM

PHP Code:

function onPlayerTouchsMe()
{
  
this.scheduleEvent(3"check", {player.accountplayer.xplayer.y});
}

function 
onCheck(papxpy)
{
  
temp.pl findPlayer(pa);

  if (
temp.pl.== px && temp.pl.== py)
  {
    
// you stood still
  
}


^-- that what you want?

godofwarares 05-12-2007 01:57 PM

Quote:

Originally Posted by theHAWKER (Post 1307201)
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.= (NPC Width In Tiles);
this.= (NPC Height in Tiles);
}

if (
playertouchsme)
{
     
timeout 3;
}

if (
timeout)
{
     
plX int(playerx 1.5 vecx(playerdir));
     
plY int(playery vecy(playerdir));
     
     if (
plY in |xx+this.w| && plX in |yy+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.

Twinny 05-12-2007 02:04 PM

You'd have to be standing on the NPC for that one to work. Might not work for something like a block.

godofwarares 05-12-2007 02:11 PM

Quote:

Originally Posted by Twinny (Post 1307245)
You'd have to be standing on the NPC for that one to work. Might not work for something like a block.

Should work now, Its detecting if the tile in front of the player is in the NPC. Should work even if its a block.


All times are GMT +2. The time now is 07:53 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.