- made intermission screen more scripting friendly.

This commit is contained in:
Christoph Oelckers 2017-02-24 00:28:33 +01:00
parent a1328b4c6e
commit 58be506a73
6 changed files with 100 additions and 35 deletions

View File

@ -154,8 +154,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, wbplayerstruct_t &h, w
{ {
if (arc.BeginObject(key)) if (arc.BeginObject(key))
{ {
arc("in", h.in) arc("kills", h.skills)
("kills", h.skills)
("items", h.sitems) ("items", h.sitems)
("secrets", h.ssecret) ("secrets", h.ssecret)
("time", h.stime) ("time", h.stime)

View File

@ -816,7 +816,6 @@ void G_DoCompleted (void)
for (i=0 ; i<MAXPLAYERS ; i++) for (i=0 ; i<MAXPLAYERS ; i++)
{ {
wminfo.plyr[i].in = playeringame[i];
wminfo.plyr[i].skills = players[i].killcount; wminfo.plyr[i].skills = players[i].killcount;
wminfo.plyr[i].sitems = players[i].itemcount; wminfo.plyr[i].sitems = players[i].itemcount;
wminfo.plyr[i].ssecret = players[i].secretcount; wminfo.plyr[i].ssecret = players[i].secretcount;

View File

@ -231,7 +231,7 @@ public:
int me; // wbs->pnum int me; // wbs->pnum
EState state; // specifies current state EState state; // specifies current state
wbstartstruct_t *wbs; // contains information passed into intermission wbstartstruct_t *wbs; // contains information passed into intermission
wbplayerstruct_t*plrs; // wbs->plyr[] wbplayerstruct_t* Plrs[MAXPLAYERS]; // wbs->plyr[]
int cnt; // used for general timing int cnt; // used for general timing
int bcnt; // used for timing of background animation int bcnt; // used for timing of background animation
int cnt_kills[MAXPLAYERS]; int cnt_kills[MAXPLAYERS];
@ -1192,12 +1192,12 @@ public:
if (playeringame[i] if (playeringame[i]
&& i!=playernum) && i!=playernum)
{ {
frags += plrs[playernum].frags[i]; frags += Plrs[playernum]->frags[i];
} }
} }
// JDC hack - negative frags. // JDC hack - negative frags.
frags -= plrs[playernum].frags[playernum]; frags -= Plrs[playernum]->frags[playernum];
return frags; return frags;
} }
@ -1225,9 +1225,9 @@ public:
{ {
for (j = 0; j < MAXPLAYERS; j++) for (j = 0; j < MAXPLAYERS; j++)
if (playeringame[j]) if (playeringame[j])
player_deaths[i] += plrs[j].frags[i]; player_deaths[i] += Plrs[j]->frags[i];
total_deaths += player_deaths[i]; total_deaths += player_deaths[i];
total_frags += plrs[i].fragcount; total_frags += Plrs[i]->fragcount;
} }
} }
} }
@ -1250,7 +1250,7 @@ public:
if (!playeringame[i]) if (!playeringame[i])
continue; continue;
cnt_frags[i] = plrs[i].fragcount; cnt_frags[i] = Plrs[i]->fragcount;
cnt_deaths[i] = player_deaths[i]; cnt_deaths[i] = player_deaths[i];
} }
S_Sound(CHAN_VOICE | CHAN_UI, "intermission/nextstage", 1, ATTN_NONE); S_Sound(CHAN_VOICE | CHAN_UI, "intermission/nextstage", 1, ATTN_NONE);
@ -1271,8 +1271,8 @@ public:
cnt_frags[i] += 2; cnt_frags[i] += 2;
if (cnt_frags[i] > plrs[i].fragcount) if (cnt_frags[i] > Plrs[i]->fragcount)
cnt_frags[i] = plrs[i].fragcount; cnt_frags[i] = Plrs[i]->fragcount;
else else
stillticking = true; stillticking = true;
} }
@ -1443,7 +1443,7 @@ public:
// Draw game time // Draw game time
y += height + CleanYfac; y += height + CleanYfac;
int seconds = Tics2Seconds(plrs[me].stime); int seconds = Tics2Seconds(Plrs[me]->stime);
int hours = seconds / 3600; int hours = seconds / 3600;
int minutes = (seconds % 3600) / 60; int minutes = (seconds % 3600) / 60;
seconds = seconds % 60; seconds = seconds % 60;
@ -1502,9 +1502,9 @@ public:
if (!playeringame[i]) if (!playeringame[i])
continue; continue;
cnt_kills[i] = plrs[i].skills; cnt_kills[i] = Plrs[i]->skills;
cnt_items[i] = plrs[i].sitems; cnt_items[i] = Plrs[i]->sitems;
cnt_secret[i] = plrs[i].ssecret; cnt_secret[i] = Plrs[i]->ssecret;
if (dofrags) if (dofrags)
cnt_frags[i] = WI_fragSum (i); cnt_frags[i] = WI_fragSum (i);
@ -1527,8 +1527,8 @@ public:
cnt_kills[i] += 2; cnt_kills[i] += 2;
if (cnt_kills[i] > plrs[i].skills) if (cnt_kills[i] > Plrs[i]->skills)
cnt_kills[i] = plrs[i].skills; cnt_kills[i] = Plrs[i]->skills;
else else
stillticking = true; stillticking = true;
} }
@ -1552,8 +1552,8 @@ public:
continue; continue;
cnt_items[i] += 2; cnt_items[i] += 2;
if (cnt_items[i] > plrs[i].sitems) if (cnt_items[i] > Plrs[i]->sitems)
cnt_items[i] = plrs[i].sitems; cnt_items[i] = Plrs[i]->sitems;
else else
stillticking = true; stillticking = true;
} }
@ -1577,8 +1577,8 @@ public:
cnt_secret[i] += 2; cnt_secret[i] += 2;
if (cnt_secret[i] > plrs[i].ssecret) if (cnt_secret[i] > Plrs[i]->ssecret)
cnt_secret[i] = plrs[i].ssecret; cnt_secret[i] = Plrs[i]->ssecret;
else else
stillticking = true; stillticking = true;
} }
@ -1794,10 +1794,10 @@ public:
sp_state = 10; sp_state = 10;
S_Sound (CHAN_VOICE | CHAN_UI, "intermission/nextstage", 1, ATTN_NONE); S_Sound (CHAN_VOICE | CHAN_UI, "intermission/nextstage", 1, ATTN_NONE);
cnt_kills[0] = plrs[me].skills; cnt_kills[0] = Plrs[me]->skills;
cnt_items[0] = plrs[me].sitems; cnt_items[0] = Plrs[me]->sitems;
cnt_secret[0] = plrs[me].ssecret; cnt_secret[0] = Plrs[me]->ssecret;
cnt_time = Tics2Seconds(plrs[me].stime); cnt_time = Tics2Seconds(Plrs[me]->stime);
cnt_par = wbs->partime / TICRATE; cnt_par = wbs->partime / TICRATE;
cnt_total_time = Tics2Seconds(wbs->totaltime); cnt_total_time = Tics2Seconds(wbs->totaltime);
} }
@ -1811,9 +1811,9 @@ public:
if (!(bcnt&3)) if (!(bcnt&3))
S_Sound (CHAN_VOICE | CHAN_UI, "intermission/tick", 1, ATTN_NONE); S_Sound (CHAN_VOICE | CHAN_UI, "intermission/tick", 1, ATTN_NONE);
} }
if (!gameinfo.intermissioncounter || cnt_kills[0] >= plrs[me].skills) if (!gameinfo.intermissioncounter || cnt_kills[0] >= Plrs[me]->skills)
{ {
cnt_kills[0] = plrs[me].skills; cnt_kills[0] = Plrs[me]->skills;
S_Sound (CHAN_VOICE | CHAN_UI, "intermission/nextstage", 1, ATTN_NONE); S_Sound (CHAN_VOICE | CHAN_UI, "intermission/nextstage", 1, ATTN_NONE);
sp_state++; sp_state++;
} }
@ -1827,9 +1827,9 @@ public:
if (!(bcnt&3)) if (!(bcnt&3))
S_Sound (CHAN_VOICE | CHAN_UI, "intermission/tick", 1, ATTN_NONE); S_Sound (CHAN_VOICE | CHAN_UI, "intermission/tick", 1, ATTN_NONE);
} }
if (!gameinfo.intermissioncounter || cnt_items[0] >= plrs[me].sitems) if (!gameinfo.intermissioncounter || cnt_items[0] >= Plrs[me]->sitems)
{ {
cnt_items[0] = plrs[me].sitems; cnt_items[0] = Plrs[me]->sitems;
S_Sound (CHAN_VOICE | CHAN_UI, "intermission/nextstage", 1, ATTN_NONE); S_Sound (CHAN_VOICE | CHAN_UI, "intermission/nextstage", 1, ATTN_NONE);
sp_state++; sp_state++;
} }
@ -1843,9 +1843,9 @@ public:
if (!(bcnt&3)) if (!(bcnt&3))
S_Sound (CHAN_VOICE | CHAN_UI, "intermission/tick", 1, ATTN_NONE); S_Sound (CHAN_VOICE | CHAN_UI, "intermission/tick", 1, ATTN_NONE);
} }
if (!gameinfo.intermissioncounter || cnt_secret[0] >= plrs[me].ssecret) if (!gameinfo.intermissioncounter || cnt_secret[0] >= Plrs[me]->ssecret)
{ {
cnt_secret[0] = plrs[me].ssecret; cnt_secret[0] = Plrs[me]->ssecret;
S_Sound (CHAN_VOICE | CHAN_UI, "intermission/nextstage", 1, ATTN_NONE); S_Sound (CHAN_VOICE | CHAN_UI, "intermission/nextstage", 1, ATTN_NONE);
sp_state++; sp_state++;
} }
@ -1862,7 +1862,7 @@ public:
cnt_total_time += 3; cnt_total_time += 3;
} }
int sec = Tics2Seconds(plrs[me].stime); int sec = Tics2Seconds(Plrs[me]->stime);
if (!gameinfo.intermissioncounter || cnt_time >= sec) if (!gameinfo.intermissioncounter || cnt_time >= sec)
cnt_time = sec; cnt_time = sec;
@ -2141,7 +2141,7 @@ public:
acceleratestage = 0; acceleratestage = 0;
cnt = bcnt = 0; cnt = bcnt = 0;
me = wbs->pnum; me = wbs->pnum;
plrs = wbs->plyr; for (int i = 0; i < 8; i++) Plrs[i] = &wbs->plyr[i];
} }
void WI_Start (wbstartstruct_t *wbstartstruct) void WI_Start (wbstartstruct_t *wbstartstruct)
@ -2180,3 +2180,27 @@ void WI_Start(wbstartstruct_t *wbstartstruct)
{ {
WI_Screen.WI_Start(wbstartstruct); WI_Screen.WI_Start(wbstartstruct);
} }
DEFINE_FIELD_X(WBPlayerStruct, wbplayerstruct_t, skills);
DEFINE_FIELD_X(WBPlayerStruct, wbplayerstruct_t, sitems);
DEFINE_FIELD_X(WBPlayerStruct, wbplayerstruct_t, ssecret);
DEFINE_FIELD_X(WBPlayerStruct, wbplayerstruct_t, stime);
DEFINE_FIELD_X(WBPlayerStruct, wbplayerstruct_t, frags);
DEFINE_FIELD_X(WBPlayerStruct, wbplayerstruct_t, fragcount);
DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, finished_ep);
DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, next_ep);
DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, current);
DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, next);
DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, LName0);
DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, LName1);
DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, maxkills);
DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, maxitems);
DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, maxsecret);
DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, maxfrags);
DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, partime);
DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, sucktime);
DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, totaltime);
DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, pnum);
DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, plyr);

