Help With Spawning Star fighters [Solved]

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
Lorul1
Rebel Colonel
Rebel Colonel
Posts: 562
Joined: Wed Apr 24, 2013 10:34 pm
Projects :: Assault on Theed
Games I'm Playing :: Battlegrounds
xbox live or psn: No gamertag set
Location: Your House

Help With Spawning Star fighters [Solved]

Post by Lorul1 »

Im making a space map and i need help figuring out how to make the star fighters spawn in while in space. What im talking about is, when you drift of away from your mothership enemy and friendly ships just come from nowhere.
I know they do this in every stock map and some modded maps, but i just need help figuring it out
Last edited by Lorul1 on Mon Jun 23, 2014 11:32 pm, edited 1 time in total.
User avatar
Locutus
1st Lieutenant
1st Lieutenant
Posts: 420
Joined: Fri Jun 04, 2010 10:08 am
Projects :: Stargate Battlefront Pegasus
Location: Germany
Contact:

Re: Help With Spawning Star fighters

Post by Locutus »

I don't know what causes the bug that makes fighter magically appear out of nowhere at the map edges but regarding space spawn your possibilities are limited.
Unfortunately you can't spawn vehicles via lua (well, technically you can but they're not usable in that case) so what you have left is either pre-placing them in ZE (means, no respawn) or using a regular vehicle spawn.

When using a vehicle spawn, I assume you want your vehicles do sth. in space and not just standing around. The simplest solution here is to change the pilot type of your fighter to "vehicleself". It can be entered by soldiers but the fighter also acts on its own. But be aware that adding this behavior will break your map for MP. The second possibility would be forcing an AI player into the fighter.

This is some working code I was using for the Stargate mod map:
Hidden/Spoiler:
[code]if ScriptCB_InMultiplayer() then
print("SG1: SpawnWrtDest1: Timer2 expired: Setup Multiplayer")
if not wrt_dest_1_manned then
print("SG1: SpawnWrtDest1: Timer2 expired: Destroyer alive")
OnCharacterSpawn(
function(character)
print("SG1: SpawnWrtDest1: Timer2 expired: OnCharacterSpawn")
if not IsCharacterHuman(character) and GetCharacterTeam(character) == 2 and not wrt_dest_1_manned then
print("SG1: SpawnWrtDest1: Timer2 expired: OnCharacterSpawn: Enter Vehicle")
EnterVehicle(character, "wrt_vehspawn_destroyer1")
EntityFlyerTakeOff("wrt_vehspawn_destroyer1")
EntityFlyerInitAsFlying("wrt_vehspawn_destroyer1")
wrt_dest_1_manned = true
end
end
)
end
else
print("SG1: SpawnWrtDest1: Timer2 expired: Setup Singleplayer")
SetClassProperty("wrt_fly_destroyer", "PilotType", "vehicleself")
--SetProperty("wrt_vehspawn_destroyer1", "PilotType", "vehicleself") --log error: EntityClass not found
print("SG1: SpawnWrtDest1: Timer2 expired: Property set to vehicleself")
end[/code]
Note that in this example the spawned vehicle can stay idle for some time in case we don't have a character spawn immediately after the vehicle spawn.
I am currently trying to find a workaround but it's not working properly:
Hidden/Spoiler:
[code]local pilot_found = false
local i = 1
while not pilot_found and i < 32 do
pilot = GetTeamMember(2, i)
wurm = GetCharacterVehicle(pilot)
--search for a "free" character
if pilot and not IsCharacterHuman(pilot) and not wrt_dest_1_manned then --and GetCharacterVehicle(pilot) == nil
print("SG1: SpawnWrtDest1: Timer2 expired: OnCharacterSpawn: AI into frigate")
EnterVehicle(pilot, "wrt_vehspawn_destroyer1")
EntityFlyerTakeOff("wrt_vehspawn_destroyer1")
EntityFlyerInitAsFlying("wrt_vehspawn_destroyer1")
wrt_dest_1_manned = true
pilot_found = true
end
i = i+1
end
--force-grab a character that is busy
if not pilot_found then
print("SG1: SpawnWrtDest1: Timer2 expired: Bad. No AI found")
i = 0
while not pilot_found and i < 32 do
pilot = GetTeamMember(2, i)
if GetCharacterVehicle(pilot) ~= nil then
print("SG1: SpawnWrtDest1: Timer2 expired: ssssgate")
ExitVehicle(pilot)
EnterVehicle(pilot, "wrt_vehspawn_destroyer1")
EntityFlyerTakeOff("wrt_vehspawn_destroyer1")
EntityFlyerInitAsFlying("wrt_vehspawn_destroyer1")
wrt_dest_1_manned = true
pilot_found = true
--SpawnCharacter(characterindex, GetPathPoint("wrt_cp2_spawn", 0))
end
i = i + 1
end
end [/code]
Hope that helps a bit, though I'm currently also looking for a solution and would also be glad about help^^
User avatar
Lorul1
Rebel Colonel
Rebel Colonel
Posts: 562
Joined: Wed Apr 24, 2013 10:34 pm
Projects :: Assault on Theed
Games I'm Playing :: Battlegrounds
xbox live or psn: No gamertag set
Location: Your House

Re: Help With Spawning Star fighters

Post by Lorul1 »

Okay thanks locutus
I never saw the ships coming from nowhere as a bug, rather a fix for a lack of star fighters. Maybe a fix that the game designers never shiped to modtools after final testing. (Along with the correct color for the geonosis dirt, and tantive 4 walls with panels). but thank you for the explanation and different methods I can try

Also I would like to help you with your workaround, however I know little to nothing about programming and by the look of your script you probably know alot more that I do. I'm just a 15 year old that picked up modding battlefront 2 :funny2: .For now I only know as much Lua as I need but, one day when I learn more about programing in LUA I would be glad help you with your workaround. 8)

Thanks again.
Post Reply