sentrychris / undeadbytes

https://sentrychris.github.io/undeadbytes
https://sentrychris.github.io/undeadbytes/play
MIT License
1 stars 2 forks source link

Rebalance the ammo refill pickup logic #7

Open sentrychris opened 12 months ago

sentrychris commented 12 months ago

Whenever an ammo refill is picked up, the following method in src/browser/lib/Ballistics/Ballistics.js gets called:

refillWeaponAmmoClip () {
  if (this.weapon.clip.current === this.weapon.clip.capacity) {
    if (this.weapon.magazines.current < this.weapon.magazines.capacity) {
      ++this.weapon.magazines.current;
    }
  } else {
    this.weapon.clip.current = this.weapon.clip.capacity;
  }
}

this.weapon is set to the selected weapon from the available weapons in src\browser\lib\Ballistics\mappings.js, for example, if the player is currently using a pistol, this.weapon is:

{
    name: 'Pistol',
    type: 'gun',
    projectile: {...},
    clip: {
      current: 10,
      capacity: 10
    },
    magazines: {
      current: 2,
      capacity: 2
    },
    ...
  },

Visual explanation of clip vs magazine:

clip-vs-magazine

The curent logic

When an ammo refill item is picked up, the method first checks to see if the player's current clip count is equal to the weapon's clip capacity, ie. checks to see if the current magazine is full. If this is not the case, then it will refill the player's current weapon clip.

If the current magazine is full then it checks to see if the number of weapon magazines carried by the player is lower than the weapon's magazine limit. If this is the case, then another magazine will be added to the player's inventory for the weapon they are currently using.

The problems

The ammo refill is too simplistic and not very well balanced, for example:

  1. If a player fires just 1 bullet from their pistol, an ammo refill is only worth 1 bullet, if a player empties their clip entirely and then picks up an ammo refill, it is worth an entire clip, this should be far more balanced.

  2. If the player already has max ammo and max magazines, then the refill pickup is worthless and wasted, it should instead either not pickup if the player's current weapon is at full capacity, or it should refill the next weapon in the indexed mappings array.

  3. Relating to point 2, if all the user's weapons are at full capacity, the ammo refill should either not be used, or potentially more complex - stored for later use via a hotkey.