Both sides previous revisionPrevious revisionNext revision | Previous revision |
cw4:cpack:docs:23977d46-b69d-431a-82e1-f4013f889c5a [2021/04/11 04:00] – Updated for script version 1.4.2 qople | cw4:cpack:docs:23977d46-b69d-431a-82e1-f4013f889c5a [2025/02/14 14:57] (current) – external edit 127.0.0.1 |
---|
Script vars: | Script vars: |
| |
* baseMoveSpeed: The maximum speed the player can hit, in cells per update. High values will lead to clipping. | * moveSpeed: The maximum speed the player can hit, in cells per update. High values will lead to clipping. |
* accelTime: The number of updates it takes for the player to reach full speed from a standstill. | * accelTime: The number of updates it takes for the player to reach full speed from a standstill. |
* decelTime: The number of updates it takes for the player to stop from full speed. | * decelTime: The number of updates it takes for the player to stop from full speed. |
* collisionThreshold: The highest terrain difference that the player can walk over. | * collisionThreshold: The highest terrain difference that the player can walk over. |
* startX, startZ: The cell coordinates of the player's spawn and respawn point. | * startX, startZ: The cell coordinates of the player's spawn and respawn point. |
* startRotation: The direction that the player points when they spawn, in degrees. 0 faces them in the positive Z direction. | * startRotation: The direction that the player points when they spawn, in degrees. 0 faces them in the positive Z direction. Clock-Wise rotation. |
* stunDuration: How many updates the player stays stunned for. Consecutive stuns do not stack. | * stunDuration: How many updates the player stays stunned for. Consecutive stuns do not stack. |
| |
| |
* maxHealth: The max health the player has. 30 is the default. Damage taken is proportional to the square root of creeper, with a depth of 1 dealing 0.1 damage per update. | * maxHealth: The max health the player has. 30 is the default. Damage taken is proportional to the square root of creeper, with a depth of 1 dealing 0.1 damage per update. |
* bonusRequirement: The percentage of health the player must stay above for the custom objective. | * bonusRequirement: The percentage of health the player must stay above for the custom objective. Set to negative to disable. |
* startingWeapons: A string containing a list of the weapons that are unlocked upon starting the level, separated by commas. Order doesn't affect this. | * startingWeapons: A string containing a list of the weapons that are unlocked upon starting the level, separated by commas. Order doesn't affect this. |
* weaponOrder: A list of all weapons that are in the level, in order of their hotkeys. Changing the order of this will rearrange the weapon hotkeys. | * weaponOrder: A list of all weapons that are in the level, in order of their hotkeys. Changing the order of this will rearrange the weapon hotkeys. |
| |
==== Totems.4rpl ==== | |
| |
Makes all totems charge in a way usable in a first-person level. Rules are as follows: | |
| |
* Totems will gain charge at an increasing rate while the player is within 15 cells. | |
* Partially charged totems will stop charging when the player is outside that radius, but will not lose charge. | |
* Totems will lose charge when there is creeper on the center cell of the unit. | |
* Disabled totems ("unit: off") will not charge, and any existing ammo will be removed. | |
| |
There are no script vars. | |
| |
==== Vanilla Weapons.4rpl ==== | ==== Vanilla Weapons.4rpl ==== |
* useWallOverride: Whether to use a 2000 terrain override on cells with terrain 19 and 20. If it's on, updates all cells on game start or compile. | * useWallOverride: Whether to use a 2000 terrain override on cells with terrain 19 and 20. If it's on, updates all cells on game start or compile. |
* wallUpdateRate: How often the wall overrides should be updated during game time. 1 checks the whole map every frame (not recommended), 90 checks over it every 3 seconds, and so on. Has no effect if useWallOverride is 0. Setting to 0 disables the updates, so the overrides will not change if terrain changes. | * wallUpdateRate: How often the wall overrides should be updated during game time. 1 checks the whole map every frame (not recommended), 90 checks over it every 3 seconds, and so on. Has no effect if useWallOverride is 0. Setting to 0 disables the updates, so the overrides will not change if terrain changes. |
| * chargeTotems: Makes all totems charge in a way usable in a first-person level. Rules are as follows: |
| * Totems will gain charge at an increasing rate while the player is within 15 cells. |
| * Partially charged totems will stop charging when the player is outside that radius, but will not lose charge. |
| * Totems will lose charge when there is creeper on the center cell of the unit. |
| * Disabled totems ("unit: off") will not charge, and any existing ammo will be removed. |
* selectionMode: Controls selection and building behavior for hybrid levels. The options are: \\ 0: Default behavior \\ 1: Disables building in first person mode \\ 2: Disables building in and out of first person \\ 3: Same as 1, but also overrides selecting units \\ 4: Same as 2, but also overrides selecting units | * selectionMode: Controls selection and building behavior for hybrid levels. The options are: \\ 0: Default behavior \\ 1: Disables building in first person mode \\ 2: Disables building in and out of first person \\ 3: Same as 1, but also overrides selecting units \\ 4: Same as 2, but also overrides selecting units |
* selectableWhitelist: A comma separated list of [[4rpl:commands:unit_types|unit types]] that are still selectable when unit selection is turned off by the script. The DPS monitor is internally added to this list. | * selectableWhitelist: A comma separated list of [[4rpl:commands:unit_types|unit types]] that are still selectable when unit selection is turned off by the script. The DPS monitor is internally added to this list. |
| * buildWhitelist: A comma separated list of unit types that are still buildable when building is turned off by the script. |
| |
===== 4RPL Extensions ===== | ===== 4RPL Extensions ===== |
| isFPMode | A bool, indicating whether the player is currently in first person mode. Updates while paused. | | | isFPMode | A bool, indicating whether the player is currently in first person mode. Updates while paused. | |
| playerForward | A normalized 3-dimensional vector pointing in the direction the player is looking. Changing this will //not// rotate the player. Useful for making something move in front of the player. | | | playerForward | A normalized 3-dimensional vector pointing in the direction the player is looking. Changing this will //not// rotate the player. Useful for making something move in front of the player. | |
| playerHealth | A floating point from 0 to 1 representing how much health the player has out of their max health. | | | playerHealth | A floating point from 0 to maxHealth representing how much health the player has. | |
| playerPos | The position of the player as a 3-dimensional vector. It is the location of the camera when the player is in first person mode, not the terrain below the camera. This means it is roughly 9 cells above the terrain by default. Changing this will teleport the player to that x and z, but the y always follows the terrain. | | | playerPos | The position of the player as a 3-dimensional vector. It is the location of the camera when the player is in first person mode, not the terrain below the camera. This means it is roughly 9 cells above the terrain by default. Changing this will teleport the player to that x and z, but the y always follows the terrain. | |
| playerStunned | A boolean indicating whether or not the player is stunned. | | | playerStunned | A boolean indicating whether or not the player is stunned. | |
| Initialize | Whenever a weapon pack is initialized at the start of the game, before its weapons are added to the weaponAttributes table. | One weapon added by that script, which the script is also registered as. | | | Initialize | Whenever a weapon pack is initialized at the start of the game, before its weapons are added to the weaponAttributes table. | One weapon added by that script, which the script is also registered as. | |
| DamagePlayer | Call to damage the player by a fixed amount. Negative values will heal the player. | The amount to damage the player | | | DamagePlayer | Call to damage the player by a fixed amount. Negative values will heal the player. | The amount to damage the player | |
| AddText | Call to display text on the bottom of the screen. Must be called every update while the text is shown. Calling it several times in one update adds a separate line for each. Useful for letting the player know something minor, or for debugging. | The text to display | | | AddText | Call to display text on the bottom of the screen. Must be called every update while the text is shown. Calling it several times in one update adds a separate line for each. Useful for letting the player know something minor, or for debugging. | The text to display. If calling from a script that runs while paused, add "WP:" before the text to display. | |
| |
==== Interacting with Weapon Attributes ==== | ==== Interacting with Weapon Attributes ==== |
\\ ==== Overriding Movement ==== | \\ ==== Overriding Movement ==== |
| |
Player movement is fairly limited by default, with the most obvious example of this being the inability to move vertically. To move the player with a script while having the crosshair and other bits and bobs following, the basic formula is as follows: | Writing to the playerPos global will teleport the player. If high FPS is on, a tween frame will be added to make movement smoother. To disable that, set the W component of the vector (the 4th one) to true. To snap the height to the terrain, set the Y component to anything less than -100. |
| |
* Register for MSG_FrameAdvance | |
* Use the RplCam control APIs to move the camera inside that message, multiplying the passage of time by *frameToUpdate to make sure it works at the same speed both with and without high FPS | |
* Save the RplCam position to *playerPos and the RplCam forward to *playerForward | |
| |
As soon as you stop changing the camera position, normal movement will return. | As soon as you stop changing the camera position, normal movement will return. |
=== Unlocking a weapon === | === Unlocking a weapon === |
| |
GetRegisteredScriptVar("Player" "unlockedWeapons") "weaponName" AppendToList | <code 4RPL>GetRegisteredScriptVar("Player" "unlockedWeapons") "weaponName" AppendToList</code> |
| |
| === Changing the Respawn Point === |
| <code 4RPL>SetRegisteredScriptVar("Move" "checkpoint" <-cellX <-cellZ FC)</code> |
| |
<=[[cw4:custom| Index]] | <=[[cw4:custom| Index]] |
| |
| |