Przejdź do treści

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)

func void AI_AimAt(var C_NPC attacker, var C_NPC target) 

Parameters

  • var C_NPC attacker - instance of the attacker
  • var C_NPC target - C_NPC instance of the target

AI_AlignToFP

AI_AlignToFP

Aligns the NPC to the Freepoint

func void AI_AlignToFP(var C_NPC npc) 

Parameters

  • var C_NPC npc - instance of the NPC

AI_AlignToWP

AI_AlignToWP

Aligns the NPC to the Waypoint

func void AI_AlignToWP(var C_NPC npc) 

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()

func void AI_Attack(var C_NPC npc) 

Parameters

  • var C_NPC npc - instance of the NPC

AI_CanSeeNpc

AI_CanSeeNpc

If slf can see oth starts given AI state function

func void AI_CanSeeNpc(var C_NPC slf, var C_NPC oth, var func function) 

Parameters

  • var C_NPC slf - instance of the first NPC
  • var C_NPC oth - instance of the second NPC
  • var func function - AI state function to start (ZS_*)

AI_ContinueRoutine

AI_ContinueRoutine

Continues the daily routine. Includes standing up

func void AI_ContinueRoutine(var C_NPC npc) 

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.

func void AI_Defend(var C_NPC npc) 

Parameters

  • var C_NPC npc - instance of the NPC

AI_Dodge

AI_Dodge

Makes the NPC dodge a bit backward

func void AI_Dodge(var C_NPC npc) 

Parameters

  • var C_NPC npc - instance of the NPC

AI_DrawWeapon

AI_DrawWeapon

Draws the equipped melee weapon

func void AI_DrawWeapon(var C_NPC npc) 

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)

func void AI_DropItem(var C_NPC npc, var int iteminstance) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var int iteminstance - item instance name

AI_EquipArmor

AI_EquipArmor

Equips armor from the inventory

func void AI_EquipArmor(var C_NPC npc, var C_ITEM armor) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var C_ITEM armor - armor instance to equip

AI_EquipBestArmor

AI_EquipBestArmor

Equips the best armor available in the NPCs inventory

func void AI_EquipBestArmor(var C_NPC npc) 

Parameters

  • var C_NPC npc - instance of the NPC

AI_EquipBestMeleeWeapon

AI_EquipBestMeleeWeapon

Equips the best melee weapon available in the NPCs inventory

func void AI_EquipBestMeleeWeapon(var C_NPC npc) 

Parameters

  • var C_NPC npc - instance of the NPC

AI_EquipBestRangedWeapon

AI_EquipBestRangedWeapon

Equips the best ranged weapon available in the NPCs inventory

func void AI_EquipBestRangedWeapon(var C_NPC npc) 

Parameters

  • var C_NPC npc - instance of the NPC

AI_FinishingMove

AI_FinishingMove

Makes attacker kill target with a finishing move if possible

func void AI_FinishingMove(var C_NPC attacker, var C_NPC target) 

Parameters

  • var C_NPC attacker - instance of the attacking NPC
  • var C_NPC target - instance of the target NPC

AI_Flee

AI_Flee

Makes the NPC flee from the target

func void AI_Flee(var C_NPC npc) 

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

func void AI_GotoFP(var C_NPC npc, var string fpname) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var 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

func void AI_GotoNextFP(var C_NPC npc, var string fpname) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var 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

func void AI_GotoItem(var C_NPC npc, var C_ITEM itm) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var C_ITEM itm - instance of the item

AI_GotoNpc

AI_GotoNpc

Makes slf go to oth

func void AI_GotoNpc(var C_NPC slf, var C_NPC oth) 

Parameters

  • var C_NPC slf - instance of the NPC
  • var C_NPC oth - instance of the other NPC

AI_GotoSound

AI_GotoSound

Makes NPC go to the source of the sound

func void AI_GotoSound(var C_NPC npc) 

Parameters

  • var C_NPC npc - instance of the NPC

AI_GotoWP

AI_GotoWP

NPC goes to the specified waypoint

func void AI_GotoWP(var C_NPC npc, var string wpname) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var string wpname - name of the waypoint

AI_LookAt

AI_LookAt

Makes NPC look at the target object (only head moves)

func void AI_LookAt(var C_NPC npc, var string target) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var string target - name of the object to look at

AI_LookAtNpc

AI_LookAtNpc

Makes slf looks at oth (only head moves)

func void AI_LookAtNpc(var C_NPC slf, var C_NPC oth) 

Parameters

  • var C_NPC slf - instance of the NPC
  • var 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

func void AI_Output(var C_NPC slf, var C_NPC oth, var string outputname) 

Parameters

  • var C_NPC slf - instance of the NPC
  • var C_NPC oth - C_NPC instance of the target NPC
  • var string outputname - name of the output and the associated .wav file

Example

AI_Output (self ,other, "DIA_Addon_Xardas_Hello_14_00"); //There you are again! (smiling) I never thought the two of us would meet again.

