1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-12-08 22:04:31 +00:00

Merge remote-tracking branch 'origin/master' into createnewpeople

This commit is contained in:
SkyHasACat 2025-08-03 12:14:10 -07:00
commit 4a2f85cfde
83 changed files with 280 additions and 234 deletions

View file

@ -82,7 +82,7 @@ message(STATUS "Configuring OpenMW...")
set(OPENMW_VERSION_MAJOR 0) set(OPENMW_VERSION_MAJOR 0)
set(OPENMW_VERSION_MINOR 50) set(OPENMW_VERSION_MINOR 50)
set(OPENMW_VERSION_RELEASE 0) set(OPENMW_VERSION_RELEASE 0)
set(OPENMW_LUA_API_REVISION 86) set(OPENMW_LUA_API_REVISION 87)
set(OPENMW_POSTPROCESSING_API_REVISION 3) set(OPENMW_POSTPROCESSING_API_REVISION 3)
set(OPENMW_VERSION_COMMITHASH "") set(OPENMW_VERSION_COMMITHASH "")

View file

@ -5,7 +5,8 @@
#include <future> #include <future>
#include <system_error> #include <system_error>
#include <osgDB/WriteFile> #include <osgDB/ReaderWriter>
#include <osgDB/Registry>
#include <osgViewer/ViewerEventHandlers> #include <osgViewer/ViewerEventHandlers>
#include <SDL.h> #include <SDL.h>
@ -28,7 +29,6 @@
#include <components/compiler/extensions0.hpp> #include <components/compiler/extensions0.hpp>
#include <components/stereo/multiview.hpp>
#include <components/stereo/stereomanager.hpp> #include <components/stereo/stereomanager.hpp>
#include <components/sceneutil/glextensions.hpp> #include <components/sceneutil/glextensions.hpp>

View file

@ -75,6 +75,7 @@ namespace MWBase
const MWRender::AnimPriority& priority, int blendMask, bool autodisable, float speedmult, const MWRender::AnimPriority& priority, int blendMask, bool autodisable, float speedmult,
std::string_view start, std::string_view stop, float startpoint, uint32_t loops, bool loopfallback) std::string_view start, std::string_view stop, float startpoint, uint32_t loops, bool loopfallback)
= 0; = 0;
virtual void jailTimeServed(const MWWorld::Ptr& actor, int days) = 0;
virtual void skillLevelUp(const MWWorld::Ptr& actor, ESM::RefId skillId, std::string_view source) = 0; virtual void skillLevelUp(const MWWorld::Ptr& actor, ESM::RefId skillId, std::string_view source) = 0;
virtual void skillUse(const MWWorld::Ptr& actor, ESM::RefId skillId, int useType, float scale) = 0; virtual void skillUse(const MWWorld::Ptr& actor, ESM::RefId skillId, int useType, float scale) = 0;
virtual void onHit(const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim, const MWWorld::Ptr& weapon, virtual void onHit(const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim, const MWWorld::Ptr& weapon,

View file

@ -4,6 +4,7 @@
#include <components/misc/strings/format.hpp> #include <components/misc/strings/format.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/luamanager.hpp"
#include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
@ -86,46 +87,6 @@ namespace MWGui
// We should not worsen corprus when in prison // We should not worsen corprus when in prison
player.getClass().getCreatureStats(player).getActiveSpells().skipWorsenings(mDays * 24); player.getClass().getCreatureStats(player).getActiveSpells().skipWorsenings(mDays * 24);
MWBase::Environment::get().getLuaManager()->jailTimeServed(player, mDays);
const auto& skillStore = MWBase::Environment::get().getESMStore()->get<ESM::Skill>();
std::set<const ESM::Skill*> skills;
for (int day = 0; day < mDays; ++day)
{
auto& prng = MWBase::Environment::get().getWorld()->getPrng();
const ESM::Skill* skill = skillStore.searchRandom({}, prng);
skills.insert(skill);
MWMechanics::SkillValue& value = player.getClass().getNpcStats(player).getSkill(skill->mId);
if (skill->mId == ESM::Skill::Security || skill->mId == ESM::Skill::Sneak)
value.setBase(std::min(100.f, value.getBase() + 1));
else
value.setBase(std::max(0.f, value.getBase() - 1));
}
const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
std::string message;
if (mDays == 1)
message = gmst.find("sNotifyMessage42")->mValue.getString();
else
message = gmst.find("sNotifyMessage43")->mValue.getString();
message = Misc::StringUtils::format(message, mDays);
for (const ESM::Skill* skill : skills)
{
int skillValue = player.getClass().getNpcStats(player).getSkill(skill->mId).getBase();
std::string skillMsg = gmst.find("sNotifyMessage44")->mValue.getString();
if (skill->mId == ESM::Skill::Sneak || skill->mId == ESM::Skill::Security)
skillMsg = gmst.find("sNotifyMessage39")->mValue.getString();
skillMsg = Misc::StringUtils::format(skillMsg, skill->mName, skillValue);
message += "\n" + skillMsg;
}
std::vector<std::string> buttons;
buttons.emplace_back("#{Interface:OK}");
MWBase::Environment::get().getWindowManager()->interactiveMessageBox(message, buttons);
} }
} }

View file

@ -774,12 +774,10 @@ namespace MWGui
, mGlobalMapRender(std::make_unique<MWRender::GlobalMap>(localMapRender->getRoot(), workQueue)) , mGlobalMapRender(std::make_unique<MWRender::GlobalMap>(localMapRender->getRoot(), workQueue))
, mEditNoteDialog() , mEditNoteDialog()
{ {
static bool registered = false; [[maybe_unused]] static const bool registered = [] {
if (!registered)
{
MyGUI::FactoryManager::getInstance().registerFactory<MarkerWidget>("Widget"); MyGUI::FactoryManager::getInstance().registerFactory<MarkerWidget>("Widget");
registered = true; return true;
} }();
mEditNoteDialog.setVisible(false); mEditNoteDialog.setVisible(false);
mEditNoteDialog.eventOkClicked += MyGUI::newDelegate(this, &MapWindow::onNoteEditOk); mEditNoteDialog.eventOkClicked += MyGUI::newDelegate(this, &MapWindow::onNoteEditOk);

View file

@ -352,6 +352,7 @@ namespace MWGui
getWidget(mAvailableEffectsList, "AvailableEffects"); getWidget(mAvailableEffectsList, "AvailableEffects");
getWidget(mUsedEffectsView, "UsedEffects"); getWidget(mUsedEffectsView, "UsedEffects");
getWidget(mPriceLabel, "PriceLabel"); getWidget(mPriceLabel, "PriceLabel");
getWidget(mPlayerGold, "PlayerGold");
getWidget(mBuyButton, "BuyButton"); getWidget(mBuyButton, "BuyButton");
getWidget(mCancelButton, "CancelButton"); getWidget(mCancelButton, "CancelButton");
@ -370,6 +371,10 @@ namespace MWGui
mPtr = actor; mPtr = actor;
mNameEdit->setCaption({}); mNameEdit->setCaption({});
MWWorld::Ptr player = MWMechanics::getPlayer();
int playerGold = player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId);
mPlayerGold->setCaptionWithReplacing(MyGUI::utility::toString(playerGold));
startEditing(); startEditing();
} }

View file

@ -175,6 +175,7 @@ namespace MWGui
MyGUI::Button* mBuyButton; MyGUI::Button* mBuyButton;
MyGUI::Button* mCancelButton; MyGUI::Button* mCancelButton;
MyGUI::TextBox* mPriceLabel; MyGUI::TextBox* mPriceLabel;
MyGUI::TextBox* mPlayerGold;
ESM::Spell mSpell; ESM::Spell mSpell;
}; };

View file

