-
Notifications
You must be signed in to change notification settings - Fork 2
Weapons Module
This module handles functions, hooks, and convars related to weapons, their spawning, import scripts, and other general weapon data. It also has to do with overriding or "redirecting" certain entities so that they spawn another entity. This is done to for example convert all weapon_zm_revolver entities to weapon_ttt_deagle entities. More on this is explained in the Entity Redirects section below.
Old weapon import scripts are completely supported, you can even still use the old tool that Badking made for this. I may eventually create my own tool that supports more custom entities but for the time being its perfectly fine to use Badking's old one.
The entity and weapon redirect system handles the replacement certain map entities by other entities. You can see currently redirected entities in sh_entity_redirects.lua, specifically with the TTT.Weapons.RedirectedEntities
and TTT.Weapons.RedirectedWeapons
tables. You can add a new redirect by following the same form as the other entities/weapons. Below is a simple template:
TTT.Weapons.RedirectedWeapons["myWeaponClass"] = {
Base = "weaponClassToInheritFrom",
AnyOtherKey = "anyOtherValue"
}
TTT.Weapons.RedirectedEntities["myEntityClass"] = {
Base = "entityClassToInheritFrom",
AnyOtherKey = "anyOtherValue"
}
You can see that you can also add any other variables to the weapon/entity class. For example: print(weapons.Get("myEntityClass").AnyOtherKey)
would output "anyOtherValue". All original TTT weapons and entities are given the IsOriginalTTTEntity variable set to true. Every single redirected entity is given the IsConvertedEntity variable set to true.
Weapon Kinds:
- WEAPON_INVALID = 0
- WEAPON_UNARMED = 1
- WEAPON_MELEE = 2
- WEAPON_CARRY = 3
- WEAPON_PRIMARY = 4
- WEAPON_SECONDARY = 5
- WEAPON_GRENADE = 6
- WEAPON_EQUIP1 = 7
- WEAPON_EQUIP2 = 8
- WEAPON_SPECIALEQUIP = 9
Each weapon must be given a Kind set to one of these enums in order to determine what slot the weapon takes up.
Crowbar Door Open Types:
- OPEN_NO = 0
- OPEN_ROT = 1
- OPEN_DOOR = 2
- OPEN_BUT = 3
- OPEN_NOTOGGLE = 4
These enumerations are used to determine an entity's openability by the crowbar. OPEN_NO means the crowbar cannot open the entity.
I simplified all ammo names down to the below list. You can see their definitions in sh_weapons.lua.
- ar
- pistol_heavy
- pistol_light
- sniper
- shotgun_buckshot
- none
ConVar | Default Value | Flags/Realm | Description |
---|---|---|---|
ttt_weapon_spawn_count | 0 | Server, Archived | How many extra weapons to spawn on unarmed CSS/TF2 maps missing import scripts. 0 for max player count + 3. |
ttt_weapon_use_import_scripts | 1 | Server, Archived | Should we use weapon import scripts. |
TODO: Add should redirect hooks here
TTT.Weapons.CanDropWeapon - Server
- Desc: Can the given player drop their current weapon.
- Arg One: Player, who wants to drop a weapon.
- Arg Two: Weapon, weapon they want to drop.
- Returns: Boolean, can they drop the weapon.
TTT.Weapons.DroppedWeapon - Server
- Desc: Called when the player dropped their weapon..
- Arg One: Player, who dropped their weapon.
- Arg Two: Weapon, that they just dropped.
TTT.Weapons.CanDropActiveAmmo - Server
- Desc: Can the given player drop their current weapon's ammo.
- Arg One: Player, who wants to drop their active weapon's ammo.
- Arg Two: Weapon, that they will be dropping ammo from.
- Arg Three: String, ammo entity class that would be created.
- Returns: Boolean, can they drop the ammo.
TTT.Weapons.PlayerDroppedActiveAmmo - Server
- Desc: Called when the player dropped their ammo..
- Arg One: Player, who dropped their ammo.
- Arg Two: Weapon, where the ammo they dropped came from.
- Arg Three: Entity, the ammo box produced when dropping the ammo.
TTT.Weapons.ShouldUseImportScript - Server
- Desc: Should the server use weapon import scripts for this map.
- Arg One: String, map name of the current map.
- Returns: Boolean, false to disable import scripts.