• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Local variable for loop

Status
Not open for further replies.
Level 5
Joined
Feb 5, 2008
Messages
109
Hi! =)

I just made an ability which creates some dust around the caster and spawns a wurm after that.

It's somehow not working because I use a local variable for the loop (at least I guess that's why), but I have to do so, otherwise other triggers will surely stop this one from working correctly.
I also read somewhere that you can declare just one local variable in GUI. Is that true?

Ah, and please tell me if I got any memory leaks in this.

  • Dune Worm
    • Events
      • Unit - A unit starts the effect of an ability
    • Conditions
      • (Ability being cast) Gleich Dune Worm
    • Actions
      • Custom script: local location udg_Point
      • Custom script: local integer udg_Integer
      • Animation - Play (Triggering unit)'s spell animation
      • Set Point = (Position of (Triggering unit))
      • For each (Integer Integer) from 1 to 20, do (Actions)
        • Loop - Actions
          • Set Point_2 = (Point offset by 256.00 towards ((Real(Integer)) x 18.00) degrees)
          • Special Effect - Create a special effect at Point_2 using Objects\Spawnmodels\Undead\ImpaleTargetDust\ImpaleTargetDust.mdl
          • Special Effect - Destroy (Last created special effect)
          • Set Integer_2 = Integer
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Integer_2 Gleich 20
              • (Terrain pathing at Point_2 of type Begehbarkeit is off) Gleich False
              • (Point_2 is blighted) Gleich False
            • Then - Actions
              • Unit - Create 1 Dune Worm for (Owner of (Triggering unit)) at Point_2 facing Preset for buildings degrees
            • Else - Actions
          • Point - Remove Point_2
          • Wait 0.01 seconds
      • Point - Remove Point
Thank you for help. =)
Triax
 
Last edited:
Level 5
Joined
Feb 5, 2008
Messages
109
Uh, you're kidding, aren't you?

First of all, if I use "casts an ability", the effect will start even if the spell gets interrupted.

And I need a local point to store the position where the caster stood when the effect starts and a local integer for the loop so it can't be manipulated by other triggers.
 
Level 5
Joined
Oct 17, 2006
Messages
151
Uh, you're kidding, aren't you?

First of all, if I use "casts an ability", the effect will start even if the spell gets interrupted.

And I need a local point to store the position where the caster stood when the effect starts and a local integer for the loop so it can't be manipulated by other triggers.

My mistake... :zip:

was reading it with remote access... :grin::thumbs_up:
 
Level 5
Joined
Feb 5, 2008
Messages
109
I think it's not that hard for me to learn JASS, but I don't like to. <.<
But I should be able to do the variable thing. ;D
The basic thing was that I didn't want to use any JASS in my triggers, but this should be the easiest way.

Thanks for your effort. =)

Btw, why can only one global variable be 'local'?
 
Level 5
Joined
Feb 5, 2008
Messages
109
I tried to convert it to JASS, and it went well until I tried to integrate the if into the main function.

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

function Trig_Dune_Worm_JASS_Actions takes nothing returns nothing
    local location udg_Point
    local integer Integer
    call SetUnitAnimation( GetTriggerUnit(), "spell" )
    set udg_Point = GetUnitLoc(GetTriggerUnit())
    set udg_Integer_2 = GetRandomInt(0, 20)
    set Integer = udg_Integer_2
    loop
        exitwhen Integer > ( udg_Integer_2 + 20 )
        set udg_Point_2 = PolarProjectionBJ(udg_Point, 256, ( I2R(Integer) * 18.00 ))
        call AddSpecialEffectLocBJ( udg_Point_2, "Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl" )
        call DestroyEffectBJ( GetLastCreatedEffectBJ() )
        if  ( Integer == ( udg_Integer_2 + 20 ) ) and
            ( IsTerrainPathableBJ(udg_Point_2, PATHING_TYPE_WALKABILITY) == false ) and
            ( IsPointBlightedBJ(udg_Point_2) == false )
        then
           call CreateNUnitsAtLoc( 1, 'o001', GetOwningPlayer(GetTriggerUnit()), udg_Point_2, bj_UNIT_FACING )
        endif
        call RemoveLocation( udg_Point_2 )
        call TriggerSleepAction( 0.01 )
        set Integer = Integer + 1
    endloop
    call RemoveLocation( udg_Point )
endfunction

//===========================================================================
function InitTrig_Dune_Worm_JASS takes nothing returns nothing
    set gg_trg_Dune_Worm_JASS = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Dune_Worm_JASS, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Dune_Worm_JASS, Condition( function Trig_Dune_Worm_JASS_Conditions ) )
    call TriggerAddAction( gg_trg_Dune_Worm_JASS, function Trig_Dune_Worm_JASS_Actions )
endfunction
I had a look on a tutorial for if-then-else in JASS, and I think that the syntax is correct. So what's wrong with this?
 
Level 5
Joined
Feb 5, 2008
Messages
109
Makes no difference. :S
(What you mean with BJ?)

(JASSHelper says I got a syntax error in the if-line. I put in a break there so the line just contained "if", but I still got the error. Same with "if (" (... ")").)
 
Put the whole "if" on the same line, up to "then". It seems you may be used to coding c++ or some other language where you can put random linebreaks in statements. And btw you don't need any of those parentheses apart from around function calls. The if line should be like this:
JASS:
if Integer == udg_Integer_2 + 20 and IsTerrainPathableBJ(udg_Point_2, PATHING_TYPE_WALKABILITY) == false and IsPointBlightedBJ(udg_Point_2) == false then
Since you don't know Jass very well I wouldn't bother with changing the BJs. It only makes the code run a few milliseconds faster.
 
Status
Not open for further replies.
Top