Turning Off local sides mid match

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
ZoomV
Rebel Warrant Officer
Rebel Warrant Officer
Posts: 308
Joined: Thu Aug 15, 2013 11:27 am
Projects :: Old Republic Map pack
Games I'm Playing :: BF2 SWTOR and GW2
xbox live or psn: No gamertag set
Location: Belsavis, Maximum Security Ward

Turning Off local sides mid match

Post by ZoomV »

So I'm trying to get it to where certain local side teams cease to spawn after the reinforcement count gets so low.


I'm new to scripting but this is what I have tried in ScriptPostLoad

Code: Select all

    	if GetReinforcementCount(DEF) < 40 then
    		SetUnitCount(WarDroidTeam, 0)
		SetUnitCount(SithTeam, 0)
    	end
Unfortunately its not working.

here is the full script.
Hidden/Spoiler:
[code]--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("ObjectiveConquest")


-- Empire Attacking (attacker is always #1)
local IMP = 1;
local REP = 2;
-- These variables do not change
local ATT = IMP;
local DEF = REP;

WarDroidTeam = 3;
SithTeam = 4;

function ScriptPostLoad()


--This defines the CPs. These need to happen first
cp1 = CommandPost:New{name = "cp1"}
cp2 = CommandPost:New{name = "cp2"}
cp3 = CommandPost:New{name = "cp3"}
cp4 = CommandPost:New{name = "cp4"}
cp5 = CommandPost:New{name = "cp5"}
cp6 = CommandPost:New{name = "cp6"}
cp7 = CommandPost:New{name = "cp7"}
cp8 = CommandPost:New{name = "cp8"}
cp9 = CommandPost:New{name = "cp9"}



--This sets up the actual objective. This needs to happen after cp's are defined
conquest = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF,
textATT = "game.modes.con",
textDEF = "game.modes.con2",
multiplayerRules = true}

--This adds the CPs to the objective. This needs to happen after the objective is set up
conquest:AddCommandPost(cp1)
conquest:AddCommandPost(cp2)
conquest:AddCommandPost(cp3)
conquest:AddCommandPost(cp4)
conquest:AddCommandPost(cp5)
conquest:AddCommandPost(cp6)
conquest:AddCommandPost(cp7)
conquest:AddCommandPost(cp8)
conquest:AddCommandPost(cp9)

SetAIDifficulty(SithTeam, 1, "medium")

conquest:Start()

SetUberMode(1);
EnableAIAutoBalance();


if GetReinforcementCount(DEF) < 40 then
SetUnitCount(WarDroidTeam, 0)
SetUnitCount(SithTeam, 0)
end

EnableSPHeroRules()
AddDeathRegion("death")
end[/code]
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: Turning Off local sides mid match

Post by Marth8880 »

Code: Select all

	-- spawn block for Husks -- 
	OnTicketCountChange(
		function (team, count)
			if team == CIS and count <= 20 then
					print("ME5_ObjectiveConquest: Blocking HuskTeam spawn")
				AllowAISpawn(3, false)
			else end
		end
		)
Replace "CIS" with the ID of the team whose tickets you want to be monitored.
ZoomV
Rebel Warrant Officer
Rebel Warrant Officer
Posts: 308
Joined: Thu Aug 15, 2013 11:27 am
Projects :: Old Republic Map pack
Games I'm Playing :: BF2 SWTOR and GW2
xbox live or psn: No gamertag set
Location: Belsavis, Maximum Security Ward

Re: Turning Off local sides mid match

Post by ZoomV »

Marth8880 wrote:

Code: Select all

	-- spawn block for Husks -- 
	OnTicketCountChange(
		function (team, count)
			if team == CIS and count <= 20 then
					print("ME5_ObjectiveConquest: Blocking HuskTeam spawn")
				AllowAISpawn(3, false)
			else end
		end
		)
Replace "CIS" with the ID of the team whose tickets you want to be monitored.
I have

Code: Select all

   OnTicketCountChange(
      function (team, count)
         if team == IMP and count <= 40 then
            AllowAISpawn(3, false)
            --AllowAISpawn(4, false)
         else end
	 if team == REP and count <= 40 then
            AllowAISpawn(6, false)
         else end
      end
      )
And its definitely not working.
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: Turning Off local sides mid match

Post by Marth8880 »

Try putting it in the ObjectiveConquest:Start() function of ObjectiveConquest.lua.
ZoomV
Rebel Warrant Officer
Rebel Warrant Officer
Posts: 308
Joined: Thu Aug 15, 2013 11:27 am
Projects :: Old Republic Map pack
Games I'm Playing :: BF2 SWTOR and GW2
xbox live or psn: No gamertag set
Location: Belsavis, Maximum Security Ward

Re: Turning Off local sides mid match

Post by ZoomV »

Marth8880 wrote:Try putting it in the ObjectiveConquest:Start() function of ObjectiveConquest.lua.
That's a bit problematic because I have several conquest scripts for several maps in that one mission.lvl. And not all of them have local sides and the ones that do don't have matching side numbers.
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: Turning Off local sides mid match

Post by Marth8880 »

Is there any particular reason why you have more than one or two Conquest scripts? :o

Regardless, that's a relatively easy fix. In each map, create a variable called mapHasLocalTeams (or something) and set its value to true or false depending on whether or not the map has local teams. Additionally, in each map with local teams, create a variable called localTeamToBlock (or something) and assign it the local team ID whose spawn should be blocked in that map. Then, change the first argument for the AllowAISpawn() function to the variable name. Finally, put the entire OnTicketCountChange() function into an if...then statement that checks if mapHasLocalTeams is true and if so, runs the function.
ZoomV
Rebel Warrant Officer
Rebel Warrant Officer
Posts: 308
Joined: Thu Aug 15, 2013 11:27 am
Projects :: Old Republic Map pack
Games I'm Playing :: BF2 SWTOR and GW2
xbox live or psn: No gamertag set
Location: Belsavis, Maximum Security Ward

Re: Turning Off local sides mid match

Post by ZoomV »

Marth8880 wrote:Is there any particular reason why you have more than one or two Conquest scripts? :o
I mean I have multiple maps in the same directory, so they naturally all are in the same mission.lvl. So if I modify the ObjectiveConquest LUA it affects all of the maps, which is problematic since the local sides are not even remotely standardized.
Marth8880 wrote: Regardless, that's a relatively easy fix. In each map, create a variable called mapHasLocalTeams (or something) and set its value to true or false depending on whether or not the map has local teams. Additionally, in each map with local teams, create a variable called localTeamToBlock (or something) and assign it the local team ID whose spawn should be blocked in that map. Then, change the first argument for the AllowAISpawn() function to the variable name. Finally, put the entire OnTicketCountChange() function into an if...then statement that checks if mapHasLocalTeams is true and if so, runs the function.
What about maps with multiple local sides that need blocking but those local sides are blocked based on different criteria? For instance ACW has two local sides that both have to be blocked when the DEF team's reinforcements get low. BVS has 4 local sides of which 2 need blocking but the first needs to be blocked when the ATT team's reinforcements get low and the other needs to be blocked when the DEF team's reinforcements get low.

If I'm going to put this in the ObjectiveConquest LUA I need a highly adaptive way of doing it.
Post Reply