Few questions

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Few questions

Post by petri »

To workaround the shield protection issue you could implement custom onEquipItem and onUnequipItem hooks for the shield.
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Few questions

Post by Komag »

ah, didn't think of that, nice workaround
Finished Dungeons - complete mods to play
thermalburn
Posts: 13
Joined: Mon Dec 24, 2012 12:16 am

Re: Few questions

Post 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	
}
Last edited by thermalburn on Fri Dec 28, 2012 1:31 am, edited 1 time in total.
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: Few questions

Post by JKos »

you have to enclose strings with ' or "
eg.
champion:modifyStat('protection',2)

plain protection means a variable named protection.
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
thermalburn
Posts: 13
Joined: Mon Dec 24, 2012 12:16 am

Re: Few questions

Post 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,
}
Post Reply