Some minor changes/additions.

This commit is contained in:
BenDol 2014-08-07 06:40:56 +12:00
parent 3343919c92
commit ef7f94ac76
5 changed files with 35 additions and 8 deletions

View File

@ -9,6 +9,9 @@ contentsPanel = nil
cooldownPanel = nil cooldownPanel = nil
lastPlayer = nil lastPlayer = nil
cooldown = {}
groupCooldown = {}
function init() function init()
connect(g_game, { onGameStart = online, connect(g_game, { onGameStart = online,
onSpellGroupCooldown = onSpellGroupCooldown, onSpellGroupCooldown = onSpellGroupCooldown,
@ -149,6 +152,14 @@ function updateCooldown(progressRect, duration)
end end
end end
function isGroupCooldownIconActive(groupId)
return groupCooldown[groupId]
end
function isCooldownIconActive(iconId)
return cooldown[iconId]
end
function onSpellCooldown(iconId, duration) function onSpellCooldown(iconId, duration)
local icon = loadIcon(iconId) local icon = loadIcon(iconId)
if not icon then if not icon then
@ -172,8 +183,10 @@ function onSpellCooldown(iconId, duration)
end end
local finishFunc = function() local finishFunc = function()
removeCooldown(progressRect) removeCooldown(progressRect)
cooldown[iconId] = false
end end
initCooldown(progressRect, updateFunc, finishFunc) initCooldown(progressRect, updateFunc, finishFunc)
cooldown[iconId] = true
end end
function onSpellGroupCooldown(groupId, duration) function onSpellGroupCooldown(groupId, duration)
@ -194,7 +207,9 @@ function onSpellGroupCooldown(groupId, duration)
end end
local finishFunc = function() local finishFunc = function()
turnOffCooldown(progressRect) turnOffCooldown(progressRect)
groupCooldown[groupId] = false
end end
initCooldown(progressRect, updateFunc, finishFunc) initCooldown(progressRect, updateFunc, finishFunc)
groupCooldown[groupId] = true
end end
end end

View File

@ -357,7 +357,7 @@ function onUseWith(clickedWidget, mousePosition)
if clickedWidget:getClassName() == 'UIGameMap' then if clickedWidget:getClassName() == 'UIGameMap' then
local tile = clickedWidget:getTile(mousePosition) local tile = clickedWidget:getTile(mousePosition)
if tile then if tile then
if selectedThing:isFluidContainer() then if selectedThing:isFluidContainer() or selectedThing:isMultiUse() then
g_game.useWith(selectedThing, tile:getTopMultiUseThing()) g_game.useWith(selectedThing, tile:getTopMultiUseThing())
else else
g_game.useWith(selectedThing, tile:getTopUseThing()) g_game.useWith(selectedThing, tile:getTopUseThing())
@ -590,7 +590,8 @@ function createThingMenu(menuPosition, lookThing, useThing, creatureThing)
menu:addSeparator() menu:addSeparator()
for name,opt in pairs(category) do for name,opt in pairs(category) do
if opt and opt.condition(menuPosition, lookThing, useThing, creatureThing) then 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 end
end end
@ -677,6 +678,7 @@ function processMouseAction(menuPosition, mouseButton, autoWalkPos, lookThing, u
end end
end end
local player = g_game.getLocalPlayer() local player = g_game.getLocalPlayer()
player:stopAutoWalk() player:stopAutoWalk()

View File

@ -409,8 +409,7 @@ namespace Otc
PathFindAllowNonWalkable = 8 PathFindAllowNonWalkable = 8
}; };
enum AutomapFlags enum AutomapFlags {
{
MapMarkTick = 0, MapMarkTick = 0,
MapMarkQuestion, MapMarkQuestion,
MapMarkExclamation, MapMarkExclamation,
@ -433,20 +432,24 @@ namespace Otc
MapMarkGreenSouth MapMarkGreenSouth
}; };
enum VipState enum VipState {
{
VipStateOffline = 0, VipStateOffline = 0,
VipStateOnline = 1, VipStateOnline = 1,
VipStatePending = 2 VipStatePending = 2
}; };
enum SpeedFormula enum SpeedFormula {
{
SpeedFormulaA = 0, SpeedFormulaA = 0,
SpeedFormulaB, SpeedFormulaB,
SpeedFormulaC, SpeedFormulaC,
LastSpeedFormula LastSpeedFormula
}; };
enum AnimationPhase {
PhaseAutomatic = 0,
PhaseRandom = 254,
PhaseAsync = 255
};
} }
#endif #endif

View File

@ -74,6 +74,7 @@ public:
int getNumPatternY() { return rawGetThingType()->getNumPatternY(); } int getNumPatternY() { return rawGetThingType()->getNumPatternY(); }
int getNumPatternZ() { return rawGetThingType()->getNumPatternZ(); } int getNumPatternZ() { return rawGetThingType()->getNumPatternZ(); }
int getAnimationPhases() { return rawGetThingType()->getAnimationPhases(); } int getAnimationPhases() { return rawGetThingType()->getAnimationPhases(); }
Animation getAnimation() { return rawGetThingType()->getAnimation(); }
int getGroundSpeed() { return rawGetThingType()->getGroundSpeed(); } int getGroundSpeed() { return rawGetThingType()->getGroundSpeed(); }
int getMaxTextLength() { return rawGetThingType()->getMaxTextLength(); } int getMaxTextLength() { return rawGetThingType()->getMaxTextLength(); }
Light getLight() { return rawGetThingType()->getLight(); } Light getLight() { return rawGetThingType()->getLight(); }

View File

@ -117,6 +117,12 @@ struct Animation {
int loopCount; int loopCount;
bool async; bool async;
std::vector<std::tuple<int, int> > frames; std::vector<std::tuple<int, int> > frames;
float duration(uint8 frame) {
assert(frames.size() <= frame);
std::tuple<int, int> data = frames.at(frame);
return stdext::random_range((long)std::get<0>(data), (long)std::get<1>(data));
}
}; };
class ThingType : public LuaObject class ThingType : public LuaObject