• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Some help with makeing a unit

Status
Not open for further replies.
Level 9
Joined
Aug 27, 2009
Messages
473
Some help with making a integer to many!

  • Set Unit
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ordered unit) Not equal to SS_On_Ice[SS_int]
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain type at (Position of (Ordered unit))) Not equal to Icecrown Glacier - Ice
            • Then - Actions
              • Set SS_int = (SS_int + 1)
              • Set SS_On_Ice[SS_int] = (Ordered unit)
            • Else - Actions
              • Do nothing
        • Else - Actions
          • Do nothing
How can i make this work?

As you may see

  • (Ordered unit) Not equal to SS_On_Ice[SS_int]
Only returns one unit, how to fix this without using "For Each Intenger A..." trigger?
 
Last edited:
Level 9
Joined
Aug 27, 2009
Messages
473
JASS:
function Trig_Set_Unit_Func001Func002C takes nothing returns boolean
    if ( not ( GetTerrainTypeBJ(GetUnitLoc(GetOrderedUnit())) != 'Iice' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Set_Unit_Func001C takes nothing returns boolean
    if ( not ( GetOrderedUnit() != udg_SS_On_Ice[udg_SS_int] ) ) then
        return false
    endif
    return true
endfunction

function Trig_Set_Unit_Actions takes nothing returns nothing
    if ( Trig_Set_Unit_Func001C() ) then
    if ( Trig_Set_Unit_Func001Func002C() ) then
        set udg_SS_int = ( udg_SS_int + 1 )
        set udg_SS_On_Ice[udg_SS_int] = GetOrderedUnit()
    else
        call DoNothing( )
    endif
    else
        call DoNothing( )
    endif
endfunction

//===========================================================================

function InitTrig_Set_Unit takes nothing returns nothing
    set gg_trg_Set_Unit = CreateTrigger( )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Set_Unit, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Set_Unit, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
    call TriggerAddAction( gg_trg_Set_Unit, function Trig_Set_Unit_Actions )
endfunction

Sorry about that, now its fixed..
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
Use a hashtable. You get the order unit and get its handle integer and then store a value to that. If you have a value in the hashtable at that index then it was added to the system, if not then it was not. I advise using the parent index for this and the child index you just use a constant integer. On top of that you can use some kind of array storage system.

What is best is hashtables are not O(n) efficency (usually O(1)) so scale pretty well.
 
Status
Not open for further replies.
Top