How to Get AI to Land in Hangars? [Solved]
Moderator: Moderators
-
AQT
- 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]
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]
Currently my code looks like this: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.
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-
AQT
- 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]
There is a tutorial for this here:
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.
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-
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]
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:
These sections were here before, but I wonder if they're interfering?
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:
-
Marth8880
- Resistance Leader
- Posts: 5042
- Joined: Tue Feb 09, 2010 8:43 pm
- Projects :: DI2 + Psychosis
- xbox live or psn: Marth8880
- Location: Edinburgh, UK
- Contact:
Re: How to Get AI to Land in Hangars? [Solved]
It would certainly help if IsCharacterHuman were spelled correctly. :p
-
AQT
- 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]
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]
Marth8880 wrote:It would certainly help if IsCharacterHuman were spelled correctly. :p
Oh...huh. Lol. That's weird because the code IS working. The ships are landing and nobody is dying. I'll fix it right awayAQT wrote:Yeah...I just edited the code you posted without proofreading what was already there. Assumed it was already working...
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...
