Advertisement
Guest User

Untitled

a guest
Sep 30th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. once
  2. 0 ->selected
  3. endonce
  4.  
  5. 0 GetMouseButtonDown if
  6. #This check makes sure the click event wasn't in the "forbidden space" at the bottom of the screen. This "forbidden space" is the area where the UI menus are located, so we don't want clicks in the menu area to apply to our unit.
  7. GetMouseScreenPixelPosition 96 gt if
  8. #Now that we've determined that the click was "legal" we check to see if the unit is currently selected so we know how to handle the click.
  9. <-selected eq0 if
  10. #If the unit is not currently selected, we check to see if the click happened within a certain radius of the Bertha. That way you can select the unit by clicking on the Bertha.
  11. GetMouseCell CurrentCoords Distance 4 lt if
  12. #Sets the selected state. We'll get to applying the effects in a minute.
  13. 1 ->selected
  14. #The 1 delay is to prevent aberrant behavior with clicks being processed multiple times.
  15. 1 Delay
  16. endif
  17. else
  18. #This else block will execute if the unit is already selected. Here you can process behavior for clicks while unit is selected, potentially deselecting the unit
  19.  
  20. 0 ->selected
  21. endif
  22. endif
  23. endif
  24.  
  25. #Now that we've processed clicks, we apply effects depending on whether or not the unit is selected.
  26. <-selected eq0 if
  27. #These important part of these SetImageColor commands is the final 0. That's the alpha value. That means these calls will set the images to be invisible.
  28. Self "aim" 255 0 0 0 SetImageColor
  29. Self "selector" 255 255 255 0 SetImageColor
  30. else
  31. #If the unit is selected first we display the selector and aim images. Again, the alpha value is the important part.
  32. Self "selector" 255 255 255 255 SetImageColor
  33. Self "aim" 255 0 0 100 SetImageColor
  34. #Next we check to see if the player has pressed C, V, or B while the unit is selected and toggle the appropriate state if so.
  35. "C" GetKeyDown if
  36. <-deactivated not ->deactivated
  37. endif
  38. "V" GetKeyDown if
  39. <-disarmed not ->disarmed
  40. endif
  41. "B" GetKeyDown if
  42. <-disconnected not ->disconnected
  43. endif
  44. #Finally, check to see if the user presses "Space" or "Escape" and deselect the unit if they do.
  45. "Space" GetKeyDown "Escape" GetKeyDown or if 0 ->selected endif
  46. endif
  47.  
  48. #Next we apply effects based on what state the unit is in.
  49. <-deactivated if
  50. #This makes the "deactivated" image visible and stops ammo resupply if deactivated. As usual, the alpha is the important part of the SetImageColor command.
  51. Self "deactivated" 255 255 255 255 SetImageColor
  52. Self CONST_REQUESTACPACKETS 0 SetUnitAttribute
  53. else
  54. #Make the "deactivated" image invisible if not deactivated.
  55. Self "deactivated" 255 255 255 0 SetImageColor
  56. endif
  57.  
  58. #Same stuff as deactivated. The actual "disarming" mechanism for disarming and deactivation will be handled a little later in the firing function.
  59. <-disarmed if
  60. Self "disarmed" 255 50 50 90 SetImageColor
  61. else
  62. Self "disarmed" 255 50 50 0 SetImageColor
  63. endif
  64.  
  65. #Again, same stuff.
  66. <-disconnected if
  67. Self "disconnected" 255 255 255 90 SetImageColor
  68. Self CONST_REQUESTACPACKETS 0 SetUnitAttribute
  69. else
  70. Self "disconnected" 255 255 255 0 SetImageColor
  71. endif
  72.  
  73. #Sets the unit to request AC packets only if not locked, not deactivated, and not disconnected.
  74. <-disconnected not <-deactivated not and if
  75. Self CONST_REQUESTACPACKETS 1 SetUnitAttribute
  76. endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement