mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-31 22:15:33 +00:00
Merge branch 'master' into editor2
This commit is contained in:
commit
1c80390bce
25 changed files with 1024 additions and 96 deletions
|
@ -131,9 +131,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
->default_value(false), "enable console-only script functionality")
|
||||
|
||||
("script-run", bpo::value<std::string>()->default_value(""),
|
||||
"select a file that is executed in the console on startup\n\n"
|
||||
"Note: The file contains a list of script lines, but not a complete scripts. "
|
||||
"That means no begin/end and no variable declarations.")
|
||||
"select a file containing a list of console commands that is executed on startup")
|
||||
|
||||
("new-game", bpo::value<bool>()->implicit_value(true)
|
||||
->default_value(false), "activate char gen/new game mechanics")
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace MWGui
|
|||
void AlchemyWindow::onCancelButtonClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
mAlchemy.clear();
|
||||
|
||||
|
||||
mWindowManager.removeGuiMode(GM_Alchemy);
|
||||
mWindowManager.removeGuiMode(GM_Inventory);
|
||||
}
|
||||
|
@ -119,7 +119,6 @@ namespace MWGui
|
|||
if (mIngredients[i]->isUserString("ToolTipType"))
|
||||
{
|
||||
MWWorld::Ptr ingred = *mIngredients[i]->getUserData<MWWorld::Ptr>();
|
||||
ingred.getRefData().setCount(ingred.getRefData().getCount()-1);
|
||||
if (ingred.getRefData().getCount() == 0)
|
||||
removeIngredient(mIngredients[i]);
|
||||
}
|
||||
|
|
|
@ -316,6 +316,22 @@ void addColorInString(std::string& str, const std::string& keyword,std::string c
|
|||
size_t pos = 0;
|
||||
while((pos = find_str_ci(str,keyword, pos)) != std::string::npos)
|
||||
{
|
||||
// do not add color if this portion of text is already colored.
|
||||
{
|
||||
MyGUI::TextIterator iterator (str);
|
||||
MyGUI::UString colour;
|
||||
while(iterator.moveNext())
|
||||
{
|
||||
size_t iteratorPos = iterator.getPosition();
|
||||
iterator.getTagColour(colour);
|
||||
if (iteratorPos == pos)
|
||||
break;
|
||||
}
|
||||
|
||||
if (colour == color1)
|
||||
return;
|
||||
}
|
||||
|
||||
str.insert(pos,color1);
|
||||
pos += color1.length();
|
||||
pos += keyword.length();
|
||||
|
|
|
@ -226,9 +226,14 @@ namespace MWGui
|
|||
if (start == "splash")
|
||||
splash.push_back (*it);
|
||||
}
|
||||
std::string randomSplash = splash[rand() % splash.size()];
|
||||
if (splash.size())
|
||||
{
|
||||
std::string randomSplash = splash[rand() % splash.size()];
|
||||
|
||||
Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton ().load (randomSplash, "General");
|
||||
mBackgroundImage->setImageTexture (randomSplash);
|
||||
Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton ().load (randomSplash, "General");
|
||||
mBackgroundImage->setImageTexture (randomSplash);
|
||||
}
|
||||
else
|
||||
std::cerr << "No loading screens found!" << std::endl;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -252,6 +252,7 @@ void StatsWindow::onFrame ()
|
|||
}
|
||||
|
||||
setFactions(PCstats.getFactionRanks());
|
||||
setExpelled(PCstats.getExpelled ());
|
||||
|
||||
const std::string &signId =
|
||||
MWBase::Environment::get().getWorld()->getPlayer().getBirthSign();
|
||||
|
@ -273,6 +274,15 @@ void StatsWindow::setFactions (const FactionList& factions)
|
|||
}
|
||||
}
|
||||
|
||||
void StatsWindow::setExpelled (const std::set<std::string>& expelled)
|
||||
{
|
||||
if (mExpelled != expelled)
|
||||
{
|
||||
mExpelled = expelled;
|
||||
mChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
void StatsWindow::setBirthSign (const std::string& signId)
|
||||
{
|
||||
if (signId != mBirthSignId)
|
||||
|
@ -462,6 +472,10 @@ void StatsWindow::updateSkillArea()
|
|||
if (!mSkillWidgets.empty())
|
||||
addSeparator(coord1, coord2);
|
||||
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
MWMechanics::NpcStats PCstats = MWWorld::Class::get(player).getNpcStats(player);
|
||||
std::set<std::string>& expelled = PCstats.getExpelled ();
|
||||
|
||||
addGroup(mWindowManager.getGameSettingString("sFaction", "Faction"), coord1, coord2);
|
||||
FactionList::const_iterator end = mFactions.end();
|
||||
for (FactionList::const_iterator it = mFactions.begin(); it != end; ++it)
|
||||
|
@ -473,36 +487,42 @@ void StatsWindow::updateSkillArea()
|
|||
std::string text;
|
||||
|
||||
text += std::string("#DDC79E") + faction->mName;
|
||||
text += std::string("\n#BF9959") + faction->mRanks[it->second];
|
||||
|
||||
if (it->second < 9)
|
||||
if (expelled.find(it->first) != expelled.end())
|
||||
text += "\n#{sExpelled}";
|
||||
else
|
||||
{
|
||||
// player doesn't have max rank yet
|
||||
text += std::string("\n\n#DDC79E#{sNextRank} ") + faction->mRanks[it->second+1];
|
||||
text += std::string("\n#BF9959") + faction->mRanks[it->second];
|
||||
|
||||
ESM::RankData rankData = faction->mData.mRankData[it->second+1];
|
||||
const ESM::Attribute* attr1 = store.get<ESM::Attribute>().find(faction->mData.mAttribute1);
|
||||
const ESM::Attribute* attr2 = store.get<ESM::Attribute>().find(faction->mData.mAttribute2);
|
||||
assert(attr1 && attr2);
|
||||
|
||||
text += "\n#BF9959#{" + attr1->mName + "}: " + boost::lexical_cast<std::string>(rankData.mAttribute1)
|
||||
+ ", #{" + attr2->mName + "}: " + boost::lexical_cast<std::string>(rankData.mAttribute2);
|
||||
|
||||
text += "\n\n#DDC79E#{sFavoriteSkills}";
|
||||
text += "\n#BF9959";
|
||||
for (int i=0; i<6; ++i)
|
||||
if (it->second < 9)
|
||||
{
|
||||
text += "#{"+ESM::Skill::sSkillNameIds[faction->mData.mSkillID[i]]+"}";
|
||||
if (i<5)
|
||||
text += ", ";
|
||||
// player doesn't have max rank yet
|
||||
text += std::string("\n\n#DDC79E#{sNextRank} ") + faction->mRanks[it->second+1];
|
||||
|
||||
ESM::RankData rankData = faction->mData.mRankData[it->second+1];
|
||||
const ESM::Attribute* attr1 = store.get<ESM::Attribute>().find(faction->mData.mAttribute1);
|
||||
const ESM::Attribute* attr2 = store.get<ESM::Attribute>().find(faction->mData.mAttribute2);
|
||||
assert(attr1 && attr2);
|
||||
|
||||
text += "\n#BF9959#{" + attr1->mName + "}: " + boost::lexical_cast<std::string>(rankData.mAttribute1)
|
||||
+ ", #{" + attr2->mName + "}: " + boost::lexical_cast<std::string>(rankData.mAttribute2);
|
||||
|
||||
text += "\n\n#DDC79E#{sFavoriteSkills}";
|
||||
text += "\n#BF9959";
|
||||
for (int i=0; i<6; ++i)
|
||||
{
|
||||
text += "#{"+ESM::Skill::sSkillNameIds[faction->mData.mSkillID[i]]+"}";
|
||||
if (i<5)
|
||||
text += ", ";
|
||||
}
|
||||
|
||||
text += "\n";
|
||||
|
||||
if (rankData.mSkill1 > 0)
|
||||
text += "\n#{sNeedOneSkill} " + boost::lexical_cast<std::string>(rankData.mSkill1);
|
||||
if (rankData.mSkill2 > 0)
|
||||
text += "\n#{sNeedTwoSkills} " + boost::lexical_cast<std::string>(rankData.mSkill2);
|
||||
}
|
||||
|
||||
text += "\n";
|
||||
|
||||
if (rankData.mSkill1 > 0)
|
||||
text += "\n#{sNeedOneSkill} " + boost::lexical_cast<std::string>(rankData.mSkill1);
|
||||
if (rankData.mSkill2 > 0)
|
||||
text += "\n#{sNeedTwoSkills} " + boost::lexical_cast<std::string>(rankData.mSkill2);
|
||||
}
|
||||
|
||||
w->setUserString("ToolTipType", "Layout");
|
||||
|
|
|
@ -50,6 +50,7 @@ namespace MWGui
|
|||
MyGUI::Widget* addItem(const std::string& text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
|
||||
|
||||
void setFactions (const FactionList& factions);
|
||||
void setExpelled (const std::set<std::string>& expelled);
|
||||
void setBirthSign (const std::string &signId);
|
||||
|
||||
void onWindowResize(MyGUI::Window* window);
|
||||
|
@ -71,6 +72,7 @@ namespace MWGui
|
|||
std::string mBirthSignId;
|
||||
int mReputation, mBounty;
|
||||
std::vector<MyGUI::WidgetPtr> mSkillWidgets; //< Skills and other information
|
||||
std::set<std::string> mExpelled;
|
||||
|
||||
bool mChanged;
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ ToolTips::ToolTips(MWBase::WindowManager* windowManager) :
|
|||
, mRemainingDelay(0.0)
|
||||
, mLastMouseX(0)
|
||||
, mLastMouseY(0)
|
||||
, mHorizontalScrollIndex(0)
|
||||
{
|
||||
getWidget(mDynamicToolTipBox, "DynamicToolTipBox");
|
||||
|
||||
|
@ -52,6 +53,7 @@ void ToolTips::setEnabled(bool enabled)
|
|||
|
||||
void ToolTips::onFrame(float frameDuration)
|
||||
{
|
||||
|
||||
while (mDynamicToolTipBox->getChildCount())
|
||||
{
|
||||
MyGUI::Gui::getInstance().destroyWidget(mDynamicToolTipBox->getChildAt(0));
|
||||
|
@ -103,7 +105,7 @@ void ToolTips::onFrame(float frameDuration)
|
|||
|
||||
else
|
||||
{
|
||||
const MyGUI::IntPoint& lastPressed = InputManager::getInstance().getLastPressedPosition(MyGUI::MouseButton::Left);
|
||||
const MyGUI::IntPoint& lastPressed = InputManager::getInstance().getLastPressedPosition(MyGUI::MouseButton::Left);
|
||||
|
||||
if (mousePos == lastPressed) // mouseclick makes tooltip disappear
|
||||
return;
|
||||
|
@ -114,11 +116,13 @@ void ToolTips::onFrame(float frameDuration)
|
|||
}
|
||||
else
|
||||
{
|
||||
mHorizontalScrollIndex = 0;
|
||||
mRemainingDelay = mDelay;
|
||||
}
|
||||
mLastMouseX = mousePos.left;
|
||||
mLastMouseY = mousePos.top;
|
||||
|
||||
|
||||
if (mRemainingDelay > 0)
|
||||
return;
|
||||
|
||||
|
@ -148,7 +152,8 @@ void ToolTips::onFrame(float frameDuration)
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// special handling for markers on the local map: the tooltip should only be visible
|
||||
// if the marker is not hidden due to the fog of war.
|
||||
if (focus->getUserString ("IsMarker") == "true")
|
||||
|
@ -354,7 +359,7 @@ void ToolTips::findImageExtension(std::string& image)
|
|||
}
|
||||
|
||||
IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info)
|
||||
{
|
||||
{
|
||||
mDynamicToolTipBox->setVisible(true);
|
||||
|
||||
std::string caption = info.caption;
|
||||
|
@ -388,6 +393,8 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info)
|
|||
setCoord(0, 0, 300, 300);
|
||||
|
||||
const IntPoint padding(8, 8);
|
||||
|
||||
const int maximumWidth = 500;
|
||||
|
||||
const int imageCaptionHPadding = (caption != "" ? 8 : 0);
|
||||
const int imageCaptionVPadding = (caption != "" ? 4 : 0);
|
||||
|
@ -411,7 +418,7 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info)
|
|||
IntSize textSize = textWidget->getTextSize();
|
||||
|
||||
captionSize += IntSize(imageSize, 0); // adjust for image
|
||||
IntSize totalSize = IntSize( std::max(textSize.width, captionSize.width + ((image != "") ? imageCaptionHPadding : 0)),
|
||||
IntSize totalSize = IntSize( std::min(std::max(textSize.width,captionSize.width + ((image != "") ? imageCaptionHPadding : 0)),maximumWidth),
|
||||
((text != "") ? textSize.height + imageCaptionVPadding : 0) + captionHeight );
|
||||
|
||||
if (!info.effects.empty())
|
||||
|
@ -499,8 +506,24 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info)
|
|||
(captionHeight-captionSize.height)/2,
|
||||
captionSize.width-imageSize,
|
||||
captionSize.height);
|
||||
|
||||
//if its too long we do hscroll with the caption
|
||||
if (captionSize.width > maximumWidth){
|
||||
mHorizontalScrollIndex = mHorizontalScrollIndex + 2;
|
||||
if (mHorizontalScrollIndex > captionSize.width){
|
||||
mHorizontalScrollIndex = -totalSize.width;
|
||||
}
|
||||
int horizontal_scroll = mHorizontalScrollIndex;
|
||||
if (horizontal_scroll < 40){
|
||||
horizontal_scroll = 40;
|
||||
}else{
|
||||
horizontal_scroll = 80 - mHorizontalScrollIndex;
|
||||
}
|
||||
captionWidget->setPosition (IntPoint(horizontal_scroll, captionWidget->getPosition().top + padding.top));
|
||||
} else {
|
||||
captionWidget->setPosition (captionWidget->getPosition() + padding);
|
||||
}
|
||||
|
||||
captionWidget->setPosition (captionWidget->getPosition() + padding);
|
||||
textWidget->setPosition (textWidget->getPosition() + IntPoint(0, padding.top)); // only apply vertical padding, the horizontal works automatically due to Align::HCenter
|
||||
|
||||
if (image != "")
|
||||
|
|
|
@ -90,6 +90,9 @@ namespace MWGui
|
|||
|
||||
float mFocusToolTipX;
|
||||
float mFocusToolTipY;
|
||||
|
||||
int mHorizontalScrollIndex;
|
||||
|
||||
|
||||
float mDelay;
|
||||
float mRemainingDelay; // remaining time until tooltip will show
|
||||
|
|
|
@ -204,6 +204,7 @@ namespace MWGui
|
|||
MWBase::Environment::get().getWorld ()->getFader ()->fadeIn(0.2);
|
||||
mProgressBar.setVisible (false);
|
||||
mWindowManager.removeGuiMode (GM_Rest);
|
||||
mWindowManager.removeGuiMode (GM_RestBed);
|
||||
mWaiting = false;
|
||||
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
|
|
|
@ -624,7 +624,9 @@ namespace MWInput
|
|||
void InputManager::toggleAutoMove()
|
||||
{
|
||||
if (mWindows.isGuiMode()) return;
|
||||
mPlayer.setAutoMove (!mPlayer.getAutoMove());
|
||||
|
||||
if (mControlSwitch["playercontrols"])
|
||||
mPlayer.setAutoMove (!mPlayer.getAutoMove());
|
||||
}
|
||||
|
||||
void InputManager::toggleWalking()
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <cstdlib>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include <components/esm/loadalch.hpp>
|
||||
#include <components/esm/loadspel.hpp>
|
||||
#include <components/esm/loadingr.hpp>
|
||||
|
@ -258,4 +260,18 @@ namespace MWMechanics
|
|||
|
||||
return scaledDuration-usedUp;
|
||||
}
|
||||
|
||||
bool ActiveSpells::isSpellActive(std::string id) const
|
||||
{
|
||||
boost::algorithm::to_lower(id);
|
||||
for (TContainer::iterator iter = mSpells.begin(); iter != mSpells.end(); ++iter)
|
||||
{
|
||||
std::string left = iter->first;
|
||||
boost::algorithm::to_lower(left);
|
||||
|
||||
if (iter->first == id)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,9 @@ namespace MWMechanics
|
|||
|
||||
void removeSpell (const std::string& id);
|
||||
|
||||
bool isSpellActive (std::string id) const;
|
||||
///< case insensitive
|
||||
|
||||
const MagicEffects& getMagicEffects() const;
|
||||
|
||||
TIterator begin() const;
|
||||
|
|
|
@ -203,7 +203,7 @@ const ESM::Potion *MWMechanics::Alchemy::getRecord() const
|
|||
|
||||
bool mismatch = false;
|
||||
|
||||
for (int i=0; i<static_cast<int> (iter->mEffects.mList.size()); ++iter)
|
||||
for (int i=0; i<static_cast<int> (iter->mEffects.mList.size()); ++i)
|
||||
{
|
||||
const ESM::ENAMstruct& first = iter->mEffects.mList[i];
|
||||
const ESM::ENAMstruct& second = mEffects[i];
|
||||
|
|
|
@ -350,4 +350,4 @@ void MWMechanics::NpcStats::setWerewolf (bool set)
|
|||
int MWMechanics::NpcStats::getWerewolfKills() const
|
||||
{
|
||||
return mWerewolfKills;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -332,6 +332,8 @@ void RenderingManager::update (float duration, bool paused)
|
|||
}
|
||||
mOcclusionQuery->update(duration);
|
||||
|
||||
mRendering.update(duration);
|
||||
|
||||
if(paused)
|
||||
{
|
||||
Ogre::ControllerManager::getSingleton().setTimeFactor(0.f);
|
||||
|
@ -350,8 +352,6 @@ void RenderingManager::update (float duration, bool paused)
|
|||
|
||||
mSkyManager->setGlare(mOcclusionQuery->getSunVisibility());
|
||||
|
||||
mRendering.update(duration);
|
||||
|
||||
MWWorld::RefData &data =
|
||||
MWBase::Environment::get()
|
||||
.getWorld()
|
||||
|
|
|
@ -114,71 +114,56 @@ namespace MWScript
|
|||
// discard additional arguments (reset), because we have no idea what they mean.
|
||||
for (unsigned int i=0; i<arg0; ++i) runtime.pop();
|
||||
|
||||
std::cout << "AiWanter" << std::endl;
|
||||
std::cout << "AiWander" << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpSetHello : public Interpreter::Opcode0
|
||||
class OpGetAiSetting : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
public:
|
||||
OpGetAiSetting(int index) : mIndex(index) {}
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (0, value);
|
||||
runtime.push(MWWorld::Class::get (ptr).getCreatureStats (ptr).getAiSetting (mIndex));
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpSetFight : public Interpreter::Opcode0
|
||||
class OpModAiSetting : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
public:
|
||||
OpModAiSetting(int index) : mIndex(index) {}
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (1, value);
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (mIndex,
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).getAiSetting (mIndex) + value);
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpSetFlee : public Interpreter::Opcode0
|
||||
class OpSetAiSetting : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
public:
|
||||
OpSetAiSetting(int index) : mIndex(index) {}
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (2, value);
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpSetAlarm : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (3, value);
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (mIndex,
|
||||
value);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -199,6 +184,22 @@ namespace MWScript
|
|||
const int opcodeSetFleeExplicit = 0x2000161;
|
||||
const int opcodeSetAlarm = 0x2000162;
|
||||
const int opcodeSetAlarmExplicit = 0x2000163;
|
||||
const int opcodeModHello = 0x20001b7;
|
||||
const int opcodeModHelloExplicit = 0x20001b8;
|
||||
const int opcodeModFight = 0x20001b9;
|
||||
const int opcodeModFightExplicit = 0x20001ba;
|
||||
const int opcodeModFlee = 0x20001bb;
|
||||
const int opcodeModFleeExplicit = 0x20001bc;
|
||||
const int opcodeModAlarm = 0x20001bd;
|
||||
const int opcodeModAlarmExplicit = 0x20001be;
|
||||
const int opcodeGetHello = 0x20001bf;
|
||||
const int opcodeGetHelloExplicit = 0x20001c0;
|
||||
const int opcodeGetFight = 0x20001c1;
|
||||
const int opcodeGetFightExplicit = 0x20001c2;
|
||||
const int opcodeGetFlee = 0x20001c3;
|
||||
const int opcodeGetFleeExplicit = 0x20001c4;
|
||||
const int opcodeGetAlarm = 0x20001c5;
|
||||
const int opcodeGetAlarmExplicit = 0x20001c6;
|
||||
|
||||
void registerExtensions (Compiler::Extensions& extensions)
|
||||
{
|
||||
|
@ -216,6 +217,14 @@ namespace MWScript
|
|||
extensions.registerInstruction ("setfight", "l", opcodeSetFight, opcodeSetFightExplicit);
|
||||
extensions.registerInstruction ("setflee", "l", opcodeSetFlee, opcodeSetFleeExplicit);
|
||||
extensions.registerInstruction ("setalarm", "l", opcodeSetAlarm, opcodeSetAlarmExplicit);
|
||||
extensions.registerInstruction ("modhello", "l", opcodeModHello, opcodeModHelloExplicit);
|
||||
extensions.registerInstruction ("modfight", "l", opcodeModFight, opcodeModFightExplicit);
|
||||
extensions.registerInstruction ("modflee", "l", opcodeModFlee, opcodeModFleeExplicit);
|
||||
extensions.registerInstruction ("modalarm", "l", opcodeModAlarm, opcodeModAlarmExplicit);
|
||||
extensions.registerFunction ("gethello", 'l', "", opcodeGetHello, opcodeGetHelloExplicit);
|
||||
extensions.registerFunction ("getfight", 'l', "", opcodeGetFight, opcodeGetFightExplicit);
|
||||
extensions.registerFunction ("getflee", 'l', "", opcodeGetFlee, opcodeGetFleeExplicit);
|
||||
extensions.registerFunction ("getalarm", 'l', "", opcodeGetAlarm, opcodeGetAlarmExplicit);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
|
@ -229,14 +238,32 @@ namespace MWScript
|
|||
interpreter.installSegment5 (opcodeGetAiPackageDone, new OpGetAiPackageDone<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetAiPackageDoneExplicit,
|
||||
new OpGetAiPackageDone<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetHello, new OpSetHello<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetHelloExplicit, new OpSetHello<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetFight, new OpSetFight<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetFightExplicit, new OpSetFight<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetFlee, new OpSetFlee<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetFleeExplicit, new OpSetFlee<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetAlarm, new OpSetAlarm<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetAlarmExplicit, new OpSetAlarm<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetHello, new OpSetAiSetting<ImplicitRef>(0));
|
||||
interpreter.installSegment5 (opcodeSetHelloExplicit, new OpSetAiSetting<ExplicitRef>(0));
|
||||
interpreter.installSegment5 (opcodeSetFight, new OpSetAiSetting<ImplicitRef>(1));
|
||||
interpreter.installSegment5 (opcodeSetFightExplicit, new OpSetAiSetting<ExplicitRef>(1));
|
||||
interpreter.installSegment5 (opcodeSetFlee, new OpSetAiSetting<ImplicitRef>(2));
|
||||
interpreter.installSegment5 (opcodeSetFleeExplicit, new OpSetAiSetting<ExplicitRef>(2));
|
||||
interpreter.installSegment5 (opcodeSetAlarm, new OpSetAiSetting<ImplicitRef>(3));
|
||||
interpreter.installSegment5 (opcodeSetAlarmExplicit, new OpSetAiSetting<ExplicitRef>(3));
|
||||
|
||||
interpreter.installSegment5 (opcodeModHello, new OpModAiSetting<ImplicitRef>(0));
|
||||
interpreter.installSegment5 (opcodeModHelloExplicit, new OpModAiSetting<ExplicitRef>(0));
|
||||
interpreter.installSegment5 (opcodeModFight, new OpModAiSetting<ImplicitRef>(1));
|
||||
interpreter.installSegment5 (opcodeModFightExplicit, new OpModAiSetting<ExplicitRef>(1));
|
||||
interpreter.installSegment5 (opcodeModFlee, new OpModAiSetting<ImplicitRef>(2));
|
||||
interpreter.installSegment5 (opcodeModFleeExplicit, new OpModAiSetting<ExplicitRef>(2));
|
||||
interpreter.installSegment5 (opcodeModAlarm, new OpModAiSetting<ImplicitRef>(3));
|
||||
interpreter.installSegment5 (opcodeModAlarmExplicit, new OpModAiSetting<ExplicitRef>(3));
|
||||
|
||||
interpreter.installSegment5 (opcodeGetHello, new OpGetAiSetting<ImplicitRef>(0));
|
||||
interpreter.installSegment5 (opcodeGetHelloExplicit, new OpGetAiSetting<ExplicitRef>(0));
|
||||
interpreter.installSegment5 (opcodeGetFight, new OpGetAiSetting<ImplicitRef>(1));
|
||||
interpreter.installSegment5 (opcodeGetFightExplicit, new OpGetAiSetting<ExplicitRef>(1));
|
||||
interpreter.installSegment5 (opcodeGetFlee, new OpGetAiSetting<ImplicitRef>(2));
|
||||
interpreter.installSegment5 (opcodeGetFleeExplicit, new OpGetAiSetting<ExplicitRef>(2));
|
||||
interpreter.installSegment5 (opcodeGetAlarm, new OpGetAiSetting<ImplicitRef>(3));
|
||||
interpreter.installSegment5 (opcodeGetAlarmExplicit, new OpGetAiSetting<ExplicitRef>(3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include "../mwworld/manualref.hpp"
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/containerstore.hpp"
|
||||
#include "../mwworld/actionequip.hpp"
|
||||
#include "../mwworld/inventorystore.hpp"
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
#include "ref.hpp"
|
||||
|
@ -128,12 +130,196 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpEquip : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute(Interpreter::Runtime &runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
std::string item = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(ptr).getInventoryStore (ptr);
|
||||
MWWorld::ContainerStoreIterator it = invStore.begin();
|
||||
for (; it != invStore.end(); ++it)
|
||||
{
|
||||
if (toLower(it->getCellRef().mRefID) == toLower(item))
|
||||
break;
|
||||
}
|
||||
if (it == invStore.end())
|
||||
throw std::runtime_error("Item to equip not found");
|
||||
|
||||
MWWorld::ActionEquip action (*it);
|
||||
action.execute(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpGetArmorType : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute(Interpreter::Runtime &runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Integer location = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
int slot;
|
||||
switch (location)
|
||||
{
|
||||
case 0:
|
||||
slot = MWWorld::InventoryStore::Slot_Helmet;
|
||||
break;
|
||||
case 1:
|
||||
slot = MWWorld::InventoryStore::Slot_Cuirass;
|
||||
break;
|
||||
case 2:
|
||||
slot = MWWorld::InventoryStore::Slot_LeftPauldron;
|
||||
break;
|
||||
case 3:
|
||||
slot = MWWorld::InventoryStore::Slot_RightPauldron;
|
||||
break;
|
||||
case 4:
|
||||
slot = MWWorld::InventoryStore::Slot_Greaves;
|
||||
break;
|
||||
case 5:
|
||||
slot = MWWorld::InventoryStore::Slot_Boots;
|
||||
break;
|
||||
case 6:
|
||||
slot = MWWorld::InventoryStore::Slot_LeftGauntlet;
|
||||
break;
|
||||
case 7:
|
||||
slot = MWWorld::InventoryStore::Slot_RightGauntlet;
|
||||
break;
|
||||
case 8:
|
||||
slot = MWWorld::InventoryStore::Slot_CarriedLeft; // shield
|
||||
break;
|
||||
case 9:
|
||||
slot = MWWorld::InventoryStore::Slot_LeftGauntlet;
|
||||
break;
|
||||
case 10:
|
||||
slot = MWWorld::InventoryStore::Slot_RightGauntlet;
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error ("armor index out of range");
|
||||
}
|
||||
|
||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(ptr).getInventoryStore (ptr);
|
||||
|
||||
MWWorld::ContainerStoreIterator it = invStore.getSlot (slot);
|
||||
if (it == invStore.end() || it->getTypeName () != typeid(ESM::Armor).name())
|
||||
{
|
||||
runtime.push(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
int skill = MWWorld::Class::get(*it).getEquipmentSkill (*it) ;
|
||||
if (skill == ESM::Skill::HeavyArmor)
|
||||
runtime.push(2);
|
||||
else if (skill == ESM::Skill::MediumArmor)
|
||||
runtime.push(1);
|
||||
else if (skill == ESM::Skill::LightArmor)
|
||||
runtime.push(0);
|
||||
else
|
||||
runtime.push(-1);
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpHasItemEquipped : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute(Interpreter::Runtime &runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
std::string item = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(ptr).getInventoryStore (ptr);
|
||||
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot)
|
||||
{
|
||||
MWWorld::ContainerStoreIterator it = invStore.getSlot (slot);
|
||||
if (it != invStore.end() && toLower(it->getCellRef().mRefID) == toLower(item))
|
||||
{
|
||||
runtime.push(1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
runtime.push(0);
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpHasSoulGem : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute(Interpreter::Runtime &runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
std::string creatureName = toLower (runtime.getStringLiteral (runtime[0].mInteger));
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(ptr).getInventoryStore (ptr);
|
||||
for (MWWorld::ContainerStoreIterator it = invStore.begin(MWWorld::ContainerStore::Type_Miscellaneous);
|
||||
it != invStore.end(); ++it)
|
||||
{
|
||||
|
||||
if (toLower(it->getCellRef().mSoul) == toLower(creatureName))
|
||||
{
|
||||
runtime.push(1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
runtime.push(0);
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpGetWeaponType : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute(Interpreter::Runtime &runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(ptr).getInventoryStore (ptr);
|
||||
MWWorld::ContainerStoreIterator it = invStore.getSlot (MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
if (it == invStore.end() || it->getTypeName () != typeid(ESM::Weapon).name())
|
||||
{
|
||||
runtime.push(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
runtime.push(it->get<ESM::Weapon>()->mBase->mData.mType);
|
||||
}
|
||||
};
|
||||
|
||||
const int opcodeAddItem = 0x2000076;
|
||||
const int opcodeAddItemExplicit = 0x2000077;
|
||||
const int opcodeGetItemCount = 0x2000078;
|
||||
const int opcodeGetItemCountExplicit = 0x2000079;
|
||||
const int opcodeRemoveItem = 0x200007a;
|
||||
const int opcodeRemoveItemExplicit = 0x200007b;
|
||||
const int opcodeEquip = 0x20001b3;
|
||||
const int opcodeEquipExplicit = 0x20001b4;
|
||||
const int opcodeGetArmorType = 0x20001d1;
|
||||
const int opcodeGetArmorTypeExplicit = 0x20001d2;
|
||||
const int opcodeHasItemEquipped = 0x20001d5;
|
||||
const int opcodeHasItemEquippedExplicit = 0x20001d6;
|
||||
const int opcodeHasSoulGem = 0x20001de;
|
||||
const int opcodeHasSoulGemExplicit = 0x20001df;
|
||||
const int opcodeGetWeaponType = 0x20001e0;
|
||||
const int opcodeGetWeaponTypeExplicit = 0x20001e1;
|
||||
|
||||
void registerExtensions (Compiler::Extensions& extensions)
|
||||
{
|
||||
|
@ -142,6 +328,11 @@ namespace MWScript
|
|||
opcodeGetItemCountExplicit);
|
||||
extensions.registerInstruction ("removeitem", "cl", opcodeRemoveItem,
|
||||
opcodeRemoveItemExplicit);
|
||||
extensions.registerInstruction ("equip", "c", opcodeEquip, opcodeEquipExplicit);
|
||||
extensions.registerFunction ("getarmortype", 'l', "l", opcodeGetArmorType, opcodeGetArmorTypeExplicit);
|
||||
extensions.registerFunction ("hasitemequipped", 'l', "c", opcodeHasItemEquipped, opcodeHasItemEquippedExplicit);
|
||||
extensions.registerFunction ("hassoulgem", 'l', "c", opcodeHasSoulGem, opcodeHasSoulGemExplicit);
|
||||
extensions.registerFunction ("getweapontype", 'l', "", opcodeGetWeaponType, opcodeGetWeaponTypeExplicit);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
|
@ -152,6 +343,16 @@ namespace MWScript
|
|||
interpreter.installSegment5 (opcodeGetItemCountExplicit, new OpGetItemCount<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeRemoveItem, new OpRemoveItem<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeRemoveItemExplicit, new OpRemoveItem<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeEquip, new OpEquip<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeEquipExplicit, new OpEquip<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetArmorType, new OpGetArmorType<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetArmorTypeExplicit, new OpGetArmorType<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeHasItemEquipped, new OpHasItemEquipped<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeHasItemEquippedExplicit, new OpHasItemEquipped<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeHasSoulGem, new OpHasSoulGem<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeHasSoulGemExplicit, new OpHasSoulGem<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetWeaponType, new OpGetWeaponType<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetWeaponTypeExplicit, new OpGetWeaponType<ExplicitRef>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,6 +106,58 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpGetForceRun : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(ptr).getNpcStats (ptr);
|
||||
|
||||
runtime.push (npcStats.getMovementFlag (MWMechanics::NpcStats::Flag_ForceRun));
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpGetForceSneak : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(ptr).getNpcStats (ptr);
|
||||
|
||||
runtime.push (npcStats.getMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak));
|
||||
}
|
||||
};
|
||||
|
||||
class OpGetPcRunning : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer();
|
||||
runtime.push (MWWorld::Class::get(ptr).getStance (ptr, MWWorld::Class::Run));
|
||||
}
|
||||
};
|
||||
|
||||
class OpGetPcSneaking : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer();
|
||||
runtime.push (MWWorld::Class::get(ptr).getStance (ptr, MWWorld::Class::Sneak));
|
||||
}
|
||||
};
|
||||
|
||||
const int numberOfControls = 7;
|
||||
|
||||
const int opcodeEnable = 0x200007e;
|
||||
|
@ -120,6 +172,12 @@ namespace MWScript
|
|||
const int opcodeForceSneak = 0x200015a;
|
||||
const int opcodeForceSneakExplicit = 0x200015b;
|
||||
const int opcodeGetDisabled = 0x2000175;
|
||||
const int opcodeGetPcRunning = 0x20001c9;
|
||||
const int opcodeGetPcSneaking = 0x20001ca;
|
||||
const int opcodeGetForceRun = 0x20001cb;
|
||||
const int opcodeGetForceSneak = 0x20001cc;
|
||||
const int opcodeGetForceRunExplicit = 0x20001cd;
|
||||
const int opcodeGetForceSneakExplicit = 0x20001ce;
|
||||
|
||||
const char *controls[numberOfControls] =
|
||||
{
|
||||
|
@ -151,6 +209,10 @@ namespace MWScript
|
|||
opcodeClearForceSneakExplicit);
|
||||
extensions.registerInstruction ("forcesneak", "", opcodeForceSneak,
|
||||
opcodeForceSneakExplicit);
|
||||
extensions.registerFunction ("getpcrunning", 'l', "", opcodeGetPcRunning);
|
||||
extensions.registerFunction ("getpcsneaking", 'l', "", opcodeGetPcSneaking);
|
||||
extensions.registerFunction ("getforcerun", 'l', "", opcodeGetForceRun, opcodeGetForceRunExplicit);
|
||||
extensions.registerFunction ("getforcesneak", 'l', "", opcodeGetForceSneak, opcodeGetForceSneakExplicit);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
|
@ -181,6 +243,12 @@ namespace MWScript
|
|||
new OpClearMovementFlag<ExplicitRef> (MWMechanics::NpcStats::Flag_ForceSneak));
|
||||
interpreter.installSegment5 (opcodeForceSneakExplicit,
|
||||
new OpSetMovementFlag<ExplicitRef> (MWMechanics::NpcStats::Flag_ForceSneak));
|
||||
interpreter.installSegment5 (opcodeGetPcRunning, new OpGetPcRunning);
|
||||
interpreter.installSegment5 (opcodeGetPcSneaking, new OpGetPcSneaking);
|
||||
interpreter.installSegment5 (opcodeGetForceRun, new OpGetForceRun<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetForceRunExplicit, new OpGetForceRun<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetForceSneak, new OpGetForceSneak<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetForceSneakExplicit, new OpGetForceSneak<ExplicitRef>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "../mwbase/journal.hpp"
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
#include "../mwmechanics/npcstats.hpp"
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
|
@ -159,6 +160,33 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpGetReputation : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
runtime.push (MWWorld::Class::get(ptr).getNpcStats (ptr).getReputation ());
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpSameFaction : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer();
|
||||
|
||||
runtime.push (MWWorld::Class::get(ptr).getNpcStats (ptr).isSameFaction (MWWorld::Class::get(player).getNpcStats (player)));
|
||||
}
|
||||
};
|
||||
|
||||
const int opcodeJournal = 0x2000133;
|
||||
const int opcodeSetJournalIndex = 0x2000134;
|
||||
|
@ -172,6 +200,10 @@ namespace MWScript
|
|||
const int opcodeModReputation = 0x20001ae;
|
||||
const int opcodeSetReputationExplicit = 0x20001af;
|
||||
const int opcodeModReputationExplicit = 0x20001b0;
|
||||
const int opcodeGetReputation = 0x20001b1;
|
||||
const int opcodeGetReputationExplicit = 0x20001b2;
|
||||
const int opcodeSameFaction = 0x20001b5;
|
||||
const int opcodeSameFactionExplicit = 0x20001b6;
|
||||
|
||||
void registerExtensions (Compiler::Extensions& extensions)
|
||||
{
|
||||
|
@ -188,6 +220,10 @@ namespace MWScript
|
|||
opcodeSetReputationExplicit);
|
||||
extensions.registerInstruction("modreputation", "l", opcodeModReputation,
|
||||
opcodeModReputationExplicit);
|
||||
extensions.registerFunction("getreputation", 'l', "", opcodeGetReputation,
|
||||
opcodeGetReputationExplicit);
|
||||
extensions.registerFunction("samefaction", 'l', "", opcodeSameFaction,
|
||||
opcodeSameFactionExplicit);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
|
@ -200,10 +236,14 @@ namespace MWScript
|
|||
interpreter.installSegment5 (opcodeForceGreeting, new OpForceGreeting<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeForceGreetingExplicit, new OpForceGreeting<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGoodbye, new OpGoodbye);
|
||||
interpreter.installSegment5 (opcodeGetReputation, new OpGetReputation<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetReputation, new OpSetReputation<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeModReputation, new OpModReputation<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetReputationExplicit, new OpSetReputation<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeModReputationExplicit, new OpModReputation<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetReputationExplicit, new OpGetReputation<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSameFaction, new OpSameFaction<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSameFactionExplicit, new OpSameFaction<ExplicitRef>);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,13 @@ op 0x20014: SetPCFacRep
|
|||
op 0x20015: SetPCFacRep, explicit reference
|
||||
op 0x20016: ModPCFacRep
|
||||
op 0x20017: ModPCFacRep, explicit reference
|
||||
op s 0x20018-0x3ffff unused
|
||||
op 0x20018: PcExpelled
|
||||
op 0x20019: PcExpelled, explicit
|
||||
op 0x2001a: PcExpell
|
||||
op 0x2001b: PcExpell, explicit
|
||||
op 0x2001c: PcClearExpelled
|
||||
op 0x2001d: PcClearExpelled, explicit
|
||||
op s 0x2001e-0x3ffff unused
|
||||
|
||||
Segment 4:
|
||||
(not implemented yet)
|
||||
|
@ -226,5 +232,67 @@ op 0x20001ad: SetReputation
|
|||
op 0x20001ae: ModReputation
|
||||
op 0x20001af: SetReputation, explicit
|
||||
op 0x20001b0: ModReputation, explicit
|
||||
opcodes 0x20001b1-0x3ffffff unused
|
||||
op 0x20001b1: GetReputation
|
||||
op 0x20001b2: GetReputation, explicit
|
||||
op 0x20001b3: Equip
|
||||
op 0x20001b4: Equip, explicit
|
||||
op 0x20001b5: SameFaction
|
||||
op 0x20001b6: SameFaction, explicit
|
||||
op 0x20001b7: ModHello
|
||||
op 0x20001b8: ModHello, explicit reference
|
||||
op 0x20001b9: ModFight
|
||||
op 0x20001ba: ModFight, explicit reference
|
||||
op 0x20001bb: ModFlee
|
||||
op 0x20001bc: ModFlee, explicit reference
|
||||
op 0x20001bd: ModAlarm
|
||||
op 0x20001be: ModAlarm, explicit reference
|
||||
op 0x20001bf: GetHello
|
||||
op 0x20001c0: GetHello, explicit reference
|
||||
op 0x20001c1: GetFight
|
||||
op 0x20001c2: GetFight, explicit reference
|
||||
op 0x20001c3: GetFlee
|
||||
op 0x20001c4: GetFlee, explicit reference
|
||||
op 0x20001c5: GetAlarm
|
||||
op 0x20001c6: GetAlarm, explicit reference
|
||||
op 0x20001c7: GetLocked
|
||||
op 0x20001c8: GetLocked, explicit reference
|
||||
op 0x20001c9: GetPcRunning
|
||||
op 0x20001ca: GetPcSneaking
|
||||
op 0x20001cb: GetForceRun
|
||||
op 0x20001cc: GetForceSneak
|
||||
op 0x20001cd: GetForceRun, explicit
|
||||
op 0x20001ce: GetForceSneak, explicit
|
||||
op 0x20001cf: GetEffect
|
||||
op 0x20001d0: GetEffect, explicit
|
||||
op 0x20001d1: GetArmorType
|
||||
op 0x20001d2: GetArmorType, explicit
|
||||
op 0x20001d3: GetAttacked
|
||||
op 0x20001d4: GetAttacked, explicit
|
||||
op 0x20001d5: HasItemEquipped
|
||||
op 0x20001d6: HasItemEquipped, explicit
|
||||
op 0x20001d7: GetWeaponDrawn
|
||||
op 0x20001d8: GetWeaponDrawn, explicit
|
||||
op 0x20001d9: GetRace
|
||||
op 0x20001da: GetRace, explicit
|
||||
op 0x20001db: GetSpellEffects
|
||||
op 0x20001dc: GetSpellEffects, explicit
|
||||
op 0x20001dd: GetCurrentTime
|
||||
op 0x20001de: HasSoulGem
|
||||
op 0x20001df: HasSoulGem, explicit
|
||||
op 0x20001e0: GetWeaponType
|
||||
op 0x20001e1: GetWeaponType, explicit
|
||||
op 0x20001e2: GetWerewolfKills
|
||||
op 0x20001e3: ModScale
|
||||
op 0x20001e4: ModScale, explicit
|
||||
op 0x20001e5: SetDelete
|
||||
op 0x20001e6: SetDelete, explicit
|
||||
op 0x20001e7: GetSquareRoot
|
||||
op 0x20001e8: RaiseRank
|
||||
op 0x20001e9: RaiseRank, explicit
|
||||
op 0x20001ea: LowerRank
|
||||
op 0x20001eb: LowerRank, explicit
|
||||
|
||||
opcodes 0x20001ec-0x3ffffff unused
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
|
||||
#include "../mwmechanics/npcstats.hpp"
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
#include "ref.hpp"
|
||||
|
@ -272,6 +276,121 @@ namespace MWScript
|
|||
};
|
||||
bool OpToggleVanityMode::sActivate = true;
|
||||
|
||||
template <class R>
|
||||
class OpGetLocked : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
runtime.push (ptr.getCellRef ().mLockLevel > 0);
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpGetEffect : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
int key = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
runtime.push (MWWorld::Class::get(ptr).getCreatureStats (ptr).getMagicEffects ().get (
|
||||
MWMechanics::EffectKey(key)).mMagnitude > 0);
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpGetAttacked : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
runtime.push(MWWorld::Class::get(ptr).getCreatureStats (ptr).getAttacked ());
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpGetWeaponDrawn : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
runtime.push(MWWorld::Class::get(ptr).getNpcStats (ptr).getDrawState () == MWMechanics::DrawState_Weapon);
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpGetSpellEffects : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
std::string id = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
runtime.push(MWWorld::Class::get(ptr).getCreatureStats(ptr).getActiveSpells().isSpellActive(id));
|
||||
}
|
||||
};
|
||||
|
||||
class OpGetCurrentTime : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
runtime.push(MWBase::Environment::get().getWorld()->getTimeStamp().getHour());
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpSetDelete : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
int parameter = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
if (parameter == 1)
|
||||
{
|
||||
if (ptr.isInCell())
|
||||
MWBase::Environment::get().getWorld()->deleteObject (ptr);
|
||||
else
|
||||
ptr.getRefData().setCount(0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class OpGetSquareRoot : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
float param = runtime[0].mFloat;
|
||||
runtime.pop();
|
||||
|
||||
runtime.push(std::sqrt (param));
|
||||
}
|
||||
};
|
||||
|
||||
const int opcodeXBox = 0x200000c;
|
||||
const int opcodeOnActivate = 0x200000d;
|
||||
const int opcodeActivate = 0x2000075;
|
||||
|
@ -291,6 +410,20 @@ namespace MWScript
|
|||
const int opcodeToggleVanityMode = 0x2000174;
|
||||
const int opcodeGetPcSleep = 0x200019f;
|
||||
const int opcodeWakeUpPc = 0x20001a2;
|
||||
const int opcodeGetLocked = 0x20001c7;
|
||||
const int opcodeGetLockedExplicit = 0x20001c8;
|
||||
const int opcodeGetEffect = 0x20001cf;
|
||||
const int opcodeGetEffectExplicit = 0x20001d0;
|
||||
const int opcodeGetAttacked = 0x20001d3;
|
||||
const int opcodeGetAttackedExplicit = 0x20001d4;
|
||||
const int opcodeGetWeaponDrawn = 0x20001d7;
|
||||
const int opcodeGetWeaponDrawnExplicit = 0x20001d8;
|
||||
const int opcodeGetSpellEffects = 0x20001db;
|
||||
const int opcodeGetSpellEffectsExplicit = 0x20001dc;
|
||||
const int opcodeGetCurrentTime = 0x20001dd;
|
||||
const int opcodeSetDelete = 0x20001e5;
|
||||
const int opcodeSetDeleteExplicit = 0x20001e6;
|
||||
const int opcodeGetSquareRoot = 0x20001e7;
|
||||
|
||||
void registerExtensions (Compiler::Extensions& extensions)
|
||||
{
|
||||
|
@ -317,6 +450,14 @@ namespace MWScript
|
|||
extensions.registerInstruction ("tvm", "", opcodeToggleVanityMode);
|
||||
extensions.registerFunction ("getpcsleep", 'l', "", opcodeGetPcSleep);
|
||||
extensions.registerInstruction ("wakeuppc", "", opcodeWakeUpPc);
|
||||
extensions.registerFunction ("getlocked", 'l', "", opcodeGetLocked, opcodeGetLockedExplicit);
|
||||
extensions.registerFunction ("geteffect", 'l', "l", opcodeGetEffect, opcodeGetEffectExplicit);
|
||||
extensions.registerFunction ("getattacked", 'l', "", opcodeGetAttacked, opcodeGetAttackedExplicit);
|
||||
extensions.registerFunction ("getweapondrawn", 'l', "", opcodeGetWeaponDrawn, opcodeGetWeaponDrawnExplicit);
|
||||
extensions.registerFunction ("getspelleffects", 'l', "c", opcodeGetSpellEffects, opcodeGetSpellEffectsExplicit);
|
||||
extensions.registerFunction ("getcurrenttime", 'f', "", opcodeGetCurrentTime);
|
||||
extensions.registerInstruction ("setdelete", "l", opcodeSetDelete, opcodeSetDeleteExplicit);
|
||||
extensions.registerFunction ("getsquareroot", 'f', "f", opcodeGetSquareRoot);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
|
@ -340,6 +481,20 @@ namespace MWScript
|
|||
interpreter.installSegment5 (opcodeToggleVanityMode, new OpToggleVanityMode);
|
||||
interpreter.installSegment5 (opcodeGetPcSleep, new OpGetPcSleep);
|
||||
interpreter.installSegment5 (opcodeWakeUpPc, new OpWakeUpPc);
|
||||
interpreter.installSegment5 (opcodeGetLocked, new OpGetLocked<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetLockedExplicit, new OpGetLocked<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetEffect, new OpGetEffect<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetEffectExplicit, new OpGetEffect<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetAttacked, new OpGetAttacked<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetAttackedExplicit, new OpGetAttacked<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetWeaponDrawn, new OpGetWeaponDrawn<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetWeaponDrawnExplicit, new OpGetWeaponDrawn<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetSpellEffects, new OpGetSpellEffects<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetSpellEffectsExplicit, new OpGetSpellEffects<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetCurrentTime, new OpGetCurrentTime);
|
||||
interpreter.installSegment5 (opcodeSetDelete, new OpSetDelete<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetDeleteExplicit, new OpSetDelete<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetSquareRoot, new OpGetSquareRoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -780,6 +780,210 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpGetRace : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
std::string race = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
boost::algorithm::to_lower(race);
|
||||
runtime.pop();
|
||||
|
||||
std::string npcRace = ptr.get<ESM::NPC>()->mBase->mRace;
|
||||
boost::algorithm::to_lower(npcRace);
|
||||
|
||||
runtime.push (npcRace == race);
|
||||
}
|
||||
};
|
||||
|
||||
class OpGetWerewolfKills : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer ();
|
||||
|
||||
runtime.push (MWWorld::Class::get(ptr).getNpcStats (ptr).getWerewolfKills ());
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpPcExpelled : public Interpreter::Opcode1
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
std::string factionID = "";
|
||||
if(arg0 >0 )
|
||||
{
|
||||
factionID = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks().empty())
|
||||
{
|
||||
factionID = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
factionID = MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks().begin()->first;
|
||||
}
|
||||
}
|
||||
boost::algorithm::to_lower(factionID);
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
if(factionID!="")
|
||||
{
|
||||
std::set<std::string>& expelled = MWWorld::Class::get(player).getNpcStats(player).getExpelled ();
|
||||
if (expelled.find (factionID) != expelled.end())
|
||||
{
|
||||
runtime.push(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
runtime.push(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
runtime.push(0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpPcExpell : public Interpreter::Opcode1
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
std::string factionID = "";
|
||||
if(arg0 >0 )
|
||||
{
|
||||
factionID = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks().empty())
|
||||
{
|
||||
factionID = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
factionID = MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks().begin()->first;
|
||||
}
|
||||
}
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
if(factionID!="")
|
||||
{
|
||||
std::set<std::string>& expelled = MWWorld::Class::get(player).getNpcStats(player).getExpelled ();
|
||||
boost::algorithm::to_lower(factionID);
|
||||
expelled.insert(factionID);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpPcClearExpelled : public Interpreter::Opcode1
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
std::string factionID = "";
|
||||
if(arg0 >0 )
|
||||
{
|
||||
factionID = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks().empty())
|
||||
{
|
||||
factionID = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
factionID = MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks().begin()->first;
|
||||
}
|
||||
}
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
if(factionID!="")
|
||||
{
|
||||
std::set<std::string>& expelled = MWWorld::Class::get(player).getNpcStats(player).getExpelled ();
|
||||
boost::algorithm::to_lower(factionID);
|
||||
expelled.erase (factionID);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpRaiseRank : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
std::string factionID = "";
|
||||
if(MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks().empty())
|
||||
return;
|
||||
else
|
||||
{
|
||||
factionID = MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks().begin()->first;
|
||||
}
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
|
||||
// no-op when executed on the player
|
||||
if (ptr == player)
|
||||
return;
|
||||
|
||||
std::map<std::string, int>& ranks = MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks ();
|
||||
ranks[factionID] = ranks[factionID]+1;
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpLowerRank : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
std::string factionID = "";
|
||||
if(MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks().empty())
|
||||
return;
|
||||
else
|
||||
{
|
||||
factionID = MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks().begin()->first;
|
||||
}
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
|
||||
// no-op when executed on the player
|
||||
if (ptr == player)
|
||||
return;
|
||||
|
||||
std::map<std::string, int>& ranks = MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks ();
|
||||
ranks[factionID] = ranks[factionID]-1;
|
||||
}
|
||||
};
|
||||
|
||||
const int numberOfAttributes = 8;
|
||||
|
||||
|
@ -850,6 +1054,22 @@ namespace MWScript
|
|||
const int opcodeGetBlightDisease = 0x20001aa;
|
||||
const int opcodeGetBlightDiseaseExplicit = 0x20001ab;
|
||||
|
||||
const int opcodeGetRace = 0x20001d9;
|
||||
const int opcodeGetRaceExplicit = 0x20001da;
|
||||
|
||||
const int opcodeGetWerewolfKills = 0x20001e2;
|
||||
|
||||
const int opcodePcExpelled = 0x20018;
|
||||
const int opcodePcExpelledExplicit = 0x20019;
|
||||
const int opcodePcExpell = 0x2001a;
|
||||
const int opcodePcExpellExplicit = 0x2001b;
|
||||
const int opcodePcClearExpelled = 0x2001c;
|
||||
const int opcodePcClearExpelledExplicit = 0x2001d;
|
||||
const int opcodeRaiseRank = 0x20001e8;
|
||||
const int opcodeRaiseRankExplicit = 0x20001e9;
|
||||
const int opcodeLowerRank = 0x20001ea;
|
||||
const int opcodeLowerRankExplicit = 0x20001eb;
|
||||
|
||||
void registerExtensions (Compiler::Extensions& extensions)
|
||||
{
|
||||
static const char *attributes[numberOfAttributes] =
|
||||
|
@ -870,7 +1090,7 @@ namespace MWScript
|
|||
"alteration", "illusion", "conjuration", "mysticism",
|
||||
"restoration", "alchemy", "unarmored", "security", "sneak",
|
||||
"acrobatics", "lightarmor", "shortblade", "marksman",
|
||||
"merchantile", "speechcraft", "handtohand"
|
||||
"mercantile", "speechcraft", "handtohand"
|
||||
};
|
||||
|
||||
std::string get ("get");
|
||||
|
@ -950,6 +1170,15 @@ namespace MWScript
|
|||
opcodeGetCommonDiseaseExplicit);
|
||||
extensions.registerFunction ("getblightdisease", 'l', "", opcodeGetBlightDisease,
|
||||
opcodeGetBlightDiseaseExplicit);
|
||||
|
||||
extensions.registerFunction ("getrace", 'l', "c", opcodeGetRace,
|
||||
opcodeGetRaceExplicit);
|
||||
extensions.registerFunction ("getwerewolfkills", 'f', "", opcodeGetWerewolfKills);
|
||||
extensions.registerFunction ("pcexpelled", 'l', "/S", opcodePcExpelled, opcodePcExpelledExplicit);
|
||||
extensions.registerInstruction ("pcexpell", "/S", opcodePcExpell, opcodePcExpellExplicit);
|
||||
extensions.registerInstruction ("pcclearexpelled", "/S", opcodePcClearExpelled, opcodePcClearExpelledExplicit);
|
||||
extensions.registerInstruction ("raiserank", "", opcodeRaiseRank, opcodeRaiseRankExplicit);
|
||||
extensions.registerInstruction ("lowerrank", "", opcodeLowerRank, opcodeLowerRankExplicit);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
|
@ -1045,6 +1274,21 @@ namespace MWScript
|
|||
interpreter.installSegment5 (opcodeGetCommonDiseaseExplicit, new OpGetCommonDisease<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetBlightDisease, new OpGetBlightDisease<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetBlightDiseaseExplicit, new OpGetBlightDisease<ExplicitRef>);
|
||||
|
||||
interpreter.installSegment5 (opcodeGetRace, new OpGetRace<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetRaceExplicit, new OpGetRace<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetWerewolfKills, new OpGetWerewolfKills);
|
||||
|
||||
interpreter.installSegment3 (opcodePcExpelled, new OpPcExpelled<ImplicitRef>);
|
||||
interpreter.installSegment3 (opcodePcExpelledExplicit, new OpPcExpelled<ExplicitRef>);
|
||||
interpreter.installSegment3 (opcodePcExpell, new OpPcExpell<ImplicitRef>);
|
||||
interpreter.installSegment3 (opcodePcExpellExplicit, new OpPcExpell<ExplicitRef>);
|
||||
interpreter.installSegment3 (opcodePcClearExpelled, new OpPcClearExpelled<ImplicitRef>);
|
||||
interpreter.installSegment3 (opcodePcClearExpelledExplicit, new OpPcClearExpelled<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeRaiseRank, new OpRaiseRank<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeRaiseRankExplicit, new OpRaiseRank<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeLowerRank, new OpLowerRank<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeLowerRankExplicit, new OpLowerRank<ExplicitRef>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,23 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpModScale : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Float scale = runtime[0].mFloat;
|
||||
runtime.pop();
|
||||
|
||||
// add the parameter to the object's scale.
|
||||
MWBase::Environment::get().getWorld()->scaleObject(ptr,ptr.getCellRef().mScale + scale);
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpSetAngle : public Interpreter::Opcode0
|
||||
{
|
||||
|
@ -532,6 +549,8 @@ namespace MWScript
|
|||
const int opcodePlaceAtPc = 0x200019c;
|
||||
const int opcodePlaceAtMe = 0x200019d;
|
||||
const int opcodePlaceAtMeExplicit = 0x200019e;
|
||||
const int opcodeModScale = 0x20001e3;
|
||||
const int opcodeModScaleExplicit = 0x20001e4;
|
||||
|
||||
void registerExtensions (Compiler::Extensions& extensions)
|
||||
{
|
||||
|
@ -548,6 +567,7 @@ namespace MWScript
|
|||
extensions.registerInstruction("placeitem","cffff",opcodePlaceItem);
|
||||
extensions.registerInstruction("placeatpc","clfl",opcodePlaceAtPc);
|
||||
extensions.registerInstruction("placeatme","clfl",opcodePlaceAtMe,opcodePlaceAtMeExplicit);
|
||||
extensions.registerInstruction("modscale","f",opcodeModScale,opcodeModScaleExplicit);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
|
@ -574,7 +594,9 @@ namespace MWScript
|
|||
interpreter.installSegment5(opcodePlaceItem,new OpPlaceItem<ImplicitRef>);
|
||||
interpreter.installSegment5(opcodePlaceAtPc,new OpPlaceAtPc<ImplicitRef>);
|
||||
interpreter.installSegment5(opcodePlaceAtMe,new OpPlaceAtMe<ImplicitRef>);
|
||||
interpreter.installSegment5(opcodePlaceAtMeExplicit,new OpPlaceAtMe<ExplicitRef>);
|
||||
interpreter.installSegment5(opcodePlaceAtMeExplicit,new OpPlaceAtMe<ExplicitRef>);
|
||||
interpreter.installSegment5(opcodeModScale,new OpModScale<ImplicitRef>);
|
||||
interpreter.installSegment5(opcodeModScaleExplicit,new OpModScale<ExplicitRef>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ namespace MWWorld
|
|||
mRendering->attachCameraTo(mPlayer->getPlayer());
|
||||
|
||||
mPhysics->addActor(mPlayer->getPlayer());
|
||||
|
||||
|
||||
// global variables
|
||||
mGlobalVariables = new Globals (mStore);
|
||||
|
||||
|
@ -203,6 +203,8 @@ namespace MWWorld
|
|||
mGlobalVariables->setInt ("chargenstate", 1);
|
||||
}
|
||||
|
||||
mGlobalVariables->setInt ("pcrace", 3);
|
||||
|
||||
mWorldScene = new Scene(*mRendering, mPhysics);
|
||||
|
||||
setFallbackValues(fallbackMap);
|
||||
|
@ -660,7 +662,7 @@ namespace MWWorld
|
|||
{
|
||||
MWWorld::Class::get(ptr).adjustScale(ptr,scale);
|
||||
ptr.getCellRef().mScale = scale;
|
||||
|
||||
|
||||
if(ptr.getRefData().getBaseNode() == 0)
|
||||
return;
|
||||
mRendering->scaleObject(ptr, Vector3(scale,scale,scale));
|
||||
|
@ -673,7 +675,7 @@ namespace MWWorld
|
|||
rot.x = Ogre::Degree(x).valueRadians();
|
||||
rot.y = Ogre::Degree(y).valueRadians();
|
||||
rot.z = Ogre::Degree(z).valueRadians();
|
||||
|
||||
|
||||
float *objRot = ptr.getRefData().getPosition().rot;
|
||||
if(ptr.getRefData().getBaseNode() == 0 || !mRendering->rotateObject(ptr, rot, adjust))
|
||||
{
|
||||
|
@ -781,7 +783,7 @@ namespace MWWorld
|
|||
|
||||
const ESM::Potion *World::createRecord (const ESM::Potion& record)
|
||||
{
|
||||
return mStore.insert(record);
|
||||
return mStore.insert(record);
|
||||
}
|
||||
|
||||
const ESM::Class *World::createRecord (const ESM::Class& record)
|
||||
|
@ -802,7 +804,23 @@ namespace MWWorld
|
|||
const ESM::NPC *World::createRecord(const ESM::NPC &record)
|
||||
{
|
||||
bool update = false;
|
||||
if (StringUtils::ciEqual(record.mId, "player")) {
|
||||
|
||||
if (StringUtils::ciEqual(record.mId, "player"))
|
||||
{
|
||||
static const char *sRaces[] =
|
||||
{
|
||||
"Argonian", "Breton", "Dark Elf", "High Elf", "Imperial", "Khajiit", "Nord", "Orc", "Redguard",
|
||||
"Woodelf", 0
|
||||
};
|
||||
|
||||
int i=0;
|
||||
|
||||
for (; sRaces[i]; ++i)
|
||||
if (StringUtils::ciEqual (sRaces[i], record.mRace))
|
||||
break;
|
||||
|
||||
mGlobalVariables->setInt ("pcrace", sRaces[i] ? i+1 : 0);
|
||||
|
||||
const ESM::NPC *player =
|
||||
mPlayer->getPlayer().get<ESM::NPC>()->mBase;
|
||||
|
||||
|
@ -834,7 +852,7 @@ namespace MWWorld
|
|||
/// \todo split this function up into subfunctions
|
||||
|
||||
mWorldScene->update (duration, paused);
|
||||
|
||||
|
||||
float pitch, yaw;
|
||||
Ogre::Vector3 eyepos;
|
||||
mRendering->getPlayerData(eyepos, pitch, yaw);
|
||||
|
|
|
@ -69,12 +69,9 @@ Allowed options:
|
|||
--script-all [=arg(=1)] (=0) compile all scripts (excluding dialogue scri
|
||||
pts) at startup
|
||||
--script-console [=arg(=1)] (=0) enable console-only script functionality
|
||||
--script-run arg select a file that is executed in the consol
|
||||
e on startup
|
||||
--script-run arg select a file containing a list of console
|
||||
commands that is executed on startup
|
||||
|
||||
Note: The file contains a list of script
|
||||
lines, but not a complete scripts. That mean
|
||||
s no begin/end and no variable declarations.
|
||||
--new-game [=arg(=1)] (=0) activate char gen/new game mechanics
|
||||
--fs-strict [=arg(=1)] (=0) strict file system handling (no case folding
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue