Spell functions - WoutProvost/FCNPC-AI GitHub Wiki

HomeFunctionsSpell functions

FAI_CreateSpell(name[])

FAI_GetSpellName(spellid, name[], len)
  • Description: Get a spell's name.
  • Parameters:
    • spellid: The ID of the spell to get the name of.
    • name[]: An array into which to store the name, passed by reference.
    • len: The length of the string that should be stored. Recommended to be FAI_MAX_SPELL_NAME.
  • Return values:
    • Name length: The function executed successfully.
    • -1: The function failed to execute. An invalid spellid was given.

FAI_SetSpellName(spellid, name[])
  • Description: Set a spell's name which is displayed in a TextDraw 6.
  • Parameters:
    • spellid: The ID of the spell to set the name of.
    • name[]: The name to set. Max length is FAI_MAX_SPELL_NAME.
  • Return values:
    • 1: The function executed successfully.
    • 0: The function failed to execute. An invalid spellid was given, or the given name was "" (an empty string).

FAI_GetSpellCastTime(spellid)
  • Description: Get a spell's castTime.
  • Parameters:
    • spellid: The ID of the spell to get the castTime of.
  • Return values:
    • CastTime > 0: The function executed successfully. The spell is not instant.
    • CastTime == 0: The function executed successfully. The spell is instant.
    • -1: The function failed to execute. An invalid spellid was given.

FAI_SetSpellCastTime(spellid, castTime, bool:keepCastPercent)
  • Description: Set a spell's castTime which is displayed in a TextDraw 7.
  • Parameters:
    • spellid: The ID of the spell to set the castTime of.
    • castTime: The castTime to set. If a value < 0 was given, it will be reset to 0. If the value is 0, the spell will be instant and FAI_OnStopCasting gets called immediately with castComplete true.
    • bool:keepCastPercent: Should any NPC that is casting this spell his castProgress be adapted? Defaults to false.
      • true: This will update any NPC that is casting this spell his castProgress as well so that the NPC keeps the same cast percentage. For example: castTime 500, castProgress 200, percent is 0.4 ➔ castTime set to 1000, castProgress will change to 400, percent is still 0.4.
      • false:
        1. Value > castProgress: This will not change the NPC's castProgress. For example: castTime 500, castProgress 200, percent is 0.4 ➔ castTime set to 1000, castProgress is still 200, percent is now 0.2.
        2. Value <= castProgress: This will as well lower the NPC's castProgress to be equal to the value given, because an NPC can't have more castProgress than castTime. For example: castTime 500, castProgress 200, percent is 0.4 ➔ castTime set to 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 castTime was 0 (instant).
  • Return values:
    • 1: The function executed successfully.
    • 0: The function failed to execute. An invalid spellid was given.

FAI_GetSpellAmount(spellid, &Float:amount)
  • Description: Get a spell's amount.
  • Parameters:
    • spellid: The ID of the spell to get the amount of.
    • &Float:amount: The variable into which to store the amount, passed by reference.
  • Return values:
    • 1: The function executed successfully.
    • 0: The function failed to execute. An invalid spellid was given.

FAI_SetSpellAmount(spellid, Float:amount)
  • Description: Set a spell's amount.
  • Parameters:
    • spellid: The ID of the spell to set the amount of.
    • Float:amount: The amount to set. If a value < 0.0 was given, it will be reset to 0.0.
  • Return values:
    • 1: The function executed successfully.
    • 0: The function failed to execute. An invalid spellid was given.

FAI_GetSpellCastBarColorDark(spellid)
  • Description: Get a spell's castBarColorDark.
  • Parameters:
    • spellid: The ID of the spell to get the castBarColorDark of.
  • Return values:
    • Valid color: The function executed successfully.
    • -1: The function failed to execute. An invalid spellid was given.

