Ask a simple question, get a simple answer

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
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

Is it possible to have the game perform an autosave without forcing the player to heal at a healing crystal?
Was thinking about self disabling floor triggers that autosave the game. If possible, into a different slot/name. (Not the default "Autosave" slot)
My asset pack [v1.10]
Features a bit of everything! :D
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Isaac wrote:
Connectors pass all the arguments that the hook has. A SurfaceComponent onInsertItem connector passes the SurfaceComponent and the ItemComponent.
Anytime a hook fires, its arguments are passed [afaik], but what's an example of a connector triggering a hook? (~besides onInsertItem /acceptItem, or script assigned.)
What on earth are you talking about? Connectors are triggered by hooks, not the other way around. Every time a hook triggers and doesn't return false, all connectors for that hook are triggered in order. All of these connectors receive the same arguments as the hook. PartyComponent.onDrawGui connectors pass the PartyComponent and the GraphicsContext, MonsterComponent.onProjectileHit connectors pass the MonsterComponent, ItemComponent, damage, and damageType, etc.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Howl3r
Posts: 12
Joined: Fri Aug 12, 2016 11:34 pm
Location: Finland

Re: Ask a simple question, get a simple answer

Post by Howl3r »

Is there a way to fiddle with timers and stuff so that I can make an enemy respawn in case it is not killed in given time?
User avatar
Eleven Warrior
Posts: 745
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Ask a simple question, get a simple answer

Post by Eleven Warrior »

Hi all.

Has or can anyone help me make a spell of Healing? When the spell is casted it checks to see if the champ(s) is wounded if not hudPrint Champ is not hurt, if wounded hudPrint Trynadore is healed,

It need to check if the caster is a certain level, has a certain trait, and requires eart or something else.

Also need the Scroll item to show the player gestures.

Thxs for the help on this.
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

minmay wrote:
Isaac wrote:
Connectors pass all the arguments that the hook has. A SurfaceComponent onInsertItem connector passes the SurfaceComponent and the ItemComponent.
Anytime a hook fires, its arguments are passed [afaik], but what's an example of a connector triggering a hook? (~besides onInsertItem /acceptItem, or script assigned.)
What on earth are you talking about? Connectors are triggered by hooks, not the other way around. Every time a hook triggers and doesn't return false, all connectors for that hook are triggered in order. All of these connectors receive the same arguments as the hook. PartyComponent.onDrawGui connectors pass the PartyComponent and the GraphicsContext, MonsterComponent.onProjectileHit connectors pass the MonsterComponent, ItemComponent, damage, and damageType, etc.
I wasn't talking about that, you seemed to be; so I asked for an example.

The original question was asking how to pass arguments with connectors [likely meaning plates and buttons, rather than user scripts]... and (erroneously) to hooks; unless I misread it.
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

Howl3r
Howl3r wrote:Is there a way to fiddle with timers and stuff so that I can make an enemy respawn in case it is not killed in given time?
If you need it as part of a custom monster, add this component:

Code: Select all

{
	class = "Timer",
	name = "respawnTimer",
	timerInterval = 10,
	disableSelf = true,
	onActivate = function(self)
	end,
},
And this to the monster component:

Code: Select all

onDie = function(self)
	if not self.go.respawnTimer:isEnabled() then
		self:setExp(0) --Preventing infinite xp (or don't)
		spawn(self.go.name, self.go.level, self.go.x, self.go.y, self.go.facing, self.go.elevation)
	end
end,
The monster will not respawn if it is killed within 10 seconds after it spawned, so be sure to spawn it (rather than placing it) when the party should encounter it. (or activate via script)
Since the monster object has a short delay before destroying itself, you could add another initially disabled timer and set its interval to something like 0.5 or 1, have it activate when the monster dies, and upon it activating, it'll spawn the new monster. Don't forget to add a fancy particle effect ;)


