• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[JASS] Weird Issue

Status
Not open for further replies.
Level 3
Joined
Mar 24, 2007
Messages
51
here what is going on, i've codified lots of stuff in JASS and then all of a sudden some stuff stopped working

trying to find something in common among them it looks like all loops have stopped working

JASS:
function Trig_Piercing_Strike_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A01D' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Piercing_Strike_Actions takes nothing returns nothing
local integer loop1int = 1
local integer loop1end = 20
  call UnitDamageTarget(GetTriggerUnit(), GetSpellTargetUnit(), (udg_Attack_Power[GetPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))]*10), true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ACID, null)
  call TriggerSleepAction(1)
  loop
  exitwhen loop1int > loop1end
  set loop1int = loop1int + 1
  call UnitDamageTarget(GetTriggerUnit(), GetSpellTargetUnit(), udg_Attack_Power[GetPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))], true, true, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_ACID, null)
  call TriggerSleepAction(1)
  endloop
endfunction

//===========================================================================
function InitTrig_Piercing_Strike takes nothing returns nothing
    set gg_trg_Piercing_Strike = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Piercing_Strike, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Piercing_Strike, Condition( function Trig_Piercing_Strike_Conditions ) )
    call TriggerAddAction( gg_trg_Piercing_Strike, function Trig_Piercing_Strike_Actions )
endfunction

the non-loop part works fine, its idea is to cause inicial damage then go damaging every second
both based on a stat which is an integer global called Attack_Power which ive created with arrays for each player

it damages perfectly the first damage but the loop doesnt work
is my function written wrong or sumthin' or may it be a freaking editor curse which has bugged all my loops? PS: i use JASS NewGen Pack 1.5a

another sample of my bugged code:
JASS:
function Trig_Divine_Salvation_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A011' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Divine_Salvation_Actions takes nothing returns nothing
  local integer time = 5
  local integer Spellhealing = (GetUnitAbilityLevel(GetSpellAbilityUnit(), 'A019')*6 + udg__Spellhealing)
  local integer loop1int = 1
  local integer loop1end = 5
  local real heal1 = GetUnitState(GetSpellTargetUnit(), UNIT_STATE_LIFE)
  local real heal2 = 2*Spellhealing+100
  local integer Heal_Reduction = udg__Heal_Reduction
    call SetUnitManaPercentBJ( GetSpellAbilityUnit(), 0.00 )
    loop
    set heal1 = GetUnitState(GetSpellTargetUnit(), UNIT_STATE_LIFE)
    exitwhen loop1int > loop1end        
    set loop1int = loop1int + 1        
    call SetUnitState(GetSpellTargetUnit(), UNIT_STATE_LIFE, heal1 + heal2)         
    call TriggerSleepAction(1)
    endloop
endfunction

//===========================================================================
function InitTrig_Divine_Salvation takes nothing returns nothing
    set gg_trg_Divine_Salvation = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Divine_Salvation, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Divine_Salvation, Condition( function Trig_Divine_Salvation_Conditions ) )
    call TriggerAddAction( gg_trg_Divine_Salvation, function Trig_Divine_Salvation_Actions )
endfunction

it's healing only one time aswell...
i've just thought while making this post, if loops were bugged the second spell shouldn't heal at all, since the whole healing is inside the loop... so can anyone detect what i've done of wrong at any of these codes?

edit: btw, the heal spell was working 100% fine until some time ago, and i haven't changed anything...
edit2: i have fixed the first code, ive done a big stuppidity...
i have fixed the second one, don't know how but i did...


anyway, sorry for the useless post... but i was trying to fix this for 3 hours and had no idea about what was wrong
 
Last edited:
Level 12
Joined
Apr 27, 2008
Messages
1,228
Problem is here:
call TriggerSleepAction(1)
After that function is executed, when you call the function GetSpellTargetUnit() it does not return a unit.
So to avoid this:
JASS:
local unit u=GetSpellTargetUnit()
local integer i=0
loop
exitwhen i==10
call SetUnitState(u, UNIT_STATE_LIFE,GetUnitState(u, UNIT_STATE_LIFE) + heal2)
call TriggerSleepAction(1)
set i=i+1
endloop
So basically you have to store the unit in a local variable OR do not use TriggerSleepAction(#)
P.s. GetTriggerUnit() works fine after waits.
 
Status
Not open for further replies.
Top