FAI_SetSpellCastBarColorDark(spellid, color)
  • Description: Set a spell's background color which is displayed in a TextDraw 4.
  • Parameters:
    • spellid: The ID of the spell to set the castBarColorDark of.
    • color: The castBarColorDark to set.
  • Return values:
    • 1: The function executed successfully.
    • 0: The function failed to execute. An invalid spellid was given.

FAI_GetSpellCastBarColorLight(spellid)
  • Description: Get a spell's castBarColorLight.
  • Parameters:
    • spellid: The ID of the spell to get the castBarColorLight of.
  • Return values:
    • Valid color: The function executed successfully.
    • -1: The function failed to execute. An invalid spellid was given.

FAI_SetSpellCastBarColorLight(spellid, color)
  • Description: Set a spell's foreground color which is displayed in a TextDraw 5.
  • Parameters:
    • spellid: The ID of the spell to set the castBarColorLight of.
    • color: The castBarColorLight to set.
  • Return values:
    • 1: The function executed successfully.
    • 0: The function failed to execute. An invalid spellid was given.

FAI_GetSpellCastBarInverted(spellid)
  • Description: Get a spell's castBarInverted.
  • Parameters:
    • spellid: The ID of the spell to get the castBarInverted of.
  • Return values: (bool)
    • true: CastBarInverted is true.
    • false: CastBarInverted is false, or an invalid spellid was given.

FAI_SetSpellCastBarInverted(spellid, bool:inverted, bool:invertProgressMade)
  • Description: Set wether the spell's cast bar TextDraw 5 should go from full to empty, instead of the normal empty to full.
  • Parameters:
    • spellid: The ID of the spell to set the castBarInverted of.
    • bool:inverted: True to invert the TextDraw, false to do not.
    • bool:invertProgressMade: Should the NPC's current castProgress be inverted as well? Defaults to false.
      • true: This will update any NPC that is casting this spell his castProgress as well so that the bar remains in position. For example: castTime 500, castProgress 450, not inverted ➔ invert, castProgress will change to 50, bar remains in position.
      • false: This will not update any NPC that is casting this spell his castProgress so that the bar inverts from big to small or vice versa. For example: castTime 500, castProgress 450, not inverted ➔ invert, castProgress will stay 450, bar flips from big to small.
  • Return values:
    • 1: The function executed successfully.
    • 0: The function failed to execute. An invalid spellid was given.
  • Notes: If invertProgressMade is true, but the cast bar was already inverted, the progress will not be changed.

FAI_GetSpellCastTimeInverted(spellid)
  • Description: Get a spell's castTimeInverted.
  • Parameters:
    • spellid: The ID of the spell to get the castTimeInverted of.
  • Return values: (bool)
    • true: CastTimeInverted is true.
    • false: CastTimeInverted is false, or an invalid spellid was given.

FAI_SetSpellCastTimeInverted(spellid, bool:inverted, bool:invertProgressMade)
  • Description: Set wether the spell's cast bar TextDraw 7 should go from castTime to 0, instead of the normal 0 to castTime.
  • Parameters:
    • spellid: The ID of the spell to set the castTimeInverted of.
    • bool:inverted: True to invert the TextDraw, false to do not.
    • bool:invertProgressMade: Should the NPC's current castProgress be inverted as well? Defaults to false.
      • true: This will update any NPC that is casting this spell his castProgress as well so that the displayed castTime remains equal. For example: castTime 500, castProgress 450, not inverted ➔ invert, castProgress will change to 50, castTime remains equal.
      • false: This will not update any NPC that is casting this spell his castProgress so that the displayed castTime inverts from big to small or vice versa. For example: castTime 500, castProgress 450, not inverted ➔ invert, castProgress will stay 450, displayed castTime flips from big to small.
  • Return values:
    • 1: The function executed successfully.
    • 0: The function failed to execute. An invalid spellid was given.
  • Notes: If invertProgressMade is true, but the cast time was already inverted, the progress will not be changed.

