Skip to content

Instantly share code, notes, and snippets.

@dhkatz
Last active October 6, 2018 21:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhkatz/bccf3ff398564026ce95ecfa1ef616cb to your computer and use it in GitHub Desktop.
Save dhkatz/bccf3ff398564026ce95ecfa1ef616cb to your computer and use it in GitHub Desktop.
Improved A-Wing on the new SWVR Base

Star Wars Vehicles: Redux

Introduction

With SWVR, all your code is designed to be put inside ENT:Initialize() and there only. If you find yourself having to write code elsewhere (such as overriding functions), then the base is missing a feature! Message me to get it added ASAP.

Because of this, assume ALL code examples below are inside of ENT:Initialize()

Setting Up

Setting up your ship with the basic necessary values is extremely easy. Simply run the setup function.

self:Setup(1000, 1500, nil, 550, 9, true, true)

Of course, you'll also probably want a pilot. There is a function meant just for this!

self:AddPilot(Vector(300, 0, 600), nil, {
  exitpos = Vector(-400, 0, 0),
  fpvpos = Vector(300, 0, 95)
})

In theory, these two lines of actual code are the ONLY lines required to get a ship up and running.

Of course, at this state you won't have engine effects, cool sounds, weapons, seats, etc.

Weapon System

In SWVR, adding weapons is extremely easy!

Simply create a weapon group first:

self:AddWeaponGroup("Pilot", "weapons/rz2_shoot.wav", self:InitBulltet{
  damage = 50,
  color = "red",
  delay = 0.12,
  overheatAmount = 30
})

Now, you'll probably want to add some weapons to that group.

  self:AddWeapon("Pilot", "Right", Vector(120, 87, 45))
  self:AddWeapon("Pilot", "Left", Vector(120, -87, 45))

Finally, you should update your AddPilot call to include the new weapon group. Keep in mind, any weapon groups you add to a pilot/seat must be defined BEFORE you add the pilot/seat.

self:AddPilot(Vector(300, 0, 600), nil, {
  exitpos = Vector(-400, 0, 0),
  fpvpos = Vector(300, 0, 95),
  weapons = {"Pilot"} -- Name of the group(s)
})
ENT.Base = "swvr_base"
ENT.Category = "Star Wars Vehicles: Rebels"
ENT.Spawnable = false
ENT.AdminSpawnable = false
ENT.PrintName = "A-Wing New"
ENT.Author = "Doctor Jew"
ENT.WorldModel = "models/awing/awing_bf2.mdl"
ENT.Vehicle = "AWingNew"
ENT.Allegiance = "Rebel Alliance"
list.Set("SWVRVehicles", ENT.PrintName, ENT)
util.PrecacheModel("models/awing/new_awing_cockpit.mdl") -- Precache clientside models please!
if SERVER then
function ENT:SpawnFunction(ply, tr, ClassName)
if not tr.Hit then
return
end
local ent = ents.Create(ClassName)
ent:SetPos(tr.HitPos + tr.HitNormal * 5)
ent:SetAngles(Angle(0, ply:GetAimVector():Angle().Yaw, 0))
ent:Spawn()
ent:Activate()
return ent
end
function ENT:Initialize()
self:Setup(1000, 1500, nil, 550, 7, false, true)
-- self:AddWeaponGroup(name, sound, bullet_data/torpedo_data)
self:AddWeaponGroup("Pilot", "weapons/rz2_shoot.wav", self:InitBullet{
damage = 50,
color = "red",
delay = 0.12,
overheatAmount = 30
})
-- self:AddWeapon(group, name, position)
self:AddWeapon("Pilot", "Right", Vector(120, 87, 45))
self:AddWeapon("Pilot", "Left", Vector(120, -87, 45))
-- self:AddPilot(position, angles, options)
self:AddPilot(Vector(-20, 0, 35), nil, {
exitpos = Vector(-180, 0, 0),
fpvpos = Vector(-15, 0, 75),
weapons = {"Pilot"}
})
-- Initialize the base, do not remove.
self.BaseClass.Initialize(self)
end
end
if CLIENT then
function ENT:Initialize()
self.ViewDistance = 950
self.ViewHeight = 200
-- self:AddSound(name, path, options)
self:AddSound("Engine", "vehicles/rz2_engine_loop.wav")
-- self:AddPart(name, path, position, angle)
self:AddPart("Cockpit", "models/awing/new_awing_cockpit.mdl")
-- self:AddEngine(position, start_size, end_size, lifetime, color, sprite)
self:AddEngine(Vector(-105, 42, 40), 18, 10, 2.7, Color(255, 204, 102), "sprites/orangecore1")
self:AddEngine(Vector(-105, -42, 40), 18, 10, 2.7, Color(255, 204, 102), "sprites/orangecore1")
-- Initialize the base, do not remove.
self.BaseClass.Initialize(self)
end
end
@oninoni
Copy link

oninoni commented Jul 19, 2018

To be honest i would rename the Function that is used here. Just call it "Init" or "CreateVehicle." Then you can call that from the Initialize of the baseclass and you wont have to add the "self.BasClass.Initialize(self)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment