From ef7f94ac765ce8c1daa81003bc21e1b90af1dba6 Mon Sep 17 00:00:00 2001 From: BenDol Date: Thu, 7 Aug 2014 06:40:56 +1200 Subject: [PATCH] Some minor changes/additions. --- modules/game_cooldown/cooldown.lua | 15 +++++++++++++++ modules/game_interface/gameinterface.lua | 6 ++++-- src/client/const.h | 15 +++++++++------ src/client/thing.h | 1 + src/client/thingtype.h | 6 ++++++ 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/modules/game_cooldown/cooldown.lua b/modules/game_cooldown/cooldown.lua index c126f3fc..0d28fd43 100644 --- a/modules/game_cooldown/cooldown.lua +++ b/modules/game_cooldown/cooldown.lua @@ -9,6 +9,9 @@ contentsPanel = nil cooldownPanel = nil lastPlayer = nil +cooldown = {} +groupCooldown = {} + function init() connect(g_game, { onGameStart = online, onSpellGroupCooldown = onSpellGroupCooldown, @@ -149,6 +152,14 @@ function updateCooldown(progressRect, duration) end end +function isGroupCooldownIconActive(groupId) + return groupCooldown[groupId] +end + +function isCooldownIconActive(iconId) + return cooldown[iconId] +end + function onSpellCooldown(iconId, duration) local icon = loadIcon(iconId) if not icon then @@ -172,8 +183,10 @@ function onSpellCooldown(iconId, duration) end local finishFunc = function() removeCooldown(progressRect) + cooldown[iconId] = false end initCooldown(progressRect, updateFunc, finishFunc) + cooldown[iconId] = true end function onSpellGroupCooldown(groupId, duration) @@ -194,7 +207,9 @@ function onSpellGroupCooldown(groupId, duration) end local finishFunc = function() turnOffCooldown(progressRect) + groupCooldown[groupId] = false end initCooldown(progressRect, updateFunc, finishFunc) + groupCooldown[groupId] = true end end diff --git a/modules/game_interface/gameinterface.lua b/modules/game_interface/gameinterface.lua index b0379680..24e61232 100644 --- a/modules/game_interface/gameinterface.lua +++ b/modules/game_interface/gameinterface.lua @@ -357,7 +357,7 @@ function onUseWith(clickedWidget, mousePosition) if clickedWidget:getClassName() == 'UIGameMap' then local tile = clickedWidget:getTile(mousePosition) if tile then - if selectedThing:isFluidContainer() then + if selectedThing:isFluidContainer() or selectedThing:isMultiUse() then g_game.useWith(selectedThing, tile:getTopMultiUseThing()) else g_game.useWith(selectedThing, tile:getTopUseThing()) @@ -590,7 +590,8 @@ function createThingMenu(menuPosition, lookThing, useThing, creatureThing) menu:addSeparator() for name,opt in pairs(category) do if opt and opt.condition(menuPosition, lookThing, useThing, creatureThing) then - menu:addOption(name, opt.callback, opt.shortcut) + menu:addOption(name, function() opt.callback(menuPosition, + lookThing, useThing, creatureThing) end, opt.shortcut) end end end @@ -677,6 +678,7 @@ function processMouseAction(menuPosition, mouseButton, autoWalkPos, lookThing, u end end + local player = g_game.getLocalPlayer() player:stopAutoWalk() diff --git a/src/client/const.h b/src/client/const.h index 0e822725..b147f66b 100644 --- a/src/client/const.h +++ b/src/client/const.h @@ -409,8 +409,7 @@ namespace Otc PathFindAllowNonWalkable = 8 }; - enum AutomapFlags - { + enum AutomapFlags { MapMarkTick = 0, MapMarkQuestion, MapMarkExclamation, @@ -433,20 +432,24 @@ namespace Otc MapMarkGreenSouth }; - enum VipState - { + enum VipState { VipStateOffline = 0, VipStateOnline = 1, VipStatePending = 2 }; - enum SpeedFormula - { + enum SpeedFormula { SpeedFormulaA = 0, SpeedFormulaB, SpeedFormulaC, LastSpeedFormula }; + + enum AnimationPhase { + PhaseAutomatic = 0, + PhaseRandom = 254, + PhaseAsync = 255 + }; } #endif diff --git a/src/client/thing.h b/src/client/thing.h index a276ad44..c8913bdb 100644 --- a/src/client/thing.h +++ b/src/client/thing.h @@ -74,6 +74,7 @@ public: int getNumPatternY() { return rawGetThingType()->getNumPatternY(); } int getNumPatternZ() { return rawGetThingType()->getNumPatternZ(); } int getAnimationPhases() { return rawGetThingType()->getAnimationPhases(); } + Animation getAnimation() { return rawGetThingType()->getAnimation(); } int getGroundSpeed() { return rawGetThingType()->getGroundSpeed(); } int getMaxTextLength() { return rawGetThingType()->getMaxTextLength(); } Light getLight() { return rawGetThingType()->getLight(); } diff --git a/src/client/thingtype.h b/src/client/thingtype.h index e5e0120d..10363587 100644 --- a/src/client/thingtype.h +++ b/src/client/thingtype.h @@ -117,6 +117,12 @@ struct Animation { int loopCount; bool async; std::vector > frames; + + float duration(uint8 frame) { + assert(frames.size() <= frame); + std::tuple data = frames.at(frame); + return stdext::random_range((long)std::get<0>(data), (long)std::get<1>(data)); + } }; class ThingType : public LuaObject