Game Over Script help

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
WaspUK1966
Posts: 135
Joined: Sat Aug 09, 2014 9:17 am

Game Over Script help

Post by WaspUK1966 »

I've found a flaw in the code I've used in my mod. Basically, I have a floor trigger in a fire pit that starts a timer when you land on it. This timer runs a script every second which damages the party by a certain amount until you get out of the pit, which sets off another floor trigger to stop the timer.

Code: Select all

function causedamage()


party.party:playScreenEffect("damage_screen")
playSound("champion_die")

for i=1,4 do
if party.party:getChampion(i):isAlive() then  
party.party:getChampion(i):modifyBaseStat("health", -8)   


else
end
end
end
 
But obviously, as ive found out, if you dont get out of the pit, it will keep repeating even though all the party is dead. I assumed the game would automatically end when all your party had died. How can I code it so that it ends the game when all the party is dead (game over screen) and turns off the timer etc.

Any help greatly appreciated

George
minmay
Posts: 2770
Joined: Mon Sep 23, 2013 2:24 am

Re: Game Over Script help

Post by minmay »

Don't use Champion:modifyBaseStat() to do damage, it will screw everything up. Use Champion:damage().
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.
vieuxchat
Posts: 48
Joined: Wed Mar 02, 2016 3:14 pm

Re: Game Over Script help

Post by vieuxchat »

Doesn't modifyBaseStat change your "Max" values ?
So you don't "damage" your champions, you reduce they maximum health. The game probably don't check for death after changing base stats.
User avatar
WaspUK1966
Posts: 135
Joined: Sat Aug 09, 2014 9:17 am

Re: Game Over Script help

Post by WaspUK1966 »

So how do I use Champion:damage() in my code, instead of what I used? I've tried all combos I can think of and keep getting errors.

Thanks
George
vieuxchat
Posts: 48
Joined: Wed Mar 02, 2016 3:14 pm

Re: Game Over Script help

Post by vieuxchat »

Try that :

Code: Select all

for i = 1,4 do
	party.party:getChampion(i):damage(math.random(8,15),"physical")
	party.party:getChampion(i):playDamageSound()
end
just change the math.random() part for whatever value you want.
Change "physical" for "shock" for instance if you want shock damage. (here is the damage type list : “physical”, “fire”, “poison”, “cold”, “shock”)
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Game Over Script help

Post by AndakRainor »

I use this in my gameOver function:

Code: Select all

for i = 1,4 do
  local c = party.party:getChampionByOrdinal(i)
  c:damage(c:getMaxHealth()*1000, "pure")
end
User avatar
WaspUK1966
Posts: 135
Joined: Sat Aug 09, 2014 9:17 am

Re: Game Over Script help

Post by WaspUK1966 »

Thank you so much for that! Works brilliantly. Now my Mod will work as it should. Will release soon once several tweaks are completed. Thanks once again (was giving me a bad headache!)

George
Post Reply