User Tools

Site Tools


cw4:cpack:docs:23977d46-b69d-431a-82e1-f4013f889c5a

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
cw4:cpack:docs:23977d46-b69d-431a-82e1-f4013f889c5a [2021/04/03 19:39] – [Global Variables] Sorted alphabetically qoplecw4:cpack:docs:23977d46-b69d-431a-82e1-f4013f889c5a [2024/03/19 19:06] (current) – [Player.4rpl] added clarity about how to disable "bonusRequirement". LiteralNoob
Line 47: Line 47:
 ==== Move.4rpl ==== ==== Move.4rpl ====
  
-This script controls all aspects of first-person movement: speed, collision, respawn, etc. "Run when paused" should be turned onso it can return normal controls if the player leaves first person mode while paused.+This script controls all aspects of first-person movement: speed, collision, respawn, etc. "Run when paused" should be turned on so it can return normal controls if the player leaves first person mode while paused.
  
 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.
Line 58: Line 58:
   * 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.
  
Line 68: Line 68:
  
   * 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.+  * 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 ====
Line 103: Line 92:
   * 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.
-  * 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+  * 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
   * 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 =====
Line 117: Line 112:
 | activeWeapon  | The name of the weapon that is currently selected.  | | activeWeapon  | The name of the weapon that is currently selected.  |
 | fireTimer  | The current countdown until the player can fire again. Mainly used by weapon packs. It can go below 0 if the player is not actively firing.  | | fireTimer  | The current countdown until the player can fire again. Mainly used by weapon packs. It can go below 0 if the player is not actively firing.  |
 +| frameToUpdate  | A float representing how many game updates pass for each frame. Ranges from 0.5 (1x speed with high FPS on) to 4 (4x speed with high FPS off). Scaling the speed of an effect done in [[4rpl:commands:msg_frameadvance|MSG_FrameAdvance]] by this amount makes it go in time with game updates while allowing smoother animations when high FPS is on.  |
 | 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 1 representing how much health the player has out of their max health.  |
