LuaLibrarySimpleMission.wiki
changeset 1932 15edba44c050
parent 1824 a5a87fba78fa
child 1933 458e9d8b4875
equal deleted inserted replaced
1931:d6ef1025d96f 1932:15edba44c050
    21 This function sets up the *entire* mission and needs one argument: params. The argument `params` is a table containing fields which describe the mission.
    21 This function sets up the *entire* mission and needs one argument: params. The argument `params` is a table containing fields which describe the mission.
    22 
    22 
    23 This is the definition of the `params` table:
    23 This is the definition of the `params` table:
    24 
    24 
    25 <code>
    25 <code>
    26 Mandatory fields:
    26 	Mandatory fields:
    27 - teams:		Table of teams. There must be 1-8 teams.
    27 	- teams:		Table of teams. There must be 1-8 teams.
    28 
    28 
    29 Optional fields
    29 	Optional fields
    30 - ammoConfig		Table containing basic ammo values (default: infinite skip only)
    30 	- ammoConfig		Table containing basic ammo values (default: infinite skip only)
    31 - initVars		Table where you set up environment parameters such as MinesNum.
    31 	- initVars		Table where you set up environment parameters such as MinesNum.
    32 - wind			If set, the wind will permanently set to this value (-100..100). Implies gfDisableWind
    32 	- wind			If set, the wind will permanently set to this value (-100..100). Implies gfDisableWind
    33 - gears:		Table of objects.
    33 	- gears:		Table of objects.
    34 - girders		Table of girders
    34 	- girders		Table of girders
    35 - rubbers		Table of rubbers
    35 	- rubbers		Table of rubbers
    36 
    36 
    37 AMMO
    37 	AMMO
    38 - ammoType		ammo type
    38 	- ammoType		ammo type
    39 - delay			delay (default: 0)
    39 	- delay			delay (default: 0)
    40 - numberInCrate		ammo per crate (default: 1)
    40 	- numberInCrate		ammo per crate (default: 1)
    41 - count			default starter ammo for everyone, 9 for infinite (default: 0)
    41 	- count			default starter ammo for everyone, 9 for infinite (default: 0)
    42 - probability		probability in crates (default: 0)
    42 	- probability		probability in crates (default: 0)
    43 
    43 
    44 TEAM DATA
    44 	TEAM DATA
    45 - hogs			table of hedgehogs in this team (must contain at least 1 hog)
    45 	- isMissionTeam		if true, this is the player's chosen team for this mission (default: false)
    46 - name			team name
    46 	- hogs			table of hedgehogs in this team (must contain at least 1 hog)
    47 - clanID		ID of the clan to which this team belongs to. Counting starts at 0.
    47 	- clanID		ID of the clan to which this team belongs to. Counting starts at 0.
    48 			By default, each team goes into its own clan.
    48 				By default, each team goes into its own clan.
    49 			Important: The clan of the player and allies MUST be 0.
    49 				Important: The clan of the player and allies MUST be 0.
    50 			Important: You MUST either set the clan ID explicitly for all teams or none of them.
    50 				Important: You MUST either set the clan ID explicitly for all teams or none of them.
    51 - flag			flag name (default: hedgewars)
    51 	These arguments will be ignored if this is a mission team:
    52 - grave			grave name (has default grave for each team)
    52 	- name			team name
    53 - fort			fort name (default: Castle)
    53 	- flag			flag name (default: hedgewars)
       
    54 	- grave			grave name (has default grave for each team)
       
    55 	- fort			fort name (default: Castle)
       
    56 	- voice			voicepack (default: Default_qau)
    54 
    57 
    55 HEDGEHOG DATA:
    58 	HEDGEHOG DATA:
    56 - id			optional identifier for goals
    59 	- id			optional identifier for goals
    57 - name			hog name
    60 	- health		hog health (default: 100)
    58 - x, y			hog position (default: spawns randomly on land)
    61 	- ammo			table of ammo types
    59 - botLevel		1-5: Bot level (lower=stronger). 0=human player (default: 0)
    62 	- x, y			hog position (default: spawns randomly on land)
    60 - hat			hat name (default: NoHat)
    63 	- poisoned		if true, hedgehog starts poisoned with 5 poison damage. Set to a number for other poison damage (default: false)
    61 - health		hog health (default: 100)
    64 	- frozen		if true, hedgehogs starts frozen (default: false)
    62 - poisoned		if true, hedgehog starts poisoned with 5 poison damage. Set to a number for other poison damage (default: false)
    65 	- faceLeft		initial facing direction. true=left, false=false (default: false)
    63 - frozen		if true, hedgehogs starts frozen (default: false)
    66 	These arguments will be ignored if the hog is in a mission team:
    64 - faceLeft		initial facing direction. true=left, false=false (default: false)
    67 	- name			hog name
    65 - ammo			table of ammo types
    68 	- botLevel		1-5: Bot level (lower=stronger). 0=human player (default: 0)
       
    69 	- hat			hat name (default: NoHat)
    66 
    70 
    67 GEAR TYPES:
    71 	GEAR TYPES:
    68 - type			gear type
    72 	- type			gear type
    69 ALL types:
    73 	ALL types:
    70 	id		optional identifier for goals
    74 		id		optional identifier for goals
    71 	x		x coordinate of starting position (default: 0)
    75 		x		x coordinate of starting position (default: 0)
    72 	y		y coordinate of starting position (default: 0)
    76 		y		y coordinate of starting position (default: 0)
    73 	dx		initial x speed (default: 0)
    77 		dx		initial x speed (default: 0)
    74 	dy		initial y speed (default: 0)
    78 		dy		initial y speed (default: 0)
    75 - type=gtMine		Mine
    79 	- type=gtMine		Mine
    76 	timer 		Mine timer (only for non-duds). Default: MinesTime
    80 		timer 		Mine timer (only for non-duds). Default: MinesTime
    77 	isDud		Whether the mine is a dud. default: false
    81 		isDud		Whether the mine is a dud. default: false
    78 	isFrozen	Whether the mine is frozen. If true, it implies being a dud as well. Default: false
    82 		isFrozen	Whether the mine is frozen. If true, it implies being a dud as well. Default: false
    79 	health 		Initial health of dud mines. Has no effect if isDud=false. Default: 36
    83 		health 		Initial health of dud mines. Has no effect if isDud=false. Default: 36
    80 - type=gtSMine		Sticky mine
    84 	- type=gtSMine		Sticky mine
    81 	timer		Timer. Default: 500
    85 		timer		Timer. Default: 500
    82 - type=gtAirMine	Air mine
    86 	- type=gtAirMine	Air mine
    83 	timer		Timer. Default: (MinesTime/1000 * 250)
    87 		timer		Timer. Default: (MinesTime/1000 * 250)
    84 - type=gtExplosives	Barrel
    88 	- type=gtExplosives	Barrel
    85 	health		Initial health. Default: 60
    89 		health		Initial health. Default: 60
    86 	isFrozen	Whether the barrel is frozen. Default: true with health > 60, false otherwise
    90 		isFrozen	Whether the barrel is frozen. Default: true with health > 60, false otherwise
    87 	isRolling	Whether the barrel starts in “rolling” state. Default: false
    91 		isRolling	Whether the barrel starts in “rolling” state. Default: false
    88 - type=gtCase		Crate
    92 	- type=gtCase		Crate
    89 	crateType	"health": Health crate
    93 		crateType	"health": Health crate
    90 			"supply": Ammo or utility crate (select crate type automatically)
    94 				"supply": Ammo or utility crate (select crate type automatically)
    91 			"supply_ammo_explicit": Ammo crate (not recommened)
    95 				"supply_ammo_explicit": Ammo crate (not recommened)
    92 			"supply_utility_explicit": Utility crate (not recommededn)
    96 				"supply_utility_explicit": Utility crate (not recommededn)
    93 	ammoType	Contained ammo (only for ammo and utility crates).
    97 		ammoType	Contained ammo (only for ammo and utility crates).
    94 	health		Contained health (only for health crates). Default: HealthCaseAmount
    98 		health		Contained health (only for health crates). Default: HealthCaseAmount
    95 	isFrozen	Whether the crate is frozen. Default: false
    99 		isFrozen	Whether the crate is frozen. Default: false
    96 - type=gtKnife		Cleaver
   100 	- type=gtKnife		Cleaver
    97 - type=gtTarget		Target
   101 	- type=gtTarget		Target
    98 
   102 
    99 GOALS:
   103 	GOALS:
   100 Note: If there are at least two opposing teams, a default goal is used, which is to defeat all the enemies of the
   104 	Note: If there are at least two opposing teams, a default goal is used, which is to defeat all the enemies of the
   101 player's team. If this is what you want, you can skip this section.
   105 	player's team. If this is what you want, you can skip this section.
   102 
   106 
   103 The default goal is overwritten as if customGoals has been set. Set customGoals and other related parameters for
   107 	The default goal is overwritten as if customGoals has been set. Set customGoals and other related parameters for
   104 defining your own special goals. In this case, the mission is won if all customGoals are completed.
   108 	defining your own special goals. In this case, the mission is won if all customGoals are completed.
   105 Note the mission will always fail if the player's hedgehogs and all their allies have been defeated.
   109 	Note the mission will always fail if the player's hedgehogs and all their allies have been defeated.
   106 If there is only one team (for the player), there is no default goal and one must be set explicitly.
   110 	If there is only one team (for the player), there is no default goal and one must be set explicitly.
   107 - customGoals		Table of custom goals (see below). All of them must be met to win. Some goal types might fail,
   111 	- customGoals		Table of custom goals (see below). All of them must be met to win. Some goal types might fail,
   108 			rendering the mission unwinnable and leading to the loss of the mission. An example is
   112 				rendering the mission unwinnable and leading to the loss of the mission. An example is
   109 			blowing up a crate which you should have collected.ed.
   113 				blowing up a crate which you should have collected.ed.
   110 - customNonGoals	Table of non-goals, the player loses if one of them is achieved
   114 	- customNonGoals	Table of non-goals, the player loses if one of them is achieved
   111 - customGoalCheck	When to check goals and non-goals. Values: "instant" (default), "turnStart", "turnEnd"
   115 	- customGoalCheck	When to check goals and non-goals. Values: "instant" (default), "turnStart", "turnEnd"
   112 
   116 
   113 - missionTitle:		The name of the mission (highly recommended)
   117 	- missionTitle:		The name of the mission (highly recommended)
   114 - missionIcon:		Icon of the mission panel, see documentation of ShowMission in the Lua API
   118 	- missionIcon:		Icon of the mission panel, see documentation of ShowMission in the Lua API
   115 - goalText:		A short string explaining the goal of the mission (use this if you set custom goals).
   119 	- goalText:		A short string explaining the goal of the mission (use this if you set custom goals).
   116 
   120 
   117 GOAL TYPES:
   121 	GOAL TYPES:
   118 - type			name of goal type
   122 	- type			name of goal type
   119 - failText		Optional. For non-goals, this text will be shown in the stats if mission fails due to this non-goal
   123 	- failText		Optional. For non-goals, this text will be shown in the stats if mission fails due to this non-goal
   120 			being completed. For goals which fail, this text will be displayed at failure. Note that
   124 				being completed. For goals which fail, this text will be displayed at failure. Note that
   121 			all normal goals have sensible default fail texts.
   125 				all normal goals have sensible default fail texts.
   122 - type="destroy"	Gear must be destroyed
   126 	- type="destroy"	Gear must be destroyed
   123 	- id		Gear to destroy
   127 		- id		Gear to destroy
   124 - type="teamDefeat"	Team must be defeated
   128 	- type="teamDefeat"	Team must be defeated
   125 	- teamName	Name of team to defeat
   129 		- teamName	Name of team to defeat
   126 - type="collect"	Crate must be collected
   130 	- type="collect"	Crate must be collected
   127 	FAIL CONDITION:	Crate taken by enemy, or destroyed
   131 		FAIL CONDITION:	Crate taken by enemy, or destroyed
   128 	- id		ID of crate gear to collect
   132 		- id		ID of crate gear to collect
   129 	- collectors	Optional table of gear IDs, any one of which must collect the gear (but nobody else!).
   133 		- collectors	Optional table of gear IDs, any one of which must collect the gear (but nobody else!).
   130 			By default, this is for the player's teams and allies.
   134 				By default, this is for the player's teams and allies.
   131 - type="turns"		Achieved when a number of turns has been played
   135 	- type="turns"		Achieved when a number of turns has been played
   132 	- turns 	Number of played turns 
   136 		- turns 	Number of played turns 
   133 - type="rounds"		Achieved when a number of rounds has been played
   137 	- type="rounds"		Achieved when a number of rounds has been played
   134 	- rounds	Number of played rounds
   138 		- rounds	Number of played rounds
   135 - type="suddenDeath"	Sudden Death has started
   139 	- type="suddenDeath"	Sudden Death has started
   136 - type="inZone"		A gear is within given coordinate bounds. Each of xMin, xMax, yMin and yMax is a sub-goal.
   140 	- type="inZone"		A gear is within given coordinate bounds. Each of xMin, xMax, yMin and yMax is a sub-goal.
   137 			Each sub-goal is only checked if not nil.
   141 				Each sub-goal is only checked if not nil.
   138 			You can use this to check if a gear left, right, above or below a given coordinate.
   142 				You can use this to check if a gear left, right, above or below a given coordinate.
   139 			To check if the gear is within a rectangle, just set all 4 sub-goals.
   143 				To check if the gear is within a rectangle, just set all 4 sub-goals.
   140 	FAIL CONDITION:	Gear destroyed
   144 		FAIL CONDITION:	Gear destroyed
   141 	- id		Gear to watch
   145 		- id		Gear to watch
   142 	- xMin		gear's X coordinate must be lower than this
   146 		- xMin		gear's X coordinate must be lower than this
   143 	- xMax		gear's X coordinate must be higher than this
   147 		- xMax		gear's X coordinate must be higher than this
   144 	- yMin		gear's Y coordinate must be lower than this
   148 		- yMin		gear's Y coordinate must be lower than this
   145 	- yMax		gear's Y coordinate must be higher than this
   149 		- yMax		gear's Y coordinate must be higher than this
   146 - type="distGearPos"	Distance between a gear and a fixed position
   150 	- type="distGearPos"	Distance between a gear and a fixed position
   147 	FAIL CONDITION:	Gear destroyed
   151 		FAIL CONDITION:	Gear destroyed
   148 	- distance	goal distance to compare to
   152 		- distance	goal distance to compare to
   149 	- relationship	"greaterThan" or "smallerThan"
   153 		- relationship	"greaterThan" or "smallerThan"
   150 	- id		gear to watch
   154 		- id		gear to watch
   151 	- x		x coordinate to reach
   155 		- x		x coordinate to reach
   152 	- y		y coordinate to reach
   156 		- y		y coordinate to reach
   153 - type="distGearGear"	Distance between two gears
   157 	- type="distGearGear"	Distance between two gears
   154 	FAIL CONDITION:	Any of both gears destroyed
   158 		FAIL CONDITION:	Any of both gears destroyed
   155 	- distance	goal distance to compare to
   159 		- distance	goal distance to compare to
   156 	- relationship	"greaterThan" or "smallerThan"
   160 		- relationship	"greaterThan" or "smallerThan"
   157 	- id1		first gear to compare
   161 		- id1		first gear to compare
   158 	- id2		second gear to compare
   162 		- id2		second gear to compare
   159 - type="damage"		Gear took damage or was destroyed
   163 	- type="damage"		Gear took damage or was destroyed
   160 	- id		Gear to watch
   164 		- id		Gear to watch
   161 	- damage	Minimum amount of damage to take at a single blow. Default: 1
   165 		- damage	Minimum amount of damage to take at a single blow. Default: 1
   162 	- canDestroy	If false, this goal will fail if the gear was destroyed without taking the required damage
   166 		- canDestroy	If false, this goal will fail if the gear was destroyed without taking the required damage
   163 - type="drown"		Gear has drowned
   167 	- type="drown"		Gear has drowned
   164 	FAIL CONDITION:	Gear destroyed by other means
   168 		FAIL CONDITION:	Gear destroyed by other means
   165 	- id		Gear to watch
   169 		- id		Gear to watch
   166 - type="poison"		Gear must be poisoned
   170 	- type="poison"		Gear must be poisoned
   167 	FAIL CONDITION:	Gear destroyed
   171 		FAIL CONDITION:	Gear destroyed
   168 	- id		Gear to be poisoned
   172 		- id		Gear to be poisoned
   169 - type="cure"		Gear must exist and be free from poisoning
   173 	- type="cure"		Gear must exist and be free from poisoning
   170 	FAIL CONDITION:	Gear destroyed
   174 		FAIL CONDITION:	Gear destroyed
   171 	- id		Gear to check
   175 		- id		Gear to check
   172 - type="freeze"		Gear must exist and be frozen
   176 	- type="freeze"		Gear must exist and be frozen
   173 	FAIL CONDITION:	Gear destroyed
   177 		FAIL CONDITION:	Gear destroyed
   174 	- id		Gear to be frozen
   178 		- id		Gear to be frozen
   175 - type="melt"		Gear must exist and be unfrozen
   179 	- type="melt"		Gear must exist and be unfrozen
   176 	FAIL CONDITION:	Gear destroyed
   180 		FAIL CONDITION:	Gear destroyed
   177 	- id		Gear to check
   181 		- id		Gear to check
   178 - type="waterSkip"	Gear must have skipped over water
   182 	- type="waterSkip"	Gear must have skipped over water
   179 	FAIL CONDITION:	Gear destroyed before it reached the required number of skips
   183 		FAIL CONDITION:	Gear destroyed before it reached the required number of skips
   180 	- id
   184 		- id
   181 	- skips		Total number of water skips required at least (default: 1)
   185 		- skips		Total number of water skips required at least (default: 1)
   182 </code>
   186 </code>
   183 
   187 
   184 Source: https://hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Scripts/SimpleMission.lua
   188 Source: https://hg.hedgewars.org/hedgewars/raw-file/tip/share/hedgewars/Data/Scripts/SimpleMission.lua
   185 
   189 
   186 === Examples ===
   190 === Examples ===