Campaign ambush as objective?

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

Commander_Fett
High General
High General
Posts: 847
Joined: Fri Oct 17, 2008 9:59 pm
Projects :: No Mod project currently.

Campaign ambush as objective?

Post by Commander_Fett »

I was working on a campaign map, and I set up 2 ambush regions, but I was wondering, how could I make it an objective to kill the units in the ambush? I'm not sure how, since the assault script calls for cps. Example:

Code: Select all

--objective: assault
    Objective2= ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
										text = "level.mad.campaign.2", popupText = "level.mad.campaign.2_popup"}	

	Dclass = TargetType:New{classname = "amb_inf_marine", killLimit = 8}
	Objective2:AddTarget(Dclass)
	
	Objective2.OnStart = function(self)
		Objective2.Dclass_cpGoal1 = AddAIGoal(ATT, "Defend", 100, "ambush cp one name here")
		Objective2.Dclass_cpGoal2 = AddAIGoal(amb, "Defend", 100, "ambush cp one name here")
	end
	
	Objective2.OnComplete = function(self)
		DeleteAIGoal(Objective2.Dclass_cpGoal1)
		DeleteAIGoal(Objective2.Dclass_cpGoal2)
	end


How would I edit this so it's just a deathmatch, and not calling for cps to deffend?

EDIT: Also, if I wanted the Attacking teakm to destroy 2 technounion ship cps, both the same type, and both with different names (cp_tec_1 and cp_tec_2), would the script be like this?

Code: Select all

--objective: assault
    Objective4= ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
										text = "level.mad.campaign.4", popupText = "level.mad.campaign.4_popup"}	

	Dclass = TargetType:New{classname = "geo_building_technounion_cp", killLimit = 2}
	Objective4:AddTarget(Dclass)
	
	Objective4.OnStart = function(self)
		Objective4.Dclass_cpGoal1 = AddAIGoal(ATT, "Defend", 100, "cp_tec_2, cp_tec_1")
		Objective4.Dclass_cpGoal2 = AddAIGoal(DEF, "Defend", 100, "cp_tec_2, cp_tec_1")
	end
	
	Objective4.OnComplete = function(self)
		DeleteAIGoal(Objective4.Dclass_cpGoal1)
		DeleteAIGoal(Objective4.Dclass_cpGoal2)
	end


User avatar
Eggman
Master Bounty Hunter
Master Bounty Hunter
Posts: 1516
Joined: Mon Jul 16, 2007 1:30 pm
Projects :: Battlefront Chronicles
Location: Las Vegas

Re: Campaign ambush as objective?

Post by Eggman »

Regarding the ambush, that looks like it should be okay. The only reference to cp's in that is in AI goals. If you don't want the AI to follow those goals, you can just delete them. I have a similar objective set up in one of my maps; here's what it would look like without AI goals:

Code: Select all

--Objective 5: Kill some SBDs
	Objective5 = ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF, text = "level.al3.objectives.5", popupText = "level.al3.objectives.campaign.5_popup2"}	

	SBD = TargetType:New{classname = "cis_inf_b2", killLimit = 5}
	Objective5:AddTarget(SBD)

	Objective5.OnStart = function(self)

	end
	
	Objective5.OnComplete = function(self)

	end
For just a straight deathmatch, that's how it should be set up.

Objectives where you destroy certain objects should be set up something like this:

Code: Select all

--Objective X: destroy objects (put whatever you want on this line, it doesn't really matter)
    name of first target = Target:New{name = "name of object in ZE"}
    name of second target = Target:New{name = "name of object in ZE"}
    ObjectiveX = ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF, text = "name of text", popupText = "name of popup text",  AIGoalWeight = 0}
    ObjectiveX:AddTarget(name of first target)
    ObjectiveX:AddTarget(name of second target)

    ObjectiveX.OnStart = function(self)

    end
   
    ObjectiveX.OnComplete = function(self)

    end
Where "X" is the numerical designation of your objective (or whatever else you use to designate them) and "name of first/second target" is whatever you want to use to designate the target in the script. AIGoalWeight refers to whether or not the AI try to complete the same objective, with "0" meaning they ignore the goal, and higher numbers meaning they're more likely to try to complete the goal (I think). The rest should be pretty self-explanatory.

Another example from one of my scripts:

Code: Select all

