mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-12-18 08:51:29 +00:00
Add P_GetTeamFlag and P_GetTeamFlagMapthing
This commit is contained in:
parent
313f224311
commit
87e18d410c
8 changed files with 60 additions and 14 deletions
|
@ -852,6 +852,28 @@ static int lib_pWeaponOrPanel(lua_State *L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int lib_pGetTeamFlag(lua_State *L)
|
||||
{
|
||||
int team = luaL_checkinteger(L, 1);
|
||||
if (team < 0 || team >= numteams)
|
||||
return luaL_error(L, "team index %d out of range (0 - %d)", team, numteams - 1);
|
||||
NOHUD
|
||||
INLEVEL
|
||||
LUA_PushUserdata(L, P_GetTeamFlag(team), META_MOBJ);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_pGetTeamFlagMapthing(lua_State *L)
|
||||
{
|
||||
int team = luaL_checkinteger(L, 1);
|
||||
if (team < 0 || team >= numteams)
|
||||
return luaL_error(L, "team index %d out of range (0 - %d)", team, numteams - 1);
|
||||
NOHUD
|
||||
INLEVEL
|
||||
LUA_PushUserdata(L, P_GetTeamFlagMapthing(team), META_MAPTHING);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_pFlashPal(lua_State *L)
|
||||
{
|
||||
player_t *pl = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
|
@ -4114,6 +4136,8 @@ static luaL_Reg lib[] = {
|
|||
{"P_MobjFlip",lib_pMobjFlip},
|
||||
{"P_GetMobjGravity",lib_pGetMobjGravity},
|
||||
{"P_WeaponOrPanel",lib_pWeaponOrPanel},
|
||||
{"P_GetTeamFlag",lib_pGetTeamFlag},
|
||||
{"P_GetTeamFlagMapthing",lib_pGetTeamFlagMapthing},
|
||||
{"P_FlashPal",lib_pFlashPal},
|
||||
{"P_GetClosestAxis",lib_pGetClosestAxis},
|
||||
{"P_SpawnParaloop",lib_pSpawnParaloop},
|
||||
|
|
|
@ -2386,7 +2386,7 @@ static int teamlist_set(lua_State *L)
|
|||
if (i <= 0 || i > teamlist->num)
|
||||
return luaL_error(L, "array index %d out of range (1 - %d)", i, teamlist->num);
|
||||
if (team < 0 || team >= numteams)
|
||||
return luaL_error(L, "team index %d out of range (0 - %d)", i, numteams - 1);
|
||||
return luaL_error(L, "team index %d out of range (0 - %d)", team, numteams - 1);
|
||||
teamlist->list[i - 1] = (UINT8)team;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -888,7 +888,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
|||
|
||||
player->gotflag |= teams[flagteam].flag;
|
||||
CONS_Printf(M_GetText("%s picked up the %s%s%c!\n"), plname, flagcolor, flagtext, 0x80);
|
||||
flagmobjs[flagteam] = NULL;
|
||||
P_SetTarget(&flagmobjs[flagteam], NULL);
|
||||
// code for dealing with abilities is handled elsewhere now
|
||||
break;
|
||||
}
|
||||
|
@ -4443,7 +4443,7 @@ void P_PlayerFlagBurst(player_t *player, boolean toss)
|
|||
}
|
||||
|
||||
// Pointers set for displaying time value and for consistency restoration.
|
||||
flagmobjs[team] = flag;
|
||||
P_SetTarget(&flagmobjs[team], flag);
|
||||
}
|
||||
|
||||
player->gotflag = 0;
|
||||
|
|
|
@ -336,6 +336,9 @@ SINT8 P_MobjFlip(mobj_t *mobj);
|
|||
fixed_t P_GetMobjGravity(mobj_t *mo);
|
||||
FUNCMATH boolean P_WeaponOrPanel(mobjtype_t type);
|
||||
|
||||
mobj_t *P_GetTeamFlag(UINT8 team);
|
||||
mapthing_t *P_GetTeamFlagMapthing(UINT8 team);
|
||||
|
||||
void P_CalcChasePostImg(player_t *player, camera_t *thiscam);
|
||||
boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled);
|
||||
|
||||
|
|
24
src/p_mobj.c
24
src/p_mobj.c
|
@ -10037,7 +10037,7 @@ static void P_FlagFuseThink(mobj_t *mobj)
|
|||
else if (players[consoleplayer].ctfteam != 0)
|
||||
S_StartSound(NULL, sfx_hoop3);
|
||||
|
||||
flagmobjs[team] = flagmo;
|
||||
P_SetTarget(&flagmobjs[team], flagmo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12069,7 +12069,7 @@ static boolean P_AllowMobjSpawn(mapthing_t* mthing, mobjtype_t i)
|
|||
UINT8 team = mobjinfo[i].mass;
|
||||
if (team >= numteams)
|
||||
return false;
|
||||
else if (flagmobjs[team])
|
||||
else if (flagmobjs[team] && !P_MobjWasRemoved(flagmobjs[team]))
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, M_GetText("Only one flag per team allowed in CTF!\n"));
|
||||
return false;
|
||||
|
@ -13171,11 +13171,11 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean
|
|||
}
|
||||
break;
|
||||
case MT_REDFLAG:
|
||||
flagmobjs[TEAM_RED] = mobj;
|
||||
P_SetTarget(&flagmobjs[TEAM_RED], mobj);
|
||||
flagpoints[TEAM_RED] = mobj->spawnpoint;
|
||||
break;
|
||||
case MT_BLUEFLAG:
|
||||
flagmobjs[TEAM_BLUE] = mobj;
|
||||
P_SetTarget(&flagmobjs[TEAM_BLUE], mobj);
|
||||
flagpoints[TEAM_BLUE] = mobj->spawnpoint;
|
||||
break;
|
||||
case MT_NIGHTSSTAR:
|
||||
|
@ -14185,3 +14185,19 @@ mobj_t *P_SpawnMobjFromMobj(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zo
|
|||
|
||||
return newmobj;
|
||||
}
|
||||
|
||||
mobj_t *P_GetTeamFlag(UINT8 team)
|
||||
{
|
||||
if (team >= teamsingame || P_MobjWasRemoved(flagmobjs[team]))
|
||||
return NULL;
|
||||
|
||||
return flagmobjs[team];
|
||||
}
|
||||
|
||||
mapthing_t *P_GetTeamFlagMapthing(UINT8 team)
|
||||
{
|
||||
if (team >= teamsingame)
|
||||
return NULL;
|
||||
|
||||
return flagpoints[team];
|
||||
}
|
||||
|
|
|
@ -3065,12 +3065,12 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker)
|
|||
|
||||
if (diff & MD_REDFLAG)
|
||||
{
|
||||
flagmobjs[TEAM_RED] = mobj;
|
||||
P_SetTarget(&flagmobjs[TEAM_RED], mobj);
|
||||
flagpoints[TEAM_RED] = mobj->spawnpoint;
|
||||
}
|
||||
if (diff & MD_BLUEFLAG)
|
||||
{
|
||||
flagmobjs[TEAM_BLUE] = mobj;
|
||||
P_SetTarget(&flagmobjs[TEAM_BLUE], mobj);
|
||||
flagpoints[TEAM_BLUE] = mobj->spawnpoint;
|
||||
}
|
||||
|
||||
|
|
|
@ -7040,7 +7040,7 @@ static void P_InitLevelSettings(void)
|
|||
// clear ctf pointers
|
||||
for (i = 0; i < MAXTEAMS; i++)
|
||||
{
|
||||
flagmobjs[i] = NULL;
|
||||
P_SetTarget(&flagmobjs[i], NULL);
|
||||
flagpoints[i] = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -2480,12 +2480,15 @@ static void ST_drawTeamHUD(void)
|
|||
}
|
||||
|
||||
// Display a countdown timer showing how much time left until the flag returns to base.
|
||||
if (LUA_HudEnabled(hud_teamscores))
|
||||
{
|
||||
if (flagmobjs[G_GetTeam(2)] && flagmobjs[G_GetTeam(2)]->fuse > 1 && LUA_HudEnabled(hud_teamscores))
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2 - SEP, 8, V_YELLOWMAP|V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, va("%u", (flagmobjs[G_GetTeam(2)]->fuse / TICRATE)));
|
||||
mobj_t *flagmobj = flagmobjs[G_GetTeam(2)];
|
||||
if (flagmobj && !P_MobjWasRemoved(flagmobj) && flagmobj->fuse > 1)
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2 - SEP, 8, V_YELLOWMAP|V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, va("%u", (flagmobj->fuse / TICRATE)));
|
||||
|
||||
if (flagmobjs[G_GetTeam(1)] && flagmobjs[G_GetTeam(1)]->fuse > 1 && LUA_HudEnabled(hud_teamscores))
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2 + SEP, 8, V_YELLOWMAP|V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, va("%u", (flagmobjs[G_GetTeam(1)]->fuse / TICRATE)));
|
||||
flagmobj = flagmobjs[G_GetTeam(1)];
|
||||
if (flagmobj && !P_MobjWasRemoved(flagmobj) && flagmobj->fuse > 1)
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2 + SEP, 8, V_YELLOWMAP|V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, va("%u", (flagmobj->fuse / TICRATE)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue