Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • 0
Vrencheco

Making leveling/xp scripts consistent throughout wad?

Question

I have made leveling/experience scripts in ACS and I am trying to make the following scenario possible:

 

*The player leaves MAP, a script saves the player's current xp and level

*Player enters new MAP, a script gives the player the xp and level that they had ended the previous level with.

 

I have been told that I can use UNLOADING to save those values, and ENTER to grant them to the player. But I am not sure how to go about doing that.

Share this post


Link to post

8 answers to this question

Recommended Posts

  • 0

Yes , they do work . UNLOADING excecutes the script 1 tic before leaving the map and ENTER executes when you enter a map.

Edited by Dude27th : wait a second

Share this post


Link to post
  • 0

Do you want to save points after starting a new game or between switching maps ?
If you switch maps , like normal level progress you shouldn't have too much of a problem with that.

For example:

Actor ExperiencePoint : Inventory
{
    Inventory.MaxAmount 5000
}

 

This should be stored between levels without a problem.

 

Now, if you want instead , save your experience even after starting a new game , the only way I know you could do this is by storing it in a CVAR.
Which would be saved in the configuration document for gzdoom instead of your saved file.

Share this post


Link to post
  • 0
 
 
 
 
 
 
 
6
 Advanced issues found
 
 
6
18 hours ago, Dude27th said:

Do you want to save points after starting a new game or between switching maps ?
If you switch maps , like normal level progress you shouldn't have too much of a problem with that.

For example:

Actor ExperiencePoint : Inventory
{
    Inventory.MaxAmount 5000
}

 

This should be stored between levels without a problem.

 

Now, if you want instead , save your experience even after starting a new game , the only way I know you could do this is by storing it in a CVAR.
Which would be saved in the configuration document for gzdoom instead of your saved file.

 

Yeah I want to have it saved in between maps.

Problem is, the xp/leveling system is not an inventory item. It is within an ACS script which goes as follows:

 

#include "zcommon.acs"

int currentXP = 0;
int currentLevel = 1;

int xpToLevel[20] = { 0, 	
					 100,	//lvl 2
					 200,	//lvl 3
					 300,	//lvl 4
					 400,	//lvl 5
					 500,	//lvl 6
					 600,	//lvl 7
					 700,	//lvl 8
					 800,	//lvl 9
					 900,	//lvl 10
					1000,	//lvl 11
					1100,	//lvl 12
					1200,	//lvl 13
					1300,	//lvl 14
					1400, 	//lvl 15
					1500,	//lvl 16
					1600,	//lvl 17
					1700,	//lvl 18
					1800,	//lvl 19
					1900,	//lvl 20
					 };	

	 



script 1 (int amount)
{
	currentXP = currentXP + amount;
	HudMessage( d:amount, s:" XP"; HUDMSG_PLAIN, 3, CR_CYAN, 0.5, 0.9, 35);
	
	
	for (int i = 19; i >= currentLevel; i--)
	{
		if (currentXP >= xpToLevel[i])
		{
			Print(s:"YOU LEVELED UP!");
			currentLevel = i + 1;
			break;
		}
	}
	
	ACS_Execute(1, 0,0,0,0);
}

 

Share this post


Link to post
  • 0
10 hours ago, R4L said:

 

https://zdoom.org/wiki/Scope

 

Might just need to make your declarations global?

 

 

So it would look something like this?

 

global int 1: currentXP = 0;
global int 2: currentLevel = 1;

Putting this exactly as is gives me an error, however.

Share this post


Link to post
  • 0

It seems that you cannot asign immediately a valor for a global variable. By default they are '0'.
But you can asign them a valor if you use them inside a script like:
 

Script "LevelUp" (void)
{
 	currentLevel++;
}

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×