SOLVED - dmg script help

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

SOLVED - dmg script help

Post by Drakkan »

I need help with script, which will dmg each character every 5sec, unless wearing specific chest armor(lets call it Coatl). Somebody help pls ?
Last edited by Drakkan on Fri Jan 18, 2013 12:33 pm, edited 1 time in total.
Breath from the unpromising waters.
Eye of the Atlantis
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: dmg script help

Post by Komag »

the easiest way to hurt the party is with damageTile , but that wouldn't allow individual champions with the armor to avoid the damage. You can script loss of health and hurt sounds for individuals, but that's a little tricky
Finished Dungeons - complete mods to play
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: dmg script help

Post by Drakkan »

Komag wrote:the easiest way to hurt the party is with damageTile , but that wouldn't allow individual champions with the armor to avoid the damage. You can script loss of health and hurt sounds for individuals, but that's a little tricky
well i think it would be something like (do not know commands, so just brief idea how it might probably work)
for every champion

if champion1 slot 2 is equiped Coat then
do nothing :)
else dmgpchampion1

this make for everychampion to be repeated until x-second clock is disabled.

what you think ?
Breath from the unpromising waters.
Eye of the Atlantis
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: dmg script help

Post by Grimwold »

The basic commands you will want are:

Champion:damage(amount, type)
Deals damage to the champion. Type must be “physical”, “fire”, “shock”, “poison” or “cold”.

Champion:playDamageSound()
Plays the damage sound which is determined by champion’s race and gender.

I haven't tested these, so I'm unsure if dealing damage in this way plays the damage sound anyway.


Since there are 4 champions you'll want to cycle through each and check if they are a) Enabled and b) Alive... if so, then check for the presence of the "Coat" in the Torso location... if it's missing deal damage.

Code: Select all

for i=1,4 do
    if party:getChampion(i):getEnabled() and party:getChampion(i):isAlive() then
      if party:getChampion(i):getItem(2).name == "Coat" then
        -- hudPrint("Coat found")
      else
        party:getChampion(i):damage(50, "fire") 
        party:getChampion(i):playDamageSound() 
      end
    end
end
This is theoretical code as I haven't had chance to check it.
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: dmg script help

Post by Drakkan »

Grimwold wrote:The basic commands you will want are:

Champion:damage(amount, type)
Deals damage to the champion. Type must be “physical”, “fire”, “shock”, “poison” or “cold”.

Champion:playDamageSound()
Plays the damage sound which is determined by champion’s race and gender.

I haven't tested these, so I'm unsure if dealing damage in this way plays the damage sound anyway.


Since there are 4 champions you'll want to cycle through each and check if they are a) Enabled and b) Alive... if so, then check for the presence of the "Coat" in the Torso location... if it's missing deal damage.

Code: Select all

for i=1,4 do
    if party:getChampion(i):getEnabled() and party:getChampion(i):isAlive() then
      if party:getChampion(i):getItem(2).name == "Coat" then
        -- hudPrint("Coat found")
      else
        party:getChampion(i):damage(50, "fire") 
        party:getChampion(i):playDamageSound() 
      end
    end
end
This is theoretical code as I haven't had chance to check it.
third row returnign error - attempt to index a nil value X
Breath from the unpromising waters.
Eye of the Atlantis
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: dmg script help

Post by Grimwold »

Oops... forgot the case where the champion is wearing nothing on his Torso.

try:

Code: Select all

for i=1,4 do
  if party:getChampion(i):getEnabled() and party:getChampion(i):isAlive() then
    if party:getChampion(i):getItem(2) ~= nil and party:getChampion(i):getItem(2).name == "Coat" then
      -- hudPrint("Coat found")
    else
      party:getChampion(i):damage(50, "fire")
      party:getChampion(i):playDamageSound()
    end
  end
end
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: dmg script help

Post by Drakkan »

Grimwold wrote:Oops... forgot the case where the champion is wearing nothing on his Torso.

try:

Code: Select all

for i=1,4 do
  if party:getChampion(i):getEnabled() and party:getChampion(i):isAlive() then
    if party:getChampion(i):getItem(2) ~= nil and party:getChampion(i):getItem(2).name == "Coat" then
      -- hudPrint("Coat found")
    else
      party:getChampion(i):damage(50, "fire")
      party:getChampion(i):playDamageSound()
    end
  end
end
working fine now, thanks !
Breath from the unpromising waters.
Eye of the Atlantis
Post Reply