A list of what hooks i've found.

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
Prozail
Posts: 158
Joined: Mon Oct 27, 2014 3:36 pm

A list of what hooks i've found.

Post by Prozail »

Here are all the hooks that are atleast worth testing.
Consider that many components inherit from others, so check the baseclass for more hooks.

Code: Select all


	ChampionComponent
	onReceiveCondition
	onCastSpell
	onDamage
	onDie
	onAttack
	onLevelUp
	
	MonsterComponent - 
	onEndAction
	onPerformAction
	onBeginAction 
	onHitMonster
	onDamage
	onDie
	
	FloorTrigger - 
	onToggle
	onDeactivate
	onActivate
	
	MonsterActionComponent -
		MonsterMoveComponent - 
			onUnlinkMonsterGroup
	
	HealthComponent - 
	onDie
	
	RangedAttackComponent - 
	onPostAttack
	
	ThrowAttackComponent - 
	onPostAttack
	
	TileDamagerComponent - 
	onHitChampion
	onHitMonster
	onHitObstacle
	
	BrainComponent - 
	onThink
	onBloodied
	
	TricksterBrainComponent - 
	onThinkSpecial
	
	ControllerComponent - 
	onInitialActivate
	onInitialDeactivate
	onInitialOpen
	onInitialClose
	onActivate
	onDeactivate
	onToggle
	onOpen
	onClose
	onIncrement
	onDecrement
	onReset
	onStart
	onStop
	onPause
	
	ItemComponent
	onProjectileHit
	onEquipItem
	onUnequipItem
	onPickUpItem
	onItemHitEntity - Internal??
	
	WallTriggerComponent
	onActivate
	
	UsableItemComponent
	onUseItem
	
	LightComponent
	onUpdate
	
	EquipmentItemComponent
	onRecomputeStats
	onComputeAccuracy
	onComputeCritChance
	
	MonsterActionComponent
	onAnimationEvent
	
	FirearmAttackComponent
	onBackfire
	onPostAttack
	
	SocketComponent
	onInsertItem
	onAcceptItem
	onRemoveItem
	
	ClickableComponent
	onClick
	
	CameraComponent
	onUpdate
	
	MonsterAttackComponent
	onAttack
	onAttackHit
	onDealDamage
	
	ContainerItemComponent
	onInsertItem
	onRemoveItem
	
	ProjectileImpactComponent
	onHitEntity
	onHitMonster
	onHitParty
	
	AnimationComponent
	onAnimationEvent
	
	
	SurfaceComponent
	onInsertItem
	onRemoveItem
	
	ItemActionComponent--
		MeleeAttackComponent
			onPostAttack
	
	
	PortalComponent
	onArrival
	
	LockComponent
	onActivate
	
	FloorTriggerComponent
	onActivate
	onToggle
	onDeactivate
	
	ButtonComponent
	onActivate
	
	CharSheetComponent - prob. not accessible
	onDrawInventory
	onDrawStats
	
	CounterComponent
	onActivate
	onDeactivate
	
	DoorComponent
	onOpen
	onClose
	onAttackedByChampion
	
	LeverComponent
	onActivate
	onToggle
	onDeactivate
	
	PartyComponent
	onRest
	onTurn
	onWakeUp
	onMove
	
	ProjectileComponent
	onProjectileHit
	
	SpawnerComponent
	onActivate
	
	TimerComponent
	onActivate
	
	WallTextComponent
	onShowText
	onDismissText
	
	


MrChoke
Posts: 324
Joined: Sat Oct 25, 2014 7:20 pm

Re: A list of what hooks i've found.

Post by MrChoke »

Prozail, man I don't know what I am doing wrong with these hooks. I can't get any monster ones to work. You say you got "onDie" and "OnPerofrmAction" to work for example. All I get is runtime errors. Here is my monster in monsters.lua:

Code: Select all

defineObject{
  	name = "skeleton_test",
   	baseObject = "skeleton_trooper",   
   	components = {
   		{
			class = "Monster",
		   	onDie = function()
				print("hit hook")
		   	end
        },     
   	}
 }   
