Need help with XP script

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
The Unmaker
Posts: 139
Joined: Sun Mar 30, 2008 3:15 am
Location: Pete's World :D

Need help with XP script

Post by The Unmaker »

I am trying to put together an XP system for a mod i'm making and when i use puke to increase my XP it changes the level as well

Here is my script:

Code: Select all

// XP Scripts
global int 0:level;
global int 0:XP;
// XP Add Script
script 256 (int ADDXP)
{
log(s:"You Gained ", i:ADDXP, s:"!");
XP += ADDXP;
}

// LevelUp Script
script 257 enter
{
if(level < 100)
{
if(XP > level*level)
{
level++;
print(s:"You Are Now At Level ", i:level, s:"!");
}
}
else if(level == 100)
{
SetFont("BigFont");
print(s:"Congrantulations!\nYou are at the final level!");
SetFont("SMALLFONT");
}
delay(35);
restart;
}

// HUD Script
Script 258 enter
{
HudMessage(s:"Player ID: ", i:PlayerNumber(), s:"\nLevel: ", i:level, s:"\nXP: ", i:XP, s:"\nXP To next level: ", i:level*level; HUDMSG_PLAIN, 1, 3, 0.0, 0.0, 0.0);
delay(1);
restart;
}

script 259 (void)
{
print(i:XP);
}
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Re: Need help with XP script

Post by HotWax »

Um.. That's because that's the way you coded it.

level starts at 0, since you don't initialize it otherwise. 0 * 0 = 0, so any XP at all will level the player to level 1. Level 1's cap is an enormous 1 * 1 = 1 XP. So at 2 XP, they hit level 2. At 5 XP, they hit level 3. At 10 XP, they hit level 4. Etc...
User avatar
The Unmaker
Posts: 139
Joined: Sun Mar 30, 2008 3:15 am
Location: Pete's World :D

Re: Need help with XP script

Post by The Unmaker »

no...
when i use puke 256 the xp and level are the SAME
i.e.
if i use puke 256 70 the level becomes 70
and if i do that again it become 140 and by the level up rules that i have set it cannot do that

do you want a test wad?
User avatar
The Unmaker
Posts: 139
Joined: Sun Mar 30, 2008 3:15 am
Location: Pete's World :D

Re: Need help with XP script

Post by The Unmaker »

I just figured it out!

Global vars are referenced by number not name.

Thanks to randy for explaining it on this thread:http://forum.zdoom.org/viewtopic.php?f=3&t=17202

Expect the come back of The RPG!
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Re: Need help with XP script

Post by HotWax »

Ah. That's funny I didn't notice that since I had just got done posting about it in the thread you mentioned. Heh.
User avatar
The Unmaker
Posts: 139
Joined: Sun Mar 30, 2008 3:15 am
Location: Pete's World :D

Re: Need help with XP script

Post by The Unmaker »

Yes...

BTW What stage should i put a wad on the projects page
User avatar
Cutmanmike
Posts: 11353
Joined: Mon Oct 06, 2003 3:41 pm
Operating System Version (Optional): Windows 10
Location: United Kingdom
Contact:

Re: Need help with XP script

Post by Cutmanmike »

Projects page? Do you mean the forum or the wiki?
User avatar
The Unmaker
Posts: 139
Joined: Sun Mar 30, 2008 3:15 am
Location: Pete's World :D

Re: Need help with XP script

Post by The Unmaker »

Both?
prefebly the forum
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Re: Need help with XP script

Post by HotWax »

The Unmaker wrote:BTW What stage should i put a wad on the projects page
When you have some screenshots to show and a full description of what the finished product should be.

Basically the idea is to drum up interest from the community in your project. If all you have is a vague idea, most people won't be impressed.
User avatar
The Unmaker
Posts: 139
Joined: Sun Mar 30, 2008 3:15 am
Location: Pete's World :D

Re: Need help with XP script

Post by The Unmaker »

Yes i found that out last time
User avatar
Cutmanmike
Posts: 11353
Joined: Mon Oct 06, 2003 3:41 pm
Operating System Version (Optional): Windows 10
Location: United Kingdom
Contact:

Re: Need help with XP script

Post by Cutmanmike »

Gopher it! Neither of us are mods anyway so we can't do diddly if it's not up to scratch :P just make sure you have a screenshot or two to show and everyones happy.
User avatar
The Unmaker
Posts: 139
Joined: Sun Mar 30, 2008 3:15 am
Location: Pete's World :D

Re: Need help with XP script

Post by The Unmaker »

Cutmanmike wrote:Gopher it! Neither of us are mods anyway so we can't do diddly if it's not up to scratch :P just make sure you have a screenshot or two to show and everyones happy.
Thanks for teh support :wink:
Locked

Return to “Editing (Archive)”