AI Ambush problems

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
User avatar
[Skirata]Darman[M]
Rebel Sergeant
Rebel Sergeant
Posts: 190
Joined: Mon Aug 10, 2009 8:47 am
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Imperial Center, Coruscant
Contact:

AI Ambush problems

Post by [Skirata]Darman[M] »

Hey guys, I tried to make an AI Ambush in my mission, I made everything like in the tut, but it only worked one time, then I munged again and it doesn't work. I redid my steps, same result. I tried to add a second Ambush, but it also doesn't work. errorlog sais nothing.

here's my script (only one ambush) :
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--


-- 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;
WOK = 3;
GEO = 4;
-- These variables do not change
ATT = REP;
DEF = CIS;
AmbushTeam = 5
ATM = AmbushTeam

function ScriptPostLoad()

SetAIDifficulty(0, 2, "hard")
AllowAISpawn(ATT, true)
AllowAISpawn(DEF, true)
AllowAISpawn(WOK, false)
AllowAISpawn(GEO, false)
ScriptCB_SetGameRules("campaign")
onfirstspawn = OnCharacterSpawn(
function(character)
if character == 0 then
ShowPopup("level.geo1.hints.hints")
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
BeginObjectivesTimer()
ScriptCB_EnableCommandPostVO(0)

end
end)

KillObject ("cp3")
KillObject ("zem_cp_droiddispenser3")
KillObject ("zem_cp_droiddispenser2")
KillObject ("zem_cp_droiddispenser1")
KillObject ("zem_cp_droiddispenser")
PlayAnimation("gunship3")

SetProperty ("cp2","Team",4)

--Destroy the turrets
Objective1= ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.FMB.firsttext", popupText = "level.FMB.pop.firstpopuptext"}

Dclass = TargetType:New{classname = "tur_bldg_spa_imp_recoilless", killLimit = 2}
Objective1:AddTarget(Dclass)

Objective1.OnStart = function(self)
Objective1.Dclass_cpGoal1 = AddAIGoal(ATT, "Follow", 100, 0)
Objective1.Dclass_cpGoal2 = AddAIGoal(DEF, "Destroy", 100, 0)
end

Objective1.OnComplete = function(self)
DeleteAIGoal(Objective1.Dclass_cpGoal2)
AllowAISpawn(WOK, true)
AddAIGoal(WOK, "Deathmatch", 100)
PlayAnimation("Laatc")
PlayAnimation("Laatc2")
PlayAnimation("center")
PlayAnimation("gunship1")
UnlockHeroForTeam(ATT)
end



--Kill the droid thingys
Objective2= ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.FMB.secondtext", popupText = "level.FMB.pop.secondpoputext"}

Dclass = TargetType:New{classname = "zem_cp_droiddispenser", killLimit = 3}
Objective2:AddTarget(Dclass)

Objective2.OnStart = function(self)
Objective2.Dclass_cpGoal2 = AddAIGoal(DEF, "Deathmatch", 100)
end

Objective2.OnComplete = function(self)

end



--Destory the tantive console
Dobjekt = Target:New{name = "tan4_prop_Console1"}
Dobjekt.OnDestroy = function(self)

end

Objective3 = ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.FMB.thirdtext", popupText = "level.FMB.pop.thirdpopuptext"}
Objective3:AddTarget(Dobjekt)


Objective3.OnStart = function(self)


end

Objective3.OnComplete = function(self)
ShowMessageText("game.objectives.complete", ATT)
PlayAnimation("doorright")
PlayAnimation("doorleft")
PlayAnimation("door1")
RespawnObject("cp3")
RespawnObject("zem_cp_droiddispenser3")

end




--Capture cp 3
Objective4CP = CommandPost:New{name = "cp3"}
Objective4 = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF, text = "level,FMB.fourthtext", popupText = "level.FMB.pop.fourthpopuptext", AIGoalWeight = 0}
Objective4:AddCommandPost(Objective4CP)

Objective4:AddHint("level.geo1.hints.capture_cp")

Objective4.OnStart = function(self)
AICanCaptureCP("cp3", ATT, false)
AICanCaptureCP("cp3", DEF, true)

end

Objective4.OnComplete = function(self)
ShowMessageText("game.objectives.complete", ATT)
SetProperty("cp3", "Team", 1)
SetProperty("cp3", "CaptureRegion", "")

end



--objective: assault
Dobjekt = Target:New{name = "pol1_prop_control_console"}
Dobjekt.OnDestroy = function(self)

end

Objective5 = ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.FMB.5text", popupText = "level.FMB.pop.5popuptext"}
Objective5:AddTarget(Dobjekt)


