rangedAttacks and triggerModes
In Cyberpunk2077 all firearms have potential access to 2 different fire modes, here called triggerModes
.
They are defined in an array of that name and one is specified as the primaryTriggerMode
, while the other as the secondaryTriggerMode
.
Items.Weapon_Record:
triggerModes: [ TriggerMode.FullAuto, TriggerMode.SemiAuto ]
primaryTriggerMode: TriggerMode.FullAuto
secondaryTriggerMode: TriggerMode.SemiAuto
Most weapons only use the primary, all Tech weapons use a secondary to allow charging the shot.
The game enforces a switch between the two modes depending on the player's aiming state: primaryTriggerMode
is the way you shoot while not aiming, secondaryTriggerMode
is the way you shoot while aiming (if defined).
The projectile that is gonna be fired from the gun is defined through the rangedAttacks
field.
What gets specified there is a single RangedAttackPackage
which, in turn, contains a tree of possible attacks going down to the specific bullet used and its effects.
For the purposes of this framework, we'll focus on the RangedAttack
layer, that contains the references to the different attacks to do in most cases:
Attacks.StandardHipExplosiveAds:
$type: RangedAttack
playerAttack: Attacks.Bullet_GameEffect
playerTimeDilated: Attacks.Bullet_GameEffect
secondaryPlayerAttack: Attacks.ExplosiveBulletEffect
secondaryPlayerTimeDilated: Attacks.ExplosiveBulletEffect
NPCAttack: Attacks.NPCBulletEffect
NPCTimeDilated: Attacks.NPCBulletProjectile
The first 4 fields are all usable by the player, once set up with a valid bullet/projectile entry. As with the triggerModes, primary refers to gunfire while not aiming and secondary is a potential alternative while aiming (if defined).
(if you define new attacks, remember to append them in the attacks
array of the gun)
Through this framework, you can uncouple specific guns from the automatic swap between firemodes (that would happen on aiming state change) and give the player direct control over how the weapon will shoot, through a dedicated keybind.
Here is how