• 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] Hash table Location And Type recall problems

Status
Not open for further replies.
Level 17
Joined
Apr 3, 2010
Messages
1,101
I am not exactly sure what I have done wrong here. I think I am lacking understanding of how exactly hash tables work

This is meant to save the location of a Neutral Hostile Camp setup then reload it and recreate it at a random point on the map

  • Camp Location trigger Copy Copy
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • -------- Region variable init / Location point for totem (In this example Totem or key focus point is Tree of life) --------
      • Set Regions[0] = Region 000 <gen>
      • Set Regions[1] = Region 000 Copy 2 <gen>
      • Set Regions[2] = Region 000 Copy 3 <gen>
      • Set Regions[3] = Region 000 Copy 4 <gen>
      • Set Regions[4] = Region 000 Copy 5 <gen>
      • Set Treecord[0] = (Integer((X of (Position of Tree of Eternity 0000 <gen>))))
      • Set Treecord[1] = (Integer((Y of (Position of Tree of Eternity 0000 <gen>))))
      • Set Treecord[2] = (Integer((Facing of Tree of Eternity 0000 <gen>)))
      • -------- Kk Now to save the Camp setup --------
      • Hashtable - Create a hashtable
      • Set Hashtable = (Last created hashtable)
      • -------- Saving Destructables *If required* --------
      • -------- Change 500 to whatever the count of your doods is :L? --------
      • For each (Integer A) from 0 to 100, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: Value saved
          • Set Temp_RandomDestr = (Random destructible in Regions[0])
          • Hashtable - Save Handle OfTemp_RandomDestr as (Integer A) of 0 in Hashtable
          • Hashtable - Save ((Integer((X of (Position of Temp_RandomDestr)))) - Treecord[0]) as (Integer A) of 1 in Hashtable
          • Hashtable - Save ((Integer((Y of (Position of Temp_RandomDestr)))) - Treecord[1]) as (Integer A) of 2 in Hashtable
          • Hashtable - Save Treecord[2] as (Integer A) of 3 in Hashtable
          • Destructible - Remove Temp_RandomDestr
          • Wait 0.01 seconds
          • -------- Saving units --------
          • Set Temp_unit = (Random unit from (Units in Region 000 <gen>))
          • Hashtable - Save Handle OfTemp_unit as (Integer A) of 4 in Hashtable
          • Hashtable - Save ((Integer((X of (Position of Temp_unit)))) - Treecord[0]) as (Integer A) of 5 in Hashtable
          • Hashtable - Save ((Integer((Y of (Position of Temp_unit)))) - Treecord[1]) as (Integer A) of 6 in Hashtable
          • Hashtable - Save ((Integer((Facing of Temp_unit))) - Treecord[2]) as (Integer A) of 7 in Hashtable
          • Unit - Remove Temp_unit from the game
      • Game - Display to (All players) the text: Save complete
  • Camp Creation trigger Copy Copy
    • Events
      • Player - Player 1 (Red) types a chat message containing Spawn as An exact match
    • Conditions
    • Actions
      • Unit - Create 1 Tree of Life for Neutral Hostile at (Center of Regions[(Random integer number between 0 and 6)]) facing (Real(Treecord[2])) degrees
      • Set Totem_Temp = (Last created unit)
      • For each (Integer A) from 0 to 100, do (Actions)
        • Loop - Actions
          • Wait 0.20 seconds
          • Game - Display to (All players) the text: Doodad created
          • Destructible - Create a (Destructible-type of (Load (Integer A) of 0 in Hashtable)) at ((Position of Totem_Temp) offset by ((Real((Load (Integer A) of 1 from Hashtable))), (Real((Load (Integer A) of 2 from Hashtable))))) facing (Load (Integer A) of 3 from Hashtable) with scale 1.00 and variation 0
          • Wait 0.20 seconds
          • Unit - Create 1 (Unit-type of (Load (Integer A) of 4 in Hashtable)) for Neutral Hostile at ((Position of Totem_Temp) offset by ((Real((Load (Integer A) of 5 from Hashtable))), (Load (Integer A) of 6 from Hashtable))) facing (Real((Load (Integer A) of 7 from Hashtable))) degrees
          • Game - Display to (All players) the text: Unit created
      • Game - Display to (All players) the text: Creation Complete
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,243
Last edited:
Level 17
Joined
Apr 3, 2010
Messages
1,101
So I now have this, but it still doesn't work

  • Camp Location trigger Copy Copy
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • -------- Region variable init / Location point for totem (In this example Totem or key focus point is Tree of life) --------
      • Set Regions[0] = Region 000 <gen>
      • Set Regions[1] = Region 000 Copy 2 <gen>
      • Set Regions[2] = Region 000 Copy 3 <gen>
      • Set Regions[3] = Region 000 Copy 4 <gen>
      • Set Regions[4] = Region 000 Copy 5 <gen>
      • Set Treecord[0] = (Integer((X of (Position of Tree of Eternity 0000 <gen>))))
      • Set Treecord[1] = (Integer((Y of (Position of Tree of Eternity 0000 <gen>))))
      • Set Treecord[2] = (Integer((Facing of Tree of Eternity 0000 <gen>)))
      • -------- Kk Now to save the Camp setup --------
      • Hashtable - Create a hashtable
      • Set Hashtable = (Last created hashtable)
      • -------- Saving Destructables *If required* --------
      • -------- Change 500 to whatever the count of your doods is :L? --------
      • For each (Integer A) from 0 to 100, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: Value saved
          • Set Temp_RandomDestr = (Random destructible in Regions[0])
          • Hashtable - Save Handle OfTemp_RandomDestr as (Integer A) of 0 in Hashtable
          • Hashtable - Save ((Integer((X of (Position of Temp_RandomDestr)))) - Treecord[0]) as (Integer A) of 1 in Hashtable
          • Hashtable - Save ((Integer((Y of (Position of Temp_RandomDestr)))) - Treecord[1]) as (Integer A) of 2 in Hashtable
          • Hashtable - Save Treecord[2] as (Integer A) of 3 in Hashtable
          • Destructible - Remove Temp_RandomDestr
          • Wait 0.01 seconds
          • -------- Saving units --------
          • Set Temp_unit = (Random unit from (Units in Region 000 <gen>))
          • Custom script: set udg_Integer = GetUnitTypeId(udg_Temp_unit)
          • Hashtable - Save Integer as (Integer A) of 4 in Hashtable
          • Hashtable - Save ((Integer((X of (Position of Temp_unit)))) - Treecord[0]) as (Integer A) of 5 in Hashtable
          • Hashtable - Save ((Integer((Y of (Position of Temp_unit)))) - Treecord[1]) as (Integer A) of 6 in Hashtable
          • Hashtable - Save ((Integer((Facing of Temp_unit))) - Treecord[2]) as (Integer A) of 7 in Hashtable
          • Unit - Remove Temp_unit from the game
      • Game - Display to (All players) the text: Save complete
  • Camp Creation trigger Copy Copy
    • Events
      • Player - Player 1 (Red) types a chat message containing Spawn as An exact match
    • Conditions
    • Actions
      • Unit - Create 1 Tree of Life for Neutral Hostile at (Center of Regions[(Random integer number between 0 and 6)]) facing (Real(Treecord[2])) degrees
      • Set Totem_Temp = (Last created unit)
      • For each (Integer A) from 0 to 100, do (Actions)
        • Loop - Actions
          • Wait 0.20 seconds
          • Game - Display to (All players) the text: Doodad created
          • Destructible - Create a (Destructible-type of (Load (Integer A) of 0 in Hashtable)) at ((Position of Totem_Temp) offset by ((Real((Load (Integer A) of 1 from Hashtable))), (Real((Load (Integer A) of 2 from Hashtable))))) facing (Load (Integer A) of 3 from Hashtable) with scale 1.00 and variation 0
          • Wait 0.20 seconds
          • Set Unittype = (Unit-type((String((Load (Integer A) of 4 from Hashtable)))))
          • Unit - Create 1 Unittype for Neutral Hostile at ((Position of Totem_Temp) offset by ((Real((Load (Integer A) of 5 from Hashtable))), (Load (Integer A) of 6 from Hashtable))) facing (Real((Load (Integer A) of 7 from Hashtable))) degrees
          • Game - Display to (All players) the text: Unit created
      • Game - Display to (All players) the text: Creation Complete
 
Level 17
Joined
Apr 3, 2010
Messages
1,101
Units/Doodads are not created, and when you call back the value on the hashtable it returns null. > I assume due to from what I can find out from dispersed threads about different issues, apparently Unit Type ID's are not handles but instead Integers and the GUI does not recognize this. Which is why Maker told me to save it as an Integer.

However when I save the value as an integer, the GUI won't allow me to load the integer as Unit type

  • Set UnitType = Hashtalbe - load integer // This is impossible

Effectively when I am loading a Handle the label is unable to be found.
 
Level 17
Joined
Apr 3, 2010
Messages
1,101
When I set my Unit Type as an integer I then can't create Unit type as it wants a Unit Type input directly or for it to find unit type of X unit.
 
Level 16
Joined
Dec 15, 2011
Messages
1,423
Is there a way to convert the integer to unit type?

Edit

Found it.

  • Custom script: set YourUnitTypeVar = ConvertUnitType (<your_integer>)
For the destructable, you are saving the wrong thing. It should be like this:

  • Custom script: set YourInteger = GetDestructableTypeId (<your_destructable>)
  • Save the integer
Why are you saving X and Y as integer? They should be real.
 
Level 17
Joined
Apr 3, 2010
Messages
1,101
It doesn't seem to accept the custom code (Expected a Variable name)
I have
Unittype -Unittype variable -- Integer =integer variable

Maybe I have inputted it wrong D=
  • Custom script: set Unittype = ConvertUnitType (udg_Integer)
I save X and Y as Integers as they are used for OFFSET they are simply the X and Y value variance from the Totem which is a variable point.
 
Level 16
Joined
Dec 15, 2011
Messages
1,423
Which line? Did you check the variables carefully?

edit

Nvm. I misunderstood the unit type :/

This is really annoying. Hmm, can you convert the unit creation trigger line to text and give it to me? I am more comfortable with JASS

Dest type id is in integer form, so is the damn unit type id. They can't be converted.
 
Level 17
Joined
Apr 3, 2010
Messages
1,101
I dont like those waits of yours they can screw up a trigger so easy

If I removed the waits I would make the trigger very resource intensive.

The waits do not actually affect the trigger, they just make a gap between each loop.

Which line? Did you check the variables carefully?

edit

Nvm. I misunderstood the unit type :/
JASS:
function Trig_Camp_Location_trigger_Copy_Copy_Copy_Actions takes nothing returns nothing
    // Region variable init / Location point for totem (In this example Totem or key focus point is Tree of life)
    set udg_Regions[0] = gg_rct_Region_000
    set udg_Regions[1] = gg_rct_Region_000_Copy_2
    set udg_Regions[2] = gg_rct_Region_000_Copy_3
    set udg_Regions[3] = gg_rct_Region_000_Copy_4
    set udg_Regions[4] = gg_rct_Region_000_Copy_5
    set udg_Treecord[0] = R2I(GetLocationX(GetUnitLoc(gg_unit_etoe_0000)))
    set udg_Treecord[1] = R2I(GetLocationY(GetUnitLoc(gg_unit_etoe_0000)))
    set udg_Treecord[2] = R2I(GetUnitFacing(gg_unit_etoe_0000))
    // Kk Now to save the Camp setup
    call InitHashtableBJ(  )
    set udg_Hashtable = GetLastCreatedHashtableBJ()
    // Saving Destructables *If required*
    // Change 500 to whatever the count of your doods is :L?
    set bj_forLoopAIndex = 0
    set bj_forLoopAIndexEnd = 100
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_046" )
        set udg_Temp_RandomDestr = RandomDestructableInRectSimpleBJ(udg_Regions[0])
        call SaveDestructableHandleBJ( udg_Temp_RandomDestr, GetForLoopIndexA(), GetHandleIdBJ(GetDestructableLoc(udg_Temp_RandomDestr)), udg_Hashtable )
        call SaveIntegerBJ( ( R2I(GetLocationX(GetDestructableLoc(udg_Temp_RandomDestr))) - udg_Treecord[0] ), GetForLoopIndexA(), GetHandleIdBJ(GetDestructableLoc(udg_Temp_RandomDestr)), udg_Hashtable )
        call SaveIntegerBJ( ( R2I(GetLocationY(GetDestructableLoc(udg_Temp_RandomDestr))) - udg_Treecord[1] ), GetForLoopIndexA(), GetHandleIdBJ(GetDestructableLoc(udg_Temp_RandomDestr)), udg_Hashtable )
        call SaveIntegerBJ( udg_Treecord[2], GetForLoopIndexA(), GetHandleIdBJ(GetDestructableLoc(udg_Temp_RandomDestr)), udg_Hashtable )
        call RemoveDestructable( udg_Temp_RandomDestr )
        call TriggerSleepAction( 0.01 )
        // Saving units
        set udg_Temp_unit = GroupPickRandomUnit(GetUnitsInRectAll(gg_rct_Region_000))
        call SaveUnitHandleBJ( udg_Temp_unit, GetForLoopIndexA(), 4, udg_Hashtable )
        call SaveIntegerBJ( ( R2I(GetLocationX(GetUnitLoc(udg_Temp_unit))) - udg_Treecord[0] ), GetForLoopIndexA(), 5, udg_Hashtable )
        call SaveIntegerBJ( ( R2I(GetLocationY(GetUnitLoc(udg_Temp_unit))) - udg_Treecord[1] ), GetForLoopIndexA(), 6, udg_Hashtable )
        call SaveIntegerBJ( ( R2I(GetUnitFacing(udg_Temp_unit)) - udg_Treecord[2] ), GetForLoopIndexA(), 7, udg_Hashtable )
        call RemoveUnit( udg_Temp_unit )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_047" )
endfunction

//===========================================================================
function InitTrig_Camp_Location_trigger_Copy_Copy_Copy takes nothing returns nothing
    set gg_trg_Camp_Location_trigger_Copy_Copy_Copy = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_Camp_Location_trigger_Copy_Copy_Copy, 0.00 )
    call TriggerAddAction( gg_trg_Camp_Location_trigger_Copy_Copy_Copy, function Trig_Camp_Location_trigger_Copy_Copy_Copy_Actions )
endfunction
JASS:
function Trig_Camp_Creation_trigger_Copy_Copy_Copy_Copy_Copy_Actions takes nothing returns nothing
    call CreateNUnitsAtLoc( 1, 'etol', Player(PLAYER_NEUTRAL_AGGRESSIVE), GetRectCenter(udg_Regions[GetRandomInt(0, 6)]), I2R(udg_Treecord[2]) )
    set udg_Totem_Temp = GetLastCreatedUnit()
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 100
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call TriggerSleepAction( 0.20 )
        call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_048" )
        call CreateDestructableLoc( GetDestructableTypeId(LoadDestructableHandleBJ(GetForLoopIndexA(), 0, udg_Hashtable)), OffsetLocation(GetUnitLoc(udg_Totem_Temp), I2R(LoadIntegerBJ(GetForLoopIndexA(), 1, GetLastCreatedHashtableBJ())), I2R(LoadIntegerBJ(GetForLoopIndexA(), 2, udg_Hashtable))), LoadRealBJ(GetForLoopIndexA(), 3, udg_Hashtable), 1, 0 )
        call TriggerSleepAction( 0.20 )
        call CreateNUnitsAtLoc( 1, GetUnitTypeId(LoadUnitHandleBJ(GetHandleIdBJ(LoadUnitHandleBJ(GetForLoopIndexA(), 4, udg_Hashtable)), 4, udg_Hashtable)), Player(PLAYER_NEUTRAL_AGGRESSIVE), OffsetLocation(GetUnitLoc(udg_Temp_unit), I2R(LoadIntegerBJ(GetForLoopIndexA(), 5, udg_Hashtable)), LoadRealBJ(GetForLoopIndexA(), 6, udg_Hashtable)), I2R(LoadIntegerBJ(GetForLoopIndexA(), 7, udg_Hashtable)) )
        call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_049" )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_050" )
endfunction

//===========================================================================
function InitTrig_Camp_Creation_trigger_Copy_Copy_Copy_Copy_Copy takes nothing returns nothing
    set gg_trg_Camp_Creation_trigger_Copy_Copy_Copy_Copy_Copy = CreateTrigger(  )
    call DisableTrigger( gg_trg_Camp_Creation_trigger_Copy_Copy_Copy_Copy_Copy )
    call TriggerRegisterPlayerChatEvent( gg_trg_Camp_Creation_trigger_Copy_Copy_Copy_Copy_Copy, Player(0), "Spawn", true )
    call TriggerAddAction( gg_trg_Camp_Creation_trigger_Copy_Copy_Copy_Copy_Copy, function Trig_Camp_Creation_trigger_Copy_Copy_Copy_Copy_Copy_Actions )
endfunction

This is really annoying. Hmm, can you convert the unit creation trigger line to text and give it to me? I am more comfortable with JASS

Dest type id is in integer form, so is the damn unit type id. They can't be converted.


The destructibles don't get created either D=

And here i put jass in quote :D They are for the original trigger I had before alterations.
 
Level 16
Joined
Dec 15, 2011
Messages
1,423
Copy these codes as custom scripts and replace the trigger lines.

JASS:
// Replace your Save Destructable:
call SaveInteger (udg_Hashtable, 0, GetForLoopIndexA (), GetDestructableTypeId (udg_Temp_RandomDestr))

// Replace your Save Unit:
call SaveInteger (udg_Hashtable, 4, GetForLoopIndexA(), GetUnitTypeId (udg_Temp_unit))

// Replace dest create:
call CreateDestructableLoc( LoadInteger (udg_Hashtable, 0, GetForLoopIndexA()), OffsetLocation(GetUnitLoc(udg_Totem_Temp), I2R(LoadIntegerBJ(GetForLoopIndexA(), 1, udg_Hashtable)), I2R(LoadIntegerBJ (GetForLoopIndexA(), 2, udg_Hashtable))), LoadRealBJ (GetForLoopIndexA(), 3, udg_Hashtable), 1, 0 )

// Replace unit create:
call CreateNUnitsAtLoc( 1, LoadInteger (udg_Hashtable, 4, GetForLoopIndexA()), Player(PLAYER_NEUTRAL_AGGRESSIVE), OffsetLocation(GetUnitLoc(udg_Temp_unit), I2R (LoadIntegerBJ(GetForLoopIndexA(), 5, udg_Hashtable)), LoadRealBJ(GetForLoopIndexA(), 6, udg_Hashtable)), I2R (LoadIntegerBJ(GetForLoopIndexA(), 7, udg_Hashtable)) )

I am on a phone so yeah, typos may happen.
 
Level 17
Joined
Apr 3, 2010
Messages
1,101
A little bit buggy with positioning and I had to convert the whole trigger to jass as inputting a Custom script that long crashed my WE
But it fixed my problem

TY :D! +rep
 
Status
Not open for further replies.
Top