Code: Select all
inline int32 CLuaBaseEntity::addBardSong(lua_State *L)
{
DSP_DEBUG_BREAK_IF(m_PBaseEntity == NULL);
DSP_DEBUG_BREAK_IF(lua_isnil(L, 1) || !lua_isuserdata(L, 1));
DSP_DEBUG_BREAK_IF(lua_isnil(L, 2) || !lua_isnumber(L, 2));
DSP_DEBUG_BREAK_IF(lua_isnil(L, 3) || !lua_isnumber(L, 3));
DSP_DEBUG_BREAK_IF(lua_isnil(L, 4) || !lua_isnumber(L, 4));
DSP_DEBUG_BREAK_IF(lua_isnil(L, 5) || !lua_isnumber(L, 5));
DSP_DEBUG_BREAK_IF(lua_isnil(L, 6) || !lua_isnumber(L, 6));
DSP_DEBUG_BREAK_IF(lua_isnil(L, 7) || !lua_isnumber(L, 7));
DSP_DEBUG_BREAK_IF(lua_isnil(L, 8) || !lua_isnumber(L, 8));
int32 n = lua_gettop(L);
CLuaBaseEntity* PEntity = Lunar<CLuaBaseEntity>::check(L, 1);
CStatusEffect * PEffect = new CStatusEffect(
(EFFECT)lua_tointeger(L, 2),
(uint16)lua_tointeger(L, 2),
(uint16)lua_tointeger(L, 3),
(uint16)lua_tointeger(L, 4),
(uint16)lua_tointeger(L, 5),
(uint16)lua_tointeger(L, 6),
(uint16)lua_tointeger(L, 7),
(uint16)lua_tointeger(L, 8));
uint8 maxSongs = 2;
if (PEntity && PEntity->m_PBaseEntity && PEntity->m_PBaseEntity->objtype == TYPE_PC){
CCharEntity* PCaster = (CCharEntity*)PEntity->m_PBaseEntity;
CItemWeapon* PItem = (CItemWeapon*)PCaster->getEquip(SLOT_RANGED);
if (PItem == NULL || PItem->getID() == 65535 || !(PItem->getSkillType() == SKILL_STR || PItem->getSkillType() == SKILL_WND)){
maxSongs = 1;
}
maxSongs += PCaster->getMod(MOD_MAXIMUM_SONGS_BONUS);
}
lua_pushboolean(L, ((CBattleEntity*)m_PBaseEntity)->StatusEffectContainer->ApplyBardEffect(PEffect, maxSongs));
return 1;
}
**EDIT: Cleaned up the copy/paste mess to prevent eye bleeding for any devs looking at it...