@ -29,7 +29,7 @@ namespace MWGui
: WindowBase("openmw_trainingwindow.layout") : WindowBase("openmw_trainingwindow.layout")
{ {
getWidget(mTrainingOptions, "TrainingOptions"); getWidget(mTrainingOptions, "TrainingOptions");
getWidget(mCancelButton, "CancelButton"); getWidget(mCancelButton, "OkButton");
getWidget(mPlayerGold, "PlayerGold"); getWidget(mPlayerGold, "PlayerGold");
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TrainingWindow::onCancelButtonClicked); mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TrainingWindow::onCancelButtonClicked);
@ -115,14 +115,14 @@ namespace MWGui
MyGUI::Button* button = mTrainingOptions->createWidget<MyGUI::Button>(price <= playerGold MyGUI::Button* button = mTrainingOptions->createWidget<MyGUI::Button>(price <= playerGold
? "SandTextButton" ? "SandTextButton"
: "SandTextButtonDisabled", // can't use setEnabled since that removes tooltip : "SandTextButtonDisabled", // can't use setEnabled since that removes tooltip
MyGUI::IntCoord(5, 5 + i * lineHeight, mTrainingOptions->getWidth() - 10, lineHeight), MyGUI::IntCoord(4, 3 + i * lineHeight, mTrainingOptions->getWidth() - 10, lineHeight),
MyGUI::Align::Default); MyGUI::Align::Default);
button->setUserData(skills[i].first); button->setUserData(skills[i].first);
button->eventMouseButtonClick += MyGUI::newDelegate(this, &TrainingWindow::onTrainingSelected); button->eventMouseButtonClick += MyGUI::newDelegate(this, &TrainingWindow::onTrainingSelected);
button->setCaptionWithReplacing( button->setCaptionWithReplacing(
MyGUI::TextIterator::toTagsString(skill->mName) + " - " + MyGUI::utility::toString(price)); MyGUI::TextIterator::toTagsString(skill->mName) + " - " + MyGUI::utility::toString(price) + "#{sgp}");
button->setSize(button->getTextSize().width + 12, button->getSize().height); button->setSize(button->getTextSize().width + 12, button->getSize().height);

View file

@ -1,13 +1,7 @@
#include "animationbindings.hpp" #include "animationbindings.hpp"
#include <components/esm3/loadmgef.hpp>
#include <components/esm3/loadstat.hpp>
#include <components/lua/asyncpackage.hpp>
#include <components/lua/luastate.hpp> #include <components/lua/luastate.hpp>
#include <components/lua/utilpackage.hpp>
#include <components/misc/finitenumbers.hpp> #include <components/misc/finitenumbers.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/settings/values.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/mechanicsmanager.hpp"
@ -15,11 +9,8 @@
#include "../mwmechanics/character.hpp" #include "../mwmechanics/character.hpp"
#include "../mwworld/esmstore.hpp"
#include "context.hpp" #include "context.hpp"
#include "luamanagerimp.hpp" #include "luamanagerimp.hpp"
#include "objectvariant.hpp"
namespace MWLua namespace MWLua
{ {

View file

@ -8,7 +8,7 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "idcollectionbindings.hpp" #include "idcollectionbindings.hpp"
#include "types/types.hpp" #include "recordstore.hpp"
namespace sol namespace sol
{ {

View file

@ -3,10 +3,10 @@
#include <sol/forward.hpp> #include <sol/forward.hpp>
#include "context.hpp"
namespace MWLua namespace MWLua
{ {
struct Context;
sol::table initBirthSignRecordBindings(const Context& context); sol::table initBirthSignRecordBindings(const Context& context);
} }

View file

@ -1,7 +1,5 @@
#include "cellbindings.hpp" #include "cellbindings.hpp"
#include <components/esm/esmbridge.hpp>
#include <components/esm3/loadacti.hpp> #include <components/esm3/loadacti.hpp>
#include <components/esm3/loadalch.hpp> #include <components/esm3/loadalch.hpp>
#include <components/esm3/loadappa.hpp> #include <components/esm3/loadappa.hpp>
@ -27,7 +25,6 @@
#include <components/esm4/loadammo.hpp> #include <components/esm4/loadammo.hpp>
#include <components/esm4/loadarmo.hpp> #include <components/esm4/loadarmo.hpp>
#include <components/esm4/loadbook.hpp> #include <components/esm4/loadbook.hpp>
#include <components/esm4/loadcell.hpp>
#include <components/esm4/loadclot.hpp> #include <components/esm4/loadclot.hpp>
#include <components/esm4/loadcont.hpp> #include <components/esm4/loadcont.hpp>
#include <components/esm4/loaddoor.hpp> #include <components/esm4/loaddoor.hpp>
@ -38,7 +35,6 @@
#include <components/esm4/loadligh.hpp> #include <components/esm4/loadligh.hpp>
#include <components/esm4/loadmisc.hpp> #include <components/esm4/loadmisc.hpp>
#include <components/esm4/loadmstt.hpp> #include <components/esm4/loadmstt.hpp>
#include <components/esm4/loadrefr.hpp>
#include <components/esm4/loadscol.hpp> #include <components/esm4/loadscol.hpp>
#include <components/esm4/loadstat.hpp> #include <components/esm4/loadstat.hpp>
#include <components/esm4/loadtree.hpp> #include <components/esm4/loadtree.hpp>

View file

@ -1,12 +1,12 @@
#ifndef MWLUA_CELLBINDINGS_H #ifndef MWLUA_CELLBINDINGS_H
#define MWLUA_CELLBINDINGS_H #define MWLUA_CELLBINDINGS_H
#include "context.hpp"
namespace MWLua namespace MWLua
{ {
void initCellBindingsForLocalScripts(const Context&); struct Context;
void initCellBindingsForGlobalScripts(const Context&);
void initCellBindingsForLocalScripts(const Context& context);
void initCellBindingsForGlobalScripts(const Context& context);
} }
#endif // MWLUA_CELLBINDINGS_H #endif // MWLUA_CELLBINDINGS_H

View file

@ -4,7 +4,7 @@
#include <components/lua/luastate.hpp> #include <components/lua/luastate.hpp>
#include "idcollectionbindings.hpp" #include "idcollectionbindings.hpp"
#include "types/types.hpp" #include "recordstore.hpp"
namespace sol namespace sol
{ {

View file

@ -3,10 +3,10 @@
#include <sol/forward.hpp> #include <sol/forward.hpp>
#include "context.hpp"
namespace MWLua namespace MWLua
{ {
struct Context;
sol::table initClassRecordBindings(const Context& context); sol::table initClassRecordBindings(const Context& context);
} }

View file

@ -4,7 +4,6 @@
#include <stdexcept> #include <stdexcept>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/esm3/loadfact.hpp>
#include <components/lua/l10n.hpp> #include <components/lua/l10n.hpp>
#include <components/lua/luastate.hpp> #include <components/lua/luastate.hpp>
#include <components/lua/serialization.hpp> #include <components/lua/serialization.hpp>
@ -20,6 +19,7 @@
#include "../mwworld/datetimemanager.hpp" #include "../mwworld/datetimemanager.hpp"
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
#include "context.hpp"
#include "coremwscriptbindings.hpp" #include "coremwscriptbindings.hpp"
#include "dialoguebindings.hpp" #include "dialoguebindings.hpp"
#include "factionbindings.hpp" #include "factionbindings.hpp"

View file

@ -3,13 +3,13 @@
#include <sol/forward.hpp> #include <sol/forward.hpp>
#include "context.hpp"
namespace MWLua namespace MWLua
{ {
struct Context;
void addCoreTimeBindings(sol::table& api, const Context& context); void addCoreTimeBindings(sol::table& api, const Context& context);
sol::table initCorePackage(const Context&); sol::table initCorePackage(const Context& context);
} }
#endif // MWLUA_COREBINDINGS_H #endif // MWLUA_COREBINDINGS_H

View file

@ -1,7 +1,7 @@
#ifndef OPENMW_MWLUA_DEBUGBINDINGS_H #ifndef OPENMW_MWLUA_DEBUGBINDINGS_H
#define OPENMW_MWLUA_DEBUGBINDINGS_H #define OPENMW_MWLUA_DEBUGBINDINGS_H
#include <sol/sol.hpp> #include <sol/forward.hpp>
namespace MWLua namespace MWLua
{ {

View file

@ -113,6 +113,15 @@ namespace MWLua
scripts->onSkillLevelUp(event.mSkill, event.mSource); scripts->onSkillLevelUp(event.mSkill, event.mSource);
} }
void operator()(const OnJailTimeServed& event) const
{
MWWorld::Ptr actor = getPtr(event.mActor);
if (actor.isEmpty())
return;
if (auto* scripts = getLocalScripts(actor))
scripts->onJailTimeServed(event.mDays);
}
private: private:
MWWorld::Ptr getPtr(ESM::RefNum id) const MWWorld::Ptr getPtr(ESM::RefNum id) const
{ {

View file

@ -70,8 +70,13 @@ namespace MWLua
std::string mSkill; std::string mSkill;
std::string mSource; std::string mSource;
}; };
struct OnJailTimeServed
{
ESM::RefNum mActor;
int mDays;
};
using Event = std::variant<OnActive, OnInactive, OnConsume, OnActivate, OnUseItem, OnNewExterior, OnTeleported, using Event = std::variant<OnActive, OnInactive, OnConsume, OnActivate, OnUseItem, OnNewExterior, OnTeleported,
OnAnimationTextKey, OnSkillUse, OnSkillLevelUp>; OnAnimationTextKey, OnSkillUse, OnSkillLevelUp, OnJailTimeServed>;
void clear() { mQueue.clear(); } void clear() { mQueue.clear(); }
void addToQueue(Event e) { mQueue.push_back(std::move(e)); } void addToQueue(Event e) { mQueue.push_back(std::move(e)); }

View file

@ -3,10 +3,10 @@
#include <sol/forward.hpp> #include <sol/forward.hpp>
#include "context.hpp"
namespace MWLua namespace MWLua
{ {
struct Context;
sol::table initCoreFactionBindings(const Context& context); sol::table initCoreFactionBindings(const Context& context);
} }

View file

@ -13,6 +13,7 @@
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwinput/actions.hpp" #include "../mwinput/actions.hpp"
#include "context.hpp"
#include "luamanagerimp.hpp" #include "luamanagerimp.hpp"
namespace sol namespace sol

View file

@ -3,11 +3,11 @@
#include <sol/forward.hpp> #include <sol/forward.hpp>
#include "context.hpp"
namespace MWLua namespace MWLua
{ {
sol::table initInputPackage(const Context&); struct Context;
sol::table initInputPackage(const Context& context);
} }
#endif // MWLUA_INPUTBINDINGS_H #endif // MWLUA_INPUTBINDINGS_H

View file

@ -1,14 +1,24 @@
#include "landbindings.hpp" #include "landbindings.hpp"
#include <span>
#include <string>
#include <sol/object.hpp>
#include <sol/table.hpp>
#include <sol/variadic_results.hpp>
#include <components/esm/refid.hpp> #include <components/esm/refid.hpp>
#include <components/esm/util.hpp> #include <components/esm/util.hpp>
#include <components/esmterrain/storage.hpp> #include <components/esmterrain/storage.hpp>
#include <components/lua/luastate.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
#include "../mwworld/worldmodel.hpp" #include "../mwworld/worldmodel.hpp"
#include "context.hpp"
#include "object.hpp" #include "object.hpp"
namespace namespace

View file

@ -1,10 +1,12 @@
#ifndef MWLUA_LANDBINDINGS_H #ifndef MWLUA_LANDBINDINGS_H
#define MWLUA_LANDBINDINGS_H #define MWLUA_LANDBINDINGS_H
#include "context.hpp" #include <sol/forward.hpp>
namespace MWLua namespace MWLua
{ {
struct Context;
sol::table initCoreLandBindings(const Context& context); sol::table initCoreLandBindings(const Context& context);
} }

View file

@ -1,9 +1,5 @@
#include "localscripts.hpp" #include "localscripts.hpp"
#include <components/esm3/loadcell.hpp>
#include <components/esm3/loadweap.hpp>
#include <components/misc/strings/lower.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/mechanicsmanager.hpp"
#include "../mwmechanics/aicombat.hpp" #include "../mwmechanics/aicombat.hpp"
@ -232,7 +228,7 @@ namespace MWLua
[&](LuaUtil::LuaView& view) { addPackage("openmw.self", sol::make_object(view.sol(), &mData)); }); [&](LuaUtil::LuaView& view) { addPackage("openmw.self", sol::make_object(view.sol(), &mData)); });
registerEngineHandlers({ &mOnActiveHandlers, &mOnInactiveHandlers, &mOnConsumeHandlers, &mOnActivatedHandlers, registerEngineHandlers({ &mOnActiveHandlers, &mOnInactiveHandlers, &mOnConsumeHandlers, &mOnActivatedHandlers,
&mOnTeleportedHandlers, &mOnAnimationTextKeyHandlers, &mOnPlayAnimationHandlers, &mOnSkillUse, &mOnTeleportedHandlers, &mOnAnimationTextKeyHandlers, &mOnPlayAnimationHandlers, &mOnSkillUse,
&mOnSkillLevelUp }); &mOnSkillLevelUp, &mOnJailTimeServed });
} }
void LocalScripts::setActive(bool active, bool callHandlers) void LocalScripts::setActive(bool active, bool callHandlers)

View file

@ -1,9 +1,7 @@
#ifndef MWLUA_LOCALSCRIPTS_H #ifndef MWLUA_LOCALSCRIPTS_H
#define MWLUA_LOCALSCRIPTS_H #define MWLUA_LOCALSCRIPTS_H
#include <memory> #include <string_view>
#include <set>
#include <string>
#include <utility> #include <utility>
#include <components/lua/luastate.hpp> #include <components/lua/luastate.hpp>
@ -89,6 +87,7 @@ namespace MWLua
{ {
callEngineHandlers(mOnSkillLevelUp, skillId, source); callEngineHandlers(mOnSkillLevelUp, skillId, source);
} }
void onJailTimeServed(int days) { callEngineHandlers(mOnJailTimeServed, days); }
void applyStatsCache(); void applyStatsCache();
@ -118,6 +117,7 @@ namespace MWLua
EngineHandlerList mOnPlayAnimationHandlers{ "_onPlayAnimation" }; EngineHandlerList mOnPlayAnimationHandlers{ "_onPlayAnimation" };
EngineHandlerList mOnSkillUse{ "_onSkillUse" }; EngineHandlerList mOnSkillUse{ "_onSkillUse" };
EngineHandlerList mOnSkillLevelUp{ "_onSkillLevelUp" }; EngineHandlerList mOnSkillLevelUp{ "_onSkillLevelUp" };
EngineHandlerList mOnJailTimeServed{ "_onJailTimeServed" };
}; };
} }

