[SCRIPT] Force a champion to own the scroll before casting
Posted: Fri Nov 14, 2014 8:28 pm
Hi,
Like I said in my thread about new spells, here is the script I use to force a champion to have the scroll of a spell in his inventory or in his hand to be able to cast it. You can throw it in the file "init.lua" or anywhere you want, and normally it enough. Nothing more is required.
As usual some fine tuning can be doing if you want. Obviously you have to had a "if" bloc for each new spell if you had some custom ones. For now the variable spellUiName isn't used but you can use it to create a contextual message if you want.
Like I said in my thread about new spells, here is the script I use to force a champion to have the scroll of a spell in his inventory or in his hand to be able to cast it. You can throw it in the file "init.lua" or anywhere you want, and normally it enough. Nothing more is required.
As usual some fine tuning can be doing if you want. Obviously you have to had a "if" bloc for each new spell if you had some custom ones. For now the variable spellUiName isn't used but you can use it to create a contextual message if you want.
SpoilerShow
Code: Select all
defineObject{
name = "party",
baseObject = "party",
components = {
{
class = "Party",
onCastSpell =
function(party,champion,spellName)
local itmName = ""
local spellUiName = ""
if spellName == "water_breathing" then
itmName = "scroll_water_breathing"
spellUiName = "Water Breathing"
end
if spellName == "resurrection" then
itmName = "scroll_resurrection"
spellUiName = "Resurrection"
end
if spellName == "antidote" then
itmName = "scroll_antidote"
spellUiName = "Antidote"
end
if spellName == "recovery" then
itmName = "scroll_recovery"
spellUiName = "Recovery"
end
if spellName == "antivenom" then
itmName = "scroll_antivenom"
spellUiName = "Antivenom"
end
if spellName == "enchant_arrow" then
itmName = "scroll_enchant_arrow"
spellUiName = "Enchant Arrow"
end
if spellName == "heal" then
itmName = "scroll_heal"
spellUiName = "Healing"
end
if spellName == "mass_heal" then
itmName = "scroll_mass_heal"
spellUiName = "Mass Healing"
end
if spellName == "shield" then
itmName = "scroll_shield"
spellUiName = "Shield"
end
if spellName == "force_field" then
itmName = "scroll_force_field"
spellUiName = "Force Field"
end
if spellName == "fireburst" then
itmName = "scroll_fireburst"
spellUiName = "Fireburst"
end
if spellName == "light" then
itmName = "scroll_light"
spellUiName = "Light"
end
if spellName == "darkness" then
itmName = "scroll_darkness"
spellUiName = "Darkness"
end
if spellName == "darkbolt" then
itmName = "scroll_darkbolt"
spellUiName = "Darkbolt"
end
if spellName == "fireball" then
itmName = "scroll_fireball"
spellUiName = "Fireball"
end
if spellName == "meteor_storm" then
itmName = "scroll_meteor_storm"
spellUiName = "Meteor Storm"
end
if spellName == "shock" then
itmName = "scroll_shock"
spellUiName = "Shock"
end
if spellName == "invisibility" then
itmName = "scroll_invisibility"
spellUiName = "Invisibility"
end
if spellName == "lightning_bolt" then
itmName = "scroll_lightning_bolt"
spellUiName = "Lightning Bolt"
end
if spellName == "poison_cloud" then
itmName = "scroll_poison_cloud"
spellUiName = "Poison Cloud"
end
if spellName == "poison_bolt" then
itmName = "scroll_poison_bolt"
spellUiName = "Poison Bolt"
end
if spellName == "ice_shards" then
itmName = "scroll_ice_shards"
spellUiName = "Ice Shards"
end
if spellName == "dispel" then
itmName = "scroll_dispel"
spellUiName = "Dispel"
end
if spellName == "frostbolt" then
itmName = "scroll_frostbolt"
spellUiName = "Frostbolt"
end
if spellName == "fire_shield" then
itmName = "scroll_fire_shield"
spellUiName = "Fire Shield"
end
if spellName == "shock_shield" then
itmName = "scroll_shock_shield"
spellUiName = "Shock Shield"
end
if spellName == "poison_shield" then
itmName = "scroll_poison_shield"
spellUiName = "Poison Shield"
end
if spellName == "frost_shield" then
itmName = "scroll_frost_shield"
spellUiName = "Frost Shield"
end
for i = 1, 32, 1 do
if champion:getItem(i) ~= nil and champion:getItem(i).go.name == itmName then
return true
end
end
hudPrint(champion:getName().." needs to have the spell scroll on him to be able to cast it")
return false
end
}
},
}