--Objective 10: Destroy the turrets
    turret1 = Target:New{name = "turret1"}
    turret2 = Target:New{name = "turret2"}
    Objective10 = ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF, text = "level.al3.objectives.10", popupText = "level.al3.objectives.campaign.10_popup",  AIGoalWeight = 0}
    Objective10:AddTarget(turret1)
    Objective10:AddTarget(turret2)

    Objective10.OnStart = function(self)

    end
    
    Objective10.OnComplete = function(self)

    end
Commander_Fett
High General
High General
Posts: 847
Joined: Fri Oct 17, 2008 9:59 pm
Projects :: No Mod project currently.

Re: Campaign ambush as objective?

Post by Commander_Fett »

So, Mine should look something like this:

Code: Select all

-objective: assault
    Objective2= ObjectiveAssault:New{teamATT = ATT, teamDEF = amb,
										text = "level.mad.campaign.2", popupText = "level.mad.campaign.2_popup"}	

	amb = TargetType:New{classname = "amb_inf_marine", killLimit = 8}
	Objective2:AddTarget(amb)
	
	Objective2.OnStart = function(self)
	end
	
	Objective2.OnComplete = function(self)
	end

Code: Select all

--objective: destroy the techno union ships

    cp_tec_1 = Target:New{name = "cp_tec_1"}
    cp_tec_2 = Target:New{name = "cp_tec_2"}
    Objective4= ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
										text = "level.mad.campaign.4", popupText = "level.mad.campaign.4_popup"}	

    Objective4:AddTarget(cp_tec_1)
    Objective4:AddTarget(cp_tec_2)

	
	Objective4.OnStart = function(self)
		Objective4.Dclass_cpGoal1 = AddAIGoal(ATT, "Defend", 100, "cp_tec_2, cp_tec_1")		Objective4.Dclass_cpGoal2 = AddAIGoal(DEF, "Defend", 100, "cp_tec_2, cp_tec_1")
	end-- note: would these work?
	
	Objective4.OnComplete = function(self)
		DeleteAIGoal(Objective4.Dclass_cpGoal1)
		DeleteAIGoal(Objective4.Dclass_cpGoal2)
	end
User avatar
Eggman
Master Bounty Hunter
Master Bounty Hunter
Posts: 1516
Joined: Mon Jul 16, 2007 1:30 pm
Projects :: Battlefront Chronicles
Location: Las Vegas

Re: Campaign ambush as objective?

Post by Eggman »

First one looks good, but you might need to add another "-" right at the beginning of the first line.

The second one also looks fine except for the AI goals; I'm pretty sure you'll need to adjust your quotes so the lines look like this:

Code: Select all

      Objective4.Dclass_cpGoal1 = AddAIGoal(ATT, "Defend", 100, "cp_tec_2", "cp_tec_1")
      Objective4.Dclass_cpGoal2 = AddAIGoal(DEF, "Defend", 100, "cp_tec_2", "cp_tec_1")
Commander_Fett
High General
High General
Posts: 847
Joined: Fri Oct 17, 2008 9:59 pm
Projects :: No Mod project currently.

Re: Campaign ambush as objective?

Post by Commander_Fett »

Well, I tried it out, but it keeps giving me an error with those two lines.

Code: Select all

C:\BF2_ModTools\ToolsFL\Bin\luac.exe: ..\..\common\scripts\MAD\MADc_c.lua:224: `)' expected near `"cp_tec_1"'
ERROR[scriptmunge scripts\MAD\MADc_c.lua]:Could not read input file.ERROR[scriptmunge scripts\MAD\MADc_c.lua]:Could not read input file. [continuing]
   2 Errors    0 Warnings
User avatar
Eggman
Master Bounty Hunter
Master Bounty Hunter
Posts: 1516
Joined: Mon Jul 16, 2007 1:30 pm
Projects :: Battlefront Chronicles
Location: Las Vegas

Re: Campaign ambush as objective?

Post by Eggman »

Hm, I don't know for sure if I had the right set up for the AI goals, so try removing them from the objective. If you no longer get the error message, you'll know that those lines are the problem. If they are what's causing the problem, try setting up the goals for each ship separately, rather than specifying both within the goals. In other words, give each team two goals, one for each ship.
Commander_Fett
High General
High General
Posts: 847
Joined: Fri Oct 17, 2008 9:59 pm
Projects :: No Mod project currently.

Re: Campaign ambush as objective?

Post by Commander_Fett »

Okay, I edited that code out, and now it munges. So, could I just add them in like this:

Code: Select all

     Objective4.Dclass_cpGoal1 = AddAIGoal(ATT, "Defend", 100, "cp_tec_1")
     Objective4.Dclass_cpGoal2 = AddAIGoal(DEF, "Defend", 100, "cp_tec_1")
     Objective4.Dclass_cpGoal1 = AddAIGoal(ATT, "Defend", 100, "cp_tec_2")
     Objective4.Dclass_cpGoal2 = AddAIGoal(DEF, "Defend", 100, "cp_tec_2")

Or would I have to add in the other technounion ship as objective 5?

EDIT: Wow, my campaign seems really bugy. I got to the part in the mission where you have to fight an AI ambush, but no units apear. Tidbits of the LUA for it:
Hidden/Spoiler:
-- load the gametype script
ScriptCB_DoFile("MultiObjectiveContainer")
ScriptCB_DoFile("ObjectiveAssault")
ScriptCB_DoFile("ObjectiveConquest")
ScriptCB_DoFile("ObjectiveGoto")
ScriptCB_DoFile("ObjectiveCTF")
ScriptCB_DoFile("ObjectiveTDM")
ScriptCB_DoFile("Ambush")
ScriptCB_DoFile("setup_teams")

-- REP Attacking (attacker is always #1)
REP = 1;
CIS = 2;
-- These variables do not change
ATT = REP;
DEF = CIS;
AmbushTeam = 3
amb = AmbushTeam


____________________________________________________________

--objective: kill the ambushing cis
Objective2= ObjectiveAssault:New{teamATT = ATT, teamDEF = amb,
text = "level.mad.campaign.2", popupText = "level.mad.campaign.2_popup"}

amb = TargetType:New{classname = "amb_inf_marine", killLimit = 8}
Objective2:AddTarget(amb)

Objective2.OnStart = function(self)
SetupAmbushTrigger("ambush_trigger_1", "ambush_path_1", 8, amb)
end

Objective2.OnComplete = function(self)
end


_______________________________________________________________

amb = {
team = amb,
units = 8,
reinforcements = -1,
soldier = { "amb_inf_marine",8, 8},
}
}

SetTeamAsEnemy(ATT, amb)
SetTeamAsEnemy(amb, ATT)

SetTeamAsFriend(amb, DEF)
SetTeamAsFriend(DEF, amb)
No amb troops spawn when the region is created. ( you start out inside it).
Note: do the trigger regions have to be rectangular?
User avatar
Eggman
Master Bounty Hunter
Master Bounty Hunter
Posts: 1516
Joined: Mon Jul 16, 2007 1:30 pm
Projects :: Battlefront Chronicles
Location: Las Vegas

Re: Campaign ambush as objective?

Post by Eggman »

I believe the AI goals should be set up to be numbered 1-4, so it would look like this:

Code: Select all

     Objective4.Dclass_cpGoal1 = AddAIGoal(ATT, "Defend", 100, "cp_tec_1")
     Objective4.Dclass_cpGoal2 = AddAIGoal(DEF, "Defend", 100, "cp_tec_1")
     Objective4.Dclass_cpGoal3 = AddAIGoal(ATT, "Defend", 100, "cp_tec_2")
     Objective4.Dclass_cpGoal4 = AddAIGoal(DEF, "Defend", 100, "cp_tec_2")
As for why the ambush isn't working, I'm not sure exactly. Did you have it set up and working before, or did you just add it in? If it was working before, then some other mistake is probably interfering with it, so fixing that mistake would allow the ambush to work again. If the ambush is new, then just double check the tutorials on setting up ambushes to see if you missed something. I'll admit, I've never been good at setting up ambushes with the method you used. I use this function:

Code: Select all

Ambush(ambushpath, numDudes, fromTeam)
It doesn't require a region, so I find it easier to deal with. You can just tie it in with some other event, such as "ObjectiveX.OnStart." Try using that function in place of "SetupAmbushTrigger" and see if it works.
Commander_Fett
High General
High General
Posts: 847
Joined: Fri Oct 17, 2008 9:59 pm
Projects :: No Mod project currently.

Re: Campaign ambush as objective?

Post by Commander_Fett »

Well, I tried that:

Code: Select all

