Difference between revisions of "HowTo:Edit Missions:XML integration"
m (Switched SVN URLs to GH) |
|||
(8 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==Basic XML integration== | ==Basic XML integration== | ||
− | First let me start by explaining how to run a python class... in this case we start with the prebuild <code>[ | + | First let me start by explaining how to run a python class... in this case we start with the prebuild <code>[https://github.com/vegastrike/Assets-Production/blob/master/modules/missions/privateer.py modules/missions/privateer.py]</code> script to run our mission. Open up <code>[https://github.com/vegastrike/Assets-Production/blob/master/mission/explore_universe.mission mission/explore_universe.mission]</code> First come the variables that designate how the mission should normally start. By normally I mean if they don't have any save game present. |
===Variables Section=== | ===Variables Section=== | ||
− | |||
− | + | * '''continuousterrain''' [string] | |
+ | ** "" (default) | ||
+ | * '''credits''' [float] - Starting money. | ||
+ | ** 0 (default) | ||
+ | * '''defaultplayer''' [string] - Team name. Doesn't seem to matter. {{fixme}} | ||
+ | * '''description''' [string] - Description is used in scripts only, the engine doesn't read it. | ||
+ | * '''difficulty''' [float] - Multiplier for lots of game parameters - e.g. "Basic repair" cost equals <code>[[Manual:Config:Advanced:Variables#.22physics.22_section|physics/repair_price]]</code>*difficulty. | ||
+ | ** In net games is set by server variable. Can be modified by scripts later. E.g. difficulty.py module provides a simple way to automatically vary it with PC's wealth (it only goes up, to 0.999) and in default campaign it maxes out at 400000 Cr. | ||
+ | ** 1 (default) | ||
+ | * '''num_players''' [int] | ||
+ | ** 1 (default) | ||
+ | * '''savegame''' [string] - The savegame makes the mission more of a campaign type mission where things may be saved to disk and reloaded at a later point. | ||
+ | ** If no savegame variable is specified (this is where the autosave goes) then the mission will not save and will be a one time play mission. | ||
+ | ** "" (default) | ||
+ | * '''system''' [string] - Starting system. Can be overridden via savegame or scripts. | ||
+ | ** "sol.system" and "Sol/Sol" (default) {{fixme}} | ||
+ | * '''terrain''' [string] | ||
+ | ** "" (default) | ||
<pre> | <pre> | ||
Line 31: | Line 40: | ||
</variables> | </variables> | ||
</pre> | </pre> | ||
+ | It loads <code>Crucible/Cephid_17.system</code> as the star system (which is in XML and stores all present planets) After this, comes the actors in the mission, the flightgroups of fighters. If a mission has more than one player, then each player is the leader (first ship) in each respective flightgroup. | ||
+ | Notice that so far there are a lot of values you don't see for long in the default vegastrike game. Credits, System, first flightgroup fighter, difficulty--these are all initial values but can change.... since there is specified a savegame. | ||
===Flightgroup Section=== | ===Flightgroup Section=== | ||
− | The <code> | + | |
+ | * <code>flightgroup</code> | ||
+ | ** '''name''' [string] [needed] - The displayed name. | ||
+ | ** '''logo''' [string] | ||
+ | ** '''logo_alpha''' [string] | ||
+ | ** '''faction''' [string] [needed] | ||
+ | ** '''type''' [string] [needed] - Unit type. | ||
+ | *** "hornet.xunit" (default) {{fixme}} | ||
+ | ** '''ainame''' [string] [needed] - AI to use. | ||
+ | *** Much like <code>data/ai/VegaEvents.csv</code>: it refers to <code>[https://github.com/vegastrike/Assets-Production/tree/master/ai/events data/ai/events/]'''ainame'''.*.xml</code> AI files, ''not'' .xai scripts they call. | ||
+ | *** "_ainame" - {{fixme}} Seems to use Python [https://github.com/vegastrike/Assets-Production/tree/master/modules/ai/ AI modules]. | ||
+ | ** '''waves''' [int] [needed] - Number of waves. The next one will be launched only after its predecessor is completely eliminated. | ||
+ | ** '''nr_ships''' [int] [needed] - Ships per wave. | ||
+ | ** '''terrain_nr''' | ||
+ | *** "" (default); "mission" | ||
+ | ** '''unit_type''' | ||
+ | *** "" (default) ='''unit'''; "vehicle"; "building" | ||
+ | * <code>pos</code> [double] [needed], <code>rot</code> [float] - Coordinates and orientation. | ||
+ | ** '''x''', '''y''', '''z''' [float] | ||
+ | * <code>order</code> - Scripted orders for the flightgroup. Elements are read, but seems to not being actually parsed currently. {{fixme}} Flightgroups spawn with "fire at will" directive and start acting as their AI setups and AI priorities suggest. | ||
+ | ** '''order''' [needed] | ||
+ | ** '''target''' [needed] - The name of target flightgroup. | ||
+ | ** '''priority''' - Seems not to be used at all. {{fixme}} | ||
<pre> | <pre> | ||
Line 50: | Line 83: | ||
</flightgroups> | </flightgroups> | ||
</pre> | </pre> | ||
+ | |||
+ | The <code>rot</code> flag is ignored, and the position specifies the <code>x,y,z</code> coords of the Shlimazel flightgroup, which is of type <code>llama.begin</code>. | ||
===Python Section=== | ===Python Section=== | ||
Future note: If you wanted to add a campaign to the privateer mission you would most likely modify <code>privateer.py</code> to have a campaign module get loaded.... so you wouldn't necessarily need to modify <code>explore_universe.mission</code> just to add a campaign... lets dig further into the meat of the scripting. | Future note: If you wanted to add a campaign to the privateer mission you would most likely modify <code>privateer.py</code> to have a campaign module get loaded.... so you wouldn't necessarily need to modify <code>explore_universe.mission</code> just to add a campaign... lets dig further into the meat of the scripting. | ||
− | If a mission has python tags...then it is a python mission and may have some embedded python in it. In this case the python makes a new python object of type privateer in the <code> | + | If a mission has python tags...then it is a python mission and may have some embedded python in it. In this case the python makes a new python object of type privateer in the <code>privateer.py</code> module in the <code>[https://github.com/vegastrike/Assets-Production/blob/master/modules/missions/ modules/missions/]</code> directory. |
<pre> | <pre> | ||
<python> | <python> | ||
− | + | from privateer import privateer | |
− | + | my_obj=privateer(8000,40000,500,3,2,.6,.25,.1,400000,2000) | |
+ | </python> | ||
+ | </mission> | ||
+ | </pre> | ||
+ | |||
+ | You have to be careful about newlines, etc in the XML, but it should usually work just dandy. You notice that the mission may pass in arguments to the privateer module that can make slight changes in the gameplay. This allows many cargo missions to use the same module in order to change the parameters of the cargo missions. In this case the values I have selected appear to work relatively well. | ||
+ | |||
+ | Note: Python code must be on a line by itself without any indentations--it needs to work exactly as it would if you had the contents in a python file itself. If you want the indents to work in-line with the XML file, you must prefix it with a block, such as an if statement: | ||
+ | |||
+ | <pre> | ||
+ | <python>if 1: | ||
+ | from privateer import privateer | ||
+ | my_obj=privateer(8000,40000,500,3,2,.6,.25,.1,400000,2000) | ||
</python> | </python> | ||
</mission> | </mission> | ||
</pre> | </pre> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
[[Category:HowTos|Edit Missions:XML integration]] | [[Category:HowTos|Edit Missions:XML integration]] | ||
[[Category:Development|Edit Missions:XML integration]] | [[Category:Development|Edit Missions:XML integration]] |
Latest revision as of 18:27, 22 March 2020
Basic XML integration
First let me start by explaining how to run a python class... in this case we start with the prebuild modules/missions/privateer.py
script to run our mission. Open up mission/explore_universe.mission
First come the variables that designate how the mission should normally start. By normally I mean if they don't have any save game present.
Variables Section
- continuousterrain [string]
- "" (default)
- credits [float] - Starting money.
- 0 (default)
- defaultplayer [string] - Team name. Doesn't seem to matter. FIXME
- description [string] - Description is used in scripts only, the engine doesn't read it.
- difficulty [float] - Multiplier for lots of game parameters - e.g. "Basic repair" cost equals
physics/repair_price
*difficulty.- In net games is set by server variable. Can be modified by scripts later. E.g. difficulty.py module provides a simple way to automatically vary it with PC's wealth (it only goes up, to 0.999) and in default campaign it maxes out at 400000 Cr.
- 1 (default)
- num_players [int]
- 1 (default)
- savegame [string] - The savegame makes the mission more of a campaign type mission where things may be saved to disk and reloaded at a later point.
- If no savegame variable is specified (this is where the autosave goes) then the mission will not save and will be a one time play mission.
- "" (default)
- system [string] - Starting system. Can be overridden via savegame or scripts.
- "sol.system" and "Sol/Sol" (default) FIXME
- terrain [string]
- "" (default)
<mission> <settings> <origin planet="earth" x="0000" y="100" z="000.0"/> </settings> <variables> <!-- <var name="continuousterrain" value="continuousterrain.txt"/>--> <var name="credits" value="13500"/> <var name="defaultplayer" value="blue"/> <var name="mission_name" value="Privateer Mission" /> <var name="difficulty" value=".05"/><!--starting difficulty--> <var name="system" value="Crucible/Cephid_17" /> <var name="description" value="Like, as if." /> <var name="savegame" value="explore_universe_difficulty" /> </variables>
It loads Crucible/Cephid_17.system
as the star system (which is in XML and stores all present planets) After this, comes the actors in the mission, the flightgroups of fighters. If a mission has more than one player, then each player is the leader (first ship) in each respective flightgroup.
Notice that so far there are a lot of values you don't see for long in the default vegastrike game. Credits, System, first flightgroup fighter, difficulty--these are all initial values but can change.... since there is specified a savegame.
Flightgroup Section
-
flightgroup
- name [string] [needed] - The displayed name.
- logo [string]
- logo_alpha [string]
- faction [string] [needed]
- type [string] [needed] - Unit type.
- "hornet.xunit" (default) FIXME
- ainame [string] [needed] - AI to use.
- Much like
data/ai/VegaEvents.csv
: it refers todata/ai/events/ainame.*.xml
AI files, not .xai scripts they call. - "_ainame" - FIXME Seems to use Python AI modules.
- Much like
- waves [int] [needed] - Number of waves. The next one will be launched only after its predecessor is completely eliminated.
- nr_ships [int] [needed] - Ships per wave.
- terrain_nr
- "" (default); "mission"
- unit_type
- "" (default) =unit; "vehicle"; "building"
-
pos
[double] [needed],rot
[float] - Coordinates and orientation.- x, y, z [float]
-
order
- Scripted orders for the flightgroup. Elements are read, but seems to not being actually parsed currently. FIXME Flightgroups spawn with "fire at will" directive and start acting as their AI setups and AI priorities suggest.- order [needed]
- target [needed] - The name of target flightgroup.
- priority - Seems not to be used at all. FIXME
<flightgroups> <flightgroup name="Shlimazel" faction="privateer" type="llama.begin" ainame="default" waves="1" nr_ships="1"> <pos x="-95124024.543917" y="412089916.256812" z="-110779667.398050"/> <rot x="180.0" y="180.0" z="180.0"/> <order order="tmptarget" target="omikron"/> <order priority="0" order="superiority" target="enemy"/> <order priority="1" order="bomber" target="omikron"/> <order priority="2" order="escort" target="blue"/> </flightgroup> </flightgroups>
The rot
flag is ignored, and the position specifies the x,y,z
coords of the Shlimazel flightgroup, which is of type llama.begin
.
Python Section
Future note: If you wanted to add a campaign to the privateer mission you would most likely modify privateer.py
to have a campaign module get loaded.... so you wouldn't necessarily need to modify explore_universe.mission
just to add a campaign... lets dig further into the meat of the scripting.
If a mission has python tags...then it is a python mission and may have some embedded python in it. In this case the python makes a new python object of type privateer in the privateer.py
module in the modules/missions/
directory.
<python> from privateer import privateer my_obj=privateer(8000,40000,500,3,2,.6,.25,.1,400000,2000) </python> </mission>
You have to be careful about newlines, etc in the XML, but it should usually work just dandy. You notice that the mission may pass in arguments to the privateer module that can make slight changes in the gameplay. This allows many cargo missions to use the same module in order to change the parameters of the cargo missions. In this case the values I have selected appear to work relatively well.
Note: Python code must be on a line by itself without any indentations--it needs to work exactly as it would if you had the contents in a python file itself. If you want the indents to work in-line with the XML file, you must prefix it with a block, such as an if statement:
<python>if 1: from privateer import privateer my_obj=privateer(8000,40000,500,3,2,.6,.25,.1,400000,2000) </python> </mission>