From c6c83bccea0f7506667a6af8240938105460d377 Mon Sep 17 00:00:00 2001 From: ErikasKontenis Date: Sat, 23 Nov 2019 20:01:13 +0200 Subject: [PATCH] fix fluid colors and add few more items functionality from 781 --- config.lua | 2 +- data/actions/actions.xml | 1 + data/actions/scripts/misc/distilling_rum.lua | 20 ++++++++ data/items/items.srv | 14 ++++-- src/const.h | 12 +++-- src/luascript.cpp | 1 + src/tools.cpp | 51 +++++++++++--------- 7 files changed, 68 insertions(+), 33 deletions(-) create mode 100644 data/actions/scripts/misc/distilling_rum.lua diff --git a/config.lua b/config.lua index e354f60..0383f6a 100644 --- a/config.lua +++ b/config.lua @@ -52,7 +52,7 @@ timeBetweenExActions = 1000 -- Map -- NOTE: set mapName WITHOUT .otbm at the end -mapName = "map" +mapName = "mymap" mapAuthor = "CipSoft" -- MySQL diff --git a/data/actions/actions.xml b/data/actions/actions.xml index 58ee5a9..11c642b 100644 --- a/data/actions/actions.xml +++ b/data/actions/actions.xml @@ -135,6 +135,7 @@ + diff --git a/data/actions/scripts/misc/distilling_rum.lua b/data/actions/scripts/misc/distilling_rum.lua new file mode 100644 index 0000000..55f6437 --- /dev/null +++ b/data/actions/scripts/misc/distilling_rum.lua @@ -0,0 +1,20 @@ +local distillingMachines = { + [5468] = 5512, + [5469] = 5513 +} + +function onUse(player, item, fromPosition, target, toPosition) + if not target:isItem() then + return false + end + + local machine = distillingMachines[target:getId()] + if machine then + target:transform(machine, 1) + target:decay() + item:remove(1) + return true + end + + return false +end diff --git a/data/items/items.srv b/data/items/items.srv index 4ebf110..44aa1cb 100644 --- a/data/items/items.srv +++ b/data/items/items.srv @@ -37,6 +37,12 @@ Name = "lifefluid" TypeID = 12 Name = "lemonade" +TypeID = 13 +Name = "rum" + +TypeID = 14 +Name = "coconut milk" + # --- end of server specific object types --- TypeID = 100 @@ -24702,7 +24708,7 @@ Name = "a fire bug" Description = "This strange creature has the tendency to set certain things on fire" Flags = {UseEvent,MultiUse,Take} Attributes = {Weight=3050,Brightness=3,LightColor=206} -# pradeti nuo cia jau padariau, kad iseitu harvestinti sugar cane ir nepamirsti pridedineti naujus daiktus prie npc ir monstru, kurie jau egzistuoja + TypeID = 5468 Name = "a distilling machine" Flags = {Bottom,Unpass,Unmove,Unlay} @@ -24892,13 +24898,13 @@ Flags = {Unpass,Unmove,Unlay} TypeID = 5512 Name = "a distilling machine" Flags = {Bottom,Unpass,Unmove,Unlay,Expire} -Attributes = {FluidSource=WINE,ExpireTarget=5468,TotalExpireTime=15} # TODO: FluidSource should be RUM +Attributes = {FluidSource=RUM,ExpireTarget=5468,TotalExpireTime=10} TypeID = 5513 Name = "a distilling machine" Flags = {Bottom,Unpass,Unmove,Unlay,Expire} -Attributes = {FluidSource=WINE,ExpireTarget=5469,TotalExpireTime=15} # TODO: FluidSource should be RUM - +Attributes = {FluidSource=RUM,ExpireTarget=5469,TotalExpireTime=10} +# pradeti nuo cia TypeID = 5514 Name = "a closed door" Flags = {Door,Unpass,Unmove,Unthrow,Unlay} diff --git a/src/const.h b/src/const.h index 4a8caf6..0fffaa3 100644 --- a/src/const.h +++ b/src/const.h @@ -122,6 +122,8 @@ enum FluidTypes_t : uint8_t FLUID_MANAFLUID, FLUID_LIFEFLUID, FLUID_LEMONADE, + FLUID_RUM, + FLUID_COCONUTMILK, }; enum FluidColor_t : uint8_t @@ -130,10 +132,12 @@ enum FluidColor_t : uint8_t FLUID_COLOR_BLUE = 1, FLUID_COLOR_PURPLE = 2, FLUID_COLOR_BROWN = 3, - FLUID_COLOR_RED = 4, - FLUID_COLOR_GREEN = 5, - FLUID_COLOR_YELLOW = 6, - FLUID_COLOR_WHITE = 7, + FLUID_COLOR_BROWN1 = 4, + FLUID_COLOR_RED = 5, + FLUID_COLOR_GREEN = 6, + FLUID_COLOR_BROWN2 = 7, + FLUID_COLOR_YELLOW = 8, + FLUID_COLOR_WHITE = 9, }; enum SquareColor_t : uint8_t { diff --git a/src/luascript.cpp b/src/luascript.cpp index 7519da5..529d559 100644 --- a/src/luascript.cpp +++ b/src/luascript.cpp @@ -1407,6 +1407,7 @@ void LuaScriptInterface::registerFunctions() registerEnum(FLUID_MANAFLUID) registerEnum(FLUID_LIFEFLUID) registerEnum(FLUID_LEMONADE) + registerEnum(FLUID_RUM) registerEnum(TALKTYPE_SAY) registerEnum(TALKTYPE_WHISPER) diff --git a/src/tools.cpp b/src/tools.cpp index c6f68b7..8933c31 100644 --- a/src/tools.cpp +++ b/src/tools.cpp @@ -188,40 +188,42 @@ std::string transformToSHA1(const std::string& input) uint8_t getLiquidColor(uint8_t type) { - uint8_t result = 0; + uint8_t result = FLUID_COLOR_NONE; switch (type) { - case 1: - result = 1; + case FLUID_WATER: + result = FLUID_COLOR_BLUE; break; - case 0: - result = 0; + case FLUID_NONE: + result = FLUID_COLOR_NONE; break; - case 6: - result = 4; + case FLUID_SLIME: + result = FLUID_COLOR_GREEN; break; - case 3: - case 4: - case 7: - result = 3; + case FLUID_BEER: + case FLUID_MUD: + case FLUID_OIL: + case FLUID_RUM: + result = FLUID_COLOR_BROWN; break; - case 9: - result = 6; + case FLUID_MILK: + case FLUID_COCONUTMILK: + result = FLUID_COLOR_WHITE; break; - case 2: - case 10: - result = 7; + case FLUID_WINE: + case FLUID_MANAFLUID: + result = FLUID_COLOR_PURPLE; break; - case 5: - case 11: - result = 2; + case FLUID_BLOOD: + case FLUID_LIFEFLUID: + result = FLUID_COLOR_RED; break; - case 8: - case 12: - result = 5; + case FLUID_URINE: + case FLUID_LEMONADE: + result = FLUID_COLOR_YELLOW; break; default: - result = 0; + result = FLUID_COLOR_NONE; break; } return result; @@ -717,7 +719,8 @@ FluidNames fluidNames[] = { {"milk", FLUID_MILK}, {"manafluid", FLUID_MANAFLUID}, {"lifefluid", FLUID_LIFEFLUID}, - {"lemonade", FLUID_LEMONADE} + {"lemonade", FLUID_LEMONADE}, + {"rum", FLUID_RUM} }; MagicEffectClasses getMagicEffect(const std::string& strValue)