Bot Library: Difference between revisions

From MyGamingTalk
m (1 revision imported)
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 115: Line 115:
Clears one or more roles of one or more MapGoals.
Clears one or more roles of one or more MapGoals.


'''Parameters:''' (expression, role or table)
'''Parameters:''' (expression or table, role or table)


'''Returns:''' none
'''Returns:''' none
Line 316: Line 316:
The second parameter: 0=info, 1=warning, 2=error, 3=critical
The second parameter: 0=info, 1=warning, 2=error, 3=critical


'''Note:''' logs can be disabled in omni-bot.cfg or by cvar omnibot_logsize
'''Note:''' logs are disabled if cvar omnibot_logsize is zero or negative
 
'''Note:''' logs can also be disabled in omni-bot.cfg


'''Parameters:''' (string, level[optinal, default 0])
'''Parameters:''' (string, level[optinal, default 0])
Line 934: Line 936:


=== GetGoal ===
=== GetGoal ===
Gets a reference to a map goal by name.
Gets a reference to a map goal by name. The goal name is case sensitive.


'''Parameters:''' (name of map goal to get)
'''Parameters:''' (name of map goal to get)
Line 948: Line 950:


=== GetGoals ===
=== GetGoals ===
Gets any number of map goals that match a regular expression. Stores the matching reference in the first table parameter. The previous table content is cleared since omni-bot 0.84. It's not possible to call GetGoals multiple times to accumulate results. The last optional parameter is table of parameters to filter result (Group, Role,  SkipNoInProgress, SkipNoInUse, SkipInUse) or sort result (parameter Sort, values are "none", "priority", "name", "random").
Gets any number of map goals that match a regular expression. Stores the matching reference in the first table parameter. The previous table content is cleared since omni-bot 0.84. It's not possible to call GetGoals multiple times to accumulate results. The last optional parameter is table of parameters to filter result (Group, Role,  SkipNoInProgress, SkipNoInUse, SkipInUse) or sort result (parameter Sort, values are "none", "priority", "name", "priority_name", "random").


'''Parameters:''' (table, team, expression, params[optional])
'''Parameters:''' (table, team, expression, params[optional])
Line 1,412: Line 1,414:
Sets priority of one or more MapGoals for specified team and class. The last parameter must be true for dynamically created goals (FLAG_dropped, FLAGRETURN, DEFUSE ...).
Sets priority of one or more MapGoals for specified team and class. The last parameter must be true for dynamically created goals (FLAG_dropped, FLAGRETURN, DEFUSE ...).


'''Parameters:''' (expression, priority, teamId[optional, default 0], classId[optional, default 0], persistent[optional])
'''Parameters:''' (expression or table, priority, teamId[optional, default 0], classId[optional, default 0], persistent[optional])


'''Returns:''' none
'''Returns:''' none
Line 1,427: Line 1,429:
Sets one or more roles of one or more MapGoals. The last parameter must be true for dynamically created goals (FLAG_dropped, FLAGRETURN, DEFUSE ...).
Sets one or more roles of one or more MapGoals. The last parameter must be true for dynamically created goals (FLAG_dropped, FLAGRETURN, DEFUSE ...).


'''Parameters:''' (expression, role or table, persistent[optional])
'''Parameters:''' (expression or table, role or table, persistent[optional])


'''Returns:''' none
'''Returns:''' none
Line 1,442: Line 1,444:
Passes a table full of properties along to all matching map goals to attempt to set their properties.
Passes a table full of properties along to all matching map goals to attempt to set their properties.


'''Parameters:''' (expression, table of properties)
'''Parameters:''' (expression or table, table of properties)


'''Returns:''' none
'''Returns:''' none

Latest revision as of 08:50, 1 December 2024

Script Reference Bot Library

Global Bot Functions

AddBot

Adds a bot to the game, and optionally specifies team, class, and name for the bot.

Parameters: ()

Parameters: (team)

Parameters: (team, class)

Parameters: (team, class, name)

Parameters: (table)

Returns: none

Example:

 AddBot();
 // OR
 AddBot(TEAM.AXIS);
 // OR
 AddBot(TEAM.AXIS, CLASS.SOLDIER);
 // OR
 AddBot(TEAM.AXIS, CLASS.SOLDIER, "SomeDude");
 // OR
 // not all fields are valid for all games, here's a quake 4 example
 // not all fields are required. any left out will use sensible default values
 tbl =
 {
     name="SomeDude",
     team=TEAM.STROGG,
     class=CLASS.PLAYER,
     spawnpoint="somespawnpointname",
     model="model_player_kane_strogg",
     skin="base",
 };
 AddBot(tbl);

