ScoreItems and point persistence in LMS

Discuss all aspects related to modding Zandronum here.
Post Reply
User avatar
doomista
Forum Regular
Posts: 147
Joined: Sat Mar 07, 2015 6:58 pm
Location: I've been to hell. Twice

ScoreItems and point persistence in LMS

#1

Post by doomista » Sat Apr 30, 2016 11:16 am

Hi, I am trying to redone the LMS point system for needs of my own mod. But for some reason, ScoreItems do not work as they should. Also, I need to somehow make data persistent between rounds.

In my enter script, I give each player a unique TID:

Code: Select all

int player = PlayerNumber();
Thing_ChangeTID(0, PLAYERTID + player);
Each time player scores the code goes as it follows:

Code: Select all

points[player] += score;		// player = PlayerNumber()
GiveActorInventory(PLAYERTID + player, "ScoreItem", score);
Array of points has the proper values, but for some reason, ScoreItems do not (not even when I give them via GiveInventory, the activator of the script is also the player who should receive the points). When I check them with the CheckActorInventory, I always get 0.
This problem can be solved with the points array, but I also need to tackle something else. Each time a LMS round is over and the pointlimit is not hit, the COUNTDOWN phase kick in and after that the whole map and every script is unloaded and then OPEN and ENTER scripts are run. Since the point of the revamped point system is to work between rounds, I need to somehow save the player's score so it won't be zeroed.
As I intend to evaluate pointlimit hit in the COUNTDOWN phase (loop through player scores, check wheter the reached the cvar pointlimit and then Exit_Normal(0), in the OPEN script it should work even with the sv_noexit), I can safely zero the points right before I end the map manually.
I guess your general response would be "use cvar", but does cvar support arrays? I have no interest in copypasting switch statement for eight players not to mention this would be pretty stupid if the max number of the players should rise.

Thanks for help

User avatar
doomista
Forum Regular
Posts: 147
Joined: Sat Mar 07, 2015 6:58 pm
Location: I've been to hell. Twice

Re: ScoreItems and point persistence in LMS

#2

Post by doomista » Sat Apr 30, 2016 1:59 pm

Nevermind, I just found this topic http://forum.zdoom.org/viewtopic.php?f=3&t=22183, so now i have

Code: Select all

global int 0: points[];	
which works as intended. Now I have to figure out how to display this property on the result screen and the scoreboard

User avatar
SwordGrunt
Forum Regular
Posts: 377
Joined: Thu Jun 07, 2012 8:43 pm

Re: ScoreItems and point persistence in LMS

#3

Post by SwordGrunt » Sat Apr 30, 2016 3:28 pm

SBARINFO can supposedly display Global Variables (for each player, with the index of their player number) but it didn't work for me in Zandronum, so what I did was give each player an amount of dummy inventory items equal to their score to display that on the HUD.

I did practically the same thing you're looking for in Outcast's Terminator mode, for player scores. In UpdateHudTrackers() (function.acs), the player's inventory is constantly updated according to their score variable, which is increased every time they win a round. If one or more players hit the score limit, their names are displayed and the level exits shortly after instead of restarting (arnold.acs)

So if you want to do it this way, you'd need an ENTER script instead of an OPEN one that uses GiveActorInventory, with the advantage that you don't have to alter the players' TIDS (unless you're already doing that for other things; regardless, I prefer to always avoid changing player TIDs for compatibility with other mods, something I highly prioritize in my mod specifically).

User avatar
doomista
Forum Regular
Posts: 147
Joined: Sat Mar 07, 2015 6:58 pm
Location: I've been to hell. Twice

Re: ScoreItems and point persistence in LMS

#4

Post by doomista » Sun May 01, 2016 11:45 am

SwordGrunt wrote:SBARINFO can supposedly display Global Variables (for each player, with the index of their player number) but it didn't work for me in Zandronum, so what I did was give each player an amount of dummy inventory items equal to their score to display that on the HUD.

I did practically the same thing you're looking for in Outcast's Terminator mode, for player scores. In UpdateHudTrackers() (function.acs), the player's inventory is constantly updated according to their score variable, which is increased every time they win a round. If one or more players hit the score limit, their names are displayed and the level exits shortly after instead of restarting (arnold.acs)

So if you want to do it this way, you'd need an ENTER script instead of an OPEN one that uses GiveActorInventory, with the advantage that you don't have to alter the players' TIDS (unless you're already doing that for other things; regardless, I prefer to always avoid changing player TIDs for compatibility with other mods, something I highly prioritize in my mod specifically).
I am making a Shootmania Royal mod for Doom (SM Royal is a gamemode of game Shootmania Storm, it's from Nadeo, the same guys who made Trackmania). It isn't supposed to work with anything else (since the gameplay alterations are quite huge). Somehow, using variable declared as global in acs allowed me to get rid of player TIDs, but still there are other items that need their own TIDs, so collisions still can happen. Anyways, I have a different way of showing player score, so HUD displayment is not an issue. What I need is to show them during intermission (replace LMS original Wins, Frags, Player, Time and stuff) but that will be mainly just copypasting of zanxp scripts...

Post Reply