Version 0.95 BETA

This commit is contained in:
OTCv8
2019-10-02 03:38:52 +02:00
parent 9219c78f15
commit 5220a3bdd2
501 changed files with 38097 additions and 2 deletions

View File

@@ -0,0 +1,487 @@
Icons = {}
Icons[PlayerStates.Poison] = { tooltip = tr('You are poisoned'), path = '/images/game/states/poisoned', id = 'condition_poisoned' }
Icons[PlayerStates.Burn] = { tooltip = tr('You are burning'), path = '/images/game/states/burning', id = 'condition_burning' }
Icons[PlayerStates.Energy] = { tooltip = tr('You are electrified'), path = '/images/game/states/electrified', id = 'condition_electrified' }
Icons[PlayerStates.Drunk] = { tooltip = tr('You are drunk'), path = '/images/game/states/drunk', id = 'condition_drunk' }
Icons[PlayerStates.ManaShield] = { tooltip = tr('You are protected by a magic shield'), path = '/images/game/states/magic_shield', id = 'condition_magic_shield' }
Icons[PlayerStates.Paralyze] = { tooltip = tr('You are paralysed'), path = '/images/game/states/slowed', id = 'condition_slowed' }
Icons[PlayerStates.Haste] = { tooltip = tr('You are hasted'), path = '/images/game/states/haste', id = 'condition_haste' }
Icons[PlayerStates.Swords] = { tooltip = tr('You may not logout during a fight'), path = '/images/game/states/logout_block', id = 'condition_logout_block' }
Icons[PlayerStates.Drowning] = { tooltip = tr('You are drowning'), path = '/images/game/states/drowning', id = 'condition_drowning' }
Icons[PlayerStates.Freezing] = { tooltip = tr('You are freezing'), path = '/images/game/states/freezing', id = 'condition_freezing' }
Icons[PlayerStates.Dazzled] = { tooltip = tr('You are dazzled'), path = '/images/game/states/dazzled', id = 'condition_dazzled' }
Icons[PlayerStates.Cursed] = { tooltip = tr('You are cursed'), path = '/images/game/states/cursed', id = 'condition_cursed' }
Icons[PlayerStates.PartyBuff] = { tooltip = tr('You are strengthened'), path = '/images/game/states/strengthened', id = 'condition_strengthened' }
Icons[PlayerStates.PzBlock] = { tooltip = tr('You may not logout or enter a protection zone'), path = '/images/game/states/protection_zone_block', id = 'condition_protection_zone_block' }
Icons[PlayerStates.Pz] = { tooltip = tr('You are within a protection zone'), path = '/images/game/states/protection_zone', id = 'condition_protection_zone' }
Icons[PlayerStates.Bleeding] = { tooltip = tr('You are bleeding'), path = '/images/game/states/bleeding', id = 'condition_bleeding' }
Icons[PlayerStates.Hungry] = { tooltip = tr('You are hungry'), path = '/images/game/states/hungry', id = 'condition_hungry' }
InventorySlotStyles = {
[InventorySlotHead] = "HeadSlot",
[InventorySlotNeck] = "NeckSlot",
[InventorySlotBack] = "BackSlot",
[InventorySlotBody] = "BodySlot",
[InventorySlotRight] = "RightSlot",
[InventorySlotLeft] = "LeftSlot",
[InventorySlotLeg] = "LegSlot",
[InventorySlotFeet] = "FeetSlot",
[InventorySlotFinger] = "FingerSlot",
[InventorySlotAmmo] = "AmmoSlot"
}
inventoryWindow = nil
inventoryPanel = nil
inventoryButton = nil
purseButton = nil
combatControlsWindow = nil
fightOffensiveBox = nil
fightBalancedBox = nil
fightDefensiveBox = nil
chaseModeButton = nil
safeFightButton = nil
mountButton = nil
fightModeRadioGroup = nil
buttonPvp = nil
soulLabel = nil
capLabel = nil
conditionPanel = nil
function init()
connect(LocalPlayer, {
onInventoryChange = onInventoryChange,
onBlessingsChange = onBlessingsChange
})
connect(g_game, { onGameStart = refresh })
g_keyboard.bindKeyDown('Ctrl+I', toggle)
inventoryWindow = g_ui.loadUI('inventory', modules.game_interface.getRightPanel())
inventoryWindow:disableResize()
inventoryPanel = inventoryWindow:getChildById('contentsPanel'):getChildById('inventoryPanel')
if not inventoryWindow.forceOpen then
inventoryButton = modules.client_topmenu.addRightGameToggleButton('inventoryButton', tr('Inventory') .. ' (Ctrl+I)', '/images/topbuttons/inventory', toggle)
inventoryButton:setOn(true)
end
--[[
purseButton = inventoryPanel:getChildById('purseButton')
local function purseFunction()
local purse = g_game.getLocalPlayer():getInventoryItem(InventorySlotPurse)
if purse then
g_game.use(purse)
end
end
purseButton.onClick = purseFunction
]]--
-- controls
fightOffensiveBox = inventoryWindow:recursiveGetChildById('fightOffensiveBox')
fightBalancedBox = inventoryWindow:recursiveGetChildById('fightBalancedBox')
fightDefensiveBox = inventoryWindow:recursiveGetChildById('fightDefensiveBox')
chaseModeButton = inventoryWindow:recursiveGetChildById('chaseModeBox')
safeFightButton = inventoryWindow:recursiveGetChildById('safeFightBox')
buttonPvp = inventoryWindow:recursiveGetChildById('buttonPvp')
mountButton = inventoryWindow:recursiveGetChildById('mountButton')
mountButton.onClick = onMountButtonClick
whiteDoveBox = inventoryWindow:recursiveGetChildById('whiteDoveBox')
whiteHandBox = inventoryWindow:recursiveGetChildById('whiteHandBox')
yellowHandBox = inventoryWindow:recursiveGetChildById('yellowHandBox')
redFistBox = inventoryWindow:recursiveGetChildById('redFistBox')
fightModeRadioGroup = UIRadioGroup.create()
fightModeRadioGroup:addWidget(fightOffensiveBox)
fightModeRadioGroup:addWidget(fightBalancedBox)
fightModeRadioGroup:addWidget(fightDefensiveBox)
connect(fightModeRadioGroup, { onSelectionChange = onSetFightMode })
connect(chaseModeButton, { onCheckChange = onSetChaseMode })
connect(safeFightButton, { onCheckChange = onSetSafeFight })
if buttonPvp then
connect(buttonPvp, { onClick = onSetSafeFight2 })
end
connect(g_game, {
onGameStart = online,
onGameEnd = offline,
onFightModeChange = update,
onChaseModeChange = update,
onSafeFightChange = update,
onPVPModeChange = update,
onWalk = check,
onAutoWalk = check
})
connect(LocalPlayer, { onOutfitChange = onOutfitChange })
if g_game.isOnline() then
online()
end
-- controls end
-- status
soulLabel = inventoryWindow:recursiveGetChildById('soulLabel')
capLabel = inventoryWindow:recursiveGetChildById('capLabel')
conditionPanel = inventoryWindow:recursiveGetChildById('conditionPanel')
connect(LocalPlayer, { onStatesChange = onStatesChange,
onSoulChange = onSoulChange,
onFreeCapacityChange = onFreeCapacityChange })
-- status end
refresh()
inventoryWindow:setup()
end
function terminate()
disconnect(LocalPlayer, {
onInventoryChange = onInventoryChange,
onBlessingsChange = onBlessingsChange
})
disconnect(g_game, { onGameStart = refresh })
g_keyboard.unbindKeyDown('Ctrl+I')
-- controls
if g_game.isOnline() then
offline()
end
fightModeRadioGroup:destroy()
disconnect(g_game, {
onGameStart = online,
onGameEnd = offline,
onFightModeChange = update,
onChaseModeChange = update,
onSafeFightChange = update,
onPVPModeChange = update,
onWalk = check,
onAutoWalk = check
})
disconnect(LocalPlayer, { onOutfitChange = onOutfitChange })
-- controls end
-- status
disconnect(LocalPlayer, { onStatesChange = onStatesChange,
onSoulChange = onSoulChange,
onFreeCapacityChange = onFreeCapacityChange })
-- status end
inventoryWindow:destroy()
if inventoryButton then
inventoryButton:destroy()
end
end
function toggleAdventurerStyle(hasBlessing)
for slot = InventorySlotFirst, InventorySlotLast do
local itemWidget = inventoryPanel:getChildById('slot' .. slot)
if itemWidget then
itemWidget:setOn(hasBlessing)
end
end
end
function refresh()
local player = g_game.getLocalPlayer()
for i = InventorySlotFirst, InventorySlotPurse do
if g_game.isOnline() then
onInventoryChange(player, i, player:getInventoryItem(i))
else
onInventoryChange(player, i, nil)
end
toggleAdventurerStyle(player and Bit.hasBit(player:getBlessings(), Blessings.Adventurer) or false)
end
if player then
onSoulChange(player, player:getSoul())
onFreeCapacityChange(player, player:getFreeCapacity())
end
--purseButton:setVisible(g_game.getFeature(GamePurseSlot))
end
function toggle()
if not inventoryButton then
return
end
if inventoryButton:isOn() then
inventoryWindow:close()
inventoryButton:setOn(false)
else
inventoryWindow:open()
inventoryButton:setOn(true)
end
end
function onMiniWindowClose()
if not inventoryButton then
return
end
inventoryButton:setOn(false)
end
-- hooked events
function onInventoryChange(player, slot, item, oldItem)
if slot > InventorySlotPurse then return end
if slot == InventorySlotPurse then
if g_game.getFeature(GamePurseSlot) then
--purseButton:setEnabled(item and true or false)
end
return
end
local itemWidget = inventoryPanel:getChildById('slot' .. slot)
if item then
itemWidget:setStyle('InventoryItem')
itemWidget:setItem(item)
else
itemWidget:setStyle(InventorySlotStyles[slot])
itemWidget:setItem(nil)
end
end
function onBlessingsChange(player, blessings, oldBlessings)
local hasAdventurerBlessing = Bit.hasBit(blessings, Blessings.Adventurer)
if hasAdventurerBlessing ~= Bit.hasBit(oldBlessings, Blessings.Adventurer) then
toggleAdventurerStyle(hasAdventurerBlessing)
end
end
-- controls
function update()
local fightMode = g_game.getFightMode()
if fightMode == FightOffensive then
fightModeRadioGroup:selectWidget(fightOffensiveBox)
elseif fightMode == FightBalanced then
fightModeRadioGroup:selectWidget(fightBalancedBox)
else
fightModeRadioGroup:selectWidget(fightDefensiveBox)
end
local chaseMode = g_game.getChaseMode()
chaseModeButton:setChecked(chaseMode == ChaseOpponent)
local safeFight = g_game.isSafeFight()
safeFightButton:setChecked(not safeFight)
if buttonPvp then
if safeFight then
buttonPvp:setColor("#00BB00FF")
else
buttonPvp:setColor("#FF0000FF")
end
end
if g_game.getFeature(GamePVPMode) then
local pvpMode = g_game.getPVPMode()
local pvpWidget = getPVPBoxByMode(pvpMode)
end
end
function check()
if modules.client_options.getOption('autoChaseOverride') then
if g_game.isAttacking() and g_game.getChaseMode() == ChaseOpponent then
g_game.setChaseMode(DontChase)
end
end
end
function online()
local player = g_game.getLocalPlayer()
if player then
local char = g_game.getCharacterName()
local lastCombatControls = g_settings.getNode('LastCombatControls')
if not table.empty(lastCombatControls) then
if lastCombatControls[char] then
g_game.setFightMode(lastCombatControls[char].fightMode)
g_game.setChaseMode(lastCombatControls[char].chaseMode)
g_game.setSafeFight(lastCombatControls[char].safeFight)
if lastCombatControls[char].pvpMode then
g_game.setPVPMode(lastCombatControls[char].pvpMode)
end
end
end
if g_game.getFeature(GamePlayerMounts) then
mountButton:setVisible(true)
mountButton:setChecked(player:isMounted())
else
mountButton:setVisible(false)
end
end
update()
end
function offline()
local lastCombatControls = g_settings.getNode('LastCombatControls')
if not lastCombatControls then
lastCombatControls = {}
end
conditionPanel:destroyChildren()
local player = g_game.getLocalPlayer()
if player then
local char = g_game.getCharacterName()
lastCombatControls[char] = {
fightMode = g_game.getFightMode(),
chaseMode = g_game.getChaseMode(),
safeFight = g_game.isSafeFight()
}
if g_game.getFeature(GamePVPMode) then
lastCombatControls[char].pvpMode = g_game.getPVPMode()
end
-- save last combat control settings
g_settings.setNode('LastCombatControls', lastCombatControls)
end
end
function onSetFightMode(self, selectedFightButton)
if selectedFightButton == nil then return end
local buttonId = selectedFightButton:getId()
local fightMode
if buttonId == 'fightOffensiveBox' then
fightMode = FightOffensive
elseif buttonId == 'fightBalancedBox' then
fightMode = FightBalanced
else
fightMode = FightDefensive
end
g_game.setFightMode(fightMode)
end
function onSetChaseMode(self, checked)
local chaseMode
if checked then
chaseMode = ChaseOpponent
else
chaseMode = DontChase
end
g_game.setChaseMode(chaseMode)
end
function onSetSafeFight(self, checked)
g_game.setSafeFight(not checked)
if buttonPvp then
if not checked then
buttonPvp:setColor("#00BB00FF")
else
buttonPvp:setColor("#FF0000FF")
end
end
end
function onSetSafeFight2(self)
onSetSafeFight(self, not safeFightButton:isChecked())
end
function onSetPVPMode(self, selectedPVPButton)
if selectedPVPButton == nil then
return
end
local buttonId = selectedPVPButton:getId()
local pvpMode = PVPWhiteDove
if buttonId == 'whiteDoveBox' then
pvpMode = PVPWhiteDove
elseif buttonId == 'whiteHandBox' then
pvpMode = PVPWhiteHand
elseif buttonId == 'yellowHandBox' then
pvpMode = PVPYellowHand
elseif buttonId == 'redFistBox' then
pvpMode = PVPRedFist
end
g_game.setPVPMode(pvpMode)
end
function onMountButtonClick(self, mousePos)
local player = g_game.getLocalPlayer()
if player then
player:toggleMount()
end
end
function onOutfitChange(localPlayer, outfit, oldOutfit)
if outfit.mount == oldOutfit.mount then
return
end
mountButton:setChecked(outfit.mount ~= nil and outfit.mount > 0)
end
function getPVPBoxByMode(mode)
local widget = nil
if mode == PVPWhiteDove then
widget = whiteDoveBox
elseif mode == PVPWhiteHand then
widget = whiteHandBox
elseif mode == PVPYellowHand then
widget = yellowHandBox
elseif mode == PVPRedFist then
widget = redFistBox
end
return widget
end
-- status
function toggleIcon(bitChanged)
local icon = conditionPanel:getChildById(Icons[bitChanged].id)
if icon then
icon:destroy()
else
icon = loadIcon(bitChanged)
icon:setParent(conditionPanel)
end
end
function loadIcon(bitChanged)
local icon = g_ui.createWidget('ConditionWidget', conditionPanel)
icon:setId(Icons[bitChanged].id)
icon:setImageSource(Icons[bitChanged].path)
icon:setTooltip(Icons[bitChanged].tooltip)
return icon
end
function onSoulChange(localPlayer, soul)
if not soul then return end
soulLabel:setText(tr('Soul') .. ':\n' .. soul)
end
function onFreeCapacityChange(player, freeCapacity)
if not freeCapacity then return end
if freeCapacity > 99 then
freeCapacity = math.floor(freeCapacity * 10) / 10
end
if freeCapacity > 999 then
freeCapacity = math.floor(freeCapacity)
end
if freeCapacity > 99999 then
freeCapacity = 99999
end
capLabel:setText(tr('Cap') .. ':\n' .. freeCapacity)
end
function onStatesChange(localPlayer, now, old)
if now == old then return end
local bitsChanged = bit32.bxor(now, old)
for i = 1, 32 do
local pow = math.pow(2, i-1)
if pow > bitsChanged then break end
local bitChanged = bit32.band(bitsChanged, pow)
if bitChanged ~= 0 then
toggleIcon(bitChanged)
end
end
end

