Page 2 of 2

Re: Few questions

Posted: Wed Dec 26, 2012 11:20 am
by petri
To workaround the shield protection issue you could implement custom onEquipItem and onUnequipItem hooks for the shield.

Re: Few questions

Posted: Wed Dec 26, 2012 4:22 pm
by Komag
ah, didn't think of that, nice workaround

Re: Few questions

Posted: Fri Dec 28, 2012 1:06 am
by thermalburn
petri wrote:To workaround the shield protection issue you could implement custom onEquipItem and onUnequipItem hooks for the shield.
i've been trying to get it to work but unfortunatly my scripting experience is limited. Upon equiping the shield, my editor just crashes. Could you please take a look at my script and see what could be causing this?

Code: Select all

cloneObject{
	name = "tower_shield",
	baseObject = "legionary_shield",
	uiName = "Scutum",
	evasion = 2,
	protection = 2,
	onEquipItem = function(champion,slot)
		champion:modifyStat(protection,2)
    end,
	onUnequipItem = function(champion,slot)
		champion:modifyStat(protection,-2)
    end	
}

Re: Few questions

Posted: Fri Dec 28, 2012 1:18 am
by JKos
you have to enclose strings with ' or "
eg.
champion:modifyStat('protection',2)

plain protection means a variable named protection.

Re: Few questions

Posted: Fri Dec 28, 2012 1:35 am
by thermalburn
ah thank you. its no longer crashing, so that was the problem.

EDIT #2:

got it to work correctly. I just had to up the maxstat of the stat. Here is the code if anyone is interested.

Code: Select all

cloneObject{
	name = "tower_shield",
	baseObject = "legionary_shield",
	uiName = "Scutum",
	evasion = 2,
	protection = 2,
	onEquipItem = function(champion,slot)
		if slot == 7 then
		champion:modifyStatCapacity("protection", 2)
		champion:modifyStat("protection", 2)			
		elseif slot == 8 then
		champion:modifyStatCapacity("protection", 2)
		champion:modifyStat("protection", 2)		
		else
		--do nothing
		end
    end,
	onUnequipItem = function(champion,slot)
		if slot == 7 then
		champion:modifyStatCapacity("protection", -2)
		champion:modifyStat("protection", -2)		
		elseif slot == 8 then
		champion:modifyStatCapacity("protection", -2)
		champion:modifyStat("protection", -2)	
		else
		--do nothing
		end
	end,
}