Page 1 of 1

Overriding a command in an outside script [Solved]

Posted: Sun Dec 16, 2012 4:42 pm
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)?

Re: Overriding a command in an outside script

Posted: Sun Dec 16, 2012 4:56 pm
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).

Re: Overriding a command in an outside script

Posted: Sun Dec 16, 2012 7:45 pm
by GAB
Ok AQT. I managed to get it working just like you recommended. Thanks.