Objective5.OnStart = function(self)


end

Objective5.OnComplete = function(self)
ShowMessageText("game.objectives.complete", ATT)
RespawnObject("zem_cp_droiddispenser2")
RespawnObject("zem_cp_droiddispenser1")
RespawnObject("zem_cp_droiddispenser")

end



--objective: assault
Dobjekt = Target:New{name = "zem_cp_droiddispenser3"}
Dobjekt.OnDestroy = function(self)

end

Objective6 = ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.FMB.6text", popupText = "level.FMB.pop.6popuptext"}
Objective6:AddTarget(Dobjekt)


Objective6.OnStart = function(self)


end

Objective6.OnComplete = function(self)
ShowMessageText("game.objectives.complete", ATT)

end




--Go to the region
Objective7 = ObjectiveGoto:New{TeamATT = ATT, TeamDEF = DEF,
text = "level.FMB.7text", popupText = "level.FMB.pop.7popuptext",
regionName = "goto1", mapIcon = "hud_objective_icon_circle", AIGoalWeight = 0}

Objective7:AddHint("level.geo1.hints.movement")
Objective7:AddHint("level.geo1.hints.obj_markers")
Objective7:AddHint("level.geo1.hints.review_objectives")
Objective7:AddHint("level.geo1.hints.sprint")


Objective7.OnStart = function(self)
MapAddEntityMarker("goto1", "hud_objective_icon_circle", 3.0, 1, "YELLOW", true)

end

Objective7.OnComplete = function(self)
ShowMessageText("game.objectives.complete", ATT)
MapRemoveEntityMarker("goto1")
AllowAISpawn(GEO, true)

end



--Kill the mandalorian
Objective8= ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.FMB.8text", popupText = "level.FMB.pop.8popuptext"}

Dclass = TargetType:New{classname = "cis_hero_jangofett", killLimit = 1}
Objective8:AddTarget(Dclass)

Objective8.OnStart = function(self)

SetupAmbushTrigger("ambushregion", "ambushpath", 1, 5)

end

Objective8.OnComplete = function(self)

end



end



function BeginObjectivesTimer()
beginobjectivestimer = CreateTimer("beginobjectivestimer")
OnTimerElapse(BeginObjectives, beginobjectivestimer)
SetTimerValue(beginobjectivestimer, 3)
StartTimer(beginobjectivestimer)
end

function BeginObjectives()
objectiveSequence = MultiObjectiveContainer:New{delayVictoryTime = 4}
objectiveSequence:AddObjectiveSet(Objective1)
objectiveSequence:AddObjectiveSet(Objective2)
objectiveSequence:AddObjectiveSet(Objective3)
objectiveSequence:AddObjectiveSet(Objective4)
objectiveSequence:AddObjectiveSet(Objective5)
objectiveSequence:AddObjectiveSet(Objective6)
objectiveSequence:AddObjectiveSet(Objective7)
objectiveSequence:AddObjectiveSet(Objective8)

objectiveSequence:Start()

end


---------------------------------------------------------------------------
-- FUNCTION: ScriptInit
-- PURPOSE: This function is only run once
-- INPUT:
-- OUTPUT:
-- NOTES: The name, 'ScriptInit' is a chosen convention, and each
-- mission script must contain a version of this function, as
-- it is called from C to start the mission.
---------------------------------------------------------------------------
function ScriptInit()


--tell the game to load our loading image
ReadDataFile("dc:Load\\common.lvl")

ReadDataFile("ingame.lvl")


SetMaxFlyHeight(100)
SetMaxPlayerFlyHeight (100)

SetMemoryPoolSize ("ClothData",20)
SetMemoryPoolSize ("Combo",50) -- should be ~ 2x number of jedi classes
SetMemoryPoolSize ("Combo::State",650) -- should be ~12x #Combo
SetMemoryPoolSize ("Combo::Transition",650) -- should be a bit bigger than #Combo::State
SetMemoryPoolSize ("Combo::Condition",650) -- should be a bit bigger than #Combo::State
SetMemoryPoolSize ("Combo::Attack",550) -- should be ~8-12x #Combo
SetMemoryPoolSize ("Combo::DamageSample",6000) -- should be ~8-12x #Combo::Attack
SetMemoryPoolSize ("Combo::Deflect",100) -- should be ~1x #combo

ReadDataFile("sound\\yav.lvl;yav1cw")
ReadDataFile("dc:SIDE\\rep.lvl",
"rep_inf_ep2_rifleman",
"rep_inf_ep2_rocketeer",
"rep_inf_ep2_engineer",
"rep_inf_ep2_sniper",
"rep_inf_ep2_jettrooper",
"rep_fly_gunship",
"rep_inf_covert_ops",
"rep_hover_fightertank")
ReadDataFile("dc:SIDE\\cis.lvl",
"cis_inf_rifleman",
"cis_inf_rocketeer",
"cis_inf_engineer",
"cis_inf_sniper",
"cis_inf_officer",
"cis_inf_marine",
"cis_hero_jangofett",
"cis_hover_aat")
ReadDataFile("dc:SIDE\\wok.lvl",
"rep_inf_ep3_marine",
"rep_inf_ep3_pilot")
ReadDataFile("dc:SIDE\\geo.lvl",
"cis_hero_jangofett")


ReadDataFile("dc:SIDE\\tur.lvl",
"tur_bldg_recoilless_fel_auto",
"tur_bldg_spa_imp_recoilless",
"tur_bldg_chaingun_roof")

SetupTeams{
rep = {
team = REP,
units = 5,
reinforcements = 150,
soldier = { "rep_inf_ep2_rifleman",1, 2},
assault = { "rep_inf_ep2_rocketeer",1, 2},
engineer = { "rep_inf_ep2_sniper",1, 2},
sniper = { "rep_inf_ep2_engineer",1, 2},
special = { "rep_inf_ep2_jettrooper",1, 2},

},
cis = {
team = CIS,
units = 45,
reinforcements = -1,
soldier = { "cis_inf_rifleman",9, 55},
assault = { "cis_inf_rocketeer",1, 6},
engineer = { "cis_inf_engineer",1, 6},
officer = {"cis_inf_officer",1, 10},
},
geo = {
team = GEO,
units = 1,
reinforcements = -1,
soldier = {"cis_hero_jangofett", 1, 1},
},
atm = {
team = ATM,
units = 1,
reinforcements = -1,
soldier = {"cis_hero_jangofett", 1, 1},
}
}

SetTeamName(ATM, CIS)
SetTeamAsEnemy(ATM, REP)
SetTeamAsEnemy(REP, ATM)
SetTeamAsFriend(CIS, ATM)
SetTeamAsFriend(ATM, CIS)
ClearAIGoals(ATM)
AddAIGoal(ATM, "Deathmatch", 100)

SetHeroClass(CIS, "cis_hero_darthmaul")
SetHeroClass(REP, "rep_inf_covert_ops")

SetTeamName(3, "locals")
SetTeamIcon(3, "all_icon")
AddUnitClass(3, "rep_inf_ep3_marine",40)
AddUnitClass(3, "rep_inf_ep3_pilot",1)

SetUnitCount(3, 41)
SetTeamAsFriend(ATT,3)
SetTeamAsFriend(3,ATT)
SetTeamAsEnemy(DEF,3)
SetTeamAsEnemy(3,DEF)

SetTeamAsEnemy(GEO, REP)
SetTeamAsEnemy(REP, GEO)
SetTeamAsFriend(CIS, GEO)
SetTeamAsFriend(GEO, CIS)



-- Level Stats
-- ClearWalkers()
AddWalkerType(0, 4) -- special -> droidekas
AddWalkerType(1, 0) -- 1x2 (1 pair of legs)
AddWalkerType(2, 0) -- 2x2 (2 pairs of legs)
AddWalkerType(3, 0) -- 3x2 (3 pairs of legs)
local weaponCnt = 1024
SetMemoryPoolSize("Aimer", 75)
SetMemoryPoolSize("AmmoCounter", weaponCnt)
SetMemoryPoolSize("BaseHint", 1024)
SetMemoryPoolSize("EnergyBar", weaponCnt)
SetMemoryPoolSize("EntityCloth", 32)
SetMemoryPoolSize("EntityFlyer", 32)
SetMemoryPoolSize("EntityHover", 32)
SetMemoryPoolSize("EntityLight", 200)
SetMemoryPoolSize("EntitySoundStream", 4)
SetMemoryPoolSize("EntitySoundStatic", 32)
SetMemoryPoolSize("MountedTurret", 32)
SetMemoryPoolSize("Navigator", 128)
SetMemoryPoolSize("Obstacle", 1024)
SetMemoryPoolSize("PathNode", 1024)
SetMemoryPoolSize("SoundSpaceRegion", 64)
SetMemoryPoolSize("TreeGridStack", 1024)
SetMemoryPoolSize("UnitAgent", 128)
SetMemoryPoolSize("UnitController", 128)
SetMemoryPoolSize("Weapon", weaponCnt)

