Page 1 of 1

Quest done already?

Posted: 26 Nov 2010, 20:51
by chaslinux
So I've created a simple eAthena NPC script. What I'm unclear about is setting the correct kind of variable to track whether the player has completed the quest yet or not. Here's the script:

Code: Select all

//

001-1.gat,53,74,0       script Blackbeard 138,{
        mes "[Captain Blackbeard]";
        mes "\"Me first mate tells me\"";
        mes "\"the crew has contracted scurvy.\"";
        next;
        mes "\"Bring hither 5 Oranges, \"";
        mes "\"10 Red Apples and 5 Cactus \"";
        mes "\"Potions\"";
        menu "Aye, aye, Captain",-,"Forget it",L_forgetit; 
        if (countitem ("CactusPotion") < 5 && countitem ("RedApple") < 10 && countitem ("Orange") < 5) goto L_getmore;
        mes "[Captain Blackbeard]";
        mes "\"Oh, I see these old eyes \"";
        mes "\"are failing me again, you \"";
        mes "\"have the cure for scurvy! \"";
        delitem "CactusPotion", 5;
        delitem "RedApple", 10;
        delitem "Orange", 5;
        set zeny,zeny+5000;
        getexp 3000, 1;
        close;

L_getmore:
        mes "[Captain Blackbeard]";
        mes "\"Good, now get the gone.\"";
close;

L_forgetit:
        mes "[Captain Blackbeard]";
        mes "\"May the dead curse yer soul\"";
        next;
                warp "027-1.gat",81,56;
close;
}

Re: Quest done already?

Posted: 26 Nov 2010, 23:23
by alastrim
You can create a permanent variable, like "Quest_Blackbeard", when the player brings all the items, using

Code: Select all

set Quest_Blackbeard, 1;
In this way you can be sure when a player did not do the quest (Quest_Blackbeard = 0). It works, but is not the best way to do this, because there is a limit of 96 permanent variables a character can store.

Using bitmask or keeping the same variable to multiple quests seems to be better. In this topic Acegi posted an example script on bitmask, maybe it can be useful:
http://forums.themanaworld.org/viewtopi ... 13&t=11369

Maybe you should use "||"(or), instead of "&&"(and) in this line in your script:

Code: Select all

 if (countitem ("CactusPotion") < 5 && countitem ("RedApple") < 10 && countitem ("Orange") < 5) goto L_getmore;

Re: Quest done already?

Posted: 26 Nov 2010, 23:52
by Crush
The scope of variables in eAthena depends on the prefix:

varname: A character variable
@varname: A non-persistent character variable (does not survive a server restart but doesn't waste the 96 variables limit either)
#varname: An account variable (is the same for all characters of an account)
$varname: A global variable (is the same for every character on the server)

More information about variables can be found here:
http://eathena.ws/wiki/index.php/Variables

Re: Quest done already?

Posted: 27 Nov 2010, 01:18
by Freeyorp101
I wonder if people would set their save point in Tulimshar and simply use it as means to quickly get to the graveyard when you have such a warp for turning down the quest.

Also note that the version of eAthena our tmwAthena was based on differs from mainline eAthena in a number of places regarding variable notation. For instance, there are no npc scoped variables, there is no postfix required for arrays.

---Freeyorp

Re: Quest done already?

Posted: 27 Nov 2010, 11:27
by chaslinux
Freeyorp101 wrote:I wonder if people would set their save point in Tulimshar and simply use it as means to quickly get to the graveyard when you have such a warp for turning down the quest.
Which is why the counter gets added so it can only happen once.

Re: Quest done already?

Posted: 27 Nov 2010, 11:38
by chaslinux
Thanks everyone this is all helpful.

Re: Quest done already?

Posted: 27 Nov 2010, 18:47
by Kage
Crush wrote:The scope of variables in eAthena depends on the prefix:

varname: A character variable
@varname: A non-persistent character variable (does not survive a server restart but doesn't waste the 96 variables limit either)
#varname: An account variable (is the same for all characters of an account)
$varname: A global variable (is the same for every character on the server)

More information about variables can be found here:
http://eathena.ws/wiki/index.php/Variables
You also have

$@varname: A non-persistent global variable.