Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ENT.RenderGroup = RENDERGROUP_OPAQUE
- ENT.Base = "fighter_base"
- ENT.Type = "vehicle"
- ENT.PrintName = "V-19"
- ENT.Author = "Liam0102, Cody"
- ENT.Category = "Star Wars Vehicles: Republic"
- ENT.AutomaticFrameAdvance = true
- ENT.Spawnable = false;
- ENT.AdminSpawnable = false;
- ENT.EntModel = "models/props/ships/closedtorrent/closedtorrent.mdl"
- ENT.Vehicle = "v19"
- ENT.StartHealth = 1500;
- ENT.Allegiance = "Republic";
- ENT.WingsModel = "models/props/ships/opentorrent/opentorrent.mdl"
- ENT.ClosedModel = "models/props/ships/closedtorrent/closedtorrent.mdl"
- list.Set("SWVehicles", ENT.PrintName, ENT);
- if SERVER then
- ENT.FireSound = Sound("weapons/xwing_shoot.wav");
- ENT.NextUse = {Wings = CurTime(),Use = CurTime(),Fire = CurTime(),Switch=CurTime(),};
- AddCSLuaFile();
- function ENT:SpawnFunction(pl, tr)
- local e = ents.Create("v19");
- e:SetPos(tr.HitPos + Vector(0,0,0));
- e:SetAngles(Angle(0,pl:GetAimVector():Angle().Yaw+180,0));
- e:Spawn();
- e:Activate();
- return e;
- end
- function ENT:Initialize()
- self:SetNWInt("Health",self.StartHealth);
- self.WeaponLocations = {
- WingRightR = self:GetPos()+self:GetForward()*217.5+self:GetUp()*-122.5+self:GetRight()*260,
- WingRightL = self:GetPos()+self:GetForward()*217.5+self:GetUp()*-122.5+self:GetRight()*260,
- WingLeftL = self:GetPos()+self:GetForward()*217.5+self:GetUp()*-122.5+self:GetRight()*-260,
- WingLeftR = self:GetPos()+self:GetForward()*217.5+self:GetUp()*-122.5+self:GetRight()*-260,
- }
- self.WeaponsTable = {};
- self.BoostSpeed = 2400;
- self.ForwardSpeed = 2400;
- self.UpSpeed = 600;
- self.AccelSpeed = 9;
- self.CanStandby = false;
- self.CanBack = false;
- self.CanRoll = false;
- self.CanStrafe = true;
- self.Cooldown = 2;
- self.CanShoot = true;
- self.Bullet = CreateBulletStructure(65,"blue");
- self.FireDelay = 0.15;
- self.AlternateFire = true;
- self.FireGroup = {"RightR","RightL","LeftL","LeftR"};
- self.HasWings = true;
- self.ExitModifier = {x = 100, y = -80, z = 115};
- self.CanEject = false;
- self.BaseClass.Initialize(self);
- end
- function ENT:Enter(p)
- if(!IsValid(self.Pilot)) then
- self:SetModel(self.ClosedModel);
- self:PhysicsInit(SOLID_VPHYSICS);
- self:SkinSwitch(true);
- if(IsValid(self:GetPhysicsObject())) then
- self:GetPhysicsObject():EnableMotion(true);
- self:GetPhysicsObject():Wake();
- end
- self:StartMotionController();
- end
- self.BaseClass.Enter(self,p);
- end
- function ENT:Exit(kill)
- local p = self.Pilot;
- self.BaseClass.Exit(self,kill);
- if(self.Land or self.TakeOff) then
- self:SetModel(self.EntModel);
- self:PhysicsInit(SOLID_VPHYSICS);
- if(IsValid(self:GetPhysicsObject())) then
- self:GetPhysicsObject():EnableMotion(true);
- self:GetPhysicsObject():Wake();
- end
- self:StartMotionController();
- if(IsValid(p)) then
- p:SetEyeAngles(self:GetAngles()+Angle(0,180,0));
- end
- end
- end
- function ENT:ToggleWings()
- if(!IsValid(self)) then return end;
- if(self.NextUse.Wings < CurTime()) then
- if(self.Wings) then
- self:SetModel(self.ClosedModel);
- self.Bullet = CreateBulletStructure(65,"blue");
- self.Wings = false;
- else
- self.Wings = true;
- self:SetModel(self.WingsModel);
- self.Bullet = CreateBulletStructure(75,"blue");
- self.FireGroup = {"WingRightR","WingRightL","WingLeftL","WingLeftR"};
- end
- for k,v in pairs(self.Weapons) do
- if(!self.Wings and (k=="WingLeftL" or k=="WingLeftR" or k == "WingRightL" or k=="WingRightR")) then
- v.Disabled = true;
- end
- end
- self:PhysicsInit(SOLID_VPHYSICS);
- if(IsValid(self:GetPhysicsObject())) then
- self:GetPhysicsObject():EnableMotion(true);
- self:GetPhysicsObject():Wake();
- end
- self:StartMotionController();
- self:SetNWBool("Wings",self.Wings);
- if(IsValid(self.Pilot)) then
- self.Pilot:SetNWBool("SW_Wings",self.Wings);
- end
- self.NextUse.Wings = CurTime() + 1;
- end
- end
- function ENT:Enter(p)
- self.BaseClass.Enter(self,p);
- end
- function ENT:Exit(kill)
- self.BaseClass.Exit(self,kill);
- end
- function ENT:Think()
- if(self.Inflight) then
- if(!self.Wings) then
- self.CanShoot = false;
- else
- self.CanShoot = true;
- end
- end
- self.BaseClass.Think(self);
- end
- end
- if CLIENT then
- function ENT:Draw() self:DrawModel() end
- ENT.EnginePos = {}
- ENT.Sounds={
- Engine=Sound("vehicles/xwing/xwing_fly2.wav"),
- }
- ENT.CanFPV = false;
- local Health = 0;
- local Overheat = 0;
- local Overheated = false;
- function ENT:Think()
- self.BaseClass.Think(self);
- local p = LocalPlayer();
- local Flying = self:GetNWBool("Flying".. self.Vehicle);
- local IsFlying = p:GetNWBool("Flying"..self.Vehicle);
- local Wings = self:GetNWBool("Wings");
- local TakeOff = self:GetNWBool("TakeOff");
- local Land = self:GetNWBool("Land");
- if(Flying) then
- if(!TakeOff and !Land) then
- self:FlightEffects();
- end
- Health = self:GetNWInt("Health");
- end
- end
- ENT.ViewDistance = 700;
- ENT.ViewHeight = 200;
- function ENT:FlightEffects()
- local normal = (self:GetForward() * -1):GetNormalized()
- local roll = math.Rand(-90,90)
- local p = LocalPlayer()
- local FWD = self:GetForward();
- local id = self:EntIndex();
- self.EnginePos = {
- self:GetPos()+self:GetUp()*28+self:GetRight()*-84+self:GetForward()*-110;
- self:GetPos()+self:GetUp()*28+self:GetRight()*84+self:GetForward()*-110;
- }
- for k,v in pairs(self.EnginePos) do
- local blue = self.FXEmitter:Add("sprites/bluecore",v)
- blue:SetVelocity(normal)
- blue:SetDieTime(0.025)
- blue:SetStartAlpha(255)
- blue:SetEndAlpha(255)
- blue:SetStartSize(25.5)
- blue:SetEndSize(18)
- blue:SetRoll(roll)
- blue:SetColor(255,255,255)
- local dynlight = DynamicLight(id + 4096 * k);
- dynlight.Pos = v;
- dynlight.Brightness = 5;
- dynlight.Size = 150;
- dynlight.Decay = 724;
- dynlight.R = 100;
- dynlight.G = 100;
- dynlight.B = 255;
- dynlight.DieTime = CurTime()+1;
- end
- end
- function V19Reticle()
- local p = LocalPlayer();
- local Flying = p:GetNWBool("FlyingV19");
- local self = p:GetNWEntity("V19");
- if(Flying and IsValid(self)) then
- SW_HUD_DrawHull(1500);
- SW_WeaponReticles(self);
- SW_HUD_DrawOverheating(self);
- SW_HUD_Compass(self);
- SW_HUD_DrawSpeedometer();
- end
- end
- hook.Add("HUDPaint", "V19Reticle", V19Reticle)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement