Log in

View Full Version : Need help on a turn in


Neiv
06-25-2008, 03:17 PM
I'm hoping I can get some insight on why this script is not working correctly. I ran in through a perl command line with no syntax problems.


# test script for hand in of bone chips for exp, faction, and cash
sub EVENT_ITEM
{
if(plugin::check_handin{\%itemcount,13073 => 4})
{
quest::givecash("0","5","0","0");
quest::exp(1000);
quest::faction(19927,1);
quest::ding();
quest::say("You have done well, $name! These indeed are a token of friendship with our realm. But will your heart remain true through days of darkness? I urge you, continue these deeds. And may you continue to become a trusted friend of our realm!");
}
else
{
quest::say("I have no use for these, $name. I require four remains of our enemies");
plugin::return_items(\%itemcount);
}
}


At this point the turn-in works as far as it goes. That is, when I give 4 bone chips to the npc, they are accepted, and I receive the right amount of exp, cash, and faction. However, when I test it with other items--or with fewer than 4 of the right items--those items are accepted as well, and I still receive exp, cash and faction. Because all items are accepted the script never gets to the return_items line, so I cannot tell yet whether that part is working. I've looked at several examples on these forums of the check_handin line, and mine seems to be right. But the variables are being ignored. Any clue why? Thanks!

ChaosSlayer
06-25-2008, 03:34 PM
if(plugin::check_handin{\%itemcount,13073 => 4})

swap curly brakets for parentesis here


if(plugin::check_handin(\%itemcount,13073 => 4))

Neiv
06-25-2008, 04:00 PM
That did the trick :) Thanks!

I had actually (briefly) considered that possibility, but I had seen
examples from others using the curly brackets and thought it must be a valid usage.

ChaosSlayer
06-25-2008, 04:19 PM
np
the bracket prabobly work in some cases, but parentesis work always

Neiv
06-25-2008, 07:05 PM
Okay, here's another one, then:

sub EVENT_ITEM
{
if(plugin::check_handin(\%itemcount,13732 == 1))
{
quest::givecash("0","0","0","5000");
quest::exp(3500000);
quest::faction(19927,4000);
quest::ding();
quest::say("Well done, $name! We now have the item. Yet it is certain the enemy knows of our plans; even now he is planning his attack. We must muster our defenses and set reinforcements on our [cities].");
$client->Message(15, "You receive 5000 platinum pieces");
$client->Message(15, "You receive 3500000 exp points");
$client->Message(15, "Your faction standing with the Realm could not get any better!");
}
if($text=~/cities/i)
{
quest::say("Who knows where he may strike first? Go now, $name, and make preparations for war. Take the Interior Road to the Palace, and take word to the Captain of our good fortune--and of the threat that follows. He will know what to do. I will keep watch here the time being, but will make way there if it [comes to that].");
}
if($text=~/comes to that/i)
{
quest::say("$name, listen to me carefully. You must take word to the Captain of the Guard. He knows nothing of this find, and very soon it may be too late. The Palace lies defenseless, and is vulnerable to the enemy's attack. The fate of the Palace is in your hands, $name. If you do not go quickly, who can tell what [fate] awaits them?");
}
if($text=~/fate/i)
{
quest::say("There is little time to explain it all now, Go! I have made you a full citizen of the Realm and a knight of the Palace. On this journey you bear the authority of the king himself! Go; and may the blessing of the Realm go with you! My trusted advisor will take care of matters here.");
}
else
{
quest::say("I have no use for this, $name. Do not trouble me again--unless you bring the item!");
plugin::return_items(\%itemcount);
}
}


Each time I give the item to the npc, he gives it back and defaults to the return_item text. I have triple-checked the item #, and it is correct. I have tried a different operator (< 2 instead of == 1) with the same result. I have tried placing the initial quest::say before all the reward lines, with the same result. I have run the code through a Perl cmd line and it reported no syntax problems.

Thoughts?

trevius
06-25-2008, 07:45 PM
Try the following. You forgot to put in an EVENT_SAY section:

