· 6 months ago · Mar 21, 2025, 04:20 PM
1AddCSLuaFile()
2AddCSLuaFile("von.lua")
3include("von.lua")
4
5AddCSLuaFile("sans_shared.lua")
6include("sans_shared.lua")
7
8AddCSLuaFile("s_mathematics.lua")
9include( "s_mathematics.lua" )
10
11SWEP.Base = "weapon_base"
12SWEP.PrintName = "Sans' Abilities"
13SWEP.Purpose = "You're gonna have a BAD 15 minutes."
14SWEP.Slot = 1
15SWEP.SlotPos = 2
16SWEP.Spawnable = false
17SWEP.AdminSpawnable = false
18SWEP.AdminOnly = false
19SWEP.Category = "Glitchtale"
20
21SWEP.ViewModel = "models/koperplyar/sans/vm.mdl"
22SWEP.WorldModel = ""
23SWEP.UseHands = true
24
25SWEP.Primary.Automatic = true
26SWEP.Primary.Ammo = "none"
27SWEP.Primary.ClipSize = 0
28SWEP.Primary.DefaultClip = 0
29
30SWEP.Secondary.Automatic = true
31SWEP.Secondary.Ammo = "none"
32SWEP.Secondary.ClipSize = 0
33SWEP.Secondary.DefaultClip = 0
34
35SWEP.HoldType = "normal"
36SWEP.DrawCrosshair = true
37
38if CLIENT then
39 SWEP.WepSelectIcon = surface.GetTextureID("weapons/vgui/gtsansabilities")
40 killicon.Add( "glitchtale_sans", "weapons/vgui/telekinesisspikedboneorblaster", color_white )
41end
42
43SWEP.VElements = {
44 ["1"] = { type = "Sprite", sprite = "sprites/physcannon_blueglow", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(3,1,0), size={x=20,y=20}, color = Color(255, 255, 255), nocull = true, additive = true, vertexalpha = true, vertexcolor = true, ignorez = false},
45 ["2"] = { type = "Sprite", sprite = "sprites/physcannon_blueglow", bone = "ValveBiped.Bip01_L_Hand", rel = "", pos = Vector(2,1,0), size={x=20,y=20}, color = Color(255, 255, 255), nocull = true, additive = true, vertexalpha = true, vertexcolor = true, ignorez = false}
46}
47
48SWEP.WElements = {
49 ["1"] = { type = "Sprite", sprite = "sprites/physcannon_blueglow", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(2.986, 0.439, 0), size = { x = 20, y = 20 }, color = Color(255, 255, 255, 255), nocull = true, additive = true, vertexalpha = true, vertexcolor = true, ignorez = false},
50 ["1+"] = { type = "Sprite", sprite = "sprites/physcannon_blueglow", bone = "ValveBiped.Bip01_L_Hand", rel = "", pos = Vector(2.986, 0.439, 0), size = { x = 20, y = 20 }, color = Color(255, 255, 255, 255), nocull = true, additive = true, vertexalpha = true, vertexcolor = true, ignorez = false}
51}
52
53local secondarydelaybt = 0
54
55local selecteds
56local tpstopsv
57
58local d = 0
59local cooked = 0
60
61function SWEP:Initialize()
62 if ( SERVER ) then
63
64 util.AddNetworkString( "gbresetcount" )
65
66 util.AddNetworkString( "teleportnownet" )
67 util.AddNetworkString("tpeffects")
68 util.AddNetworkString("tpeffects_everybody_can_see")
69 util.AddNetworkString("tpeffects_everybody_can_seeCL")
70 util.AddNetworkString("tpbeforeeffects")
71 util.AddNetworkString("tpselectedtoserver")
72 util.AddNetworkString("tpclose")
73 util.AddNetworkString("tpclose_reclient")
74
75 util.AddNetworkString("gb_updateclientside")
76
77
78 util.AddNetworkString("gbaddtotable")
79 util.AddNetworkString("gbnotdrivinganymore")
80 util.AddNetworkString("gbdrivingupdateclient" .. tostring(self))
81
82 --util.AddNetworkString("shieldeffectso")
83
84 util.AddNetworkString("TeleEntity")
85 util.AddNetworkString("UnTeleEntity")
86
87 --util.AddNetworkString("dtsword_dropasoul")
88
89 util.AddNetworkString( "miss" )
90
91 end
92
93 self:SetNWInt("Stre",0)
94 self:SetNWInt("Tele",0)
95 self:SetNWInt("D",0)
96
97 --self.wantedfarness = victim:GetPos()
98 self.wantedfarness = nil
99 self.secondarytoggle = 0
100 self:SetHoldType("normal")
101 secondarydelaybt = 0
102 self.Blasters = {}
103 self.Blasters_cl = {}
104 self.Shield = {}
105 self.Blastercount = 0
106 self.Victima = nil
107
108 self.AmIDrivingVehicle = nil
109 self.AmIDriving = nil
110
111 self.telekanisisstage = 0
112
113 self.panel = nil
114
115 self.primocc = 0
116 self.primaryattackoffi = 0
117
118 self.primstab = 0
119
120 self.Owner.Shielding = 0
121
122 self.noteleport = 0
123
124 self.secocc = 0
125
126 self.secondarytoggle = 0
127
128 --self.DMGboost = 0
129
130 --self.BoostupC = nil
131
132 self.zahealu = nil
133
134 hook.Add( "EntityTakeDamage", "Dodge", function( ent, dmginfo )
135 if( ent:IsPlayer() && ent:Health() > 0 ) then
136 if( ent:GetActiveWeapon():IsValid() && ent:GetVar( "miss", NULL ) != NULL ) then
137 if( CurTime() >= ent:GetVar( "miss", NULL ) ) then
138 if( ent:GetActiveWeapon():GetClass() == "glitchtale_sans" ) then
139
140 if not(dmginfo:IsDamageType(DMG_BURN + DMG_VEHICLE + DMG_FALL + DMG_BLAST + DMG_DROWN + DMG_RADIATION))then
141 --net.Start( "miss" )
142 --net.WriteEntity( ent )
143 --local dmgpos = dmginfo:GetDamagePosition()
144 --if( dmgpos != Vector() ) then
145 --net.WriteVector( dmgpos )
146 --else
147 --net.WriteVector( ent:EyePos() )
148 --end
149 --net.Broadcast()
150
151 --if not(dmginfo:IsDamageType(DMG_BURN))then
152
153 --else
154
155 --end
156
157 local d=self:GetNWInt("D")
158 if d>0||self.Tired then return end
159
160 if not(dmginfo:IsDamageType(DMG_PARALYZE))then
161 self:SetNWInt("Stre",math.Clamp(self:GetNWInt("Stre")+10.33,0,GetConVarNumber("gt_sans_sr")))
162 else
163 self:SetNWInt("Stre",math.Clamp(self:GetNWInt("Stre")+100,0,GetConVarNumber("gt_sans_sr")))
164 end
165
166 local s=self.Owner:GetModelScale()
167 GT_MissEffect(self.Owner:EyePos()+Vector(0,0,10*s),32*s,2)
168
169
170 ent:SetVar( "miss", CurTime() + 0.43 )
171 self:SetNWInt("D",0.43)
172
173 self.primocc = CurTime() + 0.53
174 self.secocc = CurTime() + 0.53
175 teleoc = CurTime() + 0.53
176 stabocc = CurTime() + 0.53
177
178
179 local entPos = ent:GetPos()
180 local att = ent
181 local newPos = ent:GetRight()*math.random(-69.3, 69.3)+entPos
182 ent:SetPos(newPos)
183
184
185 timer.Create("resetview",.001,1,function()
186 if IsValid(self.Owner)then
187 self.Owner:ViewPunchReset()
188 self.Owner:ConCommand("gt_unstuck")
189 else
190 return false
191 end
192 end)
193
194 dmginfo:SetDamage( 0 )
195 dmginfo:SetDamageForce( Vector( 0, 0, 0 ) )
196 dmginfo:SetDamageType( 0 )
197 dmginfo:SetDamageBonus( 0 )
198
199 local dodgeranduma = math.random(1,6)
200
201 if(dodgeranduma == 1)then
202 ent:EmitSound( Sound( "Weapon_Crowbar.Single" ), 75, math.random(80,100), 1, CHAN_AUTO )
203
204 elseif(dodgeranduma == 2)then
205 ent:EmitSound( Sound( "weapons/stunstick/stunstick_swing1.wav" ), 75, math.random(80,100), 1, CHAN_AUTO )
206
207 elseif(dodgeranduma == 3)then
208 ent:EmitSound( Sound( "weapons/stunstick/stunstick_swing2.wav" ), 75, math.random(80,100), 1, CHAN_AUTO )
209
210 elseif(dodgeranduma == 4)then
211 ent:EmitSound( Sound( "npc/vort/claw_swing1.wav" ), 75, math.random(80,100), 1, CHAN_AUTO )
212
213 elseif(dodgeranduma == 5)then
214 ent:EmitSound( Sound( "npc/vort/claw_swing2.wav" ), 75, math.random(80,100), 1, CHAN_AUTO )
215
216 elseif(dodgeranduma == 6)then
217 ent:EmitSound( Sound( "weapons/iceaxe/iceaxe_swing1.wav" ), 75, math.random(80,100), 1, CHAN_AUTO )
218 end
219 end
220 end
221 end
222 end
223 end
224 end)
225
226 if CLIENT then
227
228 -- Create a new table for every weapon instance
229 self.VElements = table.FullCopy( self.VElements )
230 self.WElements = table.FullCopy( self.WElements )
231 self.ViewModelBoneMods = table.FullCopy( self.ViewModelBoneMods )
232
233 self:CreateModels(self.VElements) -- create viewmodels
234 self:CreateModels(self.WElements) -- create worldmodels
235
236 -- init view model bone build function
237 if IsValid(self.Owner) then
238 local vm = self.Owner:GetViewModel()
239 if IsValid(vm) then
240 self:ResetBonePositions(vm)
241
242 -- Init viewmodel visibility
243 if (self.ShowViewModel == nil or self.ShowViewModel) then
244 vm:SetColor(Color(255,255,255,255))
245 else
246 -- we set the alpha to 1 instead of 0 because else ViewModelDrawn stops being called
247 vm:SetColor(Color(255,255,255,1))
248 -- ^ stopped working in GMod 13 because you have to do Entity:SetRenderMode(1) for translucency to kick in
249 -- however for some reason the view model resets to render mode 0 every frame so we just apply a debug material to prevent it from drawing
250 vm:SetMaterial("Debug/hsv")
251 end
252 end
253 end
254
255 end
256end
257
258if( CLIENT ) then
259 net.Receive( "miss", function()
260 local ply = net.ReadEntity()
261 local vec = net.ReadVector()
262 --print( ply, vec )
263
264 local emitter = ParticleEmitter( vec, false )
265
266 local particle = emitter:Add( Material( "undertale/miss" ), vec )
267 if( particle ) then
268 particle:SetVelocity( Vector( 0, 0, 10 ) )
269 particle:SetColor( 255, 255, 255 )
270 particle:SetLifeTime( 0 )
271 particle:SetDieTime( 2 )
272 particle:SetStartSize( 10 )
273 particle:SetEndSize( 10 )
274 particle:SetStartAlpha( 255 )
275 particle:SetEndAlpha( 0 )
276 particle:SetGravity( Vector( 0, 0, 0 ) )
277 end
278
279 emitter:Finish()
280 end )
281end
282
283if CLIENT then
284 local teledEntities = {}
285
286 net.Receive("TeleEntity", function()
287 local ent = net.ReadEntity()
288 teledEntities[ent] = true
289 end)
290
291 net.Receive("UnTeleEntity", function()
292 local ent = net.ReadEntity()
293 if teledEntities[ent] then
294 teledEntities[ent] = nil
295 end
296 end)
297
298 hook.Add("PreDrawHalos", "AddHalosToteledEntitiesSanesss", function()
299 halo.Add(table.GetKeys(teledEntities), Color(0, 155, 255), 5, 5, 2, true, false)
300 end)
301
302
303end
304
305function SWEP:Deploy()
306
307 self:SendWeaponAnim( 174 )
308
309 return true
310end
311
312function SWEP:OnDrop( )
313 if(self.Owner:GetModel() == "models/sansplayer/sansplayer.mdl") then
314 self.Owner:SetBodygroup( 1, 0 )
315 self.Owner:SetBodygroup( 2, 0 )
316 end
317
318 if(self.Owner:GetModel() == "models/nia/sans_pm.mdl") then
319 self.Owner:SetBodygroup( 2, 0 )
320 end
321
322end
323
324function SWEP:Holster( wep )
325
326 if CLIENT and IsValid(self.Owner) then
327 local vm = self.Owner:GetViewModel()
328 if IsValid(vm) then
329 self:ResetBonePositions(vm)
330 end
331 end
332
333 if( CLIENT ) then return end
334
335 if( !IsFirstTimePredicted() ) then return end
336
337 self.Owner:DoAnimationEvent( ACT_GMOD_IN_CHAT )
338 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_R_Clavicle" ), Angle( 0, 0, 0 ) )
339 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_L_Clavicle" ), Angle( 0, 0, 0 ) )
340 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_R_Forearm" ), Angle( 0, 0, 0 ) )
341 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_L_Forearm" ), Angle( 0, 0, 0 ) )
342 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_R_Hand" ), Angle( 0, 0, 0 ) )
343 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_L_Hand" ), Angle( 0, 0, 0 ) )
344 self:SetVar( "anim_reset", true )
345
346 if(self.Owner:GetModel() == "models/sansplayer/sansplayer.mdl") then
347 self.Owner:SetBodygroup( 1, 0 )
348 self.Owner:SetBodygroup( 2, 0 )
349 end
350
351 if(self.Owner:GetModel() == "models/nia/sans_pm.mdl") then
352 self.Owner:SetBodygroup( 2, 0 )
353 end
354
355 return true
356end
357
358function SWEP:Equip()
359 self.Owner:SetVar( "miss", 0 )
360end
361
362local newposition = Vector(0,0,0)
363
364local pdelay = 4
365local pocc = 0
366
367local primdelay = 0.2
368
369local gasterblastercount = 0
370local secdelay = 3
371
372local altctrlnextOccurance = 0
373local altctrldelay = 8
374
375local saocc = 0
376local sadelay = 0.3
377local istpreallyowner
378
379local tddelay = 0.5
380local tdocc = 0
381
382local stabdelay = 0.75
383local stabocc = 0
384
385local rdelay = 0.2
386local rocc = 0
387
388SWEP.NextAtt=CurTime()
389
390function SWEP:PrimaryAttack()
391
392 local primtimleft = self.primocc - CurTime()
393 local primtimstableft = self.primstab - CurTime()
394 if primtimleft < 0 then
395
396 if(self.Owner.Shielding == 1) then return end
397
398 if IsValid(self.Victima) then if primtimstableft < 0 then self:PiercingBones() self.primstab = CurTime() + 3 end return end
399
400 if self.NextAtt>CurTime()||self.Tired then return end
401
402 if self.AmIDriving == 1 then return end
403
404 if self.primaryattackoffi == 0 then
405
406 self:SetHoldType("pistol")
407
408 self:SendWeaponAnim(179)
409
410 timer.Create("settoprimaryidle" .. tostring(self),0.5,1,function()
411 if(IsValid(self))then
412 if(self.primaryattackoffi == 1)then
413 self:SendWeaponAnim(180)
414 end
415 end
416 end)
417
418 self.primaryattackoffi = 1
419 end
420
421 timer.Remove("primaryattackoff" .. tostring(self))
422 timer.Create("primaryattackoff" .. tostring(self),0.3,1,function()
423 if(IsValid(self))then
424 self:SetHoldType("normal")
425
426 self:SendWeaponAnim(181)
427
428 timer.Create("primbacktoidle" .. tostring(self),1,1,function()
429 if(IsValid(self))then
430 if(self.primaryattackoffi == 0)then
431 self:SendWeaponAnim(174)
432 end
433 end
434 end)
435
436 self.primaryattackoffi = 0
437 end
438 end)
439
440 self:SetNWInt("Stre",math.Clamp(self:GetNWInt("Stre")+2.43,0,GetConVarNumber("gt_sans_sr")))
441
442 if(SERVER)then
443
444 local ent = ents.Create( "ent_glitchtale_bone" )
445
446 local pos = self.Owner:GetShootPos() + VectorRand() * 59 + self.Owner:EyeAngles():Right() * 1
447
448 ent:SetPos( pos )
449 ent:SetAngles( ( self.Owner:GetEyeTrace().HitPos - pos ):Angle() + Angle( 90, 0, 0 ) )
450 ent:EmitSound( Sound( "undertale/bone_end.wav" ), 53, 100, 1, CHAN_AUTO )
451 ent:SetOwner( self.Owner )
452 ent:Spawn()
453 ent:Activate()
454
455 --local phys = ent:GetPhysicsObject()
456 --phys:SetVelocity( ent:GetUp() * math.random(1500,2000) ) --og
457
458 local phys = ent:GetPhysicsObject()
459 phys:SetVelocity( ent:GetUp() * math.random(5000,4500) ) --new, adjusted to j. hall (I mean, monster attacks cant do kilometers, right?)
460
461 --local phys = ent:GetPhysicsObject()
462 --phys:SetVelocity( ent:GetUp() * 10000 ) --undertale sans abilities
463
464 end
465
466 self.primocc = CurTime() + primdelay
467 end
468
469end
470
471
472function SWEP:SecondaryAttack()
473
474 local sectimleft = self.secocc - CurTime()
475 if sectimleft < 0 then
476
477 if(self.Owner.Shielding == 1) then return end
478
479 if self.NextAtt>CurTime()||self.Tired then return end
480
481 if not (self.Owner:KeyDown(IN_SPEED)) then
482 if not (self.Owner:KeyDown(IN_DUCK)) then
483 -- Normal Blaster spawn
484 if self.secondarytoggle == 0 then
485 if (self.Blastercount < 7) then
486 self:SetHoldType("melee")
487 self:SendWeaponAnim(182)
488 self.secocc = CurTime() + 0.45
489
490 self:SetNWInt("Stre", math.Clamp(self:GetNWInt("Stre") + 2.6, 0, GetConVarNumber("gt_sans_sr")))
491 self.Blastercount = self.Blastercount + 1
492
493 if (SERVER) then
494 local ent1 = ents.Create("ent_glitchtale_gaster_blaster")
495 local pos1 = self.Owner:GetPos()
496
497 ent1:SetAngles((self.Owner:GetEyeTrace().HitPos - pos1):Angle())
498 ent1:SetPos(self.Owner:GetPos() + Vector(0, 0, 45) + self.Owner:GetForward() * 50)
499 ent1:SetOwner(self.Owner)
500 ent1:Spawn()
501 ent1:Activate()
502
503 ent1:SetCount(self.Blastercount)
504
505 table.insert(self.Blasters, ent1)
506
507 ent1:CallOnRemove("chrRemoveFromList", function(ent1)
508 if IsValid(self) then
509 table.RemoveByValue(self.Blasters, ent1)
510 end
511 end)
512 end
513
514 timer.Create("secidletimer" .. tostring(self), 0.6, 1, function()
515 if not (IsValid(self)) then return end
516 self.secondarytoggle = 1
517 end)
518 end
519 end
520 else
521
522 -- Crouching Blaster spawn
523 if (SERVER) then
524 local eyeTrace = self.Owner:GetEyeTrace() -- Get player's aim trace
525
526 -- Check if the traced target is a valid entity (not the world) and within 6666 units (memo: its double in phase 2 and gaster has it on 7777)
527 if not eyeTrace.Hit or not IsValid(eyeTrace.Entity) or eyeTrace.HitWorld or self.Owner:GetPos():Distance(eyeTrace.HitPos) > 6666 then
528 self.secocc = CurTime() + 0.3 --(or 1.3)
529 return -- Do not spawn if the target is invalid or too far
530 end
531
532 -- Running Blaster spawn
533 self:SetHoldType("melee")
534 self:SendWeaponAnim(182)
535
536 timer.Create("waitbeforebluorgh2", 0.8, 1, function()
537 self:SendWeaponAnim(183)
538 self:SetHoldType("pistol")
539 end)
540
541 timer.Create("backtonormalI2", 2.3, 1, function()
542 if (IsValid(self)) then
543 self:SendWeaponAnim(174)
544 self:SetHoldType("normal")
545 self.secondarytoggle = 0
546 end
547 end)
548
549 self.secocc = CurTime() + 10
550 self:SetNWInt("Stre", math.Clamp(self:GetNWInt("Stre") + 13, 0, GetConVarNumber("gt_sans_sr")))
551
552 local entC = ents.Create("ent_glitchtale_gaster_blaster_homing")
553 local ownerPos = self.Owner:GetPos()
554 local targetPos = eyeTrace.HitPos -- Target position
555
556 -- Generate a randomized direction
557 local v = VectorRand()
558 if v.z < 0 then v.z = 0 end
559
560 -- Apply random force scaling (adjust as needed)
561 local p = Vector(v.x, v.y, v.z) * math.random(3, 773) --should be around 1333 for Gaster
562
563 -- Perform a trace check to adjust position
564 local t = util.TraceLine({
565 start = targetPos + Vector(0, 0, 60),
566 endpos = targetPos + Vector(0, 0, 60) + p,
567 filter = self.Owner
568 })
569
570 if t.Hit then
571 p = t.HitPos + t.HitNormal * 30
572 else
573 p = targetPos + Vector(0, 0, math.random(-10,60)) + p
574 end
575
576 -- Additional positioning adjustment
577 p = p + Vector(0, 0, math.random(40,140))
578
579 -- Set final position and orientation
580 entC:SetPos(p)
581 entC:SetAngles((targetPos - p):Angle())
582 entC:SetOwner(self.Owner)
583 entC:SetBlasterTarget(eyeTrace.Entity)
584 entC:Spawn()
585 entC:Activate()
586 end
587
588 end
589 else
590 -- Running Blaster spawn
591 self:SetHoldType("melee")
592 self:SendWeaponAnim(182)
593
594 timer.Create("waitbeforebluorgh", 0.8, 1, function()
595 self:SendWeaponAnim(183)
596 self:SetHoldType("pistol")
597 end)
598
599 timer.Create("backtonormalI", 2.3, 1, function()
600 if (IsValid(self)) then
601 self:SendWeaponAnim(174)
602 self:SetHoldType("normal")
603 self.secondarytoggle = 0
604 end
605 end)
606
607 self.secocc = CurTime() + 6.66
608 self:SetNWInt("Stre", math.Clamp(self:GetNWInt("Stre") + 11.46, 0, GetConVarNumber("gt_sans_sr")))
609
610 if (SERVER) then
611 local ent1I = ents.Create("ent_glitchtale_gaster_blaster_instant")
612 local pos1I = self.Owner:GetPos()
613
614 ent1I:SetAngles((self.Owner:GetEyeTrace().HitPos - pos1I):Angle())
615 ent1I:SetPos(self.Owner:GetPos() + Vector(0, 0, 45) + self.Owner:GetForward() * 53)
616 ent1I:SetOwner(self.Owner)
617 ent1I:Spawn()
618 ent1I:Activate()
619 end
620 end
621
622 if self.secondarytoggle == 1 then
623 self:SetHoldType( "pistol" )
624
625 self:SendWeaponAnim(183)
626
627 self.Blastercount = 0
628 if(table.Count(self.Blasters) < 0) then return end
629 for num,ent in pairs(self.Blasters) do
630 if IsValid(ent) then
631 ent:Shootnow()
632 self:SetNWInt("Stre",math.Clamp(self:GetNWInt("Stre")+8.86,0,GetConVarNumber("gt_sans_sr")))
633 self.secocc = CurTime() + 1.3
634 end
635 end
636 self.Blasters = {}
637
638 timer.Create("secanimebacktoidle" .. tostring(self),1.3,1,function()
639 if(IsValid(self))then
640 self:SendWeaponAnim(174)
641 end
642 end)
643
644 timer.Create("backtonormal",1.5,1,function()
645 if(IsValid(self))then
646 self:SetHoldType( "normal" )
647 end
648 end)
649
650 self.secocc = CurTime() + 1
651 self.secondarytoggle = 0
652 end
653
654 end
655
656end
657
658--thx wiki
659
660-- HACK: SetPos does not ensure that the position wont be modified again by the gamemovement.
661-- There is currently no ENTITY:Teleport binding.
662TELEPORT_QUEUE = {}
663
664hook.Add("FinishMove", "SanessUnstuckTeleport", function(ply, mv)
665 local tpData = TELEPORT_QUEUE[ply]
666 if tpData ~= nil then
667 ply:SetPos(tpData.Pos)
668 ply:SetAngles(tpData.Angles)
669 timer.Create("donotstucksas",.001,1,function()
670 if IsValid(ply)then
671 ply:ConCommand("gt_unstuck")
672 end
673 end)
674 TELEPORT_QUEUE[ply] = nil
675 return true
676 end
677end)
678
679local function TeleportPlayer(ent, pos, ang, vel)
680
681 -- Mimic IncrementInterpolationFrame, we just make sure we call the things at the right time.
682 local data = {}
683 data.Pos = pos
684 data.Angles = ang
685 data.Velocity = vel
686 data.Ent = ent
687 TELEPORT_QUEUE[ent] = data
688
689end
690
691net.Receive( "teleportnownet", function( len, ply )
692 local danewpos = net.ReadVector()
693 local friends = net.ReadTable()
694
695 teleportnow = 1
696 newposition = danewpos
697 istpreallyowner = ply
698 istpreallyowner:SetNWInt("Stre",math.Clamp(istpreallyowner:GetNWInt("Stre")+50,0,GetConVarNumber("gt_sans_sr")))
699
700 timer.Create("donotstucksasshort",.001,1,function()
701 if IsValid(istpreallyowner)then
702 istpreallyowner:ConCommand("gt_unstuck")
703 end
704 end)
705 ply.TPFriends = friends
706
707end )
708
709net.Receive( "tpeffects", function( len, ply )
710 local enti = net.ReadEntity()
711 if not ply == enti then return end
712
713 local self = enti:GetWeapon( "glitchtale_sans" )
714
715 if not(IsValid(self))then return end
716 if(IsValid(self.Owner)) then
717 local vec = self.Owner:GetPos() + Vector(0,0,-30)
718 TPEffects(enti, vec, "effects/spark", Vector(0,0,120) + VectorRand() * 25, 2, 0.8, 15, 0, 255, 50, Vector( 0, 0, 40 ))
719
720 if(CLIENT)then
721 for i, a in pairs(player.GetAll()) do
722 net.Start("tpeffects_everybody_can_see")
723 net.WriteEntity(a)
724 net.WriteEntity(enti)
725 net.WriteVector(vec)
726 net.WriteString("effects/spark")
727 net.WriteVector(Vector(0,0,120) + VectorRand() * 25)
728 net.WriteInt(2,32)
729 net.WriteFloat(0.8)
730 net.WriteInt(15,32)
731 net.WriteInt(0,32)
732 net.WriteInt(255,32)
733 net.WriteInt(50,32)
734 net.WriteVector(Vector( 0, 0, 40 ))
735 net.SendToServer()
736 end
737 end
738
739
740 end
741
742end )
743
744net.Receive( "tpbeforeeffects", function( len, ply )
745 local enti = net.ReadEntity()
746 local pos = net.ReadVector()
747
748 TPEffects(enti, pos, "particle/smokestack", Vector(0,0,30) + VectorRand() * 30, 1, math.random(4,6), math.random(5,10), math.random(1,3), math.random(20,50), 0, Vector( 0, 0, 5 ))
749
750 if(CLIENT)then
751 for i, a in pairs(player.GetAll()) do
752 net.Start("tpeffects_everybody_can_see")
753 net.WriteEntity(a)
754 net.WriteEntity(enti)
755 net.WriteVector(pos)
756 net.WriteString("particle/smokestack")
757 net.WriteVector(Vector(0,0,30) + VectorRand() * 30)
758 net.WriteInt(1,32)
759 net.WriteFloat(math.random(4,6))
760 net.WriteInt(math.random(5,10),32)
761 net.WriteInt(math.random(1,3),32)
762 net.WriteInt(math.random(20,50),32)
763 net.WriteInt(0,32)
764 net.WriteVector(Vector( 0, 0, 5 ))
765 net.SendToServer()
766 end
767 end
768
769end )
770
771net.Receive("tpeffects_everybody_can_see",function(len,ply)
772
773 --enti, pos, material, velocity, color, dietime, startsize, endsize, stalpha, edalpha, gravity)
774
775 local localpl = net.ReadEntity()
776 local enti = net.ReadEntity()
777 local pos = net.ReadVector()
778 local material = net.ReadString()
779 local velocity = net.ReadVector()
780 local color = net.ReadInt(32)
781 local dietime = net.ReadFloat()
782 local startsize = net.ReadInt(32)
783 local endsize = net.ReadInt(32)
784 local stalpha = net.ReadInt(32)
785 local edalpha = net.ReadInt(32)
786 local gravity = net.ReadVector()
787
788
789 if not(IsValid(localpl))then return end
790
791
792 net.Start("tpeffects_everybody_can_see")
793 net.WriteEntity(a)
794 net.WriteEntity(enti)
795 net.WriteVector(pos)
796 net.WriteString(material)
797 net.WriteVector(velocity)
798 net.WriteInt(color,32)
799 net.WriteFloat(dietime)
800 net.WriteInt(startsize,32)
801 net.WriteInt(endsize,32)
802 net.WriteInt(stalpha,32)
803 net.WriteInt(edalpha,32)
804 net.WriteVector(gravity)
805 net.Send(localpl)
806
807end)
808
809
810net.Receive("tpeffects_everybody_can_seeCL",function(len,ply)
811
812 local enti = net.ReadEntity()
813 local pos = net.ReadVector()
814 local material = net.ReadString()
815 local velocity = net.ReadVector()
816 local color = net.ReadInt(32)
817 local dietime = net.ReadFloat()
818 local startsize = net.ReadInt(32)
819 local endsize = net.ReadInt(32)
820 local stalpha = net.ReadInt(32)
821 local edalpha = net.ReadInt(32)
822 local gravity = net.ReadVector()
823
824
825 TPEffects(enti, pos, material, velocity, color, dietime, startsize, endsize, stalpha, edalpha, gravity)
826
827
828end)
829
830function TPEffects(enti, pos, material, velocity, color, dietime, startsize, endsize, stalpha, edalpha, gravity)
831
832 local vec = pos
833 local emitterrr = ParticleEmitter( vec, false )
834
835 local coloraR = 255
836 local coloraG = 255
837 local coloraB = 255
838
839 if(color == 1)then
840 coloraR = 100
841 coloraG = 200
842 coloraB = 255
843 end
844 if(color == 2)then
845 coloraR = 0
846 coloraG = 150
847 coloraB = 255
848 end
849
850 local particle = emitterrr:Add( Material(material), vec )
851 if( particle ) then
852 particle:SetVelocity( velocity )
853 particle:SetColor( coloraR, coloraG, coloraB )
854 particle:SetLifeTime( 0 )
855 particle:SetDieTime( dietime )
856 particle:SetAngles( Angle( math.random( 0, 360 ), math.random( 0, 360 ), math.random( 0, 360 ) ) )
857 particle:SetAngleVelocity( Angle( math.Rand( -1, 1 ), 0, 0 ) )
858 particle:SetStartSize( startsize )
859 particle:SetEndSize( endsize )
860 particle:SetStartAlpha( stalpha )
861 particle:SetEndAlpha( edalpha )
862 particle:SetGravity( gravity )
863 end
864
865 emitterrr:Finish()
866
867end
868
869
870net.Receive( "tpclose", function( len, ply )
871 tpstopsv = 1
872
873 if IsValid(ply) then
874 net.Start("tpclose_reclient")
875 net.Send(ply)
876 end
877end)
878
879function SWEP:TeleTarget(target)
880 if IsValid(self.Victima)then
881 if SERVER then
882 -- Send a net message to all clients to draw the halo
883 net.Start("TeleEntity")
884 net.WriteEntity(target)
885 net.Broadcast()
886
887 end
888 end
889
890 --Print a message in the chat
891 --if IsValid(target) then
892 --local targetName = target:IsPlayer() and target:Nick() or target:GetClass()
893 --end
894end
895
896
897function SWEP:OnRemove()
898 -- if(self.BoostupC == 1)then
899 -- self.Owner:SetMaxHealth(100)
900 -- self.Owner:SetArmor(0)
901
902 -- self.DMGboost = 0
903
904 -- self.BoostupC = 0
905
906 -- self.zahealu = nil
907
908 -- if(CLIENT)then
909 -- net.Start("dtsword_dropasoul")
910 -- net.WriteVector(self:GetPos())
911 -- net.SendToServer()
912 -- end
913 -- end
914 cooked = 0
915
916 self.Owner.Shielding = 0
917
918 self.wantedfarness = nil
919
920 self:Holster()
921
922 if IsValid(self.Victima) then
923 if(CLIENT)then
924 net.Start("nomorebluemagic")
925 net.WriteEntity(self.Victima)
926 net.SendToServer()
927 end
928 if(SERVER)then
929 if IsValid(self.Victima) then
930 net.Start("UnTeleEntity")
931 net.WriteEntity(self.Victima)
932 net.Broadcast()
933 end
934 end
935 self.Victima:SetNWEntity("blueauras",NULL)
936 --self.wantedfarness = nil
937 if self.Victima:IsPlayer() and self.Victima ~= self.Owner then
938 -- Code to execute when the entity is a player and not the owner
939 self.Victima:Freeze(false)
940 self.Victima:ConCommand("pp_mat_overlay ")
941 self.Victima:ConCommand("pp_mat_overlay blank")
942 elseif (self.Victima:IsNPC() or self.Victima.Type == "nextbot") then
943 if (SERVER) then
944 self.Victima:RemoveFlags( FL_FROZEN )
945 --self.Victima:RemoveEFlags(EFL_NO_THINK_FUNCTION)
946 end
947 end
948
949 timer.Create("givemeasecondor",1,1,function()
950 self.Victima = nil
951 end)
952 end
953end
954
955
956-- net.Receive("dtsword_dropasoul", function(len,ply)
957 -- local pos = net.ReadVector()
958
959 -- local ent = ents.Create( "ent_glitchtale_SCheart" )
960
961
962
963 -- ent:SetPos( pos )
964 -- ent:SetAngles(Angle(0,0,0))
965 -- ent:SetOwner(self.Owner)
966 -- ent:Spawn()
967
968-- end)
969
970--net.Receive("shieldeffectso", function(len,ply)
971 --if(CLIENT)then
972 --local self = net.ReadEntity()
973 --local a = net.ReadTable()
974
975 --if not(IsValid(self))then return end
976
977 --for i, vecta in pairs(a) do
978
979
980 --local vec = self:GetPos() + vecta + self.Owner:EyeAngles():Forward() * 40
981 --local emitter = ParticleEmitter( vec, false )
982
983 --local particle = emitter:Add( Material( "koperplyar/sans/sansfire" ), vec )
984 --if( particle ) then
985
986
987 --particle:SetVelocity( VectorRand() )
988 --particle:SetColor( 150, 150, 255 )
989 --particle:SetLifeTime( 0 )
990 --particle:SetDieTime( 0.3 )
991 --particle:SetAngles( Angle( math.Rand( 0, 360 ), 0, 0 ))
992 --particle:SetAngleVelocity( Angle( math.Rand( -360, 360 ), 0, 0 ))
993 --particle:SetStartSize( math.random(7,15) )
994 --particle:SetEndSize( 0 )
995 --particle:SetStartAlpha( 255 )
996 --particle:SetEndAlpha( 0 )
997 --particle:SetGravity( VectorRand() )
998 --particle:SetCollide( true )
999 --end
1000
1001 --emitter:Finish()
1002 --end
1003 --end
1004--end)
1005
1006local teleoc = 3
1007
1008
1009--local ornot = self
1010
1011--hook.Add( "Think", "dothis", function() -- this works when the gun is holstered.
1012
1013 --self:SetNWInt("Tele",math.Clamp(nt-.15,0,GetConVarNumber("gt_sans_tc")))
1014
1015--end)
1016
1017if CLIENT then
1018
1019 SWEP.vRenderOrder = nil
1020 function SWEP:ViewModelDrawn()
1021
1022 local vm = self.Owner:GetViewModel()
1023 if !IsValid(vm) then return end
1024
1025 if (!self.VElements) then return end
1026
1027 self:UpdateBonePositions(vm)
1028
1029 if (!self.vRenderOrder) then
1030
1031 -- we build a render order because sprites need to be drawn after models
1032 self.vRenderOrder = {}
1033
1034 for k, v in pairs( self.VElements ) do
1035 if (v.type == "Model") then
1036 table.insert(self.vRenderOrder, 1, k)
1037 elseif (v.type == "Sprite" or v.type == "Quad") then
1038 table.insert(self.vRenderOrder, k)
1039 end
1040 end
1041
1042 end
1043
1044 for k, name in ipairs( self.vRenderOrder ) do
1045
1046 local v = self.VElements[name]
1047 if (!v) then self.vRenderOrder = nil break end
1048 if (v.hide) then continue end
1049
1050 local model = v.modelEnt
1051 local sprite = v.spriteMaterial
1052
1053 if (!v.bone) then continue end
1054
1055 local pos, ang = self:GetBoneOrientation( self.VElements, v, vm )
1056
1057 if (!pos) then continue end
1058
1059 if (v.type == "Model" and IsValid(model)) then
1060
1061 model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
1062 ang:RotateAroundAxis(ang:Up(), v.angle.y)
1063 ang:RotateAroundAxis(ang:Right(), v.angle.p)
1064 ang:RotateAroundAxis(ang:Forward(), v.angle.r)
1065
1066 model:SetAngles(ang)
1067 --model:SetModelScale(v.size)
1068 local matrix = Matrix()
1069 matrix:Scale(v.size)
1070 model:EnableMatrix( "RenderMultiply", matrix )
1071
1072 if (v.material == "") then
1073 model:SetMaterial("")
1074 elseif (model:GetMaterial() != v.material) then
1075 model:SetMaterial( v.material )
1076 end
1077
1078 if (v.skin and v.skin != model:GetSkin()) then
1079 model:SetSkin(v.skin)
1080 end
1081
1082 if (v.bodygroup) then
1083 for k, v in pairs( v.bodygroup ) do
1084 if (model:GetBodygroup(k) != v) then
1085 model:SetBodygroup(k, v)
1086 end
1087 end
1088 end
1089
1090 if (v.surpresslightning) then
1091 render.SuppressEngineLighting(true)
1092 end
1093
1094 render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
1095 render.SetBlend(v.color.a/255)
1096 model:DrawModel()
1097 render.SetBlend(1)
1098 render.SetColorModulation(1, 1, 1)
1099
1100 if (v.surpresslightning) then
1101 render.SuppressEngineLighting(false)
1102 end
1103
1104 elseif (v.type == "Sprite" and sprite) then
1105
1106 local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
1107 render.SetMaterial(sprite)
1108 render.DrawSprite(drawpos, v.size.x, v.size.y, v.color)
1109
1110 elseif (v.type == "Quad" and v.draw_func) then
1111
1112 local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
1113 ang:RotateAroundAxis(ang:Up(), v.angle.y)
1114 ang:RotateAroundAxis(ang:Right(), v.angle.p)
1115 ang:RotateAroundAxis(ang:Forward(), v.angle.r)
1116
1117 cam.Start3D2D(drawpos, ang, v.size)
1118 v.draw_func( self )
1119 cam.End3D2D()
1120
1121 end
1122
1123 end
1124
1125 end
1126
1127 SWEP.wRenderOrder = nil
1128 function SWEP:DrawWorldModel()
1129
1130 if (self.ShowWorldModel == nil or self.ShowWorldModel) then
1131 self:DrawModel()
1132 end
1133
1134 if (!self.WElements) then return end
1135
1136 if (!self.wRenderOrder) then
1137
1138 self.wRenderOrder = {}
1139
1140 for k, v in pairs( self.WElements ) do
1141 if (v.type == "Model") then
1142 table.insert(self.wRenderOrder, 1, k)
1143 elseif (v.type == "Sprite" or v.type == "Quad") then
1144 table.insert(self.wRenderOrder, k)
1145 end
1146 end
1147
1148 end
1149
1150 if (IsValid(self.Owner)) then
1151 bone_ent = self.Owner
1152 else
1153 -- when the weapon is dropped
1154 bone_ent = self
1155 end
1156
1157 for k, name in pairs( self.wRenderOrder ) do
1158
1159 local v = self.WElements[name]
1160 if (!v) then self.wRenderOrder = nil break end
1161 if (v.hide) then continue end
1162
1163 local pos, ang
1164
1165 if (v.bone) then
1166 pos, ang = self:GetBoneOrientation( self.WElements, v, bone_ent )
1167 else
1168 pos, ang = self:GetBoneOrientation( self.WElements, v, bone_ent, "ValveBiped.Bip01_R_Hand" )
1169 end
1170
1171 if (!pos) then continue end
1172
1173 local model = v.modelEnt
1174 local sprite = v.spriteMaterial
1175
1176 if (v.type == "Model" and IsValid(model)) then
1177
1178 model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
1179 ang:RotateAroundAxis(ang:Up(), v.angle.y)
1180 ang:RotateAroundAxis(ang:Right(), v.angle.p)
1181 ang:RotateAroundAxis(ang:Forward(), v.angle.r)
1182
1183 model:SetAngles(ang)
1184 --model:SetModelScale(v.size)
1185 local matrix = Matrix()
1186 matrix:Scale(v.size)
1187 model:EnableMatrix( "RenderMultiply", matrix )
1188
1189 if (v.material == "") then
1190 model:SetMaterial("")
1191 elseif (model:GetMaterial() != v.material) then
1192 model:SetMaterial( v.material )
1193 end
1194
1195 if (v.skin and v.skin != model:GetSkin()) then
1196 model:SetSkin(v.skin)
1197 end
1198
1199 if (v.bodygroup) then
1200 for k, v in pairs( v.bodygroup ) do
1201 if (model:GetBodygroup(k) != v) then
1202 model:SetBodygroup(k, v)
1203 end
1204 end
1205 end
1206
1207 if (v.surpresslightning) then
1208 render.SuppressEngineLighting(true)
1209 end
1210
1211 render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
1212 render.SetBlend(v.color.a/255)
1213 model:DrawModel()
1214 render.SetBlend(1)
1215 render.SetColorModulation(1, 1, 1)
1216
1217 if (v.surpresslightning) then
1218 render.SuppressEngineLighting(false)
1219 end
1220
1221 elseif (v.type == "Sprite" and sprite) then
1222
1223 local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
1224 render.SetMaterial(sprite)
1225 render.DrawSprite(drawpos, v.size.x, v.size.y, v.color)
1226
1227 elseif (v.type == "Quad" and v.draw_func) then
1228
1229 local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
1230 ang:RotateAroundAxis(ang:Up(), v.angle.y)
1231 ang:RotateAroundAxis(ang:Right(), v.angle.p)
1232 ang:RotateAroundAxis(ang:Forward(), v.angle.r)
1233
1234 cam.Start3D2D(drawpos, ang, v.size)
1235 v.draw_func( self )
1236 cam.End3D2D()
1237
1238 end
1239
1240 end
1241
1242 end
1243
1244 function SWEP:GetBoneOrientation( basetab, tab, ent, bone_override )
1245
1246 local bone, pos, ang
1247 if (tab.rel and tab.rel != "") then
1248
1249 local v = basetab[tab.rel]
1250
1251 if (!v) then return end
1252
1253 -- Technically, if there exists an element with the same name as a bone
1254 -- you can get in an infinite loop. Let's just hope nobody's that stupid.
1255 pos, ang = self:GetBoneOrientation( basetab, v, ent )
1256
1257 if (!pos) then return end
1258
1259 pos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
1260 ang:RotateAroundAxis(ang:Up(), v.angle.y)
1261 ang:RotateAroundAxis(ang:Right(), v.angle.p)
1262 ang:RotateAroundAxis(ang:Forward(), v.angle.r)
1263
1264 else
1265
1266 bone = ent:LookupBone(bone_override or tab.bone)
1267
1268 if (!bone) then return end
1269
1270 pos, ang = Vector(0,0,0), Angle(0,0,0)
1271 local m = ent:GetBoneMatrix(bone)
1272 if (m) then
1273 pos, ang = m:GetTranslation(), m:GetAngles()
1274 end
1275
1276 if (IsValid(self.Owner) and self.Owner:IsPlayer() and
1277 ent == self.Owner:GetViewModel() and self.ViewModelFlip) then
1278 ang.r = -ang.r -- Fixes mirrored models
1279 end
1280
1281 end
1282
1283 return pos, ang
1284 end
1285
1286 function SWEP:CreateModels( tab )
1287
1288 if (!tab) then return end
1289
1290 -- Create the clientside models here because Garry says we can't do it in the render hook
1291 for k, v in pairs( tab ) do
1292 if (v.type == "Model" and v.model and v.model != "" and (!IsValid(v.modelEnt) or v.createdModel != v.model) and
1293 string.find(v.model, ".mdl") and file.Exists (v.model, "GAME") ) then
1294
1295 v.modelEnt = ClientsideModel(v.model, RENDER_GROUP_VIEW_MODEL_OPAQUE)
1296 if (IsValid(v.modelEnt)) then
1297 v.modelEnt:SetPos(self:GetPos())
1298 v.modelEnt:SetAngles(self:GetAngles())
1299 v.modelEnt:SetParent(self)
1300 v.modelEnt:SetNoDraw(true)
1301 v.createdModel = v.model
1302 else
1303 v.modelEnt = nil
1304 end
1305
1306 elseif (v.type == "Sprite" and v.sprite and v.sprite != "" and (!v.spriteMaterial or v.createdSprite != v.sprite)
1307 and file.Exists ("materials/"..v.sprite..".vmt", "GAME")) then
1308
1309 local name = v.sprite.."-"
1310 local params = { ["$basetexture"] = v.sprite }
1311 -- make sure we create a unique name based on the selected options
1312 local tocheck = { "nocull", "additive", "vertexalpha", "vertexcolor", "ignorez" }
1313 for i, j in pairs( tocheck ) do
1314 if (v[j]) then
1315 params["$"..j] = 1
1316 name = name.."1"
1317 else
1318 name = name.."0"
1319 end
1320 end
1321
1322 v.createdSprite = v.sprite
1323 v.spriteMaterial = CreateMaterial(name,"UnlitGeneric",params)
1324
1325 end
1326 end
1327
1328 end
1329
1330 local allbones
1331 local hasGarryFixedBoneScalingYet = false
1332
1333 function SWEP:UpdateBonePositions(vm)
1334
1335 if self.ViewModelBoneMods then
1336
1337 if (!vm:GetBoneCount()) then return end
1338
1339 -- !! WORKAROUND !! --
1340 -- We need to check all model names :/
1341 local loopthrough = self.ViewModelBoneMods
1342 if (!hasGarryFixedBoneScalingYet) then
1343 allbones = {}
1344 for i=0, vm:GetBoneCount() do
1345 local bonename = vm:GetBoneName(i)
1346 if (self.ViewModelBoneMods[bonename]) then
1347 allbones[bonename] = self.ViewModelBoneMods[bonename]
1348 else
1349 allbones[bonename] = {
1350 scale = Vector(1,1,1),
1351 pos = Vector(0,0,0),
1352 angle = Angle(0,0,0)
1353 }
1354 end
1355 end
1356
1357 loopthrough = allbones
1358 end
1359 -- !! ----------- !! --
1360
1361 for k, v in pairs( loopthrough ) do
1362 local bone = vm:LookupBone(k)
1363 if (!bone) then continue end
1364
1365 -- !! WORKAROUND !! --
1366 local s = Vector(v.scale.x,v.scale.y,v.scale.z)
1367 local p = Vector(v.pos.x,v.pos.y,v.pos.z)
1368 local ms = Vector(1,1,1)
1369 if (!hasGarryFixedBoneScalingYet) then
1370 local cur = vm:GetBoneParent(bone)
1371 while(cur >= 0) do
1372 local pscale = loopthrough[vm:GetBoneName(cur)].scale
1373 ms = ms * pscale
1374 cur = vm:GetBoneParent(cur)
1375 end
1376 end
1377
1378 s = s * ms
1379 -- !! ----------- !! --
1380
1381 if vm:GetManipulateBoneScale(bone) != s then
1382 vm:ManipulateBoneScale( bone, s )
1383 end
1384 if vm:GetManipulateBoneAngles(bone) != v.angle then
1385 vm:ManipulateBoneAngles( bone, v.angle )
1386 end
1387 if vm:GetManipulateBonePosition(bone) != p then
1388 vm:ManipulateBonePosition( bone, p )
1389 end
1390 end
1391 else
1392 self:ResetBonePositions(vm)
1393 end
1394
1395 end
1396
1397 function SWEP:ResetBonePositions(vm)
1398
1399 if (!vm:GetBoneCount()) then return end
1400 for i=0, vm:GetBoneCount() do
1401 vm:ManipulateBoneScale( i, Vector(1, 1, 1) )
1402 vm:ManipulateBoneAngles( i, Angle(0, 0, 0) )
1403 vm:ManipulateBonePosition( i, Vector(0, 0, 0) )
1404 end
1405
1406 end
1407
1408 /**************************
1409 Global utility code
1410 **************************/
1411
1412 -- Fully copies the table, meaning all tables inside this table are copied too and so on (normal table.Copy copies only their reference).
1413 -- Does not copy entities of course, only copies their reference.
1414 -- WARNING: do not use on tables that contain themselves somewhere down the line or you'll get an infinite loop
1415 function table.FullCopy( tab )
1416
1417 if (!tab) then return nil end
1418
1419 local res = {}
1420 for k, v in pairs( tab ) do
1421 if (type(v) == "table") then
1422 res[k] = table.FullCopy(v) -- recursion ho!
1423 elseif (type(v) == "Vector") then
1424 res[k] = Vector(v.x, v.y, v.z)
1425 elseif (type(v) == "Angle") then
1426 res[k] = Angle(v.p, v.y, v.r)
1427 else
1428 res[k] = v
1429 end
1430 end
1431
1432 return res
1433
1434 end
1435
1436end
1437
1438function SWEP:Think()
1439
1440 -- if(self.BoostupC == 1)then
1441 -- self.DMGboost = 5
1442
1443 -- if(self.zahealu == 0 or self.zahealu == nil)then
1444
1445 -- self.Owner:SetHealth(300)
1446 -- self.Owner:SetMaxHealth(300)
1447 -- self.Owner:SetArmor(50)
1448
1449 -- self.zahealu = 1
1450 -- end
1451
1452
1453 -- else
1454 -- self.zahealu = nil
1455 -- self.DMGboost = 0
1456 -- end
1457
1458 --if self.Owner:Health() <= 0 then
1459
1460 --end
1461
1462 local o=self.Owner
1463 local n=self:GetNWInt("Stre")
1464 local blue=self:GetNWInt("Tele")
1465
1466 --if not(o:Alive())then
1467 --local e=EffectData() e:SetMagnitude(3)
1468 --e:SetOrigin(self.Owner:GetPos()+Vector(math.random(-self.BBox.x,self.BBox.x),math.random(-self.BBox.y,self.BBox.y),self.BBox.z*(self:GetColor().a/255)))
1469 --util.Effect("dustdeath",e)
1470 --end
1471
1472 self.Speed=1
1473
1474 if n>97.3/100*GetConVarNumber("gt_sans_sr")then
1475 self.Tired=1
1476 self:SetNWBool("Tired",true)
1477 --if(self.Owner.Shielding == 1)then return end
1478 self.Speed=.3
1479 elseif n>70/100*GetConVarNumber("gt_sans_sr")then
1480 --if(self.Owner.Shielding == 1)then return end
1481 self.Speed=.5
1482 elseif n>50/100*GetConVarNumber("gt_sans_sr")then
1483 --if(self.Owner.Shielding == 1)then return end
1484 self.Speed=.7
1485 else
1486 self.Tired=nil
1487 self:SetNWBool("Tired",false)
1488 cooked = 0
1489 end
1490
1491 if self.Tired then
1492 cooked = 1
1493 --if(self.Owner.Shielding == 1)then return end
1494 self.Speed=.33
1495 end
1496
1497 --if(self.Owner.Shielding == 1)then
1498 --self.Speed=0
1499 --elseif(self.Owner.Shielding == 0)then
1500 --if self.Tired then return end
1501 --self.Speed=1
1502 --end
1503
1504 if(cooked == 1)then
1505 self:SetNWInt("D",3)
1506 end
1507
1508 if o:IsOnGround()and self.Speed<1 then
1509 o:SetLocalVelocity(o:GetVelocity()*self.Speed)
1510 end
1511
1512 self:SetNWInt("Stre",math.Clamp(n-.15,0,GetConVarNumber("gt_sans_sr")))
1513
1514
1515 if not(IsValid(self.Victima))then
1516 self:SetNWInt("Tele",math.Clamp(blue-.15,0,GetConVarNumber("gt_sans_tc")))
1517 else
1518 if self.Victima:IsNPC() or self.Victima.Type == "nextbot" or self.Victima:IsPlayer() and self.Victima ~= self.Owner then
1519 self:SetNWInt("Tele",math.Clamp(blue+.15,0,GetConVarNumber("gt_sans_tc")))
1520 else
1521 self:SetNWInt("Tele",math.Clamp(blue+.075,0,GetConVarNumber("gt_sans_tc")))
1522 end
1523 end
1524
1525 if self.Owner.Shielding == 1 then
1526 if not self.Tired then
1527 self:SetNWInt("Stre",math.Clamp(n+0.035,0,GetConVarNumber("gt_sans_sr")))
1528 else
1529 self.Owner:RemoveFlags(FL_ATCONTROLS)
1530 self.Owner.Shielding = 0
1531
1532 if SERVER then
1533 for _, ent in ipairs(self.Shield) do
1534 if IsValid(ent) then ent:Removeself() end
1535 end
1536 end
1537
1538 self.Shield = {}
1539 timer.Remove("CheckKeyRelease" .. tostring(self.Owner))
1540 end
1541 end
1542
1543 local d=self:GetNWInt("D")
1544
1545 if( self.Owner:GetVelocity():Length() < 30 || self.Owner:GetMoveType() == MOVETYPE_NOCLIP ) then
1546 --self.Owner:DoAnimationEvent( ACT_HL2MP_IDLE )
1547 --if (self.Owner:KeyDown(IN_DUCK))then return end --bugs everything crouch-related making it so think() only works when walking
1548
1549 if( self:GetVar( "anim_reset" ) != NULL ) then
1550 if(self.Owner:GetModel() == "models/nia/sans_pm.mdl") then
1551 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_R_Clavicle" ), Angle( 0, 10, -40 ) )
1552 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_L_Clavicle" ), Angle( 0, 10, 30 ) )
1553 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_R_Forearm" ), Angle( 0, -90, 0 ) )
1554 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_L_Forearm" ), Angle( 0, -90, 0 ) )
1555 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_R_Hand" ), Angle( 180, 0, 0 ) )
1556 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_L_Hand" ), Angle( 180, 0, 0 ) )
1557 end
1558 if(self.Owner:GetModel() == "models/sansplayer/sansplayer.mdl") then
1559 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_R_Clavicle" ), Angle( 0, 10, -30 ) )
1560 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_L_Clavicle" ), Angle( 0, 10, 30 ) )
1561 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_R_Forearm" ), Angle( 0, -60, 0 ) )
1562 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_L_Forearm" ), Angle( 0, -60, 0 ) )
1563 end
1564 self:SetVar( "anim_reset", NULL )
1565 end
1566 else
1567 if( self:GetVar( "anim_reset" ) == NULL && self.Owner:GetVelocity():Length() > 150 ) then
1568 self:SetVar( "anim_reset", true )
1569
1570 --self.Owner:DoAnimationEvent( ACT_GMOD_IN_CHAT )
1571 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_R_Clavicle" ), Angle( 0, 0, 0 ) )
1572 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_L_Clavicle" ), Angle( 0, 0, 0 ) )
1573 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_R_Forearm" ), Angle( 0, 0, 0 ) )
1574 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_L_Forearm" ), Angle( 0, 0, 0 ) )
1575 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_R_Hand" ), Angle( 0, 0, 0 ) )
1576 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_L_Hand" ), Angle( 0, 0, 0 ) )
1577 end
1578 end
1579
1580
1581 net.Receive("tpclose_reclient",function(len,ply)
1582 self.panel = nil
1583 end)
1584
1585 net.Receive("gb_updateclientside", function(len,ply)
1586 local gb = net.ReadTable()
1587
1588 if(gb)then
1589 self.Blasters_cl = gb
1590 end
1591 end)
1592
1593 net.Receive("gbaddtotable", function(len,ply)
1594 local gb = net.ReadEntity()
1595 local owna = net.ReadEntity()
1596
1597 if not(ply == owna) then return end
1598 if(gb)then
1599 table.insert(self.Blasters, gb)
1600 end
1601 end)
1602
1603 if(SERVER)then
1604 net.Start("gb_updateclientside")
1605 net.WriteTable(self.Blasters)
1606 net.Send(self.Owner)
1607
1608 for i,a in pairs(self.Blasters) do
1609 local drva = a:GetNWFloat( "Driver" )
1610
1611 if(drva == self.Owner)then
1612 self.AmIDriving = 1
1613 self.AmIDrivingVehicle = a
1614 end
1615 end
1616
1617 if(self.AmIDriving == 1)then
1618 for i,a in pairs(self.Blasters) do
1619
1620 local drva = a:GetNWFloat( "Driver" )
1621
1622 if(drva != self.Owner)then
1623
1624 self.AmIDriving = 0
1625
1626 end
1627 end
1628 end
1629 end
1630
1631 net.Receive("gbdrivingupdateclient" .. tostring(self), function(len,ply)
1632
1633 local driveh = net.ReadInt(32)
1634
1635 if(CLIENT)then
1636 self.AmIDriving = driveh
1637 end
1638
1639 end)
1640
1641 if(SERVER)then
1642 if(self.AmIDriving)then
1643
1644 net.Start("gbdrivingupdateclient" .. tostring(self))
1645 net.WriteInt(self.AmIDriving,32)
1646 net.Send(self.Owner)
1647
1648 end
1649 end
1650
1651
1652 local timleft = teleoc - CurTime()
1653 if(timleft < 0)then
1654 if(self.Owner:KeyDown( IN_USE ))then
1655
1656 if(self.AmIDriving == 1) then return end
1657 if(self.Owner.Shielding == 1) then return end
1658 if self.NextAtt>CurTime()||self.Tired then return end
1659 if blue > 31 then return end
1660
1661 timer.Remove("removezahvictim" .. tostring(self))
1662 timer.Create("removezahvictim" .. tostring(self),0.1,1,function()
1663 if(IsValid(self))then
1664 teleoc = CurTime() + 6.3
1665 if IsValid(self.Victima)then
1666 if(CLIENT)then
1667 net.Start("nomorebluemagic")
1668 net.WriteEntity(self.Victima)
1669 net.SendToServer()
1670 end
1671 if(SERVER)then
1672 if IsValid(self.Victima) then
1673 net.Start("UnTeleEntity")
1674 net.WriteEntity(self.Victima)
1675 net.Broadcast()
1676 end
1677 end
1678 self.Victima:SetNWEntity("blueauras",NULL)
1679 --self.wantedfarness = nil
1680 self.wantedfarness = nil
1681 if self.Victima:IsPlayer() and self.Victima ~= self.Owner then
1682 -- Code to execute when the entity is a player and not the owner
1683 self.Victima:Freeze(false)
1684 self.Victima:ConCommand("pp_mat_overlay ")
1685 self.Victima:ConCommand("pp_mat_overlay blank")
1686 elseif (self.Victima:IsNPC() or self.Victima.Type == "nextbot") then
1687 if (SERVER) then
1688 self.Victima:RemoveFlags( FL_FROZEN )
1689 --self.Victima:RemoveEFlags(EFL_NO_THINK_FUNCTION)
1690 end
1691 end
1692
1693 --timer.Create("givemeasecond",1,1,function() --breaks blue functions
1694 self.Victima = nil
1695 -- end)
1696
1697 if(self.Owner:GetModel() == "models/sansplayer/sansplayer.mdl") then
1698 self.Owner:SetBodygroup( 1, 0 )
1699 self.Owner:SetBodygroup( 2, 0 )
1700 end
1701 if(self.Owner:GetModel() == "models/nia/sans_pm.mdl") then
1702 self.Owner:SetBodygroup( 2, 0 )
1703 end
1704 else
1705 teleoc = CurTime() + 3.3
1706 end
1707
1708 self:SetVar( "anim_reset", true )
1709
1710 self:TelekanisisAnim_Stop()
1711
1712 self.telekanisisstage = nil
1713 end
1714 end)
1715 if not(self.telekanisisstage == 1)then
1716
1717 self:TelekanisisAnim_Start()
1718
1719
1720 self.telekanisisstage = 1
1721 end
1722
1723 if(self.Owner:GetModel() == "models/sansplayer/sansplayer.mdl") then
1724 self.Owner:SetBodygroup( 1, 1 )
1725 self.Owner:SetBodygroup( 2, 1 )
1726 end
1727 if(self.Owner:GetModel() == "models/nia/sans_pm.mdl") then
1728 self.Owner:SetBodygroup( 2, 1 )
1729 end
1730
1731 if not(IsValid(self.Victima))then
1732
1733 if self.NextAtt>CurTime()||self.Tired then return end
1734
1735 local tr = util.TraceLine( {
1736 start = self.Owner:GetShootPos(),
1737 endpos = self.Owner:GetShootPos() + self.Owner:EyeAngles():Forward() * 1450,
1738 filter = self.Owner
1739 } )
1740
1741 self.Victima = tr.Entity
1742
1743 if(self.Owner:GetModel() == "models/sansplayer/sansplayer.mdl") then
1744 self.Owner:SetBodygroup( 1, 0 )
1745 self.Owner:SetBodygroup( 2, 0 )
1746 end
1747 if(self.Owner:GetModel() == "models/nia/sans_pm.mdl") then
1748 self.Owner:SetBodygroup( 2, 0 )
1749 end
1750
1751 end
1752
1753 local victim = self.Victima
1754
1755 if(IsValid(victim))then
1756 if self.NextAtt>CurTime()||self.Tired then return end
1757 if blue > 31 then return end
1758
1759 local eyeAng = self.Owner:GetAngles()
1760
1761 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_R_Clavicle" ), Angle( 0, 0, 0 ) )
1762 self.Owner:ManipulateBoneAngles( self.Owner:LookupBone( "ValveBiped.Bip01_R_Clavicle" ), Angle( 0, 20, 45 - eyeAng.x ) )
1763
1764 if(CLIENT) then
1765 net.Start("dobluemagic")
1766 net.WriteEntity(victim)
1767 net.SendToServer()
1768 end
1769
1770 victim:SetNWEntity("blueauras",self.Owner)
1771 self:TeleTarget(victim)
1772
1773 if victim:IsPlayer() then
1774 if(victim == self.Owner)then return false end
1775 -- Code to execute when the entity is a player and not the owner
1776
1777 victim:ConCommand("pp_mat_overlay overlays/teleka")
1778 victim:Freeze(true)
1779 --victim:DrawViewModel(false)
1780 elseif (victim:IsNPC() or victim.Type == "nextbot") then
1781 if (SERVER) then
1782 victim:AddFlags( FL_FROZEN )
1783 --victim:AddEFlags(EFL_NO_THINK_FUNCTION)
1784 end
1785 end
1786
1787 local victvelo = victim:GetVelocity() / 3.7 --Telekanisis force strength
1788 local farness = (self.Owner:GetPos() - victim:GetPos()):Length()
1789
1790 local controllUB = Vector(0,0,0)
1791 local controllLR = Vector(0,0,0)
1792 local controllUD = Vector(0,0,0)
1793
1794 if(victim:IsPlayer())then
1795 if(victim:KeyDown( IN_FORWARD ))then
1796 controllUB = victim:EyeAngles():Forward()
1797 end
1798 if(victim:KeyDown( IN_BACK ))then
1799 controllUB = victim:EyeAngles():Forward() * -1
1800 end
1801 if(victim:KeyDown( IN_MOVELEFT ))then
1802 controllLR = victim:EyeAngles():Right() * -1
1803 end
1804 if(victim:KeyDown( IN_MOVERIGHT ))then
1805 controllLR = victim:EyeAngles():Right()
1806 end
1807 if(victim:KeyDown( IN_JUMP ))then
1808 controllUD = victim:EyeAngles():Up()
1809 end
1810 end
1811
1812 local controll = (controllUB + controllLR)
1813
1814 if(victim.CustomControll)then
1815 controll = (controllUB + controllLR) * victim.CustomControll --To set an advantage over the average victim
1816 end
1817
1818 if not(self.wantedfarness)then
1819 self.wantedfarness = farness
1820 end
1821
1822 local aim = self.Owner:EyeAngles():Forward()
1823 local actuallcontroll = (controll * (farness / 3))
1824 local posforvictim = ((aim * self.wantedfarness) + self.Owner:GetPos()) + actuallcontroll - victvelo
1825 local addedvector = Vector(0,0,0)
1826
1827 if(victim:IsPlayer() or victim:IsNPC())then
1828 addedvector = Vector(0,0,40)
1829 end
1830
1831 local directionofposition = ((posforvictim + addedvector) - victim:GetPos()):GetNormalized()
1832
1833 victim:SetVelocity(((posforvictim + addedvector) - victim:GetPos()))
1834
1835 local oldfarnness = farness
1836
1837
1838 local angularvel = Vector(0,0,0)
1839 if(self.Owner:KeyDown( IN_JUMP ))then
1840 if(self.Owner:KeyDown( IN_FORWARD ))then
1841 angularvel = angularvel + self.Owner:EyeAngles():Forward() * 5
1842 end
1843 if(self.Owner:KeyDown( IN_MOVERIGHT ))then
1844 angularvel = angularvel + self.Owner:EyeAngles():Right() * 5
1845 end
1846 if(self.Owner:KeyDown( IN_MOVELEFT ))then
1847 angularvel = angularvel + self.Owner:EyeAngles():Right() * -5
1848 end
1849 if(self.Owner:KeyDown( IN_BACK ))then
1850 angularvel = angularvel + self.Owner:EyeAngles():Forward() * -5
1851 end
1852
1853 local dephys = victim:GetPhysicsObject()
1854 if(IsValid(dephys))then
1855 dephys:AddAngleVelocity( angularvel )
1856 end
1857
1858 end
1859
1860 if(self.Owner:KeyDown( IN_WALK ) && !self.Owner:KeyDown( IN_SPEED ))then
1861 victim:SetVelocity(self.Owner:EyeAngles():Forward() * (366666 / farness))
1862
1863 farness = 10000
1864 end
1865
1866 farness = oldfarnness
1867
1868
1869 local phys = victim:GetPhysicsObject()
1870 if(IsValid(phys))then
1871 phys:AddVelocity((posforvictim + Vector(0,0,80)) - victim:GetPos())
1872
1873 if(self.Owner:KeyDown( IN_WALK ) && !self.Owner:KeyDown( IN_SPEED ))then
1874 phys:SetVelocity(self.Owner:EyeAngles():Forward() * (366666 / farness))
1875
1876 farness = 10000
1877 end
1878
1879 end
1880
1881 if(farness > 1451)then
1882 teleoc = CurTime() + 3
1883 self:SetVar( "anim_reset", true )
1884 if IsValid(self.Victima) then
1885 if self.Victima:IsPlayer() and self.Victima ~= self.Owner then
1886 -- Code to execute when the entity is a player and not the owner
1887 self.Victima:Freeze(false)
1888 self.Victima:ConCommand("pp_mat_overlay ")
1889 self.Victima:ConCommand("pp_mat_overlay blank")
1890 elseif (self.Victima:IsNPC() or self.Victima.Type == "nextbot") then
1891 if (SERVER) then
1892 self.Victima:RemoveFlags( FL_FROZEN )
1893 --self.Victima:RemoveEFlags(EFL_NO_THINK_FUNCTION)
1894 end
1895 end
1896 if(CLIENT)then
1897 net.Start("nomorebluemagic")
1898 net.WriteEntity(self.Victima)
1899 net.SendToServer()
1900 end
1901 if(SERVER)then
1902 if IsValid(self.Victima) then
1903 net.Start("UnTeleEntity")
1904 net.WriteEntity(self.Victima)
1905 net.Broadcast()
1906 end
1907 end
1908 victim:SetNWEntity("blueauras",NULL)
1909 timer.Create("givemeasecond2",1,1,function()
1910 self.Victima = nil
1911 end)
1912 end
1913 end
1914
1915 if(victim:GetClass() == "ent_glitchtale_gintegrity")then
1916 victim:ReOwner(self.Owner)
1917 end
1918
1919 local up = util.TraceLine({
1920 startpos = victim:GetPos();
1921 endpos = victim:GetPos() + Vector(0,0,victim:GetModelRadius() + 10);
1922 filter = victim
1923 })
1924 local down = util.TraceLine({
1925 startpos = victim:GetPos();
1926 endpos = victim:GetPos() + Vector(0,0,-10);
1927 filter = victim
1928 })
1929 local left = util.TraceLine({
1930 startpos = victim:GetPos();
1931 endpos = victim:GetPos() + (victim:EyeAngles():Right() * -10);
1932 filter = victim
1933 })
1934 local right = util.TraceLine({
1935 startpos = victim:GetPos();
1936 endpos = victim:GetPos() + (victim:EyeAngles():Right() * 10);
1937 filter = victim
1938 })
1939 local forwards = util.TraceLine({
1940 startpos = victim:GetPos();
1941 endpos = victim:GetPos() + (victim:EyeAngles():Forward() * 10);
1942 filter = victim
1943 })
1944 local backwards = util.TraceLine({
1945 startpos = victim:GetPos();
1946 endpos = victim:GetPos() + (victim:EyeAngles():Forward() * -10);
1947 filter = victim
1948 })
1949
1950
1951 local uE = up.Entity
1952 local dE = down.Entity
1953 local lE = left.Entity
1954 local rE = right.Entity
1955 local fE = forwards.Entity
1956 local bE = backwards.Entity
1957
1958 local dmgpositions = {}
1959
1960 table.insert(dmgpositions,uE)
1961 table.insert(dmgpositions,dE)
1962 table.insert(dmgpositions,lE)
1963 table.insert(dmgpositions,rE)
1964 table.insert(dmgpositions,fE)
1965 table.insert(dmgpositions,bE)
1966
1967 for i, a in pairs(dmgpositions) do
1968 if(a && a:IsWorld())then
1969
1970
1971 local distanca = (posforvictim - victim:GetPos()):Length()
1972
1973 if(distanca > 150)then
1974
1975 local tdtimleft = tdocc - CurTime()
1976 if tdtimleft < 0 then
1977 if(SERVER)then
1978
1979 local d = DamageInfo()
1980 d:SetInflictor(self.Owner)
1981 d:SetAttacker(self.Owner)
1982 d:SetDamage( (distanca / 50) )
1983
1984 victim:TakeDamageInfo( d )
1985
1986 end
1987 tdocc = CurTime() + tddelay
1988 end
1989
1990 end
1991
1992 end
1993 end
1994
1995 if(self.Owner:KeyDown( IN_SPEED ))then
1996 if(self.wantedfarness)then
1997 self.wantedfarness = self.wantedfarness + 10
1998 end
1999 end
2000 if(self.Owner:KeyDown( IN_DUCK ))then
2001 if(self.wantedfarness)then
2002 self.wantedfarness = self.wantedfarness - 10
2003 end
2004 end
2005
2006 if self.wantedfarness > 1450 then
2007 self.wantedfarness = 1450
2008 end
2009 if self.wantedfarness < 1 then
2010 self.wantedfarness = 1
2011 end
2012
2013 end
2014 end
2015 end
2016
2017 if(timleft < 0)then
2018 if !self.Tired and o:KeyDown(IN_USE)then
2019 self:SetNWInt("Stre",math.Clamp(self:GetNWInt("Stre")+.25,0,GetConVarNumber("gt_sans_sr")))
2020 end
2021 end
2022
2023 --if !self.Tired and o:KeyDown(IN_USE)then
2024 --self:SetNWInt("D",math.Clamp(self:GetNWInt("D")-.03,0,1))
2025 --else
2026 --self:SetNWInt("D",math.Clamp(self:GetNWInt("D")-.01,0,1))
2027 --end
2028
2029 if !self.Tired then --! is like [different]
2030 self:SetNWInt("D",math.Clamp(self:GetNWInt("D")-.01,0,1))
2031 end
2032
2033 if(self.Owner:KeyDown( IN_WALK ) && !self.Owner:KeyDown( IN_SPEED ) && !self.Owner:KeyDown( IN_DUCK ) && !self.Owner:KeyDown( IN_USE ))then
2034 local stabtimleft = stabocc - CurTime()
2035 if stabtimleft < 0 then
2036
2037 if(self.AmIDriving == 1) then return end
2038
2039 self:SendWeaponAnim( 186 )
2040
2041 timer.Create("stabbacktoidle" .. tostring(self),0.7,1,function()
2042 if !IsValid(self) then return end
2043
2044 self:SendWeaponAnim( 174 )
2045 self:SetHoldType("normal")
2046 end)
2047
2048 self:SetHoldType("knife")
2049
2050
2051 timer.Create("stabtime" .. tostring(self),0.1,1,function()
2052 if !IsValid(self) then return end
2053
2054 self.Owner:SetAnimation(PLAYER_ATTACK1)
2055 self:SetNWInt("Stre",math.Clamp(self:GetNWInt("Stre")+1,0,GetConVarNumber("gt_sans_sr")))
2056
2057 local tr = util.TraceLine( {
2058 start = self.Owner:GetShootPos(),
2059 endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * 60,
2060 filter = self.Owner,
2061 mask = MASK_SHOT_HULL
2062 } )
2063
2064 local victim = tr.Entity
2065
2066 if ( !IsValid( victim ) ) then
2067 tr = util.TraceHull( {
2068 start = self.Owner:GetShootPos(),
2069 endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * 60,
2070 filter = self.Owner,
2071 mins = Vector( -10, -10, -8 ),
2072 maxs = Vector( 10, 10, 8 ),
2073 mask = MASK_SHOT_HULL
2074 } )
2075 end
2076
2077 if(IsValid(victim))then
2078 if(SERVER)then
2079 local d = DamageInfo()
2080 d:SetDamage( math.random(25,30) )
2081 d:SetAttacker( self.Owner )
2082 d:SetInflictor( self )
2083 d:SetDamageType( DMG_SLASH )
2084
2085 victim:TakeDamageInfo( d )
2086 end
2087 end
2088 end)
2089
2090 stabocc = CurTime() + stabdelay
2091 end
2092 end
2093
2094 if self.noteleport == 0 then
2095
2096 net.Receive("tpselectedtoserver",function(len,ply)
2097 local ita = net.ReadTable()
2098
2099 selecteds = ita
2100
2101 end)
2102
2103 if (self.Owner:KeyDown( IN_DUCK )) && (self.Owner:KeyDown( IN_WALK )) then
2104 if not(self.Owner:KeyDown( IN_USE ))then
2105 if self.NextAtt>CurTime()||self.Tired then return end
2106 self:SansTeleport()
2107 end
2108 end
2109 if (self.Owner:KeyDown( IN_SPEED )) && (self.Owner:KeyDown( IN_DUCK )) then
2110 if not(self.Owner:KeyDown( IN_USE ))then
2111 if self.NextAtt>CurTime()||self.Tired then return end
2112 self:SansTeleportShort()
2113 end
2114 end
2115
2116 if teleportnow == 1 then
2117 if(istpreallyowner == self.Owner)then
2118
2119 sound.Play( "koperplyar/teleport.wav" , self.Owner:GetPos(), 75, math.random(85,105), 1 )
2120
2121 self:SetNWInt("Stre",math.Clamp(self:GetNWInt("Stre")+25.3,0,GetConVarNumber("gt_sans_sr")))
2122
2123 if(CLIENT) then
2124 net.Start("dobluemagic")
2125 net.WriteEntity(self.Owner)
2126 net.SendToServer()
2127 end
2128
2129 if(self.Owner.TPFriends)then
2130
2131 for i, a in pairs(self.Owner.TPFriends) do
2132
2133 self:SetNWInt("Stre",math.Clamp(self:GetNWInt("Stre")+10,0,GetConVarNumber("gt_sans_sr")))
2134
2135 local fpos = self.Owner:GetPos() - a:GetPos()
2136
2137 a:SetVelocity( -a:GetVelocity() )
2138 a:SetPos(newposition - fpos)
2139 if(CLIENT) then
2140 net.Start("dobluemagic")
2141 net.WriteEntity(a)
2142 net.SendToServer()
2143 end
2144 end
2145 end
2146
2147 self.Owner.TPFriends = nil
2148
2149 self.Owner:SetVelocity( -self.Owner:GetVelocity() )
2150 self.Owner:SetPos(newposition)
2151
2152 sound.Play( "koperplyar/teleport.wav" , self.Owner:GetPos(), 75, math.random(85,105), 1 )
2153
2154 self:SetHoldType( "normal" )
2155
2156 timer.Create("moretpeffectsa" .. tostring(self),0.01,50,function()
2157 net.Start( "tpeffects" )
2158 net.WriteEntity(self.Owner)
2159 net.Send( self.Owner )
2160 end)
2161 timer.Create("removeteleporteffects" .. tostring(self),0.75,1,function()
2162 timer.Remove( "teleportationeffects" .. tostring(self) )
2163 end)
2164
2165 teleportnow = 0
2166 end
2167 end
2168
2169 end
2170
2171 if self.noteleport == 0 then
2172 if not(self.Owner:KeyDown( IN_USE ))then
2173 if (self.Owner:KeyDown( IN_SPEED )) && (self.Owner:KeyDown( IN_WALK )) then
2174 local altctrltimeLeft = altctrlnextOccurance - CurTime()
2175 if altctrltimeLeft < 0 then
2176
2177 if(self.Owner.Shielding == 1) then return end
2178 if self.NextAtt>CurTime()||self.Tired then return end
2179
2180 local ptimleft = pocc - CurTime()
2181 if ptimleft < 0 then
2182
2183 self:PiercingBones()
2184
2185 pocc = CurTime() + pdelay
2186 end
2187
2188 end
2189 end
2190 end
2191 end
2192
2193 SansShared(self)
2194
2195end
2196
2197function SWEP:PiercingBones()
2198 if SERVER then
2199
2200
2201 --local g=ents.Create("ent_glitchtale_pbone")
2202 --local p=VectorRand()*math.random(60,139)
2203 --p.z=l*math.random(30,129)
2204 --local t=util.TraceLine({start=o:EyePos(),endpos=o:EyePos()+p,filter=o})
2205 --if t.Hit then p=t.HitPos+t.HitNormal*30 else p=o:EyePos()+p end
2206 --g:SetPos(p)
2207 --local e=(o:GetEyeTrace().HitPos-p):Angle()
2208 --g:SetAngles(e+Angle(90))
2209 --g:SetOwner(o)
2210 --g:SetVar( "pos", p )
2211 --g:SetVar( "normal", p )
2212 --g.Dmg=7+(l-.1)*10
2213 --local s=1
2214 --g:Spawn()
2215 --g:SetParent(self.Owner)
2216 --self.NextAtt=CurTime()
2217
2218 local tr = util.TraceLine( {
2219 start = self.Owner:GetShootPos(),
2220 endpos = self.Owner:GetShootPos() + self.Owner:EyeAngles():Forward() * 3333,
2221 filter = function( ent ) if ( ent:GetClass() == "prop_physics" ) then return false end end
2222 } )
2223
2224 local pos = tr.HitPos
2225 local rad = 104
2226
2227 sound.Play( Sound( "undertale/bone_start.wav" ), tr.HitPos )
2228
2229 for i = 1, 47 do --69 in second phase
2230 self:SendWeaponAnim(190)
2231 self:SetHoldType("pistol")
2232
2233 local n=self:GetNWInt("Stre")
2234 self:SetNWInt("Stre",math.Clamp(n+0.43,0,GetConVarNumber("gt_sans_sr")))
2235
2236 local vec = Vector( math.Rand( -rad, rad ), math.Rand( -rad, rad ), 0 )
2237 vec:Rotate( tr.HitNormal:Angle() + Angle( 90, 0, 0 ) )
2238 local ang = ( tr.HitNormal * 3 + VectorRand() ):Angle() --number adjusts how straight the bones are
2239
2240 local traceGrd = util.TraceLine( {
2241 start = pos + vec,
2242 endpos = pos + vec - ang:Up() * 50,
2243 filter = function( ent ) if ( ent:GetClass() == "prop_physics" ) then return true end end
2244 } )
2245
2246 if( traceGrd.Hit ) then
2247 local ent = ents.Create( "ent_glitchtale_pbone" )
2248 ent:SetAngles( ang + Angle( 90, 0, 0 ) )
2249 ent:SetVar( "pos", pos )
2250 ent:SetVar( "normal", tr.HitNormal )
2251 ent:SetPos( traceGrd.HitPos )
2252 ent:SetOwner( self.Owner )
2253 --ent:EmitSound( "undertale/bone_start.wav", 75, 100, 1, CHAN_AUTO )
2254 ent:Spawn()
2255 self.NextAtt=CurTime()
2256 end
2257 end
2258
2259 else
2260 self.NextAtt=CurTime()+1
2261 self:SetNextPrimaryFire(CurTime()+1)
2262 self:SetNextSecondaryFire(CurTime()+1)
2263
2264 end
2265
2266 self.Owner.Shielding = 0
2267
2268end
2269
2270
2271function SWEP:Reload()
2272 local rtimeleft = rocc - CurTime()
2273 if rtimeleft < 0 then
2274 --timer.Remove("checkreload" .. tostring(self))
2275 -- timer.Create("checkreload" .. tostring(self), 0.25, 1, function()
2276 --self.Owner.Shielding = 0
2277 --end)
2278
2279 if self.NextAtt>CurTime()||self.Tired then return end
2280
2281 if self.Owner.Shielding == 0 then
2282 if SERVER then
2283 local entsb = ents.Create("ent_glitchtale_bone_spinner")
2284 local possb = self.Owner:GetPos()
2285
2286 entsb:SetAngles((self.Owner:GetEyeTrace().HitPos - possb):Angle())
2287 entsb:SetPos(self.Owner:GetPos() + Vector(0, 0, 45) + self.Owner:GetForward() * 50)
2288 entsb:SetOwner(self.Owner)
2289 entsb:Spawn()
2290
2291 table.insert(self.Shield, entsb)
2292
2293 entsb:CallOnRemove("chrRemoveFromList", function(entsb)
2294 if IsValid(self) then
2295 table.RemoveByValue(self.Shield, entsb)
2296 end
2297 end)
2298
2299 local entsbfake = ents.Create("ent_glitchtale_bone_faker")
2300 local posfake = self.Owner:GetPos()
2301
2302 entsbfake:SetAngles((self.Owner:GetEyeTrace().HitPos - posfake):Angle())
2303 entsbfake:SetPos(self.Owner:GetPos() + Vector(0, 0, 45) + self.Owner:GetForward() * 50)
2304 entsbfake:SetOwner(self.Owner)
2305 entsbfake:Spawn()
2306
2307 table.insert(self.Shield, entsbfake)
2308
2309 entsbfake:CallOnRemove("chrRemoveFromList", function(entsbfake)
2310 if IsValid(self) then
2311 table.RemoveByValue(self.Shield, entsbfake)
2312 end
2313 end)
2314 end
2315
2316 self:SetHoldType("pistol")
2317 self:TelekanisisAnim_Start()
2318 self.Owner:AddFlags(FL_ATCONTROLS)
2319 self.Owner.Shielding = 1
2320
2321 timer.Create("CheckKeyRelease" .. tostring(self.Owner), 0.1, 0, function()
2322 if not IsValid(self) or not IsValid(self.Owner) then return end
2323 if not self.Owner:KeyDown(IN_RELOAD) then
2324 self:TelekanisisAnim_Stop()
2325 self:SetHoldType("normal")
2326 self.Owner:RemoveFlags(FL_ATCONTROLS)
2327 self.Owner.Shielding = 0
2328
2329 if SERVER then
2330 for _, ent in ipairs(self.Shield) do
2331 if IsValid(ent) then ent:Removeself() end
2332 end
2333 end
2334
2335 self.Shield = {}
2336 timer.Remove("CheckKeyRelease" .. tostring(self.Owner))
2337 end
2338 end)
2339 end
2340
2341 --if not(self.Sradiusa)then
2342 --self.Sradiusa = 20
2343 --end
2344
2345 --self.Sradiusa = self.Sradiusa + 20
2346
2347 --if(self.Sradiusa > 100)then
2348 --self.Sradiusa = 20
2349 --end
2350 --local tablecircle = {}
2351
2352 --for i = 1,360, 20 do
2353
2354 --local x, y = CalculateCircle( self.Sradiusa, i , 0, 0 )
2355
2356 --local vectori = Vector(x,0,y)
2357 --vectori:Rotate( self.Owner:EyeAngles() + Angle(0,90,0) )
2358
2359 --table.insert(tablecircle, vectori)
2360
2361 --end
2362 --if(SERVER)then
2363 --for i, a in pairs(player.GetAll()) do
2364 --net.Start("shieldeffectso")
2365 --net.WriteEntity(self)
2366 --net.WriteTable(tablecircle)
2367 --net.Send(a)
2368 --end
2369 --end
2370
2371 rocc = CurTime() + 2.57
2372 end
2373end
2374
2375
2376
2377function SWEP:TelekanisisAnim_Start()
2378
2379 self:SendWeaponAnim(195)
2380
2381 timer.Create("telekanisisidlea" .. tostring(self),0.5,1,function()
2382 if(IsValid(self))then
2383 if(self.Telekanisising == nil)then
2384 self:TelekanisisAnim_Idle()
2385 end
2386 end
2387 end)
2388
2389 self.Telekanisising = nil
2390
2391end
2392function SWEP:TelekanisisAnim_Idle()
2393
2394 self:SendWeaponAnim(196)
2395
2396end
2397function SWEP:TelekanisisAnim_Stop()
2398
2399 self.Telekanisising = 1
2400
2401 self:SendWeaponAnim(197)
2402
2403 timer.Create("backtoidletelekanisis" .. tostring(self),0.5,1,function()
2404 if(IsValid(self))then
2405 if(self.Telekanisising == 1)then
2406 self:SendWeaponAnim(174)
2407 end
2408 end
2409 end)
2410
2411end
2412
2413
2414function SWEP:SansTeleportShort()
2415 local shiftalttimeLeft = saocc - CurTime()
2416 if shiftalttimeLeft < 0 then
2417
2418 self:SendWeaponAnim(189)
2419
2420 timer.Create("shortteleportbacktoidle" .. tostring(self),0.45,1,function()
2421 if(IsValid(self))then
2422 self:SendWeaponAnim(174)
2423 end
2424 end)
2425
2426 local teleportnow = 0
2427
2428 local number = 1500
2429
2430 local forwarda = Vector((self.Owner:EyeAngles():Forward() * number).x,(self.Owner:EyeAngles():Forward() * number).y,0)
2431
2432 local tr = util.TraceLine( {
2433 start = self.Owner:GetPos() + Vector(0,0,30),
2434 endpos = self.Owner:GetPos() + Vector(0,0,30) + forwarda,
2435 filter = self.Owner
2436 } )
2437
2438 local tr2 = util.TraceLine( {
2439 start = self.Owner:GetPos() + Vector(0,0,30) + forwarda,
2440 endpos = self.Owner:GetPos() + Vector(0,0,30) + forwarda + Vector(0,0,number),
2441 filter = self.Owner
2442 } )
2443
2444 local tr3 = util.TraceLine( {
2445 start = self.Owner:GetPos(),
2446 endpos = self.Owner:GetPos(),
2447 filter = self.Owner
2448 } )
2449 local posu = Vector(0,0,0)
2450 local posu1 = Vector(0,0,0)
2451
2452 if(tr2.HitNormal)then
2453 posu = tr3.HitPos - self.Owner:GetPos()
2454 end
2455 if(tr.HitNormal)then
2456 posu1 = tr.HitNormal * 40
2457 end
2458
2459 local pos = tr.HitPos + posu + posu1
2460
2461 if(CLIENT)then
2462 net.Start( "teleportnownet" )
2463 net.WriteVector(pos)
2464 net.SendToServer()
2465 end
2466
2467 if(self.ShortTpadddelay)then
2468 self.ShortTpadddelay = self.ShortTpadddelay + 0.1
2469 else
2470 self.ShortTpadddelay = 0
2471 end
2472 timer.Remove("setitbacktonormaldelay" .. tostring(self))
2473 timer.Create("setitbacktonormaldelay" .. tostring(self),3,1,function()
2474 if(IsValid(self))then
2475 self.ShortTpadddelay = 0
2476 end
2477 end)
2478
2479 saocc = CurTime() + 0.451 + self.ShortTpadddelay
2480 end
2481end
2482
2483function SWEP:SansTeleport()
2484 local shiftalttimeLeft = saocc - CurTime()
2485 if shiftalttimeLeft < 0 then
2486
2487 self:SendWeaponAnim(187)
2488
2489
2490 self:SetHoldType( "melee" )
2491 local selected
2492 local locations = {}
2493 local map = game.GetMap()
2494 local teleportnow = 0
2495 local selected2
2496 local changed = false
2497
2498 timer.Create("teleportationeffects" .. tostring(self),0.01,0,function()
2499 if(CLIENT)then return end
2500
2501 if(IsValid(self))then
2502
2503 if(tpstopsv == 1)then
2504
2505 self:SendWeaponAnim(188)
2506
2507
2508 timer.Remove("teleportationeffects" .. tostring(self))
2509 timer.Remove("snapingidle" .. tostring(self))
2510
2511 tpstopsv = 0
2512
2513 return
2514
2515 end
2516
2517 net.Start( "tpeffects" )
2518 net.WriteEntity(self.Owner)
2519 net.Send( self.Owner )
2520
2521 if selecteds then
2522 net.Start( "tpbeforeeffects" )
2523 net.WriteEntity(self.Owner)
2524 net.WriteVector(selecteds.pos)
2525 net.Send( self.Owner )
2526 end
2527
2528 else
2529 timer.Remove("teleportationeffects" .. tostring(self))
2530 timer.Remove("snapingidle" .. tostring(self))
2531 end
2532 end)
2533
2534 tpstopsv = 0
2535
2536 if(CLIENT) then
2537
2538 if(self.panel)then
2539 return
2540 end
2541
2542 local window = vgui.Create( "DFrame" )
2543 window:SetSize( 600,600 )
2544 window:Center()
2545 window:SetTitle( "Sans Teleportation Menu" )
2546 window:MakePopup()
2547 window.Paint = function( self, w, h ) -- 'function Frame:Paint( w, h )' works too
2548 draw.RoundedBox( 0, 0, 0, w, h, Color( 100, 150, 255, 150 ) ) -- Draw a red box instead of the frame
2549 end
2550
2551
2552
2553 function window:OnClose()
2554 net.Start("tpclose")
2555 net.SendToServer()
2556
2557 timer.Remove("teleportationeffects" .. tostring(self))
2558 timer.Remove("snapingidle" .. tostring(self))
2559 end
2560
2561 local label = vgui.Create( "DLabel", window )
2562 label:SetPos(320,100)
2563 label:SetColor(Color(255,255,255,255))
2564 label:SetFont("DermaLarge")
2565 label:SetText("Cordinates")
2566 label:SizeToContents()
2567
2568 local vec1 = vgui.Create( "DTextEntry", window )
2569 vec1:SetPos( 250, 150 )
2570 vec1:SetSize( 100, 25 )
2571 vec1:SetText( "X" )
2572 vec1.OnGetFocus = function( self )
2573 if self:GetValue()=="X" then
2574 self:SetText("")
2575 end
2576 end
2577 vec1.OnLoseFocus = function( self )
2578 if self:GetValue()=="" then
2579 self:SetText("X")
2580 else
2581 self:OnEnter()
2582 end
2583 end
2584 vec1.OnEnter = function( self )
2585 if selected and tonumber(self:GetValue()) then
2586 selected.pos.x=tonumber(self:GetValue())
2587 changed=true
2588 end
2589 end
2590
2591
2592 local vec2 = vgui.Create( "DTextEntry", window )
2593 vec2:SetPos( 340, 150 )
2594 vec2:SetSize( 100, 25 )
2595 vec2:SetText( "Y" )
2596 vec2.OnGetFocus = function( self )
2597 if self:GetValue()=="Y" then
2598 self:SetText("")
2599 end
2600 end
2601 vec2.OnLoseFocus = function( self )
2602 if self:GetValue()=="" then
2603 self:SetText("Y")
2604 else
2605 self:OnEnter()
2606 end
2607 end
2608 vec2.OnEnter = function( self )
2609 if selected and tonumber(self:GetValue()) then
2610 selected.pos.y=tonumber(self:GetValue())
2611 changed=true
2612 end
2613 end
2614
2615
2616 local vec3 = vgui.Create( "DTextEntry", window )
2617 vec3:SetPos( 430, 150 )
2618 vec3:SetSize( 100, 25 )
2619 vec3:SetText( "Z" )
2620 vec3.OnGetFocus = function( self )
2621 if self:GetValue()=="Z" then
2622 self:SetText("")
2623 end
2624 end
2625 vec3.OnLoseFocus = function( self )
2626 if self:GetValue()=="" then
2627 self:SetText("Z")
2628 else
2629 self:OnEnter()
2630 end
2631 end
2632 vec3.OnEnter = function( self )
2633 if selected and tonumber(self:GetValue()) then
2634 selected.pos.z=tonumber(self:GetValue())
2635 changed=true
2636 end
2637 end
2638
2639 local function UpdateTextBoxes()
2640 if selected then
2641 local vec=selected.pos
2642 if vec then
2643 vec1:SetText(vec.x)
2644 vec2:SetText(vec.y)
2645 vec3:SetText(vec.z)
2646 end
2647 else
2648 vec1:SetText("X")
2649 vec2:SetText("Y")
2650 vec3:SetText("Z")
2651 end
2652 end
2653
2654 local listview = vgui.Create( "DListView", window )
2655 listview:SetPos(10,30)
2656 listview:SetSize(225,260)
2657 listview:SetMultiSelect( false )
2658 listview:AddColumn( "Saved Locations" )
2659 listview.OnClickLine = function(self,line)
2660
2661 local name=line:GetValue(1)
2662
2663 self:ClearSelection()
2664 self:SelectItem(line)
2665
2666 for k,v in pairs(locations[map]) do
2667 if v.name==name then
2668 selected=v
2669 selected2=line
2670 UpdateTextBoxes()
2671 if selected then
2672 net.Start("tpselectedtoserver")
2673 net.WriteTable(selected)
2674 net.SendToServer()
2675 end
2676 end
2677 end
2678 end
2679
2680 local friendfoe = {}
2681
2682 listview.OnRowRightClick = function(lineid,line)
2683
2684 local name=lineid:GetValue(1)
2685
2686 for k,v in pairs(locations[map]) do
2687 if v.name==name then
2688 selected=v
2689 selected2=lineid
2690 UpdateTextBoxes()
2691
2692 if selected then
2693 net.Start("tpselectedtoserver")
2694 net.WriteTable(selected)
2695 net.SendToServer()
2696 end
2697 end
2698 end
2699
2700 if selected then
2701 for i, a in pairs(friendfoe)do
2702
2703 if((a:GetPos() - self.Owner:GetPos()):Length() > 150)then
2704 table.RemoveByValue(friendfoe,a)
2705 end
2706
2707 end
2708
2709 self.Owner.ReturnPrevios = self.Owner:GetPos()
2710
2711 net.Start( "teleportnownet" )
2712
2713 net.WriteVector(selected.pos)
2714
2715 if friendfoe then
2716 net.WriteTable(friendfoe)
2717 end
2718
2719 net.SendToServer()
2720
2721
2722 window:Close()
2723 else
2724 LocalPlayer():ChatPrint("No location selected.")
2725 end
2726 end
2727
2728 local nowline
2729
2730 local listview1 = vgui.Create( "DListView", window )
2731 listview1:SetPos(190,400)
2732 listview1:SetSize(200,150)
2733 listview1:SetMultiSelect( false )
2734 listview1:AddColumn( "Friends or Foes?" )
2735 listview1.OnClickLine = function(self,line)
2736
2737 nowline = line:GetValue(1)
2738
2739 if(table.HasValue( friendfoe, nowline ))then
2740
2741 table.RemoveByValue(friendfoe,line:GetValue(1))
2742
2743 function line:Paint( width, hight )
2744
2745
2746
2747 end
2748
2749 else
2750 table.insert(friendfoe,line:GetValue(1))
2751
2752 function line:Paint( width, hight )
2753
2754 surface.SetDrawColor( 0, 200, 150, 150 )
2755 surface.DrawRect(0, 0, width, hight)
2756
2757 end
2758
2759 end
2760
2761 end
2762
2763 local function Reload()
2764 listview:ClearSelection()
2765 listview:Clear()
2766 selected=nil
2767 selected2=nil
2768
2769 for k,v in pairs(locations[map]) do
2770 listview:AddLine( v.name )
2771 end
2772
2773 if(self.Owner)then
2774
2775 local friends = ents.FindInSphere( self.Owner:GetPos(), 300 )
2776
2777 for i, f in pairs(friends) do
2778
2779 if((f:IsPlayer() or f:IsNPC()) && f != self.Owner)then
2780
2781 listview1:AddLine( f )
2782
2783 end
2784 end
2785 end
2786 UpdateTextBoxes()
2787
2788 end
2789
2790
2791
2792 local function Load(msg)
2793 locations={}
2794 locations[map]={}
2795 if file.Exists("sans_locations.txt", "DATA") then
2796 locations=von.deserialize(file.Read("sans_locations.txt"))
2797 if not locations[map] then
2798 locations[map]={}
2799 end
2800 if msg then
2801 LocalPlayer():ChatPrint("Sans Locations loaded.")
2802 end
2803 elseif file.Exists("gasters_locations.txt", "DATA") then
2804 locations=von.deserialize(file.Read("gasters_locations.txt"))
2805 if not locations[map] then
2806 locations[map]={}
2807 end
2808 if msg then
2809 LocalPlayer():ChatPrint("No Sans's Locations found, but found Gaster's Locations.")
2810 end
2811 end
2812 Reload()
2813 end
2814 Load(false)
2815
2816 local function Save(msg)
2817 file.Write("sans_locations.txt", von.serialize(locations))
2818 changed=false
2819 if msg then
2820 LocalPlayer():ChatPrint("Sans Locations saved.")
2821 end
2822 end
2823
2824 local function New()
2825 Derma_StringRequest(
2826 "New Location",
2827 "Please enter a name for the new location",
2828 "",
2829 function(name)
2830 local exists=false
2831 for k,v in pairs(locations[map]) do
2832 if v.name==name then
2833 exists=true
2834 break
2835 end
2836 end
2837 if string.len(name)==0 then
2838 LocalPlayer():ChatPrint("Invalid name.")
2839 elseif exists then
2840 LocalPlayer():ChatPrint("Name already in use.")
2841 else
2842 local pos=Vector(0,0,0)
2843 local ang=Angle(0,0,0)
2844 Derma_Query(
2845 "Would you like to use the current Position?",
2846 "Use Current Pos?",
2847 "Yes",
2848 function()
2849 if IsValid(self.Owner) then
2850 pos=self.Owner:GetPos()
2851 ang=self.Owner:GetAngles()
2852 else
2853 LocalPlayer():ChatPrint("Error, som shit gone wrong")
2854 end
2855 table.insert(locations[map], {name=name, pos=pos, ang=ang})
2856 Reload()
2857 changed=true
2858 end,
2859 "No",
2860 function()
2861 table.insert(locations[map], {name=name, pos=pos, ang=ang})
2862 Reload()
2863 changed=true
2864 end
2865 )
2866 end
2867 end,
2868 function(name) end
2869 )
2870 end
2871
2872 local function Rename(location,line)
2873 Derma_StringRequest(
2874 "New Location",
2875 "Please enter a new name for the location",
2876 location.name,
2877 function(name)
2878 local exists=false
2879 for k,v in pairs(locations[map]) do
2880 if v.name==name then
2881 exists=true
2882 break
2883 end
2884 end
2885 if string.len(name)==0 then
2886 LocalPlayer():ChatPrint("We don't tolerate nothingness here!")
2887 elseif exists then
2888 local funninamealreadyexistsnames = {"Nope.", "Nah.", "No. I Refuse", "Originality is nice to have."}
2889 LocalPlayer():ChatPrint(table.Random(funninamealreadyexistsnames))
2890 else
2891 location.name=name
2892 Reload()
2893 changed=true
2894 end
2895 end,
2896 function(name) end
2897 )
2898 end
2899 local function Clear()
2900 Derma_Query(
2901 "Are you sure you want to clear this maps stored location data?",
2902 "Clear Data",
2903 "Yes",
2904 function()
2905 locations[map]={}
2906 Reload()
2907 LocalPlayer():ChatPrint("Map location data cleared.")
2908 changed=true
2909 end,
2910 "No",
2911 function()
2912 end
2913 )
2914 end
2915
2916 local function Delete(location)
2917 for k,v in pairs(locations[map]) do
2918 if v.name==location.name then
2919 table.remove(locations[map],k)
2920 Reload()
2921 changed=true
2922 end
2923 end
2924 end
2925
2926 local closefunc = window.Close
2927 window.Close=function(self)
2928 if changed then
2929 Save(true)
2930 closefunc(self)
2931 else
2932 closefunc(self)
2933 end
2934
2935 net.Start("tpclose")
2936 net.SendToServer()
2937
2938 timer.Remove("checkforpeople" .. tostring(self))
2939
2940 end
2941
2942 local button = vgui.Create( "DButton", window )
2943 button:SetSize( 100, 30 )
2944 button:SetPos( 250, 200 )
2945 button:SetText( "New" )
2946 button.DoClick = function( button )
2947 New()
2948 end
2949
2950 local button = vgui.Create( "DButton", window )
2951 button:SetSize( 100, 30 )
2952 button:SetPos( 340, 200 )
2953 button:SetText( "Rename" )
2954 button.DoClick = function( button )
2955 if selected then
2956 Rename(selected,selected2)
2957 else
2958 LocalPlayer():ChatPrint("No location selected.")
2959 end
2960 end
2961
2962 local button = vgui.Create( "DButton", window )
2963 button:SetSize( 100, 30 )
2964 button:SetPos( 430, 200 )
2965 button:SetText( "Delete" )
2966 button.DoClick = function( button )
2967 if selected then
2968 Delete(selected)
2969 else
2970 LocalPlayer():ChatPrint("No location selected.")
2971 end
2972 end
2973
2974 local button = vgui.Create( "DButton", window )
2975 button:SetSize( 100, 30 )
2976 button:SetPos( 400, 300 )
2977 button:SetText( "Music" )
2978 button.DoClick = function( button )
2979 local randuma = math.random(1,3)
2980
2981 if(randuma == 1)then
2982 self:StopSound("koperplyar/megalovania1.mp3")
2983 self:StopSound("koperplyar/megalovania2.mp3")
2984 self:StopSound("koperplyar/megalovania3.mp3")
2985
2986 self:EmitSound("koperplyar/megalovania1.mp3", 75, 100, 1)
2987 end
2988 if(randuma == 2)then
2989 self:StopSound("koperplyar/megalovania1.mp3")
2990 self:StopSound("koperplyar/megalovania2.mp3")
2991 self:StopSound("koperplyar/megalovania3.mp3")
2992
2993 self:EmitSound("koperplyar/megalovania2.mp3", 75, 100, 1)
2994 end
2995 if(randuma == 3)then
2996 self:StopSound("koperplyar/megalovania1.mp3")
2997 self:StopSound("koperplyar/megalovania2.mp3")
2998 self:StopSound("koperplyar/megalovania3.mp3")
2999
3000 self:EmitSound("koperplyar/megalovania3.mp3", 75, 100, 1)
3001 end
3002
3003 end
3004 local button = vgui.Create( "DButton", window )
3005 button:SetSize( 100, 30 )
3006 button:SetPos( 490, 300 )
3007 button:SetText( "Stop" )
3008 button.DoClick = function( button )
3009 self:StopSound("koperplyar/megalovania1.mp3")
3010 self:StopSound("koperplyar/megalovania2.mp3")
3011 self:StopSound("koperplyar/megalovania3.mp3")
3012 end
3013
3014
3015 local button = vgui.Create( "DButton", window )
3016 button:SetSize( 100, 30 )
3017 button:SetPos( 0, 500 )
3018 button:SetText( "Help (console)" )
3019 button.DoClick = function( button )
3020 print("Main Controlls:")
3021 print("Primary: Fast Shooting Bones")
3022 print("Secondary: Gasterblaster. (up to 7)")
3023 print("50% can be locked down, so the other 50% aims further: (hold down E)")
3024 print("feature: can use telekanisis to edit the gasterblasters position (accidental feature)")
3025 print("Press E on the gasterblaster to fly it! and repress E to jump off.")
3026 print("Telekanisis (E): Can make objects fly to your will. (warning! players might be able to escape! keep them near you! this is a feature!)")
3027 print("can also use Shift / Tab to make them come closer or farther.")
3028 print("when pressing Alt it will launch it.")
3029 print("holding down SPACE and the movement-keys, will make it rotate!")
3030 print("Quick Teleport: When you press Shift + Crouch, you will quick teleport (you cannot teleport UP. this is intentional)")
3031 print("Long Teleport: When you press Schift + Alt, a menu will appear (this menu) where you can;")
3032 print("make new locations using X,Y,Z cordinates.")
3033 print("teleport to destination by right clicking.")
3034 print("or select the position. (this will show in game where the position is... via blue-effects)")
3035 print("delete....rename....and clear everything.")
3036 print("the music button plays one of the 3 remixes of megalovania. the stop button makes it stop.")
3037 print("the friends or foes is an feature that lets you click on nearby allies for them to teleport with you")
3038 print("it works by left clicking on one of the nearby entities within a radius on the menu, it should be highlited greenish blue")
3039 print("and to deselect simply left click again. it should return to white.")
3040 print("Piercing Bones: Shift + Crouch allows you to draw a line, wich will make an rectangle wich includes bones. that damage....")
3041 print("simply press the buttons, and move your mouse within 1 second")
3042 print("Shield (R): Simply hold down R to have a shield on. if working correctly. particles in formations of circles will appear, and you will get * 0.25 the damage")
3043 print("or otherwise known as /4 the damage.")
3044 print("Misc:")
3045 print("Custom Death: simply die. (if working correctly: body will dust / disintegrate)")
3046 print("Able to receive /~quote~/SOUL/~quote~/ from DT Sword, NOT YET IMPLEMENTED, IT AIN HIA.")
3047
3048 end
3049
3050
3051 local label = vgui.Create( "DLabel", window )
3052 label:SetPos(260,300) -- Position
3053 label:SetColor(Color(255,255,255,255)) -- Color
3054 label:SetFont("Trebuchet24")
3055 label:SetText("Data") -- Text
3056 label:SizeToContents() -- make the control the same size as the text.
3057
3058 local button = vgui.Create( "DButton", window )
3059 button:SetSize( 100, 30 )
3060 button:SetPos( 75, 300 )
3061 button:SetText( "Return" )
3062 button.DoClick = function( button )
3063 if(self.Owner.ReturnPrevios)then
3064
3065 for i, a in pairs(friendfoe)do
3066
3067 if((a:GetPos() - self.Owner:GetPos()):Length() > 150)then
3068 table.RemoveByValue(friendfoe,a)
3069 end
3070
3071 end
3072
3073 net.Start( "teleportnownet" )
3074 net.WriteVector(self.Owner.ReturnPrevios)
3075
3076 if friendfoe then
3077 net.WriteTable(friendfoe)
3078 end
3079 net.SendToServer()
3080
3081 window:Close()
3082
3083 else
3084 self.Owner:ChatPrint("No earlier Location!")
3085 end
3086 end
3087
3088
3089 local button = vgui.Create( "DButton", window )
3090 button:SetSize( 100, 30 )
3091 button:SetPos( 140, 350 )
3092 button:SetText( "Clear Data" )
3093 button.DoClick = function( button )
3094 Clear()
3095 end
3096
3097 local button = vgui.Create( "DButton", window )
3098 button:SetSize( 100, 30 )
3099 button:SetPos( 240, 350 )
3100 button:SetText( "Load Data" )
3101 button.DoClick = function( button )
3102 Load(true)
3103 end
3104
3105 local button = vgui.Create( "DButton", window )
3106 button:SetSize( 100, 30 )
3107 button:SetPos( 340, 350 )
3108 button:SetText( "Save Data" )
3109 button.DoClick = function( button )
3110 Save(true)
3111 end
3112
3113 self.panel = 1
3114
3115 end
3116
3117 saocc = CurTime() + sadelay
3118 end
3119end
3120
3121
3122local dodgeFadeAlphaD = 255 -- Start at full opacity
3123local fadeSpeedD = 23 -- Speed at which the bar fades away
3124
3125local dodgeFadeAlphaS = 255 -- Start at full opacity
3126local fadeSpeedS = 11 -- Speed at which the bar fades away
3127
3128local dodgeFadeAlphaT = 255 -- Start at full opacity
3129local fadeSpeedT = 20 -- Speed at which the bar fades away
3130
3131if (CLIENT) then
3132
3133 function SWEP:DrawHUD()
3134 local x=ScrW()/2
3135 local y=ScrH()/2
3136 local tc=TEXT_ALIGN_CENTER
3137 local tr=TEXT_ALIGN_RIGHT
3138 local tl=TEXT_ALIGN_LEFT
3139 local p=self.Owner
3140 local te=p:GetEyeTrace()
3141 local ta=te.Entity
3142 local c=color_white
3143
3144 local d = self:GetNWInt("D") -- Dodge delay
3145 local n = self:GetNWInt("Stre")
3146 local tele = self:GetNWInt("Tele")
3147
3148 local fadeOutD = false
3149 local fadeOutS = false
3150 local fadeOutT = false
3151
3152 if d <= 0 then
3153 fadeOutD = true -- Start fading when the bar is full
3154 else
3155 fadeOutD = false
3156 dodgeFadeAlphaD = 255 -- Reset opacity when dodging again
3157 end
3158
3159 if n <= 0 then
3160 fadeOutS = true -- Start fading when the bar is full
3161 else
3162 fadeOutS = false
3163 dodgeFadeAlphaS = 255 -- Reset opacity when dodging again
3164 end
3165
3166 if tele <= 0 then
3167 fadeOutT = true -- Start fading when the bar is full
3168 else
3169 fadeOutT = false
3170 dodgeFadeAlphaT = 255 -- Reset opacity when dodging again
3171 end
3172
3173 -- Gradually decrease alpha when fading
3174 if fadeOutD then
3175 dodgeFadeAlphaD = math.max(0, dodgeFadeAlphaD - (FrameTime() * fadeSpeedD))
3176 end
3177 if fadeOutS then
3178 dodgeFadeAlphaS = math.max(0, dodgeFadeAlphaS - (FrameTime() * fadeSpeedS))
3179 end
3180 if fadeOutT then
3181 dodgeFadeAlphaT = math.max(0, dodgeFadeAlphaT - (FrameTime() * fadeSpeedT))
3182 end
3183
3184
3185
3186 surface.SetDrawColor(d*100,0,0,255 * (dodgeFadeAlphaD / 255))
3187 surface.DrawRect(ScrW()*.96-5,ScrH()*.35-5,ScrW()*.025+10,ScrH()*.1+10)
3188 surface.SetDrawColor(0,205-d*100,255-d* 100, dodgeFadeAlphaD)
3189 surface.DrawRect(ScrW()*.96,ScrH()*.35,ScrW()*.025,ScrH()*.1*(1-d))
3190 draw.SimpleText("Dodge delay", "8bitoperator", ScrW() * .99, ScrH() * .47,Color(255,255-d*100,255-d * 100, dodgeFadeAlphaD),tr,tc)
3191
3192
3193 surface.SetDrawColor(0,0,0,255 * (dodgeFadeAlphaS / 255))
3194 surface.DrawRect(ScrW()*.96-5,ScrH()*.5-5,ScrW()*.025+10,ScrH()*.25+10)
3195 --surface.SetDrawColor(0,0,255,155)
3196 --surface.SetDrawColor(255,255,255,255)
3197 surface.SetDrawColor(255,255-n*2.3,102-n*2.3, dodgeFadeAlphaS)
3198 local g=1-self:GetNWInt("Stre")/GetConVarNumber("gt_sans_sr")
3199 local u=math.floor(math.sin(CurTime()*9)*1.2)
3200 local u2=0
3201 local r=math.floor(math.sin(CurTime()*4.5+1)*1.1)
3202 if g<.35 then r=0 u=math.floor(math.sin(CurTime()*2)/2*3.6)u2=u/2 end
3203 u=ScrH()-298+u
3204 r=ScrW()-250+r
3205 surface.DrawRect(ScrW()*.96,ScrH()*.5,ScrW()*.025,ScrH()*.25*g)
3206 --surface.SetDrawColor(0,0,0,255)
3207 local t=1-math.Clamp(self:GetNextPrimaryFire()-CurTime(),0,5)*2
3208 --surface.SetDrawColor(255,255,255,255*t)
3209 draw.SimpleText("Strength", "8bitoperator", ScrW() * .99, ScrH() * .77,Color(255,255-n*2,255-n*2, dodgeFadeAlphaS),tr,tc)
3210
3211
3212 surface.SetDrawColor(0,0,0,255 * (dodgeFadeAlphaT / 255))
3213 surface.DrawRect(ScrW()*.01-5,ScrH()*.5-5,ScrW()*.025+10,ScrH()*.25+10) -- Adjusted position to left side
3214 surface.SetDrawColor(0,105-tele*3.5,255-tele*3.5, dodgeFadeAlphaT)
3215 local gtele=1-self:GetNWInt("Tele")/GetConVarNumber("gt_sans_tc")
3216 local utele=math.floor(math.sin(CurTime()*9)*1.2)
3217 local utele2=0
3218 local l=math.floor(math.sin(CurTime()*4.5+1)*1.1)
3219 if gtele<.35 then l=0 utele=math.floor(math.sin(CurTime()*2)/2*3.6)utele2=utele/2 end
3220 utele=ScrH()-298+utele
3221 l=250+l -- Changed from ScrW()-250+l to move it to the left
3222 surface.DrawRect(ScrW()*.01,ScrH()*.5,ScrW()*.025,ScrH()*.25*gtele) -- Adjusted position to left side
3223 local t=1-math.Clamp(self:GetNextPrimaryFire()-CurTime(),0,5)*2
3224 draw.SimpleText("Telekinesis", "8bitoperator", ScrW() * .01, ScrH() * .77,Color(255,255-tele*3.5,255-tele*3.5, dodgeFadeAlphaT),tl,tc) -- Adjusted text position to left
3225
3226 local sizex = 300
3227 local sizey = 30
3228 local indentx = 10
3229 local indenty = 10
3230 local quarter = 105.6 -- Each quarter of the bar in units
3231
3232 local sastatus = saspower >= max_saspower and "Special Ability (Ready)" or "Special Ability"
3233
3234 -- Text
3235 surface.SetFont("ChatFont")
3236 surface.SetTextColor(100 + saspower, 100 + saspower, 100 + saspower, 255)
3237 surface.SetTextPos(ScrW() - sizex - indentx, ScrH() - sizey - indenty - 19)
3238 surface.DrawText(sastatus)
3239
3240 -- Background bar
3241 surface.SetDrawColor(90, 90, 90, 125)
3242 surface.DrawRect(ScrW() - sizex - indentx, ScrH() - sizey - indenty, sizex, sizey)
3243
3244 -- Progress bar
3245 surface.SetDrawColor(150 + saspower, 150 + saspower, 150 + saspower, 255)
3246 surface.DrawRect(ScrW() - sizex - indentx, ScrH() - sizey - indenty, (saspower / max_saspower) * sizex, sizey)
3247
3248 -- Quarter separators
3249 for i = 1, 2 do -- Draw 3 separators at 1/4, 1/2, and 3/4
3250 local separatorX = ScrW() - sizex - indentx + (i * quarter * (sizex / 300))
3251 surface.SetDrawColor(155 - saspower, 155 - saspower, 155 - saspower, 255) -- Black color for the separators
3252 surface.DrawRect(separatorX, ScrH() - sizey - indenty, 2, sizey) -- 2-pixel wide line
3253 end
3254 end
3255end
3256
3257
3258if CLIENT then
3259 hook.Add( "RenderScreenspaceEffects", "blueauras.RenderScreenspaceEffects", function()
3260 local lp = LocalPlayer()
3261 for k,v in ipairs( ents.GetAll() ) do
3262 local sanessuser = v:GetNWEntity( "blueauras", NULL)
3263
3264 if IsValid(sanessuser) then
3265 local col = Color(sanessuser:GetPlayerColor().x*2550,sanessuser:GetPlayerColor().y*2550,sanessuser:GetPlayerColor().z*2550,255)
3266 end
3267 end
3268
3269 for k,v in ipairs( player.GetAll() ) do
3270 local weap = v:GetActiveWeapon()
3271
3272 if IsValid(weap) and IsValid(weap:GetNWEntity( "blueauras", NULL)) then
3273 local sanessuser = weap:GetNWEntity( "blueauras", NULL)
3274 local col = Color(sanessuser:GetPlayerColor().x*2550,sanessuser:GetPlayerColor().y*2550,sanessuser:GetPlayerColor().z*2550,255)
3275 end
3276 end
3277 end)
3278
3279 hook.Add( "Think", "blueauras.Glow", function()
3280 for k,v in ipairs( ents.GetAll() ) do
3281 local sanessuser = v:GetNWEntity( "blueauras", NULL)
3282 if IsValid(sanessuser) then
3283 local light = DynamicLight( v:EntIndex() )
3284 if ( light ) then
3285 light.r = 0
3286 light.g = 155
3287 light.b = 255
3288 light.Pos = v:WorldSpaceCenter() + LocalPlayer():GetAimVector()
3289 light.Brightness = 22
3290 light.Size = 6
3291 light.Decay = 25
3292 light.DieTime = CurTime() + 0.2
3293 light.Style = 1
3294 end
3295 end
3296 end
3297 end )
3298end
3299