Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- once
- 0 ->selected
- endonce
- 0 GetMouseButtonDown if
- #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.
- GetMouseScreenPixelPosition 96 gt if
- #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.
- <-selected eq0 if
- #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.
- GetMouseCell CurrentCoords Distance 4 lt if
- #Sets the selected state. We'll get to applying the effects in a minute.
- 1 ->selected
- #The 1 delay is to prevent aberrant behavior with clicks being processed multiple times.
- 1 Delay
- endif
- else
- #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
- 0 ->selected
- endif
- endif
- endif
- #Now that we've processed clicks, we apply effects depending on whether or not the unit is selected.
- <-selected eq0 if
- #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.
- Self "aim" 255 0 0 0 SetImageColor
- Self "selector" 255 255 255 0 SetImageColor
- else
- #If the unit is selected first we display the selector and aim images. Again, the alpha value is the important part.
- Self "selector" 255 255 255 255 SetImageColor
- Self "aim" 255 0 0 100 SetImageColor
- #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.
- "C" GetKeyDown if
- <-deactivated not ->deactivated
- endif
- "V" GetKeyDown if
- <-disarmed not ->disarmed
- endif
- "B" GetKeyDown if
- <-disconnected not ->disconnected
- endif
- #Finally, check to see if the user presses "Space" or "Escape" and deselect the unit if they do.
- "Space" GetKeyDown "Escape" GetKeyDown or if 0 ->selected endif
- endif
- #Next we apply effects based on what state the unit is in.
- <-deactivated if
- #This makes the "deactivated" image visible and stops ammo resupply if deactivated. As usual, the alpha is the important part of the SetImageColor command.
- Self "deactivated" 255 255 255 255 SetImageColor
- Self CONST_REQUESTACPACKETS 0 SetUnitAttribute
- else
- #Make the "deactivated" image invisible if not deactivated.
- Self "deactivated" 255 255 255 0 SetImageColor
- endif
- #Same stuff as deactivated. The actual "disarming" mechanism for disarming and deactivation will be handled a little later in the firing function.
- <-disarmed if
- Self "disarmed" 255 50 50 90 SetImageColor
- else
- Self "disarmed" 255 50 50 0 SetImageColor
- endif
- #Again, same stuff.
- <-disconnected if
- Self "disconnected" 255 255 255 90 SetImageColor
- Self CONST_REQUESTACPACKETS 0 SetUnitAttribute
- else
- Self "disconnected" 255 255 255 0 SetImageColor
- endif
- #Sets the unit to request AC packets only if not locked, not deactivated, and not disconnected.
- <-disconnected not <-deactivated not and if
- Self CONST_REQUESTACPACKETS 1 SetUnitAttribute
- endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement