How do I get AI to enter hangers in a space map?

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
anakin3482
Posts: 4
Joined: Mon Dec 07, 2020 6:09 pm
Projects :: No Mod project currently.
Games I'm Playing :: Battlefront II 2005
xbox live or psn: No gamertag set

How do I get AI to enter hangers in a space map?

Post by anakin3482 »

I'm working on a space battle between two capital ships but it's in conquest mode. I'm wanting to expand the capital ships as well. I can't seem to get the AI to enter the enemy hangers on the capital ships. How would I go about this? I want them to go after the CPs too.

Here are my SCW scripts

SCWc_cmn:
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
-- SPAX - Clone Wars Template Common File
-- Common script that shares all setup information
--

ScriptCB_DoFile("setup_teams")

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

function SetupUnits()
ReadDataFile("SIDE\\rep.lvl",
"rep_inf_ep3_rifleman",
"rep_inf_ep3_rocketeer",
"rep_inf_ep3_engineer",
"rep_inf_ep3_sniper",
"rep_inf_ep3_pilot",
"rep_inf_ep3_marine",
"rep_inf_ep3_officer",
"rep_inf_ep3_jettrooper",
"rep_fly_anakinstarfighter_sc",
"rep_fly_arc170fighter_sc",
"rep_veh_remote_terminal",
"rep_fly_gunship_sc",
"rep_fly_vwing")

ReadDataFile("SIDE\\cis.lvl",
"cis_inf_rifleman",
"cis_inf_rocketeer",
"cis_inf_engineer",
"cis_inf_sniper",
"cis_inf_pilot",
"cis_inf_marine",
"cis_inf_officer",
"cis_inf_droideka",
"cis_fly_droidfighter_sc",
"cis_fly_droidgunship",
"cis_fly_greviousfighter",
"cis_fly_tridroidfighter")

ReadDataFile("SIDE\\tur.lvl",
"tur_bldg_spa_cis_beam",
"tur_bldg_spa_cis_chaingun",
"tur_bldg_spa_rep_beam",
"tur_bldg_spa_rep_chaingun",
"tur_bldg_chaingun_roof"
)
end

myTeamConfig = {
rep = {
team = REP,
units = 100,
reinforcements = 500,
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},
pilot = { "rep_inf_ep3_pilot",26},
marine = { "rep_inf_ep3_marine",6},
officer = {"rep_inf_ep3_officer",1, 4},
special = { "rep_inf_ep3_jettrooper",1, 4},

},
cis = {
team = CIS,
units = 100,
reinforcements = 500,
soldier = { "cis_inf_rifleman",9, 25},
assault = { "cis_inf_rocketeer",1, 4},
engineer = { "cis_inf_engineer",1, 4},
sniper = { "cis_inf_sniper",1, 4},
pilot = { "cis_inf_pilot",26},
marine = { "cis_inf_marine",6},
officer = {"cis_inf_officer",1, 4},
special = { "cis_inf_droideka",1, 4},

}
}

ScriptCB_DoFile("LinkedTurrets")
function SetupTurrets()
--CIS turrets
turretLinkageCIS = LinkedTurrets:New{ team = CIS, mainframe = "cis-defense",
turrets = {"cis_turr_1", "cis_turr_2", "cis_turr_3", "cis_turr_4", "cis_turr_5", "cis_turr_6"} }
turretLinkageCIS:Init()

function turretLinkageCIS:OnDisableMainframe()
ShowMessageText("level.spa.hangar.mainframe.atk.down", REP)
ShowMessageText("level.spa.hangar.mainframe.def.down", CIS)

BroadcastVoiceOver( "ROSMP_obj_20", REP )
BroadcastVoiceOver( "COSMP_obj_21", CIS )
end
function turretLinkageCIS:OnEnableMainframe()
ShowMessageText("level.spa.hangar.mainframe.atk.up", REP)
ShowMessageText("level.spa.hangar.mainframe.def.up", CIS)

BroadcastVoiceOver( "ROSMP_obj_22", REP )
BroadcastVoiceOver( "COSMP_obj_23", CIS )
end

--REP turrets
turretLinkageREP = LinkedTurrets:New{ team = REP, mainframe = "rep-defense",
turrets = {"rep_turr_1", "rep_turr_2", "rep_turr_3", "rep_turr_4", "rep_turr_5", "rep_turr_6"} }
turretLinkageREP:Init()

function turretLinkageREP:OnDisableMainframe()
ShowMessageText("level.spa.hangar.mainframe.atk.down", CIS)
ShowMessageText("level.spa.hangar.mainframe.def.down", REP)

BroadcastVoiceOver( "ROSMP_obj_21", REP )
BroadcastVoiceOver( "COSMP_obj_20", CIS )
end
function turretLinkageREP:OnEnableMainframe()
ShowMessageText("level.spa.hangar.mainframe.atk.up", CIS)
ShowMessageText("level.spa.hangar.mainframe.def.up", REP)

BroadcastVoiceOver( "ROSMP_obj_23", REP )
BroadcastVoiceOver( "COSMP_obj_22", CIS )
end
end

function ScriptPreInit()
SetWorldExtents(2500)
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()
-- Designers, this line *MUST* be first!
ReadDataFile("ingame.lvl")

SetMinFlyHeight(-1800)
SetMaxFlyHeight(1800)
SetMinPlayerFlyHeight(-1800)
SetMaxPlayerFlyHeight(1800)
SetAIVehicleNotifyRadius(100)

ReadDataFile("sound\\spa.lvl;spa2cw")
ScriptCB_SetDopplerFactor(0.4)
ScaleSoundParameter("tur_weapons", "MinDistance", 3.0);
ScaleSoundParameter("tur_weapons", "MaxDistance", 3.0);
ScaleSoundParameter("tur_weapons", "MuteDistance", 3.0);
ScaleSoundParameter("Ordnance_Large", "MinDistance", 3.0);
ScaleSoundParameter("Ordnance_Large", "MaxDistance", 3.0);
ScaleSoundParameter("Ordnance_Large", "MuteDistance", 3.0);
ScaleSoundParameter("explosion", "MaxDistance", 5.0);
ScaleSoundParameter("explosion", "MuteDistance", 5.0);

SetupUnits()
SetupTeams(myTeamConfig)

-- Level Stats
ClearWalkers()
local weaponCnt = 250
local guyCnt = 32
local units = 72
SetMemoryPoolSize("Aimer", 200)
SetMemoryPoolSize("AmmoCounter", weaponCnt)
SetMemoryPoolSize("BaseHint", 73)
SetMemoryPoolSize("EnergyBar", weaponCnt)
SetMemoryPoolSize("EntityCloth", 0)
SetMemoryPoolSize("EntityDroideka",0)
SetMemoryPoolSize("EntityDroid",0)
SetMemoryPoolSize("EntityHover", 0)
SetMemoryPoolSize("EntityFlyer", 36)
SetMemoryPoolSize("ParticleTransformer::SizeTransf", 1500)
SetMemoryPoolSize("ParticleTransformer::ColorTrans" , 1784)
SetMemoryPoolSize("ParticleTransformer::PositionTr", 1500)
SetMemoryPoolSize("EntityLight", 100)
SetMemoryPoolSize("EntityRemoteTerminal", 12)
SetMemoryPoolSize("EntitySoldier",guyCnt)
SetMemoryPoolSize("SoldierAnimation", 200)
SetMemoryPoolSize("FLEffectObject::OffsetMatrix", 120)
SetMemoryPoolSize("MountedTurret", 70)
SetMemoryPoolSize("Navigator", guyCnt)
SetMemoryPoolSize("Obstacle", 150)
SetMemoryPoolSize("PassengerSlot", 0)
SetMemoryPoolSize("PathNode", 92)
SetMemoryPoolSize("UnitAgent", units)
SetMemoryPoolSize("UnitController", units)
SetMemoryPoolSize("Weapon", weaponCnt)
SetMemoryPoolSize("TentacleSimulator", 0)
SetMemoryPoolSize("Combo::DamageSample", 0)

SetSpawnDelay(10.0, 0.25)

-- do any pool allocations, custom loading here
if myScriptInit then
myScriptInit()
myScriptInit = nil
end

ReadDataFile("dc:SCW\\spa_sky.lvl", "tat")

ReadDataFile("dc:SCW\\SCW.lvl", myGameMode)

SetDenseEnvironment("false")

SetParticleLODBias(15000)

-- Sound Stats
local voiceSlow = OpenAudioStream("sound\\global.lvl", "spa1_objective_vo_slow")
AudioStreamAppendSegments("sound\\global.lvl", "rep_unit_vo_slow", voiceSlow)
AudioStreamAppendSegments("sound\\global.lvl", "cis_unit_vo_slow", voiceSlow)
AudioStreamAppendSegments("sound\\global.lvl", "global_vo_slow", voiceSlow)

