From: Laszlo T. <ave...@us...> - 2010-09-08 16:51:39
|
gemrb: Infinity Engine emulator The branch master has been updated via ce47f11e3fc17895881da9d33690f595d5cafc20 (commit) Summary of changes: gemrb/GUIScripts/iwd2/GUICommonWindows.py | 1 - gemrb/core/GameScript/Actions.cpp | 21 +++++++++++++++++++-- gemrb/core/Spellbook.cpp | 25 +++++++++++++++++++++++++ gemrb/core/Spellbook.h | 3 +++ 4 files changed, 47 insertions(+), 3 deletions(-) from 6ad57a8fbd3202f1b398d2c61d954868ce39e299 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=ce47f11e3fc17895881da9d33690f595d5cafc20 commit ce47f11e3fc17895881da9d33690f595d5cafc20 Author: Avenger <ave...@so...> Date: Wed Sep 8 18:50:10 2010 +0200 fixed (and improved) RemoveSpell action Now it works as in original engine, but also has the previously assumed feature (removes spell or simply unmemorize it) diff --git a/gemrb/GUIScripts/iwd2/GUICommonWindows.py b/gemrb/GUIScripts/iwd2/GUICommonWindows.py index da2d31a..0ffb84f 100644 --- a/gemrb/GUIScripts/iwd2/GUICommonWindows.py +++ b/gemrb/GUIScripts/iwd2/GUICommonWindows.py @@ -322,7 +322,6 @@ def ActionUseItemPressed (): return def ActionCastPressed (): - print "CASRRE" GemRB.SetVar ("TopIndex", 0) GemRB.SetVar ("ActionLevel", 2) UpdateActionsWindow () diff --git a/gemrb/core/GameScript/Actions.cpp b/gemrb/core/GameScript/Actions.cpp index 15706a0..90cb068 100644 --- a/gemrb/core/GameScript/Actions.cpp +++ b/gemrb/core/GameScript/Actions.cpp @@ -5128,17 +5128,34 @@ void GameScript::AddSpecialAbility( Scriptable* Sender, Action* parameters) core->SetEventFlag(EF_ACTION); } +//actually this just depletes a spell, doesn't remove it from the book +//GemRB extension: the first/second int parameter can also make it removed +//from the spell memorization schedule (also from the spellbook) void GameScript::RemoveSpell( Scriptable* Sender, Action* parameters) { + ieResRef spellres; + int type; + if (Sender->Type!=ST_ACTOR) { return; } + if (!ResolveSpellName( spellres, parameters) ) { + return; + } Actor *actor = (Actor *) Sender; if (parameters->string0Parameter[0]) { - actor->spellbook.RemoveSpell(parameters->string0Parameter); + type = parameters->int1Parameter; + } else { + type = parameters->int0Parameter; + } + if (type==2) { + //remove spell from both book and memorization + actor->spellbook.RemoveSpell(spellres); return; } - actor->spellbook.RemoveSpell(parameters->int0Parameter); + //type == 1 remove spell only from memorization + //type == 0 original behaviour: deplete only + actor->spellbook.UnmemorizeSpell(spellres, type); } void GameScript::SetScriptName( Scriptable* Sender, Action* parameters) diff --git a/gemrb/core/Spellbook.cpp b/gemrb/core/Spellbook.cpp index 6451343..bf9c364 100644 --- a/gemrb/core/Spellbook.cpp +++ b/gemrb/core/Spellbook.cpp @@ -600,6 +600,31 @@ bool Spellbook::UnmemorizeSpell(CREMemorizedSpell* spell) return false; } +bool Spellbook::UnmemorizeSpell(const ieResRef ResRef, bool deplete) +{ + for (int type = 0; type<NUM_BOOK_TYPES; type++) { + std::vector< CRESpellMemorization* >::iterator sm; + for (sm = spells[type].begin(); sm != spells[type].end(); sm++) { + std::vector< CREMemorizedSpell* >::iterator s; + for (s = (*sm)->memorized_spells.begin(); s != (*sm)->memorized_spells.end(); s++) { + if (strnicmp(ResRef, (*s)->SpellResRef, sizeof(ieResRef) ) ) { + continue; + } + if (deplete) { + (*s)->Flags = 0; + } else { + delete *s; + (*sm)->memorized_spells.erase( s ); + } + ClearSpellInfo(); + return true; + } + } + } + + return false; +} + //bitfield disabling type: 1 - mage, 2 - cleric etc //level: if set, then finds that level only CREMemorizedSpell* Spellbook::FindUnchargedSpell(int type, int level) diff --git a/gemrb/core/Spellbook.h b/gemrb/core/Spellbook.h index 78ae688..f80d6ad 100644 --- a/gemrb/core/Spellbook.h +++ b/gemrb/core/Spellbook.h @@ -205,6 +205,9 @@ public: /** Removes memorized spell */ bool UnmemorizeSpell(CREMemorizedSpell* spl); + /** Removes (or just depletes) memorized spell by ResRef */ + bool UnmemorizeSpell(const char *resref, bool deplete); + /** finds the first spell needing to rememorize */ CREMemorizedSpell* FindUnchargedSpell(int type, int level=0); ----------------------------------------------------------------------- This is an automated email from the git hooks/post-receive script. -- gemrb: Infinity Engine emulator |