• 🏆 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] Hashtable problems

Status
Not open for further replies.
Level 19
Joined
Aug 16, 2007
Messages
881
Well, I've not been triggering for a while and now I got problems with my bullet system I'm creating for my map. The bullets won't move. Please take a look at those two triggers and tell me if you see any error. (=

The system is NOT DONE yet, I'll just have to fix this "won't" move error.

(I've added three debug texts in my system trigger, Ingame it will show:

1
2
1
3



  • Shoot
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Shoot
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Player_Weapon[(Player number of (Owner of (Triggering unit)))] Equal to 1
        • Then - Actions
          • Set temp_point[0] = (Position of (Triggering unit))
          • Set temp_point[1] = (Target point of ability being cast)
          • Set r[0] = (Angle from temp_point[0] to temp_point[1])
          • Set temp_point[2] = (temp_point[0] offset by 10.00 towards r[0] degrees)
          • Unit - Create 1 Bullet_Dummy for (Owner of (Triggering unit)) at temp_point[2] facing r[0] degrees
          • Special Effect - Create a special effect attached to the chest of (Last created unit) using Abilities\Weapons\QuillSprayMissile\QuillSprayMissile.mdl
          • -------- -- -- -- -- -- -- --------
          • Set r[1] = 50.00
          • Set r[2] = 12.50
          • Set r[3] = 20.00
          • Set r[4] = 0.00
          • Set r[5] = (Distance between temp_point[0] and temp_point[1])
          • Set r[6] = 40.00
          • Hashtable - Save r[0] as (Key Angle) of (Key (Last created unit)) in BulletSys_Hashtable
          • Hashtable - Save r[1] as (Key Damage) of (Key (Last created unit)) in BulletSys_Hashtable
          • Hashtable - Save r[2] as (Key Speed) of (Key (Last created unit)) in BulletSys_Hashtable
          • Hashtable - Save r[3] as (Key Height) of (Key (Last created unit)) in BulletSys_Hashtable
          • Hashtable - Save r[4] as (Key DisTravel) of (Key (Last created unit)) in BulletSys_Hashtable
          • Hashtable - Save r[5] as (Key DisTravelMax) of (Key (Last created unit)) in BulletSys_Hashtable
          • Hashtable - Save r[6] as (Key AoEHit) of (Key (Last created unit)) in BulletSys_Hashtable
          • Hashtable - Save Handle Of(Last created special effect) as (Key Model) of (Key (Last created unit)) in BulletSys_Hashtable
          • Unit Group - Add (Last created unit) to BulletSysGroup[0]
          • Set BulletSys_Int = (BulletSys_Int + 1)
          • -------- -- -- -- -- -- -- --------
          • Custom script: call RemoveLocation(udg_temp_point[0])
          • Custom script: call RemoveLocation(udg_temp_point[1])
          • Custom script: call RemoveLocation(udg_temp_point[2])
        • Else - Actions
      • -------- - - - - - - --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • BulletSys_Int Greater than 0
        • Then - Actions
          • Trigger - Turn on Bullet System <gen>
        • Else - Actions




  • Bullet System
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Game - Display to (All players) the text: 1
      • Set BulletSysGroup[1] = (Random BulletSys_Int units from BulletSysGroup[0])
      • Unit Group - Pick every unit in BulletSysGroup[1] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
            • Then - Actions
              • Game - Display to (All players) the text: 2
              • -------- Load Angle --------
              • Set BS_r[0] = (Load (Key Angle) of (Key (Picked unit)) from BulletSys_Hashtable)
              • -------- Load Damage --------
              • Set BS_r[1] = (Load (Key Damage) of (Key (Picked unit)) from BulletSys_Hashtable)
              • -------- Load Speed --------
              • Set BS_r[2] = (Load (Key Speed) of (Key (Picked unit)) from BulletSys_Hashtable)
              • -------- Load Height --------
              • Set BS_r[3] = (Load (Key Height) of (Key (Picked unit)) from BulletSys_Hashtable)
              • -------- Load DisTravel --------
              • Set BS_r[4] = (Load (Key DisTravel) of (Key (Picked unit)) from BulletSys_Hashtable)
              • -------- Load DisTravelMax --------
              • Set BS_r[5] = (Load (Key DisTravelMax) of (Key (Picked unit)) from BulletSys_Hashtable)
              • -------- Load AoEHit --------
              • Set BS_r[6] = (Load (Key AoEHit) of (Key (Picked unit)) from BulletSys_Hashtable)
              • -------- - - - - - --------
              • Set BS_r[4] = (BS_r[4] + BS_r[2])
              • Set temp_point[0] = (Position of (Picked unit))
              • Set temp_point[1] = (temp_point[0] offset by BS_r[2] towards BS_r[0] degrees)
              • Unit - Move (Picked unit) instantly to temp_point[1]
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • BS_r[4] Greater than or equal to BS_r[5]
                • Then - Actions
                  • Unit - Kill (Picked unit)
                • Else - Actions
                  • Hashtable - Save BS_r[4] as (Key DisTravel) of (Key (Picked unit)) in BulletSys_Hashtable
              • -------- - - - - - --------
              • Custom script: call RemoveLocation(udg_temp_point[0])
              • Custom script: call RemoveLocation(udg_temp_point[1])
            • Else - Actions
              • Game - Display to (All players) the text: 3
              • Special Effect - Destroy (Load (Key Model) of (Key (Picked unit)) in BulletSys_Hashtable)
              • Unit Group - Remove (Picked unit) from BulletSysGroup[0]
              • Set BulletSys_Int = (BulletSys_Int - 1)
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in BulletSys_Hashtable
      • Custom script: call DestroyGroup(udg_BulletSysGroup[1])
      • -------- - - - - - --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • BulletSys_Int Less than or equal to 0
        • Then - Actions
          • Trigger - Turn off Bullet System <gen>
        • Else - Actions
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Can't see anything wrong with it. Try debugging if with floating text, create it above picked unit, and make it display the speed. Also create floating text at loc[0] and loc[1] to see if they are correct.

What do you use Bullet_Sys_int for? To me it looks unnecessary. It's the same as number of units in group[0]. Therefore group[1] is unnecessary. Or am I missing something?
 
Level 19
Joined
Aug 16, 2007
Messages
881
Can't see anything wrong with it. Try debugging if with floating text, create it above picked unit, and make it display the speed. Also create floating text at loc[0] and loc[1] to see if they are correct.

What do you use Bullet_Sys_int for? To me it looks unnecessary. It's the same as number of units in group[0]. Therefore group[1] is unnecessary. Or am I missing something?

I'll try that ^^ Well, won't the Unit Group leak if I use it without destroying it? And if I destroy it, won't all units in that group disappear then? That's why I'm using Bullet_Sys_Int, etc.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
You can add and remove units from a group without causing a leak. You don't need to destroy BulletSysGroup[0] at all with the way you're using it.

Remove these lines:

Set BulletSys_Int = (BulletSys_Int + 1)
Set BulletSysGroup[1] = (Random BulletSys_Int units from BulletSysGroup[0])
Custom script: call DestroyGroup(udg_BulletSysGroup[1])
Set BulletSys_Int = (BulletSys_Int - 1)

and replace

"BulletSys_Int Greater than 0" with "Trigger- Bullet System is off"
"Unit Group - Pick every unit in BulletSysGroup[1] and do (Actions)" with "Unit Group - Pick every unit in BulletSysGroup[0] and do (Actions)"
"BulletSys_Int Less than or equal to 0" with "BulletSysGroup[0] is empty"
 
Level 19
Joined
Aug 16, 2007
Messages
881
You can add and remove units from a group without causing a leak. You don't need to destroy BulletSysGroup[0] at all with the way you're using it.

Remove these lines:

Set BulletSys_Int = (BulletSys_Int + 1)
Set BulletSysGroup[1] = (Random BulletSys_Int units from BulletSysGroup[0])
Custom script: call DestroyGroup(udg_BulletSysGroup[1])

and replace

"BulletSys_Int Greater than 0" with "Trigger- Bullet System is off"
"Unit Group - Pick every unit in BulletSysGroup[1] and do (Actions)" with "Unit Group - Pick every unit in BulletSysGroup[0] and do (Actions)"
"BulletSys_Int Less than or equal to 0" with "BulletSysGroup[0] is empty"

Thanks, I got it to work now! :D +rep
 
Status
Not open for further replies.
Top