Tag Archives: backspace

Eliminating Teams

So far one can win rounds by defending or destroying the goals.
Another aspect of the gameplay is eliminating the whole opponent team.


Until now players immediately respawn as soon as they are eliminated, like that you just can’t eliminate all opponents.
So it’s needed to not spawn players anymore as soon as the round has started. This leads to spectating for the rest of the round which might not be fun for some players so I also added a setting to enable respawning during rounds. (As I said this will automatically prevent winning rounds by eliminating the opponent team.)

When the script is about to spawn a player I simply check if the StartTime is over:

if (!S_EnableRoundRespawn && Now > StartTime) {
     // Round has already started
     continue;
}

Now all members of a team can be eliminated which will lead to a win for the other team.


For knowing how many players of each team are alive I will use the property ClansNbPlayersAlive of CSmMode.
In the round end conditions I check if this numbers drops to 0 for a team and appoint the respective opponent team to the round winner.

Pay attention to a case where a team doesn’t immediately lose by being eliminated!
If the attacking team already planted the bomb it can still win because the defense has to defuse the bomb in order to save the goal and win the round. Because of this I protect the attacking team from losing as long as the bomb is planted.


In my SpeedBall game mode I implemented Friendly Fire which brought the competitive play to another level because you have to care even more about each shot you make to not hit your team members.
Defusing will have the same feature because I really like it. ;)
It can be easily disabled via a new script setting (which is in fact disabled by default).

For preventing hitting team members I checked if an OnHit event represents a hit between players of the same team and discard the event if it’s the case.
From now on the script only checks it as long as the FriendlyFire setting is disabled. While it’s enabled the events will still be handled and passed on leading to damage for the victim.

if (!S_FriendlyFire && Event.Shooter.CurrentClan == Event.Victim.CurrentClan) {
     // Invalid Team Hit
     Discard(Event);
     continue;
}

As players who are hitting their own team members shouldn’t be rewarded for that action I grant them negative points leading to a loss of total points.

if (Event.Shooter.CurrentClan == Event.Victim.CurrentClan) {
     // Team Hit
     Points *= -1;
}

That’s all that needs to be done for friendly fire! An easy but great feature.


During testing the mode you might have noticed that you can’t press backspace yet.
That’s caused by the fact that I Discard() all events that I don’t explicitly handle.
Whenever a player presses backspace there is an OnPlayerRequestRespawn event risen which I from now on simply PassOn().

case CSmModeEvent::EType::OnPlayerRequestRespawn: {
     // Player wants to be despawned
     PassOn(Event);
}

Now you can be despawned by pressing backspace. Keep in mind that you will have to spectate for the rest of the round if the respawning during rounds is disabled. ;)


I’ve also added some delay between rounds to let players breathe a bit. ;)

MB_Sleep(1000);

The function MB_Sleep() is implemented in the ModeBase (a general hint for that is the MB_ prefix) and lets the script wait for the given amount of milliseconds.


You can find the new version of the script here: Defusing6.Script.txt

Have fun eliminating your opponents (and not your team members! :P).