sub EVENT_ITEM {

if(plugin::check_handin(\%itemcount,13732 == 1)) {

quest::givecash("0","0","0","5000");
quest::exp(3500000);
quest::faction(19927,4000);
quest::ding();
quest::say("Well done, $name! We now have the item. Yet it is certain the enemy knows of our plans; even now he is planning his attack. We must muster our defenses and set reinforcements on our [cities].");
$client->Message(15, "You receive 5000 platinum pieces");
$client->Message(15, "You receive 3500000 exp points");
$client->Message(15, "Your faction standing with the Realm could not get any better!"); }

else {
quest::say("I have no use for this, $name. Do not trouble me again--unless you bring the item!");
plugin::return_items(\%itemcount); }

}

Sub EVENT_SAY {

if($text=~/cities/i) {

quest::say("Who knows where he may strike first? Go now, $name, and make preparations for war. Take the Interior Road to the Palace, and take word to the Captain of our good fortune--and of the threat that follows. He will know what to do. I will keep watch here the time being, but will make way there if it [comes to that]."); }

if($text=~/comes to that/i) {

quest::say("$name, listen to me carefully. You must take word to the Captain of the Guard. He knows nothing of this find, and very soon it may be too late. The Palace lies defenseless, and is vulnerable to the enemy's attack. The fate of the Palace is in your hands, $name. If you do not go quickly, who can tell what [fate] awaits them?"); }

if($text=~/fate/i) {

quest::say("There is little time to explain it all now, Go! I have made you a full citizen of the Realm and a knight of the Palace. On this journey you bear the authority of the king himself! Go; and may the blessing of the Realm go with you! My trusted advisor will take care of matters here."); }

}

Neiv
06-25-2008, 08:18 PM
Thanks Trevius. I made the change, but he's still returning the item. I'm just learning Perl, so I appreciate your patience with this. Fyi, I already have one EVENT_SAY section that comes before the EVENT_ITEM section (yours would be a second one that comes after). I didn't include it in the first post because it was working fine on it's own. The only section I'm having trouble with is the turn in. Any other suggestions?

trevius
06-25-2008, 08:31 PM
You only want to have 1 EVENT_SAY in your quest. Put all of the ones in the script I posted into your pre-existing one and remove the one I put in.

You have to keep certain things like that completely separated for a reason, otherwise they will get messed up as you are now seeing.

Anytime you have an "if" statement, whatever it is if'ing on is what section it should go in. So, if's on text should go in EVENT_SAY, and if's on turn ins should go in EVENT_ITEM, and if's on timers should go in EVENT_TIMER, etc.

Neiv
06-25-2008, 08:51 PM
Okay, here's the entire script, annotated by me. Maybe this will help.


# player hails npc. If player is carrying item #13732, npc offers to take item.
# Otherwise, npc wants nothing to do with player.

sub EVENT_SAY
{
if($text=~/hail/i)
{
if(plugin::check_hasitem($client, 13732))
{
quest::say("What is this? You bring good tidings indeed, $name! Give me the item.");
}
else
{
quest::say("Do you not see I have enough [trouble] already? Your welcome here is doubtful");
}
if($text=~/trouble/i)
{
quest::say("I sense my will is being bent by some [evil].");
}
if($text=~/evil/i)
{
quest::emote("mumbles inaudibly; his eyes stare blankly");
}
}
}

# above script works well independently. If the player has the item, the npc responds favorably.

sub EVENT_ITEM
{
if(plugin::check_handin(\%itemcount,13732 == 1))
{
quest::givecash("0","0","0","5000");
quest::exp(3500000);
quest::faction(19927,4000);
quest::ding();
quest::say("Well done, $name! We now have the item. Yet it is certain the enemy knows of our plans; even now he is planning his attack. We must muster our defenses and set reinforcements on our [cities].");
$client->Message(15, "You receive 5000 platinum pieces");
$client->Message(15, "You receive 3500000 exp points");
$client->Message(15, "Your faction standing with the Realm could not get any better!");
}
else
{
quest::say("I have no use for this, $name. Do not trouble me again--unless you bring the item!");
plugin::return_items(\%itemcount);
}
}

# in the above script, the player hands in item. If wrong item, it's handed back. If correct item, npc doles out cash, exp, and faction. This is the part that is failing. Below is the section you added (or rather modified from my original):

