== Global available Constants ==
LAND_WIDTH, LAND_HEIGHT
Game flags:
gfForts, gfMultiWeapon, gfSolidLand, gfDivideTeams, gfLowGravity, gfLaserSight, gfInvulnerable, gfMines, gfVampiric, gfKarma, gfArtillery, gfOneClanMode, gfRandomOrder, gfKing, gfPlaceHog, gfSharedAmmo, gfDisableGirders, gfExplosives, gfDisableLandObjects, gfAISurvival, gfInfAttack, gfResetWeps, gfPerHogAmmo, gfDisableWind
More constants at [GearTypes Gear Types] , [AmmoTypes Ammo Types], [Sounds], [States] Additional global changing variables accessible: * !TurnTimeLeft - number of game ticks left until the current turn ends * !ClansCount - number of clans in the game (teams with the same color belong to one clan) == Event Handlers == === onGameInit() ===
This function is called before the game loads its resources. One can modify various game variables here:
* Seed = 0 - sets the seed of the random number generator * !GameFlags = gfSolidLand + gfArtillery + … - sets the gameflags, see above for the available flags * !TurnTime = 60000 - set the turntime in ms * !CaseFreq = 0 - frequency of crate drops * HealthCaseProb = 35 - chance of receiving a health crate * HealthCaseAmount = 25 - amount of health in a health crate * !DamagePercent = 100 - percent of damage to inforce * !MinesNum = 0 - number of mines being placed (before 0.9.14 LandAdds) * !MinesTime = 3 - time for a mine to explode from activated, -1 for random * !MineDudPercent = 0 - chance of mine being a dud * Explosives = 0 - number of explosives being placed * Delay = 0 - delay between each round * !SuddenDeathTurns = 30 - turns until sudden death begins * WaterRise = 47 - height of water rise at sudden death in pixels * HealthDecrease = 5 - amount of health decreased on sudden death * Map = "Bamboo" - the map being played * Theme = "Bamboo" - the theme to be used If you want to add teams or hogs manually you have to do it here. === onGameStart() ===
This function is called when the first round starts.
Can be used to show the mission and for more setup, for example initial target spawning. === onGameTick() ===
This function is called on every game tick, i.e. 1000 times a second.
=== onGearAdd(gearUid) ===
This function is called when a new gear is added. Useful in combination with !GetGearType(gearUid).
=== onGearDelete(gearUid) ===
This function is called when a new gear is deleted. Useful in combination with !GetGearType(gearUid).
=== onAmmoStoreInit() ===
This function is called when the game is initialized to request the available ammo and ammo probabilities. Use !SetAmmo here.
== Functions for creating gears == === !AddGear(x, y, gearType, state, dx, dy, timer) ===
This creates a new gear at position x,y (measured from top left) of kind gearType (see [GearTypes Gear Types]). The initial velocities are dx and dy. All arguments are numbers. The function returns the uid of the gear created.
Example: local gear = !AddGear(0, 0, gtTarget, 0, 0, 0, 0) !FindPlace(gear, true, 0, LAND_WIDTH) === !SpawnHealthCrate(x, y) (0.9.14) ===
Spawns a health crate at the specified position.
=== !SpawnAmmoCrate(x, y, ammoType) (0.9.14) ===
Spawns an ammo crate at the specified position with content of ammoType (see [AmmoTypes Ammo Types]). Because by default settings the number of ammo in crates is zero it has to be increased to at least one with SetAmmo first, see the example:
Example: !SetAmmo(amGrenade, 0, 0, 0, 1) -- see below !SpawnAmmoCrate(0, 0, amGrenade) -- x=y=0 means random position on map === !SpawnUtilityCrate(x, y, ammoType) (0.9.14) ===
Spawns an utility crate at specified position with content of ammoType.
Example: !SetAmmo(amLaserSight, 0, 0, 0, 1) !SpawnUtilityCrate(0, 0, amLaserSight) === !AddTeam(teamname, color, grave, fort, voicepack) ===
Adds a new team. Note that this can only be done in onGameInit(), not at a later time. First argument is the team name followed by color, grave, fort and voicepack settings.
Notice: This works only for singleplayers training missions for now and will desync multiplayer games. Example: !AddTeam("team 1", 14483456, "Simple", "Island", "Default") === !AddHog(hogname, botlevel, health, hat) ===
Adds a new hedgehog for current team (last created one), with botlevel and specified health also head.
Notice: This works only for singleplayers training missions for now and will desync multiplayer games. Example: local player = !AddHog("HH 1", 0, 100, "!NoHat") -- botlevel 0 means human player !SetGearPosition(player, 1500, 1000) == Functions to get gear properties == === !GetGearType(gearUid) ===
returns one of [GearTypes Gear Types] for the specified gear
=== !GetGearPosition(gearUid) ===
returns tuple of x,y coordinates for the specified gear
=== !GetHogClan(gearUid) ===
returns the clan id of the specified hedgehog gear
=== !GetHogName(gearUid) ===
returns the name of the specified hedgehog gear
=== GetX(gearUid) ===
returns x coordinate of the gear
=== GetY(gearUid) ===
returns y coordinate of the gear
=== !GetState(gearUid) ===
returns the state of the gear. This is one of [States]
=== !GetFollowGear(gearUid) ===
Returns the uid of the gear that is currently being followed.
=== !GetTimer(gearUid) (0.9.14) ===
returns the timer of the gear. This is for example the time it takes for watermelon, mine, etc. to explode. This is also the time used to specify the blowtorch or rcplane time.
=== !GetHealth(gearUid) (0.9.14) ===
returns the health of the gear
=== !GetBotLevel(gearUid) (0.9.14) ===
returns the bot level from 0 to 5. 0 means human player.
== Functions to modify gears == === !FindPlace(gearUid, fall, left, right) ===
Finds a place for the specified gear between x=left and x=right and places it there.
Example: gear = !AddGear(…) !FindPlace(gear, true, 0, LAND_WIDTH) -- places the gear randomly between 0 and LAND_WIDTH === !SetGearPosition(gearUid, x, y) ===
Places the specified gear exactly at the position (x,y).
=== !SetAmmo(ammoType, count, probability, delay, numberInCrate) ===
This updates the settings for a specified [AmmoTypes Ammo Type] as of count available for players, spawn probability, availability delay in turns, and the number available in crates. This is supposed to be used in the onAmmoStoreInit() even handler.
Example: !SetAmmo(amShotgun, 9, 0, 0, 0) -- unlimited amount of shotgun ammo for players !SetAmmo(amGrenade, 0, 0, 0, 3) -- crates should contain always three grenade === !SetHealth(gearUid, health) ===
Sets the health of the specified gear.
=== !SetEffect(gearUid, effect, true/false) (0.9.14) ===
Enables (true) or disables (false) one of the effects heInvulnerable, heResurrectable, hePoisoned for the specified hedgehog gear.
Example: (sets all bots poisoned) function onGearAdd(gear) if (!GetGearType(gear) === gtHedgehog) and (!GetBotLevel(gear) > 0) then !SetEffect(gear, hePoisoned, true) end end === CopyPV(gearUid, gearUid) ===
This sets the position and velocity of the second gear to the first one.
=== CopyPV2(gearUid, gearUid) ===
This sets the position of the second gear to that of the first one, but makes its velocity twice the one of the first.
=== !FollowGear(gearUid) ===
Makes the gameclient follow the specifiec gear.
=== !SetState(gearUid, state) ===
Sets the state of the specified gear to one of [States]
=== !SetTag(gearUid, tag) === === !SetTimer(gearUid, timer) (0.9.14) ===
Sets the timer of the specified gear. Also see !GetTimer.
== Other Functions == === !EndGame() ===
Makes the game end.
=== !ParseCommand(string) ===
Makes the gameclient parse the specified custom command.
=== !ShowMission(caption, subcaption, text, icon, time) === === !HideMission() === === !PlaySound(soundId) === === !SetZoom(zoomLevel) (0.9.14) ===
Sets the zoom level. The value for maximum zoom is currently 1.0 and for minimum 3.0 The default zoom level is 2.0
=== !GetZoom() (0.9.14) ===
Returns the current zoom level
== Debugging Functions == === !WriteLnToConsole(string) (0.9.14) ===
Guess :D