Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   triggeraction/callnpc barrier (https://forums.graalonline.com/forums/showthread.php?t=48966)

G_yoshi 11-04-2003 03:08 AM

triggeraction/callnpc barrier
 
Why am I unable to do a triggeraction with params to one NPC that will do a triggeraction back with params? I've tried the combination of doing triggeraction and responding with callnpc but nothing happens. The purpose of this is to create something of a pathnode system which I can send NPCs to run along. I'm sure there are better ways of having an NPC get from point A to point B. This is just the way I chose.

*note
This is a crude script at the moment. All I'm doing is testing my idea without too much success :(.

<sending NPC>
NPC Code:

...

if (timeout) {

for (lag=0; lag<10; lag++) {
if (dir==3) {
//showimg lag,brick.png,x+lag+vecx(dir)*2,y+1+vecy(dir)*2;
triggeraction x+lag+vecx(dir)*2,y+1+vecy(dir)*2,path,#v(id),#v(l ag);
}
sleep .1;
}
timeout = 0.45;
}

if (node) {
setcharprop #c,PING!;
distx = strtofloat(#p(0));
disty = strtofloat(#p(1));
disttime = strtofloat(#s(path.latency));
}



<recieving NPC>
NPC Code:
if (playerenters) {
setshape 1,48,48;
dontblock;
}

if (actionpath) {
setstring path.npcindex,#p(0);
setstring path.latency,#p(1);
setcharprop #c,FOUND!;
//play quickbm.wav;
callnpc strtofloat(#s(path.npcindex)),node,#v(x),#(y);
}



'lag' is used to determine the actual time distance (in tiles). The 'recieving NPC' works. I just can't get the sender to respond to the callnpc sent to it. showimg is so I know where its triggering :]

slimchance11 11-04-2003 06:20 AM

Is the level in the levels list? I've been having trouble using triggeraction on servers too, your script looks fine, i've been trying things like that too and they never seem to work, I think something with triggeraction on servers has changed o0

Kaimetsu 11-04-2003 06:28 AM

Ew, don't put sleeps in loops. And non-prefixed vars are volatile. It's not guaranteed that their values will be preserved between frames.

ZeLpH_MyStiK 11-04-2003 07:01 AM

I'm not 100% sure, but, I believe triggeraction cannot be done from inside a timeout loop. Anyone care to verify?

Kaimetsu 11-04-2003 07:11 AM

Quote:

Originally posted by ZeLpH_MyStiK
I'm not 100% sure, but, I believe triggeraction cannot be done from inside a timeout loop.
Why not?

ZeLpH_MyStiK 11-04-2003 07:18 AM

I believe it's because the timeout loop is too fast for triggeractions. Its the same reason why I was told that a timeout or sleep of 0.05 is necessary in a while loop, otherwise it may crash the npcserver.

Kaimetsu 11-04-2003 07:33 AM

Quote:

Originally posted by ZeLpH_MyStiK
I believe it's because the timeout loop is too fast for triggeractions. Its the same reason why I was told that a timeout or sleep of 0.05 is necessary in a while loop, otherwise it may crash the npcserver.
Um... okay. You can send triggeractions whenever you want, dude. Might not be advisable, but it's possible.

Gambet 11-04-2003 07:46 AM

yea, triggeraction is common with the NC system, its wats used for practically anything you may need it for. Its faster, easier, and works perfectly. (unless u cant script)

ZeLpH_MyStiK 11-04-2003 07:57 AM

Hmm, interesting, I was taught that it would crash the NPC-Server. ::TAKES A CLOSER LOOK AT SCRIPT ABOVE:: =)

GoZelda 11-04-2003 09:20 PM

Quote:

Originally posted by ZeLpH_MyStiK
Hmm, interesting, I was taught that it would crash the NPC-Server. ::TAKES A CLOSER LOOK AT SCRIPT ABOVE:: =)
Erm, serverside it wouldn't work i s'ppose, because you have a minimum of 0.1 in a timeout.

G_yoshi 11-05-2003 04:30 AM

Quote:

Originally posted by slimchance11
Is the level in the levels list? I've been having trouble using triggeraction on servers too, your script looks fine, i've been trying things like that too and they never seem to work, I think something with triggeraction on servers has changed o0
This is only to test offline at the moment. I had this same problem a long time ago when I tried to setup player damage since I use my own health system. I can send the triggers, but I can't send two triggers consecutively with parameters in each :/



Quote:

Originally posted by Kaimetsu
Ew, don't put sleeps in loops. And non-prefixed vars are volatile. It's not guaranteed that their values will be preserved between frames.
As already noted its just a crude script, but you're probably right. I put the sleep in there in case there was a problem in that it couldn't break from the for loop. I'm guessing that when an NPC is called or triggered while in any kind of loop it will automattically break to jump to where it has been called or triggered?

I could probably set a string in the loop that contains the ID, but I'm not sure if

NPC Code:

for (this.i=0; this.i<npcscount; this.i++) {
callnpc this.i,<flag>,;
}



will actually use that NPC's ID since what is usually set is somewhere in the thousands range. I haven't tried that yet.

Kaimetsu 11-05-2003 05:29 AM

Quote:

Originally posted by G_yoshi
As already noted its just a crude script, but you're probably right. I put the sleep in there in case there was a problem in that it couldn't break from the for loop. I'm guessing that when an NPC is called or triggered while in any kind of loop it will automattically break to jump to where it has been called or triggered?
Well, technically NPCs can't be triggered while in loops - the events are accumulated and triggered in sequence. If you're talking about events occuring when the sleep pointer is set then you might be right, I've never been foolhardy enough to experiment with it.

G_yoshi 11-05-2003 05:54 AM

Quote:

Originally posted by Kaimetsu


Well, technically NPCs can't be triggered while in loops - the events are accumulated and triggered in sequence. If you're talking about events occuring when the sleep pointer is set then you might be right, I've never been foolhardy enough to experiment with it.

I see. Hmm. Well, I tried my idea of setting the character NPC's id to a string and doing the callnpc loop and it resonded. Now if I can get it to stop running the for loop :x

*edit*
Its sort of working. Biggest issue right now is finding a way to make it ignore the last node it walked to when searching for a node that is not in the same direction.

ZeLpH_MyStiK 11-05-2003 07:17 AM

Ok, I guess someone *cough*Kai*cough* deleted my script. If you want it, just IM me on AIM. My SN is DarkBlade7788.

G_yoshi 11-05-2003 07:20 AM

Quote:

Originally posted by ZeLpH_MyStiK
Ok, I guess someone *cough*Kai*cough* deleted my script. If you want it, just IM me on AIM. My SN is DarkBlade7788.
What script? I wasn't exactly asking for a script. I was looking for input on what I was doing that could help me solve my problem. I wound up trying something else that I didn't try last night and it worked. Now I have new problems to deal with o.O


All times are GMT +2. The time now is 08:52 PM.

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