View File

@ -32,8 +32,6 @@ class FTexture;
// //
struct wbplayerstruct_t struct wbplayerstruct_t
{ {
bool in; // whether the player is in game
// Player stats, kills, collected items etc. // Player stats, kills, collected items etc.
int skills; int skills;
int sitems; int sitems;

View File

@ -25,6 +25,8 @@
#include "zscript/menu/readthis.txt" #include "zscript/menu/readthis.txt"
#include "zscript/menu/conversationmenu.txt" #include "zscript/menu/conversationmenu.txt"
#include "zscript/statscreen/types.txt"
#include "zscript/inventory/inventory.txt" #include "zscript/inventory/inventory.txt"
#include "zscript/inventory/inv_misc.txt" #include "zscript/inventory/inv_misc.txt"
#include "zscript/inventory/stateprovider.txt" #include "zscript/inventory/stateprovider.txt"

View File

@ -0,0 +1,43 @@
//
// INTERMISSION
// Structure passed e.g. to WI_Start(wb)
//
struct WBPlayerStruct native
{
// Player stats, kills, collected items etc.
native int skills;
native int sitems;
native int ssecret;
native int stime;
native int frags[MAXPLAYERS];
native int fragcount; // [RH] Cumulative frags for this player
}
struct WBStartStruct native
{
native int finished_ep;
native int next_ep;
native String current; // [RH] Name of map just finished
native String next; // next level, [RH] actual map name
native TextureID LName0;
native TextureID LName1;
native int maxkills;
native int maxitems;
native int maxsecret;
native int maxfrags;
// the par time and sucktime
native int partime; // in tics
native int sucktime; // in minutes
// total time for the entire current game
native int totaltime;
// index of this player in game
native int pnum;
}