See Also: KickBot, KickAll


AllocGoalSerialNum

Gets unique goal serial number.

Parameters: none

Returns: integer


CalcTrajectory

Calculates a projectile trajectory, and returns the results in a table, or null if no trajectory exists for the parameters given.

Parameters: (Vector3 start position, Vector3 target position, projectile speed, projectile gravity)

Returns: table or null

Example:

 mypos = Vector3(10,10,10); // get a valid position from somewhere
 targpos = Vector3(20,20,20); // get a valid position from somewhere
 projVel = 1000;
 projGrav = 0.5;
 traj = CalcTrajectory(mypos, targpos, projVel, projGrav);
 if(traj)
 {
     // if a table was returned, there can be 1 or 2 trajectories stored in it.
     // the 1st trajectory is the most direct trajectory
     // the 2nd trajectory is normally a mortar trajectory with a high degree of arc.
     // both trajectories are a unit length facing vector
     b.TurnToFacing(traj[0]);
     // OR
     b.TurnToFacing(traj[1]);
 }

CheatsEnabled

Checks if cheat mode is enabled in the game. Useful for debug or development scripts that use functions that are only available in cheat mode.

Parameters: none

Returns: true if cheats are enabled, false if not

Example:

 if(CheatsEnabled())
 {
     // do something
 }

See Also: EntityKill, ServerCommand


CheckEntityBoundsIntersect

Checks if entities intersect.

Parameters: (entity1, entity2)

Returns: true/false


ClearGoalRole

Clears one or more roles of one or more MapGoals.

Parameters: (expression or table, role or table)

Returns: none

Example:

 example: ClearGoalRole( "FLAG_Gold", ROLE.ATTACKER ); //1 goal, 1 role
 example: ClearGoalRole( "DEFEND_City[4567]", { ROLE.DEFENDER2, ROLE.DEFENDER3}); //4 goals, 2 roles

See Also: Roles


ConfigGet

Gets a config value from omni-bot.cfg. Sets a config value if it does not exist yet and if the third parameter is not null.

Type of the return value is string, int or float according to the third parameter. If you call ConfigGet with only 2 parameters, it will return string.

Parameters: (section, config parameter name, config parameter value[optional])

Returns: config parameter value

Example:

ft = ConfigGet("FireTeam", "enabled", 1);

See Also: ConfigSet


ConfigSet

Sets a config value in omni-bot.cfg.

Parameters: (section, config parameter name, config parameter value)

Returns: none

Example:

ConfigSet("FireTeam", "enabled", 0);

See Also: ConfigGet


CreateMapGoal

Creates a new goal.

Parameters: (type)

Returns: MapGoal object


Debug Functions


DrawAABB

See: DrawDebugAABB


DrawArrow

Draws an arrow. Used for facing or AimVectors.

Parameters: (Vector3 start, Vector3 end, color, duration)

Returns: none


DrawDebugAABB

Draws a box.

Parameters: (AABB, color, duration)

Returns: none

Example:

 AABB box; // initialize it with something
 // draw it in red for 5 seconds
 DrawDebugAABB(box, COLOR.RED, 5);

See Also: DrawDebugLine, GetEntWorldAABB


DrawDebugLine

Draws a line in the environment. Useful for debugging.

Parameters: (Vector3 start, Vector3 end, color, duration)

Returns: none

Example:

 start = Vector3(0,0,0);
 end = Vector3(20,20,20);
 // draw it in red for 5 seconds
 DrawDebugLine(start, end, COLOR.RED, 5);

See Also: DrawDebugAABB, GetEntWorldAABB


DrawEntityAABB

Draws a bounding box around an entity. The box is usually much bigger than the entity.

Parameters: (entity, duration, color)

Returns: true/false


DrawEntityOBB

Draws an oriented box around an entity.

Parameters: (entity, duration, color)

Returns: true/false


DrawLine

See: DrawDebugLine


DrawRadius

Draws radius.

Parameters: (position, radius, color, duration)

Returns: none


DrawText3d

Draws text.

Parameters: (position, string, color, duration, maxDistanceFromPlayer[optional, default 1024])

Returns: none


DrawTrajectory

Draws trajectory of grenade, mortar, airstrike or smokebomb.

Parameters: ( {Position, Velocity, Interval, Duration, BounceLoss, GravityMultiplier, StopAtHit, TraceBounce }, color, duration)

Returns: target position


DumpConsoleToFile

Saves debug console, only if debug window is enabled.

Parameters: (file name)

Returns: none


EchoToScreen

Prints a message to the screen.

Parameters: (duration, message)

