Data Realms Fan Forums http://45.55.195.193/ |
|
Picking a faction to fight? http://45.55.195.193/viewtopic.php?f=4&t=31446 |
Page 1 of 1 |
Author: | hydroline [ Sun Jul 15, 2012 6:42 pm ] |
Post subject: | Picking a faction to fight? |
I was wondering how I can choose which faction to fight instead of them being randomly picked. I noramally play endless skirmish mode. |
Author: | No_0ne [ Mon Jul 16, 2012 4:36 am ] |
Post subject: | Re: Picking a faction to fight? |
Open up Constants.lua in the Base.rte, go to the line that says rte.TechList and remove the factions you don't want to fight against. So, if you only wanted to fight the Coalition, it would look like this: rte.TechList = {"Coalition"}; |
Author: | Joseh123 [ Tue Jul 17, 2012 5:34 am ] |
Post subject: | Re: Picking a faction to fight? |
Oh, and I also have a question related to the title and thread. Is there any way to change the Load outs to the ones of a specific faction without going on the campaign, just going to a normal skirmish battle? |
Author: | Sir [ Tue Jul 17, 2012 12:05 pm ] |
Post subject: | Re: Picking a faction to fight? |
Is there a way to make the AI use all factions instead of having only one faction to fight for the entire match? It gets very annoying building an awesome base only to get stuck with the dummys for the rest of the game. |
Author: | Cybernetic [ Fri Jul 20, 2012 10:22 am ] |
Post subject: | Re: Picking a faction to fight? |
For endless it would be really great if the factions cycled. There would be a lua timer and every few minutes the attacking faction would swap. Giving each faction a chance to go at you. I will try coding this myself in lua and post it here. I don't think you guys UNDERSTAND how long it took me to find this topic again. But here it is as promised, borowed my friends laptop to code this, was realy easy though. Copy all that in the spoiler into your Data Realms\Cortex Command\Base.rte\Activities\EndlessSkirmish.lua Code: package.loaded.Constants = nil; require("Constants"); function EndlessSkirmish:StartActivity() self.playertally = 0; self.playerlist = {}; for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do if self:PlayerActive(player) and self:PlayerHuman(player) then self.playerlist[player + 1] = true; self.playertally = self.playertally + 1; -- Check if we already have a brain assigned if not self:GetPlayerBrain(player) then 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 self.ActivityState = Activity.EDITING; -- Open all doors so we can do pathfinding through them with the brain placement MovableMan:OpenAllDoors(true, Activity.NOTEAM); AudioMan:ClearMusicQueue(); AudioMan:PlayMusic("Base.rte/Music/dBSoundworks/ccambient4.ogg", -1, -1); self:SetLandingZone(Vector(player*SceneMan.SceneWidth, 0), player) else -- Set the found brain to be the selected actor at start self:SetPlayerBrain(foundBrain, player); self:SwitchToActor(foundBrain, player, self:GetTeamOfPlayer(player)); self:SetLandingZone(self:GetPlayerBrain(player).Pos, 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 if not self.CPUTeam then self.CPUTeam = Activity.NOTEAM end -- Select a tech for the CPU player self.CPUTechName = rte.TechList[math.random(#rte.TechList)]; self.ESpawnTimer = Timer(); self.CycleTimer = Timer(); --CHANGE THIS TO SET THE TIME BETWEEN FACTION CYCLES!!!!!!! self.CycleTime = 64000; if self.Difficulty <= GameActivity.CAKEDIFFICULTY then self:SetTeamFunds(10000 * rte.StartingFundsScale, Activity.TEAM_1); self:SetTeamFunds(10000 * rte.StartingFundsScale, Activity.TEAM_2); self:SetTeamFunds(10000 * rte.StartingFundsScale, Activity.TEAM_3); self:SetTeamFunds(10000 * rte.StartingFundsScale, Activity.TEAM_4); self.BaseSpawnTime = 16000; self.RandomSpawnTime = 8000; elseif self.Difficulty <= GameActivity.EASYDIFFICULTY then self:SetTeamFunds(8000 * rte.StartingFundsScale, Activity.TEAM_1); self:SetTeamFunds(8000 * rte.StartingFundsScale, Activity.TEAM_2); self:SetTeamFunds(8000 * rte.StartingFundsScale, Activity.TEAM_3); self:SetTeamFunds(8000 * rte.StartingFundsScale, Activity.TEAM_4); self.BaseSpawnTime = 15500; self.RandomSpawnTime = 7000; elseif self.Difficulty <= GameActivity.MEDIUMDIFFICULTY then self:SetTeamFunds(6000 * rte.StartingFundsScale, Activity.TEAM_1); self:SetTeamFunds(6000 * rte.StartingFundsScale, Activity.TEAM_2); self:SetTeamFunds(6000 * rte.StartingFundsScale, Activity.TEAM_3); self:SetTeamFunds(6000 * rte.StartingFundsScale, Activity.TEAM_4); self.BaseSpawnTime = 15000; self.RandomSpawnTime = 6000; elseif self.Difficulty <= GameActivity.HARDDIFFICULTY then self:SetTeamFunds(4000 * rte.StartingFundsScale, Activity.TEAM_1); self:SetTeamFunds(4000 * rte.StartingFundsScale, Activity.TEAM_2); self:SetTeamFunds(4000 * rte.StartingFundsScale, Activity.TEAM_3); self:SetTeamFunds(4000 * rte.StartingFundsScale, Activity.TEAM_4); self.BaseSpawnTime = 14500; self.RandomSpawnTime = 5000; elseif self.Difficulty <= GameActivity.NUTSDIFFICULTY then self:SetTeamFunds(3000 * rte.StartingFundsScale, Activity.TEAM_1); self:SetTeamFunds(3000 * rte.StartingFundsScale, Activity.TEAM_2); self:SetTeamFunds(3000 * rte.StartingFundsScale, Activity.TEAM_3); self:SetTeamFunds(3000 * rte.StartingFundsScale, Activity.TEAM_4); self.BaseSpawnTime = 14000; self.RandomSpawnTime = 4500; elseif self.Difficulty <= GameActivity.MAXDIFFICULTY then self:SetTeamFunds(2000 * rte.StartingFundsScale, Activity.TEAM_1); self:SetTeamFunds(2000 * rte.StartingFundsScale, Activity.TEAM_2); self:SetTeamFunds(2000 * rte.StartingFundsScale, Activity.TEAM_3); self:SetTeamFunds(2000 * rte.StartingFundsScale, Activity.TEAM_4); self.BaseSpawnTime = 13500; self.RandomSpawnTime = 4000; end self.StartTimer = Timer(); self.TimeLeft = 1000; end function EndlessSkirmish:UpdateActivity() if self.ActivityState ~= Activity.OVER and self.ActivityState ~= Activity.EDITING then -- Close all doors after placing brains so our fortresses are secure if not self.StartTimer:IsPastSimMS(1000) then MovableMan:OpenAllDoors(false, Activity.NOTEAM); end -- Clear all objective markers, they get re-added each frame self:ClearObjectivePoints(); -- Keep track of which teams we have set objective points for already, since multiple players can be on the same team local setTeam = { [Activity.TEAM_1] = false, [Activity.TEAM_2] = false, [Activity.TEAM_3] = false, [Activity.TEAM_4] = false }; for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do if self:PlayerActive(player) and self:PlayerHuman(player) then if not self.StartTimer:IsPastSimMS(3000) then FrameMan:SetScreenText("Keep fighting to the end!", player, 333, 5000, true); end -- The current player's team local team = self:GetTeamOfPlayer(player); -- Check if any player's brain is dead if not MovableMan:IsActor(self:GetPlayerBrain(player)) then self:SetPlayerBrain(nil, player); self:ResetMessageTimer(player); FrameMan:ClearScreenText(player); FrameMan:SetScreenText("Your brain has been destroyed!", player, 333, -1, false); if self.playerlist[player + 1] then self.playerlist[player + 1] = false; self.playertally = self.playertally - 1; end else --Add objective points if not setTeam[team] then -- Add objective points self:AddObjectivePoint("Protect!", self:GetPlayerBrain(player).AboveHUDPos, team, GameActivity.ARROWDOWN); for otherPlayer = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do if otherPlayer ~= player and self:PlayerActive(otherPlayer) and self:PlayerHuman(otherPlayer) and MovableMan:IsActor(self:GetPlayerBrain(otherPlayer)) then local otherTeam = self:GetTeamOfPlayer(otherPlayer); if otherTeam ~= team then self:AddObjectivePoint("Destroy!", self:GetPlayerBrain(otherPlayer).AboveHUDPos, team, GameActivity.ARROWDOWN); else self:AddObjectivePoint("Protect!", self:GetPlayerBrain(otherPlayer).AboveHUDPos, team, GameActivity.ARROWDOWN); end end end setTeam[team] = true; end end end end if self.CPUTeam ~= Activity.NOTEAM and self.CycleTimer:IsPastSimMS(self.CycleTime) then self.CycleTimer:Reset() self.CycleTime = 16000; self.CPUTechName = rte.TechList[math.random(#rte.TechList)]; FrameMan:SetScreenText(TechList[math.random(#rte.TechList)].."are attacking", player, 333, 5000, true); end -- Spawn the AI if self.CPUTeam ~= Activity.NOTEAM and self.ESpawnTimer:IsPastSimMS(self.TimeLeft) then self.ESpawnTimer:Reset() self.TimeLeft = (self.BaseSpawnTime + math.random(self.RandomSpawnTime) * rte.SpawnIntervalScale) if MovableMan:GetMOIDCount() < rte.MOIDCountMax then local ship, actorsInCargo if PosRand() < 0.6 then -- Set up the ship to deliver this stuff ship = RandomACDropShip("Craft", self.CPUTechName); actorsInCargo = rte.PassengerMax else ship = RandomACRocket("Craft", self.CPUTechName); actorsInCargo = math.min(math.random(2), rte.PassengerMax) end if ship then ship.Team = self.CPUTeam -- Set the ship up with a cargo of a few armed and equipped actors for i = 1, actorsInCargo do -- Get any Actor from the CPU's native tech local passenger if PosRand() > rte.CrabToHumanSpawnRatio * 0.5 then passenger = RandomAHuman("Actors", self.CPUTechName); passenger:AddInventoryItem(RandomHDFirearm("Primary Weapons", self.CPUTechName)); passenger:AddInventoryItem(RandomHDFirearm("Secondary Weapons", self.CPUTechName)); if PosRand() < 0.5 then passenger:AddInventoryItem(RandomHDFirearm("Diggers", self.CPUTechName)); end else passenger = RandomACrab("Mecha", self.CPUTechName); end -- Set AI mode and team so it knows who and what to fight for! passenger.AIMode = Actor.AIMODE_BRAINHUNT; passenger.Team = self.CPUTeam; ship:AddInventoryItem(passenger); end -- Find a good place to land if not self.CPU_LZx or PosRand() < 0.2 then self.CPU_LZx = self:DesignateLZs() end -- Set the spawn point of the ship from orbit ship.Pos.X = self.CPU_LZx + RangeRand(-300, 300) ship.Pos.Y = -50 ship.Vel.Y = 5 if SceneMan.SceneWrapsX then if ship.Pos.X > SceneMan.SceneWidth then ship.Pos.X = ship.Pos.X - SceneMan.SceneWidth elseif ship.Pos.X < 0 then ship.Pos.X = ship.Pos.X + SceneMan.SceneWidth end else if ship.Pos.X > SceneMan.SceneWidth - 100 then ship.Pos.X = SceneMan.SceneWidth - 100 elseif ship.Pos.X < 100 then ship.Pos.X = 100 end end -- Spawn the ship onto the scene MovableMan:AddActor(ship); end end end --Win/Lose Conditions if self.CPUTeam == Activity.NOTEAM then local setTeam = { [Activity.TEAM_1] = false, [Activity.TEAM_2] = false, [Activity.TEAM_3] = false, [Activity.TEAM_4] = false } for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do if self:PlayerActive(player) and self:PlayerHuman(player) and MovableMan:IsActor(self:GetPlayerBrain(player)) then setTeam[self:GetTeamOfPlayer(player)] = true end end local activeTeams = 0 local lastTeam = -1 for team = Activity.TEAM_1, Activity.TEAM_4 do if setTeam[team] then activeTeams = activeTeams + 1 lastTeam = team end end if activeTeams == 1 then self.WinnerTeam = lastTeam ActivityMan:EndActivity() elseif activeTeams < 1 then ActivityMan:EndActivity() end elseif self.playertally == 0 then self.WinnerTeam = self.CPUTeam ActivityMan:EndActivity() end else -- Game is in editing or other modes, so open all does and reset the game running timer MovableMan:OpenAllDoors(true, Activity.NOTEAM) self.StartTimer:Reset() for actor in MovableMan.AddedActors do if actor.ClassName ~= "ADoor" then actor.AIMode = Actor.AIMODE_SENTRY end end end end ----------------------------------------------- -- Make sure that all players have a LZ function EndlessSkirmish:DesignateLZs() -- First, get the player LZs local OccupiedLZs = {} for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do if self:PlayerHuman(player) then -- The players have placed the LZs by now, insert them in to the occupied list local PlayerLZ = self:GetLandingZone(player) table.insert(OccupiedLZs, {x=PlayerLZ.X, team=self:GetTeamOfPlayer(player)}) end end -- Find a good spot to land return self:FindLZ(self.CPUTeam, OccupiedLZs, false) -- allow the AI to cheat and see all enemy units end ----------------------------------------------- -- Find the best LZ possible function EndlessSkirmish:FindLZ(myTeam, OccupiedLZs, SceneLZs, ignoreUnseen) -- Assing a value to each XY position on the map depending on how many units have LOS to it local LOSgrid = {} local Dist, SeePos, mag, range local Free = Vector() local size = 80 for Act in MovableMan.Actors do if Act.Team ~= myTeam and Act.ClassName ~= "ADoor" then if not ignoreUnseen or not SceneMan:IsUnseen(Act.Pos.X, Act.Pos.Y, myTeam) then -- don't calculate the LOS for unseen actors if ignoreUnseen is true -- Cast rays in all directions (if the actor is visible to this team) for i = 0, 1 do for ang = math.pi*i-1, math.pi*i+1, 0.2 do if 0 ~= SceneMan:CastObstacleRay(Act.EyePos, Vector(FrameMan.PlayerScreenWidth, 0):RadRotate(ang), Vector(), Free, Act.ID, Act.IgnoresWhichTeam, rte.grassID, 7) then Dist = SceneMan:ShortestDistance(Act.EyePos, Free, false) mag = Dist.Magnitude for i = 10, mag, size do range = i / mag SeePos = Act.EyePos + Dist * range SeePos.X = math.floor(SeePos.X/size+0.5) * size SeePos.Y = math.floor(SeePos.Y/size+0.5) * size if not LOSgrid[SeePos.X] then LOSgrid[SeePos.X] = {} end -- Assign a score to this XY-position, higher means worse LZ LOSgrid[SeePos.X][SeePos.Y] = (LOSgrid[SeePos.X][SeePos.Y] or 0) + (2-range) end end end end end end end -- Cast rays down towards the ground and caluculate how visible our descent is to the enemy local LZs = {} local Hit = Vector() local height = math.floor((SceneMan.SceneHeight-size)/size)*size local score for x = 0, SceneMan.SceneWidth, size do if SceneMan:CastObstacleRay(Vector(x, 0), Vector(0, height), Hit, Vector(), 0, -1, rte.grassID, 7) > size*2 then score = 0 if LOSgrid[x] then for y = 0, Hit.Y, size do if LOSgrid[x][y] then score = score + LOSgrid[x][y] end end end LZs[#LZs+1] = {Pos=Vector(x, Hit.Y), score=score} else LZs[#LZs+1] = {Pos=Vector(x, 0), score=2} -- This LZ is not accessible, so it might be dangerous to try to land next to it end end -- Inspect all potential LZs and adjust the score depending on adjacent LZs local weight = 0.8 -- n% of the new score come from the LZ's own score, the rest from the neighbours local NextLZ for i = 2, #LZs do if LZs[i+1] then NextLZ = LZs[i+1] else NextLZ = LZs[1] end LZs[i].score = LZs[i-1].score*(1-weight)/2 + LZs[i].score*weight + NextLZ.score*(1-weight)/2 -- Adjust score for LZ "flattnes" LZs[i].score = LZs[i].score + (math.abs(LZs[i-1].Pos.Y - LZs[i].Pos.Y) - 20) / 200 -- a Y difference above 20 reduce the chance of picking this LZ LZs[i].score = LZs[i].score + (math.abs(NextLZ.Pos.Y - LZs[i].Pos.Y) - 20) / 200 end if OccupiedLZs and #OccupiedLZs > 0 then local distance, worst for i = 1, #LZs do worst = -100 -- Increase the score around any existing LZs to avoid collisions for _, OcLZ in pairs(OccupiedLZs) do distance = SceneMan:ShortestDistance(LZs[i].Pos, Vector(OcLZ.x, LZs[i].Pos.Y), false).Largest / SceneMan.SceneWidth if OcLZ.team == myTeam then worst = math.max(worst, LZs[i].score + 10 * math.exp(-(distance*distance)/0.05)) -- Increase the score around the LZ else worst = math.max(worst, LZs[i].score + 15 * math.exp(-(distance*distance)/0.2)) -- Increase the score over the whole scene, but with an exponential drop off end end LZs[i].score = worst end end -- Remove the worst 50% of the LZs table.sort(LZs, function(A, B) return A.score < B.score end) for i = 1, math.floor(#LZs/2) do table.remove(LZs) end -- Invert and normalize the score so the best LZ has the highest score local worstScore = LZs[#LZs].score local bestScore = worstScore - LZs[1].score + 1 for _, LZ in pairs(LZs) do LZ.score = (worstScore - LZ.score + 1) / bestScore end -- Use Softmax to pick one of the n best LZs local sum = 0 for _, LZ in pairs(LZs) do sum = sum + math.exp(10 * LZ.score) end if sum > 0 then local pick = math.random() * sum sum = 0 for _, LZ in pairs(LZs) do sum = sum + math.exp(10 * LZ.score) if sum >= pick then return LZ.Pos.X end end end -- No safe LZ found; pick a LZ at random return math.random(SceneMan.SceneWidth) end Also if you want to play against all factions: Code: -- Misc global constants.. add whatever you like and thinks makes sense across multiple scripts. All should be under the rte table rte = {}; -- This will be replaced by a more data driven system soon rte.TechList = {"Coalition", "Dummy", "Ronin", "Techion","Browncoats", "Imperatus"}; rte.OffensiveLoadouts = {"Default", "Infantry Light", "Infantry Heavy", "Infantry CQB", "Infantry Grenadier", "Infantry Sniper", "Mecha"}; rte.DefensiveLoadouts = {"Default", "Infantry Heavy", "Infantry CQB", "Infantry Sniper", "Infantry Engineer", "Mecha"}; rte.EngineerLoadouts = {"Infantry Engineer"}; rte.MOIDCountMax = 210; rte.SpawnIntervalScale = 1.0; rte.StartingFundsScale = 1.0; rte.PassengerMax = 3; -- Should be defined in the ini of each ship rte.ShipMassMax = 2250; rte.CrabToHumanSpawnRatio = 0.25; -- Materials rte.airID = 0; rte.goldID = 2; rte.doorID = 4; -- Xenocronium rte.grassID = 128; -- AI movement rte.Obst = {R_LOW = 1, R_FRONT = 2, R_HIGH = 3, R_UP = 5, L_UP = 6, L_HIGH = 8, L_FRONT = 9, L_LOW = 10}; that you replace in Cortex Command\Base.rte\Constants.lua |
Author: | Sir [ Sun Jul 22, 2012 4:48 am ] |
Post subject: | Re: Picking a faction to fight? |
Cybernetic wrote: Copy all that in the spoiler into your Data Realms\Cortex Command\Base.rte\Activities\EndlessSkirmish.lua I did, but every time I go into endless skirmish defense the lua console says something along the lines of "endless skirmish defense was NOT started due to errors". Do I copy it into Data Realms\Cortex Command\Base.rte\Activities\EndlessSkirmish.lua, or do I replace it? |
Author: | Joseh123 [ Mon Jul 23, 2012 1:35 am ] |
Post subject: | Re: Picking a faction to fight? |
I think you gotta replace it... If you did, then copy |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |