Constant Variables & Server Crash

Content and general development discussion, including maps, quests, and server code from the development team.
Post Reply
User avatar
chaslinux
Novice
Novice
Posts: 109
Joined: Sat Aug 08, 2009 2:57 am
Location: Kitchener, Ontario

Constant Variables & Server Crash

Post by chaslinux » Mon Dec 06, 2010 11:06 pm

Hi all. I wrote a couple of npc/*.txt's that both used the same constant variable: Pirate_quest. My server seemed to be fine with the first script, but when I added the second script the server(s) died. I checked and rechecked the second script, made a few changes, no luck. When I removed both scripts the server came alive again. I seem to have overloaded the constant variables. So I have 2 questions as a result:

1. Does a constant variable have to be declared in another file in order to pass between the two scripts safely?

2. Could I instead use one of the constants already defined in the game, just set it higher? (of course this takes the change of munging the other quests).

Cheers and thanks,

Tarq
User avatar
Freeyorp101
TMW Adviser
TMW Adviser
Posts: 703
Joined: Tue Nov 04, 2008 10:17 am
Location: New Zealand

Re: Constant Variables & Server Crash

Post by Freeyorp101 » Mon Dec 06, 2010 11:29 pm

tmwAthena has no concept of 'constant variables'. You can have script constants, defined in db/const.txt. Note that for non-core values the standard is to have constants in ALL_CAPS_WITH_UNDERSCORES.


---Freeyorp
(09:58:17) < tux9th> Freeyorp: your sig on the forums is kind of outdated
User avatar
chaslinux
Novice
Novice
Posts: 109
Joined: Sat Aug 08, 2009 2:57 am
Location: Kitchener, Ontario

Re: Constant Variables & Server Crash

Post by chaslinux » Tue Dec 07, 2010 12:31 am

Freeyorp101 wrote:tmwAthena has no concept of 'constant variables'. You can have script constants, defined in db/const.txt.
Would the combination of not having the variable defined in db/const.txt and used in 2 scripts have caused the server to crash?
User avatar
Freeyorp101
TMW Adviser
TMW Adviser
Posts: 703
Joined: Tue Nov 04, 2008 10:17 am
Location: New Zealand

Re: Constant Variables & Server Crash

Post by Freeyorp101 » Tue Dec 07, 2010 4:30 am

It's either a constant, or a variable, but not both. Please be more specific about what you are trying to do.


---Freeyorp
(09:58:17) < tux9th> Freeyorp: your sig on the forums is kind of outdated
User avatar
Crush
TMW Adviser
TMW Adviser
Posts: 8046
Joined: Thu Aug 25, 2005 5:08 pm
Location: Germany

Re: Constant Variables & Server Crash

Post by Crush » Tue Dec 07, 2010 11:44 am

I think what chaslinux means is not a constant variable but a persistent variable (one which is saved in the database), because he mentioned the variable name being "Pirate_quest", which has no prefix, which means that it is a persistent character-bound variable.
  • former Manasource Programmer
  • former TMW Pixel artist
  • NOT a game master

Please do not send me any inquiries regarding player accounts on TMW.


You might have heard a certain rumor about me. This rumor is completely false. You might also have heard the other rumor about me. This rumor is 100% accurate.
User avatar
chaslinux
Novice
Novice
Posts: 109
Joined: Sat Aug 08, 2009 2:57 am
Location: Kitchener, Ontario

Re: Constant Variables & Server Crash

Post by chaslinux » Tue Dec 07, 2010 9:17 pm

Crush wrote:I think what chaslinux means is not a constant variable but a persistent variable (one which is saved in the database), because he mentioned the variable name being "Pirate_quest", which has no prefix, which means that it is a persistent character-bound variable.
Thanks Crush, as you guys can see I'm not much of a programmer. Here's the code from both:

npc/001-1_Tulimshar/easton.txt

Code: Select all

//

001-1.gat,53,74,0       script Easton 138,{
//      set Pirate_quest,0;
        if (Pirate_quest >=4) goto L_doneit;
        if (Pirate_quest ==3) goto L_quest4;
        if (Pirate_quest ==2) goto L_quest3;
        if (Pirate_quest ==1) goto L_quest2;
        if (Pirate_quest <1) goto L_start;
        
        // If this happens something is wrong
        mes "Easton looks confused.";
        close;

L_start:
        set Pirate_quest, 0;
        mes "[Captain Easton]";
        mes "The crew need a good leave";
        mes "prove yer salt and bring ";
        mes "hither 1 coin purse and 500";
        mes "casino coins";
        menu "I have them Captain",-,"Not the now Captain",L_forgetit;
        if (countitem ("CoinBag") < 1 || countitem ("CasinoCoins") < 500) goto L_getmore;
        mes "Thank thee mate";
        set Pirate_quest, 1; 
        delitem "CoinBag",1;
        delitem "CasinoCoins",500;
        getexp 1000, 1;
close;
        
L_quest2:
        mes "[Captain Easton]";
        mes "Me first mate tells me";
        mes "the crew has contracted scurvy.";
        next;
        mes "Bring hither 50 Oranges, ";
        mes "100 Red Apples and 50 Cactus";
        mes "Potions";
        menu "Aye, aye, Captain",-,"Not the now Captain",L_forgetit; 
        if (countitem ("CactusPotion") < 50 || countitem ("RedApple") < 100 || countitem ("Orange") < 50) goto L_getmore;
        mes "[Captain Easton]";
        mes "Oh, I see these old eyes";
        mes "are failing me again, you";
        mes "have the cure for scurvy!";
        set Pirate_quest, 2;
        delitem "CactusPotion", 50;
        delitem "RedApple", 100;
        delitem "Orange", 50;
        set zeny,zeny+5000;
        getexp 3000, 1;
close;

L_quest3:
        mes "[Captain Easton]";
        mes "The figure-head and bowspirit";
        mes "of one of the fleet is no more";
        next;
        mes "Will ye fetch 100 logs and 2";
        mes "iron ingots for repairs?";
        menu "Yea Captain",-,"Not the now Captain",L_forgetit;
        if (countitem("RawLog") < 100 || countitem ("IngotIron")< 2) goto L_getmore;
        getinventorylist;
        if (@inventorylist_count==100) goto L_nospace;
        mes "Bless you, you have the";
        mes "repair materials!";
        set Pirate_quest, 3;
        delitem "RawLog", 100;
        delitem "IngotIron", 2;
        set zeny, zeny+10000;
        getexp 7000, 1;
        getitem 622, 1;
        mes "[Captain Easton]";
        mes "Take this mate's bandana as";
        mes "reward for all yer work";
close;

L_quest4:
        mes "[Cpatian Easton";
        mes "Ye have been a big help";
        mes "mate. There is one more ";
        mes "task ye may want to take.";
        next;
        mes "I'll warn ye now, most don't";
        mes "return.";
        next;
        mes "Ye will need to wear the";
        mes "bandana I gave ye and bear";
        mes "the mark of the Easton clain.";
        next;
        mes "We have an agent far west of ";
        mes "these lands. That agent is ";
        mes "inactive to those who don't";
        mes "wear crew gear and bear the";
        mes "mark of the Easton clan.";
        next;
        mes "If ye choose to be marked, the";
        mes "agent will be active for thee.";
        next;
        mes "The agent carries the key to";
        mes "tremendous treasure, but also";
        mes "bears the weight of a great";
        mes "curse!";
        next;
        mes "Decide now if ye want to be";
        mes "marked with the Easton mark?";
        menu "Yea",-,"Nea",L_forgetit;
        mes "bandana I gave ye and bear";
        mes "the mark of the Easton clain.";
        next;
        mes "We have an agent far west of ";
        mes "these lands. That agent is ";
        mes "inactive to those who don't";
        mes "wear crew gear and bear the";
        mes "mark of the Easton clan.";
        next;
        mes "If ye choose to be marked, the";
        mes "agent will be active for thee.";
        next;
        mes "The agent carries the key to";
        mes "tremendous treasure, but also";
        mes "bears the weight of a great";
        mes "curse!";
        next;
        mes "Decide now if ye want to be";
        mes "marked with the Easton mark?";
        menu "Yea",-,"Nea",L_forgetit;
        set Pirate_quest, 4;
        mes "Mate, welcome to the clan!";
        mes "Ye've been marked as one of";
        mes "our own. Seek out our agent.";
        mes "This experience should';
        mes "help thee.";
        next;
        getexp rand(50000)+1, 1; 
close;

L_nospace:
        mes "[Captain Easton]";
        mes "Ye need to free some space";
        mes "in yer inventory before ye";
        mes "get yer reward.";
close;

L_getmore:
        mes "[Captain Easton]";
        mes "Ya need more lad,";
        mes "now get thee gone.";
close;

L_forgetit:
        mes "[Captain Easton]";
        mes "Come back when yer ready.";
close;

L_doneit:
        mes "Thanks fer yer help. Our";
        mes "business here is done.";
close;
}
The above worked okay until I introduced the next script:

npc/028-1/khent.txt

Code: Select all

//
028-1.gat,50,44,0       script Khent 138,{
        if (Pirate_quest ==4) goto L_marked;
        set @TEMP, rand(12);
        if (@TEMP ==0) goto L_1;
        if (@TEMP ==1) goto L_2;
        if (@TEMP ==2) goto L_3;
        if (@TEMP ==3) goto L_4;
        if (@TEMP ==4) goto L_5;
        if (@TEMP ==5) goto L_6;
        if (@TEMP ==6) goto L_7;
        if (@TEMP ==7) goto L_8;
        if (@TEMP ==8) goto L_9;
        if (@TEMP ==9) goto L_10;
        if (@TEMP ==10) goto L_11;
        if (@TEMP ==11) goto L_12;

        mes "Something is wrong.";
close;

L_1:
        mes "[Khent]";
        mes "Just hanging loose with ";
        mes "these ghastly monsters.";
close;

L_2:
        mes "[Khent]";
        mes "I'm investigating the ";
        mes "hunting patterns of the";
        mes "Fallen.";
close;

L_3:
        mes "[Khent]";
        mes "For Wizardry you really";
        mes "should see Auldsbel.";
close;

L_4:
        mes "[Khent]";
        mes "I was once a young man,";
        mes "but I crossed the wrong";
        mes "people.";
close;

L_5:
        mes "[Khent]";
        mes "Did you know that ";
        mes "stalactites are full";
        mes "of minerals";
close;
L_6:
        mes "[Khent]";
        mes "Elanore is much more than";
        mes "she appears to be at first.";
close;

L_7:
        mes "[Khent]";
        mes "Even the dumbest novice";
        mes "can brew a 100 hp tiny";
        mes "potion.";
close;

L_8:
        mes "[Khent]";
        mes "I wish they opened Nivalis again";
close;

L_9:
        mes "[Khent]";
        mes "These parts are full of";
        mes "facinating creatures. Of ";
        mes "special interest are the";
        mes "spectres.";
close;

L_10:
        mes "[Khent]";
        mes "You didn't hear this from";
        mes "me, but I heard something";
        mes "about a legend sword.";
close;

L_11:
        mes "[Khent]";
        mes "Sea slimes are distant";
        mes "cousins to red slimes";
close;

L_marked:
        mes "[Khent]";
        mes "Fantastic! You're one";
        mes "of the Easton clan!";
        next;
        mes "I have a favour, but I";
        mes "hesitate to ask...";
        next;
        mes "We travelled far, Captain";
        mes "Easton and I. In fact I";
        mes "was once his young first mate";
        mes "but we stole treasure from";
        mes "a terrible undead sorceress.";
        next;
L_10:
        mes "[Khent]";
        mes "You didn't hear this from";
        mes "me, but I heard something";
        mes "about a legend sword.";
close;

L_11:
        mes "[Khent]";
        mes "Sea slimes are distant";
        mes "cousins to red slimes";
close;

L_marked:
        mes "[Khent]";
        mes "Fantastic! You're one";
        mes "of the Easton clan!";
        next;
        mes "I have a favour, but I";
        mes "hesitate to ask...";
        next;
        mes "We travelled far, Captain";
        mes "Easton and I. In fact I";
        mes "was once his young first mate";
        mes "but we stole treasure from";
        mes "a terrible undead sorceress.";
        next;
        mes "That woman cursed me with";
        mes "a terrible curse. Within me";
        mes "dwells the most terrifying";
        mes "monster...";
        next;
        mes "Death lives within me!";
        mes "The monster has cut down";
        mes "groups of adventurers";
        mes "before. Consider my request";
        mes "very closely -- your life";
        mes "depends on it";
        next;
        mes "Will you take on the";
        mes "deadly beast within me?";
        menu "Bring it on",-,"In the future",L_future;
        mes "Okay here goes...";
        next;
//      monster "this",0,0,"Reaper",1111,1;
close;

L_future:
        mes "[Khent]";
        mes "Sorry to hear that."
close;
}
The second script is unfinished. I disabled spawning the monster. When I introduced the second script the server crashed and would not come up even when I disabled the second script. I had to disable both this and the first script for he server to come back. So I was wondering if the persistent variable took up all my variable space or the problem was caused by the fact that I didn't define them in that db/const.txt file? Shouldn't be since it's a constant correct?

So if this is the case then would it be better to reuse the same persistent variable used in many of the Tulimshar quests? TMW_Quest I think it was.
alastrim
Novice
Novice
Posts: 137
Joined: Tue Jun 02, 2009 1:19 pm
Location: Brasil

Re: Constant Variables & Server Crash

Post by alastrim » Tue Dec 07, 2010 11:46 pm

You should try running "./mapserver" in terminal, this way you can see if there is any error in your script. Running this comand I could see the following errors:

Small error:

mes "This experience should';
should be
mes "This experience should";

Duplicated labels:

L_10, L_11 and L_marked
User avatar
chaslinux
Novice
Novice
Posts: 109
Joined: Sat Aug 08, 2009 2:57 am
Location: Kitchener, Ontario

Re: Constant Variables & Server Crash

Post by chaslinux » Wed Dec 08, 2010 12:31 am

alastrim wrote:You should try running "./mapserver" in terminal, this way you can see if there is any error in your script. Running this comand I could see the following errors:
This is my fault, the original scripts didn't have duplicate labels, I was cutting and pasting from vi and not paying enough attention. But I will try running mapserver, thanks for the tip!
Post Reply