Advertisement
Terrah

nwnx_magic

Sep 13th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 11.18 KB | None | 0 0
  1. //Unpacks a string into special abilities
  2. //The formatting should be "Spell Ready Level\n"
  3. //IE: 0 1 15 (acid cloud, ready, level 15)
  4. int NWNX_Magic_UnpackSpecialAbilityString( object oCreature, string sData );
  5.  
  6. //Packs the spelllike ability list of oCreature
  7. //The string is formatted as "Spell Ready Level\n"
  8. //And can be directly used with NWNX_Magic_UnpackSpecialAbilityString
  9. string NWNX_Magic_PackSpecialAbilityString( object oCreature );
  10.  
  11. //Returns the spell-like ability from nIndex
  12. //The string is formatted as "Spell Ready Level"
  13. //Returns an empty string on failure
  14. string NWNX_Magic_GetSpellLikeAbility( object oCreature, int nIndex );
  15.  
  16. //Get the length of the spell-like ability array
  17. int NWNX_Magic_GetSpellLikeLength( object oCreature );
  18.  
  19. //Removes the data located in nIndex
  20. //Returns true/false
  21. int NWNX_Magic_RemoveSpellLikeAbility( object oCreature, int nIndex );
  22.  
  23. //Adds a memorized spell to oCreature
  24. //This will create additional spellslots if neasesary
  25. //Use with caution
  26. //Formatting: "classindex spelllevel spellid ready metamagic domain"
  27. //Class index should be 0, 1 or 2
  28. int NWNX_Magic_AddMemorizedSpell( object oCreature, string sData );
  29.  
  30. //Modify the amount of spellslots avaiable for oCreature
  31. //This function only covers memorization spell-slots
  32. //If nSpellslots = -1 the function will return the number of spellslots available instead
  33. int NWNX_Magic_SetNumberOfSpellslots( object oCreature, int nClassIndex, int nSpellLevel, int nSpellSlots );
  34.  
  35. //This modifies spells per day data (relevant for sorcs etc)
  36. //nClassIndex must be 0-2
  37. //nType: 0=bonus spells 1=spells left 2=spells max
  38. //if nSpells is -1 the function will return the current number
  39. int NWNX_Magic_ModifySpellsPerDay( object oCreature, int nClassIndex, int nSpellLevel, int nType, int nSpells );
  40.  
  41. //Sets a memorized spell to oCreature
  42. //This will create additional spellslots if neasesary
  43. //Use with caution
  44. //Formatting: "classindex spelllevel spellslots spellid ready metamagic domain"
  45. //Class index should be 0, 1 or 2
  46. //If spellid, ready, metamagic, domain is 0 the spellslot will be removed (unmemorized)
  47. int NWNX_Magic_SetMemorizedSpell( object oCreature, string sData );
  48.  
  49. //Get memorized spelldata from oCreature
  50. //nClass has to be within 0-2 range
  51. //returns "spellid ready metamagic domain"
  52. //returns "0 0 0 0" if the slot is empty
  53. string NWNX_Magic_GetMemorizedSpell( object oCreature, int nClass, int nSpellLevel, int nSlot );
  54.  
  55. //Packs a spellevel into a string
  56. //nClassIndex must be between 0-2
  57. string NWNX_Magic_PackSpellLevelIntoString( object oCreature, int nClassIndex, int nSpellLevel );
  58.  
  59. //Unpacks a spellevel from a string unto oCreature
  60. //This does not add spellslots if they're missing
  61. //Returns the number of spells unpacked
  62. //nClassIndex must be between 0-2
  63. int NWNX_Magic_UnPackSpellLevelString( object oCreature, int nClassIndex, int nSpellLevel, string sData );
  64.  
  65. //Removes all memorized spells from nSpellLevel
  66. //nClassIndex must be between 0-2
  67. //if nSetSpellsUnReady = 1 the spells are kept, but set to un-ready (used up)
  68. void NWNX_Magic_EmptySpellLevel( object oCreature, int nClassIndex, int nSpellLevel, int nSetSpellsUnReady );
  69.  
  70. //Adds a known spell to oCreature at nSpellevel
  71. //ClassIndex must be between 0-2
  72. void NWNX_Magic_AddKnownSpell( object oCreature, int nClassIndex, int nSpellLevel, int nSpellToAdd );
  73.  
  74. //Get a known spell from oCreature
  75. //classindex must be between 0-2
  76. //returns -1 if there is no known spell in nIndex (end of the array)
  77. int NWNX_Magic_GetKnownSpell( object oCreature, int nClassIndex, int nSpellLevel, int nIndex );
  78.  
  79. //Attempts to remove a known spell from oCreature
  80. //classindex must be between 0-2
  81. //Returns true/false depending on success
  82. int NWNX_Magic_RemoveKnownSpell( object oCreature, int nClassIndex, int nSpellLevel, int nSpell );
  83.  
  84. int NWNX_Magic_RemoveKnownSpell( object oCreature, int nClassIndex, int nSpellLevel, int nSpell ){
  85.  
  86.     SetLocalString( oCreature, "NWNX!MAGIC!RemoveKnownSpell", IntToString( nClassIndex )+" "+IntToString( nSpellLevel )+" "+IntToString( nSpell ) );
  87.     int nRet = StringToInt( GetLocalString( oCreature, "NWNX!MAGIC!RemoveKnownSpell" ) );
  88.     DeleteLocalString( oCreature, "NWNX!MAGIC!RemoveKnownSpell" );
  89.     return nRet;
  90. }
  91.  
  92. int NWNX_Magic_GetKnownSpell( object oCreature, int nClassIndex, int nSpellLevel, int nIndex ){
  93.  
  94.     SetLocalString( oCreature, "NWNX!MAGIC!GetKnownSpell", IntToString( nClassIndex )+" "+IntToString( nSpellLevel )+" "+IntToString( nIndex ) );
  95.     int nRet = StringToInt( GetLocalString( oCreature, "NWNX!MAGIC!GetKnownSpell" ) );
  96.     DeleteLocalString( oCreature, "NWNX!MAGIC!GetKnownSpell" );
  97.     return nRet;
  98. }
  99.  
  100. void NWNX_Magic_AddKnownSpell( object oCreature, int nClassIndex, int nSpellLevel, int nSpellToAdd ){
  101.  
  102.     SetLocalString( oCreature, "NWNX!MAGIC!AddKnownSpell", IntToString( nClassIndex )+" "+IntToString( nSpellLevel )+" "+IntToString( nSpellToAdd ) );
  103.     DeleteLocalString( oCreature, "NWNX!MAGIC!AddKnownSpell" );
  104. }
  105.  
  106. void NWNX_Magic_EmptySpellLevel( object oCreature, int nClassIndex, int nSpellLevel, int nSetSpellsUnReady ){
  107.  
  108.     SetLocalString( oCreature, "NWNX!MAGIC!EmptySpellBook", IntToString( nClassIndex )+" "+IntToString( nSpellLevel )+" "+IntToString( nSetSpellsUnReady ) );
  109.     DeleteLocalString( oCreature, "NWNX!MAGIC!EmptySpellBook" );
  110. }
  111.  
  112. int NWNX_Magic_UnPackSpellLevelString( object oCreature, int nClassIndex, int nSpellLevel, string sData ){
  113.  
  114.     if( GetObjectType( oCreature ) != OBJECT_TYPE_CREATURE )
  115.         return -1;
  116.  
  117.     SetLocalString( oCreature, "NWNX!MAGIC!UnPackSpellLevelString", IntToString( nClassIndex )+" "+IntToString( nSpellLevel )+" "+sData );
  118.     int nRet = StringToInt( GetLocalString( oCreature, "NWNX!MAGIC!UnPackSpellLevelString" ) );
  119.     DeleteLocalString( oCreature, "NWNX!MAGIC!UnPackSpellLevelString" );
  120.     return nRet;
  121. }
  122.  
  123. string NWNX_Magic_PackSpellLevelIntoString( object oCreature, int nClassIndex, int nSpellLevel ){
  124.  
  125.     if( GetObjectType( oCreature ) != OBJECT_TYPE_CREATURE )
  126.         return "";
  127.  
  128.     //16*32 memoryspace
  129.     string sString;
  130.     int n;
  131.     for( n=0;n<32;n++ ){
  132.         sString+="                ";
  133.     }
  134.  
  135.     SetLocalString( oCreature, "NWNX!MAGIC!PackSpellLevelIntoString", IntToString( nClassIndex )+" "+IntToString( nSpellLevel )+"~"+sString );
  136.     string nRet = GetLocalString( oCreature, "NWNX!MAGIC!PackSpellLevelIntoString" );
  137.     DeleteLocalString( oCreature, "NWNX!MAGIC!PackSpellLevelIntoString" );
  138.     return nRet;
  139. }
  140.  
  141. string NWNX_Magic_GetMemorizedSpell( object oCreature, int nClass, int nSpellLevel, int nSlot ){
  142.  
  143.     if( GetObjectType( oCreature ) != OBJECT_TYPE_CREATURE )
  144.         return "";
  145.  
  146.     SetLocalString( oCreature, "NWNX!MAGIC!GetMemorizedSpell", IntToString( nClass )+" "+IntToString( nSpellLevel )+" "+IntToString( nSlot )+"~                                  " );
  147.     string nRet = GetLocalString( oCreature, "NWNX!MAGIC!GetMemorizedSpell" );
  148.     DeleteLocalString( oCreature, "NWNX!MAGIC!GetMemorizedSpell" );
  149.     return nRet;
  150. }
  151.  
  152. int NWNX_Magic_ModifySpellsPerDay( object oCreature, int nClassIndex, int nSpellLevel, int nType, int nSpells ){
  153.  
  154.     if( GetObjectType( oCreature ) != OBJECT_TYPE_CREATURE )
  155.         return 0;
  156.  
  157.     SetLocalString( oCreature, "NWNX!MAGIC!ModifySpellsPerDay", IntToString( nClassIndex )+" "+IntToString( nSpellLevel )+" "+IntToString( nType )+" "+IntToString( nSpells ) );
  158.     int nRet = StringToInt( GetLocalString( oCreature, "NWNX!MAGIC!ModifySpellsPerDay" ) );
  159.     DeleteLocalString( oCreature, "NWNX!MAGIC!ModifySpellsPerDay" );
  160.     return nRet;
  161. }
  162.  
  163. int NWNX_Magic_SetNumberOfSpellslots( object oCreature, int nClassIndex, int nSpellLevel, int nSpellSlots ){
  164.  
  165.     if( GetObjectType( oCreature ) != OBJECT_TYPE_CREATURE )
  166.         return 0;
  167.  
  168.     SetLocalString( oCreature, "NWNX!MAGIC!SetNumberOfSpellslots", IntToString( nClassIndex )+" "+IntToString( nSpellLevel )+" "+IntToString( nSpellSlots ) );
  169.     int nRet = StringToInt( GetLocalString( oCreature, "NWNX!MAGIC!SetNumberOfSpellslots" ) );
  170.     DeleteLocalString( oCreature, "NWNX!MAGIC!SetNumberOfSpellslots" );
  171.     return nRet;
  172. }
  173.  
  174. int NWNX_Magic_SetMemorizedSpell( object oCreature, string sData ){
  175.  
  176.     if( GetObjectType( oCreature ) != OBJECT_TYPE_CREATURE )
  177.         return 0;
  178.  
  179.     SetLocalString( oCreature, "NWNX!MAGIC!AddMemorizedSpell", sData );
  180.     int nRet = StringToInt( GetLocalString( oCreature, "NWNX!MAGIC!AddMemorizedSpell" ) );
  181.     DeleteLocalString( oCreature, "NWNX!MAGIC!AddMemorizedSpell" );
  182.     return nRet;
  183. }
  184.  
  185. int NWNX_Magic_AddMemorizedSpell( object oCreature, string sData ){
  186.  
  187.     if( GetObjectType( oCreature ) != OBJECT_TYPE_CREATURE )
  188.         return 0;
  189.  
  190.     SetLocalString( oCreature, "NWNX!MAGIC!AddMemorizedSpell", sData );
  191.     int nRet = StringToInt( GetLocalString( oCreature, "NWNX!MAGIC!AddMemorizedSpell" ) );
  192.     DeleteLocalString( oCreature, "NWNX!MAGIC!AddMemorizedSpell" );
  193.     return nRet;
  194. }
  195.  
  196. int NWNX_Magic_GetSpellLikeLength( object oCreature ){
  197.  
  198.     if( GetObjectType( oCreature ) != OBJECT_TYPE_CREATURE )
  199.         return 0;
  200.  
  201.     SetLocalString( oCreature, "NWNX!MAGIC!GetSpellLikeLength", "~        " );
  202.     int nRet = StringToInt( GetLocalString( oCreature, "NWNX!MAGIC!GetSpellLikeLength" ) );
  203.     DeleteLocalString( oCreature, "NWNX!MAGIC!GetSpellLikeLength" );
  204.     return nRet;
  205. }
  206.  
  207. int NWNX_Magic_UnpackSpecialAbilityString( object oCreature, string sData ){
  208.  
  209.     if( GetObjectType( oCreature ) != OBJECT_TYPE_CREATURE )
  210.         return -1;
  211.  
  212.     SetLocalString( oCreature, "NWNX!MAGIC!AddSpellLikeAbility", sData );
  213.     int nRet = StringToInt( GetLocalString( oCreature, "NWNX!MAGIC!AddSpellLikeAbility" ) );
  214.     DeleteLocalString( oCreature, "NWNX!MAGIC!AddSpellLikeAbility" );
  215.     return nRet;
  216. }
  217.  
  218. string NWNX_Magic_PackSpecialAbilityString( object oCreature ){
  219.  
  220.     if( GetObjectType( oCreature ) != OBJECT_TYPE_CREATURE )
  221.         return "";
  222.  
  223.     //16*32 memoryspace
  224.     string sString;
  225.     int n;
  226.     for( n=0;n<32;n++ ){
  227.         sString+="                ";
  228.     }
  229.  
  230.     SetLocalString( oCreature, "NWNX!MAGIC!PackSpellLikeAbilities", "~"+sString );
  231.     string nRet = GetLocalString( oCreature, "NWNX!MAGIC!PackSpellLikeAbilities" );
  232.     DeleteLocalString( oCreature, "NWNX!MAGIC!PackSpellLikeAbilities" );
  233.     return nRet;
  234. }
  235.  
  236. string NWNX_Magic_GetSpellLikeAbility( object oCreature, int nIndex ){
  237.  
  238.     if( GetObjectType( oCreature ) != OBJECT_TYPE_CREATURE )
  239.  
  240.         return "";
  241.     //16*2 memoryspace
  242.     string sString;
  243.     int n;
  244.     for( n=0;n<2;n++ ){
  245.         sString+="                ";
  246.     }
  247.  
  248.     SetLocalString( oCreature, "NWNX!MAGIC!GetSpellLikeAbility", IntToString( nIndex )+"~"+sString );
  249.     string nRet = GetLocalString( oCreature, "NWNX!MAGIC!GetSpellLikeAbility" );
  250.     DeleteLocalString( oCreature, "NWNX!MAGIC!GetSpellLikeAbility" );
  251.     return nRet;
  252. }
  253.  
  254. int NWNX_Magic_RemoveSpellLikeAbility( object oCreature, int nIndex ){
  255.  
  256.     if( GetObjectType( oCreature ) != OBJECT_TYPE_CREATURE )
  257.         return -1;
  258.  
  259.     SetLocalString( oCreature, "NWNX!MAGIC!RemoveSpellLikeAbility", IntToString( nIndex ) );
  260.     int nRet = StringToInt( GetLocalString( oCreature, "NWNX!MAGIC!RemoveSpellLikeAbility" ) );
  261.     DeleteLocalString( oCreature, "NWNX!MAGIC!RemoveSpellLikeAbility" );
  262.     return nRet;
  263. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement