Vrencheco Posted July 24, 2019 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. 0 Share this post Link to post
0 Dude27th Posted July 25, 2019 (edited) Yes , they do work . UNLOADING excecutes the script 1 tic before leaving the map and ENTER executes when you enter a map. Edited July 25, 2019 by Dude27th : wait a second 0 Share this post Link to post
0 Dude27th Posted July 25, 2019 (edited) 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. 0 Share this post Link to post
0 Vrencheco Posted July 25, 2019 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); } 0 Share this post Link to post
0 Dude27th Posted July 26, 2019 I think that the valor of the variables don't carry on from one map to another 0 Share this post Link to post
0 Barry Burton Posted July 26, 2019 (edited) 11 hours ago, Dude27th said: I think that the valor of the variables don't carry on from one map to another https://zdoom.org/wiki/Scope Might just need to make your declarations global? 1 Share this post Link to post
0 Dude27th Posted July 26, 2019 Oh yeah , they work that way ! ... You can assign them directly a valor tho ? 0 Share this post Link to post
0 Vrencheco Posted July 26, 2019 (edited) 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. 0 Share this post Link to post
0 Dude27th Posted July 27, 2019 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++; } 0 Share this post Link to post
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