Tag Archives: blockpole

Capturing

One thing about ShootMania that I think is really rewarding is the sound of a captured goal.
So lets take a look at how we can get this capture satisfaction. :)

Important to know is the fact that poles don’t get captured on their own as soon as a player steps on them.
You have to check for this circumstance and set the capture speed of the pole manually.


The goal posts of a map are accessible via the API array BlockPoles and have the class CSmBlockPole.
For managing the capturing progress they have their own CSmGauges.

In the Defusing game mode the attacking team has to plant the bomb and the defending team has to defuse it afterwards. For now I will only focus on capturing and defusing, without actually winning the round.

The bomb will be represented by an Ident variable that holds the id of the (imaginary) bomb carrier. As long as it has not yet been planted the variable has the value NullId. When a pole has been captured the variable will hold the Id of the pole so that I know where the bomb is located. After this point other goals will be ignored and will stay inactive.

Of course only members of the attacking team can plant the bomb (later only the single player carrying the bomb). In Counter-Strike the planting gets aborted as soon as you move. In my ShootMania version I will abort the capturing when the attackers leave the goal posts.
Defusing is only possible by the defending team (the rule about progress abortion applies here as well).

In order to check if a specific player is standing on the goal you can check the Sector of the pole object. It has an array of player ids "PlayersIds".
I simply loop through the array and check which kind of player is standing on the pole at which moment.

if (Player.CurrentClan == Pole.Gauge.Clan) {
// Attacker
}

So I can set the capture Speed to a positive value when an attacker is trying to capture and to a negative value when a defender is trying to defuse the bomb.
For the abortion of bomb activation/defusing I reset the capture progress as soon as no attacker/defender is standing on the pole.

The capture Speed is calculated based on the Max value of the Gauge and the capture time setting I’ve introduced in this version. Via settings players can modify the gameplay parameters to their liking.

Speed = MathLib::NearestInteger(Pole.Gauge.Max / (S_ActivationTime * 1000.));

Pole.Gauge.Max is the maximal value the gauge has to reach in order to actually capture the goal, it’s set to a high value at the beginning of the map.
S_ActivationTime is the setting defining the duration for capturing, it’s set to 5 seconds by default.
* 1000. is necessary to convert the amount of seconds to milliseconds with which the script is working.

In order to defuse an activated bomb defenders have to decapture poles longer than it takes to activate them in the first place. That’s managed by another setting, for now its default value is 1.5 so that defusing takes 1.5x the time as activating. So the activation time is multiplied with S_DefusingTimeFactor and changed to negative for inverting the capture progress.

With each yield; the current value of a Gauge is modified by its Speed value so that after some time the value reaches its Max and an OnCapture event is risen. By handling this event I know that the pole has been captured and I don’t have to check for (Value == Max).


Additionally I’ve set a constant called “CompatibleMapTypes” which restricts the amount of compatible maps. So in my case I’ve set it to “DefusingArena”. You can use several different map types by listing them separated with commas (example: “DefusingArena,RoyalArena,EliteArena”)

There are a few optional constants that you can set for the script.
– Version (shown for example on the server-join-screen),
– CompatibleMapTypes (defining the compatible maps)
– Description (shown in the server-join-screen and via the ingame menu “Help”).


In case you think: “Hey, Bomb Defusal in Counter-Strike doesn’t work like that!”
Yes, I know. The details of the game mode will come with time. It makes sense to focus on a properly working variant before paying attention to details of the specific gameplay.

Without requirements or design, programming is the art of adding bugs to an empty text file.

– Louis Srygley

You can find the current version of the game mode script here: Defusing4.Script.txt

Greetings,
Steff