Team swap fix script

 

This will fix the bugs on the ladders and MG42’s concerning team swapping. It works by following the player’s team when they start using the object. If they change before they have stopped using it. They are killed. The fix required lines to execute the script at the start of using a ladder and at the start of using a turret weapon. Then once again executed at the end of using each.

 

Ladder

 

To states:

 

state JUMP_OFF_LADDER

state FINISHED_GET_OFF_LADDER

 

The line ‘exec global/check_team_swap.scr "end"’ should be added under an entrycommands section.

 

The states should now look like this:

 

 

state FINISHED_GET_OFF_LADDER

{

            movetype legs

 

            entrycommands

            {

                        exec global/check_team_swap.scr "end"

            }

 

            entrycommands

            {

                        unattachfromladder

                        safeholster 0 // pull weapon back out if we put it away to get on the ladder

            }

 

            states

            {

                        STAND                                                           : default

            }

}

 

// same as FINISHED_GET_OFF_LADDER, except that the player is jumping off

state JUMP_OFF_LADDER

{

            movetype legs

           

            entrycommands

            {

                        exec global/check_team_swap.scr "end"

                        unattachfromladder

                        safeholster 0 // pull weapon back out if we put it away to get on the ladder

                        jumpxy -70 0 150

            }

 

            states

            {

                        STAND                                   : default

            }

}

 

 

state USE_LADDER

 

This state also needs an exec line. The line ‘exec global/check_team_swap.scr’ should be added within the entrycommands of state USE_LADDER.

 

state USE_LADDER

{

            movetype climbwall

           

            entrycommands

            {

                        exec global/check_team_swap.scr

                        safeholster 1 // put our weapon away

                        attachtoladder // gets the ladder we're going to be climbing

            }

           

//          action

//          {

//                      none : default

//          }

           

            states

            {

//                      PUTAWAY_MAIN                : PUTAWAYMAIN

                        LADDER_PUTAWAY                        : PUTAWAYMAIN

                        LATCH_ONTO_LADDER     : !ONGROUND

                        GET_ON_LADDER                : default

            }

}

 

MG42

 

The MG42 has no turret_end state. So we need to add one and also change the TURRET_IDLE state to use it when the player done using the turret. First we need to exec the team balance script at the start, so in state TURRET_START add an entrycommands section with a line to execute the team balance script.

 

            entrycommands

            {

                        exec global/check_team_swap.scr

            }

 

The state TURRET_START should now look like this:

 

state TURRET_START

{

 

 

//          movetype anim

 

            entrycommands

            {

                        exec global/check_team_swap.scr

            }

 

//          action

//          {

//                      turret_idle                     : default

//          }

           

            states

            {

//                      TURRET_USE                        : +USE

 

                        TURRET_PUTAWAY            : PUTAWAYMAIN     // Basic put weapon away move.

                        TURRET_IDLE                       : default

            }

}

 

The state after starting then goes to TURRET_IDLE. From that state we need to find when a player ends using a turret and exec a script. In state TURRET_IDLE replace ‘STAND                                   : !IS_USING_TURRET’ with ‘TURRET_END                      : !IS_USING_TURRET’

 

NOTE: I could have just added an exitcommands section. God knows why I didn’t?

 

Anyway your state should now look like this.

 

 

state TURRET_IDLE

{

            movetype anim

 

            action

            {

                        turret_idle                     : default

            }

           

            states

            {

//                      TURRET_USE                        : +USE

//                      GENERIC_USE                      : +USE

                        TURRET_END                        : !IS_USING_TURRET

            }

}

 

Then finally you can just copy and paste the state below into your torso file.

 

state TURRET_END

{

            entrycommands

            {

                        exec global/check_team_swap.scr "end"

            }

 

            states

            {

 

                        STAND                                   : default

            }

}