Hooks
static bool BeforeCvLuaUnit_lSetDamage(lua_State* L, int& result);static void AfterCvLuaUnit_lSetDamage(lua_State* L, int& result);static int ReplaceCvLuaUnit_lSetDamage(int (*original)(lua_State*), lua_State* L);CivRegisterBefore<CivHooks::CvLuaUnit_lSetDamage>(host, &BeforeCvLuaUnit_lSetDamage);CivRegisterAfter<CivHooks::CvLuaUnit_lSetDamage>(host, &AfterCvLuaUnit_lSetDamage);CivRegisterReplace<CivHooks::CvLuaUnit_lSetDamage>(host, &ReplaceCvLuaUnit_lSetDamage);
Code
3765//void setDamage(int iNewValue, int /*PlayerTypes*/ ePlayer, bNotifyEntity = true);3766int CvLuaUnit::lSetDamage(lua_State* L)3767{3768 CvUnit* pkUnit = GetInstance(L);3769 const int iNewValue = lua_tointeger(L, 2);3770 const PlayerTypes ePlayer = (lua_isnil(L, 3))? NO_PLAYER : (PlayerTypes)lua_tointeger(L, 3);3771 const bool bNotifyEntity = luaL_optint(L, 4, 1);37723773#if defined(MOD_API_UNIT_STATS)3774 pkUnit->setDamage(iNewValue, ePlayer, -1, bNotifyEntity);3775#else3776 pkUnit->setDamage(iNewValue, ePlayer, bNotifyEntity);3777#endif3778 return 0;3779}