· 7 years ago · Jan 19, 2019, 07:44 PM
1if ( SERVER ) then
2 AddCSLuaFile( "shared.lua" )
3end
4
5if ( CLIENT ) then
6
7 SWEP.PrintName = "Death's Scythe"
8 SWEP.Author = "Tablo"
9 SWEP.Category = "Taco SWEPS"
10 SWEP.Slot = 0
11 SWEP.SlotPos = 1
12 SWEP.DrawAmmo = false
13 SWEP.IconLetter = "w"
14
15 killicon.AddFont( "weapon_crowbar", "HL2MPTypeDeath", "6", Color( 255, 80, 0, 255 ) )
16
17 surface.CreateFont( "Taco_Text", {
18 font = "Trebuchet24",
19 size = 30,
20 weight = 500,
21 blursize = 0,
22 scanlines = 0,
23 antialias = true,
24 underline = false,
25 italic = false,
26 strikeout = false,
27 symbol = false,
28 rotary = false,
29 shadow = false,
30 additive = false,
31 outline = false,
32 } )
33 surface.CreateFont( "Center_taco_text", {
34 font = "Trebuchet24",
35 size = 100,
36 weight = 100,
37 blursize = 0,
38 scanlines = 0,
39 antialias = true,
40 underline = false,
41 italic = false,
42 strikeout = false,
43 symbol = false,
44 rotary = false,
45 shadow = false,
46 additive = false,
47 outline = false,
48 } )
49end
50
51SWEP.Base = "weapon_base"
52
53SWEP.Spawnable = false
54SWEP.AdminSpawnable = false
55SWEP.AdminOnly = false
56
57
58SWEP.ViewModel = "models/tiggomods/weapons/DmC5/v_osiris.mdl"
59--SWEP.WorldModel = "models/tiggomods/weapons/DmC5/w_osiris.mdl"
60SWEP.DrawCrosshair = true
61
62SWEP.ViewModelFOV = 65
63
64SWEP.ViewModelFlip = false
65
66
67SWEP.Weight = 1
68SWEP.AutoSwitchTo = true
69SWEP.AutoSwitchFrom = false
70SWEP.CSMuzzleFlashes = false
71
72SWEP.Primary.Damage = 35
73SWEP.Primary.Force = 150
74SWEP.Primary.ClipSize = -1
75SWEP.Primary.Delay = 1
76SWEP.Primary.DefaultClip = 1
77SWEP.Primary.Automatic = false
78SWEP.Primary.Ammo = "none"
79
80SWEP.Secondary.ClipSize = -1
81SWEP.Secondary.DefaultClip = -1
82SWEP.Secondary.Damage = 0
83SWEP.Secondary.Automatic = false
84SWEP.Secondary.Ammo = "none"
85
86SWEP.Grim_Reaper_Miss_Sound = Sound("weapons/grim_reaper/sycth_swing.wav")
87SWEP.Grim_Reaper_Wall_Sound = Sound("weapons/grim_reaper/sycth_hit_wall_1.wav")
88SWEP.Grim_Reaper_Non_Wall_Sound = Sound("weapons/grim_reaper/sycth_hit_wall_1.wav")
89
90local nextheartbeat = 0
91
92SWEP.Grim_Reaper_Intro = Sound("ambient/voices/playground_memory.wav")
93
94SWEP.ViewModelFlip = false
95SWEP.UseHands = false
96SWEP.WorldModel = "" --models/tiggomods/weapons/dmc5/w_osiris.mdl
97SWEP.ShowWorldModel = false
98
99SWEP.WElements = {
100 ["reaperscythe"] = { type = "Model", model = "models/tiggomods/weapons/dmc5/w_osiris.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(3.635, 2.4, 0), angle = Angle(19.87, -3.507, 180), size = Vector(0.69, 0.69, 0.69), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
101}
102
103SWEP.Grim_Reaper_Slash_Distance = 140
104function SWEP:SetupDataTables()
105 self:NetworkVar( "Float", 0, "NextMeleeAttack" )
106end
107
108function SWEP:PrimaryAttack()
109
110 self.Owner:SetAnimation( PLAYER_ATTACK1 )
111 self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
112
113 if (hook.Run("CanPlayerSwingScyth", self.Owner) == false) then
114 return
115 end
116
117 self:EmitSound( self.Grim_Reaper_Miss_Sound )
118
119 self:SetNextMeleeAttack( CurTime() + 0.2 )
120
121 self:SetNextPrimaryFire( CurTime() + 0.4 )
122
123end
124
125function SWEP:Grim_Reaper_Deal_Damage()
126
127 self.Owner:LagCompensation( true )
128
129 local tr = util.TraceLine( {
130 start = self.Owner:GetShootPos(),
131 endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * self.Grim_Reaper_Slash_Distance,
132 filter = self.Owner,
133 mask = MASK_SHOT_HULL
134 } )
135
136 if ( !IsValid( tr.Entity ) ) then
137 tr = util.TraceHull( {
138 start = self.Owner:GetShootPos(),
139 endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * self.Grim_Reaper_Slash_Distance,
140 filter = self.Owner,
141 mins = Vector( -10, -10, -8 ),
142 maxs = Vector( 10, 10, 8 ),
143 mask = MASK_SHOT_HULL
144 } )
145 end
146
147 -- We need the second part for single player because SWEP:Think is ran shared in SP
148 if ( tr.HitWorld && !( game.SinglePlayer() && CLIENT ) ) then
149 self:EmitSound( self.Grim_Reaper_Wall_Sound )
150
151 elseif ( tr.HitNonWorld && !( game.SinglePlayer() && CLIENT ) ) then
152 self:EmitSound( self.Grim_Reaper_Non_Wall_Sound )
153 end
154
155 if IsValid( tr.Entity ) then
156 if ( tr.Entity:GetClass() == "func_breakable_surf" ) then
157 local bullet = {}
158 bullet.Num= 1
159 bullet.Src = self.Owner:GetShootPos()
160 bullet.Dir= self.Owner:GetAimVector()
161 bullet.Spread = Vector(0,0,0)
162 bullet.Tracer = 0
163 bullet.Force = 1
164 bullet.Damage = 0
165 self.Owner:FireBullets(bullet)
166 end
167 end
168
169 local hit = false
170
171 if ( SERVER && IsValid( tr.Entity ) && ( tr.Entity:IsPlayer()) ) then
172 local dmginfo = DamageInfo()
173
174 local attacker = self.Owner
175 if ( !IsValid( attacker ) ) then attacker = self end
176 dmginfo:SetAttacker( attacker )
177
178 dmginfo:SetInflictor( self )
179-- dmginfo:SetDamage( math.random( 65, 75 ) )
180 if tr.Entity:Health() <= 30 and tr.Entity:IsPlayer() then
181 dmginfo:SetDamage (9999999)
182 self.Owner:SetHealth( math.Clamp( self.Owner:Health() + 10, 0, 220 ) )
183 else
184 dmginfo:SetDamage( 0 )
185 self.Owner:SetHealth( math.Clamp( self.Owner:Health() - 15, 0, 220 ) )
186 if self.Owner:Health() <= 0 then
187 self.Owner:Kill()
188 end
189 end
190
191 self:EmitSound( self.Grim_Reaper_Non_Wall_Sound )
192-- self.Owner:SetHealth( math.Clamp( self.Owner:Health() + 10, 0, 500 ) )
193
194 tr.Entity:TakeDamageInfo( dmginfo )
195 hit = true
196
197 end
198
199 if ( SERVER && IsValid( tr.Entity ) ) then
200 local phys = tr.Entity:GetPhysicsObject()
201 if ( IsValid( phys ) ) then
202 phys:ApplyForceOffset( self.Owner:GetAimVector() * 80 * phys:GetMass(), tr.HitPos )
203 end
204 end
205
206 self.Owner:LagCompensation( false )
207
208end
209
210function SWEP:Think()
211 if CurTime() > nextheartbeat then
212 nextheartbeat = CurTime() + 0.8
213 for k,v in pairs( ents.GetAll() ) do
214 if IsValid(v) then
215 if ( v:IsPlayer() and v:Alive() and v:Health() <= 30 and v:Health() > 0 and v ~= self.Owner then
216 if (ply:Team() != TEAM_DEADPOOL) or (ply:Team() != TEAM_LADY_DEADPOOL) then
217 if CLIENT then
218 self.Owner.emitter = ParticleEmitter( self.Owner:GetPos() )
219 surface.PlaySound("weapons/grim_reaper/sycth_heart_beat.mp3")
220 local heartbeat = self.Owner.emitter:Add( "sprites/light_glow02_add_noz", v:GetPos() + Vector(0,0,50) )
221 heartbeat:SetDieTime( 0.5 )
222 heartbeat:SetStartAlpha( 255 )
223 heartbeat:SetEndAlpha( 0 )
224 heartbeat:SetStartSize( 200 )
225 heartbeat:SetEndSize( 0 )
226 heartbeat:SetColor(255,0,0)
227 end
228 end
229 end
230 end
231 end
232 end
233
234 local curtime = CurTime()
235
236 local grim_reaper_scyth_time = self:GetNextMeleeAttack()
237
238 if ( grim_reaper_scyth_time > 0 && CurTime() > grim_reaper_scyth_time ) then
239
240 self:Grim_Reaper_Deal_Damage()
241
242 self:SetNextMeleeAttack( 0 )
243
244 end
245end
246
247function SWEP:SecondaryAttack()
248 return false
249end
250
251function SWEP:DrawHUD()
252 for k, v in pairs(player.GetAll()) do
253 if (v != self.Owner and v:Health() <= 30 and v:Health() > 0 ) then
254 if (ply:Team() != TEAM_DEADPOOL) or (ply:Team() != TEAM_LADY_DEADPOOL) then
255 local position = v:LocalToWorld(v:OBBCenter() + Vector(0,0,50)):ToScreen()
256 local x, y = position.x, position.y
257 draw.DrawText("KILL...", "Taco_Text" , x, y, Color(255,255,255), TEXT_ALIGN_CENTER)
258 end
259 end
260 end
261end
262
263--[[********************************************************
264 SWEP Construction Kit base code
265 Created by Clavus
266 Available for public use, thread at:
267 facepunch.com/threads/1032378
268
269
270 DESCRIPTION:
271 This script is meant for experienced scripters
272 that KNOW WHAT THEY ARE DOING. Don't come to me
273 with basic Lua questions.
274
275 Just copy into your SWEP or SWEP base of choice
276 and merge with your own code.
277
278 The SWEP.VElements, SWEP.WElements and
279 SWEP.ViewModelBoneMods tables are all optional
280 and only have to be visible to the client.
281********************************************************]]--
282
283function SWEP:Initialize()
284
285 -- other initialize code goes here
286
287 self:SetWeaponHoldType( "melee2" )
288 self.Weapon:EmitSound( self.Grim_Reaper_Intro )
289
290 if CLIENT then
291
292 -- Create a new table for every weapon instance
293 self.VElements = table.FullCopy( self.VElements )
294 self.WElements = table.FullCopy( self.WElements )
295 self.ViewModelBoneMods = table.FullCopy( self.ViewModelBoneMods )
296
297 self:CreateModels(self.VElements) -- create viewmodels
298 self:CreateModels(self.WElements) -- create worldmodels
299
300 -- init view model bone build function
301 if IsValid(self.Owner) then
302 local vm = self.Owner:GetViewModel()
303 if IsValid(vm) then
304 self:ResetBonePositions(vm)
305
306 -- Init viewmodel visibility
307 if (self.ShowViewModel == nil or self.ShowViewModel) then
308 vm:SetColor(Color(255,255,255,255))
309 else
310 -- we set the alpha to 1 instead of 0 because else ViewModelDrawn stops being called
311 vm:SetColor(Color(255,255,255,1))
312 -- ^ stopped working in GMod 13 because you have to do Entity:SetRenderMode(1) for translucency to kick in
313 -- 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
314 vm:SetMaterial("Debug/hsv")
315 end
316 end
317 end
318
319 end
320
321end
322
323function SWEP:Holster()
324
325 if CLIENT and IsValid(self.Owner) then
326 local vm = self.Owner:GetViewModel()
327 if IsValid(vm) then
328 self:ResetBonePositions(vm)
329 end
330 end
331
332 if SERVER then
333 self.Owner:SetColor( Color(255, 255, 255, 255) )
334 self.Owner:SetMaterial( "" )
335 self.Owner:DrawShadow(true)
336 self.Owner:SetRunSpeed(255)
337 self.Owner:SetJumpPower(200)
338-- self.Owner:GodDisable()
339 end
340
341 return true
342end
343
344function SWEP:Deploy()
345
346 if SERVER then
347 self.Owner:SetColor( Color(255, 255, 255, 0) )
348 self.Owner:SetMaterial( "sprites/heatwave" )
349 self.Owner:DrawShadow(false)
350 self.Owner:SetRunSpeed(700)
351 self.Owner:SetJumpPower(800)
352-- self.Owner:GodEnable()
353 end
354
355 return true
356end
357
358function SWEP:OnRemove()
359 self:Holster()
360end
361
362if CLIENT then
363
364 SWEP.vRenderOrder = nil
365 function SWEP:ViewModelDrawn()
366
367 local vm = self.Owner:GetViewModel()
368 if !IsValid(vm) then return end
369
370 if (!self.VElements) then return end
371
372 self:UpdateBonePositions(vm)
373
374 if (!self.vRenderOrder) then
375
376 -- we build a render order because sprites need to be drawn after models
377 self.vRenderOrder = {}
378
379 for k, v in pairs( self.VElements ) do
380 if (v.type == "Model") then
381 table.insert(self.vRenderOrder, 1, k)
382 elseif (v.type == "Sprite" or v.type == "Quad") then
383 table.insert(self.vRenderOrder, k)
384 end
385 end
386
387 end
388
389 for k, name in ipairs( self.vRenderOrder ) do
390
391 local v = self.VElements[name]
392 if (!v) then self.vRenderOrder = nil break end
393 if (v.hide) then continue end
394
395 local model = v.modelEnt
396 local sprite = v.spriteMaterial
397
398 if (!v.bone) then continue end
399
400 local pos, ang = self:GetBoneOrientation( self.VElements, v, vm )
401
402 if (!pos) then continue end
403
404 if (v.type == "Model" and IsValid(model)) then
405
406 model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
407 ang:RotateAroundAxis(ang:Up(), v.angle.y)
408 ang:RotateAroundAxis(ang:Right(), v.angle.p)
409 ang:RotateAroundAxis(ang:Forward(), v.angle.r)
410
411 model:SetAngles(ang)
412 --model:SetModelScale(v.size)
413 local matrix = Matrix()
414 matrix:Scale(v.size)
415 model:EnableMatrix( "RenderMultiply", matrix )
416
417 if (v.material == "") then
418 model:SetMaterial("")
419 elseif (model:GetMaterial() != v.material) then
420 model:SetMaterial( v.material )
421 end
422
423 if (v.skin and v.skin != model:GetSkin()) then
424 model:SetSkin(v.skin)
425 end
426
427 if (v.bodygroup) then
428 for k, v in pairs( v.bodygroup ) do
429 if (model:GetBodygroup(k) != v) then
430 model:SetBodygroup(k, v)
431 end
432 end
433 end
434
435 if (v.surpresslightning) then
436 render.SuppressEngineLighting(true)
437 end
438
439 render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
440 render.SetBlend(v.color.a/255)
441 model:DrawModel()
442 render.SetBlend(1)
443 render.SetColorModulation(1, 1, 1)
444
445 if (v.surpresslightning) then
446 render.SuppressEngineLighting(false)
447 end
448
449 elseif (v.type == "Sprite" and sprite) then
450
451 local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
452 render.SetMaterial(sprite)
453 render.DrawSprite(drawpos, v.size.x, v.size.y, v.color)
454
455 elseif (v.type == "Quad" and v.draw_func) then
456
457 local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
458 ang:RotateAroundAxis(ang:Up(), v.angle.y)
459 ang:RotateAroundAxis(ang:Right(), v.angle.p)
460 ang:RotateAroundAxis(ang:Forward(), v.angle.r)
461
462 cam.Start3D2D(drawpos, ang, v.size)
463 v.draw_func( self )
464 cam.End3D2D()
465
466 end
467
468 end
469
470 end
471
472 SWEP.wRenderOrder = nil
473 function SWEP:DrawWorldModel()
474
475 if (self.ShowWorldModel == nil or self.ShowWorldModel) then
476 self:DrawModel()
477 end
478
479 if (!self.WElements) then return end
480
481 if (!self.wRenderOrder) then
482
483 self.wRenderOrder = {}
484
485 for k, v in pairs( self.WElements ) do
486 if (v.type == "Model") then
487 table.insert(self.wRenderOrder, 1, k)
488 elseif (v.type == "Sprite" or v.type == "Quad") then
489 table.insert(self.wRenderOrder, k)
490 end
491 end
492
493 end
494
495 if (IsValid(self.Owner)) then
496 bone_ent = self.Owner
497 else
498 -- when the weapon is dropped
499 bone_ent = self
500 end
501
502 for k, name in pairs( self.wRenderOrder ) do
503
504 local v = self.WElements[name]
505 if (!v) then self.wRenderOrder = nil break end
506 if (v.hide) then continue end
507
508 local pos, ang
509
510 if (v.bone) then
511 pos, ang = self:GetBoneOrientation( self.WElements, v, bone_ent )
512 else
513 pos, ang = self:GetBoneOrientation( self.WElements, v, bone_ent, "ValveBiped.Bip01_R_Hand" )
514 end
515
516 if (!pos) then continue end
517
518 local model = v.modelEnt
519 local sprite = v.spriteMaterial
520
521 if (v.type == "Model" and IsValid(model)) then
522
523 model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
524 ang:RotateAroundAxis(ang:Up(), v.angle.y)
525 ang:RotateAroundAxis(ang:Right(), v.angle.p)
526 ang:RotateAroundAxis(ang:Forward(), v.angle.r)
527
528 model:SetAngles(ang)
529 --model:SetModelScale(v.size)
530 local matrix = Matrix()
531 matrix:Scale(v.size)
532 model:EnableMatrix( "RenderMultiply", matrix )
533
534 if (v.material == "") then
535 model:SetMaterial("")
536 elseif (model:GetMaterial() != v.material) then
537 model:SetMaterial( v.material )
538 end
539
540 if (v.skin and v.skin != model:GetSkin()) then
541 model:SetSkin(v.skin)
542 end
543
544 if (v.bodygroup) then
545 for k, v in pairs( v.bodygroup ) do
546 if (model:GetBodygroup(k) != v) then
547 model:SetBodygroup(k, v)
548 end
549 end
550 end
551
552 if (v.surpresslightning) then
553 render.SuppressEngineLighting(true)
554 end
555
556 render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
557 render.SetBlend(v.color.a/255)
558 model:DrawModel()
559 render.SetBlend(1)
560 render.SetColorModulation(1, 1, 1)
561
562 if (v.surpresslightning) then
563 render.SuppressEngineLighting(false)
564 end
565
566 elseif (v.type == "Sprite" and sprite) then
567
568 local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
569 render.SetMaterial(sprite)
570 render.DrawSprite(drawpos, v.size.x, v.size.y, v.color)
571
572 elseif (v.type == "Quad" and v.draw_func) then
573
574 local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
575 ang:RotateAroundAxis(ang:Up(), v.angle.y)
576 ang:RotateAroundAxis(ang:Right(), v.angle.p)
577 ang:RotateAroundAxis(ang:Forward(), v.angle.r)
578
579 cam.Start3D2D(drawpos, ang, v.size)
580 v.draw_func( self )
581 cam.End3D2D()
582
583 end
584
585 end
586
587 end
588
589 function SWEP:GetBoneOrientation( basetab, tab, ent, bone_override )
590
591 local bone, pos, ang
592 if (tab.rel and tab.rel != "") then
593
594 local v = basetab[tab.rel]
595
596 if (!v) then return end
597
598 -- Technically, if there exists an element with the same name as a bone
599 -- you can get in an infinite loop. Let's just hope nobody's that stupid.
600 pos, ang = self:GetBoneOrientation( basetab, v, ent )
601
602 if (!pos) then return end
603
604 pos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
605 ang:RotateAroundAxis(ang:Up(), v.angle.y)
606 ang:RotateAroundAxis(ang:Right(), v.angle.p)
607 ang:RotateAroundAxis(ang:Forward(), v.angle.r)
608
609 else
610
611 bone = ent:LookupBone(bone_override or tab.bone)
612
613 if (!bone) then return end
614
615 pos, ang = Vector(0,0,0), Angle(0,0,0)
616 local m = ent:GetBoneMatrix(bone)
617 if (m) then
618 pos, ang = m:GetTranslation(), m:GetAngles()
619 end
620
621 if (IsValid(self.Owner) and self.Owner:IsPlayer() and
622 ent == self.Owner:GetViewModel() and self.ViewModelFlip) then
623 ang.r = -ang.r -- Fixes mirrored models
624 end
625
626 end
627
628 return pos, ang
629 end
630
631 function SWEP:CreateModels( tab )
632
633 if (!tab) then return end
634
635 -- Create the clientside models here because Garry says we can't do it in the render hook
636 for k, v in pairs( tab ) do
637 if (v.type == "Model" and v.model and v.model != "" and (!IsValid(v.modelEnt) or v.createdModel != v.model) and
638 string.find(v.model, ".mdl") and file.Exists (v.model, "GAME") ) then
639
640 v.modelEnt = ClientsideModel(v.model, RENDER_GROUP_VIEW_MODEL_OPAQUE)
641 if (IsValid(v.modelEnt)) then
642 v.modelEnt:SetPos(self:GetPos())
643 v.modelEnt:SetAngles(self:GetAngles())
644 v.modelEnt:SetParent(self)
645 v.modelEnt:SetNoDraw(true)
646 v.createdModel = v.model
647 else
648 v.modelEnt = nil
649 end
650
651 elseif (v.type == "Sprite" and v.sprite and v.sprite != "" and (!v.spriteMaterial or v.createdSprite != v.sprite)
652 and file.Exists ("materials/"..v.sprite..".vmt", "GAME")) then
653
654 local name = v.sprite.."-"
655 local params = { ["$basetexture"] = v.sprite }
656 -- make sure we create a unique name based on the selected options
657 local tocheck = { "nocull", "additive", "vertexalpha", "vertexcolor", "ignorez" }
658 for i, j in pairs( tocheck ) do
659 if (v[j]) then
660 params["$"..j] = 1
661 name = name.."1"
662 else
663 name = name.."0"
664 end
665 end
666
667 v.createdSprite = v.sprite
668 v.spriteMaterial = CreateMaterial(name,"UnlitGeneric",params)
669
670 end
671 end
672
673 end
674
675 local allbones
676 local hasGarryFixedBoneScalingYet = false
677
678 function SWEP:UpdateBonePositions(vm)
679
680 if self.ViewModelBoneMods then
681
682 if (!vm:GetBoneCount()) then return end
683
684 -- !! WORKAROUND !! --
685 -- We need to check all model names :/
686 local loopthrough = self.ViewModelBoneMods
687 if (!hasGarryFixedBoneScalingYet) then
688 allbones = {}
689 for i=0, vm:GetBoneCount() do
690 local bonename = vm:GetBoneName(i)
691 if (self.ViewModelBoneMods[bonename]) then
692 allbones[bonename] = self.ViewModelBoneMods[bonename]
693 else
694 allbones[bonename] = {
695 scale = Vector(1,1,1),
696 pos = Vector(0,0,0),
697 angle = Angle(0,0,0)
698 }
699 end
700 end
701
702 loopthrough = allbones
703 end
704 -- !! ----------- !! --
705
706 for k, v in pairs( loopthrough ) do
707 local bone = vm:LookupBone(k)
708 if (!bone) then continue end
709
710 -- !! WORKAROUND !! --
711 local s = Vector(v.scale.x,v.scale.y,v.scale.z)
712 local p = Vector(v.pos.x,v.pos.y,v.pos.z)
713 local ms = Vector(1,1,1)
714 if (!hasGarryFixedBoneScalingYet) then
715 local cur = vm:GetBoneParent(bone)
716 while(cur >= 0) do
717 local pscale = loopthrough[vm:GetBoneName(cur)].scale
718 ms = ms * pscale
719 cur = vm:GetBoneParent(cur)
720 end
721 end
722
723 s = s * ms
724 -- !! ----------- !! --
725
726 if vm:GetManipulateBoneScale(bone) != s then
727 vm:ManipulateBoneScale( bone, s )
728 end
729 if vm:GetManipulateBoneAngles(bone) != v.angle then
730 vm:ManipulateBoneAngles( bone, v.angle )
731 end
732 if vm:GetManipulateBonePosition(bone) != p then
733 vm:ManipulateBonePosition( bone, p )
734 end
735 end
736 else
737 self:ResetBonePositions(vm)
738 end
739
740 end
741
742 function SWEP:ResetBonePositions(vm)
743
744 if (!vm:GetBoneCount()) then return end
745 for i=0, vm:GetBoneCount() do
746 vm:ManipulateBoneScale( i, Vector(1, 1, 1) )
747 vm:ManipulateBoneAngles( i, Angle(0, 0, 0) )
748 vm:ManipulateBonePosition( i, Vector(0, 0, 0) )
749 end
750
751 end
752
753 /**************************
754 Global utility code
755 **************************/
756
757 -- Fully copies the table, meaning all tables inside this table are copied too and so on (normal table.Copy copies only their reference).
758 -- Does not copy entities of course, only copies their reference.
759 -- WARNING: do not use on tables that contain themselves somewhere down the line or you'll get an infinite loop
760 function table.FullCopy( tab )
761
762 if (!tab) then return nil end
763
764 local res = {}
765 for k, v in pairs( tab ) do
766 if (type(v) == "table") then
767 res[k] = table.FullCopy(v) -- recursion ho!
768 elseif (type(v) == "Vector") then
769 res[k] = Vector(v.x, v.y, v.z)
770 elseif (type(v) == "Angle") then
771 res[k] = Angle(v.p, v.y, v.r)
772 else
773 res[k] = v
774 end
775 end
776
777 return res
778
779 end
780
781end
782
783hook.Add( "canDropWeapon", "grim_reaper_sycth_drop", function( ply, wep )
784 if wep:GetClass() == "grim_reaper_sycth" then
785 return false
786 end
787end)