Casting functions - WoutProvost/FCNPC-AI GitHub Wiki

HomeFunctionsCasting functions

FAI_StartCastingSpell(npcid, spellid, targetid)
  • Description: Start an NPC casting a spell.
  • Parameters:
    • npcid: The ID of the NPC to start the cast of.
    • spellid: The ID of the spell to start the cast of.
    • targetid: The ID of the player the spell should be cast on. Can be INVALID_PLAYER_ID. Defaults to INVALID_PLAYER_ID.
  • Return values:
    • 1: The function executed successfully.
    • 0: The function failed to execute. An invalid npcid was given, or an invalid spellid was given, or the NPC is dead, or the NPC is casting already, or the player is not connected (except INVALID_PLAYER_ID).
  • Notes: The spell will not be replaced when another spell is currently being cast. Use FAI_StopCasting first or FAI_SetCastingSpell instead. The spell will be replaced when the cast bar is still shown for the additional time.

FAI_GetCastingSpell(npcid)
  • Description: Get an NPC's casting spell.
  • Parameters:
    • npcid: The ID of the NPC to get the casting spell of.
  • Return values:
    • Valid spellid: The function executed successfully. A spell is being cast.
    • -1: The function failed to execute. An invalid npcid was given, or the NPC wasn't casting.

FAI_SetCastingSpell(npcid, spellid, bool:keepCastPercent)
  • Description: Replace a NPC's spell he is casting, with another spell. The casting target doesn't change.
  • Parameters:
    • npcid: The ID of the NPC to set the casting spell of.
    • spellid: The ID of the spell to set.
    • bool:keepCastPercent: Should the NPC's castProgress be adapted? Defaults to false.
      • true: This will update the NPC's castProgress as well so that the NPC keeps the same cast percentage. For example: castTime spell1 500, castProgress 200, percent is 0.4 ➔ castTime spell2 1000, castProgress will change to 400, percent is still 0.4.
      • false:
        1. CastTime spell2 > castProgress: This will not change the NPC's castProgress. For example: castTime spell1 500, castProgress 200, percent is 0.4 ➔ castTime spell2 1000, castProgress is still 200, percent is now 0.2.
        2. CastTime spell2 <= castProgress: This will as well lower the NPC's castProgress to be equal to the castTime of the new spell, because an NPC can't have more castProgress than castTime. For example: castTime spell1 500, castProgress 200, percent is 0.4 ➔ castTime spell2 150, castProgress will change to 150, percent is now 1.0. FAI_OnStopCasting gets called immediately with castComplete true. Cast bar starts showing extra (if showExtraTime > 0), except if the castTime of the new spell was 0 (instant).
  • Return values:
    • 1: The function executed successfully.
    • 0: The function failed to execute. An invalid npcid was given, or an invalid spellid was given, or the NPC is dead, or the NPC is not casting.

FAI_GetCastingProgress(npcid)
  • Description: Get a NPC's casting progress.
  • Parameters:
    • npcid: The ID of the NPC to get the casting progress of.
  • Return values:
    • Valid progress: The function executed successfully. A spell is being cast.
    • -1: The function failed to execute. An invalid npcid was given, or the NPC wasn't casting.

FAI_SetCastingProgress(npcid, progress)
  • Description: Change an NPC's castProgress of a spell he is casting.
  • Parameters:
    • npcid: The ID of the NPC to set the castProgress of.
    • progress: The castProgress to set. If a value < 0 was given, it will be reset to 0.
      • Value < castTime: The castProgress will be set to the given value.
      • Value > = castTime: The castProgress will be set to the castTime, because an NPC can't have more castProgress than castTime. For example: castTime 500, castProgress 200 ➔ castProgress set to 550, castProgress will change to 500. FAI_OnStopCasting gets called immediately with castComplete true. Cast bar starts showing extra (if showExtraTime > 0), except if castTime was 0 (instant).
  • Return values:
    • 1: The function executed successfully.
    • 0: The function failed to execute. An invalid npcid was given, or the NPC is dead, or the NPC is not casting.
  • Notes:

FAI_GetCastingTarget(npcid)
  • Description: Get an NPC's casting target. This is not the same as the NPC's target.
  • Parameters:
    • npcid: The ID of the NPC to get the casting target of.
  • Return values:
    • Valid target: The function executed successfully. A spell is being cast on a player.
    • INVALID_PLAYER_ID: The function executed successfully. A spell is being cast on nobody.
    • -1: The function failed to execute. An invalid npcid was given, or the NPC wasn't casting.

FAI_SetCastingTarget(npcid, targetid)
  • Description: Change an NPC's casting target of a spell he is casting. This is not the same as the NPC's target.
  • Parameters:
    • npcid: The ID of the NPC to set the casting target of.
    • targetid: The ID of the player to set.
  • Return values:
    • 1: The function executed successfully.
    • 0: The function failed to execute. An invalid npcid was given, or the NPC is dead, or the NPC is not casting, or the player is not connected (except INVALID_PLAYER_ID).
  • Notes: The target doesn't have to be valid for the NPC, doesn't have to be streamed in for the NPC and doesn't have to be within the aggro range of the NPC.

FAI_GetCastingExtraProgress(npcid)
  • Description: Get an NPC's casting extra progress.
  • Parameters:
    • npcid: The ID of the NPC to get the casting extra progress of.
  • Return values:
    • Valid extra progress: The function executed successfully. The cast bar is being shown for the additional time.
    • -1: The function failed to execute. An invalid npcid was given, or the cast bar was not being shown for the additional time (this includes when the NPC is still casting).

