mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-12-18 17:01:20 +00:00
Add P_PlayerHasTeamFlag
This commit is contained in:
parent
bdc364f19e
commit
5eb7f09346
4 changed files with 37 additions and 17 deletions
|
@ -845,7 +845,6 @@ static int lib_pGetMobjGravity(lua_State *L)
|
||||||
static int lib_pWeaponOrPanel(lua_State *L)
|
static int lib_pWeaponOrPanel(lua_State *L)
|
||||||
{
|
{
|
||||||
mobjtype_t type = luaL_checkinteger(L, 1);
|
mobjtype_t type = luaL_checkinteger(L, 1);
|
||||||
//HUDSAFE
|
|
||||||
if (type >= NUMMOBJTYPES)
|
if (type >= NUMMOBJTYPES)
|
||||||
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
|
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
|
||||||
lua_pushboolean(L, P_WeaponOrPanel(type));
|
lua_pushboolean(L, P_WeaponOrPanel(type));
|
||||||
|
@ -855,9 +854,8 @@ static int lib_pWeaponOrPanel(lua_State *L)
|
||||||
static int lib_pGetTeamFlag(lua_State *L)
|
static int lib_pGetTeamFlag(lua_State *L)
|
||||||
{
|
{
|
||||||
int team = luaL_checkinteger(L, 1);
|
int team = luaL_checkinteger(L, 1);
|
||||||
if (team < 0 || team >= numteams)
|
if (team <= 0 || team >= numteams)
|
||||||
return luaL_error(L, "team index %d out of range (0 - %d)", team, numteams - 1);
|
return luaL_error(L, "team index %d out of range (1 - %d)", team, numteams - 1);
|
||||||
NOHUD
|
|
||||||
INLEVEL
|
INLEVEL
|
||||||
LUA_PushUserdata(L, P_GetTeamFlag(team), META_MOBJ);
|
LUA_PushUserdata(L, P_GetTeamFlag(team), META_MOBJ);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -866,9 +864,8 @@ static int lib_pGetTeamFlag(lua_State *L)
|
||||||
static int lib_pGetTeamFlagMapthing(lua_State *L)
|
static int lib_pGetTeamFlagMapthing(lua_State *L)
|
||||||
{
|
{
|
||||||
int team = luaL_checkinteger(L, 1);
|
int team = luaL_checkinteger(L, 1);
|
||||||
if (team < 0 || team >= numteams)
|
if (team <= 0 || team >= numteams)
|
||||||
return luaL_error(L, "team index %d out of range (0 - %d)", team, numteams - 1);
|
return luaL_error(L, "team index %d out of range (1 - %d)", team, numteams - 1);
|
||||||
NOHUD
|
|
||||||
INLEVEL
|
INLEVEL
|
||||||
LUA_PushUserdata(L, P_GetTeamFlagMapthing(team), META_MAPTHING);
|
LUA_PushUserdata(L, P_GetTeamFlagMapthing(team), META_MAPTHING);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1762,6 +1759,19 @@ static int lib_pPlayerShouldUseSpinHeight(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int lib_pPlayerHasTeamFlag(lua_State *L)
|
||||||
|
{
|
||||||
|
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||||
|
INT32 team = (INT32)luaL_checkinteger(L, 2);
|
||||||
|
INLEVEL
|
||||||
|
if (!player)
|
||||||
|
return LUA_ErrInvalid(L, "player_t");
|
||||||
|
if (team <= 0 || team >= numteams)
|
||||||
|
luaL_error(L, "team index %d out of range (1 - %d)", team, numteams-1);
|
||||||
|
lua_pushboolean(L, P_PlayerHasTeamFlag(player, team));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// P_MAP
|
// P_MAP
|
||||||
///////////
|
///////////
|
||||||
|
|
||||||
|
@ -2347,8 +2357,8 @@ static int lib_pMobjTouchingTeamBase(lua_State *L)
|
||||||
INLEVEL
|
INLEVEL
|
||||||
if (!mo)
|
if (!mo)
|
||||||
return LUA_ErrInvalid(L, "mobj_t");
|
return LUA_ErrInvalid(L, "mobj_t");
|
||||||
if (team <= 0 || team >= teamsingame)
|
if (team <= 0 || team >= numteams)
|
||||||
luaL_error(L, "team index %d out of range (1 - %d)", team, teamsingame-1);
|
luaL_error(L, "team index %d out of range (1 - %d)", team, numteams-1);
|
||||||
LUA_PushUserdata(L, P_MobjTouchingTeamBase(mo, team), META_SECTOR);
|
LUA_PushUserdata(L, P_MobjTouchingTeamBase(mo, team), META_SECTOR);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -2514,8 +2524,8 @@ static int lib_pTeamHasFlagAtBase(lua_State *L)
|
||||||
{
|
{
|
||||||
INT32 team = luaL_checkinteger(L, 1);
|
INT32 team = luaL_checkinteger(L, 1);
|
||||||
INLEVEL
|
INLEVEL
|
||||||
if (team <= 0 || team >= teamsingame)
|
if (team <= 0 || team >= numteams)
|
||||||
luaL_error(L, "team index %d out of range (1 - %d)", team, teamsingame-1);
|
luaL_error(L, "team index %d out of range (1 - %d)", team, numteams-1);
|
||||||
lua_pushboolean(L, P_TeamHasFlagAtBase(team));
|
lua_pushboolean(L, P_TeamHasFlagAtBase(team));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -3554,8 +3564,8 @@ static int lib_gAddGametype(lua_State *L)
|
||||||
if (idx >= 0 && idx < MAXTEAMS)
|
if (idx >= 0 && idx < MAXTEAMS)
|
||||||
{
|
{
|
||||||
int team_index = luaL_checkinteger(L, -1);
|
int team_index = luaL_checkinteger(L, -1);
|
||||||
if (team_index < 0 || team_index >= numteams)
|
if (team_index <= 0 || team_index >= numteams)
|
||||||
luaL_error(L, "team index %d out of range (0 - %d)", team_index, numteams-1);
|
luaL_error(L, "team index %d out of range (1 - %d)", team_index, numteams-1);
|
||||||
|
|
||||||
teamlist[idx] = (UINT8)team_index;
|
teamlist[idx] = (UINT8)team_index;
|
||||||
|
|
||||||
|
@ -4265,6 +4275,7 @@ static luaL_Reg lib[] = {
|
||||||
{"P_SwitchShield",lib_pSwitchShield},
|
{"P_SwitchShield",lib_pSwitchShield},
|
||||||
{"P_PlayerCanEnterSpinGaps",lib_pPlayerCanEnterSpinGaps},
|
{"P_PlayerCanEnterSpinGaps",lib_pPlayerCanEnterSpinGaps},
|
||||||
{"P_PlayerShouldUseSpinHeight",lib_pPlayerShouldUseSpinHeight},
|
{"P_PlayerShouldUseSpinHeight",lib_pPlayerShouldUseSpinHeight},
|
||||||
|
{"P_PlayerHasTeamFlag",lib_pPlayerHasTeamFlag},
|
||||||
|
|
||||||
// p_map
|
// p_map
|
||||||
{"P_CheckPosition",lib_pCheckPosition},
|
{"P_CheckPosition",lib_pCheckPosition},
|
||||||
|
|
|
@ -2043,8 +2043,8 @@ static int gametype_set(lua_State *L)
|
||||||
if (i >= 0 && i < MAXTEAMS)
|
if (i >= 0 && i < MAXTEAMS)
|
||||||
{
|
{
|
||||||
int team_index = luaL_checkinteger(L, -1);
|
int team_index = luaL_checkinteger(L, -1);
|
||||||
if (team_index < 0 || team_index >= numteams)
|
if (team_index <= 0 || team_index >= numteams)
|
||||||
luaL_error(L, "team index %d out of range (0 - %d)", team_index, numteams-1);
|
luaL_error(L, "team index %d out of range (1 - %d)", team_index, numteams-1);
|
||||||
|
|
||||||
gt->teams.list[i] = (UINT8)team_index;
|
gt->teams.list[i] = (UINT8)team_index;
|
||||||
|
|
||||||
|
@ -2415,8 +2415,8 @@ static int teamlist_set(lua_State *L)
|
||||||
int team = luaL_checkinteger(L, 3);
|
int team = luaL_checkinteger(L, 3);
|
||||||
if (i <= 0 || i > teamlist->num)
|
if (i <= 0 || i > teamlist->num)
|
||||||
return luaL_error(L, "array index %d out of range (1 - %d)", i, teamlist->num);
|
return luaL_error(L, "array index %d out of range (1 - %d)", i, teamlist->num);
|
||||||
if (team < 0 || team >= numteams)
|
if (team <= 0 || team >= numteams)
|
||||||
return luaL_error(L, "team index %d out of range (0 - %d)", team, numteams - 1);
|
return luaL_error(L, "team index %d out of range (1 - %d)", team, numteams - 1);
|
||||||
teamlist->list[i - 1] = (UINT8)team;
|
teamlist->list[i - 1] = (UINT8)team;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,6 +146,7 @@ void P_ForceLocalAngle(player_t *player, angle_t angle);
|
||||||
boolean P_PlayerFullbright(player_t *player);
|
boolean P_PlayerFullbright(player_t *player);
|
||||||
boolean P_PlayerCanEnterSpinGaps(player_t *player);
|
boolean P_PlayerCanEnterSpinGaps(player_t *player);
|
||||||
boolean P_PlayerShouldUseSpinHeight(player_t *player);
|
boolean P_PlayerShouldUseSpinHeight(player_t *player);
|
||||||
|
boolean P_PlayerHasTeamFlag(player_t *player, UINT8 team);
|
||||||
|
|
||||||
boolean P_IsObjectInGoop(mobj_t *mo);
|
boolean P_IsObjectInGoop(mobj_t *mo);
|
||||||
boolean P_IsObjectOnGround(mobj_t *mo);
|
boolean P_IsObjectOnGround(mobj_t *mo);
|
||||||
|
|
|
@ -13086,3 +13086,11 @@ boolean P_PlayerShouldUseSpinHeight(player_t *player)
|
||||||
&& player->dashmode >= DASHMODE_THRESHOLD && player->mo->state-states == S_PLAY_DASH)
|
&& player->dashmode >= DASHMODE_THRESHOLD && player->mo->state-states == S_PLAY_DASH)
|
||||||
|| JUMPCURLED(player));
|
|| JUMPCURLED(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean P_PlayerHasTeamFlag(player_t *player, UINT8 team)
|
||||||
|
{
|
||||||
|
if (!G_GametypeHasTeams() || team >= numteams)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return player->gotflag & teams[team].flag;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue