• 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] Will this Hashtable setup look ok and work?

Status
Not open for further replies.

TKF

TKF

Level 19
Joined
Nov 29, 2006
Messages
1,267
I'm quite new to hashtable, I tried to learn the tuts, but understood it only partially and caused my "brain to bleed a bit". I'm not a very fast learner.

I've been stuck on JNGP all these years and just dled 1.5e version and discovered new triggers called hashtables. I discovered that they are 3 dimensional, not just 2 like variable with arrays. Or 2 dimension integer arrays setup instead of just 1.

So someone who are used to these, can you help me out and see if I did it correctly. I'm not intending to test it before I change everything, I want some input first.


I'm trying to create a Hashtable damage data which stores almost everything of the damage missiles do. I'm want to use this to replace the old GUI triggers which for every time if triggers sets a value, I want the values to be set from start. I didn't find unit-type in the hashtable :/


This might not be the best way of setup in GUI, but heres what I've done so far.

  • Hash
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- It's hard to understand --------
      • Hashtable - Create a hashtable
      • Set HashDamageData = (Last created hashtable)
      • -------- The first is data value, INT, REAL, BOOLEAN, STRING etc whatever... --------
      • -------- 1st array value represent different data values for different situations that I need triggers for --------
      • -------- 0 Represent shield damage (in relative %) - REAL --------
      • -------- 1 Represent hull damage (in %) - REAL --------
      • -------- 2 Represent core damage over time - INT --------
      • -------- 3 Represent direct core damage - INT --------
      • -------- 4 Energy drain when cruiser shields is online - INT --------
      • -------- 5 Energy drain on cruiser hull impact and vessels - INT --------
      • -------- 6 checks if it applies by laser upgrade - BOOLEAN --------
      • -------- 7 Represent vessel/asteroid damage - REAL --------
      • -------- ---- --------
      • -------- 2nd array value is ID number for each MissileUnitType[] projectile, using loop to fetch the number of dying projectile --------
      • -------- ---- --------
      • Set MissileUnitType[0] = Piranha Light Missile (Space)
      • Hashtable - Save 15.00 as 0 of 0 in HashDamageData
      • Hashtable - Save 1.60 as 1 of 0 in HashDamageData
      • Hashtable - Save 1050.00 as 7 of 0 in HashDamageData
      • -------- 2 dimensional hashtable array can be used for saving different values for each possible event which calls upon different damage for different situations --------
      • Set MissileUnitType[1] = Scorpion Light Missile (Space)
      • Hashtable - Save 6.00 as 0 of 1 in HashDamageData
      • Hashtable - Save 0.10 as 1 of 1 in HashDamageData
      • Hashtable - Save 150.00 as 7 of 1 in HashDamageData
      • Set MissileUnitType[2] = Scorpion Light Missile (Cluster)
      • Hashtable - Save 6.00 as 0 of 2 in HashDamageData
      • Hashtable - Save 0.15 as 1 of 2 in HashDamageData
      • Hashtable - Save 700.00 as 7 of 2 in HashDamageData
      • Set MissileUnitType[3] = Wasp Light Missile (Space)
      • Hashtable - Save 30.00 as 0 of 3 in HashDamageData
      • Hashtable - Save 0.70 as 1 of 3 in HashDamageData
      • Hashtable - Save 16 as 2 of 3 in HashDamageData
      • Hashtable - Save 2000 as 4 of 3 in HashDamageData
      • Hashtable - Save 2000 as 5 of 3 in HashDamageData
      • Hashtable - Save 800.00 as 7 of 3 in HashDamageData
      • Set MissileUnitType[4] = Sabretooth Heavy Missile (Space)
      • Hashtable - Save 50.00 as 0 of 4 in HashDamageData
      • Hashtable - Save 1.00 as 1 of 4 in HashDamageData
      • Hashtable - Save 68 as 2 of 4 in HashDamageData
      • Hashtable - Save 20 as 3 of 4 in HashDamageData
      • Hashtable - Save 2500 as 4 of 4 in HashDamageData
      • Hashtable - Save 4000 as 5 of 4 in HashDamageData
      • Hashtable - Save 1500.00 as 7 of 4 in HashDamageData
      • Set MissileUnitType[5] = Fighter Laser (Space)
      • Hashtable - Save 0.88 as 0 of 5 in HashDamageData
      • Hashtable - Save 0.11 as 1 of 5 in HashDamageData
      • -------- Hashtables can save boolean = true in a data row setup, thus attaching a true condition to only a certain unit types, like laser projectiles in this example --------
      • Hashtable - Save True as 6 of 5 in HashDamageData
      • Hashtable - Save 125.00 as 7 of 5 in HashDamageData
      • -------- etc and so on until i made setup for all the 28 projectiles --------
  • Shield Hit
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Killing unit)) Equal to Battlecruiser Locator
    • Actions
      • -------- 2nd trigger --------
      • Set MissileHitCruiserTemp = (Triggering unit)
      • For each (Integer A) from 0 to 27, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of MissileHitCruiserTemp) Equal to MissileUnitType[(Integer A)]
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Killing unit) Equal to CruiserLocator[1]
                • Then - Actions
                  • -------- Usually where you set a real value, use the "Hashtable - Load Real Value (hashtable)" --------
                  • Set Cruiser1Shield = (Cruiser1Shield - ((Load 0 of (Integer A) from HashDamageData) x ShieldResistance[0]))
                  • -------- Usually where you set a integer value, use the "Hashtable - Load Integer Value (hashtable)" --------
                  • Set CoreDamageLeach[1] = (CoreDamageLeach[1] + ((Load 2 of (Integer A) from HashDamageData) / 2))
                  • Set CoreStabilityPoints[1] = (CoreStabilityPoints[1] - ((Load 3 of (Integer A) from HashDamageData) / 2))
                  • Set Cruiser1StoredPower = (Cruiser1StoredPower - (Load 4 of (Integer A) from HashDamageData))
                  • -------- You can check if things = true with Hashtable Boolean value, and with 2 dimension array you can set this condition to a certain number of units --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Load 6 of (Integer A) from HashDamageData) Equal to True
                    • Then - Actions
                      • -------- This applies more damage since this projectile gets a damage buff by a certain upgrade --------
                      • Set Cruiser1Shield = (Cruiser1Shield - (((Load 0 of (Integer A) from HashDamageData) x (0.20 x (Real((Current research level of Cruiser Laser Upgrade for (Owner of (Triggering unit))))))) x ShieldResistance[0]))
                    • Else - Actions
                  • Sound - Play ManaFlareStrike <gen> at 100.00% volume, attached to Battlecruiser Unit 0001 <gen>
                • Else - Actions
                  • Set Cruiser2Shield = (Cruiser2Shield - ((Load 0 of (Integer A) from HashDamageData) x ShieldResistance[1]))
                  • Set CoreDamageLeach[2] = (CoreDamageLeach[2] + ((Load 2 of (Integer A) from HashDamageData) / 2))
                  • Set CoreStabilityPoints[2] = (CoreStabilityPoints[2] - ((Load 3 of (Integer A) from HashDamageData) / 2))
                  • Set Cruiser2StoredPower = (Cruiser2StoredPower - (Load 4 of (Integer A) from HashDamageData))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Load 6 of (Integer A) from HashDamageData) Equal to True
                    • Then - Actions
                      • Set Cruiser2Shield = (Cruiser2Shield - (((Load 0 of (Integer A) from HashDamageData) x (0.20 x (Real((Current research level of Cruiser Laser Upgrade for (Owner of (Triggering unit))))))) x ShieldResistance[0]))
                    • Else - Actions
                  • Sound - Play ManaFlareStrike <gen> at 100.00% volume, attached to Battlecruiser Unit 0092 <gen>
            • Else - Actions


  • Hull Hit
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Killing unit)) Equal to Battlecruiser Hardpoint 2
    • Actions
      • -------- 3rd trigger --------
      • Set MissileHitCruiserTemp = (Triggering unit)
      • For each (Integer A) from 0 to 27, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of MissileHitCruiserTemp) Equal to MissileUnitType[(Integer A)]
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Killing unit)) Equal to Player 11 (Dark Green)
                • Then - Actions
                  • -------- Here there is a different value from the same setup --------
                  • Set Cruiser1Hull = (Cruiser1Hull - (Load 1 of (Integer A) from HashDamageData))
                  • Set CoreDamageLeach[1] = (CoreDamageLeach[1] + (Load 2 of (Integer A) from HashDamageData))
                  • Set CoreStabilityPoints[1] = (CoreStabilityPoints[1] - (Load 3 of (Integer A) from HashDamageData))
                  • Set Cruiser1StoredPower = (Cruiser1StoredPower - (Load 5 of (Integer A) from HashDamageData))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Load 6 of (Integer A) from HashDamageData) Equal to True
                    • Then - Actions
                      • Set Cruiser1Hull = (Cruiser1Hull - (((Load 1 of (Integer A) from HashDamageData) x (0.20 x (Real((Current research level of Cruiser Laser Upgrade for (Owner of (Triggering unit))))))) x ShieldResistance[0]))
                    • Else - Actions
                • Else - Actions
                  • Set Cruiser2Hull = (Cruiser2Hull - (Load 1 of (Integer A) from HashDamageData))
                  • Set CoreDamageLeach[2] = (CoreDamageLeach[2] + (Load 2 of (Integer A) from HashDamageData))
                  • Set CoreStabilityPoints[2] = (CoreStabilityPoints[2] - (Load 3 of (Integer A) from HashDamageData))
                  • Set Cruiser2StoredPower = (Cruiser2StoredPower - (Load 5 of (Integer A) from HashDamageData))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Load 6 of (Integer A) from HashDamageData) Equal to True
                    • Then - Actions
                      • Set Cruiser1Hull = (Cruiser1Hull - (((Load 1 of (Integer A) from HashDamageData) x (0.20 x (Real((Current research level of Cruiser Laser Upgrade for (Owner of (Triggering unit))))))) x ShieldResistance[0]))
                    • Else - Actions
            • Else - Actions
 
Level 7
Joined
Jan 28, 2012
Messages
266
yes it does, but you should use the unitype for the integer instead of 0, 1 etc..(this will eliminate your loop)
example
  • Hashtable - Save 15.00 as 0 of MissileUnitType[0] in HashDamageData
and then when you load it use Load 0 of GetUnitTypeId(Missile) etc..
 
  • Like
Reactions: TKF

TKF

TKF

Level 19
Joined
Nov 29, 2006
Messages
1,267
yes it does, but you should use the unitype for the integer instead of 0, 1 etc..(this will eliminate your loop)
example
  • Hashtable - Save 15.00 as 0 of MissileUnitType[0] in HashDamageData
and then when you load it use Load 0 of GetUnitTypeId(Missile) etc..

Well if the map I was working on was using the regular editor, I could do that but unfortunately it don't. I can't do that. I also get 8 errors when loading map.

Code:
Trigger Database Error
[Trigger Actions] - SaveWidgetHandleBJ
[Trigger Actions] - SaveAbilityHandleBJ
[Trigger Actions] - SaveTriggerEventHandleBJ
[Trigger Actions] - SaveRegionHandleBJ
[Trigger Actions] - SaveUnitPoolHandleBJ
[Trigger Actions] - SaveItemPoolHAndleBJ
[Trigger Actions] - SaveMultiboardItemHandleBJ
[Trigger Actions] - SaveTrackableHandleBJ
Data section and text section have differing number of parameters (3,4).

I can pick between WEU and UMSWE, If I don't pick one of them them map becomes not editable due to 1500 compile errors when resaving and total trigger failure nothing works ingame. A dirty trick Callex managed to made which I don't know how I can fix it.


EDIT: Forget it. I'm porting it out of UMSWE to check if I'm able to do as you said. I need a day or 2 maybe. Killing all adv. shit triggers.
 
Last edited:
Status
Not open for further replies.
Top