Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.57 KB | None | 0 0
  1. ENT.RenderGroup = RENDERGROUP_OPAQUE
  2. ENT.Base = "fighter_base"
  3. ENT.Type = "vehicle"
  4.  
  5. ENT.PrintName = "V-19"
  6. ENT.Author = "Liam0102, Cody"
  7. ENT.Category = "Star Wars Vehicles: Republic"
  8. ENT.AutomaticFrameAdvance = true
  9. ENT.Spawnable = false;
  10. ENT.AdminSpawnable = false;
  11.  
  12. ENT.EntModel = "models/props/ships/closedtorrent/closedtorrent.mdl"
  13. ENT.Vehicle = "v19"
  14. ENT.StartHealth = 1500;
  15. ENT.Allegiance = "Republic";
  16.  
  17. ENT.WingsModel = "models/props/ships/opentorrent/opentorrent.mdl"
  18. ENT.ClosedModel = "models/props/ships/closedtorrent/closedtorrent.mdl"
  19. list.Set("SWVehicles", ENT.PrintName, ENT);
  20.  
  21. if SERVER then
  22.  
  23. ENT.FireSound = Sound("weapons/xwing_shoot.wav");
  24. ENT.NextUse = {Wings = CurTime(),Use = CurTime(),Fire = CurTime(),Switch=CurTime(),};
  25.  
  26. AddCSLuaFile();
  27. function ENT:SpawnFunction(pl, tr)
  28. local e = ents.Create("v19");
  29. e:SetPos(tr.HitPos + Vector(0,0,0));
  30. e:SetAngles(Angle(0,pl:GetAimVector():Angle().Yaw+180,0));
  31. e:Spawn();
  32. e:Activate();
  33. return e;
  34. end
  35.  
  36. function ENT:Initialize()
  37.  
  38. self:SetNWInt("Health",self.StartHealth);
  39.  
  40. self.WeaponLocations = {
  41. WingRightR = self:GetPos()+self:GetForward()*217.5+self:GetUp()*-122.5+self:GetRight()*260,
  42. WingRightL = self:GetPos()+self:GetForward()*217.5+self:GetUp()*-122.5+self:GetRight()*260,
  43. WingLeftL = self:GetPos()+self:GetForward()*217.5+self:GetUp()*-122.5+self:GetRight()*-260,
  44. WingLeftR = self:GetPos()+self:GetForward()*217.5+self:GetUp()*-122.5+self:GetRight()*-260,
  45.  
  46. }
  47. self.WeaponsTable = {};
  48. self.BoostSpeed = 2400;
  49. self.ForwardSpeed = 2400;
  50. self.UpSpeed = 600;
  51. self.AccelSpeed = 9;
  52. self.CanStandby = false;
  53. self.CanBack = false;
  54. self.CanRoll = false;
  55. self.CanStrafe = true;
  56. self.Cooldown = 2;
  57. self.CanShoot = true;
  58. self.Bullet = CreateBulletStructure(65,"blue");
  59. self.FireDelay = 0.15;
  60. self.AlternateFire = true;
  61. self.FireGroup = {"RightR","RightL","LeftL","LeftR"};
  62. self.HasWings = true;
  63. self.ExitModifier = {x = 100, y = -80, z = 115};
  64. self.CanEject = false;
  65.  
  66. self.BaseClass.Initialize(self);
  67.  
  68. end
  69.  
  70. function ENT:Enter(p)
  71. if(!IsValid(self.Pilot)) then
  72. self:SetModel(self.ClosedModel);
  73. self:PhysicsInit(SOLID_VPHYSICS);
  74. self:SkinSwitch(true);
  75. if(IsValid(self:GetPhysicsObject())) then
  76. self:GetPhysicsObject():EnableMotion(true);
  77. self:GetPhysicsObject():Wake();
  78. end
  79. self:StartMotionController();
  80. end
  81. self.BaseClass.Enter(self,p);
  82. end
  83.  
  84. function ENT:Exit(kill)
  85. local p = self.Pilot;
  86. self.BaseClass.Exit(self,kill);
  87. if(self.Land or self.TakeOff) then
  88. self:SetModel(self.EntModel);
  89. self:PhysicsInit(SOLID_VPHYSICS);
  90. if(IsValid(self:GetPhysicsObject())) then
  91. self:GetPhysicsObject():EnableMotion(true);
  92. self:GetPhysicsObject():Wake();
  93. end
  94. self:StartMotionController();
  95. if(IsValid(p)) then
  96. p:SetEyeAngles(self:GetAngles()+Angle(0,180,0));
  97. end
  98. end
  99. end
  100.  
  101. function ENT:ToggleWings()
  102. if(!IsValid(self)) then return end;
  103. if(self.NextUse.Wings < CurTime()) then
  104. if(self.Wings) then
  105. self:SetModel(self.ClosedModel);
  106. self.Bullet = CreateBulletStructure(65,"blue");
  107. self.Wings = false;
  108. else
  109. self.Wings = true;
  110. self:SetModel(self.WingsModel);
  111. self.Bullet = CreateBulletStructure(75,"blue");
  112. self.FireGroup = {"WingRightR","WingRightL","WingLeftL","WingLeftR"};
  113. end
  114. for k,v in pairs(self.Weapons) do
  115. if(!self.Wings and (k=="WingLeftL" or k=="WingLeftR" or k == "WingRightL" or k=="WingRightR")) then
  116. v.Disabled = true;
  117. end
  118. end
  119. self:PhysicsInit(SOLID_VPHYSICS);
  120. if(IsValid(self:GetPhysicsObject())) then
  121. self:GetPhysicsObject():EnableMotion(true);
  122. self:GetPhysicsObject():Wake();
  123. end
  124. self:StartMotionController();
  125. self:SetNWBool("Wings",self.Wings);
  126. if(IsValid(self.Pilot)) then
  127. self.Pilot:SetNWBool("SW_Wings",self.Wings);
  128. end
  129. self.NextUse.Wings = CurTime() + 1;
  130. end
  131. end
  132.  
  133. function ENT:Enter(p)
  134. self.BaseClass.Enter(self,p);
  135. end
  136.  
  137. function ENT:Exit(kill)
  138. self.BaseClass.Exit(self,kill);
  139. end
  140.  
  141. function ENT:Think()
  142.  
  143.  
  144. if(self.Inflight) then
  145. if(!self.Wings) then
  146. self.CanShoot = false;
  147. else
  148. self.CanShoot = true;
  149. end
  150.  
  151. end
  152. self.BaseClass.Think(self);
  153. end
  154.  
  155. end
  156.  
  157. if CLIENT then
  158.  
  159. function ENT:Draw() self:DrawModel() end
  160.  
  161. ENT.EnginePos = {}
  162. ENT.Sounds={
  163. Engine=Sound("vehicles/xwing/xwing_fly2.wav"),
  164. }
  165. ENT.CanFPV = false;
  166.  
  167. local Health = 0;
  168. local Overheat = 0;
  169. local Overheated = false;
  170. function ENT:Think()
  171. self.BaseClass.Think(self);
  172.  
  173. local p = LocalPlayer();
  174. local Flying = self:GetNWBool("Flying".. self.Vehicle);
  175. local IsFlying = p:GetNWBool("Flying"..self.Vehicle);
  176. local Wings = self:GetNWBool("Wings");
  177. local TakeOff = self:GetNWBool("TakeOff");
  178. local Land = self:GetNWBool("Land");
  179.  
  180. if(Flying) then
  181. if(!TakeOff and !Land) then
  182. self:FlightEffects();
  183. end
  184. Health = self:GetNWInt("Health");
  185.  
  186. end
  187.  
  188.  
  189. end
  190.  
  191. ENT.ViewDistance = 700;
  192. ENT.ViewHeight = 200;
  193.  
  194. function ENT:FlightEffects()
  195. local normal = (self:GetForward() * -1):GetNormalized()
  196. local roll = math.Rand(-90,90)
  197. local p = LocalPlayer()
  198. local FWD = self:GetForward();
  199. local id = self:EntIndex();
  200.  
  201. self.EnginePos = {
  202. self:GetPos()+self:GetUp()*28+self:GetRight()*-84+self:GetForward()*-110;
  203.  
  204. self:GetPos()+self:GetUp()*28+self:GetRight()*84+self:GetForward()*-110;
  205. }
  206. for k,v in pairs(self.EnginePos) do
  207.  
  208. local blue = self.FXEmitter:Add("sprites/bluecore",v)
  209. blue:SetVelocity(normal)
  210. blue:SetDieTime(0.025)
  211. blue:SetStartAlpha(255)
  212. blue:SetEndAlpha(255)
  213. blue:SetStartSize(25.5)
  214. blue:SetEndSize(18)
  215. blue:SetRoll(roll)
  216. blue:SetColor(255,255,255)
  217.  
  218. local dynlight = DynamicLight(id + 4096 * k);
  219. dynlight.Pos = v;
  220. dynlight.Brightness = 5;
  221. dynlight.Size = 150;
  222. dynlight.Decay = 724;
  223. dynlight.R = 100;
  224. dynlight.G = 100;
  225. dynlight.B = 255;
  226. dynlight.DieTime = CurTime()+1;
  227.  
  228. end
  229.  
  230. end
  231.  
  232. function V19Reticle()
  233.  
  234. local p = LocalPlayer();
  235. local Flying = p:GetNWBool("FlyingV19");
  236. local self = p:GetNWEntity("V19");
  237. if(Flying and IsValid(self)) then
  238. SW_HUD_DrawHull(1500);
  239. SW_WeaponReticles(self);
  240. SW_HUD_DrawOverheating(self);
  241.  
  242. SW_HUD_Compass(self);
  243. SW_HUD_DrawSpeedometer();
  244. end
  245. end
  246. hook.Add("HUDPaint", "V19Reticle", V19Reticle)
  247.  
  248. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement