Data Realms Fan Forums http://45.55.195.193/ |
|
What is the longest lua script you've ever written for CC? http://45.55.195.193/viewtopic.php?f=4&t=23759 |
Page 1 of 1 |
Author: | Mehman [ Mon May 16, 2011 2:25 pm ] |
Post subject: | What is the longest lua script you've ever written for CC? |
Hi, as the title suggests I was wondering what is the longest script written for CC. Here is mine: Code: function Create(self) self.c = self:GetController(); self.AIMode = 1; self.setalt = 75; self.Grenade = 0; self.reload = 0; self.timer = Timer(); self.Shield = 100; --do not edit this -----------Variables you can edit:----------- self.healtime = 2000 --the actor will regenerate 1% of his health every self.healtime ms. self.ShieldPower = 7500; --this you can edit: a higher number will make the shield more powerful, a lower number less powerful self.ShieldRegen = 0.10; --the % of the shield that will be regenerated in 1 tick (60 ticks in a second if you haven't modified your DeltaTime) 1.25 <-> 1.25% / tick <-> 75% / sec. self.ShowRealShieldValue = false; --activating this will show you the real power of the shield instead of a %. --------------------------------------------- self.i = CreateTDExplosive("Null Device","Tank.rte"); self.i.Pos = self.AboveHUDPos + Vector(0,-8); self.i.Vel = self.Vel; MovableMan:AddMO(self.i); self.ammodisplay = CreateTDExplosive("Null Device","Tank.rte"); self.ammodisplay.Pos = self.AboveHUDPos + Vector(0,40); self.ammodisplay.Vel = self.Vel; MovableMan:AddMO(self.ammodisplay); self.altsensor1 = CreateTDExplosive("Null Device","Tank.rte"); self.altsensor1.Pos = self.Pos + Vector(25,0); self.altsensor1.Vel = self.Vel; MovableMan:AddMO(self.altsensor1); self.altsensor2 = CreateTDExplosive("Null Device","Tank.rte"); self.altsensor2.Pos = self.Pos + Vector(-25,0); self.altsensor2.Vel = self.Vel; MovableMan:AddMO(self.altsensor2); self.MG = CreateTDExplosive("MG Turret","Tank.rte"); self.MG.Pos = self.Pos + Vector(35,-35); self.MG.Vel = self.Vel; MovableMan:AddMO(self.MG); self.MGAim = 0.00; self.altsensor1:Activate(); self.altsensor2:Activate(); self.MG:Activate(); --keymapping local listkeys = {}; listkeys[0] = "Flamer"; listkeys[1] = "AmmoChange"; listkeys[2] = "Grenade"; listkeys[3] = "MG"; local f = require("io"); f.input("Tank.rte/Keys.ini"); local ok = -5; for line in f.lines() do if line == listkeys[0] then ok = 0; elseif line == listkeys[1] then ok = 1; elseif line == listkeys[2] then ok = 2; elseif line == listkeys[3] then ok = 3; elseif ok > -1 then if ok == 0 then self.FlamerKey = tonumber(line); elseif ok == 1 then self.AmmoChangeKey = tonumber(line); elseif ok == 2 then self.GrenadeKey = tonumber(line); elseif ok == 3 then self.MGKey = tonumber(line); end ok = -5; end end f.input():close(); --ammo listing self.PresetName = "0"; self.listammo = {}; self.listtype = {}; self.listvel = {}; local fi = require("io"); fi.input("Tank.rte/AmmoList.ini"); local ook = -5; self.o = 0; for line in fi.lines() do if line == "Ammo:" then ook = 0; elseif line == "AmmoType:" then ook = 1; elseif line == "MuzzleVelocity:" then ook = 2; self.o = self.o+1; elseif ook > -1 then if ook == 0 then self.listammo[self.o] = line; elseif ook == 1 then self.listtype[self.o] = line; elseif ook == 2 then self.listvel[self.o-1] = tonumber(line); end ook = -5; end end fi.input():close(); end function Destroy(self) if MovableMan:ValidMO(self.i) then ToTDExplosive(self.i).ToDelete = true; end if MovableMan:ValidMO(self.altsensor1) then ToTDExplosive(self.altsensor1).ToDelete = true; end if MovableMan:ValidMO(self.altsensor2) then ToTDExplosive(self.altsensor2).ToDelete = true; end end function Update(self) --propulsion, stabilisation self.alt = self:GetAltitude(0,1); if self.alt < self.setalt and self.Vel.Y > -10 then self.Vel.Y = self.Vel.Y - 0.5; end if self.Vel.Y < -4.5 then self.Vel.Y = self.Vel.Y + 1.5; elseif self.Vel.Y > 4.5 then self.Vel.Y = self.Vel.Y - 1.5; end self.AngularVel = 0.95 * self.AngularVel; if self.Vel.X < 8 and self.c:IsState(3) then self.Vel.X = self.Vel.X + 1; elseif self.Vel.X > -8 and self.c:IsState(4) then self.Vel.X = self.Vel.X - 1; end if self.setalt < 150 and self.c:IsState(5) then self.setalt = self.setalt + 0.75; elseif self.setalt > 25 and self.c:IsState(6) then self.setalt = self.setalt - 0.75; end if self.Health <= 0 then self:GibThis(); end --grenade launcher if self:IsPlayerControlled() == true and UInputMan:KeyPressed(self.GrenadeKey) and self.Grenade>0 then local Gre = CreateAEmitter("Incendiary Tank Grenade","Tank.rte"); if self.HFlipped then Gre.Pos = Vector(self.Pos.X+10,self.Pos.Y-45); else Gre.Pos = Vector(self.Pos.X-10,self.Pos.Y-45); end Gre.Vel = Vector(self.Vel.X,self.Vel.Y-15); MovableMan:AddMO(Gre); self.Grenade = self.Grenade - 1; local s = CreateAEmitter("Grenade Launch Sound","Tank.rte"); s.Pos = self.Pos; MovableMan:AddMO(s); end --terrain detection and automatic orientation if MovableMan:ValidMO(self.altsensor1) and MovableMan:ValidMO(self.altsensor2) then if self.altsensor1.PresetName ~= "Entity" and self.altsensor2.PresetName ~= "Entity" then self.alt1 = ToTDExplosive(self.altsensor1):GetAltitude(0,1); self.alt2 = ToTDExplosive(self.altsensor2):GetAltitude(0,1); if self.alt1 < self.alt2 and self.RotAngle < (math.pi/12) then local acc = (0.025*math.abs(self.alt1-self.alt2)); if acc > 1 then acc = 1; end self.AngularVel = self.AngularVel + acc; elseif self.alt2 < self.alt1 and self.RotAngle > -(math.pi/12) then local acc = (0.025*math.abs(self.alt1-self.alt2)); if acc > 1 then acc = 1; end self.AngularVel = self.AngularVel - acc; end self.altsensor1.Pos = self.Pos + Vector(math.cos(self.RotAngle)*35,-math.sin(self.RotAngle)*35); self.altsensor1.Vel = self.Vel; self.altsensor2.Pos = self.Pos + Vector(-math.cos(self.RotAngle)*35,math.sin(self.RotAngle)*35); self.altsensor2.Vel = self.Vel; end elseif self.Age > 250 then self.altsensor1 = CreateTDExplosive("Null Device","Tank.rte"); self.altsensor1.Pos = self.Pos + Vector(math.cos(self.RotAngle)*35,-math.sin(self.RotAngle)*35); self.altsensor1.Vel = self.Vel; MovableMan:AddMO(self.altsensor1); self.altsensor2 = CreateTDExplosive("Null Device","Tank.rte"); self.altsensor2.Pos = self.Pos + Vector(-math.cos(self.RotAngle)*35,math.sin(self.RotAngle)*35) self.altsensor2.Vel = self.Vel; MovableMan:AddMO(self.altsensor2); self.altsensor1:Activate(); self.altsensor2:Activate(); end --energy shield if self.timer:IsPastSimMS(self.healtime) and self.Health > 0 then if self.Health < 100 then self.Health = self.Health + 1; end if self.Grenade < 3 then self.Grenade = self.Grenade + 1; end self.timer:Reset(); end if self.Shield < 100 then self.Shield = self.Shield + self.ShieldRegen; end if self.Shield > 100 then self.Shield = 100; end local partvel; for particle in MovableMan.Particles do partvel = particle.Vel - self.Vel; if math.abs(partvel.Magnitude) > 20 then local dist = SceneMan:ShortestDistance(self.Pos, particle.Pos, true); local power = math.abs((0.5*particle.Mass*(partvel.Magnitude^2)*particle.Sharpness)/(self.ShieldPower)); if particle.ClassName == "AEmitter" then power = math.abs((0.5*particle.Mass*(partvel.Magnitude^2))/(0.075*self.ShieldPower)); end if dist.Magnitude < 125 and particle.Age > 50 and (math.abs(partvel.Magnitude)) > 30 and (self.Shield) > power and particle.PresetName ~= "Mehman Frag 4" and particle.PresetName ~= "AP Shell" and particle.PresetName ~= "Particle AT" then self.Shield = self.Shield - power; local Glow = CreateMOPixel("Little Shield Glow","Tank.rte"); Glow.Pos = particle.Pos; MovableMan:AddMO(Glow); if particle.ClassName == "AEmitter" then particle.Vel.X = - particle.Vel.X; particle.Vel.Y = - particle.Vel.Y; else particle.ToDelete = true; end end end end if MovableMan:ValidMO(self.i) then if self.i.PresetName ~= "Entity" then if self.ShowRealShieldValue == false then self.i.PresetName = math.ceil(self.Shield).."%"; else self.i.PresetName = math.ceil( (self.Shield/100)*self.ShieldPower )..""; end self.i.Pos = self.AboveHUDPos + Vector(0,-8); self.i.Vel = self.Vel; if self.Health <= 0 or self.Status == 4 then self.i:Activate(); end end elseif self.Age > 250 then self.i = CreateTDExplosive("Null Device","Tank.rte"); self.i.Pos = self.AboveHUDPos + Vector(0,-8); self.i.Vel = self.Vel; MovableMan:AddMO(self.i); self.i.PresetName = math.ceil(self.Shield).."%"; end --coaxial flamer if ( self:IsPlayerControlled() == true and UInputMan:KeyHeld(self.FlamerKey) ) then local rand = math.random(0,100); if rand > 10 then local fl = CreateAEmitter("Particle TankF","Tank.rte"); fl.Pos = Vector(self.Pos.X+math.cos(self:GetAimAngle(true))*38,-18+self.Pos.Y-math.sin(self:GetAimAngle(true))*35); fl.Vel = Vector(self.Vel.X+math.cos(self:GetAimAngle(true))*35,self.Vel.Y-math.sin(self:GetAimAngle(true))*35); MovableMan:AddMO(fl); else local fl = CreateAEmitter("Particle TankFT","Tank.rte"); fl.Pos = Vector(self.Pos.X+math.cos(self:GetAimAngle(true))*38,-18+self.Pos.Y-math.sin(self:GetAimAngle(true))*35); fl.Vel = Vector(self.Vel.X+math.cos(self:GetAimAngle(true))*35,self.Vel.Y-math.sin(self:GetAimAngle(true))*35); MovableMan:AddMO(fl); end end --ammo change if ( self:IsPlayerControlled() == true and UInputMan:KeyPressed(self.AmmoChangeKey) ) then if tonumber(self.PresetName) < self.o-1 then self.PresetName = tostring(tonumber(self.PresetName)+1); else self.PresetName = "0"; end end --MG if MovableMan:ValidMO(self.MG) then if self.MG.PresetName ~= "Entity" then if self.HFlipped then self.MG.Pos = self.Pos + Vector(math.cos(self.RotAngle-0.2521198)*-42.45,math.sin(self.RotAngle-0.2521198)*42.45); self.MG.HFlipped = false; else self.MG.Pos = self.Pos + Vector(math.cos(self.RotAngle+0.2521198)*42.45,-math.sin(self.RotAngle+0.2521198)*42.45); self.MG.HFlipped = true; end local MGAngle = (self.MG.RotAngle % (2*math.pi)) - math.pi; if self.HFlipped then if MGAngle < -self.MGAim then self.MG.AngularVel = 1.5; elseif MGAngle > -self.MGAim then self.MG.AngularVel = -1.5; end else if MGAngle < self.MGAim then self.MG.AngularVel = 1.5; elseif MGAngle > self.MGAim then self.MG.AngularVel = -1.5; end end self.MG.Vel = self.Vel; if self:IsPlayerControlled() == true and UInputMan:MouseWheelMoved() == -1 then if self.MGAim > -0.75 then self.MGAim = self.MGAim - 0.05; end elseif self:IsPlayerControlled() == true and UInputMan:MouseWheelMoved() == 1 then if self.MGAim < 0.75 then self.MGAim = self.MGAim + 0.05; end end if ( self:IsPlayerControlled() == true and UInputMan:KeyHeld(self.MGKey) and self.reload >= 6 ) then local rand = math.random(0,100); if rand < 75 then local bullet = CreateAEmitter("Particle Tank MG","Tank.rte"); if self.HFlipped then bullet.Pos = self.MG.Pos + Vector(math.cos(self.MG.RotAngle)*16,math.sin(self.MG.RotAngle)*-16); bullet.Vel = Vector(math.cos(self.MG.RotAngle)*16,math.sin(self.MG.RotAngle)*-16); else bullet.Pos = self.MG.Pos + Vector(math.cos(self.MG.RotAngle)*-16,math.sin(self.MG.RotAngle)*16); bullet.Vel = Vector(math.cos(self.MG.RotAngle)*-16,math.sin(self.MG.RotAngle)*16); end MovableMan:AddMO(bullet); else local bullet = CreateAEmitter("Particle Tank MGT","Tank.rte"); if self.HFlipped then bullet.Pos = self.MG.Pos + Vector(math.cos(self.MG.RotAngle)*16,math.sin(self.MG.RotAngle)*-16); bullet.Vel = Vector(math.cos(self.MG.RotAngle)*16,math.sin(self.MG.RotAngle)*-16); else bullet.Pos = self.MG.Pos + Vector(math.cos(self.MG.RotAngle)*-16,math.sin(self.MG.RotAngle)*16); bullet.Vel = Vector(math.cos(self.MG.RotAngle)*-16,math.sin(self.MG.RotAngle)*16); end MovableMan:AddMO(bullet); end self.reload = 0; end end elseif self.Age > 250 then self.MG = CreateTDExplosive("MG Turret","Tank.rte"); if self.HFlipped then self.MG.Pos = self.Pos + Vector(math.cos(self.RotAngle+0.2421198)*-42.45,math.sin(self.RotAngle+0.2421198)*42.45); else self.MG.Pos = self.Pos + Vector(math.cos(self.RotAngle+0.2421198)*42.45,-math.sin(self.RotAngle+0.2421198)*42.45); end self.MG.Vel = self.Vel; MovableMan:AddMO(self.MG); self.MG:Activate(); end if self.reload <6 then self.reload = self.reload + 1; end --Ammo Display if MovableMan:ValidMO(self.ammodisplay) then if self.ammodisplay.PresetName ~= "Entity" then self.ammodisplay.PresetName = self.listammo[tonumber(self.PresetName)]; self.ammodisplay.Pos = self.AboveHUDPos + Vector(0,40); self.ammodisplay.Vel = self.Vel; if self.Health <= 0 or self.Status == 4 then self.ammodisplay:Activate(); end end elseif self.Age > 250 then self.ammodisplay = CreateTDExplosive("Null Device","Tank.rte"); self.ammodisplay.Pos = self.AboveHUDPos + Vector(0,40); self.ammodisplay.Vel = self.Vel; MovableMan:AddMO(self.ammodisplay); self.ammodisplay.PresetName = self.listammo[tonumber(self.PresetName)]; end end 489 lines It is the code of a hovering tank equipped with a cannon with multiple types of ammo(the major part of this system is in another script), a coaxial flamethrower, a defensive grenade launcher, an MG turret and an energy shield. Please use the spoiler tag for obvious reasons and briefly explain what the code does. |
Author: | Xery [ Mon May 16, 2011 8:31 pm ] |
Post subject: | Re: What is the longest lua script you've ever written for CC? |
The main script of "The FBM CB 4200"(LastBanana) viewtopic.php?f=61&t=17138 --Include the keybindings.
dofile("Computer.rte/Bindings.lua"); function point_distance_vec(pointA,pointB) --Returns the distance from Vector A to Vector B. return math.sqrt((pointA.X - pointB.X) ^ 2 + (pointA.Y - pointB.Y) ^ 2); end function point_direction_vec(pointA,pointB) --Returns the direction from Vector A to Vector B. return math.atan2(pointA.Y - pointB.Y,pointA.X - pointB.X); end function find_closest_obj(maxDist,position) --Find the closest thing. local curDist = maxDist; local curObj = nil; for actor in MovableMan.Actors do local dist = point_distance_vec(actor.Pos,position); if dist < curDist and dist < actor.Radius and actor.PresetName ~= "Cursor Representor" then curObj = actor; curDist = dist; end end for item in MovableMan.Items do local dist = point_distance_vec(item.Pos,position); if dist < curDist and dist < item.Radius then curObj = item; curDist = dist; end end for particle in MovableMan.Particles do local dist = point_distance_vec(particle.Pos,position); if dist < curDist and dist < particle.Radius and particle.ClassName ~= "MOPixel" then curObj = particle; curDist = dist; end end for i=1,MovableMan:GetMOIDCount()-1 do local mo = MovableMan:GetMOFromID(i); local dist = point_distance_vec(mo.Pos,position); if dist < curDist and dist < mo.Radius and mo.ClassName ~= "MOPixel" and mo.PresetName ~= "Cursor Representor" then curObj = MovableMan:GetMOFromID(mo.RootID); curDist = dist; end end return curObj; end function find_closest_actor(maxDist,position) --Find the closest thing. local curDist = maxDist; local curObj = nil; for actor in MovableMan.Actors do local dist = point_distance_vec(actor.Pos,position); if dist < curDist and dist < actor.Radius and actor.PresetName ~= "Cursor Representor" then curObj = actor; curDist = dist; end end for i=1,MovableMan:GetMOIDCount()-1 do local mo = MovableMan:GetMOFromID(i); local dist = point_distance_vec(mo.Pos,position); if dist < curDist and dist < mo.Radius and mo.ClassName ~= "MOPixel" and mo.PresetName ~= "Cursor Representor" then local root = MovableMan:GetMOFromID(mo.RootID); if root:IsActor() then curObj = ToActor(MovableMan:GetMOFromID(mo.RootID)); curDist = dist; end end end return curObj; end function find_closest_nbrain_actor(maxDist,position) --Find the closest thing. local curDist = maxDist; local curObj = nil; for actor in MovableMan.Actors do local dist = point_distance_vec(actor.Pos,position); if dist < curDist and dist < actor.Radius and actor.PresetName ~= "Cursor Representor" and actor:IsInGroup("Brains") == false then curObj = actor; curDist = dist; end end for i=1,MovableMan:GetMOIDCount()-1 do local mo = MovableMan:GetMOFromID(i); local dist = point_distance_vec(mo.Pos,position); if dist < curDist and dist < mo.Radius and mo.ClassName ~= "MOPixel" and mo.PresetName ~= "Cursor Representor" then local root = MovableMan:GetMOFromID(mo.RootID); if root:IsActor() and root:IsInGroup("Brains") == false then curObj = ToActor(MovableMan:GetMOFromID(mo.RootID)); curDist = dist; end end end return curObj; end function find_closest_mo(maxDist,position) --Find the closest MO. local curDist = maxDist; local curObj = nil; for i=1,MovableMan:GetMOIDCount()-1 do local mo = MovableMan:GetMOFromID(i); local dist = point_distance_vec(mo.Pos,position); if dist < curDist and dist < mo.Radius and mo.ClassName ~= "MOPixel" and mo.PresetName ~= "Cursor Representor" then curObj = MovableMan:GetMOFromID(i); curDist = dist; end end return curObj; end function find_closest_mosr(maxDist,position) --Find the closest MO. local curDist = maxDist; local curObj = nil; for i=1,MovableMan:GetMOIDCount()-1 do local mo = MovableMan:GetMOFromID(i); local dist = point_distance_vec(mo.Pos,position); if dist < curDist and dist < mo.Radius and mo.ClassName ~= "MOPixel" and mo.ClassName ~= "MOSParticle" and mo.PresetName ~= "Cursor Representor" then curObj = ToMOSRotating(MovableMan:GetMOFromID(i)); curDist = dist; end end return curObj; end --The following function shamelessly stolen and adapted from: http://snipplr.com/view/22482/bresenham ... algorithm/ function line_pixels_table(posA,posB,pixTable) local x2,y2; x2 = posB.X; y2 = posB.Y; if posA ~= posB then local x,y,dx,dy,sx,sy; x = posA.X; y = posA.Y; local steep = false; local d = SceneMan:ShortestDistance(posA,posB,true); dx = math.abs(d.X); if d.X > 0 then sx = 1; else sx = -1; end dy = math.abs(d.Y); if d.Y > 0 then sy = 1; else sy = -1; end if dy > dx then steep = true; local temp = x; x = y; y = temp; temp = dx; dx = dy; dy = temp; temp = sx; sx = sy; sy = temp; end d = (2 * dy) - dx; for i=0,dx do if steep then pixTable[x * SceneMan.SceneWidth + y] = Vector(y,x); else pixTable[y * SceneMan.SceneWidth + x] = Vector(x,y); end while d >= 0 do y = y + sy; d = d - (2 * dx); end x = x + sx; d = d + (2 * dy); end end pixTable[y2 * SceneMan.SceneWidth + x2] = Vector(x2,y2); end --This function draws a line out of the given MOPixel. Uses the same base function as the last. function draw_line_mopix(posA,posB,MOPName) local x2,y2; x2 = posB.X; y2 = posB.Y; if posA ~= posB then local x,y,dx,dy,sx,sy; x = posA.X; y = posA.Y; local steep = false; local d = SceneMan:ShortestDistance(posA,posB,true); dx = math.abs(d.X); if d.X > 0 then sx = 1; else sx = -1; end dy = math.abs(d.Y); if d.Y > 0 then sy = 1; else sy = -1; end if dy > dx then steep = true; local temp = x; x = y; y = temp; temp = dx; dx = dy; dy = temp; temp = sx; sx = sy; sy = temp; end d = (2 * dy) - dx; for i=0,dx do local seg = CreateMOPixel(MOPName); if steep then seg.Pos = Vector(y,x); else seg.Pos = Vector(x,y) end MovableMan:AddParticle(seg); while d >= 0 do y = y + sy; d = d - (2 * dx); end x = x + sx; d = d + (2 * dy); end end local endSeg = CreateMOPixel(MOPName); endSeg.Pos = Vector(x2,y2); MovableMan:AddParticle(endSeg); end function Create(self) --The object to switch to for viewing purposes. self.rep = nil; --Where the cursor is. self.cursorPos = self.Pos; --Which tool is in use. self.curTool = 1; --List of cursors. self.cursors = { "Selector", "Physics Grabber", "Lasso", "Finger of Death", "Bomber", "Exploder", "Burster", "Delete", "Freezer", "Invincibility", "Pencil", "Eraser", "Turret", "Reticle" }; --The cursor offsets to accomodate for the sprites. self.cursorOffset = { Vector(7,10), Vector(13,13), Vector(11,10), Vector(11,11), Vector(11,10), Vector(13,13), Vector(11,11), Vector(10,10), Vector(10,10), Vector(10,10), Vector(8,8), Vector(8,6), Vector(7,8), Vector(0,0) }; --The currently grabbed item. self.grabbedObj = nil; --Whether the object used to hit MOs. self.objHitMOs = false; --Whether the object used to get hit by MOs. self.objGotHitByMOs = false; --The PinStrength of the object before grabbing. self.objOldPin = 0; --The list of objects to grow and burst. self.burstList = {}; --Rate to grow bursting objects in scale increase per frame. self.growRate = 0.02; --Scale at which to explode the object. self.burstSize = 1.5; --The list of actors to freeze. self.freezeList = {}; --The list of invincible actors. self.invincibleList = {}; --The table of pixels to place. self.pixTable = {}; --The table of pixels to erase. self.eraseTable = {}; --The size of the square eraser. self.eraserSize = 8; --Where drawing started. self.startDraw = nil; --Max pixels drawn per frame for optimization reasons. Shared between erasing and drawing. self.pixCutoff = 100; --The amount of pixel movement per frame on the keyboard implementation. self.keyMovementSpeed = 5; --How much to divide the keyboard movement speed by in accurate mode. self.accurateMod = 3; --How much to multiply the keyboard movement speed by in speed mode. self.speedMod = 3; --How long the lasso rope is. self.ropeLength = 50; --The amount of lasso rope friction. self.ropeFriction = 1.02; --List of weapons turned into turrets. self.turretList = {}; --Minimum that a turret can search for enemies. self.turretRange = 500; --Timer to release trigger on turrets momentarily. self.testTimer = Timer(); --How often to do so. self.testTime = 2500; --Play the startup sound. local sound = CreateAEmitter("Computer.rte/Startup"); sound.Pos = self.Pos; MovableMan:AddParticle(sound); --Start the running sound. self.soundEmitter = CreateAEmitter("Computer.rte/Running"); self.soundEmitter:EnableEmission(true); self.soundEmitter.Pos = self.Pos; MovableMan:AddParticle(self.soundEmitter); --The startup animation timer. self.startupTimer = Timer(); --How long it takes to start up (milliseconds). self.startup = 4500; end function Update(self) self:ReloadScripts(); --Check if hotkey mode is enabled. local hotKeyHeld = UInputMan:KeyHeld(hotKeyMain); --Check for hotkey presses. if hotKeyHeld then for k,v in pairs(hotKeys) do if UInputMan:KeyHeld(v) then self.curTool = k; end end end --Change the frame according to circumstances. if self.Health <= 0 then --BSOD. self.Frame = 8; elseif self.startupTimer:IsPastSimMS(self.startup) then --Get whether any primary button was pressed, held or released. local pressed = false; local held = false; local released = false; if hotKeyHeld == false then pressed = (UInputMan:MouseButtonPressed(0) or UInputMan:KeyPressed(8)); held = (UInputMan:MouseButtonHeld(0) or UInputMan:KeyHeld(8)); released = (UInputMan:MouseButtonReleased(0) or UInputMan:KeyReleased(8)); end --Windows screen. self.Frame = 7; --If this has been switched to... if self:IsPlayerControlled() then --Make sure the representor exists. if MovableMan:IsActor(self.rep) == false then self.rep = CreateActor("Computer.rte/Cursor Representor"); self.rep.Pos = self.Pos; self.rep.Team = -1; MovableMan:AddActor(self.rep); end --Switch to it. ActivityMan:GetActivity():SwitchToActor(self.rep,self:GetController().Player,-1); elseif MovableMan:IsActor(self.rep) then if self.rep:IsPlayerControlled() then --Get the mouse movement. local mouseMovement = UInputMan:GetMouseMovement(3); local keylr = 0; local keyud = 0; local modifier = 1; --If the hotkey is held down, check for hotkey presses instead of usual movement. if hotKeyHeld == false then --Get movement for keyboard controls. if UInputMan:KeyHeld(fbnLeft) then keylr = -1; elseif UInputMan:KeyHeld(fbnRight) then keylr = 1; end if UInputMan:KeyHeld(fbnUp) then keyud = -1; elseif UInputMan:KeyHeld(fbnDown) then keyud = 1; end if UInputMan:KeyHeld(fbnSlow) then modifier = 1/self.accurateMod; end if UInputMan:KeyHeld(fbnSpeed) then modifier = self.speedMod; end end local keyMovement = Vector(keylr * self.keyMovementSpeed * modifier,keyud * self.keyMovementSpeed * modifier); --Add it all up to get the new cursor position. local desiredPos = self.cursorPos + mouseMovement + keyMovement; --Keep the mouse in the screen. UInputMan:SetMousePos(Vector(FrameMan.ResX/2,FrameMan.ResY/2),3); --Wrap around. local wrapped = false; if desiredPos.X > SceneMan.SceneWidth then if SceneMan.SceneWrapsX then desiredPos.X = desiredPos.X % SceneMan.SceneWidth; wrapped = true; else desiredPos.X = SceneMan.SceneWidth; end end if desiredPos.X < 0 then if SceneMan.SceneWrapsX then desiredPos.X = desiredPos.X + SceneMan.SceneWidth; wrapped = true; else desiredPos.X = 0; end end if desiredPos.Y > SceneMan.SceneHeight then if SceneMan.SceneWrapsY then desiredPos.Y = desiredPos.Y % SceneMan.SceneHeight; wrapped = true; else desiredPos.Y = SceneMan.SceneHeight; end end if desiredPos.Y < 0 then if SceneMan.SceneWrapsY then desiredPos.Y = desiredPos.Y + SceneMan.SceneHeight; wrapped = true; else desiredPos.Y = 0; end end --Set the cursor's position. self.cursorPos = desiredPos; --If the Selector tool is in use... if self.curTool == 1 then --On press... if pressed then --Find an object. local curObj = find_closest_obj(99999,self.cursorPos); --Grab the object if one was found. if MovableMan:ValidMO(curObj) then self.grabbedObj = curObj; self.objHitMOs = self.grabbedObj.HitsMOs; self.objGotHitByMOs = self.grabbedObj.GetsHitByMOs; self.objOldPin = self.grabbedObj.PinStrength; self.grabbedObj.HitsMOs = false; self.grabbedObj.GetsHitByMOs = false; self.grabbedObj.PinStrength = 10000; end end --When the button is released, release the object. if released and MovableMan:ValidMO(self.grabbedObj) then self.grabbedObj.HitsMOs = self.objHitMOs; self.grabbedObj.GetsHitByMOs = self.objGotHitByMOs; self.grabbedObj.PinStrength = self.objOldPin; self.grabbedObj = nil; end --If an object has been grabbed... if MovableMan:ValidMO(self.grabbedObj) then --Make sure the object wouldn't get stuck in terrain. local inTerrain = false; local checkRadius = self.grabbedObj.Radius; if SceneMan:CastStrengthRay(self.cursorPos,Vector(checkRadius,0),0,Vector(),5,0,true) then inTerrain = true; end if SceneMan:CastStrengthRay(self.cursorPos,Vector(0,checkRadius),0,Vector(),5,0,true) then inTerrain = true; end if SceneMan:CastStrengthRay(self.cursorPos,Vector(-checkRadius,0),0,Vector(),5,0,true) then inTerrain = true; end if SceneMan:CastStrengthRay(self.cursorPos,Vector(0,-checkRadius),0,Vector(),5,0,true) then inTerrain = true; end if not inTerrain then --Move it. self.grabbedObj.Pos = self.cursorPos; end --Disable its movement. self.grabbedObj.Vel = Vector(0,0); self.grabbedObj.AngularVel = 0; end elseif self.curTool == 2 then --If the Physics Grabber tool is in use... --On press... if pressed then --Find an object. local curObj = find_closest_obj(99999,self.cursorPos); --Grab the object if one was found. if MovableMan:ValidMO(curObj) then self.grabbedObj = curObj; self.grabbedObj.PinStrength = 0; end end --When the button is released, release the object. if released and MovableMan:ValidMO(self.grabbedObj) then self.grabbedObj = nil; end --If an object has been grabbed... if MovableMan:ValidMO(self.grabbedObj) then --Negate gravity. self.grabbedObj.Vel.Y = self.grabbedObj.Vel.Y - SceneMan.GlobalAcc.Y * TimerMan.DeltaTimeSecs; --Make the object fly toward the cursor position. self.grabbedObj.Vel = SceneMan:ShortestDistance(self.grabbedObj.Pos,self.cursorPos,true); --Keep the velocity in realistic bounds. if self.grabbedObj.Vel.X > 500 then self.grabbedObj.Vel.X = 500 end if self.grabbedObj.Vel.X < -500 then self.grabbedObj.Vel.X = -500 end if self.grabbedObj.Vel.Y > 500 then self.grabbedObj.Vel.Y = 500 end if self.grabbedObj.Vel.Y < -500 then self.grabbedObj.Vel.Y = -500 end end elseif self.curTool == 3 then --If the Lasso tool is in use... --On press... if pressed then --Find an object. local curObj = find_closest_obj(99999,self.cursorPos); --Grab the object if one was found. if MovableMan:ValidMO(curObj) then self.grabbedObj = curObj; self.grabbedObj.PinStrength = 0; end end --When the button is released, release the object. if released and MovableMan:ValidMO(self.grabbedObj) then self.grabbedObj = nil; end --If an object has been grabbed... if MovableMan:ValidMO(self.grabbedObj) then --Draw the rope. draw_line_mopix(self.cursorPos,self.grabbedObj.Pos,"Computer.rte/Rope Segment"); --If the object is outside of the rope's bounds... local dist = point_distance_vec(self.grabbedObj.Pos,self.cursorPos); if dist > self.ropeLength then --Make the object fly toward the cursor position. local mult = self.grabbedObj.Vel.Magnitude; if mult < 1 then mult = 1; end self.grabbedObj.Vel = self.grabbedObj.Vel + (SceneMan:ShortestDistance(self.grabbedObj.Pos,self.cursorPos,true) * mult) / 150; --Create friction. if self.grabbedObj.Vel.Magnitude > 1 then self.grabbedObj.Vel = self.grabbedObj.Vel / self.ropeFriction; end end --Keep the velocity in realistic bounds. if self.grabbedObj.Vel.X > 500 then self.grabbedObj.Vel.X = 500 end if self.grabbedObj.Vel.X < -500 then self.grabbedObj.Vel.X = -500 end if self.grabbedObj.Vel.Y > 500 then self.grabbedObj.Vel.Y = 500 end if self.grabbedObj.Vel.Y < -500 then self.grabbedObj.Vel.Y = -500 end end elseif self.curTool == 4 then --If the Finger of Death tool is in use... --On press... if pressed then --Find an object. local clickedActor = find_closest_actor(99999,self.cursorPos); --Kill the actor if one was found. if MovableMan:ValidMO(clickedActor) then clickedActor.Health = 0; end end elseif self.curTool == 5 then --If the Bomber tool is in use... --On press... if pressed then --Create the bomb. local bomb = CreateTDExplosive("Ronin.rte/Stick Grenade"); --Put it in position. bomb.Pos = self.cursorPos; --Create it. MovableMan:AddParticle(bomb); --Explode it. bomb:GibThis(); end elseif self.curTool == 6 then --If the Exploder tool is in use... --On press... if pressed then --Find an object. local clickedObj = find_closest_obj(99999,self.cursorPos); --Explode the object if one was found. if MovableMan:ValidMO(clickedObj) then for i=1,MovableMan:GetMOIDCount()-1 do local mo = MovableMan:GetMOFromID(i); if mo.RootID == clickedObj.ID and mo.ClassName ~= "MOPixel" and mo.ClassName ~= "MOSParticle" then ToMOSRotating(mo):GibThis(); end end end end elseif self.curTool == 7 then --If the Burster tool is in use... --On press... if pressed then --Find an object. local clickedMO = find_closest_mosr(99999,self.cursorPos); --Burst the object if one was found. if clickedMO ~= nil then table.insert(self.burstList,clickedMO); end end elseif self.curTool == 8 then --If the Delete tool is in use... --On press... if pressed then --Find an object. local clickedMO = find_closest_mo(99999,self.cursorPos); --Delete the object if one was found. if clickedMO ~= nil then clickedMO.ToDelete = true; end end elseif self.curTool == 9 then --If the Freezer tool is in use... --On press... if pressed then --Find an object. local clickedMO = find_closest_mo(99999,self.cursorPos); --If one was found... if clickedMO ~= nil then --Check if the object is an actor. local mo = MovableMan:GetMOFromID(clickedMO.RootID); if mo:IsActor() then --If it is, kill it. ToActor(mo).Health = 0; end --Freeze all of its parts. for i=1,MovableMan:GetMOIDCount()-1 do local mo = MovableMan:GetMOFromID(i); if mo.RootID == clickedMO.RootID then table.insert(self.freezeList,mo); end end end end elseif self.curTool == 10 then --If the Invincibility tool is in use... --On press... if pressed then --Find an object. local clickedActor = find_closest_actor(99999,self.cursorPos); --Add it to the list of invincible actors. if MovableMan:IsActor(clickedActor) then table.insert(self.invincibleList,clickedActor); end end elseif self.curTool == 11 then --If the Pencil tool is in use... --When the button is held... if held then --Draw the line. We draw multiple lines so there is thickness. if self.startDraw ~= nil then line_pixels_table(self.startDraw,self.cursorPos,self.pixTable); line_pixels_table(self.startDraw + Vector(1,0),self.cursorPos + Vector(1,0),self.pixTable); line_pixels_table(self.startDraw + Vector(-1,0),self.cursorPos + Vector(-1,0),self.pixTable); line_pixels_table(self.startDraw + Vector(0,1),self.cursorPos + Vector(0,1),self.pixTable); line_pixels_table(self.startDraw + Vector(0,-1),self.cursorPos + Vector(0,-1),self.pixTable); line_pixels_table(self.startDraw + Vector(1,1),self.cursorPos + Vector(1,1),self.pixTable); line_pixels_table(self.startDraw + Vector(-1,1),self.cursorPos + Vector(-1,1),self.pixTable); line_pixels_table(self.startDraw + Vector(1,-1),self.cursorPos + Vector(1,-1),self.pixTable); line_pixels_table(self.startDraw + Vector(-1,-1),self.cursorPos + Vector(-1,-1),self.pixTable); end --Store this position. self.startDraw = Vector(self.cursorPos.X,self.cursorPos.Y); else --Reset the drawing. self.startDraw = nil; end elseif self.curTool == 12 then --If the Eraser tool is in use... --When the button is held... if held then --Draw the line. This is done in a large square as it is more efficient than a circle but must be larger for the eraser. if self.startDraw ~= nil then for x = -self.eraserSize / 2,self.eraserSize / 2 do for y = -self.eraserSize / 2,self.eraserSize / 2 do line_pixels_table(self.startDraw + Vector(x,y),self.cursorPos + Vector(x,y),self.eraseTable); end end end --Store this position. self.startDraw = Vector(self.cursorPos.X,self.cursorPos.Y); else --Reset the drawing. self.startDraw = nil; end elseif self.curTool == 13 then --If the Turret tool is in use... --On press... if pressed then --Find an object. local curObj = find_closest_obj(99999,self.cursorPos); --Grab the object if one was found. if MovableMan:ValidMO(curObj) then local isTurret = false; for k,v in pairs(self.turretList) do if v.ID == curObj.ID then isTurret = true; curObj.PinStrength = 0; ToHeldDevice(curObj):Deactivate(); table.remove(self.turretList,k) end end if curObj:IsHeldDevice() and isTurret == false then self.grabbedObj = curObj; self.objHitMOs = self.grabbedObj.HitsMOs; self.objGotHitByMOs = self.grabbedObj.GetsHitByMOs; self.grabbedObj.HitsMOs = false; self.grabbedObj.GetsHitByMOs = false; self.grabbedObj.PinStrength = 10000; end end end --When the button is released, release the object. if released and MovableMan:ValidMO(self.grabbedObj) then self.grabbedObj.HitsMOs = self.objHitMOs; self.grabbedObj.GetsHitByMOs = self.objGotHitByMOs; --Add it to the turret list. table.insert(self.turretList,ToHeldDevice(self.grabbedObj)); self.grabbedObj = nil; end --If an object has been grabbed... if MovableMan:ValidMO(self.grabbedObj) then --Make sure the object wouldn't get stuck in terrain. local inTerrain = false; local checkRadius = self.grabbedObj.Radius; if SceneMan:CastStrengthRay(self.cursorPos,Vector(checkRadius,0),0,Vector(),5,0,true) then inTerrain = true; end if SceneMan:CastStrengthRay(self.cursorPos,Vector(0,checkRadius),0,Vector(),5,0,true) then inTerrain = true; end if SceneMan:CastStrengthRay(self.cursorPos,Vector(-checkRadius,0),0,Vector(),5,0,true) then inTerrain = true; end if SceneMan:CastStrengthRay(self.cursorPos,Vector(0,-checkRadius),0,Vector(),5,0,true) then inTerrain = true; end if not inTerrain then --Move it. self.grabbedObj.Pos = self.cursorPos; end --Disable its movement. self.grabbedObj.Vel = Vector(0,0); self.grabbedObj.AngularVel = 0; end end --Scroll. self.rep.Pos = self.cursorPos; --Draw the cursor. local cursor = CreateMOPixel("Computer.rte/" .. self.cursors[self.curTool]); cursor.Pos = self.cursorPos + self.cursorOffset[self.curTool]; MovableMan:AddParticle(cursor); --Go through tool types with mouse wheel as long as nothing is being held. if not held then --Check if any scrolling is happening. local scrolling = UInputMan:MouseWheelMoved(); if UInputMan:KeyPressed(fbnScrollUp) then scrolling = 1; elseif UInputMan:KeyPressed(fbnScrollDown) then scrolling = -1; end self.curTool = self.curTool + scrolling; if self.curTool > #self.cursors then self.curTool = 1; elseif self.curTool < 1 then self.curTool = #self.cursors; end end --Don't let the cursor representor die. self.rep.Health = 100; self.rep.ToDelete = false; else --Reset the cursor. self.rep.ToDelete = true; self.cursorPos = self.Pos; end end --Burst objects. for k,v in pairs(self.burstList) do --If it no longer exists, stop trying to access it. if v.PresetName == "" or v.ToDelete == true then table.remove(self.burstList,k); else --Grow it. v.Scale = v.Scale + self.growRate; if v.Scale > self.burstSize then --If it's big enough to do so, burst it. v:GibThis(); table.remove(self.burstList,k); end end end --Freeze objects. for k,v in pairs(self.freezeList) do --If it no longer exists, stop trying to access it. if v.PresetName == "" or v.ToDelete == true then table.remove(self.freezeList,k); else --Freeze it. v.ToSettle = true; v.Vel = Vector(); v.AngularVel = 0; end end --Invincibility...fy actors. for k,v in pairs(self.invincibleList) do --If it no longer exists, stop trying to access it. if MovableMan:IsActor(v) == false then table.remove(self.invincibleList,k); else --Set its health to 100. v.Health = 100; --Make it glow. v:FlashWhite(1); end end --Turret code. for k,v in pairs(self.turretList) do --If it no longer exists, stop trying to access it. if MovableMan:IsDevice(v) == false then table.remove(self.turretList,k); else --Get the range. local range = self.turretRange; if v.SharpLength > self.turretRange then range = v.SharpLength; end --If the Reticle cursor is selected and in range... if self.curTool == 14 and point_distance_vec(v.Pos,self.cursorPos) < range then --Aim for it. if self.cursorPos.X < v.Pos.X then v.HFlipped = true; v.RotAngle = -point_direction_vec(v.Pos,self.cursorPos); else v.HFlipped = false; v.RotAngle = math.pi - point_direction_vec(v.Pos,self.cursorPos); end --Fire. if held then v:Activate(); else v:Deactivate(); end else --Search for enemies. local target = nil; for actor in MovableMan.Actors do if actor.Team ~= self.Team and point_distance_vec(v.Pos,actor.Pos) < range then --Check if the actor can be seen. local foundMOID = SceneMan:CastMORay(v.Pos,SceneMan:ShortestDistance(v.Pos,actor.EyePos,true),v.ID,0,false,5); if foundMOID ~= 0 and foundMOID ~= 255 then if MovableMan:GetMOFromID(foundMOID).RootID == actor.ID then --A target was found. Stop searching. target = actor; break; end end end end --If a target was located... if target then --Aim for it. if target.Pos.X < v.Pos.X then v.HFlipped = true; v.RotAngle = -point_direction_vec(v.Pos,target.EyePos); else v.HFlipped = false; v.RotAngle = math.pi - point_direction_vec(v.Pos,target.EyePos); end --Fire. Let go of the button periodically, as this allows the AI to continue firing for some reason. if self.testTimer:IsPastSimMS(self.testTime) == false then v:Activate(); else v:Deactivate(); end if self.testTimer:IsPastSimMS(self.testTime + 10) then self.testTimer:Reset(); end else v:Deactivate(); end end end end --Draw. local nPix = 0; for k,v in pairs(self.pixTable) do --Create a random pixel. local pixel = CreateMOPixel("Computer.rte/Draw Pixel " .. math.random(1,4)); --Create the glow. local glow = CreateMOPixel("Computer.rte/Pixel Glow"); --Place it. pixel.Pos = v; glow.Pos = v; --Spawn it. MovableMan:AddParticle(pixel); MovableMan:AddParticle(glow); --Make it settle. pixel.ToSettle = true; --Remove the entry. self.pixTable[k] = nil; --Increment pixel counter. nPix = nPix + 1; --If we've drawn too many pixels this frame, break. if nPix > self.pixCutoff / 2 then break; end end --Erase. nPix = 0; for k,v in pairs(self.eraseTable) do --We only need to erase if terrain is there, so check. if SceneMan:GetTerrMatter(v.X,v.Y) ~= 0 then --Create the erase pixel. local pixel = CreateMOSRotating("Computer.rte/Erase Pixel"); --Create the glow. local glow = CreateMOPixel("Computer.rte/Pixel Glow"); --Place it. pixel.Pos = v; glow.Pos = v; --Spawn it. MovableMan:AddParticle(pixel); MovableMan:AddParticle(glow); --Make it cut out its shape in the terrain. pixel:ForceDeepCheck(true); --Increment pixel counter. nPix = nPix + 1; --If we've drawn too many pixels this frame, break. if nPix > self.pixCutoff / 2 then break; end end --Remove the entry. self.eraseTable[k] = nil; end --Make sure the sound emitter is in the right place. if MovableMan:IsParticle(self.soundEmitter) then self.soundEmitter.Pos = self.Pos; self.soundEmitter.ToDelete = false; end else --Load. self.Frame = math.floor(((self.startup - self.startupTimer:LeftTillSimMS(self.startup)) / self.startup) * 7); end end function Destroy(self) --Stop playing the sound. if MovableMan:IsParticle(self.soundEmitter) then self.soundEmitter.ToDelete = true; end --If the representor exists, delete it. if MovableMan:IsActor(self.rep) then self.rep.ToDelete = true; end end 1036 lines One of the scripts of "GMod Tools"(CaveCricket48) viewtopic.php?f=61&t=17648 function Create(self)
self.GeneralTimer = Timer(); self.cantogglemode = true; self.displaymenu = false; self.currentmode = 1; self.parentplayer = 0; self.mapwrapx = SceneMan.SceneWrapsX; self.canuseprimary = true; self.canusesecondary = true; self.modename = {}; self.modedescription = {}; ------------------------------ ----- Menu Stuff self.modename[1] = "Cloner"; self.modedescription[1] = "Press CROUCH over an object to copy it. Press FIRE to spawn the object."; self.copyname = nil; self.copyclass = nil; self.modename[2] = "Cloner Pinned"; self.modedescription[2] = "Press CROUCH over an object to copy it. Press FIRE to spawn the object pinned."; self.modename[3] = "Remover"; self.modedescription[3] = "Press FIRE over an object to delete it, and press CROUCH over an object to delete it and everything attached."; self.modename[4] = "Welder"; self.modedescription[4] = "Press FIRE over an object to make it the base, and CROUCH over another object to attach it to the base."; self.weldtargeta = nil; self.weldtargetb = nil; self.modename[5] = "Weld Remover"; self.modedescription[5] = "Press FIRE over an object to remove all welds on it."; self.modename[6] = "Balloon Tool"; self.modedescription[6] = "Press FIRE over an object to attach a balloon to it, and CROUCH to remove all ballons attached to it."; self.modename[7] = "Thruster Tool"; self.modedescription[7] = "Hold FIRE over an object, move the cursor, and release to attach a thruster to it that points at the cursor."; self.modename[8] = "Emitter Controller"; self.modedescription[8] = "Press FIRE over an emitter to enable it and CROUCH to disable it."; self.modename[9] = "Device Controller"; self.modedescription[9] = "Press FIRE over a device to select it. Press FIRE to use it and CROUCH + (move cursor) to aim."; self.modename[10] = "Actor Controller"; self.modedescription[10] = "Press FIRE over a actor to switch control to it."; self.modename[11] = "Health Controller"; self.modedescription[11] = "Press FIRE over a actor to add health, and CROUCH to subtract health."; self.modename[12] = "Object Spawner"; self.modedescription[12] = "Press FIRE to bring up the build menu and use like normal."; ------------------------------ self.totalmodes = #self.modename; self.modulename = "GMod.rte"; local curdist = 30 for i = 1,MovableMan:GetMOIDCount()-1 do gun = MovableMan:GetMOFromID(i); if gun.PresetName == "Tool Gun" and gun.ClassName == "HDFirearm" and (gun.Pos-self.Pos).Magnitude < curdist then actor = MovableMan:GetMOFromID(gun.RootID); if MovableMan:IsActor(actor) and ToActor(actor):IsPlayerControlled() == true then self.parent = ToActor(actor); self.parentgun = ToHDFirearm(gun); self.cursor = CreateActor("Tool Gun Cursor",self.modulename); self.cursor.Pos = self.Pos; self.cursor.Team = self.parent.Team; MovableMan:AddActor(self.cursor); self.parentplayer = self.parent:GetController().Player; ActivityMan:GetActivity():SwitchToActor(self.cursor,self.parent:GetController().Player,self.parent.Team); self.parent:SetControllerMode(Controller.CIM_DISABLED, -1); end end end end function Update(self) if MovableMan:IsActor(self.parent) and MovableMan:IsActor(self.cursor) and self.parentgun ~= nil and self.parentgun.ID ~= 255 then self.ToDelete = false; self.ToSettle = false; self.PinStrength = 1000; self.Pos = self.parent.Pos; local anglenumber = SceneMan:ShortestDistance(self.parentgun.MuzzlePos,self.cursor.Pos,self.mapwrapx).AbsRadAngle; if anglenumber > (math.pi*0.5) or anglenumber < -(math.pi*0.5) then self.parent.HFlipped = true; self.parent:SetAimAngle(-anglenumber+math.pi); elseif anglenumber < (math.pi*0.5) or anglenumber > -(math.pi*0.5) then self.parent.HFlipped = false; self.parent:SetAimAngle(anglenumber); end if self.cursor:GetController():IsState(Controller.BODY_JUMP) and not(self.cursor:GetController():IsState(Controller.WEAPON_FIRE)) then self.displaymenu = true; if self.cantogglemode == true and self.cursor:GetController():IsState(Controller.HOLD_LEFT) and self.currentmode > 1 then self.currentmode = self.currentmode - 1; self.cantogglemode = false; end if self.cantogglemode == true and self.cursor:GetController():IsState(Controller.HOLD_RIGHT) and self.currentmode < self.totalmodes then self.currentmode = self.currentmode + 1; self.cantogglemode = false; end if not(self.cursor:GetController():IsState(Controller.HOLD_LEFT)) and not(self.cursor:GetController():IsState(Controller.HOLD_RIGHT)) then self.cantogglemode = true; end else self.displaymenu = false; self.actionmode = self.currentmode; end if self.cursor:GetController():IsState(Controller.PIE_MENU_ACTIVE) then ActivityMan:GetActivity():SwitchToActor(self.parent,self.parentplayer,self.parent.Team); end if self.cursor:IsPlayerControlled() == false then self.cursor.ToDelete = true; end ---------------------------------------- if self.actionmode == 1 or self.actionmode == 2 then -- Cloner ---------------------------------------- if self.cursor:GetController():IsState(Controller.BODY_CROUCH) and self.canusesecondary == true then local detectobject = SceneMan:GetMOIDPixel(self.cursor.Pos.X,self.cursor.Pos.Y); if detectobject ~= 255 then local copyobject = MovableMan:GetMOFromID(detectobject); if copyobject.ClassName == "HDFirearm" or copyobject.ClassName == "TDExplosive" or copyobject.ClassName == "HeldDevice" or copyobject.ClassName == "AEmitter" then self.copyname = copyobject.PresetName; self.copyclass = copyobject.ClassName; elseif copyobject.ClassName ~= "HDFirearm" and copyobject.ClassName ~= "TDExplosive" and copyobject.ClassName ~= "HeldDevice" and copyobject.ClassName ~= "AEmitter" then local basecopyobject = MovableMan:GetMOFromID(copyobject.RootID); self.copyname = basecopyobject.PresetName; self.copyclass = basecopyobject.ClassName; end self.canusesecondary = false; self.firefx = true; end elseif not(self.cursor:GetController():IsState(Controller.BODY_CROUCH)) then self.canusesecondary = true; end if self.cursor:GetController():IsState(Controller.WEAPON_FIRE) and self.canuseprimary == true then self.canuseprimary = false; if self.copyname ~= nil and self.copyclass ~= nil then if self.copyclass == "Actor" then self.clonee = CreateActor(self.copyname); self.clonee.Pos = self.cursor.Pos; self.clonee.Team = self.parent.Team; MovableMan:AddActor(self.clonee); elseif self.copyclass == "ACrab" then self.clonee = CreateACrab(self.copyname); self.clonee.Pos = self.cursor.Pos; self.clonee.AIMode = Actor.AIMODE_SENTRY; self.clonee.Team = self.parent.Team; MovableMan:AddActor(self.clonee); elseif self.copyclass == "AHuman" then self.clonee = CreateAHuman(self.copyname); self.clonee.Pos = self.cursor.Pos; self.clonee.AIMode = Actor.AIMODE_SENTRY; self.clonee.Team = self.parent.Team; MovableMan:AddActor(self.clonee); elseif self.copyclass == "ACRocket" then self.clonee = CreateACRocket(self.copyname); self.clonee.Pos = self.cursor.Pos; self.clonee.Team = self.parent.Team; MovableMan:AddActor(self.clonee); elseif self.copyclass == "ACDropShip" then self.clonee = CreateACDropShip(self.copyname); self.clonee.Pos = self.cursor.Pos; self.clonee.Team = self.parent.Team; MovableMan:AddActor(self.clonee); elseif self.copyclass == "AEmitter" then self.clonee = CreateAEmitter(self.copyname); self.clonee.Pos = self.cursor.Pos; MovableMan:AddParticle(self.clonee); elseif self.copyclass == "MOSRotating" then self.clonee = CreateMOSRotating(self.copyname); self.clonee.Pos = self.cursor.Pos; MovableMan:AddParticle(self.clonee); elseif self.copyclass == "HDFirearm" then self.clonee = CreateHDFirearm(self.copyname); self.clonee.Pos = self.cursor.Pos; MovableMan:AddItem(self.clonee); elseif self.copyclass == "TDExplosive" then self.clonee = CreateTDExplosive(self.copyname); self.clonee.Pos = self.cursor.Pos; MovableMan:AddItem(self.clonee); elseif self.copyclass == "HeldDevice" then self.clonee = CreateHeldDevice(self.copyname); self.clonee.Pos = self.cursor.Pos; MovableMan:AddItem(self.clonee); end if self.actionmode == 2 then self.clonee.PinStrength = 1000; end self.canuseprimary = false; self.firefx = true; end elseif not(self.cursor:GetController():IsState(Controller.WEAPON_FIRE)) then self.canuseprimary = true; end ---------------------------------------- elseif self.actionmode == 3 then -- Remover ---------------------------------------- if self.cursor:GetController():IsState(Controller.WEAPON_FIRE) and self.canuseprimary == true then local detectobject = SceneMan:GetMOIDPixel(self.cursor.Pos.X,self.cursor.Pos.Y); if detectobject ~= 255 then local object = MovableMan:GetMOFromID(detectobject); object.ToDelete = true; self.canuseprimary = false; self.firefx = true; end end if self.cursor:GetController():IsState(Controller.BODY_CROUCH) and self.canuseprimary == true then local detectobject = SceneMan:GetMOIDPixel(self.cursor.Pos.X,self.cursor.Pos.Y); if detectobject ~= 255 then local object = MovableMan:GetMOFromID(detectobject); local baseobject = MovableMan:GetMOFromID(object.RootID); baseobject.ToDelete = true; self.canuseprimary = false; self.firefx = true; end end if not(self.cursor:GetController():IsState(Controller.WEAPON_FIRE)) and not(self.cursor:GetController():IsState(Controller.BODY_CROUCH)) then self.canuseprimary = true; end ---------------------------------------- elseif self.actionmode == 4 then -- Welder ---------------------------------------- if self.cursor:GetController():IsState(Controller.WEAPON_FIRE) and self.canuseprimary == true then local detectobject = SceneMan:GetMOIDPixel(self.cursor.Pos.X,self.cursor.Pos.Y); if detectobject ~= 255 then local object = MovableMan:GetMOFromID(detectobject); if (self.weldtargetb ~= nil and self.weldtargetb.RootID ~= object.RootID) or self.weldtargetb == nil then self.weldtargeta = object; self.firefx = true; else local failsound = CreateAEmitter("Tool Gun Sound Failed",self.modulename); failsound.Pos = self.cursor.Pos; MovableMan:AddParticle(failsound); end self.canuseprimary = false; end elseif not(self.cursor:GetController():IsState(Controller.WEAPON_FIRE)) then self.canuseprimary = true; end if self.cursor:GetController():IsState(Controller.BODY_CROUCH) and self.canusesecondary == true then local detectobject = SceneMan:GetMOIDPixel(self.cursor.Pos.X,self.cursor.Pos.Y); if detectobject ~= 255 then local object = MovableMan:GetMOFromID(detectobject); if self.weldtargeta ~= nil and self.weldtargeta.RootID ~= object.RootID then self.weldtargetb = object; self.firefx = true; else local failsound = CreateAEmitter("Tool Gun Sound Failed",self.modulename); failsound.Pos = self.cursor.Pos; MovableMan:AddParticle(failsound); end self.canusesecondary = false; end elseif not(self.cursor:GetController():IsState(Controller.BODY_CROUCH)) then self.canusesecondary = true; end if self.weldtargeta ~= nil and self.weldtargeta.ID ~= 255 and self.weldtargetb ~= nil and self.weldtargetb.ID ~= 255 then local listnum = #toolgunsticktargetA + 1; toolgunsticktargetA[listnum] = self.weldtargeta; toolgunsticktargetB[listnum] = self.weldtargetb; toolgunsticktargetflipped[listnum] = self.weldtargeta.HFlipped; toolgunstickpositionX[listnum] = self.weldtargetb.Pos.X-self.weldtargeta.Pos.X; toolgunstickpositionY[listnum] = self.weldtargetb.Pos.Y-self.weldtargeta.Pos.Y; toolgunstickrotation[listnum] = self.weldtargeta.RotAngle; toolgunstickdirection[listnum] = self.weldtargetb.RotAngle; self.weldtargeta = nil; self.weldtargetb = nil; end ---------------------------------------- elseif self.actionmode == 5 then -- Weld Remover ---------------------------------------- if self.cursor:GetController():IsState(Controller.WEAPON_FIRE) and self.canuseprimary == true then local detectobject = SceneMan:GetMOIDPixel(self.cursor.Pos.X,self.cursor.Pos.Y); if detectobject ~= 255 then local object = MovableMan:GetMOFromID(detectobject); for i = 1, #toolgunsticktargetA do if toolgunsticktargetA[i] ~= nil and toolgunsticktargetA[i].ID == object.ID then toolgunsticktargetA[i] = nil; end end for i = 1, #toolgunsticktargetB do if toolgunsticktargetB[i] ~= nil and toolgunsticktargetB[i].ID == object.ID then toolgunsticktargetB[i] = nil; end end self.canuseprimary = false; self.firefx = true; end elseif not(self.cursor:GetController():IsState(Controller.WEAPON_FIRE)) then self.canuseprimary = true; end ---------------------------------------- elseif self.actionmode == 6 then -- Balloon Tool ---------------------------------------- if self.cursor:GetController():IsState(Controller.WEAPON_FIRE) and self.canuseprimary == true then local detectobject = SceneMan:GetMOIDPixel(self.cursor.Pos.X,self.cursor.Pos.Y); if detectobject ~= 255 then local object = MovableMan:GetMOFromID(detectobject); local balloon = CreateMOSRotating("Tool Gun Balloon",self.modulename); balloon.Pos = object.Pos; balloon.Frame = math.random(1,4)-1; MovableMan:AddParticle(balloon); local listnum = #toolgunballoontarget + 1; toolgunballoontarget[listnum] = object; toolgunballoon[listnum] = balloon; self.canuseprimary = false; self.firefx = true; end elseif not(self.cursor:GetController():IsState(Controller.WEAPON_FIRE)) and not(self.cursor:GetController():IsState(Controller.BODY_CROUCH)) then self.canuseprimary = true; end if self.cursor:GetController():IsState(Controller.BODY_CROUCH) and self.canuseprimary == true then local detectobject = SceneMan:GetMOIDPixel(self.cursor.Pos.X,self.cursor.Pos.Y); if detectobject ~= 255 then local object = MovableMan:GetMOFromID(detectobject); for i = 1, #toolgunballoontarget do if toolgunballoontarget[i] ~= nil and toolgunballoontarget[i].ID == object.ID then if MovableMan:IsParticle(toolgunballoon[i]) then toolgunballoon[i].PinStrength = 0; toolgunballoon[i].ToDelete = true; end toolgunballoontarget[i] = nil; end end self.canuseprimary = false; self.firefx = true; end end ---------------------------------------- elseif self.actionmode == 7 then -- Thruster Tool ---------------------------------------- if self.cursor:GetController():IsState(Controller.WEAPON_FIRE) then if self.thrustertarget == nil or (self.thrustertarget ~= nil and self.thrustertarget.ID == 255) then local detectobject = SceneMan:GetMOIDPixel(self.cursor.Pos.X,self.cursor.Pos.Y); if detectobject ~= 255 then self.thrustertarget = MovableMan:GetMOFromID(detectobject); self.thrusterposX = self.cursor.Pos.X-self.thrustertarget.Pos.X; self.thrusterposY = self.cursor.Pos.Y-self.thrustertarget.Pos.Y; self.thrusterangle = self.thrustertarget.RotAngle; self.firefx = true; end elseif self.thrustertarget ~= nil and self.thrustertarget.ID ~= 255 then local fxarrow = CreateMOSRotating("Tool Gun Arrow",self.modulename); fxarrow.Pos = self.thrustertarget.Pos + Vector(self.thrusterposX,self.thrusterposY):RadRotate(self.thrustertarget.RotAngle-self.thrusterangle); fxarrow.RotAngle = SceneMan:ShortestDistance(self.thrustertarget.Pos,self.cursor.Pos,self.mapwrapx).AbsRadAngle; MovableMan:AddParticle(fxarrow); end elseif not(self.cursor:GetController():IsState(Controller.WEAPON_FIRE)) then if self.thrustertarget ~= nil and self.thrustertarget.ID ~= 255 then local thruster = CreateAEmitter("Tool Gun Thruster",self.modulename); thruster.Pos = self.thrustertarget.Pos; thruster.RotAngle = SceneMan:ShortestDistance(self.thrustertarget.Pos,self.cursor.Pos,self.mapwrapx).AbsRadAngle; MovableMan:AddParticle(thruster); local listnum = #toolgunthrustertarget + 1; toolgunthrustertarget[listnum] = self.thrustertarget; toolgunthruster[listnum] = thruster; toolgunthrusterpositionX[listnum] = self.thrusterposX; toolgunthrusterpositionY[listnum] = self.thrusterposY; toolgunthrusterrotation[listnum] = self.thrusterangle; toolgunthrusterdirection[listnum] = thruster.RotAngle; self.thrusterposX = nil; self.thrusterposY = nil; self.thrusterangle = nil; self.thrustertarget = nil; self.firefx = true; end end if self.cursor:GetController():IsState(Controller.BODY_CROUCH) and self.canuseprimary == true then local detectobject = SceneMan:GetMOIDPixel(self.cursor.Pos.X,self.cursor.Pos.Y); if detectobject ~= 255 then local object = MovableMan:GetMOFromID(detectobject); for i = 1, #toolgunthrustertarget do if toolgunthrustertarget[i] ~= nil and toolgunthrustertarget[i].ID == object.ID then if MovableMan:IsParticle(toolgunthruster[i]) then toolgunthruster[i].PinStrength = 0; toolgunthruster[i].ToDelete = true; end toolgunthrustertarget[i] = nil; end end self.canuseprimary = false; self.firefx = true; end elseif not(self.cursor:GetController():IsState(Controller.BODY_CROUCH)) then self.canuseprimary = true; end ---------------------------------------- elseif self.actionmode == 8 then -- Emitter Controller ---------------------------------------- if self.cursor:GetController():IsState(Controller.WEAPON_FIRE) and self.canuseprimary == true then local detectobject = SceneMan:GetMOIDPixel(self.cursor.Pos.X,self.cursor.Pos.Y); if detectobject ~= 255 then local emitter = MovableMan:GetMOFromID(detectobject); if emitter.ClassName == "AEmitter" then ToAEmitter(emitter):EnableEmission(true); self.firefx = true; self.canuseprimary = false; end end end if self.cursor:GetController():IsState(Controller.BODY_CROUCH) and self.canuseprimary == true then local detectobject = SceneMan:GetMOIDPixel(self.cursor.Pos.X,self.cursor.Pos.Y); if detectobject ~= 255 then local emitter = MovableMan:GetMOFromID(detectobject); if emitter.ClassName == "AEmitter" then ToAEmitter(emitter):EnableEmission(false); self.firefx = true; self.canuseprimary = false; end end end if not(self.cursor:GetController():IsState(Controller.WEAPON_FIRE)) and not(self.cursor:GetController():IsState(Controller.BODY_CROUCH)) then self.canuseprimary = true; end ---------------------------------------- elseif self.actionmode == 9 then -- Device Controller ---------------------------------------- if self.cursor:GetController():IsState(Controller.WEAPON_FIRE) and self.canuseprimary == true then if not(MovableMan:IsDevice(self.selecteddevice)) then local detectobject = SceneMan:GetMOIDPixel(self.cursor.Pos.X,self.cursor.Pos.Y); if detectobject ~= 255 then local device = MovableMan:GetMOFromID(detectobject); if MovableMan:IsDevice(device) then self.selecteddevice = device; self.canuseprimary = false; end end end elseif not(self.cursor:GetController():IsState(Controller.WEAPON_FIRE)) then self.canuseprimary = true; end if MovableMan:IsDevice(self.selecteddevice) then self.selecteddevice.Vel = Vector(0,0); self.selecteddevice.AngularVel = 0; self.selecteddevice.HFlipped = false; if self.cursor:GetController():IsState(Controller.BODY_CROUCH) then self.selecteddevice.PinStrength = 1000; self.selecteddevice.RotAngle = SceneMan:ShortestDistance(self.selecteddevice.Pos,self.cursor.Pos,self.mapwrapx).AbsRadAngle; elseif not(self.cursor:GetController():IsState(Controller.BODY_CROUCH)) then self.selecteddevice.Pos = self.cursor.Pos; self.selecteddevice.PinStrength = 0; end if self.cursor:GetController():IsState(Controller.WEAPON_FIRE) and self.canuseprimary == true then if self.selecteddevice.ClassName == "HDFirearm" then ToHDFirearm(self.selecteddevice):Activate(); elseif self.selecteddevice.ClassName == "TDExplosive" then ToTDExplosive(self.selecteddevice):Activate(); end elseif not(self.cursor:GetController():IsState(Controller.WEAPON_FIRE)) then if self.selecteddevice.ClassName == "HDFirearm" then ToHDFirearm(self.selecteddevice):Deactivate(); elseif self.selecteddevice.ClassName == "TDExplosive" then if ToTDExplosive(self.selecteddevice):IsActivated() == true then self.selecteddevice.PinStrength = 0; self.selecteddevice.Vel = SceneMan:ShortestDistance(self.selecteddevice.Pos,self.cursor.Pos,self.mapwrapx); self.selecteddevice = nil; end end end end if self.cursor:GetController():IsState(Controller.BODY_JUMP) then self.selecteddevice = nil; end ---------------------------------------- elseif self.actionmode == 10 then -- Actor Controller ---------------------------------------- if self.cursor:GetController():IsState(Controller.WEAPON_FIRE) then local detectobject = SceneMan:GetMOIDPixel(self.cursor.Pos.X,self.cursor.Pos.Y); if detectobject ~= 255 then local actorpart = MovableMan:GetMOFromID(detectobject); local actor = MovableMan:GetMOFromID(actorpart.RootID); if MovableMan:IsActor(actor) then ActivityMan:GetActivity():SwitchToActor(ToActor(actor),self.parentplayer,actor.Team); end end end ---------------------------------------- elseif self.actionmode == 11 then -- Health Controller ---------------------------------------- if self.cursor:GetController():IsState(Controller.WEAPON_FIRE) then local detectobject = SceneMan:GetMOIDPixel(self.cursor.Pos.X,self.cursor.Pos.Y); if detectobject ~= 255 then local actorpart = MovableMan:GetMOFromID(detectobject); local actor = MovableMan:GetMOFromID(actorpart.RootID); if MovableMan:IsActor(actor) and ToActor(actor).Health < 100 then ToActor(actor).Health = ToActor(actor).Health + 1; end end end if self.cursor:GetController():IsState(Controller.BODY_CROUCH) then local detectobject = SceneMan:GetMOIDPixel(self.cursor.Pos.X,self.cursor.Pos.Y); if detectobject ~= 255 then local actorpart = MovableMan:GetMOFromID(detectobject); local actor = MovableMan:GetMOFromID(actorpart.RootID); if MovableMan:IsActor(actor) then ToActor(actor).Health = ToActor(actor).Health - 1; end end end ---------------------------------------- elseif self.actionmode == 12 then -- Object Spawner ---------------------------------------- if self.cursor:GetController():IsState(Controller.WEAPON_FIRE) and self.canuseprimary == true then ActivityMan:GetActivity().ActivityState = Activity.EDITING; self.canuseprimary = false; self.cursor.ToDelete = true; elseif not(self.cursor:GetController():IsState(Controller.WEAPON_FIRE)) then self.canuseprimary = true; end ---------------------------------------- end ---------------------------------------- if self.firefx == true then self.firefx = false; local firesound = CreateAEmitter("Tool Gun Sound Fire "..math.random(1,2),self.modulename); firesound.Pos = self.cursor.Pos; MovableMan:AddParticle(firesound); local fxring = CreateMOSRotating("Tool Gun FX Ring",self.modulename); fxring.Pos = self.cursor.Pos; fxring.Scale = 0; MovableMan:AddParticle(fxring); self.cursordist = SceneMan:ShortestDistance(self.parentgun.MuzzlePos,self.cursor.Pos,self.mapwrapx); self.cursordistnum = math.floor(self.cursordist.Magnitude/20); for i = 1, self.cursordistnum do self.launchfx = CreateMOSRotating("Tool Gun Beam",self.modulename); self.launchfx.Pos = self.parentgun.MuzzlePos + Vector((i-1)*20,0):RadRotate(self.cursordist.AbsRadAngle); self.launchfx.RotAngle = self.cursordist.AbsRadAngle; MovableMan:AddParticle(self.launchfx); end end else if MovableMan:IsActor(self.cursor) then self.cursor.ToDelete = true; end self.ToDelete = true; end if self.displaymenu == false then local textsetter = self.modename[self.currentmode].." - "..self.modedescription[self.currentmode]; FrameMan:ClearScreenText(self.parentplayer); FrameMan:SetScreenText(textsetter,self.parentplayer,0,1,false); elseif self.displaymenu == true then local textsetter = "Tools: "..self.modename[self.currentmode].." ("..self.currentmode.."/"..self.totalmodes..")"; FrameMan:ClearScreenText(self.parentplayer); FrameMan:SetScreenText(textsetter,self.parentplayer,0,1,true); end if not(MovableMan:IsParticle(gmodglobalscript)) then local globalscriptpar = CreateMOSRotating("Tool Gun Global Script","GMod.rte"); globalscriptpar.Pos = Vector(0,0); MovableMan:AddParticle(globalscriptpar); end end 631lines |
Author: | Xery [ Mon May 16, 2011 8:32 pm ] |
Post subject: | Re: What is the longest lua script you've ever written for CC? |
The AI script of "Independent"(Abdul Alhazred) viewtopic.php?f=61&t=20482 Independent = {}
function Create(self) function Hash(Pos) return math.ceil(Pos.X/60) + math.floor(Pos.Y/60)*self.WidthFactor end self.LifeTimer = Timer() self.MoveTimer = Timer() self.MissileTimer = Timer() self.WatchdogTimer = Timer() self.missilePause = 250 self.Gravity = SceneMan.GlobalAcc * TimerMan.DeltaTimeSecs -- acceleration from gravity in pixels/frame/frame self.Factor = FrameMan.PPM * TimerMan.DeltaTimeSecs -- converts m/s to pixels/frame self.WepRng = FrameMan.PlayerScreenWidth * 0.75 self.TurretOffset = Vector(20, -7) self.ThrusterOffset = Vector(-16, 7) self.jetBurst = 7 self.jetPower = 0.8 self.acc_t = 0 self.acc_ang = 0 self.HeadAngle = 0 self.WidthFactor = math.floor(SceneMan.SceneWidth / 60 + 0.5) self.resolution = 1 if self.Team < 0 then self.Frame = 1 else self.Frame = self.Team end if DebugIcon then DrawDebug = DebugIcon else DrawDebug = function(A, B) end end -- Find the head local MoObj for i = 1, MovableMan:GetMOIDCount()-1 do if i ~= thisID and MovableMan:GetRootMOID(i) == self.ID then MoObj = MovableMan:GetMOFromID(i) if MoObj.PresetName == "Independent Head" then self.Head = ToAttachable(MoObj) self.HeadAngle = self.Head.RotAngle break end end end end function Update(self) if self.Health < 1 then return end --[[ Debug if self.LZ then DrawDebug("Eye", self.LZ) end]] if not self.Head or not self.Head:IsAttached() then self:GibThis() return else -- Align head with target if self.HFlipped then self.Head.RotAngle = self.Head.RotAngle * 0.7 + (3.14 + self.HeadAngle) * 0.3 else self.Head.RotAngle = self.Head.RotAngle * 0.7 + self.HeadAngle * 0.3 end end local Ctrl = self:GetController() local TurretPos = self.Pos + self:RotateOffset(self.TurretOffset) local ThrusterPos = self.Pos + self:RotateOffset(self.ThrusterOffset) -- Update thrusters if self.Thrust then if MovableMan:IsParticle(self.Thrust) and self.Thrust.PresetName ~= "Entity" then self.Thrust.Pos = ThrusterPos self.Thrust.RotAngle = self.RotAngle + SceneMan:ShortestDistance(TurretPos + Vector(0,-15), ThrusterPos, false).AbsRadAngle if self.acc_t > 0 then self.Vel = self.Vel + Vector(self.jetPower,0):RadRotate(self.acc_ang) self.acc_t = self.acc_t - 1 else self.Thrust:EnableEmission(false) if self.TargetVel and self.Vel.Magnitude > self.TargetVel.Magnitude then -- We have probably left the ground self.WatchdogTimer:Reset() self.TargetVel = nil end end else self.Thrust = nil end end if self.Break then if MovableMan:IsParticle(self.Break) and self.Break.PresetName ~= "Entity" then self.Break.RotAngle = self.Vel.AbsRadAngle self.Break.Pos = self.Pos + self:RotateOffset(Vector(-8, 12)) if self.Vel.Magnitude > 5 then self.Vel = Vector(self.Vel.X*0.85, self.Vel.Y*0.9) end else self.Break = nil end end -- Update muzzle flash if self.Flash then if MovableMan:IsParticle(self.Flash) and self.Flash.PresetName ~= "Entity" then self.Flash.Pos = TurretPos else self.Flash = nil end end -- Check if the target is still valid if self.Target and (not self.Target.ID or self.Target.ID > 254 or self.Target.PresetName == "Entity") then self.Target = nil end if self:IsPlayerControlled() then if Ctrl:IsState(Controller.BODY_JUMPSTART) then self.acc_t = 5 if self.HFlipped then self.acc_ang = self.RotAngle+1.84 else self.acc_ang = self.RotAngle+1.30 end self.Vel = self.Vel + Vector(self.jetBurst/2,0):RadRotate(self.acc_ang) if self.Thrust then self.Thrust.ToDelete = true end -- Start jet pack self.Thrust = CreateAEmitter("Jump Thruster", "Independent.rte") self.Thrust.Pos = ThrusterPos self.Thrust.RotAngle = self.RotAngle + SceneMan:ShortestDistance(TurretPos + Vector(0,-15), ThrusterPos, false).AbsRadAngle MovableMan:AddParticle(self.Thrust) elseif Ctrl:IsState(Controller.BODY_JUMP) then self.acc_t = self.acc_t + 1 end self.WatchdogTimer:Reset() return else if not self.WatchdogTimer:IsPastSimMS(20000) then Ctrl:SetState(Controller.MOVE_RIGHT, false) Ctrl:SetState(Controller.MOVE_LEFT, false) Ctrl:SetState(Controller.BODY_CROUCH, false) else --DrawDebug("Eye Green", self.Pos) -- Debug if self.LZ then self:AddAISceneWaypoint(self.LZ) self.AIMode = Actor.AIMODE_GOTO elseif self.Targets and #self.Targets > 0 then local Act = self.Targets[math.random(#self.Targets)].Act if MovableMan:ValidMO(Act) and Act.PresetName ~= "Entity" then self:AddAISceneWaypoint(Act.Pos) self.AIMode = Actor.AIMODE_GOTO end else self.AIMode = Actor.AIMODE_BRAINHUNT end if Ctrl:IsState(Controller.BODY_JUMPSTART) then self.acc_t = 5 if self.HFlipped then self.acc_ang = self.RotAngle+1.84 else self.acc_ang = self.RotAngle+1.30 end self.Vel = self.Vel*0.67 + Vector(self.jetBurst,0):RadRotate(self.acc_ang) if self.Thrust then self.Thrust.ToDelete = true end -- Start jet pack self.Thrust = CreateAEmitter("Jump Thruster", "Independent.rte") self.Thrust.Pos = ThrusterPos self.Thrust.RotAngle = self.RotAngle + SceneMan:ShortestDistance(TurretPos + Vector(0,-15), ThrusterPos, false).AbsRadAngle MovableMan:AddParticle(self.Thrust) end end end -- Stabilize self.RotAngle = self.RotAngle * 0.95 if math.abs(self.RotAngle) < 0.2 or math.abs(self.AngularVel) > 5 then self.AngularVel = self.AngularVel * 0.9 end -- Search for targets and evaluate the threat level if (not self.Target and self.LifeTimer:IsPastSimMS(250)) or self.LifeTimer:IsPastSimMS(750) then self.LifeTimer:Reset() -- Dislodge if self.Vel.Magnitude < 0.1 then self:ForceDeepCheck(true) end if self.Health < 99 then self.Health = self.Health + RangeRand(0.4, 1.4) end local Act, Weapon, Dist, range, score, root_id self.Targets = {} self.Occupied = {} for i = 1, MovableMan:GetMOIDCount()-1 do -- Identify enemy weapons by iterating over the MOs instead of the actors root_id = MovableMan:GetRootMOID(i) if root_id ~= self.ID then -- Don't target yourself if root_id ~= i then -- A held weapon have the root id of the actor holding it Act = MovableMan:GetMOFromID(root_id) if MovableMan:IsActor(Act) then Act = ToActor(Act) if Act.Team ~= self.Team and Act.PresetName ~= "Entity" then Dist = SceneMan:ShortestDistance(TurretPos, Act.Pos, false) range = Dist.Magnitude score = 1 - range / SceneMan.SceneDim.Magnitude + Act.GoldValue/5000 + Act.Health/1000 -- Bias towards targeting the AI controlled actors if Act:IsPlayerControlled() then score = score - 0.05 end if range < self.WepRng then score = score + 0.2 -- Within our range if SceneMan:CastFindMORay(TurretPos, Dist, Act.ID, Vector(), self.ID, false, 7) then score = score + 0.5 -- LOS if Act:GetController():IsState(Controller.AIM_SHARP) then Dist = SceneMan:ShortestDistance(self.Pos, Act.ViewPoint, false) score = score + 0.1 if Dist.Magnitude < 60 then -- This enemy is aiming at us score = score + 0.4 end end end end if Act.ClassName == "ADoor" then score = score * 0.5 Act = MovableMan:GetMOFromID(i) -- Attack the actual door instead of the motor else Weapon = MovableMan:GetMOFromID(i) if Weapon.ClassName == "HDFirearm" then local tmp = math.min(0.01 + Weapon.GoldValue/1000 + Weapon.Mass/100, 0.15) if range < ToHeldDevice(Weapon).SharpLength then score = score + tmp * 2 else score = score + tmp end end if self.InvTarget and self.InvTarget.ID == Act.ID then score = score / 3 --DrawDebug("Eye Green Long", Act.Pos) --Debug end end table.insert(self.Targets, {Act=Act, score=score, dist=range}) end end else Act = MovableMan:GetMOFromID(root_id) if MovableMan:IsActor(Act) and Act.PresetName ~= "Entity" and Act.ClassName ~= "ADoor" then Act = ToActor(Act) if Act.Team == self.Team then score = -1 else range = SceneMan:ShortestDistance(TurretPos, Act.Pos, false).Magnitude score = (1 - range / SceneMan.SceneDim.Magnitude + Act.GoldValue/5000 + Act.Health/1000)*0.9 table.insert(self.Targets, {Act=Act, score=score, dist=range}) end -- Transform the position in to a spatial hash if Act.Vel.Magnitude < 3 then local h = Hash(Act.Pos) for i = -1, 1 do self.Occupied[h+i] = score end end end end end end if #self.Targets > 0 then self.targetIndex = math.min(math.floor(RangeRand(1,3)+0.5), #self.Targets) table.sort(self.Targets, function(a,b) return a.score > b.score end) self.InvTarget = nil self.Target = self.Targets[1].Act else self.Targets = nil end elseif self.Targets and self.MissileTimer:IsPastSimMS(self.missilePause) and self.Vel.Magnitude < 1 then if self.AimRocket then -- Look for a missile trajectory to the target if not MovableMan:ValidMO(self.AimRocket.Act) or self.AimRocket.Act.PresetName == "Entity" then self.AimRocket = nil else local running, Data = coroutine.resume(self.AimRocket.Co, self, self.AimRocket.Act.Pos ) if Data and Data.ang then self.HeadAngle = Data.ang if Data.str + Data.dist < self.AimRocket.minStr + self.AimRocket.dist and SceneMan:CastObstacleRay(self.Pos + self:RotateOffset(Vector(7,-20)), Vector(50,0):RadRotate(Data.ang), Vector(), Vector(), self.ID, -1, 3) == -1 then self.AimRocket.minStr = Data.str self.AimRocket.dist = Data.dist self.AimRocket.ang = Data.ang end end if not running then -- the coroutine return false when done self.MissileTimer:Reset() if self.AimRocket.ang and self.AimRocket.minStr < 70 then -- Launch local Missile if self.AimRocket.Act.Vel.Magnitude < 3.5 then if self.AimRocket.dist < 60 then Missile = CreateAEmitter("Rocket Launch", "Independent.rte") Missile.PresetName = "Rocket" Missile.Sharpness = -1 elseif self.AimRocket.dist < 120 then Missile = CreateAEmitter("Mine Launch", "Independent.rte") Missile.PresetName = "Mine Missile" Missile.Sharpness = -1 end elseif self.AimRocket.dist < 500 and self.AimRocket.minStr < 15 then Missile = CreateAEmitter("Homing Missile Launch", "Independent.rte") Missile.PresetName = "Homing Missile" Missile.Sharpness = self.AimRocket.Act.ID end if Missile then self.WatchdogTimer:Reset() Missile.Vel = Vector(5, 0):RadRotate(self.AimRocket.ang) Missile.RotAngle = self.AimRocket.ang Missile.Pos = self.Head.Pos + self.Head:RotateOffset(Vector(14,0)) MovableMan:AddParticle(Missile) Missile:SetWhichMOToNotHit(self, -1) self:SetWhichMOToNotHit(Missile, -1) self.HeadAngle = self.AimRocket.ang self.missilePause = RangeRand(4500,7000) end else self.missilePause = RangeRand(1000,2000) end self.AimRocket = nil end end elseif self.targetIndex <= #self.Targets then local Targ = self.Targets[self.targetIndex] if Targ and Targ.dist > 175 and Targ.dist < 1500 and MovableMan:ValidMO(Targ.Act) and Targ.Act.PresetName ~= "Entity" and Targ.Act.Vel.Magnitude < 30 then self.AimRocket = {Co=coroutine.create(Independent.FindRocketPath), minStr=math.huge, Act=Targ.Act, dist=0} end self.targetIndex = self.targetIndex + 1 else self.Targets = nil end end -- Find a location to shoot from if self.Target and not self.FindPathCo then if not self.LZ or self.MoveTimer:IsPastSimMS(2000) then if not self.FindLZCo then self.FindLZCo = coroutine.create(Independent.FindLZ) else local running, LZ = coroutine.resume(self.FindLZCo, self) if running then if LZ then self.MoveTimer:Reset() self.FindLZCo = nil self.LZ = LZ end else --print("Can't find a location to shoot from") self.FindLZCo = nil self.InvTarget = self.Target if self.Targets and #self.Targets > 1 then local r = math.random(2, #self.Targets) if self.Targets[r] then self.Target = self.Targets[r].Act if self.Target and (not self.Target.ID or self.Target.ID > 254 or self.Target.PresetName == "Entity") then self.Target = nil end end end end end end else self.FindLZCo = nil end if self.LZ and not self.AimRocket then -- Don't jump while evaluating targets if self.Vel.Magnitude < 3 then if SceneMan:ShortestDistance(self.Pos, self.LZ, false).Magnitude < 30 then -- At target self.WatchdogTimer:Reset() self.LZ = nil self.AIMode = 0 elseif math.abs(self.RotAngle) < 0.2 then if self.FindPathCo then if not coroutine.resume(self.FindPathCo, self) then -- The coroutine return false when done self.FindPathCo = nil if #self.Waypoints > 0 then self.acc_ang = self.Waypoints[1].ang self.acc_t = self.Waypoints[1].acc_t self.TargetVel = self.Vel + Vector(self.jetBurst,0):RadRotate(self.acc_ang) self.Vel = self.TargetVel if self.Thrust then self.Thrust.ToDelete = true end -- Start jet pack self.Thrust = CreateAEmitter("Jump Thruster", "Independent.rte") self.Thrust.Pos = ThrusterPos self.Thrust.RotAngle = self.RotAngle + SceneMan:ShortestDistance(TurretPos + Vector(0,-15), ThrusterPos, false).AbsRadAngle MovableMan:AddParticle(self.Thrust) else --print("Independent: Can't find path to LZ") self.LZ = nil self.InvTarget = self.Target if self.Targets and #self.Targets > 1 then local r = math.random(2, #self.Targets) if self.Targets[r] then self.Target = self.Targets[r].Act if self.Target and (not self.Target.ID or self.Target.ID > 254 or self.Target.PresetName == "Entity") then self.Target = nil end end end end end else self.Waypoints = {} self.FindPathCo = coroutine.create(Independent.FindJumpPath) end end else self.FindPathCo = nil end end if not self.Break and self.Vel.Y > 6 and SceneMan:CastObstacleRay(self.Pos, self.Vel*8, Vector(), Vector(), self.ID, -1, 4) > -1 then -- Start jet pack self.Break = CreateAEmitter("Break Thruster", "Independent.rte") self.Break.RotAngle = self.Vel.AbsRadAngle self.Break.Pos = self.Pos MovableMan:AddParticle(self.Break) end if self.Target then --DrawDebug("Eye Red", self.Target.Pos) --Debug -- Face the enemy Ctrl:SetState(Controller.AIM_SHARP, true) self:SetAimAngle(SceneMan:ShortestDistance(self.Pos, self.Target.Pos, false).AbsRadAngle) if not self.fire then local TargPos self.even = not self.even if self.even then TargPos = self.Target.Pos + Vector(15,0):RadRotate(self.Target.RotAngle+1.571) else TargPos = self.Target.Pos end local Free = Vector() local Dist = SceneMan:ShortestDistance(TurretPos, TargPos, false) if not self.burst then if Dist.Magnitude < self.WepRng/3 then self.burst = math.random(10,20) else self.burst = math.random(4,10) end end if Dist.Magnitude < self.WepRng * 1.05 then local ang = Dist.AbsRadAngle local TestPos = TurretPos + Vector(3,0):RadRotate(ang) if SceneMan:GetMOIDPixel(TestPos.X, TestPos.Y) ~= self.ID then local id = SceneMan:CastMORay(TurretPos, Dist, self.ID, -1, false, 3) if id and id < 255 then local MO = MovableMan:GetMOFromID(MovableMan:GetRootMOID(id)) if MO.Team ~= self.Team then self.WatchdogTimer:Reset() self.Flash = CreateAEmitter("Flash Blaster MG", "Independent.rte") self.Flash.RotAngle = ang self.Flash.Pos = TurretPos MovableMan:AddParticle(self.Flash) local Bullet = CreateMOPixel("Particle Blaster MG", "Independent.rte") Bullet.Pos = TestPos if self.Vel.Magnitude > 3 then Bullet.Vel = Vector(99,0):RadRotate(ang + RangeRand(-0.12, 0.12)) else Bullet.Vel = Vector(99,0):RadRotate(ang + RangeRand(-0.07, 0.07)) end Bullet:SetWhichMOToNotHit(self, -1) MovableMan:AddParticle(Bullet) self.burst = self.burst - 1 if self.burst < 1 then self.burst = nil self.fire = math.random(10,30) else self.fire = math.random(5,8) end end end end else self.fire = 15 end else self.fire = self.fire - 1 if self.fire < 1 then self.fire = false end end end end -- Calculate how to jump to the LZ Independent.FindJumpPath = function(self) local NextWpts = {} local FindJumpAngCo = coroutine.create(Independent.FindJumpAngle) local yi = false while coroutine.resume(FindJumpAngCo, self, self.Pos, NextWpts) do if yi then coroutine.yield() -- Spread out the search over several frames end yi = not yi end if #NextWpts > 0 then table.sort(NextWpts, function(a,b) return a.dist < b.dist end) if SceneMan:ShortestDistance(self.LZ, NextWpts[1].Pos, false).Magnitude < 40 then self.Waypoints[1] = { Pos = NextWpts[1].Pos, dist = NextWpts[1].dist, ang = NextWpts[1].ang, acc_t = NextWpts[1].acc_t } return else self.Waypoints[#self.Waypoints+1] = { Pos = NextWpts[1].Pos, dist = NextWpts[1].dist, ang = NextWpts[1].ang, acc_t = NextWpts[1].acc_t } end self.resolution = 1.5 local TempWpts for i,Wpt in pairs(NextWpts) do -- Now check the paths to the LZ from all positions found TempWpts = {} --DrawDebug("Brain", Wpt.Pos + Vector(0,-5)) yi = false FindJumpAngCo = coroutine.create(Independent.FindJumpAngle) while coroutine.resume(FindJumpAngCo, self, Vector(Wpt.Pos.X, Wpt.Pos.Y), TempWpts) do if yi then coroutine.yield() -- Spread out the search over several frames end yi = not yi end if #TempWpts > 0 then table.sort(TempWpts, function(a,b) return a.dist < b.dist end) -- Check if Wpt lead to TempWpts[1] if SceneMan:ShortestDistance(self.LZ, TempWpts[1].Pos, false).Magnitude < 40 then self.Waypoints[1] = { Pos = Wpt.Pos, dist = Wpt.dist, ang = Wpt.ang, acc_t = Wpt.acc_t } return else self.Waypoints[#self.Waypoints+1] = { Pos = Wpt.Pos, dist = TempWpts[1].dist, ang = Wpt.ang, acc_t = Wpt.acc_t } end end end end if #self.Waypoints > 0 then table.sort(self.Waypoints, function(a,b) return a.dist < b.dist end) elseif #NextWpts > 0 then -- Just in case table.sort(NextWpts, function(a,b) return a.dist < b.dist end) self.Waypoints[1] = { Pos = NextWpts[1].Pos, dist = NextWpts[1].dist, ang = NextWpts[1].ang, acc_t = NextWpts[1].acc_t } end end -- Calculate one jump Independent.FindJumpAngle = function(self, StartPos, Wpts) local Vel, Acc, NewPos, OldPos local Range = SceneMan:ShortestDistance(self.LZ, StartPos, false) local mag = Range.Magnitude local maxAcc = math.floor(500/TimerMan.DeltaTimeMS + 0.5) -- TTL: 500ms local minAcc = math.floor(math.min(1 + math.abs(Range.Y/60) + mag/60, maxAcc/2) + 0.5) local accRes = math.max(math.floor(5 * self.resolution + 0.5), 1) local minAng = 0.1 local maxAng = 2.0 local angRes = 0.11 * self.resolution local dir if Range.AbsRadAngle < 1.571 then dir = 3.142 if self.LZ.Y < StartPos.Y then minAng = 0.6 angRes = angRes * 0.9 end else -- Target is to the right dir = -4.712 if self.LZ.Y < StartPos.Y then maxAng = 1.3 angRes = angRes * 0.9 end end for acc_t = minAcc, maxAcc, accRes do for ang = minAng, maxAng, angRes do Vel = self.Vel + Vector(self.jetBurst,0):RadRotate(dir-ang) Acc = Vector(self.jetPower,0):RadRotate(dir-ang) OldPos = Vector(StartPos.X, StartPos.Y) for t = 1, 500 do NewPos = OldPos + Vel * self.Factor --if t % 8 == 0 then DrawDebug("Blue", NewPos) end -- Debug if t < acc_t then Vel = Vel + Acc + self.Gravity else Vel = Vel + self.Gravity end if NewPos.Y < -50 or SceneMan:GetTerrMatter(NewPos.X - 24, NewPos.Y - 13) > 0 or SceneMan:GetTerrMatter(NewPos.X + 24, NewPos.Y - 13) > 0 or SceneMan:GetTerrMatter(NewPos.X, NewPos.Y + 15) > 0 then break end -- The feet hit the ground if SceneMan:GetTerrMatter(NewPos.X, NewPos.Y + 20) > 0 then if self.Occupied[Hash(NewPos)] then break end -- Make sure we land at a steep angle or have space to recover from a fall Range = SceneMan:ShortestDistance(OldPos, NewPos, false) if math.abs(Range.X*1.2) > math.abs(Range.Y) then if (Range.X > 0 and SceneMan:GetTerrMatter(NewPos.X + 30, NewPos.Y + 20) == 0) or (Range.X < 0 and SceneMan:GetTerrMatter(NewPos.X - 30, NewPos.Y + 20) == 0) then break end end Wpts[#Wpts+1] = { Pos = Vector(NewPos.X, NewPos.Y), dist = SceneMan:ShortestDistance(self.LZ, NewPos, false).Magnitude + t/10, ang = dir - ang, acc_t = acc_t } --DrawDebug("Cross", Vector(NewPos.X, NewPos.Y)) break end OldPos = Vector(NewPos.X, NewPos.Y) end coroutine.yield(true) -- Spread out the search over several frames end end end -- Try to find a rocket trajectory to the target Independent.FindRocketPath = function(self, TargetPos) local OldPos, NewPos, Vel local dist, angle, state, hs local StartPos = self.Pos + self:RotateOffset(Vector(7,-20)) local fiveHundredMS = 500 / TimerMan.DeltaTimeMS local delta = FrameMan.PPM * TimerMan.DeltaTimeSecs * 3 -- Simulate every third frame local Temp local tmp = SceneMan:ShortestDistance(StartPos, TargetPos, false).Magnitude if StartPos.Y > TargetPos.Y then -- The target is above the shooter Temp = Vector(TargetPos.X, TargetPos.Y - tmp) else Temp = Vector(TargetPos.X, TargetPos.Y - tmp/3) end local startAng = SceneMan:ShortestDistance(StartPos, Temp, false).AbsRadAngle for aimAng = startAng-0.5, startAng+0.5, 0.08 do angle = aimAng state = 1 -- Not armed Vel = Vector(5, 0):RadRotate(angle) OldPos = Vector(StartPos.X, StartPos.Y) for t = 1, 93, 3 do NewPos = OldPos + Vel * delta hs = Hash(NewPos) if self.Occupied[hs] and self.Occupied[hs] < 0 then -- Avoid hitting allies break end if t <= fiveHundredMS then Vel = Vel + Vector(0.8,0):RadRotate(angle) * 3 -- Fake rocket emitter else --DrawDebug("Orange", NewPos) -- Debug state = 2 -- Armed Temp = SceneMan:ShortestDistance(NewPos, TargetPos, false) dist = Temp.Magnitude -- Taget bracketed? if math.abs(SceneMan:ShortestDistance(OldPos, TargetPos, false).AbsRadAngle - Temp.AbsRadAngle) > 1 then Temp = OldPos + SceneMan:ShortestDistance(OldPos, NewPos, false) * 0.5 dist = SceneMan:ShortestDistance(Temp, TargetPos, false).Magnitude if dist < 30 then state = 3 -- This will probably hit the target break end end end -- The missile hit something if NewPos.Y < -25 or SceneMan:GetTerrMatter(NewPos.X, NewPos.Y) > 0 then break end for _ = 1, 3 do -- Fake OrientToVel angle = angle*0.67 + Vel.AbsRadAngle*0.33 end Vel = Vel + Vector(0, 0.66) -- Fake gravity (0.2*3.3) OldPos:SetXY(NewPos.X, NewPos.Y) end if state > 2 then dist = dist * 0.5 tmp = 0 elseif state > 1 then if dist < 500 then tmp = SceneMan:CastStrengthSumRay(NewPos, TargetPos, 4, 128) -- Ignore grass else tmp = 10000 end else dist = 10000 tmp = 10000 end coroutine.yield({ang=aimAng, dist=dist, str=tmp}) -- Spread out the search over several frames end end -- Find a location to shoot from Independent.FindLZ = function(self) local Free = Vector() local TestPos, dist local LZs = {} local startAng = SceneMan:ShortestDistance(self.Target.Pos, self.Pos, false).AbsRadAngle * 0.67 for ang = startAng, startAng + 6.28, 0.13 do for rng = 9, self.WepRng, 9 do TestPos = self.Target.Pos + Vector(rng,0):RadRotate(ang) --DrawDebug("Orange", TestPos) if TestPos.Y < 0 or SceneMan:GetTerrMatter(TestPos.X, TestPos.Y) > 0 then break end if rng > 55 then if SceneMan:CastObstacleRay(TestPos, Vector(0,30), Vector(), Free, self.ID, -1, 5) > 0 and not self.Occupied[Hash(Free)] then dist = SceneMan:ShortestDistance(self.Pos, Free, false).Magnitude / 2 dist = dist - SceneMan:ShortestDistance(self.Target.Pos, Free, false).Magnitude dist = dist + SceneMan:CastStrengthSumRay(Free, Free + Vector(0,-60), 3, 128) table.insert(LZs, {Pos=Vector(Free.X, Free.Y - 20), score=dist}) end end end coroutine.yield() -- Spread out the search over several frames end if #LZs > 0 then table.sort(LZs, function(a,b) return a.score < b.score end) coroutine.yield(LZs[1].Pos) -- Return the answer end end 856 lines |
Author: | Xery [ Mon May 16, 2011 8:33 pm ] |
Post subject: | Re: What is the longest lua script you've ever written for CC? |
And, scripts of mission mods are usually over 900lines. The main script of "Prison Escape Episode 2"(LastBanana) viewtopic.php?f=24&t=17619 function point_direction_vec(pointA,pointB)
--Returns the direction from Vector A to Vector B. return math.atan2(pointA.Y - pointB.Y,pointA.X - pointB.X); end function Speak(person,text,length) --Set the text. ActivityMan:GetActivity():ResetMessageTimer(Activity.PLAYER_1); FrameMan:ClearScreenText(Activity.PLAYER_1); FrameMan:SetScreenText(string.upper(person.PresetName) .. ": " .. text, Activity.PLAYER_1, 0, length, false); --Add the marker. local marker = CreateAEmitter("Prison Escape Ep2.rte/Speech Marks"); marker.Mass = person.ID; marker.Lifetime = length; MovableMan:AddParticle(marker); end function PrisonEscapeMission2:StartActivity() --Create an invisible brain. self.brain = CreateActor("Base.rte/Brain Case"); self.brain.Team = Activity.TEAM_1; self.brain.Pos = Vector(600,550); self.brain.Scale = 0; self.brain.GetsHitByMOs = false; self.brain.HitsMOs = false; MovableMan:AddActor(self.brain); self:SetPlayerBrain(self.brain,Activity.PLAYER_1); self:SwitchToActor(self.brain,Activity.PLAYER_1,-1); --Actors to spawn. local guard1 = CreateAHuman("Base.rte/Robot 2"); guard1.Pos = Vector(1430,360); guard1.Team = Activity.TEAM_2; MovableMan:AddActor(guard1); guard1:SetControllerMode(Controller.CIM_NETWORK,-1); guard1.HFlipped = true; local guard2 = CreateAHuman("Base.rte/Robot 2"); guard2.Pos = Vector(1440,456); guard2.Team = Activity.TEAM_2; MovableMan:AddActor(guard2); guard2:SetControllerMode(Controller.CIM_NETWORK,-1); guard2.HFlipped = true; local guard3 = CreateAHuman("Base.rte/Robot 2"); guard3.Pos = Vector(1260,626); guard3.Team = Activity.TEAM_2; MovableMan:AddActor(guard3); guard3:SetControllerMode(Controller.CIM_NETWORK,-1); guard3.HFlipped = true; self.soldier1 = CreateAHuman("Prison Escape Ep2.rte/Soldier Light"); self.soldier1.Pos = Vector(2220,456); self.soldier1.Team = Activity.TEAM_2; self.soldier1.HFlipped = true; self.soldier1:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Pistol")); MovableMan:AddActor(self.soldier1); self.soldier1.AIMode = Actor.AIMODE_SENTRY; local soldier2 = CreateAHuman("Prison Escape Ep2.rte/Soldier Light"); soldier2.Pos = Vector(2029,648); soldier2.Team = Activity.TEAM_2; soldier2.HFlipped = false; soldier2:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Compact Assault Rifle")); MovableMan:AddActor(soldier2); soldier2.AIMode = Actor.AIMODE_SENTRY; self.soldier3 = CreateAHuman("Prison Escape Ep2.rte/Soldier Light"); self.soldier3.Pos = Vector(2895,384); self.soldier3.Team = Activity.TEAM_2; self.soldier3.HFlipped = true; self.soldier3:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Shotgun")); MovableMan:AddActor(self.soldier3); self.soldier3.AIMode = Actor.AIMODE_SENTRY; self.soldier4 = CreateAHuman("Prison Escape Ep2.rte/Soldier Heavy"); self.soldier4.Pos = Vector(3324,408); self.soldier4.Team = Activity.TEAM_2; self.soldier4.HFlipped = true; self.soldier4:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Compact Assault Rifle")); MovableMan:AddActor(self.soldier4); self.soldier4.AIMode = Actor.AIMODE_SENTRY; self.soldier5 = CreateAHuman("Prison Escape Ep2.rte/Soldier Heavy"); self.soldier5.Pos = Vector(3420,408); self.soldier5.Team = Activity.TEAM_2; self.soldier5.HFlipped = true; self.soldier5:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Compact Assault Rifle")); MovableMan:AddActor(self.soldier5); self.soldier5.AIMode = Actor.AIMODE_SENTRY; --Blocks player's exit through first opening. self.shield1 = CreateMOSRotating("Prison Escape Ep2.rte/Force Field V"); self.shield1.Pos = Vector(1932,420); MovableMan:AddParticle(self.shield1); --Blocks player from exiting during first battle. self.shield2 = CreateMOSRotating("Prison Escape Ep2.rte/Force Field H"); self.shield2.Pos = Vector(2190,504); self.shield2.HFlipped = true; MovableMan:AddParticle(self.shield2); self.shield3 = CreateMOSRotating("Prison Escape Ep2.rte/Force Field H"); self.shield3.Pos = Vector(2190,552); self.shield3.HFlipped = true; MovableMan:AddParticle(self.shield3); --Blocks player's exit through second opening. self.shield4 = CreateMOSRotating("Prison Escape Ep2.rte/Force Field V"); self.shield4.Pos = Vector(2796,324); MovableMan:AddParticle(self.shield4); --Blocks player's entrance into the enemy spawn room. self.shield5 = CreateMOSRotating("Prison Escape Ep2.rte/Force Field H Ballistic"); self.shield5.Pos = Vector(3618,600); MovableMan:AddParticle(self.shield5); --The enemy brain. self.enemyBrain = CreateActor("Prison Escape Ep2.rte/Richard Borno"); self.enemyBrain.Pos = Vector(3372,368); self.enemyBrain.Team = Activity.TEAM_2; self.enemyBrain.GetsHitByMOs = false; MovableMan:AddActor(self.enemyBrain); --The escape rocket. self.rocket = CreateAEmitter("Prison Escape Ep2.rte/Escape Rocket"); self.rocket.Pos = Vector(3852,499); self.rocket.PinStrength = 99999; MovableMan:AddParticle(self.rocket); --A floating health symbol implying that there's an actor next to the ship. self.symbol = CreateActor("Base.rte/Brain Case"); self.symbol.RotAngle = 0; self.symbol.HFlipped = true; self.symbol.Scale = 0; self.symbol.Team = Activity.TEAM_1; self.symbol.Pos = Vector(3876,520); self.symbol.PresetName = "Fiona"; MovableMan:AddActor(self.symbol); --Something for enemies to aim at on the ship. self.aimer = CreateActor("Base.rte/Brain Case"); self.aimer.Scale = 0; self.aimer.Team = Activity.TEAM_1; self.aimer.Pos = Vector(3852,460); MovableMan:AddActor(self.aimer); --The cloning tube. self.cloneTube = CreateAEmitter("Prison Escape Ep2.rte/Clone Generator"); self.cloneTube.Pos = Vector(3372,528); self.cloneTube:EnableEmission(false); self.cloneTube.Team = Activity.TEAM_2; MovableMan:AddParticle(self.cloneTube); --The gun maker. self.gunMaker = CreateAEmitter("Prison Escape Ep2.rte/Gun Maker"); self.gunMaker.Pos = Vector(3470,492); self.gunMaker:EnableEmission(false); self.gunMaker.Team = Activity.TEAM_2; MovableMan:AddParticle(self.gunMaker); --The shield maker. self.shieldMaker = CreateAEmitter("Prison Escape Ep2.rte/Shield Maker"); self.shieldMaker.Pos = Vector(3566,492); self.shieldMaker:EnableEmission(false); self.shieldMaker.Team = Activity.TEAM_2; MovableMan:AddParticle(self.shieldMaker); --The enemy spawn room self.spawnRoom = SceneMan.Scene:GetArea("Enemy Spawn Room"); --Timer to count events. self.eventTimer = Timer(); --How fast the ship falls. self.shipFallSpeed = 40; --Where the ship actually landed. self.landingSpot = Vector(); --The player's last position. self.playerPos = Vector(); --How often ending clones should shoot. self.shootTime = 500; self.shootTimer = Timer(); --Whether the player was HFlipped. self.playerHFlip = false; --Where the player was aiming. self.playerAim = 0; --Which of the endings the player got. self.endMsg = 0; --Give the player no funds. self:SetTeamFunds(0,Activity.TEAM_1); if checkpoint == nil then --The current event stage. self.eventStage = 0; --Items the player has. hasDeagle = true; hasPstl = false; hasCAR = false; hasAR = false; hasShotgun = false; hasShield = false; --How many times the player has respawned. respawns = 0; --What the camera should be focusing on. self.target = self.brain; --What AIMode the target should be in. self.targetMode = Controller.CIM_NETWORK; --Don't play music yet. AudioMan:StopMusic(); else --The current event stage. self.eventStage = 64; --Set the actor's position. self.playerPos = Vector(3350,415); --What AIMode the target should be in. self.targetMode = Controller.CIM_PLAYER; --Spawn Fiona. self.partner = CreateAHuman("Prison Escape Ep2.rte/Fiona"); self.partner:SetControllerMode(Controller.CIM_NETWORK,-1); self.partner.Pos = SceneMan:MovePointToGround(Vector(50,0),0,0); self.partner.Team = Activity.TEAM_1; self.partner:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Amazon Pistol")); self.partner:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Amazon Pistol (Offhand)")); MovableMan:AddActor(self.partner); --Report the amount of respawns. self:ReportDeath(Activity.TEAM_1,respawns + 1); --Play music. AudioMan:ClearMusicQueue(); AudioMan:PlayMusic("Prison Escape Ep2.rte/Sound/Music/Plucked_From_Space.ogg", -1, -1); self.startup = true; end end function PrisonEscapeMission2:UpdateActivity() if self.startup and self.eventTimer:IsPastSimMS(100) then --Kill all enemies. for actor in MovableMan.Actors do if actor.Team == Activity.TEAM_2 then if actor.PresetName == "Richard Borno" then actor.ToDelete = true; else actor.Health = 0; end end end self.startup = false; end --Keep the brain's health invisible. self.brain.Team = -1; if self:ActivityOver() == false then --Stay controlling the target. if MovableMan:IsActor(self.target) then if self:GetControlledActor(Activity.TEAM_1) == nil then self:SwitchToActor(self.target,Activity.PLAYER_1,Activity.TEAM_1); else --If the target isn't already controlled, switch to it. local other = self:GetControlledActor(Activity.PLAYER_1); if self.target.ID ~= other.ID then self:SwitchToActor(self.target,Activity.PLAYER_1,Activity.TEAM_1); --Set the target's controller mode. if self.targetMode == Controller.CIM_NETWORK then self.target:SetControllerMode(Controller.CIM_NETWORK,-1); else self.target:SetControllerMode(Controller.CIM_PLAYER,Activity.PLAYER_1); end --Set the last actor back to the right mode. other:SetControllerMode(Controller.CIM_NETWORK,-1); end end end --Respawn the player if they died. local playerAlive = true; if MovableMan:IsActor(self.playerActor) == false then playerAlive = false; elseif self.playerActor.Health <= 0 then self.playerActor.ToDelete = true; playerAlive = false; else --Keep the player in the right mode. if self.playerActor:IsPlayerControlled() == false then --Set the target's controller mode. if self.targetMode == Controller.CIM_NETWORK then self.playerActor:SetControllerMode(Controller.CIM_NETWORK,-1); else self.playerActor:SetControllerMode(Controller.CIM_PLAYER,Activity.PLAYER_1); end end --Update the player's position. self.playerPos.X = self.playerActor.Pos.X; self.playerPos.Y = self.playerActor.Pos.Y; self:SetObservationTarget(self.playerPos,Activity.PLAYER_1); --Update the player's aim. self.playerAim = self.playerActor:GetAimAngle(false); self.playerHFlip = self.playerActor.HFlipped; --Update the player's inventory. if self.playerActor:HasObject("Pistol") then hasPistol = true; end if self.playerActor:HasObject("Compact Assault Rifle") then hasCAR = true; end if self.playerActor:HasObject("Assault Rifle") then hasAR = true; end if self.playerActor:HasObject("Shotgun") then hasShotgun = true; end if self.playerActor:HasObject("Riot Shield") then hasShield = true; end --Keep the player inside the level. if self.playerActor.Pos.X < 0 then self.playerActor.Pos.X = 0; self.playerActor.Vel.X = 0; end if self.playerActor.Pos.X > SceneMan.SceneWidth then self.playerActor.Pos.X = SceneMan.SceneWidth; self.playerActor.Vel.X = 0; end end --Check that the actor isn't inside of a rocket. if MovableMan:IsActor(self.escapeRocket) then if self.escapeRocket:HasObject("Dafred") then playerAlive = true; end end if playerAlive == false and self.eventStage >= 6 then respawns = respawns + 1; self.playerActor = CreateAHuman("Prison Escape Ep2.rte/Dafred"); self.playerActor.Pos = self.playerPos; self.playerActor.HFlipped = self.playerHFlip; self.playerActor:SetAimAngle(self.playerAim); self.playerActor.Team = Activity.TEAM_1; --Give the player their items back. self.playerActor:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Desert Eagle")); if hasPistol then self.playerActor:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Pistol")); end if hasCAR then self.playerActor:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Compact Assault Rifle")); end if hasAR then self.playerActor:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Assault Rifle")); end if hasShotgun then self.playerActor:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Shotgun")); end if hasShield then self.playerActor:AddInventoryItem(CreateHeldDevice("Base.rte/Riot Shield")); end MovableMan:AddActor(self.playerActor); self:SwitchToActor(self.playerActor,Activity.PLAYER_1,Activity.TEAM_1); self.target = self.playerActor; end --After a few seconds, send the dropship hurtling in. if self.eventTimer:IsPastSimMS(2500) and self.eventStage == 0 then self.ship = CreateMOSRotating("Prison Escape Ep2.rte/Ruined Ship"); self.ship.Pos = Vector(0,0); self.ship.RotAngle = math.pi * 1.25; MovableMan:AddParticle(self.ship); self.eventStage = 1; end --Make the dropship land in the desired spot. if MovableMan:IsParticle(self.ship) then if self.ship:GetAltitude(0,0) > 50 then self.ship.Vel = SceneMan:ShortestDistance(self.ship.Pos,Vector(600,550),false); self.ship.Vel = (self.ship.Vel / self.ship.Vel.Largest) * self.shipFallSpeed; elseif self.ship.Vel.Magnitude < 15 and self.ship.Vel.Magnitude > -15 and self.eventStage == 1 then --Pin the ship in place and make a crashing sound. self.ship.PinStrength = 99999; self.ship.Vel = Vector(0,0); self.ship.RotAngle = 3.36; local sound = CreateAEmitter("Prison Escape Ep2.rte/Crash Sound Emitter"); sound.Pos = self.ship.Pos; MovableMan:AddParticle(sound); --Store where the ship landed. self.landingSpot = self.ship.Pos; --Play music. AudioMan:ClearMusicQueue(); AudioMan:PlayMusic("Prison Escape Ep2.rte/Sound/Music/What_It_Feels_Like.ogg", -1, -1); self.eventStage = 2; end --Keep the dropship in place. if self.eventStage >= 2 then self.ship.Pos = self.landingSpot; end --3 door hits. if self.eventTimer:IsPastSimMS(5000) and self.eventStage == 2 then local sound = CreateAEmitter("Prison Escape Ep2.rte/Hit Sound 1 Emitter"); sound.Pos = self.ship.Pos; MovableMan:AddParticle(sound); self.eventStage = 3; end if self.eventTimer:IsPastSimMS(6400) and self.eventStage == 3 then local sound = CreateAEmitter("Prison Escape Ep2.rte/Hit Sound 2 Emitter"); sound.Pos = self.ship.Pos; MovableMan:AddParticle(sound); self.eventStage = 4; end if self.eventTimer:IsPastSimMS(8000) and self.eventStage == 4 then local sound = CreateAEmitter("Prison Escape Ep2.rte/Hit Sound 3 Emitter"); sound.Pos = self.ship.Pos; MovableMan:AddParticle(sound); --Break off the door. local doorPos = Vector(); local doorAng = 0; for i=1,MovableMan:GetMOIDCount()-1 do local mo = MovableMan:GetMOFromID(i); if mo.RootID == self.ship.ID and mo.PresetName == "Ruined Ship Door" then doorPos = mo.Pos; doorAng = mo.RotAngle; ToAttachable(mo):Detach(); end end local door = CreateAttachable("Prison Escape Ep2.rte/Ruined Ship Door"); door.Pos = doorPos; door.RotAngle = doorAng; door.Vel = Vector(-5,2); door.AngularVel = 3; door.GetsHitByMOs = false; MovableMan:AddParticle(door); self.ship.GetsHitByMOs = false; self.eventStage = 5; end --Spawn the player from inside the ship. if self.eventTimer:IsPastSimMS(8300) and self.eventStage == 5 then self.playerActor = CreateAHuman("Prison Escape Ep2.rte/Dafred"); self.playerActor.Pos = self.ship.Pos + Vector(-25,-10); self.playerActor.Vel = Vector(-11,-10); self.playerActor.HFlipped = true; self.playerActor.Team = Activity.TEAM_1; self.playerActor.AIMode = Actor.AIMODE_SENTRY; MovableMan:AddActor(self.playerActor); self.playerActor:SetControllerMode(Controller.CIM_NETWORK,-1); --Move the camera over. self.brain.Pos = self.brain.Pos + Vector(-200,0); self.eventStage = 6; end --Spawn Fiona. if self.eventTimer:IsPastSimMS(9400) and self.eventStage == 6 then self.partner = CreateAHuman("Prison Escape Ep2.rte/Fiona"); self.partner.Pos = self.ship.Pos + Vector(-25,-10); self.partner.Vel = Vector(-10,-10); self.partner.HFlipped = true; self.partner.Team = Activity.TEAM_1; self.partner.AIMode = Actor.AIMODE_SENTRY; MovableMan:AddActor(self.partner); self.partner:SetControllerMode(Controller.CIM_NETWORK,-1); self.eventStage = 7; end --Make Fiona and Dafred not collide. if self.eventStage == 7 then local partsFound = false; for i=1,MovableMan:GetMOIDCount()-1 do local mo = MovableMan:GetMOFromID(i); if mo.RootID == self.partner.ID then partsFound = true; mo:SetWhichMOToNotHit(self.playerActor,-1); elseif mo.RootID == self.playerActor.ID then mo:SetWhichMOToNotHit(self.partner,-1); end end if partsFound then self.eventStage = 8; end end --Spawn Brutus. if self.eventTimer:IsPastSimMS(10100) and self.eventStage == 8 then self.survivor = CreateAHuman("Ronin.rte/Brutus"); self.survivor.Pos = self.ship.Pos + Vector(-25,-10); self.survivor.Vel = Vector(-9,-10); self.survivor.HFlipped = true; self.survivor.Team = Activity.TEAM_1; self.survivor.AIMode = Actor.AIMODE_SENTRY; MovableMan:AddActor(self.survivor); self.survivor:SetControllerMode(Controller.CIM_NETWORK,-1); self.eventStage = 9; end --Explode the ship. if self.eventTimer:IsPastSimMS(11600) and self.eventStage == 9 then --Create the explosives. for i=1,5 do local bomb = CreateTDExplosive("Pineapple Grenade"); bomb.Pos = self.ship.Pos + Vector(-25,-10); bomb.Vel = Vector(0,0); MovableMan:AddParticle(bomb); bomb:GibThis(); end --Make everyone look. for actor in MovableMan.Actors do if actor.ClassName == "AHuman" and actor.Team == Activity.TEAM_1 then actor.HFlipped = false; actor:SetAimAngle(math.pi / 5); actor.Pos.Y = SceneMan:MovePointToGround(actor.Pos,0,0).Y - 10; end end self.eventStage = 10; end end --If Fiona is dead, fail. if self.eventStage >= 7 and self.eventStage <= 71 and MovableMan:IsActor(self.partner) == false then local inShip = false; if MovableMan:IsActor(self.escapeRocket) then if self.escapeRocket:HasObject("Fiona") then inShip = true; end end if inShip == false then self.endMsg = 2; self.WinnerTeam = Activity.TEAM_2; ActivityMan:EndActivity(); end end --If the escape rocket has been destroyed, fail. if self.eventStage <= 70 and MovableMan:IsParticle(self.rocket) == false then self.symbol.ToDelete = true; self.aimer.ToDelete = true; self:SetObservationTarget(Vector(3852,499),Activity.PLAYER_1); self.partner.Pos = Vector(3880,534); self.partner.Health = 0; self.endMsg = 3; self.WinnerTeam = Activity.TEAM_2; ActivityMan:EndActivity(); end if self.eventTimer:IsPastSimMS(12000) and self.eventStage == 10 then --Speech. Speak(self.partner,"Oh god, there were still people in there!",2500); self.eventStage = 11; end if self.eventTimer:IsPastSimMS(15000) and self.eventStage == 11 then --Speech. Speak(self.partner,"...I guess we'll have to go on without them.",2500); --Let the ship settle. self.ship.PinStrength = 0; self.ship.ToSettle = true; --Turn everyone to look at Fiona. self.survivor.HFlipped = true; self.survivor:SetAimAngle(-math.pi / ; self.playerActor:SetAimAngle(math.pi / 6); self.eventStage = 12; end if self.eventTimer:IsPastSimMS(16000) and self.eventStage == 12 then self.pda = CreateHDFirearm("Prison Escape Ep2.rte/PDA"); --Take Fiona's PDA out. self.partner:AddInventoryItem(self.pda); self.partner:SetAimAngle(0); self.eventStage = 13; end if self.eventTimer:IsPastSimMS(18000) and self.eventStage == 13 then --Speech. Speak(self.partner,"According to my PDA, we're right in front of a Coalition outpost.",2500); self.eventStage = 14; end if self.eventTimer:IsPastSimMS(21000) and self.eventStage == 14 then --Speech. Speak(self.partner,"I think they're the ones who shot us down. There has to be a rocket or something in there that we can escape with.",5000); self.eventStage = 15; end if self.eventTimer:IsPastSimMS(26250) and self.eventStage == 15 then --Speech. Speak(self.survivor,"So you're telling me that we need to break into their base?",3000); self.eventStage = 16; end if self.eventTimer:IsPastSimMS(29500) and self.eventStage == 16 then --Speech. Speak(self.partner,"Basically.",1500); self.eventStage = 17; end if self.eventTimer:IsPastSimMS(31250) and self.eventStage == 17 then --Speech. Speak(self.survivor,"The three of us against their entire barracks?",2500); self.eventStage = 18; end if self.eventTimer:IsPastSimMS(34000) and self.eventStage == 18 then --Speech. Speak(self.partner,"Well... Yeah.",1500); --Remove the PDA. self.pda.ToDelete = true; self.partner:SetAimAngle(math.pi / ; self.eventStage = 19; end if self.eventTimer:IsPastSimMS(35750) and self.eventStage == 19 then --Speech. Speak(self.survivor,"No turning back, nobody to save us, and a good chance that at least one of us will die?",4000); self.eventStage = 20; end if self.eventTimer:IsPastSimMS(40000) and self.eventStage == 20 then --Speech. Speak(self.partner,"Look, if you've got a better plan, then-",1000); self.eventStage = 21; end if self.eventTimer:IsPastSimMS(41100) and self.eventStage == 21 then --Speech. Speak(self.survivor,"AWESOME! I'm going in.",2000); self.survivor:SetAimAngle(0); self.sGun = CreateHDFirearm("Prison Escape Ep2.rte/YAK47"); self.survivor:AddInventoryItem(self.sGun); self.eventStage = 22; end if self.eventStage >= 22 and self.eventStage < 26 then if self.survivor.Pos.X < 800 then self.survivor:GetController():SetState(Controller.MOVE_RIGHT,true); if self.survivor.Pos.X > 450 and self.survivor.Pos.X < 600 then self.survivor:GetController():SetState(Controller.BODY_JUMP,true); end if self.survivor.Vel.Magnitude < 0.5 and self.survivor.Vel.Magnitude > -0.5 then self.survivor.Pos.Y = self.survivor.Pos.Y - 1; end else self.survivor.HFlipped = true; self.survivor.Pos.X = 800; self.survivor.Vel.X = 0; end end if self.eventTimer:IsPastSimMS(43250) and self.eventStage == 22 then --Speech. Speak(self.partner,"Brutus, wait!",2000); self.eventStage = 23; end if self.eventTimer:IsPastSimMS(45500) and self.eventStage == 23 then --Speech. Speak(self.partner,"What an idiot. We should probably follow him before he gets himself killed.",3000); self.partner.HFlipped = true; self.partner:SetAimAngle(-math.pi / ; self.eventStage = 24; end if self.eventTimer:IsPastSimMS(48750) and self.eventStage == 24 then --Speech. Speak(self.partner,"Brutus, slow down!",2000); self.partner:SetAimAngle(0); self:SwitchToActor(self.playerActor,Activity.PLAYER_1,Activity.TEAM_1); self.target = self.playerActor; self.targetMode = Controller.CIM_PLAYER; self.eventStage = 25; end if self.eventStage == 25 then if self.playerActor.Pos.X > 575 then self.playerActor.Pos.X = 575; self.playerActor.Vel.X = 0; end if self.partner.Pos.X > 450 and self.partner.Pos.X < 525 then self.partner:GetController():SetState(Controller.BODY_JUMP,true); end if self.partner.Pos.X < 650 then self.partner:GetController():SetState(Controller.MOVE_RIGHT,true); end if self.partner.Vel.Magnitude < 0.5 and self.partner.Vel.Magnitude > -0.5 then self.partner.Pos.Y = self.partner.Pos.Y - 1; end --Once everyone is in place... if self.partner.Pos.X > 625 and self.survivor.Pos.X > 775 and self.playerActor.Pos.X > 560 and self.eventStage == 25 then --Stop controlling the player for a moment. self.playerActor:SetControllerMode(Controller.CIM_NETWORK,-1); self.targetMode = Controller.CIM_NETWORK; self.playerActor.Vel.X = 0; --Speech. Speak(self.partner,"Brutus, wait for us! You can't possibly take them all down by yourself!",3000); self.partner:SetAimAngle(math.pi / ; --Make Brutus look at Fiona. self.survivor:SetAimAngle(-math.pi / ; self.survivor.HFlipped = true; self.survivor.Pos.Y = SceneMan:MovePointToGround(self.survivor.Pos,0,0).Y - 10; --Restart the timer's counting again. self.eventTimer:Reset(); self.eventStage = 26; end end if self.eventStage == 25 or self.eventStage == 26 then if self.partner.Pos.X > 650 then self.partner.Vel.X = 0; self.partner.Pos.X = 650; end end if self.eventStage >= 26 and self.eventStage <= 31 then --Turn the player to face them. self.playerActor.HFlipped = false; end if self.eventTimer:IsPastSimMS(3250) and self.eventStage == 26 then Speak(self.survivor,"Pff, you guys are too slow. Besides, this'll be a piece of cake.",3000); self.eventStage = 27; end if self.eventTimer:IsPastSimMS(6500) and self.eventStage == 27 then Speak(self.survivor,"Watch and learn, you wuss. I'll walk all ov-",1000); self.survivor.HFlipped = false; self.survivor:SetAimAngle(0); self.eventStage = 28; end if self.eventTimer:IsPastSimMS(7500) and self.eventStage == 28 then --Fire a shot to kill Brutus. self.killRifle = CreateHDFirearm("Prison Escape Ep2.rte/Hyper-Accurate HSR"); self.killRifle.HFlipped = true; self.killRifle.Pos = self.survivor.Pos + Vector(500,-16); self.killRifle.PinStrength = 10000; MovableMan:AddItem(self.killRifle); self.killRifle:Activate(); self.eventStage = 29; end if self.eventStage == 29 and MovableMan:IsActor(self.survivor) then --Keep Brutus from flying back. self.survivor.Vel = Vector(0,0); end if MovableMan:IsActor(self.survivor) == false and self.eventStage == 29 then Speak(self.partner,"WOAH! Get down!",1250); --Don't count this death. self:ReportDeath(Activity.TEAM_1,-1); --Remove the gun. self.killRifle.ToDelete = true; --If Brutus' gun is still around, make sure it isn't any longer. if MovableMan:IsDevice(self.sGun) then self.sGun.ToSettle = true; end --Let Brutus die. self.survivor.PinStrength = 0; self.eventTimer:Reset(); self.eventStage = 30; end if self.eventStage == 30 then self.partner:GetController():SetState(Controller.BODY_CROUCH,true); self.partner:GetController():SetState(Controller.MOVE_RIGHT,true); self.playerActor:GetController():SetState(Controller.BODY_CROUCH,true); self.playerActor:GetController():SetState(Controller.MOVE_RIGHT,true); end if self.eventTimer:IsPastSimMS(1510) and self.eventStage == 30 then Speak(self.partner,"I knew it. Guard robots. Dammit, Brutus, we needed you...",4000); self.partner.Pos.Y = SceneMan:MovePointToGround(self.partner.Pos,0,0).Y - 10; self.partner:GetController():SetState(Controller.MOVE_RIGHT,true); self.playerActor:GetController():SetState(Controller.MOVE_RIGHT,true); self.eventStage = 31; end if self.eventTimer:IsPastSimMS(6000) and self.eventStage == 31 then Speak(self.partner,"I wonder what kind of network connection they're on. Let's see...",4000); --Take Fiona's PDA out. self.pda = CreateHDFirearm("Prison Escape Ep2.rte/PDA"); self.partner:AddInventoryItem(self.pda); self.partner:SetAimAngle(0); self.eventStage = 32; end if self.eventTimer:IsPastSimMS(10250) and self.eventStage == 32 then Speak(self.partner,"...You're kidding me. Their password is \"password\". Their firmware is out of date, too.",4000); self.eventStage = 33; end if self.eventTimer:IsPastSimMS(16000) and self.eventStage == 33 then --Kill the robots. for actor in MovableMan.Actors do if actor.PresetName == "Robot 2" then actor.Health = 0; actor.Vel = Vector(math.random() * 2 - 1,math.random() * 2 - 1); --Don't count this death. self:ReportDeath(Activity.TEAM_1,-1); end end --Open the door. for actor in MovableMan.Actors do if actor.ClassName == "ADoor" and actor.Pos.X < 1850 then actor.Team = Activity.TEAM_1; end end Speak(self.partner,"Okay, their front guard robots are disabled. The rest of their security is out of range.",4000); self.eventStage = 34; end if self.eventTimer:IsPastSimMS(20250) and self.eventStage == 34 then Speak(self.partner,"Let's get going. They'll be after us in no time now that their front entrance is wide open.",4000); --Look at Dafred. self.partner.HFlipped = true; --Put away the pda. self.pda.ToDelete = true; --Give Fiona her weapons. self.pistolA = CreateHDFirearm("Prison Escape Ep2.rte/Amazon Pistol (Offhand)"); self.partner:AddInventoryItem(self.pistolA); --Give the player a weapon. self.playerActor:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Desert Eagle")); --Switch control to Dafred again. self:SwitchToActor(self.playerActor,Activity.PLAYER_1,Activity.TEAM_1); self.targetMode = Controller.CIM_PLAYER; self.eventStage = 35; end if self.eventTimer:IsPastSimMS(20500) and self.eventStage == 35 then --Equip Fiona's second pistol. self.partner.HFlipped = true; self.pistolB = CreateHDFirearm("Prison Escape Ep2.rte/Amazon Pistol"); self.partner:AddInventoryItem(self.pistolB); self.partner:GetController():SetState(Controller.WEAPON_CHANGE_PREV,true); self.partner:SetAimAngle(-0.1); self.eventStage = 36; end if self.eventTimer:IsPastSimMS(22000) and self.eventStage == 36 then if self.partner.Pos.X < 1734 then self.partner:GetController():SetState(Controller.MOVE_RIGHT,true); else self.partner.HFlipped = true; end if (self.partner.Pos.X > 750 and self.partner.Pos.X < 775) or (self.partner.Pos.X > 1450 and self.partner.Pos.X < 1500) then self.partner:GetController():SetState(Controller.BODY_JUMP,true); end if self.partner.Vel.Magnitude < 0.5 and self.partner.Vel.Magnitude > -0.5 then self.partner.Pos.Y = self.partner.Pos.Y - 1; end if self.playerActor.Pos.X > 1680 then self.playerActor.Vel.X = 0; self.playerActor.Pos.X = 1680; end if self.playerActor.Pos.Y < 310 and self.playerActor.Pos.X > 1412 then self.playerActor.Pos.X = 1412; self.playerActor.Vel.X = 0; end if self.partner.Pos.X > 1734 and self.playerActor.Pos.X > 1640 then --Stop controlling the player. self.playerActor:SetControllerMode(Controller.CIM_NETWORK,-1); self.targetMode = Controller.CIM_NETWORK; --Speech Speak(self.partner,"I'm going to see what's behind this door. Cover me.",4000); self.partner.HFlipped = true; self.playerActor.HFlipped = false; self.playerActor:SetAimAngle(0); self.eventTimer:Reset(); self.eventStage = 37; end end if self.eventStage == 37 and self.eventTimer:IsPastSimMS(4000) then self.partner:GetController():SetState(Controller.MOVE_RIGHT,true); if self.partner.Vel.Magnitude < 0.5 and self.partner.Vel.Magnitude > -0.5 then self.partner.Pos.Y = self.partner.Pos.Y - 1; end if self.partner.Pos.X > 1875 then --Close the doors again. for actor in MovableMan.Actors do if actor.ClassName == "ADoor" and actor.Pos.X > 1750 and actor.Pos.X < 1850 then actor.Team = Activity.TEAM_2; end end self.eventTimer:Reset(); self.eventStage = 38; end end if self.eventStage == 38 and self.eventTimer:IsPastSimMS(1000) then self.partner.HFlipped = true; Speak(self.partner,"Unless you just shut that door, I'd say that they know we're here now.",4000); self.eventStage = 39; end if self.eventStage == 39 and self.eventTimer:IsPastSimMS(5250) then self.partner.HFlipped = true; Speak(self.partner,"I guess I won't be coming back out that way. You check the other path, I'll take this portal.",4000); self.eventStage = 40; end if self.eventStage == 40 and self.eventTimer:IsPastSimMS(9500) then self.partner.HFlipped = true; Speak(self.partner,"Good luck. Let's make sure the others' deaths weren't in vain.",4000); self.eventStage = 41; end if self.eventStage == 41 and self.eventTimer:IsPastSimMS(13750) then self.partner:GetController():SetState(Controller.MOVE_RIGHT,true); if self.partner.Vel.Magnitude < 0.5 and self.partner.Vel.Magnitude > -0.5 then self.partner.Pos.Y = self.partner.Pos.Y - 1; end if self.partner.Pos.X > 2200 then --Switch control to Dafred again. self:SwitchToActor(self.playerActor,Activity.PLAYER_1,Activity.TEAM_1); self.targetMode = Controller.CIM_PLAYER; --Play music. AudioMan:ClearMusicQueue(); AudioMan:PlayMusic("Prison Escape Ep2.rte/Sound/Music/Mind_Stalker.ogg", -1, -1); self.eventStage = 42; end end if self.eventStage >= 42 then --Disable the teleporter. cantele[1]:Reset(); end if self.eventStage == 42 and MovableMan:IsActor(self.soldier1) == false then --Spawn the dropship with troops in it. self.enemyDropShip = CreateACDropShip("Prison Escape Ep2.rte/Drop Ship MK1 Slowspawn"); self.enemyDropShip.Pos = Vector(1740,0); self.enemyDropShip:SetControllerMode(Controller.CIM_NETWORK,-1); self.enemyDropShip.Team = Activity.TEAM_2; self.attacker1 = CreateAHuman("Prison Escape Ep2.rte/Soldier Light"); self.attacker1:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Pistol")); self.attacker1.Team = Activity.TEAM_2; self.attacker1:SetControllerMode(Controller.CIM_NETWORK,-1); self.attacker1.AIMode = Actor.AIMODE_GOTO; self.attacker1:AddAISceneWaypoint(Vector(2144,550)); self.enemyDropShip:AddInventoryItem(self.attacker1); self.attacker2 = CreateAHuman("Prison Escape Ep2.rte/Soldier Light"); self.attacker2:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Pistol")); self.attacker2.Team = Activity.TEAM_2; self.attacker2:AddInventoryItem(CreateHeldDevice("Prison Escape Ep2.rte/Riot Shield")); self.attacker2:SetControllerMode(Controller.CIM_NETWORK,-1); self.attacker2.AIMode = Actor.AIMODE_GOTO; self.attacker2:AddAISceneWaypoint(Vector(2144,550)); self.enemyDropShip:AddInventoryItem(self.attacker2); self.attacker3 = CreateAHuman("Prison Escape Ep2.rte/Soldier Heavy"); self.attacker3:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Compact Assault Rifle")); self.attacker3.Team = Activity.TEAM_2; self.attacker3:SetControllerMode(Controller.CIM_NETWORK,-1); self.attacker3.AIMode = Actor.AIMODE_GOTO; self.attacker3:AddAISceneWaypoint(Vector(2144,550)); self.enemyDropShip:AddInventoryItem(self.attacker3); MovableMan:AddActor(self.enemyDropShip); self.eventStage = 43; end if self.eventStage == 43 or self.eventStage == 44 then self.enemyDropShip.Pos.X = 1740; end --Lower the dropship. if self.eventStage == 43 then self.enemyDropShip:GetController():SetState(Controller.MOVE_DOWN,true); if self.enemyDropShip.Pos.Y > 150 then self.enemyDropShip:GetController():SetState(Controller.PRESS_FACEBUTTON,true); self.enemyDropShip:GetController():SetState(Controller.MOVE_DOWN,false); self.eventStage = 44; end end --Let the actors come out. if self.eventStage == 44 then if self.enemyDropShip.Pos.Y > 200 then self.enemyDropShip:GetController():SetState(Controller.MOVE_UP,true); end if MovableMan:IsActor(self.attacker1) and MovableMan:IsActor(self.attacker2) and MovableMan:IsActor(self.attacker3) then self.enemyDropShip:GetController():SetState(Controller.PRESS_FACEBUTTON,true); self.eventStage = 45; end end --Make the actors move. if self.eventStage == 44 or self.eventStage == 45 then if MovableMan:IsActor(self.attacker1) then if self.attacker1:GetController().InputMode == Controller.CIM_NETWORK then self.attacker1:GetController():SetState(Controller.MOVE_RIGHT,true); if self.attacker1.Pos.X > 1968 then self.attacker1:SetControllerMode(Controller.CIM_AI,-1); end end end if MovableMan:IsActor(self.attacker2) then if self.attacker2:GetController().InputMode == Controller.CIM_NETWORK then self.attacker2:GetController():SetState(Controller.MOVE_RIGHT,true); if self.attacker2.Pos.X > 1968 then self.attacker2:SetControllerMode(Controller.CIM_AI,-1); end end end if MovableMan:IsActor(self.attacker3) then if self.attacker3:GetController().InputMode == Controller.CIM_NETWORK then self.attacker3:GetController():SetState(Controller.MOVE_RIGHT,true); if self.attacker3.Pos.X > 1968 then self.attacker3:SetControllerMode(Controller.CIM_AI,-1); end end end end --Take off again. if self.eventStage == 45 then if MovableMan:IsActor(self.enemyDropShip) then self.enemyDropShip:GetController():SetState(Controller.MOVE_UP,true); end --If the player has killed all the enemies, let the shields down. if (MovableMan:IsActor(self.attacker1) == false or self.attacker1.PresetName == "Dafred") and (MovableMan:IsActor(self.attacker2) == false or self.attacker2.PresetName == "Dafred") and (MovableMan:IsActor(self.attacker3) == false or self.attacker1.PresetName == "Dafred") then self.shield2.ToDelete = true; self.shield3.ToDelete = true; self.eventStage = 46; end end if self.eventStage == 46 and (MovableMan:IsActor(self.soldier3) == false or self.soldier3.PresetName == "Dafred") then self.dropCrate = CreateACRocket("Dummy.rte/Drop Crate"); self.dropCrate.Pos = Vector(2796,0); self.dropCrate.Team = Activity.TEAM_2; local attacker4 = CreateAHuman("Prison Escape Ep2.rte/Soldier Light"); attacker4.Team = Activity.TEAM_2; attacker4.AIMode = Actor.AIMODE_PATROL; attacker4:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Pistol")); self.dropCrate:AddInventoryItem(attacker4); local attacker5 = CreateAHuman("Prison Escape Ep2.rte/Soldier Light"); attacker5.Team = Activity.TEAM_2; attacker5.AIMode = Actor.AIMODE_PATROL; attacker5:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Pistol")); self.dropCrate:AddInventoryItem(attacker5); local attacker6 = CreateAHuman("Prison Escape Ep2.rte/Soldier Light"); attacker6.Team = Activity.TEAM_2; attacker6.AIMode = Actor.AIMODE_PATROL; attacker6:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Pistol")); self.dropCrate:AddInventoryItem(attacker6); MovableMan:AddActor(self.dropCrate); self.eventStage = 47; end if MovableMan:IsActor(self.dropCrate) then self.dropCrate.RotAngle = math.pi; end if self.eventStage == 47 then --Keep the crate moving down. self.dropCrate.Vel.Y = 15; --Break the doors off. if self.dropCrate.Pos.Y > 240 then for actor in MovableMan.Actors do if actor.PresetName == "Door Rotate Short" and actor.Pos.X > 2711 and actor.Pos.X < 2855 then actor:GibThis(); --Don't count this death. self:ReportDeath(Activity.TEAM_2,-1); self.eventStage = 48; end end end end if self.eventStage == 48 then --If the player has killed all the guards and is in the room... if (MovableMan:IsActor(self.soldier4) == false or self.soldier4.PresetName == "Dafred") and (MovableMan:IsActor(self.soldier5) == false or self.soldier5.PresetName == "Dafred") then if self.playerActor.Pos.X > 3318 then --Lose control momentarily. self.playerActor:SetControllerMode(Controller.CIM_NETWORK,-1); self.targetMode = Controller.CIM_NETWORK; self.playerActor.HFlipped = false; self.playerActor:SetAimAngle(math.pi - point_direction_vec(self.playerActor.Pos,self.enemyBrain.Pos)); self.enemyBrain.GetsHitByMOs = true; Speak(self.enemyBrain,"Don't even think about it. That would be a very bad move.",4000); --Stop music. AudioMan:ClearMusicQueue(); AudioMan:StopMusic(); self.eventTimer:Reset(); self.eventStage = 49; end end end if self.eventStage == 49 and self.eventTimer:IsPastSimMS(4250) then Speak(self.enemyBrain,"Let's put it this way - if you kill me, the whole Coalition army will be after you.",5000); self.eventStage = 50; end if self.eventStage == 50 and self.eventTimer:IsPastSimMS(10250) then Speak(self.enemyBrain,"You're already on their wanted list. Don't make it any worse for yourself.",5000); self.eventStage = 51; end if self.eventStage == 51 and self.eventTimer:IsPastSimMS(15500) then Speak(self.enemyBrain,"Now, put down the gun.",2000); self.eventStage = 52; end if self.eventStage == 52 and self.eventTimer:IsPastSimMS(19750) then self.disarmed = CreateHeldDevice("Disarmed"); self.playerActor:AddInventoryItem(self.disarmed); self.playerActor:GetController():SetState(Controller.WEAPON_CHANGE_PREV,true); self.eventStage = 53; end if self.eventStage == 53 and self.eventTimer:IsPastSimMS(20000) then Speak(self.enemyBrain,"Good. Now, I happen to know that you have a friend with you. She's in the next room over.",5000); self.eventStage = 54; end if self.eventStage == 54 and self.eventTimer:IsPastSimMS(25250) then Speak(self.enemyBrain,"After the stunt she pulled off, helping you escape from the prison,",4000); self.eventStage = 55; end if self.eventStage == 55 and self.eventTimer:IsPastSimMS(29500) then Speak(self.enemyBrain,"she has quite a bounty on her head. So, I'll make you a deal.",4000); self.eventStage = 56; end if self.eventStage == 56 and self.eventTimer:IsPastSimMS(34750) then Speak(self.enemyBrain,"Leave her with my guards, and I'll let you go, scot-free. Nobody will know you were here.",5000); self.eventStage = 57; end if self.eventStage == 57 and self.eventTimer:IsPastSimMS(40000) then Speak(self.enemyBrain,"She won't even know you left her. I'll let you right out with that rocket.",5000); self.eventStage = 58; end if self.eventStage == 58 and self.eventTimer:IsPastSimMS(45250) then self.disarmed.ToDelete = true; self.eventStage = 59; end if self.eventStage == 59 and self.eventTimer:IsPastSimMS(45500) then self.newDeagle = CreateHDFirearm("Prison Escape Ep2.rte/Desert Eagle"); self.playerActor:AddInventoryItem(self.newDeagle); self.playerActor:GetController():SetState(Controller.WEAPON_CHANGE_PREV,true); self.playerActor:SetAimAngle(math.pi - point_direction_vec(self.playerActor.Pos,self.enemyBrain.Pos)); self.eventStage = 60; end if self.eventStage == 60 and self.eventTimer:IsPastSimMS(45750) then self.playerActor:GetController():SetState(Controller.WEAPON_FIRE,true); --Play music. AudioMan:ClearMusicQueue(); AudioMan:PlayMusic("Prison Escape Ep2.rte/Sound/Music/Plucked_From_Space.ogg", -1, -1); self.eventStage = 61; end if self.eventStage == 61 and self.eventTimer:IsPastSimMS(46000) then Speak(self.enemyBrain,"AUGH, MY BRAIN! You'll pay for that!",1500); self.eventStage = 62; end if self.eventStage == 62 and self.eventTimer:IsPastSimMS(48000) then self.enemyBrain.Pos.Y = self.enemyBrain.Pos.Y - 0.5; if self.enemyBrain.Pos.Y < 288 then self.ePos = Vector(self.enemyBrain.Pos.X,self.enemyBrain.Pos.Y); self.enemyBrain.ToDelete = true; --Don't count this death. self:ReportDeath(Activity.TEAM_2,-1); --Make the brain into a rocket. self.enemyBrain = CreateACRocket("Prison Escape Ep2.rte/Brain Rocket"); self.enemyBrain.Pos = self.ePos; self.enemyBrain.Team = Activity.TEAM_2; self.enemyBrain.PinStrength = 9999; MovableMan:AddActor(self.enemyBrain); self.enemyBrain:EraseFromTerrain(); self.eventStage = 63; end end if self.eventStage == 63 then if MovableMan:IsActor(self.enemyBrain) then self.enemyBrain.Pos.X = self.ePos.X; self.enemyBrain.RotAngle = 0; if self.enemyBrain.Pos.Y > 240 then self.enemyBrain.Pos.Y = self.enemyBrain.Pos.Y - 0.5; else self.enemyBrain.PinStrength = 0; self.enemyBrain:GetController():SetState(Controller.MOVE_UP,true); end else self.eventStage = 64; self:SwitchToActor(self.playerActor,Activity.PLAYER_1,Activity.TEAM_1); self.targetMode = Controller.CIM_PLAYER; self.newDeagle.ToDelete = true; self.playerActor:GetController():SetState(Controller.WEAPON_CHANGE_PREV,true); end end if self.eventStage == 64 then if self.playerActor.Pos.X > 3760 then Speak(self.symbol,"Dafred! Thank goodness you're still alive. We have a bit of a problem.",4000); checkpoint = true; self.eventStage = 65; self.eventTimer:Reset(); end end if self.eventStage == 65 and self.eventTimer:IsPastSimMS(4250) then Speak(self.symbol,"That room over there is their cloning station. I heard it starting up a few minutes back.",4000); self.eventStage = 66; end if self.eventStage == 66 and self.eventTimer:IsPastSimMS(8500) then Speak(self.symbol,"Our escape rocket here has a busted thruster. I can fix it, but I need time.",4000); self.eventStage = 67; end if self.eventStage == 67 and self.eventTimer:IsPastSimMS(12750) then Speak(self.symbol,"You look like you're in rough shape, but if you can hold them off for just a moment,",4000); self.eventStage = 68; end if self.eventStage == 68 and self.eventTimer:IsPastSimMS(17000) then Speak(self.symbol,"I can get this thing in working condition and we can get the hell out of here.",4000); --Turn on the emitters. self.cloneTube:EnableEmission(true); self.gunMaker:EnableEmission(true); self.shieldMaker:EnableEmission(true); self.eventStage = 69; end if self.eventStage == 69 and self.eventTimer:IsPastSimMS(21250) then Speak(self.symbol,"Crap, here they come! Get ready!",4000); self.rocket:EnableEmission(true); --Play music. AudioMan:ClearMusicQueue(); AudioMan:PlayMusic("Prison Escape Ep2.rte/Sound/Music/HyperReactive.ogg", -1, -1); --Start the timer. self.escapeTimer = Timer(); self.eventStage = 70; end if self.eventStage >= 70 and self.eventStage < 72 then --Control new clones. for actor in MovableMan.Actors do if actor.Team == Activity.TEAM_2 then --Make them exit the room. if self.spawnRoom:IsInside(actor.Pos) then actor:SetControllerMode(Controller.CIM_NETWORK,-1); actor:GetController():SetState(Controller.MOVE_RIGHT,true); actor:GetController():SetState(Controller.WEAPON_PICKUP,true); --If the actor hasn't equipped its pistol, do so. if actor:Inventory() ~= nil then if actor:Inventory().PresetName == "Pistol" then actor:GetController():SetState(Controller.WEAPON_CHANGE_PREV,true); end end elseif actor.Pos.X < 3750 and actor.Pos.Y > 500 and actor:GetController().InputMode == Controller.CIM_NETWORK then --Make them continue to walk forward and aim at the rocket. if MovableMan:IsParticle(self.rocket) then actor:SetAimAngle(math.pi - point_direction_vec(actor.Pos,self.rocket.Pos)); end actor:GetController():SetState(Controller.MOVE_RIGHT,true); --Fire periodically. if self.shootTimer:IsPastSimMS(self.shootTime + 100) then self.shootTimer:Reset(); elseif self.shootTimer:IsPastSimMS(self.shootTime) then actor:GetController():SetState(Controller.WEAPON_FIRE,true); else actor:GetController():SetState(Controller.WEAPON_FIRE,false); end else --Turn AI on again. actor:SetControllerMode(Controller.CIM_AI,-1); --Keep them down. if actor.Pos.Y < 575 then actor.Pos.Y = 575; actor.Vel.Y = 0; end end end end --Display the time. if self.eventTimer:IsPastSimMS(21000) then FrameMan:SetScreenText(math.floor(self.escapeTimer:LeftTillSimMS(34000) / 1000) .. " SECONDS LEFT!", Activity.PLAYER_1, 0, 1, false); end end if self.eventStage == 70 and self.escapeTimer:IsPastSimMS(34000) then --Activate the rocket. self.rocket.ToDelete = true; self.escapeRocket = CreateACRocket("Base.rte/Rocket MK2"); self.escapeRocket.PinStrength = 99999; self.escapeRocket.Pos = Vector(3854,506); self.escapeRocket.Team = Activity.TEAM_1; self.escapeRocket.GetsHitByMOs = false; self.escapeRocket:SetControllerMode(Controller.CIM_NETWORK,-1); self.escapeRocket.RotAngle = 0; MovableMan:AddActor(self.escapeRocket); self.escapeRocket:GetController():SetState(Controller.PRESS_FACEBUTTON,true); --Add Fiona back. self.partner.Pos = self.symbol.Pos + Vector(20,10); self.partner.HFlipped = true; self.symbol.ToDelete = true; self.aimer.ToDelete = true; Speak(self.partner,"Okay, it's all patched up! Get in, quick!",1500); self.eventStage = 71; self.eventTimer:Reset(); end if self.eventStage == 71 then self.escapeRocket.RotAngle = 0; if self.eventTimer:IsPastSimMS(1500) then if MovableMan:IsActor(self.partner) then self.partner:GetController():SetState(Controller.BODY_JUMP,true); if self.partner.Pos.X < 3850 then self.partner.Pos.X = 3850; self.partner.Vel.X = 0; end end end if self.escapeRocket:HasObject("Dafred") and self.escapeRocket:HasObject("Fiona") then self.escapeRocket.PinStrength = 0; self.eventStage = 72; end end if self.eventStage == 72 then if MovableMan:IsActor(self.escapeRocket) then self.escapeRocket:GetController():SetState(Controller.MOVE_UP,true); self.target = self.escapeRocket; self.targetMode = Controller.CIM_NETWORK; self.escapeRocket.Pos.X = 3852; self.escapeRocket.RotAngle = 0; end end end --Objective markers. self:ClearObjectivePoints(); if self.eventStage == 25 then self:AddObjectivePoint("Follow Brutus!",self.survivor.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); end if self.eventStage == 36 and MovableMan:IsActor(self.partner) then self:AddObjectivePoint("Follow Fiona!",self.partner.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); end if self.eventStage == 42 then if self.playerActor.Pos.X < 1980 then self:AddObjectivePoint("Continue ahead!",Vector(2122,560),Activity.TEAM_1,GameActivity.ARROWDOWN); elseif MovableMan:IsActor(self.soldier1) then self:AddObjectivePoint("Kill!",self.soldier1.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); end end if self.eventStage == 45 then if MovableMan:IsActor(self.attacker1) and self.attacker1.PresetName ~= "Dafred" then self:AddObjectivePoint("Kill!",self.attacker1.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); end if MovableMan:IsActor(self.attacker2) and self.attacker2.PresetName ~= "Dafred" then self:AddObjectivePoint("Kill!",self.attacker2.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); end if MovableMan:IsActor(self.attacker3) and self.attacker3.PresetName ~= "Dafred" then self:AddObjectivePoint("Kill!",self.attacker3.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); end end if self.eventStage == 46 then if self.playerActor.Pos.X < 2600 then self:AddObjectivePoint("Continue ahead!",Vector(2800,565),Activity.TEAM_1,GameActivity.ARROWDOWN); else self:AddObjectivePoint("Kill!",self.soldier3.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); end end if self.eventStage == 48 then if self.playerActor.Pos.X < 3125 then self:AddObjectivePoint("Go for the brain!",self.enemyBrain.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); else local soldiers = false; if MovableMan:IsActor(self.soldier4) and self.soldier4.PresetName ~= "Dafred" then self:AddObjectivePoint("Kill!",self.soldier4.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); soldiers = true; end if MovableMan:IsActor(self.soldier5) and self.soldier5.PresetName ~= "Dafred" then self:AddObjectivePoint("Kill!",self.soldier5.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); soldiers = true; end if soldiers == false then self:AddObjectivePoint("Walk up to the brain!",self.enemyBrain.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); end end end if self.eventStage == 64 and MovableMan:IsActor(self.symbol) then self:AddObjectivePoint("Get to Fiona!",self.symbol.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); end if self.eventStage == 70 and MovableMan:IsActor(self.aimer) then self:AddObjectivePoint("Protect!",self.aimer.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); end if self.eventStage == 71 then self:AddObjectivePoint("Get in!",self.escapeRocket.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); end self:YSortObjectivePoints(); end function PrisonEscapeMission2:PauseActivity() end function PrisonEscapeMission2:EndActivity() --If the player won the level... if self.endMsg == 1 then self:ResetMessageTimer(Activity.PLAYER_1); FrameMan:ClearScreenText(Activity.PLAYER_1); FrameMan:SetScreenText("FIONA: Nice work! That was a close call. I'm plotting a course back to the base.", Activity.PLAYER_1, 0, 5000, false); checkpoint = nil; elseif self.endMsg == 2 then self:ResetMessageTimer(Activity.PLAYER_1); FrameMan:ClearScreenText(Activity.PLAYER_1); FrameMan:SetScreenText("Fiona is dead. You have no pilot to escape with. Mission failed.", Activity.PLAYER_1, 0, 5000, false); elseif self.endMsg == 3 then self:ResetMessageTimer(Activity.PLAYER_1); FrameMan:ClearScreenText(Activity.PLAYER_1); FrameMan:SetScreenText("Your escape ship is destroyed - you have no way of leaving the base. Mission failed.", Activity.PLAYER_1, 0, 5000, false); end end function PrisonEscapeMission2:CraftEnteredOrbit() --If the end stage has been reached... if self.eventStage == 72 then if self.OrbitedCraft:HasObject("Dafred") and self.OrbitedCraft:HasObject("Fiona") then --Win! self.endMsg = 1; self.WinnerTeam = Activity.TEAM_1; ActivityMan:EndActivity(); self.brain.Pos = Vector(3852,0); end end end Well, 1651 lines. Sorry for these 3 continuous replies, but the code's too long that it reach the limit of one post. |
Author: | zoidberg [ Mon May 16, 2011 9:32 pm ] |
Post subject: | Re: What is the longest lua script you've ever written for CC? |
mine is only 133 lines, including tons of "print" Code: function Create(self) self.atimer = Timer() self.btimer = Timer() self.ctimer = Timer() for i = 1, MovableMan:GetMOIDCount()-1 do if MovableMan:GetMOFromID(i).RootID == self.ID and i ~= self.ID then self.att = MovableMan:GetMOFromID(i) if self.att.ClassName == "HDFirearm" then self.gun = ToHDFirearm(self.att) -- print("gun name = "..self.gun.PresetName) end end end self.PresetName = "Artillery 1" self.mode = 1 self.land = false self:SetAimAngle(math.pi/2) end function Update(self) local cont = self:GetController() cont:SetState(Controller.MOVE_RIGHT, false) cont:SetState(Controller.MOVE_LEFT, false) local terrcheck = Vector(0,0) if not self.land and SceneMan:CastStrengthRay(self.Pos,Vector(0,20),0,terrcheck,0,0,true) then self.Vel = self.Vel * 0.4 -- add some cool anti-gravity - looking effect under self. --[[ local el = CreateAEmitter("Landing Emitter Left") el.Pos = self.Pos + Vector(-5, 5):RadRotate(self.RotAngle) MovableMan:AddMO(el) local er = CreateAEmitter("Landing Emitter Right") er.Pos = self.Pos + Vector(5, 5):RadRotate(self.RotAngle) MovableMan:AddMO(er) ]] if self.Frame < self.FrameCount - 3 then self:SetAimAngle(math.pi/2) if self.ctimer:IsPastSimMS(400) then self.Frame = self.Frame + 1 self.ctimer:Reset() self.Pos = self.Pos + Vector(0, -1):RadRotate(self.RotAngle) end end if self.Frame >= self.FrameCount - 3 then self.land = true end end if cont:IsState(Controller.BODY_JUMPSTART) and self.atimer:IsPastSimMS(2000) then if self.PresetName == "Artillery 1" then self.PresetName = "Artillery 2" self.mode = 1 local sfx = CreateAEmitter("Ammo Change Emitter") sfx.Pos = self.Pos MovableMan:AddParticle(sfx) self.atimer:Reset() self.Frame = self.FrameCount - 2 else self.PresetName = "Artillery 1" self.mode = -1 local sfx = CreateAEmitter("Ammo Change Emitter") sfx.Pos = self.Pos MovableMan:AddParticle(sfx) self.atimer:Reset() self.Frame = self.FrameCount - 1 end end if not cont:IsPlayerControlled(-1) then self:SetControllerMode(Controller.CIM_DISABLED, -1) -- self.Status = 2 if self.btimer:IsPastSimMS(2000) then for actor in MovableMan.Actors do -- print("some actors") if actor.Team ~= self.Team and actor.ClassName ~= "ADoor" and actor.ClassName ~= "ACraft" then -- print("enemies") local grav = SceneMan.GlobalAcc.Y local vel = 30 local xd = (actor.Pos.X - self.gun.Pos.X) / FrameMan.PPM -- print("delta x = "..xd) local yd = (actor.Pos.Y - self.gun.Pos.Y) / FrameMan.PPM -- print("delta y = "..yd) local avg = yd / 2 -- print("average height = "..avg) -- print("firemode = "..self.mode) -- print("vars set") local alpha = math.atan(((vel ^ 2) + (self.mode * (((vel ^ 4) - (grav ^ 2) * (xd ^ 2) - (2 * grav * yd * (vel ^ 2))) ^ 0.5))) / (grav * xd)) -- print(type(alpha)) -- print("check actual aim angle = "..alpha) -- print("checking angle") if alpha <= math.pi and alpha >= 0 then -- print("angle is good") local ptime = ((vel * math.sin(alpha)) + math.sqrt((((vel * math.sin(alpha)) ^ 2) + (2 * grav * avg)))) / grav -- ptime = ptime * TimerMan.DeltaTimeSecs -- print("time of proj's flight = "..ptime) -- print("calculated time") local vxd = xd + (actor.Vel.X * ptime) -- print("delta x incl. vel = "..vxd) local vyd = yd + (actor.Vel.Y * ptime) -- print("delta y incl. vel = "..vyd) -- print("firemode = "..self.mode) -- print("deltas set") local beta = math.atan(((vel ^ 2) + (self.mode * (((vel ^ 4) - (grav ^ 2) * (vxd ^ 2) - (2 * grav * vyd * (vel ^ 2))) ^ 0.5))) / (grav * vxd)) -- print("aim angle incl. delta vel = "..beta) -- print("checking angle again") if beta <= math.pi and beta >= 0 then -- print("angle is good again") self:SetAimAngle(beta) -- print("aiming") -- self.gun:Activate() cont:SetState(Controller.AIM_SHARP, true) cont:SetState(Controller.WEAPON_FIRE, true) -- print("fired") if self.gun:IsReloading() or self.gun:NeedsReloading() then -- self.gun:Deactivate() cont:SetState(Controller.AIM_SHARP, false) cont:SetState(Controller.WEAPON_FIRE, false) cont:SetState(Controller.WEAPON_RELOAD, true) end -- print("done") end end end end self.btimer:Reset() end if self.gun:NeedsReloading() then cont:SetState(Controller.WEAPON_RELOAD, true) end else self:SetControllerMode(Controller.CIM_PLAYER , self.Team) end end |
Author: | Coops [ Tue May 17, 2011 12:13 am ] |
Post subject: | Re: What is the longest lua script you've ever written for CC? |
I was working on my first lua mod with help from CC48 Which turned out to be somewhere along 1700 lines of script. I wish I still had the script though (Probably still do but I don't want to fish it out of my mod dump), It's still unfinished as well. |
Author: | Grif [ Tue May 17, 2011 5:32 am ] |
Post subject: | Re: What is the longest lua script you've ever written for CC? |
I was working on a lua powered total conversion of the game into a vertically scrolling shooter. All told in each of the myriad files I probably ran up to around four or five thousand lines. |
Author: | Jourdy288 [ Tue May 17, 2011 5:28 pm ] |
Post subject: | Re: What is the longest lua script you've ever written for CC? |
Xery wrote: And, scripts of mission mods are usually over 900lines. The main script of "Prison Escape Episode 2"(LastBanana) viewtopic.php?f=24&t=17619 function point_direction_vec(pointA,pointB)
--Returns the direction from Vector A to Vector B. return math.atan2(pointA.Y - pointB.Y,pointA.X - pointB.X); end function Speak(person,text,length) --Set the text. ActivityMan:GetActivity():ResetMessageTimer(Activity.PLAYER_1); FrameMan:ClearScreenText(Activity.PLAYER_1); FrameMan:SetScreenText(string.upper(person.PresetName) .. ": " .. text, Activity.PLAYER_1, 0, length, false); --Add the marker. local marker = CreateAEmitter("Prison Escape Ep2.rte/Speech Marks"); marker.Mass = person.ID; marker.Lifetime = length; MovableMan:AddParticle(marker); end function PrisonEscapeMission2:StartActivity() --Create an invisible brain. self.brain = CreateActor("Base.rte/Brain Case"); self.brain.Team = Activity.TEAM_1; self.brain.Pos = Vector(600,550); self.brain.Scale = 0; self.brain.GetsHitByMOs = false; self.brain.HitsMOs = false; MovableMan:AddActor(self.brain); self:SetPlayerBrain(self.brain,Activity.PLAYER_1); self:SwitchToActor(self.brain,Activity.PLAYER_1,-1); --Actors to spawn. local guard1 = CreateAHuman("Base.rte/Robot 2"); guard1.Pos = Vector(1430,360); guard1.Team = Activity.TEAM_2; MovableMan:AddActor(guard1); guard1:SetControllerMode(Controller.CIM_NETWORK,-1); guard1.HFlipped = true; local guard2 = CreateAHuman("Base.rte/Robot 2"); guard2.Pos = Vector(1440,456); guard2.Team = Activity.TEAM_2; MovableMan:AddActor(guard2); guard2:SetControllerMode(Controller.CIM_NETWORK,-1); guard2.HFlipped = true; local guard3 = CreateAHuman("Base.rte/Robot 2"); guard3.Pos = Vector(1260,626); guard3.Team = Activity.TEAM_2; MovableMan:AddActor(guard3); guard3:SetControllerMode(Controller.CIM_NETWORK,-1); guard3.HFlipped = true; self.soldier1 = CreateAHuman("Prison Escape Ep2.rte/Soldier Light"); self.soldier1.Pos = Vector(2220,456); self.soldier1.Team = Activity.TEAM_2; self.soldier1.HFlipped = true; self.soldier1:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Pistol")); MovableMan:AddActor(self.soldier1); self.soldier1.AIMode = Actor.AIMODE_SENTRY; local soldier2 = CreateAHuman("Prison Escape Ep2.rte/Soldier Light"); soldier2.Pos = Vector(2029,648); soldier2.Team = Activity.TEAM_2; soldier2.HFlipped = false; soldier2:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Compact Assault Rifle")); MovableMan:AddActor(soldier2); soldier2.AIMode = Actor.AIMODE_SENTRY; self.soldier3 = CreateAHuman("Prison Escape Ep2.rte/Soldier Light"); self.soldier3.Pos = Vector(2895,384); self.soldier3.Team = Activity.TEAM_2; self.soldier3.HFlipped = true; self.soldier3:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Shotgun")); MovableMan:AddActor(self.soldier3); self.soldier3.AIMode = Actor.AIMODE_SENTRY; self.soldier4 = CreateAHuman("Prison Escape Ep2.rte/Soldier Heavy"); self.soldier4.Pos = Vector(3324,408); self.soldier4.Team = Activity.TEAM_2; self.soldier4.HFlipped = true; self.soldier4:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Compact Assault Rifle")); MovableMan:AddActor(self.soldier4); self.soldier4.AIMode = Actor.AIMODE_SENTRY; self.soldier5 = CreateAHuman("Prison Escape Ep2.rte/Soldier Heavy"); self.soldier5.Pos = Vector(3420,408); self.soldier5.Team = Activity.TEAM_2; self.soldier5.HFlipped = true; self.soldier5:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Compact Assault Rifle")); MovableMan:AddActor(self.soldier5); self.soldier5.AIMode = Actor.AIMODE_SENTRY; --Blocks player's exit through first opening. self.shield1 = CreateMOSRotating("Prison Escape Ep2.rte/Force Field V"); self.shield1.Pos = Vector(1932,420); MovableMan:AddParticle(self.shield1); --Blocks player from exiting during first battle. self.shield2 = CreateMOSRotating("Prison Escape Ep2.rte/Force Field H"); self.shield2.Pos = Vector(2190,504); self.shield2.HFlipped = true; MovableMan:AddParticle(self.shield2); self.shield3 = CreateMOSRotating("Prison Escape Ep2.rte/Force Field H"); self.shield3.Pos = Vector(2190,552); self.shield3.HFlipped = true; MovableMan:AddParticle(self.shield3); --Blocks player's exit through second opening. self.shield4 = CreateMOSRotating("Prison Escape Ep2.rte/Force Field V"); self.shield4.Pos = Vector(2796,324); MovableMan:AddParticle(self.shield4); --Blocks player's entrance into the enemy spawn room. self.shield5 = CreateMOSRotating("Prison Escape Ep2.rte/Force Field H Ballistic"); self.shield5.Pos = Vector(3618,600); MovableMan:AddParticle(self.shield5); --The enemy brain. self.enemyBrain = CreateActor("Prison Escape Ep2.rte/Richard Borno"); self.enemyBrain.Pos = Vector(3372,368); self.enemyBrain.Team = Activity.TEAM_2; self.enemyBrain.GetsHitByMOs = false; MovableMan:AddActor(self.enemyBrain); --The escape rocket. self.rocket = CreateAEmitter("Prison Escape Ep2.rte/Escape Rocket"); self.rocket.Pos = Vector(3852,499); self.rocket.PinStrength = 99999; MovableMan:AddParticle(self.rocket); --A floating health symbol implying that there's an actor next to the ship. self.symbol = CreateActor("Base.rte/Brain Case"); self.symbol.RotAngle = 0; self.symbol.HFlipped = true; self.symbol.Scale = 0; self.symbol.Team = Activity.TEAM_1; self.symbol.Pos = Vector(3876,520); self.symbol.PresetName = "Fiona"; MovableMan:AddActor(self.symbol); --Something for enemies to aim at on the ship. self.aimer = CreateActor("Base.rte/Brain Case"); self.aimer.Scale = 0; self.aimer.Team = Activity.TEAM_1; self.aimer.Pos = Vector(3852,460); MovableMan:AddActor(self.aimer); --The cloning tube. self.cloneTube = CreateAEmitter("Prison Escape Ep2.rte/Clone Generator"); self.cloneTube.Pos = Vector(3372,528); self.cloneTube:EnableEmission(false); self.cloneTube.Team = Activity.TEAM_2; MovableMan:AddParticle(self.cloneTube); --The gun maker. self.gunMaker = CreateAEmitter("Prison Escape Ep2.rte/Gun Maker"); self.gunMaker.Pos = Vector(3470,492); self.gunMaker:EnableEmission(false); self.gunMaker.Team = Activity.TEAM_2; MovableMan:AddParticle(self.gunMaker); --The shield maker. self.shieldMaker = CreateAEmitter("Prison Escape Ep2.rte/Shield Maker"); self.shieldMaker.Pos = Vector(3566,492); self.shieldMaker:EnableEmission(false); self.shieldMaker.Team = Activity.TEAM_2; MovableMan:AddParticle(self.shieldMaker); --The enemy spawn room self.spawnRoom = SceneMan.Scene:GetArea("Enemy Spawn Room"); --Timer to count events. self.eventTimer = Timer(); --How fast the ship falls. self.shipFallSpeed = 40; --Where the ship actually landed. self.landingSpot = Vector(); --The player's last position. self.playerPos = Vector(); --How often ending clones should shoot. self.shootTime = 500; self.shootTimer = Timer(); --Whether the player was HFlipped. self.playerHFlip = false; --Where the player was aiming. self.playerAim = 0; --Which of the endings the player got. self.endMsg = 0; --Give the player no funds. self:SetTeamFunds(0,Activity.TEAM_1); if checkpoint == nil then --The current event stage. self.eventStage = 0; --Items the player has. hasDeagle = true; hasPstl = false; hasCAR = false; hasAR = false; hasShotgun = false; hasShield = false; --How many times the player has respawned. respawns = 0; --What the camera should be focusing on. self.target = self.brain; --What AIMode the target should be in. self.targetMode = Controller.CIM_NETWORK; --Don't play music yet. AudioMan:StopMusic(); else --The current event stage. self.eventStage = 64; --Set the actor's position. self.playerPos = Vector(3350,415); --What AIMode the target should be in. self.targetMode = Controller.CIM_PLAYER; --Spawn Fiona. self.partner = CreateAHuman("Prison Escape Ep2.rte/Fiona"); self.partner:SetControllerMode(Controller.CIM_NETWORK,-1); self.partner.Pos = SceneMan:MovePointToGround(Vector(50,0),0,0); self.partner.Team = Activity.TEAM_1; self.partner:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Amazon Pistol")); self.partner:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Amazon Pistol (Offhand)")); MovableMan:AddActor(self.partner); --Report the amount of respawns. self:ReportDeath(Activity.TEAM_1,respawns + 1); --Play music. AudioMan:ClearMusicQueue(); AudioMan:PlayMusic("Prison Escape Ep2.rte/Sound/Music/Plucked_From_Space.ogg", -1, -1); self.startup = true; end end function PrisonEscapeMission2:UpdateActivity() if self.startup and self.eventTimer:IsPastSimMS(100) then --Kill all enemies. for actor in MovableMan.Actors do if actor.Team == Activity.TEAM_2 then if actor.PresetName == "Richard Borno" then actor.ToDelete = true; else actor.Health = 0; end end end self.startup = false; end --Keep the brain's health invisible. self.brain.Team = -1; if self:ActivityOver() == false then --Stay controlling the target. if MovableMan:IsActor(self.target) then if self:GetControlledActor(Activity.TEAM_1) == nil then self:SwitchToActor(self.target,Activity.PLAYER_1,Activity.TEAM_1); else --If the target isn't already controlled, switch to it. local other = self:GetControlledActor(Activity.PLAYER_1); if self.target.ID ~= other.ID then self:SwitchToActor(self.target,Activity.PLAYER_1,Activity.TEAM_1); --Set the target's controller mode. if self.targetMode == Controller.CIM_NETWORK then self.target:SetControllerMode(Controller.CIM_NETWORK,-1); else self.target:SetControllerMode(Controller.CIM_PLAYER,Activity.PLAYER_1); end --Set the last actor back to the right mode. other:SetControllerMode(Controller.CIM_NETWORK,-1); end end end --Respawn the player if they died. local playerAlive = true; if MovableMan:IsActor(self.playerActor) == false then playerAlive = false; elseif self.playerActor.Health <= 0 then self.playerActor.ToDelete = true; playerAlive = false; else --Keep the player in the right mode. if self.playerActor:IsPlayerControlled() == false then --Set the target's controller mode. if self.targetMode == Controller.CIM_NETWORK then self.playerActor:SetControllerMode(Controller.CIM_NETWORK,-1); else self.playerActor:SetControllerMode(Controller.CIM_PLAYER,Activity.PLAYER_1); end end --Update the player's position. self.playerPos.X = self.playerActor.Pos.X; self.playerPos.Y = self.playerActor.Pos.Y; self:SetObservationTarget(self.playerPos,Activity.PLAYER_1); --Update the player's aim. self.playerAim = self.playerActor:GetAimAngle(false); self.playerHFlip = self.playerActor.HFlipped; --Update the player's inventory. if self.playerActor:HasObject("Pistol") then hasPistol = true; end if self.playerActor:HasObject("Compact Assault Rifle") then hasCAR = true; end if self.playerActor:HasObject("Assault Rifle") then hasAR = true; end if self.playerActor:HasObject("Shotgun") then hasShotgun = true; end if self.playerActor:HasObject("Riot Shield") then hasShield = true; end --Keep the player inside the level. if self.playerActor.Pos.X < 0 then self.playerActor.Pos.X = 0; self.playerActor.Vel.X = 0; end if self.playerActor.Pos.X > SceneMan.SceneWidth then self.playerActor.Pos.X = SceneMan.SceneWidth; self.playerActor.Vel.X = 0; end end --Check that the actor isn't inside of a rocket. if MovableMan:IsActor(self.escapeRocket) then if self.escapeRocket:HasObject("Dafred") then playerAlive = true; end end if playerAlive == false and self.eventStage >= 6 then respawns = respawns + 1; self.playerActor = CreateAHuman("Prison Escape Ep2.rte/Dafred"); self.playerActor.Pos = self.playerPos; self.playerActor.HFlipped = self.playerHFlip; self.playerActor:SetAimAngle(self.playerAim); self.playerActor.Team = Activity.TEAM_1; --Give the player their items back. self.playerActor:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Desert Eagle")); if hasPistol then self.playerActor:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Pistol")); end if hasCAR then self.playerActor:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Compact Assault Rifle")); end if hasAR then self.playerActor:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Assault Rifle")); end if hasShotgun then self.playerActor:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Shotgun")); end if hasShield then self.playerActor:AddInventoryItem(CreateHeldDevice("Base.rte/Riot Shield")); end MovableMan:AddActor(self.playerActor); self:SwitchToActor(self.playerActor,Activity.PLAYER_1,Activity.TEAM_1); self.target = self.playerActor; end --After a few seconds, send the dropship hurtling in. if self.eventTimer:IsPastSimMS(2500) and self.eventStage == 0 then self.ship = CreateMOSRotating("Prison Escape Ep2.rte/Ruined Ship"); self.ship.Pos = Vector(0,0); self.ship.RotAngle = math.pi * 1.25; MovableMan:AddParticle(self.ship); self.eventStage = 1; end --Make the dropship land in the desired spot. if MovableMan:IsParticle(self.ship) then if self.ship:GetAltitude(0,0) > 50 then self.ship.Vel = SceneMan:ShortestDistance(self.ship.Pos,Vector(600,550),false); self.ship.Vel = (self.ship.Vel / self.ship.Vel.Largest) * self.shipFallSpeed; elseif self.ship.Vel.Magnitude < 15 and self.ship.Vel.Magnitude > -15 and self.eventStage == 1 then --Pin the ship in place and make a crashing sound. self.ship.PinStrength = 99999; self.ship.Vel = Vector(0,0); self.ship.RotAngle = 3.36; local sound = CreateAEmitter("Prison Escape Ep2.rte/Crash Sound Emitter"); sound.Pos = self.ship.Pos; MovableMan:AddParticle(sound); --Store where the ship landed. self.landingSpot = self.ship.Pos; --Play music. AudioMan:ClearMusicQueue(); AudioMan:PlayMusic("Prison Escape Ep2.rte/Sound/Music/What_It_Feels_Like.ogg", -1, -1); self.eventStage = 2; end --Keep the dropship in place. if self.eventStage >= 2 then self.ship.Pos = self.landingSpot; end --3 door hits. if self.eventTimer:IsPastSimMS(5000) and self.eventStage == 2 then local sound = CreateAEmitter("Prison Escape Ep2.rte/Hit Sound 1 Emitter"); sound.Pos = self.ship.Pos; MovableMan:AddParticle(sound); self.eventStage = 3; end if self.eventTimer:IsPastSimMS(6400) and self.eventStage == 3 then local sound = CreateAEmitter("Prison Escape Ep2.rte/Hit Sound 2 Emitter"); sound.Pos = self.ship.Pos; MovableMan:AddParticle(sound); self.eventStage = 4; end if self.eventTimer:IsPastSimMS(8000) and self.eventStage == 4 then local sound = CreateAEmitter("Prison Escape Ep2.rte/Hit Sound 3 Emitter"); sound.Pos = self.ship.Pos; MovableMan:AddParticle(sound); --Break off the door. local doorPos = Vector(); local doorAng = 0; for i=1,MovableMan:GetMOIDCount()-1 do local mo = MovableMan:GetMOFromID(i); if mo.RootID == self.ship.ID and mo.PresetName == "Ruined Ship Door" then doorPos = mo.Pos; doorAng = mo.RotAngle; ToAttachable(mo):Detach(); end end local door = CreateAttachable("Prison Escape Ep2.rte/Ruined Ship Door"); door.Pos = doorPos; door.RotAngle = doorAng; door.Vel = Vector(-5,2); door.AngularVel = 3; door.GetsHitByMOs = false; MovableMan:AddParticle(door); self.ship.GetsHitByMOs = false; self.eventStage = 5; end --Spawn the player from inside the ship. if self.eventTimer:IsPastSimMS(8300) and self.eventStage == 5 then self.playerActor = CreateAHuman("Prison Escape Ep2.rte/Dafred"); self.playerActor.Pos = self.ship.Pos + Vector(-25,-10); self.playerActor.Vel = Vector(-11,-10); self.playerActor.HFlipped = true; self.playerActor.Team = Activity.TEAM_1; self.playerActor.AIMode = Actor.AIMODE_SENTRY; MovableMan:AddActor(self.playerActor); self.playerActor:SetControllerMode(Controller.CIM_NETWORK,-1); --Move the camera over. self.brain.Pos = self.brain.Pos + Vector(-200,0); self.eventStage = 6; end --Spawn Fiona. if self.eventTimer:IsPastSimMS(9400) and self.eventStage == 6 then self.partner = CreateAHuman("Prison Escape Ep2.rte/Fiona"); self.partner.Pos = self.ship.Pos + Vector(-25,-10); self.partner.Vel = Vector(-10,-10); self.partner.HFlipped = true; self.partner.Team = Activity.TEAM_1; self.partner.AIMode = Actor.AIMODE_SENTRY; MovableMan:AddActor(self.partner); self.partner:SetControllerMode(Controller.CIM_NETWORK,-1); self.eventStage = 7; end --Make Fiona and Dafred not collide. if self.eventStage == 7 then local partsFound = false; for i=1,MovableMan:GetMOIDCount()-1 do local mo = MovableMan:GetMOFromID(i); if mo.RootID == self.partner.ID then partsFound = true; mo:SetWhichMOToNotHit(self.playerActor,-1); elseif mo.RootID == self.playerActor.ID then mo:SetWhichMOToNotHit(self.partner,-1); end end if partsFound then self.eventStage = 8; end end --Spawn Brutus. if self.eventTimer:IsPastSimMS(10100) and self.eventStage == 8 then self.survivor = CreateAHuman("Ronin.rte/Brutus"); self.survivor.Pos = self.ship.Pos + Vector(-25,-10); self.survivor.Vel = Vector(-9,-10); self.survivor.HFlipped = true; self.survivor.Team = Activity.TEAM_1; self.survivor.AIMode = Actor.AIMODE_SENTRY; MovableMan:AddActor(self.survivor); self.survivor:SetControllerMode(Controller.CIM_NETWORK,-1); self.eventStage = 9; end --Explode the ship. if self.eventTimer:IsPastSimMS(11600) and self.eventStage == 9 then --Create the explosives. for i=1,5 do local bomb = CreateTDExplosive("Pineapple Grenade"); bomb.Pos = self.ship.Pos + Vector(-25,-10); bomb.Vel = Vector(0,0); MovableMan:AddParticle(bomb); bomb:GibThis(); end --Make everyone look. for actor in MovableMan.Actors do if actor.ClassName == "AHuman" and actor.Team == Activity.TEAM_1 then actor.HFlipped = false; actor:SetAimAngle(math.pi / 5); actor.Pos.Y = SceneMan:MovePointToGround(actor.Pos,0,0).Y - 10; end end self.eventStage = 10; end end --If Fiona is dead, fail. if self.eventStage >= 7 and self.eventStage <= 71 and MovableMan:IsActor(self.partner) == false then local inShip = false; if MovableMan:IsActor(self.escapeRocket) then if self.escapeRocket:HasObject("Fiona") then inShip = true; end end if inShip == false then self.endMsg = 2; self.WinnerTeam = Activity.TEAM_2; ActivityMan:EndActivity(); end end --If the escape rocket has been destroyed, fail. if self.eventStage <= 70 and MovableMan:IsParticle(self.rocket) == false then self.symbol.ToDelete = true; self.aimer.ToDelete = true; self:SetObservationTarget(Vector(3852,499),Activity.PLAYER_1); self.partner.Pos = Vector(3880,534); self.partner.Health = 0; self.endMsg = 3; self.WinnerTeam = Activity.TEAM_2; ActivityMan:EndActivity(); end if self.eventTimer:IsPastSimMS(12000) and self.eventStage == 10 then --Speech. Speak(self.partner,"Oh god, there were still people in there!",2500); self.eventStage = 11; end if self.eventTimer:IsPastSimMS(15000) and self.eventStage == 11 then --Speech. Speak(self.partner,"...I guess we'll have to go on without them.",2500); --Let the ship settle. self.ship.PinStrength = 0; self.ship.ToSettle = true; --Turn everyone to look at Fiona. self.survivor.HFlipped = true; self.survivor:SetAimAngle(-math.pi / ; self.playerActor:SetAimAngle(math.pi / 6); self.eventStage = 12; end if self.eventTimer:IsPastSimMS(16000) and self.eventStage == 12 then self.pda = CreateHDFirearm("Prison Escape Ep2.rte/PDA"); --Take Fiona's PDA out. self.partner:AddInventoryItem(self.pda); self.partner:SetAimAngle(0); self.eventStage = 13; end if self.eventTimer:IsPastSimMS(18000) and self.eventStage == 13 then --Speech. Speak(self.partner,"According to my PDA, we're right in front of a Coalition outpost.",2500); self.eventStage = 14; end if self.eventTimer:IsPastSimMS(21000) and self.eventStage == 14 then --Speech. Speak(self.partner,"I think they're the ones who shot us down. There has to be a rocket or something in there that we can escape with.",5000); self.eventStage = 15; end if self.eventTimer:IsPastSimMS(26250) and self.eventStage == 15 then --Speech. Speak(self.survivor,"So you're telling me that we need to break into their base?",3000); self.eventStage = 16; end if self.eventTimer:IsPastSimMS(29500) and self.eventStage == 16 then --Speech. Speak(self.partner,"Basically.",1500); self.eventStage = 17; end if self.eventTimer:IsPastSimMS(31250) and self.eventStage == 17 then --Speech. Speak(self.survivor,"The three of us against their entire barracks?",2500); self.eventStage = 18; end if self.eventTimer:IsPastSimMS(34000) and self.eventStage == 18 then --Speech. Speak(self.partner,"Well... Yeah.",1500); --Remove the PDA. self.pda.ToDelete = true; self.partner:SetAimAngle(math.pi / ; self.eventStage = 19; end if self.eventTimer:IsPastSimMS(35750) and self.eventStage == 19 then --Speech. Speak(self.survivor,"No turning back, nobody to save us, and a good chance that at least one of us will die?",4000); self.eventStage = 20; end if self.eventTimer:IsPastSimMS(40000) and self.eventStage == 20 then --Speech. Speak(self.partner,"Look, if you've got a better plan, then-",1000); self.eventStage = 21; end if self.eventTimer:IsPastSimMS(41100) and self.eventStage == 21 then --Speech. Speak(self.survivor,"AWESOME! I'm going in.",2000); self.survivor:SetAimAngle(0); self.sGun = CreateHDFirearm("Prison Escape Ep2.rte/YAK47"); self.survivor:AddInventoryItem(self.sGun); self.eventStage = 22; end if self.eventStage >= 22 and self.eventStage < 26 then if self.survivor.Pos.X < 800 then self.survivor:GetController():SetState(Controller.MOVE_RIGHT,true); if self.survivor.Pos.X > 450 and self.survivor.Pos.X < 600 then self.survivor:GetController():SetState(Controller.BODY_JUMP,true); end if self.survivor.Vel.Magnitude < 0.5 and self.survivor.Vel.Magnitude > -0.5 then self.survivor.Pos.Y = self.survivor.Pos.Y - 1; end else self.survivor.HFlipped = true; self.survivor.Pos.X = 800; self.survivor.Vel.X = 0; end end if self.eventTimer:IsPastSimMS(43250) and self.eventStage == 22 then --Speech. Speak(self.partner,"Brutus, wait!",2000); self.eventStage = 23; end if self.eventTimer:IsPastSimMS(45500) and self.eventStage == 23 then --Speech. Speak(self.partner,"What an idiot. We should probably follow him before he gets himself killed.",3000); self.partner.HFlipped = true; self.partner:SetAimAngle(-math.pi / ; self.eventStage = 24; end if self.eventTimer:IsPastSimMS(48750) and self.eventStage == 24 then --Speech. Speak(self.partner,"Brutus, slow down!",2000); self.partner:SetAimAngle(0); self:SwitchToActor(self.playerActor,Activity.PLAYER_1,Activity.TEAM_1); self.target = self.playerActor; self.targetMode = Controller.CIM_PLAYER; self.eventStage = 25; end if self.eventStage == 25 then if self.playerActor.Pos.X > 575 then self.playerActor.Pos.X = 575; self.playerActor.Vel.X = 0; end if self.partner.Pos.X > 450 and self.partner.Pos.X < 525 then self.partner:GetController():SetState(Controller.BODY_JUMP,true); end if self.partner.Pos.X < 650 then self.partner:GetController():SetState(Controller.MOVE_RIGHT,true); end if self.partner.Vel.Magnitude < 0.5 and self.partner.Vel.Magnitude > -0.5 then self.partner.Pos.Y = self.partner.Pos.Y - 1; end --Once everyone is in place... if self.partner.Pos.X > 625 and self.survivor.Pos.X > 775 and self.playerActor.Pos.X > 560 and self.eventStage == 25 then --Stop controlling the player for a moment. self.playerActor:SetControllerMode(Controller.CIM_NETWORK,-1); self.targetMode = Controller.CIM_NETWORK; self.playerActor.Vel.X = 0; --Speech. Speak(self.partner,"Brutus, wait for us! You can't possibly take them all down by yourself!",3000); self.partner:SetAimAngle(math.pi / ; --Make Brutus look at Fiona. self.survivor:SetAimAngle(-math.pi / ; self.survivor.HFlipped = true; self.survivor.Pos.Y = SceneMan:MovePointToGround(self.survivor.Pos,0,0).Y - 10; --Restart the timer's counting again. self.eventTimer:Reset(); self.eventStage = 26; end end if self.eventStage == 25 or self.eventStage == 26 then if self.partner.Pos.X > 650 then self.partner.Vel.X = 0; self.partner.Pos.X = 650; end end if self.eventStage >= 26 and self.eventStage <= 31 then --Turn the player to face them. self.playerActor.HFlipped = false; end if self.eventTimer:IsPastSimMS(3250) and self.eventStage == 26 then Speak(self.survivor,"Pff, you guys are too slow. Besides, this'll be a piece of cake.",3000); self.eventStage = 27; end if self.eventTimer:IsPastSimMS(6500) and self.eventStage == 27 then Speak(self.survivor,"Watch and learn, you wuss. I'll walk all ov-",1000); self.survivor.HFlipped = false; self.survivor:SetAimAngle(0); self.eventStage = 28; end if self.eventTimer:IsPastSimMS(7500) and self.eventStage == 28 then --Fire a shot to kill Brutus. self.killRifle = CreateHDFirearm("Prison Escape Ep2.rte/Hyper-Accurate HSR"); self.killRifle.HFlipped = true; self.killRifle.Pos = self.survivor.Pos + Vector(500,-16); self.killRifle.PinStrength = 10000; MovableMan:AddItem(self.killRifle); self.killRifle:Activate(); self.eventStage = 29; end if self.eventStage == 29 and MovableMan:IsActor(self.survivor) then --Keep Brutus from flying back. self.survivor.Vel = Vector(0,0); end if MovableMan:IsActor(self.survivor) == false and self.eventStage == 29 then Speak(self.partner,"WOAH! Get down!",1250); --Don't count this death. self:ReportDeath(Activity.TEAM_1,-1); --Remove the gun. self.killRifle.ToDelete = true; --If Brutus' gun is still around, make sure it isn't any longer. if MovableMan:IsDevice(self.sGun) then self.sGun.ToSettle = true; end --Let Brutus die. self.survivor.PinStrength = 0; self.eventTimer:Reset(); self.eventStage = 30; end if self.eventStage == 30 then self.partner:GetController():SetState(Controller.BODY_CROUCH,true); self.partner:GetController():SetState(Controller.MOVE_RIGHT,true); self.playerActor:GetController():SetState(Controller.BODY_CROUCH,true); self.playerActor:GetController():SetState(Controller.MOVE_RIGHT,true); end if self.eventTimer:IsPastSimMS(1510) and self.eventStage == 30 then Speak(self.partner,"I knew it. Guard robots. Dammit, Brutus, we needed you...",4000); self.partner.Pos.Y = SceneMan:MovePointToGround(self.partner.Pos,0,0).Y - 10; self.partner:GetController():SetState(Controller.MOVE_RIGHT,true); self.playerActor:GetController():SetState(Controller.MOVE_RIGHT,true); self.eventStage = 31; end if self.eventTimer:IsPastSimMS(6000) and self.eventStage == 31 then Speak(self.partner,"I wonder what kind of network connection they're on. Let's see...",4000); --Take Fiona's PDA out. self.pda = CreateHDFirearm("Prison Escape Ep2.rte/PDA"); self.partner:AddInventoryItem(self.pda); self.partner:SetAimAngle(0); self.eventStage = 32; end if self.eventTimer:IsPastSimMS(10250) and self.eventStage == 32 then Speak(self.partner,"...You're kidding me. Their password is \"password\". Their firmware is out of date, too.",4000); self.eventStage = 33; end if self.eventTimer:IsPastSimMS(16000) and self.eventStage == 33 then --Kill the robots. for actor in MovableMan.Actors do if actor.PresetName == "Robot 2" then actor.Health = 0; actor.Vel = Vector(math.random() * 2 - 1,math.random() * 2 - 1); --Don't count this death. self:ReportDeath(Activity.TEAM_1,-1); end end --Open the door. for actor in MovableMan.Actors do if actor.ClassName == "ADoor" and actor.Pos.X < 1850 then actor.Team = Activity.TEAM_1; end end Speak(self.partner,"Okay, their front guard robots are disabled. The rest of their security is out of range.",4000); self.eventStage = 34; end if self.eventTimer:IsPastSimMS(20250) and self.eventStage == 34 then Speak(self.partner,"Let's get going. They'll be after us in no time now that their front entrance is wide open.",4000); --Look at Dafred. self.partner.HFlipped = true; --Put away the pda. self.pda.ToDelete = true; --Give Fiona her weapons. self.pistolA = CreateHDFirearm("Prison Escape Ep2.rte/Amazon Pistol (Offhand)"); self.partner:AddInventoryItem(self.pistolA); --Give the player a weapon. self.playerActor:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Desert Eagle")); --Switch control to Dafred again. self:SwitchToActor(self.playerActor,Activity.PLAYER_1,Activity.TEAM_1); self.targetMode = Controller.CIM_PLAYER; self.eventStage = 35; end if self.eventTimer:IsPastSimMS(20500) and self.eventStage == 35 then --Equip Fiona's second pistol. self.partner.HFlipped = true; self.pistolB = CreateHDFirearm("Prison Escape Ep2.rte/Amazon Pistol"); self.partner:AddInventoryItem(self.pistolB); self.partner:GetController():SetState(Controller.WEAPON_CHANGE_PREV,true); self.partner:SetAimAngle(-0.1); self.eventStage = 36; end if self.eventTimer:IsPastSimMS(22000) and self.eventStage == 36 then if self.partner.Pos.X < 1734 then self.partner:GetController():SetState(Controller.MOVE_RIGHT,true); else self.partner.HFlipped = true; end if (self.partner.Pos.X > 750 and self.partner.Pos.X < 775) or (self.partner.Pos.X > 1450 and self.partner.Pos.X < 1500) then self.partner:GetController():SetState(Controller.BODY_JUMP,true); end if self.partner.Vel.Magnitude < 0.5 and self.partner.Vel.Magnitude > -0.5 then self.partner.Pos.Y = self.partner.Pos.Y - 1; end if self.playerActor.Pos.X > 1680 then self.playerActor.Vel.X = 0; self.playerActor.Pos.X = 1680; end if self.playerActor.Pos.Y < 310 and self.playerActor.Pos.X > 1412 then self.playerActor.Pos.X = 1412; self.playerActor.Vel.X = 0; end if self.partner.Pos.X > 1734 and self.playerActor.Pos.X > 1640 then --Stop controlling the player. self.playerActor:SetControllerMode(Controller.CIM_NETWORK,-1); self.targetMode = Controller.CIM_NETWORK; --Speech Speak(self.partner,"I'm going to see what's behind this door. Cover me.",4000); self.partner.HFlipped = true; self.playerActor.HFlipped = false; self.playerActor:SetAimAngle(0); self.eventTimer:Reset(); self.eventStage = 37; end end if self.eventStage == 37 and self.eventTimer:IsPastSimMS(4000) then self.partner:GetController():SetState(Controller.MOVE_RIGHT,true); if self.partner.Vel.Magnitude < 0.5 and self.partner.Vel.Magnitude > -0.5 then self.partner.Pos.Y = self.partner.Pos.Y - 1; end if self.partner.Pos.X > 1875 then --Close the doors again. for actor in MovableMan.Actors do if actor.ClassName == "ADoor" and actor.Pos.X > 1750 and actor.Pos.X < 1850 then actor.Team = Activity.TEAM_2; end end self.eventTimer:Reset(); self.eventStage = 38; end end if self.eventStage == 38 and self.eventTimer:IsPastSimMS(1000) then self.partner.HFlipped = true; Speak(self.partner,"Unless you just shut that door, I'd say that they know we're here now.",4000); self.eventStage = 39; end if self.eventStage == 39 and self.eventTimer:IsPastSimMS(5250) then self.partner.HFlipped = true; Speak(self.partner,"I guess I won't be coming back out that way. You check the other path, I'll take this portal.",4000); self.eventStage = 40; end if self.eventStage == 40 and self.eventTimer:IsPastSimMS(9500) then self.partner.HFlipped = true; Speak(self.partner,"Good luck. Let's make sure the others' deaths weren't in vain.",4000); self.eventStage = 41; end if self.eventStage == 41 and self.eventTimer:IsPastSimMS(13750) then self.partner:GetController():SetState(Controller.MOVE_RIGHT,true); if self.partner.Vel.Magnitude < 0.5 and self.partner.Vel.Magnitude > -0.5 then self.partner.Pos.Y = self.partner.Pos.Y - 1; end if self.partner.Pos.X > 2200 then --Switch control to Dafred again. self:SwitchToActor(self.playerActor,Activity.PLAYER_1,Activity.TEAM_1); self.targetMode = Controller.CIM_PLAYER; --Play music. AudioMan:ClearMusicQueue(); AudioMan:PlayMusic("Prison Escape Ep2.rte/Sound/Music/Mind_Stalker.ogg", -1, -1); self.eventStage = 42; end end if self.eventStage >= 42 then --Disable the teleporter. cantele[1]:Reset(); end if self.eventStage == 42 and MovableMan:IsActor(self.soldier1) == false then --Spawn the dropship with troops in it. self.enemyDropShip = CreateACDropShip("Prison Escape Ep2.rte/Drop Ship MK1 Slowspawn"); self.enemyDropShip.Pos = Vector(1740,0); self.enemyDropShip:SetControllerMode(Controller.CIM_NETWORK,-1); self.enemyDropShip.Team = Activity.TEAM_2; self.attacker1 = CreateAHuman("Prison Escape Ep2.rte/Soldier Light"); self.attacker1:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Pistol")); self.attacker1.Team = Activity.TEAM_2; self.attacker1:SetControllerMode(Controller.CIM_NETWORK,-1); self.attacker1.AIMode = Actor.AIMODE_GOTO; self.attacker1:AddAISceneWaypoint(Vector(2144,550)); self.enemyDropShip:AddInventoryItem(self.attacker1); self.attacker2 = CreateAHuman("Prison Escape Ep2.rte/Soldier Light"); self.attacker2:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Pistol")); self.attacker2.Team = Activity.TEAM_2; self.attacker2:AddInventoryItem(CreateHeldDevice("Prison Escape Ep2.rte/Riot Shield")); self.attacker2:SetControllerMode(Controller.CIM_NETWORK,-1); self.attacker2.AIMode = Actor.AIMODE_GOTO; self.attacker2:AddAISceneWaypoint(Vector(2144,550)); self.enemyDropShip:AddInventoryItem(self.attacker2); self.attacker3 = CreateAHuman("Prison Escape Ep2.rte/Soldier Heavy"); self.attacker3:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Compact Assault Rifle")); self.attacker3.Team = Activity.TEAM_2; self.attacker3:SetControllerMode(Controller.CIM_NETWORK,-1); self.attacker3.AIMode = Actor.AIMODE_GOTO; self.attacker3:AddAISceneWaypoint(Vector(2144,550)); self.enemyDropShip:AddInventoryItem(self.attacker3); MovableMan:AddActor(self.enemyDropShip); self.eventStage = 43; end if self.eventStage == 43 or self.eventStage == 44 then self.enemyDropShip.Pos.X = 1740; end --Lower the dropship. if self.eventStage == 43 then self.enemyDropShip:GetController():SetState(Controller.MOVE_DOWN,true); if self.enemyDropShip.Pos.Y > 150 then self.enemyDropShip:GetController():SetState(Controller.PRESS_FACEBUTTON,true); self.enemyDropShip:GetController():SetState(Controller.MOVE_DOWN,false); self.eventStage = 44; end end --Let the actors come out. if self.eventStage == 44 then if self.enemyDropShip.Pos.Y > 200 then self.enemyDropShip:GetController():SetState(Controller.MOVE_UP,true); end if MovableMan:IsActor(self.attacker1) and MovableMan:IsActor(self.attacker2) and MovableMan:IsActor(self.attacker3) then self.enemyDropShip:GetController():SetState(Controller.PRESS_FACEBUTTON,true); self.eventStage = 45; end end --Make the actors move. if self.eventStage == 44 or self.eventStage == 45 then if MovableMan:IsActor(self.attacker1) then if self.attacker1:GetController().InputMode == Controller.CIM_NETWORK then self.attacker1:GetController():SetState(Controller.MOVE_RIGHT,true); if self.attacker1.Pos.X > 1968 then self.attacker1:SetControllerMode(Controller.CIM_AI,-1); end end end if MovableMan:IsActor(self.attacker2) then if self.attacker2:GetController().InputMode == Controller.CIM_NETWORK then self.attacker2:GetController():SetState(Controller.MOVE_RIGHT,true); if self.attacker2.Pos.X > 1968 then self.attacker2:SetControllerMode(Controller.CIM_AI,-1); end end end if MovableMan:IsActor(self.attacker3) then if self.attacker3:GetController().InputMode == Controller.CIM_NETWORK then self.attacker3:GetController():SetState(Controller.MOVE_RIGHT,true); if self.attacker3.Pos.X > 1968 then self.attacker3:SetControllerMode(Controller.CIM_AI,-1); end end end end --Take off again. if self.eventStage == 45 then if MovableMan:IsActor(self.enemyDropShip) then self.enemyDropShip:GetController():SetState(Controller.MOVE_UP,true); end --If the player has killed all the enemies, let the shields down. if (MovableMan:IsActor(self.attacker1) == false or self.attacker1.PresetName == "Dafred") and (MovableMan:IsActor(self.attacker2) == false or self.attacker2.PresetName == "Dafred") and (MovableMan:IsActor(self.attacker3) == false or self.attacker1.PresetName == "Dafred") then self.shield2.ToDelete = true; self.shield3.ToDelete = true; self.eventStage = 46; end end if self.eventStage == 46 and (MovableMan:IsActor(self.soldier3) == false or self.soldier3.PresetName == "Dafred") then self.dropCrate = CreateACRocket("Dummy.rte/Drop Crate"); self.dropCrate.Pos = Vector(2796,0); self.dropCrate.Team = Activity.TEAM_2; local attacker4 = CreateAHuman("Prison Escape Ep2.rte/Soldier Light"); attacker4.Team = Activity.TEAM_2; attacker4.AIMode = Actor.AIMODE_PATROL; attacker4:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Pistol")); self.dropCrate:AddInventoryItem(attacker4); local attacker5 = CreateAHuman("Prison Escape Ep2.rte/Soldier Light"); attacker5.Team = Activity.TEAM_2; attacker5.AIMode = Actor.AIMODE_PATROL; attacker5:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Pistol")); self.dropCrate:AddInventoryItem(attacker5); local attacker6 = CreateAHuman("Prison Escape Ep2.rte/Soldier Light"); attacker6.Team = Activity.TEAM_2; attacker6.AIMode = Actor.AIMODE_PATROL; attacker6:AddInventoryItem(CreateHDFirearm("Prison Escape Ep2.rte/Pistol")); self.dropCrate:AddInventoryItem(attacker6); MovableMan:AddActor(self.dropCrate); self.eventStage = 47; end if MovableMan:IsActor(self.dropCrate) then self.dropCrate.RotAngle = math.pi; end if self.eventStage == 47 then --Keep the crate moving down. self.dropCrate.Vel.Y = 15; --Break the doors off. if self.dropCrate.Pos.Y > 240 then for actor in MovableMan.Actors do if actor.PresetName == "Door Rotate Short" and actor.Pos.X > 2711 and actor.Pos.X < 2855 then actor:GibThis(); --Don't count this death. self:ReportDeath(Activity.TEAM_2,-1); self.eventStage = 48; end end end end if self.eventStage == 48 then --If the player has killed all the guards and is in the room... if (MovableMan:IsActor(self.soldier4) == false or self.soldier4.PresetName == "Dafred") and (MovableMan:IsActor(self.soldier5) == false or self.soldier5.PresetName == "Dafred") then if self.playerActor.Pos.X > 3318 then --Lose control momentarily. self.playerActor:SetControllerMode(Controller.CIM_NETWORK,-1); self.targetMode = Controller.CIM_NETWORK; self.playerActor.HFlipped = false; self.playerActor:SetAimAngle(math.pi - point_direction_vec(self.playerActor.Pos,self.enemyBrain.Pos)); self.enemyBrain.GetsHitByMOs = true; Speak(self.enemyBrain,"Don't even think about it. That would be a very bad move.",4000); --Stop music. AudioMan:ClearMusicQueue(); AudioMan:StopMusic(); self.eventTimer:Reset(); self.eventStage = 49; end end end if self.eventStage == 49 and self.eventTimer:IsPastSimMS(4250) then Speak(self.enemyBrain,"Let's put it this way - if you kill me, the whole Coalition army will be after you.",5000); self.eventStage = 50; end if self.eventStage == 50 and self.eventTimer:IsPastSimMS(10250) then Speak(self.enemyBrain,"You're already on their wanted list. Don't make it any worse for yourself.",5000); self.eventStage = 51; end if self.eventStage == 51 and self.eventTimer:IsPastSimMS(15500) then Speak(self.enemyBrain,"Now, put down the gun.",2000); self.eventStage = 52; end if self.eventStage == 52 and self.eventTimer:IsPastSimMS(19750) then self.disarmed = CreateHeldDevice("Disarmed"); self.playerActor:AddInventoryItem(self.disarmed); self.playerActor:GetController():SetState(Controller.WEAPON_CHANGE_PREV,true); self.eventStage = 53; end if self.eventStage == 53 and self.eventTimer:IsPastSimMS(20000) then Speak(self.enemyBrain,"Good. Now, I happen to know that you have a friend with you. She's in the next room over.",5000); self.eventStage = 54; end if self.eventStage == 54 and self.eventTimer:IsPastSimMS(25250) then Speak(self.enemyBrain,"After the stunt she pulled off, helping you escape from the prison,",4000); self.eventStage = 55; end if self.eventStage == 55 and self.eventTimer:IsPastSimMS(29500) then Speak(self.enemyBrain,"she has quite a bounty on her head. So, I'll make you a deal.",4000); self.eventStage = 56; end if self.eventStage == 56 and self.eventTimer:IsPastSimMS(34750) then Speak(self.enemyBrain,"Leave her with my guards, and I'll let you go, scot-free. Nobody will know you were here.",5000); self.eventStage = 57; end if self.eventStage == 57 and self.eventTimer:IsPastSimMS(40000) then Speak(self.enemyBrain,"She won't even know you left her. I'll let you right out with that rocket.",5000); self.eventStage = 58; end if self.eventStage == 58 and self.eventTimer:IsPastSimMS(45250) then self.disarmed.ToDelete = true; self.eventStage = 59; end if self.eventStage == 59 and self.eventTimer:IsPastSimMS(45500) then self.newDeagle = CreateHDFirearm("Prison Escape Ep2.rte/Desert Eagle"); self.playerActor:AddInventoryItem(self.newDeagle); self.playerActor:GetController():SetState(Controller.WEAPON_CHANGE_PREV,true); self.playerActor:SetAimAngle(math.pi - point_direction_vec(self.playerActor.Pos,self.enemyBrain.Pos)); self.eventStage = 60; end if self.eventStage == 60 and self.eventTimer:IsPastSimMS(45750) then self.playerActor:GetController():SetState(Controller.WEAPON_FIRE,true); --Play music. AudioMan:ClearMusicQueue(); AudioMan:PlayMusic("Prison Escape Ep2.rte/Sound/Music/Plucked_From_Space.ogg", -1, -1); self.eventStage = 61; end if self.eventStage == 61 and self.eventTimer:IsPastSimMS(46000) then Speak(self.enemyBrain,"AUGH, MY BRAIN! You'll pay for that!",1500); self.eventStage = 62; end if self.eventStage == 62 and self.eventTimer:IsPastSimMS(48000) then self.enemyBrain.Pos.Y = self.enemyBrain.Pos.Y - 0.5; if self.enemyBrain.Pos.Y < 288 then self.ePos = Vector(self.enemyBrain.Pos.X,self.enemyBrain.Pos.Y); self.enemyBrain.ToDelete = true; --Don't count this death. self:ReportDeath(Activity.TEAM_2,-1); --Make the brain into a rocket. self.enemyBrain = CreateACRocket("Prison Escape Ep2.rte/Brain Rocket"); self.enemyBrain.Pos = self.ePos; self.enemyBrain.Team = Activity.TEAM_2; self.enemyBrain.PinStrength = 9999; MovableMan:AddActor(self.enemyBrain); self.enemyBrain:EraseFromTerrain(); self.eventStage = 63; end end if self.eventStage == 63 then if MovableMan:IsActor(self.enemyBrain) then self.enemyBrain.Pos.X = self.ePos.X; self.enemyBrain.RotAngle = 0; if self.enemyBrain.Pos.Y > 240 then self.enemyBrain.Pos.Y = self.enemyBrain.Pos.Y - 0.5; else self.enemyBrain.PinStrength = 0; self.enemyBrain:GetController():SetState(Controller.MOVE_UP,true); end else self.eventStage = 64; self:SwitchToActor(self.playerActor,Activity.PLAYER_1,Activity.TEAM_1); self.targetMode = Controller.CIM_PLAYER; self.newDeagle.ToDelete = true; self.playerActor:GetController():SetState(Controller.WEAPON_CHANGE_PREV,true); end end if self.eventStage == 64 then if self.playerActor.Pos.X > 3760 then Speak(self.symbol,"Dafred! Thank goodness you're still alive. We have a bit of a problem.",4000); checkpoint = true; self.eventStage = 65; self.eventTimer:Reset(); end end if self.eventStage == 65 and self.eventTimer:IsPastSimMS(4250) then Speak(self.symbol,"That room over there is their cloning station. I heard it starting up a few minutes back.",4000); self.eventStage = 66; end if self.eventStage == 66 and self.eventTimer:IsPastSimMS(8500) then Speak(self.symbol,"Our escape rocket here has a busted thruster. I can fix it, but I need time.",4000); self.eventStage = 67; end if self.eventStage == 67 and self.eventTimer:IsPastSimMS(12750) then Speak(self.symbol,"You look like you're in rough shape, but if you can hold them off for just a moment,",4000); self.eventStage = 68; end if self.eventStage == 68 and self.eventTimer:IsPastSimMS(17000) then Speak(self.symbol,"I can get this thing in working condition and we can get the hell out of here.",4000); --Turn on the emitters. self.cloneTube:EnableEmission(true); self.gunMaker:EnableEmission(true); self.shieldMaker:EnableEmission(true); self.eventStage = 69; end if self.eventStage == 69 and self.eventTimer:IsPastSimMS(21250) then Speak(self.symbol,"Crap, here they come! Get ready!",4000); self.rocket:EnableEmission(true); --Play music. AudioMan:ClearMusicQueue(); AudioMan:PlayMusic("Prison Escape Ep2.rte/Sound/Music/HyperReactive.ogg", -1, -1); --Start the timer. self.escapeTimer = Timer(); self.eventStage = 70; end if self.eventStage >= 70 and self.eventStage < 72 then --Control new clones. for actor in MovableMan.Actors do if actor.Team == Activity.TEAM_2 then --Make them exit the room. if self.spawnRoom:IsInside(actor.Pos) then actor:SetControllerMode(Controller.CIM_NETWORK,-1); actor:GetController():SetState(Controller.MOVE_RIGHT,true); actor:GetController():SetState(Controller.WEAPON_PICKUP,true); --If the actor hasn't equipped its pistol, do so. if actor:Inventory() ~= nil then if actor:Inventory().PresetName == "Pistol" then actor:GetController():SetState(Controller.WEAPON_CHANGE_PREV,true); end end elseif actor.Pos.X < 3750 and actor.Pos.Y > 500 and actor:GetController().InputMode == Controller.CIM_NETWORK then --Make them continue to walk forward and aim at the rocket. if MovableMan:IsParticle(self.rocket) then actor:SetAimAngle(math.pi - point_direction_vec(actor.Pos,self.rocket.Pos)); end actor:GetController():SetState(Controller.MOVE_RIGHT,true); --Fire periodically. if self.shootTimer:IsPastSimMS(self.shootTime + 100) then self.shootTimer:Reset(); elseif self.shootTimer:IsPastSimMS(self.shootTime) then actor:GetController():SetState(Controller.WEAPON_FIRE,true); else actor:GetController():SetState(Controller.WEAPON_FIRE,false); end else --Turn AI on again. actor:SetControllerMode(Controller.CIM_AI,-1); --Keep them down. if actor.Pos.Y < 575 then actor.Pos.Y = 575; actor.Vel.Y = 0; end end end end --Display the time. if self.eventTimer:IsPastSimMS(21000) then FrameMan:SetScreenText(math.floor(self.escapeTimer:LeftTillSimMS(34000) / 1000) .. " SECONDS LEFT!", Activity.PLAYER_1, 0, 1, false); end end if self.eventStage == 70 and self.escapeTimer:IsPastSimMS(34000) then --Activate the rocket. self.rocket.ToDelete = true; self.escapeRocket = CreateACRocket("Base.rte/Rocket MK2"); self.escapeRocket.PinStrength = 99999; self.escapeRocket.Pos = Vector(3854,506); self.escapeRocket.Team = Activity.TEAM_1; self.escapeRocket.GetsHitByMOs = false; self.escapeRocket:SetControllerMode(Controller.CIM_NETWORK,-1); self.escapeRocket.RotAngle = 0; MovableMan:AddActor(self.escapeRocket); self.escapeRocket:GetController():SetState(Controller.PRESS_FACEBUTTON,true); --Add Fiona back. self.partner.Pos = self.symbol.Pos + Vector(20,10); self.partner.HFlipped = true; self.symbol.ToDelete = true; self.aimer.ToDelete = true; Speak(self.partner,"Okay, it's all patched up! Get in, quick!",1500); self.eventStage = 71; self.eventTimer:Reset(); end if self.eventStage == 71 then self.escapeRocket.RotAngle = 0; if self.eventTimer:IsPastSimMS(1500) then if MovableMan:IsActor(self.partner) then self.partner:GetController():SetState(Controller.BODY_JUMP,true); if self.partner.Pos.X < 3850 then self.partner.Pos.X = 3850; self.partner.Vel.X = 0; end end end if self.escapeRocket:HasObject("Dafred") and self.escapeRocket:HasObject("Fiona") then self.escapeRocket.PinStrength = 0; self.eventStage = 72; end end if self.eventStage == 72 then if MovableMan:IsActor(self.escapeRocket) then self.escapeRocket:GetController():SetState(Controller.MOVE_UP,true); self.target = self.escapeRocket; self.targetMode = Controller.CIM_NETWORK; self.escapeRocket.Pos.X = 3852; self.escapeRocket.RotAngle = 0; end end end --Objective markers. self:ClearObjectivePoints(); if self.eventStage == 25 then self:AddObjectivePoint("Follow Brutus!",self.survivor.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); end if self.eventStage == 36 and MovableMan:IsActor(self.partner) then self:AddObjectivePoint("Follow Fiona!",self.partner.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); end if self.eventStage == 42 then if self.playerActor.Pos.X < 1980 then self:AddObjectivePoint("Continue ahead!",Vector(2122,560),Activity.TEAM_1,GameActivity.ARROWDOWN); elseif MovableMan:IsActor(self.soldier1) then self:AddObjectivePoint("Kill!",self.soldier1.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); end end if self.eventStage == 45 then if MovableMan:IsActor(self.attacker1) and self.attacker1.PresetName ~= "Dafred" then self:AddObjectivePoint("Kill!",self.attacker1.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); end if MovableMan:IsActor(self.attacker2) and self.attacker2.PresetName ~= "Dafred" then self:AddObjectivePoint("Kill!",self.attacker2.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); end if MovableMan:IsActor(self.attacker3) and self.attacker3.PresetName ~= "Dafred" then self:AddObjectivePoint("Kill!",self.attacker3.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); end end if self.eventStage == 46 then if self.playerActor.Pos.X < 2600 then self:AddObjectivePoint("Continue ahead!",Vector(2800,565),Activity.TEAM_1,GameActivity.ARROWDOWN); else self:AddObjectivePoint("Kill!",self.soldier3.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); end end if self.eventStage == 48 then if self.playerActor.Pos.X < 3125 then self:AddObjectivePoint("Go for the brain!",self.enemyBrain.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); else local soldiers = false; if MovableMan:IsActor(self.soldier4) and self.soldier4.PresetName ~= "Dafred" then self:AddObjectivePoint("Kill!",self.soldier4.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); soldiers = true; end if MovableMan:IsActor(self.soldier5) and self.soldier5.PresetName ~= "Dafred" then self:AddObjectivePoint("Kill!",self.soldier5.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); soldiers = true; end if soldiers == false then self:AddObjectivePoint("Walk up to the brain!",self.enemyBrain.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); end end end if self.eventStage == 64 and MovableMan:IsActor(self.symbol) then self:AddObjectivePoint("Get to Fiona!",self.symbol.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); end if self.eventStage == 70 and MovableMan:IsActor(self.aimer) then self:AddObjectivePoint("Protect!",self.aimer.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); end if self.eventStage == 71 then self:AddObjectivePoint("Get in!",self.escapeRocket.AboveHUDPos + Vector(0,-8),Activity.TEAM_1,GameActivity.ARROWDOWN); end self:YSortObjectivePoints(); end function PrisonEscapeMission2:PauseActivity() end function PrisonEscapeMission2:EndActivity() --If the player won the level... if self.endMsg == 1 then self:ResetMessageTimer(Activity.PLAYER_1); FrameMan:ClearScreenText(Activity.PLAYER_1); FrameMan:SetScreenText("FIONA: Nice work! That was a close call. I'm plotting a course back to the base.", Activity.PLAYER_1, 0, 5000, false); checkpoint = nil; elseif self.endMsg == 2 then self:ResetMessageTimer(Activity.PLAYER_1); FrameMan:ClearScreenText(Activity.PLAYER_1); FrameMan:SetScreenText("Fiona is dead. You have no pilot to escape with. Mission failed.", Activity.PLAYER_1, 0, 5000, false); elseif self.endMsg == 3 then self:ResetMessageTimer(Activity.PLAYER_1); FrameMan:ClearScreenText(Activity.PLAYER_1); FrameMan:SetScreenText("Your escape ship is destroyed - you have no way of leaving the base. Mission failed.", Activity.PLAYER_1, 0, 5000, false); end end function PrisonEscapeMission2:CraftEnteredOrbit() --If the end stage has been reached... if self.eventStage == 72 then if self.OrbitedCraft:HasObject("Dafred") and self.OrbitedCraft:HasObject("Fiona") then --Win! self.endMsg = 1; self.WinnerTeam = Activity.TEAM_1; ActivityMan:EndActivity(); self.brain.Pos = Vector(3852,0); end end end Well, 1651 lines. *SNIFFLE* Thank you, thank you sooo much! Downloaded, will play later. So. Much. Win. I wish I could learn Lua. Unfortunately, my head would most likely explode. I'm struggling with the .ini enough as it is. |
Author: | Spider101 [ Mon Aug 01, 2011 9:30 pm ] |
Post subject: | Re: What is the longest lua script you've ever written for CC? |
Well nothing like 1036 lines of text to put a wannabemodder off modding |
Author: | Contrary [ Tue Aug 02, 2011 4:46 am ] |
Post subject: | Re: What is the longest lua script you've ever written for CC? |
And you don't need Lua for good stuff, my favourite mods are Lua-less. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |