Basically I want to recharge a spent item, I know I can do a destroy and spawn in an alcove, but is there a way to do this and/or recharge it while the players has it in their hands?
Say a fighter has the Fire Blade and it's empty, can I have a spell that will swap it for a charged one or recharge it while he is holding it?
Scripting Experts: Is This Possible?
Re: Scripting Experts: Is This Possible?
The Crystal of Recharging does exactly that as an usable item
Re: Scripting Experts: Is This Possible?
We are in the LoG 1 section...
- Zo Kath Ra
- Posts: 940
- Joined: Sat Apr 21, 2012 9:57 am
- Location: Germany
Re: Scripting Experts: Is This Possible?
I haven't tried this, but maybe you could useHypnoToad wrote: ↑Tue Feb 05, 2019 9:36 am Basically I want to recharge a spent item, I know I can do a destroy and spawn in an alcove, but is there a way to do this and/or recharge it while the players has it in their hands?
Say a fighter has the Fire Blade and it's empty, can I have a spell that will swap it for a charged one or recharge it while he is holding it?
http://www.grimrock.net/modding_log1/sc ... reference/
Champion:getItem(slot)
Champion:removeItem(slot)
Champion:insertItem(slot, item)
Re: Scripting Experts: Is This Possible?
Thanks for the advice, I looked at that and it's beyond my limited scripting knowledge so I'm likely going with put the item in an alcove and insert a coin and it recharges (swaps it out for a recharged one).Zo Kath Ra wrote: ↑Tue Feb 05, 2019 10:28 pm I haven't tried this, but maybe you could use
http://www.grimrock.net/modding_log1/sc ... reference/
Champion:getItem(slot)
Champion:removeItem(slot)
Champion:insertItem(slot, item)
Re: Scripting Experts: Is This Possible?
Here is a working spell, and spell_scroll item.
Code: Select all
defineSpell{
name = "recharge_fireblade",
uiName = "Recharge Fireblade",
skill = "fire_magic",
level = 5,
runes = "ADE",
manaCost = 50,
onCast = function(champion, X, Y, direction, skill)
for slot = 7,8 do
local item = champion:getItem(slot)
if item and item.name == "fire_blade" then
item:setCharges(9)
champion:setCondition("fire_shield", 2)
playSound("generic_spell")
return
elseif item and item.name == "fire_blade_empty" then
champion:removeItem(slot)
champion:insertItem(slot, spawn('fire_blade'))
champion:getItem(slot):setCharges(9)
champion:setCondition("fire_shield", 2)
playSound("generic_spell")
return
end
end
hudPrint(champion:getName().."'s spell fizzled.")
hudPrint("[No equipped Fireblade]")
end
}
defineObject{
name = "scroll_recharge_fireblade",
class = "Item",
uiName = "Scroll of Recharge Fireblade",
model = "assets/models/items/scroll_spell.fbx",
gfxIndex = 113,
scroll = true,
spell = "recharge_fireblade",
weight = 0.3,
}
Re: Scripting Experts: Is This Possible?
Wow, that's just what I wanted, thanks soooooo much!Isaac wrote: ↑Wed Feb 06, 2019 1:25 am Here is a working spell, and spell_scroll item.
Code: Select all
defineSpell{ name = "recharge_fireblade", uiName = "Recharge Fireblade", skill = "fire_magic", level = 5, runes = "ADE", manaCost = 50, onCast = function(champion, X, Y, direction, skill) for slot = 7,8 do local item = champion:getItem(slot) if item and item.name == "fire_blade" then item:setCharges(9) champion:setCondition("fire_shield", 2) playSound("generic_spell") return elseif item and item.name == "fire_blade_empty" then champion:removeItem(slot) champion:insertItem(slot, spawn('fire_blade')) champion:getItem(slot):setCharges(9) champion:setCondition("fire_shield", 2) playSound("generic_spell") return end end hudPrint(champion:getName().."'s spell fizzled.") hudPrint("[No equipped Fireblade]") end } defineObject{ name = "scroll_recharge_fireblade", class = "Item", uiName = "Scroll of Recharge Fireblade", model = "assets/models/items/scroll_spell.fbx", gfxIndex = 113, scroll = true, spell = "recharge_fireblade", weight = 0.3, }
