forked from mirror/openmw-tes3mp
Issue #68: added getdeadcount script function
This commit is contained in:
parent
f72c35fc17
commit
453f347ee8
7 changed files with 44 additions and 1 deletions
|
@ -76,6 +76,9 @@ namespace MWBase
|
||||||
|
|
||||||
virtual void restoreDynamicStats() = 0;
|
virtual void restoreDynamicStats() = 0;
|
||||||
///< If the player is sleeping, this should be called every hour.
|
///< If the player is sleeping, this should be called every hour.
|
||||||
|
|
||||||
|
virtual int countDeaths (const std::string& id) const = 0;
|
||||||
|
///< Return the number of deaths for actors with the given ID.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -262,4 +262,14 @@ namespace MWMechanics
|
||||||
calculateRestoration (*iter, 3600);
|
calculateRestoration (*iter, 3600);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Actors::countDeaths (const std::string& id) const
|
||||||
|
{
|
||||||
|
std::map<std::string, int>::const_iterator iter = mDeathCount.find (id);
|
||||||
|
|
||||||
|
if (iter!=mDeathCount.end())
|
||||||
|
return iter->second;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,9 @@ namespace MWMechanics
|
||||||
|
|
||||||
void restoreDynamicStats();
|
void restoreDynamicStats();
|
||||||
///< If the player is sleeping, this should be called every hour.
|
///< If the player is sleeping, this should be called every hour.
|
||||||
|
|
||||||
|
int countDeaths (const std::string& id) const;
|
||||||
|
///< Return the number of deaths for actors with the given ID.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -326,4 +326,9 @@ namespace MWMechanics
|
||||||
buildPlayer();
|
buildPlayer();
|
||||||
mUpdatePlayer = true;
|
mUpdatePlayer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MechanicsManager::countDeaths (const std::string& id) const
|
||||||
|
{
|
||||||
|
return mActors.countDeaths (id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,10 @@ namespace MWMechanics
|
||||||
|
|
||||||
virtual void restoreDynamicStats();
|
virtual void restoreDynamicStats();
|
||||||
///< If the player is sleeping, this should be called every hour.
|
///< If the player is sleeping, this should be called every hour.
|
||||||
|
|
||||||
|
virtual int countDeaths (const std::string& id) const;
|
||||||
|
///< Return the number of deaths for actors with the given ID.
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -206,5 +206,6 @@ op 0x200019f: GetPcSleep
|
||||||
op 0x20001a0: ShowMap
|
op 0x20001a0: ShowMap
|
||||||
op 0x20001a1: FillMap
|
op 0x20001a1: FillMap
|
||||||
op 0x20001a2: WakeUpPc
|
op 0x20001a2: WakeUpPc
|
||||||
opcodes 0x20001a3-0x3ffffff unused
|
op 0x20001a3: GetDeadCount
|
||||||
|
opcodes 0x20001a4-0x3ffffff unused
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/dialoguemanager.hpp"
|
#include "../mwbase/dialoguemanager.hpp"
|
||||||
|
#include "../mwbase/mechanicsmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwworld/player.hpp"
|
#include "../mwworld/player.hpp"
|
||||||
|
@ -591,6 +592,17 @@ namespace MWScript
|
||||||
/// \todo modify disposition towards the player
|
/// \todo modify disposition towards the player
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class OpGetDeadCount : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
|
runtime[0].mInteger = MWBase::Environment::get().getMechanicsManager()->countDeaths (id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const int numberOfAttributes = 8;
|
const int numberOfAttributes = 8;
|
||||||
|
@ -643,6 +655,8 @@ namespace MWScript
|
||||||
const int opcodeGetLevelExplicit = 0x200018d;
|
const int opcodeGetLevelExplicit = 0x200018d;
|
||||||
const int opcodeSetLevel = 0x200018e;
|
const int opcodeSetLevel = 0x200018e;
|
||||||
const int opcodeSetLevelExplicit = 0x200018f;
|
const int opcodeSetLevelExplicit = 0x200018f;
|
||||||
|
|
||||||
|
const int opcodeGetDeadCount = 0x20001a3;
|
||||||
|
|
||||||
void registerExtensions (Compiler::Extensions& extensions)
|
void registerExtensions (Compiler::Extensions& extensions)
|
||||||
{
|
{
|
||||||
|
@ -729,6 +743,8 @@ namespace MWScript
|
||||||
|
|
||||||
extensions.registerInstruction("setlevel", "l", opcodeSetLevel, opcodeSetLevelExplicit);
|
extensions.registerInstruction("setlevel", "l", opcodeSetLevel, opcodeSetLevelExplicit);
|
||||||
extensions.registerFunction("getlevel", 'l', "", opcodeGetLevel, opcodeGetLevelExplicit);
|
extensions.registerFunction("getlevel", 'l', "", opcodeGetLevel, opcodeGetLevelExplicit);
|
||||||
|
|
||||||
|
extensions.registerFunction("getdeadcount", 'l', "c", opcodeGetDeadCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
|
@ -806,6 +822,7 @@ namespace MWScript
|
||||||
interpreter.installSegment5 (opcodeSetLevel, new OpSetLevel<ImplicitRef>);
|
interpreter.installSegment5 (opcodeSetLevel, new OpSetLevel<ImplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeSetLevelExplicit, new OpSetLevel<ExplicitRef>);
|
interpreter.installSegment5 (opcodeSetLevelExplicit, new OpSetLevel<ExplicitRef>);
|
||||||
|
|
||||||
|
interpreter.installSegment5 (opcodeGetDeadCount, new OpGetDeadCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue