• 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.

Loading a hash value inside a unit group condition

Status
Not open for further replies.
Level 9
Joined
Dec 6, 2007
Messages
233
This
  • Set Temp_Unit_Group = (Units within (Real((Load Physical_Radius of (Key (Matching unit)) from Projectile_Hash))) of Laser_Point3 matching ((((Matching unit) is Mechanical) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True)))
is a line from a trigger of mine. Through some intense debugging, I determined that it doesn't work because Load Physical_Radius of (Key (Matching unit)) from Projectile_Hash returns a default 0 every time, which if it works correctly, should never be. Can I not load a hashtable value from matching unit? Or am I going to have to find an alternate solution?
 
This
  • Set Temp_Unit_Group = (Units within (Real((Load Physical_Radius of (Key (Matching unit)) from Projectile_Hash))) of Laser_Point3 matching ((((Matching unit) is Mechanical) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True)))
is a line from a trigger of mine. Through some intense debugging, I determined that it doesn't work because Load Physical_Radius of (Key (Matching unit)) from Projectile_Hash returns a default 0 every time, which if it works correctly, should never be. Can I not load a hashtable value from matching unit? Or am I going to have to find an alternate solution?

are you sure that you saved a value? or maybe you loaded a wrong value? or maybe you did not initialize the hashtable...

and please POST THE WHOLE TRIGGER so that we can easily see the problem...
 
Level 9
Joined
Dec 6, 2007
Messages
233
  • hash
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Rocket_Salvo_Hash = (Last created hashtable)
      • Hashtable - Create a hashtable
      • Set Attack_Target_Hash = (Last created hashtable)
      • Hashtable - Create a hashtable
      • Set armorhash = (Last created hashtable)
      • Hashtable - Create a hashtable
      • Set Projectile_Hash = (Last created hashtable)
      • Hashtable - Create a hashtable
      • Set Missile_Target_Hash = (Last created hashtable)
      • Hashtable - Create a hashtable
      • Set Compound_Hash = (Last created hashtable)
  • Unit Group - Pick every unit in Sheilds_Ready and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Picked unit)) Equal to Frigate
        • Then - Actions
          • Set Sheild_Radius = 150.00
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to Railgun Emplacement
            • Then - Actions
              • Set Sheild_Radius = 100.00
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Picked unit)) Equal to Carrier
                • Then - Actions
                  • Set Sheild_Radius = 150.00
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Picked unit)) Equal to Cruiser
                    • Then - Actions
                      • Set Sheild_Radius = 400.00
                    • Else - Actions
      • Hashtable - Save (Integer(Sheild_Radius)) as Physical_Radius of (Key (Picked unit)) in Projectile_Hash
      • Unit Group - Add (Picked unit) to Sheild_Protectees
  • Laser Beam
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Laser_Is_Firing and do (Actions)
        • Loop - Actions
          • Set Temp_Real = 700.00
          • Set Temp_Real2 = 700.00
          • Set Laser_Point1 = (Position of (Picked unit))
          • Set Laser_Point2 = (Position of (Load Laser_Target of (Key (Picked unit)) in Projectile_Hash))
          • Set Temp_Handel = (Picked unit)
          • For each (Integer A) from 1 to 70, do (Actions)
            • Loop - Actions
              • Set Laser_Point3 = (Laser_Point1 offset by ((Real((Integer A))) x 10.00) towards ((Angle from Laser_Point1 to Laser_Point2) + ((Real((Load Laser_Beam_Timer of (Key Temp_Handel) from Projectile_Hash))) - 15.00)) degrees)
              • Set Temp_Unit_Group = (Units within (Real((Load Physical_Radius of (Key (Matching unit)) from Projectile_Hash))) of Laser_Point3 matching ((((Matching unit) is Mechanical) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True)))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Temp_Unit_Group is empty) Equal to False
                • Then - Actions
                  • Set Temp_Real = (Distance between Laser_Point3 and Laser_Point1)
                • Else - Actions
              • Custom script: call DestroyGroup(udg_Temp_Unit_Group)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Temp_Real Less than Temp_Real2
                • Then - Actions
                  • Set Temp_Real2 = Temp_Real
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Temp_Real Not equal to 700.00
                    • Then - Actions
                      • Set Damaged_Unit = (Picked unit)
                      • Set Temp_Handel = (Picked unit)
                    • Else - Actions
                • Else - Actions
              • Custom script: call RemoveLocation(udg_Laser_Point3)
          • Custom script: call DestroyGroup(udg_Temp_Unit_Group)
          • Set Laser_Point3 = (Laser_Point1 offset by Temp_Real2 towards ((Angle from Laser_Point1 to Laser_Point2) + ((Real((Load Laser_Beam_Timer of (Key (Picked unit)) from Projectile_Hash))) - 15.00)) degrees)
          • Set Temp_Lightning1 = (Load Laser_Beam of (Key (Picked unit)) in Projectile_Hash)
          • Custom script: call MoveLightningEx(udg_Temp_Lightning1 , true, GetLocationX(udg_Laser_Point3), GetLocationY(udg_Laser_Point3), 75, GetLocationX(udg_Laser_Point1), GetLocationY(udg_Laser_Point1), 75)
          • Hashtable - Save ((Load Laser_Beam_Timer of (Key (Picked unit)) from Projectile_Hash) - 1) as Laser_Beam_Timer of (Key (Picked unit)) in Projectile_Hash
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Temp_Real Not equal to 700.00
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Damaged_Unit is in Sheild_Protectees) Equal to True
                • Then - Actions
                  • Unit - Set mana of Damaged_Unit to ((Mana of Damaged_Unit) - 1.00)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Load (Key armorvalue) of (Key Temp_Handel) from armorhash) Greater than or equal to 10
                    • Then - Actions
                      • Hashtable - Save ((Load (Key armorvalue) of (Key Temp_Handel) from armorhash) - 10) as (Key armorvalue) of (Key Temp_Handel) in armorhash
                    • Else - Actions
                      • Unit - Cause (Picked unit) to damage Ship, dealing (10.00 - (Real((Load (Key armorvalue) of (Key Temp_Handel) from armorhash)))) damage of attack type Spells and damage type Normal
                      • Hashtable - Save 0 as (Key armorvalue) of (Key Temp_Handel) in armorhash
            • Else - Actions
          • Custom script: call RemoveLocation(udg_Laser_Point1)
          • Custom script: call RemoveLocation(udg_Laser_Point2)
          • Custom script: call RemoveLocation(udg_Laser_Point3)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load Laser_Beam_Timer of (Key (Picked unit)) from Projectile_Hash) Equal to 0
            • Then - Actions
              • Unit Group - Remove (Picked unit) from Laser_Is_Firing
              • Lightning - Destroy Temp_Lightning1
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Laser_Is_Firing is empty) Equal to True
            • Then - Actions
              • Trigger - Turn off (This trigger)
            • Else - Actions
