• 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] help triggers about arrow keys

Status
Not open for further replies.
Level 5
Joined
Sep 22, 2012
Messages
90
greeting peepz,

First off, I AM NOOB:

I have this so called arrow key system, uploaded here in hive:
my map

I've noticed that every minutes it takes up more memory. I've tried reading different stuff about memory leaks from programming view and war3 view. I've managed to add some custom scripts but its no good. Even without using some triggered abilities, it somehow leaks :(. Any suggestions? please help I want to learn this stuff.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
1. Why do you create events for ALL players instead of only creating them for the playings that are actually playing? There's no need to. Use the "(All Players) loop. (All Players) only returns players that are playing, not computers nor neutrals.
  • Player Group - Pick every player in (All Players) and do (Actions)
    • Loop - Actions
      • Trigger - Add event...
2. Everytime you use "Position of..." "Center of..." you're leaking. You have to do
  • Set PointVariable = Center Of Region
  • Unit - Create unit at PointVariable
  • Custom script: call RemoveLocation(udg_PointVariable)
3. Create a Player Group for those that are pressing a key. When they press the arrow, add them to the group and turn on the loop. When they release the arrow key, remove them from the group. Make the Loop actions inside an "Then" block. The "if" is (Number of Players in This Group is > 0) and the "Else" is "Turn off This Trigger".
  • If - Conditions
    • Number of Players in ThisGroup is greater than 0
  • Then - Actions
    • Player Group - Pick Every Player in All Players and.. bla bla
  • Else - Actions
    • Trigger - Turn off (This Trigger)
My best suggestion: Turn everything to JASS, and optimize it removing BJ's, avoiding unneeded Conditions Functions, and using locals instead of globals.
 
Last edited:
Level 5
Joined
Sep 22, 2012
Messages
90
I forgot, the moveing actions are supposed to be if-else ladders, here is it
  • moveloop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer every_players) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (unit_main[every_players] is alive) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • unit_move_valid[every_players] Equal to True
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • arrow_east[every_players] Equal to True
                          • arrow_west[every_players] Equal to True
                          • arrow_north[every_players] Equal to True
                          • arrow_south[every_players] Equal to True
                    • Then - Actions
                      • Set event_presser = True
                      • Set temp_loc_from = (Position of unit_main[every_players])
                      • -------- speedmodifiers**stun,slow,haste --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Or - Any (Conditions) are true
                            • Conditions
                              • (unit_main[every_players] has buff Stunned) Equal to True
                        • Then - Actions
                          • Set unit_move_valid[every_players] = False
                        • Else - Actions
                          • Set unit_current_speed[every_players] = unit_speed_original[every_players]
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Or - Any (Conditions) are true
                            • Conditions
                              • (unit_main[every_players] has buff Unknown (B003)) Equal to True
                        • Then - Actions
                          • Set unit_current_speed[every_players] = (unit_current_speed[every_players] x 1.60)
                        • Else - Actions
                          • Set unit_current_speed[every_players] = unit_speed_original[every_players]
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Or - Any (Conditions) are true
                            • Conditions
                              • (unit_main[every_players] has buff Tornado (Slow Aura)) Equal to True
                        • Then - Actions
                          • Set unit_current_speed[every_players] = (unit_current_speed[every_players] x 0.80)
                        • Else - Actions
                          • Set unit_current_speed[every_players] = unit_speed_original[every_players]
                      • -------- donecheckbuff --------
                      • Set reset_anim = False
                      • -------- chkpath --------
                      • Set path_check = (temp_loc_from offset by 60.00 towards 0.00 degrees)
                      • Custom script: set bj_wantDestroyGroup = true
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (unit_main[every_players] is A flying unit) Not equal to True
                          • Or - Any (Conditions) are true
                            • Conditions
                              • (Number of units in (Units within 60.00 of path_check)) Greater than 1
                              • (Terrain pathing at path_check of type Walkability is off) Equal to True
                        • Then - Actions
                          • Set rect_ee = False
                        • Else - Actions
                          • Set rect_ee = True
                      • Custom script: call RemoveLocation(udg_path_check)
                      • -------- chkpath --------
                      • Set path_check = (temp_loc_from offset by 60.00 towards 90.00 degrees)
                      • Custom script: set bj_wantDestroyGroup = true
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (unit_main[every_players] is A flying unit) Not equal to True
                          • Or - Any (Conditions) are true
                            • Conditions
                              • (Number of units in (Units within 60.00 of path_check)) Greater than 1
                              • (Terrain pathing at path_check of type Walkability is off) Equal to True
                        • Then - Actions
                          • Set rect_nn = False
                        • Else - Actions
                          • Set rect_nn = True
                      • Custom script: call RemoveLocation(udg_path_check)
                      • -------- chkpath --------
                      • Set path_check = (temp_loc_from offset by 60.00 towards 180.00 degrees)
                      • Custom script: set bj_wantDestroyGroup = true
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (unit_main[every_players] is A flying unit) Not equal to True
                          • Or - Any (Conditions) are true
                            • Conditions
                              • (Number of units in (Units within 60.00 of path_check)) Greater than 1
                              • (Terrain pathing at path_check of type Walkability is off) Equal to True
                        • Then - Actions
                          • Set rect_ww = False
                        • Else - Actions
                          • Set rect_ww = True
                      • Custom script: call RemoveLocation(udg_path_check)
                      • -------- chkpath --------
                      • Set path_check = (temp_loc_from offset by 60.00 towards 270.00 degrees)
                      • Custom script: set bj_wantDestroyGroup = true
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (unit_main[every_players] is A flying unit) Not equal to True
                          • Or - Any (Conditions) are true
                            • Conditions
                              • (Number of units in (Units within 60.00 of path_check)) Greater than 1
                              • (Terrain pathing at path_check of type Walkability is off) Equal to True
                        • Then - Actions
                          • Set rect_ss = False
                        • Else - Actions
                          • Set rect_ss = True
                      • Custom script: call RemoveLocation(udg_path_check)
                      • -------- chkpath --------
                      • -------- moveproc --------
                      • Animation - Play unit_main[every_players]'s walk animation, using only Common animations
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • And - All (Conditions) are true
                            • Conditions
                              • And - All (Conditions) are true
                                • Conditions
                                  • arrow_south[every_players] Equal to True
                                  • arrow_west[every_players] Equal to True
                              • And - All (Conditions) are true
                                • Conditions
                                  • rect_ss Equal to True
                                  • rect_ww Equal to True
                        • Then - Actions
                          • Set temp_loc_to = (temp_loc_from offset by unit_current_speed[every_players] towards 225.00 degrees)
                          • Unit - Move unit_main[every_players] instantly to temp_loc_to, facing 225.00 degrees
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • And - All (Conditions) are true
                                • Conditions
                                  • And - All (Conditions) are true
                                    • Conditions
                                      • arrow_south[every_players] Equal to True
                                      • arrow_east[every_players] Equal to True
                                  • And - All (Conditions) are true
                                    • Conditions
                                      • rect_ss Equal to True
                                      • rect_ee Equal to True
                            • Then - Actions
                              • Set temp_loc_to = (temp_loc_from offset by unit_current_speed[every_players] towards 315.00 degrees)
                              • Unit - Move unit_main[every_players] instantly to temp_loc_to, facing 315.00 degrees
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • And - All (Conditions) are true
                                    • Conditions
                                      • And - All (Conditions) are true
                                        • Conditions
                                          • arrow_north[every_players] Equal to True
                                          • arrow_east[every_players] Equal to True
                                      • And - All (Conditions) are true
                                        • Conditions
                                          • rect_nn Equal to True
                                          • rect_ee Equal to True
                                • Then - Actions
                                  • Set temp_loc_to = (temp_loc_from offset by unit_current_speed[every_players] towards 45.00 degrees)
                                  • Unit - Move unit_main[every_players] instantly to temp_loc_to, facing 45.00 degrees
                                • Else - Actions
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • And - All (Conditions) are true
                                        • Conditions
                                          • And - All (Conditions) are true
                                            • Conditions
                                              • arrow_north[every_players] Equal to True
                                              • arrow_west[every_players] Equal to True
                                          • And - All (Conditions) are true
                                            • Conditions
                                              • rect_nn Equal to True
                                              • rect_ww Equal to True
                                    • Then - Actions
                                      • Set temp_loc_to = (temp_loc_from offset by unit_current_speed[every_players] towards 135.00 degrees)
                                      • Unit - Move unit_main[every_players] instantly to temp_loc_to, facing 135.00 degrees
                                    • Else - Actions
                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                        • If - Conditions
                                          • And - All (Conditions) are true
                                            • Conditions
                                              • arrow_west[every_players] Equal to True
                                              • rect_ww Equal to True
                                        • Then - Actions
                                          • Set temp_loc_to = (temp_loc_from offset by unit_current_speed[every_players] towards 180.00 degrees)
                                          • Unit - Move unit_main[every_players] instantly to temp_loc_to, facing 180.00 degrees
                                        • Else - Actions
                                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            • If - Conditions
                                              • And - All (Conditions) are true
                                                • Conditions
                                                  • arrow_east[every_players] Equal to True
                                                  • rect_ee Equal to True
                                            • Then - Actions
                                              • Set temp_loc_to = (temp_loc_from offset by unit_current_speed[every_players] towards 0.00 degrees)
                                              • Unit - Move unit_main[every_players] instantly to temp_loc_to, facing 0.00 degrees
                                            • Else - Actions
                                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                • If - Conditions
                                                  • And - All (Conditions) are true
                                                    • Conditions
                                                      • arrow_south[every_players] Equal to True
                                                      • rect_ss Equal to True
                                                • Then - Actions
                                                  • Set temp_loc_to = (temp_loc_from offset by unit_current_speed[every_players] towards 270.00 degrees)
                                                  • Unit - Move unit_main[every_players] instantly to temp_loc_to, facing 270.00 degrees
                                                • Else - Actions
                                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                    • If - Conditions
                                                      • And - All (Conditions) are true
                                                        • Conditions
                                                          • arrow_north[every_players] Equal to True
                                                          • rect_nn Equal to True
                                                    • Then - Actions
                                                      • Set temp_loc_to = (temp_loc_from offset by unit_current_speed[every_players] towards 90.00 degrees)
                                                      • Unit - Move unit_main[every_players] instantly to temp_loc_to, facing 90.00 degrees
                                                    • Else - Actions
                      • Custom script: call RemoveLocation(udg_temp_loc_to)
                      • Custom script: call RemoveLocation(udg_temp_loc_from)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • arrow_east[every_players] Equal to False
                          • arrow_west[every_players] Equal to False
                          • arrow_north[every_players] Equal to False
                          • arrow_south[every_players] Equal to False
                        • Then - Actions
                          • Set event_presser = False
                        • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • reset_anim Equal to False
                        • Then - Actions
                          • Set reset_anim = True
                          • Animation - Reset unit_main[every_players]'s animation
                        • Else - Actions
                          • Animation - Queue unit_main[every_players]'s stand animation
                • Else - Actions
                  • Set event_presser = True
            • Else - Actions
              • Animation - Queue unit_main[every_players]'s death animation
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • event_presser Equal to False
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
Mr.Mag told be to add all pressing events at initialization. I don't want getting into complex stuff like jass since I'm still learning the basics of programming. It seems to be working fine until I've notice mem build ups :(
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Yeah, add those pressing events on map initialization, but only for players that are playing. That's what i said in subject #1 in my past post.

I know you don't handle jass, but I still had yo suggest it.
 
Level 5
Joined
Sep 22, 2012
Messages
90
well thanks sir, I'll see jass if I can handle it. Does it still leak? i mean my moving actions? Thanks for the feedback :D. I'll try doing add players to group.
 
Status
Not open for further replies.
Top