FAI_GetSpellCanMove(spellid)
  • Description: Get a spell's canMove.
  • Parameters:
    • spellid: The ID of the spell to get the canMove of.
  • Return values: (bool)
    • true: CanMove is true.
    • false: CanMove is false, or an invalid spellid was given.

FAI_SetSpellCanMove(spellid, bool:canMove)
  • Description: Set wether an NPC can move while he is casting the spell.
  • Parameters:
    • spellid: The ID of the spell to set the canMove of.
    • bool:canMove: True if the NPC can move while casting, false to do not.
  • Return values:
    • 1: The function executed successfully.
    • 0: The function failed to execute. An invalid spellid was given.

FAI_GetSpellCanAttack(spellid)
  • Description: Get a spell's canAttack.
  • Parameters:
    • spellid: The ID of the spell to get the canAttack of.
  • Return values: (bool)
    • true: CanAttack is true.
    • false: CanAttack is false, or an invalid spellid was given.

FAI_SetSpellCanAttack(spellid, bool:canAttack)
  • Description: Set wether an NPC can attack while he is casting the spell.
  • Parameters:
    • spellid: The ID of the spell to set the canAttack of.
    • bool:canAttack: True if the NPC can attack while casting, false to do not.
  • Return values:
    • 1: The function executed successfully.
    • 0: The function failed to execute. An invalid spellid was given.

FAI_GetSpellInfo(spellid, info[], len)
  • Description: Get a spell's info.
  • Parameters:
    • spellid: The ID of the spell to get the info of.
    • info[]: An array into which to store the info, passed by reference.
    • len: The length of the string that should be stored. Recommended to be FAI_MAX_SPELL_INFO.
  • Return values:
    • Info length: The function executed successfully.
    • -1: The function failed to execute. An invalid spellid was given.

FAI_SetSpellInfo(spellid, info[])
  • Description: Set a spell's info.
  • Parameters:
    • spellid: The ID of the spell to set the info of.
    • info[]: The info to set. Max length is FAI_MAX_SPELL_INFO. If "" (an empty string) is given, the system will generate a spellInfo based on the other spell settings.
  • Return values:
    • 1: The function executed successfully.
    • 0: The function failed to execute. An invalid spellid was given.

FAI_DestroySpell(spellid)
  • Description: Destroys a spell that was created using one of the FAI_CreateSpell functions.
  • Parameters:
    • spellid: The ID of the spell to destroy.
  • Return values:
    • 1: The function executed successfully.
    • 0: The function failed to execute. An invalid spellid was given.

FAI_DestroyAllSpells()
  • Description: Destroys all spells that were created using one of the FAI_CreateSpell functions. This function gets executed automatically when OnFilterScriptExit is called, if the include is included in a filterscript, or when OnGameModeExit is called, if the include is included in a gamemode.
  • Parameters: This function has no parameters.
  • Return values: This function always returns 1.

FAI_IsValidSpell(spellid)
  • Description: Checks if a spell is created.
  • Parameters:
    • spellid: The ID of the spell to check.
  • Return values: (bool)
    • true: The spell is created.
    • false: The spell is not created, or a spellid < 0 was given, or a spellid > = FAI_MAX_SPELLS was given.

FAI_SpellToString(spellid, string[], len, bool:allowDefaultColors)
  • Description: Get a spell's name + info.
  • Parameters:
    • spellid: The ID of the spell to get the name + info of.
    • string[]: An array into which to store the name + info, passed by reference.
    • len: The length of the string that should be stored. Recommended to be FAI_MAX_SPELL_NAME + FAI_MAX_SPELL_INFO + 15.
    • bool:allowDefaultColors: Should the string be colored with the system default colors? Defaults to true. The spell name will have color 0xffffffff and the spell info will have color 0xffd517ff.
  • Return values:
    • String length: The function executed successfully.
    • -1: The function failed to execute. An invalid spellid was given.