Migrating to ManiaPlanet 3

Hey there folks,

After a long time I’m back with new Defusing posts. ;)
The first step we have to take before going on with developing actual features is the migration to ManiaPlanet 3 (MP3).

Nadeo introduced quite some new stuff but also discarded some old things.
Especially if you look at maniascript classes!


The well known BlockSpawns and BlockPoles are gone.
Now you have to access the Spawns and Goals via the new landmarks arrays
“MapLandmarks_PlayerSpawn” and “MapLandmarks_Gauge”.
For that and more new properties I recommend taking a look at the class documentation.

A “landmark” is a generic block on the map that can have various properties and features.
The spawn block for example is a landmark that has a filled PlayerSpawn property to use for spawning players.
The goal blocks are now called “Gauge” which basically tells you that it can be captured. Since they added the gates, the name “Goal” didn’t fit anymore, as the gates can be captured just like the goals and checkpoints.
The CSmMode class has some array properties to conveniently access these different types of blocks.

Implementing this change is basically the only thing we have to do for Defusing because it doesn’t have many features.
In order to do that I heavily recommend using the ingame script editor and its “Compile” function. It will tell you if you use deprecated properties or functions so that you can replace them accordingly.
Most of the time the needed change is a simple replacing of the name as the new classes have pretty much the same interfaces as their old versions.

“BlockSpawns” becomes “MapLandmarks_PlayerSpawn”
“BlockPoles” becomes “MapLandmarks_Gauge”
“Bases” becomes “MapBases”


Though there are a few stumbling blocks that I would like to mention here:

1. The property “CSmModeEvent::BlockPole” hasn’t been marked as deprecated yet even though it’s supposed to be replaced by “CSmModeEvent::Landmark”! You will need to watch out for that yourself as you don’t get a warning for it. I simply search for the string “block” via Ctrl+F to check if there are obsolete occurrences.

2. Using spawn objects to spawn players has a facet that you should keep in mind. Before MP3 one often accessed an object from the BlockSpawns array and passed it to the spawn function. Now you have to pass the .PlayerSpawn object of a spawn landmark. The thing is that many game modes save ids of spawns in variables. For that you should now use the landmark id because there is no array of playerspawn objects.
It’s kind of obvious but I just wanted to mention it because I saw someone doing something like:

declare Spawn <=> MapLandmarks_PlayerSpawn[0].PlayerSpawn;

This way he doesn’t have access to the landmark and its properties like the Position which is quite important imo.

3. If you use Manialinks with scripts you will have to check them by yourself as they aren’t validated by the Compile function, simply because they are placed in a string so that their code can’t be recognised.
I noticed that the log will print the warning if an error occurs. So if you want to quickly check if your Manialink script needs some update work you can cause an error on porpose.
For example like that:

log(BlockPoles.count); // Deprecated property access
Null.Error = True; // Error source

This will lead to the result you can see here:
Deprecated warning in Manialink script
(The script needs to have a valid syntax because the warning wouldn’t show up if there is a compile error.)


Now you’re good to go for updating your game mode script for ManiaPlanet 3.
And we will be able to add some nice stuff in the future because Defusing is now again fully supported by MP3.

You can find the updated script on GitHub: Defusing v0.08

Cheers,
Steff

New Posts after Upcoming Update!

Hey there,

You probably have noticed that there haven’t been any posts in 2014. This is mainly caused by the fact that I don’t have much time these months.
Now I would have the time to continue the work on Defusing while blogging about it, but with the big update around the corner I would rather like to wait for it to be released.

The first post will then be about migrating an existing mode to MP3.
After that the actual development of Defusing will continue.

So stay tuned and have fun!

Cheers,
Steff

Merry Christmas!

Merry Christmas in Advance! :)

I will be visiting my hometown during the Christmas holidays so there won’t be any posts until early January.
For that time I wish you guys peaceful and happy days and a happy new year! :D

(I know this is too early but I won’t have time to do it during the next weeks. ^.^)

Greetings,
steeffeen

The Bomb is a Thing

Currently the Bomb is still kind of non-existent because everybody can capture goals. That will be changed now.

First of all I prevent anyone from capturing Goals if it isn’t the bomb carrier.
I simply add a check of the player when someone tries to capture:

if (Player.Id != G_BombCarrierId) {
// Not the bomb carrier
continue;
}


Now it’s needed to actually give the bomb to a player so that she/he is able to activate it. This is done when preparing the next round.

I loop through all players of the attacking team and pick one of them based on a few rules.
Each time you carry the bomb timestamp is set. This timestamp is checked when looking for the next carrier so that each player has to carry it at some point.
You will get chosen if:
– You didn’t carry the bomb so far or
– You’re the one that didn’t carry the bomb for the longest duration.

If the team has currently no players the bomb will simply be placed in one of the team’s spawns so that the next joining player can pick it up.


Picking up the bomb? You’ve heard right! That’s the next step.
The most common case in which that will be needed is when the bomb carrier is eliminated.

First lets list all the situation when the bomb gets dropped: It happens every time the bomb carrier…
– Gets eliminated
– Presses backspace
– Switches the team
– Switches to spectator mode
– Leaves the server (not covered yet)

In all of these case I call my new function DropBomb(Player);
It sets the bomb carrier id to NullId and saves the player’s position as the new bomb’s drop position (new global variable).

One note: I check if the given player is the bomb carrier INSIDE the function in order to save some code because this way I don’t have to add the check each time I call the function.


Now the picking up of the bomb!
Whenever the bomb is dropped which is represented by the G_BombCarrierId being NullId I check if a player of the attacking team is close enough to pick it up.

declare Distance = MathLib::Distance(Player.Position, G_BombDropPosition);
if (Distance > C_BombPickUpDistance) {
// Too far away
continue;
}
PickUpBomb(Player);

The Distance function of the MathLib takes two coordinates as Vec3 variables and calculates the distance between them. Easy as that.

Picking up the bomb is possible in a range of 2.5 meters for now, maybe it will be needed to be adjusted. We will see.

#Const C_BombPickUpDistance 2.5


One annoying thing about the current version of the mode is that you can’t really run it without players in each team because the empty team will always instantly lose because its players have been eliminated.
So from now on to win by eliminating there has to be at least one player in the opponent team.

if (ClansNbPlayers[Clan+1] <= 0 || ClansNbPlayersAlive[Clan+1] > 0) {
// No players in the team or not all of them eliminated yet
continue;
}


Two minor things at the end:
1. I’ve added one line which will enable the name tags for the players.

SM::SetupDefaultVisibility();

If you take a look at the SM script you will see that this function configures the displaying of name tags and armor gauges which are all deactivated by default.

2. The constant saving the number of bots has been changed to a script setting so that you can easily deactivate them on a server. (The amount of playing bots is updated at the beginning of rounds.)


That’s it for today.
See you next time.

Check the new script version here: Defusing7.Script.txt

Btw: Take a look at the script: It already has 600 lines! And it doesn’t even have any working User Interface yet which will need a LOT more code. ;)