Advertisement
Guest User

Untitled

a guest
Jun 6th, 2014
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.57 KB | None | 0 0
  1. SWEP.Author = "Darkfortune, Dorpz (For fixing)"
  2. SWEP.Contact = "dorpzman@hotmail.com"
  3. SWEP.Purpose = "Allows you to swing all over the place like!"
  4. SWEP.Instructions = "Left click to shot web"
  5.  
  6. SWEP.Spawnable = true
  7. SWEP.AdminSpawnable = true
  8.  
  9. SWEP.PrintName = "Spiderman's Gun"
  10. SWEP.Slot = 2
  11. SWEP.SlotPos = 0
  12. SWEP.DrawAmmo = false
  13. SWEP.DrawCrosshair = true
  14. SWEP.ViewModel = "models/weapons/v_pistol.mdl"
  15. SWEP.WorldModel = "models/weapons/w_pistol.mdl"
  16.  
  17. -- //TTT Convertion Code \\
  18.  
  19. SWEP.Base = "weapon_tttbase"
  20. SWEP.Kind = WEAPON_EQUIP1
  21. SWEP.CanBuy = { ROLE_DETECTIVE }
  22. SWEP.AutoSpawnable = false
  23. SWEP.InLoadoutFor = nil
  24. SWEP.LimitedStock = false
  25. SWEP.AllowDrop = true
  26. SWEP.IsSilent = false
  27. SWEP.NoSights = false
  28.  
  29.  
  30. if CLIENT then
  31. SWEP.PrintName = "Spiderman's Gun"
  32. SWEP.Slot = 7
  33.  
  34. SWEP.EquipMenuData = {
  35. type = "Weapon",
  36. desc = "Fly ... High ..."
  37. };
  38.  
  39. SWEP.Icon = "VGUI/ttt/spiderman"
  40. end
  41.  
  42. if SERVER then
  43. resource.AddFile("materials/VGUI/ttt/spiderman.vmt")
  44. end
  45.  
  46. -- //TTT Convertion Code \\
  47.  
  48.  
  49. function SWEP:Initialize()
  50.  
  51. nextshottime = CurTime()
  52. self:SetWeaponHoldType( "pistol" )
  53.  
  54. end
  55.  
  56. function SWEP:Think()
  57.  
  58. if (!self.Owner || self.Owner == NULL) then return end
  59.  
  60. if ( self.Owner:KeyPressed( IN_ATTACK ) ) then
  61.  
  62. self:StartAttack()
  63.  
  64. elseif ( self.Owner:KeyDown( IN_ATTACK ) && inRange ) then
  65.  
  66. self:UpdateAttack()
  67.  
  68. elseif ( self.Owner:KeyReleased( IN_ATTACK ) && inRange ) then
  69.  
  70. self:EndAttack( true )
  71.  
  72. end
  73.  
  74. if ( self.Owner:KeyPressed( IN_ATTACK2 ) ) then
  75.  
  76. self:Attack2()
  77.  
  78. end
  79.  
  80. end
  81.  
  82. function SWEP:DoTrace( endpos )
  83. local trace = {}
  84. trace.start = self.Owner:GetShootPos()
  85. trace.endpos = trace.start + (self.Owner:GetAimVector() * 14096)
  86. if(endpos) then trace.endpos = (endpos - self.Tr.HitNormal * 7) end
  87. trace.filter = { self.Owner, self.Weapon }
  88.  
  89. self.Tr = nil
  90. self.Tr = util.TraceLine( trace )
  91. end
  92.  
  93. function SWEP:StartAttack()
  94. local gunPos = self.Owner:GetShootPos()
  95. local disTrace = self.Owner:GetEyeTrace()
  96. local hitPos = disTrace.HitPos
  97.  
  98. local x = (gunPos.x - hitPos.x)^2;
  99. local y = (gunPos.y - hitPos.y)^2;
  100. local z = (gunPos.z - hitPos.z)^2;
  101. local distance = math.sqrt(x + y + z);
  102.  
  103. local distanceCvar = GetConVarNumber("rope_distance")
  104. inRange = false
  105. if distance <= distanceCvar then
  106. inRange = true
  107. end
  108.  
  109. if inRange then
  110. if (SERVER) then
  111.  
  112. if (!self.Beam) then
  113. self.Beam = ents.Create( "rope" )
  114. self.Beam:SetPos( self.Owner:GetShootPos() )
  115. self.Beam:Spawn()
  116. end
  117.  
  118. self.Beam:SetParent( self.Owner )
  119. self.Beam:SetOwner( self.Owner )
  120.  
  121. end
  122.  
  123. self:DoTrace()
  124. self.speed = 10000
  125. self.startTime = CurTime()
  126. self.endTime = CurTime() + self.speed
  127. self.dt = -1
  128.  
  129. if (SERVER && self.Beam) then
  130. self.Beam:GetTable():SetEndPos( self.Tr.HitPos )
  131. end
  132.  
  133. self:UpdateAttack()
  134.  
  135. else
  136. end
  137. end
  138.  
  139. function SWEP:UpdateAttack()
  140.  
  141. self.Owner:LagCompensation( true )
  142.  
  143. if (!endpos) then endpos = self.Tr.HitPos end
  144.  
  145. if (SERVER && self.Beam) then
  146. self.Beam:GetTable():SetEndPos( endpos )
  147. end
  148.  
  149. lastpos = endpos
  150.  
  151.  
  152. if ( self.Tr.Entity:IsValid() ) then
  153.  
  154. endpos = self.Tr.Entity:GetPos()
  155. if ( SERVER ) then
  156. self.Beam:GetTable():SetEndPos( endpos )
  157. end
  158.  
  159. end
  160.  
  161. local vVel = (endpos - self.Owner:GetPos())
  162. local Distance = endpos:Distance(self.Owner:GetPos())
  163.  
  164. local et = (self.startTime + (Distance/self.speed))
  165. if(self.dt != 0) then
  166. self.dt = (et - CurTime()) / (et - self.startTime)
  167. end
  168. if(self.dt < 0) then
  169. self.dt = 0
  170. end
  171.  
  172. if(self.dt == 0) then
  173. zVel = self.Owner:GetVelocity().z
  174. vVel = vVel:GetNormalized()*(math.Clamp(Distance,0,7))
  175. if( SERVER ) then
  176. local gravity = GetConVarNumber("sv_Gravity")
  177. vVel:Add(Vector(0,0,(gravity/100)*1.5))
  178. if(zVel < 0) then
  179. vVel:Sub(Vector(0,0,zVel/100))
  180. end
  181. self.Owner:SetVelocity(vVel)
  182. end
  183. end
  184.  
  185. endpos = nil
  186.  
  187. self.Owner:LagCompensation( false )
  188.  
  189. end
  190.  
  191. function SWEP:EndAttack( shutdownsound )
  192.  
  193. if ( CLIENT ) then return end
  194. if ( !self.Beam ) then return end
  195.  
  196. self.Beam:Remove()
  197. self.Beam = nil
  198.  
  199. end
  200.  
  201. function SWEP:Attack2()
  202.  
  203.  
  204. if (CLIENT) then return end
  205. local CF = self.Owner:GetFOV()
  206. if CF == 90 then
  207. self.Owner:SetFOV(30,.3)
  208. elseif CF == 30 then
  209. self.Owner:SetFOV(90,.3)
  210. end
  211. end
  212.  
  213. function SWEP:Holster()
  214. self:EndAttack( false )
  215. return true
  216. end
  217.  
  218. function SWEP:OnRemove()
  219. self:EndAttack( false )
  220. return true
  221. end
  222.  
  223.  
  224. function SWEP:PrimaryAttack()
  225. end
  226.  
  227. function SWEP:SecondaryAttack()
  228. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement