From 5002c6df5a9a56c53c6fb17a84a3fcc4a8c1e800 Mon Sep 17 00:00:00 2001 From: Jonathan <30329245+CookStar@users.noreply.github.com> Date: Tue, 6 Jun 2023 11:31:19 +0900 Subject: [PATCH 1/7] Added WeaponSlot to CS:GO. Added WeaponType to CS:GO. --- .../weapons/constants/csgo/WeaponSlot.ini | 9 +++++++ .../weapons/constants/csgo/WeaponType.ini | 26 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100755 addons/source-python/data/source-python/weapons/constants/csgo/WeaponSlot.ini create mode 100755 addons/source-python/data/source-python/weapons/constants/csgo/WeaponType.ini diff --git a/addons/source-python/data/source-python/weapons/constants/csgo/WeaponSlot.ini b/addons/source-python/data/source-python/weapons/constants/csgo/WeaponSlot.ini new file mode 100755 index 000000000..036136b27 --- /dev/null +++ b/addons/source-python/data/source-python/weapons/constants/csgo/WeaponSlot.ini @@ -0,0 +1,9 @@ +# ../data/source-python/weapons/constants/csgo/WeaponSlot.ini + +PRIMARY = 0 +SECONDARY = 1 +KNIFE = 2 +GRENADE = 3 +C4 = 4 +SHIELD = 11 +TABLET = 12 diff --git a/addons/source-python/data/source-python/weapons/constants/csgo/WeaponType.ini b/addons/source-python/data/source-python/weapons/constants/csgo/WeaponType.ini new file mode 100755 index 000000000..bab54a7c2 --- /dev/null +++ b/addons/source-python/data/source-python/weapons/constants/csgo/WeaponType.ini @@ -0,0 +1,26 @@ +# ../data/source-python/weapons/constants/csgo/WeaponType.ini + +KNIFE = 0 +PISTOL = 1 +SMG = 2 +SUBMACHINEGUN = 2 +RIFLE = 3 +SHOTGUN = 4 +SNIPERRIFLE = 5 +SNIPER = 5 +MACHINEGUN = 6 +MG = 6 +C4 = 7 +EXPLOSIVE = 7 +TASER = 8 +GRENADE = 9 +EQUIPMENT = 10 +STACKABLEITEM = 11 +FISTS = 12 +BREACHCHARGE = 13 +BUMPMINE = 14 +TABLET = 15 +MELEE = 16 +SHIELD = 17 +ZONEREPULSOR = 18 +UNKNOWN = 19 From accf31dd230328e9d857b5914bb5a38280f3431b Mon Sep 17 00:00:00 2001 From: Jonathan <30329245+CookStar@users.noreply.github.com> Date: Tue, 6 Jun 2023 11:33:10 +0900 Subject: [PATCH 2/7] Fixed WeaponID in CS:GO. --- .../weapons/constants/csgo/WeaponID.ini | 120 ++++++++++-------- 1 file changed, 65 insertions(+), 55 deletions(-) mode change 100644 => 100755 addons/source-python/data/source-python/weapons/constants/csgo/WeaponID.ini diff --git a/addons/source-python/data/source-python/weapons/constants/csgo/WeaponID.ini b/addons/source-python/data/source-python/weapons/constants/csgo/WeaponID.ini old mode 100644 new mode 100755 index f05c480f4..35692a964 --- a/addons/source-python/data/source-python/weapons/constants/csgo/WeaponID.ini +++ b/addons/source-python/data/source-python/weapons/constants/csgo/WeaponID.ini @@ -1,60 +1,64 @@ # ../data/source-python/weapons/constants/csgo/WeaponID.ini -P228 = 1 -GLOCK = 2 -SCOUT = 3 -HEGRENADE = 4 -XM1014 = 5 -C4 = 6 -MAC10 = 7 +DEAGLE = 1 +ELITE = 2 +FIVESEVEN = 3 +GLOCK = 4 +#P228 = 5 +#USP = 6 +AK47 = 7 AUG = 8 -SMOKEGRENADE = 9 -ELITE = 10 -FIVESEVEN = 11 -UMP45 = 12 -SG550 = 13 -GALIL = 14 -FAMAS = 15 -USP = 16 -AWP = 17 -MP5NAVY = 18 -M249 = 19 -M3 = 20 -M4A1 = 21 -TMP = 22 -G3SG1 = 23 -FLASHBANG = 24 -DEAGLE = 25 -SG552 = 26 -AK47 = 27 -KNIFE = 28 -P90 = 29 -SHIELD = 30 -KEVLAR = 31 -ASSAULTSUIT = 32 -NIGHTVISION = 33 -GALILAR = 34 -BIZON = 35 -MAG7 = 36 -NEGEV = 37 -SAWEDOFF = 38 -TEC9 = 39 -TASER = 40 -HKP2K = 41 -MP7 = 42 -MP9 = 43 -NOVA = 44 -P250 = 45 -SCAR17 = 46 -SCAR20 = 47 -SG556 = 48 -SSG08 = 49 -KNIFEGG = 50 -MOLOTOV = 51 -DECOY = 52 -INCENDIARY = 53 -DEFUSER = 54 -HEAVYASSAULTSUIT = 55 +AWP = 9 +FAMAS = 10 +G3SG1 = 11 +#GALIL = 12 +GALILAR = 13 +M249 = 14 +#M3 = 15 +M4A1 = 16 +MAC10 = 17 +#MP5NAVY = 18 +P90 = 19 +ZONE_REPULSOR = 20 +#SCOUT = 20 +#SG550 = 21 +#SG552 = 22 +MP5SD = 23 +#TMP = 23 +UMP45 = 24 +XM1014 = 25 +BIZON = 26 +MAG7 = 27 +NEGEV = 28 +SAWEDOFF = 29 +TEC9 = 30 +TASER = 31 +HKP2000 = 32 +MP7 = 33 +MP9 = 34 +NOVA = 35 +P250 = 36 +SHIELD = 37 +#SCAR17 = 37 +SCAR20 = 38 +SG556 = 39 +SSG08 = 40 +KNIFEGG = 41 +KNIFE = 42 +FLASHBANG = 43 +HEGRENADE = 44 +SMOKEGRENADE = 45 +MOLOTOV = 46 +DECOY = 47 +INCGRENADE = 48 +C4 = 49 +KEVLAR = 50 +ASSAULTSUIT = 51 +HEAVYASSAULTSUIT = 52 +NVGS = 54 +NVG = 54 +NIGHTVISION = 54 +DEFUSER = 55 CUTTERS = 56 HEALTHSHOT = 57 KNIFE_T = 59 @@ -62,7 +66,7 @@ M4A1_SILENCER = 60 USP_SILENCER = 61 CZ75A = 63 REVOLVER = 64 -TAGGRENADE = 68 +TAGRENADE = 68 FISTS = 69 BREACHCHARGE = 70 TABLET = 72 @@ -75,8 +79,10 @@ FIREBOMB = 81 DIVERSION = 82 FRAG_GRENADE = 83 SNOWBALL = 84 +BUMPMINE = 85 # Knives from cases. BAYONET = 500 +KNIFE_CSS = 503 KNIFE_FLIP = 505 KNIFE_GUT = 506 KNIFE_KARAMBIT = 507 @@ -86,7 +92,11 @@ KNIFE_FALCHION = 512 KNIFE_SURVIVAL_BOWIE = 514 KNIFE_BUTTERFLY = 515 KNIFE_PUSH = 516 +KNIFE_CORD = 517 +KNIFE_CANIS = 518 KNIFE_URSUS = 519 KNIFE_GYPSY_JACKKNIFE = 520 +KNIFE_OUTDOOR = 521 KNIFE_STILETTO = 522 KNIFE_WIDOWMAKER = 523 +KNIFE_SKELETON = 525 From 00d7f549897b40af137395f0d338e7948a4e5e2e Mon Sep 17 00:00:00 2001 From: Jonathan <30329245+CookStar@users.noreply.github.com> Date: Tue, 6 Jun 2023 11:36:50 +0900 Subject: [PATCH 3/7] Changed WeaponID and WeaponType to the names used internally in CS:S. --- .../weapons/constants/orangebox/cstrike/WeaponID.ini | 2 ++ .../weapons/constants/orangebox/cstrike/WeaponType.ini | 5 +++++ 2 files changed, 7 insertions(+) mode change 100644 => 100755 addons/source-python/data/source-python/weapons/constants/orangebox/cstrike/WeaponID.ini mode change 100644 => 100755 addons/source-python/data/source-python/weapons/constants/orangebox/cstrike/WeaponType.ini diff --git a/addons/source-python/data/source-python/weapons/constants/orangebox/cstrike/WeaponID.ini b/addons/source-python/data/source-python/weapons/constants/orangebox/cstrike/WeaponID.ini old mode 100644 new mode 100755 index 30c716861..9809fc157 --- a/addons/source-python/data/source-python/weapons/constants/orangebox/cstrike/WeaponID.ini +++ b/addons/source-python/data/source-python/weapons/constants/orangebox/cstrike/WeaponID.ini @@ -32,4 +32,6 @@ P90 = 29 SHIELD = 30 KEVLAR = 31 ASSAULTSUIT = 32 +NVGS = 33 +NVG = 33 NIGHTVISION = 33 diff --git a/addons/source-python/data/source-python/weapons/constants/orangebox/cstrike/WeaponType.ini b/addons/source-python/data/source-python/weapons/constants/orangebox/cstrike/WeaponType.ini old mode 100644 new mode 100755 index 51aecb5c7..6ea48b5c6 --- a/addons/source-python/data/source-python/weapons/constants/orangebox/cstrike/WeaponType.ini +++ b/addons/source-python/data/source-python/weapons/constants/orangebox/cstrike/WeaponType.ini @@ -3,9 +3,14 @@ KNIFE = 0 PISTOL = 1 SMG = 2 +SUBMACHINEGUN = 2 RIFLE = 3 SHOTGUN = 4 +SNIPERRIFLE = 5 SNIPER = 5 MACHINEGUN = 6 +MG = 6 +C4 = 7 EXPLOSIVE = 7 GRENADE = 8 +UNKNOWN = 9 From 88393905367b45b2218579630d06a540c84bd542 Mon Sep 17 00:00:00 2001 From: Jonathan <30329245+CookStar@users.noreply.github.com> Date: Tue, 6 Jun 2023 11:42:38 +0900 Subject: [PATCH 4/7] Added WeaponID and WeaponType to WeaponClass. Changed WeaponClass.slot to return WeaponSlot. Changed WeaponClass to be able to reference parent_class. Added missing WeaponClass data for CS:GO. --- .../data/source-python/weapons/csgo.ini | 271 ++++++++++++++---- .../data/source-python/weapons/cstrike.ini | 58 ++++ .../source-python/weapons/instance.py | 55 +++- 3 files changed, 331 insertions(+), 53 deletions(-) mode change 100644 => 100755 addons/source-python/data/source-python/weapons/csgo.ini mode change 100644 => 100755 addons/source-python/data/source-python/weapons/cstrike.ini mode change 100644 => 100755 addons/source-python/packages/source-python/weapons/instance.py diff --git a/addons/source-python/data/source-python/weapons/csgo.ini b/addons/source-python/data/source-python/weapons/csgo.ini old mode 100644 new mode 100755 index 04bb66bc5..f2bf1c06d --- a/addons/source-python/data/source-python/weapons/csgo.ini +++ b/addons/source-python/data/source-python/weapons/csgo.ini @@ -35,6 +35,8 @@ # ========================================================================= # Snipers [[awp]] + id = 9 + type = 5 slot = 0 maxammo = 30 ammoprop = 6 @@ -44,6 +46,8 @@ tags = "all,primary,rifle,sniper" [[g3sg1]] + id = 11 + type = 5 slot = 0 maxammo = 90 ammoprop = 2 @@ -53,6 +57,8 @@ tags = "all,primary,rifle,sniper" [[scar20]] + id = 38 + type = 5 slot = 0 maxammo = 90 ammoprop = 2 @@ -62,6 +68,8 @@ tags = "all,primary,rifle,sniper" [[ssg08]] + id = 40 + type = 5 slot = 0 maxammo = 90 ammoprop = 2 @@ -72,6 +80,8 @@ # Assault Rifles [[ak47]] + id = 7 + type = 3 slot = 0 maxammo = 90 ammoprop = 2 @@ -81,6 +91,8 @@ tags = "all,primary,rifle" [[aug]] + id = 8 + type = 3 slot = 0 maxammo = 90 ammoprop = 2 @@ -90,6 +102,8 @@ tags = "all,primary,rifle" [[famas]] + id = 10 + type = 3 slot = 0 maxammo = 90 ammoprop = 3 @@ -99,6 +113,8 @@ tags = "all,primary,rifle" [[galilar]] + id = 13 + type = 3 slot = 0 maxammo = 90 ammoprop = 3 @@ -108,6 +124,8 @@ tags = "all,primary,rifle" [[m4a1]] + id = 16 + type = 3 slot = 0 maxammo = 90 ammoprop = 3 @@ -117,6 +135,8 @@ tags = "all,primary,rifle" [[m4a1_silencer]] + id = 60 + type = 3 slot = 0 maxammo = 75 ammoprop = 4 @@ -127,6 +147,8 @@ tags = "all,secondary,rifle" [[sg556]] + id = 39 + type = 3 slot = 0 maxammo = 90 ammoprop = 3 @@ -137,6 +159,8 @@ # SMGs [[bizon]] + id = 26 + type = 2 slot = 0 maxammo = 120 ammoprop = 7 @@ -146,6 +170,8 @@ tags = "all,primary,smg" [[mac10]] + id = 17 + type = 2 slot = 0 maxammo = 100 ammoprop = 9 @@ -154,7 +180,21 @@ item_definition_index = 17 tags = "all,primary,smg" + [[mp5sd]] + id = 23 + type = 2 + slot = 0 + maxammo = 120 + ammoprop = 7 + clip = 30 + cost = 1500 + item_definition_index = 23 + parent_class = "weapon_mp7" + tags = "all,primary,smg" + [[mp7]] + id = 33 + type = 2 slot = 0 maxammo = 120 ammoprop = 7 @@ -164,6 +204,8 @@ tags = "all,primary,smg" [[mp9]] + id = 34 + type = 2 slot = 0 maxammo = 120 ammoprop = 7 @@ -173,6 +215,8 @@ tags = "all,primary,smg" [[p90]] + id = 19 + type = 2 slot = 0 maxammo = 100 ammoprop = 13 @@ -182,6 +226,8 @@ tags = "all,primary,smg" [[ump45]] + id = 24 + type = 2 slot = 0 maxammo = 100 ammoprop = 9 @@ -190,18 +236,10 @@ item_definition_index = 24 tags = "all,primary,smg" - [[mp5sd]] - slot = 0 - maxammo = 120 - ammoprop = 7 - clip = 30 - cost = 1500 - item_definition_index = 23 - parent_class = "weapon_mp7" - tags = "all,primary,smg" - # Shotguns [[mag7]] + id = 27 + type = 4 slot = 0 maxammo = 32 ammoprop = 8 @@ -211,6 +249,8 @@ tags = "all,primary,shotgun" [[nova]] + id = 35 + type = 4 slot = 0 maxammo = 32 ammoprop = 8 @@ -220,6 +260,8 @@ tags = "all,primary,shotgun" [[sawedoff]] + id = 29 + type = 4 slot = 0 maxammo = 32 ammoprop = 8 @@ -229,6 +271,8 @@ tags = "all,primary,shotgun" [[xm1014]] + id = 25 + type = 4 slot = 0 maxammo = 32 ammoprop = 8 @@ -239,6 +283,8 @@ # Heavy Machine Gun [[m249]] + id = 14 + type = 6 slot = 0 maxammo = 200 ammoprop = 5 @@ -248,6 +294,8 @@ tags = "all,primary,machinegun" [[negev]] + id = 28 + type = 6 slot = 0 maxammo = 300 ammoprop = 5 @@ -260,6 +308,8 @@ # SECONDARY WEAPONS # ========================================================================= [[cz75a]] + id = 63 + type = 1 slot = 1 maxammo = 12 ammoprop = 12 @@ -270,6 +320,8 @@ tags = "all,secondary,pistol" [[deagle]] + id = 1 + type = 1 slot = 1 maxammo = 35 ammoprop = 1 @@ -279,6 +331,8 @@ tags = "all,secondary,pistol" [[elite]] + id = 2 + type = 1 slot = 1 maxammo = 120 ammoprop = 7 @@ -288,6 +342,8 @@ tags = "all,secondary,pistol" [[fiveseven]] + id = 3 + type = 1 slot = 1 maxammo = 100 ammoprop = 13 @@ -297,6 +353,8 @@ tags = "all,secondary,pistol" [[glock]] + id = 4 + type = 1 slot = 1 maxammo = 120 ammoprop = 7 @@ -306,6 +364,8 @@ tags = "all,secondary,pistol" [[hkp2000]] + id = 32 + type = 1 slot = 1 maxammo = 52 ammoprop = 10 @@ -315,6 +375,8 @@ tags = "all,secondary,pistol" [[p250]] + id = 36 + type = 1 slot = 1 maxammo = 26 ammoprop = 20 @@ -324,6 +386,8 @@ tags = "all,secondary,pistol" [[revolver]] + id = 64 + type = 1 slot = 1 maxammo = 8 ammoprop = 1 @@ -334,6 +398,8 @@ tags = "all,secondary,pistol" [[tec9]] + id = 30 + type = 1 slot = 1 maxammo = 90 ammoprop = 7 @@ -343,6 +409,8 @@ tags = "all,secondary,pistol" [[usp_silencer]] + id = 61 + type = 1 slot = 1 maxammo = 24 ammoprop = 11 @@ -356,167 +424,228 @@ # MELEE WEAPONS # ========================================================================= [[axe]] + id = 75 + type = 16 slot = 2 item_definition_index = 75 parent_class = "weapon_melee" tags = "all,melee" + [[bayonet]] + id = 500 + type = 0 + slot = 2 + item_definition_index = 500 + parent_class = "weapon_knife" + tags = "all,knife,melee,earned" + [[fists]] + id = 69 + type = 12 slot = 2 item_definition_index = 69 tags = "all,melee" [[hammer]] + id = 76 + type = 16 slot = 2 item_definition_index = 76 parent_class = "weapon_melee" tags = "all,melee" [[knife]] + id = 42 + type = 0 slot = 2 item_definition_index = 42 tags = "all,knife,melee" - [[bayonet]] + [[knife_butterfly]] + id = 515 + type = 0 slot = 2 - item_definition_index = 500 + item_definition_index = 515 parent_class = "weapon_knife" tags = "all,knife,melee,earned" - [[knife_butterfly]] + [[knife_canis]] + id = 518 + type = 0 slot = 2 - item_definition_index = 515 + item_definition_index = 518 + parent_class = "weapon_knife" + tags = "all,knife,melee,earned" + + [[knife_cord]] + id = 517 + type = 0 + slot = 2 + item_definition_index = 517 + parent_class = "weapon_knife" + tags = "all,knife,melee,earned" + + [[knife_css]] + id = 503 + type = 0 + slot = 2 + item_definition_index = 503 parent_class = "weapon_knife" tags = "all,knife,melee,earned" [[knife_falchion]] + id = 512 + type = 0 slot = 2 item_definition_index = 512 parent_class = "weapon_knife" tags = "all,knife,melee,earned" [[knife_flip]] + id = 505 + type = 0 slot = 2 item_definition_index = 505 parent_class = "weapon_knife" tags = "all,knife,melee,earned" [[knife_ghost]] + id = 80 + type = 0 slot = 2 item_definition_index = 80 + parent_class = "weapon_knife" tags = "all,knife,melee" [[knife_gut]] + id = 506 + type = 0 slot = 2 item_definition_index = 506 parent_class = "weapon_knife" tags = "all,knife,melee,earned" [[knife_gypsy_jackknife]] + id = 520 + type = 0 slot = 2 item_definition_index = 520 parent_class = "weapon_knife" tags = "all,knife,melee,earned" [[knife_karambit]] + id = 507 + type = 0 slot = 2 item_definition_index = 507 parent_class = "weapon_knife" tags = "all,knife,melee,earned" [[knife_m9_bayonet]] + id = 508 + type = 0 slot = 2 item_definition_index = 508 parent_class = "weapon_knife" tags = "all,knife,melee,earned" + [[knife_outdoor]] + id = 521 + type = 0 + slot = 2 + item_definition_index = 521 + parent_class = "weapon_knife" + tags = "all,knife,melee,earned" + [[knife_push]] + id = 516 + type = 0 slot = 2 item_definition_index = 516 parent_class = "weapon_knife" tags = "all,knife,melee,earned" + [[knife_skeleton]] + id = 525 + type = 0 + slot = 2 + item_definition_index = 525 + parent_class = "weapon_knife" + tags = "all,knife,melee,earned" + [[knife_stiletto]] + id = 522 + type = 0 slot = 2 item_definition_index = 522 parent_class = "weapon_knife" tags = "all,knife,melee,earned" [[knife_survival_bowie]] + id = 514 + type = 0 slot = 2 item_definition_index = 514 parent_class = "weapon_knife" tags = "all,knife,melee,earned" [[knife_t]] + id = 59 + type = 0 slot = 2 item_definition_index = 59 parent_class = "weapon_knife" tags = "all,knife,melee" [[knife_tactical]] + id = 509 + type = 0 slot = 2 item_definition_index = 509 parent_class = "weapon_knife" tags = "all,knife,melee,earned" [[knife_ursus]] + id = 519 + type = 0 slot = 2 item_definition_index = 519 parent_class = "weapon_knife" tags = "all,knife,melee,earned" [[knife_widowmaker]] + id = 523 + type = 0 slot = 2 item_definition_index = 523 parent_class = "weapon_knife" tags = "all,knife,melee,earned" [[knifegg]] + id = 41 + type = 0 slot = 2 + item_definition_index = 41 tags = "all,knife,melee" - [[knife_css]] - slot = 2 - item_definition_index = 503 - parent_class = "weapon_knife" - tags = "all,knife,melee,earned" - - [[knife_cord]] - slot = 2 - item_definition_index = 517 - parent_class = "weapon_knife" - tags = "all,knife,melee,earned" - - [[knife_canis]] - slot = 2 - item_definition_index = 518 - parent_class = "weapon_knife" - tags = "all,knife,melee,earned" - - [[knife_outdoor]] - slot = 2 - item_definition_index = 521 - parent_class = "weapon_knife" - tags = "all,knife,melee,earned" - - [[knife_skeleton]] - slot = 2 - item_definition_index = 525 - parent_class = "weapon_knife" - tags = "all,knife,melee,earned" - [[melee]] + id = 74 + type = 16 slot = 2 + item_definition_index = 74 tags = "all,melee" [[spanner]] + id = 78 + type = 16 slot = 2 item_definition_index = 78 parent_class = "weapon_melee" tags = "all,melee" [[taser]] + id = 31 + type = 8 slot = 2 maxammo = 1 ammoprop = 19 @@ -525,11 +654,12 @@ item_definition_index = 31 tags = "all,melee" - # ========================================================================= # PROJECTILE WEAPONS # ========================================================================= [[decoy]] + id = 47 + type = 9 slot = 3 maxammo = "ammo_grenade_limit_default" ammoprop = 18 @@ -538,6 +668,8 @@ tags = "all,grenade" [[diversion]] + id = 82 + type = 9 slot = 3 maxammo = "ammo_grenade_limit_default" ammoprop = 18 @@ -546,6 +678,8 @@ tags = "all,grenade" [[firebomb]] + id = 81 + type = 9 slot = 3 maxammo = "ammo_grenade_limit_default" ammoprop = 17 @@ -554,6 +688,8 @@ tags = "all,grenade,incendiary" [[flashbang]] + id = 43 + type = 9 slot = 3 maxammo = "ammo_grenade_limit_flashbang" ammoprop = 15 @@ -562,6 +698,8 @@ tags = "all,grenade" [[frag_grenade]] + id = 83 + type = 9 slot = 3 maxammo = "ammo_grenade_limit_default" ammoprop = 14 @@ -570,6 +708,8 @@ tags = "all,grenade,explosive" [[hegrenade]] + id = 44 + type = 9 slot = 3 maxammo = "ammo_grenade_limit_default" ammoprop = 14 @@ -578,6 +718,8 @@ tags = "all,grenade,explosive" [[incgrenade]] + id = 48 + type = 9 slot = 3 maxammo = "ammo_grenade_limit_default" ammoprop = 17 @@ -586,6 +728,8 @@ tags = "all,grenade,incendiary" [[molotov]] + id = 46 + type = 9 slot = 3 maxammo = "ammo_grenade_limit_default" ammoprop = 17 @@ -594,6 +738,8 @@ tags = "all,grenade,incendiary" [[smokegrenade]] + id = 45 + type = 9 slot = 3 maxammo = "ammo_grenade_limit_default" ammoprop = 16 @@ -602,6 +748,8 @@ tags = "all,grenade" [[snowball]] + id = 84 + type = 9 slot = 3 maxammo = "ammo_grenade_limit_snowballs" ammoprop = 24 @@ -609,34 +757,44 @@ tags = "all,grenade" [[tagrenade]] + id = 68 + type = 9 slot = 3 maxammo = "ammo_grenade_limit_default" ammoprop = 22 + item_definition_index = 68 tags = "all,grenade,tool,coop" - # ========================================================================= # TOOLS # ========================================================================= [[breachcharge]] + id = 70 + type = 13 slot = 4 maxammo = "ammo_grenade_limit_breachcharge" ammoprop = 23 item_definition_index = 70 tags = "all,grenade,tool,explosive" - [[c4]] - slot = 4 - item_definition_index = 49 - tags = "all,objective" - [[bumpmine]] + id = 85 + type = 14 slot = 4 item_definition_index = 85 maxammo = "ammo_grenade_limit_bumpmine" tags = "all,tool" + [[c4]] + id = 49 + type = 7 + slot = 4 + item_definition_index = 49 + tags = "all,objective" + [[healthshot]] + id = 57 + type = 11 slot = 11 item_definition_index = 57 maxammo = "ammo_item_limit_healthshot" @@ -644,11 +802,22 @@ tags = "all,tool,coop" [[shield]] + id = 37 + type = 17 slot = 11 item_definition_index = 37 tags = "all,tool" [[tablet]] + id = 72 + type = 15 slot = 12 item_definition_index = 72 tags = "all,tool" + + [[zone_repulsor]] + id = 20 + type = 18 + slot = 11 + item_definition_index = 20 + tags = "all,tool" diff --git a/addons/source-python/data/source-python/weapons/cstrike.ini b/addons/source-python/data/source-python/weapons/cstrike.ini old mode 100644 new mode 100755 index 97190f2fd..3c06baf3a --- a/addons/source-python/data/source-python/weapons/cstrike.ini +++ b/addons/source-python/data/source-python/weapons/cstrike.ini @@ -17,6 +17,8 @@ # ========================================================================= # Snipers [[awp]] + id = 17 + type = 5 slot = 0 maxammo = "ammo_338mag_max" ammoprop = 5 @@ -25,6 +27,8 @@ tags = "all,primary,rifle,sniper" [[g3sg1]] + id = 23 + type = 5 slot = 0 maxammo = "ammo_762mm_max" ammoprop = 2 @@ -33,6 +37,8 @@ tags = "all,primary,rifle,sniper" [[scout]] + id = 3 + type = 5 slot = 0 maxammo = "ammo_762mm_max" ammoprop = 2 @@ -41,6 +47,8 @@ tags = "all,primary,rifle,sniper" [[sg550]] + id = 13 + type = 5 slot = 0 maxammo = "ammo_556mm_max" ammoprop = 3 @@ -50,6 +58,8 @@ # Assault Rifles [[ak47]] + id = 27 + type = 3 slot = 0 maxammo = "ammo_762mm_max" ammoprop = 2 @@ -58,6 +68,8 @@ tags = "all,primary,rifle" [[aug]] + id = 8 + type = 3 slot = 0 maxammo = "ammo_762mm_max" ammoprop = 2 @@ -66,6 +78,8 @@ tags = "all,primary,rifle" [[famas]] + id = 15 + type = 3 slot = 0 maxammo = "ammo_556mm_max" ammoprop = 3 @@ -74,6 +88,8 @@ tags = "all,primary,rifle" [[galil]] + id = 14 + type = 3 slot = 0 maxammo = "ammo_556mm_max" ammoprop = 3 @@ -82,6 +98,8 @@ tags = "all,primary,rifle" [[m4a1]] + id = 21 + type = 3 slot = 0 maxammo = "ammo_556mm_max" ammoprop = 3 @@ -90,6 +108,8 @@ tags = "all,primary,rifle" [[sg552]] + id = 26 + type = 3 slot = 0 maxammo = "ammo_556mm_max" ammoprop = 3 @@ -99,6 +119,8 @@ # SMGs [[mac10]] + id = 7 + type = 2 slot = 0 maxammo = "ammo_45acp_max" ammoprop = 8 @@ -107,6 +129,8 @@ tags = "all,primary,smg" [[mp5navy]] + id = 18 + type = 2 slot = 0 maxammo = "ammo_9mm_max" ammoprop = 6 @@ -115,6 +139,8 @@ tags = "all,primary,smg" [[p90]] + id = 29 + type = 2 slot = 0 maxammo = "ammo_57mm_max" ammoprop = 10 @@ -123,6 +149,8 @@ tags = "all,primary,smg" [[tmp]] + id = 22 + type = 2 slot = 0 maxammo = "ammo_9mm_max" ammoprop = 6 @@ -131,6 +159,8 @@ tags = "all,primary,smg" [[ump45]] + id = 12 + type = 2 slot = 0 maxammo = "ammo_45acp_max" ammoprop = 8 @@ -140,6 +170,8 @@ # Shotguns [[m3]] + id = 20 + type = 4 slot = 0 maxammo = "ammo_buckshot_max" ammoprop = 7 @@ -148,6 +180,8 @@ tags = "all,primary,shotgun" [[xm1014]] + id = 5 + type = 4 slot = 0 maxammo = "ammo_buckshot_max" ammoprop = 7 @@ -157,6 +191,8 @@ # Heavy Machine Gun [[m249]] + id = 19 + type = 6 slot = 0 maxammo = "ammo_556mm_box_max" ammoprop = 4 @@ -168,6 +204,8 @@ # SECONDARY WEAPONS # ========================================================================= [[deagle]] + id = 25 + type = 1 slot = 1 maxammo = "ammo_50AE_max" ammoprop = 1 @@ -176,6 +214,8 @@ tags = "all,secondary,pistol" [[elite]] + id = 10 + type = 1 slot = 1 maxammo = "ammo_9mm_max" ammoprop = 6 @@ -184,6 +224,8 @@ tags = "all,secondary,pistol" [[fiveseven]] + id = 11 + type = 1 slot = 1 maxammo = "ammo_57mm_max" ammoprop = 10 @@ -192,6 +234,8 @@ tags = "all,secondary,pistol" [[glock]] + id = 2 + type = 1 slot = 1 maxammo = "ammo_9mm_max" ammoprop = 6 @@ -200,6 +244,8 @@ tags = "all,secondary,pistol" [[p228]] + id = 1 + type = 1 slot = 1 maxammo = "ammo_357sig_max" ammoprop = 9 @@ -208,6 +254,8 @@ tags = "all,secondary,pistol" [[usp]] + id = 16 + type = 1 slot = 1 maxammo = "ammo_45acp_max" ammoprop = 8 @@ -219,6 +267,8 @@ # MELEE WEAPONS # ========================================================================= [[knife]] + id = 28 + type = 0 slot = 2 tags = "all,knife,melee" @@ -226,6 +276,8 @@ # PROJECTILE WEAPONS # ========================================================================= [[hegrenade]] + id = 4 + type = 8 slot = 3 maxammo = "ammo_hegrenade_max" ammoprop = 11 @@ -233,6 +285,8 @@ tags = "all,grenade,explosive" [[flashbang]] + id = 24 + type = 8 slot = 3 maxammo = "ammo_flashbang_max" ammoprop = 12 @@ -240,6 +294,8 @@ tags = "all,grenade" [[smokegrenade]] + id = 9 + type = 9 slot = 3 maxammo = "ammo_smokegrenade_max" ammoprop = 13 @@ -250,5 +306,7 @@ # TOOLS # ========================================================================= [[c4]] + id = 6 + type = 7 slot = 4 tags = "all,objective" diff --git a/addons/source-python/packages/source-python/weapons/instance.py b/addons/source-python/packages/source-python/weapons/instance.py old mode 100644 new mode 100755 index 79c155b0c..1ec121a68 --- a/addons/source-python/packages/source-python/weapons/instance.py +++ b/addons/source-python/packages/source-python/weapons/instance.py @@ -8,6 +8,10 @@ # Source.Python Imports # Cvars from cvars import ConVar +# Weapons +from weapons.constants import WeaponID +from weapons.constants import WeaponSlot +from weapons.constants import WeaponType # ============================================================================= @@ -31,8 +35,26 @@ def __init__(self, name, basename, properties): # Store the weapon's base name self._basename = basename + # Store the weapon's id number + _id = properties.get('id', None) + try: + self._id = WeaponID(_id) + except ValueError: + self._id = _id + + # Store the weapon's type number + _type = properties.get('type', None) + try: + self._type = WeaponType(_type) + except ValueError: + self._type = _type + # Store the weapon's slot number - self._slot = properties.get('slot', None) + _slot = properties.get('slot', None) + try: + self._slot = WeaponSlot(_slot) + except ValueError: + self._slot = _slot # Store the weapon's max ammo amount self._maxammo = properties.get('maxammo', None) @@ -46,6 +68,9 @@ def __init__(self, name, basename, properties): # Store the weapon's cost self._cost = properties.get('cost', None) + # Store the weapon's parent_class + self._parent_class = properties.get('parent_class', None) + # Store the weapon's item definition index self._item_definition_index = properties.get('item_definition_index', None) @@ -68,11 +93,27 @@ def basename(self): """ return self._basename + @property + def id(self): + """Return the id of the weapon. + + :rtype: int/WeaponID + """ + return self._id + + @property + def type(self): + """Return the type of the weapon. + + :rtype: int/WeaponType + """ + return self._type + @property def slot(self): """Return the slot of the weapon. - :rtype: int + :rtype: int/WeaponSlot """ return self._slot @@ -123,6 +164,16 @@ def cost(self): """ return self._cost + @property + def parent_class(self): + """Return the parent class of the weapon. + + :return: + None if the parent class data is missing. + :rtype: str + """ + return self._parent_class + @property def item_definition_index(self): """Return the item definition index of the weapon. From 22a661fb12b5e2a2e1f6f946fda75a40735f1ef2 Mon Sep 17 00:00:00 2001 From: Jonathan <30329245+CookStar@users.noreply.github.com> Date: Sat, 10 Jun 2023 11:56:05 +0900 Subject: [PATCH 5/7] Changed ID, Type, Slot in CS:GO/CS:S weapon data to the weapon constants' name. Added sniperrifle, assaultrifle, submachinegun, mg tags to CS:GO/CS:S weapon data. Added cant_create, cant_find, and parent tags to CS:GO weapon data. Changed Entity.create, Entity.find, and Weapon.weapon_name in CS:GO to use new added tags with WeaponClassIter. --- .../data/source-python/weapons/csgo.ini | 683 ++++++++---------- .../data/source-python/weapons/cstrike.ini | 207 +++--- .../entities/engines/csgo/csgo.py | 55 +- .../weapons/engines/csgo/csgo.py | 9 +- .../source-python/weapons/instance.py | 46 +- 5 files changed, 470 insertions(+), 530 deletions(-) mode change 100644 => 100755 addons/source-python/packages/source-python/weapons/engines/csgo/csgo.py diff --git a/addons/source-python/data/source-python/weapons/csgo.ini b/addons/source-python/data/source-python/weapons/csgo.ini index ddf897724..11ad8a86c 100755 --- a/addons/source-python/data/source-python/weapons/csgo.ini +++ b/addons/source-python/data/source-python/weapons/csgo.ini @@ -35,789 +35,708 @@ # ========================================================================= # Snipers [[awp]] - id = 9 - type = 5 - slot = 0 + id = "AWP" + type = "SNIPERRIFLE" + slot = "PRIMARY" maxammo = 30 ammoprop = 6 clip = 5 cost = 4750 - item_definition_index = 9 - tags = "all,primary,rifle,sniper" + tags = "all,primary,rifle,sniper,sniperrifle" [[g3sg1]] - id = 11 - type = 5 - slot = 0 + id = "G3SG1" + type = "SNIPERRIFLE" + slot = "PRIMARY" maxammo = 90 ammoprop = 2 clip = 20 cost = 5000 - item_definition_index = 11 - tags = "all,primary,rifle,sniper" + tags = "all,primary,rifle,sniper,sniperrifle" [[scar20]] - id = 38 - type = 5 - slot = 0 + id = "SCAR20" + type = "SNIPERRIFLE" + slot = "PRIMARY" maxammo = 90 ammoprop = 2 clip = 20 cost = 5000 - item_definition_index = 38 - tags = "all,primary,rifle,sniper" + tags = "all,primary,rifle,sniper,sniperrifle" [[ssg08]] - id = 40 - type = 5 - slot = 0 + id = "SSG08" + type = "SNIPERRIFLE" + slot = "PRIMARY" maxammo = 90 ammoprop = 2 clip = 10 cost = 1700 - item_definition_index = 40 - tags = "all,primary,rifle" + tags = "all,primary,rifle,sniper,sniperrifle" # Assault Rifles [[ak47]] - id = 7 - type = 3 - slot = 0 + id = "AK47" + type = "RIFLE" + slot = "PRIMARY" maxammo = 90 ammoprop = 2 clip = 30 cost = 2700 - item_definition_index = 7 - tags = "all,primary,rifle" + tags = "all,primary,rifle,assaultrifle" [[aug]] - id = 8 - type = 3 - slot = 0 + id = "AUG" + type = "RIFLE" + slot = "PRIMARY" maxammo = 90 ammoprop = 2 clip = 30 cost = 3150 - item_definition_index = 8 - tags = "all,primary,rifle" + tags = "all,primary,rifle,assaultrifle" [[famas]] - id = 10 - type = 3 - slot = 0 + id = "FAMAS" + type = "RIFLE" + slot = "PRIMARY" maxammo = 90 ammoprop = 3 clip = 25 cost = 2250 - item_definition_index = 10 - tags = "all,primary,rifle" + tags = "all,primary,rifle,assaultrifle" [[galilar]] - id = 13 - type = 3 - slot = 0 + id = "GALILAR" + type = "RIFLE" + slot = "PRIMARY" maxammo = 90 ammoprop = 3 clip = 35 cost = 2000 - item_definition_index = 13 - tags = "all,primary,rifle" + tags = "all,primary,rifle,assaultrifle" [[m4a1]] - id = 16 - type = 3 - slot = 0 + id = "M4A1" + type = "RIFLE" + slot = "PRIMARY" maxammo = 90 ammoprop = 3 clip = 30 cost = 3100 - item_definition_index = 16 - tags = "all,primary,rifle" + tags = "all,primary,rifle,assaultrifle,parent" [[m4a1_silencer]] - id = 60 - type = 3 - slot = 0 + id = "M4A1_SILENCER" + type = "RIFLE" + slot = "PRIMARY" maxammo = 80 ammoprop = 4 clip = 20 cost = 2900 - item_definition_index = 60 parent_class = "weapon_m4a1" - tags = "all,secondary,rifle" + tags = "all,secondary,rifle,assaultrifle,cant_find" [[sg556]] - id = 39 - type = 3 - slot = 0 + id = "SG556" + type = "RIFLE" + slot = "PRIMARY" maxammo = 90 ammoprop = 3 clip = 30 cost = 2750 - item_definition_index = 39 - tags = "all,primary,rifle" + tags = "all,primary,rifle,assaultrifle" # SMGs [[bizon]] - id = 26 - type = 2 - slot = 0 + id = "BIZON" + type = "SMG" + slot = "PRIMARY" maxammo = 120 ammoprop = 7 clip = 64 cost = 1400 - item_definition_index = 26 - tags = "all,primary,smg" + tags = "all,primary,smg,submachinegun" [[mac10]] - id = 17 - type = 2 - slot = 0 + id = "MAC10" + type = "SMG" + slot = "PRIMARY" maxammo = 100 ammoprop = 9 clip = 30 cost = 1050 - item_definition_index = 17 - tags = "all,primary,smg" + tags = "all,primary,smg,submachinegun" [[mp5sd]] - id = 23 - type = 2 - slot = 0 + id = "MP5SD" + type = "SMG" + slot = "PRIMARY" maxammo = 120 ammoprop = 7 clip = 30 cost = 1500 - item_definition_index = 23 parent_class = "weapon_mp7" - tags = "all,primary,smg" + tags = "all,primary,smg,submachinegun,cant_find" [[mp7]] - id = 33 - type = 2 - slot = 0 + id = "MP7" + type = "SMG" + slot = "PRIMARY" maxammo = 120 ammoprop = 7 clip = 30 cost = 1700 - item_definition_index = 33 - tags = "all,primary,smg" + tags = "all,primary,smg,submachinegun,parent" [[mp9]] - id = 34 - type = 2 - slot = 0 + id = "MP9" + type = "SMG" + slot = "PRIMARY" maxammo = 120 ammoprop = 7 clip = 30 cost = 1250 - item_definition_index = 34 - tags = "all,primary,smg" + tags = "all,primary,smg,submachinegun" [[p90]] - id = 19 - type = 2 - slot = 0 + id = "P90" + type = "SMG" + slot = "PRIMARY" maxammo = 100 ammoprop = 13 clip = 50 cost = 2350 - item_definition_index = 19 - tags = "all,primary,smg" + tags = "all,primary,smg,submachinegun" [[ump45]] - id = 24 - type = 2 - slot = 0 + id = "UMP45" + type = "SMG" + slot = "PRIMARY" maxammo = 100 ammoprop = 9 clip = 25 cost = 1200 - item_definition_index = 24 - tags = "all,primary,smg" + tags = "all,primary,smg,submachinegun" # Shotguns [[mag7]] - id = 27 - type = 4 - slot = 0 + id = "MAG7" + type = "SHOTGUN" + slot = "PRIMARY" maxammo = 32 ammoprop = 8 clip = 5 cost = 1800 - item_definition_index = 27 tags = "all,primary,shotgun" [[nova]] - id = 35 - type = 4 - slot = 0 + id = "NOVA" + type = "SHOTGUN" + slot = "PRIMARY" maxammo = 32 ammoprop = 8 clip = 8 cost = 1200 - item_definition_index = 35 tags = "all,primary,shotgun" [[sawedoff]] - id = 29 - type = 4 - slot = 0 + id = "SAWEDOFF" + type = "SHOTGUN" + slot = "PRIMARY" maxammo = 32 ammoprop = 8 clip = 7 cost = 1200 - item_definition_index = 29 tags = "all,primary,shotgun" [[xm1014]] - id = 25 - type = 4 - slot = 0 + id = "XM1014" + type = "SHOTGUN" + slot = "PRIMARY" maxammo = 32 ammoprop = 8 clip = 7 cost = 2000 - item_definition_index = 25 tags = "all,primary,shotgun" # Heavy Machine Gun [[m249]] - id = 14 - type = 6 - slot = 0 + id = "M249" + type = "MACHINEGUN" + slot = "PRIMARY" maxammo = 200 ammoprop = 5 clip = 100 cost = 5200 - item_definition_index = 14 - tags = "all,primary,machinegun" + tags = "all,primary,machinegun,mg" [[negev]] - id = 28 - type = 6 - slot = 0 + id = "NEGEV" + type = "MACHINEGUN" + slot = "PRIMARY" maxammo = 300 ammoprop = 5 clip = 150 cost = 1700 - item_definition_index = 28 - tags = "all,primary,machinegun" + tags = "all,primary,machinegun,mg" # ========================================================================= # SECONDARY WEAPONS # ========================================================================= [[cz75a]] - id = 63 - type = 1 - slot = 1 + id = "CZ75A" + type = "PISTOL" + slot = "SECONDARY" maxammo = 12 ammoprop = 12 clip = 12 cost = 500 - item_definition_index = 63 parent_class = "weapon_p250" - tags = "all,secondary,pistol" + tags = "all,secondary,pistol,cant_find" [[deagle]] - id = 1 - type = 1 - slot = 1 + id = "DEAGLE" + type = "PISTOL" + slot = "SECONDARY" maxammo = 35 ammoprop = 1 clip = 7 cost = 700 - item_definition_index = 1 - tags = "all,secondary,pistol" + tags = "all,secondary,pistol,parent" [[elite]] - id = 2 - type = 1 - slot = 1 + id = "ELITE" + type = "PISTOL" + slot = "SECONDARY" maxammo = 120 ammoprop = 7 clip = 30 cost = 500 - item_definition_index = 2 tags = "all,secondary,pistol" [[fiveseven]] - id = 3 - type = 1 - slot = 1 + id = "FIVESEVEN" + type = "PISTOL" + slot = "SECONDARY" maxammo = 100 ammoprop = 13 clip = 20 cost = 500 - item_definition_index = 3 tags = "all,secondary,pistol" [[glock]] - id = 4 - type = 1 - slot = 1 + id = "GLOCK" + type = "PISTOL" + slot = "SECONDARY" maxammo = 120 ammoprop = 7 clip = 20 cost = 200 - item_definition_index = 4 tags = "all,secondary,pistol" [[hkp2000]] - id = 32 - type = 1 - slot = 1 + id = "HKP2000" + type = "PISTOL" + slot = "SECONDARY" maxammo = 52 ammoprop = 10 clip = 13 cost = 200 - item_definition_index = 32 - tags = "all,secondary,pistol" + tags = "all,secondary,pistol,parent" [[p250]] - id = 36 - type = 1 - slot = 1 + id = "P250" + type = "PISTOL" + slot = "SECONDARY" maxammo = 26 ammoprop = 20 clip = 13 cost = 300 - item_definition_index = 36 - tags = "all,secondary,pistol" + tags = "all,secondary,pistol,parent" [[revolver]] - id = 64 - type = 1 - slot = 1 + id = "REVOLVER" + type = "PISTOL" + slot = "SECONDARY" maxammo = 8 ammoprop = 1 clip = 8 cost = 600 - item_definition_index = 64 parent_class = "weapon_deagle" - tags = "all,secondary,pistol" + tags = "all,secondary,pistol,cant_find" [[tec9]] - id = 30 - type = 1 - slot = 1 + id = "TEC9" + type = "PISTOL" + slot = "SECONDARY" maxammo = 90 ammoprop = 7 clip = 18 cost = 500 - item_definition_index = 30 tags = "all,secondary,pistol" [[usp_silencer]] - id = 61 - type = 1 - slot = 1 + id = "USP_SILENCER" + type = "PISTOL" + slot = "SECONDARY" maxammo = 24 ammoprop = 11 clip = 12 cost = 200 - item_definition_index = 61 parent_class = "weapon_hkp2000" - tags = "all,secondary,pistol" + tags = "all,secondary,pistol,cant_find" # ========================================================================= # MELEE WEAPONS # ========================================================================= [[axe]] - id = 75 - type = 16 - slot = 2 - item_definition_index = 75 + id = "AXE" + type = "MELEE" + slot = "KNIFE" parent_class = "weapon_melee" - tags = "all,melee" + tags = "all,melee,cant_find" [[bayonet]] - id = 500 - type = 0 - slot = 2 - item_definition_index = 500 + id = "BAYONET" + type = "KNIFE" + slot = "KNIFE" parent_class = "weapon_knife" - tags = "all,knife,melee,earned" + tags = "all,knife,melee,earned,cant_create,cant_find" [[fists]] - id = 69 - type = 12 - slot = 2 - item_definition_index = 69 + id = "FISTS" + type = "FISTS" + slot = "KNIFE" tags = "all,melee" [[hammer]] - id = 76 - type = 16 - slot = 2 - item_definition_index = 76 + id = "HAMMER" + type = "MELEE" + slot = "KNIFE" parent_class = "weapon_melee" - tags = "all,melee" + tags = "all,melee,cant_find" [[knife]] - id = 42 - type = 0 - slot = 2 - item_definition_index = 42 - tags = "all,knife,melee" + id = "KNIFE" + type = "KNIFE" + slot = "KNIFE" + tags = "all,knife,melee,parent" [[knife_butterfly]] - id = 515 - type = 0 - slot = 2 - item_definition_index = 515 + id = "KNIFE_BUTTERFLY" + type = "KNIFE" + slot = "KNIFE" parent_class = "weapon_knife" - tags = "all,knife,melee,earned" + tags = "all,knife,melee,earned,cant_create,cant_find" [[knife_canis]] - id = 518 - type = 0 - slot = 2 - item_definition_index = 518 + id = "KNIFE_CANIS" + type = "KNIFE" + slot = "KNIFE" parent_class = "weapon_knife" - tags = "all,knife,melee,earned" + tags = "all,knife,melee,earned,cant_create,cant_find" [[knife_cord]] - id = 517 - type = 0 - slot = 2 - item_definition_index = 517 + id = "KNIFE_CORD" + type = "KNIFE" + slot = "KNIFE" parent_class = "weapon_knife" - tags = "all,knife,melee,earned" + tags = "all,knife,melee,earned,cant_create,cant_find" [[knife_css]] - id = 503 - type = 0 - slot = 2 - item_definition_index = 503 + id = "KNIFE_CSS" + type = "KNIFE" + slot = "KNIFE" parent_class = "weapon_knife" - tags = "all,knife,melee,earned" + tags = "all,knife,melee,earned,cant_create,cant_find" [[knife_falchion]] - id = 512 - type = 0 - slot = 2 - item_definition_index = 512 + id = "KNIFE_FALCHION" + type = "KNIFE" + slot = "KNIFE" parent_class = "weapon_knife" - tags = "all,knife,melee,earned" + tags = "all,knife,melee,earned,cant_create,cant_find" [[knife_flip]] - id = 505 - type = 0 - slot = 2 - item_definition_index = 505 + id = "KNIFE_FLIP" + type = "KNIFE" + slot = "KNIFE" parent_class = "weapon_knife" - tags = "all,knife,melee,earned" + tags = "all,knife,melee,earned,cant_create,cant_find" [[knife_ghost]] - id = 80 - type = 0 - slot = 2 - item_definition_index = 80 + id = "KNIFE_GHOST" + type = "KNIFE" + slot = "KNIFE" parent_class = "weapon_knife" - tags = "all,knife,melee" + tags = "all,knife,melee,cant_find" [[knife_gut]] - id = 506 - type = 0 - slot = 2 - item_definition_index = 506 + id = "KNIFE_GUT" + type = "KNIFE" + slot = "KNIFE" parent_class = "weapon_knife" - tags = "all,knife,melee,earned" + tags = "all,knife,melee,earned,cant_create,cant_find" [[knife_gypsy_jackknife]] - id = 520 - type = 0 - slot = 2 - item_definition_index = 520 + id = "KNIFE_GYPSY_JACKKNIFE" + type = "KNIFE" + slot = "KNIFE" parent_class = "weapon_knife" - tags = "all,knife,melee,earned" + tags = "all,knife,melee,earned,cant_create,cant_find" [[knife_karambit]] - id = 507 - type = 0 - slot = 2 - item_definition_index = 507 + id = "KNIFE_KARAMBIT" + type = "KNIFE" + slot = "KNIFE" parent_class = "weapon_knife" - tags = "all,knife,melee,earned" + tags = "all,knife,melee,earned,cant_create,cant_find" [[knife_m9_bayonet]] - id = 508 - type = 0 - slot = 2 - item_definition_index = 508 + id = "KNIFE_M9_BAYONET" + type = "KNIFE" + slot = "KNIFE" parent_class = "weapon_knife" - tags = "all,knife,melee,earned" + tags = "all,knife,melee,earned,cant_create,cant_find" [[knife_outdoor]] - id = 521 - type = 0 - slot = 2 - item_definition_index = 521 + id = "KNIFE_OUTDOOR" + type = "KNIFE" + slot = "KNIFE" parent_class = "weapon_knife" - tags = "all,knife,melee,earned" + tags = "all,knife,melee,earned,cant_create,cant_find" [[knife_push]] - id = 516 - type = 0 - slot = 2 - item_definition_index = 516 + id = "KNIFE_PUSH" + type = "KNIFE" + slot = "KNIFE" parent_class = "weapon_knife" - tags = "all,knife,melee,earned" + tags = "all,knife,melee,earned,cant_create,cant_find" [[knife_skeleton]] - id = 525 - type = 0 - slot = 2 - item_definition_index = 525 + id = "KNIFE_SKELETON" + type = "KNIFE" + slot = "KNIFE" parent_class = "weapon_knife" - tags = "all,knife,melee,earned" + tags = "all,knife,melee,earned,cant_create,cant_find" [[knife_stiletto]] - id = 522 - type = 0 - slot = 2 - item_definition_index = 522 + id = "KNIFE_STILETTO" + type = "KNIFE" + slot = "KNIFE" parent_class = "weapon_knife" - tags = "all,knife,melee,earned" + tags = "all,knife,melee,earned,cant_create,cant_find" [[knife_survival_bowie]] - id = 514 - type = 0 - slot = 2 - item_definition_index = 514 + id = "KNIFE_SURVIVAL_BOWIE" + type = "KNIFE" + slot = "KNIFE" parent_class = "weapon_knife" - tags = "all,knife,melee,earned" + tags = "all,knife,melee,earned,cant_create,cant_find" [[knife_t]] - id = 59 - type = 0 - slot = 2 - item_definition_index = 59 + id = "KNIFE_T" + type = "KNIFE" + slot = "KNIFE" parent_class = "weapon_knife" - tags = "all,knife,melee" + tags = "all,knife,melee,cant_find" [[knife_tactical]] - id = 509 - type = 0 - slot = 2 - item_definition_index = 509 + id = "KNIFE_TACTICAL" + type = "KNIFE" + slot = "KNIFE" parent_class = "weapon_knife" - tags = "all,knife,melee,earned" + tags = "all,knife,melee,earned,cant_create,cant_find" [[knife_ursus]] - id = 519 - type = 0 - slot = 2 - item_definition_index = 519 + id = "KNIFE_URSUS" + type = "KNIFE" + slot = "KNIFE" parent_class = "weapon_knife" - tags = "all,knife,melee,earned" + tags = "all,knife,melee,earned,cant_create,cant_find" [[knife_widowmaker]] - id = 523 - type = 0 - slot = 2 - item_definition_index = 523 + id = "KNIFE_WIDOWMAKER" + type = "KNIFE" + slot = "KNIFE" parent_class = "weapon_knife" - tags = "all,knife,melee,earned" + tags = "all,knife,melee,earned,cant_create,cant_find" [[knifegg]] - id = 41 - type = 0 - slot = 2 - item_definition_index = 41 + id = "KNIFEGG" + type = "KNIFE" + slot = "KNIFE" tags = "all,knife,melee" [[melee]] - id = 74 - type = 16 - slot = 2 - item_definition_index = 74 - tags = "all,melee" + id = "MELEE" + type = "MELEE" + slot = "KNIFE" + tags = "all,melee,parent" [[spanner]] - id = 78 - type = 16 - slot = 2 - item_definition_index = 78 + id = "SPANNER" + type = "MELEE" + slot = "KNIFE" parent_class = "weapon_melee" - tags = "all,melee" + tags = "all,melee,cant_find" [[taser]] - id = 31 - type = 8 - slot = 2 + id = "TASER" + type = "TASER" + slot = "KNIFE" maxammo = 1 ammoprop = 19 clip = 1 cost = 200 - item_definition_index = 31 tags = "all,melee" # ========================================================================= # PROJECTILE WEAPONS # ========================================================================= [[decoy]] - id = 47 - type = 9 - slot = 3 + id = "DECOY" + type = "GRENADE" + slot = "GRENADE" maxammo = "ammo_grenade_limit_default" ammoprop = 18 cost = 50 - item_definition_index = 47 - tags = "all,grenade" + tags = "all,grenade,parent" [[diversion]] - id = 82 - type = 9 - slot = 3 + id = "DIVERSION" + type = "GRENADE" + slot = "GRENADE" maxammo = "ammo_grenade_limit_default" ammoprop = 18 - item_definition_index = 82 parent_class = "weapon_decoy" - tags = "all,grenade" + tags = "all,grenade,cant_find" [[firebomb]] - id = 81 - type = 9 - slot = 3 + id = "FIREBOMB" + type = "GRENADE" + slot = "GRENADE" maxammo = "ammo_grenade_limit_default" ammoprop = 17 - item_definition_index = 81 parent_class = "weapon_molotov" - tags = "all,grenade,incendiary" + tags = "all,grenade,incendiary,cant_find" [[flashbang]] - id = 43 - type = 9 - slot = 3 + id = "FLASHBANG" + type = "GRENADE" + slot = "GRENADE" maxammo = "ammo_grenade_limit_flashbang" ammoprop = 15 cost = 200 - item_definition_index = 43 tags = "all,grenade" [[frag_grenade]] - id = 83 - type = 9 - slot = 3 + id = "FRAG_GRENADE" + type = "GRENADE" + slot = "GRENADE" maxammo = "ammo_grenade_limit_default" ammoprop = 14 - item_definition_index = 83 parent_class = "weapon_hegrenade" - tags = "all,grenade,explosive" + tags = "all,grenade,explosive,cant_find" [[hegrenade]] - id = 44 - type = 9 - slot = 3 + id = "HEGRENADE" + type = "GRENADE" + slot = "GRENADE" maxammo = "ammo_grenade_limit_default" ammoprop = 14 cost = 300 - item_definition_index = 44 - tags = "all,grenade,explosive" + tags = "all,grenade,explosive,parent" [[incgrenade]] - id = 48 - type = 9 - slot = 3 + id = "INCGRENADE" + type = "GRENADE" + slot = "GRENADE" maxammo = "ammo_grenade_limit_default" ammoprop = 17 cost = 600 - item_definition_index = 48 tags = "all,grenade,incendiary" [[molotov]] - id = 46 - type = 9 - slot = 3 + id = "MOLOTOV" + type = "GRENADE" + slot = "GRENADE" maxammo = "ammo_grenade_limit_default" ammoprop = 17 cost = 400 - item_definition_index = 46 - tags = "all,grenade,incendiary" + tags = "all,grenade,incendiary,parent" [[smokegrenade]] - id = 45 - type = 9 - slot = 3 + id = "SMOKEGRENADE" + type = "GRENADE" + slot = "GRENADE" maxammo = "ammo_grenade_limit_default" ammoprop = 16 cost = 300 - item_definition_index = 45 tags = "all,grenade" [[snowball]] - id = 84 - type = 9 - slot = 3 + id = "SNOWBALL" + type = "GRENADE" + slot = "GRENADE" maxammo = "ammo_grenade_limit_snowballs" ammoprop = 24 - item_definition_index = 84 tags = "all,grenade" [[tagrenade]] - id = 68 - type = 9 - slot = 3 + id = "TAGRENADE" + type = "GRENADE" + slot = "GRENADE" maxammo = "ammo_grenade_limit_default" ammoprop = 22 - item_definition_index = 68 tags = "all,grenade,tool,coop" # ========================================================================= # TOOLS # ========================================================================= [[breachcharge]] - id = 70 - type = 13 - slot = 4 + id = "BREACHCHARGE" + type = "BREACHCHARGE" + slot = "C4" maxammo = "ammo_grenade_limit_breachcharge" ammoprop = 23 - item_definition_index = 70 tags = "all,grenade,tool,explosive" [[bumpmine]] - id = 85 - type = 14 - slot = 4 - item_definition_index = 85 + id = "BUMPMINE" + type = "BUMPMINE" + slot = "C4" maxammo = "ammo_grenade_limit_bumpmine" tags = "all,tool" [[c4]] - id = 49 - type = 7 - slot = 4 - item_definition_index = 49 + id = "C4" + type = "C4" + slot = "C4" tags = "all,objective" [[healthshot]] - id = 57 - type = 11 - slot = 11 - item_definition_index = 57 + id = "HEALTHSHOT" + type = "STACKABLEITEM" + slot = "SHIELD" maxammo = "ammo_item_limit_healthshot" ammoprop = 21 tags = "all,tool,coop" [[shield]] - id = 37 - type = 17 - slot = 11 - item_definition_index = 37 + id = "SHIELD" + type = "SHIELD" + slot = "SHIELD" tags = "all,tool" [[tablet]] - id = 72 - type = 15 - slot = 12 - item_definition_index = 72 + id = "TABLET" + type = "TABLET" + slot = "TABLET" tags = "all,tool" [[zone_repulsor]] - id = 20 - type = 18 - slot = 11 - item_definition_index = 20 + id = "ZONE_REPULSOR" + type = "ZONEREPULSOR" + slot = "SHIELD" tags = "all,tool" diff --git a/addons/source-python/data/source-python/weapons/cstrike.ini b/addons/source-python/data/source-python/weapons/cstrike.ini index 3c06baf3a..9f1164886 100755 --- a/addons/source-python/data/source-python/weapons/cstrike.ini +++ b/addons/source-python/data/source-python/weapons/cstrike.ini @@ -17,162 +17,162 @@ # ========================================================================= # Snipers [[awp]] - id = 17 - type = 5 - slot = 0 + id = "AWP" + type = "SNIPERRIFLE" + slot = "PRIMARY" maxammo = "ammo_338mag_max" ammoprop = 5 clip = 10 cost = 4750 - tags = "all,primary,rifle,sniper" + tags = "all,primary,rifle,sniper,sniperrifle" [[g3sg1]] - id = 23 - type = 5 - slot = 0 + id = "G3SG1" + type = "SNIPERRIFLE" + slot = "PRIMARY" maxammo = "ammo_762mm_max" ammoprop = 2 clip = 20 cost = 5000 - tags = "all,primary,rifle,sniper" + tags = "all,primary,rifle,sniper,sniperrifle" [[scout]] - id = 3 - type = 5 - slot = 0 + id = "SCOUT" + type = "SNIPERRIFLE" + slot = "PRIMARY" maxammo = "ammo_762mm_max" ammoprop = 2 clip = 10 cost = 2750 - tags = "all,primary,rifle,sniper" + tags = "all,primary,rifle,sniper,sniperrifle" [[sg550]] - id = 13 - type = 5 - slot = 0 + id = "SG550" + type = "SNIPERRIFLE" + slot = "PRIMARY" maxammo = "ammo_556mm_max" ammoprop = 3 clip = 30 cost = 4200 - tags = "all,primary,rifle,sniper" + tags = "all,primary,rifle,sniper,sniperrifle" # Assault Rifles [[ak47]] - id = 27 - type = 3 - slot = 0 + id = "AK47" + type = "RIFLE" + slot = "PRIMARY" maxammo = "ammo_762mm_max" ammoprop = 2 clip = 30 cost = 2500 - tags = "all,primary,rifle" + tags = "all,primary,rifle,assaultrifle" [[aug]] - id = 8 - type = 3 - slot = 0 + id = "AUG" + type = "RIFLE" + slot = "PRIMARY" maxammo = "ammo_762mm_max" ammoprop = 2 clip = 30 cost = 3500 - tags = "all,primary,rifle" + tags = "all,primary,rifle,assaultrifle" [[famas]] - id = 15 - type = 3 - slot = 0 + id = "FAMAS" + type = "RIFLE" + slot = "PRIMARY" maxammo = "ammo_556mm_max" ammoprop = 3 clip = 25 cost = 2250 - tags = "all,primary,rifle" + tags = "all,primary,rifle,assaultrifle" [[galil]] - id = 14 - type = 3 - slot = 0 + id = "GALIL" + type = "RIFLE" + slot = "PRIMARY" maxammo = "ammo_556mm_max" ammoprop = 3 clip = 35 cost = 2000 - tags = "all,primary,rifle" + tags = "all,primary,rifle,assaultrifle" [[m4a1]] - id = 21 - type = 3 - slot = 0 + id = "M4A1" + type = "RIFLE" + slot = "PRIMARY" maxammo = "ammo_556mm_max" ammoprop = 3 clip = 30 cost = 3100 - tags = "all,primary,rifle" + tags = "all,primary,rifle,assaultrifle" [[sg552]] - id = 26 - type = 3 - slot = 0 + id = "SG552" + type = "RIFLE" + slot = "PRIMARY" maxammo = "ammo_556mm_max" ammoprop = 3 clip = 30 cost = 3500 - tags = "all,primary,rifle" + tags = "all,primary,rifle,assaultrifle" # SMGs [[mac10]] - id = 7 - type = 2 - slot = 0 + id = "MAC10" + type = "SMG" + slot = "PRIMARY" maxammo = "ammo_45acp_max" ammoprop = 8 clip = 30 cost = 1400 - tags = "all,primary,smg" + tags = "all,primary,smg,submachinegun" [[mp5navy]] - id = 18 - type = 2 - slot = 0 + id = "MP5NAVY" + type = "SMG" + slot = "PRIMARY" maxammo = "ammo_9mm_max" ammoprop = 6 clip = 30 cost = 1500 - tags = "all,primary,smg" + tags = "all,primary,smg,submachinegun" [[p90]] - id = 29 - type = 2 - slot = 0 + id = "P90" + type = "SMG" + slot = "PRIMARY" maxammo = "ammo_57mm_max" ammoprop = 10 clip = 50 cost = 2350 - tags = "all,primary,smg" + tags = "all,primary,smg,submachinegun" [[tmp]] - id = 22 - type = 2 - slot = 0 + id = "TMP" + type = "SMG" + slot = "PRIMARY" maxammo = "ammo_9mm_max" ammoprop = 6 clip = 30 cost = 1250 - tags = "all,primary,smg" + tags = "all,primary,smg,submachinegun" [[ump45]] - id = 12 - type = 2 - slot = 0 + id = "UMP45" + type = "SMG" + slot = "PRIMARY" maxammo = "ammo_45acp_max" ammoprop = 8 clip = 25 cost = 1700 - tags = "all,primary,smg" + tags = "all,primary,smg,submachinegun" # Shotguns [[m3]] - id = 20 - type = 4 - slot = 0 + id = "M3" + type = "SHOTGUN" + slot = "PRIMARY" maxammo = "ammo_buckshot_max" ammoprop = 7 clip = 8 @@ -180,9 +180,9 @@ tags = "all,primary,shotgun" [[xm1014]] - id = 5 - type = 4 - slot = 0 + id = "XM1014" + type = "SHOTGUN" + slot = "PRIMARY" maxammo = "ammo_buckshot_max" ammoprop = 7 clip = 7 @@ -191,22 +191,22 @@ # Heavy Machine Gun [[m249]] - id = 19 - type = 6 - slot = 0 + id = "M249" + type = "MACHINEGUN" + slot = "PRIMARY" maxammo = "ammo_556mm_box_max" ammoprop = 4 clip = 100 cost = 5750 - tags = "all,primary,machinegun" + tags = "all,primary,machinegun,mg" # ========================================================================= # SECONDARY WEAPONS # ========================================================================= [[deagle]] - id = 25 - type = 1 - slot = 1 + id = "DEAGLE" + type = "PISTOL" + slot = "SECONDARY" maxammo = "ammo_50AE_max" ammoprop = 1 clip = 7 @@ -214,9 +214,9 @@ tags = "all,secondary,pistol" [[elite]] - id = 10 - type = 1 - slot = 1 + id = "ELITE" + type = "PISTOL" + slot = "SECONDARY" maxammo = "ammo_9mm_max" ammoprop = 6 clip = 30 @@ -224,9 +224,9 @@ tags = "all,secondary,pistol" [[fiveseven]] - id = 11 - type = 1 - slot = 1 + id = "FIVESEVEN" + type = "PISTOL" + slot = "SECONDARY" maxammo = "ammo_57mm_max" ammoprop = 10 clip = 20 @@ -234,9 +234,9 @@ tags = "all,secondary,pistol" [[glock]] - id = 2 - type = 1 - slot = 1 + id = "GLOCK" + type = "PISTOL" + slot = "SECONDARY" maxammo = "ammo_9mm_max" ammoprop = 6 clip = 20 @@ -244,9 +244,9 @@ tags = "all,secondary,pistol" [[p228]] - id = 1 - type = 1 - slot = 1 + id = "P228" + type = "PISTOL" + slot = "SECONDARY" maxammo = "ammo_357sig_max" ammoprop = 9 clip = 13 @@ -254,9 +254,9 @@ tags = "all,secondary,pistol" [[usp]] - id = 16 - type = 1 - slot = 1 + id = "USP" + type = "PISTOL" + slot = "SECONDARY" maxammo = "ammo_45acp_max" ammoprop = 8 clip = 12 @@ -267,36 +267,37 @@ # MELEE WEAPONS # ========================================================================= [[knife]] - id = 28 - type = 0 - slot = 2 + id = "KNIFE" + type = "KNIFE" + slot = "KNIFE" tags = "all,knife,melee" # ========================================================================= # PROJECTILE WEAPONS # ========================================================================= [[hegrenade]] - id = 4 - type = 8 - slot = 3 + id = "HEGRENADE" + type = "GRENADE" + slot = "GRENADE" maxammo = "ammo_hegrenade_max" ammoprop = 11 cost = 300 tags = "all,grenade,explosive" [[flashbang]] - id = 24 - type = 8 - slot = 3 + id = "FLASHBANG" + type = "GRENADE" + slot = "GRENADE" maxammo = "ammo_flashbang_max" ammoprop = 12 cost = 200 tags = "all,grenade" [[smokegrenade]] - id = 9 - type = 9 - slot = 3 + id = "SMOKEGRENADE" + # This is the type in the actual game. + type = "UNKNOWN" + slot = "GRENADE" maxammo = "ammo_smokegrenade_max" ammoprop = 13 cost = 300 @@ -306,7 +307,7 @@ # TOOLS # ========================================================================= [[c4]] - id = 6 - type = 7 - slot = 4 + id = "C4" + type = "C4" + slot = "C4" tags = "all,objective" diff --git a/addons/source-python/packages/source-python/entities/engines/csgo/csgo.py b/addons/source-python/packages/source-python/entities/engines/csgo/csgo.py index 70007f06e..8ff237160 100755 --- a/addons/source-python/packages/source-python/entities/engines/csgo/csgo.py +++ b/addons/source-python/packages/source-python/entities/engines/csgo/csgo.py @@ -10,24 +10,25 @@ from . import Entity as _Entity from entities import BaseEntityGenerator from entities.helpers import pointer_from_inthandle -# Weapons -from weapons.manager import weapon_manager +# Filters +from filters.weapons import WeaponClassIter # ============================================================================= # >> GLOBAL VARIABLES # ============================================================================= -_weapon_names_for_definition = { - weapon_manager[weapon].name: values.get('item_definition_index') - for weapon, values in weapon_manager.ini.get('weapons', {}).items() - if values.get('item_definition_index') +_cant_create_weapons = { + weapon_class.name: weapon_class + for weapon_class in WeaponClassIter('cant_create') } -_weapon_parents = { - weapon_manager[weapon].name: values.get('parent_class') - for weapon, values in weapon_manager.ini.get('weapons', {}).items() - if values.get('parent_class') +_cant_find_weapons = { + weapon_class.name: weapon_class + for weapon_class in WeaponClassIter('cant_find') +} +_parent_weapons = { + weapon_class.name: weapon_class.item_definition_index + for weapon_class in WeaponClassIter('parent') } -_parent_weapons = set(_weapon_parents.values()) # ============================================================================= @@ -41,35 +42,45 @@ class Entity(_Entity): @classmethod def create(cls, classname): - index = _weapon_names_for_definition.get(classname) - if index is not None: - parent_class = _weapon_parents.get(classname) - entity = super().create(parent_class or classname) - entity.item_definition_index = index + # Specific weapons cannot be created directly, create a parent class + # for the weapon and set the item_definition_index. + weapon_class = _cant_create_weapons.get(classname, None) + if weapon_class is not None: + entity = super().create(weapon_class.parent_class) + entity.item_definition_index = weapon_class.item_definition_index else: entity = super().create(classname) return entity @classmethod def find(cls, classname): - index = _weapon_names_for_definition.get(classname) - if classname in _weapon_parents and index is not None: - parent_classname = _weapon_parents[classname] + # Specific weapons cannot be found directly, instead iterate over + # the parent class and detect if the item_definition_index matches. + weapon_class = _cant_find_weapons.get(classname, None) + if weapon_class is not None: + parent_classname = weapon_class.parent_class + item_definition_index = weapon_class.item_definition_index for entity in BaseEntityGenerator(parent_classname, True): if not entity.is_networked(): continue if entity.get_network_property_int( 'm_AttributeManager.m_Item.m_iItemDefinitionIndex' - ) == index: + ) == item_definition_index: return cls(entity.index) - elif classname in _parent_weapons: + + # Parent weapon class is equivalent to the child class, therefore + # iterates over the parent class to detect if + # the item_definition_index matches. + parent_item_definition_index = _parent_weapons.get(classname, None) + if parent_item_definition_index is not None: for entity in BaseEntityGenerator(classname, True): if not entity.is_networked(): continue if entity.get_network_property_int( 'm_AttributeManager.m_Item.m_iItemDefinitionIndex' - ) in (index, 0): + ) in (parent_item_definition_index, 0): return cls(entity.index) + return super().find(classname) thrower = property( diff --git a/addons/source-python/packages/source-python/weapons/engines/csgo/csgo.py b/addons/source-python/packages/source-python/weapons/engines/csgo/csgo.py old mode 100644 new mode 100755 index 2756e8041..7e367abe0 --- a/addons/source-python/packages/source-python/weapons/engines/csgo/csgo.py +++ b/addons/source-python/packages/source-python/weapons/engines/csgo/csgo.py @@ -7,16 +7,17 @@ # ============================================================================= # Source.Python from . import Weapon as _Weapon -from weapons.manager import weapon_manager +# Filters +from filters.weapons import WeaponClassIter # ============================================================================= # >> GLOBAL VARIABLES # ============================================================================= _item_definition_indexes = { - values.get('item_definition_index'): weapon_manager[weapon].name - for weapon, values in weapon_manager.ini['weapons'].items() - if values.get('item_definition_index') + weapon_class.item_definition_index: weapon_class.name + for weapon_class in WeaponClassIter('all') + if weapon_class.item_definition_index is not None } diff --git a/addons/source-python/packages/source-python/weapons/instance.py b/addons/source-python/packages/source-python/weapons/instance.py index 1ec121a68..45dc6acea 100755 --- a/addons/source-python/packages/source-python/weapons/instance.py +++ b/addons/source-python/packages/source-python/weapons/instance.py @@ -36,25 +36,16 @@ def __init__(self, name, basename, properties): self._basename = basename # Store the weapon's id number - _id = properties.get('id', None) - try: - self._id = WeaponID(_id) - except ValueError: - self._id = _id + self._id = self.parse_weapon_constants( + properties.get('id', None), WeaponID) # Store the weapon's type number - _type = properties.get('type', None) - try: - self._type = WeaponType(_type) - except ValueError: - self._type = _type + self._type = self.parse_weapon_constants( + properties.get('type', None), WeaponType) # Store the weapon's slot number - _slot = properties.get('slot', None) - try: - self._slot = WeaponSlot(_slot) - except ValueError: - self._slot = _slot + self._slot = self.parse_weapon_constants( + properties.get('slot', None), WeaponSlot) # Store the weapon's max ammo amount self._maxammo = properties.get('maxammo', None) @@ -71,9 +62,6 @@ def __init__(self, name, basename, properties): # Store the weapon's parent_class self._parent_class = properties.get('parent_class', None) - # Store the weapon's item definition index - self._item_definition_index = properties.get('item_definition_index', None) - # Store the weapon's tags self._tags = properties.get('tags', 'all').split(',') @@ -182,7 +170,7 @@ def item_definition_index(self): None if the item defition index data is missing. :rtype: int """ - return self._item_definition_index + return int(self._id) @property def tags(self): @@ -191,3 +179,23 @@ def tags(self): :rtype: list """ return self._tags + + @staticmethod + def parse_weapon_constants(value, weapon_constants): + """Parses weapon constants. + + :return: + Returns the value as it is if weapon constants cannot be found. + """ + if isinstance(value, int): + try: + return weapon_constants(_id) + except ValueError: + pass + elif isinstance(value, str): + try: + return getattr(weapon_constants, value) + except AttributeError: + pass + + return value From 4bd787748c9a6cac6508dc71d3341a6802e88fd1 Mon Sep 17 00:00:00 2001 From: Jonathan <30329245+CookStar@users.noreply.github.com> Date: Sat, 10 Jun 2023 12:02:14 +0900 Subject: [PATCH 6/7] Fixed a bug in WeaponClass.item_definition_index. --- addons/source-python/packages/source-python/weapons/instance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/source-python/packages/source-python/weapons/instance.py b/addons/source-python/packages/source-python/weapons/instance.py index 45dc6acea..24356f1ec 100755 --- a/addons/source-python/packages/source-python/weapons/instance.py +++ b/addons/source-python/packages/source-python/weapons/instance.py @@ -170,7 +170,7 @@ def item_definition_index(self): None if the item defition index data is missing. :rtype: int """ - return int(self._id) + return int(self._id) if self._id is not None else None @property def tags(self): From d571bc018b21e89af36c0b3f83d94c4db356bf38 Mon Sep 17 00:00:00 2001 From: Jonathan <30329245+CookStar@users.noreply.github.com> Date: Sat, 10 Jun 2023 20:25:46 +0900 Subject: [PATCH 7/7] Fixed a bug in WeaponClass.parse_weapon_constants. --- addons/source-python/packages/source-python/weapons/instance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/source-python/packages/source-python/weapons/instance.py b/addons/source-python/packages/source-python/weapons/instance.py index 24356f1ec..10101cae1 100755 --- a/addons/source-python/packages/source-python/weapons/instance.py +++ b/addons/source-python/packages/source-python/weapons/instance.py @@ -189,7 +189,7 @@ def parse_weapon_constants(value, weapon_constants): """ if isinstance(value, int): try: - return weapon_constants(_id) + return weapon_constants(value) except ValueError: pass elif isinstance(value, str):