Sub EVENT_SAY
{
if($text=~/cities/i)
{
quest::say("Who knows where he may strike first? Go now, $name, and make preparations for war. Take the Interior Road to the Palace, and take word to the Captain of our good fortune--and of the threat that follows. He will know what to do. I will keep watch here the time being, but will make way there if it [comes to that].");
}
if($text=~/comes to that/i)
{
quest::say("$name, listen to me carefully. You must take word to the Captain of the Guard. He knows nothing of this find, and very soon it may be too late. The Palace lies defenseless, and is vulnerable to the enemy's attack. The fate of the Palace is in your hands, $name. If you do not go quickly, who can tell what [fate] awaits them?");
}
if($text=~/fate/i)
{
quest::say("There is little time to explain it all now, Go! I have made you a full citizen of the Realm and a knight of the Palace. On this journey you bear the authority of the king himself! Go; and may the blessing of the Realm go with you! My trusted advisor will take care of matters here.");
}
}


I removed the final EVENT_SAY section and tested the script without it, and the npc still returns the item. It makes no sense to me. He recognizes the item in the hail during the first section ((hasitem), but doesn't seem to recognize it when I actually give it to him.

ChaosSlayer
06-25-2008, 09:08 PM
i think you have an icorect follow up of elses and ifs in first part

there can only be ONE else inside a single if and i belvie you have incorect open closed brakets


sub EVENT_SAY
{ - OPENED
if($text=~/hail/i)
{ - OPENED
if(plugin::check_hasitem($client, 13732))
{ - OPENED
quest::say("What is this? You bring good tidings indeed, $name! Give me the item.");
} - CLOSED
else
{ - OPENED
quest::say("Do you not see I have enough [trouble] already? Your welcome here is doubtful");
} - CLOSED


- MISSING CLOSEING BRAKET HERE

if($text=~/trouble/i)
{
quest::say("I sense my will is being bent by some [evil].");
}
if($text=~/evil/i)
{
quest::emote("mumbles inaudibly; his eyes stare blankly");
}
}

} - WRONGLY PLACED BRAKET

Neiv
06-25-2008, 09:30 PM
I made your change, Chaos, and (oddly enough) it made no difference in the quest (not sure why--you'd think placement of brackets would matter). I'm making live changes directly to the quest/zone folder, and I "reloadquest" after each change. As I mentioned above, that part of the script has always worked fine. It fails only once it calls the EVENT_ITEM script.

Neiv
06-25-2008, 09:56 PM
Okay, I have been experimenting with this code, and got it to (semi-) work. I replaced:

sub EVENT_ITEM {
if(plugin::check_handin(\%itemcount,13732 == 1))
{

with . . .

sub EVENT_ITEM {
if($item,13732)
{

I though, as long as I have only one item to turn in, maybe I won't need the count variable. I have no idea whether this is "sound" from a scripting standpoint, but the npc now takes the item and rewards me with the right exp, plat and faction. But now he'll also take just any item and give the same reward. Any way to modify this so only that item is recognized?

ChaosSlayer
06-25-2008, 09:58 PM
oh yeah make sure than you only have ONE EVENT_SAY section as Trevies pointed out

and to be sure
you need to place a closing curcly braket when I said
and remove one where i said

ChaosSlayer
06-25-2008, 10:16 PM
try this.
replace

if(plugin::check_handin(\%itemcount,13732 == 1))

with

if(plugin::check_handin(\%itemcount,13732 => 1))

Neiv
06-25-2008, 10:39 PM
try this.
replace

if(plugin::check_handin(\%itemcount,13732 == 1))

with

if(plugin::check_handin(\%itemcount,13732 => 1))

Yay! That did it! It's now accepting only item 13732. Since that item is lore, the ">" operator becomes moot. (But why doesn't == work?)

Thanks for all the help. Next up; mob spawns triggered by the same turn-in. Going to try my hand at solo-ing the quest:spawn feature, but I may be back. Thanks again.

trevius
06-25-2008, 10:46 PM
Was about to paste this when you apparently resolved your issues. Your quest still had the brackets in the wrong lines for your hasitem check and text responses to work properly. I adjusted that, I also did the => fix, and I removed all of the ;s and --s in your quest::say's, because you have to be careful when using certain characters in there, and I haven't personally used either of those in that way. So, I thought it might have something to do with your issue, but apparently not.

Here is the final quest after my edits:

sub EVENT_SAY {

if($text=~/hail/i) {
if(plugin::check_hasitem($client, 13732)) {
quest::say("What is this? You bring good tidings indeed, $name! Give me the item."); }

else {
quest::say("Do you not see I have enough [trouble] already? Your welcome here is doubtful"); }
}

if($text=~/trouble/i) {
quest::say("I sense my will is being bent by some [evil]."); }

if($text=~/evil/i) {
quest::emote("mumbles inaudibly and his eyes stare blankly"); }

if($text=~/cities/i) {
quest::say("Who knows where he may strike first? Go now, $name, and make preparations for war. Take the Interior Road to the Palace, and take word to the Captain of our good fortune, and of the threat that follows. He will know what to do. I will keep watch here the time being, but will make way there if it [comes to that]."); }

if($text=~/comes to that/i) {
quest::say("$name, listen to me carefully. You must take word to the Captain of the Guard. He knows nothing of this find, and very soon it may be too late. The Palace lies defenseless, and is vulnerable to the enemy's attack. The fate of the Palace is in your hands, $name. If you do not go quickly, who can tell what [fate] awaits them?"); }

if($text=~/fate/i) {
quest::say("There is little time to explain it all now, Go! I have made you a full citizen of the Realm and a knight of the Palace. On this journey you bear the authority of the king himself! Go! And may the blessing of the Realm go with you! My trusted advisor will take care of matters here."); }

}


sub EVENT_ITEM {

if(plugin::check_handin(\%itemcount, 13732 => 1)) {
quest::givecash("0","0","0","5000");
quest::exp(3500000);
quest::faction(19927,4000);
quest::ding();
quest::say("Well done, $name! We now have the item. Yet it is certain the enemy knows of our plans. Even now he is planning his attack. We must muster our defenses and set reinforcements on our [cities].");
$client->Message(15, "You receive 5000 platinum pieces");
$client->Message(15, "You receive 3500000 exp points");
$client->Message(15, "Your faction standing with the Realm could not get any better!"); }

else {
quest::say("I have no use for this, $name. Do not trouble me again. Unless you bring the item!");
plugin::return_items(\%itemcount); }

}

Notice that I also changed the format on how the quest is written so that it is easier to read. It is a good idea to write in a way similar to that so you can find mistakes quicker.

And, whenever I am working on a quest, I remove 1 section at a time until I narrow it down to a certain section and then I remove a line at a time until it works. Then add them in again until it breaks and fix the line that is causing the break to happen.

ChaosSlayer
06-26-2008, 12:16 AM
Yay! That did it! It's now accepting only item 13732. Since that item is lore, the ">" operator becomes moot. (But why doesn't == work?)

Thanks for all the help. Next up; mob spawns triggered by the same turn-in. Going to try my hand at solo-ing the quest:spawn feature, but I may be back. Thanks again.


I belive its not the operator you thing it is.
rather than "greater or equal" it reads something like "fetch from item slot"
- basilcy its not an operator at all (from my logical understanding)

regading mob spawns. here is an easy sample for you to work with pulled from one of my quests





sub EVENT_ITEM
{

if(plugin::check_handin(\%itemcount, 1027 => 1))
{
quest::say("Now that you got back my magical tome, I have no more use for you. Sorry dear...");

#spawns 4 KOS mobs around you

my $x;
my $y;
my $z;
my $h;

$x = $npc->GetX();
$y = $npc->GetY();
$z = $npc->GetZ();
$h = $npc->GetHeading();

quest::spawn2(58012,0,0,$x+5,$y+5,$z,$h);
quest::spawn2(58012,0,0,$x-5,$y-5,$z,$h);
quest::spawn2(58012,0,0,$x+5,$y-5,$z,$h);
quest::spawn2(58012,0,0,$x-5,$y+5,$z,$h);
}



else
{
plugin::return_items(\%itemcount);

}



}






Enjoy =)

Neiv
06-26-2008, 09:51 AM
Thanks Trevius. I replaced my current version with yours just to be on the safe side, so your work wasn't in vain. It also helped me to see a better way to format. Thanks again.

Neiv
06-26-2008, 10:04 AM
I belive its not the operator you thing it is.
rather than "greater or equal" it reads something like "fetch from item slot"
- basilcy its not an operator at all (from my logical understanding)
That's good to know. I just assumed it was a "greater than or equal to" operator, but could not figure out why the = comes before the >. That explains it.

regading mob spawns. here is an easy sample for you to work with pulled from one of my quests
Very helpful. I will use this as a template. Thanks. What's the logic behind using quest::spawn2 rather than quest::spawn?

Neiv
06-26-2008, 01:06 PM
Chaos, I modified your spawn script and everything works great. I now have the first part of a larger npc war script finished. Just seeing all those guards spawn to reinforce the kingdom when I turned in the item to the king brought a tear to my eye :wink:

Thanks again for all the help!

ChaosSlayer
06-26-2008, 02:45 PM
Chaos, I modified your spawn script and everything works great. I now have the first part of a larger npc war script finished. Just seeing all those guards spawn to reinforce the kingdom when I turned in the item to the king brought a tear to my eye :wink:

Thanks again for all the help!

np 8-)
.

Neiv
06-26-2008, 07:08 PM
Okay, one thing I didn't expect was for the newly spawned mobs to disappear when I log off. If I want them to remain spawned until they are killed by a player raid or an npc war, is there a way to do that? The goal of the npc spawn is to provide reinforcements against members of another faction coming in and taking over the city in an attempt to retake the item I just turned in to the king. If they despawn when I log from my account, then the quest is functionally useless to my storyline. I want to make it so that they remain there to guard the realm against players of a different faction who are looking for the item I just turned into the king. If another faction does come in, kills all the npcs (except for the king), loots a specified item from one of the named npcs, and turns it into to the king, the king then yields the item they came for (via another turn-in), and all his reinforcements despawn, never to spawn again until and unless someone else turns in the same item to him.

How do I make the spawns stay put? Would that be a quest::spawn rather than a quest::spawn2? Something else? Also, once I have them there, I want to have the second item turn-in trigger their despawn. Any ideas on this?

ChaosSlayer
06-26-2008, 07:13 PM
the server has no way to store any data about something what is not a part of default spawn DB

you may want to turn on the Persistant State rule in Variables section of the DB. but no garantee that server will record and reproduce CURRENT state for mosb that are not part of DB spawns

basicly if you looking for soemthing like a GM event where mobs become persistant, you want to actualy add them to regular spawn tables and turn then on and off as requred.

of course it would have to be done by hand, cuase there no conection betwen quest scripts and DB

NOTE: once Persistant State has been turned on ANY changes you do Db will auto crash the server untill Persistant State turned off.


As far as despawning goes, there is a comand quest::depop

basicly once item turned in to quest NPC, npc will need to send a SIGNAL code command to each npc you want to dispawn, and each of those npcs will execute depop comand

Neiv
06-27-2008, 10:48 AM
you may want to turn on the Persistant State rule in Variables section of the DB. but no garantee that server will record and reproduce CURRENT state for mosb that are not part of DB spawns
Actually, this works very well. I turned persistent state on, did the quest, did a #zsave (not sure if that matters, but I did it anyway), logged out, shut down world, came back in and the mobs were still there.
As far as despawning goes, there is a comand quest::depop. basicly once item turned in to quest NPC, npc will need to send a SIGNAL code command to each npc you want to dispawn, and each of those npcs will execute depop comand
Thanks; I'll give this a try.

ChaosSlayer
06-27-2008, 11:46 AM
well its nice to know that Persistant State rule works like this .
Rememebr however - you will not be able to edit DB as long as it turned on.

I mean you can edit it, but then the server won't boot up cuase Persistant State requres for Db to remain IDENTICAL to what it was before server was shot down in order to restore it to exactly how it was

I once did that.. I spend 3 days trying to figure out why server is not booting up anymore =)

Neiv
06-27-2008, 11:09 PM
well its nice to know that Persistant State rule works like this . Rememebr however - you will not be able to edit DB as long as it turned on. I mean you can edit it, but then the server won't boot up cuase Persistant State requres for Db to remain IDENTICAL to what it was before server was shot down in order to restore it to exactly how it was
Odd. I have been able to make changes to the DB with this on. I changed the zone points in the zone_points table for a custom zone I have, and it works just fine.

ChaosSlayer
06-27-2008, 11:17 PM
well from what i know its not all parts of the DB its some parts which would have a direct impact of persistant data stored - like walking grid for a mob