Page 1 of 1

[SCRIPT] Example script for delayedCall

Posted: Fri May 22, 2015 3:26 am
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

Re: Example script for delayedCall

Posted: Fri May 22, 2015 7:44 am
by Eleven Warrior
This Script is awesome man Thank you for sharing this code. It will make my life much easier :)

Re: Example script for delayedCall

Posted: Sat May 23, 2015 9:26 am
by st1nger
No problem.

I am pleased that it will help you.