My first attempt at a "watcher" script
Here's what I've come up with. Any help in this would be greatly appreciated.
Background: Player finds item, and item gives him pvp status until he can take the item safely to his kingdom. Each time player zones, certain npcs look for him in an attempt to get the item (via an aggro object in player.pl). If one of those npcs catches up with him and kills him, the following script is triggered: Code:
#Slayer pl Code:
#Watcher pl -- watcher is on a 2-point stationary grid with a 5-sec delay Code:
#Lord pl -- spawned in slayer script |
Just to avoid wasting anyone's time, I've already caught SUB EVENT_WAYPOINT and changed it to sub EVENT_WAYPOINT.
I also placed . . . "quest::delglobal("king");" just above the "quest::setglobal("king", 4, 7, "F");" in the Slayer script. The script is still not working. |
Did you check for typos? again, this will help.
|
Might want to change timer to $timer
|
Quote:
|
The syntax of all three scripts checks out "ok"
|
Quote:
|
Script still does not work :(
|
Quote:
Code:
sub EVENT_WAYPOINT { |
I don't understand this;
Code:
if (defined($qglobals{king})) kingdomfaction = king1 you have to follow sequence to set a global; Code:
quest::delglobal("king1"); Code:
if (defined($qglobals{king})) |
Okay, I've narrowed down the problem to the watcher script. I sandwiched the "setglobal" in the slayer script between two shouts, like this:
Code:
quest::delglobal("king"); I also added some shouts to the watcher script, like this: Code:
sub EVENT_WAYPOINT |
Is your watcher set to have access to qglobals in the npc_types table?
|
Quote:
In the meantime . . . I have been playing with the watcher script and changed it from this: Code:
sub EVENT_WAYPOINT Code:
sub EVENT_WAYPOINT |
No it only looks like it's working, but it's not - set the flag
|
Just to clarify, the flags allows that particular NPC to view the globals. This is so they don't have to exported for every single NPC (which, as you can imagine, can be VERY resource intensive). Anyone can set a global, even without the flag set in npc_types. That's why you can set it in the player.pl file (which coincidentally has the globals accessable automatically), but can't read it in the watcher script.
This caused me a lot of headache with the PoJ Trial of Execution when it was first changed, but once I figured it out, it was easy enough to fix. |
I would have mine working 'half-assed' when I forget to set that- it would do things like make the global, but not change it.
|
Okay, appreciate the tip on setting the qglobal flag on the npcs. Things are almost working correctly. I'm currently having an issue with the watcher. The signal script on the watcher triggers a settimer on the spawned npc. That timer has three parts to it so that the npc kneels to simulate "looting" the item (actually stripped from the client by the slayer), then stands to make an announcement to the server that he is now ruling the world, then depops. The problem is, the watcher keeps tripping the timer and restarting it before the npc is able to depop. How do I get the signal to stop?
|
When using quest::settimer(id,time), as soon as it hits 0, it will start over and repeat itself. Make sure you are using quest::stoptimer(id).
Another idea (not sure if it will work; you will need to test)... you might be able to have him signal himself. For example, looks like the NPCID is 999247. To start the sequence, I would have the watcher signal the Lord: Code:
#Watcher.pl () Code:
#Lord.pl (999247) |
I will try this, thanks. One point though. I have a stoptimer on all the timers, so I don't think that's the problem. The shout and emote statements are being repeated, and I have to think that's due to the EVENT_WAYPOINT, which triggers each time the npc leaves a waypoint (in this case, every 7 seconds--I tried adjusting it to 10 seconds, but the npc stalls out for some reason). Which is also why I'm dubious about adding seconds to the timer function of the watcher (whether in a timer or a signalwith function). If the watcher re-signals the Lord each time he leave a waypoint, and if the pause time of the waypoint movement is set to 7, then it seems to me that the waypoint movement of the watcher will override any longer duration of time I set in a timer on the Lord. Feel free to correct me on this if I'm wrong.
I'll try the signalwith function and see if I get different results. Thanks again. |
Quote:
|
Yeah, sorry about that. I have modified this several times since I posted. Here is the Lord script with the stoptimers:
Code:
sub EVENT_SIGNAL Code:
sub EVENT_SIGNAL |
Ok, I see. You could add a variable that doesn't allow him to continuously react to signals. And with your stoptimers, you should stop them as soon as the trigger hits. Take a look at this example:
Code:
my $started; |
Code:
my $started; |
I've never used a my outside of a sub before, just saw that used in another file. Maybe put it inside the spawn? Not sure if that will change the scope of it though, which will negate what I was doing...
Or try my $started = 0; That's the only thing I could think of that would be wrong here. |
Quote:
|
All times are GMT -4. The time now is 03:57 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.