View file

@ -1,29 +1,30 @@
#ifndef MWLUA_LUABINDINGS_H #ifndef MWLUA_LUABINDINGS_H
#define MWLUA_LUABINDINGS_H #define MWLUA_LUABINDINGS_H
#include <map>
#include <sol/forward.hpp> #include <sol/forward.hpp>
#include <string>
#include "context.hpp" #include <map>
#include <string>
namespace MWLua namespace MWLua
{ {
struct Context;
// Initialize Lua packages that are available for all scripts. // Initialize Lua packages that are available for all scripts.
std::map<std::string, sol::object> initCommonPackages(const Context&); std::map<std::string, sol::object> initCommonPackages(const Context& context);
// Initialize Lua packages that are available for global scripts (additionally to common packages). // Initialize Lua packages that are available for global scripts (additionally to common packages).
std::map<std::string, sol::object> initGlobalPackages(const Context&); std::map<std::string, sol::object> initGlobalPackages(const Context& context);
// Initialize Lua packages that are available for local scripts (additionally to common packages). // Initialize Lua packages that are available for local scripts (additionally to common packages).
std::map<std::string, sol::object> initLocalPackages(const Context&); std::map<std::string, sol::object> initLocalPackages(const Context& context);
// Initialize Lua packages that are available only for local scripts on the player (additionally to common and local // Initialize Lua packages that are available only for local scripts on the player (additionally to common and local
// packages). // packages).
std::map<std::string, sol::object> initPlayerPackages(const Context&); std::map<std::string, sol::object> initPlayerPackages(const Context& context);
// Initialize Lua packages that are available only for menu scripts (additionally to common packages). // Initialize Lua packages that are available only for menu scripts (additionally to common packages).
std::map<std::string, sol::object> initMenuPackages(const Context&); std::map<std::string, sol::object> initMenuPackages(const Context& context);
} }
#endif // MWLUA_LUABINDINGS_H #endif // MWLUA_LUABINDINGS_H

View file

@ -5,6 +5,10 @@
#include <MyGUI_InputManager.h> #include <MyGUI_InputManager.h>
#include <osg/Stats> #include <osg/Stats>
#include <sol/object.hpp>
#include <sol/table.hpp>
#include <sol/types.hpp>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/esm/luascripts.hpp> #include <components/esm/luascripts.hpp>
@ -15,7 +19,6 @@
#include <components/l10n/manager.hpp> #include <components/l10n/manager.hpp>
#include <components/lua_ui/content.hpp>
#include <components/lua_ui/registerscriptsettings.hpp> #include <components/lua_ui/registerscriptsettings.hpp>
#include <components/lua_ui/util.hpp> #include <components/lua_ui/util.hpp>
@ -490,6 +493,11 @@ namespace MWLua
EngineEvents::OnSkillLevelUp{ getId(actor), skillId.serializeText(), std::string(source) }); EngineEvents::OnSkillLevelUp{ getId(actor), skillId.serializeText(), std::string(source) });
} }
void LuaManager::jailTimeServed(const MWWorld::Ptr& actor, int days)
{
mEngineEvents.addToQueue(EngineEvents::OnJailTimeServed{ getId(actor), days });
}
void LuaManager::onHit(const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim, const MWWorld::Ptr& weapon, void LuaManager::onHit(const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim, const MWWorld::Ptr& weapon,
const MWWorld::Ptr& ammo, int attackType, float attackStrength, float damage, bool isHealth, const MWWorld::Ptr& ammo, int attackType, float attackStrength, float damage, bool isHealth,
const osg::Vec3f& hitPos, bool successful, MWMechanics::DamageSourceType sourceType) const osg::Vec3f& hitPos, bool successful, MWMechanics::DamageSourceType sourceType)

