Page 1 of 1

SOLVED - dmg script help

Posted: Thu Jan 17, 2013 10:54 pm
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 ?

Re: dmg script help

Posted: Fri Jan 18, 2013 12:48 am
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

Re: dmg script help

Posted: Fri Jan 18, 2013 12:58 am
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 ?

Re: dmg script help

Posted: Fri Jan 18, 2013 1:33 am
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.

Re: dmg script help

Posted: Fri Jan 18, 2013 11:55 am
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

Re: dmg script help

Posted: Fri Jan 18, 2013 12:02 pm
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

Re: dmg script help

Posted: Fri Jan 18, 2013 12:33 pm
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 !