From c51df93e3e483b83f098ea86636cb73bb7f82c14 Mon Sep 17 00:00:00 2001 From: EgzoT Date: Wed, 15 Nov 2017 01:02:06 +0100 Subject: [PATCH 1/3] Add setPathable() function Adding function who changing item attribute (ThingAttrNotPathable). Allows to walk on not pathable items (ThingAttrNotPathable -> true) like parcels, fire fields etc. and vice versa. Modifying item attribute without editing items sources files. Temporary action for the duration of the client session. Usage: print(g_things.getThingType(3504):isNotPathable()) -> true g_things.getThingType(3504):setPathable(true) print(g_things.getThingType(3504):isNotPathable()) -> false Helpful for highter levels players to ignoring "avoiding" fire/energy/poison fields etc. when using map click. --- src/client/luafunctions.cpp | 1 + src/client/thingtype.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/client/luafunctions.cpp b/src/client/luafunctions.cpp index 1c1ce018..66d0ee84 100644 --- a/src/client/luafunctions.cpp +++ b/src/client/luafunctions.cpp @@ -526,6 +526,7 @@ void Client::registerLuaFunctions() g_lua.bindClassMemberFunction("isNotMoveable", &ThingType::isNotMoveable); g_lua.bindClassMemberFunction("blockProjectile", &ThingType::blockProjectile); g_lua.bindClassMemberFunction("isNotPathable", &ThingType::isNotPathable); + g_lua.bindClassMemberFunction("setPathable", &ThingType::setPathable); g_lua.bindClassMemberFunction("isPickupable", &ThingType::isPickupable); g_lua.bindClassMemberFunction("isHangable", &ThingType::isHangable); g_lua.bindClassMemberFunction("isHookSouth", &ThingType::isHookSouth); diff --git a/src/client/thingtype.h b/src/client/thingtype.h index 278df324..b8709574 100644 --- a/src/client/thingtype.h +++ b/src/client/thingtype.h @@ -178,6 +178,7 @@ public: bool isNotMoveable() { return m_attribs.has(ThingAttrNotMoveable); } bool blockProjectile() { return m_attribs.has(ThingAttrBlockProjectile); } bool isNotPathable() { return m_attribs.has(ThingAttrNotPathable); } + void setPathable(bool var) { var == true ? m_attribs.remove(ThingAttrNotPathable) : m_attribs.set(ThingAttrNotPathable, true); } bool isPickupable() { return m_attribs.has(ThingAttrPickupable); } bool isHangable() { return m_attribs.has(ThingAttrHangable); } bool isHookSouth() { return m_attribs.has(ThingAttrHookSouth); } From 5650db7ba23194f389e6f2f59079edfbbbe7376b Mon Sep 17 00:00:00 2001 From: EgzoT Date: Wed, 15 Nov 2017 02:20:33 +0100 Subject: [PATCH 2/3] Move definition to thingtype.cpp file Move definition from thingtype.h to thingtype.cpp file --- src/client/thingtype.cpp | 8 ++++++++ src/client/thingtype.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/client/thingtype.cpp b/src/client/thingtype.cpp index 7a9fb5b1..28d6b3b6 100644 --- a/src/client/thingtype.cpp +++ b/src/client/thingtype.cpp @@ -564,3 +564,11 @@ int ThingType::getExactSize(int layer, int xPattern, int yPattern, int zPattern, Size size = m_texturesFramesOriginRects[animationPhase][frameIndex].size() - m_texturesFramesOffsets[animationPhase][frameIndex].toSize(); return std::max(size.width(), size.height()); } + +void ThingType::setPathable(bool var) +{ + if(var == true) + m_attribs.remove(ThingAttrNotPathable); + else + m_attribs.set(ThingAttrNotPathable, true); +} \ No newline at end of file diff --git a/src/client/thingtype.h b/src/client/thingtype.h index b8709574..ee362e95 100644 --- a/src/client/thingtype.h +++ b/src/client/thingtype.h @@ -178,7 +178,7 @@ public: bool isNotMoveable() { return m_attribs.has(ThingAttrNotMoveable); } bool blockProjectile() { return m_attribs.has(ThingAttrBlockProjectile); } bool isNotPathable() { return m_attribs.has(ThingAttrNotPathable); } - void setPathable(bool var) { var == true ? m_attribs.remove(ThingAttrNotPathable) : m_attribs.set(ThingAttrNotPathable, true); } + void setPathable(bool var); bool isPickupable() { return m_attribs.has(ThingAttrPickupable); } bool isHangable() { return m_attribs.has(ThingAttrHangable); } bool isHookSouth() { return m_attribs.has(ThingAttrHookSouth); } From c1a5a661e7d40ab4d355bbf72c3b45c044efb0e8 Mon Sep 17 00:00:00 2001 From: EgzoT Date: Fri, 17 Nov 2017 02:32:31 +0100 Subject: [PATCH 3/3] Fixed indentation and changed function location --- src/client/thingtype.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/thingtype.h b/src/client/thingtype.h index ee362e95..ac95f101 100644 --- a/src/client/thingtype.h +++ b/src/client/thingtype.h @@ -178,7 +178,6 @@ public: bool isNotMoveable() { return m_attribs.has(ThingAttrNotMoveable); } bool blockProjectile() { return m_attribs.has(ThingAttrBlockProjectile); } bool isNotPathable() { return m_attribs.has(ThingAttrNotPathable); } - void setPathable(bool var); bool isPickupable() { return m_attribs.has(ThingAttrPickupable); } bool isHangable() { return m_attribs.has(ThingAttrHangable); } bool isHookSouth() { return m_attribs.has(ThingAttrHookSouth); } @@ -207,6 +206,7 @@ public: // additional float getOpacity() { return m_opacity; } bool isNotPreWalkable() { return m_attribs.has(ThingAttrNotPreWalkable); } + void setPathable(bool var); private: const TexturePtr& getTexture(int animationPhase);