How to Get AI to Land in Hangars? [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

AQT
Gametoast Staff
Gametoast Staff
Posts: 4910
Joined: Sat Nov 03, 2007 4:55 pm
Location: SoCal, USA

Re: How to Get AI to Land in Hangars? [Solved]

Post by AQT »

ForceAIOutOfVehicles will prevent all AI or AI on a specified team from using any vehicle. Instead, as soon as the ship lands in the hangar, use SetProperty to set DisableTime for the ship to 1+e37, and then immediately use SetProperty again to set DisableTime to 0. This will instantaneously kick all units out of the ship while still making entering the ship possible afterwards.
Ascertes
Private Second Class
Posts: 65
Joined: Thu Aug 18, 2016 3:42 pm
Projects :: Space Carida
xbox live or psn: No gamertag set

Re: How to Get AI to Land in Hangars? [Solved]

Post by Ascertes »

AQT wrote:ForceAIOutOfVehicles will prevent all AI or AI on a specified team from using any vehicle. Instead, as soon as the ship lands in the hangar, use SetProperty to set DisableTime for the ship to 1+e37, and then immediately use SetProperty again to set DisableTime to 0. This will instantaneously kick all units out of the ship while still making entering the ship possible afterwards.
Currently my code looks like this:

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)
            print("Houston, the Eagle has landed")
      end
      if not IsCharacerHuman(character) then
         ExitVehicle(character)
      end
   end,
   "rep-cp1con"
)
end
So what would my code look like with the features you included? This kind of scripting isn't exactly what I'm good at :|
AQT
Gametoast Staff
Gametoast Staff
Posts: 4910
Joined: Sat Nov 03, 2007 4:55 pm
Location: SoCal, USA

Re: How to Get AI to Land in Hangars? [Solved]

Post by AQT »

There is a tutorial for this here:
The two new lines would be right after EntityFlyerLand(ship):

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
I don't know what would happen to the ship if you were to disable it while it is in the process of landing. But if the ship does successfully get disabled and also doesn't land properly, try creating and starting a timer to wait long enough for it to do so and then disable it.
Ascertes
Private Second Class
Posts: 65
Joined: Thu Aug 18, 2016 3:42 pm
Projects :: Space Carida
xbox live or psn: No gamertag set

Re: How to Get AI to Land in Hangars? [Solved]

Post by Ascertes »

I added the code like you said, but it's not working. 2-3 AI remain in the ship after landing.

However, I think it's note worthy I'm getting some odd Severity 3 messages in my BF2Log. Despite being severity 3, the game still works fine. I'll attach the relevant sections:
Hidden/Spoiler:
Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):68>

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):68>

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):51>

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):68>

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):68>

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):119>

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):102>

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):51>

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):68>

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):68>

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):119>

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):119>

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):85>

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):119>

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):102>

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):85>

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):68>

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):34>

flyer found :D
Houston, the Eagle has landed

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: (none):0: attempt to call global `IsCharacerHuman' (a nil value)
stack traceback:
(none): in function <(none):34>

flyer found :D
Houston, the Eagle has landed

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: (none):0: attempt to call global `IsCharacerHuman' (a nil value)
stack traceback:
(none): in function <(none):34>

flyer found :D
Houston, the Eagle has landed

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: (none):0: attempt to call global `IsCharacerHuman' (a nil value)
stack traceback:
(none): in function <(none):34>

flyer found :D
Houston, the Eagle has landed

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: (none):0: attempt to call global `IsCharacerHuman' (a nil value)
stack traceback:
(none): in function <(none):34>

flyer found :D
Houston, the Eagle has landed

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: (none):0: attempt to call global `IsCharacerHuman' (a nil value)
stack traceback:
(none): in function <(none):34>

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):34>
These sections were here before, but I wonder if they're interfering?
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: How to Get AI to Land in Hangars? [Solved]

Post by Marth8880 »

It would certainly help if IsCharacterHuman were spelled correctly. :p
AQT
Gametoast Staff
Gametoast Staff
Posts: 4910
Joined: Sat Nov 03, 2007 4:55 pm
Location: SoCal, USA

Re: How to Get AI to Land in Hangars? [Solved]

Post by AQT »

Yeah...I just edited the code you posted without proofreading what was already there. Assumed it was already working...
Ascertes
Private Second Class
Posts: 65
Joined: Thu Aug 18, 2016 3:42 pm
Projects :: Space Carida
xbox live or psn: No gamertag set

Re: How to Get AI to Land in Hangars? [Solved]

Post by Ascertes »

Marth8880 wrote:It would certainly help if IsCharacterHuman were spelled correctly. :p
AQT wrote:Yeah...I just edited the code you posted without proofreading what was already there. Assumed it was already working...
Oh...huh. Lol. That's weird because the code IS working. The ships are landing and nobody is dying. I'll fix it right away :D

EDIT: With this new revelation of misspellings, I wonder if I'll even need the 2 lines you added.

EDIT2: It's all working now. All of it. Thanks so much guys! I left your code in AQT. I don't even want to mess with it anymore lol.

EDIT3: Still getting those errors, though...
Post Reply