How would I go about placing invisible brains (that are unselectable to players and also invisible to the AI) if there happens to be additional human players (2-4) for either team 1 or 2 in a
mission?
So far i tried the "invisible brain" code from exodus mission and got it to work somewhat, but the AI still goes after it and the brain can be selected. Also, when multiple human players are present (for example 2 in team 1 and one person in team 2) the game just crashes right after the mission starts.
I don't have alot of previous coding experience, so I apologize beforehand for my mistakes!
I think here I also tried to create a soldier (or a dummy) that would get selected at start instead of the brain
Code:
for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do
if self:PlayerActive(player) and self:PlayerHuman(player) then
-- Check if we already have a brain assigned
if not self:GetPlayerBrain(player) then
self.braindead[player] = false;
local foundBrain = MovableMan:GetUnassignedBrain(self:GetTeamOfPlayer(player));
-- 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
--Create an invisible brain.
self.brain = CreateActor("Base.rte/Brain Case");
self.brain.Team = self:GetTeamOfPlayer(player);
self.brain.Pos = Vector(320,234);
self.brain:SetAimAngle(math.pi / -5)
self.brain.HFlipped = true;
self.brain.Scale = 0;
self.brain.GetsHitByMOs = false;
self.brain.HitsMOs = false;
if self.brain.Team == Activity.TEAM_2 then
self.p2soldier = CreateAHuman("Dummy");
self.p2soldier.Team = Activity.TEAM_2;
self.p2soldier.Pos = Vector(1704,1428);
self.p2soldier:AddInventoryItem(CreateHDFirearm("Blaster"));
MovableMan:AddActor(self.p2soldier);
MovableMan:AddActor(self.brain);
else
self.p2soldier = CreateAHuman("Soldier Light");
self.p2soldier.Team = Activity.TEAM_1;
self.p2soldier.Pos = Vector(1704,1428);
self.p2soldier:AddInventoryItem(CreateHDFirearm("Coalition.rte/Assault Rifle"));
MovableMan:AddActor(self.p2soldier);
MovableMan:AddActor(self.brain);
end
self:SetPlayerBrain(self.brain,player);
self:SwitchToActor(self.p2soldier,player,-1);
else
-- Set the found brain to be the selected actor at start
self:SetPlayerBrain(foundBrain, player);
self:SwitchToActor(foundBrain, player, self:GetTeamOfPlayer(player));
-- Set the observation target to the brain, so that if/when it dies, the view flies to it in observation mode
self:SetObservationTarget(self:GetPlayerBrain(player).Pos, player)
end
end
end
end