LuaAPI.wiki
changeset 1694 d3bebda2cdfd
parent 1693 a1ff7cf0f55c
child 1695 6bf2e6deedb0
equal deleted inserted replaced
1693:a1ff7cf0f55c 1694:d3bebda2cdfd
   485 === <tt>!AddHog(hogname, botlevel, health, hat)</tt> ===
   485 === <tt>!AddHog(hogname, botlevel, health, hat)</tt> ===
   486 Adds a new hedgehog for current team (last created one with the `AddTeam` function), with a bot level, an initial health and a hat.
   486 Adds a new hedgehog for current team (last created one with the `AddTeam` function), with a bot level, an initial health and a hat.
   487 
   487 
   488 `botlevel` ranges from `0` to `5`, where `0` denotes a human player and `1` to `5` denote the skill level of a bot, where `1` is strongest and `5` is the weakest. Note that this is the reverse order of how the bot level is displayed in the game. Note that mixing human-controlled and computer-controlled hedgehogs in the same team is not permitted, but it is permitted to use different computer difficulty levels in the same team.
   488 `botlevel` ranges from `0` to `5`, where `0` denotes a human player and `1` to `5` denote the skill level of a bot, where `1` is strongest and `5` is the weakest. Note that this is the reverse order of how the bot level is displayed in the game. Note that mixing human-controlled and computer-controlled hedgehogs in the same team is not permitted, but it is permitted to use different computer difficulty levels in the same team.
   489 
   489 
   490 *Warning*: This only works in singleplayer mode (e.g. missions). Also, Hedgewars only supports up to 48 hedgehogs in a game. If you add more hedgehogs or call this function in multiplayer mode, Hedgewars might fail.
   490 Returns the gear ID.
       
   491 
       
   492 *Warning*: This only works in singleplayer mode (e.g. missions). Also, Hedgewars only supports up to 64 hedgehogs in a game.
   491 
   493 
   492 Example:
   494 Example:
   493 
   495 
   494 <code language="lua">    local player = AddHog("HH 1", 0, 100, "NoHat") -- botlevel 0 means human player
   496 <code language="lua">    local player = AddHog("HH 1", 0, 100, "NoHat") -- botlevel 0 means human player
   495     SetGearPosition(player, 1500, 1000)</code>
   497     SetGearPosition(player, 1500, 1000)
       
   498     -- hint: If you don't call `SetGearPosition`, the hog spawns randomly</code>
       
   499 
       
   500 === <tt>!AddMissionHog(health)</tt> (0.9.25) ===
       
   501 Add a hedgehog for the current team, using the player-chosen team identity when playing in singleplayer missions. The “current team” is the last team that was added with `AddMissionTeam` or `AddTeam`.
       
   502 
       
   503 The name and hat match the player's team definition. The hog is also always player-controlled.
       
   504 
       
   505 <code language="lua">-- Add player team with 3 hogs
       
   506 AddMissionTeam(-1)
       
   507 AddMissionHog(100)
       
   508 AddMissionHog(100)
       
   509 AddMissionHog(100)</code>
       
   510 
       
   511 <code language="lua">-- You can also mix mission hogs with “hardcoded” hogs.
       
   512 -- This adds a player team with 2 hogs taken from the player team and 1 hog with a hardcoded name, botlevel and hat.
       
   513 AddMissionTeam(-2)
       
   514 AddMissionHog(100)
       
   515 AddMissionHog(100)
       
   516 AddHog("My Hardcoded Hog", 0, 100, "NoHat")
       
   517 </code>
       
   518 
   496 == Functions to get gear properties ==
   519 == Functions to get gear properties ==
   497 
   520 
   498 === <tt>!GetGearType(gearUid)</tt> ===
   521 === <tt>!GetGearType(gearUid)</tt> ===
   499 This function returns the [GearTypes gear type] for the specified gear, if it exists.  If it doesn't exist, `nil` is returned.
   522 This function returns the [GearTypes gear type] for the specified gear, if it exists.  If it doesn't exist, `nil` is returned.
   500 
   523 
  1386 
  1409 
  1387 <code language="lua">AddTeam("team 1", -1, "Simple", "Tank", "Default", "hedgewars")
  1410 <code language="lua">AddTeam("team 1", -1, "Simple", "Tank", "Default", "hedgewars")
  1388 --[[ Adds a new team with name “team 1”, the first default color (usually red), the grave “Simple”,
  1411 --[[ Adds a new team with name “team 1”, the first default color (usually red), the grave “Simple”,
  1389 the fort “Tank” the voicepack “Default” and the flag “hedgewars”. ]]</code>
  1412 the fort “Tank” the voicepack “Default” and the flag “hedgewars”. ]]</code>
  1390 
  1413 
       
  1414 === <tt>!AddMissionTeam(color)</tt> (0.9.25) ===
       
  1415 Adds a new team using the player-chosen team identity when playing a singleplayer mission.
       
  1416 Does not work in multiplayer.
       
  1417 
       
  1418 This function is very similar to `AddTeam`. Team settings like name or flag do not need to be specified, they will be taken from the player-chosen team.
       
  1419 You only need to specify the color, which works like in `AddTeam`.
       
  1420 
       
  1421 Use `AddMissionHog` or `AddHog` afterwards to add hedgehogs for this team. You can mix `AddMissionHog` and `AddHog` as you wish.
       
  1422 
       
  1423  * `color`: See `AddTeam`.
       
  1424 
       
  1425 Example:
       
  1426 <code language="lua">-- Add mission team with default clan color
       
  1427 AddMissionTeam(-1)</code>
       
  1428 
  1391 ==== <tt>!GetTeamName(teamIdx)</tt> (0.9.24) ====
  1429 ==== <tt>!GetTeamName(teamIdx)</tt> (0.9.24) ====
  1392 Returns the name of the team with the index `teamIdx`. `teamIdx` is a number between 0 and `TeamsCount-1`.
  1430 Returns the name of the team with the index `teamIdx`. `teamIdx` is a number between 0 and `TeamsCount-1`.
  1393 
  1431 
  1394 ==== <tt>!GetTeamIndex(teamname)</tt> (0.9.24) ====
  1432 ==== <tt>!GetTeamIndex(teamname)</tt> (0.9.24) ====
  1395 Returns the team index (number between 0 and `TeamsCount-1`) of the team with the name `teamName`.
  1433 Returns the team index (number between 0 and `TeamsCount-1`) of the team with the name `teamName`.