This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| crpl:crpltutorial:easycrpl [2015/04/13 22:56] – Telanir | crpl:crpltutorial:easycrpl [2025/02/14 14:57] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| ===== EasyCRPL ===== | ===== EasyCRPL ===== | ||
| + | == Version 1.1 == | ||
| - | < | + | < |
| - | # | + | |
| # ===== :EasyCRPL: Collection by Telanir ===== | # ===== :EasyCRPL: Collection by Telanir ===== | ||
| + | # --VERSION: 1.1 | ||
| + | # CREDITS: | ||
| + | # Big thanks to Knuckle Cracker (knucracker) for an amazing game and lots of well commented source! | ||
| + | # Big thanks to Tyler21 for a contribution of Forcefield code using Field cells! | ||
| # | # | ||
| # Usage: Simply paste this script at the bottom of your | # Usage: Simply paste this script at the bottom of your | ||
| Line 37: | Line 41: | ||
| # This code can be used at any time if it is in your | # This code can be used at any time if it is in your | ||
| # script, and generally comes in blocks of functions. | # script, and generally comes in blocks of functions. | ||
| + | # Forcefield Manager: A custom forcefield manager that helps safely create functional forcefields. | ||
| + | # @SetForcefieldProperties: | ||
| + | # | ||
| # List-Builder: | # List-Builder: | ||
| # @BeginList [* *...] @BuildList | # @BeginList [* *...] @BuildList | ||
| Line 57: | Line 64: | ||
| # -- | # -- | ||
| # | # | ||
| + | # @GetCreeperInRadius: | ||
| # @SetImageAlpha: | # @SetImageAlpha: | ||
| # @TerrainAccessible: | # @TerrainAccessible: | ||
| Line 80: | Line 88: | ||
| # Wiki CRPL Reference: http:// | # Wiki CRPL Reference: http:// | ||
| # | # | ||
| + | |||
| + | # | ||
| + | #======== FORCEFIELD MANAGER ========== | ||
| + | # | ||
| + | |||
| + | # Sets the Forcefield properties. | ||
| + | # Order goes: RANGE CPUSH ACPUSH | ||
| + | # The higher the PUSH values the more the | ||
| + | # forcefield repels from the epicenter. | ||
| + | # Values are in millionths per unit of creeper moved. | ||
| + | # Notation: f1 i1 i2 - | ||
| + | # 12.5 100000 100000 @SetForcefieldProperties | ||
| + | : | ||
| + | -? | ||
| + | -> | ||
| + | -> | ||
| + | -> | ||
| + | true -> | ||
| + | -?FF_X or(-?FF_Y) not if | ||
| + | CurrentCoords ->FF_Y ->FF_X | ||
| + | endif | ||
| + | endif | ||
| + | |||
| + | # Function : | ||
| + | # Sets the coordinates of future forcefields. | ||
| + | # If a previous forcefield was present it removes | ||
| + | # the old one and creates a new one. | ||
| + | # Notation: x y - | ||
| + | # e.g. CurrentCoords @SetForcefieldCoords | ||
| + | : | ||
| + | -? | ||
| + | @WipeForcefield | ||
| + | ->FF_Y | ||
| + | ->FF_X | ||
| + | @CreateForcefield | ||
| + | else | ||
| + | ->FF_Y | ||
| + | ->FF_X | ||
| + | endif | ||
| + | |||
| + | # Function : | ||
| + | # By default initializing forcefield properties locks the | ||
| + | # method and helps prevent leftover forcefields. | ||
| + | : | ||
| + | @WipeForcefield | ||
| + | 0 -> | ||
| + | 0 -> | ||
| + | 0 -> | ||
| + | --FF_INITIALIZED | ||
| + | |||
| + | # Function : | ||
| + | # Safe method to wipe forcefield, if there is none it will be ignored. | ||
| + | # Notation: - | ||
| + | # e.g. @WipeForcefield | ||
| + | : | ||
| + | -? | ||
| + | -? | ||
| + | --FORCEFIELD_AVAILABLE | ||
| + | @ModifyForcefield(< | ||
| + | endif | ||
| + | endif | ||
| + | |||
| + | # Function : | ||
| + | # Creates a Forcefield with the initialized parameters. | ||
| + | # Notation: - | ||
| + | # e.g. @CreateForcefield | ||
| + | : | ||
| + | -? | ||
| + | -? | ||
| + | true -> | ||
| + | @ModifyForcefield(< | ||
| + | endif | ||
| + | endif | ||
| + | |||
| + | # Major props to Tyler, thanks for helping make forcefields work as intended. | ||
| + | # Function : | ||
| + | # Adds input creeper and anti-creeper to surrounding field cells with | ||
| + | # strength decreasing with distance form the epicenter. | ||
| + | # Negative values will modify the forces in opposite directions and 0 will change nothing. | ||
| + | # Notation: x y f1 i1 i2 - | ||
| + | # e.g. CurrentCoords 10 100000 -100000 @ModifyForcefield | ||
| + | : | ||
| + | neg -> | ||
| + | neg -> | ||
| + | asfloat -> | ||
| + | ->SF_Y | ||
| + | ->SF_X | ||
| + | |||
| + | < | ||
| + | do | ||
| + | < | ||
| + | do | ||
| + | <-SF_X J add < | ||
| + | <-SF_Y I add < | ||
| + | |||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | @GetVector(@GetAngle(< | ||
| + | @GetVector(@GetAngle(< | ||
| + | GetFieldCell(< | ||
| + | SetFieldCell(< | ||
| + | endif | ||
| + | endif | ||
| + | loop | ||
| + | loop | ||
| # | # | ||
| Line 558: | Line 675: | ||
| < | < | ||
| + | # Function : | ||
| + | # Returns the SUM of all creeper in a certain square | ||
| + | # around an origin. If there is anti-creeper present this | ||
| + | # value may go into the negatives. | ||
| + | # Notation: x y f1 - f2 | ||
| + | # eg. CurrentCoords 1 @GetCreeperInRadius -> | ||
| + | : | ||
| + | -> | ||
| + | ->CR_Y | ||
| + | ->CR_X | ||
| + | 0 ->CR_C | ||
| + | < | ||
| + | |||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | loop | ||
| + | loop | ||
| + | |||
| + | <-CR_C | ||
| + | |||
| # Function: : | # Function: : | ||
| # Sets the alpha of the specified image for self. | # Sets the alpha of the specified image for self. | ||
| Line 633: | Line 773: | ||
| false | false | ||
| + | # Function :OccupyArea | ||
| + | # Safety net for @AddOccupy to prevent bad areas. | ||
| + | # Notation: x y f1 - | ||
| + | # eg. < | ||
| + | # #in a 3x3 grid around the central point, useful for flying units looking to land | ||
| + | :OccupyArea | ||
| + | -? | ||
| + | # First occupation is legal. | ||
| + | -> | ||
| + | ->OA_Y | ||
| + | ->OA_X | ||
| + | |||
| + | <-OA_X <-OA_Y <-OA_RAD true @AddOccupy | ||
| + | # Does occupy, is initialized. | ||
| + | true -> | ||
| + | else | ||
| + | < | ||
| + | # If occupying land already, disable occupation for re-assigning. | ||
| + | < | ||
| + | endif | ||
| + | -> | ||
| + | ->OA_Y | ||
| + | ->OA_X | ||
| + | < | ||
| + | < | ||
| + | endif | ||
| + | < | ||
| + | endif | ||
| + | |||
| + | : | ||
| + | < | ||
| + | # If occupying land already, disable occupation. | ||
| + | <-OA_X <-OA_Y <-OA_RAD false @AddOccupy | ||
| + | false -> | ||
| + | endif | ||
| + | |||
| # Function :AddOccupy | # Function :AddOccupy | ||
| # Returns whether or not a certain area is occupied by one or | # Returns whether or not a certain area is occupied by one or | ||
| Line 638: | Line 814: | ||
| # Notation: x y f1 b1 - | # Notation: x y f1 b1 - | ||
| # eg. CurrentCoords 1 false @AddOccupy #this would allow another unit to land | # eg. CurrentCoords 1 false @AddOccupy #this would allow another unit to land | ||
| - | # #in a 3x3 grid around the centarl | + | # #in a 3x3 grid around the central |
| :AddOccupy | :AddOccupy | ||
| -> | -> | ||
| Line 1003: | Line 1179: | ||
| < | < | ||
| < | < | ||
| - | |||
| </ | </ | ||