Skip to content

Commit

Permalink
player.PlayerEntity: When equipping a player's inventory item, replac…
Browse files Browse the repository at this point in the history
…e the weapon if it has a silencer as well

This fixes the issue when switching between weapon classes and weapons
therein which have a silencer, i.e. the M4A1-S:

  guns 1        => choose M4A1-S, remove silencer
  guns 2        => choose M4A1-S, replace the weapon with the default silencer state

  guns 1        => choose M4A1-S, equip weapon with silencer off
  guns 2        => choose M4A1-S, equip weapon with silencer on

Signed-off-by: BackRaw <[email protected]>
  • Loading branch information
BackRaw committed Oct 19, 2018
1 parent 1b5e895 commit b4b08bb
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions addons/source-python/plugins/udm/players/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,12 @@ def equip_inventory_item(self, tag):
if weapon is None:
self.equip_weapon(inventory_item.data.name)

# Replace it with the correct weapon, if the player isn't supposed to be equipped with it
# Else, replace it with the correct weapon
else:
weapon_data = weapon_manager.by_name(weapon.weapon_name)

if weapon_data.name != inventory_item.data.name:
if weapon_data.name != inventory_item.data.name or weapon_data.has_silencer:
weapon.remove()

# Equip the correct weapon
self.equip_weapon(inventory_item.data.name)

def equip_random_weapon(self, tag):
Expand Down

0 comments on commit b4b08bb

Please sign in to comment.