Valve did very hacky implementations of the items over the years, causing Spaghetti code, here’s a compilation of what’s wrong.

Hi, this’ll be a bit technical so I’ll just do an introduction for this so you guys can understand how items in CSGO work.

Basically you’ve got the code part which is compiled in C++ etc… the usual stuff for a game, then they rely on a file called items_game.txt which basically is the implementation of the items in-game and on their item server. The part which is dirty right now is how weapons are implemented. I’ll add comments to the parts of the code so you can better understand what is what.

here’s an example of an item existing in the game:

"7" // unique ID of the item { "name" "weapon_ak47" // name of the item "prefab" "weapon_ak47_prefab" // prefab used as a base "item_quality" "normal" "baseitem" "1" // if the item is owned by default "default_slot_item" "1" // if the item is the default item in the buy menu for this slot "item_sub_position" "rifle1" // position in the buymenu } 

here’s its “prefab” (what the item uses as its base; I’ve removed the non important parts so it doesn’t fill the post with code) :

"weapon_ak47_prefab" { "prefab" "rifle" // prefab based on "item_class" "weapon_ak47" // C++ class of the item "item_name" "#SFUI_WPNHUD_AK47" // readable name of the item for players "item_description" "#CSGO_Item_Desc_AK47" // description for players "model_player" "models/weapons/v_rif_ak47.mdl" // Firstperson model "model_world" "models/weapons/w_rif_ak47.mdl" // Thirdperson model "model_dropped" "models/weapons/w_rif_ak47_dropped.mdl" // When the item is on the floor "used_by_classes" // Who can buy it / equip it { "counter-terrorists" "0" "terrorists" "1" } "attributes" // Ajusts on the C++ class, usually gameplay related { "magazine model" "models/weapons/w_rif_ak47_mag.mdl" // Example of an attribute, this is the dropped magazine when reloading "primary reserve ammo max" "90" // Maximum ammo that can be carried "spread" "0.600000" "damage" "36" // Damage dealt, later multiplied by the hitbox's multipliers "cycletime" "0.100000" // "60/RoundsPerMinute" to get the cycletime [ . . . ] } "visuals" // Visual effects of the weapon, some are wrong and should be attributes { "muzzle_flash_effect_1st_person" "weapon_muzzle_flash_assaultrifle" // Muzzle particle "muzzle_flash_effect_3rd_person" "weapon_muzzle_flash_assaultrifle" "heat_effect" "weapon_muzzle_smoke" // Smoke particle "addon_location" "primary_rifle" "eject_brass_effect" "weapon_shell_casing_rifle" // Shells particle "tracer_effect" "weapon_tracers_assrifle" // Bullet Tracers particle "weapon_type" "Rifle" // Type of weapon, defines what animations to use in thirdperson, also what kind of weapon it is (scoped, grenade, melee etc..) "primary_ammo" "BULLET_PLAYER_762MM" // Ammo used by the gun, obsolete? "sound_single_shot" "Weapon_AK47.Single" // Sound script used when firing "sound_nearlyempty" "Default.nearlyempty" // The Low ammo CLICK sound script } } 

Now that being said, a lot of mistakes were made on the Programming side, the items_game should always be doing what it says it should do.

Some basic OOP mistakes were made since few years and it’s starting to get visible by players and laughable at times by modders and hackers, it’s becoming a meme on how unreliable and dirty their code is and I can’t believe CS:GO’s programmers don’t think the same. I can understand that it’s underwhelming to work on existing spaghetti code and you have to deal with it by doing an other layer of spaghetti but they can’t continue like that, at some point the bugs will become insane. Cleaning those issues will be a god sent for both their team and us.

So here’s a list I did to point out what’s wrong and I’m probably missing a lot of them:

  • weapon_aug, weapon_sg556

    • Scopes aren’t implemented correctly since a year, worked fine before, their item_name is used instead of their class name resulting in weird issues if you decide to implement a new weapon based on it, this should be implemented inside the class itself and not rely on weird hack inside the code. [PREVIEW]
    • the “aimsight *” “attributes” are obsolete and don’t do anything EXCEPT “models/weapons/v_rif_aug_scopelensmask.mdl” which sets the mask of the item. Either remove their implementation in the items_game or implement them in their C++ class.
  • weapon_molotov, weapon_firebomb

    • Fire particles are spawned only if the ID of the item matches the one inside the C++ code (id: 46, 81), this is a misconception and a taped solution. This issue popped on reddit when dangerzone was released, the particles were missing on the weapon_firebomb and I guess a simple C++ edit was done in order to not bother fixing how the molotov works in the first place! This should be done directly inside the weapon class or as a “visuals” attribute with the attachement in parameter.
      • Here’s an other issue not related to the items_game but generally: Thirdperson particles used on the worldmodel are getting rendered in firstperson [PREVIEW]
  • weapon_shield

    • This one is a mess… First I’m guessing they’ve rewrote the entire way weapons work inside it which is just dirty, Second, if the item is equiped as a primary weapon, secondary or anything, you’ll be FORCED to pick it up and will drop your current weapon equiped in the slot it wants to be in [PREVIEW]
    • If the item_name doesn’t match “weapon_shield” the animations will be set to the knife’s, again a very big misconception, this is either the C++ class’ job or an items_game “visuals” parameter which already exists and is used by pretty much EVERY WEAPON. [PREVIEW]
    • Hitboxes are on the viewmodel, they don’t do anything, no point in having them.

Now to the structure of the items_game.txt

This mess:

 "alternate_icons2" { "weapon_icons" { "65604" { "icon_path" "econ/default_generated/weapon_deagle_hy_ddpat_urb_light" } "65605" { "icon_path" "econ/default_generated/weapon_deagle_hy_ddpat_urb_medium" } "65606" { "icon_path" "econ/default_generated/weapon_deagle_hy_ddpat_urb_heavy" } "65684" { "icon_path" "econ/default_generated/weapon_deagle_aa_flames_light" } [ . . . ] "330014002" { "icon_path" "econ/default_generated/studded_hydra_gloves_bloodhound_hydra_case_hardened_heavy" } } } 

There is literally 14401 lines of those things which have basically NO REASON BEING HERE in the first place, this is a huge misconception. they should be inside their respective items or in separate items_game file for readability reasons, I also doubt that they’re still used in Panorama. Anyway here’s what a skin looks like inside the items_game

 "17" { "name" "hy_ddpat_urb" "description_string" "#PaintKit_hy_ddpat" "description_tag" "#PaintKit_hy_ddpat_urb_Tag" "pattern" "ddpat" "style" "2" "color0" "40 40 40" "color1" "80 80 80" "color2" "140 140 140" "color3" "180 180 180" "phongintensity" "10" "pattern_scale" "2" "pattern_offset_x_start" "0" "pattern_offset_x_end" "1" "pattern_offset_y_start" "0" "pattern_offset_y_end" "1" } 

I’m also thinking that at times they just don’t know what they’re doing due to the mess Hidden Path Entertainment did when they were working on the game and all the mess Valve did over the years just accumulated causing unreadable code leading the programmers to work dirty to get shit done (that’s just how I see it). If possible those issues should be addressed for the sake of everybody and especially them not fixing code that breaks over the updates due to poor implementations or worse.

A bit of bright side now because I kinda make them look bad haha:

  • Icons for weapons are now fully based on their items_name, this makes implementing new weapons SUPER EASILY for them.
  • They just have to add a new entry in a file to set the positions and rotations for the inventory and buymenu when they create a new weapon
  • How flexible the items_game is when they don’t hard code weapons (this whole topic), you can basically set whatever you want on the fly.
  • Panorama is actually amazing, the amount of customization you can do when modding the game is crazy and no doubt that with them using JS… they can do anything they want easily, the guys who worked on panorama did a very very good job… it’s reliable and works as expected… Though it’s sad we can’t mod the JS part ( ͡° ͜ʖ ͡°)

The team have really outdone themselves so far in the recent years, they need to keep it up! Fixing those issues I believe will help everyone, Server owners will be happy and so will modders and ultimately players.

Just don’t code the dirty way like those said examples, because it feels amateurish for a AAA company.

TL:DR: Valve plz fix. Their implementation of items is a mess, they really need to fix it and stop working messy probably due to bad communication between departments.

submitted by /u/-ZooL-
[link] [comments]