From: Jaka K. <lyn...@us...> - 2010-05-12 14:45:52
|
gemrb: Infinity Engine emulator The branch master has been updated via 53c982a0e9ebe23ca117de290f5977879dc6b22a (commit) Summary of changes: gemrb/core/Actions.cpp | 56 +------------------------------- gemrb/core/Actor.cpp | 83 ++++++++++++++++++++++++++++++++++++++++++++++- gemrb/core/Actor.h | 4 ++ 3 files changed, 87 insertions(+), 56 deletions(-) from 37e5f81b72659018dc87f554e19262d7258f6f08 (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=53c982a0e9ebe23ca117de290f5977879dc6b22a commit 53c982a0e9ebe23ca117de290f5977879dc6b22a Author: Jaka Kranjc <lyn...@us...> Date: Wed May 12 15:30:05 2010 +0200 do a skill check before (re)applying the modal effect and display the failed attempt message on failure diff --git a/gemrb/core/Actions.cpp b/gemrb/core/Actions.cpp index c81f81e..e133976 100644 --- a/gemrb/core/Actions.cpp +++ b/gemrb/core/Actions.cpp @@ -5350,19 +5350,6 @@ void GameScript::FindTraps(Scriptable* Sender, Action* /*parameters*/) actor->SetModal( MS_DETECTTRAPS); } -static EffectRef fx_disable_button_ref={ "DisableButton", NULL, -1 }; - -inline void HideFailed(Actor* actor) -{ - actor->SetModal(MS_NONE); - - Effect *newfx; - newfx = EffectQueue::CreateEffect(fx_disable_button_ref, 0, ACT_STEALTH, FX_DURATION_INSTANT_LIMITED); - newfx->Duration = 6; // 90 ticks, 1 round - core->ApplyEffect(newfx, actor, actor); - delete newfx; -} - void GameScript::Hide(Scriptable* Sender, Action* /*parameters*/) { if (Sender->Type!=ST_ACTOR) { @@ -5370,48 +5357,9 @@ void GameScript::Hide(Scriptable* Sender, Action* /*parameters*/) } Actor *actor = (Actor *) Sender; - ieDword roll = actor->LuckyRoll(1, 100, 0); - if (roll == 1) { - HideFailed(actor); - return; - } - - // check for disabled dualclassed thieves (not sure if we need it) - - if (actor->Modified[IE_DISABLEDBUTTON] & (1<<ACT_STEALTH)) { - HideFailed(actor); - return; - } - - // check if the pc is in combat (seen / heard) - Game *game = core->GetGame(); - if (game->PCInCombat(actor)) { - HideFailed(actor); - return; - } - - ieDword skill; - if (core->HasFeature(GF_HAS_HIDE_IN_SHADOWS)) { - skill = (actor->GetStat(IE_HIDEINSHADOWS) + actor->GetStat(IE_STEALTH))/2; - } else { - skill = actor->GetStat(IE_STEALTH); - } - - // check how bright our spot is - ieDword lightness = game->GetCurrentArea()->GetLightLevel(actor->Pos); - // seems to be the color overlay at midnight; lightness of a point with rgb (200, 100, 100) - // TODO: but our NightTint computes to a higher value, which one is bad? - ieDword ref_lightness = 43; - ieDword light_diff = int((lightness - ref_lightness) * 100 / (100 - ref_lightness)) / 2; - ieDword chance = (100 - light_diff) * skill/100; - - if (roll > chance) { - HideFailed(actor); - return; + if (actor->TryToHide()) { + actor->SetModal(MS_STEALTH); } - - actor->SetModal( MS_STEALTH); - //TODO: expiry isn't instant (skill based transition?) } diff --git a/gemrb/core/Actor.cpp b/gemrb/core/Actor.cpp index 72adf26..3f4b9fe 100644 --- a/gemrb/core/Actor.cpp +++ b/gemrb/core/Actor.cpp @@ -3595,7 +3595,6 @@ void Actor::SetModal(ieDword newstate, bool force) ModalState = MS_NONE; } else { ModalState = newstate; - core->DisplayStringName(core->ModalStates[ModalState].entering_str, 0xffffff, this, IE_STR_SOUND|IE_STR_SPEECH); } //update the action bar @@ -4250,7 +4249,18 @@ void Actor::UpdateActorState(ieDword gameTime) { printMessage("Actor","Modal Spell Effect was not set!\n", YELLOW); ModalSpell[0]='*'; } else if(ModalSpell[0]!='*') { - core->ApplySpell(ModalSpell, this, this, 0); + if (ModalSpellSkillCheck()) { + core->ApplySpell(ModalSpell, this, this, 0); + if (InParty) { + core->DisplayStringName(core->ModalStates[ModalState].entering_str, 0xffffff, this, IE_STR_SOUND|IE_STR_SPEECH); + } + } else { + if (InParty) { + core->DisplayStringName(core->ModalStates[ModalState].failed_str, 0xffffff, this, IE_STR_SOUND|IE_STR_SPEECH); + } + ModalState = MS_NONE; + // TODO: wait for a round until allowing new states? + } } } @@ -6134,3 +6144,72 @@ bool Actor::IsRacialEnemy(Actor* target) } return false; } + +bool Actor::ModalSpellSkillCheck() { + switch(ModalState) { + case MS_BATTLESONG: + case MS_DETECTTRAPS: + case MS_TURNUNDEAD: + return true; + case MS_STEALTH: + return TryToHide(); + case MS_NONE: + default: + return false; + } +} + +static EffectRef fx_disable_button_ref={ "DisableButton", NULL, -1 }; + +inline void HideFailed(Actor* actor) +{ + Effect *newfx; + newfx = EffectQueue::CreateEffect(fx_disable_button_ref, 0, ACT_STEALTH, FX_DURATION_INSTANT_LIMITED); + newfx->Duration = 6; // 90 ticks, 1 round + core->ApplyEffect(newfx, actor, actor); + delete newfx; +} + +bool Actor::TryToHide() { + ieDword roll = LuckyRoll(1, 100, 0); + if (roll == 1) { + HideFailed(this); + return false; + } + + // check for disabled dualclassed thieves (not sure if we need it) + + if (Modified[IE_DISABLEDBUTTON] & (1<<ACT_STEALTH)) { + HideFailed(this); + return false; + } + + // check if the pc is in combat (seen / heard) + Game *game = core->GetGame(); + if (game->PCInCombat(this)) { + HideFailed(this); + return false; + } + + ieDword skill; + if (core->HasFeature(GF_HAS_HIDE_IN_SHADOWS)) { + skill = (GetStat(IE_HIDEINSHADOWS) + GetStat(IE_STEALTH))/2; + } else { + skill = GetStat(IE_STEALTH); + } + + // check how bright our spot is + ieDword lightness = game->GetCurrentArea()->GetLightLevel(Pos); + // seems to be the color overlay at midnight; lightness of a point with rgb (200, 100, 100) + // TODO: but our NightTint computes to a higher value, which one is bad? + ieDword ref_lightness = 43; + ieDword light_diff = int((lightness - ref_lightness) * 100 / (100 - ref_lightness)) / 2; + ieDword chance = (100 - light_diff) * skill/100; + + if (roll > chance) { + HideFailed(this); + return false; + } + return true; +} + diff --git a/gemrb/core/Actor.h b/gemrb/core/Actor.h index f0b6be2..a687ebf 100644 --- a/gemrb/core/Actor.h +++ b/gemrb/core/Actor.h @@ -642,5 +642,9 @@ public: bool IsBehind(Actor* target); /* checks whether the target is the actor's racial enemy */ bool IsRacialEnemy(Actor* target); + /* checks whether the actor can stay in the current modal state */ + bool ModalSpellSkillCheck(); + /* does all the game logic checks to see if the actor can hide */ + bool TryToHide(); }; #endif ----------------------------------------------------------------------- This is an automated email from the git hooks/post-receive script. -- gemrb: Infinity Engine emulator |