Advertisement
Guest User

Full Codwe

a guest
Sep 24th, 2013
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.99 KB | None | 0 0
  1. if ( SERVER ) then
  2.  
  3. AddCSLuaFile( "shared.lua" )
  4. end
  5.  
  6. if ( CLIENT ) then
  7.  
  8. SWEP.PrintName = "EMSSS-12"
  9. SWEP.Author = "Babel Industries (Model by Defuse)"
  10. SWEP.Contact = "";
  11. SWEP.Instructions = "Electro Magnetic Shelless Slug Shotgun"
  12. SWEP.Category = "Babel Industries"
  13. SWEP.Slot = 2
  14. SWEP.SlotPos = 1
  15. SWEP.IconLetter = "k"
  16. SWEP.WepSelectIcon = surface.GetTextureID("vgui/entities/weapon_emsss")
  17.  
  18. killicon.AddFont( "weapon_peashotty", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) )
  19.  
  20. SWEP.WElements = {
  21. ["some_unique_name"] = { type = "Model", model = "models/weapons/w_shot_mssuper90.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(1.58, 0.504, 0.3), angle = Angle(-6.588, 0.794, 176.725), size = Vector(1, 1, 1), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
  22. }
  23.  
  24. end
  25.  
  26.  
  27. SWEP.Base = "weapon_tttbase"
  28. SWEP.Spawnable = true
  29. SWEP.AdminSpawnable = false
  30.  
  31.  
  32. SWEP.HoldType = "shotgun"
  33. SWEP.ViewModelFOV = 71
  34. SWEP.ViewModelFlip = true
  35. SWEP.ViewModel = "models/weapons/v_shot_mssuper90.mdl"
  36. SWEP.WorldModel = "models/weapons/w_shotgun.mdl"
  37. SWEP.ShowViewModel = true
  38. SWEP.ShowWorldModel = false
  39. SWEP.ViewModelBoneMods = {}
  40. SWEP.Icon = "vgui/entities/weapon_emsss"
  41. SWEP.Kind = WEAPON_HEAVY
  42. SWEP.AmmoEnt = "item_box_buckshot_ttt"
  43.  
  44. function SWEP:Deploy()
  45. self.Owner:EmitSound( "weapons/barret_arm_draw.wav" ) ;
  46. self.Weapon:SendWeaponAnim( ACT_VM_DRAW )
  47. self:SetDeploySpeed( self.Weapon:SequenceDuration(0.2) )
  48. return true;
  49. end
  50.  
  51.  
  52. SWEP.Primary.Sound = Sound( "weapons/m3/s3-1.wav" )
  53. SWEP.Primary.Recoil = 1
  54. SWEP.Primary.Damage = 5
  55. SWEP.Primary.NumShots = 1
  56. SWEP.Primary.Cone = 0.035
  57. SWEP.Primary.ClipSize = 12
  58. SWEP.Primary.Delay = 1.1
  59. SWEP.Primary.DefaultClip = 70
  60. SWEP.Primary.Automatic = true
  61. SWEP.Primary.Ammo = "buckshot"
  62.  
  63. SWEP.Secondary.ClipSize = -1
  64. SWEP.Secondary.DefaultClip = -1
  65. SWEP.Secondary.Automatic = false
  66. SWEP.Secondary.Ammo = "none"
  67. SWEP.CanBuy = { ROLE_TRAITOR }
  68.  
  69. SWEP.IronSightsPos = Vector(3.046, -4.427, 2.834)
  70. SWEP.IronSightsAng = Vector(0, 0, 0)
  71.  
  72. SWEP.RunArmOffset = Vector(-0.601, -3.935, -1.461)
  73. SWEP.RunArmAngle = Vector(8.032, -41.885, 0)
  74.  
  75.  
  76.  
  77. function SWEP:PrimaryAttack()
  78. // Make sure we can shoot first
  79. if ( !self:CanPrimaryAttack() ) then return end
  80.  
  81. self.Weapon:EmitSound(Sound("weapons/m3/s3-1.wav"))
  82.  
  83.  
  84.  
  85. self:ShootBullet( 38, 1, 0 )
  86.  
  87. // Remove 1 bullet from our clip
  88. self:TakePrimaryAmmo( 1 )
  89.  
  90. local vShootPos = self.Owner:GetShootPos()
  91. local vShootAng = self.Owner:GetAimVector()
  92.  
  93. local t = {}
  94.  
  95. t.caller = self.Owner
  96. t.start = vShootPos
  97. t.sang = vShootAng
  98. t.mreps = 38
  99. t.reps = 0
  100. t.damage = 40
  101. t.length = 70
  102. t.filter = self.Owner
  103. t.maxpens = 38
  104. t.pens = 0
  105. t.powdeg = .01
  106. t.skew = Vector( 0.035, 0.035, 0.035 )
  107. t.canbounce = true
  108. t.bounceang = .3
  109. t.bouncechance = .4
  110.  
  111. // Punch the player's view
  112. self.Owner:ViewPunch( Angle( 1, 1, 1 ) )
  113. self.Weapon:SetNextPrimaryFire( CurTime() + 1.2 )
  114.  
  115.  
  116.  
  117.  
  118. return true
  119.  
  120. --Bleh? This swep doesn't work if this isn't here.
  121.  
  122. end
  123.  
  124. function SWEP:ShootBullet( damage, num_bullets, aimcone )
  125. local bullet = {}
  126. bullet.Num = 1
  127. bullet.Src = self.Owner:GetShootPos()
  128. bullet.Dir = self.Owner:GetAimVector()
  129. bullet.Spread = Vector( 0.021, 0.021, 0.021 )
  130. bullet.Tracer = 5000
  131. bullet.Force = 5000
  132. bullet.Damage = damage
  133. bullet.AmmoType = "AR2AltFire"
  134. bullet.Callback = function(attacker,tr,dmginfo)
  135. ParticleEffect("striderbuster_attach_ring",tr.HitPos,Angle(0,0,0),nil)
  136.  
  137.  
  138.  
  139. end
  140. self.Owner:FireBullets( bullet )
  141. self:ShootEffects()
  142.  
  143. end
  144.  
  145. /*---------------------------------------------------------
  146. Reload does nothing
  147. ---------------------------------------------------------*/
  148.  
  149. /*---------------------------------------------------------
  150. Think does nothing
  151. ---------------------------------------------------------*/
  152. function SWEP:Think()
  153.  
  154. if self.Weapon:Clip1() > self.Primary.ClipSize then
  155. self.Weapon:SetClip1(self.Primary.ClipSize)
  156. end
  157.  
  158. if self.Weapon:GetNetworkedBool( "reloading") == true then
  159.  
  160. if self.Weapon:GetNetworkedInt( "reloadtimer") < CurTime() then
  161. if self.unavailable then return end
  162.  
  163. if ( self.Weapon:Clip1() >= self.Primary.ClipSize || self.Owner:GetAmmoCount( self.Primary.Ammo ) <= 0 ) then
  164. self.Weapon:SetNextPrimaryFire(CurTime() + 0.8)
  165. self.Weapon:SetNextSecondaryFire(CurTime() + 0.8)
  166. self.Weapon:SetNetworkedBool( "reloading", false)
  167. self.Weapon:EmitSound( "weapons/m3/s3_pump.wav" )
  168. self.Weapon:SendWeaponAnim(ACT_SHOTGUN_RELOAD_FINISH)
  169. else
  170.  
  171. self.Weapon:SetNetworkedInt( "reloadtimer", CurTime() + 12.45 )
  172. self.Weapon:SendWeaponAnim( ACT_VM_RELOAD )
  173. self.Owner:RemoveAmmo( 1, self.Primary.Ammo, false )
  174. self.Weapon:SetClip1( self.Weapon:Clip1() + 1 )
  175. self.Weapon:SetNextPrimaryFire(CurTime() + 0.8)
  176. self.Weapon:SetNextSecondaryFire(CurTime() + 0.8)
  177. self.Weapon:EmitSound( "weapons/m3/s3_insertshell.wav" )
  178.  
  179. if ( self.Weapon:Clip1() >= self.Primary.ClipSize || self.Owner:GetAmmoCount( self.Primary.Ammo ) <= 0) then
  180. self.Weapon:SetNextPrimaryFire(CurTime() + 12.5)
  181. self.Weapon:SetNextSecondaryFire(CurTime() + 12.5)
  182.  
  183. else
  184. self.Weapon:SetNextPrimaryFire(CurTime() + 0.5)
  185. self.Weapon:SetNextSecondaryFire(CurTime() + 0.5)
  186.  
  187. end
  188. end
  189. end
  190. end
  191. end
  192.  
  193. function SWEP:Initialize()
  194.  
  195. // other initialize code goes here
  196.  
  197. if CLIENT then
  198.  
  199. // Create a new table for every weapon instance
  200. self.VElements = table.FullCopy( self.VElements )
  201. self.WElements = table.FullCopy( self.WElements )
  202. self.ViewModelBoneMods = table.FullCopy( self.ViewModelBoneMods )
  203.  
  204. self:CreateModels(self.VElements) // create viewmodels
  205. self:CreateModels(self.WElements) // create worldmodels
  206.  
  207. // init view model bone build function
  208. local vm = self.Owner:GetViewModel()
  209. if IsValid(vm) then
  210. self:ResetBonePositions(vm)
  211. end
  212.  
  213. // Init viewmodel visibility
  214. if (self.ShowViewModel == nil or self.ShowViewModel) then
  215. vm:SetColor(Color(255,255,255,255))
  216. else
  217. // we set the alpha to 1 instead of 0 because else ViewModelDrawn stops being called
  218. vm:SetColor(Color(255,255,255,1))
  219. // ^ stopped working in GMod 13 because you have to do Entity:SetRenderMode(1) for translucency to kick in
  220. // 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
  221. vm:SetMaterial("Debug/hsv")
  222. end
  223.  
  224. end
  225.  
  226. end
  227.  
  228. function SWEP:Holster()
  229.  
  230. if CLIENT then
  231. local vm = self.Owner:GetViewModel()
  232. if IsValid(vm) then
  233. self:ResetBonePositions(vm)
  234. end
  235. end
  236.  
  237. return true
  238. end
  239.  
  240. if CLIENT then
  241.  
  242. SWEP.vRenderOrder = nil
  243. function SWEP:ViewModelDrawn()
  244.  
  245. local vm = self.Owner:GetViewModel()
  246. if !IsValid(vm) then return end
  247.  
  248. if (!self.VElements) then return end
  249.  
  250. self:UpdateBonePositions(vm)
  251.  
  252. if (!self.vRenderOrder) then
  253.  
  254. // we build a render order because sprites need to be drawn after models
  255. self.vRenderOrder = {}
  256.  
  257. for k, v in pairs( self.VElements ) do
  258. if (v.type == "Model") then
  259. table.insert(self.vRenderOrder, 1, k)
  260. elseif (v.type == "Sprite" or v.type == "Quad") then
  261. table.insert(self.vRenderOrder, k)
  262. end
  263. end
  264.  
  265. end
  266.  
  267. for k, name in ipairs( self.vRenderOrder ) do
  268.  
  269. local v = self.VElements[name]
  270. if (!v) then self.vRenderOrder = nil break end
  271. if (v.hide) then continue end
  272.  
  273. local model = v.modelEnt
  274. local sprite = v.spriteMaterial
  275.  
  276. if (!v.bone) then continue end
  277.  
  278. local pos, ang = self:GetBoneOrientation( self.VElements, v, vm )
  279.  
  280. if (!pos) then continue end
  281.  
  282. if (v.type == "Model" and IsValid(model)) then
  283.  
  284. model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
  285. ang:RotateAroundAxis(ang:Up(), v.angle.y)
  286. ang:RotateAroundAxis(ang:Right(), v.angle.p)
  287. ang:RotateAroundAxis(ang:Forward(), v.angle.r)
  288.  
  289. model:SetAngles(ang)
  290. //model:SetModelScale(v.size)
  291. local matrix = Matrix()
  292. matrix:Scale(v.size)
  293. model:EnableMatrix( "RenderMultiply", matrix )
  294.  
  295. if (v.material == "") then
  296. model:SetMaterial("")
  297. elseif (model:GetMaterial() != v.material) then
  298. model:SetMaterial( v.material )
  299. end
  300.  
  301. if (v.skin and v.skin != model:GetSkin()) then
  302. model:SetSkin(v.skin)
  303. end
  304.  
  305. if (v.bodygroup) then
  306. for k, v in pairs( v.bodygroup ) do
  307. if (model:GetBodygroup(k) != v) then
  308. model:SetBodygroup(k, v)
  309. end
  310. end
  311. end
  312.  
  313. if (v.surpresslightning) then
  314. render.SuppressEngineLighting(true)
  315. end
  316.  
  317. render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
  318. render.SetBlend(v.color.a/255)
  319. model:DrawModel()
  320. render.SetBlend(1)
  321. render.SetColorModulation(1, 1, 1)
  322.  
  323. if (v.surpresslightning) then
  324. render.SuppressEngineLighting(false)
  325. end
  326.  
  327. elseif (v.type == "Sprite" and sprite) then
  328.  
  329. local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
  330. render.SetMaterial(sprite)
  331. render.DrawSprite(drawpos, v.size.x, v.size.y, v.color)
  332.  
  333. elseif (v.type == "Quad" and v.draw_func) then
  334.  
  335. local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
  336. ang:RotateAroundAxis(ang:Up(), v.angle.y)
  337. ang:RotateAroundAxis(ang:Right(), v.angle.p)
  338. ang:RotateAroundAxis(ang:Forward(), v.angle.r)
  339.  
  340. cam.Start3D2D(drawpos, ang, v.size)
  341. v.draw_func( self )
  342. cam.End3D2D()
  343.  
  344. end
  345.  
  346. end
  347.  
  348. end
  349.  
  350. SWEP.wRenderOrder = nil
  351. function SWEP:DrawWorldModel()
  352.  
  353. if (self.ShowWorldModel == nil or self.ShowWorldModel) then
  354. self:DrawModel()
  355. end
  356.  
  357. if (!self.WElements) then return end
  358.  
  359. if (!self.wRenderOrder) then
  360.  
  361. self.wRenderOrder = {}
  362.  
  363. for k, v in pairs( self.WElements ) do
  364. if (v.type == "Model") then
  365. table.insert(self.wRenderOrder, 1, k)
  366. elseif (v.type == "Sprite" or v.type == "Quad") then
  367. table.insert(self.wRenderOrder, k)
  368. end
  369. end
  370.  
  371. end
  372.  
  373. if (IsValid(self.Owner)) then
  374. bone_ent = self.Owner
  375. else
  376. // when the weapon is dropped
  377. bone_ent = self
  378. end
  379.  
  380. for k, name in pairs( self.wRenderOrder ) do
  381.  
  382. local v = self.WElements[name]
  383. if (!v) then self.wRenderOrder = nil break end
  384. if (v.hide) then continue end
  385.  
  386. local pos, ang
  387.  
  388. if (v.bone) then
  389. pos, ang = self:GetBoneOrientation( self.WElements, v, bone_ent )
  390. else
  391. pos, ang = self:GetBoneOrientation( self.WElements, v, bone_ent, "ValveBiped.Bip01_R_Hand" )
  392. end
  393.  
  394. if (!pos) then continue end
  395.  
  396. local model = v.modelEnt
  397. local sprite = v.spriteMaterial
  398.  
  399. if (v.type == "Model" and IsValid(model)) then
  400.  
  401. model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
  402. ang:RotateAroundAxis(ang:Up(), v.angle.y)
  403. ang:RotateAroundAxis(ang:Right(), v.angle.p)
  404. ang:RotateAroundAxis(ang:Forward(), v.angle.r)
  405.  
  406. model:SetAngles(ang)
  407. //model:SetModelScale(v.size)
  408. local matrix = Matrix()
  409. matrix:Scale(v.size)
  410. model:EnableMatrix( "RenderMultiply", matrix )
  411.  
  412. if (v.material == "") then
  413. model:SetMaterial("")
  414. elseif (model:GetMaterial() != v.material) then
  415. model:SetMaterial( v.material )
  416. end
  417.  
  418. if (v.skin and v.skin != model:GetSkin()) then
  419. model:SetSkin(v.skin)
  420. end
  421.  
  422. if (v.bodygroup) then
  423. for k, v in pairs( v.bodygroup ) do
  424. if (model:GetBodygroup(k) != v) then
  425. model:SetBodygroup(k, v)
  426. end
  427. end
  428. end
  429.  
  430. if (v.surpresslightning) then
  431. render.SuppressEngineLighting(true)
  432. end
  433.  
  434. render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
  435. render.SetBlend(v.color.a/255)
  436. model:DrawModel()
  437. render.SetBlend(1)
  438. render.SetColorModulation(1, 1, 1)
  439.  
  440. if (v.surpresslightning) then
  441. render.SuppressEngineLighting(false)
  442. end
  443.  
  444. elseif (v.type == "Sprite" and sprite) then
  445.  
  446. local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
  447. render.SetMaterial(sprite)
  448. render.DrawSprite(drawpos, v.size.x, v.size.y, v.color)
  449.  
  450. elseif (v.type == "Quad" and v.draw_func) then
  451.  
  452. local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
  453. ang:RotateAroundAxis(ang:Up(), v.angle.y)
  454. ang:RotateAroundAxis(ang:Right(), v.angle.p)
  455. ang:RotateAroundAxis(ang:Forward(), v.angle.r)
  456.  
  457. cam.Start3D2D(drawpos, ang, v.size)
  458. v.draw_func( self )
  459. cam.End3D2D()
  460.  
  461. end
  462.  
  463. end
  464.  
  465. end
  466.  
  467. function SWEP:GetBoneOrientation( basetab, tab, ent, bone_override )
  468.  
  469. local bone, pos, ang
  470. if (tab.rel and tab.rel != "") then
  471.  
  472. local v = basetab[tab.rel]
  473.  
  474. if (!v) then return end
  475.  
  476. // Technically, if there exists an element with the same name as a bone
  477. // you can get in an infinite loop. Let's just hope nobody's that stupid.
  478. pos, ang = self:GetBoneOrientation( basetab, v, ent )
  479.  
  480. if (!pos) then return end
  481.  
  482. pos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
  483. ang:RotateAroundAxis(ang:Up(), v.angle.y)
  484. ang:RotateAroundAxis(ang:Right(), v.angle.p)
  485. ang:RotateAroundAxis(ang:Forward(), v.angle.r)
  486.  
  487. else
  488.  
  489. bone = ent:LookupBone(bone_override or tab.bone)
  490.  
  491. if (!bone) then return end
  492.  
  493. pos, ang = Vector(0,0,0), Angle(0,0,0)
  494. local m = ent:GetBoneMatrix(bone)
  495. if (m) then
  496. pos, ang = m:GetTranslation(), m:GetAngles()
  497. end
  498.  
  499. if (IsValid(self.Owner) and self.Owner:IsPlayer() and
  500. ent == self.Owner:GetViewModel() and self.ViewModelFlip) then
  501. ang.r = -ang.r // Fixes mirrored models
  502. end
  503.  
  504. end
  505.  
  506. return pos, ang
  507. end
  508.  
  509. function SWEP:CreateModels( tab )
  510.  
  511. if (!tab) then return end
  512.  
  513. // Create the clientside models here because Garry says we can't do it in the render hook
  514. for k, v in pairs( tab ) do
  515. if (v.type == "Model" and v.model and v.model != "" and (!IsValid(v.modelEnt) or v.createdModel != v.model) and
  516. string.find(v.model, ".mdl") and file.Exists (v.model, "GAME") ) then
  517.  
  518. v.modelEnt = ClientsideModel(v.model, RENDER_GROUP_VIEW_MODEL_OPAQUE)
  519. if (IsValid(v.modelEnt)) then
  520. v.modelEnt:SetPos(self:GetPos())
  521. v.modelEnt:SetAngles(self:GetAngles())
  522. v.modelEnt:SetParent(self)
  523. v.modelEnt:SetNoDraw(true)
  524. v.createdModel = v.model
  525. else
  526. v.modelEnt = nil
  527. end
  528.  
  529. elseif (v.type == "Sprite" and v.sprite and v.sprite != "" and (!v.spriteMaterial or v.createdSprite != v.sprite)
  530. and file.Exists ("materials/"..v.sprite..".vmt", "GAME")) then
  531.  
  532. local name = v.sprite.."-"
  533. local params = { ["$basetexture"] = v.sprite }
  534. // make sure we create a unique name based on the selected options
  535. local tocheck = { "nocull", "additive", "vertexalpha", "vertexcolor", "ignorez" }
  536. for i, j in pairs( tocheck ) do
  537. if (v[j]) then
  538. params["$"..j] = 1
  539. name = name.."1"
  540. else
  541. name = name.."0"
  542. end
  543. end
  544.  
  545. v.createdSprite = v.sprite
  546. v.spriteMaterial = CreateMaterial(name,"UnlitGeneric",params)
  547.  
  548. end
  549. end
  550.  
  551. end
  552.  
  553. local allbones
  554. local hasGarryFixedBoneScalingYet = false
  555.  
  556. function SWEP:UpdateBonePositions(vm)
  557.  
  558. if self.ViewModelBoneMods then
  559.  
  560. if (!vm:GetBoneCount()) then return end
  561.  
  562. // !! WORKAROUND !! //
  563. // We need to check all model names :/
  564. local loopthrough = self.ViewModelBoneMods
  565. if (!hasGarryFixedBoneScalingYet) then
  566. allbones = {}
  567. for i=0, vm:GetBoneCount() do
  568. local bonename = vm:GetBoneName(i)
  569. if (self.ViewModelBoneMods[bonename]) then
  570. allbones[bonename] = self.ViewModelBoneMods[bonename]
  571. else
  572. allbones[bonename] = {
  573. scale = Vector(1,1,1),
  574. pos = Vector(0,0,0),
  575. angle = Angle(0,0,0)
  576. }
  577. end
  578. end
  579.  
  580. loopthrough = allbones
  581. end
  582. // !! ----------- !! //
  583.  
  584. for k, v in pairs( loopthrough ) do
  585. local bone = vm:LookupBone(k)
  586. if (!bone) then continue end
  587.  
  588. // !! WORKAROUND !! //
  589. local s = Vector(v.scale.x,v.scale.y,v.scale.z)
  590. local p = Vector(v.pos.x,v.pos.y,v.pos.z)
  591. local ms = Vector(1,1,1)
  592. if (!hasGarryFixedBoneScalingYet) then
  593. local cur = vm:GetBoneParent(bone)
  594. while(cur >= 0) do
  595. local pscale = loopthrough[vm:GetBoneName(cur)].scale
  596. ms = ms * pscale
  597. cur = vm:GetBoneParent(cur)
  598. end
  599. end
  600.  
  601. s = s * ms
  602. // !! ----------- !! //
  603.  
  604. if vm:GetManipulateBoneScale(bone) != s then
  605. vm:ManipulateBoneScale( bone, s )
  606. end
  607. if vm:GetManipulateBoneAngles(bone) != v.angle then
  608. vm:ManipulateBoneAngles( bone, v.angle )
  609. end
  610. if vm:GetManipulateBonePosition(bone) != p then
  611. vm:ManipulateBonePosition( bone, p )
  612. end
  613. end
  614. else
  615. self:ResetBonePositions(vm)
  616. end
  617.  
  618. end
  619.  
  620. function SWEP:ResetBonePositions(vm)
  621.  
  622. if (!vm:GetBoneCount()) then return end
  623. for i=0, vm:GetBoneCount() do
  624. vm:ManipulateBoneScale( i, Vector(1, 1, 1) )
  625. vm:ManipulateBoneAngles( i, Angle(0, 0, 0) )
  626. vm:ManipulateBonePosition( i, Vector(0, 0, 0) )
  627. end
  628.  
  629. end
  630.  
  631. /**************************
  632. Global utility code
  633. **************************/
  634.  
  635. // Fully copies the table, meaning all tables inside this table are copied too and so on (normal table.Copy copies only their reference).
  636. // Does not copy entities of course, only copies their reference.
  637. // WARNING: do not use on tables that contain themselves somewhere down the line or you'll get an infinite loop
  638. function table.FullCopy( tab )
  639.  
  640. if (!tab) then return nil end
  641.  
  642. local res = {}
  643. for k, v in pairs( tab ) do
  644. if (type(v) == "table") then
  645. res[k] = table.FullCopy(v) // recursion ho!
  646. elseif (type(v) == "Vector") then
  647. res[k] = Vector(v.x, v.y, v.z)
  648. elseif (type(v) == "Angle") then
  649. res[k] = Angle(v.p, v.y, v.r)
  650. else
  651. res[k] = v
  652. end
  653. end
  654.  
  655. return res
  656.  
  657. end
  658.  
  659. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement