Merge pull request #115 from TheSumm/spellSystem

Custom spell support & tweaks
This commit is contained in:
TheSumm 2012-10-07 21:59:45 -07:00
commit efdfb0e946
4 changed files with 318 additions and 227 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -1,3 +1,21 @@
SpelllistSettings = {
['Default'] = {
iconFile = 'icons.png',
iconSize = {width = 32, height = 32},
spellListWidth = 210,
spellWindowWidth = 550,
spellOrder = {'Animate Dead', 'Annihilation', 'Avalanche', 'Berserk', 'Blood Rage', 'Brutal Strike', 'Cancel Invisibility', 'Challenge', 'Chameleon', 'Charge', 'Conjure Arrow', 'Conjure Bolt', 'Conjure Explosive Arrow', 'Conjure Piercing Bolt', 'Conjure Poisoned Arrow', 'Conjure Power Bolt', 'Conjure Sniper Arrow', 'Convince Creature', 'Creature Illusion', 'Cure Bleeding', 'Cure Burning', 'Cure Curse', 'Cure Electrification', 'Cure Poison', 'Cure Poison Rune', 'Curser', 'Death Strike', 'Desintegrate', 'Destroy Field', 'Divine Caldera', 'Divine Healing', 'Divine Missile', 'Electrify', 'Enchant Party', 'Enchant Spear', 'Enchant Staff', 'Energy Beam', 'Energy Field', 'Energy Strike', 'Energy Wall', 'Energy Wave', 'Energybomb', 'Envenom', 'Eternal Winter', 'Ethereal Spear', 'Explosion', 'Fierce Berserk', 'Find Person', 'Fire Field', 'Fire Wall', 'Fire Wave', 'Fireball', 'Firebomb', 'Flame Strike', 'Food', 'Front Sweep', 'Great Energy Beam', 'Great Fireball', 'Great Light', 'Groundshaker', 'Haste', 'Heal Friend', 'Heal Party', 'Heavy Magic Missile', 'Hells Core', 'Holy Flash', 'Holy Missile', 'Ice Strike', 'Ice Wave', 'Icicle', 'Ignite', 'Inflict Wound', 'Intense Healing', 'Intense Healing Rune', 'Intense Recovery', 'Intense Wound Cleansing', 'Invisibility', 'Levitate', 'Light', 'Light Healing', 'Light Magic Missile', 'Lightning', 'Magic Rope', 'Magic Shield', 'Magic Wall', 'Mass Healing', 'Paralyze', 'Physical Strike', 'Poison Bomb', 'Poison Field', 'Poison Wall', 'Protect Party', 'Protector', 'Rage of the Skies', 'Recovery', 'Salvation', 'Sharpshooter', 'Soulfire', 'Stalagmite', 'Stone Shower', 'Strong Energy Strike', 'Strong Ethereal Spear', 'Strong Flame Strike', 'Strong Haste', 'Strong Ice Strike', 'Strong Ice Wave', 'Strong Terra Strike', 'Sudden Death', 'Summon Creature', 'Swift Foot', 'Terra Strike', 'Terra Wave', 'Thunderstorm', 'Train Party', 'Ultimate Energy Strike', 'Ultimate Flame Strike', 'Ultimate Healing', 'Ultimate Healing Rune', 'Ultimate Ice Strike', 'Ultimate Light', 'Ultimate Terra Strike', 'Whirlwind Throw', 'Wild Growth', 'Wound Cleansing', 'Wrath of Nature'}
},
['Sample'] = {
iconFile = 'sample.png',
iconSize = {width = 64, height = 64},
spellOrder = {'Critical Strike', 'Firefly', 'Fire Breath', 'Moonglaives', 'Wind Walk'}
}
}
local SpelllistProfile = 'Default'
spelllistWindow = nil
spelllistButton = nil
spellList = nil
@ -10,6 +28,7 @@ cooldownValueLabel = nil
levelValueLabel = nil
manaValueLabel = nil
premiumValueLabel = nil
descriptionValueLabel = nil
vocationBoxAny = nil
vocationBoxSorcerer = nil
@ -56,13 +75,23 @@ local filters = {
groupId = FILTER_GROUP_ANY
}
local spellDisplayOrder = {'Animate Dead', 'Annihilation', 'Avalanche', 'Berserk', 'Blood Rage', 'Brutal Strike', 'Cancel Invisibility', 'Challenge', 'Chameleon', 'Charge', 'Conjure Arrow', 'Conjure Bolt', 'Conjure Explosive Arrow', 'Conjure Piercing Bolt', 'Conjure Poisoned Arrow', 'Conjure Power Bolt', 'Conjure Sniper Arrow', 'Convince Creature', 'Creature Illusion', 'Cure Bleeding', 'Cure Burning', 'Cure Curse', 'Cure Electrification', 'Cure Poison', 'Cure Poison Rune', 'Curser', 'Death Strike', 'Desintegrate', 'Destroy Field', 'Divine Caldera', 'Divine Healing', 'Divine Missile', 'Electrify', 'Enchant Party', 'Enchant Spear', 'Enchant Staff', 'Energy Beam', 'Energy Field', 'Energy Strike', 'Energy Wall', 'Energy Wave', 'Energybomb', 'Envenom', 'Eternal Winter', 'Ethereal Spear', 'Explosion', 'Fierce Berserk', 'Find Person', 'Fire Field', 'Fire Wall', 'Fire Wave', 'Fireball', 'Firebomb', 'Flame Strike', 'Food', 'Front Sweep', 'Great Energy Beam', 'Great Fireball', 'Great Light', 'Groundshaker', 'Haste', 'Heal Friend', 'Heal Party', 'Heavy Magic Missile', 'Hells Core', 'Holy Flash', 'Holy Missile', 'Ice Strike', 'Ice Wave', 'Icicle', 'Ignite', 'Inflict Wound', 'Intense Healing', 'Intense Healing Rune', 'Intense Recovery', 'Intense Wound Cleansing', 'Invisibility', 'Levitate', 'Light', 'Light Healing', 'Light Magic Missile', 'Lightning', 'Magic Rope', 'Magic Shield', 'Magic Wall', 'Mass Healing', 'Paralyze', 'Physical Strike', 'Poison Bomb', 'Poison Field', 'Poison Wall', 'Protect Party', 'Protector', 'Rage of the Skies', 'Recovery', 'Salvation', 'Sharpshooter', 'Soulfire', 'Stalagmite', 'Stone Shower', 'Strong Energy Strike', 'Strong Ethereal Spear', 'Strong Flame Strike', 'Strong Haste', 'Strong Ice Strike', 'Strong Ice Wave', 'Strong Terra Strike', 'Sudden Death', 'Summon Creature', 'Swift Foot', 'Terra Strike', 'Terra Wave', 'Thunderstorm', 'Train Party', 'Ultimate Energy Strike', 'Ultimate Flame Strike', 'Ultimate Healing', 'Ultimate Healing Rune', 'Ultimate Ice Strike', 'Ultimate Light', 'Ultimate Terra Strike', 'Whirlwind Throw', 'Wild Growth', 'Wound Cleansing', 'Wrath of Nature'}
function setSpelllistProfile(name)
if SpelllistProfile == name then return end
function getIconImageClip(id)
return (((id-1)%12)*32) .. ' ' .. ((math.ceil(id/12)-1)*32) .. ' 32 32'
if SpelllistSettings[name] and SpellInfo[name] then
local oldProfile = SpelllistProfile
SpelllistProfile = name
changeSpelllistProfile(oldProfile)
else
perror('Spelllist profile \'' .. name .. '\' could not be set.')
end
end
function setupOptions()
function getIconImageClip(id)
return (((id-1)%12)*SpelllistSettings[SpelllistProfile].iconSize.width) .. ' ' .. ((math.ceil(id/12)-1)*SpelllistSettings[SpelllistProfile].iconSize.height) .. ' ' .. SpelllistSettings[SpelllistProfile].iconSize.width .. ' ' .. SpelllistSettings[SpelllistProfile].iconSize.height
end
function setOptions()
if g_game.getClientVersion() >= 950 then -- Vocation is only send in newer clients
spelllistWindow:getChildById('buttonFilterVocation'):setVisible(true)
else
@ -71,7 +100,7 @@ function setupOptions()
end
function init()
connect(g_game, { onGameStart = setupOptions,
connect(g_game, { onGameStart = setOptions,
onGameEnd = resetWindow })
spelllistWindow = g_ui.displayUI('spelllist.otui', modules.game_interface.getRightPanel())
@ -89,6 +118,7 @@ function init()
levelValueLabel = spelllistWindow:getChildById('labelLevelValue')
manaValueLabel = spelllistWindow:getChildById('labelManaValue')
premiumValueLabel = spelllistWindow:getChildById('labelPremiumValue')
descriptionValueLabel = spelllistWindow:getChildById('labelDescriptionValue')
vocationBoxAny = spelllistWindow:getChildById('vocationBoxAny')
vocationBoxSorcerer = spelllistWindow:getChildById('vocationBoxSorcerer')
@ -136,33 +166,13 @@ function init()
g_keyboard.bindKeyPress('Down', function() spellList:focusNextChild(KeyboardFocusReason) end, spelllistWindow)
g_keyboard.bindKeyPress('Up', function() spellList:focusPreviousChild(KeyboardFocusReason) end, spelllistWindow)
for i = 1, #spellDisplayOrder do
local spell = spellDisplayOrder[i]
local info = SpellInfo[spell]
local tmpLabel = g_ui.createWidget('SpellListLabel', spellList)
tmpLabel:setId(spell)
tmpLabel:setText(spell .. '\n\'' .. info.words .. '\'')
tmpLabel:setPhantom(false)
if not(SpellIcons[info.icon]) then
perror('Spell icon \'' .. info.icon .. '\' not found.')
else
tmpLabel:setImageClip(getIconImageClip(SpellIcons[info.icon][1]))
end
tmpLabel.onClick = updateSpellInformation
end
connect(spellList, { onChildFocusChange = function(self, focusedChild)
if focusedChild == nil then return end
updateSpellInformation(focusedChild)
end })
setupOptions()
initialiseSpelllist()
setOptions()
resizeWindow()
end
function terminate()
disconnect(g_game, { onGameStart = setupOptions,
disconnect(g_game, { onGameStart = setOptions,
onGameEnd = resetWindow })
disconnect(spellList, { onChildFocusChange = function(self, focusedChild)
@ -192,6 +202,7 @@ function terminate()
levelValueLabel = nil
manaValueLabel = nil
premiumValueLabel = nil
descriptionValueLabel = nil
vocationBoxAny = nil
vocationBoxSorcerer = nil
@ -209,13 +220,64 @@ function terminate()
premiumBoxYes = nil
end
function initialiseSpelllist()
for i = 1, #SpelllistSettings[SpelllistProfile].spellOrder do
local spell = SpelllistSettings[SpelllistProfile].spellOrder[i]
local info = SpellInfo[SpelllistProfile][spell]
local tmpLabel = g_ui.createWidget('SpellListLabel', spellList)
tmpLabel:setId(spell)
tmpLabel:setText(spell .. '\n\'' .. info.words .. '\'')
tmpLabel:setPhantom(false)
local iconId = tonumber(info.icon)
if not iconId and SpellIcons[info.icon] then
iconId = SpellIcons[info.icon][1]
end
if not(iconId) then
perror('Spell icon \'' .. info.icon .. '\' not found.')
end
tmpLabel:setHeight(SpelllistSettings[SpelllistProfile].iconSize.height + 4)
tmpLabel:setTextOffset(topoint((SpelllistSettings[SpelllistProfile].iconSize.width + 10) .. ' ' .. (SpelllistSettings[SpelllistProfile].iconSize.height - 32)/2 + 3))
tmpLabel:setImageSource('/game_spelllist/icons/' .. SpelllistSettings[SpelllistProfile].iconFile)
tmpLabel:setImageClip(getIconImageClip(iconId))
tmpLabel:setImageSize(tosize(SpelllistSettings[SpelllistProfile].iconSize.width .. ' ' .. SpelllistSettings[SpelllistProfile].iconSize.height))
tmpLabel.onClick = updateSpellInformation
end
connect(spellList, { onChildFocusChange = function(self, focusedChild)
if focusedChild == nil then return end
updateSpellInformation(focusedChild)
end })
end
function changeSpelllistProfile(oldProfile)
-- Delete old labels
for i = 1, #SpelllistSettings[oldProfile].spellOrder do
local spell = SpelllistSettings[oldProfile].spellOrder[i]
local tmpLabel = spellList:getChildById(spell)
tmpLabel:destroy()
end
-- Create new spelllist and ajust window
initialiseSpelllist()
setOptions()
resizeWindow()
resetWindow()
end
function updateSpelllist()
for i = 1, #spellDisplayOrder do
local spell = spellDisplayOrder[i]
local info = SpellInfo[spell]
for i = 1, #SpelllistSettings[SpelllistProfile].spellOrder do
local spell = SpelllistSettings[SpelllistProfile].spellOrder[i]
local info = SpellInfo[SpelllistProfile][spell]
local tmpLabel = spellList:getChildById(spell)
local localPlayer = g_game.getLocalPlayer()
if not info.level then print(spell) end
if (not(filters.level) or info.level <= localPlayer:getLevel()) and (not(filters.vocation) or table.find(info.vocations, localPlayer:getVocation())) and (filters.vocationId == FILTER_VOCATION_ANY or table.find(info.vocations, filters.vocationId) or table.find(info.vocations, filters.vocationId+4)) and (filters.groupId == FILTER_GROUP_ANY or info.group[filters.groupId]) and (filters.premium == FILTER_PREMIUM_ANY or (info.premium and filters.premium == FILTER_PREMIUM_YES) or (not(info.premium) and filters.premium == FILTER_PREMIUM_NO)) then
tmpLabel:setVisible(true)
else
@ -236,9 +298,10 @@ function updateSpellInformation(widget)
local level = ''
local mana = ''
local premium = ''
local description = ''
if SpellInfo[spell] then
local info = SpellInfo[spell]
if SpellInfo[SpelllistProfile][spell] then
local info = SpellInfo[SpelllistProfile][spell]
name = spell
formula = info.words
@ -262,6 +325,7 @@ function updateSpellInformation(widget)
level = info.level
mana = info.mana .. ' / ' .. info.soul
premium = (info.premium and 'yes' or 'no')
description = info.description or '-'
end
nameValueLabel:setText(name)
@ -273,6 +337,7 @@ function updateSpellInformation(widget)
levelValueLabel:setText(level)
manaValueLabel:setText(mana)
premiumValueLabel:setText(premium)
descriptionValueLabel:setText(description)
end
function toggle()
@ -333,6 +398,11 @@ function toggleFilter(widget, selectedWidget)
updateSpelllist()
end
function resizeWindow()
spelllistWindow:setWidth(SpelllistSettings['Default'].spellWindowWidth + SpelllistSettings[SpelllistProfile].iconSize.width - 32)
spellList:setWidth(SpelllistSettings['Default'].spellListWidth + SpelllistSettings[SpelllistProfile].iconSize.width - 32)
end
function resetWindow()
spelllistWindow:hide()
spelllistButton:setOn(false)

View File

@ -29,7 +29,7 @@ SpellInfoValueLabel < Label
MainWindow
id: spelllistWindow
!text: tr('Spell List')
size: 500 400
size: 550 400
@onEscape: toggle()
TextList
@ -142,6 +142,12 @@ MainWindow
anchors.top: labelMana.bottom
text: Premium:
SpellInfoLabel
id: labelDescription
anchors.left: spellList.right
anchors.top: labelPremium.bottom
text: Description:
SpellInfoValueLabel
id: labelNameValue
anchors.left: labelName.right
@ -187,6 +193,11 @@ MainWindow
anchors.left: labelPremium.right
anchors.top: labelManaValue.bottom
SpellInfoValueLabel
id: labelDescriptionValue
anchors.left: labelDescription.right
anchors.top: labelPremiumValue.bottom
Label
id: labelVocationFilter
anchors.top: labelPremium.bottom
@ -194,7 +205,7 @@ MainWindow
width: 70
font: verdana-11px-monochrome
text: Vocation
margin-top: 25
margin-top: 30
margin-left: 20
CheckBox
@ -245,7 +256,7 @@ MainWindow
width: 70
font: verdana-11px-monochrome
text: Group
margin-top: 25
margin-top: 30
margin-left: 20
CheckBox
@ -288,7 +299,7 @@ MainWindow
width: 70
font: verdana-11px-monochrome
text: Premium
margin-top: 25
margin-top: 30
margin-left: 20
CheckBox

View File

@ -1,5 +1,6 @@
-- ['Spell Name'] = {words = '', exhaustion = spellCooldown, premium = true/false, type = 'Instant'/'Conjure', icon = iconName, mana = manaCost, level = levelRequirement, soul = soulCost, group = {[groupId] = groupCooldown}, vocation = {vocationIds}}
SpellInfo = {
['Default'] = {
['Death Strike'] = {words = 'exori mort', exhaustion = 2000, premium = true, type = 'Instant', icon = 'deathstrike', mana = 20, level = 16, soul = 0, group = {[1] = 2000}, vocations = {1, 5}},
['Flame Strike'] = {words = 'exori flam', exhaustion = 2000, premium = true, type = 'Instant', icon = 'flamestrike', mana = 20, level = 14, soul = 0, group = {[1] = 2000}, vocations = {1, 2, 5, 6}},
['Strong Flame Strike'] = {words = 'exori gran flam', exhaustion = 8000, premium = true, type = 'Instant', icon = 'strongflamestrike', mana = 60, level = 70, soul = 0, group = {[1] = 2000, [4] = 8000}, vocations = {1, 5}},
@ -78,7 +79,7 @@ SpellInfo = {
['Protector'] = {words = 'utamo tempo', exhaustion = 2000, premium = true, type = 'Instant', icon = 'protector', mana = 200, level = 55, soul = 0, group = {[1] = 10000, [3] = 2000}, vocations = {4, 8}},
['Blood Rage'] = {words = 'utito tempo', exhaustion = 2000, premium = true, type = 'Instant', icon = 'bloodrage', mana = 290, level = 60, soul = 0, group = {[3] = 2000}, vocations = {4, 8}},
['Train Party'] = {words = 'utito mas sio', exhaustion = 2000, premium = true, type = 'Instant', icon = 'trainparty', mana = 'Var.', level = 32, soul = 0, group = {[3] = 2000}, vocations = {8}},
['Protect Party'] = {words = 'utamo mas sio', exhaustion = 2000, premium = true, type = 'Instant', icon = 'protectparty', mana = 'Var.', evel = 32, soul = 0, group = {[3] = 2000}, vocations = {7}},
['Protect Party'] = {words = 'utamo mas sio', exhaustion = 2000, premium = true, type = 'Instant', icon = 'protectparty', mana = 'Var.', level = 32, soul = 0, group = {[3] = 2000}, vocations = {7}},
['Heal Party'] = {words = 'utura mas sio', exhaustion = 2000, premium = true, type = 'Instant', icon = 'healparty', mana = 'Var.', level = 32, soul = 0, group = {[3] = 2000}, vocations = {6}},
['Enchant Party'] = {words = 'utori mas sio', exhaustion = 2000, premium = true, type = 'Instant', icon = 'enchantparty', mana = 'Var.', level = 32, soul = 0, group = {[3] = 2000}, vocations = {5}},
['Summon Creature'] = {words = 'utevo res', exhaustion = 2000, premium = false, type = 'Instant', icon = 'summoncreature', mana = 'Var.', level = 25, soul = 0, group = {[3] = 2000}, vocations = {1, 2, 5, 6}},
@ -125,6 +126,15 @@ SpellInfo = {
['Stone Shower'] = {words = 'adori mas tera', exhaustion = 2000, premium = false, type = 'Conjure', icon = 'stoneshower', mana = 430, level = 28, soul = 3, group = {[3] = 2000}, vocations = {2, 6}},
['Thunderstorm'] = {words = 'adori mas vis', exhaustion = 2000, premium = false, type = 'Conjure', icon = 'thunderstorm', mana = 430, level = 28, soul = 3, group = {[3] = 2000}, vocations = {1, 5}},
['Holy Missile'] = {words = 'adori san', exhaustion = 2000, premium = false, type = 'Conjure', icon = 'holymissile', mana = 350, level = 27, soul = 3, group = {[3] = 2000}, vocations = {3, 7}}
},
['Sample'] = {
['Wind Walk'] = {words = 'windwalk', description = 'Run at enormous speed.', exhaustion = 2000, premium = false, type = 'Instant', icon = 1, mana = 50, level = 10, soul = 0, group = {[3] = 2000}, vocations = {1, 2}},
['Fire Breath'] = {words = 'firebreath', description = 'A strong firewave.', exhaustion = 2000, premium = false, type = 'Instant', icon = 2, mana = 350, level = 27, soul = 0, group = {[1] = 2000}, vocations = {4, 8}},
['Moonglaives'] = {words = 'moonglaives', description = 'Throw moonglaives around you.', exhaustion = 2000, premium = false, type = 'Instant', icon = 3, mana = 90, level = 55, soul = 0, group = {[1] = 2000}, vocations = {3, 7}},
['Critical Strike'] = {words = 'criticalstrike', description = 'Land a critical strike.', exhaustion = 2000, premium = false, type = 'Instant', icon = 4, mana = 350, level = 27, soul = 0, group = {[1] = 2000}, vocations = {3, 4, 7, 8}},
['Firefly'] = {words = 'firefly', description = 'Summon a angry firefly', exhaustion = 2000, premium = false, type = 'Instant', icon = 5, mana = 350, level = 27, soul = 0, group = {[1] = 2000}, vocations = {1, 2, 5, 6}}
}
}
-- ['const_name'] = {client_id, TFS_id}