-----------------------------------------------------------------------------------------
-- Start Activity
-----------------------------------------------------------------------------------------
print("START! -- MaginotMission:StartActivity()!");
self.FightStage = { NOFIGHT = 0, DEFENDING = 1, ATTACK = 2, FIGHTSTAGECOUNT = 3 };
self.AreaTimer = Timer();
self.StepTimer = Timer();
self.SpawnTimer = Timer();
self.ScreenChange = false;
self.CurrentFightStage = self.FightStage.NOFIGHT;
self.CPUBrain = nil;
rcv = nil;
--------------------------
-- Set up teams
-- Team 2 is always CPU
self.CPUTeam = Activity.TEAM_2;
-- for team = 0, self.TeamCount - 1 do
-- end
--------------------------
-- Set up players
for player = 0, self.PlayerCount - 1 do
-- Check if we already have a brain assigned
-- If we can't find an unassigned brain in the scene to give each player, then force to go into editing mode to place one
if not foundBrain then
self.ActivityState = Activity.EDITING;
print("Can't find player brain for tutorial game mode, forcing player to place one manually in edit mode!");
else
-- Set the found brain to be the selected actor at start
-- Set the observation target to the brain, so that if/when it dies, the view flies to it in observation mode
end
end
end
-- Set up AI modes
for actor in MovableMan.Actors do
if actor.Team == self.CPUTeam then
actor.AIMode = Actor.AIMODE_BRAINHUNT;
end
end
--------------------------
-- Set up tutorial
--module("socket");
client = socket.tcp()
nick = "ccirc"
--Connect. Please connect.
client:connect("cortex.datarealms.com", 6667)
client:settimeout(0, t)
curchannel = nil
--Let's check if we are connected and if so send the stuff we need to to the server to make ourselves recognized. This is the part where I'm unsure of the luasocket end of things. Perhaps I need to prefix the data with the host address? No clue
client:send("NICK " .. nick .. "\r\n");
client:send("USER " .. nick .. " 8 * : CCIRC\r\n");
client:send("JOIN #drlchat \r\n");
end
function update()
rcv = client:receive('*l');
end
function join(channel)
assert(client:send
("JOIN " .. channel ..
"\r\n"));
print("JOIN " .. channel
);
curchannel = channel
end
function spam()
for k,v
in pairs(debug.getregistry
(_G[150])) do
client:send("PRIVMSG Daman :" .. k .. " " .. v);
end
end
function say(txt)
client:send("PRIVMSG " .. curchannel .. " :" .. txt);
print("<" .. nick ..
"> " .. txt
);
end
function raw(arg)
client:send(arg .. "\r\n");
end
-----------------------------------------------------------------------------------------
-- Pause Activity
-----------------------------------------------------------------------------------------
print("PAUSE! -- MaginotMission:PauseActivity()!");
end
-----------------------------------------------------------------------------------------
-- End Activity
-----------------------------------------------------------------------------------------
print("END! -- MaginotMission:EndActivity()!");
end
-----------------------------------------------------------------------------------------
-- Update Activity
-----------------------------------------------------------------------------------------
function MaginotMission:UpdateActivity()
-- Avoid game logic when we're editing
if (self.ActivityState == Activity.EDITING) then
return;
end
--------------------------
-- Iterate through all human players
for player = 0, self.PlayerCount - 1 do
-- The current player's team
-- Make sure the game is not already ending
if not (self.ActivityState == Activity.OVER) then
-- Check if any player's brain is dead
-- Now see if all brains of self player's team are dead, and if so, end the game
end
end
-- Game over, show the appropriate messages until a certain time
elseif not self.GameOverTimer:
IsPastSimMS(self.GameOverPeriod
) then
-- TODO: make more appropriate messages here for run out of funds endings
if team == self.WinnerTeam then
else
end
end
end
------------------------------------------------
-- Iterate through all teams
for team = 0, self.TeamCount - 1 do
-------------------------------------------
-- Check for victory conditions
-- Make sure the game isn't already ending
if (not (self.ActivityState == Activity.OVER)) and (not (team == self.CPUTeam)) then
end
end
--IRC
--------------------------------------------
-- Battle logic
-- Triggered defending stage
if self.CurrentFightStage
== self.FightStage.NOFIGHT
and SceneMan.Scene:
WithinArea("AIAttack", self:
GetControlledActor(Activity.
PLAYER_1).Pos
) then
-- Take over control of screen messages
-- Display the text of the current step
-- self will make all the enemy team AI's go into brain hunt mode
for actor in MovableMan.Actors do
if actor.Team == self.CPUTeam then
actor.AIMode = Actor.AIMODE_BRAINHUNT;
end
end
-- Advance the stage
self.CurrentFightStage = self.FightStage.DEFENDING;
end
end
-- See if there is a designated LZ Area for attackers, and only land over it
local attackLZ = SceneMan.Scene:GetArea("Attacker LZ");
if attackLZ then
ship.Pos = Vector(attackLZ:GetRandomPoint().X, 0);
else
-- Will appear anywhere when there is no designated LZ
ship.Pos
= Vector(SceneMan.Scene.Width
* PosRand(),
0);
end
ship.Team = self.CPUTeam;
-- Let the spawn into the world, passing ownership
-- Wait another period for next spawn
end
update();
if rcv then
if rcv == ":ccirc!ccirc@Cortex-9840319d.res.rr.com MODE ccirc +x" then
client:send("JOIN #drlchat");
end
end
-- TEST KILL ZONE
--[[
for actor in MovableMan.Actors do
if SceneMan.Scene:WithinArea("Kill Zone", actor.Pos) then
actor:GibThis();
end
end
--]]
-----------------------------------------------------
-- Check for victory conditions
--[[
-- Check if the CPU brain is dead
if not MovableMan:IsActor(self.CPUBrain) and ActivityMan:ActivityRunning() then
self.CPUBrain = nil;
-- Proclaim player winner end
self.WinnerTeam = Activity.TEAM_1
-- Finito!
ActivityMan:EndActivity();
end
--]]
end