Permalink
Browse files

fixed "enemy sighted" autopause to work in non-bg1 too

now also each new combatant can trigger one and there is no downtime
after battles, since we don't rely on combatcounter anymore
  • Loading branch information...
1 parent 8f27767 commit 6c8253e9382ccfa094d16b9ed7f2d64adea04824 @lynxlynxlynx lynxlynxlynx committed Jul 27, 2013
View
@@ -1423,7 +1423,8 @@ void Map::ActorSpottedByPlayer(Actor *actor)
}
if (!(actor->GetInternalFlag()&IF_STOPATTACK) && !core->GetGame()->AnyPCInCombat()) {
- if (actor->Modified[IE_EA]>=EA_EVILCUTOFF) {
+ if (actor->Modified[IE_EA] > EA_EVILCUTOFF && !(actor->GetInternalFlag() & IF_TRIGGER_AP)) {
+ actor->SetInternalFlag(IF_TRIGGER_AP, BM_OR);
core->Autopause(AP_ENEMY, actor);
}
}
@@ -7172,7 +7172,10 @@ bool Actor::HasBodyHeat() const
void Actor::Draw(const Region &screen)
{
Map* area = GetCurrentArea();
- if (!area) return;
+ if (!area) {
+ InternalFlags &= ~IF_TRIGGER_AP;
+ return;
+ }
int cx = Pos.x;
int cy = Pos.y;
@@ -7187,13 +7190,15 @@ void Actor::Draw(const Region &screen)
if (!(InternalFlags&IF_REALLYDIED)) {
// for a while this didn't return (disable drawing) if about to hibernate;
// Avenger said (aa10aaed) "we draw the actor now for the last time".
+ InternalFlags &= ~IF_TRIGGER_AP;
return;
}
}
// if an actor isn't visible, should we still draw video cells?
// let us assume not, for now..
if (!(InternalFlags & IF_VISIBLE)) {
+ InternalFlags &= ~IF_TRIGGER_AP;
return;
}
@@ -7205,6 +7210,7 @@ void Actor::Draw(const Region &screen)
//visual feedback
CharAnimations* ca = GetAnims();
if (!ca) {
+ InternalFlags &= ~IF_TRIGGER_AP;
return;
}
@@ -7471,6 +7477,15 @@ void Actor::Draw(const Region &screen)
if (tmp && Persistent() && (core->GetGame()->GameTime % (core->Time.round_size/2) == 0)) { // smaller delta to skip fading
DisplayHeadHPRatio();
}
+
+ // trigger on-enemy-sighted autopause
+ if (!(InternalFlags & IF_TRIGGER_AP)) {
+ // always recheck in case of EA changes (npc going hostile)
+ if (Modified[IE_EA] > EA_EVILCUTOFF && !(InternalFlags & IF_STOPATTACK)) {
+ InternalFlags |= IF_TRIGGER_AP;
+ core->Autopause(AP_ENEMY, this);
+ }
+ }
}
/* Handling automatic stance changes */
@@ -640,6 +640,17 @@ ieDword Scriptable::GetInternalFlag() const
return InternalFlags;
}
+void Scriptable::SetInternalFlag(int value, int mode)
+{
+ switch (mode) {
+ case BM_OR: InternalFlags|=value; break;
+ case BM_NAND: InternalFlags&=~value; break;
+ case BM_SET: InternalFlags=value; break;
+ case BM_AND: InternalFlags&=value; break;
+ case BM_XOR: InternalFlags^=value; break;
+ }
+}
+
void Scriptable::InitTriggers()
{
triggers.clear();
@@ -108,6 +108,7 @@ class SpriteCover;
#define IF_IDLE 0x100000
//#define IF_PARTYRESTED 0x200000 //party rested trigger event
#define IF_FORCEUPDATE 0x400000
+#define IF_TRIGGER_AP 0x800000
//the actor should stop attacking
#define IF_STOPATTACK (IF_JUSTDIED|IF_REALLYDIED|IF_CLEANUP|IF_IDLE)
@@ -307,6 +308,7 @@ class GEM_EXPORT Scriptable {
void Deactivate();
void PartyRested();
ieDword GetInternalFlag() const;
+ void SetInternalFlag(int value, int mode);
const char* GetScriptName() const;
Map* GetCurrentArea() const;
void SetMap(Map *map);

0 comments on commit 6c8253e

Please sign in to comment.