View file

@ -3,9 +3,10 @@
#include <filesystem> #include <filesystem>
#include <map> #include <map>
#include <osg/Stats>
#include <set> #include <set>
#include <osg/Stats>
#include <components/lua/inputactions.hpp> #include <components/lua/inputactions.hpp>
#include <components/lua/luastate.hpp> #include <components/lua/luastate.hpp>
#include <components/lua/scripttracker.hpp> #include <components/lua/scripttracker.hpp>
@ -92,6 +93,7 @@ namespace MWLua
bool loopfallback) override; bool loopfallback) override;
void skillUse(const MWWorld::Ptr& actor, ESM::RefId skillId, int useType, float scale) override; void skillUse(const MWWorld::Ptr& actor, ESM::RefId skillId, int useType, float scale) override;
void skillLevelUp(const MWWorld::Ptr& actor, ESM::RefId skillId, std::string_view source) override; void skillLevelUp(const MWWorld::Ptr& actor, ESM::RefId skillId, std::string_view source) override;
void jailTimeServed(const MWWorld::Ptr& actor, int days) override;
void onHit(const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim, const MWWorld::Ptr& weapon, void onHit(const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim, const MWWorld::Ptr& weapon,
const MWWorld::Ptr& ammo, int attackType, float attackStrength, float damage, bool isHealth, const MWWorld::Ptr& ammo, int attackType, float attackStrength, float damage, bool isHealth,
const osg::Vec3f& hitPos, bool successful, MWMechanics::DamageSourceType sourceType) override; const osg::Vec3f& hitPos, bool successful, MWMechanics::DamageSourceType sourceType) override;

View file

@ -3,10 +3,10 @@
#include <sol/forward.hpp> #include <sol/forward.hpp>
#include "context.hpp"
namespace MWLua namespace MWLua
{ {
struct Context;
sol::table initCoreMagicBindings(const Context& context); sol::table initCoreMagicBindings(const Context& context);
void addActorMagicBindings(sol::table& actor, const Context& context); void addActorMagicBindings(sol::table& actor, const Context& context);
} }

View file

@ -3,11 +3,11 @@
#include <sol/forward.hpp> #include <sol/forward.hpp>
#include "context.hpp"
namespace MWLua namespace MWLua
{ {
sol::table initMarkupPackage(const Context&); struct Context;
sol::table initMarkupPackage(const Context& context);
} }
#endif // MWLUA_MARKUPBINDINGS_H #endif // MWLUA_MARKUPBINDINGS_H

View file

