Overriding a command in an outside script [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
GAB
1st Lieutenant
1st Lieutenant
Posts: 431
Joined: Sun Jul 03, 2011 8:56 pm
Location: Somewhere around the world
Contact:

Overriding a command in an outside script [Solved]

Post by GAB »

Recently I've been working on a campaign script and created an objective where the goal is to zero the enemy reinforcements and then I want the game to wait for a few seconds for some voice-over and stuff to play.

However, as far as I've noticed, Battlefront 2 is scripted to immediately declare victory to the team opposing the one that runs out of reinforcements, therefore not giving time for my VO and stuff. I believe this is handled by the code below, located in the Objective.lua

Code: Select all

        --If a team runs out of reinforcements, they lose right away.
        --If you want to disable the reinforcement countdown,
        --call SetReinforcementCount(teamID, -1)
        OnTicketCountChange(
            function (team, count)
                if count <= 0 then              
                    MissionDefeat(team)
                end
            end
            )
    end
Since I don't want to modify the Objective.lua because it would affect all the gamemodes (Objective.lua lua is the base for all modetypes) I question: Is it possible to override this code from the mission lua (ABCc_c)?
Last edited by GAB on Sun Dec 16, 2012 7:45 pm, edited 1 time in total.
AQT
Gametoast Staff
Gametoast Staff
Posts: 4910
Joined: Sat Nov 03, 2007 4:55 pm
Location: SoCal, USA

Re: Overriding a command in an outside script

Post by AQT »

Write a function where once when the enemy reinforcement count hits zero:
  • Set the enemy reinforcement count to infinity (it can be any value greater than zero, but infinity will look nicer, I think)
  • Disable all enemy spawn paths (only if you want them to stop spawning now that their reinforcement count is no longer zero)
  • Start a timer "for some voice-over and stuff to play"
  • Once the timer ends, set the enemy reinforcement back to zero
Or you can make a copy of the Objective.lua, name it to something else, modify it, and load it just in your campaign script (be sure to list it in your mission.req).
User avatar
GAB
1st Lieutenant
1st Lieutenant
Posts: 431
Joined: Sun Jul 03, 2011 8:56 pm
Location: Somewhere around the world
Contact:

Re: Overriding a command in an outside script

Post by GAB »

Ok AQT. I managed to get it working just like you recommended. Thanks.
Post Reply