Deal damage to party

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!
Emera Nova
Posts: 146
Joined: Wed Jun 11, 2014 1:31 am

Deal damage to party

Post by Emera Nova »

So I'm thinking of making a puzzle that as you do it the party takes damage, problem I could see happening with it would be it breaking if a champion is already dead.

So I'm guessing the script would need to first check to see if each champion is still alive, and if not skip that champion for the damage. And then it would need to deal the damage to other champions.

Idea's on the script itself?
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Deal damage to party

Post by minmay »

damaging dead champions is not a problem unless perhaps you try to do it in a really weird way like with setHealth
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.
Emera Nova
Posts: 146
Joined: Wed Jun 11, 2014 1:31 am

Re: Deal damage to party

Post by Emera Nova »

So I have this which I thought would be the answer to the deal damage to party but its not working so something is wrong.

Code: Select all

function Damage()
	party.party:getChampion:damage(5, fire)
end
User avatar
THOM
Posts: 1281
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Deal damage to party

Post by THOM »

You have to specify which champion is meant. Also you have to bring fire into quotationmarks:

Code: Select all

function Damage()
   party.party:getChampion(1):damage(5, "fire")
end
This will deal damage only to champion number one.
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
Emera Nova
Posts: 146
Joined: Wed Jun 11, 2014 1:31 am

Re: Deal damage to party

Post by Emera Nova »

:o O was so close with that makes sense that you would have to tell it which one tho. ^-^its working now tho so yay! xD Now to just solve my gun problems and I'll be set to move on with my dungeon.
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Deal damage to party

Post by Eleven Warrior »

Hi Thom. I cant remember the code for damage whole party not just one member any help please thxs :)
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: Deal damage to party

Post by Isaac »

Eleven Warrior wrote:Hi Thom. I cant remember the code for damage whole party not just one member any help please thxs :)
Well, you can either loop through the party, or use damageTile on the party's location.

Code: Select all

function partyDamage()
for x = 1,4 do
   local t = party.party:getChampion(x) 
   t:damage(5, "fire")
   playSound("damage_"..t:getRace().."_"..t:getSex())
end
end

Code: Select all

function partyDamage()
  damageTile(party.level, party.x, party.y, party.facing, party.elevation, 512, "fire", 5)
  for x = 1,4 do
   local t = party.party:getChampion(x) 
   playSound("damage_"..t:getRace().."_"..t:getSex())
end
end
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Deal damage to party

Post by Eleven Warrior »

Thxs Issac awesome man :)
User avatar
THOM
Posts: 1281
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Deal damage to party

Post by THOM »

This would work also

Code: Select all

function Damage()
   party.party:getChampion(1):damage(5, "fire")
   party.party:getChampion(2):damage(5, "fire")
   party.party:getChampion(3):damage(5, "fire")
   party.party:getChampion(4):damage(5, "fire")
end
Sometimes solutions are very obvious...
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: Deal damage to party

Post by Isaac »

THOM wrote:This would work also

Code: Select all

function Damage()
   party.party:getChampion(1):damage(5, "fire")
   party.party:getChampion(2):damage(5, "fire")
   party.party:getChampion(3):damage(5, "fire")
   party.party:getChampion(4):damage(5, "fire")
end
Sometimes solutions are very obvious...
This is good too. I wonder why damageTile and :damage() do not cause champion sounds for the injury?
Post Reply