function recreatepilot(actor,self) local spawnpos = actor.Pos; local spawnteam = actor.Team; local spawnhp = actor.Health; local spawnAI = actor.AIMode local spawnname = actor.PresetName; local spawntype = actor.ClassName; local guy = nil if spawntype == "AHuman" then guy = CreateAHuman(spawnname); end if spawntype == "ACrab" then guy = CreateACrab(spawnname); end if spawntype == "actor" then guy = CreateActor(spawnname); end if spawntype == "ACDropShip" then guy = CreateACDropShip(spawnname); end if spawntype == "ACRocket" then guy = CreateACRocket(spawnname); end guy.Pos = spawnpos guy.Team = spawnteam guy.AIMode = spawnAI guy.Health = spawnhp if gmode[actor.ID] ~= 2 then --guy:AddInventoryItem(CreateTDExplosive("VDemo Thing")) if VDemoon ~= true then local part = CreateAEmitter("VDemo Man"); part.Pos = self.Pos MovableMan:AddMO(part); VDemolist = {} VDemotimelist = {} VDemoprimelist = {} end table.insert(VDemolist,guy) table.insert(VDemotimelist,Timer()) table.insert(VDemoprimelist,false) end --MovableMan:AddActor(guy) --ActivityMan:GetActivity():ReportDeath(spawnteam,-1); return guy end function Destroy(self) gmode[self.ID] = nil if ActivityMan:GetActivity():ActivityOver() == false then -- Not sure about second check, but should prevent game crash self.Pod = CreateACRocket("Drop Crate") local tempdude = recreatepilot(self.pilot,self) tempdude:AddInventoryItem(CreateTDExplosive("Manual Control Implant")) self.Pod:AddInventoryItem(tempdude) self.Pod.Pos.X = self.Pos.X + 20 self.Pod.Pos.Y = self.Pos.Y + 0 self.Pod.Team = self.Team MovableMan:AddActor(self.Pod) if self.brain ~= nil then self.brain.Lifetime = 1 end end if ActivityMan:GetActivity():ActivityOver() then glist = {} end end function Create(self) function lengthdir_x(dist,ang) return dist * math.cos(-ang); end function lengthdir_y(dist,ang) return dist * math.sin(-ang); end self.throttle = 25; self.shottimer = Timer(); self.droptimer = Timer(); hasbomb = 0; self.pilot = CreateACRocket("Drop Crate") self.brain = nil self.dtimer = Timer() self.timeron = false self.Pod = CreateACRocket("Drop Crate") self.tempdude = CreateACRocket("Drop Crate") if glist == nil then glist = {} end if gnew == nil then gnew = {} end if gmode == nil then gmode = {} end glist[self.ID] = self.pilot gmode[self.ID] = 1 gnew[self.ID] = false self.oldID = self.ID end function Update(self) if gnew[self.oldID] then self.pilot = glist[self.oldID] gnew[self.oldID] = false end if self.ID ~= self.oldID then glist[self.oldID] = nil gmode[self.oldID] = nil gnew[self.oldID] = nil self.oldID = self.ID glist[self.ID] = self.pilot gmode[self.ID] = 1 end self.pilot = glist[self.ID] if self.pilot:IsInGroup("Brains") then if self.brain == nil then self.brain = CreateActor("Brain Case") self.brain.GetsHitByMOs = false self.brain.HitsMOs = false self.brain.Scale = 0 self.brain.CharHeight = 100 self.brain.Team = self.Team MovableMan:AddActor(self.brain) globalbrain.Lifetime = 2 end self.brain.Pos = self.Pos if self.brain:IsPlayerControlled() then ActivityMan:GetActivity():SwitchToActor(self,self.brain:GetController().Player,self.Team) end elseif self.brain ~= nil then self.brain.Lifetime = 1 self.brain = nil end if self.pilot.PresetName == "Drop Crate" then self:GetController().InputMode = 3 if self.Health < 100 and math.random(32) == 1 then self.Health = self.Health * 1.1 if self.Health > 100 then self.Health = 100 end end self.Vel.Y = 1 self.Vel.X = 0 self.RotAngle = 0 self.AngularVel = 0 if self:GetAltitude(100,1) <= 25 then self.Vel.Y = 0 end for player = 0, ActivityMan:GetActivity().PlayerCount - 1 do if MovableMan:IsActor(ActivityMan:GetActivity():GetControlledActor(player)) then if ActivityMan:GetActivity():GetControlledActor(player).ID == self.ID then ActivityMan:GetActivity():SwitchToActor(ActivityMan:GetActivity():GetPlayerBrain(player),player,ActivityMan:GetActivity():GetTeamOfPlayer(player)); end end end else if self:GetController().InputMode == 3 then self:GetController().InputMode = 2 end self.Team = self.pilot.Team if godly then self.Health = 110 end if forcewarp then if self.Pos.X >= SceneMan.SceneDim.X and self.Vel.X > 0 then self.Pos.X = 0 end if self.Pos.X <= 0 and self.Vel.X < 1 then self.Pos.X = SceneMan.SceneDim.X end end if ceiling and self.Pos.Y < 10 and self.Vel.Y < 0 then self.Vel.Y = self.Vel.Y * -2 self.Pos.Y = 10 end if self:GetController():IsState(Controller.MOVE_UP) then if self.throttle <= 45 then self.throttle = self.throttle + 1; end end if self:GetController():IsState(Controller.MOVE_DOWN) then if self.throttle >= 15 then self.throttle = self.throttle - 1; end end if self:GetController():IsState(Controller.MOVE_LEFT) then self.RotAngle = self.RotAngle + 0.08; end if self:GetController():IsState(Controller.MOVE_RIGHT) then self.RotAngle = self.RotAngle - 0.08; end if self:GetController():IsState(Controller.PRIMARY_ACTION) then if self.shottimer:IsPastRealMS(50) == true then bullet = CreateAEmitter("Sound Effect 1"); if self.HFlipped == false then bullet.Pos.X = self.Pos.X - lengthdir_x(75,self.RotAngle + math.pi); bullet.Pos.Y = self.Pos.Y - lengthdir_y(75,self.RotAngle + math.pi); bullet.RotAngle = self.RotAngle; else bullet.Pos.X = self.Pos.X - lengthdir_x(75,self.RotAngle); bullet.Pos.Y = self.Pos.Y - lengthdir_y(75,self.RotAngle); bullet.RotAngle = self.RotAngle + math.pi; end MovableMan:AddParticle(bullet); self.shottimer:Reset(); end end --[[ bomb = CreateMOSRotating("Plane Bomb","Plane.rte"); bomb.HitsMOs = false; bomb.Pos.X = self.Pos.X - lengthdir_x(25,self.RotAngle + math.pi / 2); bomb.Pos.Y = self.Pos.Y - lengthdir_y(25,self.RotAngle + math.pi / 2); bomb.RotAngle = self.RotAngle; if hasbomb == 0 then MovableMan:AddParticle(bomb); hasbomb = 1; end ]]-- if self:GetController():IsMouseControlled() == true then if self:GetController():IsState(Controller.SECONDARY_ACTION) then if self.droptimer:IsPastRealMS(500) == true then bomb = CreateMOSRotating("Plane Bomb","Plane.rte"); bomb2 = CreateMOSRotating("Plane Bomb 2","Plane.rte"); if self.HFlipped == false then bomb.HitsMOs = false; bomb.Vel.X = lengthdir_x(self.throttle / 1.1,self.RotAngle); bomb.Vel.Y = lengthdir_y(self.throttle / 1.1,self.RotAngle); bomb.Pos.X = self.Pos.X - lengthdir_x(25,self.RotAngle + math.pi / 2); bomb.Pos.Y = self.Pos.Y - lengthdir_y(25,self.RotAngle + math.pi / 2); bomb.RotAngle = self.RotAngle; MovableMan:AddParticle(bomb); else bomb2.HitsMOs = false; bomb2.Vel.X = lengthdir_x(-self.throttle / 1.1,self.RotAngle); bomb2.Vel.Y = lengthdir_y(-self.throttle / 1.1,self.RotAngle); bomb2.Pos.X = self.Pos.X + lengthdir_x(25,self.RotAngle - math.pi / 2); bomb2.Pos.Y = self.Pos.Y - lengthdir_y(25,self.RotAngle + math.pi / 2); bomb2.RotAngle = self.RotAngle + math.pi; MovableMan:AddParticle(bomb2); end self.droptimer:Reset(); end end else if self:GetController():IsState(Controller.AIM_SHARP) then if self.droptimer:IsPastRealMS(500) == true then bomb = CreateMOSRotating("Plane Bomb","Plane.rte"); bomb2 = CreateMOSRotating("Plane Bomb 2","Plane.rte"); if self.HFlipped == false then bomb.HitsMOs = false; bomb.Vel.X = lengthdir_x(self.throttle / 1.1,self.RotAngle); bomb.Vel.Y = lengthdir_y(self.throttle / 1.1,self.RotAngle); bomb.Pos.X = self.Pos.X - lengthdir_x(25,self.RotAngle + math.pi / 2); bomb.Pos.Y = self.Pos.Y - lengthdir_y(25,self.RotAngle + math.pi / 2); bomb.RotAngle = self.RotAngle; MovableMan:AddParticle(bomb); else bomb2.HitsMOs = false; bomb2.Vel.X = lengthdir_x(-self.throttle / 1.1,self.RotAngle); bomb2.Vel.Y = lengthdir_y(-self.throttle / 1.1,self.RotAngle); bomb2.Pos.X = self.Pos.X + lengthdir_x(25,self.RotAngle - math.pi / 2); bomb2.Pos.Y = self.Pos.Y - lengthdir_y(25,self.RotAngle + math.pi / 2); bomb2.RotAngle = self.RotAngle + math.pi; MovableMan:AddParticle(bomb2); end self.droptimer:Reset(); end end end if self.RotAngle > 3.14 or self.RotAngle < -3.14 then self.RotAngle = 0; if self.HFlipped == false then self.HFlipped = true; else self.HFlipped = false; end end if self.Health < 0 and math.abs(self.Vel.Y) < 25 then self:GibThis() end if self.HFlipped == false then self.Vel.X = lengthdir_x(self.throttle,self.RotAngle); self.Vel.Y = lengthdir_y(self.throttle,self.RotAngle); else self.Vel.X = lengthdir_x(-self.throttle,self.RotAngle); self.Vel.Y = lengthdir_y(-self.throttle,self.RotAngle); end end swappause = false if (UInputMan:KeyHeld(26)) and (self:IsPlayerControlled()) then self.timeron = false self.dtimer:Reset() self.pilot.Pos.X = self.Pos.X + 20 self.pilot.Pos.Y = self.Pos.Y + 0 self.tempdude = recreatepilot(self.pilot,self) MovableMan:AddActor(self.tempdude) self.pilot = CreateACRocket("Drop Crate") end if self.Health < 1 then self:GibThis() end if self.pilot == nil then self.pilot = CreateACRocket("Drop Crate") end glist[self.ID] = self.pilot end