AI functions
Functions for working with NPCs AI queue. Every function is added to the AI queue of the specified NPC and executed in the order they were added.
Functions
AI_AimAt
AI_AimAt
Aims at the target with a ranged weapon (have to be drawn first)
Parameters
var C_NPC attacker
- instance of the attackervar C_NPC target
- C_NPC instance of the target
AI_AlignToFP
AI_AlignToFP
Aligns the NPC to the Freepoint
Parameters
var C_NPC npc
- instance of the NPC
AI_AlignToWP
AI_AlignToWP
Aligns the NPC to the Waypoint
Parameters
var C_NPC npc
- instance of the NPC
AI_Attack
AI_Attack
Starts the combat AI (should be called in the ZS_Attack loop). Uses the internal target that can be set by Npc_SetTarget()
and Npc_GetNextTarget()
Parameters
var C_NPC npc
- instance of the NPC
AI_CanSeeNpc
AI_CanSeeNpc
If slf
can see oth
starts given AI state function
Parameters
var C_NPC slf
- instance of the first NPCvar C_NPC oth
- instance of the second NPCvar func function
- AI state function to start (ZS_*)
AI_ContinueRoutine
AI_ContinueRoutine
Continues the daily routine. Includes standing up
Parameters
var C_NPC npc
- instance of the NPC
AI_Defend
AI_Defend
Adds overlay message (EV_DEFEND
) that ends when the NPC performs a parry triggered by another NPC's attack.
Parameters
var C_NPC npc
- instance of the NPC
AI_Dodge
AI_Dodge
Makes the NPC dodge a bit backward
Parameters
var C_NPC npc
- instance of the NPC
AI_DrawWeapon
AI_DrawWeapon
Draws the equipped melee weapon
Parameters
var C_NPC npc
- instance of the NPC
AI_DropItem
AI_DropItem
Drops the item with the specified item ID on the ground (works only in dialogs)
Parameters
var C_NPC npc
- instance of the NPCvar int iteminstance
- item instance name
AI_EquipArmor
AI_EquipArmor
Equips armor from the inventory
Parameters
var C_NPC npc
- instance of the NPCvar C_ITEM armor
- armor instance to equip
AI_EquipBestArmor
AI_EquipBestArmor
Equips the best armor available in the NPCs inventory
Parameters
var C_NPC npc
- instance of the NPC
AI_EquipBestMeleeWeapon
AI_EquipBestMeleeWeapon
Equips the best melee weapon available in the NPCs inventory
Parameters
var C_NPC npc
- instance of the NPC
AI_EquipBestRangedWeapon
AI_EquipBestRangedWeapon
Equips the best ranged weapon available in the NPCs inventory
Parameters
var C_NPC npc
- instance of the NPC
AI_FinishingMove
AI_FinishingMove
Makes attacker
kill target
with a finishing move if possible
Parameters
var C_NPC attacker
- instance of the attacking NPCvar C_NPC target
- instance of the target NPC
AI_Flee
AI_Flee
Makes the NPC flee from the target
Parameters
var C_NPC npc
- instance of the NPC
AI_GotoFP
AI_GotoFP
Finds the nearest available freepoint near the NPC, moves there, and aligns accordingly
Parameters
var C_NPC npc
- instance of the NPCvar string fpname
- name of the freepoint (could be only the middle part of the name:FP_
+fpname
+_01
)
AI_GotoNextFP
AI_GotoNextFP
Finds an available freepoint within near the NPC (not the nearest one), moves there, and aligns accordingly. Useful for NPCs that are already at the freepoint
Parameters
var C_NPC npc
- instance of the NPCvar string fpname
- name of the freepoint (could be only the middle part of the name:FP_
+fpname
+_01
)
AI_GotoItem
AI_GotoItem
Makes the NPC go to the specified item
Parameters
var C_NPC npc
- instance of the NPCvar C_ITEM itm
- instance of the item
AI_GotoNpc
AI_GotoNpc
Makes slf
go to oth
Parameters
var C_NPC slf
- instance of the NPCvar C_NPC oth
- instance of the other NPC
AI_GotoSound
AI_GotoSound
Makes NPC go to the source of the sound
Parameters
var C_NPC npc
- instance of the NPC
AI_GotoWP
AI_GotoWP
NPC goes to the specified waypoint
Parameters
var C_NPC npc
- instance of the NPCvar string wpname
- name of the waypoint
AI_LookAt
AI_LookAt
Makes NPC look at the target object (only head moves)
Parameters
var C_NPC npc
- instance of the NPCvar string target
- name of the object to look at
AI_LookAtNpc
AI_LookAtNpc
Makes slf
looks at oth
(only head moves)
Parameters
var C_NPC slf
- instance of the NPCvar C_NPC oth
- instance of the other NPC
AI_Output
AI_Output
Makes slf
say a line of text to oth
. The actual text is defined by the comment after the function call
Parameters
var C_NPC slf
- instance of the NPCvar C_NPC oth
- C_NPC instance of the target NPCvar string outputname
- name of the output and the associated .wav file
Example
AI_OutputSVM
AI_OutputSVM
Makes slf
say an SVM text to oth
Parameters
var C_NPC slf
- instance of the NPCvar C_NPC oth
- C_NPC instance of the target NPCvar string svmname
- name of the SVM
AI_OutputSVM_Overlay
AI_OutputSVM_Overlay
Makes slf
say an SVM text to oth
, but does not wait for the SVM to finish before executing the next AI command. Useful for comments right before and during combat
Parameters
var C_NPC slf
- instance of the NPCvar C_NPC oth
- C_NPC instance of the target NPCvar string svmname
- name of the SVM
AI_PlayAni
AI_PlayAni
Plays an animation on the NPC
Parameters
var C_NPC npc
- instance of the NPCvar string aniname
- name of the animation UPPERCASE
AI_PlayAniBS
AI_PlayAniBS
Plays an animation on the NPC and sets its body state
Parameters
var C_NPC npc
- instance of the NPCvar string aniname
- name of the animation UPPERCASEvar int bodystate
- body state
AI_PlayFX
AI_PlayFX
Plays a visual effect (VFX)
Parameters
var C_NPC origin
- NPC who is the effect origin and also to whose AI queue the function is addedvar instance target
- instance of the effect target objectvar string effect
- name of the visual effect
Warning
This function is only available in Gothic 2
AI_StopFX
AI_StopFX
Stops a visual effect (VFX)
Parameters
var C_NPC npc
- instance of the NPCvar string effect
- name of the visual effect
Warning
This function is only available in Gothic 2
AI_PointAt
AI_PointAt
Makes NPC point at the target object
Parameters
var C_NPC npc
- instance of the NPCname
- name of the waypoint or object
AI_PointAtNpc
AI_PointAtNpc
Makes slf
point with hand at oth
Parameters
var C_NPC slf
- instance of the NPCvar C_NPC oth
- instance of the other NPC
AI_PrintScreen
AI_PrintScreen
Prints a message on the screen. The function is queued on hero
AI queue.
Parameters
var string text
- message to printvar int posx
- x position as percent (-1 to center)var int posy
- y position as percent (-1 to center)var string font
- font to usevar int timesec
- display duration in seconds
Warning
This function is only available in Gothic 2
AI_ProcessInfos
AI_ProcessInfos
Opens a dialog window with NPS's C_INFO instances if its state is ZS_TALK
.
When called on hero
, the dialog window for the currently contrloled NPC instance will be opened.
Parameters
var C_NPC npc
- instance of the NPC
AI_ReadyMeleeWeapon
AI_ReadyMeleeWeapon
Draws the equipped melee weapon
Parameters
var C_NPC npc
- instance of the NPC
AI_ReadyRangedWeapon
AI_ReadyRangedWeapon
Draws the equipped ranged weapon
Parameters
var C_NPC npc
- instance of the NPC
AI_ReadySpell
AI_ReadySpell
Readies a spell
Parameters
var C_NPC npc
- instance of the NPCvar int spellid
- ID of the spellvar int investmana
- amount of mana to invest
AI_UnreadySpell
AI_UnreadySpell
Unreadies a spell
Parameters
var C_NPC npc
- instance of the NPC
AI_RemoveWeapon
AI_RemoveWeapon
Puts away the drawn weapon
Parameters
var C_NPC npc
- instance of the NPC
AI_SetNpcsToState
AI_SetNpcsToState
Sets all NPCs within a radius of x cm to the specified ZS state
Parameters
var C_NPC npc
- instance of the NPCvar func state
- ZS state functionvar int radius
- radius in cm
AI_SetWalkmode
AI_SetWalkmode
Specifies the walk mode (run, walk, sneak) of the NPC
Parameters
var C_NPC npc
- instance of the NPCvar int mode
- walk mode
AI_ShootAt
AI_ShootAt
Shoots at the target with a ranged weapon
Parameters
var C_NPC attacker
- instance of the attacker NPCvar C_NPC target
- instance of the target NPC
AI_Snd_Play
AI_Snd_Play
Plays a sound (queued)
Parameters
var C_NPC npc
- instance of the NPC to whose AI queue the function is addedvar string sndName
- C_SFX instance name
Warning
This function is only available in Gothic 2
AI_Snd_Play3D
AI_Snd_Play3D
Plays a sound at the position of the npc (queued)
Parameters
var C_NPC npc
- instance of the NPC to whose AI queue the function is addedvar C_NPC origin
- instance of the NPC whose position the sound is played atvar string sndName
- C_SFX instance name
Warning
This function is only available in Gothic 2
AI_StandUp
AI_StandUp
Makes NPC stand up from a sitting or lying position
Parameters
var C_NPC npc
- instance of the NPC
AI_StandUpQuick
AI_StandUpQuick
Makes NPC stand up from a sitting or lying position without playing transition animations
Parameters
var C_NPC npc
- instance of the NPC
AI_StartState
AI_StartState
Puts the NPC into the specified AI state (ZS_*)
Parameters
var C_NPC npc
- instance of the NPCvar func state
- function representing the AI state (ZS_*)var int statebehaviour
-0
to end the current state immediately,1
to finish it properlyvar string wpname
- name of the waypoint to do the action at
AI_StopAim
AI_StopAim
Makes the NPC stop aiming at the target
Parameters
var C_NPC npc
- instance of the NPC
AI_StopLookAt
AI_StopLookAt
Makes npc stop looking at a target and returns to the default forward gaze
Parameters
var C_NPC npc
- instance of the NPC
AI_StopPointAt
AI_StopPointAt
Makes the NPC stop pointing at the target
Parameters
var C_NPC npc
- instance of the NPC
AI_StopProcessInfos
AI_StopProcessInfos
Exits the dialog window of the NPC
Parameters
var C_NPC npc
- instance of the NPC
AI_TakeItem
AI_TakeItem
The NPC goes to the specified item and takes it
Parameters
var C_NPC npc
- instance of the NPCvar C_ITEM itm
- instance of the item
AI_Teleport
AI_Teleport
Teleports the NPC to the specified location
Parameters
var C_NPC npc
- instance of the NPCvar string waypoint
- name of the waypoint or object to teleport to
AI_TurnAway
AI_TurnAway
Makes slf
turn away from oth
Parameters
var C_NPC slf
- instance of the NPCvar C_NPC oth
- instance of the other NPC
AI_TurnToNpc
AI_TurnToNpc
Makes slf
turn torwards oth
Parameters
var C_NPC slf
- instance of the NPCvar C_NPC oth
- instance of the other NPC
AI_TurnToSound
AI_TurnToSound
Makes NPC turn to the source of the sound
Parameters
var C_NPC npc
- instance of the NPC
AI_UnequipArmor
AI_UnequipArmor
Unequips the current armor
Parameters
var C_NPC npc
- instance of the NPC
AI_UnequipWeapons
AI_UnequipWeapons
Unequips all weapons
Parameters
var C_NPC npc
- instance of the NPC
AI_UseItem
AI_UseItem
Makes the NPC use an item to the end of its use state
Parameters
var C_NPC npc
- instance of the NPCvar int iteminstance
- name of the item instance
AI_UseItemToState
AI_UseItemToState
Makes the NPC use an item until it reaches the target state
Parameters
var C_NPC npc
- instance of the NPCvar int iteminstance
- name of the item instancevar int state
- target state (1 for S1 etc. -1 to end the action)
AI_UseMob
AI_UseMob
Uses an intetactive object with the specified schema name until it reaches the target state.
If the target state is already present, the NPC will move to the MOB but do nothing
Parameters
var C_NPC npc
- instance of the NPCvar string schemename
- name of the schema (e.g.BENCH
)var int targetstate
- target state (1 for S1 etc. -1 to end the action)
Return value
The function returns TRUE if the mob was used, FALSE otherwise
AI_Wait
AI_Wait
Makes NPC wait for a specified number of seconds
Parameters
var C_NPC npc
- instance of the NPCvar float timesec
- float number of seconds to wait
AI_WaitMS
AI_WaitMS
Makes NPC wait for a specified number of milliseconds
Parameters
var C_NPC npc
- instance of the NPCvar int timems
- number of milliseconds to wait
AI_WaitTillEnd
AI_WaitTillEnd
Makes slf
wait until oth
finishes its current AI command (does not work with AI overlays)
Parameters
var C_NPC slf
- instance of the NPCother
- instance of the other NPC
Deprecated
AI_Ask
AI_Ask
Probably relic of the old dialog system
AI_AskText
AI_AskText
Probably relic of the old dialog system
AI_WaitForQuestion
AI_WaitForQuestion
Probably relic of the old dialog system
AI_CombatReactToDamage
AI_PlayCutscene
AI_PlayCutscene
Relic of the cutscene system
Starts a cutscene with the specified name
Parameters
var C_NPC npc
- instance of the NPCvar string csname
- string name of the cutscene
AI_Quicklook
AI_Quicklook
T_QLOOK
animation is missing
Makes slf
looks at oth
for 2 seconds (only head moves)
Parameters
var C_NPC slf
- instance of the NPCvar C_NPC oth
- instance of the other NPC
AI_TakeMob
AI_TakeMob
Relic of the mob carrying system
AI_DropMob
AI_DropMob
Relic of the mob carrying system ```dae func void AI_DropMob(var C_NPC npc)
AI_WhirlAround
AI_WhirlAround
S_SURPRISE
animation is missing
Makes slf
quickly turn to oth
and play a surprise animation
Parameters
var C_NPC slf
- instance of the NPCvar C_NPC oth
- instance of the other NPC
AI_WhirlAroundToSource
AI_WhirlAroundToSource
S_SURPRISE
animation is missing
Makes NPC quickly turn to sound source and play a surprise animation
Parameters
var C_NPC npc
- instance of the NPC
AI_LookForItem
AI_LookForItem
Not used in the original scripts, does nothing
NPC searches for the item with the specified instance name
Parameters
var C_NPC npc
- instance of the NPCvar int iteminstance
- instance name of the item
Warning
The function is only present in Gothic 1.
zParserExtender
zParserExtender implements quite a few new AI external functions.