cloneObject for LoG2 (update: modifyObjects)

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: cloneObject for LoG2 (important bug fix 30.11)

Post by JKos »

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.
- 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
cameronC
Posts: 80
Joined: Wed Apr 11, 2012 10:54 pm

Re: cloneObject for LoG2 (update: modifyObjects)

Post by cameronC »

Quite useful! Thanks!
Writer and sometimes artist of the very slightly acclaimed comic series Scrambled Circuits. A comic series about a robot written by a human.

Grimrock 2 socketSystem: viewtopic.php?f=22&t=8546 / Github
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: cloneObject for LoG2 (update: modifyObjects)

Post by Drakkan »

supercool, thanks !
Breath from the unpromising waters.
Eye of the Atlantis
User avatar
QuintinStone
Posts: 72
Joined: Sat Nov 01, 2014 9:58 pm

Re: cloneObject for LoG2 (important bug fix 30.11)

Post 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.
Crypt of Zulfar
User avatar
cromcrom
Posts: 549
Joined: Tue Sep 11, 2012 7:16 am
Location: Chateauroux in a socialist s#!$*&% formerly known as "France"

Re: cloneObject for LoG2 (update: modifyObjects)

Post by cromcrom »

So, here is the connect weapon to monster hook that was sorely needed. Thanks a lot for this, again, JKos.
A trip of a thousand leagues starts with a step.
Post Reply