#Global Hooks
$Simulation:
[
--------------------------
--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 = 0
nullvec = ma.newVector(0,0,0)
end
RedFlag.Velocity = nullvec
GreenFlag.Velocity = nullvec
------------------
--CARRY RED FLAG--
------------------
if RedFlagBearer ~= nil then
RedFlag.Position = RedFlagBearer.Position
---------------------
--GREEN TEAM SCORES--
---------------------
if (RedFlagBearer.Position:getDistance(GreenBase.Position) < 50) and (GreenFlagBearer == nil) and (GreenDrop == 0) then
RedFlagBearer = nil
RedFlag.Position = RedBase.Position
GreenScore = GreenScore + 1
end
end
if RedFlagBearer ~= nil then
-----------------
--DROP RED FLAG--
-----------------
if RedFlagBearer.HitpointsLeft < 1 then
RedFlagBearer = nil
RedDrop = 1
end
end
-------------------
--PICKUP RED FLAG--
-------------------
if (RedFlagBearer == nil) then --if RedFlag isn't being carried
for i = 1, mn.getNumShips() do --run though all ships
thisShip = mn.getShipByIndex(i)
if thisShip.Position:getDistance(RedFlag.Position) < 10 then --if one of those ships is touched the flag
if thisShip.Team ~= RedFlag.Team then --filter out one team
RedFlagBearer = thisShip -- he's the flagbearer!
else --recovering a dropped flag
if RedDrop == 1 and thisShip ~= RedFlag then
--ba.error(thisShip.Name)
RedDrop = 0
RedFlag.Position = RedBase.Position
RedFlagBearer = nil
end
end
end
end
end
--------------------
--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) < 50) 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
end
end
if 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)
end
end
---------------------
--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.Position:getDistance(GreenFlag.Position) < 10 then --if one of those ships is touched the flag
if thisShip.Team ~= GreenFlag.Team then --filter out one team
GreenFlagBearer = thisShip -- he's the flagbearer!
else --recovering a dropped flag
if GreenDrop == 1 and thisShip ~= GreenFlag then
--ba.error(thisShip.Name)
GreenDrop = 0
GreenFlag.Position = GreenBase.Position
GreenFlagBearer = nil
end
end
end
end
end
]
$HUD:
[
swidth = gr.getScreenWidth()
sheight = gr.getScreenHeight()
halfwidth = swidth*0.5
halfheight = sheight*0.5
redX = swidth*0.6
greenX = swidth*0.4
teamX = sheight*0.1
scoreX = sheight*0.12
rednoticeY = sheight*0.15
greennoticeY = sheight*0.17
gr.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)
end
if GreenFlagBearer ~= nil then
gr.setColor(0,128,0)
gr.drawString("The Green Flag has been taken!", greenX, greennoticeY)
end
]
#End