From 2f3e4c3c65c1287a6aab4a3c5587da58ca4323b6 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Mon, 29 May 2017 22:18:02 +0100 Subject: [PATCH] * Per Mystic's request, made lives for 100 rings individual. * P_GiveCoopLives bundles the coop lives reward for everyone versus reward for one person in other gametypes thing into one function. Available in Lua. --- src/lua_baselib.c | 14 ++++++++++++++ src/p_enemy.c | 20 +------------------- src/p_local.h | 1 + src/p_user.c | 42 +++++++++++++++++++++++++----------------- 4 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 93f2979fa..025b7fe0d 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -978,6 +978,19 @@ static int lib_pGivePlayerLives(lua_State *L) return 0; } +static int lib_pGiveCoopLives(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + INT32 numlives = (INT32)luaL_checkinteger(L, 2); + boolean sound = (boolean)lua_opttrueboolean(L, 3); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + P_GiveCoopLives(player, numlives, sound); + return 0; +} + static int lib_pResetScore(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -2428,6 +2441,7 @@ static luaL_Reg lib[] = { {"P_SpawnGhostMobj",lib_pSpawnGhostMobj}, {"P_GivePlayerRings",lib_pGivePlayerRings}, {"P_GivePlayerLives",lib_pGivePlayerLives}, + {"P_GiveCoopLives",lib_pGiveCoopLives}, {"P_ResetScore",lib_pResetScore}, {"P_DoJumpShield",lib_pDoJumpShield}, {"P_DoBubbleBounce",lib_pDoBubbleBounce}, diff --git a/src/p_enemy.c b/src/p_enemy.c index b206a7c89..c0451adf3 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3285,25 +3285,7 @@ void A_ExtraLife(mobj_t *actor) P_PlayLivesJingle(player); } else - { - if (!((netgame || multiplayer) && gametype == GT_COOP)) - { - P_GivePlayerLives(player, 1); - P_PlayLivesJingle(player); - } - else - { - INT32 i; - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i]) - continue; - - P_GivePlayerLives(&players[i], 1); - P_PlayLivesJingle(&players[i]); - } - } - } + P_GiveCoopLives(player, 1, true); } // Function: A_BombShield diff --git a/src/p_local.h b/src/p_local.h index 2cf6dbb98..f34ed1307 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -148,6 +148,7 @@ void P_SwitchShield(player_t *player, UINT16 shieldtype); mobj_t *P_SpawnGhostMobj(mobj_t *mobj); void P_GivePlayerRings(player_t *player, INT32 num_rings); void P_GivePlayerLives(player_t *player, INT32 numlives); +void P_GiveCoopLives(player_t *player, INT32 numlives, boolean sound); UINT8 P_GetNextEmerald(void); void P_GiveEmerald(boolean spawnObj); #if 0 diff --git a/src/p_user.c b/src/p_user.c index a3bb7e4b6..0be95e761 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -933,23 +933,8 @@ void P_GivePlayerRings(player_t *player, INT32 num_rings) if (gainlives) { - if (!((netgame || multiplayer) && gametype == GT_COOP)) - { - P_GivePlayerLives(player, gainlives); - P_PlayLivesJingle(player); - } - else - { - INT32 i; - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i]) - continue; - - P_GivePlayerLives(&players[i], gainlives); - P_PlayLivesJingle(&players[i]); - } - } + P_GivePlayerLives(player, gainlives); + P_PlayLivesJingle(player); } } } @@ -970,6 +955,29 @@ void P_GivePlayerLives(player_t *player, INT32 numlives) player->lives = 1; } +void P_GiveCoopLives(player_t player, INT32 numlives, boolean sound) +{ + if (!((netgame || multiplayer) && gametype == GT_COOP && cv_playstyle.value)) + { + P_GivePlayerLives(player, 1); + if (sound) + P_PlayLivesJingle(player); + } + else + { + INT32 i; + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + + P_GivePlayerLives(&players[i], 1); + if (sound) + P_PlayLivesJingle(&players[i]); + } + } +} + // // P_DoSuperTransformation //