Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-12-2007, 05:09 AM
theHAWKER theHAWKER is offline
**FLIP OUT**
theHAWKER's Avatar
Join Date: Mar 2006
Location: canada, vancouver
Posts: 768
theHAWKER is an unknown quantity at this point
Question 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?
__________________
**FLIP OUT**
Reply With Quote
  #2  
Old 05-12-2007, 05:21 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
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.
Reply With Quote
  #3  
Old 05-12-2007, 05:46 AM
Deadly_Killer Deadly_Killer is offline
Registered User
Join Date: Feb 2002
Posts: 227
Deadly_Killer is on a distinguished road
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?
__________________
- Zidane / Zidaya
Reply With Quote
  #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.= (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.
__________________
What signature? I see no signature?

Last edited by godofwarares; 05-12-2007 at 02:10 PM..
Reply With Quote
  #5  
Old 05-12-2007, 02:04 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
You'd have to be standing on the NPC for that one to work. Might not work for something like a block.
Reply With Quote
  #6  
Old 05-12-2007, 02:11 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 Twinny View Post
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.
__________________
What signature? I see no signature?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:43 PM.


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