XML/Scenario

From MegaGlest
Revision as of 01:36, 11 October 2019 by Titi (talk | contribs)
Jump to navigation Jump to search

Commands

Scenarios are special types of battles where the creator can modify the game from its regular style, and even add Lua scripting.

XML

<?xml version="1.0" standalone="yes" ?>
<scenario>
	<difficulty value="3"/>
	<players>
		<player control="human" faction="faction_name" team="1"/>
		<player control="network" faction="faction_name" team="2"/>
		<player control="cpu" faction="faction_name" resource_multiplier="1.0" team="2"/>
	</players>
	<map value="map_name"/>
	<tileset value="tileset_name"/>
	<tech-tree value="techtree_name"/>
	<fog-of-war value="true"/>
	<default-resources value="true"/>
	<default-units value="true"/>
	<default-victory-conditions value="true"/>
	<scripts>
		<global>
		
			<!-- Lua Code -->
		
		</global>
		<onSave>
		
			<!-- Lua Code -->
		
		</onSave>
		<onLoad>
		
			<!-- Lua Code -->
		
		</onLoad>
		<!-- End MG Only -->
		<startup>
		
			<!-- Lua Code -->
		
		</startup>
		<unitCreated>
		
			<!-- Lua Code -->
		
		</unitCreated>
		<resourceHarvested>
		
			<!-- Lua Code -->
		
		</resourceHarvested>
		<unitCreatedOfType type="unit_name">
		
			<!-- Lua Code -->
		
		</unitCreatedOfType>
		<unitDied>
		
			<!-- Lua Code -->
		
		</unitDied>
	</scripts>
</scenario>

Documentation

difficulty

This is the displayed difficulty, as a number from 0-5. It does not affect the scenario in any way, and is only used to display what YOU think the difficulty should be classified as. The default english difficulties are:

0 = Very Easy
1= Easy
2= Medium
3= Hard
4= Very Hard
5= Insane

players

This is a list of the players in this game, where each player gets their own <player /> tag. Attributes are control, which is either human, cpu, or cpu-ultra cpu-easy and cpu-mega. MegaGlest also adds the option of a network player. This asserts who controls that player, and one must be human and one must be some brand of cpu. In MegaGlest you can also edit the resource_multiplier for the cpu.

The faction is the name of the faction (must all be in the same techtree), and the team is the team number for the purpose of placing players on the same or different teams (players with the same number are allies, while different numbers are enemies).

map

The name of the map to use. It should exist in the player's maps folder or you can also have the map inside the scenario's folder itself, to allow the map to be used for the scenario only, without appearing in the regular game menu.

tileset

The name of the tileset to use. Note that it must exist in the user's tileset folder.

tech-tree

The techtree to use for the scenario. The existing factions for each player must exist in it.

fog-of-war

An optional value. If true, fog of war and the shroud of darkness will be displayed as normal, if false, there will be no fog of war nor the shroud of darkness. Finally explored will remove the shroud of darkness, but keep the fog of war.

default-resources

If true, the faction XML will be used to define the starting resources. If false, they start with no resources and you must use Lua to specify the resources to give. Generally on for non-scripted scenarios.

default-units

If true, the faction XML will be used to define the starting units. If false, they start with no units and you must use Lua to specify the units to give. Generally on for non-scripted scenarios.

default-victory-conditions

If true, the game is won or lost by defeating all the opponents (or more specifically, all the opponent's units which have a be-built skill). If false, the game only ends when the Lua script tells it to. Generally on for non-scripted scenarios.


scripts

See Lua

Lua code will go in children tags of scripts. The exact Lua code available depends on the engine used, but the XML tags are all the same. Lua code will be executed based on what tag it is in.

XML tag Description
<global> Everything in this tag will be executed whenever the scenario will be starded.
<onSave> Everything in this tag will be executed when the scenario gets saved. Here you can store variables you when the savegame gets loaded.
<onLoad> Everything in this tag will be executed when the savegame of the scenario is startd. Here you can also restore saved variables.
<startup> Everything in this tag will be executed once at the start of the scenario.
<unitCreated> Everything in this tag will be executed each time any player creates a new unit.
<resourceHarvested> Everything in this tag will be executed whenever a resource is harvested.
<unitCreatedOfType type="unit_name"> Everything in this tag will be executed when a unit of the specified name is created by any player.
<unitDied> Everything in this tag will be executed every time a unit from any player dies.

See also