Page 4 of 4

Re: cloneObject for LoG2 (important bug fix 30.11)

Posted: Thu Dec 04, 2014 6:18 pm
by QuintinStone
JKos wrote:Update: added modifyObjects function

Description: Modifies multiple objects filtered by component names
Example: Add meleeattack.onHitMonster hook to all objects which do have both item and meleeattack components (which means all melee weapons).

Code: Select all

modifyObjects{
	filter = {
		hasComponents = {'item','meleeattack'}
	},
	components = {
		{ 
			name = 'meleeattack',
			onHitMonster = function(self, monster, tside, damage, champion)
				print(champion:getName(),'hits',monster.go.id,'with',self.go.name,'from',tside,'dealing damage:',damage)
			end
		}
	}

}
Warning: will override default values, so in this example all default onHitMonster-hooks on melee weapons will be overridden.

I will probably add more filters later, for example traits or tags could be useful.

Edit: I changed the installation method, see opening post.
Very slick. Well done.

Re: cloneObject for LoG2 (update: modifyObjects)

Posted: Thu Dec 04, 2014 7:35 pm
by cromcrom
So, here is the connect weapon to monster hook that was sorely needed. Thanks a lot for this, again, JKos.