share/hedgewars/Data/Scripts/SimpleMission.lua
changeset 14483 310b167141cc
parent 14466 734a7af2dfc2
child 14484 764ba6182389
equal deleted inserted replaced
14482:d4aa64f51c9f 14483:310b167141cc
    51 	- numberInCrate		ammo per crate (default: 1)
    51 	- numberInCrate		ammo per crate (default: 1)
    52 	- count			default starter ammo for everyone, 9 for infinite (default: 0)
    52 	- count			default starter ammo for everyone, 9 for infinite (default: 0)
    53 	- probability		probability in crates (default: 0)
    53 	- probability		probability in crates (default: 0)
    54 
    54 
    55 	TEAM DATA
    55 	TEAM DATA
       
    56 	- isMissionTeam		if true, this is the player's chosen team for this mission (default: false)
    56 	- hogs			table of hedgehogs in this team (must contain at least 1 hog)
    57 	- hogs			table of hedgehogs in this team (must contain at least 1 hog)
    57 	- name			team name
       
    58 	- clanID		ID of the clan to which this team belongs to. Counting starts at 0.
    58 	- clanID		ID of the clan to which this team belongs to. Counting starts at 0.
    59 				By default, each team goes into its own clan.
    59 				By default, each team goes into its own clan.
    60 				Important: The clan of the player and allies MUST be 0.
    60 				Important: The clan of the player and allies MUST be 0.
    61 				Important: You MUST either set the clan ID explicitly for all teams or none of them.
    61 				Important: You MUST either set the clan ID explicitly for all teams or none of them.
       
    62 	These arguments will be ignored if this is a mission team:
       
    63 	- name			team name
    62 	- flag			flag name (default: hedgewars)
    64 	- flag			flag name (default: hedgewars)
    63 	- grave			grave name (has default grave for each team)
    65 	- grave			grave name (has default grave for each team)
    64 	- fort			fort name (default: Castle)
    66 	- fort			fort name (default: Castle)
    65 
    67 
    66 	HEDGEHOG DATA:
    68 	HEDGEHOG DATA:
    67 	- id			optional identifier for goals
    69 	- id			optional identifier for goals
    68 	- name			hog name
    70 	- health		hog health (default: 100)
       
    71 	- ammo			table of ammo types
    69 	- x, y			hog position (default: spawns randomly on land)
    72 	- x, y			hog position (default: spawns randomly on land)
    70 	- botLevel		1-5: Bot level (lower=stronger). 0=human player (default: 0)
       
    71 	- hat			hat name (default: NoHat)
       
    72 	- health		hog health (default: 100)
       
    73 	- poisoned		if true, hedgehog starts poisoned with 5 poison damage. Set to a number for other poison damage (default: false)
    73 	- poisoned		if true, hedgehog starts poisoned with 5 poison damage. Set to a number for other poison damage (default: false)
    74 	- frozen		if true, hedgehogs starts frozen (default: false)
    74 	- frozen		if true, hedgehogs starts frozen (default: false)
    75 	- faceLeft		initial facing direction. true=left, false=false (default: false)
    75 	- faceLeft		initial facing direction. true=left, false=false (default: false)
    76 	- ammo			table of ammo types
    76 	These arguments will be ignored if the hog is in a mission team:
       
    77 	- name			hog name
       
    78 	- botLevel		1-5: Bot level (lower=stronger). 0=human player (default: 0)
       
    79 	- hat			hat name (default: NoHat)
    77 
    80 
    78 	GEAR TYPES:
    81 	GEAR TYPES:
    79 	- type			gear type
    82 	- type			gear type
    80 	ALL types:
    83 	ALL types:
    81 		id		optional identifier for goals
    84 		id		optional identifier for goals
   654 				clanID = clanCounter
   657 				clanID = clanCounter
   655 				clanCounter = clanCounter + 1
   658 				clanCounter = clanCounter + 1
   656 			else
   659 			else
   657 				clanID = teamData.clanID
   660 				clanID = teamData.clanID
   658 			end
   661 			end
   659 			grave = def(teamData.grave, defaultGraves[math.min(teamID, 8)])
   662 
   660 			fort = def(teamData.fort, "Castle")
   663 			local idx
   661 			voice = def(teamData.voice, "Default")
   664 			if teamData.isMissionTeam then
   662 			flag = def(teamData.flag, defaultFlags[math.min(teamID, 8)])
   665 				idx = AddMissionTeam(-(clanID+1))
   663 
   666 				_G.sm.playerClan = clanID
   664 			AddTeam(name, -(clanID+1), grave, fort, voice, flag)
   667 			else
       
   668 				grave = def(teamData.grave, defaultGraves[math.min(teamID, 8)])
       
   669 				fort = def(teamData.fort, "Castle")
       
   670 				voice = def(teamData.voice, "Default")
       
   671 				flag = def(teamData.flag, defaultFlags[math.min(teamID, 8)])
       
   672 
       
   673 				idx = AddTeam(name, -(clanID+1), grave, fort, voice, flag)
       
   674 				local realName = GetTeamName(idx)
       
   675 				-- Update all teamDefeat goals if the real team name differs from the
       
   676 				-- team configuration.
       
   677 				-- (AddTeam might change the name due to naming collisions)
       
   678 				if name ~= realName then
       
   679 					local checks = { params.customGoals, params.customNonGoals }
       
   680 					for c=1, 2 do
       
   681 						if checks[c] then
       
   682 							for k,goal in pairs(checks[c]) do
       
   683 								if goal.type == "teamDefeat" and goal.teamName == name then
       
   684 									goal.teamName = realName
       
   685 								end
       
   686 							end
       
   687 						end
       
   688 					end
       
   689 				end
       
   690 			end
   665 
   691 
   666 			for hogID, hogData in pairs(teamData.hogs) do
   692 			for hogID, hogData in pairs(teamData.hogs) do
   667 				local name, botLevel, health, hat
   693 				local name, botLevel, health, hat
   668 				name = def(hogData.name, string.format(loc("Hog %d"), hogID))
   694 				name = def(hogData.name, string.format(loc("Hog %d"), hogID))
   669 				botLevel = def(hogData.botLevel, 0)
   695 				botLevel = def(hogData.botLevel, 0)
   670 				health = def(hogData.health, 100)
   696 				health = def(hogData.health, 100)
   671 				hat = def(hogData.hat, "NoHat")
   697 				hat = def(hogData.hat, "NoHat")
   672 				local hog = AddHog(name, botLevel, health, hat)
   698 				local hog
       
   699 				if teamData.isMissionTeam then
       
   700 					hog = AddMissionHog(health)
       
   701 				else
       
   702 					hog = AddHog(name, botLevel, health, hat)
       
   703 				end
   673 				if hogData.x ~= nil and hogData.y ~= nil then
   704 				if hogData.x ~= nil and hogData.y ~= nil then
   674 					SetGearPosition(hog, hogData.x, hogData.y)
   705 					SetGearPosition(hog, hogData.x, hogData.y)
   675 				end
   706 				end
   676 				if hogData.faceLeft then
   707 				if hogData.faceLeft then
   677 					HogTurnLeft(hog, true)
   708 					HogTurnLeft(hog, true)