· 7 years ago · Jan 19, 2019, 07:36 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 and ((ply:Team() != TEAM_DEADPOOL) or (ply:Team() != TEAM_LADY_DEADPOOL))) then
216 if CLIENT then
217 self.Owner.emitter = ParticleEmitter( self.Owner:GetPos() )
218 surface.PlaySound("weapons/grim_reaper/sycth_heart_beat.mp3")
219 local heartbeat = self.Owner.emitter:Add( "sprites/light_glow02_add_noz", v:GetPos() + Vector(0,0,50) )
220 heartbeat:SetDieTime( 0.5 )
221 heartbeat:SetStartAlpha( 255 )
222 heartbeat:SetEndAlpha( 0 )
223 heartbeat:SetStartSize( 200 )
224 heartbeat:SetEndSize( 0 )
225 heartbeat:SetColor(255,0,0)
226 end
227 end
228 end
229 end
230 end
231
232 local curtime = CurTime()
233
234 local grim_reaper_scyth_time = self:GetNextMeleeAttack()
235
236 if ( grim_reaper_scyth_time > 0 && CurTime() > grim_reaper_scyth_time ) then
237
238 self:Grim_Reaper_Deal_Damage()
239
240 self:SetNextMeleeAttack( 0 )
241
242 end
243end
244
245function SWEP:SecondaryAttack()
246 return false
247end
248
249function SWEP:DrawHUD()
250 for k, v in pairs(player.GetAll()) do
251 if (v != self.Owner and v:Health() <= 30 and v:Health() > 0 ) then
252 local position = v:LocalToWorld(v:OBBCenter() + Vector(0,0,50)):ToScreen()
253 local x, y = position.x, position.y
254 draw.DrawText("KILL...", "Taco_Text" , x, y, Color(255,255,255), TEXT_ALIGN_CENTER)
255 end
256 end
257end
258
259--[[********************************************************
260 SWEP Construction Kit base code
261 Created by Clavus
262 Available for public use, thread at:
263 facepunch.com/threads/1032378
264
265
266 DESCRIPTION:
267 This script is meant for experienced scripters
268 that KNOW WHAT THEY ARE DOING. Don't come to me
269 with basic Lua questions.
270
271 Just copy into your SWEP or SWEP base of choice
272 and merge with your own code.
273
274 The SWEP.VElements, SWEP.WElements and
275 SWEP.ViewModelBoneMods tables are all optional
276 and only have to be visible to the client.
277********************************************************]]--
278
279function SWEP:Initialize()
280
281 -- other initialize code goes here
282
283 self:SetWeaponHoldType( "melee2" )
284 self.Weapon:EmitSound( self.Grim_Reaper_Intro )
285
286 if CLIENT then
287
288 -- Create a new table for every weapon instance
289 self.VElements = table.FullCopy( self.VElements )
290 self.WElements = table.FullCopy( self.WElements )
291 self.ViewModelBoneMods = table.FullCopy( self.ViewModelBoneMods )
292
293 self:CreateModels(self.VElements) -- create viewmodels
294 self:CreateModels(self.WElements) -- create worldmodels
295
296 -- init view model bone build function
297 if IsValid(self.Owner) then
298 local vm = self.Owner:GetViewModel()
299 if IsValid(vm) then
300 self:ResetBonePositions(vm)
301
302 -- Init viewmodel visibility
303 if (self.ShowViewModel == nil or self.ShowViewModel) then
304 vm:SetColor(Color(255,255,255,255))
305 else
306 -- we set the alpha to 1 instead of 0 because else ViewModelDrawn stops being called
307 vm:SetColor(Color(255,255,255,1))
308 -- ^ stopped working in GMod 13 because you have to do Entity:SetRenderMode(1) for translucency to kick in
309 -- 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
310 vm:SetMaterial("Debug/hsv")
311 end
312 end
313 end
314
315 end
316
317end
318
319function SWEP:Holster()
320
321 if CLIENT and IsValid(self.Owner) then
322 local vm = self.Owner:GetViewModel()
323 if IsValid(vm) then
324 self:ResetBonePositions(vm)
325 end
326 end
327
328 if SERVER then
329 self.Owner:SetColor( Color(255, 255, 255, 255) )
330 self.Owner:SetMaterial( "" )
331 self.Owner:DrawShadow(true)
332 self.Owner:SetRunSpeed(255)
333 self.Owner:SetJumpPower(200)
334-- self.Owner:GodDisable()
335 end
336
337 return true
338end
339
340function SWEP:Deploy()
341
342 if SERVER then
343 self.Owner:SetColor( Color(255, 255, 255, 0) )
344 self.Owner:SetMaterial( "sprites/heatwave" )
345 self.Owner:DrawShadow(false)
346 self.Owner:SetRunSpeed(700)
347 self.Owner:SetJumpPower(800)
348-- self.Owner:GodEnable()
349 end
350
351 return true
352end
353
354function SWEP:OnRemove()
355 self:Holster()
356end
357
358if CLIENT then
359
360 SWEP.vRenderOrder = nil
361 function SWEP:ViewModelDrawn()
362
363 local vm = self.Owner:GetViewModel()
364 if !IsValid(vm) then return end
365
366 if (!self.VElements) then return end
367
368 self:UpdateBonePositions(vm)
369
370 if (!self.vRenderOrder) then
371
372 -- we build a render order because sprites need to be drawn after models
373 self.vRenderOrder = {}
374
375 for k, v in pairs( self.VElements ) do
376 if (v.type == "Model") then
377 table.insert(self.vRenderOrder, 1, k)
378 elseif (v.type == "Sprite" or v.type == "Quad") then
379 table.insert(self.vRenderOrder, k)
380 end
381 end
382
383 end
384
385 for k, name in ipairs( self.vRenderOrder ) do
386
387 local v = self.VElements[name]
388 if (!v) then self.vRenderOrder = nil break end
389 if (v.hide) then continue end
390
391 local model = v.modelEnt
392 local sprite = v.spriteMaterial
393
394 if (!v.bone) then continue end
395
396 local pos, ang = self:GetBoneOrientation( self.VElements, v, vm )
397
398 if (!pos) then continue end
399
400 if (v.type == "Model" and IsValid(model)) then
401
402 model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
403 ang:RotateAroundAxis(ang:Up(), v.angle.y)
404 ang:RotateAroundAxis(ang:Right(), v.angle.p)
405 ang:RotateAroundAxis(ang:Forward(), v.angle.r)
406
407 model:SetAngles(ang)
408 --model:SetModelScale(v.size)
409 local matrix = Matrix()
410 matrix:Scale(v.size)
411 model:EnableMatrix( "RenderMultiply", matrix )
412
413 if (v.material == "") then
414 model:SetMaterial("")
415 elseif (model:GetMaterial() != v.material) then
416 model:SetMaterial( v.material )
417 end
418
419 if (v.skin and v.skin != model:GetSkin()) then
420 model:SetSkin(v.skin)
421 end
422
423 if (v.bodygroup) then
424 for k, v in pairs( v.bodygroup ) do
425 if (model:GetBodygroup(k) != v) then
426 model:SetBodygroup(k, v)
427 end
428 end
429 end
430
431 if (v.surpresslightning) then
432 render.SuppressEngineLighting(true)
433 end
434
435 render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
436 render.SetBlend(v.color.a/255)
437 model:DrawModel()
438 render.SetBlend(1)
439 render.SetColorModulation(1, 1, 1)
440
441 if (v.surpresslightning) then
442 render.SuppressEngineLighting(false)
443 end
444
445 elseif (v.type == "Sprite" and sprite) then
446
447 local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
448 render.SetMaterial(sprite)
449 render.DrawSprite(drawpos, v.size.x, v.size.y, v.color)
450
451 elseif (v.type == "Quad" and v.draw_func) then
452
453 local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
454 ang:RotateAroundAxis(ang:Up(), v.angle.y)
455 ang:RotateAroundAxis(ang:Right(), v.angle.p)
456 ang:RotateAroundAxis(ang:Forward(), v.angle.r)
457
458 cam.Start3D2D(drawpos, ang, v.size)
459 v.draw_func( self )
460 cam.End3D2D()
461
462 end
463
464 end
465
466 end
467
468 SWEP.wRenderOrder = nil
469 function SWEP:DrawWorldModel()
470
471 if (self.ShowWorldModel == nil or self.ShowWorldModel) then
472 self:DrawModel()
473 end
474
475 if (!self.WElements) then return end
476
477 if (!self.wRenderOrder) then
478
479 self.wRenderOrder = {}
480
481 for k, v in pairs( self.WElements ) do
482 if (v.type == "Model") then
483 table.insert(self.wRenderOrder, 1, k)
484 elseif (v.type == "Sprite" or v.type == "Quad") then
485 table.insert(self.wRenderOrder, k)
486 end
487 end
488
489 end
490
491 if (IsValid(self.Owner)) then
492 bone_ent = self.Owner
493 else
494 -- when the weapon is dropped
495 bone_ent = self
496 end
497
498 for k, name in pairs( self.wRenderOrder ) do
499
500 local v = self.WElements[name]
501 if (!v) then self.wRenderOrder = nil break end
502 if (v.hide) then continue end
503
504 local pos, ang
505
506 if (v.bone) then
507 pos, ang = self:GetBoneOrientation( self.WElements, v, bone_ent )
508 else
509 pos, ang = self:GetBoneOrientation( self.WElements, v, bone_ent, "ValveBiped.Bip01_R_Hand" )
510 end
511
512 if (!pos) then continue end
513
514 local model = v.modelEnt
515 local sprite = v.spriteMaterial
516
517 if (v.type == "Model" and IsValid(model)) then
518
519 model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
520 ang:RotateAroundAxis(ang:Up(), v.angle.y)
521 ang:RotateAroundAxis(ang:Right(), v.angle.p)
522 ang:RotateAroundAxis(ang:Forward(), v.angle.r)
523
524 model:SetAngles(ang)
525 --model:SetModelScale(v.size)
526 local matrix = Matrix()
527 matrix:Scale(v.size)
528 model:EnableMatrix( "RenderMultiply", matrix )
529
530 if (v.material == "") then
531 model:SetMaterial("")
532 elseif (model:GetMaterial() != v.material) then
533 model:SetMaterial( v.material )
534 end
535
536 if (v.skin and v.skin != model:GetSkin()) then
537 model:SetSkin(v.skin)
538 end
539
540 if (v.bodygroup) then
541 for k, v in pairs( v.bodygroup ) do
542 if (model:GetBodygroup(k) != v) then
543 model:SetBodygroup(k, v)
544 end
545 end
546 end
547
548 if (v.surpresslightning) then
549 render.SuppressEngineLighting(true)
550 end
551
552 render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
553 render.SetBlend(v.color.a/255)
554 model:DrawModel()
555 render.SetBlend(1)
556 render.SetColorModulation(1, 1, 1)
557
558 if (v.surpresslightning) then
559 render.SuppressEngineLighting(false)
560 end
561
562 elseif (v.type == "Sprite" and sprite) then
563
564 local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
565 render.SetMaterial(sprite)
566 render.DrawSprite(drawpos, v.size.x, v.size.y, v.color)
567
568 elseif (v.type == "Quad" and v.draw_func) then
569
570 local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
571 ang:RotateAroundAxis(ang:Up(), v.angle.y)
572 ang:RotateAroundAxis(ang:Right(), v.angle.p)
573 ang:RotateAroundAxis(ang:Forward(), v.angle.r)
574
575 cam.Start3D2D(drawpos, ang, v.size)
576 v.draw_func( self )
577 cam.End3D2D()
578
579 end
580
581 end
582
583 end
584
585 function SWEP:GetBoneOrientation( basetab, tab, ent, bone_override )
586
587 local bone, pos, ang
588 if (tab.rel and tab.rel != "") then
589
590 local v = basetab[tab.rel]
591
592 if (!v) then return end
593
594 -- Technically, if there exists an element with the same name as a bone
595 -- you can get in an infinite loop. Let's just hope nobody's that stupid.
596 pos, ang = self:GetBoneOrientation( basetab, v, ent )
597
598 if (!pos) then return end
599
600 pos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
601 ang:RotateAroundAxis(ang:Up(), v.angle.y)
602 ang:RotateAroundAxis(ang:Right(), v.angle.p)
603 ang:RotateAroundAxis(ang:Forward(), v.angle.r)
604
605 else
606
607 bone = ent:LookupBone(bone_override or tab.bone)
608
609 if (!bone) then return end
610
611 pos, ang = Vector(0,0,0), Angle(0,0,0)
612 local m = ent:GetBoneMatrix(bone)
613 if (m) then
614 pos, ang = m:GetTranslation(), m:GetAngles()
615 end
616
617 if (IsValid(self.Owner) and self.Owner:IsPlayer() and
618 ent == self.Owner:GetViewModel() and self.ViewModelFlip) then
619 ang.r = -ang.r -- Fixes mirrored models
620 end
621
622 end
623
624 return pos, ang
625 end
626
627 function SWEP:CreateModels( tab )
628
629 if (!tab) then return end
630
631 -- Create the clientside models here because Garry says we can't do it in the render hook
632 for k, v in pairs( tab ) do
633 if (v.type == "Model" and v.model and v.model != "" and (!IsValid(v.modelEnt) or v.createdModel != v.model) and
634 string.find(v.model, ".mdl") and file.Exists (v.model, "GAME") ) then
635
636 v.modelEnt = ClientsideModel(v.model, RENDER_GROUP_VIEW_MODEL_OPAQUE)
637 if (IsValid(v.modelEnt)) then
638 v.modelEnt:SetPos(self:GetPos())
639 v.modelEnt:SetAngles(self:GetAngles())
640 v.modelEnt:SetParent(self)
641 v.modelEnt:SetNoDraw(true)
642 v.createdModel = v.model
643 else
644 v.modelEnt = nil
645 end
646
647 elseif (v.type == "Sprite" and v.sprite and v.sprite != "" and (!v.spriteMaterial or v.createdSprite != v.sprite)
648 and file.Exists ("materials/"..v.sprite..".vmt", "GAME")) then
649
650 local name = v.sprite.."-"
651 local params = { ["$basetexture"] = v.sprite }
652 -- make sure we create a unique name based on the selected options
653 local tocheck = { "nocull", "additive", "vertexalpha", "vertexcolor", "ignorez" }
654 for i, j in pairs( tocheck ) do
655 if (v[j]) then
656 params["$"..j] = 1
657 name = name.."1"
658 else
659 name = name.."0"
660 end
661 end
662
663 v.createdSprite = v.sprite
664 v.spriteMaterial = CreateMaterial(name,"UnlitGeneric",params)
665
666 end
667 end
668
669 end
670
671 local allbones
672 local hasGarryFixedBoneScalingYet = false
673
674 function SWEP:UpdateBonePositions(vm)
675
676 if self.ViewModelBoneMods then
677
678 if (!vm:GetBoneCount()) then return end
679
680 -- !! WORKAROUND !! --
681 -- We need to check all model names :/
682 local loopthrough = self.ViewModelBoneMods
683 if (!hasGarryFixedBoneScalingYet) then
684 allbones = {}
685 for i=0, vm:GetBoneCount() do
686 local bonename = vm:GetBoneName(i)
687 if (self.ViewModelBoneMods[bonename]) then
688 allbones[bonename] = self.ViewModelBoneMods[bonename]
689 else
690 allbones[bonename] = {
691 scale = Vector(1,1,1),
692 pos = Vector(0,0,0),
693 angle = Angle(0,0,0)
694 }
695 end
696 end
697
698 loopthrough = allbones
699 end
700 -- !! ----------- !! --
701
702 for k, v in pairs( loopthrough ) do
703 local bone = vm:LookupBone(k)
704 if (!bone) then continue end
705
706 -- !! WORKAROUND !! --
707 local s = Vector(v.scale.x,v.scale.y,v.scale.z)
708 local p = Vector(v.pos.x,v.pos.y,v.pos.z)
709 local ms = Vector(1,1,1)
710 if (!hasGarryFixedBoneScalingYet) then
711 local cur = vm:GetBoneParent(bone)
712 while(cur >= 0) do
713 local pscale = loopthrough[vm:GetBoneName(cur)].scale
714 ms = ms * pscale
715 cur = vm:GetBoneParent(cur)
716 end
717 end
718
719 s = s * ms
720 -- !! ----------- !! --
721
722 if vm:GetManipulateBoneScale(bone) != s then
723 vm:ManipulateBoneScale( bone, s )
724 end
725 if vm:GetManipulateBoneAngles(bone) != v.angle then
726 vm:ManipulateBoneAngles( bone, v.angle )
727 end
728 if vm:GetManipulateBonePosition(bone) != p then
729 vm:ManipulateBonePosition( bone, p )
730 end
731 end
732 else
733 self:ResetBonePositions(vm)
734 end
735
736 end
737
738 function SWEP:ResetBonePositions(vm)
739
740 if (!vm:GetBoneCount()) then return end
741 for i=0, vm:GetBoneCount() do
742 vm:ManipulateBoneScale( i, Vector(1, 1, 1) )
743 vm:ManipulateBoneAngles( i, Angle(0, 0, 0) )
744 vm:ManipulateBonePosition( i, Vector(0, 0, 0) )
745 end
746
747 end
748
749 /**************************
750 Global utility code
751 **************************/
752
753 -- Fully copies the table, meaning all tables inside this table are copied too and so on (normal table.Copy copies only their reference).
754 -- Does not copy entities of course, only copies their reference.
755 -- WARNING: do not use on tables that contain themselves somewhere down the line or you'll get an infinite loop
756 function table.FullCopy( tab )
757
758 if (!tab) then return nil end
759
760 local res = {}
761 for k, v in pairs( tab ) do
762 if (type(v) == "table") then
763 res[k] = table.FullCopy(v) -- recursion ho!
764 elseif (type(v) == "Vector") then
765 res[k] = Vector(v.x, v.y, v.z)
766 elseif (type(v) == "Angle") then
767 res[k] = Angle(v.p, v.y, v.r)
768 else
769 res[k] = v
770 end
771 end
772
773 return res
774
775 end
776
777end
778
779hook.Add( "canDropWeapon", "grim_reaper_sycth_drop", function( ply, wep )
780 if wep:GetClass() == "grim_reaper_sycth" then
781 return false
782 end
783end)