#Global Hooks$Simulation:[if mn.getMissionFilename() == "bsgctftest_mp" then --The mission MUST be named that to start the whole CTF thing----------------------------MISSION INITIALIZATION----------------------------if missionInit == nil then RedFlagBearer = nil GreenFlagBearer = nil RedScore = 0 GreenScore = 0 RedBase = mn.getShipByName("Red Base") --These ships MUST be in the game in order for this to work! GreenBase = mn.getShipByName("Green Base") RedFlag = mn.getShipByName("Red Flag") GreenFlag = mn.getShipByName("Green Flag") missionInit = 42 RedDrop = 0 GreenDrop = 0end--------------------CARRY RED FLAG--------------------if RedFlagBearer ~= nil then RedFlag.Position = RedFlagBearer.Position --------------------- --GREEN TEAM SCORES-- --------------------- if (RedFlagBearer.Position:getDistance(GreenBase.Position) < 10) and (GreenFlagBearer == nil) and (GreenDrop == 0) then RedFlagBearer = nil RedFlag.Position = RedBase.Position GreenScore = GreenScore + 1 endendif RedFlagBearer ~= nil then ----------------- --DROP RED FLAG-- ----------------- if RedFlagBearer.HitpointsLeft < 1 then RedFlagBearer = nil RedDrop = 1 endend---------------------PICKUP RED FLAG---------------------if (RedFlagBearer == nil) then --if GreenFlag isn't being carried for i = 1, mn.getNumShips() do --run though all ships thisShip = mn.getShipByIndex(i) if thisShip.Team ~= RedFlag.Team then --filter out one team if thisShip.Position:getDistance(RedFlag.Position) < 10 then --if one of those ships is touched the flag RedFlagBearer = thisShip -- he's the flagbearer! end else if RedDrop == 1 then RedDrop = 0 RedFlag.Position = RedBase.Position RedFlagBearer = nil end end endend----------------------CARRY GREEN FLAG----------------------if GreenFlagBearer ~= nil then --If the flag is being carried... GreenFlag.Position = GreenFlagBearer.Position --Make the Flag be carried ------------------- --RED TEAM SCORES-- ------------------- --if the enemy flag is at your base, and the RedFlag is at your base... if (GreenFlagBearer.Position:getDistance(RedBase.Position) < 10) and (RedFlagBearer == nil) and (RedDrop == 0) then GreenFlagBearer = nil --No more flagbearer GreenFlag.Position = GreenBase.Position --Flag goes back to the base RedScore = RedScore + 1 --And you get a point endendif GreenFlagBearer ~= nil then ------------------- --DROP GREEN FLAG-- ------------------- if GreenFlagBearer.HitpointsLeft < 1 then --If the flagbearer DIES GreenFlagBearer = nil --No flagbearer! GreenDrop = 1 --Dropped Flag flag (hehe) endend-----------------------PICKUP GREEN FLAG-----------------------if (GreenFlagBearer == nil) then --if GreenFlag isn't being carried for i = 1, mn.getNumShips() do --run though all ships thisShip = mn.getShipByIndex(i) if thisShip.Team ~= GreenFlag.Team then --filter out one team if thisShip.Position:getDistance(GreenFlag.Position) < 10 then --if one of those ships is touched the flag GreenFlagBearer = thisShip -- he's the flagbearer! end else --recovering a dropped flag if GreenDrop == 1 then GreenDrop = 0 GreenFlag.Position = GreenBase.Position GreenFlagBearer = nil end end endendend]$HUD:[if mn.getMissionFilename() == "bsgctftest" or mn.getMissionFilename() == "bsgctftest_mp" then --The mission MUST be named that to start the whole CTF thingswidth = gr.getScreenWidth()sheight = gr.getScreenHeight()halfwidth = swidth*0.5halfheight = sheight*0.5redX = swidth*0.6greenX = swidth*0.4teamX = sheight*0.1scoreX = sheight*0.12rednoticeY = sheight*0.15greennoticeY = sheight*0.17gr.setColor(192,0,0)gr.drawString("Red", redX, teamX)gr.drawString(RedScore, redX, scoreX)gr.setColor(0,128,0)gr.drawString("Green", greenX, teamX)gr.drawString(GreenScore, greenX, scoreX)if RedFlagBearer ~= nil then gr.setColor(192,0,0) gr.drawString("The Red Flag has been taken!", greenX, rednoticeY)endif GreenFlagBearer ~= nil then gr.setColor(0,128,0) gr.drawString("The Green Flag has been taken!", greenX, greennoticeY)endgr.setColor(255,255,255)gr.drawString("DEBUG: The Red Flagbearer is...", 100, 100)if RedFlagBearer = nil then gr.drawString("No one", 100, 110)else RedName = RedFlagBearer.Name gr.drawString(RedName, 100, 110)endgr.drawString("DEBUG: The Green Flagbearer is...", 200, 100)if GreenFlagBearer = nil then gr.drawString("No one", 200, 110)else GreenName = GreenFlagBearer.Name gr.drawString(GreenName, 200, 110)endend]#End