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.
This commit is contained in:
EgzoT 2017-11-15 01:02:06 +01:00 committed by GitHub
parent 2095951e07
commit c51df93e3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 0 deletions

View File

@ -526,6 +526,7 @@ void Client::registerLuaFunctions()
g_lua.bindClassMemberFunction<ThingType>("isNotMoveable", &ThingType::isNotMoveable); g_lua.bindClassMemberFunction<ThingType>("isNotMoveable", &ThingType::isNotMoveable);
g_lua.bindClassMemberFunction<ThingType>("blockProjectile", &ThingType::blockProjectile); g_lua.bindClassMemberFunction<ThingType>("blockProjectile", &ThingType::blockProjectile);
g_lua.bindClassMemberFunction<ThingType>("isNotPathable", &ThingType::isNotPathable); g_lua.bindClassMemberFunction<ThingType>("isNotPathable", &ThingType::isNotPathable);
g_lua.bindClassMemberFunction<ThingType>("setPathable", &ThingType::setPathable);
g_lua.bindClassMemberFunction<ThingType>("isPickupable", &ThingType::isPickupable); g_lua.bindClassMemberFunction<ThingType>("isPickupable", &ThingType::isPickupable);
g_lua.bindClassMemberFunction<ThingType>("isHangable", &ThingType::isHangable); g_lua.bindClassMemberFunction<ThingType>("isHangable", &ThingType::isHangable);
g_lua.bindClassMemberFunction<ThingType>("isHookSouth", &ThingType::isHookSouth); g_lua.bindClassMemberFunction<ThingType>("isHookSouth", &ThingType::isHookSouth);

View File

@ -178,6 +178,7 @@ public:
bool isNotMoveable() { return m_attribs.has(ThingAttrNotMoveable); } bool isNotMoveable() { return m_attribs.has(ThingAttrNotMoveable); }
bool blockProjectile() { return m_attribs.has(ThingAttrBlockProjectile); } bool blockProjectile() { return m_attribs.has(ThingAttrBlockProjectile); }
bool isNotPathable() { return m_attribs.has(ThingAttrNotPathable); } 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 isPickupable() { return m_attribs.has(ThingAttrPickupable); }
bool isHangable() { return m_attribs.has(ThingAttrHangable); } bool isHangable() { return m_attribs.has(ThingAttrHangable); }
bool isHookSouth() { return m_attribs.has(ThingAttrHookSouth); } bool isHookSouth() { return m_attribs.has(ThingAttrHookSouth); }