Merge remote-tracking branch 'digmaster/master'

actorid
Marc Zinnschlag 11 years ago
commit 2e7b4e798e

@ -879,12 +879,23 @@ namespace MWMechanics
iter->second->update(duration); iter->second->update(duration);
} }
// Kill dead actors // Kill dead actors, update some variables
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();iter++) for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();iter++)
{ {
const MWWorld::Class &cls = MWWorld::Class::get(iter->first); const MWWorld::Class &cls = MWWorld::Class::get(iter->first);
CreatureStats &stats = cls.getCreatureStats(iter->first); CreatureStats &stats = cls.getCreatureStats(iter->first);
//KnockedOutOneFrameLogic
//Used for "OnKnockedOut" command
//Put here to ensure that it's run for PRECISELY one frame.
if(stats.getKnockedDown() && !stats.getKnockedDownOneFrame() && !stats.getKnockedDownOverOneFrame()) { //Start it for one frame if nessesary
stats.setKnockedDownOneFrame(true);
}
else if (stats.getKnockedDownOneFrame() && !stats.getKnockedDownOverOneFrame()) { //Turn off KnockedOutOneframe
stats.setKnockedDownOneFrame(false);
stats.setKnockedDownOverOneFrame(true);
}
if(!stats.isDead()) if(!stats.isDead())
{ {
if(iter->second->isDead()) if(iter->second->isDead())
@ -1018,7 +1029,6 @@ namespace MWMechanics
{ {
const MWWorld::Class &cls = MWWorld::Class::get(iter->first); const MWWorld::Class &cls = MWWorld::Class::get(iter->first);
CreatureStats &stats = cls.getCreatureStats(iter->first); CreatureStats &stats = cls.getCreatureStats(iter->first);
if(!stats.isDead() && stats.getAiSequence().getTypeId() == AiPackage::TypeIdFollow) if(!stats.isDead() && stats.getAiSequence().getTypeId() == AiPackage::TypeIdFollow)
{ {
MWMechanics::AiFollow* package = static_cast<MWMechanics::AiFollow*>(stats.getAiSequence().getActivePackage()); MWMechanics::AiFollow* package = static_cast<MWMechanics::AiFollow*>(stats.getAiSequence().getActivePackage());
@ -1040,7 +1050,6 @@ namespace MWMechanics
{ {
const MWWorld::Class &cls = MWWorld::Class::get(*iter); const MWWorld::Class &cls = MWWorld::Class::get(*iter);
CreatureStats &stats = cls.getCreatureStats(*iter); CreatureStats &stats = cls.getCreatureStats(*iter);
if(!stats.isDead() && stats.getAiSequence().getTypeId() == AiPackage::TypeIdCombat) if(!stats.isDead() && stats.getAiSequence().getTypeId() == AiPackage::TypeIdCombat)
{ {
MWMechanics::AiCombat* package = static_cast<MWMechanics::AiCombat*>(stats.getAiSequence().getActivePackage()); MWMechanics::AiCombat* package = static_cast<MWMechanics::AiCombat*>(stats.getAiSequence().getActivePackage());

@ -17,7 +17,7 @@ namespace MWMechanics
mAttacked (false), mHostile (false), mAttacked (false), mHostile (false),
mAttackingOrSpell(false), mAttackingOrSpell(false),
mIsWerewolf(false), mIsWerewolf(false),
mFallHeight(0), mRecalcDynamicStats(false), mKnockdown(false), mHitRecovery(false), mBlock(false), mFallHeight(0), mRecalcDynamicStats(false), mKnockdown(false), mKnockdownOneFrame(false), mKnockdownOverOneFrame(false), mHitRecovery(false), mBlock(false),
mMovementFlags(0), mDrawState (DrawState_Nothing), mAttackStrength(0.f) mMovementFlags(0), mDrawState (DrawState_Nothing), mAttackStrength(0.f)
{ {
for (int i=0; i<4; ++i) for (int i=0; i<4; ++i)
@ -387,6 +387,8 @@ namespace MWMechanics
void CreatureStats::setKnockedDown(bool value) void CreatureStats::setKnockedDown(bool value)
{ {
mKnockdown = value; mKnockdown = value;
if(!value) //Resets the "OverOneFrame" flag
setKnockedDownOverOneFrame(false);
} }
bool CreatureStats::getKnockedDown() const bool CreatureStats::getKnockedDown() const
@ -394,6 +396,23 @@ namespace MWMechanics
return mKnockdown; return mKnockdown;
} }
void CreatureStats::setKnockedDownOneFrame(bool value)
{
mKnockdownOneFrame = value;
}
bool CreatureStats::getKnockedDownOneFrame() const
{
return mKnockdownOneFrame;
}
void CreatureStats::setKnockedDownOverOneFrame(bool value) {
mKnockdownOverOneFrame = value;
}
bool CreatureStats::getKnockedDownOverOneFrame() const {
return mKnockdownOverOneFrame;
}
void CreatureStats::setHitRecovery(bool value) void CreatureStats::setHitRecovery(bool value)
{ {
mHitRecovery = value; mHitRecovery = value;
@ -479,7 +498,7 @@ namespace MWMechanics
} }
// Relates to NPC gold reset delay // Relates to NPC gold reset delay
void CreatureStats::setTradeTime(MWWorld::TimeStamp tradeTime) void CreatureStats::setTradeTime(MWWorld::TimeStamp tradeTime)
{ {
mTradeTime = tradeTime; mTradeTime = tradeTime;
} }
@ -489,11 +508,11 @@ namespace MWMechanics
return mTradeTime; return mTradeTime;
} }
void CreatureStats::setGoldPool(int pool) void CreatureStats::setGoldPool(int pool)
{ {
mGoldPool = pool; mGoldPool = pool;
} }
int CreatureStats::getGoldPool() const int CreatureStats::getGoldPool() const
{ {
return mGoldPool; return mGoldPool;
} }

@ -41,6 +41,8 @@ namespace MWMechanics
bool mHostile; bool mHostile;
bool mAttackingOrSpell; bool mAttackingOrSpell;
bool mKnockdown; bool mKnockdown;
bool mKnockdownOneFrame;
bool mKnockdownOverOneFrame;
bool mHitRecovery; bool mHitRecovery;
bool mBlock; bool mBlock;
unsigned int mMovementFlags; unsigned int mMovementFlags;
@ -188,7 +190,14 @@ namespace MWMechanics
float getEvasion() const; float getEvasion() const;
void setKnockedDown(bool value); void setKnockedDown(bool value);
///Returns true for the entire duration of the actor being knocked down
bool getKnockedDown() const; bool getKnockedDown() const;
void setKnockedDownOneFrame(bool value);
///Returns true only for the first frame of the actor being knocked out; used for "onKnockedOut" command
bool getKnockedDownOneFrame() const;
void setKnockedDownOverOneFrame(bool value);
///Returns true for all but the first frame of being knocked out; used to know to not reset mKnockedDownOneFrame
bool getKnockedDownOverOneFrame() const;
void setHitRecovery(bool value); void setHitRecovery(bool value);
bool getHitRecovery() const; bool getHitRecovery() const;
void setBlock(bool value); void setBlock(bool value);

@ -388,5 +388,7 @@ op 0x200023c: StopCombat
op 0x200023d: StopCombatExplicit op 0x200023d: StopCombatExplicit
op 0x200023e: GetPcInJail op 0x200023e: GetPcInJail
op 0x200023f: GetPcTraveling op 0x200023f: GetPcTraveling
op 0x2000240: onKnockout
op 0x2000241: onKnockoutExplicit
opcodes 0x2000240-0x3ffffff unused opcodes 0x2000242-0x3ffffff unused

@ -1060,6 +1060,22 @@ namespace MWScript
} }
}; };
template <class R>
class OpOnKnockout : public Interpreter::Opcode0
{
public:
virtual void execute (Interpreter::Runtime& runtime)
{
MWWorld::Ptr ptr = R()(runtime);
Interpreter::Type_Integer value =
MWWorld::Class::get (ptr).getCreatureStats (ptr).getKnockedDownOneFrame();
runtime.push (value);
}
};
template <class R> template <class R>
class OpIsWerewolf : public Interpreter::Opcode0 class OpIsWerewolf : public Interpreter::Opcode0
{ {
@ -1236,6 +1252,8 @@ namespace MWScript
interpreter.installSegment5 (Compiler::Stats::opcodeOnDeath, new OpOnDeath<ImplicitRef>); interpreter.installSegment5 (Compiler::Stats::opcodeOnDeath, new OpOnDeath<ImplicitRef>);
interpreter.installSegment5 (Compiler::Stats::opcodeOnDeathExplicit, new OpOnDeath<ExplicitRef>); interpreter.installSegment5 (Compiler::Stats::opcodeOnDeathExplicit, new OpOnDeath<ExplicitRef>);
interpreter.installSegment5 (Compiler::Stats::opcodeOnKnockout, new OpOnKnockout<ImplicitRef>);
interpreter.installSegment5 (Compiler::Stats::opcodeOnKnockoutExplicit, new OpOnKnockout<ExplicitRef>);
interpreter.installSegment5 (Compiler::Stats::opcodeIsWerewolf, new OpIsWerewolf<ImplicitRef>); interpreter.installSegment5 (Compiler::Stats::opcodeIsWerewolf, new OpIsWerewolf<ImplicitRef>);
interpreter.installSegment5 (Compiler::Stats::opcodeIsWerewolfExplicit, new OpIsWerewolf<ExplicitRef>); interpreter.installSegment5 (Compiler::Stats::opcodeIsWerewolfExplicit, new OpIsWerewolf<ExplicitRef>);
@ -1245,7 +1263,7 @@ namespace MWScript
interpreter.installSegment5 (Compiler::Stats::opcodeUndoWerewolf, new OpSetWerewolf<ImplicitRef, false>); interpreter.installSegment5 (Compiler::Stats::opcodeUndoWerewolf, new OpSetWerewolf<ImplicitRef, false>);
interpreter.installSegment5 (Compiler::Stats::opcodeUndoWerewolfExplicit, new OpSetWerewolf<ExplicitRef, false>); interpreter.installSegment5 (Compiler::Stats::opcodeUndoWerewolfExplicit, new OpSetWerewolf<ExplicitRef, false>);
interpreter.installSegment5 (Compiler::Stats::opcodeSetWerewolfAcrobatics, new OpSetWerewolfAcrobatics<ImplicitRef>); interpreter.installSegment5 (Compiler::Stats::opcodeSetWerewolfAcrobatics, new OpSetWerewolfAcrobatics<ImplicitRef>);
interpreter.installSegment5 (Compiler::Stats::opcodeSetWerewolfAcrobaticsExplicit, new OpSetWerewolfAcrobatics<ExplicitRef>); interpreter.installSegment5 (Compiler::Stats::opcodeSetWerewolfAcrobaticsExplicit, new OpSetWerewolfAcrobatics<ExplicitRef>);
} }
} }
} }

@ -95,7 +95,7 @@ namespace MWWorld
bool wasTeleported() const; bool wasTeleported() const;
void setTeleported(bool teleported); void setTeleported(bool teleported);
///Checks all actors to see if anyone has an aipackage against you ///Checks all nearby actors to see if anyone has an aipackage against you
bool isInCombat(); bool isInCombat();
void clear(); void clear();

@ -444,6 +444,7 @@ namespace Compiler
extensions.registerInstruction ("lowerrank", "", opcodeLowerRank, opcodeLowerRankExplicit); extensions.registerInstruction ("lowerrank", "", opcodeLowerRank, opcodeLowerRankExplicit);
extensions.registerFunction ("ondeath", 'l', "", opcodeOnDeath, opcodeOnDeathExplicit); extensions.registerFunction ("ondeath", 'l', "", opcodeOnDeath, opcodeOnDeathExplicit);
extensions.registerFunction ("onknockout", 'l', "", opcodeOnKnockout, opcodeOnKnockoutExplicit);
extensions.registerFunction ("iswerewolf", 'l', "", opcodeIsWerewolf, opcodeIsWerewolfExplicit); extensions.registerFunction ("iswerewolf", 'l', "", opcodeIsWerewolf, opcodeIsWerewolfExplicit);

@ -377,6 +377,8 @@ namespace Compiler
const int opcodeLowerRankExplicit = 0x20001eb; const int opcodeLowerRankExplicit = 0x20001eb;
const int opcodeOnDeath = 0x20001fc; const int opcodeOnDeath = 0x20001fc;
const int opcodeOnDeathExplicit = 0x2000205; const int opcodeOnDeathExplicit = 0x2000205;
const int opcodeOnKnockout = 0x2000240;
const int opcodeOnKnockoutExplicit = 0x2000241;
const int opcodeBecomeWerewolf = 0x2000217; const int opcodeBecomeWerewolf = 0x2000217;
const int opcodeBecomeWerewolfExplicit = 0x2000218; const int opcodeBecomeWerewolfExplicit = 0x2000218;

Loading…
Cancel
Save