// Downloaded at : http://www.akbalder.com/ManiaPlanet/GameModes/ShootMania/JailbreakArena.Script.txt
/* -------------------------------------- */
// Name: JailbreakArena
// Version: 201403281108
// Author: Florian "Akbalder" Guillard
// Contact: akbalder@gmail.com
// Description: MapType for Jailbreak
// Details: One spawn, one goal and one jailspawn for each clan
/* -------------------------------------- */
#RequireContext CSmMapType
#Const Version "2014-03-28"
#Const MapTypeVersion 1
#Const ScriptName "JailbreakArena.Script.txt"
#Include "TextLib" as TextLib
#Include "Libs/Nadeo/Anchor.Script.txt" as Anchor
#Include "Libs/Nadeo/MapType.Script.txt" as MapType
// ---------------------------------- //
// Globales
// ---------------------------------- //
declare Text Rules;
// ---------------------------------- //
// Functions
// ---------------------------------- //
// ---------------------------------- //
// Initialize the anchors
Void InitAnchors() {
foreach (Anchor in AnchorData) {
if (Anchor.DefaultTag == "Spawn") {
if (Anchor.Tag != "Spawn" && Anchor.Tag != "JailSpawn") Anchor.Tag = Anchor.DefaultTag;
if (Anchor.Order != 1 && Anchor.Order != 2) Anchor.Order = 1;
} else if (Anchor.DefaultTag == "Goal") {
Anchor.Tag = Anchor.DefaultTag;
if (Anchor.Order != 1 && Anchor.Order != 2) Anchor.Order = 1;
}else {
Anchor.Tag = Anchor.DefaultTag;
Anchor.Order = Anchor.DefaultOrder;
}
}
}
// ---------------------------------- //
// Check if the map is valid
Void UpdateValidability() {
InitAnchors();
Anchor::UpdateAnchorCounts();
for(I, 1, 2) {
if (!Anchor::HasExactlyOneAnchor("Spawn", I, TextLib::Compose(_("You must place exactly one Spawn #%1"), TextLib::ToText(I)))) return;
if (!Anchor::HasExactlyOneAnchor("Goal", I, TextLib::Compose(_("You must place exactly one Goal #%1"), TextLib::ToText(I)))) return;
if (!Anchor::HasExactlyOneAnchor("JailSpawn", I, TextLib::Compose(_("You must place exactly one JailSpawn #%1"), TextLib::ToText(I)))) return;
}
ValidationStatus = CSmMapType::ValidationStatus::Validated;
}
// ---------------------------------- //
// Return the manialink for goal anchor edition
Text EditGoalAnchorManialink() {
declare MLText =
"""
""";
return MLText;
}
// ---------------------------------- //
// Return the manialink for spawn anchor edition
Text EditSpawnAnchorManialink() {
declare MLText =
"""
""";
return MLText;
}
// ---------------------------------- //
// Manialink for non editable anchor
Text NoEditManialink() {
return """
""";
}
// ---------------------------------- //
// Show the anchor edition manialink
Void EditAnchorData(Ident _EditedAnchorDataId)
{
UpdateValidability();
declare Text AnchorTag for ManialinkPage;
declare Integer AnchorOrder for ManialinkPage;
declare Boolean Finish for ManialinkPage;
declare DefaultTag = AnchorData[_EditedAnchorDataId].DefaultTag;
if (DefaultTag == "Goal") ManialinkText = EditGoalAnchorManialink();
else if(DefaultTag == "Spawn") ManialinkText = EditSpawnAnchorManialink();
else ManialinkText = NoEditManialink();
AnchorTag = AnchorData[_EditedAnchorDataId].Tag;
AnchorOrder = AnchorData[_EditedAnchorDataId].Order;
Finish = False;
while(!Finish) {
yield;
}
AnchorData[_EditedAnchorDataId].Tag = AnchorTag;
AnchorData[_EditedAnchorDataId].Order = AnchorOrder;
UpdateValidability();
}
// ---------------------------------- //
// Main
// ---------------------------------- //
main() {
MapType::SetVersion(MapTypeVersion);
UpdateValidability();
CustomEditAnchorData = True;
Rules = _("You must place exactly one Spawn #1 and one Spawn #2.\nYou must place exactly one Goal #1 and one Goal #2.\nYou must place exactly one JailSpawn #1 and one JailSpawn #2.");
while (True) {
yield;
ManialinkText = "";
foreach(Event in PendingEvents) {
if(Event.Type == CPluginEvent::Type::MapModified) {
UpdateValidability();
} else if(Event.Type == CPluginEvent::Type::EditAnchor) {
EditAnchorData(Event.EditedAnchorDataId);
}
}
}
}