I suppose you'll need an explanation of the trigger. The trigger controls a sweeping continuous laser beam, making it stop at the closest point on an enemy ship. In my map, every ship has a specific shield radius, and when the shields go down they have a smaller physical radius. Hence the need to load this radius via hashtable. The laser sweeps out a 30 degree arc, following shield contours perfectly and looking awesome. I know this because it functions flawlessly if I set the number that it's having trouble loading to a random number. Whith the trigger as it is right now, it things that the enemy ship is size 0, and therefore the laser never even hits it.

There is one other flaw.

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Temp_Real Less than Temp_Real2
    • Then - Actions
      • Set Temp_Real2 = Temp_Real
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Temp_Real Not equal to 700.00
        • Then - Actions
          • Set Damaged_Unit = (Picked unit)
          • Set Temp_Handel = (Picked unit)
        • Else - Actions
    • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Temp_Real Not equal to 700.00
    • Then - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Damaged_Unit is in Sheild_Protectees) Equal to True
        • Then - Actions
          • Unit - Set mana of Damaged_Unit to ((Mana of Damaged_Unit) - 1.00)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load (Key armorvalue) of (Key Temp_Handel) from armorhash) Greater than or equal to 10
            • Then - Actions
              • Hashtable - Save ((Load (Key armorvalue) of (Key Temp_Handel) from armorhash) - 10) as (Key armorvalue) of (Key Temp_Handel) in armorhash
            • Else - Actions
              • Unit - Cause (Picked unit) to damage Ship, dealing (10.00 - (Real((Load (Key armorvalue) of (Key Temp_Handel) from armorhash)))) damage of attack type Spells and damage type Normal
              • Hashtable - Save 0 as (Key armorvalue) of (Key Temp_Handel) in armorhash
    • Else - Actions
^These don't work, no damage is applied, and mana isn't depleted at all. I suppose I could use some help here too


EDIT: oops, wrong line of code, i still had my random number in there, lemme fix that...

EDIT2: Fixed
 
