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 11-25-2015, 10:57 PM
Kirko Kirko is offline
Registered Guest
Join Date: Dec 2014
Location: Texas
Posts: 61
Kirko has a spectacular aura aboutKirko has a spectacular aura about
Editing a local NPC

How would I go the way of editing local npcs from a level. I had tried changing the layer of one in clientside but only changed for me and no one else.
I tried doing in serverside but the layer wouldn't change. I had the npcs chat change to the layer it was in and it was chatting correctly but the layer wouldn't actually change.
Reply With Quote
  #2  
Old 11-26-2015, 03:32 AM
Elk Elk is offline
Sr Marketing Strategist
Elk's Avatar
Join Date: Nov 2005
Location: Deerland
Posts: 3,829
Elk has a brilliant futureElk has a brilliant futureElk has a brilliant futureElk has a brilliant futureElk has a brilliant futureElk has a brilliant futureElk has a brilliant future
Send a message via ICQ to Elk Send a message via AIM to Elk Send a message via MSN to Elk Send a message via Yahoo to Elk
open the level in texteditor and change it manually
__________________
iEra IGN: *Elk (Darkshire)
iCla. IGN: *Elk (Darkshire)
iZone IGN: *Elk (Darkshire)




Reply With Quote
  #3  
Old 11-26-2015, 08:15 AM
Jakov_the_Jakovasaur Jakov_the_Jakovasaur is offline
Deleted by Darlene159
Jakov_the_Jakovasaur's Avatar
Join Date: Sep 2013
Location: Deleted by Darlene159
Posts: 353
Jakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud of
hello!

this is probably a case of the 'layer' variable not synchronising from serverside to clientside, you could try either setting it via drawunderplayer()/drawoverplayer() or by triggering its change using npc.trigger('Event', params...);
__________________
This signature has been deleted by Darlene159.
Reply With Quote
  #4  
Old 11-26-2015, 01:19 PM
Kirko Kirko is offline
Registered Guest
Join Date: Dec 2014
Location: Texas
Posts: 61
Kirko has a spectacular aura aboutKirko has a spectacular aura about
So I got it to work some what. In class that the npc is joined to I have
PHP Code:
function onLayerChange(){
  
this.trigger("Update");
  
//this.chat = "test1";//this worked
  //this.layer = params[2];//can only be changed in clientside
  
this.triggeraction(this.x+.5,this.y+.5,"LayerChange2","");//doesnt work
}

//#CLIENTSIDE
function onPlayerEnters()
  
this.layer=this.attr[2]

//doesnt work
function onLayerChange2(){
  
this.trigger("Update");
  
this.chat "test2";
  
onPlayerEnters();

the layer only changes when I update level or reenter level. I tried triggering "Update" for the npc in my weapon script and some other thnigs but no luck
Reply With Quote
  #5  
Old 11-26-2015, 03:38 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
Unfortunately you can't trigger clientside like that (it would need to copy the trigger to every player in the level). The best way I remember solving these kind of issues is using a timeout to check an attr, sadly.

You could also hack it by triggering a weapon clientside on each player in the level, but that feels kind of bad too. You can't do point-triggers to clientside, though.

edit: nevermind, this entire post is wrong, see below
__________________

Last edited by cbk1994; 11-26-2015 at 06:17 PM..
Reply With Quote
  #6  
Old 11-26-2015, 04:08 PM
Tim_Rocks Tim_Rocks is offline
a true gentlemen
Tim_Rocks's Avatar
Join Date: Aug 2008
Location: USA
Posts: 1,863
Tim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to behold
Chris' method of using attr w/ a timeout makes the most sense.
__________________
Reply With Quote
  #7  
Old 11-26-2015, 04:09 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by cbk1994 View Post
You can't do point-triggers to clientside, though.
You can since V6, I have a lot of scripts which work as follows:

PHP Code:

function onUpdate(temp.val) {
  
this.attr[4] = int(timevar2);
  
this.attr[5] = temp.val;
  
triggeraction(this.1this.1"Update""");
}

//#CLIENTSIDE
function onCreated()
  
this.setshape(13232);

function 
onPlayerEnters()
  if (
this.updatetTime != this.attr[4])
    
this.onActionUpdate();

function 
onActionUpdate() {
  
this.updatetTime this.attr[4];
  echo(
"New value is " this.attr[5]);

Looking at -

Quote:
Originally Posted by Kirko View Post
PHP Code:
function onLayerChange(){
  
this.trigger("Update");
  
//this.chat = "test1";//this worked
  //this.layer = params[2];//can only be changed in clientside
  
this.triggeraction(this.x+.5,this.y+.5,"LayerChange2","");//doesnt work

this.triggeraction() won't work as it is not an NPC function, but a level function. Change it to one of just triggeraction(), level.triggeraction() or this.level.triggeraction(). The NPC needs a Clientside setshape() in order to receive the triggeraction as well.
Reply With Quote
  #8  
Old 11-26-2015, 04:12 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by ffcmike View Post
You can since V6
Confirmed. Stefan added it after popular demand.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #9  
Old 11-26-2015, 06:16 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
Quote:
Originally Posted by ffcmike View Post
You can since V6
whoops, thanks for correcting me! clearly I'm a bit behind the times .
__________________
Reply With Quote
  #10  
Old 11-26-2015, 07:29 PM
Kirko Kirko is offline
Registered Guest
Join Date: Dec 2014
Location: Texas
Posts: 61
Kirko has a spectacular aura aboutKirko has a spectacular aura about
Got it to work!! thanks so much!!
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 01:00 AM.


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