Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-17-2012, 03:13 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Won't detect players touching NPC

I'm trying to script some sort of an event, and I'm having a little trouble. Basically, the point is not to get hit by the blocks randomly warping around the room. I've got that sorted. Now, I can't seem to get the NPC to detect if it's hit a player! Can somebody tell me what I'm doing wrong?

PHP Code:
function onCreated() {
  
setTimer(0.05);
  
setshape(1,32,32);
}

function 
onTimeout() {
  
  if (
this.on == 1) {
    
this.timer -= 1// Start the count down
    
this.random(3.5,57.5);
    
this.random(18,46);
   
    if (
player.x in this.xthis.this.width | && player.y in this.ythis.this.height|) {
      
player.chat "I've been hit!";
    }
  }
  
  if (
this.timer == 0) {
    
this.on 0// Stop warping
  
}
  
setTimer(0.05);

Edit
I think I've found my issue. It can't detect the players x and y co-ords server side? It worked when I created a new NPC and made it clientside. If I do this to my NPC, players won't be able to see the same X and Y of the block that other players see, and that's what I'm trying to do. Anybody got any ideas?

Just wondering if I could use a triggeraction to get around this. Would it be possible to send a triggeraction from the serverside to the clientside?

Edit
I've managed to put the movement and whatever clientside, and trigger the movement via the serverside using triggeraction. Now, I need help again trying to make the NPC detect if a player is in it's x and y.

PHP Code:
/*
Timer is the amount of time it takes
to warp around the room. The higher the
timer, the longer the warp session is.
*/
function onPlayerChats() {
  if (
player.guild != "Events Team") {
    return;
  }
  if (
player.chat == ":warp") {
    
triggeraction(31,33,"start",NULL);
  }
}

function 
onActionhit() {
  
player.chat "HAS BEEN HIT!";
}

//#CLIENTSIDE

const TIMER 25;

function 
onCreated() {
  
setTimer(0.05);
  
setshape(1,32,32);
  
this.height this.width 32;
}

function 
onTimeout() {
  
this.chat "Status:" SPC this.on;
  if (
this.on == 1) {
    
this.timer -= 1;
    
this.random(3.5,57.5);
    
this.random(18,46);
    if (
player.x in this.xthis.this.width | && player.y in this.ythis.this.height|) {
      
triggeraction(player.xplayer.y"hit"NULL);
    }
  }
  if (
this.timer == 0) {
    
this.on 0;
    
this.31;
    
this.33;
  }
  
setTimer(0.05);
}

function 
onActionstart() {
  
this.on 1;
  
this.timer TIMER;

__________________

Last edited by Emera; 02-17-2012 at 04:11 PM..
Reply With Quote
 


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 05:56 AM.


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