Same Item Turn for Changing Quest Globals - Need Help
So, I am trying to make a quest that will level characters by 1 level each time they turn in 4 ItemID 2835. I can't get it to work properly. I have 2 examples below which I have tried adjustments to, but neither seem to work properly.
First, I tried this script, which uses elsifs, but I haven't really used them much before so it is very possible there could be a mistake. This one does absolutely nothing if I turn in the items. In fact, it doesn't even return them. Code:
sub EVENT_ITEM { Code:
sub EVENT_ITEM { |
hmm could you try this - use the FIRST code sample, but replace "elseif"s with regular "if"s
if it works the way i understand it, it should produce chain leveling reaction =) |
Actually, I tried that first and it had the same effect as the elsif's, which was no effect.
|
Try adding $max_level=undef; in the script at the end.
|
Quote:
|
Why even use the globals in this case seems to be overkill?
a simple if level 70 and you turn in the item the npc does a #level 71 if level 71 and you turn in the items the npc does #level 72 etc etc dont feel like writing it up but you get the idea. |
Quote:
btw I consulted the popular "credit card" code, and it indeed uses things such as $max_level=undef; after each adjustment statement. I do not uderstand the processing logic behind it, but apperently this is how it supose to work |
Actually, in my real quest scripts, I do have:
Code:
{ The reason I want globals for this is mainly for my de-level quests. My server has quests to de-level characters to any level they want. Since my server's max level is 70, the quested levels have to be remembered so people can return to their previous level if it is higher than level 70. If I don't use globals on this quest, I will just have to use them on both different types of de-level quests (one is permanent and one is temporary). I figured I might as well define them here if possible. Also, in reply to Mattmeck; I have a feeling that if qglobals doesn't work when turning in 1 item and having multiple different requirements for the same hand in, I am willing to bet that checking for character level would have the same problem. I will test it tonight. But, I think the issue is with the item check, and it won't let it be checked again for the other IFs. Actually, maybe it is the plugin. Maybe I can try it without it, but those plugins are handy. |
2 Things that will make it work using the If statements.
1st, use different items for each handin. Using the SAME item each time for each level seems to confuse the program. If there is a way to clear the items after handing them in and setting the new setglobal, before the next if statememt, then it may work. To make it properly return the items if they are not correct, add a return;. Code:
else |
I'm SLOW but persistant... LOL
The following is working perfectly on my system.... As you can see, you only can have 1 if for the items and then do your multiple checks for the max_level. Even returns multiple incorrect items. Code:
sub EVENT_ITEM { |
Quote:
Then again, there looks to be a syntax error in the 1st set of code, which should do what you're trying to do: Code:
if (plugin::check_handin(\%itemcount, 2835=>4) { Code:
if (plugin::check_handin(\%itemcount, 2835=>4)) { Quote:
Code:
sub EVENT_ITEM { Code:
sub EVENT_ITEM { |
Thanks guys! I really appreciate the help! Turned out after all of that it was just that little typo that I missed a right parenthesis that AndMetal pointed out.
It is working now. The only problem I am still having is with it returning items after the player is at global 75. That isn't really a problem, since they won't have a use after that point anymore anyway. And I am pretty sure I can get it figured out on my own. |
The "handin" plug-in is a facility to check that a player gives the proper items, and consume them if it is the case. It should really be used as the last check in an "if" chain, as it performs a side-effect (removes the given items, they are given it is too late).
So you can probably avoid having the player "loose" the items by first checking for your max_level (and anything else), then when all conditions are fulfilled perform the hand-in. Basically you check that the PC fulfills the conditions for the hand-in, then you have the NPC accept the items. "accept-and-eat" would be a good description for the "handin". Another solution you have is to re-summon the given items in case you use "handin" first (gulp the items are eaten, only use with troll NPCs:D). Add a summonitem instruction with the item ID and 4 occurences. The "return_items" plugin does just that. Or if you want to make tests on the items given by the player before doing other tests (may be in some case you would like to), you can always return to the definition of the "handin" and use the "$itemcount" map, which associates given item IDs to the amount of items given. Remeber to check that an item has been given before checking its amount. You can even adjust the amount given as you want, in the same way "handin" works. For example you could use (from a silly quest I have been writing) : Code:
if(defined($itemcount{13078}) && $itemcount{13078} >= 4 # Summoned: Black Bread) |
I have a related question - how would you write a code for NPC to automaticly return anything given wihout checkign for specific item?
So far I only figured out how to do it by checking for item which does not even exist (id 1000), but there got to be way to do it simpler? Code:
sub EVENT_ITEM |
I do not know how other people do, but I use my little spoon.
OK silly reference to a joke about consultants, may be only known in France sorry :) More to the point I simply do : sub EVENT_ITEM { plugin::return_items(\%itemcount); } and it works. I saw in another thread it could be done as a default for all NPCs without quests (and may be it is in PEQ right now). |
All times are GMT -4. The time now is 10:58 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.