AI_OutputSVM

AI_OutputSVM

Makes slf say an SVM text to oth

func void AI_OutputSVM(var C_NPC slf, var C_NPC oth, var string svmname) 

Parameters

  • var C_NPC slf - instance of the NPC
  • var C_NPC oth - C_NPC instance of the target NPC
  • var 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

func void AI_OutputSVM_Overlay(var C_NPC slf, var C_NPC oth, var string svmname) 

Parameters

  • var C_NPC slf - instance of the NPC
  • var C_NPC oth - C_NPC instance of the target NPC
  • var string svmname - name of the SVM

AI_PlayAni

AI_PlayAni

Plays an animation on the NPC

func void AI_PlayAni(var C_NPC npc, var string aniname) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var string aniname - name of the animation UPPERCASE

AI_PlayAniBS

AI_PlayAniBS

Plays an animation on the NPC and sets its body state

func void AI_PlayAniBS(var C_NPC npc, var string aniname, var int bodystate) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var string aniname - name of the animation UPPERCASE
  • var int bodystate - body state

AI_PlayFX

AI_PlayFX

Plays a visual effect (VFX)

func void AI_PlayFX(var C_NPC origin, var instance target, var string effect) 

Parameters

  • var C_NPC origin - NPC who is the effect origin and also to whose AI queue the function is added
  • var instance target - instance of the effect target object
  • var 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)

func void AI_StopFX(var C_NPC npc, var string effect) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var 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

func void AI_PointAt(var C_NPC npc, var string target) 

Parameters

  • var C_NPC npc - instance of the NPC
  • name - name of the waypoint or object

AI_PointAtNpc

AI_PointAtNpc

Makes slf point with hand at oth

func void AI_PointAtNpc(var C_NPC slf, var C_NPC oth) 

Parameters

  • var C_NPC slf - instance of the NPC
  • var 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.

func int AI_PrintScreen(var string text, var int posx, var int posy, var string font, var int timesec) 

Parameters

  • var string text - message to print
  • var int posx - x position as percent (-1 to center)
  • var int posy - y position as percent (-1 to center)
  • var string font - font to use
  • var 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.

func void AI_ProcessInfos(var C_NPC npc) 

Parameters

  • var C_NPC npc - instance of the NPC

AI_ReadyMeleeWeapon

AI_ReadyMeleeWeapon

Draws the equipped melee weapon

func void AI_ReadyMeleeWeapon(var C_NPC npc) 

Parameters

  • var C_NPC npc - instance of the NPC

AI_ReadyRangedWeapon

AI_ReadyRangedWeapon

Draws the equipped ranged weapon

func void AI_ReadyRangedWeapon(var C_NPC npc) 

Parameters

  • var C_NPC npc - instance of the NPC

AI_ReadySpell

AI_ReadySpell

Readies a spell

func void AI_ReadySpell(var C_NPC npc, var int spellid, var int investmana) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var int spellid - ID of the spell
  • var int investmana - amount of mana to invest

AI_UnreadySpell

AI_UnreadySpell

Unreadies a spell

func void AI_UnreadySpell(var C_NPC npc) 

Parameters

  • var C_NPC npc - instance of the NPC

AI_RemoveWeapon

AI_RemoveWeapon

Puts away the drawn weapon

func void AI_RemoveWeapon(var C_NPC npc) 

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

func void AI_SetNpcsToState(var C_NPC npc, var func state, var int radius) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var func state - ZS state function
  • var int radius - radius in cm

AI_SetWalkmode

AI_SetWalkmode

Specifies the walk mode (run, walk, sneak) of the NPC

func void AI_SetWalkmode(var C_NPC npc, var int mode) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var int mode - walk mode

AI_ShootAt

AI_ShootAt

Shoots at the target with a ranged weapon

func void AI_ShootAt(var C_NPC attacker, var C_NPC target) 

Parameters

  • var C_NPC attacker - instance of the attacker NPC
  • var C_NPC target - instance of the target NPC

AI_Snd_Play

AI_Snd_Play

Plays a sound (queued)

func void AI_Snd_Play(var C_NPC npc, var string sndName) 

Parameters

  • var C_NPC npc - instance of the NPC to whose AI queue the function is added
  • var 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)

func void AI_Snd_Play3D(var C_NPC npc, var C_NPC origin, var string sndName) 

Parameters

  • var C_NPC npc - instance of the NPC to whose AI queue the function is added
  • var C_NPC origin - instance of the NPC whose position the sound is played at
  • var 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

func void AI_StandUp(var C_NPC npc) 

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

func void AI_StandUpQuick(var C_NPC npc) 

Parameters

  • var C_NPC npc - instance of the NPC

AI_StartState

AI_StartState

Puts the NPC into the specified AI state (ZS_*)

func void AI_StartState(var C_NPC npc, var func state, var int statebehaviour, var string wpname) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var func state - function representing the AI state (ZS_*)
  • var int statebehaviour - 0 to end the current state immediately, 1 to finish it properly
  • var string wpname - name of the waypoint to do the action at

AI_StopAim

AI_StopAim

Makes the NPC stop aiming at the target

func void AI_StopAim(var C_NPC npc) 

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

func void AI_StopLookAt(var C_NPC npc) 

Parameters

  • var C_NPC npc - instance of the NPC

AI_StopPointAt

AI_StopPointAt

Makes the NPC stop pointing at the target

func void AI_StopPointAt(var C_NPC npc) 

Parameters

  • var C_NPC npc - instance of the NPC

AI_StopProcessInfos

AI_StopProcessInfos

Exits the dialog window of the NPC

func void AI_StopProcessInfos(var C_NPC npc) 

Parameters

  • var C_NPC npc - instance of the NPC

AI_TakeItem

AI_TakeItem

The NPC goes to the specified item and takes it

func void AI_TakeItem(var C_NPC npc, var C_ITEM itm) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var C_ITEM itm - instance of the item

AI_Teleport

AI_Teleport

Teleports the NPC to the specified location

func void AI_Teleport(var C_NPC npc, var string waypoint) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var string waypoint - name of the waypoint or object to teleport to

AI_TurnAway

AI_TurnAway

Makes slf turn away from oth

func void AI_TurnAway(var C_NPC slf, var C_NPC oth) 

Parameters

  • var C_NPC slf - instance of the NPC
  • var C_NPC oth - instance of the other NPC

AI_TurnToNpc

AI_TurnToNpc

Makes slf turn torwards oth

func void AI_TurnToNpc(var C_NPC slf, var C_NPC oth) 

Parameters

  • var C_NPC slf - instance of the NPC
  • var C_NPC oth - instance of the other NPC

AI_TurnToSound

AI_TurnToSound

Makes NPC turn to the source of the sound

func void AI_TurnToSound(var C_NPC npc) 

Parameters

  • var C_NPC npc - instance of the NPC

AI_UnequipArmor

AI_UnequipArmor

Unequips the current armor

func void AI_UnequipArmor(var C_NPC npc) 

Parameters

  • var C_NPC npc - instance of the NPC

AI_UnequipWeapons

AI_UnequipWeapons

Unequips all weapons

func void AI_UnequipWeapons(var C_NPC npc) 

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

func void AI_UseItem(var C_NPC npc, var int iteminstance) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var int iteminstance - name of the item instance

AI_UseItemToState

AI_UseItemToState

Makes the NPC use an item until it reaches the target state

func void AI_UseItemToState(var C_NPC npc, var int iteminstance, var int state) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var int iteminstance - name of the item instance
  • var 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

func int AI_UseMob(var C_NPC npc, var string schemename, var int targetstate) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var 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

func void AI_Wait(var C_NPC npc, var float timesec) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var float timesec - float number of seconds to wait

AI_WaitMS

AI_WaitMS

Makes NPC wait for a specified number of milliseconds

func void AI_WaitMS(var C_NPC npc, var int timems) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var 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)

func void AI_WaitTillEnd(var C_NPC slf, var C_NPC oth) 

Parameters

  • var C_NPC slf - instance of the NPC
  • other - instance of the other NPC

Deprecated

AI_Ask

AI_Ask

Probably relic of the old dialog system

func void AI_Ask(var C_NPC npc, var func anseryes, var func answerno) 

AI_AskText

AI_AskText

Probably relic of the old dialog system

func void AI_AskText(var C_NPC npc, var func funcyes, var func funcno, var string stryes, var string strno) 

AI_WaitForQuestion

AI_WaitForQuestion

Probably relic of the old dialog system

func void AI_WaitForQuestion(var C_NPC npc, var func scriptfunc) 

AI_CombatReactToDamage

AI_CombatReactToDamage

Does nothing

func void AI_CombatReactToDamage(var instance n0) 

AI_PlayCutscene

AI_PlayCutscene

Relic of the cutscene system
Starts a cutscene with the specified name

func void AI_PlayCutscene(var C_NPC npc, var string csname) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var 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)

func void AI_Quicklook(var C_NPC slf, var C_NPC oth) 

Parameters

  • var C_NPC slf - instance of the NPC
  • var C_NPC oth - instance of the other NPC

AI_TakeMob

AI_TakeMob

Relic of the mob carrying system

func void AI_TakeMob(var C_NPC npc, var string mobname) 

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

func void AI_WhirlAround(var C_NPC slf, var C_NPC oth) 

Parameters

  • var C_NPC slf - instance of the NPC
  • var 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

func void AI_WhirlAroundToSource(var C_NPC npc) 

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

func void AI_LookForItem(var C_NPC npc, var int iteminstance) 

Parameters

  • var C_NPC npc - instance of the NPC
  • var 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.