Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-07-2011, 11:23 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
disable onPlayerTouchsMe()

When I want a script to do something I simply use:
PHP Code:
function onPlayerTouchsMe() {
//dostuff

but how can I make it that if the player doesnt touch the npc anymore, it will stop? Like:
PHP Code:
function onPlayerTouchsMe() {
setcharani("walk",null);
}
//Now the command/script I would need here. Invented one for example
function onPlayerStopsTouchingMe() {
setcharani("idle",null);

I just know the
PHP Code:
function onPlayerTouchsOther() {
//dostuff

but than it will make it only, if I touch other NPC´s.
Reply With Quote
  #2  
Old 03-07-2011, 11:29 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Quite vague, what're you wanting it to do exactly? You do know if you touch it, you touch it alot of times? I don't know of this would work...

HTML Code:
function onPlayerTouchsMe() {
  this.ani = "walk";
  
  cancelevents("onFinishTouch");
  scheduleevent(0.2, "onFinishTouch", "");
}

function onFinishTouch() {
  this.ani = "idle";
}
It will run "onFinishTouch" 0.2 seconds after the NPC was touched. Reduce time if needed- don't use it serverside (if possible)
__________________
Reply With Quote
  #3  
Old 03-07-2011, 11:30 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
There is no "Stops Touching Me" event, depending on the situation I would do something like this:

PHP Code:
function onPlayerTouchsMe() { 
  if (
this.ani != "walk"this.setcharani("walk",null);
  
setTimer(0.25); 
}

function 
onTimeout() {
  
this.setcharani("idle""");

Provided the player continues to touch the NPC it won't timeout (because it will keep getting reset to 0.25) and go to the idle position. Maybe adjust the timer to suit your needs though.

Edit: Well... Timeout, scheduleevent, same difference.
__________________
Quote:
Reply With Quote
  #4  
Old 03-07-2011, 11:45 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Hmm well both won´t work.

Quote:
Originally Posted by xAndrewx View Post
Quite vague, what're you wanting it to do exactly
I´m trying to make a railroad script . I´m sure there is a way more easier way, but I wanted to do it like when the player touches it, it will move the playerx, and if the player doesn´t touch it anymore, it will stop moving the player :/

Or is there maybe an easier way with the moving of the player?
Reply With Quote
  #5  
Old 03-07-2011, 11:52 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Sounds like you want to disable default movement and rescript it using GraalControl.onKeyDown/onKeyUp or if (keydown(key)).
__________________
Reply With Quote
  #6  
Old 03-07-2011, 11:54 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by cbk1994 View Post
Sounds like you want to disable default movement and rescript it using GraalControl.onKeyDown/onKeyUp or if (keydown(key)).
jea
Reply With Quote
  #7  
Old 03-08-2011, 12:01 AM
MrOmega MrOmega is offline
One More Time
MrOmega's Avatar
Join Date: Aug 2010
Location: TN, USA
Posts: 631
MrOmega is an unknown quantity at this point
Send a message via AIM to MrOmega Send a message via MSN to MrOmega Send a message via Yahoo to MrOmega
use a timeout and use checks

PHP Code:
function onCreated()
{

  
this.width = <WIDTH>; //In Tiles
  
this.height = <HEIGHT>; //In Tiles
  
onTimeout();

}

function 
onTimeout()
{

  if ( 
player.1.5 in this.xthis.width| &&
       
player.2.0 in this.ythis.height| &&
       !
this.touch)
  {

    
this.touch true;
    
//Touch Actions

  
}

  if ( !( 
player.1.5 in this.xthis.width|) &&
       !( 
player.2.0 in this.ythis.height|) &&
       
this.touch)
  {

    
this.touch false;
    
//Stop Touch Actions

  
}

  
setTimer0.1);


replace <WIDTH> and <HEIGHT> with the NPCs width and height in tiles, not pixels. ( 1 pixel would equal ( 1 / 16), btw)
__________________
Time is the fire in which we burn...
Up, Up, Down, Down, Left, Right, Left, Right, B, A, Select, Start! Now I got 99 LIVES!!!
Reply With Quote
  #8  
Old 03-08-2011, 12:04 AM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Hmm I guess I found something similiar. Didn´t test it yet but from looking around in the forums I got this idea (first off player moves from alone to the right):
PHP Code:
//#CLIENTSIDE
function onCreated() {
this.image "myimage.png";
}
function 
onPlayerTouchsme() {
  if (
player.dir 2) {
    if (
playerx in |getimgwidththis.image)| && playery in |getimgheightthis.image)|) {
    
settimer("0.1");
    }
if (!
playerx in |getimgwidththis.image)| && !playery in |getimgheightthis.image)|) {
    
settimer("0");
    }
  }
}
function 
onTimeout() {
  
playerx += 1;
  
settimer("0.1");

EDIT: added if the player isn´t inside the picture
Reply With Quote
  #9  
Old 03-08-2011, 12:28 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Keep in mind:

player.x is a tile-based coordinate, and getimgwidth is by pixels. 1 tile width/height = 16 pixels.

therefore... tile width = (pixels / 16)
__________________
Quote:
Reply With Quote
  #10  
Old 03-08-2011, 01:03 AM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by fowlplay4 View Post
Keep in mind:

player.x is a tile-based coordinate, and getimgwidth is by pixels. 1 tile width/height = 16 pixels.

therefore... tile width = (pixels / 16)
and what about:

getimgwidth( this.image)/16
Reply With Quote
  #11  
Old 03-08-2011, 01:08 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by callimuc View Post
getimgwidth( this.image)/16
That's how you would do it. Honestly your script isn't making much sense.
__________________
Quote:
Reply With Quote
  #12  
Old 03-08-2011, 01:30 AM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Hehe I´m testing around with commands and so on.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 04:16 PM.


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