From 09e9e2ba4df083d64bda7bb3536a4115bde2d901 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Mon, 3 Dec 2018 20:28:07 -0500 Subject: [PATCH] Add player taunt functions to Lua People have REALLY wanted these for their scripts --- src/k_kart.c | 14 ++++----- src/k_kart.h | 7 +++++ src/lua_baselib.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 7 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index b462d961..1204253e 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1520,7 +1520,7 @@ void K_KartMoveAnimation(player_t *player) } } -static void K_TauntVoiceTimers(player_t *player) +void K_TauntVoiceTimers(player_t *player) { if (!player) return; @@ -1529,7 +1529,7 @@ static void K_TauntVoiceTimers(player_t *player) player->kartstuff[k_voices] = 4*TICRATE; } -static void K_RegularVoiceTimers(player_t *player) +void K_RegularVoiceTimers(player_t *player) { if (!player) return; @@ -1540,7 +1540,7 @@ static void K_RegularVoiceTimers(player_t *player) player->kartstuff[k_tauntvoices] = 4*TICRATE; } -static void K_PlayAttackTaunt(mobj_t *source) +void K_PlayAttackTaunt(mobj_t *source) { sfxenum_t pick = P_RandomKey(2); // Gotta roll the RNG every time this is called for sync reasons boolean tasteful = (!source->player || !source->player->kartstuff[k_tauntvoices]); @@ -1554,7 +1554,7 @@ static void K_PlayAttackTaunt(mobj_t *source) K_TauntVoiceTimers(source->player); } -static void K_PlayBoostTaunt(mobj_t *source) +void K_PlayBoostTaunt(mobj_t *source) { sfxenum_t pick = P_RandomKey(2); // Gotta roll the RNG every time this is called for sync reasons boolean tasteful = (!source->player || !source->player->kartstuff[k_tauntvoices]); @@ -1568,7 +1568,7 @@ static void K_PlayBoostTaunt(mobj_t *source) K_TauntVoiceTimers(source->player); } -static void K_PlayOvertakeSound(mobj_t *source) +void K_PlayOvertakeSound(mobj_t *source) { boolean tasteful = (!source->player || !source->player->kartstuff[k_voices]); @@ -1588,7 +1588,7 @@ static void K_PlayOvertakeSound(mobj_t *source) K_RegularVoiceTimers(source->player); } -static void K_PlayHitEmSound(mobj_t *source) +void K_PlayHitEmSound(mobj_t *source) { if (cv_kartvoices.value) S_StartSound(source, sfx_khitem); @@ -1598,7 +1598,7 @@ static void K_PlayHitEmSound(mobj_t *source) K_RegularVoiceTimers(source->player); } -static void K_PlayPowerGloatSound(mobj_t *source) +void K_PlayPowerGloatSound(mobj_t *source) { if (cv_kartvoices.value) S_StartSound(source, sfx_kgloat); diff --git a/src/k_kart.h b/src/k_kart.h index fed490db..c570fd58 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -24,6 +24,13 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid) void K_MatchGenericExtraFlags(mobj_t *mo, mobj_t *master); void K_RespawnChecker(player_t *player); void K_KartMoveAnimation(player_t *player); +void K_TauntVoiceTimers(player_t *player); +void K_RegularVoiceTimers(player_t *player); +void K_PlayAttackTaunt(player_t *player); +void K_PlayBoostTaunt(player_t *player); +void K_PlayOvertakeSound(player_t *player); +void K_PlayHitEmSound(player_t *player); +void K_PlayPowerGloatSound(player_t *player); void K_KartPlayerHUDUpdate(player_t *player); void K_KartPlayerThink(player_t *player, ticcmd_t *cmd); void K_KartPlayerAfterThink(player_t *player); diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 4d630d9e..c18f6d19 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -2442,6 +2442,76 @@ static int lib_kMomentumToFacing(lua_State *L) return 0; } +static int lib_kTauntVoiceTimers(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + NOHUD + if (!player) + return LUA_ErrInvalid(L, "player_t"); + K_TauntVoiceTimers(player); + return 0; +} + +static int lib_kRegularVoiceTimers(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + NOHUD + if (!player) + return LUA_ErrInvalid(L, "player_t"); + K_RegularVoiceTimers(player); + return 0; +} + +static int lib_kPlayAttackTaunt(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + NOHUD + if (!player) + return LUA_ErrInvalid(L, "player_t"); + K_PlayAttackTaunt(player); + return 0; +} + +static int lib_kPlayBoostTaunt(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + NOHUD + if (!player) + return LUA_ErrInvalid(L, "player_t"); + K_PlayBoostTaunt(player); + return 0; +} + +static int lib_kPlayOvertakeSound(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + NOHUD + if (!player) + return LUA_ErrInvalid(L, "player_t"); + K_PlayOvertakeSound(player); + return 0; +} + +static int lib_kPlayHitEmSound(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + NOHUD + if (!player) + return LUA_ErrInvalid(L, "player_t"); + K_PlayHitEmSound(player); + return 0; +} + +static int lib_kPlayPowerGloatSound(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + NOHUD + if (!player) + return LUA_ErrInvalid(L, "player_t"); + K_PlayPowerGloatSound(player); + return 0; +} + static int lib_kGetKartSpeed(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -2698,6 +2768,13 @@ static luaL_Reg lib[] = { {"K_StripItems",lib_kStripItems}, {"K_StripOther",lib_kStripOther}, {"K_MomentumToFacing",lib_kMomentumToFacing}, + {"K_TauntVoiceTimers",lib_kTauntVoiceTimers}, + {"K_RegularVoiceTimers",lib_kRegularVoiceTimers}, + {"K_PlayAttackTaunt",lib_kPlayAttackTaunt}, + {"K_PlayBoostTaunt",lib_kPlayBoostTaunt}, + {"K_PlayOvertakeSound",lib_kPlayOvertakeSound}, + {"K_PlayHitEmSound",lib_kPlayHitEmSound}, + {"K_PlayPowerGloatSound",lib_kPlayPowerGloatSound}, {"K_GetKartSpeed",lib_kGetKartSpeed}, {"K_GetKartAccel",lib_kGetKartAccel}, {"K_GetKartFlashing",lib_kGetKartFlashing},