damaging problems

jackall

You can change this now in User CP.
Reaction score
37
I have no idea why but it only damages the target once for 5% of their HP.
This is the function that does the damage.
JASS:
function HPPercentDamage takes unit source, unit target, real percent, boolean currHP, attacktype at, damagetype dt returns nothing
    local real dmg
    if currHP then
        set dmg = GetUnitState(target,UNIT_STATE_LIFE)*percent
    else
        set dmg = GetUnitState(target,UNIT_STATE_MAX_LIFE)*percent
    endif
    call BJDebugMsg(R2S(dmg))
    call UnitDamageTarget(source,target,dmg,true,false,at,dt,WEAPON_TYPE_WHOKNOWS)
endfunction

This is where I'm using it.
Trigger:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • tmpReal Less than or equal to 0.20
      • (Unit-type of tmpUnit) Equal to Spell Tower
    • Then - Actions
      • Custom script: call CreateDummy(udg_tmpUnit,udg_tmpUnit2,'h003',udg_tmpInt,'A00A',"entanglingroots")
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • Custom script: call HPPercentDamage(udg_Dummy[udg_tmpInt-1],udg_tmpUnit2,.05,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_UNIVERSAL)
          • Wait 1.00 game-time seconds
      • Custom script: set noRoots=false
    • Else - Actions
      • Custom script: set noRoots=true
 

Dirac

22710180
Reaction score
147
waits inside loops break everything... waits in fact break everything
There's a way to code that function without any local declarations.
JASS:
function HPPercentDamage takes unit source, unit target, real percent, boolean currHP, attacktype at, damagetype dt returns nothing
    if currHP then
        call UnitDamageTarget(source,target,GetUnitState(target,UNIT_STATE_LIFE)*percent,true,false,at,dt,WEAPON_TYPE_WHOKNOWS)
    else
        call UnitDamageTarget(source,target,GetUnitState(target,UNIT_STATE_MAX_LIFE)*percent,true,false,at,dt,WEAPON_TYPE_WHOKNOWS)
    endif
endfunction
 

jackall

You can change this now in User CP.
Reaction score
37
tried and yet again... didn't work
the thing is BJDebugMsg in the function displays 12.5(what it should be) once, after that only 0's
btw: HPPercentDamage isn't in that trigger
 

StEaLtHmAn

New Member
Reaction score
2
tried and yet again... didn't work
the thing is BJDebugMsg in the function displays 12.5(what it should be) once, after that only 0's
btw: HPPercentDamage isn't in that trigger

The jass is fine, Dirac kindly pointed out that it could be optimized.
and he stated that the:
Trigger:
  • Wait 1.00 game-time seconds

breaks the for loop. its a common noob error. You need to use timers if you want to create a delay. forloops can not have waits in them.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top