Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Move Script to stop (https://forums.graalonline.com/forums/showthread.php?t=134267667)

sssssssssss 12-28-2012 05:48 AM

Move Script to stop
 
So I'm using FP4's movement script for npcs (http://forums.graalonline.com/forums...ad.php?t=85370)
and I'm trying to let the actions be interrupted so the npc will stop to chat and other stuff, w/o it being set in the actions and instead by onPlayerTouchsMe, I've added these to the level npc (remember fp4's stuff is also there, these are just additions, I believe the way I'm triggering is probably the problem):

PHP Code:

function onCreated()
{
  
level.npc.jaqor this;
}
// Function to stop the walk of the npc when chatting with a player
function onStopWalk()
{
  echo(
"trigger");
  
// save this.actions
  
this.actionsSaved this.actions;
  
this.actions = {
    
"wait: 9000"
  
};
  
this.savActPos this.actionpos;
  
doAction(0);
}

// Function to resume original actions
public function onResume()
{
  echo(
"resume");
  
this.actions this.actionsSaved;
  
doAction(this.savActPos);
}
//#CLIENTSIDE
function onPlayerTouchsMe()
{
  
this.trigger("StopWalk");
  
findweapon("-System/NPCDialog").loadDialog(this.headthis.speakerthis.msgthis.options);


The weapon calling at the bottom eventuall sends to this serverside trigger in the weapon (and yes it does reach it)

PHP Code:

function onActionServerside()
{
  if (
params[0] == "moveNPC")
  {
    
//echo("server");
    
level.npc.(@params[1]).trigger("Resume");
  }
}
//#CLIENTSIDE
function doesntReallyMatter()
{
  
triggerserver("gui"this.name"moveNPC"this.speaker);


It seems it's not getting to either trigger on the lv npc at all. if I echo on the wep trigger to server action it does get to that though...

fowlplay4 12-28-2012 06:34 AM

You're in luck, I actually updated that script for my use elsewhere about a year ago. I posted my changes here. I would recommend keeping it client-side though.

sssssssssss 12-28-2012 06:42 AM

Awesome. Thanks!

I wanted it serverside so the npc is at the same spot for everyone, due to party quests, ect.

sssssssssss 12-28-2012 07:22 AM

Errrr nm.

If you set it both on clientside and serverside in the same class it seems to mess it up. If you need it serverside, just leaving it only serverside works fine. Dunno or understand why but thats what just happened xD

sssssssssss 12-28-2012 07:33 AM

Also to my original problem. I still need to trigger from the weapon showing the dialog to the level npc, so on a waitfor it knows when to continue. I'm still basically using the same thing, send a trigger to server in weapon, send a trigger serverside in weapon to serverside on level npc.

On the level npc now though it's just this for waiting for the trigger from the wnpc:

PHP Code:

function onPlayerTouchsMe()
{
  
npc_stop();
  
this.dir = (player.dir 2) % 4;
  
waitfor(this"onDialogDone"3600);
  
npc_continue();


I've also tried just "DialogDone" in waitfor as well... it's not doing anything until the waitfor times out.

The weapon npc:
PHP Code:

function onActionServerside()
{
  if (
params[0] == "finishedDialog")
  {
    
level.npc.(@params[1]).trigger("DialogDone");
  }
}
//#CLIENTSIDE 
function doesntReallyMatter() 

  
triggerserver("gui"this.name"finishedDialog"this.speaker);



fowlplay4 12-28-2012 07:47 AM

Try using a database NPC variable instead of a level variable. I.e.

("Control-NPC").npc.jaqor = this;

then in your script..

("Control-NPC").npc.(@params[1]).trigger("Resume");

sssssssssss 12-28-2012 07:49 AM

Changed above post to match what I have. Sorry about that.

It's still mostly the same. I might just have the wrong idea of how this is supposed to work, but from my understanding you call the trigger to the level npc from the serverside of the wnpc. The level npc sits with a waitfor, waiting for that trigger name to pull up, from the trigger sent from the wnpc.

Like I said I've tried onDialogDone and DialogDone as well in the waitfor.

Ill just post what I got so we're up to date with each other xD


Still not working unfortunately...

wnpc:
PHP Code:

function onActionServerside()
{
  if (
params[0] == "finishedDialog")
  {
    (
"Control-NPC").npc.(@params[1]).trigger("DialogDone");
  }


level npc:
PHP Code:

function onCreated()
{
  (
"Control-NPC").npc.jaqor this;
  
this.join("npc_movement");
  
// stuff
}
function 
onPlayerTouchsMe()
{
  
npc_stop();
  
this.dir = (player.dir 2) % 4;
  
waitfor(this"onDialogDone"3600);
  
npc_continue();


Did just DialogDone on waitfor too...

fowlplay4 12-28-2012 04:49 PM

in your server-side portion verify that you're actually sending a trigger to the right place and that you can see it's nickname (give it one):

echo("trigger" SPC params[1]);
echo(("Control-NPC").npc.(@params[1]).nick);

sssssssssss 12-28-2012 04:53 PM

Yup.

NPC Code:
trigger Jaqor



That was echo("trigger" SPC params[1]);
Putting .nick didn't work.

cbk1994 12-28-2012 05:03 PM

Quote:

Originally Posted by fowlplay4 (Post 1710853)
("Control-NPC").npc.(@params[1]).trigger("Resume");

Just be careful to validate that parameter before you do this to avoid allowing a hacker to send rogue triggers to any NPC you're using like this.

fowlplay4 12-28-2012 05:51 PM

Quote:

Originally Posted by sssssssssss (Post 1710879)
Yup.
That was echo("trigger" SPC params[1]);
Putting .nick didn't work.

You have Jaqor but your variable is jaqor, and the lack of a nick would indicate to me that it's not finding the npc.

Variables are case-sensitive:

PHP Code:

function onCreated() {
  
temp.1;
  
temp.2;
  echo(
temp.== temp.A);
  echo(
temp.a SPC temp.A);
}

//The script of NPC JerretNPC has been updated by fowlplay4
//0
//1 2 

I would probably go back to using level instead of Control-NPC for now as well.

sssssssssss 12-28-2012 07:16 PM

Oh goodness.....

Sorry and thanks for pointing that out. It's always really stupid things that get me stuck. xD

fowlplay4 12-29-2012 12:14 AM

Quote:

Originally Posted by sssssssssss (Post 1710895)
Oh goodness.....

Sorry and thanks for pointing that out. It's always really stupid things that get me stuck. xD

Use your params when you're debugging next time.

sssssssssss 12-29-2012 12:16 AM

I did. Just didn't pay that much attention I guess.


All times are GMT +2. The time now is 02:55 AM.

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