From: Jaka K. <lyn...@us...> - 2011-01-09 20:23:52
|
gemrb: Infinity Engine emulator The branch master has been updated via 355ca212b4366d45a9b4b5a796f2a23c7e8ca649 (commit) via 0c5a9d5f611a00703e1b6de4f272f24fcff364cc (commit) Summary of changes: gemrb/core/Scriptable/ActorBlock.cpp | 58 +++++++++++++++++++++++++++++----- gemrb/core/Scriptable/ActorBlock.h | 3 ++ gemrb/override/bg2/wildmag.2da | 2 +- 3 files changed, 54 insertions(+), 9 deletions(-) from f6dfbccc99ef1888271c22f6e6d3ed18101b4b33 (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=355ca212b4366d45a9b4b5a796f2a23c7e8ca649 commit 355ca212b4366d45a9b4b5a796f2a23c7e8ca649 Author: Jaka Kranjc <lyn...@us...> Date: Sun Jan 9 21:25:28 2011 +0100 added Scriptable::HandleHardcodedSurge and implemented two of the hardcoded surges: "random spell" and "apply some other spell first" diff --git a/gemrb/core/Scriptable/ActorBlock.cpp b/gemrb/core/Scriptable/ActorBlock.cpp index 18d5bf0..84aa518 100644 --- a/gemrb/core/Scriptable/ActorBlock.cpp +++ b/gemrb/core/Scriptable/ActorBlock.cpp @@ -964,20 +964,21 @@ int Scriptable::CheckWildSurge() if (check < 100) { // lookup the spell in the "check" row of wildmag.2da ieResRef surgeSpellRef; + memset(surgeSpellRef, 0, sizeof(surgeSpellRef)); strncpy(surgeSpellRef, core->SurgeSpells[check-1].spell, 8); Spell *surgeSpell = gamedata->GetSpell(surgeSpellRef); if (!surgeSpell) { - // TODO: handle the hardcoded cases - they'll also fail here - SpellHeader = -1; - SpellResRef[0] = 0; - printMessage("Scriptable", "New spell not found, aborting cast mid-surge!\n", LIGHT_RED); - caster->SetStance(IE_ANI_READY); - return 0; + // handle the hardcoded cases - they'll also fail here + if (!HandleHardcodedSurge(surgeSpellRef, spl, caster)) { + return 0; + } + } else { + // finally change the spell + // the hardcoded bunch does it on its own when needed + strncpy(SpellResRef, surgeSpellRef, 8); } - // finally change the spell - strncpy(SpellResRef, surgeSpellRef, 8); // display feedback: Wild Surge: bla bla char text[200]; snprintf(text, 200, "%s %s", core->GetString(displaymsg->GetStringReference(STR_WILDSURGE), 0), core->GetString(core->SurgeSpells[check-1].message, 0)); @@ -989,6 +990,47 @@ int Scriptable::CheckWildSurge() return 1; } +bool Scriptable::HandleHardcodedSurge(ieResRef surgeSpellRef, Spell *spl, Actor *caster) +{ + // format: ID or ID.param1 or +SPELLREF + int types = caster->spellbook.GetTypes(); + int lvl = spl->SpellLevel-1; + switch (surgeSpellRef[0]) { + case '7': // random spell of the same level (FIXME: make an effect out of this?) + // change this if we ever want the surges to respect the original type + for (int i=0; i<types; i++) { + unsigned int spellCount = caster->spellbook.GetKnownSpellsCount(i, lvl); + if (!spellCount) continue; + int id = core->Roll(1, spellCount, -1); + CREKnownSpell *ck = caster->spellbook.GetKnownSpell(i, lvl, id); + if (ck) { + strncpy(SpellResRef, ck->SpellResRef, 8); + break; + } + } + break; + case '+': // cast normally, but also cast SPELLREF first + core->ApplySpell(surgeSpellRef+1, caster, caster, caster->GetCasterLevel(spl->SpellType)); + break; + case '0': // cast spell param1 times + case '1': // change projectile (id) to param1 + case '2': // also target target type param1 + case '3': // (wild surge) roll param1 more times + case '4': // change the target type to param1 + case '5': // change the target to a random actor + case '6': // change saving throw (+param1) + case '8': // spell cast at (param1)x level + case '9': // set projectile speed to param1 % + default: + SpellHeader = -1; + SpellResRef[0] = 0; + printMessage("Scriptable", "New spell not found, aborting cast mid-surge!\n", LIGHT_RED); + caster->SetStance(IE_ANI_READY); + return false; + } + return true; +} + bool Scriptable::TimerActive(ieDword ID) { if (ID>=MAX_TIMER) { diff --git a/gemrb/core/Scriptable/ActorBlock.h b/gemrb/core/Scriptable/ActorBlock.h index fc59696..72945e8 100644 --- a/gemrb/core/Scriptable/ActorBlock.h +++ b/gemrb/core/Scriptable/ActorBlock.h @@ -26,6 +26,7 @@ #include "CharAnimations.h" #include "Inventory.h" #include "PathFinder.h" +#include "Spell.h" // for HandleHardcodedSurge (repeat the spell lookup if this header is unwanted) #include "Sprite2D.h" #include "TileOverlay.h" #include "Variables.h" @@ -283,6 +284,8 @@ private: int SpellCast(bool instant); /* also part of the spellcasting process, creating the projectile */ void CreateProjectile(const ieResRef SpellResRef, ieDword tgt, bool fake); + /* do some magic for the wierd/awesome wild surges */ + bool HandleHardcodedSurge(ieResRef surgeSpellRef, Spell *spl, Actor *caster); }; class GEM_EXPORT Selectable : public Scriptable { http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=0c5a9d5f611a00703e1b6de4f272f24fcff364cc commit 0c5a9d5f611a00703e1b6de4f272f24fcff364cc Author: Jaka Kranjc <lyn...@us...> Date: Sun Jan 9 21:23:53 2011 +0100 wildmag.2da: halvdur should apply to the original spell diff --git a/gemrb/override/bg2/wildmag.2da b/gemrb/override/bg2/wildmag.2da index 01bda8e..1528d02 100644 --- a/gemrb/override/bg2/wildmag.2da +++ b/gemrb/override/bg2/wildmag.2da @@ -56,7 +56,7 @@ 53 SPWM153 0x363 * 54 SPWM154 0x36a * 55 SPWM155 0x36b * -56 HALVDUR 0x36c duration_halved +56 +HALVDUR 0x36c duration_halved 57 SPWM157 0x36d * 58 9.50 0x36e projectile_speed_halved 59 SPWM159 0x37a * ----------------------------------------------------------------------- This is an automated email from the git hooks/post-receive script. -- gemrb: Infinity Engine emulator |