Last edited:
Level 9
Joined
Dec 6, 2007
Messages
233
  • For each (Integer A) from 1 to 70, do (Actions)
    • Loop - Actions
      • Set Laser_Point3 = (Laser_Point1 offset by ((Real((Integer A))) x 10.00) towards ((Angle from Laser_Point1 to Laser_Point2) + ((Real((Load Laser_Beam_Timer of (Key Temp_Handel) from Projectile_Hash))) - 15.00)) degrees)
      • Set Temp_Unit_Group = (Units within (Real((Load Physical_Radius of (Key (Matching unit)) from Projectile_Hash))) of Laser_Point3 matching ((((Matching unit) is Mechanical) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Temp_Unit_Group is empty) Equal to False
        • Then - Actions
          • Set Temp_Real = (Distance between Laser_Point3 and Laser_Point1)
        • Else - Actions
      • Custom script: call DestroyGroup(udg_Temp_Unit_Group)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Temp_Real Less than Temp_Real2
        • Then - Actions
          • Set Temp_Real2 = Temp_Real
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Temp_Real Not equal to 700.00
            • Then - Actions
              • Set Damaged_Unit = (Picked unit)
              • Set Temp_Handel = (Picked unit)
            • Else - Actions
        • Else - Actions
      • Custom script: call RemoveLocation(udg_Laser_Point3)
set Temp_Unit_Group =
 
Level 9
Joined
Dec 6, 2007
Messages
233
It's finding units that are touching the point it's checking. Picked unit in it's case refers to the unit picked from Laser_Is_Firing (I checked to make sure).
 
I really think the problem lies in that part or else it lies in your saving part but I cannot find a problem there...

anyway from what I understand, matching unit is only used for comparisons/conditions, and for a group pick, matching unit will then be equal to every one unit that it checks to be included or not in the group, if so then that is your problem and that would mean that you cant really use it...
 
Level 9
Joined
Dec 6, 2007
Messages
233
Ok, that's what i thought, but i wanted to make sure. I made a workaround that is a little slower, but works. However, I'm still having this problem:
There is one other flaw.

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Temp_Real Less than Temp_Real2
    • Then - Actions
      • Set Temp_Real2 = Temp_Real
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Temp_Real Not equal to 700.00
        • Then - Actions
          • Set Damaged_Unit = (Picked unit)
          • Set Temp_Handel = (Picked unit)
        • Else - Actions
    • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Temp_Real Not equal to 700.00
    • Then - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Damaged_Unit is in Sheild_Protectees) Equal to True
        • Then - Actions
          • Unit - Set mana of Damaged_Unit to ((Mana of Damaged_Unit) - 1.00)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load (Key armorvalue) of (Key Temp_Handel) from armorhash) Greater than or equal to 10
            • Then - Actions
              • Hashtable - Save ((Load (Key armorvalue) of (Key Temp_Handel) from armorhash) - 10) as (Key armorvalue) of (Key Temp_Handel) in armorhash
            • Else - Actions
              • Unit - Cause (Picked unit) to damage Ship, dealing (10.00 - (Real((Load (Key armorvalue) of (Key Temp_Handel) from armorhash)))) damage of attack type Spells and damage type Normal
              • Hashtable - Save 0 as (Key armorvalue) of (Key Temp_Handel) in armorhash
    • Else - Actions
^These don't work, no damage is applied, and mana isn't depleted at all. I suppose I could use some help here too
 
Ok, that's what i thought, but i wanted to make sure. I made a workaround that is a little slower, but works. However, I'm still having this problem:

the matching unit is only set once the group enum action is fired and you use it at the function call itself so basically there is no matching unit yet...

why not just used the variable damage_unit since temp_handel is also equal to picked unit which is also equal to damage_unit.... also your temp_real not equal to 700 is a bit redundant... you already used it when you set the damage_unit and temp_handel so no need for it in the next actions really... next, where do you set the variable Ship? for the mana thing, I have no idea why it doesnt reduce the mana...
 
Level 9
Joined
Dec 6, 2007
Messages
233
If you're curious, here's what i did to fix it

  • For each (Integer A) from 1 to 70, do (Actions)
    • Loop - Actions
      • Set Laser_Point3 = (Laser_Point1 offset by ((Real((Integer A))) x 10.00) towards ((Angle from Laser_Point1 to Laser_Point2) + ((Real((Load Laser_Beam_Timer of (Key Temp_Handel) from Projectile_Hash))) - 15.00)) degrees)
      • Set Temp_Unit_Group = (Units within 700.00 of Laser_Point3 matching ((((Matching unit) is Mechanical) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True)))
      • Unit Group - Pick every unit in Temp_Unit_Group and do (Actions)
        • Loop - Actions
          • Set Temp_Unit_Loc = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between Temp_Unit_Loc and Laser_Point3) Less than or equal to (Real((Load Physical_Radius of (Key (Picked unit)) from Projectile_Hash)))
            • Then - Actions
            • Else - Actions
              • Unit Group - Remove (Picked unit) from Temp_Unit_Group
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Temp_Unit_Group is empty) Equal to False
        • Then - Actions
          • Set Temp_Real = (Distance between Laser_Point3 and Laser_Point1)
        • Else - Actions
      • Custom script: call DestroyGroup(udg_Temp_Unit_Group)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Temp_Real Less than Temp_Real2
        • Then - Actions
          • Set Temp_Real2 = Temp_Real
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Temp_Real Not equal to 700.00
            • Then - Actions
              • Set Damaged_Unit = (Picked unit)
              • Set Temp_Handel = (Picked unit)
            • Else - Actions
        • Else - Actions
      • Custom script: call RemoveLocation(udg_Laser_Point3)
 
Status
Not open for further replies.
Top