Skip to content

Get spell names (not IDs)

Hi. Is there any way to get spell names when object casts them?
I build function which can get IDs but how to convert it to log the name of spell ?

Comments

  • its_a_fireits_a_fire Member Posts: 4
    By using the the ID integer to find the right row on spells.2da then grabbing the "Labels" column value for that spell.
  • DeviC3DeviC3 Member Posts: 25
    edited December 2018
    I've match spells from that source https://nwnlexicon.com/index.php?title=Spell_(constant_group)
    But how to get this labels to log file ? Or convert ID numbers to strings
  • its_a_fireits_a_fire Member Posts: 4
    edited December 2018
    If you're using this in a log for developers/admins to consult, converting the spell ID integer into a string with IntToString() would be the simplest solution.

    If the log needs to be more human-readable, a function like this - which I'm posting untested - will get the label from the 2DA for a given spell.

    (deleted - see better code from Daz below!)
    Post edited by its_a_fire on
  • DazDaz Member Posts: 125
    You can just do the following since the SPELL_* constants are the same as their row in spells.2da
    string sSpellLabel = Get2DAString("spells", "Label", GetSpellId());
    Or if you want to be fancy you can get the name from the tlk table like this:
    string sSpellName = GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", GetSpellId())));
  • DeviC3DeviC3 Member Posts: 25
    It works...what a shame, I really forgot about this function.
    string LogSpellCasted = Get2DAString("spells", "Label", GetSpellId());
    Thanks, and cheers guys!
Sign In or Register to comment.