local 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\\spa.lvl", "spa")
OpenAudioStream("sound\\spa.lvl", "spa")
-- OpenAudioStream("sound\\global.lvl", "global_vo_quick")
-- OpenAudioStream("sound\\global.lvl", "global_vo_slow")
-- OpenAudioStream("sound\\tat.lvl", "tat1_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)

SetLowReinforcementsVoiceOver(REP, REP, "rep_off_defeat_im", .1, 1)
SetLowReinforcementsVoiceOver(REP, CIS, "rep_off_victory_im", .1, 1)
SetLowReinforcementsVoiceOver(CIS, CIS, "cis_off_defeat_im", .1, 1)
SetLowReinforcementsVoiceOver(CIS, REP, "cis_off_victory_im", .1, 1)

SetOutOfBoundsVoiceOver(REP, "Repleaving")
SetOutOfBoundsVoiceOver(CIS, "Cisleaving")

SetAmbientMusic(REP, 1.0, "rep_spa_amb_start", 0,1)
SetAmbientMusic(REP, 0.99, "rep_spa_amb_middle", 1,1)
SetAmbientMusic(REP, 0.1,"rep_spa_amb_end", 2,1)
SetAmbientMusic(CIS, 1.0, "cis_spa_amb_start", 0,1)
SetAmbientMusic(CIS, 0.99, "cis_spa_amb_middle", 1,1)
SetAmbientMusic(CIS, 0.1,"cis_spa_amb_end", 2,1)

SetVictoryMusic(REP, "rep_spa_amb_victory")
SetDefeatMusic (REP, "rep_spa_amb_defeat")
SetVictoryMusic(CIS, "cis_spa_amb_victory")
SetDefeatMusic (CIS, "cis_spa_amb_defeat")

SetSoundEffect("ScopeDisplayZoomIn", "binocularzoomin")
SetSoundEffect("ScopeDisplayZoomOut", "binocularzoomout")
--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")

-- Camera Stats Battle over Felucia
-- Rep ship from behind
AddCameraShot(0.998795, -0.041143, -0.026739, -0.001101, -720.435303, 809.024963, 2779.057129);
-- CIS ship from behind
AddCameraShot(0.028389, -0.001117, -0.998823, -0.039312, -629.853760, 809.024963, -2050.946289);
-- Overall from right side of map
AddCameraShot(-0.335210, 0.057062, -0.927078, -0.157814, 1372.964233, 1940.014038, -2266.423828);
-- Overall from left side of map
AddCameraShot(0.911880, -0.246677, -0.316680, -0.085667, -2183.282471, 1940.014038, 2760.666748);


AddDeathRegion("deathregion3")
AddDeathRegion("deathregion4")
AddLandingRegion("rep-CP1Con")
AddLandingRegion("cis-CP1Con")

end
SCWc_Diet Dr. Pepper:
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
-- SPAX - Clone Wars Template Assault File
--
ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("SCWc_cmn") --rename ABC to your modID


---- load the gametype script
ScriptCB_DoFile("ObjectiveConquest")


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

myGameMode = "SCW_CW-Conquest" --rename ABC to your modID

function myScriptInit()
SetMemoryPoolSize("CommandFlyer", 2)
end


function ScriptPostLoad()


--This defines the CPs. These need to happen first
cp1 = CommandPost:New{name = "cp1"}
cp2 = CommandPost:New{name = "cp2"}





--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:Start()

end



User avatar
AnthonyBF2
Sith
Sith
Posts: 1255
Joined: Wed Aug 21, 2013 3:55 pm
Projects :: PS2+PSP Overhaul

Re: How do I get AI to enter hangers in a space map?

Post by AnthonyBF2 »

BF2 isn't programmed with "AI going to hangars, landing, and getting out" support but someone on Gametoast made a script that does it. Search around and you'll find it eventually.
anakin3482
Posts: 4
Joined: Mon Dec 07, 2020 6:09 pm
Projects :: No Mod project currently.
Games I'm Playing :: Battlefront II 2005
xbox live or psn: No gamertag set

Re: How do I get AI to enter hangers in a space map?

Post by anakin3482 »

AnthonyBF2 wrote:
Tue Aug 31, 2021 4:03 pm
BF2 isn't programmed with "AI going to hangars, landing, and getting out" support but someone on Gametoast made a script that does it. Search around and you'll find it eventually.
That's exactly why I posted this. I did a bunch of searching and couldn't find anything. Do you know who made the script or have a link to it?
MileHighGuy
Jedi
Jedi
Posts: 1194
Joined: Fri Dec 19, 2008 7:58 pm

Re: How do I get AI to enter hangers in a space map?

Post by MileHighGuy »

I searched this board for "land in hangars"

http://gametoast.com/viewtopic.php?f=27 ... rs#p527793

Code: Select all

function ScriptPostLoad()
ActivateRegion("rep-cp1con")
Land = OnEnterRegion(
   function(region, character)
      if GetEntityClass(GetCharacterVehicle(character)) == FindEntityClass("cis_fly_droidgunship") then
            print("flyer found :D")
         ship = GetCharacterVehicle(character)
         EntityFlyerLand(ship)
	      SetProperty(ship, "DisableTime", 1e+37)
	      SetProperty(ship, "DisableTime", 0)
            print("Houston, the Eagle has landed")
      end
      if not IsCharacerHuman(character) then
         ExitVehicle(character)
      end
   end,
   "rep-cp1con"
)
end
You will have to update the code to reflect the vehicle and regions you want. Refer to the thread for more info!
Post Reply