--objective: kill the ambushing cis
    Objective2= ObjectiveAssault:New{teamATT = ATT, teamDEF = amb,
										text = "level.mad.campaign.2", popupText = "level.mad.campaign.2_popup"}	

	amb = TargetType:New{classname = "amb_inf_marine", killLimit = 8}
	Objective2:AddTarget(amb)
	
	Objective2.OnStart = function(self)
--	SetupAmbushTrigger("ambush_trigger_1", "ambush_path_1", 8, amb) 
Ambush(ambush_path_1, 8, amb)
	end
	
	Objective2.OnComplete = function(self)
	end
But that doesn't seem to work either. I'm not sure why, IU set up the path and the side's odf and reqs are right...
Commander_Fett
High General
High General
Posts: 847
Joined: Fri Oct 17, 2008 9:59 pm
Projects :: No Mod project currently.

Campaign ambush problem

Post by Commander_Fett »

I was working on setting up a campaign ambush, but the ai never spawn. I checked the side by adding the unit to conquest, and it worked fine, and there's nothing wrong with the paths, so I figured it must be the LUA. However, I can't seem to find the problem.
My LUA (only the parts that refer to the team, amb)
Hidden/Spoiler:
[code]-- load the gametype script
ScriptCB_DoFile("MultiObjectiveContainer")
ScriptCB_DoFile("ObjectiveAssault")
ScriptCB_DoFile("ObjectiveConquest")
ScriptCB_DoFile("ObjectiveGoto")
ScriptCB_DoFile("ObjectiveCTF")
ScriptCB_DoFile("ObjectiveTDM")
ScriptCB_DoFile("Ambush")
ScriptCB_DoFile("setup_teams")

-- REP Attacking (attacker is always #1)
REP = 1;
CIS = 2;
-- These variables do not change
ATT = REP;
DEF = CIS;
AmbushTeam = 3
amb = AmbushTeam

__________________________________________________________________________

--objective: kill the ambushing cis
Objective2= ObjectiveAssault:New{teamATT = ATT, teamDEF = amb,
text = "level.mad.campaign.2", popupText = "level.mad.campaign.2_popup"}

amb = TargetType:New{classname = "amb_inf_marine", killLimit = 8}
Objective2:AddTarget(amb)

Objective2.OnStart = function(self)
-- SetupAmbushTrigger("ambush_trigger_1", "ambush_path_1", 8, amb)
Ambush(ambush_path_1, 8, amb)
end

Objective2.OnComplete = function(self)
end

__________________________________________________________________

ReadDataFile("dc:SIDE\\amb.lvl",
"amb_inf_marine")

SetupTeams{
rep = {
team = REP,
units = 20,
reinforcements = 150,
soldier = { "rep_inf_ep3_rifleman",9, 25},
assault = { "rep_inf_ep3_rocketeer",1, 4},
engineer = { "rep_inf_ep3_engineer",1, 4},
sniper = { "rep_inf_ep3_sniper",1, 4},
officer = {"rep_inf_ep3_officer",1, 4},
special = { "rep_inf_ep3_jettrooper",1, 4},

},
cis = {
team = CIS,
units = 20,
reinforcements = 150,
soldier = { "cis_inf_rifleman",9, 25},
assault = { "cis_inf_rocketeer",1, 4},
engineer = { "cis_inf_engineer",1, 4},
sniper = { "cis_inf_sniper",1, 4},
officer = {"cis_inf_officer",1, 4},
special = { "cis_inf_droideka",1, 4},
},

amb = {
team = amb,
units = 8,
reinforcements = -1,
soldier = { "amb_inf_marine",8, 8},
}
}

SetTeamAsEnemy(ATT, amb)
SetTeamAsEnemy(amb, ATT)

SetTeamAsFriend(amb, DEF)
SetTeamAsFriend(DEF, amb)



[/code]
Any help would be greatly appreciated.

Topics merged -Staff
RepSharpshooter
Gametoast Staff
Gametoast Staff
Posts: 1351
Joined: Tue Jul 10, 2007 4:10 pm

Re: Campaign ambush as objective?

Post by RepSharpshooter »

You have amb being both the ambush team and the targets. You need to have 2 separate variables.
Commander_Fett
High General
High General
Posts: 847
Joined: Fri Oct 17, 2008 9:59 pm
Projects :: No Mod project currently.

Re: Campaign ambush as objective?

Post by Commander_Fett »

Where would I specify that?
RepSharpshooter
Gametoast Staff
Gametoast Staff
Posts: 1351
Joined: Tue Jul 10, 2007 4:10 pm

Re: Campaign ambush as objective?

Post by RepSharpshooter »

Code: Select all

ambushers = TargetType:New{classname = "amb_inf_marine", killLimit = 8}
You had that set to "amb" which overwrote your ambush team number.
Commander_Fett
High General
High General
Posts: 847
Joined: Fri Oct 17, 2008 9:59 pm
Projects :: No Mod project currently.

Re: Campaign ambush as objective?

Post by Commander_Fett »

so wait, would I just remove the AI ambush and those units would spawn anyway?
RepSharpshooter
Gametoast Staff
Gametoast Staff
Posts: 1351
Joined: Tue Jul 10, 2007 4:10 pm

Re: Campaign ambush as objective?

Post by RepSharpshooter »

If they had a cp with their team number yes. You could use an invisible cp like the gammoreans do on jabbas.

But regardless, you cannot use the same variable twice, it overwrites and screws things up.
Hidden/Spoiler:
ambushers = TargetType:New{classname = "amb_inf_marine", killLimit = 8}
Objective2:AddTarget(ambushers)
amb is an integer, and ambushers is a target. You had them set to the same variable, which makes absolutely no sense.
Commander_Fett
High General
High General
Posts: 847
Joined: Fri Oct 17, 2008 9:59 pm
Projects :: No Mod project currently.

Re: Campaign ambush as objective?

Post by Commander_Fett »

so, I would change it to this:

Code: Select all

	atm = TargetType:New{classname = "atm_inf_marine", killLimit = 8}
	Objective2:AddTarget(atm)
(change team name)
User avatar
ThePanda
Private Second Class
Posts: 74
Joined: Sat Dec 20, 2008 4:22 pm

Re: Campaign ambush as objective?

Post by ThePanda »

You could just change it to amb2 instead of atm.

Also, I don't think you have to change the units name, you can still keep it as amb_inf_marine.
RepSharpshooter
Gametoast Staff
Gametoast Staff
Posts: 1351
Joined: Tue Jul 10, 2007 4:10 pm

Re: Campaign ambush as objective?

Post by RepSharpshooter »

No? what is this atm??

You're really confusing me.

Code: Select all

ambushers = TargetType:New{classname = "amb_inf_marine", killLimit = 8}
Objective2:AddTarget(ambushers)
all you need to change is that.
ambushers are the target
amb is the team number
Commander_Fett
High General
High General
Posts: 847
Joined: Fri Oct 17, 2008 9:59 pm
Projects :: No Mod project currently.

Re: Campaign ambush as objective?

Post by Commander_Fett »

okay, I set up an ambush path, and tried to make ai spawn from it. (team was amb, renamed atm) I want the objective to be destroying the ambushing units. However, the AI won't spawn.
RepSharpshooter
Gametoast Staff
Gametoast Staff
Posts: 1351
Joined: Tue Jul 10, 2007 4:10 pm

Re: Campaign ambush as objective?

Post by RepSharpshooter »

Ok I keep repeating the same answer, and you keep ignoring and repeating the same problem and this is going nowhere.

This is from the geo1c_c.lua It is the objective that ambushes droids and killing them is the objective, which is exactly what you are doing.
Hidden/Spoiler:
--Objective 2a, destroy the 3 droids

Scouts = TargetType:New{classname = "cis_inf_rifleman", killLimit = 3, icon = "hud_objective_icon_circle"}

Objective2a = ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.geo1.objectives.campaign.2a", popupText = "level.geo1.objectives.campaign.2a_popup", AIGoalWeight = 0}
Objective2a:AddTarget(Scouts)

Objective2a:AddHint("level.geo1.hints.weapons")
Objective2a:AddHint("level.geo1.hints.lockon")
Objective2a:AddHint("level.geo1.hints.reticle")
Objective2a:AddHint("level.geo1.hints.enemymarkers")

Objective2a.OnStart = function(self)
Ambush("scout_ambush_spawn", 3, 4)
scouts_goal = AddAIGoal(4, "Defend", 100, "health_pad")
end

Objective2a.OnComplete = function(self)
ShowMessageText("game.objectives.complete", ATT)
DeleteAIGoal(scouts_goal)
BroadcastVoiceOver("GEO_obj_56", ATT)

end
See how scouts ISNT a team? it is another variable.

I really don't see any other way to help after giving you the solution 5 times in a row.
Post Reply