NPC callbacks - WoutProvost/FCNPC-AI GitHub Wiki

HomeCallbacksNPC callbacks

FAI_OnEncounterStart(npcid, bool:reasonShot, firstTarget)
  • Description: This callback is called when a player gets aggro from an idle NPC.
  • Parameters:
    • npcid: The ID of the NPC for which the encounter started.
    • bool:reasonShot: True if the NPC was damaged from afar, false if the player entered the NPC's aggro range or FAI_SetTarget was successfully used.
    • firstTarget: The ID of the player that took aggro from the idle NPC.
  • Return values: This callback does not handle returns.
  • Notes: Called once during the whole encounter, which is at the start of the encounter.

FAI_OnEncounterStop(npcid, bool:reasonDeath, lastTarget)
  • Description: This callback is called when no valid players are available for the NPC after the encounter started.
  • Parameters:
    • npcid: The ID of the NPC for which the encounter started.
    • bool:reasonDeath: True if the encounter stopped because the NPC died, false if the encounter stopped because the NPC was respawned, was destroyed, the target was out of range and FAI_SetAggroRange with checkForTarget true was used, the target was an NPC and FAI_SetAllowNPCTargets with checkForTarget true was used, FAI_SetTarget with INVALID_PLAYER_ID was used.
    • lastTarget: The ID of the last player that had aggro from the NPC.
  • Return values: This callback does not handle returns.
  • Notes: Called once during the whole encounter, which is at the end of the encounter.

FAI_OnPlayerGetAggro(playerid, npcid)
  • Description: This callback is called when a player gets aggro from an NPC.
  • Parameters:
    • playerid: The ID of the player that got aggro from the NPC.
    • npcid: The ID of the NPC that the player aggroed.
  • Return values: This callback does not handle returns.
  • Notes: Can be called multiple times for different players during the whole encounter.

FAI_OnPlayerLoseAggro(playerid, npcid)
  • Description: This callback is called when a player loses aggro from an NPC.
  • Parameters:
    • playerid: The ID of the player that lost aggro from the NPC.
    • npcid: The ID of the NPC that the player lost aggro from.
  • Return values: This callback does not handle returns.
  • Notes:
    • Can be called multiple times for different players during the whole encounter.
    • A player will lose aggro from an NPC if that player becomes invalid for the NPC, or if the NPC streames out for that player.
    • A player will lose aggro if the NPC: dies, is respawned, is destroyed, out of aggro range when FAI_SetAggroRange with checkForTarget true is used, or if the target is an NPC when FAI_SetAllowNPCTargets with checkForTarget true is used, or if FAI_SetBehaviour with checkForTarget true is used.