otland / forgottenserver

A free and open-source MMORPG server emulator written in C++
https://otland.net
GNU General Public License v2.0
1.59k stars 1.06k forks source link

fluidcontainer/trashholding mechanic #3957

Closed ghost closed 3 months ago

ghost commented 2 years ago

Desired functionality

  1. create a vial filled with any fluid type, example /i vial, 2
  2. use the vial with lava target tile

what should happen is the vial should empty and effect should be displayed on target tile, in this case "fire"

so need a way to check for trashholder type and effect

<item fromid="598" toid="601" name="lava"> <attribute key="type" value="trashholder"/> <attribute key="effect" value="fire"/> <attribute key="allowpickupable" value="1"/> </item>

https://github.com/otland/forgottenserver/blob/master/data/actions/scripts/other/fluids.lua

ghost commented 2 years ago

leaving this code here for later, cba do a pr atm

first need to check if itemType is trahsholder and that it has effect (todo)

here is how to get the effect and empty the vial toPosition:sendMagicEffect(targetItemType:getMagicEffect()) item:transform(item.itemid, FLUID_NONE)

luascript.cpp registerMethod("ItemType", "getMagicEffect", LuaScriptInterface::luaItemTypeGetMagicEffect);

int LuaScriptInterface::luaItemTypeGetMagicEffect(lua_State* L) { // itemType:getMagicEffect() const ItemType* itemType = getUserdata<const ItemType>(L, 1); if (itemType) { lua_pushnumber(L, itemType->magicEffect); } else { lua_pushnil(L); } return 1; }

luascript.h static int luaItemTypeGetMagicEffect(lua_State* L);