Making DOOM 3 Mods : AI Scripts

The AI scripts are a couple of orders of magnitude more complex than the map or weapon scripts. I honestly wouldn't even try touching them unless you know C++ really well.

Bernie probably has the most simple ai script (he just walks towards you tries to smack you), but even that is more complex than most of the weapon scripts.

I will put more documentation here later.

Handy AI Functions
findEnemy [useFOV]Returns the first living enemy the actor can see. If useFOV is true then it only returns enemies in the actors field of view. Returns null if the actor is outside the player PVS.
findEnemyAI [useFOV]Returns the nearest living enemy the actor can see (rather than the first enemy, which may not be the closest). Otherwise behaves like findEnemy.
findEnemyInCombatNodesReturns the first living enemy visible to the combat nodes this actor is targeting.
closestReachableEnemyOfEntity [entity]Returns the living enemy closest to a specified entity. The sentry uses this to attack actors close to the player.
heardSound [ignore_team]If an alert sound was created in the area of the actor, this function returns the sound. Otherwise it returns null. ignore_team will cause it to skip sounds made by team members.
setEnemy [entity]Sets the enemy if this actor to entity.
clearEnemySets this actor to not have an enemy.
muzzleFlash [jointname]Trigger a muzzle flash on the joint named jointname
createMissile [jointname]Creates a projectile (specified by "def_projectile" in the actor entityDef) bound to the joint named jointname, then returns the projectile.
attackMissile [jointname]Launches a projectile at the enemy from the joint named jointname. Returns the projectile entity.
fireMissileAtTarget [jointname],
[targetname]
Launches a projectile at the specified target entity. Otherwise behaves like attackMissile.
launchMissile [origin], [angles]Launches a projectile from the specified origin and angles. Returns the projectile.
attackMelee [meleeDef]Performs a melee attack using the specified melee damageDef (see melee_commandoTentacle in actor_zombie_commando.def for an example definition). Returns true if it hit something.
directDamage [target], [damageDef]Perform direct damage to a target entity, using the damageDef specified by damageDef.
radiusDamageFromJoint [jointname],
[damageDef]
Perform radius damage using the specified damageDef. The center of the radius is attached to the joint specified by jointname.
attackBegin [damageDef]Starts an attack, if the actor touches anything during the attack, he will deal direct damage to the object using the specified damageDef.
attackEndEnds an attack.
meleeAttackToJoint [jointname],
[damageDef]
Deal direct damage using the specified damageDef to any entities between the eye position and the specified joint. This is used by the commando to damage anything that touches the tentacle.
randomPathRandom returns one of the path entity targeted by this actor.
canBecomeSolidReturns true if there is nothing intersecting this actors collision geometry.
becomeSolidMakes the actor solid. Enables and links the actor clip model and allows the actor to take damage (assuming "noDamage" is not set).
becomeRagdollTurns the actor into a ragdoll. Used to make Ed (the scientist with the lamp) 'die' at the end.
stopRagdollDisables the ragdoll and returns control to the animator. Used for monsters that are resurrected by the Archvile.
setHealth [health]Sets the health for the actor. Used for resurecting things, and also for the scientist in MC Underground who turns into a zombie.
getHealthReturns the health of the actor.
allowDamageEnables the actor to take damage.
ignoreDamageMakes the actor not take damage.
getCurrentYawReturns the current yaw angle (heading, facing direction) of the actor.
turnTo [angle]Sets the ideal yaw for the actor (does not actually set the yaw, the actor will turn over a few frames).
turnToPos [position]Sets the ideal yaw for the actor so he is facing the specified position.
turnToEntity [entity]Sets the ideal yaw for the actor so he is facing the specified entity.
moveStatusReturns the current move status of the actor, which is one of the following:
MOVE_STATUS_DONE, MOVE_STATUS_MOVING, MOVE_STATUS_WAITING, MOVE_STATUS_DEST_NOT_FOUND, MOVE_STATUS_DEST_UNREACHABLE, MOVE_STATUS_BLOCKED_BY_WALL, MOVE_STATUS_BLOCKED_BY_OBJECT, MOVE_STATUS_BLOCKED_BY_ENEMY, MOVE_STATUS_BLOCKED_BY_MONSTER
stopMoveSets the move status to MOVE_STATUS_DONE.
moveToCoverTell the actor to try to move to an area that the enemy can't see.
moveToEnemyTell the actor to try to move towards the enemy, or the last known enemy position.
moveToEnemyHeightMove to be the same height as the enemy (used for the guardian seekers).
moveOutOfRange [entity], [range]Tell the actor to move away from the specified entity by at least range units.
moveToAttackPosition [entity],
[animation]
Tell the actor to move to some position where it can attack entity using the specified animation. Used by the setry because he has to get into his 'attack pose' before he can start firing.
wanderTell the actor to just randomly wander around with no particular direction.
moveToEntity [entity]Tell the actor to get as close as possible to entity (within 8 units).
moveToPosition [pos]Tell the actor to move as close as possible to the specified position (within 8 units).
slideTo [pos], [time]Slide the actor over to the position over time seconds. Used to make sure actors are in the exact spot before triggering something. time is normally pretty small (0.25), but it doesn't have to be.
facingIdealReturns true if the actor is facing his ideal yaw angle (as set by turnTo or a similar function).
faceEnemyTell the actor to continually turn towards the last known enemy position.
faceEntity [entity]Tell the actor to continually turn towards the specified entity.
getCombatNodeReturns a combat node that is closer to the enemy than the current actor position.
enemyInCombatCone [combatCone],
[useCurrentEnemyPosition]
Returns true if the enemy is in the specified combat cone. If useCurrentPosition is true then it will use the actual enemy position, otherwise it will use the last known position.
waitMoveDoesn't return until the current move is finished. Not used in Doom 3.
getJumpVelocity [pos], [speed], [maxHeight]Returns a velocity vector that will cause the actor to land at the position. Returns a zero vector if the jump is impossible. jumpHeight is the maximum height the jump is allowed to get.
entityInAttackCone [entity]Returns true if the entity is our attack cone.
canSee [entity]Returns true if the entity is in our field of view and not behind a wall.
setTalkTarget [entity]Sets the talk target to the specified entity and sets AI_TALK to true (if entity is null then it sets AI_TALK to false).
getTalkTargetReturns the current talk target.
setTalkState [state]Talk state is one of:
TALK_NEVER, TALK_DEAD, TALK_OK, TALK_BUSY
enemyRangeReturns the distance to the enemy.
enemyRange2DReturns the distance to the enemy in 2d (ignoring Z).
getEnemyReturns the current enemy entity.
getEnemyPosReturns the last known position of the current enemy.
getEnemyEyePosReturns the last known position of the eye of the current enemy.
predictEnemyPos [time]Return the predicted position of the current enemy time seconds from now.
canHitEnemyReturns true if there is nothing in between the actor and his enemy (or the actor and someone else on the enemy team).
canHitEnemyFromAnim [animation]Returns true if a projectile launched using the specified animation would hit the enemy.
canHitEnemyFromJoint [jointname]Returns true if a projectile launched from the specified joint would hit the enemy.
enemyPositionValidReturns false if the actor knows for a fact the enemy is not at the last known position.
chargeAttack [damageDef]Calls attackBegin(damageDef) then moves directly towards the enemy position.
testChargeAttackReturns the time it would take to hit the enemy if the actor ran straight towards it. Returns 0 if there is something in the way.
testMoveToPosition [position]Returns true if there is nothing between the actor and the position.
testAnimMoveTowardEnemy [animation]Returns true if the actor can hit the enemy while running the specified animation without anything getting in the way.
testAnimMove [animation]Returns true if the actor can perform the animation without something getting in the way.
testMeleeAttackReturns true if a melee attack would hit the enemy.
testAnimAttack [animation]Returns true if performing the specified animation would hit the player.
shrivel [time]Modifies shaderparm 8 from 1.0 to 0.5 over time (will return after multiple frames). Not used in Doom 3.
burnCause the actor to burn and fizzle away.
clearBurnReset the actor burn time (so the actor is no longer burned).
preBurnTurn shadows off.
setSmokeVisibility [smokeSystem], [state]Turn the specified smoke particle system on or off (by setting state to true or false).
numSmokeEmittersReturns the number of smoke emitters on the actor.
waitAction [action]Doesn't return until the specified action finishes. In this context action is generally an animation name.
stopThinkingCauses the thread to end and the actor to go dormant.
getTurnDeltaReturns the angle in degrees between the current yaw and the ideal yaw.
getMoveTypeGets the current move type. Move type is one of:
MOVETYPE_DEAD, MOVETYPE_ANIM, MOVETYPE_SLIDE, MOVETYPE_FLY, MOVETYPE_STATIC
setMoveTypeSets the current move type.
saveMoveSave the current move to an internal variable.
restoreMoveRestore a previously saved move.
allowMovement [flag]Pass true to let the actor move around.
enableClipEnable the actor collision geometry.
disableClip"Disable the actor collision geometry.
enableGravity"Make the actor obey the laws of physics.
disableGravity"Make the actor float around like gravity didn't exist.
enableAFPush"Set "af_push_moveables" to true.
disableAFPush"Set "af_push_moveables" to false.
setFlySpeed [speed]Set "fly_speed".
setFlyOffset [offset]Set "fly_offset".
clearFlyOffsetReset "fly_offset" to whatever it was in the spawn agrs.
getClosestHiddenTarget [type]Returns the closest entity of the specified type that the player cannot see. Used to find lost combat nodes that the player can't see.
getRandomTarget [type]Randomly returns a target of the specified type.
travelDistanceToPoint [pos]Returns the actual travel distance to the specified position (SLOW).
travelDistanceToEntity [entity]Returns the actual travel distance to the specified entity (SLOW).
travelDistanceBetweenPoints [pointa], [pointb]Returns the actual travel distance from point a to point b (SLOW).
travelDistanceBetweenEntities [ent1], [ent2]Returns the actual travel distance from entity 1 to entity 2 (SLOW).
lookAt [entity], [duration]Aim an actors head and eyes at an entity for some amount of time.
lookAtEnemy [duration]Aim an actors head and eyes at his enemy for some amount of time.
setBoneMod [flag]Enables or disables head looking.
killKills the actor.
wakeOnFlashlight [flag]Pass true to have the actor activate when the flashlight shines on it.
locateEnemyUpdate the last known enemy position.
kickObstacles [entity], [force]Apply some kick force to objects in front of the actor, focusing extra attention on entity (which can be null).
getObstacleReturns the entity that's blocking the actors movement (likely candidate to be kicked).
pushPointIntoAAS [pos]Tries to push the position into a valid AAS area. Returns the new position.
getTurnRateReturns "turn_rate"
setTurnRate [rate]Sets "turn_rate"
animTurn [maxAngle]Enable or disable animation controlled turning. Pass in the maximum degrees the animation turns, or 0 to disable.
allowHiddenMovement [flag]Pass true to run physics even when the actor is hidden.
findActorsInBounds [mins], [maxs]Returns an actor inside the specified bounds.
canReachPosition [pos]Returns true if it is possible for the actor to move to the specified position.
canReachEntity [entity]Returns true if it is possible for the actor to move to the specified entity.
canReachEnemyReturns true if it is possible for the actor to move to his enemy.
getReachableEntityPosition [entity]Return the position of the entity within the AAS if possible or just the position otherwise.

Copyright © 2004 id software