Skip to content

Commit

Permalink
formatted code
Browse files Browse the repository at this point in the history
  • Loading branch information
mexikoedi committed Jan 5, 2024
1 parent a673500 commit 803e5f6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 38 deletions.
14 changes: 1 addition & 13 deletions lua/autorun/sh_batarang_convars.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
if engine.ActiveGamemode() ~= "terrortown" then return end

-- convars added with default values
CreateConVar("ttt_batarang_primary_sound", "1", {FCVAR_REPLICATED, FCVAR_ARCHIVE, FCVAR_NOTIFY}, "Sound of the primary attack")

CreateConVar("ttt_batarang_hit_sound", "1", {FCVAR_REPLICATED, FCVAR_ARCHIVE, FCVAR_NOTIFY}, "Sound of the hit")

CreateConVar("ttt_batarang_automaticFire", "0", {FCVAR_REPLICATED, FCVAR_ARCHIVE, FCVAR_NOTIFY}, "Enable automatic fire")

CreateConVar("ttt_batarang_damage", "150", {FCVAR_REPLICATED, FCVAR_ARCHIVE, FCVAR_NOTIFY}, "Damage dealt on impact")

CreateConVar("ttt_batarang_ammo", "3", {FCVAR_REPLICATED, FCVAR_ARCHIVE, FCVAR_NOTIFY}, "Default ammo the batarang has when bought")

CreateConVar("ttt_batarang_clipSize", "3", {FCVAR_REPLICATED, FCVAR_ARCHIVE, FCVAR_NOTIFY}, "Clipsize of the batarang")

CreateConVar("ttt_batarang_rps", "0.4", {FCVAR_REPLICATED, FCVAR_ARCHIVE, FCVAR_NOTIFY}, "Shots per second")

hook.Add("TTTUlxInitCustomCVar", "TTTBatarangInitRWCVar", function(name)
ULib.replicatedWritableCvar("ttt_batarang_primary_sound", "rep_ttt_batarang_primary_sound", GetConVar("ttt_batarang_primary_sound"):GetBool(), true, false, name)
ULib.replicatedWritableCvar("ttt_batarang_hit_sound", "rep_ttt_batarang_hit_sound", GetConVar("ttt_batarang_hit_sound"):GetBool(), true, false, name)
Expand All @@ -28,10 +20,7 @@ end)
if CLIENT then
-- Use string or string.format("%.f",<steamid64>)
-- addon dev emblem in scoreboard
hook.Add("TTT2FinishedLoading", "TTT2RegistermexikoediAddonDev", function()
AddTTT2AddonDev("76561198279816989")
end)

