[SCRIPT] Example script for delayedCall

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!
Post Reply
User avatar
st1nger
Posts: 19
Joined: Wed May 29, 2013 8:44 pm
Location: Germany

[SCRIPT] Example script for delayedCall

Post by st1nger »

(I'm from germany, my english is not the best. Sorry about that.)

I didn't know whether this is interesting for you, but often I read the counter and timer are used here.
so in my example you need none of them.
Maybe it helps a few newcomers.


Example for an wizard sequence:

Code: Select all

function startWTalk1()
	delayedCall(self.go.id, 0.1, "teleeffect") -- all delayedCall lines start at the same time, you need to calculate the time between the scenes
	delayedCall(self.go.id, 0.4, "spawnwiz") -- delay 0.3 + 0.1 from above
	delayedCall(self.go.id, 2.4, "wiztext1") -- delay 2.0 + 0.4 from above
	delayedCall(self.go.id, 7.4, "wiztext2") -- delay 5.0 + 2.4 from above
	delayedCall(self.go.id, 12.4, "wiztext3") -- delay 5.0 + 7.4 from above
	delayedCall(self.go.id, 15.4, "wizCS") -- delay 3.0 + 12.4 from above
	delayedCall(self.go.id, 15.9, "setnight") -- delay 0.5 + 15.4 from above
	delayedCall(self.go.id, 17.9, "wiztext4") -- delay 2.0 + 15.9 from above
	delayedCall(self.go.id, 20.9, "wizESC") -- delay 3.0 + 17.9 from above
	delayedCall(self.go.id, 21.9, "wizlaugh") -- 1.0 + 20.9 from above
end

function teleeffect()
	spawn("teleportation_effect", 1, 15, 25, 2, 0) -- change coordinates as you wish
end

function spawnwiz()
	spawn("wizard_scriptable", 1, 15, 25, 2, 0, "wiztalk1") --change coordinates as you wish
	wiztalk1:createComponent("GoromorgShield") -- makes imune to player attacks
	wiztalk1.goromorgshield:setEnergy(50000) -- enough hp for the complete scene
end

function wiztext1()
	hudPrint("So you made it here. I thought you can't make it.")
end

function wiztext2()
	hudPrint("On the day this place is peaceful. But I find that boring. We bring some tension into the game!")
end

function wiztext3()
	hudPrint("You're not afraid of the dark are you?")
end

function wizCS()
	wiztalk1.brain:performAction("castShield") -- used for the cast animation (no shield effect visible, because the shield is already active)
	wiztalk1.goromorgshield:setEnergy(50000) -- the castShield script sets the hp to 500. so i set it back to 50k
end

function setnight()
	GameMode.setTimeOfDay(1.5) -- set time to night
end

function wiztext4()
	hudPrint("From now on there is eternal night!")
end

function wizESC()
	wiztalk1.brain:performAction("escape") -- wizard teleports from the scene
end

function wizlaugh()
	playSound("wizard_laugh")
end
Last edited by st1nger on Wed May 27, 2015 1:04 pm, edited 1 time in total.
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Example script for delayedCall

Post by Eleven Warrior »

This Script is awesome man Thank you for sharing this code. It will make my life much easier :)
User avatar
st1nger
Posts: 19
Joined: Wed May 29, 2013 8:44 pm
Location: Germany

Re: Example script for delayedCall

Post by st1nger »

No problem.

I am pleased that it will help you.
Post Reply