Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing method in MonsterSpell for outfits #4014

Merged
merged 1 commit into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions data/scripts/lib/register_monster_type.lua
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@ local function AbilityTableToSpell(ability)
if ability.shootEffect then
spell:setCombatShootEffect(ability.shootEffect)
end
local outfit = ability.outfit or ability.monster or ability.item
if outfit then
spell:setOutfit(outfit)
end
if ability.name == "drunk" then
spell:setConditionType(CONDITION_DRUNK)
if ability.drunkenness then
Expand Down
23 changes: 23 additions & 0 deletions src/luascript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3096,6 +3096,7 @@ void LuaScriptInterface::registerFunctions()
registerMethod("MonsterSpell", "setConditionTickInterval", LuaScriptInterface::luaMonsterSpellSetConditionTickInterval);
registerMethod("MonsterSpell", "setCombatShootEffect", LuaScriptInterface::luaMonsterSpellSetCombatShootEffect);
registerMethod("MonsterSpell", "setCombatEffect", LuaScriptInterface::luaMonsterSpellSetCombatEffect);
registerMethod("MonsterSpell", "setOutfit", LuaScriptInterface::luaMonsterSpellSetOutfit);

// Party
registerClass("Party", "", LuaScriptInterface::luaPartyCreate);
Expand Down Expand Up @@ -15192,6 +15193,28 @@ int LuaScriptInterface::luaMonsterSpellSetCombatEffect(lua_State* L)
return 1;
}

int LuaScriptInterface::luaMonsterSpellSetOutfit(lua_State* L)
{
// monsterSpell:setOutfit(outfit)
MonsterSpell* spell = getUserdata<MonsterSpell>(L, 1);
if (spell) {
if (isTable(L, 2)) {
spell->outfit = getOutfit(L, 2);
} else if (isNumber(L, 2)) {
spell->outfit.lookTypeEx = getNumber<uint16_t>(L, 2);
} else if (isString(L, 2)) {
MonsterType* mType = g_monsters.getMonsterType(getString(L, 2));
if (mType) {
spell->outfit = mType->info.outfit;
}
}
pushBoolean(L, true);
} else {
lua_pushnil(L);
}
return 1;
}

// Party
int32_t LuaScriptInterface::luaPartyCreate(lua_State* L)
{
Expand Down
1 change: 1 addition & 0 deletions src/luascript.h
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,7 @@ class LuaScriptInterface
static int luaMonsterSpellSetConditionTickInterval(lua_State* L);
static int luaMonsterSpellSetCombatShootEffect(lua_State* L);
static int luaMonsterSpellSetCombatEffect(lua_State* L);
static int luaMonsterSpellSetOutfit(lua_State* L);

// Party
static int luaPartyCreate(lua_State* L);
Expand Down