Skip to content

Refactor how we get an actors weapons

Ryan Walder requested to merge ryanw/hardened-characters into master

Intent

We have a _getEquippedWeapons function in CPRActor which will return equipped weapons but not itemUpgrades/cyberweapons

This MR replaces this function with a more general function: getWeapons in ActorWeaponSchema with the following filters:

What are considered weapons:
  * item.type === weapon
  * item.type === cyberware.isWeapon
  * item.type === itemUpgrade.modifiers.secondaryWeapon.configuired

`all`:       everything considered a weapon above
`available`:      weapon: owned/carried/equipped
             cyberWeapon: isWeapon && isInstalledInActor
             itemUpgrade: secondaryWeapon.configuired &&
                          installedIn weapon that is owned/carried/equipped
`owned`:          weapon: owned
             itemUpgrade: secondaryWeapon.configuired &&
                          installedIn weapon that is owned
`carried`:        weapon: carried
             itemUpgrade: secondaryWeapon.configuired &&
                          installedIn weapon that is carried
`equipped`:       weapon: equipped
             cyberWeapon: isWeapon && isInstalledInActor
             itemUpgrade: secondaryWeapon.configuired &&
                          installedIn weapon that is equipped

This then provides a set of getters to allow access of these with actor.system.weapons.equipped etc.


  • This is meant for a hotfix
  • This is meant for the next release (see milestone)
  • This needs more reviewers than normal; there may be controversy or high complexity
  • This intentionally introduces regressions that will be addressed later
  • There is/will be documentation changes on the wiki
  • Please do not send commits here without coordinating closely with the owner
  • This is a Build System change

Related Issues

  • N/A

Steps to Test

  1. Read the diff

In game (functionality):

  1. Checkout/Build/Load
  2. Create Actor
  3. Add Assault Rifle
  4. Add Bow
  5. Add Bayonet
  6. Add Cyberarm
  7. Add Wolvers
  8. Equip Assault Rifle
    • Assault Rifle Shows in Fight Tab/Weapons
  9. Equip Bow
    • Receive yellow warning box about hands
  10. Install Bayonet in Assault Rifle
    • Bayonet shows in fight tab when Assault Rifle is equipped
    • Bayonet does not show in fight tab when Assault Rifle is not equipped
  11. Install Wolvers in Cyberarm
    • Wolvers show in fight tab once installed, not when not installed

In game (console):

  1. Access the various states of weapons ad described above using the console
    • game.actors.get("Lb9fE5V3PhDKBTlL").system.weapons.all
    • game.actors.get("Lb9fE5V3PhDKBTlL").system.weapons.available
    • game.actors.get("Lb9fE5V3PhDKBTlL").system.weapons.owned
    • game.actors.get("Lb9fE5V3PhDKBTlL").system.weapons.carried
    • game.actors.get("Lb9fE5V3PhDKBTlL").system.weapons.equipped
      • All results should match the description at the top of the MR description
Edited by Ryan Walder

Merge request reports