Page 2 of 2

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

Posted: Sat Nov 05, 2016 4:50 pm
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.

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

Posted: Sun Nov 06, 2016 6:55 pm
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 :|

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

Posted: Sun Nov 06, 2016 10:38 pm
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.

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

Posted: Tue Nov 08, 2016 3:45 pm
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?

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

Posted: Tue Nov 08, 2016 7:48 pm
by Marth8880
It would certainly help if IsCharacterHuman were spelled correctly. :p

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

Posted: Tue Nov 08, 2016 9:31 pm
by AQT
Yeah...I just edited the code you posted without proofreading what was already there. Assumed it was already working...

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

Posted: Wed Nov 09, 2016 7:08 pm
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...