View File

@@ -0,0 +1,9 @@
Module
name: game_inventory
description: View local player equipments window
author: baxnie, edubart, BeniS, otclientv8
website: https://github.com/edubart/otclient
sandboxed: true
scripts: [ inventory ]
@onLoad: init()
@onUnload: terminate()

View File

@@ -0,0 +1,282 @@
InventoryItem < Item
$on:
image-source: /images/ui/item-blessed
HeadSlot < InventoryItem
id: slot1
image-source: /images/game/slots/head
&position: {x=65535, y=1, z=0}
$on:
image-source: /images/game/slots/head-blessed
BodySlot < InventoryItem
id: slot4
image-source: /images/game/slots/body
&position: {x=65535, y=4, z=0}
$on:
image-source: /images/game/slots/body-blessed
LegSlot < InventoryItem
id: slot7
image-source: /images/game/slots/legs
&position: {x=65535, y=7, z=0}
$on:
image-source: /images/game/slots/legs-blessed
FeetSlot < InventoryItem
id: slot8
image-source: /images/game/slots/feet
&position: {x=65535, y=8, z=0}
$on:
image-source: /images/game/slots/feet-blessed
NeckSlot < InventoryItem
id: slot2
image-source: /images/game/slots/neck
&position: {x=65535, y=2, z=0}
$on:
image-source: /images/game/slots/neck-blessed
LeftSlot < InventoryItem
id: slot6
image-source: /images/game/slots/left-hand
&position: {x=65535, y=6, z=0}
$on:
image-source: /images/game/slots/left-hand-blessed
FingerSlot < InventoryItem
id: slot9
image-source: /images/game/slots/finger
&position: {x=65535, y=9, z=0}
$on:
image-source: /images/game/slots/finger-blessed
BackSlot < InventoryItem
id: slot3
image-source: /images/game/slots/back
&position: {x=65535, y=3, z=0}
$on:
image-source: /images/game/slots/back-blessed
RightSlot < InventoryItem
id: slot5
image-source: /images/game/slots/right-hand
&position: {x=65535, y=5, z=0}
$on:
image-source: /images/game/slots/right-hand-blessed
AmmoSlot < InventoryItem
id: slot10
image-source: /images/game/slots/ammo
&position: {x=65535, y=10, z=0}
$on:
image-source: /images/game/slots/ammo-blessed
PurseButton < Button
id: purseButton
size: 26 26
!tooltip: tr('Open purse')
icon-source: /images/game/slots/purse
icon-size: 24 24
icon-offset: 1 1
CombatBox < UICheckBox
size: 20 20
image-clip: 0 0 20 20
margin-left: 4
$checked:
image-clip: 0 20 20 20
InventoryButton < Button
font: verdana-11px-antialised
height: 20
SoulCapLabel < GameLabel
text-align: center
color: #FFFFFF
font: cipsoftFont
margin-top: 4
text-offset: 0 3
width: 36
height: 20
icon-source: /images/game/slots/soulcap
FightOffensiveBox < CombatBox
image-source: /images/game/combatmodes/fightoffensive
FightBalancedBox < CombatBox
image-source: /images/game/combatmodes/fightbalanced
FightDefensiveBox < CombatBox
image-source: /images/game/combatmodes/fightdefensive
ChaseModeBox < CombatBox
image-source: /images/game/combatmodes/chasemode
SafeFightBox < CombatBox
image-source: /images/game/combatmodes/safefight
MountButton < CombatBox
image-source: /images/game/combatmodes/mount
MiniWindow
id: inventoryWindow
!text: tr('Inventory')
icon: /images/topbuttons/inventory
height: 200
@onClose: modules.game_inventory.onMiniWindowClose()
&save: true
--&forceOpen: true
MiniWindowContents
anchors.left: parent.left
Panel
id: inventoryPanel
margin-right: 63
margin-top: 2
anchors.fill: parent
HeadSlot
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
margin-top: 3
BodySlot
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin-top: 3
LegSlot
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin-top: 3
FeetSlot
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin-top: 3
NeckSlot
anchors.top: slot1.top
anchors.right: slot1.left
margin-top: 10
margin-right: 5
LeftSlot
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin-top: 3
FingerSlot
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin-top: 3
BackSlot
anchors.top: slot1.top
anchors.left: slot1.right
margin-top: 10
margin-left: 5
RightSlot
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin-top: 3
AmmoSlot
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin-top: 3
SoulCapLabel
id: soulLabel
anchors.top: slot10.bottom
anchors.horizontalCenter: slot10.horizontalCenter
SoulCapLabel
id: capLabel
anchors.top: slot9.bottom
anchors.horizontalCenter: slot9.horizontalCenter
Panel
id: conditionPanel
layout:
type: horizontalBox
height: 22
padding: 2
anchors.top: slot8.bottom
anchors.left: slot6.left
anchors.right: slot5.right
margin-top: 4
border-width: 1
border-color: #00000077
background-color: #ffffff11
Panel
margin-top: 5
anchors.fill: parent
anchors.left: prev.right
FightOffensiveBox
id: fightOffensiveBox
anchors.left: parent.left
anchors.top: parent.top
margin-left: 8
ChaseModeBox
id: chaseModeBox
anchors.left: prev.right
anchors.top: parent.top
FightBalancedBox
id: fightBalancedBox
margin-top: 22
anchors.left: parent.left
anchors.top: parent.top
margin-left: 8
SafeFightBox
id: safeFightBox
margin-top: 22
anchors.left: prev.right
anchors.top: parent.top
FightDefensiveBox
id: fightDefensiveBox
margin-top: 44
anchors.left: parent.left
anchors.top: parent.top
margin-left: 8
MountButton
id: mountButton
margin-top: 44
anchors.left: prev.right
anchors.top: parent.top
Panel
margin-top: 4
margin-right: 5
anchors.fill: parent
anchors.top: prev.bottom
layout:
type: verticalBox
InventoryButton
!text: tr('Stop')
@onClick: g_game.stop(); g_game.cancelAttackAndFollow()
InventoryButton
!text: tr('Quests')
@onClick: g_game.requestQuestLog()
InventoryButton
!text: tr('Options')
@onClick: modules.client_options.toggle()
InventoryButton
!text: tr('Hotkeys')
@onClick: modules.game_hotkeys.toggle()
InventoryButton
!text: tr('Logout')
@onClick: modules.game_interface.tryLogout()