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.
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 --------
-
Events
-
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
-
If - Conditions
- 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
-
If - Conditions
- Sound - Play ManaFlareStrike <gen> at 100.00% volume, attached to Battlecruiser Unit 0092 <gen>
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
Events
-
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
-
If - Conditions
-
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
-
If - Conditions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
Events