mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-20 18:01:16 +00:00
Merge conflicts 4d22b9f17
This commit is contained in:
parent
4d22b9f17f
commit
0f4eb4fab9
3 changed files with 68 additions and 29 deletions
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2012-2016 by John "JTE" Muniz.
|
||||
// Copyright (C) 2012-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 2012-2021 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -68,6 +68,8 @@ automatically.
|
|||
X (GameQuit),\
|
||||
X (PlayerCmd),/* building the player's ticcmd struct (Ported from SRB2Kart) */\
|
||||
X (MusicChange),\
|
||||
X (PlayerHeight),/* override player height */\
|
||||
X (PlayerCanEnterSpinGaps),\
|
||||
|
||||
#define STRING_HOOK_LIST(X) \
|
||||
X (BotAI),/* B_BuildTailsTiccmd by skin name */\
|
||||
|
@ -124,3 +126,5 @@ int LUA_HookSeenPlayer(player_t *player, player_t *seenfriend);
|
|||
int LUA_HookShouldJingleContinue(player_t *, const char *musname);
|
||||
int LUA_HookPlayerCmd(player_t *, ticcmd_t *);
|
||||
int LUA_HookMusicChange(const char *oldname, struct MusicChange *);
|
||||
fixed_t LUA_HookPlayerHeight(player_t *player);
|
||||
int LUA_HookPlayerCanEnterSpinGaps(player_t *player);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2012-2016 by John "JTE" Muniz.
|
||||
// Copyright (C) 2012-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 2012-2021 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -231,7 +231,7 @@ typedef struct Hook_State Hook_State;
|
|||
typedef void (*Hook_Callback)(Hook_State *);
|
||||
|
||||
struct Hook_State {
|
||||
int status;/* return status to calling function */
|
||||
INT32 status;/* return status to calling function */
|
||||
void * userdata;
|
||||
int hook_type;
|
||||
mobjtype_t mobj_type;/* >0 if mobj hook */
|
||||
|
@ -1005,13 +1005,13 @@ static void res_musicchange(Hook_State *hook)
|
|||
if (lua_isboolean(gL, -4))
|
||||
*musicchange->looping = lua_toboolean(gL, -4);
|
||||
// output 4: position override
|
||||
if (lua_isboolean(gL, -3))
|
||||
if (lua_isnumber(gL, -3))
|
||||
*musicchange->position = lua_tonumber(gL, -3);
|
||||
// output 5: prefadems override
|
||||
if (lua_isboolean(gL, -2))
|
||||
if (lua_isnumber(gL, -2))
|
||||
*musicchange->prefadems = lua_tonumber(gL, -2);
|
||||
// output 6: fadeinms override
|
||||
if (lua_isboolean(gL, -1))
|
||||
if (lua_isnumber(gL, -1))
|
||||
*musicchange->fadeinms = lua_tonumber(gL, -1);
|
||||
}
|
||||
|
||||
|
@ -1052,3 +1052,38 @@ int LUA_HookMusicChange(const char *oldname, struct MusicChange *param)
|
|||
|
||||
return hook.status;
|
||||
}
|
||||
|
||||
static void res_playerheight(Hook_State *hook)
|
||||
{
|
||||
if (!lua_isnil(gL, -1))
|
||||
{
|
||||
fixed_t returnedheight = lua_tonumber(gL, -1);
|
||||
// 0 height has... strange results, but it's not problematic like negative heights are.
|
||||
// when an object's height is set to a negative number directly with lua, it's forced to 0 instead.
|
||||
// here, I think it's better to ignore negatives so that they don't replace any results of previous hooks!
|
||||
if (returnedheight >= 0)
|
||||
hook->status = returnedheight;
|
||||
}
|
||||
}
|
||||
|
||||
fixed_t LUA_HookPlayerHeight(player_t *player)
|
||||
{
|
||||
Hook_State hook;
|
||||
if (prepare_hook(&hook, -1, HOOK(PlayerHeight)))
|
||||
{
|
||||
LUA_PushUserdata(gL, player, META_PLAYER);
|
||||
call_hooks(&hook, 1, 1, res_playerheight);
|
||||
}
|
||||
return hook.status;
|
||||
}
|
||||
|
||||
int LUA_HookPlayerCanEnterSpinGaps(player_t *player)
|
||||
{
|
||||
Hook_State hook;
|
||||
if (prepare_hook(&hook, 0, HOOK(PlayerCanEnterSpinGaps)))
|
||||
{
|
||||
LUA_PushUserdata(gL, player, META_PLAYER);
|
||||
call_hooks(&hook, 1, 1, res_force);
|
||||
}
|
||||
return hook.status;
|
||||
}
|
||||
|
|
46
src/p_user.c
46
src/p_user.c
|
@ -1111,7 +1111,7 @@ boolean P_PlayerCanDamage(player_t *player, mobj_t *thing)
|
|||
return false;
|
||||
|
||||
{
|
||||
UINT8 shouldCollide = LUAh_PlayerCanDamage(player, thing);
|
||||
UINT8 shouldCollide = LUA_HookPlayerCanDamage(player, thing);
|
||||
if (P_MobjWasRemoved(thing))
|
||||
return false; // removed???
|
||||
if (shouldCollide == 1)
|
||||
|
@ -1594,7 +1594,7 @@ boolean P_EvaluateMusicStatus(UINT16 status, const char *musname)
|
|||
break;
|
||||
|
||||
case JT_OTHER: // Other state
|
||||
result = LUAh_ShouldJingleContinue(&players[i], musname);
|
||||
result = LUA_HookShouldJingleContinue(&players[i], musname);
|
||||
break;
|
||||
|
||||
case JT_NONE: // Null state
|
||||
|
@ -1860,7 +1860,7 @@ void P_SpawnShieldOrb(player_t *player)
|
|||
I_Error("P_SpawnShieldOrb: player->mo is NULL!\n");
|
||||
#endif
|
||||
|
||||
if (LUAh_ShieldSpawn(player))
|
||||
if (LUA_HookPlayer(player, HOOK(ShieldSpawn)))
|
||||
return;
|
||||
|
||||
if (player->powers[pw_shield] & SH_FORCE)
|
||||
|
@ -4583,7 +4583,7 @@ static void P_DoSpinAbility(player_t *player, ticcmd_t *cmd)
|
|||
|
||||
if (cmd->buttons & BT_SPIN)
|
||||
{
|
||||
if (LUAh_SpinSpecial(player))
|
||||
if (LUA_HookPlayer(player, HOOK(SpinSpecial)))
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5055,7 +5055,7 @@ static boolean P_PlayerShieldThink(player_t *player, ticcmd_t *cmd, mobj_t *lock
|
|||
}
|
||||
}
|
||||
}
|
||||
if ((!(player->charflags & SF_NOSHIELDABILITY)) && (cmd->buttons & BT_SPIN && !LUAh_ShieldSpecial(player))) // Spin button effects
|
||||
if ((!(player->charflags & SF_NOSHIELDABILITY)) && (cmd->buttons & BT_SPIN && !LUA_HookPlayer(player, HOOK(ShieldSpecial)))) // Spin button effects
|
||||
{
|
||||
// Force stop
|
||||
if ((player->powers[pw_shield] & ~(SH_FORCEHP|SH_STACK)) == SH_FORCE)
|
||||
|
@ -5179,7 +5179,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd)
|
|||
// and you don't have a shield, do it!
|
||||
P_DoSuperTransformation(player, false);
|
||||
}
|
||||
else if (!LUAh_JumpSpinSpecial(player))
|
||||
else if (!LUA_HookPlayer(player, HOOK(JumpSpinSpecial)))
|
||||
switch (player->charability)
|
||||
{
|
||||
case CA_THOK:
|
||||
|
@ -5252,7 +5252,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd)
|
|||
|
||||
if (cmd->buttons & BT_JUMP && !player->exiting && !P_PlayerInPain(player))
|
||||
{
|
||||
if (LUAh_JumpSpecial(player))
|
||||
if (LUA_HookPlayer(player, HOOK(JumpSpecial)))
|
||||
;
|
||||
// all situations below this require jump button not to be pressed already
|
||||
else if (player->pflags & PF_JUMPDOWN)
|
||||
|
@ -5287,7 +5287,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd)
|
|||
}*/
|
||||
else if (player->pflags & PF_JUMPED)
|
||||
{
|
||||
if (!LUAh_AbilitySpecial(player))
|
||||
if (!LUA_HookPlayer(player, HOOK(AbilitySpecial)))
|
||||
switch (player->charability)
|
||||
{
|
||||
case CA_THOK:
|
||||
|
@ -5480,7 +5480,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd)
|
|||
}
|
||||
else if (player->pflags & PF_THOKKED)
|
||||
{
|
||||
if (!LUAh_AbilitySpecial(player))
|
||||
if (!LUA_HookPlayer(player, HOOK(AbilitySpecial)))
|
||||
switch (player->charability)
|
||||
{
|
||||
case CA_FLY:
|
||||
|
@ -5503,7 +5503,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd)
|
|||
break;
|
||||
}
|
||||
}
|
||||
else if ((!(player->charflags & SF_NOSHIELDABILITY)) && ((player->powers[pw_shield] & SH_NOSTACK) == SH_WHIRLWIND && !player->powers[pw_super] && !LUAh_ShieldSpecial(player)))
|
||||
else if ((!(player->charflags & SF_NOSHIELDABILITY)) && ((player->powers[pw_shield] & SH_NOSTACK) == SH_WHIRLWIND && !player->powers[pw_super] && !LUA_HookPlayer(player, HOOK(ShieldSpecial))))
|
||||
P_DoJumpShield(player);
|
||||
}
|
||||
|
||||
|
@ -8653,7 +8653,7 @@ void P_MovePlayer(player_t *player)
|
|||
{
|
||||
boolean atspinheight = false;
|
||||
fixed_t oldheight = player->mo->height;
|
||||
fixed_t luaheight = LUAh_PlayerHeight(player);
|
||||
fixed_t luaheight = LUA_HookPlayerHeight(player);
|
||||
|
||||
if (luaheight != -1)
|
||||
{
|
||||
|
@ -10515,7 +10515,7 @@ boolean P_SpectatorJoinGame(player_t *player)
|
|||
else
|
||||
changeto = (P_RandomFixed() & 1) + 1;
|
||||
|
||||
if (!LUAh_TeamSwitch(player, changeto, true, false, false))
|
||||
if (!LUA_HookTeamSwitch(player, changeto, true, false, false))
|
||||
return false;
|
||||
|
||||
if (player->mo)
|
||||
|
@ -10532,7 +10532,7 @@ boolean P_SpectatorJoinGame(player_t *player)
|
|||
{
|
||||
// Call ViewpointSwitch hooks here.
|
||||
// The viewpoint was forcibly changed.
|
||||
LUAh_ViewpointSwitch(player, &players[consoleplayer], true);
|
||||
LUA_HookViewpointSwitch(player, &players[consoleplayer], true);
|
||||
displayplayer = consoleplayer;
|
||||
}
|
||||
|
||||
|
@ -10550,7 +10550,7 @@ boolean P_SpectatorJoinGame(player_t *player)
|
|||
// respawn in place and sit there for the rest of the round.
|
||||
if (!((gametyperules & GTR_HIDEFROZEN) && leveltime > (hidetime * TICRATE)))
|
||||
{
|
||||
if (!LUAh_TeamSwitch(player, 3, true, false, false))
|
||||
if (!LUA_HookTeamSwitch(player, 3, true, false, false))
|
||||
return false;
|
||||
if (player->mo)
|
||||
{
|
||||
|
@ -10577,7 +10577,7 @@ boolean P_SpectatorJoinGame(player_t *player)
|
|||
{
|
||||
// Call ViewpointSwitch hooks here.
|
||||
// The viewpoint was forcibly changed.
|
||||
LUAh_ViewpointSwitch(player, &players[consoleplayer], true);
|
||||
LUA_HookViewpointSwitch(player, &players[consoleplayer], true);
|
||||
displayplayer = consoleplayer;
|
||||
}
|
||||
|
||||
|
@ -11503,7 +11503,7 @@ void P_PlayerThink(player_t *player)
|
|||
}
|
||||
if (player->playerstate == PST_REBORN)
|
||||
{
|
||||
LUAh_PlayerThink(player);
|
||||
LUA_HookPlayer(player, HOOK(PlayerThink));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -11605,7 +11605,7 @@ void P_PlayerThink(player_t *player)
|
|||
|
||||
if (player->playerstate == PST_DEAD)
|
||||
{
|
||||
LUAh_PlayerThink(player);
|
||||
LUA_HookPlayer(player, HOOK(PlayerThink));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -11726,7 +11726,7 @@ void P_PlayerThink(player_t *player)
|
|||
{
|
||||
player->mo->flags2 &= ~MF2_SHADOW;
|
||||
P_DeathThink(player);
|
||||
LUAh_PlayerThink(player);
|
||||
LUA_HookPlayer(player, HOOK(PlayerThink));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -11768,7 +11768,7 @@ void P_PlayerThink(player_t *player)
|
|||
{
|
||||
if (P_SpectatorJoinGame(player))
|
||||
{
|
||||
LUAh_PlayerThink(player);
|
||||
LUA_HookPlayer(player, HOOK(PlayerThink));
|
||||
return; // player->mo was removed.
|
||||
}
|
||||
}
|
||||
|
@ -11873,7 +11873,7 @@ void P_PlayerThink(player_t *player)
|
|||
|
||||
if (!player->mo)
|
||||
{
|
||||
LUAh_PlayerThink(player);
|
||||
LUA_HookPlayer(player, HOOK(PlayerThink));
|
||||
return; // P_MovePlayer removed player->mo.
|
||||
}
|
||||
|
||||
|
@ -12327,7 +12327,7 @@ void P_PlayerThink(player_t *player)
|
|||
}
|
||||
#undef dashmode
|
||||
|
||||
LUAh_PlayerThink(player);
|
||||
LUA_HookPlayer(player, HOOK(PlayerThink));
|
||||
|
||||
/*
|
||||
// Colormap verification
|
||||
|
@ -12896,7 +12896,7 @@ void P_PlayerAfterThink(player_t *player)
|
|||
|
||||
if (player->followmobj)
|
||||
{
|
||||
if (LUAh_FollowMobj(player, player->followmobj) || P_MobjWasRemoved(player->followmobj))
|
||||
if (LUA_HookFollowMobj(player, player->followmobj) || P_MobjWasRemoved(player->followmobj))
|
||||
{;}
|
||||
else
|
||||
{
|
||||
|
@ -12975,7 +12975,7 @@ boolean P_PlayerFullbright(player_t *player)
|
|||
// returns true if the player can enter a sector that they could not if standing at their skin's full height
|
||||
boolean P_PlayerCanEnterSpinGaps(player_t *player)
|
||||
{
|
||||
UINT8 canEnter = LUAh_PlayerCanEnterSpinGaps(player);
|
||||
UINT8 canEnter = LUA_HookPlayerCanEnterSpinGaps(player);
|
||||
if (canEnter == 1)
|
||||
return true;
|
||||
else if (canEnter == 2)
|
||||
|
|
Loading…
Reference in a new issue