If you need it on a single monster, do the following:
Add a timer, name it "respawn_timer_1", make it disable self, and have the interval set to the time for the party to kill the monster.
Add a monster, name it "myMonster_1", and have it trigger the scripts "respawn" function on death.
Add a script entity, name it "respawn_script_1", and add this to it:

Code: Select all

function respawn(monster)
	if not respawn_timer_1.timer:isEnabled() then 
		if monster.go.id == "myMonster_1" then
			if not myMonster_2 then
				local m = spawn(monster.go.name, monster.go.level, monster.go.x, monster.go.y, monster.go.facing, monster.go.elevation, "myMonster_2")
				m.monster:addConnector("onDie", "respawn_script_1", "respawn")
				respawn_timer_1.timer:enable()
			else
				print("error")
			end
		elseif monster.go.id == "myMonster_2" then
			if not myMonster_1 then
				local m = spawn(monster.go.name, monster.go.level, monster.go.x, monster.go.y, monster.go.facing, monster.go.elevation, "myMonster_1")
				m.monster:addConnector("onDie", "respawn_script_1", "respawn")
				respawn_timer_1.timer:enable()
			else
				print("error")
			end
		else
			print("wrong ID")
		end
	else
		print("The monster died")
	end
end
Make sure the interval is not too small(higher than 5), so the monster object will be deleted by the time he is ready to respawn.
If you still want to the interval to be lower than 5, you could make then "myMonster_2" checker spawn a ""myMonster_3", and have its checker spawn a "myMonster_1".
Last edited by zimberzimber on Sun Aug 14, 2016 8:49 am, edited 1 time in total.
My asset pack [v1.10]
Features a bit of everything! :D
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

Eleven Warrior
Eleven Warrior wrote:Hi all.

Has or can anyone help me make a spell of Healing? When the spell is casted it checks to see if the champ(s) is wounded if not hudPrint Champ is not hurt, if wounded hudPrint Trynadore is healed,

It need to check if the caster is a certain level, has a certain trait, and requires eart or something else.

Also need the Scroll item to show the player gestures.

Thxs for the help on this.
Here: (not sure what you meant by "eart")

Code: Select all

defineSpell{ -- Heals the caster based on their life magic skill and concentration
	name = "heal",
	uiName = "Heal",
	gesture = 258,
	manaCost = 30,
	skill = "concentration",
	icon = 60,
	spellIcon = 1,
	description = "Heal your own wounds. \nHealth restored: concentration * 10 + 30",
	
	onCast = function(champion, x, y, direction, skill)
		local reqLv = 5
		local reqTrait = "wizard"
		if champion:getLevel() >= reqLv and champion:hasTrait(reqTrait) then
			if champion:getHealth() == champion:getMaxHealth() then
				hudPrint(champion:getName().." was healed")
			else
				hudPrint(champion:getName().." is not wounded")
			end
		end
	end,
}
From what I saw, scroll items are generated automatically.
My asset pack [v1.10]
Features a bit of everything! :D
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

zimberzimber wrote:Here: (not sure what you meant by "eart")
Earth

**Requires Earth [magic] or something**

BTW: Howl3r is posting questions in both the LoG1 and LoG2 threads; but which game? (It affects the answers)
Howl3r
Posts: 12
Joined: Fri Aug 12, 2016 11:34 pm
Location: Finland

Re: Ask a simple question, get a simple answer

Post by Howl3r »

Isaac wrote:
zimberzimber wrote:Here: (not sure what you meant by "eart")
Earth

**Requires Earth [magic] or something**

BTW: Howl3r is posting questions in both the LoG1 and LoG2 threads; but which game? (It affects the answers)
Oh f**k. Yeah thanks for noting me. I have been looking just through the internet for guides and haven't even noticed that a part of them are LoG 2 forums. Sorry about that :d
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

Isaac wrote:
zimberzimber wrote:Here: (not sure what you meant by "eart")
Earth

**Requires Earth [magic] or something**
Derp :?
Just need to replace concentration with earth_magic then
My asset pack [v1.10]
Features a bit of everything! :D
Post Reply