FAI_SetCastingExtraProgress(npcid, progress)
  • Description: Change an NPC's casting extra progress of a spell that is still showing for the additional time.
  • Parameters:
    • npcid: The ID of the NPC to set the casting extra progress of.
    • progress: The casting extra progress to set. If a value < 0 was given, it will be reset to 0.
      • Value < FAI_CAST_BAR_SHOW_EXTRA_TIME: The casting extra progress will be set to the given value.
      • Value > = FAI_CAST_BAR_SHOW_EXTRA_TIME: The casting extra progress will be set to FAI_CAST_BAR_SHOW_EXTRA_TIME, because an NPC can't have more casting extra progress than FAI_CAST_BAR_SHOW_EXTRA_TIME. For example: showExtraTime 500, showExtraProgress 200 ➔ showExtraProgress set to 550, showExtraProgress will change to 500. The cast bar will disappear immediately.
  • Return values:
    • 1: The function executed successfully.
    • 0: The function failed to execute. An invalid npcid was given, or the NPC is dead, or the cast bar was not being shown for the additional time (this includes when the NPC is still casting).
  • Notes:
    • The castbar is shown a bit longer after the cast has finished. This can be changed by defining FAI_CAST_BAR_SHOW_EXTRA_TIME as 0.
    • Instant spells don't show the cast bar for an additional time, regardless of the value of FAI_CAST_BAR_SHOW_EXTRA_TIME.

FAI_StopAllesCasting()
  • Description: Stops all NPCs from casting, regardless of the spell that they are casting.
  • Parameters: This function has no parameters.
  • Return values: This function always returns 1.

FAI_StopAllesCastingSpell(spellid)
  • Description: Stops all NPCs from casting a particular spell.
  • Parameters:
    • spellid: The ID of the spell that should stop being cast by all NPCs (if they are casting it).
  • Return values:
    • 1: All NPCs stopped casting the given spell.
    • 0: An invalid spellid was given.

FAI_StopCasting(npcid)
  • Description: Stops an NPC casting, regardless of the spell that is being cast.
  • Parameters:
    • npcid: The ID of the NPC that should stop casting (if he is casting).
  • Return values:
    • 1: If the NPC was casting, he stops casting and FAI_OnStopCasting is called with castComplete false.
    • 0: An invalid npcid was given, or an invalid spellid was given.
  • Notes: If the NPC was not casting, FAI_OnStopCasting will not be called.

FAI_StopCastingSpell(npcid, spellid)
  • Description: Stops an NPC casting a particular spell.
  • Parameters:
    • npcid: The ID of the NPC that should stop casting (if he is casting).
    • spellid: The ID of the spell that the NPC should stop casting.
  • Return values:
    • 1: If the NPC was casting the given spell, he stops casting and FAI_OnStopCasting is called with castComplete false.
    • 0: An invalid npcid was given, or an invalid spellid was given, or the given spell is not the spell that is being cast.
  • Notes: If the NPC was not casting the given spell, FAI_OnStopCasting will not be called.

FAI_IsCasting(npcid)
  • Description: Checks if an NPC is casting, regardless of the spell that is being cast.
  • Parameters:
    • npcid: The ID of the NPC to check.
  • Return values: (bool)
    • true: The NPC is casting.
    • false: An invalid npcid was given, or an invalid spellid was given, or the NPC is not casting.
  • Notes:
    • When the NPC has finished casting, but the cast bar is still shown for the additional time, this function will return false! Use FAI_IsCastBarExtra instead.
    • If the cast bar is still shown for the additional time, the NPC isn't casting anymore!

FAI_IsCastingSpell(npcid, spellid)
  • Description: Checks if an NPC is casting a particular spell.
  • Parameters:
    • npcid: The ID of the NPC to check.
    • spellid: The ID of the spell to check.
  • Return values: (bool)
    • true: The NPC is casting the given spell.
    • false: An invalid npcid was given, or an invalid spellid was given, or the NPC is not casting, or the given spell is not the spell that is being cast.
  • Notes: When the NPC has finished casting, but the cast bar is still shown for the additional time, this function will return false! Use FAI_IsCastBarExtraForSpell instead.

FAI_IsCastBarExtra(npcid)
  • Description: Checks if an NPC is showing the cast bar for the additional time, regardless of the spell shown.
  • Parameters:
    • npcid: The ID of the NPC to check.
  • Return values: (bool)
    • true: The NPC is showing the cast bar for the additional time.
    • false: An invalid npcid was given, or an invalid spellid was given, or the cast bar is not showing for the additional time.
  • Notes: When the NPC is casting, this function will return false! Use FAI_IsCasting instead.

FAI_IsCastBarExtraForSpell(npcid, spellid)
  • Description: Checks if an NPC is showing the cast bar for the additional time and the spell shown is a particular spell.
  • Parameters:
    • npcid: The ID of the NPC to check.
    • spellid: The ID of the spell to check.
  • Return values: (bool)
    • true: The NPC is showing the cast bar for the additional time and the spell shown is the given spell.
    • false: An invalid npcid was given, or an invalid spellid was given, or the cast bar is not showing for the additional time, or the given spell is not the spell shown.
  • Notes: When the NPC is casting, this function will return false! Use FAI_IsCastingSpell instead.