int Spellbook::LearnSpell(Spell *spell, int memo) { CREKnownSpell *spl = new CREKnownSpell(); strncpy(spl->SpellResRef, spell->Name, 8); spl->Type = (ieWord) GetSpellType(spell->SpellType); if ( spl->Type == IE_SPELL_TYPE_INNATE) { spl->Level = 0; } else { spl->Level = (ieWord) (spell->SpellLevel-1); } bool ret=AddKnownSpell(spl, memo); if (!ret) { delete spl; } return spell->SpellLevel; // return only the spell level (xp is based on xpbonus) }
char* CNWNXMagic::OnRequest(char *gameObject, char* Request, char* Parameters){ for( unsigned int n=0; n<strlen( Parameters );n++ ){ if( Parameters[n]=='~' ) Parameters[n]='\0'; } Log( "o %s( %08X: %s )\n", Request, ((CNWSCreature*)gameObject)->obj.obj_generic.obj_id, Parameters ); if( strcmp( Request, "AddSpellLikeAbility" ) == 0 ){ sprintf( Parameters, "%i", AddSpellLikeAbility( (CNWSCreature*)gameObject, Parameters ) ); } else if( strcmp( Request, "GetSpellLikeAbility" ) == 0 ){ GetSpellLikeAbility( (CNWSCreature*)gameObject, Parameters ); } else if( strcmp( Request, "RemoveSpellLikeAbility" ) == 0 ){ RemoveSpellLikeAbility( (CNWSCreature*)gameObject, Parameters ); } else if( strcmp( Request, "PackSpellLikeAbilities" ) == 0 ){ PackSpellLikeAbilities( (CNWSCreature*)gameObject, Parameters ); } else if( strcmp( Request, "AddMemorizedSpell" ) == 0 ){ AddMemorizedSpell( (CNWSCreature*)gameObject, Parameters ); } else if( strcmp( Request, "SetMemorizedSpell" ) == 0 ){ SetMemorizedSpell( (CNWSCreature*)gameObject, Parameters ); } else if( strcmp( Request, "SetNumberOfSpellslots" ) == 0 ){ SetNumberOfSpellslots( (CNWSCreature*)gameObject, Parameters ); } else if( strcmp( Request, "GetSpellLikeLength" ) == 0 ){ NWNXSpecialAbilities * Repository = (NWNXSpecialAbilities*)((CNWSCreature*)gameObject)->cre_stats->cs_specabil; if( Repository == NULL ) strcpy( Parameters, "0" ); else sprintf( Parameters, "%i", Repository->Len ); } else if( strcmp( Request, "GetMemorizedSpell" ) == 0 ){ GetMemorizedSpell( (CNWSCreature*)gameObject, Parameters ); } else if( strcmp( Request, "ModifySpellsPerDay" ) == 0 ){ ModifySpellsPerDay( (CNWSCreature*)gameObject, Parameters ); } else if( strcmp( Request, "PackSpellLevelIntoString" ) == 0 ){ PackSpellLevelIntoString( (CNWSCreature*)gameObject, Parameters ); } else if( strcmp( Request, "UnPackSpellLevelString" ) == 0 ){ UnPackSpellLevelString( (CNWSCreature*)gameObject, Parameters ); } else if( strcmp( Request, "EmptySpellBook" ) == 0 ){ EmptySpellBook( (CNWSCreature*)gameObject, Parameters ); } else if( strcmp( Request, "AddKnownSpell" ) == 0 ){ AddKnownSpell( (CNWSCreature*)gameObject, Parameters ); } else if( strcmp( Request, "GetKnownSpell" ) == 0 ){ sprintf( Parameters, "%i", GetKnownSpell( (CNWSCreature*)gameObject, Parameters ) ); } else if( strcmp( Request, "RemoveKnownSpell" ) == 0 ){ sprintf( Parameters, "%i", RemoveKnownSpell( (CNWSCreature*)gameObject, Parameters ) ); } else if( strcmp( Request, "DumpSpells" ) == 0 ){ DumpSpellData( (CNWSCreature*)gameObject ); } return NULL; }