WAC Helicopter "helicopter.SeatsT function or whatever changed?
0 replies, posted
I'm very new to lua and whatnot, but I have an addon i'm trying to fix for the newest version of WAC. There used to be a value or function or whatever, called ".wep", and now it's no longer available. It basically updated seats, and in my case, it adds weapons to a WAC helicopter that didn't originally have the weapons on, without having to re-spawn it. This is the newest version code:
[CODE]
function ENT:addStuff() end
function ENT:addWeapons()
self.weapons = {}
for i, w in pairs(self.Weapons) do
if i != "BaseClass" then
local pod = ents.Create(w.class)
pod:SetPos(self:GetPos())
pod:SetParent(self)
for index, value in pairs(w.info) do
pod[index] = value
end
pod.aircraft = self
pod:Spawn()
pod:Activate()
pod:SetNoDraw(true)
pod.podIndex = i
self.weapons[i] = pod
self:AddOnRemove(pod)
end
end
if self.Camera then
self.camera = ents.Create("prop_physics")
self.camera:SetModel("models/props_junk/popcan01a.mdl")
self.camera:SetNoDraw(true)
self.camera:SetPos(self:LocalToWorld(self.Camera.pos))
self.camera:SetParent(self)
self.camera:Spawn()
end
end
function ENT:addSeats()
self.seats = {}
local e = self:addEntity("wac_seat_connector")
e:SetPos(self:LocalToWorld(self.SeatSwitcherPos))
e:SetNoDraw(true)
e:Spawn()
e:Activate()
e.wac_ignore = true
e:SetNotSolid(true)
e:SetParent(self)
self:SetSwitcher(e)
for k, v in pairs(self.Seats) do
if k != "BaseClass" then
local ang = self:GetAngles()
self.seats[k] = self:addEntity("prop_vehicle_prisoner_pod")
self.seats[k].activeProfile = 1
self.seats[k]:SetModel("models/nova/airboat_seat.mdl")
self.seats[k]:SetPos(self:LocalToWorld(v.pos))
self.seats[k]:Spawn()
self.seats[k]:Activate()
self.seats[k]:SetNWInt("selectedWeapon", 0)
if v.ang then
local a = self:GetAngles()
a.y = a.y-90
a:RotateAroundAxis(Vector(0,0,1), v.ang.y)
self.seats[k]:SetAngles(a)
else
ang:RotateAroundAxis(self:GetUp(), -90)
self.seats[k]:SetAngles(ang)
end
self.seats[k]:SetNoDraw(true)
self.seats[k]:SetNotSolid(true)
self.seats[k]:SetParent(self)
self.seats[k].wac_ignore = true
self.seats[k]:SetNWEntity("wac_aircraft", self)
self.seats[k]:SetKeyValue("limitview","0")
self:SetNWInt("seat_"..k.."_actwep", 1)
e:addVehicle(self.seats[k])
end
end
end
function ENT:addWheels()
for _,t in pairs(self.Wheels) do
if t.mdl then
local e=self:addEntity("prop_physics")
e:SetModel(t.mdl)
e:SetPos(self:LocalToWorld(t.pos))
e:SetAngles(self:GetAngles())
e:Spawn()
e:Activate()
local ph=e:GetPhysicsObject()
if t.mass then
ph:SetMass(t.mass)
end
ph:EnableDrag(false)
constraint.Axis(e,self,0,0,Vector(0,0,0),self:WorldToLocal(e:LocalToWorld(Vector(0,1,0))),0,0,t.friction,1)
table.insert(self.wheels,e)
self:AddOnRemove(e)
end
end
end
function ENT:fireWeapon(bool, i)
if !self.Seats[i].weapons then return end
local pod = self.weapons[self.Seats[i].weapons[self.seats[i].activeProfile]]
if !pod then return end
pod.shouldFire = bool
pod:trigger(bool, self.seats[i])
end
function ENT:nextWeapon(i, p)
if !self.Seats[i].weapons then return end
local seat = self.seats[i]
local Seat = self.Seats[i]
local pod = self.weapons[Seat.weapons[seat.activeProfile]]
if pod then
pod:select(false)
pod.seat = nil
end
if seat.activeProfile == #Seat.weapons then
seat.activeProfile = 0
else
seat.activeProfile = seat.activeProfile + 1
end
if Seat.weapons[seat.activeProfile] then
local weapon = self.weapons[Seat.weapons[seat.activeProfile]]
weapon:select(true)
weapon.seat = seat
end
self:SetNWInt("seat_"..i.."_actwep", seat.activeProfile)
end
[/CODE]
And here's the old version:
[CODE]
function ENT:AddStuff() end
function ENT:AddSeats()
self.Seats={}
local e=self:addEntity("wac_v_connector")
e:SetPos(self:LocalToWorld(self.SeatSwitcherPos))
e:SetNoDraw(true)
e:Spawn()
e.wac_ignore = true
e:SetNotSolid(true)
e:SetParent(self)
self.SeatSwitcher=e
for k,v in pairs(self.SeatsT) do
local ang=self:GetAngles()
v.wep_act=1
v.wep_next=0
for i,t in pairs(v.wep) do
if type(t)=="table" then
if t.Init then t.Init(self,t) end
self:SetNWInt("seat_"..k.."_"..i.."_ammo",t.Ammo)
self:SetNWInt("seat_"..k.."_"..i.."_nextshot",1)
self:SetNWInt("seat_"..k.."_"..i.."_lastshot",0)
else
t=nil
end
end
self:SetNWInt("seat_"..k.."_actwep", 1)
self.Seats[k]=self:addEntity("prop_vehicle_prisoner_pod")
self.Seats[k]:SetModel("models/nova/airboat_seat.mdl")
self.Seats[k]:SetPos(self:LocalToWorld(v.Pos))
if v.Ang then
local a=self:GetAngles()
a.y=a.y-90
a:RotateAroundAxis(Vector(0,0,1),v.Ang.y)
self.Seats[k]:SetAngles(a)
else
ang:RotateAroundAxis(self:GetUp(),-90)
self.Seats[k]:SetAngles(ang)
end
self.Seats[k]:Spawn()
self.Seats[k]:SetNoDraw(true)
self.Seats[k].Helicopter = self
self.Seats[k].Phys = self.Seats[k]:GetPhysicsObject()
self.Seats[k].Phys:EnableGravity(true)
self.Seats[k].Phys:SetMass(1)
self.Seats[k]:SetNotSolid(true)
self.Seats[k]:SetParent(self)
self.Seats[k].wac_ignore = true
self.Seats[k]:SetNWEntity("wac_aircraft", self)
self.Seats[k]:SetKeyValue("limitview","0")
self.SeatSwitcher:AddVehicle(self.Seats[k])
self:AddOnRemove(self.Seats[k])
end
end
function ENT:AddWheels()
for _,t in pairs(self.WheelInfo) do
if t.mdl then
local e=self:addEntity("prop_physics")
e:SetModel(t.mdl)
e:SetPos(self:LocalToWorld(t.pos))
e:SetAngles(self:GetAngles())
e:Spawn()
e:Activate()
local ph=e:GetPhysicsObject()
if ph:IsValid() then
if t.mass then
ph:SetMass(t.mass)
end
ph:EnableDrag(false)
else
e:Remove()
end
constraint.Axis(e,self,0,0,Vector(0,0,0),self:WorldToLocal(e:LocalToWorld(Vector(0,1,0))),0,0,t.friction,1)
table.insert(self.Wheels,e)
self:AddOnRemove(e)
end
end
end
function ENT:NextWeapon(t,k,p)
if t.wep[t.wep_act].DeSelect then t.wep[t.wep_act].DeSelect(self, t.wep[t.wep_act], p) end
t.wep_act=(t.wep_act<#t.wep)and(t.wep_act+1)or(1)
t.wep_next=CurTime()+0.5
self:SetNWInt("seat_"..k.."_actwep", t.wep_act)
end
[/CODE]
I'm not asking for a fix, im just wondering if anyone could help me locate the new value/function for ".wep". I have tried contacting the creator of the addon, but no response. Please no hate, because i'm new. Thanks.
[editline]3rd December 2015[/editline]
I fixed the first part, but im still missing the other half. ".wep"
Sorry, you need to Log In to post a reply to this thread.