From e2b89ac5f20eede52aea4a51ea81c5b6e8da021d Mon Sep 17 00:00:00 2001 From: KevinW1998 Date: Sat, 24 Oct 2015 17:46:00 +0200 Subject: [PATCH] Added more flags to the NPC class --- LunaDll/Changelog.txt | 3 +- LunaDll/LuaMain/LuaProxy.h | 11 ++- .../LuaMain/LuaProxyComponent/LuaProxyNPC.cpp | 71 +++++++++++++++++++ LunaDll/LuaMain/LunaLuaMain.cpp | 5 ++ LunaDll/SMBXInternal/NPCs.h | 2 +- 5 files changed, 89 insertions(+), 3 deletions(-) diff --git a/LunaDll/Changelog.txt b/LunaDll/Changelog.txt index 5cdf9fdf8..3df281995 100644 --- a/LunaDll/Changelog.txt +++ b/LunaDll/Changelog.txt @@ -1,4 +1,5 @@ - +v0.7.2.1 BETA: + * Extended NPC class v0.7.2 BETA: * Extended Level class and World class (Overworld) diff --git a/LunaDll/LuaMain/LuaProxy.h b/LunaDll/LuaMain/LuaProxy.h index 3ea617245..3b0569384 100644 --- a/LunaDll/LuaMain/LuaProxy.h +++ b/LunaDll/LuaMain/LuaProxy.h @@ -365,7 +365,16 @@ namespace LuaProxy { void setAi4(double ai4, lua_State* L); double ai5(lua_State* L) const; void setAi5(double ai5, lua_State* L); - + bool drawOnlyMask(lua_State* L) const; + void setDrawOnlyMask(bool drawOnlyMask, lua_State* L); + bool isInvincibleToSword(lua_State* L) const; + void setIsInvincibleToSword(bool isInvincibleToSword, lua_State* L); + bool legacyBoss(lua_State* L); + void setLegacyBoss(bool legacyBoss, lua_State *L); + bool friendly(lua_State* L); + void setFriendly(bool friendly, lua_State* L); + bool dontMove(lua_State* L); + void setDontMove(bool dontMove, lua_State* L); bool isValid() const; bool isValid_throw(lua_State *L) const; diff --git a/LunaDll/LuaMain/LuaProxyComponent/LuaProxyNPC.cpp b/LunaDll/LuaMain/LuaProxyComponent/LuaProxyNPC.cpp index 3250af295..aa58d87fe 100644 --- a/LunaDll/LuaMain/LuaProxyComponent/LuaProxyNPC.cpp +++ b/LunaDll/LuaMain/LuaProxyComponent/LuaProxyNPC.cpp @@ -484,6 +484,77 @@ void LuaProxy::NPC::setLayerObj(const LuaProxy::Layer &value, lua_State *L) thisnpc->layerName = ::Layer::Get(value.layerIndex())->ptLayerName; } +bool LuaProxy::NPC::drawOnlyMask(lua_State * L) const +{ + if (!isValid_throw(L)) return false; + + return (bool)::NPC::Get(m_index)->isMaskOnly; +} + +void LuaProxy::NPC::setDrawOnlyMask(bool drawOnlyMask, lua_State * L) +{ + if (!isValid_throw(L)) return; + + ::NPC::Get(m_index)->isMaskOnly = COMBOOL(drawOnlyMask); +} + +bool LuaProxy::NPC::isInvincibleToSword(lua_State * L) const +{ + if (!isValid_throw(L)) return false; + + return (bool)::NPC::Get(m_index)->invincibilityToSword; +} + +void LuaProxy::NPC::setIsInvincibleToSword(bool isInvincibleToSword, lua_State * L) +{ + if (!isValid_throw(L)) return; + + ::NPC::Get(m_index)->invincibilityToSword = COMBOOL(isInvincibleToSword); +} + +bool LuaProxy::NPC::legacyBoss(lua_State * L) +{ + if (!isValid_throw(L)) return false; + + return (bool)::NPC::Get(m_index)->legacyBoss; +} + +void LuaProxy::NPC::setLegacyBoss(bool legacyBoss, lua_State * L) +{ + if (!isValid_throw(L)) return; + + ::NPC::Get(m_index)->legacyBoss = COMBOOL(legacyBoss); +} + +bool LuaProxy::NPC::friendly(lua_State * L) +{ + if (!isValid_throw(L)) return false; + + return (bool)::NPC::Get(m_index)->friendly; +} + +void LuaProxy::NPC::setFriendly(bool friendly, lua_State * L) +{ + if (!isValid_throw(L)) return; + + ::NPC::Get(m_index)->friendly = COMBOOL(friendly); +} + +bool LuaProxy::NPC::dontMove(lua_State * L) +{ + if (!isValid_throw(L)) return false; + + return (bool)::NPC::Get(m_index)->dontMove; +} + +void LuaProxy::NPC::setDontMove(bool dontMove, lua_State* L) +{ + if (!isValid_throw(L)) return; + + ::NPC::Get(m_index)->dontMove2 = COMBOOL(dontMove); + ::NPC::Get(m_index)->dontMove = COMBOOL(dontMove); +} + double LuaProxy::NPC::ai1(lua_State * L) const { if (!isValid_throw(L)) return 0.0; diff --git a/LunaDll/LuaMain/LunaLuaMain.cpp b/LunaDll/LuaMain/LunaLuaMain.cpp index 823873f8d..d5eb55822 100644 --- a/LunaDll/LuaMain/LunaLuaMain.cpp +++ b/LunaDll/LuaMain/LunaLuaMain.cpp @@ -869,6 +869,11 @@ void CLunaLua::bindAll() .property("ai3", &LuaProxy::NPC::ai3, &LuaProxy::NPC::setAi3) .property("ai4", &LuaProxy::NPC::ai4, &LuaProxy::NPC::setAi4) .property("ai5", &LuaProxy::NPC::ai5, &LuaProxy::NPC::setAi5) + .property("drawOnlyMask", &LuaProxy::NPC::drawOnlyMask, &LuaProxy::NPC::setDrawOnlyMask) + .property("invincibleToSword", &LuaProxy::NPC::isInvincibleToSword, &LuaProxy::NPC::setIsInvincibleToSword) + .property("legacyBoss", &LuaProxy::NPC::legacyBoss, &LuaProxy::NPC::setLegacyBoss) + .property("friendly", &LuaProxy::NPC::friendly, &LuaProxy::NPC::setFriendly) + .property("dontMove", &LuaProxy::NPC::dontMove, &LuaProxy::NPC::setDontMove) .property("isValid", &LuaProxy::NPC::isValid), diff --git a/LunaDll/SMBXInternal/NPCs.h b/LunaDll/SMBXInternal/NPCs.h index f1194a7dc..894883d6b 100644 --- a/LunaDll/SMBXInternal/NPCs.h +++ b/LunaDll/SMBXInternal/NPCs.h @@ -387,7 +387,7 @@ struct NPCMOB { short activated; //+0x44 short friendly; //+0x46 short dontMove; //+0x48 - short unknown_4A; //+0x4A + short dontMove2; //+0x4A VB6StrPtr talkMsg; //+0x4C short unknown_50; //+0x50 short unknown_52; //+0x52