@ -7,6 +7,8 @@
#include "../mwbase/statemanager.hpp" #include "../mwbase/statemanager.hpp"
#include "../mwstate/character.hpp" #include "../mwstate/character.hpp"
#include "context.hpp"
namespace MWLua namespace MWLua
{ {
static const MWState::Character* findCharacter(std::string_view characterDir) static const MWState::Character* findCharacter(std::string_view characterDir)

View file

@ -9,11 +9,11 @@
#include "../mwbase/luamanager.hpp" #include "../mwbase/luamanager.hpp"
#include "context.hpp"
#include "inputprocessor.hpp" #include "inputprocessor.hpp"
namespace MWLua namespace MWLua
{ {
struct Context;
sol::table initMenuPackage(const Context& context); sol::table initMenuPackage(const Context& context);

View file

@ -12,6 +12,7 @@
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
#include "../mwworld/worldimp.hpp" #include "../mwworld/worldimp.hpp"
#include "context.hpp"
#include "object.hpp" #include "object.hpp"
#include <stdexcept> #include <stdexcept>

View file

@ -3,13 +3,11 @@
#include <sol/forward.hpp> #include <sol/forward.hpp>
#include "context.hpp"
namespace MWLua namespace MWLua
{ {
struct Context;
sol::table initMWScriptBindings(const Context&); sol::table initMWScriptBindings(const Context& context);
} }
#endif // MWLUA_MWSCRIPTBINDINGS_H #endif // MWLUA_MWSCRIPTBINDINGS_H

View file

@ -13,9 +13,12 @@
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/scene.hpp" #include "../mwworld/scene.hpp"
#include "context.hpp"
#include "luamanagerimp.hpp" #include "luamanagerimp.hpp"
#include "objectlists.hpp" #include "objectlists.hpp"
#include <vector>
namespace namespace
{ {
template <class T = MWWorld::Ptr> template <class T = MWWorld::Ptr>

View file

@ -3,11 +3,11 @@
#include <sol/forward.hpp> #include <sol/forward.hpp>
#include "context.hpp"
namespace MWLua namespace MWLua
{ {
sol::table initNearbyPackage(const Context&); struct Context;
sol::table initNearbyPackage(const Context& context);
} }
#endif // MWLUA_NEARBYBINDINGS_H #endif // MWLUA_NEARBYBINDINGS_H

View file

@ -1,9 +1,7 @@
#ifndef MWLUA_OBJECT_H #ifndef MWLUA_OBJECT_H
#define MWLUA_OBJECT_H #define MWLUA_OBJECT_H
#include <map>
#include <stdexcept> #include <stdexcept>
#include <typeindex>
#include <sol/sol.hpp> #include <sol/sol.hpp>

View file

@ -1,12 +1,12 @@
#ifndef MWLUA_OBJECTBINDINGS_H #ifndef MWLUA_OBJECTBINDINGS_H
#define MWLUA_OBJECTBINDINGS_H #define MWLUA_OBJECTBINDINGS_H
#include "context.hpp"
namespace MWLua namespace MWLua
{ {
void initObjectBindingsForLocalScripts(const Context&); struct Context;
void initObjectBindingsForGlobalScripts(const Context&);
void initObjectBindingsForLocalScripts(const Context& context);
void initObjectBindingsForGlobalScripts(const Context& context);
} }
#endif // MWLUA_OBJECTBINDINGS_H #endif // MWLUA_OBJECTBINDINGS_H

View file

@ -1,9 +1,5 @@
#include "objectlists.hpp" #include "objectlists.hpp"
#include <components/esm3/esmreader.hpp>
#include <components/esm3/esmwriter.hpp>
#include <components/esm3/loadcell.hpp>
#include <components/misc/resourcehelpers.hpp> #include <components/misc/resourcehelpers.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"

View file

@ -8,6 +8,7 @@
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwrender/postprocessor.hpp" #include "../mwrender/postprocessor.hpp"
#include "context.hpp"
#include "luamanagerimp.hpp" #include "luamanagerimp.hpp"
namespace namespace

View file

@ -3,11 +3,11 @@
#include <sol/forward.hpp> #include <sol/forward.hpp>
#include "context.hpp"
namespace MWLua namespace MWLua
{ {
sol::table initPostprocessingPackage(const Context&); struct Context;
sol::table initPostprocessingPackage(const Context& context);
} }
#endif // MWLUA_POSTPROCESSINGBINDINGS_H #endif // MWLUA_POSTPROCESSINGBINDINGS_H

View file

@ -8,7 +8,7 @@
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
#include "idcollectionbindings.hpp" #include "idcollectionbindings.hpp"
#include "types/types.hpp" #include "recordstore.hpp"
namespace namespace
{ {

View file

@ -3,10 +3,10 @@
#include <sol/forward.hpp> #include <sol/forward.hpp>
#include "context.hpp"
namespace MWLua namespace MWLua
{ {
struct Context;
sol::table initRaceRecordBindings(const Context& context); sol::table initRaceRecordBindings(const Context& context);
} }

View file

@ -1,10 +1,16 @@
#ifndef MWLUA_RECORDSTORE_H #ifndef MWLUA_RECORDSTORE_H
#define MWLUA_RECORDSTORE_H #define MWLUA_RECORDSTORE_H
#include <sol/sol.hpp> #include <type_traits>
#include <sol/forward.hpp>
#include <sol/overload.hpp>
#include <sol/state_view.hpp>
#include <sol/table.hpp>
#include <sol/types.hpp>
#include <sol/unsafe_function.hpp>
#include <sol/usertype.hpp>
#include <components/esm/defs.hpp>
#include <components/lua/luastate.hpp>
#include <components/lua/util.hpp> #include <components/lua/util.hpp>
#include "apps/openmw/mwbase/environment.hpp" #include "apps/openmw/mwbase/environment.hpp"

View file

@ -3,11 +3,11 @@
#include <sol/forward.hpp> #include <sol/forward.hpp>
#include "context.hpp"
namespace MWLua namespace MWLua
{ {
sol::table initCoreSoundBindings(const Context&); struct Context;
sol::table initCoreSoundBindings(const Context& context);
sol::table initAmbientPackage(const Context& context); sol::table initAmbientPackage(const Context& context);
} }

View file

@ -1,9 +1,11 @@
#include "stats.hpp" #include "stats.hpp"
#include <algorithm> #include <algorithm>
#include <memory>
#include <optional> #include <optional>
#include <string>
#include <string_view> #include <string_view>
#include <type_traits>
#include <utility>
#include <variant> #include <variant>
#include <components/esm3/loadclas.hpp> #include <components/esm3/loadclas.hpp>

View file

@ -108,6 +108,10 @@ namespace MWLua
} }
luaManager->addUIMessage(message, mode); luaManager->addUIMessage(message, mode);
}; };
api["_showInteractiveMessage"] = [windowManager](std::string_view message, sol::optional<sol::table>) {
windowManager->interactiveMessageBox(message, { "#{Interface:OK}" });
};
api["CONSOLE_COLOR"] = LuaUtil::makeStrictReadOnly(LuaUtil::tableFromPairs<std::string, Misc::Color>(lua, api["CONSOLE_COLOR"] = LuaUtil::makeStrictReadOnly(LuaUtil::tableFromPairs<std::string, Misc::Color>(lua,
{ {
{ "Default", Misc::Color::fromHex(MWBase::WindowManager::sConsoleColor_Default.substr(1)) }, { "Default", Misc::Color::fromHex(MWBase::WindowManager::sConsoleColor_Default.substr(1)) },

View file

@ -3,11 +3,11 @@
#include <sol/forward.hpp> #include <sol/forward.hpp>
#include "context.hpp"
namespace MWLua namespace MWLua
{ {
sol::table initUserInterfacePackage(const Context&); struct Context;
sol::table initUserInterfacePackage(const Context& context);
} }
#endif // MWLUA_UIBINDINGS_H #endif // MWLUA_UIBINDINGS_H

View file

@ -1,7 +1,8 @@
#ifndef MWLUA_USERDATASERIALIZER_H #ifndef MWLUA_USERDATASERIALIZER_H
#define MWLUA_USERDATASERIALIZER_H #define MWLUA_USERDATASERIALIZER_H
#include "object.hpp" #include <map>
#include <memory>
namespace LuaUtil namespace LuaUtil
{ {

View file

@ -3,11 +3,11 @@
#include <sol/forward.hpp> #include <sol/forward.hpp>
#include "context.hpp"
namespace MWLua namespace MWLua
{ {
sol::table initVFSPackage(const Context&); struct Context;
sol::table initVFSPackage(const Context& context);
} }
#endif // MWLUA_VFSBINDINGS_H #endif // MWLUA_VFSBINDINGS_H

View file

@ -8,7 +8,6 @@
#include <components/esm3/loadligh.hpp> #include <components/esm3/loadligh.hpp>
#include <components/esm3/loadmisc.hpp> #include <components/esm3/loadmisc.hpp>
#include <components/esm3/loadnpc.hpp> #include <components/esm3/loadnpc.hpp>
#include <components/esm3/loadskil.hpp>
#include <components/esm3/loadweap.hpp> #include <components/esm3/loadweap.hpp>
#include <components/lua/luastate.hpp> #include <components/lua/luastate.hpp>
#include <components/misc/finitenumbers.hpp> #include <components/misc/finitenumbers.hpp>
@ -28,6 +27,7 @@
#include "luamanagerimp.hpp" #include "luamanagerimp.hpp"
#include "animationbindings.hpp" #include "animationbindings.hpp"
#include "context.hpp"
#include "corebindings.hpp" #include "corebindings.hpp"
#include "mwscriptbindings.hpp" #include "mwscriptbindings.hpp"

View file

@ -3,11 +3,11 @@
#include <sol/forward.hpp> #include <sol/forward.hpp>
#include "context.hpp"
namespace MWLua namespace MWLua
{ {
sol::table initWorldPackage(const Context&); struct Context;
sol::table initWorldPackage(const Context& context);
} }
#endif // MWLUA_WORLDBINDINGS_H #endif // MWLUA_WORLDBINDINGS_H

View file

@ -401,14 +401,12 @@ namespace MWRender
{ {
if (mViewMode == VM_FirstPerson) if (mViewMode == VM_FirstPerson)
{ {
static bool prototypeAdded = false; [[maybe_unused]] static const bool prototypeAdded = [&] {
if (!prototypeAdded)
{
osg::ref_ptr<osgUtil::RenderBin> depthClearBin(new osgUtil::RenderBin); osg::ref_ptr<osgUtil::RenderBin> depthClearBin(new osgUtil::RenderBin);
depthClearBin->setDrawCallback(new DepthClearCallback()); depthClearBin->setDrawCallback(new DepthClearCallback());
osgUtil::RenderBin::addRenderBinPrototype("DepthClear", depthClearBin); osgUtil::RenderBin::addRenderBinPrototype("DepthClear", depthClearBin);
prototypeAdded = true; return true;
} }();
mObjectRoot->getOrCreateStateSet()->setRenderBinDetails( mObjectRoot->getOrCreateStateSet()->setRenderBinDetails(
RenderBin_FirstPerson, "DepthClear", osg::StateSet::OVERRIDE_RENDERBIN_DETAILS); RenderBin_FirstPerson, "DepthClear", osg::StateSet::OVERRIDE_RENDERBIN_DETAILS);
} }

View file

@ -88,14 +88,13 @@ namespace MWRender
if (mProgramBlobber != nullptr) if (mProgramBlobber != nullptr)
{ {
static bool pipelineLogged = [&] { [[maybe_unused]] static const bool pipelineLogged = [&] {
if (mUseCompute) if (mUseCompute)
Log(Debug::Info) << "Initialized compute shader pipeline for water ripples"; Log(Debug::Info) << "Initialized compute shader pipeline for water ripples";
else else
Log(Debug::Info) << "Initialized fallback fragment shader pipeline for water ripples"; Log(Debug::Info) << "Initialized fallback fragment shader pipeline for water ripples";
return true; return true;
}(); }();
(void)pipelineLogged;
} }
setCullCallback(new osg::NodeCallback); setCullCallback(new osg::NodeCallback);

View file

@ -522,16 +522,14 @@ namespace MWSound
/* We need to make sure ffmpeg is initialized. Optionally silence warning /* We need to make sure ffmpeg is initialized. Optionally silence warning
* output from the lib */ * output from the lib */
static bool done_init = false; [[maybe_unused]] static const bool doneInit = [] {
if (!done_init)
{
// This is not needed anymore above FFMpeg version 4.0 // This is not needed anymore above FFMpeg version 4.0
#if LIBAVCODEC_VERSION_INT < 3805796 #if LIBAVCODEC_VERSION_INT < 3805796
av_register_all(); av_register_all();
#endif #endif
av_log_set_level(AV_LOG_ERROR); av_log_set_level(AV_LOG_ERROR);
done_init = true; return true;
} }();
} }
FFmpegDecoder::~FFmpegDecoder() FFmpegDecoder::~FFmpegDecoder()

View file

@ -1273,13 +1273,12 @@ namespace MWWorld
const std::size_t leftCapacity = mPreloader->getMaxCacheSize() - mPreloader->getCacheSize(); const std::size_t leftCapacity = mPreloader->getMaxCacheSize() - mPreloader->getCacheSize();
if (cells.size() > leftCapacity) if (cells.size() > leftCapacity)
{ {
static bool logged = [&] { [[maybe_unused]] static const bool logged = [&] {
Log(Debug::Warning) << "Not enough cell preloader cache capacity to preload exterior cells, consider " Log(Debug::Warning) << "Not enough cell preloader cache capacity to preload exterior cells, consider "
"increasing \"preload cell cache max\" up to " "increasing \"preload cell cache max\" up to "
<< (mPreloader->getCacheSize() + cells.size()); << (mPreloader->getCacheSize() + cells.size());
return true; return true;
}(); }();
(void)logged;
cells.resize(leftCapacity); cells.resize(leftCapacity);
} }

View file

@ -407,6 +407,7 @@ add_component_dir(detournavigator
areatype areatype
asyncnavmeshupdater asyncnavmeshupdater
bounds bounds
cellgridbounds
changetype changetype
collisionshapetype collisionshapetype
commulativeaabb commulativeaabb

View file

@ -8,7 +8,6 @@
#include <algorithm> #include <algorithm>
#include <cstdint> #include <cstdint>
#include <optional>
#include <tuple> #include <tuple>
#include <type_traits> #include <type_traits>
#include <variant> #include <variant>

View file

@ -10,10 +10,8 @@
#include <osg/io_utils> #include <osg/io_utils>
#include <functional>
#include <memory> #include <memory>
#include <optional> #include <optional>
#include <stdexcept>
#include <vector> #include <vector>
namespace DetourNavigator namespace DetourNavigator
@ -79,7 +77,7 @@ namespace DetourNavigator
return; return;
} }
const auto data const std::unique_ptr<PreparedNavMeshData> data
= prepareNavMeshTileData(*recastMesh, mWorldspace, mTilePosition, mAgentBounds, mSettings.mRecast); = prepareNavMeshTileData(*recastMesh, mWorldspace, mTilePosition, mAgentBounds, mSettings.mRecast);
if (data == nullptr) if (data == nullptr)

View file

@ -3,8 +3,6 @@
#include "exceptions.hpp" #include "exceptions.hpp"
#include "flags.hpp" #include "flags.hpp"
#include "navmeshdata.hpp" #include "navmeshdata.hpp"
#include "navmeshdb.hpp"
#include "navmeshtilescache.hpp"
#include "offmeshconnection.hpp" #include "offmeshconnection.hpp"
#include "preparednavmeshdata.hpp" #include "preparednavmeshdata.hpp"
#include "recastcontext.hpp" #include "recastcontext.hpp"
@ -22,8 +20,6 @@
#include <algorithm> #include <algorithm>
#include <array> #include <array>
#include <iomanip>
#include <limits>
namespace DetourNavigator namespace DetourNavigator
{ {

View file

@ -4,7 +4,6 @@
#include <DetourCommon.h> #include <DetourCommon.h>
#include <DetourNavMesh.h> #include <DetourNavMesh.h>
#include <algorithm>
#include <cassert> #include <cassert>
#include <stdexcept> #include <stdexcept>
#include <tuple> #include <tuple>

View file

@ -6,7 +6,6 @@
#include <osg/Vec3f> #include <osg/Vec3f>
#include <tuple> #include <tuple>
#include <vector>
namespace DetourNavigator namespace DetourNavigator
{ {

View file

@ -4,8 +4,6 @@
#include <Recast.h> #include <Recast.h>
#include <cstring>
namespace namespace
{ {
void initPolyMeshDetail(rcPolyMeshDetail& value) noexcept void initPolyMeshDetail(rcPolyMeshDetail& value) noexcept

View file

@ -3,9 +3,10 @@
#include "flags.hpp" #include "flags.hpp"
#include <optional>
#include <osg/Vec3f> #include <osg/Vec3f>
#include <optional>
class dtNavMeshQuery; class dtNavMeshQuery;
namespace DetourNavigator namespace DetourNavigator

View file

@ -11,9 +11,7 @@
#include <osg/Vec3f> #include <osg/Vec3f>
#include <cstdint> #include <cstdint>
#include <memory>
#include <numeric> #include <numeric>
#include <string>
#include <tuple> #include <tuple>
#include <vector> #include <vector>

View file

@ -1,6 +1,7 @@
#include "configurationmanager.hpp" #include "configurationmanager.hpp"
#include <fstream> #include <fstream>
#include <map>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/fallback/validate.hpp> #include <components/fallback/validate.hpp>

View file

@ -1,7 +1,6 @@
#ifndef COMPONENTS_FILES_CONFIGURATIONMANAGER_HPP #ifndef COMPONENTS_FILES_CONFIGURATIONMANAGER_HPP
#define COMPONENTS_FILES_CONFIGURATIONMANAGER_HPP #define COMPONENTS_FILES_CONFIGURATIONMANAGER_HPP
#include <map>
#include <optional> #include <optional>
#include <stack> #include <stack>
#include <string_view> #include <string_view>

View file

@ -95,13 +95,10 @@ namespace SceneUtil
static void setReversed(bool reverseZ) static void setReversed(bool reverseZ)
{ {
static bool init = false; [[maybe_unused]] static const bool init = [&] {
if (!init)
{
AutoDepth::sReversed = reverseZ; AutoDepth::sReversed = reverseZ;
init = true; return true;
} }();
} }
static bool isReversed() static bool isReversed()

View file

@ -27,7 +27,6 @@
#include <osg/ClipControl> #include <osg/ClipControl>
#include <sstream> #include <sstream>
#include <deque>
#include <vector> #include <vector>
#include "glextensions.hpp" #include "glextensions.hpp"

View file

@ -107,8 +107,8 @@ Example:
local attack = { local attack = {
attacker = self, attacker = self,
weapon = Actor.getEquipment(self, Actor.EQUIPMENT_SLOT.CarriedRight), weapon = Actor.getEquipment(self, Actor.EQUIPMENT_SLOT.CarriedRight),
sourceType = I.Combat.ATTACK_SOURCE_TYPE.Melee, sourceType = I.Combat.ATTACK_SOURCE_TYPES.Melee,
strenght = 1, strength = 1,
type = self.ATTACK_TYPE.Chop, type = self.ATTACK_TYPE.Chop,
damage = { damage = {
health = 20, health = 20,

View file

@ -11,6 +11,7 @@ Interfaces
AI <interface_ai> AI <interface_ai>
AnimationController <interface_animation> AnimationController <interface_animation>
Camera <interface_camera> Camera <interface_camera>
Combat <interface_combat>
Controls <interface_controls> Controls <interface_controls>
Crimes <interface_crimes> Crimes <interface_crimes>
GamepadControls <interface_gamepadcontrols> GamepadControls <interface_gamepadcontrols>

View file

@ -68,6 +68,12 @@
<Widget type="HBox" position="0 336 558 60"> <Widget type="HBox" position="0 336 558 60">
<Property key="Padding" value="16"/> <Property key="Padding" value="16"/>
<Widget type="AutoSizedTextBox" skin="NormalText" name="PlayerGoldTextBox">
<Property key="Caption" value="#{sGold}"/>
<UserString key="ToolTipType" value="Layout"/>
<UserString key="ToolTipLayout" value="TextToolTip"/>
</Widget>
<Widget type="AutoSizedTextBox" skin="SandText" name="PlayerGold"/>
<Widget type="Spacer"/> <Widget type="Spacer"/>
<Widget type="AutoSizedTextBox" skin="NormalText"> <Widget type="AutoSizedTextBox" skin="NormalText">

View file

@ -1,28 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout"> <MyGUI type="Layout">
<Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 319 200" align="Center" name="_Main"> <Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 320 200" align="Center" name="_Main">
<Widget type="TextBox" skin="NormalText" position="0 5 319 24" name="Select" align="Right Top"> <Widget type="TextBox" skin="NormalText" position="6 3 300 24" name="Select" align="Right Top">
<Property key="TextAlign" value="Center"/> <Property key="TextAlign" value="Center"/>
<Property key="Caption" value="#{sServiceTrainingTitle}"/> <Property key="Caption" value="#{sServiceTrainingTitle}"/>
</Widget> </Widget>
<Widget type="TextBox" skin="SandText" position="5 30 319 24" name="Travel" align="Right Top"> <Widget type="TextBox" skin="SandText" position="6 22 300 24" name="Travel" align="Right Top">
<Property key="TextAlign" value="Left"/> <Property key="TextAlign" value="Left"/>
<Property key="Caption" value="#{sTrainingServiceTitle}"/> <Property key="Caption" value="#{sTrainingServiceTitle}"/>
</Widget> </Widget>
<Widget type="Widget" skin="MW_Box" position="6 54 299 100" align="Left Top" name="TrainingOptions"> <Widget type="Widget" skin="MW_Box" position="6 42 300 115" align="Left Top" name="TrainingOptions">
</Widget> </Widget>
<Widget type="TextBox" skin="SandText" position="8 161 200 24" name="PlayerGold" align="Right Top"> <Widget type="TextBox" skin="SandText" position="6 161 200 24" name="PlayerGold" align="Right Top">
<Property key="TextAlign" value="Left"/> <Property key="TextAlign" value="Left"/>
</Widget> </Widget>
<Widget type="AutoSizedButton" skin="MW_Button" position="244 161 60 24" name="CancelButton" align="Right Top"> <Widget type="AutoSizedButton" skin="MW_Button" position="246 161 60 24" name="OkButton" align="Right Top">
<Property key="ExpandDirection" value="Left"/> <Property key="ExpandDirection" value="Left"/>
<Property key="Caption" value="#{Interface:Cancel}"/> <Property key="Caption" value="#{Interface:OK}"/>
</Widget> </Widget>
</Widget> </Widget>

View file

@ -39,7 +39,8 @@ end
local function skillLevelUpHandler(skillid, source, params) local function skillLevelUpHandler(skillid, source, params)
local skillStat = NPC.stats.skills[skillid](self) local skillStat = NPC.stats.skills[skillid](self)
if skillStat.base >= 100 then if (skillStat.base >= 100 and params.skillIncreaseValue > 0) or
(skillStat.base <= 0 and params.skillIncreaseValue < 0) then
return false return false
end end
@ -62,25 +63,67 @@ local function skillLevelUpHandler(skillid, source, params)
= levelStat.skillIncreasesForSpecialization[params.levelUpSpecialization] + params.levelUpSpecializationIncreaseValue; = levelStat.skillIncreasesForSpecialization[params.levelUpSpecialization] + params.levelUpSpecializationIncreaseValue;
end end
local skillRecord = Skill.record(skillid) if source ~= 'jail' then
local npcRecord = NPC.record(self) local skillRecord = Skill.record(skillid)
local class = NPC.classes.record(npcRecord.class) local npcRecord = NPC.record(self)
local class = NPC.classes.record(npcRecord.class)
ambient.playSound("skillraise") ambient.playSound("skillraise")
local message = string.format(core.getGMST('sNotifyMessage39'),skillRecord.name,skillStat.base) local message = string.format(core.getGMST('sNotifyMessage39'),skillRecord.name,skillStat.base)
if source == I.SkillProgression.SKILL_INCREASE_SOURCES.Book then if source == I.SkillProgression.SKILL_INCREASE_SOURCES.Book then
message = '#{sBookSkillMessage}\n'..message message = '#{sBookSkillMessage}\n'..message
end
ui.showMessage(message, { showInDialogue = false })
if levelStat.progress >= core.getGMST('iLevelUpTotal') then
ui.showMessage('#{sLevelUpMsg}', { showInDialogue = false })
end
if not source or source == I.SkillProgression.SKILL_INCREASE_SOURCES.Usage then skillStat.progress = 0 end
end
end
local function jailTimeServed(days)
if not days or days <= 0 then
return
end end
ui.showMessage(message, { showInDialogue = false }) local oldSkillLevels = {}
local skillByNumber = {}
if levelStat.progress >= core.getGMST('iLevelUpTotal') then for skillid, skillStat in pairs(NPC.stats.skills) do
ui.showMessage('#{sLevelUpMsg}', { showInDialogue = false }) oldSkillLevels[skillid] = skillStat(self).base
skillByNumber[#skillByNumber+1] = skillid
end end
if not source or source == I.SkillProgression.SKILL_INCREASE_SOURCES.Usage then skillStat.progress = 0 end math.randomseed(core.getSimulationTime())
for day=1,days do
local skillid = skillByNumber[math.random(#skillByNumber)]
-- skillLevelUp() handles skill-based increase/decrease
I.SkillProgression.skillLevelUp(skillid, I.SkillProgression.SKILL_INCREASE_SOURCES.Jail)
end
local message = ''
if days == 1 then
message = string.format(core.getGMST('sNotifyMessage42'), days)
else
message = string.format(core.getGMST('sNotifyMessage43'), days)
end
for skillid, skillStat in pairs(NPC.stats.skills) do
local diff = skillStat(self).base - oldSkillLevels[skillid]
if diff ~= 0 then
local skillMsg = core.getGMST('sNotifyMessage39')
if diff < 0 then
skillMsg = core.getGMST('sNotifyMessage44')
end
local skillRecord = Skill.record(skillid)
message = message..'\n'..string.format(skillMsg, skillRecord.name, skillStat(self).base)
end
end
I.UI.showInteractiveMessage(message)
end end
local function skillUsedHandler(skillid, params) local function skillUsedHandler(skillid, params)
@ -114,6 +157,7 @@ I.SkillProgression.addSkillLevelUpHandler(skillLevelUpHandler)
return { return {
engineHandlers = { engineHandlers = {
onUpdate = onUpdate, onUpdate = onUpdate,
_onJailTimeServed = jailTimeServed,
}, },
eventHandlers = { eventHandlers = {

View file

@ -38,6 +38,7 @@ local Skill = core.stats.Skill
-- Table of all existing sources for skill increases. Any sources not listed below will be treated as equal to Trainer. -- Table of all existing sources for skill increases. Any sources not listed below will be treated as equal to Trainer.
-- @type SkillLevelUpSource -- @type SkillLevelUpSource
-- @field #string Book book -- @field #string Book book
-- @field #string Jail jail
-- @field #string Trainer trainer -- @field #string Trainer trainer
-- @field #string Usage usage -- @field #string Usage usage
@ -131,15 +132,17 @@ local function skillLevelUp(skillid, source)
levelUpAttributeIncreaseValue = core.getGMST('iLevelUpMajorMultAttribute') levelUpAttributeIncreaseValue = core.getGMST('iLevelUpMajorMultAttribute')
end end
local options = local options = {}
{ if source == 'jail' and not (skillid == 'security' or skillid == 'sneak') then
skillIncreaseValue = 1, options.skillIncreaseValue = -1
levelUpProgress = levelUpProgress, else
levelUpAttribute = skillRecord.attribute, options.skillIncreaseValue = 1
levelUpAttributeIncreaseValue = levelUpAttributeIncreaseValue, options.levelUpProgress = levelUpProgress
levelUpSpecialization = skillRecord.specialization, options.levelUpAttribute = skillRecord.attribute
levelUpSpecializationIncreaseValue = core.getGMST('iLevelupSpecialization'), options.levelUpAttributeIncreaseValue = levelUpAttributeIncreaseValue
} options.levelUpSpecialization = skillRecord.specialization
options.levelUpSpecializationIncreaseValue = core.getGMST('iLevelupSpecialization')
end
for i = #skillLevelUpHandlers, 1, -1 do for i = #skillLevelUpHandlers, 1, -1 do
if skillLevelUpHandlers[i](skillid, source, options) == false then if skillLevelUpHandlers[i](skillid, source, options) == false then
@ -156,8 +159,15 @@ return {
-- @context local -- @context local
-- @usage local I = require('openmw.interfaces') -- @usage local I = require('openmw.interfaces')
-- --
-- -- Make jail time hurt sneak skill instead of benefitting it
-- I.SkillProgression.addSkillLevelUpHandler(function(skillid, source, options)
-- if skillid == 'sneak' and source == 'jail' and options.skillIncreaseValue > 0 then
-- options.skillIncreaseValue = -options.skillIncreaseValue
-- end
-- end)
--
-- -- Forbid increasing destruction skill past 50 -- -- Forbid increasing destruction skill past 50
-- I.SkillProgression.addSkillLevelUpHandler(function(skillid, options) -- I.SkillProgression.addSkillLevelUpHandler(function(skillid, source, options)
-- if skillid == 'destruction' and types.NPC.stats.skills.destruction(self).base >= 50 then -- if skillid == 'destruction' and types.NPC.stats.skills.destruction(self).base >= 50 then
-- return false -- return false
-- end -- end
@ -187,7 +197,7 @@ return {
-- a modifiable table of skill level up values, and can be modified to change the behavior of later handlers. -- a modifiable table of skill level up values, and can be modified to change the behavior of later handlers.
-- These values are calculated based on vanilla mechanics. Setting any value to nil will cause that mechanic to be skipped. By default contains these values: -- These values are calculated based on vanilla mechanics. Setting any value to nil will cause that mechanic to be skipped. By default contains these values:
-- --
-- * `skillIncreaseValue` - The numeric amount of skill levels gained. -- * `skillIncreaseValue` - The numeric amount of skill levels gained. By default this is 1, except when the source is jail in which case it will instead be -1 for all skills except sneak and security.
-- * `levelUpProgress` - The numeric amount of level up progress gained. -- * `levelUpProgress` - The numeric amount of level up progress gained.
-- * `levelUpAttribute` - The string identifying the attribute that should receive points from this skill level up. -- * `levelUpAttribute` - The string identifying the attribute that should receive points from this skill level up.
-- * `levelUpAttributeIncreaseValue` - The numeric amount of attribute increase points received. This contributes to the amount of each attribute the character receives during a vanilla level up. -- * `levelUpAttributeIncreaseValue` - The numeric amount of attribute increase points received. This contributes to the amount of each attribute the character receives during a vanilla level up.
@ -263,7 +273,7 @@ return {
--- Trigger a skill level up, activating relevant handlers --- Trigger a skill level up, activating relevant handlers
-- @function [parent=#SkillProgression] skillLevelUp -- @function [parent=#SkillProgression] skillLevelUp
-- @param #string skillid The id of the skill to level up. -- @param #string skillid The id of the skill to level up.
-- @param #SkillLevelUpSource source The source of the skill increase. -- @param #SkillLevelUpSource source The source of the skill increase. Note that passing a value of @{#SkillLevelUpSource.Jail} will cause a skill decrease for all skills except sneak and security.
skillLevelUp = skillLevelUp, skillLevelUp = skillLevelUp,
--- @{#SkillLevelUpSource} --- @{#SkillLevelUpSource}
@ -272,6 +282,7 @@ return {
Book = 'book', Book = 'book',
Usage = 'usage', Usage = 'usage',
Trainer = 'trainer', Trainer = 'trainer',
Jail = 'jail',
}, },
--- Compute the total skill gain required to level up a skill based on its current level, and other modifying factors such as major skills and specialization. --- Compute the total skill gain required to level up a skill based on its current level, and other modifying factors such as major skills and specialization.

View file

@ -171,7 +171,7 @@ return {
interface = { interface = {
--- Interface version --- Interface version
-- @field [parent=#UI] #number version -- @field [parent=#UI] #number version
version = 2, version = 3,
--- All available UI modes. --- All available UI modes.
-- Use `view(I.UI.MODE)` in `luap` console mode to see the list. -- Use `view(I.UI.MODE)` in `luap` console mode to see the list.
@ -254,6 +254,13 @@ return {
-- @return #boolean -- @return #boolean
isWindowVisible = isWindowVisible, isWindowVisible = isWindowVisible,
---
-- Shows a message as an interactive message box pausing the game, with a single button with the localized text OK.
-- @function [parent=#UI] showInteractiveMessage
-- @param #string message Message to display
-- @param #table options Options (none yet)
showInteractiveMessage = ui._showInteractiveMessage
-- TODO -- TODO
-- registerHudElement = function(name, showFn, hideFn) end, -- registerHudElement = function(name, showFn, hideFn) end,
-- showHudElement = function(name, bool) end, -- showHudElement = function(name, bool) end,

View file

@ -18,7 +18,7 @@
-- * `scale` - a boolean, to set if the sound's pitch should be scaled by simulation time scaling (default: true); -- * `scale` - a boolean, to set if the sound's pitch should be scaled by simulation time scaling (default: true);
-- * `loop` - a boolean, to set if the sound should be repeated when it ends (default: false); -- * `loop` - a boolean, to set if the sound should be repeated when it ends (default: false);
-- @usage local params = { -- @usage local params = {
-- timeOffset=0.1 -- timeOffset=0.1,
-- volume=0.3, -- volume=0.3,
-- scale=false, -- scale=false,
-- pitch=1.0, -- pitch=1.0,
@ -38,7 +38,7 @@
-- * `scale` - a boolean, to set if the sound's pitch should be scaled by simulation time scaling (default: true); -- * `scale` - a boolean, to set if the sound's pitch should be scaled by simulation time scaling (default: true);
-- * `loop` - a boolean, to set if the sound should be repeated when it ends (default: false); -- * `loop` - a boolean, to set if the sound should be repeated when it ends (default: false);
-- @usage local params = { -- @usage local params = {
-- timeOffset=0.1 -- timeOffset=0.1,
-- volume=0.3, -- volume=0.3,
-- scale=false, -- scale=false,
-- pitch=1.0, -- pitch=1.0,

View file

@ -188,7 +188,7 @@
-- --
-- * `loops` - a number >= 0, the number of times the animation should loop after the first play (default: 0). -- * `loops` - a number >= 0, the number of times the animation should loop after the first play (default: 0).
-- * `priority` - Either a single #Priority value that will be assigned to all bone groups. Or a table mapping bone groups to its priority (default: PRIORITY.Default). -- * `priority` - Either a single #Priority value that will be assigned to all bone groups. Or a table mapping bone groups to its priority (default: PRIORITY.Default).
-- * `blendMask` - A mask of which bone groups to include in the animation (Default: BLEND_MASK.All. -- * `blendMask` - A mask of which bone groups to include in the animation (Default: BLEND_MASK.All).
-- * `autoDisable` - If true, the animation will be immediately removed upon finishing, which means information will not be possible to query once completed. (Default: true) -- * `autoDisable` - If true, the animation will be immediately removed upon finishing, which means information will not be possible to query once completed. (Default: true)
-- * `speed` - a floating point number >= 0, the speed at which the animation should play (default: 1) -- * `speed` - a floating point number >= 0, the speed at which the animation should play (default: 1)
-- * `startKey` - the animation key at which the animation should start (default: "start") -- * `startKey` - the animation key at which the animation should start (default: "start")
@ -242,7 +242,7 @@
-- model = types.Static.record(mgef.hitStatic).model, -- model = types.Static.record(mgef.hitStatic).model,
-- options = { -- options = {
-- vfxId = mgef.id, -- vfxId = mgef.id,
-- particuleTextureOverride = mgef.particle, -- particleTextureOverride = mgef.particle,
-- loop = false, -- loop = false,
-- } -- }
-- }) -- })
@ -254,7 +254,7 @@
-- Can only be used on self. -- Can only be used on self.
-- @function [parent=#animation] removeVfx -- @function [parent=#animation] removeVfx
-- @param openmw.core#GameObject actor -- @param openmw.core#GameObject actor
-- @param #number vfxId an integer ID that uniquely identifies the VFX to remove -- @param #string vfxId a string ID that uniquely identifies the VFX to remove
--- ---
-- Removes all vfx from the actor. -- Removes all vfx from the actor.

View file

@ -109,7 +109,6 @@
--- ---
-- Additional summand for the yaw angle; useful for camera shaking effects. -- Additional summand for the yaw angle; useful for camera shaking effects.
-- Setting extra pitch doesn't block player input.
-- Full yaw is `getYaw()+getExtraYaw()`. -- Full yaw is `getYaw()+getExtraYaw()`.
-- @function [parent=#camera] setExtraYaw -- @function [parent=#camera] setExtraYaw
-- @param #number value -- @param #number value
@ -122,7 +121,7 @@
--- ---
-- Additional summand for the roll angle; useful for camera shaking effects. -- Additional summand for the roll angle; useful for camera shaking effects.
-- Full yaw is `getRoll()+getExtraRoll()`. -- Full roll is `getRoll()+getExtraRoll()`.
-- @function [parent=#camera] setExtraRoll -- @function [parent=#camera] setExtraRoll
-- @param #number value -- @param #number value
@ -150,7 +149,7 @@
--- ---
-- Set preferred offset between tracked position (see `getTrackedPosition`) and the camera focal point (the center of the screen) in third person mode. -- Set preferred offset between tracked position (see `getTrackedPosition`) and the camera focal point (the center of the screen) in third person mode.
-- The offset is a 2d vector (X, Y) where X is horizontal (to the right from the character) and Y component is vertical (upward). -- The offset is a 2d vector (X, Y) where X is horizontal (to the right from the character) and Y component is vertical (upward).
-- The real offset can differ from the preferred one during smooth transition of if blocked by an obstacle. -- The real offset can differ from the preferred one during smooth transition or if blocked by an obstacle.
-- Smooth transition happens by default every time when the preferred offset was changed. Use `instantTransition()` to skip the current transition. -- Smooth transition happens by default every time when the preferred offset was changed. Use `instantTransition()` to skip the current transition.
-- @function [parent=#camera] setFocalPreferredOffset -- @function [parent=#camera] setFocalPreferredOffset
-- @param openmw.util#Vector2 offset -- @param openmw.util#Vector2 offset

View file

@ -801,7 +801,7 @@
-- * `pitch` - a floating point number >= 0, to set a sound pitch (default: 1); -- * `pitch` - a floating point number >= 0, to set a sound pitch (default: 1);
-- * `loop` - a boolean, to set if sound should be repeated when it ends (default: false); -- * `loop` - a boolean, to set if sound should be repeated when it ends (default: false);
-- @usage local params = { -- @usage local params = {
-- timeOffset=0.1 -- timeOffset=0.1,
-- volume=0.3, -- volume=0.3,
-- loop=false, -- loop=false,
-- pitch=1.0 -- pitch=1.0
@ -822,7 +822,7 @@
-- * `pitch` - a floating point number >= 0, to set a sound pitch (default: 1); -- * `pitch` - a floating point number >= 0, to set a sound pitch (default: 1);
-- * `loop` - a boolean, to set if sound should be repeated when it ends (default: false); -- * `loop` - a boolean, to set if sound should be repeated when it ends (default: false);
-- @usage local params = { -- @usage local params = {
-- timeOffset=0.1 -- timeOffset=0.1,
-- volume=0.3, -- volume=0.3,
-- loop=false, -- loop=false,
-- pitch=1.0 -- pitch=1.0

View file

@ -1011,7 +1011,7 @@
-- @param openmw.core#GameObject actor NPC object -- @param openmw.core#GameObject actor NPC object
-- @param #string faction Faction ID -- @param #string faction Faction ID
-- @usage local NPC = require('openmw.types').NPC; -- @usage local NPC = require('openmw.types').NPC;
-- NPC.clearExpell(player, "mages guild"); -- NPC.clearExpelled(player, "mages guild");
--- ---
-- Check if NPC is expelled from given faction. -- Check if NPC is expelled from given faction.