Returns: none

Example:

 EchoToScreen(5,"Hello World!");

EnableDebugWindow

Enables or disables debug window. Does not work in release build of omnibot dynamic link library. You must use omnibot_et.dll from dw_enabled subfolder on Assembla.

Parameters: (true/false, width[optional, default 1024], height[optional, default 768], bitsPerPixel[optional, default 32])

Returns: none


Error

Prints an error to the games output console.

Parameters: (error message)

Returns: none

Example:

 Error("Somethin bad happened");

Log

Writes a string to the omnibot log file.

The second parameter: 0=info, 1=warning, 2=error, 3=critical

Note: logs are disabled if cvar omnibot_logsize is zero or negative

Note: logs can also be disabled in omni-bot.cfg

Parameters: (string, level[optinal, default 0])

Returns: none

Example:

 Log("Something cool happened");
 Log("Something bad happened", 2);

ShowPaths

Debug Information function. Prints Omni-bot version, revision, and revision date, along with file system paths.

Parameters: none

Returns: none

Example:

 ShowPaths();

TransformAndDrawLineList

Parameters: (veclist, color, duration, position, euler)

Returns: none

Example:

 TransformAndDrawLineList({Vec3(20,80,0), Vec3(20,-60,0), Vec3(-90,70,30), Vec3(-90,-50,30)}, 
  COLOR.RED, 5, GetLocalPosition(), Vec3(DegToRad(45),0,0));

DeleteTriggerRegion

Deletes a trigger region previously created with OnTriggerRegion. Because regions aren't required to have unique names, DeleteTriggerRegion will delete all regions that match the provided name. This allows grouping of different trigger regions by shared names.

Parameters: (name)