SetSpawnDelay(10.0, 0.25)
--ReadDataFile("dc:FMB\\FMB.lvl", "FMB_conquest")
ReadDataFile("dc:FMB\\FMB.lvl", "FMB_conquest")
SetDenseEnvironment("false")

-- Local Stats
--SetTeamName(3, "locals")
--SetTeamIcon(3, "all_icon")
--AddUnitClass(3, "rep_inf_ep3_marine", 40)
--AddUnitClass(3, "rep_inf_ep3_pilot", 1)
--SetUnitCount(3, 7)
--SetTeamAsEnemy(3,DEF)
--SetTeamAsFriend(3,ATT)

-- Sound

SetSoundEffect("ScopeDisplayZoomIn", "binocularzoomin")
SetSoundEffect("ScopeDisplayZoomOut", "binocularzoomout")

voiceSlow = OpenAudioStream("sound\\global.lvl", "rep_unit_vo_slow")
AudioStreamAppendSegments("sound\\global.lvl", "cis_unit_vo_slow", voiceSlow)
AudioStreamAppendSegments("sound\\global.lvl", "global_vo_slow", voiceSlow)

voiceQuick = OpenAudioStream("sound\\global.lvl", "rep_unit_vo_quick")
AudioStreamAppendSegments("sound\\global.lvl", "cis_unit_vo_quick", voiceQuick)

OpenAudioStream("sound\\global.lvl", "cw_music")
-- OpenAudioStream("sound\\global.lvl", "global_vo_quick")
-- OpenAudioStream("sound\\global.lvl", "global_vo_slow")
OpenAudioStream("sound\\yav.lvl", "yav1")
OpenAudioStream("sound\\yav.lvl", "yav1")
OpenAudioStream("sound\\yav.lvl", "yav1_emt")

SetBleedingVoiceOver(REP, REP, "rep_off_com_report_us_overwhelmed", 1)
SetBleedingVoiceOver(REP, CIS, "rep_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(CIS, REP, "cis_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(CIS, CIS, "cis_off_com_report_us_overwhelmed", 1)

SetOutOfBoundsVoiceOver(2, "cisleaving")
SetOutOfBoundsVoiceOver(1, "repleaving")

SetAmbientMusic(REP, 1.0, "rep_yav_amb_start", 0,1)
SetAmbientMusic(REP, 0.8, "rep_yav_amb_middle", 1,1)
SetAmbientMusic(REP, 0.2, "rep_yav_amb_end", 2,1)
SetAmbientMusic(CIS, 1.0, "cis_yav_amb_start", 0,1)
SetAmbientMusic(CIS, 0.8, "cis_yav_amb_middle", 1,1)
SetAmbientMusic(CIS, 0.2, "cis_yav_amb_end", 2,1)

SetVictoryMusic(REP, "rep_yav_amb_victory")
SetDefeatMusic (REP, "rep_yav_amb_defeat")
SetVictoryMusic(CIS, "cis_yav_amb_victory")
SetDefeatMusic (CIS, "cis_yav_amb_defeat")

SetSoundEffect("ScopeDisplayZoomIn", "binocularzoomin")
SetSoundEffect("ScopeDisplayZoomOut", "binocularzoomout")
--SetSoundEffect("BirdScatter", "birdsFlySeq1")
--SetSoundEffect("WeaponUnableSelect", "com_weap_inf_weaponchange_null")
--SetSoundEffect("WeaponModeUnableSelect", "com_weap_inf_modechange_null")
SetSoundEffect("SpawnDisplayUnitChange", "shell_select_unit")
SetSoundEffect("SpawnDisplayUnitAccept", "shell_menu_enter")
SetSoundEffect("SpawnDisplaySpawnPointChange", "shell_select_change")
SetSoundEffect("SpawnDisplaySpawnPointAccept", "shell_menu_enter")
SetSoundEffect("SpawnDisplayBack", "shell_menu_exit")


--OpeningSateliteShot
AddCameraShot(0.405418, 0.018834, -0.912953, 0.042412, 156.734161, 6.037713, 180.226318);

AddCameraShot(0.405418, 0.018834, -0.912953, 0.042412, 156.734161, 6.037713, 180.226318);
AddCameraShot(0.405418, 0.018834, -0.912953, 0.042412, 156.734161, 6.037713, 180.226318);
end
can someone help me or see what's wrong?
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: AI Ambush problems

Post by Fiodis »

Hmm, manual clean + remunge?
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: AI Ambush problems

Post by [RDH]Zerted »

Please post the error log anyway.
Post Reply