Ok, I have one section saying you need to access globals via the hash, another that this is possibly deprecated, and yet another insisting you don't need to set the NPC data in the DB for them to use them.. Added a private note on the subject to Caveman, but its been some number of hours, and figured, since I was confused, maybe it was a good idea to ask here too, so someone else looking for it can figure it out. The question is, how do you check on the value of a global, never mind use one correctly.
These are the relevant snips, from one of the NPCs in the quest line for Shar Vahl. While I know that some of the stuff I am doing may not be in live, its easy enough for someone to comment out the say event code for the stuff that isn't. I felt though that there where too many ways you could mess yourself up, from accidentally handing an item to someone that didn't have the return items code on them, to having nice people level you past level 10, then losing your body, with the needed items on it, before you get a chance to do the quest. At least one of the fixmes, for Bindarah is in the live, but missing from PEQ (and obscure enough I include a fix that is more sane).
Anyway. The problem is, from what I understand of the language, it should be working. So, either a) the global isn't being set, b) the globals are not available on these NPCs, or c) I screwed something up.
Here is the code from one of them:
Code:
## Changes by Kagehi.
## $Shar_Vahl_Cit tracks the steps you take to gain your initiate cloak.
## Since we don't want to hand people things that they can't normally get, or
## stuff they haven't earned, we need to track which stage in the quest they
## are at. 1 = Citizen Application. 2 = Cert. of Taxability, 3 = Stamped Cert.,
## 4 = Note to King Raja, 5 Note 'from' the king, 6 = Notarized Application
## and 7 = Initiate's Cloak.
sub EVENT_SAY {
if($text=~/Hail/i){
quest::say("Hail. are you here to assist with something specific or just looking for something to do.");}
##Non-canon, for fixmes if you lose certain items (which are needed for this quest line and others).
##No idea if Live does this now or not. If these do exist there, feel free to adjust it.
if($text=~/application/i && $Shar_Vahl_Cit == 1){
quest::say("Luckily for you someone found it.");
quest::summonitem(2873);}
if($text=~/cloak/i && $Shar_Vahl_Cit == 7){
quest::say("Someone found this under a table at the one of the pubs. Try not to lose it this time.");
quest::summonitem(2878);}
}
sub EVENT_ITEM {
if(plugin::check_handin(\%itemcount,18552 => 1)){
quest::say("Our newest instrumentalist arrives! You have grown strong in the safety of our city and it is time now for you to repay our society. The Jharin. keepers of our history. accept you and deem you to be worthy of our training. Take this application to Registrar Bindarah and return to me with proof of your citizenship.");
quest::say("I know that you may be nervous right now... after all. this should be a very exciting first step for you. If you happen to get lost while looking for the registrar. just ask one of the other citizens or guards for directions. They will most likely know where to find the place or person that you are looking for.");
## We don't care at this point who gives you the application, cloak, etc.
## Only later, when we get into class specific quests will the person you
## come to, in order to recover lost items, matter.
## Using "all npc, this player, and all zones", since some later stuff in
## the class quest lines, linked to the cloak, are in other zones, should we
## use this to track cloak progress as well.
quest::setglobal("Shar_Vahl_Cit",1,5,"F");
quest::summonitem("2873");
}
elsif (plugin::check_handin(\%itemcount, 2897 => 1)) {
quest::say("This item. by itself. means nothing to me.");
quest::say("$name. citizen of Shar Vahl. accept this cloak as a symbol of your loyalty and service to our noble people. It will grow with you. young initiate. and like you it has incredible potential. Present your slate of citizenship to Gherik and he will guide you through your early training. May your songs inspire us all!");
quest::setglobal("Shar_Vahl_Cit",7,5,"F");
quest::summonitem("2878");
} else {
#do all other handins first with plugin, then let it do disciplines
plugin::try_tome_handins(\%itemcount, $class, 'Beastlord');
}
plugin::return_items(\%itemcount);
}
#END of FILE Zone:sharvahl ID:155166 -- Elder_Hymnist_Hortitosh
Relevant bits being ones like:
quest::setglobal("Shar_Vahl_Cit",1,5,"F");
and
if($text=~/application/i && $Shar_Vahl_Cit == 1){
I don't quite see where I messed up, though I do note some cases in other examples where people place extra () around things. In any case, the info on how to use globals isn't quite as clear as it should be imho, about which versions require what, and which things are needed, or not, like telling the DB that the NPC uses them, or not needing to do so. Could be I just badly misread that part.
---
Oh, BTW. As a side note, I presume that the server doesn't yet have something like quest::findnpc(<id>);? Luclin will need this, since one of its features was NPC awareness, where you could ask the guard where to find someone, including some not listed in the normal find, and the guards closest to them could activate a wisp, to lead you there. There doesn't seem to be any way at all to do that right now. :(