mirror of
https://github.com/yquake2/rogue.git
synced 2024-11-29 07:22:30 +00:00
Implemented coop_elevator_delay
cvar (for func_plat)
In coop it's often hard to get on the same elevator together, because they're immediately triggered once the first player steps on it. This cvar sets a delay (1 second by default) for the elevator to wait before moving, so other players have some time to get on it. If you like elevators/platforms that suck, just set it to `0` :-P Currently only used in func_plat, if it turns out that other entities are used for automatically triggered platforms, we'll have to adapt those as well (I guess wait_and_change() is generally useful for that). We're not bumping the savegame version because they should only break in an uncommon corner case: *Coop* savegames created with clients including this change will not work on older clients - SP savegames are not affected and old savegames on new clients also still work.
This commit is contained in:
parent
6820b0cad1
commit
9dfd9de811
6 changed files with 40 additions and 2 deletions
35
src/g_func.c
35
src/g_func.c
|
@ -664,6 +664,39 @@ Use_Plat(edict_t *ent, edict_t *other, edict_t *activator /* unused */)
|
||||||
plat_go_down(ent);
|
plat_go_down(ent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
wait_and_change_think(edict_t* ent)
|
||||||
|
{
|
||||||
|
void (*afterwaitfunc)(edict_t *) = ent->moveinfo.endfunc;
|
||||||
|
ent->moveinfo.endfunc = NULL;
|
||||||
|
afterwaitfunc(ent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In coop mode, this waits for coop_elevator_delay seconds
|
||||||
|
* before calling afterwaitfunc(ent); otherwise it just calls
|
||||||
|
* afterwaitfunc(ent);
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
wait_and_change(edict_t* ent, void (*afterwaitfunc)(edict_t *))
|
||||||
|
{
|
||||||
|
float waittime = coop_elevator_delay->value;
|
||||||
|
if (coop->value && waittime > 0.0f)
|
||||||
|
{
|
||||||
|
if(ent->nextthink == 0)
|
||||||
|
{
|
||||||
|
ent->moveinfo.endfunc = afterwaitfunc;
|
||||||
|
ent->think = wait_and_change_think;
|
||||||
|
ent->nextthink = level.time + waittime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
afterwaitfunc(ent);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Touch_Plat_Center(edict_t *ent, edict_t *other, cplane_t *plane /* unsed */,
|
Touch_Plat_Center(edict_t *ent, edict_t *other, cplane_t *plane /* unsed */,
|
||||||
csurface_t *surf /* unused */)
|
csurface_t *surf /* unused */)
|
||||||
|
@ -687,7 +720,7 @@ Touch_Plat_Center(edict_t *ent, edict_t *other, cplane_t *plane /* unsed */,
|
||||||
|
|
||||||
if (ent->moveinfo.state == STATE_BOTTOM)
|
if (ent->moveinfo.state == STATE_BOTTOM)
|
||||||
{
|
{
|
||||||
plat_go_up(ent);
|
wait_and_change(ent, plat_go_up);
|
||||||
}
|
}
|
||||||
else if (ent->moveinfo.state == STATE_TOP)
|
else if (ent->moveinfo.state == STATE_TOP)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,6 +23,7 @@ edict_t *g_edicts;
|
||||||
cvar_t *deathmatch;
|
cvar_t *deathmatch;
|
||||||
cvar_t *coop;
|
cvar_t *coop;
|
||||||
cvar_t *coop_baseq2; /* treat spawnflags according to baseq2 rules */
|
cvar_t *coop_baseq2; /* treat spawnflags according to baseq2 rules */
|
||||||
|
cvar_t *coop_elevator_delay;
|
||||||
cvar_t *coop_pickup_weapons;
|
cvar_t *coop_pickup_weapons;
|
||||||
cvar_t *dmflags;
|
cvar_t *dmflags;
|
||||||
cvar_t *skill;
|
cvar_t *skill;
|
||||||
|
|
|
@ -585,6 +585,7 @@ extern cvar_t *maxentities;
|
||||||
extern cvar_t *deathmatch;
|
extern cvar_t *deathmatch;
|
||||||
extern cvar_t *coop;
|
extern cvar_t *coop;
|
||||||
extern cvar_t *coop_baseq2; /* treat spawnflags according to baseq2 rules */
|
extern cvar_t *coop_baseq2; /* treat spawnflags according to baseq2 rules */
|
||||||
|
extern cvar_t *coop_elevator_delay;
|
||||||
extern cvar_t *coop_pickup_weapons;
|
extern cvar_t *coop_pickup_weapons;
|
||||||
extern cvar_t *dmflags;
|
extern cvar_t *dmflags;
|
||||||
extern cvar_t *skill;
|
extern cvar_t *skill;
|
||||||
|
|
|
@ -214,7 +214,8 @@ InitGame(void)
|
||||||
deathmatch = gi.cvar ("deathmatch", "0", CVAR_LATCH);
|
deathmatch = gi.cvar ("deathmatch", "0", CVAR_LATCH);
|
||||||
coop = gi.cvar ("coop", "0", CVAR_LATCH);
|
coop = gi.cvar ("coop", "0", CVAR_LATCH);
|
||||||
coop_baseq2 = gi.cvar ("coop_baseq2", "0", CVAR_LATCH);
|
coop_baseq2 = gi.cvar ("coop_baseq2", "0", CVAR_LATCH);
|
||||||
coop_pickup_weapons = gi.cvar("coop_pickup_weapons", "0", 0);
|
coop_elevator_delay = gi.cvar("coop_elevator_delay", "1.0", CVAR_ARCHIVE);
|
||||||
|
coop_pickup_weapons = gi.cvar("coop_pickup_weapons", "0", CVAR_ARCHIVE);
|
||||||
skill = gi.cvar ("skill", "1", CVAR_LATCH);
|
skill = gi.cvar ("skill", "1", CVAR_LATCH);
|
||||||
maxentities = gi.cvar ("maxentities", "1024", CVAR_LATCH);
|
maxentities = gi.cvar ("maxentities", "1024", CVAR_LATCH);
|
||||||
gamerules = gi.cvar ("gamerules", "0", CVAR_LATCH); //PGM
|
gamerules = gi.cvar ("gamerules", "0", CVAR_LATCH); //PGM
|
||||||
|
|
|
@ -1487,3 +1487,4 @@ extern void DBall_GameInit ( void ) ;
|
||||||
extern void DBall_SelectSpawnPoint ( edict_t * ent , vec3_t origin , vec3_t angles ) ;
|
extern void DBall_SelectSpawnPoint ( edict_t * ent , vec3_t origin , vec3_t angles ) ;
|
||||||
extern void DBall_ClientBegin ( edict_t * ent ) ;
|
extern void DBall_ClientBegin ( edict_t * ent ) ;
|
||||||
extern int DBall_CheckDMRules ( void ) ;
|
extern int DBall_CheckDMRules ( void ) ;
|
||||||
|
extern void wait_and_change_think(edict_t* ent);
|
||||||
|
|
|
@ -1488,4 +1488,5 @@
|
||||||
{"DBall_SelectSpawnPoint", (byte *)DBall_SelectSpawnPoint},
|
{"DBall_SelectSpawnPoint", (byte *)DBall_SelectSpawnPoint},
|
||||||
{"DBall_ClientBegin", (byte *)DBall_ClientBegin},
|
{"DBall_ClientBegin", (byte *)DBall_ClientBegin},
|
||||||
{"DBall_CheckDMRules", (byte *)DBall_CheckDMRules},
|
{"DBall_CheckDMRules", (byte *)DBall_CheckDMRules},
|
||||||
|
{"wait_and_change_think", (byte *)wait_and_change_think},
|
||||||
{0, 0}
|
{0, 0}
|
||||||
|
|
Loading…
Reference in a new issue