-
Notifications
You must be signed in to change notification settings - Fork 6
/
chef.lua
264 lines (248 loc) · 9.21 KB
/
chef.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
--Luctus' Chef
--Made with love by OverlordAkise
--This should only be an example on how this works. Do not use it in a malicious way!
local tkey = KEY_LALT --Which button should toggle everything
local pkey = KEY_9 --Button to remove everything asap (=panic)
local aimsmoothness = 0.2 --0.1 for "little help only", 1 for flick
local aimbone = "ValveBiped.Bip01_Head1" --which bone to aim on
local chef = {}
chef.specs = {}
chef.looks = {}
chef.log = {}
chef.lastShot = 0
chef.shotCount = 0
chef.recoilAcc = Angle(0,0,0)
local color_white = Color(255,255,255,255)
local color_black = Color(0,0,0,255)
local color_grey = Color(205,205,255,255)
function chef.GetTarget(ply)
local bone = ply:LookupBone(aimbone)
if bone ~= nil then
local pos, ang = ply:GetBonePosition(bone)
return pos
end
return ply:GetPos()+ply:OBBCenter()
end
function chef.ChatText(message)
print(message)
table.insert(chef.log,message)
if #chef.log > 20 then
table.remove(chef.log,1)
end
end
function chef.GetRank(ply)
if ply:IsSuperAdmin() then return "SUPERADMIN" end
if ply:GetNWString("usergroup") then return ply:GetNWString("usergroup") end
if ply:IsAdmin() then return "ADMIN" end
return "user"
end
local lastCheckToggle = 0
local isShowing = false
hook.Add("HUDPaint", "FPP_HUDPaint", function()
if input.IsKeyDown(pkey) then
hook.Remove("HUDPaint","FPP_HUDPaint")
hook.Remove("CreateMove", "Keypad")
hook.Remove("entity_killed", "RemoveEntitiesOnCleanUp")
timer.Remove("UTimeThink")
end
if lastCheckToggle < CurTime() then
if input.IsKeyDown(tkey) then isShowing = not isShowing end
lastCheckToggle = CurTime()+0.1
end
if not isShowing then return end
local me = LocalPlayer()
local scrw = ScrW()
local scrh = ScrH()
if not IsValid(me) then return end
--Chat
for k,text in ipairs(chef.log) do
draw.SimpleText(text,"Default",3,scrh/2.5-k*10,color_grey)
end
--Spectator
for k,ply in ipairs(chef.specs) do
if ply:IsValid() then
draw.SimpleText(ply:Nick(), "Default", scrw/1.3, scrh-5-k*10,color_grey)
end
end
--Lookers
for k,nick in ipairs(chef.looks) do
draw.SimpleText(nick, "Default", scrw/1.7, scrh-5-k*10, color_grey)
end
--Speed
draw.SimpleText(math.Round(me:GetVelocity():Length()), "Default", scrw/2, scrh-60, color_grey, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
--Rectangles
surface.SetDrawColor(255,255,255,255)
for k,ply in ipairs(player.GetAll()) do
if ply == me then continue end
local posfeet = ply:GetPos():ToScreen()
if not posfeet.visible then continue end
local poshead = chef.GetTarget(ply):ToScreen()
local admintext = chef.GetRank(ply)
surface.DrawLine(posfeet.x, posfeet.y, poshead.x, poshead.y)
draw.SimpleTextOutlined(ply:Name(), "Default", poshead.x, poshead.y - 20, color_grey, 1, 0, 1, color_black)
draw.SimpleTextOutlined("["..admintext.."]", "Default", posfeet.x, posfeet.y + 12, color_grey, 1, 0, 1, color_black)
end
--LOGO
surface.SetDrawColor(255, 255, 255, 255)
surface.DrawLine(5, 5, 15, 5)
surface.DrawLine(15, 5, 15, 26)
surface.DrawLine(5, 5, 5, 25)
surface.DrawLine(5, 25, 15, 25)
surface.DrawLine(5, 20, 15, 20)
surface.DrawLine(8, 5, 8, 15)
surface.DrawLine(12, 5, 12, 15)
--aim
if not input.IsMouseDown(MOUSE_RIGHT) then return end
local closest = nil
local closestDist = 999999999
local vx,vy = scrw/2,scrh/2
for k,ply in ipairs(player.GetAll()) do
if ply == me then continue end
if not me:IsLineOfSightClear(ply) then continue end
local d2 = ply:EyePos():ToScreen()
if not d2.visible then continue end
local dist = math.sqrt((vx-d2.x)^2+(vy-d2.y)^2)
if dist < closestDist then
closestDist = dist
closest = chef.GetTarget(ply)
end
end
if chef.lastShot+0.5 < CurTime() then
chef.shotCount = 0
chef.recoilAcc = Angle(0,0,0)
end
if closest and IsValid(me:GetActiveWeapon()) and me:GetActiveWeapon().canaim then
me:SetEyeAngles(LerpAngle(aimsmoothness,me:LocalEyeAngles(),(closest - me:GetShootPos()):Angle()-chef.recoilAcc))
end
end)
hook.Add("CreateMove", "Keypad", function(cmd)
if bit.band(cmd:GetButtons(),IN_JUMP) ~= 0 and not LocalPlayer():IsOnGround() then
cmd:SetButtons(bit.band(cmd:GetButtons(),bit.bnot(IN_JUMP)))
end
end)
gameevent.Listen("entity_killed")
hook.Add("entity_killed", "RemoveEntitiesOnCleanUp", function(data)
local attacker_index = data.entindex_attacker
local victim_index = data.entindex_killed
local ply = "nobody?"
local atk = "the map"
local wep = "unknown weapon"
local inflictor = ents.GetByIndex(data.entindex_inflictor)
for _, p in ipairs(player.GetHumans()) do
if p:EntIndex() == victim_index then
ply = p:Nick()
end
if p:EntIndex() == attacker_index then
atk = p:Nick()
if p:GetActiveWeapon() and p:GetActiveWeapon():IsValid() then
wep = p:GetActiveWeapon():GetPrintName()
end
end
end
if attacker_index == victim_index then chef.ChatText(ply.." necked himself") return end
if inflictor:IsValid() and inflictor:GetClass() == "prop_physics" then
chef.ChatText(ply.." got crushed by a prop!")
end
chef.ChatText(atk.." killed "..ply.." with a "..wep)
end)
local MaxViewAng = math.cos(math.rad(45))
timer.Create("UTimeThink",1,0,function()
--lookers
chef.looks = {}
local me = LocalPlayer()
local myeyes = me:EyePos()
for k,ply in ipairs(player.GetAll()) do
if ply == me then continue end
local Trace = {}
Trace.start = myeyes
Trace.endpos = ply:EyePos()
Trace.filter = {ply,me}
TraceRes = util.TraceLine(Trace)
if TraceRes.Hit then continue end --block vision
if ply:EyeAngles():Forward():Dot(me:EyePos() - ply:EyePos()) > MaxViewAng then
if not table.HasValue(chef.looks, ply:Nick()) then
table.insert(chef.looks, ply:Nick())
end
end
end
--Spectator
for k,ply in ipairs(player.GetHumans()) do
if ply:GetObserverTarget() and ply:GetObserverTarget() == me and not table.HasValue(chef.specs, ply) then
chef.ChatText(ply:Nick().." has begun spectating you!")
table.insert(chef.specs, ply)
end
end
--Spectator 2
for k,ply in ipairs(chef.specs) do
if not IsValid(ply) then table.remove(chef.specs, k) continue end
if (not ply:GetObserverTarget()) or ply:GetObserverTarget() ~= me then
chef.ChatText(ply:Nick().." has stopped spectating you!")
table.remove(chef.specs, k)
end
end
--Weapon no kick up
local wep = me:GetActiveWeapon()
if wep and IsValid(wep) then
if not wep.cCooked then
chef.CookWeapon(wep,me)
end
end
end)
function chef.CookWeapon(wep,ply)
wep.cCooked = true
local class = wep:GetClass()
if string.StartWith(class,"cw_") then
wep.canaim = true
wep.Primary.Recoil = 0
wep.oldRecoil = wep.Recoil
wep.Recoil = 0
wep.MakeRecoil = function()end
wep.simulateRecoil = function()end
wep.addFireSpread = function()end
wep.oldPA = wep.PrimaryAttack
function wep:PrimaryAttack()
wep:oldPA()
ply:ViewPunchReset(9999)
chef.lastShot = CurTime()
if chef.shotCount > 4 then return end
chef.shotCount = chef.shotCount + 1
chef.recoilAcc = chef.recoilAcc + Angle(-self.oldRecoil * 1.25 * self:GetRecoilModifier(), 0, 0)
end
elseif string.StartWith(class,"fas2_") then
wep.canaim = true
wep.oldViewKick = wep.ViewKick
wep.ViewKick = 0
wep.Recoil = 0
wep.AimRecoil = function()end
wep.HipRecoil = function()end
wep.Recoil = function()end
function wep:AimRecoil()
ply:ViewPunchReset(9999)
chef.lastShot = CurTime()
if chef.shotCount > 2 then return end
chef.shotCount = chef.shotCount + 1
mod = ply:Crouching() and 0.75 or 1
chef.recoilAcc = chef.recoilAcc + (Angle(-wep.oldViewKick, wep.oldViewKick * math.Rand(-0.2475, 0.2475), 0) * (1 + wep.AddSpread * (wep.SpreadToRecoil and wep.SpreadToRecoil or 1)) * mod * (wep.dt.Bipod and 0.3 or 1))
end
elseif string.StartWith(class,"m9k_") then
wep.canaim = true
wep.Primary.KickDown = 0
wep.Primary.KickUp = 0
wep.Primary.KickHorizontal = 0
wep.oldShootBullet = wep.ShootBullet
wep.ShootBullet = function(damage, recoil, num_bullets, aimcone)
wep.oldShootBullet(damage,recoil,num_bullets,aimcone)
ply:ViewPunchReset()
ply:SetEyeAngles(ply:EyeAngles())
end
elseif string.StartWith(class,"tfa_") then
wep.canaim = true
local orgRecoil = wep.Recoil
wep.Recoil = function (recoil, ifp)
ply:ViewPunchReset()
orgRecoil(recoil, ifp)
return
end
end
end
print("// chef v1.1 is cooking //")