Skip to content

Commit

Permalink
Added World and View Models (#1327)
Browse files Browse the repository at this point in the history
Added a few world and view models to some weapons. Some weapons still
have their old "holstered" look. We might want to update them in a later
PR or keep them that way.

## Radio

![image_2024-01-26_10-52-55](https://github.com/TTT-2/TTT2/assets/13639408/eaef3f6a-8617-4466-b74d-1bf955da341a)

## Beacon

![image_2024-01-26_11-13-59](https://github.com/TTT-2/TTT2/assets/13639408/86a2dca3-5633-4946-9c90-87472ad27c45)

## Decoy

![image_2024-01-26_11-23-10](https://github.com/TTT-2/TTT2/assets/13639408/f25cd528-bcad-4827-a0fc-d5863765cf91)

## Binoculars

![image_2024-01-26_11-30-21](https://github.com/TTT-2/TTT2/assets/13639408/fa864874-2c82-4e8b-bb22-bf9f6896a05c)

## Visualizer (CSE)

![image_2024-01-26_11-42-53](https://github.com/TTT-2/TTT2/assets/13639408/d90bba20-0bc1-4871-8b35-db60f58012f0)
  • Loading branch information
TimGoll authored Feb 5, 2024
1 parent a52f830 commit 982f898
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 121 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ All notable changes to TTT2 will be documented here. Inspired by [keep a changel
- Icon for `Voice & Volume` menu
- Made beacon model and icon unique from decoy (by @EntranceJew)
- Added `SWEP:ClearHUDHelp()` to allow blanking the help text, for dynamically updating help text on equipment (by @EntranceJew)
- Added custom world and view models to some builtin weapons (by @TimGoll)
- added for: radio, beacon, decoy, binoculars, visualizer
- Added support for easy addition of custom view and world models (by @TimGoll)
- Added `AddCustomViewModel` to add custom view models
- Added `AddCustomWorldModel` to add custom world models
Expand Down
3 changes: 1 addition & 2 deletions gamemodes/terrortown/entities/entities/ttt_cse_proj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ end
DEFINE_BASECLASS("ttt_base_placeable")

ENT.Base = "ttt_base_placeable"
ENT.Model = "models/Items/battery.mdl"

ENT.RenderGroup = RENDERGROUP_BOTH
ENT.Model = "models/Items/battery.mdl"

ENT.Range = 128
ENT.MaxScenesPerPulse = 3
Expand Down
2 changes: 2 additions & 0 deletions gamemodes/terrortown/entities/entities/ttt_decoy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ end
DEFINE_BASECLASS("ttt_base_placeable")

ENT.Base = "ttt_base_placeable"

ENT.Model = "models/props_lab/reciever01b.mdl"

ENT.CanHavePrints = false
ENT.CanUseKey = true

Expand Down
70 changes: 39 additions & 31 deletions gamemodes/terrortown/entities/weapons/weapon_ttt_beacon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@ end

DEFINE_BASECLASS("weapon_tttbase")

SWEP.HoldType = "normal"
SWEP.HoldType = "slam"

if CLIENT then
SWEP.PrintName = "beacon_name"
SWEP.Slot = 6

SWEP.ViewModelFOV = 70
SWEP.ViewModelFlip = false

SWEP.UseHands = true
SWEP.ShowDefaultViewModel = false
SWEP.ShowDefaultWorldModel = false

SWEP.EquipMenuData = {
type = "item_weapon",
Expand All @@ -26,8 +31,8 @@ end

SWEP.Base = "weapon_tttbase"

SWEP.ViewModel = "models/weapons/v_crowbar.mdl"
SWEP.WorldModel = "models/props_lab/reciever01b.mdl"
SWEP.ViewModel = "models/weapons/cstrike/c_c4.mdl"
SWEP.WorldModel = "models/props_lab/reciever01a.mdl"

SWEP.Primary.ClipSize = 3
SWEP.Primary.DefaultClip = 1
Expand Down Expand Up @@ -117,26 +122,43 @@ function SWEP:Reload()
return false
end

---
-- @realm shared
function SWEP:OnRemove()
if
CLIENT
and IsValid(self:GetOwner())
and self:GetOwner() == LocalPlayer()
and self:GetOwner():IsTerror()
then
RunConsoleCommand("lastinv")
end
end

if CLIENT then
---
-- @realm client
function SWEP:Initialize()
self:AddTTT2HUDHelp("beacon_help_pri", "beacon_help_sec")

return BaseClass.Initialize(self)
self:AddCustomViewModel("vmodel", {
type = "Model",
model = "models/props_lab/reciever01a.mdl",
bone = "ValveBiped.Bip01_R_Finger2",
rel = "",
pos = Vector(2.2, 6.5, -1),
angle = Angle(120, 10, 0),
size = Vector(0.6, 0.6, 0.6),
color = Color(255, 255, 255, 255),
surpresslightning = false,
material = "",
skin = 0,
bodygroup = {},
})

self:AddCustomWorldModel("wmodel", {
type = "Model",
model = "models/props_lab/reciever01a.mdl",
bone = "ValveBiped.Bip01_R_Hand",
rel = "",
pos = Vector(6.7, 7, -1),
angle = Angle(-60, 35, 0),
size = Vector(0.6, 0.6, 0.6),
color = Color(255, 255, 255, 255),
surpresslightning = false,
material = "",
skin = 0,
bodygroup = {},
})

self.BaseClass.Initialize(self)
end

---
Expand All @@ -148,18 +170,4 @@ if CLIENT then
RunConsoleCommand("lastinv")
end
end

---
-- @realm client
function SWEP:DrawWorldModel()
if IsValid(self:GetOwner()) then
return
end

self:DrawModel()
end

---
-- @realm client
function SWEP:DrawWorldModelTranslucent() end
end
31 changes: 19 additions & 12 deletions gamemodes/terrortown/entities/weapons/weapon_ttt_binoculars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ end

DEFINE_BASECLASS("weapon_tttbase")

SWEP.HoldType = "normal"
SWEP.HoldType = "camera"

if CLIENT then
SWEP.PrintName = "binoc_name"
SWEP.Slot = 7

SWEP.ShowDefaultViewModel = false
SWEP.ShowDefaultWorldModel = false

SWEP.EquipMenuData = {
type = "item_weapon",
Expand Down Expand Up @@ -281,19 +282,25 @@ if CLIENT then
function SWEP:Initialize()
self:AddTTT2HUDHelp("binoc_help_pri", "binoc_help_sec")
self:AddHUDHelpLine("binoc_help_reload", Key("+reload", "R"))
cv_thickness = GetConVar("ttt_crosshair_thickness")

return BaseClass.Initialize(self)
end

---
-- @ignore
function SWEP:DrawWorldModel()
if IsValid(self:GetOwner()) then
return
end
cv_thickness = GetConVar("ttt_crosshair_thickness")

self:DrawModel()
self:AddCustomWorldModel("wmodel", {
type = "Model",
model = "models/Items/combine_rifle_cartridge01.mdl",
bone = "ValveBiped.Bip01_R_Hand",
rel = "",
pos = Vector(4, 5, 0),
angle = Angle(0, 80, -20),
size = Vector(0.7, 0.7, 0.7),
color = Color(255, 255, 255, 255),
surpresslightning = false,
material = "",
skin = 0,
bodygroup = {},
})

self.BaseClass.Initialize(self)
end

---
Expand Down
4 changes: 2 additions & 2 deletions gamemodes/terrortown/entities/weapons/weapon_ttt_c4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ SWEP.WeaponID = AMMO_C4
SWEP.builtin = true

SWEP.UseHands = true
SWEP.ViewModel = Model("models/weapons/cstrike/c_c4.mdl")
SWEP.WorldModel = Model("models/weapons/w_c4.mdl")
SWEP.ViewModel = "models/weapons/cstrike/c_c4.mdl"
SWEP.WorldModel = "models/weapons/w_c4.mdl"

SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
Expand Down
72 changes: 39 additions & 33 deletions gamemodes/terrortown/entities/weapons/weapon_ttt_cse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ end

DEFINE_BASECLASS("weapon_tttbase")

SWEP.HoldType = "normal"
SWEP.HoldType = "grenade"

if CLIENT then
SWEP.PrintName = "vis_name"
SWEP.Slot = 6

SWEP.ViewModelFOV = 10
SWEP.ViewModelFOV = 70
SWEP.ViewModelFlip = false

SWEP.UseHands = true
SWEP.ShowDefaultViewModel = false
SWEP.ShowDefaultWorldModel = false

SWEP.EquipMenuData = {
type = "item_weapon",
desc = "vis_desc",
Expand All @@ -27,8 +31,8 @@ end

SWEP.Base = "weapon_tttbase"

SWEP.ViewModel = Model("models/weapons/v_crowbar.mdl")
SWEP.WorldModel = Model("models/Items/battery.mdl")
SWEP.ViewModel = "models/weapons/cstrike/c_eq_fraggrenade.mdl"
SWEP.WorldModel = "models/Items/battery.mdl"

SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
Expand Down Expand Up @@ -103,27 +107,43 @@ function SWEP:Reload()
return false
end

---
-- @ignore
function SWEP:OnRemove()
if SERVER then
return
end

local owner = self:GetOwner()

if IsValid(owner) and owner == LocalPlayer() and owner:Alive() then
RunConsoleCommand("lastinv")
end
end

if CLIENT then
---
-- @ignore
function SWEP:Initialize()
self:AddTTT2HUDHelp("vis_help_pri")

return BaseClass.Initialize(self)
self:AddCustomViewModel("vmodel", {
type = "Model",
model = "models/Items/battery.mdl",
bone = "ValveBiped.Bip01_R_Finger2",
rel = "",
pos = Vector(1.5, 1.5, 2.7),
angle = Angle(180, 20, 0),
size = Vector(0.65, 0.65, 0.65),
color = Color(255, 255, 255, 255),
surpresslightning = false,
material = "",
skin = 0,
bodygroup = {},
})

self:AddCustomWorldModel("wmodel", {
type = "Model",
model = "models/Items/battery.mdl",
bone = "ValveBiped.Bip01_R_Hand",
rel = "",
pos = Vector(3.2, 2.5, 2.7),
angle = Angle(180, -100, 0),
size = Vector(0.65, 0.65, 0.65),
color = Color(255, 255, 255, 255),
surpresslightning = false,
material = "",
skin = 0,
bodygroup = {},
})

self.BaseClass.Initialize(self)
end

---
Expand All @@ -135,18 +155,4 @@ if CLIENT then
RunConsoleCommand("lastinv")
end
end

---
-- @realm client
function SWEP:DrawWorldModel()
if IsValid(self:GetOwner()) then
return
end

self:DrawModel()
end

---
-- @realm client
function SWEP:DrawWorldModelTranslucent() end
end
Loading

0 comments on commit 982f898

Please sign in to comment.