Parameters: (serial #)

Returns: none

Example:

 // creates a sphere trigger 256 units in radius around 0,0,0, then delete it immediately.
 triggerInfo =
 {
 	Name="TestTrigger",
 	TriggerOnClass=CLASS.ANYPLAYER,
 	OnEnter = function(ent)
 	{
 		print(GetEntName(ent),"entered aabb trigger");
 	},
 	OnExit = function(ent)
 	{
 		print(GetEntName(ent),"exited aabb trigger");
 	},
 };
 serial = OnTriggerRegion(Vector3(0,0,0),256,triggerInfo);

 DeleteTriggerRegion(serial);
 // OR
 DeleteTriggerRegion("TestTrigger");

See Also: OnTriggerRegion


DistanceBetween

Utility function for checking distances between 2 objects. This function takes 2 parameters, but the parameter types can vary.

Parameters: (object1, object2)

For this function, each parameter can be one of the following types.

  • Vector3
  • GameEntity
  • GameId
  • MapGoal

This provides a flexible and fast function that allows a script to check the distance between a variety of source and destination object, and reduces the need for the script to convert between GameEntity or GameId, or to get the position of the GameEntity itself.

Returns: distance between the objects

Example:

 // assume entity1 is a GameEntity from another source, such as GetAllType
 if(DistanceBetween(b.GetGameEntity(), entity1))
 {
 }
 // OR
 if(DistanceBetween(b.GetGameEntity(), Vector3(10,20,30))
 {
 }

DynamicPathsUpdated

Finds new path for bots in teams specified if paths go through waypoint which has dynamic flag.

Parameters: (teamId, ...)

Returns: none



Entity Functions

EntityIsOutside

Checks if a given entity is outside. Added in 0.83

Parameters: (entity)

Returns: true/false


EntityIsValid

Checks if a given entity is valid.

Parameters: (entity)

Returns: true/false


EntityKill

Kills an entity. Requires cheats to be enabled.

Parameters: (GameEntity/GameId)

Returns: true if successful, false if not

Example:

 EntityKill(GetEntityByName("truck"));

See Also: CheatsEnabled


GetEntBonePosition

Gets the world position of a specific bone on an entity.

Note: This function may not be implemented for all games. It's not implemented in ET.

Parameters: (GameEntity/GameId, BoneId)

Returns: Vector3 world bone position, or null if bone not found

Example:

 headpos = GetEntBonePosition(someent, BONE.HEAD);
 if(headpos)
 {
     // got head position
 }

GetEntCategory

Checks if the entity belongs to one or more entity categories. This function takes one or more categories, and returns true if the entity belongs to all the provided categories.

Parameters: (GameEntity/GameId, Category, ...)

Returns: true if the entity belongs to all provided categories.

Example:

 if(GetEntCategory(someent, CAT.PROJECTILE))
 {
 } 
 if(GetEntCategory(someent, CAT.PLAYER, CAT.VEHICLE))
 {
 }

See also: CAT


GetEntClass

Gets the class of the entity.

Parameters: (GameEntity/GameId)

Returns: class of entity, or null if there was an error

Example:

 if(GetEntClass(someent) == CLASS.SOLDIER)
 {
 }


See also: CLASS


GetEntEquippedWeapon

Gets current weapon of a player.

Parameters: (GameEntity/GameId)

Returns: weaponId

Example:

 weapon = GetEntEquippedWeapon(this.TargetEntity);

GetEntEyePosition

Gets the world eye position of an entity.

Note: position is not correct if bot is looking up or down

Parameters: (GameEntity/GameId)

Returns: Vector3 eye position, or null if there was an error

Example:

 eyepos = GetEntEyePosition(someent);
 if(eyepos)
 {
     // got eye position
 }

GetEntFacing

Gets the world facing vector of an entity

Parameters: (GameEntity/GameId)

Returns: Vector3 facing, or null if there was an error

Example:

 face = GetEntFacing(someent);
 if(face)
 {
     // got face vector, as a direction vector
 }

GetEntFlags

Checks if the entity has one or more entity flags.

Parameters: (GameEntity/GameId, Entity Flag, ...)

Returns: true if the entity has any of provided entity flags.

Example:

 if(GetEntFlags(someent, ENTFLAG.CROUCHED))
 {
 } 
 if(GetEntFlags(someent, ENTFLAG.CROUCHED, ENTFLAG.RELOADING))
 {
 }

See also: ENTFLAG


GetEntHealthAndArmor

Gets health and armor of an entity.

Parameters: (GameEntity/GameId, table)

Returns: true if successful, false if not

Properties stored into table:

  • Health - Current Health
  • MaxHealth - Max Health
  • Armor - Current Armor
  • MaxArmor - Max Armor

Example:

healthArmor = {};
if(GetEntHealthAndArmor(someentity, healthArmor))
{
	if(healthArmor.Health < 20)
	{
		b.Say("I'm Hurt!");
	}
}

See also: Util.GetEntHealth


GetEntName

See: GetEntityName


GetEntOwner

Gets the owner of an entity. Typically used for entities that can be held or carried.

Note: If player who is carrying objective is kicked, GetEntOwner will return invalid entity till end of match. This bug is in all ET mods (except the last version of omnibot mod).

Parameters: (GameEntity/GameId)

Returns: GameId of owner, or null if none or error

Example:

 owner = GetEntOwner(someent);

GetEntPosition

Gets the world position of an entity.

Note: old mods return wrong position (NoQuarter 1.2.5, ETpub 0.9.0, Jaymod 2.1.7, ...).

Parameters: (GameEntity/GameId)

Returns: Vector3 world position, or null if error

Example:

 p = GetEntPosition(someent);

GetEntPowerups

Checks if the entity has one or more powerups. This function takes one or more powerups, and returns true if the entity has all of them.

Parameters: (GameEntity/GameId, PowerUp, ...)

Returns: true if the entity has all powerups.

Example:

 if(GetEntPowerups(someent, POWERUP.INVINCIBLE))
 {
 } 
 if(GetEntPowerups(someent, POWERUP.QUADDAMAGE, POWERUP.BERSERK))
 {
 }

GetEntRotationMatrix

Gets the Matrix3 full transform of an entity.

Parameters: (GameEntity/GameId, Matrix3<optional>)

If you pass an Matrix3 as the 2nd parameter, that object will be filled in instead of a new Matrix3 returned. This can save memory allocations in a script that calls the function often by re-using the same object.

Returns: true if Matrix3 passed as 2nd parameter and filled in successfully, if no Matrix3 provided, returns Matrix3 for entity. Both return null on an error.

Example:

 entMat = GetEntRotationMatrix(someent);
 if(entMat)
 {
      // do something
 }
 // re-use the same Matrix3 later
 if(GetEntRotationMatrix(someent, entMat))
 {
 }

GetEntTeam

Gets the team id that the entity belongs to.

Parameters: (GameEntity/GameId)

Returns: Team Id of entity, or null if error

Example:

 if(GetEntTeam(someent) == TEAM.RED)
 {
 }

See also: TEAM


GetEntVelocity

Gets the world velocity of an entity.

Parameters: (GameEntity/GameId)

Returns: Vector3 world velocity, or null if error

Example:

 vel = GetEntVelocity(someent);

GetEntWorldAABB

Gets the bounding box for an entity. The box is usually much bigger than the entity. Center of the box is not equal to entity position.

Parameters: (GameEntity/GameId, AABB<optional>)

If you pass an AABB as the 2nd parameter, that object will be filled in instead of a new AABB returned. This can save memory allocations in a script that calls the function often by re-using the same object.

Returns: true if AABB passed as 2nd parameter and filled in successfully, if no AABB provided, returns AABB for entity. Both return null on an error.

Example:

 entAABB = GetEntWorldAABB(someent);
 if(entAABB)
 {
      // do something
 }
 // re-use the same AABB later
 if(GetEntWorldAABB(someent, entAABB))
 {
 }

GetEntityByName

Finds entity by target name. In ET you can use command /entitylist to see entity names.

Unfortunately this functions can't find entities which have only script name, but don't have target name.

Parameters: (name)

Returns: GameEntity found, or null if none found


GetEntityInSphere

Finds an entity within a radius around a point that matches a particular class Id. It is set up so that it can be used in a loop to find all entities.

Parameters: (Vector3 position, radius, classid, start entity)

Returns: GameEntity found, or null if none found

Example:

 p = Vector3(10,10,10);
 radius = 20;
 ent = GetEntityInSphere(p, radius, CLASS.ANYPLAYER, null);
 while(ent)
 {
     // do something with it?
     // get the next one found
     ent = GetEntityInSphere(p, radius, CLASS.ANYPLAYER, ent);
 }

GetEntityLocalSpace

Converts a world position into a local space position of a specified entity.

Parameters: (GameEntity/GameId, Vector3 world position)

Returns: Vector3 local space position, or null if error

Example:

 worldpos = Vector3(10,10,10);
 localpos = GetEntityLocalSpace(someent, worldpos);

See Also: GetEntityWorldSpace


GetEntityName

Gets the name of an entity. In ET you can use command /entitylist to see all entity names.

If entity has defined both script name and target name, GetEntityName returns script name.

Parameters: (GameEntity/GameId)

Returns: name of entity, or null if error

Example:

 entName = GetEntityName(someent);
 if(entName == "SomeName")
 {
      // do something
 }

GetEntityStat

Generic function for getting information about an entity, by name.

Parameters: (GameEntity/GameId, stat name)

Returns: stat, or null if error or stat doesn't exist. The type depends on the stat.

Example:

 kills = GetEntityStat(someent, "kills");
 deaths = GetEntityStat(someent, "deaths");
 xp = GetEntityStat(bot.GetGameEntity(), "xp");

GetEntityWorldSpace

Converts a local space position into a world space position of a specified entity.

Parameters: (GameEntity/GameId, Vector3 local position)

Returns: Vector3 world space position, or null if error

Example:

 localpos = Vector3(10,10,10);
 worldpos = GetEntityWorldSpace(someent, localpos);

See Also: GetEntityLocalSpace


GetGameEntityFromId

Converts a GameId to a GameEntity.

Parameters: (GameId)

Returns: GameEntity

Example:

 ent = GetGameEntityFromId(2);

See Also: GetGameIdFromEntity


GetGameIdFromEntity

Converts a GameEntity to a GameId.

Parameters: (GameEntity)

Returns: GameId

Example:

 id = GetGameIdFromEntity(someent);

See Also: GetGameEntityFromId


ExecCommand

This function executes a bot command as if it came from the games input console.

Parameters: (command string)

Returns: none

Example:

 ExecCommand("addbot 1 2")

ExecCommandOnClient

Executes a command for the entity. Usually equivilent to console commands.

Parameters: (GameEntity/GameId, command string)

Returns: none

Example:

 ExecCommandOnClient(bot.GetGameEntity(), "setviewpos 1200 2300 150 0");

ExecScript

Attempts to execute a script file. File is searched in scripts folder, global_scripts folder or game folder (omni-bot/et).

Parameters: (filename)

Returns: true if successful, false if not

Example:

 ExecScript("myscript.gm");

GetClassNameFromId

Gets the current class name from a class id.

Parameters: (classId)

Returns: string


GetGameName

Gets the name of the currently running game.

Parameters: none

Returns: name of game

Example:

 if(GetGameName() == "Enemy Territory")
 {
 }
 else if(GetGameName() == "Quake 4")
 {
 }

GetGameState

Gets the current state of the game (Playing, Warm-up, Warm-up Countdown, Intermission, Waiting for Players, Paused, Invalid).

Parameters: none

Returns: name of game state

Example:

 if(GetGameState() == "Playing")
 {
 }

GetGameTimeLeft

Gets the current amount of time remaining in the game round.

Parameters: none

Returns: time left, in seconds

Example:

 if(GetGameTimeLeft() < 30)
 {
 }

GetGoal

Gets a reference to a map goal by name. The goal name is case sensitive.

Parameters: (name of map goal to get)

Returns: MapGoal if found, null if not

Example:

 mg = GetGoal("MAP_FLAG_redflag");

See Also: MapGoal


GetGoals

Gets any number of map goals that match a regular expression. Stores the matching reference in the first table parameter. The previous table content is cleared since omni-bot 0.84. It's not possible to call GetGoals multiple times to accumulate results. The last optional parameter is table of parameters to filter result (Group, Role, SkipNoInProgress, SkipNoInUse, SkipInUse) or sort result (parameter Sort, values are "none", "priority", "name", "priority_name", "random").

Parameters: (table, team, expression, params[optional])

Returns: none

Example:

 goals = {};
 GetGoals(goals, TEAM.AXIS, "FLAG.*", { Sort="priority" });

See Also: Util.GoalTable, GetGoal


GetGravity

Gets the current gravity of the game.

Parameters: none

Returns: gravity

Example:

 grav = GetGravity();

GetLocalAABB

Gets bounding box of local player.

Parameters: none

Returns: AABB


GetLocalAimNormal

Gets normal at aim position of local player.

Parameters: (collision mask[optional, default floodfill])

Returns: Vector3


GetLocalAimPosition

Gets aim position of local player.

Parameters: (collision mask[optional, default floodfill])

Returns: Vector3


GetLocalEntity

Gets local player.

Parameters: none

Returns: GameEntity


GetLocalEyePosition

Gets eye position of local player.

Parameters: none

Returns: Vector3


GetLocalCommand

Gets name of just running console command. It is useful if you use same script for multiple commands.

Parameters: none

Returns: string or null


GetLocalFacing

Gets facing vector of local player.

Parameters: none

Returns: Vector3


GetLocalGroundPosition

Gets ground position of local player.

Parameters: none

Returns: Vector3 or null


GetLocalPosition

Gets position of local player.

Parameters: none

Returns: Vector3


GetMapExtents

Gets the AABB map extents. Map extends are the bounds of the entire map.

Parameters: (AABB<optional>)

Returns: If no AABB passed as parameter, function will return the map AABB, otherwise the AABB parameter will be filled in with the results, and the function will return nothing.

Example:

 aabb = GetMapExtents();
 // or
 AABB aabb;
 GetMapExtents(aabb);

GetMapName

Get the name of the current map.

Parameters: none

Returns: name of map

Example:

 if(GetMapName() == "oasis")
 {
 }

GetModName

Gets the name of the currently running mod.

Parameters: none

Returns: name of mod

Example:

 if(GetModName() == "etpub")
 {
 }

GetModVersion

Gets the version of the current mod.

Parameters: none

Returns: version of mod

Example:

 if(GetModVersion() == "DOOM 1.3")
 {
 }

GetNearestNonSolid

This function is similar to TraceLine, but ignores solids.

Parameters: (start, end, trace mask[optional])

Returns: position


GetPointContents

Gets the contents bits for a given position.

Parameters: (Vector3 position)

Returns: contents bits. Use bitwise manipulators along with constants from the global CONTENT table to check for specific content bits.

Example:

 contents = GetPointContents(Vector3(10,10,10));
 if(contents & CONTENT.WATER)
 {
 }

GetTeamStat

Generic function for getting information about a team, by name. It's not implemented in ET.

Parameters: (Team Id, stat name)

Returns: stat, or null if error or stat doesn't exist. The type depends on the stat.

Example:

 score = GetTeamStat(TEAM.RED, "score");

GetTime

Gets the current time elapsed in the game.

Parameters: none

Returns: time, in seconds

Example:

 if(GetTime() > 30)
 {
 }

GetWeapon

Gets weapon object by ID.

Parameters: (weaponId)

Returns: Weapon


GetWeaponIdFromClassId

Converts classId to weaponId.

Parameters: (classId)

Returns: weaponId


GroundPoint

Returns a point on the ground directly below the provided point.

Parameters: (position)

Returns: ground position


KickAll

Kicks all bots from the game.

Parameters: none

Returns: none

Example:

 KickAll();

KickBot

Kicks a bot by name.

Parameters: (name)

Returns: none

Example:

 KickBot("Fred");

KickBotFromTeam

Kicks last bot from team.

Parameters: (teamId)

Returns: none

Example:

 KickBot(TEAM.AXIS);

MoveBotToAnotherTeam

Moves a bot from a team to another team.

Parameters: (source teamId, destination teamId)

Returns: none


OnTrigger

Registers a script function callback for a given trigger string.

Parameters: (trigger string, script function)

Returns: none

Example:

 global Map =
 {
  myfunc = function(trigger)
  {
    direction = ToVector(trigger.Action);
    entityName = GetEntName(trigger.Entity);
  }
 };
 global OnMapLoad = function()
 { 
  OnTrigger( "cargo_lift_goto", Map.myfunc);
 };

See Also: Triggers


OnTriggerRegion

Creates one of several types of trigger regions. A trigger region is an area that watches for entities of certain types to touch them and calls script callback functions for enter and exit. Useful if you want an easy way to be notified when certain entities go to certain areas of the map.

This function takes a table as the last parameter to define a number of flexible options for the trigger region. Here is a list of available key/value options for the table.

  • Name - Optional name to give the region. Does not need to be unique.
  • OnEnter - script function to call when an entity touches the region.
  • OnExit - script function to call when an entity stops touching the region.
  • TriggerOnClass - Define the class id you want the region to trigger on. This field may also be an indexed table with up to 8 class ids.
  • TriggerOnCategory - Category of entities to watch for. This field may also be an indexed table with as many categories as you want to limit the trigger to.
  • TriggerOnEntity - A specific entity to trigger on. This field may also be an indexed table with up to 8 entities you want to limit the trigger to.

The following region types are supported. The type is dependent on which parameters of the function are used.

  • AABB - Axis aligned bounding box.
  • Sphere - A radius around a position.

Triggers may be rendered for reference with /bot drawtriggers 1

Parameters: (AABB, table)

Parameters: (position, radius, table)

Returns: unique serial number of region

Example:

 // creates a sphere trigger 256 units in radius around 0,0,0
 triggerInfo =
 {
 	Name="TestTrigger",
 	TriggerOnClass=CLASS.ANYPLAYER,
 	OnEnter = function(ent)
 	{
 		print(GetEntName(ent),"entered aabb trigger");
 	},
 	OnExit = function(ent)
 	{
 		print(GetEntName(ent),"exited aabb trigger");
 	},
 };
 serial = OnTriggerRegion(Vector3(0,0,0),256,triggerInfo);

See Also: DeleteTriggerRegion


RegisterDefaultProfile

Registers a default profile that will be loaded for any bot that joins a specified class.

Parameters: (Class Id, script name)

Returns: none

Example:

 RegisterDefaultProfile(CLASS.SOLDIER, "def_bot.gm");

ReloadGoalScripts

Executes all goal scripts. You must also kick all bots because any changes will be applied to newly added bots.

Parameters: none

Returns: none


RunScript

See: ExecScript


SendTrigger

It is used by goal scripts to call function in map script. Parameter TagName is string which must be same as the first parameter of function OnTrigger.

Parameters: ( { TagName, Entity, Activator, Action } )

Returns: none

Example:

SendTrigger({
 Entity = ent,
 Activator = null,
 TagName = GetEntName(ent) + " at location",
 Action = "arrived"
});

ServerCommand

Executes a server command. Requires cheats to be enabled.

Parameters: none

Returns: true if cheats are enabled, false if not

Example:

 ServerCommand("map oasis");

See Also: CheatsEnabled


ServerScriptFunction

Not implemented in ET.

Parameters: (entity name, function name, parameters[optinal])

Returns: none


SetAvailableMapGoals

Enables/Disables the available status of one or more map goals that match a regular expression, for a specific team.

Parameters: (Team Id, enable/disable, mapgoal expression string)

Parameters: (Team Id, enable/disable, table of mapgoal expressions) (added in 0.84)

Returns: number of goals that match regular expression

Example:

 SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK.*" );
 SetAvailableMapGoals( TEAM.AXIS, true, { "DEFEND_gate.*", "MOUNTMG42_bunker", "SNIPE_tower.*" } );


See Also: Availability, GetGoal, GetGoals


SetGoalGroup

Sets the goal or table of goals group name.

Parameters: (goalname or table, groupname)

Returns: none

Example:

 SetGoalGroup( "SomeGoalName", "SomeGroupName" );
 SetGoalGroup( { "ROUTE_route1", "ROUTE_route2", "someothergoal" }, "MyGroup" );

See Also: Util.DisableGroup, Util.EnableGroup, Util.GetGroup, Util.SetGroup, Util.ShowGroup


SetGoalPriority

Sets priority of one or more MapGoals for specified team and class. The last parameter must be true for dynamically created goals (FLAG_dropped, FLAGRETURN, DEFUSE ...).

Parameters: (expression or table, priority, teamId[optional, default 0], classId[optional, default 0], persistent[optional])

Returns: none

Example:

 example: SetGoalPriority( "FLAG_Gold", 0.7 ); //all teams and all classes
 example: SetGoalPriority( "CHECKPOINT_City", 0.8, TEAM.AXIS); //axis only all classes
 example: SetGoalPriority( "DEFUSE_somedyno.*", 0.0, TEAM.AXIS, CLASS.ENGINEER, true ); //the persistent parameter is used for dynamic goals that may not have been created yet

See Also: Priority


SetGoalRole

Sets one or more roles of one or more MapGoals. The last parameter must be true for dynamically created goals (FLAG_dropped, FLAGRETURN, DEFUSE ...).

Parameters: (expression or table, role or table, persistent[optional])

Returns: none

Example:

 example: SetGoalRole( "FLAG_Gold", ROLE.ATTACKER ); //1 goal, 1 role
 example: SetGoalRole( "DEFEND_City[4567]", { ROLE.DEFENDER2, ROLE.DEFENDER3}); //4 goals, 2 roles
 example: SetGoalRole( "DEFUSE_somedyno.*", ROLE.DEFENDER2, true ); //the persistent parameter is used for dynamic goals that may not have been created yet

See Also: Roles


SetMapGoalProperties

Passes a table full of properties along to all matching map goals to attempt to set their properties.

Parameters: (expression or table, table of properties)

Returns: none

Example:

 // Set the camp time for all attack and defend goals
 SetMapGoalProperties( "ATTACK_.*", {mincamptime=15, maxcamptime=30});
 SetMapGoalProperties( "DEFEND_.*", {mincamptime=15, maxcamptime=30});

See Also: Goal specific instructions for a list of properties for each map goal type.


TraceLine

Performs a traceline collision test, and returns the results in a table. TraceLine calls are useful for testing visibility, line of sight, or for getting a collision point along a line.

Parameters: (Vector3 start, Vector3 end, AABB, collision mask, ignore user GameId, use PVS)

  • Vector3 start - Start position of trace line.
  • Vector3 end - End position of trace line.
  • AABB - Pass an AABB if you with the line to have volume, otherwise pass null.
  • Collision Mask - Mask of collision types to test. See global TRACE table.
  • GameId - Ignore this GameId in the traceline. Usually the entity or bot it originates from.
  • UsePVS - true to use PVS (Potentially visible set), false to ignore PVS

Always pass false to not UsePVS if you need collision information from the call to TraceLine. UsePVS=true is useful when all you need to know is whether or not something is blocking the path from start to end, it will not give you the collision position. It is slightly faster in most cases to use PVS as an early out test, but doing so limits the amount of useful information you get back from the function. In many cases you don't need this information, so the extra speed is useful.

Returns: table of results

Results table contains the following information.

  • fraction - 0.0 to 1.0 The ratio along the line the collision took place. Not always valid if UsePVS=true. Example: 0.5 means ray hit half way between the start and end.
  • startsolid - true/false The traceline started inside a solid object. Not always valid if UsePVS=true

Additional properties are available if UsePVS=false and there was a collision.

  • entity - May be null, the GameEntity that was hit in the collision.
  • normal - The Vector3 normal of the collision point.
  • end - The Vector3 world position of the collision.
  • contents - water etc., see global CONTENT table.
  • surface - ice, ladder, see global SURFACE table.

Example:

 // Do a traceline along a bots facing 1024 units out
 start = b.GetEyePosition();
 end = start + b.GetFacing() * 1024;
 tr = TraceLine(start, end, null, TRACE.SHOT, b.GetGameId(), false);

 // the fraction value tells us of a collision or not. If it's 1, there was no collision. If less than 1 there was a collision.
 if(tr.fraction < 1)
 {
     // tr.startsolid
     // tr.entity
     // tr.normal
     // tr.end
     // tr.contents
     // tr.surface
 }

Enemy Territory Addendum

GetCabinetData

Gets information about health or ammo cabinet. Properties CurrentAmount, MaxAmount, Rate are stored into table.

Parameters: (entity, table)

Returns: true if successful, null if not

Example:

cab = {};
if (GetCabinetData( GetGoal("AMMOCAB_north").GetEntity(), cab)){
	print( cab.CurrentAmount );
}

GetCvar

Gets a game cvar. Returns zero if the cvar does not exists or if its value cannot be converted to integer.

Parameters: (name)

Returns: integer

Example:

friendlyFire = GetCvar("g_friendlyfire");

GetGameType

Gets the current game type:

2 - single-map objective, 3 - stopwatch, 4 - campaign, 5 - last man standing

Parameters: none

Returns: integer


IsWaitingForMedic

Deprecated.


SetCvar

Sets a game cvar.

Parameters: (name, value)

Returns: true if successful, false if not