[CODE] Better Ai Hangar Landing

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
MDPtoaster
Private Third Class
Posts: 54
Joined: Mon Mar 25, 2019 4:38 pm
Games I'm Playing :: SWBF2
xbox live or psn: No gamertag set

[CODE] Better Ai Hangar Landing

Post by MDPtoaster »

CODE BY Ryan Hank:

"A better AI landing script that waits for the flyer to land before forcing everybody out, as well as a flyerpath toggle to stop double landings. It's only simple and works for a singular region, but can easily be adapted to use multiple regions and paths"


Follow the tutorial found here: https://gametoast.com/viewtopic.php?f=27&t=32640 then use the following code instead of the tutorial's

Happy modding

Code: Select all

function LandingStuff()

    ActivateRegion("uwing-land")
    local isInRegion
    
    OnEnterRegionTeam(
        function(region, character)
            local characterVehicle = GetCharacterVehicle(character)
            
            if GetEntityClass(characterVehicle) == FindEntityClass("all_fly_uwing_sc") then   -- checks if the characters vehicle matches a specific class
                local boardingShip = characterVehicle
                EntityFlyerLand(boardingShip)                                                 -- forces the flyer to land
            end
        end,
    "uwing-land", 1                                                                           -- region name and entering team used for the check
    )
    
    OnCharacterLandedFlyerClass(
        function (character, flyer)
            if IsCharacterInRegion(character, "uwing-land") then           -- checks the vehicle pilot character is in the required region
                SetProperty(flyer, "DisableTime", 0.05)                    -- forces everybody out with no effect played
                isInRegion = 1
            end
        end,
    "all_fly_uwing_sc"                                                     -- the flyer class (odf) name
    )
        
    OnObjectKillClass(
        function(object, killer)
            if isInRegion == 1 then
                EnableFlyerPath("landingpath", 1)           -- re-enables the landing flyer path upon object death
                isInRegion = 0
            end
        end,
    "all_fly_uwing_sc"                                      -- the flyer class (odf) name
    )
end
MileHighGuy
Jedi
Jedi
Posts: 1194
Joined: Fri Dec 19, 2008 7:58 pm

Re: [CODE] Better Ai Hangar Landing

Post by MileHighGuy »

great work!
Post Reply