Creating custom weapons - basics: Difference between revisions
From TF2 Classified Wiki
More actions
No edit summary |
mNo edit summary |
||
| (24 intermediate revisions by the same user not shown) | |||
| Line 6: | Line 6: | ||
Demonstrate using a c_model with attach_to_hands 2 and possibly a v_model with attach_to hands 1. | Demonstrate using a c_model with attach_to_hands 2 and possibly a v_model with attach_to hands 1. | ||
Adjust the positions of the examples and text to look less messy. | |||
If you're going to add information, put it in [[Creating custom weapons#Creating your first weapon|Creating your first weapon]] only if it's '''very''' important to creating weapons, and otherwise put it in [[Creating custom weapons - advanced]]. Do NOT overwhelm beginners! | |||
''' | Don't try to fix the wonky indentation in the examples. It's inconsequential and fixing it here will make it look bad in Notepad ++, so it's best to leave it as is. Yeah, I'm annoyed by it too lol}} | ||
If you're here, chances are you're looking to create your own weapons for ''TF2 Classified''. Whether for use against bots or other players, this guide should hopefully | |||
'''This guide is currently incomplete, but it should suffice if you just need the very basics!''' | |||
If you're here, chances are you're looking to create your own weapons for ''TF2 Classified''. Whether for use against bots or other players, this guide should hopefully help you to start out with creating custom weapons. If it doesn't, consider asking for help in the '''#modding-discussion''' channel in the [https://discord.gg/tf2classified official TF2C Discord]. | |||
= Creating a custom item schema = | = Creating a custom item schema = | ||
| Line 17: | Line 21: | ||
== custom_items_game.txt == | == custom_items_game.txt == | ||
To begin, create a file named {{code|custom_items_game.txt}} in | To begin, create a file named {{code|custom_items_game.txt}} in the {{code|<SteamUserDir>\Team Fortress 2 Classified\tf2classified\custom\<Mod Name>\scripts\items}} directory. This is the file that contains all the information regarding your custom weapons. Please note that you cannot have multiple {{code|custom_items_game.txt}} files loaded simultaneously, so any other mod folders that contain them should be placed in {{code|tf2classified\custom\disabled}} to allow the new custom item schema to load. | ||
It should be noted that the {{code|custom_items_game.txt}} method is the simplest and objectively best option for defining custom weapons, as it automatically inherits data from the newest version of the vanilla {{code|items_game.txt}} file. It is possible to override the vanilla item schema with one that contains custom weapons, but this method is not recommended as the overriding file must be manually updated each patch for parity with the vanilla {{code|items_game.txt}} file. For you and your players' sake, use the {{code|custom_items_game.txt}} method ''only''. | |||
== Setting up parameters == | == Setting up parameters == | ||
| Line 23: | Line 29: | ||
<pre> | <pre> | ||
#base "items_game.txt" | |||
"items_game" | |||
{ | |||
"items" | |||
{ | |||
} | |||
"prefabs" | |||
{ | |||
} | |||
"attributes" | |||
{ | |||
} | |||
} | |||
</pre> | </pre> | ||
| Line 46: | Line 65: | ||
<pre> | <pre> | ||
"items_game" | |||
{ | |||
"items" | |||
{ | |||
"<item id>" | |||
{ | |||
"name" "<internal name>" | |||
"item_name" "<item name>" | |||
"item_type_name" "<item type name>" | |||
"item_quality" "<item name colour>" | |||
"item_logname" "<dev console name>" | |||
"item_iconname" "<icon name>" | |||
"item_class" "<item class>" | |||
"item_slot" "<backpack slot>" | |||
"anim_slot" "<player model and c_model animations>" | |||
"bucket" "<inventory slot override>" | |||
"bucket_position" "<inventory subslot override>" | |||
"model_player" "<view model>" | |||
"model_world" "<world model>" | |||
"image_inventory" "<backpack icon>" | |||
"attach_to_hands" "<view model animation type>" | |||
"used_by_classes" | |||
{ | |||
"<class>" "<backpack slot>" | |||
} | |||
"attributes" | |||
{ | |||
"<attribute name>" | |||
{ | |||
"attribute_class" "<attribute class>" | |||
"value" "<value>" | |||
} | |||
} | |||
"static_attrs" | |||
{ | |||
"<attribute class>" "<value>" | |||
} | |||
"visuals" | |||
{ | |||
"<parameter>" "value" | |||
} | |||
"mouse_pressed_sound" "<backpack select sound>" | |||
"drop_sound" "<backpack deselect sound>" | |||
} | |||
} | |||
} | |||
</pre> | </pre> | ||
| Line 120: | Line 194: | ||
<pre> | <pre> | ||
"items_game" | |||
{ | |||
"items" | |||
{ | |||
"10000" // Custom Pistol | |||
// You can add comments to your item schema with double slashes! | |||
{ | |||
"name" "CUSTOM_PISTOL_TEST" | |||
"item_name" "Custom Pistol" | |||
"item_type_name" "#TF_Weapon_Pistol" | |||
"item_logname" "pistol_test" | |||
"item_iconname" "pistol" | |||
"item_class" "tf_weapon_pistol" | |||
"item_slot" "secondary" | |||
"anim_slot" "secondary" | |||
"model_player" "models/weapons/v_models/v_pistol_scout.mdl" | |||
"model_world" "models/weapons/w_models/w_pistol.mdl" | |||
"image_inventory" "backpack/weapons/w_models/w_pistol" | |||
"attach_to_hands" "2" | |||
"used_by_classes" | |||
{ | |||
"scout" "1" | |||
} | |||
"attributes" | |||
{ | |||
"clip size bonus" | |||
{ | |||
"attribute_class" "mult_clipsize" | |||
"value" "2" | |||
} | |||
"damage penalty" | |||
{ | |||
"attribute_class" "mult_dmg" | |||
"value" "0.67" | |||
} | |||
} | |||
"static_attrs" | |||
{ | |||
"min_viewmodel_offset" "10 0 -10" | |||
} | |||
"visuals" | |||
{ | |||
"sound_single_shot" "Weapon_Winger.Single" | |||
"sound_burst" "Weapon_Winger.SingleCrit" | |||
} | |||
"mouse_pressed_sound" "ui/item_light_gun_pickup.wav" | |||
"drop_sound" "ui/item_light_gun_drop.wav" | |||
} | |||
} | |||
} | |||
</pre> | </pre> | ||
| Line 132: | Line 263: | ||
<pre> | <pre> | ||
"items_game | |||
{ | |||
"items" | |||
{ | |||
"<item ID>" | |||
{ | |||
<...> | |||
"attributes" | |||
{ | |||
"damage bonus" | |||
{ | |||
"attribute_class" "mult_dmg" | |||
"value" "1.33" | |||
} | |||
"clip size penalty" | |||
{ | |||
"attribute_class" "mult_clipsize" | |||
"value" "0.5" | |||
} | |||
"can headshot" | |||
{ | |||
"attribute_class" "can_headshot" | |||
"value" "1" | |||
} | |||
} | |||
<...> | |||
} | |||
} | |||
} | |||
</pre> | </pre> | ||
| Line 147: | Line 306: | ||
<pre> | <pre> | ||
"items_game" | |||
{ | |||
<...> | |||
"attributes" | |||
{ | |||
"40000" | |||
{ | |||
"name" "can headshot VISIBLE" | |||
"attribute_class" "can_headshot" | |||
"description_format" "value_is_additive" | |||
"stored_as_integer" "1" | |||
"description_string" "#Attrib_RevolverUseHitLocations" | |||
} | |||
} | |||
} | |||
</pre> | </pre> | ||
In your {{code|preset=3|"attributes"}} parameter (the one with the same indentation as {{code|preset=3|"items"}} and {{code|preset=3|"prefabs"}} - I know, it's confusing), | In your {{code|preset=3|"attributes"}} parameter (the one with the same indentation as {{code|preset=3|"items"}} and {{code|preset=3|"prefabs"}} - I know, it's confusing), paste the above attribute. This is a copy of the {{code|"can headshot"}} attribute that's been simplified for this tutorial. | ||
The {{code|"description_string"}} parameter is responsible for the stats displayed in an item's description. Here, it's been set to the plaintext "Crits on headshot", which means that it won't be affected by language. Thankfully, in this instance, there's a suitable localised string that can be used instead to ensure that it's understandable to a wider range of people. | The {{code|"description_string"}} parameter is responsible for the stats displayed in an item's description. Here, it's been set to the plaintext "Crits on headshot", which means that it won't be affected by language. Thankfully, in this instance, there's a suitable localised string that can be used instead to ensure that it's understandable to a wider range of people. | ||
| Line 166: | Line 340: | ||
<pre> | <pre> | ||
"items_game" | |||
{ | |||
"items" | |||
{ | |||
"<item ID>" | |||
{ | |||
<...> | |||
"attributes" | |||
{ | |||
"can headshot VISIBLE" | |||
{ | |||
"attribute_class" "can_headshot" | |||
"value" "1" | |||
} | |||
"damage bonus" | |||
{ | |||
"attribute_class" "mult_dmg" | |||
"value" "1.33" | |||
} | |||
"clip size penalty" | |||
{ | |||
"attribute_class" "mult_clipsize" | |||
"value" "0.5" | |||
} | |||
} | |||
<...> | |||
} | |||
} | |||
} | |||
</pre> | </pre> | ||
| Line 177: | Line 379: | ||
<pre> | <pre> | ||
"items_game" | |||
{ | |||
<...> | |||
"attributes" | |||
{ | |||
"40000" | |||
{ | |||
"name" "can headshot VISIBLE" | |||
"attribute_class" "can_headshot" | |||
"description_format" "value_is_additive" | |||
"stored_as_integer" "1" | |||
"description_string" "#Attrib_RevolverUseHitLocations" | |||
"effect_type" "positive" | |||
} | |||
} | |||
} | |||
</pre> | </pre> | ||
| Line 191: | Line 409: | ||
<pre> | <pre> | ||
"items_game" | |||
{ | |||
"items" | |||
{ | |||
"<item ID>" | |||
{ | |||
<...> | |||
"item_logname" "pistol_test" | |||
"item_iconname" "winger" | |||
"item_class" "tf_weapon_pistol" | |||
"item_slot" "secondary" | |||
"anim_slot" "secondary" | |||
"model_player" "models/workshop/weapons/c_models/c_winger_pistol/c_winger_pistol.mdl" | |||
"image_inventory" "backpack/workshop/weapons/c_models/c_winger_pistol/c_winger_pistol" | |||
"attach_to_hands" "1" | |||
"used_by_classes" | |||
{ | |||
"scout" "1" | |||
"engineer" "1" | |||
} | |||
<...> | |||
} | |||
} | |||
} | |||
</pre> | </pre> | ||
| Line 207: | Line 453: | ||
<pre> | <pre> | ||
"items_game" | |||
{ | |||
"items" | |||
{ | |||
"<item ID>" | |||
{ | |||
<...> | |||
"model_player_per_class" | |||
{ | |||
"engineer" "models/weapons/v_models/v_pistol_engineer.mdl" | |||
"scout" "models/weapons/v_models/v_pistol_scout.mdl" | |||
} | |||
<...> | |||
} | |||
} | |||
} | |||
</pre> | </pre> | ||
| Line 219: | Line 480: | ||
If you make changes to the custom item schema, use the command {{code|cl_reload_item_schema}} to show the changes in game. {{code|sv_reload_item_schema}} can also be used to update the custom item schema for the whole server in multiplayer. | If you make changes to the custom item schema, use the command {{code|cl_reload_item_schema}} to show the changes in game. {{code|sv_reload_item_schema}} can also be used to update the custom item schema for the whole server in multiplayer. | ||
= | = Modifying vanilla weapons = | ||
''This section will potentially include a different method for editing vanilla weapons that isn't widely used. In the meantime, please do '''not''' write any other methods here, and use this method with caution if you plan on editing vanilla weapons.'' | |||
To modify vanilla items, you can include blank item entries in your custom schema with the same IDs as the ones you want to edit. From there, simply add new parameters, and they will merge with the original item's in game. If the same parameter or attribute is in both the vanilla item entry and the copy, then the copy's version will take priority. | |||
= | When attempting to override a item entry with the {{code|preset=3|baseitem}} parameter, you may have noticed that every other item with it disappears. To counteract this, include a blank copy of any base item you haven't modified in your custom item schema. It should be noted that any base items added to the vanilla item schema in updates must also be added to your custom schema, otherwise they will fail to appear in game. However, this is a rare occurrence, so constant maintenance won't be necessary. | ||
= | Below is an example {{code|custom_items_game.txt}} file that contains empty copies of every item with the {{code|preset=3|baseitem}} parameter as of [[3.0.0]]. | ||
<pre> | |||
#base "items_game.txt" | |||
"items_game" | |||
{ | |||
"items" | |||
{ | |||
"0" // Bat | |||
{ | |||
} | |||
"1" // Bottle | |||
{ | |||
} | |||
"2" // Fire Axe | |||
{ | |||
} | |||
"3" // Kukri | |||
{ | |||
} | |||
"4" // Knife | |||
{ | |||
} | |||
"5" // Fists | |||
{ | |||
} | |||
"6" // Shovel | |||
{ | |||
} | |||
"7" // Wrench | |||
{ | |||
} | |||
"8" // Bonesaw | |||
{ | |||
} | |||
"9" // Shotgun (Engineer) | |||
{ | |||
} | |||
"10" // Shotgun (Soldier) | |||
{ | |||
} | |||
"11" // Shotgun (Heavy) | |||
{ | |||
} | |||
"12" // Shotgun (Pyro) | |||
{ | |||
} | |||
"13" // Scattergun | |||
{ | |||
} | |||
"14" // Sniper Rifle | |||
{ | |||
} | |||
"15" // Minigun | |||
{ | |||
} | |||
"16" // SMG | |||
{ | |||
} | |||
"17" // Syringe Gun | |||
{ | |||
} | |||
"18" // Rocket Launcher | |||
{ | |||
} | |||
"19" // Grenade Launcher | |||
{ | |||
} | |||
"20" // Stickybomb Launcher | |||
{ | |||
} | |||
"21" // Flame Thrower | |||
{ | |||
} | |||
"22" // Pistol (Engineer) | |||
{ | |||
} | |||
"23" // Pistol (Scout) | |||
{ | |||
} | |||
"24" // Revolver | |||
{ | |||
} | |||
"25" // PDA: Teleporter (Construction PDA) | |||
{ | |||
} | |||
"26" // Destruction PDA | |||
{ | |||
} | |||
"27" // Disguise Kit | |||
{ | |||
} | |||
"28" // Builder (Toolbox) | |||
{ | |||
} | |||
"29" // Medi Gun | |||
{ | |||
} | |||
"30" // Invis Watch | |||
{ | |||
} | |||
"735" // Sapper | |||
{ | |||
} | |||
"1132" // Spellbook Magazine (Halloween) | |||
{ | |||
} | |||
"1152" // Grappling Hook (Mannpower) | |||
{ | |||
} | |||
"1155" // PASS Time Jack (PASS Time) | |||
{ | |||
} | |||
"2000" // Umbrella | |||
{ | |||
} | |||
} | |||
} | |||
</pre> | |||
= | = List of useful attributes = | ||
The table below lists generally useful attributes from [[List of TF2C item attributes|this page]]. | |||
== | <div style="max-width: 100%; overflow-x: scroll;"> | ||
{| class="wikitable sortable grid" | |||
! class="header" style="font-size: 16px;background-color: #583a31;color: white;" | ID | |||
! class="header" style="font-size: 16px;background-color: #583a31;color: white;" | Name | |||
! class="header" style="font-size: 16px;background-color: #583a31;color: white;" | Description | |||
! class="header" style="font-size: 16px;background-color: #583a31;color: white;" | Value Type | |||
! class="header" style="font-size: 16px;background-color: #583a31;color: white;" | Class | |||
! class="header" style="font-size: 16px;background-color: #583a31;color: white;" | Notes | |||
|- | |||
| 43 || scattergun no reload single || Attrib_Scattergun_NoReloadSingle || additive || set_scattergun_no_reload_single || Hidden | |||
|- | |||
| 128 || provide on active || When weapon is active || additive || provide_on_active || | |||
|- | |||
| 280 || override projectile type || || additive || set_scattergun_no_reload_single || Hidden | |||
Changes the projectile type of the weapon | |||
|- | |||
| 298 || mod ammo per shot || Per Shot: -%''s1'' ammo || additive || mod_ammo_per_shot || | |||
|- | |||
| 303 || mod max primary clip override || || additive || mod_max_primary_clip_override || Hidden | |||
|- | |||
| 551 || special taunt || || additive || special_taunt || Hidden | |||
|- | |||
| 674 || class select override vcd || Attrib_Class_Select_Override_VCD || additive || class_select_override_vcd || Hidden | |||
|- | |||
| 675 || custom projectile model || || additive || custom_projectile_model || Hidden | |||
Supports Rockets, Pipes, Stickies and Tranquillizer Darts | |||
|- | |||
| 796 || min_viewmodel_offset || || additive || min_viewmodel_offset || Hidden | |||
Used for "tf_use_min_viewmodels 1" to shift the viewmodel's position | |||
|- | |||
| 2029 || allowed in medieval mode || || || allowed_in_medieval_mode || Hidden | |||
|- | |||
| 2058 || meter_label || || || meter_label || Hidden | |||
|- | |||
| 5011 || extra wearable bodygroup toggle active || || additive || extra_wearable_bodygroup_toggle_active || Hidden | |||
|- | |||
| 5048 || custom hand viewmodel || || additive || custom_hand_viewmodel || | |||
Hidden <br> | |||
Uses a string | |||
|- | |||
| 5129 || mod burstfire || Sentry Gun turns +%s'''1'''% faster || additive || mod_burstfire || Note: Uses Wrong Localization string | |||
|- | |||
| 5135 || hidden separator || || || hidden_separator || All attributes in a weapon after this one will be hidden from the tooltip. | |||
|- | |||
| 5157 || passive reload holstered || Passively reloads ammo while holstered || additive || passive_reload_holstered || | |||
|- | |||
| 5194 || hide ammo hud || || additive || hide_ammo_hud || Hidden | |||
|- | |||
| 5199 || banned in medieval mode || || additive || banned_in_medieval_mode || Hidden | |||
|- | |||
| 5201 || custom disguise sound || || additive || custom_disguise_sound || Hidden | |||
|- | |||
| 5228 || mod ammo per reload || || additive || mod_ammo_per_reload || Hidden | |||
|- | |||
| 5229 || set reload single || || additive || set_reload_single || | |||
|- | |||
| 5230 || Reload time start || || inverted percentage || mult_reload_time_start || | |||
|- | |||
| 5231 || Reload time refill || || inverted percentage || mult_reload_time_refill || | |||
|- | |||
| 5249 || mod use custom ammo type || || additive || mod_use_custom_ammo_type || | |||
Hidden <br> | |||
Modes: <br> | |||
1 = Primary Ammo <br> | |||
2 = Secondary Ammo <br> | |||
3 = Metal <br> | |||
4 = Grenades1 <br> | |||
5 = Grenades2 | |||
|- | |||
| 5252 || set sentry bullet || || additive || set_sentry_bullet || | |||
Hidden <br> | |||
Value is the projectile index from "override_projectile_type" | |||
|- | |||
| 5253 || set sentry rocket || || additive || set_sentry_rocket || | |||
Hidden <br> | |||
Value is the projectile index from "override_projectile_type" | |||
|- | |||
| 5254 || weapon exclusive to holiday || || additive || weapon_exclusive_to_holiday || | |||
Hidden <br> | |||
Modes: <br> | |||
1 = TF Birthday <br> | |||
2 = Halloween <br> | |||
3 = Christmas <br> | |||
4 = End of the Line <br> | |||
5 = Invasion <br> | |||
6 = Valentines <br> | |||
7 = Pyromania <br> | |||
8 = Full Moon <br> | |||
9 = Halloween OR Full Moon <br> | |||
10 = Halloween OR Full Moon OR Valentines <br> | |||
11 = April Fools <br> | |||
12 = Soldier Day (Rick May Passing) <br> | |||
13 = Summer | |||
|- | |||
| 5256 || mod projectiles per shot || || additive || mod_projectiles_per_shot || | |||
|- | |||
| 5263 || mod set banner flag model || || additive || mod_set_banner_flag_model || Hidden | |||
|- | |||
| 5264 || custom banner sound || || additive || custom_banner_sound || Hidden | |||
|- | |||
| 5268 || auto jumping || Wearer can automatically jump by holding the jump button || additive || auto_jumping || | |||
|- | |||
| 5270 || always draw tracer || || additive || mod_always_draw_tracer_effect || | |||
Hidden <br> | |||
Value is frequency, 1 being always | |||
|- | |||
| 5271 || never draw tracer || || additive || mod_never_draw_tracer_effect || Hidden | |||
|- | |||
| 5272 || duck jumping || Wearer can jump while crouching || additive || duck_jumping || | |||
|- | |||
| ??? || N/A || N/A || N/A || custom_magazine_model || Requires custom attribute | |||
|} | |||
= See also = | = See also = | ||
* [[Creating custom weapons - advanced]] | |||
* [[Creating custom weapons - VScript]] | |||
* [[List of TF2C item attributes]] | * [[List of TF2C item attributes]] | ||
* [[List of TF2C item classes]] | * [[List of TF2C item classes]] | ||