From: Jaka K. <lyn...@us...> - 2010-09-28 16:57:08
|
gemrb: Infinity Engine emulator The branch master has been updated via d06d119ebf1d70017780afa1fc6f4abcc71e58d4 (commit) via b85a400ec59fd1041865bc719d6e660a35877223 (commit) Summary of changes: gemrb/core/Inventory.cpp | 27 +++++++++++++++++++++++++++ gemrb/core/Inventory.h | 2 ++ gemrb/core/Scriptable/Actor.cpp | 7 +++---- 3 files changed, 32 insertions(+), 4 deletions(-) from 7837bc4274f69cfa5e8cadef43adcdf08a841a40 (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=d06d119ebf1d70017780afa1fc6f4abcc71e58d4 commit d06d119ebf1d70017780afa1fc6f4abcc71e58d4 Author: Jaka Kranjc <lyn...@us...> Date: Tue Sep 28 18:50:31 2010 +0200 added Inventory::ProvidesCriticalAversion to check if the actor wears any item that can avert critical hits diff --git a/gemrb/core/Inventory.cpp b/gemrb/core/Inventory.cpp index 33d1ab6..793cf7a 100644 --- a/gemrb/core/Inventory.cpp +++ b/gemrb/core/Inventory.cpp @@ -1754,3 +1754,30 @@ unsigned int Inventory::FindStealableItem() return 0; } +// extension to allow more or less than head gear to avert critical hits +bool Inventory::ProvidesCriticalAversion() +{ + for (size_t i = 0; i < Slots.size(); i++) { + CREItem *item = Slots[i]; + if (!item || ! (item->Flags & IE_INV_ITEM_EQUIPPED)) { + continue; + } + + Item *itm = gamedata->GetItem(item->ItemResRef); + if (!itm) { + continue; + } + + for (int h = 0; h < itm->ExtHeaderCount; h++) { + ITMExtHeader *header = itm->GetExtHeader(h); + if (header && (header->RechargeFlags & IE_ITEM_TOGGLE_CRITS)) { + return true; + } + } + } + // remove this when items with the IE_ITEM_TOGGLE_CRITS set become available + if (HasItemInSlot("", SLOT_HEAD)) { + return true; + } + return false; +} diff --git a/gemrb/core/Inventory.h b/gemrb/core/Inventory.h index 3f418fb..9c9443a 100644 --- a/gemrb/core/Inventory.h +++ b/gemrb/core/Inventory.h @@ -317,6 +317,8 @@ public: int WhyCantEquip(int slot, int twohanded) const; /** returns a slot that has a stealable item */ unsigned int FindStealableItem(); + /** checks if any equipped item provides critical hit aversion */ + bool ProvidesCriticalAversion(); //setting important constants static void Init(int mb); static void SetHeadSlot(int arg); diff --git a/gemrb/core/Scriptable/Actor.cpp b/gemrb/core/Scriptable/Actor.cpp index c615cde..b74d1e1 100644 --- a/gemrb/core/Scriptable/Actor.cpp +++ b/gemrb/core/Scriptable/Actor.cpp @@ -4627,8 +4627,7 @@ void Actor::ModifyDamage(Actor *target, Scriptable *hitter, int &damage, int &re if (critical) { //a critical surely raises the morale? NewBase(IE_MORALE, 1, MOD_ADDITIVE); - int head = inventory.GetHeadSlot(); - if ((head!=-1) && target->inventory.HasItemInSlot("",(ieDword) head)) { + if (target->inventory.ProvidesCriticalAversion()) { //critical hit is averted by helmet displaymsg->DisplayConstantStringName(STR_NO_CRITICAL, 0xffffff, target); } else { http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=b85a400ec59fd1041865bc719d6e660a35877223 commit b85a400ec59fd1041865bc719d6e660a35877223 Author: Jaka Kranjc <lyn...@us...> Date: Tue Sep 28 11:55:18 2010 +0200 use the new backstabibility bit diff --git a/gemrb/core/Scriptable/Actor.cpp b/gemrb/core/Scriptable/Actor.cpp index 35d1e91..c615cde 100644 --- a/gemrb/core/Scriptable/Actor.cpp +++ b/gemrb/core/Scriptable/Actor.cpp @@ -3798,11 +3798,11 @@ ITMExtHeader *Actor::GetWeapon(WeaponInfo &wi, bool leftorright) ITMExtHeader *which; if (GetAttackStyle() == WEAPON_RANGED) { which = item->GetWeaponHeader(true); - wi.backstabbing = false; + wi.backstabbing = which->RechargeFlags & IE_ITEM_BACKSTAB; } else { which = item->GetWeaponHeader(false); // any melee weapon usable by a single class thief is game (UAI does not affect this) - wi.backstabbing = !(item->UsabilityBitmask & 0x400000); + wi.backstabbing = !(item->UsabilityBitmask & 0x400000) || (which->RechargeFlags & IE_ITEM_BACKSTAB); } //make sure we use 'false' in this freeitem ----------------------------------------------------------------------- This is an automated email from the git hooks/post-receive script. -- gemrb: Infinity Engine emulator |