Skip to content

CS:GO weapons update #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Dec 10, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Issue #153.
Added Weapon.get_weapon_name to the base Weapon class and CS:GO specific.
  • Loading branch information
satoon101 committed Oct 7, 2016
commit 62bce07c72eb4e3b108ed4247f4755048e80d2fc
4 changes: 4 additions & 0 deletions addons/source-python/packages/source-python/weapons/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,7 @@ def set_secondary_fire_ammo(self, value):
secondary_fire_ammo = property(
get_secondary_fire_ammo, set_secondary_fire_ammo,
doc="""Property to get/set the weapon's secondary fire ammo.""")

def get_weapon_name(self):
"""Return the full class name of the weapon."""
return self.classname
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
from weapons.manager import weapon_manager


# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
_item_definition_indexes = {
values['item_definition_index']: weapon
for weapon, values in weapon_manager.ini['weapons'].items()
}


# =============================================================================
# >> CLASSES
# =============================================================================
Expand All @@ -29,7 +38,6 @@ def get_ammo(self):
)
)


def set_ammo(self, value):
"""Set the player's ammo property for the weapon."""
# Is the weapon not a grenade?
Expand All @@ -46,8 +54,14 @@ def set_ammo(self, value):
value,
)


# Set the "ammo" property methods
ammo = property(
get_ammo, set_ammo,
doc="""Property to get/set the weapon's ammo.""")

def get_weapon_name(self):
"""Return the full class name of the weapon."""
return _item_definition_indexes.get(
self.item_definition_index,
self.classname,
)