The dungeon loads fine. As soon as I try to preview I get this:
[string "Monster.lua]:0: bad argument #1 to findNode (string expected, got nil)

No idea what it is complaining about. Getting very frustrated with these hooks. I am starting to think these are mostly broken until the next update.

You are getting these to work?



UPDATE: I get them to work when added dynamically! That is good. Still don't know what I am doing wrong with the monster.lua script though...

ALSO: Thanks for figuring "onPerformAction". That is huge. Because the actions I am getting are "move" and "turn". That is where onMove for monsters went.
User avatar
Leki
Posts: 550
Joined: Wed Sep 12, 2012 3:49 pm

Re: A list of what hooks i've found.

Post by Leki »

... you just replaced complex asset definition of skeleton_troopers 'Monster class', by yours own 'Monster' class, so your Monster definition is missing this. In other words, you can replace model class, where is only "one line" in definition --> path to the model, but not 'Monster' where is a ton of obligatory definitions we don't known yet.
I'm the Gate I'm the Key.
Dawn of Lore
MrChoke
Posts: 324
Joined: Sat Oct 25, 2014 7:20 pm

Re: A list of what hooks i've found.

Post by MrChoke »

Leki wrote:... you just replaced complex asset definition of skeleton_troopers 'Monster class', by yours own 'Monster' class, so your Monster definition is missing this. In other words, you can replace model class, where is only "one line" in definition --> path to the model, but not 'Monster' where is a ton of obligatory definitions we don't known yet.
I am not so sure about that. With Log 2, we clone objects using defineObject but we specify the "baseObject". So I should have gotten all of what defines a "skeleton_trooper" and then overwritten any behavior I wanted in the script. All I was overwriting was trying to get the hooks to work.
cameronC
Posts: 80
Joined: Wed Apr 11, 2012 10:54 pm

Re: A list of what hooks i've found.

Post by cameronC »

MrChoke wrote:
Leki wrote:... you just replaced complex asset definition of skeleton_troopers 'Monster class', by yours own 'Monster' class, so your Monster definition is missing this. In other words, you can replace model class, where is only "one line" in definition --> path to the model, but not 'Monster' where is a ton of obligatory definitions we don't known yet.
I am not so sure about that. With Log 2, we clone objects using defineObject but we specify the "baseObject". So I should have gotten all of what defines a "skeleton_trooper" and then overwritten any behavior I wanted in the script. All I was overwriting was trying to get the hooks to work.
Custom assets will take all of the components of the baseObject but altering any component overrides the entire component of the baseObject. So if you clone a dagger and change only the attackPower of the meleeAttack component, everything else in that component will be empty (So you can't throw the dagger as it has no weight defined, the editor will complain about a gfxIndex as it is not defined anymore, etc).
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
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: A list of what hooks i've found.

Post by msyblade »

cloneObject would copy all of the originals properties, changing what you want from the original, whereas defineObject creates an entirely new object, with only the definitions you give it (in this case, almost nothing). You want to clone the trooper and its properties, until we get the asset reference and can define new ones correctly. Hope this helps!
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
User avatar
Leki
Posts: 550
Joined: Wed Sep 12, 2012 3:49 pm

Re: A list of what hooks i've found.

Post by Leki »

onDie is also in health I guess, so you can try:

Code: Select all

          {
             class = "Health",
             health = 1,
             onDie = function()
               print("I died.")
             end,
          },
Last edited by Leki on Mon Nov 03, 2014 2:05 am, edited 1 time in total.
I'm the Gate I'm the Key.
Dawn of Lore
User avatar
Prozail
Posts: 158
Joined: Mon Oct 27, 2014 3:36 pm

Re: A list of what hooks i've found.

Post by Prozail »

@leki: Monsters actually doesn't have a separate HealthComponent, its handled in MonsterComponent


this is the minimal definition of a monster (except for the onDie.. that can be removed)
what was missing was the "meshName" line.. that caused the nil error

Code: Select all


defineObject{
	name = "skeleton_test",
	baseObject = "skeleton_trooper",   
	components = {
		{
			class = "Monster",
			name = "monster",
			meshName = "skeleton_knight_trooper_mesh",
			onDie = function(sender)
				hudPrint("I'll be back!")
			end

		},     
	}
}   


NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: A list of what hooks i've found.

Post by NutJob »

I think you found what I was looking for earlier

Code: Select all

   PortalComponent
   onArrival
Thanks for this list!
MrChoke
Posts: 324
Joined: Sat Oct 25, 2014 7:20 pm

Re: A list of what hooks i've found.

Post by MrChoke »

Prozail wrote:@leki: Monsters actually doesn't have a separate HealthComponent, its handled in MonsterComponent


this is the minimal definition of a monster (except for the onDie.. that can be removed)
what was missing was the "meshName" line.. that caused the nil error

Code: Select all


defineObject{
	name = "skeleton_test",
	baseObject = "skeleton_trooper",   
	components = {
		{
			class = "Monster",
			name = "monster",
			meshName = "skeleton_knight_trooper_mesh",
			onDie = function(sender)
				hudPrint("I'll be back!")
			end

		},     
	}
}   


I am learning a lot. That works. Thanks guys!
Post Reply