• 🏆 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] A faster response.

Status
Not open for further replies.
Level 15
Joined
Oct 29, 2012
Messages
1,474
Hi guys, long-story-short-ly, I have some ARROWS system. Although I know it's not very efficient and has a delay, but that's not the problem. The problem is, the response to trigger after another one stops. For example, HERO goes right according to Right trigger, then when RIGHT ARROW is released, the unit stops, and directly presses LEFT, then Left trigger runs. Unfortunately, releasing right arrow then clicking left directly doesn't work, which makes the unit just stops, and left trigger will be ignored. I want a faster response whereas LEFT trigger will run after right trigger stops.

Here are triggers:
  • Paint Right Stop
    • Events
      • Player - Player 1 (Red) Releases the Right Arrow key
      • Player - Player 2 (Blue) Releases the Right Arrow key
      • Player - Player 3 (Teal) Releases the Right Arrow key
      • Player - Player 4 (Purple) Releases the Right Arrow key
      • Player - Player 5 (Yellow) Releases the Right Arrow key
      • Player - Player 6 (Orange) Releases the Right Arrow key
      • Player - Player 7 (Green) Releases the Right Arrow key
      • Player - Player 8 (Pink) Releases the Right Arrow key
      • Player - Player 9 (Gray) Releases the Right Arrow key
      • Player - Player 10 (Light Blue) Releases the Right Arrow key
      • Player - Player 11 (Dark Green) Releases the Right Arrow key
    • Conditions
      • ((Triggering player) is in Paint_Up_Players) Equal to False
      • ((Triggering player) is in Paint_Left_Players) Equal to False
      • ((Triggering player) is in Paint_Down_Players) Equal to False
      • ((Triggering player) is in Paint_Waving_Players) Equal to False
    • Actions
      • Player Group - Remove (Triggering player) from Paint_Right_Players
      • Animation - Reset CharacterUnit[(Player number of (Triggering player))]'s animation
  • Paint Left
    • Events
      • Player - Player 1 (Red) Presses the Left Arrow key
      • Player - Player 2 (Blue) Presses the Left Arrow key
      • Player - Player 3 (Teal) Presses the Left Arrow key
      • Player - Player 4 (Purple) Presses the Left Arrow key
      • Player - Player 5 (Yellow) Presses the Left Arrow key
      • Player - Player 6 (Orange) Presses the Left Arrow key
      • Player - Player 7 (Green) Presses the Left Arrow key
      • Player - Player 8 (Pink) Presses the Left Arrow key
      • Player - Player 9 (Gray) Presses the Left Arrow key
      • Player - Player 10 (Light Blue) Presses the Left Arrow key
      • Player - Player 11 (Dark Green) Presses the Left Arrow key
    • Conditions
      • ((Triggering player) is in Paint_Up_Players) Equal to False
      • ((Triggering player) is in Paint_Right_Players) Equal to False
      • ((Triggering player) is in Paint_Down_Players) Equal to False
      • ((Triggering player) is in Paint_Waving_Players) Equal to False
    • Actions
      • Player Group - Add (Triggering player) to Paint_Left_Players
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Store booleans in an array like "right arrow is down[]" and "left arrow is down[]"
every 0.03 seconds (which i assume that you use to do something) dont pick every player in player group but check for all players what arrows are down.
if both are down, do nothing
else do something
that is a more effective and maybe more efficient way to do this
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
For loops we almost all use 0.03 as you cannot see visual difference between 0.03 and 0.01...
You might have seen this other thread that I started a while ago where they discuss this 0.03 loop on a very high level... which has nothing to do with the original question though.
You could reduce cpu usage 3 times by using 0.03 instead of 0.01.

But that is not what we discuss in here.
You could indeed pick every unit in (All Players) and get the player number and use that to access the booleans.
But you could also do it like this:
  • For each (Integer TempInteger) from 1 to 12, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • IsArrowDown_LeftArrow[TempInteger] Equal to True
              • IsArrowDown_RightArrow[TempInteger] Equal to False
        • Then - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • IsArrowDown_LeftArrow[TempInteger] Equal to False
              • IsArrowDown_RightArrow[TempInteger] Equal to True
        • Then - Actions
        • Else - Actions
I actually used different variable names but you can figure.
Be aware that if you use "Player number of (Player)" starts with 1 while "GetPlayerNumber()" starts with 0.
(This only matters if you use JASS in your map.)
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Ofcourse you can figgure the key pressed/released trigger but if not then here it is:
  • Press Left Arrow Key
    • Events
      • Player - Player 1 (Red) Presses the Left Arrow key
      • Player - Player 2 (Blue) Presses the Left Arrow key
      • Player - Player 3 (Teal) Presses the Left Arrow key
      • Player - Player 4 (Purple) Presses the Left Arrow key
      • Player - Player 5 (Yellow) Presses the Left Arrow key
    • Conditions
    • Actions
      • Set IsArrowDown_LeftArrow[(Player number of (Triggering player))] = True
 
Status
Not open for further replies.
Top