hook.Add("TTT2FinishedLoading", "TTT2RegistermexikoediAddonDev", function() AddTTT2AddonDev("76561198279816989") end)
hook.Add("TTTUlxModifyAddonSettings", "TTTBatarangModifySettings", function(name)
local tttrspnl = xlib.makelistlayout{
w = 415,
Expand All @@ -48,7 +37,6 @@ if CLIENT then
tttrslst1:SetPos(5, 25)
tttrslst1:SetSize(390, 180)
tttrslst1:SetSpacing(5)

tttrslst1:AddItem(xlib.makecheckbox{
label = "ttt_batarang_primary_sound (Def. 1)",
repconvar = "rep_ttt_batarang_primary_sound",
Expand Down
3 changes: 1 addition & 2 deletions lua/entities/ent_ttt_ttt2_batarang/cl_init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
if engine.ActiveGamemode() ~= "terrortown" then return end
include("shared.lua")

function ENT:Initialize()
end

Expand All @@ -9,4 +8,4 @@ end

function ENT:Draw()
self:DrawModel()
end
end
8 changes: 1 addition & 7 deletions lua/entities/ent_ttt_ttt2_batarang/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ AddCSLuaFile()
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")

function ENT:Initialize()
self:SetModel("models/rottweiler/batarang_thrown.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
Expand All @@ -13,10 +12,8 @@ function ENT:Initialize()
util.PrecacheSound("weapons/batarang/hit1.wav")
util.PrecacheSound("weapons/batarang/hit2.wav")
util.PrecacheSound("weapons/batarang/hit3.wav")

if GetConVar("ttt_batarang_hit_sound"):GetBool() then
self.Hit = {Sound("physics/metal/sawblade_stick1.wav"), Sound("physics/metal/sawblade_stick2.wav"), Sound("physics/metal/sawblade_stick3.wav")}

self.FleshHit = {Sound("weapons/batarang/hit1.wav"), Sound("weapons/batarang/hit2.wav"), Sound("weapons/batarang/hit3.wav")}
end

Expand All @@ -25,10 +22,7 @@ end

function ENT:Think()
self.lifetime = self.lifetime or CurTime() + 20

if CurTime() > self.lifetime then
self:Remove()
end
if CurTime() > self.lifetime then self:Remove() end
end

function ENT:Disable()
Expand Down
18 changes: 2 additions & 16 deletions lua/weapons/weapon_ttt_ttt2_batarang/shared.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
if engine.ActiveGamemode() ~= "terrortown" then return end

if SERVER then
AddCSLuaFile()
resource.AddFile("materials/models/rottweiler/batarang.vmt")
Expand All @@ -13,12 +12,9 @@ SWEP.SlotPos = 2
SWEP.AmmoEnt = nil
SWEP.Icon = "vgui/entities/weapon_batarang"
SWEP.HoldType = "melee"

SWEP.CanBuy = {ROLE_DETECTIVE}

SWEP.InLoadoutFor = nil
SWEP.LimitedStock = true

SWEP.EquipMenuData = {
type = "item_weapon",
name = "Batarang",
Expand Down Expand Up @@ -48,11 +44,9 @@ SWEP.Primary.DefaultClip = GetConVar("ttt_batarang_ammo"):GetInt()
SWEP.Primary.Automatic = GetConVar("ttt_batarang_automaticFire"):GetBool()
SWEP.Primary.RPS = GetConVar("ttt_batarang_rps"):GetFloat()
SWEP.Primary.Ammo = "none"

if CLIENT then
function SWEP:GetViewModelPosition(pos, ang)
pos = pos + ang:Forward() * 4

return pos, ang
end
end
Expand All @@ -79,17 +73,12 @@ function SWEP:PrimaryAttack()
local dmg = DamageInfo()
dmg:SetAttacker(self:GetOwner())
dmg:SetInflictor(self)

if GetConVar("ttt_batarang_primary_sound"):GetBool() then
self:EmitSound("weapons/batarang/throw" .. tostring(math.random(1, 4)) .. ".wav")
end

if GetConVar("ttt_batarang_primary_sound"):GetBool() then self:EmitSound("weapons/batarang/throw" .. tostring(math.random(1, 4)) .. ".wav") end
local dm = GetConVar("ttt_batarang_damage"):GetInt()
self:ShootBullet(dm, 1, 0)
self:TakePrimaryAmmo(1)
self:GetOwner():ViewPunch(Angle(-1, 0, 0))
self:SendWeaponAnim(ACT_VM_PRIMARYATTACK)

if SERVER then
local batarang = ents.Create("ent_ttt_ttt2_batarang")
batarang:SetAngles(self:GetOwner():EyeAngles())
Expand All @@ -101,9 +90,6 @@ function SWEP:PrimaryAttack()
local phys = batarang:GetPhysicsObject()
phys:SetVelocity(self:GetOwner():GetAimVector() * 7000)
phys:AddAngleVelocity(Vector(0, 0, 90))

if self:Clip1() == 0 then
self:Remove()
end
if self:Clip1() == 0 then self:Remove() end
end
end

0 comments on commit 803e5f6

Please sign in to comment.