-| playerPos  | The position of the playeras 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. 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 bool indicating whether or not the player is stunned.  |+| playerStunned  | A boolean indicating whether or not the player is stunned.  |
 | weaponAttributes  | A table containing all attribute values for all weapons. More detail in [[23977d46-b69d-431a-82e1-f4013f889c5a#interacting_with_weapon_attributes|interacting with weapon attributes]]  | | weaponAttributes  | A table containing all attribute values for all weapons. More detail in [[23977d46-b69d-431a-82e1-f4013f889c5a#interacting_with_weapon_attributes|interacting with weapon attributes]]  |
  
Line 131: Line 127:
  
 ^  Message Channel  ^  When it is sent  ^  Data included  ^ ^  Message Channel  ^  When it is sent  ^  Data included  ^
-| ItemCollected  | When an info cache is collected via the item.4rpl script. Also causes Player.4rpl to update its locally stored values for weapon attributes.  | The ID of the unit that sent the message  |+| ItemCollected  | When an info cache is collected via the item.4rpl script. Also causes Player.4rpl to update its locally stored values for weapon attributes, so it should be called whenever the weapon attribute table is changed.  | The ID of the unit that sent the message  |
 | PlayerDied  | When the player's health reaches 0  | How many times the player has died  | | PlayerDied  | When the player's health reaches 0  | How many times the player has died  |
 | Respawn  | When the respawn button is pressed  | 0  | | Respawn  | When the respawn button is pressed  | 0  |
 | WeaponEffect  | Whenever a weapon effect is created. Calling this will create the weapon effect.  | A list: ["weaponName", position (a V3)]  | | WeaponEffect  | Whenever a weapon effect is created. Calling this will create the weapon effect.  | A list: ["weaponName", position (a V3)]  |
 | WeaponFired  | When the player fires any weapon  | 0  | | WeaponFired  | When the player fires any weapon  | 0  |
-| CrosshairUpdated  | Every frame update, after the crosshair's position is updated  | The ID of the crosshair  |+| CrosshairUpdated  | Every frame, after the crosshair's position is updated  | The ID of the crosshair  |
 | 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 ====
Line 210: Line 206:
 #List stat vars here. Format as weaponAttributeName. weaponOther is supported. #List stat vars here. Format as weaponAttributeName. weaponOther is supported.
  
-once+:Once
   @SetHiddenAttributes   @SetHiddenAttributes
   @InitializeWeapons   @InitializeWeapons
Line 219: Line 215:
   #Make the weapon visually different from others   #Make the weapon visually different from others
   RegisterForMsg("CrosshairUpdated" "CrosshairAppearance")   RegisterForMsg("CrosshairUpdated" "CrosshairAppearance")
-endonce 
  
 :SetHiddenAttributes :SetHiddenAttributes
Line 254: Line 249:
 </hidden> </hidden>
  
-Visual settings for weapons are in the form of hidden attributes. Some of them are vector types, meaning they cannot be set as input vars. They are:+\\ Visual settings for weapons are in the form of hidden attributes. Some of them are vector types, meaning they cannot be set as input vars. They are:
  
 ^  Attribute Name  ^  Default Value  ^  Description  ^  Notes  ^ ^  Attribute Name  ^  Default Value  ^  Description  ^  Notes  ^
Line 266: Line 261:
 | EffectScale  | 1.0  | The scale the effect is made at. Applied to all dimensions.  |  | | EffectScale  | 1.0  | The scale the effect is made at. Applied to all dimensions.  |  |
 | Path  | 0  | The type of path and targeting the weapon uses. 0 is straight (cannon), and 1 is ballistic (mortar). If it is anything else, the crosshair will be hidden and the weapon will not fire on its own, leaving that up to you and giving more freedom.  |  | | Path  | 0  | The type of path and targeting the weapon uses. 0 is straight (cannon), and 1 is ballistic (mortar). If it is anything else, the crosshair will be hidden and the weapon will not fire on its own, leaving that up to you and giving more freedom.  |  |
 +| BulletGUID  | ""  | The GUID of a unit to create that replaces the default sphere mesh of the bullet. More below.  |  |
 +
 +=== Using BulletGUID ===
 +
 +If the BulletGUID attribute is defined for a weapon, the default bullet will be hidden, and a unit of the given type is created to act as the visual. This unit:
 +
 +  * Follows the same path the bullet would
 +  * Is rotated to match the direction it is moving
 +  * Is spawned with a variable named "parent" containing the unit ID of the bullet that created it
 +  * Is destroyed when the bullet hits something or leaves the map
 +
 +It can have scripts attached to it that make animations or provide additional weapon logic. BulletGUID does nothing for weapons that do not use default bullets.
  
 === The Advanced way === === The Advanced way ===
  
-When a weapon's Path attribute is set to anything other than 0 or 1, nothing is done for you, meaning you have more freedom about what you do with the weapon, but it is more work to make.+When a weapon's Path attribute is set to anything other than 0 or 1, nothing is done for you, meaning you have more freedom about what you do with the weapon, but it is more work to make. It's recommended that these weapons use a negative path to prevent overlap in case more path options are added for basic weapons.
  
 The additional parts of the weapon that need to be addressed are: The additional parts of the weapon that need to be addressed are:
Line 349: Line 356:
  
 </hidden> </hidden>
 +
 +\\ ==== Overriding Movement ====
 +
 +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.
 +
 +As soon as you stop changing the camera position, normal movement will return.
  
 ==== Misc. ==== ==== Misc. ====
  
-Some code snippets that might be useful for some purposes.+Code snippets that might be useful for some purposes.
  
 === 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]]
  
  
cw4/cpack/docs/23977d46-b69d-431a-82e1-f4013f889c5a.1617493178.txt.gz · Last modified: 2021/04/03 19:39 by qople