mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-03 17:54:06 +00:00
Move rng to components
This commit is contained in:
parent
7a46d4f46a
commit
8c810e3620
@ -11,7 +11,7 @@
|
|||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
// TODO: move to component
|
// TODO: move to component
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include <components/vfs/manager.hpp>
|
#include <components/vfs/manager.hpp>
|
||||||
#include <components/vfs/registerarchives.hpp>
|
#include <components/vfs/registerarchives.hpp>
|
||||||
@ -196,7 +196,7 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
|
|||||||
, mExportFonts(false)
|
, mExportFonts(false)
|
||||||
, mNewGame (false)
|
, mNewGame (false)
|
||||||
{
|
{
|
||||||
OEngine::Misc::Rng::init();
|
Misc::Rng::init();
|
||||||
std::srand ( static_cast<unsigned int>(std::time(NULL)) );
|
std::srand ( static_cast<unsigned int>(std::time(NULL)) );
|
||||||
MWClass::registerClasses();
|
MWClass::registerClasses();
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
#include "creature.hpp"
|
#include "creature.hpp"
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include <components/esm/loadcrea.hpp>
|
#include <components/esm/loadcrea.hpp>
|
||||||
#include <components/esm/creaturestate.hpp>
|
#include <components/esm/creaturestate.hpp>
|
||||||
@ -251,7 +251,7 @@ namespace MWClass
|
|||||||
|
|
||||||
float hitchance = MWMechanics::getHitChance(ptr, victim, ref->mBase->mData.mCombat);
|
float hitchance = MWMechanics::getHitChance(ptr, victim, ref->mBase->mData.mCombat);
|
||||||
|
|
||||||
if(OEngine::Misc::Rng::rollProbability() >= hitchance/100.0f)
|
if(Misc::Rng::rollProbability() >= hitchance/100.0f)
|
||||||
{
|
{
|
||||||
victim.getClass().onHit(victim, 0.0f, false, MWWorld::Ptr(), ptr, false);
|
victim.getClass().onHit(victim, 0.0f, false, MWWorld::Ptr(), ptr, false);
|
||||||
MWMechanics::reduceWeaponCondition(0.f, false, weapon, ptr);
|
MWMechanics::reduceWeaponCondition(0.f, false, weapon, ptr);
|
||||||
@ -377,7 +377,7 @@ namespace MWClass
|
|||||||
float agilityTerm = getCreatureStats(ptr).getAttribute(ESM::Attribute::Agility).getModified() * getGmst().fKnockDownMult->getFloat();
|
float agilityTerm = getCreatureStats(ptr).getAttribute(ESM::Attribute::Agility).getModified() * getGmst().fKnockDownMult->getFloat();
|
||||||
float knockdownTerm = getCreatureStats(ptr).getAttribute(ESM::Attribute::Agility).getModified()
|
float knockdownTerm = getCreatureStats(ptr).getAttribute(ESM::Attribute::Agility).getModified()
|
||||||
* getGmst().iKnockDownOddsMult->getInt() * 0.01f + getGmst().iKnockDownOddsBase->getInt();
|
* getGmst().iKnockDownOddsMult->getInt() * 0.01f + getGmst().iKnockDownOddsBase->getInt();
|
||||||
if (ishealth && agilityTerm <= damage && knockdownTerm <= OEngine::Misc::Rng::roll0to99())
|
if (ishealth && agilityTerm <= damage && knockdownTerm <= Misc::Rng::roll0to99())
|
||||||
{
|
{
|
||||||
getCreatureStats(ptr).setKnockedDown(true);
|
getCreatureStats(ptr).setKnockedDown(true);
|
||||||
|
|
||||||
@ -681,7 +681,7 @@ namespace MWClass
|
|||||||
++sound;
|
++sound;
|
||||||
}
|
}
|
||||||
if(!sounds.empty())
|
if(!sounds.empty())
|
||||||
return sounds[OEngine::Misc::Rng::rollDice(sounds.size())]->mSound;
|
return sounds[Misc::Rng::rollDice(sounds.size())]->mSound;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == ESM::SoundGenerator::Land)
|
if (type == ESM::SoundGenerator::Land)
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include <components/esm/loadmgef.hpp>
|
#include <components/esm/loadmgef.hpp>
|
||||||
#include <components/esm/loadnpc.hpp>
|
#include <components/esm/loadnpc.hpp>
|
||||||
@ -513,7 +513,7 @@ namespace MWClass
|
|||||||
|
|
||||||
float hitchance = MWMechanics::getHitChance(ptr, victim, ptr.getClass().getSkill(ptr, weapskill));
|
float hitchance = MWMechanics::getHitChance(ptr, victim, ptr.getClass().getSkill(ptr, weapskill));
|
||||||
|
|
||||||
if (OEngine::Misc::Rng::rollProbability() >= hitchance / 100.0f)
|
if (Misc::Rng::rollProbability() >= hitchance / 100.0f)
|
||||||
{
|
{
|
||||||
othercls.onHit(victim, 0.0f, false, weapon, ptr, false);
|
othercls.onHit(victim, 0.0f, false, weapon, ptr, false);
|
||||||
MWMechanics::reduceWeaponCondition(0.f, false, weapon, ptr);
|
MWMechanics::reduceWeaponCondition(0.f, false, weapon, ptr);
|
||||||
@ -643,7 +643,7 @@ namespace MWClass
|
|||||||
const GMST& gmst = getGmst();
|
const GMST& gmst = getGmst();
|
||||||
|
|
||||||
int chance = store.get<ESM::GameSetting>().find("iVoiceHitOdds")->getInt();
|
int chance = store.get<ESM::GameSetting>().find("iVoiceHitOdds")->getInt();
|
||||||
if (OEngine::Misc::Rng::roll0to99() < chance)
|
if (Misc::Rng::roll0to99() < chance)
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getDialogueManager()->say(ptr, "hit");
|
MWBase::Environment::get().getDialogueManager()->say(ptr, "hit");
|
||||||
}
|
}
|
||||||
@ -652,7 +652,7 @@ namespace MWClass
|
|||||||
float agilityTerm = getCreatureStats(ptr).getAttribute(ESM::Attribute::Agility).getModified() * gmst.fKnockDownMult->getFloat();
|
float agilityTerm = getCreatureStats(ptr).getAttribute(ESM::Attribute::Agility).getModified() * gmst.fKnockDownMult->getFloat();
|
||||||
float knockdownTerm = getCreatureStats(ptr).getAttribute(ESM::Attribute::Agility).getModified()
|
float knockdownTerm = getCreatureStats(ptr).getAttribute(ESM::Attribute::Agility).getModified()
|
||||||
* gmst.iKnockDownOddsMult->getInt() * 0.01f + gmst.iKnockDownOddsBase->getInt();
|
* gmst.iKnockDownOddsMult->getInt() * 0.01f + gmst.iKnockDownOddsBase->getInt();
|
||||||
if (ishealth && agilityTerm <= damage && knockdownTerm <= OEngine::Misc::Rng::roll0to99())
|
if (ishealth && agilityTerm <= damage && knockdownTerm <= Misc::Rng::roll0to99())
|
||||||
{
|
{
|
||||||
getCreatureStats(ptr).setKnockedDown(true);
|
getCreatureStats(ptr).setKnockedDown(true);
|
||||||
|
|
||||||
@ -678,7 +678,7 @@ namespace MWClass
|
|||||||
MWWorld::InventoryStore::Slot_RightPauldron, MWWorld::InventoryStore::Slot_RightPauldron,
|
MWWorld::InventoryStore::Slot_RightPauldron, MWWorld::InventoryStore::Slot_RightPauldron,
|
||||||
MWWorld::InventoryStore::Slot_LeftGauntlet, MWWorld::InventoryStore::Slot_RightGauntlet
|
MWWorld::InventoryStore::Slot_LeftGauntlet, MWWorld::InventoryStore::Slot_RightGauntlet
|
||||||
};
|
};
|
||||||
int hitslot = hitslots[OEngine::Misc::Rng::rollDice(20)];
|
int hitslot = hitslots[Misc::Rng::rollDice(20)];
|
||||||
|
|
||||||
float unmitigatedDamage = damage;
|
float unmitigatedDamage = damage;
|
||||||
float x = damage / (damage + getArmorRating(ptr));
|
float x = damage / (damage + getArmorRating(ptr));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <MyGUI_ScrollBar.h>
|
#include <MyGUI_ScrollBar.h>
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include "../mwbase/windowmanager.hpp"
|
#include "../mwbase/windowmanager.hpp"
|
||||||
#include "../mwbase/mechanicsmanager.hpp"
|
#include "../mwbase/mechanicsmanager.hpp"
|
||||||
@ -85,7 +85,7 @@ namespace MWGui
|
|||||||
std::set<int> skills;
|
std::set<int> skills;
|
||||||
for (int day=0; day<mDays; ++day)
|
for (int day=0; day<mDays; ++day)
|
||||||
{
|
{
|
||||||
int skill = OEngine::Misc::Rng::rollDice(ESM::Skill::Length);
|
int skill = Misc::Rng::rollDice(ESM::Skill::Length);
|
||||||
skills.insert(skill);
|
skills.insert(skill);
|
||||||
|
|
||||||
MWMechanics::SkillValue& value = player.getClass().getNpcStats(player).getSkill(skill);
|
MWMechanics::SkillValue& value = player.getClass().getNpcStats(player).getSkill(skill);
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#include <MyGUI_Gui.h>
|
#include <MyGUI_Gui.h>
|
||||||
#include <MyGUI_TextBox.h>
|
#include <MyGUI_TextBox.h>
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include <components/settings/settings.hpp>
|
#include <components/settings/settings.hpp>
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ namespace MWGui
|
|||||||
|
|
||||||
if (!mResources.empty())
|
if (!mResources.empty())
|
||||||
{
|
{
|
||||||
std::string const & randomSplash = mResources.at(OEngine::Misc::Rng::rollDice(mResources.size()));
|
std::string const & randomSplash = mResources.at(Misc::Rng::rollDice(mResources.size()));
|
||||||
|
|
||||||
Ogre::TextureManager::getSingleton ().load (randomSplash, Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
|
Ogre::TextureManager::getSingleton ().load (randomSplash, Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "pickpocketitemmodel.hpp"
|
#include "pickpocketitemmodel.hpp"
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include "../mwmechanics/npcstats.hpp"
|
#include "../mwmechanics/npcstats.hpp"
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
@ -20,7 +20,7 @@ namespace MWGui
|
|||||||
{
|
{
|
||||||
for (size_t i = 0; i<mSourceModel->getItemCount(); ++i)
|
for (size_t i = 0; i<mSourceModel->getItemCount(); ++i)
|
||||||
{
|
{
|
||||||
if (chance <= OEngine::Misc::Rng::roll0to99())
|
if (chance <= Misc::Rng::roll0to99())
|
||||||
mHiddenItems.push_back(mSourceModel->getItem(i));
|
mHiddenItems.push_back(mSourceModel->getItem(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <MyGUI_ScrollView.h>
|
#include <MyGUI_ScrollView.h>
|
||||||
#include <MyGUI_Gui.h>
|
#include <MyGUI_Gui.h>
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include <components/esm/records.hpp>
|
#include <components/esm/records.hpp>
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ void Recharge::onItemClicked(MyGUI::Widget *sender)
|
|||||||
intelligenceTerm = 1;
|
intelligenceTerm = 1;
|
||||||
|
|
||||||
float x = (npcStats.getSkill(ESM::Skill::Enchant).getModified() + intelligenceTerm + luckTerm) * stats.getFatigueTerm();
|
float x = (npcStats.getSkill(ESM::Skill::Enchant).getModified() + intelligenceTerm + luckTerm) * stats.getFatigueTerm();
|
||||||
int roll = OEngine::Misc::Rng::roll0to99();
|
int roll = Misc::Rng::roll0to99();
|
||||||
if (roll < x)
|
if (roll < x)
|
||||||
{
|
{
|
||||||
std::string soul = gem.getCellRef().getSoul();
|
std::string soul = gem.getCellRef().getSoul();
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <MyGUI_InputManager.h>
|
#include <MyGUI_InputManager.h>
|
||||||
#include <MyGUI_ControllerManager.h>
|
#include <MyGUI_ControllerManager.h>
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include <components/widgets/numericeditbox.hpp>
|
#include <components/widgets/numericeditbox.hpp>
|
||||||
|
|
||||||
@ -367,7 +367,7 @@ namespace MWGui
|
|||||||
else
|
else
|
||||||
x += abs(int(npcTerm - pcTerm));
|
x += abs(int(npcTerm - pcTerm));
|
||||||
|
|
||||||
int roll = OEngine::Misc::Rng::rollDice(100) + 1;
|
int roll = Misc::Rng::rollDice(100) + 1;
|
||||||
if(roll > x || (mCurrentMerchantOffer < 0) != (mCurrentBalance < 0)) //trade refused
|
if(roll > x || (mCurrentMerchantOffer < 0) != (mCurrentBalance < 0)) //trade refused
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWindowManager()->
|
MWBase::Environment::get().getWindowManager()->
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <MyGUI_ProgressBar.h>
|
#include <MyGUI_ProgressBar.h>
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include <components/widgets/box.hpp>
|
#include <components/widgets/box.hpp>
|
||||||
#include <components/settings/settings.hpp>
|
#include <components/settings/settings.hpp>
|
||||||
@ -156,7 +156,7 @@ namespace MWGui
|
|||||||
{
|
{
|
||||||
// figure out if player will be woken while sleeping
|
// figure out if player will be woken while sleeping
|
||||||
float fSleepRandMod = world->getStore().get<ESM::GameSetting>().find("fSleepRandMod")->getFloat();
|
float fSleepRandMod = world->getStore().get<ESM::GameSetting>().find("fSleepRandMod")->getFloat();
|
||||||
if (OEngine::Misc::Rng::rollProbability() > fSleepRandMod)
|
if (Misc::Rng::rollProbability() > fSleepRandMod)
|
||||||
{
|
{
|
||||||
float fSleepRestMod = world->getStore().get<ESM::GameSetting>().find("fSleepRestMod")->getFloat();
|
float fSleepRestMod = world->getStore().get<ESM::GameSetting>().find("fSleepRestMod")->getFloat();
|
||||||
mInterruptAt = hoursToWait - int(fSleepRestMod * hoursToWait);
|
mInterruptAt = hoursToWait - int(fSleepRestMod * hoursToWait);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "activespells.hpp"
|
#include "activespells.hpp"
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include <components/misc/stringops.hpp>
|
#include <components/misc/stringops.hpp>
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ namespace MWMechanics
|
|||||||
{
|
{
|
||||||
for (TContainer::iterator it = mSpells.begin(); it != mSpells.end(); )
|
for (TContainer::iterator it = mSpells.begin(); it != mSpells.end(); )
|
||||||
{
|
{
|
||||||
if (OEngine::Misc::Rng::roll0to99() < chance)
|
if (Misc::Rng::roll0to99() < chance)
|
||||||
mSpells.erase(it++);
|
mSpells.erase(it++);
|
||||||
else
|
else
|
||||||
++it;
|
++it;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <OgreMath.h>
|
#include <OgreMath.h>
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include <components/esm/aisequence.hpp>
|
#include <components/esm/aisequence.hpp>
|
||||||
|
|
||||||
@ -396,7 +396,7 @@ namespace MWMechanics
|
|||||||
if (!distantCombat) attackType = chooseBestAttack(weapon, movement);
|
if (!distantCombat) attackType = chooseBestAttack(weapon, movement);
|
||||||
else attackType = ESM::Weapon::AT_Chop; // cause it's =0
|
else attackType = ESM::Weapon::AT_Chop; // cause it's =0
|
||||||
|
|
||||||
strength = OEngine::Misc::Rng::rollClosedProbability();
|
strength = Misc::Rng::rollClosedProbability();
|
||||||
|
|
||||||
// Note: may be 0 for some animations
|
// Note: may be 0 for some animations
|
||||||
timerAttack = minMaxAttackDuration[attackType][0] +
|
timerAttack = minMaxAttackDuration[attackType][0] +
|
||||||
@ -407,7 +407,7 @@ namespace MWMechanics
|
|||||||
{
|
{
|
||||||
const MWWorld::ESMStore &store = world->getStore();
|
const MWWorld::ESMStore &store = world->getStore();
|
||||||
int chance = store.get<ESM::GameSetting>().find("iVoiceAttackOdds")->getInt();
|
int chance = store.get<ESM::GameSetting>().find("iVoiceAttackOdds")->getInt();
|
||||||
if (OEngine::Misc::Rng::roll0to99() < chance)
|
if (Misc::Rng::roll0to99() < chance)
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getDialogueManager()->say(actor, "attack");
|
MWBase::Environment::get().getDialogueManager()->say(actor, "attack");
|
||||||
}
|
}
|
||||||
@ -514,17 +514,17 @@ namespace MWMechanics
|
|||||||
{
|
{
|
||||||
if(movement.mPosition[0] || movement.mPosition[1])
|
if(movement.mPosition[0] || movement.mPosition[1])
|
||||||
{
|
{
|
||||||
timerCombatMove = 0.1f + 0.1f * OEngine::Misc::Rng::rollClosedProbability();
|
timerCombatMove = 0.1f + 0.1f * Misc::Rng::rollClosedProbability();
|
||||||
combatMove = true;
|
combatMove = true;
|
||||||
}
|
}
|
||||||
// only NPCs are smart enough to use dodge movements
|
// only NPCs are smart enough to use dodge movements
|
||||||
else if(actorClass.isNpc() && (!distantCombat || (distantCombat && distToTarget < rangeAttack/2)))
|
else if(actorClass.isNpc() && (!distantCombat || (distantCombat && distToTarget < rangeAttack/2)))
|
||||||
{
|
{
|
||||||
//apply sideway movement (kind of dodging) with some probability
|
//apply sideway movement (kind of dodging) with some probability
|
||||||
if (OEngine::Misc::Rng::rollClosedProbability() < 0.25)
|
if (Misc::Rng::rollClosedProbability() < 0.25)
|
||||||
{
|
{
|
||||||
movement.mPosition[0] = OEngine::Misc::Rng::rollProbability() < 0.5 ? 1.0f : -1.0f;
|
movement.mPosition[0] = Misc::Rng::rollProbability() < 0.5 ? 1.0f : -1.0f;
|
||||||
timerCombatMove = 0.05f + 0.15f * OEngine::Misc::Rng::rollClosedProbability();
|
timerCombatMove = 0.05f + 0.15f * Misc::Rng::rollClosedProbability();
|
||||||
combatMove = true;
|
combatMove = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -639,7 +639,7 @@ namespace MWMechanics
|
|||||||
float s2 = speed2 * t;
|
float s2 = speed2 * t;
|
||||||
float t_swing =
|
float t_swing =
|
||||||
minMaxAttackDuration[ESM::Weapon::AT_Thrust][0] +
|
minMaxAttackDuration[ESM::Weapon::AT_Thrust][0] +
|
||||||
(minMaxAttackDuration[ESM::Weapon::AT_Thrust][1] - minMaxAttackDuration[ESM::Weapon::AT_Thrust][0]) * OEngine::Misc::Rng::rollClosedProbability();
|
(minMaxAttackDuration[ESM::Weapon::AT_Thrust][1] - minMaxAttackDuration[ESM::Weapon::AT_Thrust][0]) * Misc::Rng::rollClosedProbability();
|
||||||
|
|
||||||
if (t + s2/speed1 <= t_swing)
|
if (t + s2/speed1 <= t_swing)
|
||||||
{
|
{
|
||||||
@ -763,10 +763,10 @@ ESM::Weapon::AttackType chooseBestAttack(const ESM::Weapon* weapon, MWMechanics:
|
|||||||
if (weapon == NULL)
|
if (weapon == NULL)
|
||||||
{
|
{
|
||||||
//hand-to-hand deal equal damage for each type
|
//hand-to-hand deal equal damage for each type
|
||||||
float roll = OEngine::Misc::Rng::rollClosedProbability();
|
float roll = Misc::Rng::rollClosedProbability();
|
||||||
if(roll <= 0.333f) //side punch
|
if(roll <= 0.333f) //side punch
|
||||||
{
|
{
|
||||||
movement.mPosition[0] = OEngine::Misc::Rng::rollClosedProbability() ? 1.0f : -1.0f;
|
movement.mPosition[0] = Misc::Rng::rollClosedProbability() ? 1.0f : -1.0f;
|
||||||
movement.mPosition[1] = 0;
|
movement.mPosition[1] = 0;
|
||||||
attackType = ESM::Weapon::AT_Slash;
|
attackType = ESM::Weapon::AT_Slash;
|
||||||
}
|
}
|
||||||
@ -790,10 +790,10 @@ ESM::Weapon::AttackType chooseBestAttack(const ESM::Weapon* weapon, MWMechanics:
|
|||||||
|
|
||||||
float total = static_cast<float>(slash + chop + thrust);
|
float total = static_cast<float>(slash + chop + thrust);
|
||||||
|
|
||||||
float roll = OEngine::Misc::Rng::rollClosedProbability();
|
float roll = Misc::Rng::rollClosedProbability();
|
||||||
if(roll <= (slash/total))
|
if(roll <= (slash/total))
|
||||||
{
|
{
|
||||||
movement.mPosition[0] = (OEngine::Misc::Rng::rollClosedProbability() < 0.5f) ? 1.0f : -1.0f;
|
movement.mPosition[0] = (Misc::Rng::rollClosedProbability() < 0.5f) ? 1.0f : -1.0f;
|
||||||
movement.mPosition[1] = 0;
|
movement.mPosition[1] = 0;
|
||||||
attackType = ESM::Weapon::AT_Slash;
|
attackType = ESM::Weapon::AT_Slash;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <OgreVector3.h>
|
#include <OgreVector3.h>
|
||||||
#include <OgreSceneNode.h>
|
#include <OgreSceneNode.h>
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include <components/esm/aisequence.hpp>
|
#include <components/esm/aisequence.hpp>
|
||||||
|
|
||||||
@ -329,7 +329,7 @@ namespace MWMechanics
|
|||||||
static float fVoiceIdleOdds = MWBase::Environment::get().getWorld()->getStore()
|
static float fVoiceIdleOdds = MWBase::Environment::get().getWorld()->getStore()
|
||||||
.get<ESM::GameSetting>().find("fVoiceIdleOdds")->getFloat();
|
.get<ESM::GameSetting>().find("fVoiceIdleOdds")->getFloat();
|
||||||
|
|
||||||
float roll = OEngine::Misc::Rng::rollProbability() * 10000.0f;
|
float roll = Misc::Rng::rollProbability() * 10000.0f;
|
||||||
|
|
||||||
// In vanilla MW the chance was FPS dependent, and did not allow proper changing of fVoiceIdleOdds
|
// In vanilla MW the chance was FPS dependent, and did not allow proper changing of fVoiceIdleOdds
|
||||||
// due to the roll being an integer.
|
// due to the roll being an integer.
|
||||||
@ -504,7 +504,7 @@ namespace MWMechanics
|
|||||||
if(!storage.mPathFinder.isPathConstructed())
|
if(!storage.mPathFinder.isPathConstructed())
|
||||||
{
|
{
|
||||||
assert(mAllowedNodes.size());
|
assert(mAllowedNodes.size());
|
||||||
unsigned int randNode = OEngine::Misc::Rng::rollDice(mAllowedNodes.size());
|
unsigned int randNode = Misc::Rng::rollDice(mAllowedNodes.size());
|
||||||
// NOTE: initially constructed with local (i.e. cell) co-ordinates
|
// NOTE: initially constructed with local (i.e. cell) co-ordinates
|
||||||
Ogre::Vector3 destNodePos(PathFinder::MakeOgreVector3(mAllowedNodes[randNode]));
|
Ogre::Vector3 destNodePos(PathFinder::MakeOgreVector3(mAllowedNodes[randNode]));
|
||||||
|
|
||||||
@ -631,7 +631,7 @@ namespace MWMechanics
|
|||||||
.get<ESM::GameSetting>().find("fIdleChanceMultiplier")->getFloat();
|
.get<ESM::GameSetting>().find("fIdleChanceMultiplier")->getFloat();
|
||||||
|
|
||||||
unsigned short idleChance = static_cast<unsigned short>(fIdleChanceMultiplier * mIdle[counter]);
|
unsigned short idleChance = static_cast<unsigned short>(fIdleChanceMultiplier * mIdle[counter]);
|
||||||
unsigned short randSelect = (int)(OEngine::Misc::Rng::rollProbability() * int(100 / fIdleChanceMultiplier));
|
unsigned short randSelect = (int)(Misc::Rng::rollProbability() * int(100 / fIdleChanceMultiplier));
|
||||||
if(randSelect < idleChance && randSelect > idleRoll)
|
if(randSelect < idleChance && randSelect > idleRoll)
|
||||||
{
|
{
|
||||||
playedIdle = counter+2;
|
playedIdle = counter+2;
|
||||||
@ -653,7 +653,7 @@ namespace MWMechanics
|
|||||||
|
|
||||||
state.moveIn(new AiWanderStorage());
|
state.moveIn(new AiWanderStorage());
|
||||||
|
|
||||||
int index = OEngine::Misc::Rng::rollDice(mAllowedNodes.size());
|
int index = Misc::Rng::rollDice(mAllowedNodes.size());
|
||||||
ESM::Pathgrid::Point dest = mAllowedNodes[index];
|
ESM::Pathgrid::Point dest = mAllowedNodes[index];
|
||||||
|
|
||||||
// apply a slight offset to prevent overcrowding
|
// apply a slight offset to prevent overcrowding
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include <components/esm/loadskil.hpp>
|
#include <components/esm/loadskil.hpp>
|
||||||
#include <components/esm/loadappa.hpp>
|
#include <components/esm/loadappa.hpp>
|
||||||
@ -297,7 +297,7 @@ void MWMechanics::Alchemy::addPotion (const std::string& name)
|
|||||||
|
|
||||||
newRecord.mName = name;
|
newRecord.mName = name;
|
||||||
|
|
||||||
int index = OEngine::Misc::Rng::rollDice(6);
|
int index = Misc::Rng::rollDice(6);
|
||||||
assert (index>=0 && index<6);
|
assert (index>=0 && index<6);
|
||||||
|
|
||||||
static const char *meshes[] = { "standard", "bargain", "cheap", "fresh", "exclusive", "quality" };
|
static const char *meshes[] = { "standard", "bargain", "cheap", "fresh", "exclusive", "quality" };
|
||||||
@ -470,7 +470,7 @@ MWMechanics::Alchemy::Result MWMechanics::Alchemy::create (const std::string& na
|
|||||||
return Result_RandomFailure;
|
return Result_RandomFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getAlchemyFactor() < OEngine::Misc::Rng::roll0to99())
|
if (getAlchemyFactor() < Misc::Rng::roll0to99())
|
||||||
{
|
{
|
||||||
removeIngredients();
|
removeIngredients();
|
||||||
return Result_RandomFailure;
|
return Result_RandomFailure;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <OgreSceneNode.h>
|
#include <OgreSceneNode.h>
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
@ -109,7 +109,7 @@ namespace MWMechanics
|
|||||||
int iBlockMinChance = gmst.find("iBlockMinChance")->getInt();
|
int iBlockMinChance = gmst.find("iBlockMinChance")->getInt();
|
||||||
x = std::min(iBlockMaxChance, std::max(iBlockMinChance, x));
|
x = std::min(iBlockMaxChance, std::max(iBlockMinChance, x));
|
||||||
|
|
||||||
if (OEngine::Misc::Rng::roll0to99() < x)
|
if (Misc::Rng::roll0to99() < x)
|
||||||
{
|
{
|
||||||
// Reduce shield durability by incoming damage
|
// Reduce shield durability by incoming damage
|
||||||
int shieldhealth = shield->getClass().getItemHealth(*shield);
|
int shieldhealth = shield->getClass().getItemHealth(*shield);
|
||||||
@ -187,7 +187,7 @@ namespace MWMechanics
|
|||||||
int skillValue = attacker.getClass().getSkill(attacker,
|
int skillValue = attacker.getClass().getSkill(attacker,
|
||||||
weapon.getClass().getEquipmentSkill(weapon));
|
weapon.getClass().getEquipmentSkill(weapon));
|
||||||
|
|
||||||
if (OEngine::Misc::Rng::rollProbability() >= getHitChance(attacker, victim, skillValue) / 100.0f)
|
if (Misc::Rng::rollProbability() >= getHitChance(attacker, victim, skillValue) / 100.0f)
|
||||||
{
|
{
|
||||||
victim.getClass().onHit(victim, 0.0f, false, projectile, attacker, false);
|
victim.getClass().onHit(victim, 0.0f, false, projectile, attacker, false);
|
||||||
MWMechanics::reduceWeaponCondition(0.f, false, weapon, attacker);
|
MWMechanics::reduceWeaponCondition(0.f, false, weapon, attacker);
|
||||||
@ -225,7 +225,7 @@ namespace MWMechanics
|
|||||||
&& !appliedEnchantment)
|
&& !appliedEnchantment)
|
||||||
{
|
{
|
||||||
float fProjectileThrownStoreChance = gmst.find("fProjectileThrownStoreChance")->getFloat();
|
float fProjectileThrownStoreChance = gmst.find("fProjectileThrownStoreChance")->getFloat();
|
||||||
if (OEngine::Misc::Rng::rollProbability() < fProjectileThrownStoreChance / 100.f)
|
if (Misc::Rng::rollProbability() < fProjectileThrownStoreChance / 100.f)
|
||||||
victim.getClass().getContainerStore(victim).add(projectile, 1, victim);
|
victim.getClass().getContainerStore(victim).add(projectile, 1, victim);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ namespace MWMechanics
|
|||||||
|
|
||||||
saveTerm *= 1.25f * normalisedFatigue;
|
saveTerm *= 1.25f * normalisedFatigue;
|
||||||
|
|
||||||
float x = std::max(0.f, saveTerm - OEngine::Misc::Rng::roll0to99());
|
float x = std::max(0.f, saveTerm - Misc::Rng::roll0to99());
|
||||||
|
|
||||||
int element = ESM::MagicEffect::FireDamage;
|
int element = ESM::MagicEffect::FireDamage;
|
||||||
if (i == 1)
|
if (i == 1)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef OPENMW_MECHANICS_DISEASE_H
|
#ifndef OPENMW_MECHANICS_DISEASE_H
|
||||||
#define OPENMW_MECHANICS_DISEASE_H
|
#define OPENMW_MECHANICS_DISEASE_H
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include "../mwbase/windowmanager.hpp"
|
#include "../mwbase/windowmanager.hpp"
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
@ -51,7 +51,7 @@ namespace MWMechanics
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
int x = static_cast<int>(fDiseaseXferChance * 100 * resist);
|
int x = static_cast<int>(fDiseaseXferChance * 100 * resist);
|
||||||
if (OEngine::Misc::Rng::rollDice(10000) < x)
|
if (Misc::Rng::rollDice(10000) < x)
|
||||||
{
|
{
|
||||||
// Contracted disease!
|
// Contracted disease!
|
||||||
actor.getClass().getCreatureStats(actor).getSpells().add(it->first);
|
actor.getClass().getCreatureStats(actor).getSpells().add(it->first);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "enchanting.hpp"
|
#include "enchanting.hpp"
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include "../mwworld/manualref.hpp"
|
#include "../mwworld/manualref.hpp"
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
@ -70,7 +70,7 @@ namespace MWMechanics
|
|||||||
|
|
||||||
if(mSelfEnchanting)
|
if(mSelfEnchanting)
|
||||||
{
|
{
|
||||||
if(getEnchantChance() <= (OEngine::Misc::Rng::roll0to99()))
|
if(getEnchantChance() <= (Misc::Rng::roll0to99()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
mEnchanter.getClass().skillUsageSucceeded (mEnchanter, ESM::Skill::Enchant, 2);
|
mEnchanter.getClass().skillUsageSucceeded (mEnchanter, ESM::Skill::Enchant, 2);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef OPENMW_MECHANICS_LEVELLEDLIST_H
|
#ifndef OPENMW_MECHANICS_LEVELLEDLIST_H
|
||||||
#define OPENMW_MECHANICS_LEVELLEDLIST_H
|
#define OPENMW_MECHANICS_LEVELLEDLIST_H
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ namespace MWMechanics
|
|||||||
|
|
||||||
failChance += levItem->mChanceNone;
|
failChance += levItem->mChanceNone;
|
||||||
|
|
||||||
if (OEngine::Misc::Rng::roll0to99() < failChance)
|
if (Misc::Rng::roll0to99() < failChance)
|
||||||
return std::string();
|
return std::string();
|
||||||
|
|
||||||
std::vector<std::string> candidates;
|
std::vector<std::string> candidates;
|
||||||
@ -55,7 +55,7 @@ namespace MWMechanics
|
|||||||
}
|
}
|
||||||
if (candidates.empty())
|
if (candidates.empty())
|
||||||
return std::string();
|
return std::string();
|
||||||
std::string item = candidates[OEngine::Misc::Rng::rollDice(candidates.size())];
|
std::string item = candidates[Misc::Rng::rollDice(candidates.size())];
|
||||||
|
|
||||||
// Vanilla doesn't fail on nonexistent items in levelled lists
|
// Vanilla doesn't fail on nonexistent items in levelled lists
|
||||||
if (!MWBase::Environment::get().getWorld()->getStore().find(Misc::StringUtils::lowerCase(item)))
|
if (!MWBase::Environment::get().getWorld()->getStore().find(Misc::StringUtils::lowerCase(item)))
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "mechanicsmanagerimp.hpp"
|
#include "mechanicsmanagerimp.hpp"
|
||||||
#include "npcstats.hpp"
|
#include "npcstats.hpp"
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include <components/esm/stolenitems.hpp>
|
#include <components/esm/stolenitems.hpp>
|
||||||
|
|
||||||
@ -733,7 +733,7 @@ namespace MWMechanics
|
|||||||
float x = 0;
|
float x = 0;
|
||||||
float y = 0;
|
float y = 0;
|
||||||
|
|
||||||
float roll = OEngine::Misc::Rng::rollClosedProbability() * 100;
|
float roll = Misc::Rng::rollClosedProbability() * 100;
|
||||||
|
|
||||||
if (type == PT_Admire)
|
if (type == PT_Admire)
|
||||||
{
|
{
|
||||||
@ -1393,7 +1393,7 @@ namespace MWMechanics
|
|||||||
|
|
||||||
float target = x - y;
|
float target = x - y;
|
||||||
|
|
||||||
return (OEngine::Misc::Rng::roll0to99() >= target);
|
return (Misc::Rng::roll0to99() >= target);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MechanicsManager::startCombat(const MWWorld::Ptr &ptr, const MWWorld::Ptr &target)
|
void MechanicsManager::startCombat(const MWWorld::Ptr &ptr, const MWWorld::Ptr &target)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "pickpocket.hpp"
|
#include "pickpocket.hpp"
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwworld/esmstore.hpp"
|
#include "../mwworld/esmstore.hpp"
|
||||||
@ -41,7 +41,7 @@ namespace MWMechanics
|
|||||||
int iPickMaxChance = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
|
int iPickMaxChance = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
|
||||||
.find("iPickMaxChance")->getInt();
|
.find("iPickMaxChance")->getInt();
|
||||||
|
|
||||||
int roll = OEngine::Misc::Rng::roll0to99();
|
int roll = Misc::Rng::roll0to99();
|
||||||
if (t < pcSneak / iPickMinChance)
|
if (t < pcSneak / iPickMinChance)
|
||||||
{
|
{
|
||||||
return (roll > int(pcSneak / iPickMinChance));
|
return (roll > int(pcSneak / iPickMinChance));
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
@ -48,7 +48,7 @@ void Repair::repair(const MWWorld::Ptr &itemToRepair)
|
|||||||
|
|
||||||
float x = (0.1f * pcStrength + 0.1f * pcLuck + armorerSkill) * fatigueTerm;
|
float x = (0.1f * pcStrength + 0.1f * pcLuck + armorerSkill) * fatigueTerm;
|
||||||
|
|
||||||
int roll = OEngine::Misc::Rng::roll0to99();
|
int roll = Misc::Rng::roll0to99();
|
||||||
if (roll <= x)
|
if (roll <= x)
|
||||||
{
|
{
|
||||||
int y = static_cast<int>(fRepairAmountMult * toolQuality * roll);
|
int y = static_cast<int>(fRepairAmountMult * toolQuality * roll);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "security.hpp"
|
#include "security.hpp"
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwworld/containerstore.hpp"
|
#include "../mwworld/containerstore.hpp"
|
||||||
@ -50,7 +50,7 @@ namespace MWMechanics
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getMechanicsManager()->objectOpened(mActor, lock);
|
MWBase::Environment::get().getMechanicsManager()->objectOpened(mActor, lock);
|
||||||
if (OEngine::Misc::Rng::roll0to99() <= x)
|
if (Misc::Rng::roll0to99() <= x)
|
||||||
{
|
{
|
||||||
lock.getClass().unlock(lock);
|
lock.getClass().unlock(lock);
|
||||||
resultMessage = "#{sLockSuccess}";
|
resultMessage = "#{sLockSuccess}";
|
||||||
@ -91,7 +91,7 @@ namespace MWMechanics
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getMechanicsManager()->objectOpened(mActor, trap);
|
MWBase::Environment::get().getMechanicsManager()->objectOpened(mActor, trap);
|
||||||
if (OEngine::Misc::Rng::roll0to99() <= x)
|
if (Misc::Rng::roll0to99() <= x)
|
||||||
{
|
{
|
||||||
trap.getCellRef().setTrap("");
|
trap.getCellRef().setTrap("");
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include "../mwbase/windowmanager.hpp"
|
#include "../mwbase/windowmanager.hpp"
|
||||||
#include "../mwbase/soundmanager.hpp"
|
#include "../mwbase/soundmanager.hpp"
|
||||||
@ -282,7 +282,7 @@ namespace MWMechanics
|
|||||||
if (castChance > 0)
|
if (castChance > 0)
|
||||||
x *= 50 / castChance;
|
x *= 50 / castChance;
|
||||||
|
|
||||||
float roll = OEngine::Misc::Rng::rollClosedProbability() * 100;
|
float roll = Misc::Rng::rollClosedProbability() * 100;
|
||||||
if (magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude)
|
if (magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude)
|
||||||
roll -= resistance;
|
roll -= resistance;
|
||||||
|
|
||||||
@ -385,7 +385,7 @@ namespace MWMechanics
|
|||||||
target.getClass().getCreatureStats(target).getMagicEffects().get(ESM::MagicEffect::ResistCommonDisease).getMagnitude()
|
target.getClass().getCreatureStats(target).getMagicEffects().get(ESM::MagicEffect::ResistCommonDisease).getMagnitude()
|
||||||
: target.getClass().getCreatureStats(target).getMagicEffects().get(ESM::MagicEffect::ResistBlightDisease).getMagnitude();
|
: target.getClass().getCreatureStats(target).getMagicEffects().get(ESM::MagicEffect::ResistBlightDisease).getMagnitude();
|
||||||
|
|
||||||
if (OEngine::Misc::Rng::roll0to99() <= x)
|
if (Misc::Rng::roll0to99() <= x)
|
||||||
{
|
{
|
||||||
// Fully resisted, show message
|
// Fully resisted, show message
|
||||||
if (target == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
if (target == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||||
@ -415,7 +415,7 @@ namespace MWMechanics
|
|||||||
if (spell && caster != target && target.getClass().isActor())
|
if (spell && caster != target && target.getClass().isActor())
|
||||||
{
|
{
|
||||||
float absorb = target.getClass().getCreatureStats(target).getMagicEffects().get(ESM::MagicEffect::SpellAbsorption).getMagnitude();
|
float absorb = target.getClass().getCreatureStats(target).getMagicEffects().get(ESM::MagicEffect::SpellAbsorption).getMagnitude();
|
||||||
absorbed = (OEngine::Misc::Rng::roll0to99() < absorb);
|
absorbed = (Misc::Rng::roll0to99() < absorb);
|
||||||
if (absorbed)
|
if (absorbed)
|
||||||
{
|
{
|
||||||
//const ESM::Static* absorbStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find ("VFX_Absorb");
|
//const ESM::Static* absorbStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find ("VFX_Absorb");
|
||||||
@ -463,7 +463,7 @@ namespace MWMechanics
|
|||||||
if (!reflected && magnitudeMult > 0 && !caster.isEmpty() && caster != target && !(magicEffect->mData.mFlags & ESM::MagicEffect::Unreflectable))
|
if (!reflected && magnitudeMult > 0 && !caster.isEmpty() && caster != target && !(magicEffect->mData.mFlags & ESM::MagicEffect::Unreflectable))
|
||||||
{
|
{
|
||||||
float reflect = target.getClass().getCreatureStats(target).getMagicEffects().get(ESM::MagicEffect::Reflect).getMagnitude();
|
float reflect = target.getClass().getCreatureStats(target).getMagicEffects().get(ESM::MagicEffect::Reflect).getMagnitude();
|
||||||
bool isReflected = (OEngine::Misc::Rng::roll0to99() < reflect);
|
bool isReflected = (Misc::Rng::roll0to99() < reflect);
|
||||||
if (isReflected)
|
if (isReflected)
|
||||||
{
|
{
|
||||||
//const ESM::Static* reflectStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find ("VFX_Reflect");
|
//const ESM::Static* reflectStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find ("VFX_Reflect");
|
||||||
@ -491,7 +491,7 @@ namespace MWMechanics
|
|||||||
|
|
||||||
if (magnitudeMult > 0 && !absorbed)
|
if (magnitudeMult > 0 && !absorbed)
|
||||||
{
|
{
|
||||||
float random = OEngine::Misc::Rng::rollClosedProbability();
|
float random = Misc::Rng::rollClosedProbability();
|
||||||
float magnitude = effectIt->mMagnMin + (effectIt->mMagnMax - effectIt->mMagnMin) * random;
|
float magnitude = effectIt->mMagnMin + (effectIt->mMagnMax - effectIt->mMagnMin) * random;
|
||||||
magnitude *= magnitudeMult;
|
magnitude *= magnitudeMult;
|
||||||
|
|
||||||
@ -824,7 +824,7 @@ namespace MWMechanics
|
|||||||
|
|
||||||
// Check success
|
// Check success
|
||||||
float successChance = getSpellSuccessChance(spell, mCaster);
|
float successChance = getSpellSuccessChance(spell, mCaster);
|
||||||
if (OEngine::Misc::Rng::roll0to99() >= successChance)
|
if (Misc::Rng::roll0to99() >= successChance)
|
||||||
{
|
{
|
||||||
if (mCaster == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
if (mCaster == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicSkillFail}");
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicSkillFail}");
|
||||||
@ -902,7 +902,7 @@ namespace MWMechanics
|
|||||||
+ 0.1f * creatureStats.getAttribute (ESM::Attribute::Luck).getModified())
|
+ 0.1f * creatureStats.getAttribute (ESM::Attribute::Luck).getModified())
|
||||||
* creatureStats.getFatigueTerm();
|
* creatureStats.getFatigueTerm();
|
||||||
|
|
||||||
int roll = OEngine::Misc::Rng::roll0to99();
|
int roll = Misc::Rng::roll0to99();
|
||||||
if (roll > x)
|
if (roll > x)
|
||||||
{
|
{
|
||||||
// "X has no effect on you"
|
// "X has no effect on you"
|
||||||
|
@ -38,7 +38,7 @@ namespace MWMechanics
|
|||||||
for (unsigned int i=0; i<spell->mEffects.mList.size();++i)
|
for (unsigned int i=0; i<spell->mEffects.mList.size();++i)
|
||||||
{
|
{
|
||||||
if (spell->mEffects.mList[i].mMagnMin != spell->mEffects.mList[i].mMagnMax)
|
if (spell->mEffects.mList[i].mMagnMin != spell->mEffects.mList[i].mMagnMax)
|
||||||
random[i] = OEngine::Misc::Rng::rollClosedProbability();
|
random[i] = Misc::Rng::rollClosedProbability();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <osg/UserDataContainer>
|
#include <osg/UserDataContainer>
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include <components/misc/resourcehelpers.hpp>
|
#include <components/misc/resourcehelpers.hpp>
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ void HeadAnimationTime::setEnabled(bool enabled)
|
|||||||
|
|
||||||
void HeadAnimationTime::resetBlinkTimer()
|
void HeadAnimationTime::resetBlinkTimer()
|
||||||
{
|
{
|
||||||
mBlinkTimer = -(2.0f + OEngine::Misc::Rng::rollDice(6));
|
mBlinkTimer = -(2.0f + Misc::Rng::rollDice(6));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeadAnimationTime::update(float dt)
|
void HeadAnimationTime::update(float dt)
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include <components/misc/resourcehelpers.hpp>
|
#include <components/misc/resourcehelpers.hpp>
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include <components/vfs/manager.hpp>
|
#include <components/vfs/manager.hpp>
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ namespace MWSound
|
|||||||
if(!filelist.size())
|
if(!filelist.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int i = OEngine::Misc::Rng::rollDice(filelist.size());
|
int i = Misc::Rng::rollDice(filelist.size());
|
||||||
|
|
||||||
// Don't play the same music track twice in a row
|
// Don't play the same music track twice in a row
|
||||||
if (filelist[i] == mLastPlayedMusic)
|
if (filelist[i] == mLastPlayedMusic)
|
||||||
@ -570,7 +570,7 @@ namespace MWSound
|
|||||||
if(!cell->isExterior() || sTimePassed < sTimeToNextEnvSound)
|
if(!cell->isExterior() || sTimePassed < sTimeToNextEnvSound)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float a = OEngine::Misc::Rng::rollClosedProbability();
|
float a = Misc::Rng::rollClosedProbability();
|
||||||
// NOTE: We should use the "Minimum Time Between Environmental Sounds" and
|
// NOTE: We should use the "Minimum Time Between Environmental Sounds" and
|
||||||
// "Maximum Time Between Environmental Sounds" fallback settings here.
|
// "Maximum Time Between Environmental Sounds" fallback settings here.
|
||||||
sTimeToNextEnvSound = 5.0f*a + 15.0f*(1.0f-a);
|
sTimeToNextEnvSound = 5.0f*a + 15.0f*(1.0f-a);
|
||||||
@ -599,7 +599,7 @@ namespace MWSound
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int r = OEngine::Misc::Rng::rollDice(total);
|
int r = Misc::Rng::rollDice(total);
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
soundIter = regn->mSoundList.begin();
|
soundIter = regn->mSoundList.begin();
|
||||||
|
@ -367,7 +367,7 @@ void MWWorld::InventoryStore::updateMagicEffects(const Ptr& actor)
|
|||||||
// Roll some dice, one for each effect
|
// Roll some dice, one for each effect
|
||||||
params.resize(enchantment.mEffects.mList.size());
|
params.resize(enchantment.mEffects.mList.size());
|
||||||
for (unsigned int i=0; i<params.size();++i)
|
for (unsigned int i=0; i<params.size();++i)
|
||||||
params[i].mRandom = OEngine::Misc::Rng::rollClosedProbability();
|
params[i].mRandom = Misc::Rng::rollClosedProbability();
|
||||||
|
|
||||||
// Try resisting each effect
|
// Try resisting each effect
|
||||||
int i=0;
|
int i=0;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include <components/esm/esmwriter.hpp>
|
#include <components/esm/esmwriter.hpp>
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ namespace MWWorld
|
|||||||
std::vector<const T*> results;
|
std::vector<const T*> results;
|
||||||
std::for_each(mShared.begin(), mShared.end(), GetRecords(id, &results));
|
std::for_each(mShared.begin(), mShared.end(), GetRecords(id, &results));
|
||||||
if(!results.empty())
|
if(!results.empty())
|
||||||
return results[OEngine::Misc::Rng::rollDice(results.size())];
|
return results[Misc::Rng::rollDice(results.size())];
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "weather.hpp"
|
#include "weather.hpp"
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include <components/esm/weatherstate.hpp>
|
#include <components/esm/weatherstate.hpp>
|
||||||
|
|
||||||
@ -527,7 +527,7 @@ void WeatherManager::update(float duration, bool paused)
|
|||||||
if (mThunderSoundDelay <= 0)
|
if (mThunderSoundDelay <= 0)
|
||||||
{
|
{
|
||||||
// pick a random sound
|
// pick a random sound
|
||||||
int sound = OEngine::Misc::Rng::rollDice(4);
|
int sound = Misc::Rng::rollDice(4);
|
||||||
std::string* soundName = NULL;
|
std::string* soundName = NULL;
|
||||||
if (sound == 0) soundName = &mThunderSoundID0;
|
if (sound == 0) soundName = &mThunderSoundID0;
|
||||||
else if (sound == 1) soundName = &mThunderSoundID1;
|
else if (sound == 1) soundName = &mThunderSoundID1;
|
||||||
@ -543,7 +543,7 @@ void WeatherManager::update(float duration, bool paused)
|
|||||||
//mRendering->getSkyManager()->setLightningStrength( mThunderFlash / mThunderThreshold );
|
//mRendering->getSkyManager()->setLightningStrength( mThunderFlash / mThunderThreshold );
|
||||||
//else
|
//else
|
||||||
{
|
{
|
||||||
mThunderChanceNeeded = static_cast<float>(OEngine::Misc::Rng::rollDice(100));
|
mThunderChanceNeeded = static_cast<float>(Misc::Rng::rollDice(100));
|
||||||
mThunderChance = 0;
|
mThunderChance = 0;
|
||||||
//mRendering->getSkyManager()->setLightningStrength( 0.f );
|
//mRendering->getSkyManager()->setLightningStrength( 0.f );
|
||||||
}
|
}
|
||||||
@ -624,7 +624,7 @@ std::string WeatherManager::nextWeather(const ESM::Region* region) const
|
|||||||
* 70% will be greater than 30 (in theory).
|
* 70% will be greater than 30 (in theory).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int chance = OEngine::Misc::Rng::rollDice(100) + 1; // 1..100
|
int chance = Misc::Rng::rollDice(100) + 1; // 1..100
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
for (; i < probability.size(); ++i)
|
for (; i < probability.size(); ++i)
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include <libs/openengine/bullet/trace.h>
|
#include <libs/openengine/bullet/trace.h>
|
||||||
#include <libs/openengine/bullet/physic.hpp>
|
#include <libs/openengine/bullet/physic.hpp>
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include <components/files/collections.hpp>
|
#include <components/files/collections.hpp>
|
||||||
#include <components/compiler/locals.hpp>
|
#include <components/compiler/locals.hpp>
|
||||||
@ -3176,7 +3176,7 @@ namespace MWWorld
|
|||||||
const ESM::CreatureLevList* list = getStore().get<ESM::CreatureLevList>().find(creatureList);
|
const ESM::CreatureLevList* list = getStore().get<ESM::CreatureLevList>().find(creatureList);
|
||||||
|
|
||||||
int iNumberCreatures = getStore().get<ESM::GameSetting>().find("iNumberCreatures")->getInt();
|
int iNumberCreatures = getStore().get<ESM::GameSetting>().find("iNumberCreatures")->getInt();
|
||||||
int numCreatures = 1 + OEngine::Misc::Rng::rollDice(iNumberCreatures); // [1, iNumberCreatures]
|
int numCreatures = 1 + Misc::Rng::rollDice(iNumberCreatures); // [1, iNumberCreatures]
|
||||||
|
|
||||||
for (int i=0; i<numCreatures; ++i)
|
for (int i=0; i<numCreatures; ++i)
|
||||||
{
|
{
|
||||||
@ -3227,7 +3227,7 @@ namespace MWWorld
|
|||||||
|
|
||||||
std::stringstream modelName;
|
std::stringstream modelName;
|
||||||
modelName << "Blood_Model_";
|
modelName << "Blood_Model_";
|
||||||
int roll = OEngine::Misc::Rng::rollDice(3); // [0, 2]
|
int roll = Misc::Rng::rollDice(3); // [0, 2]
|
||||||
modelName << roll;
|
modelName << roll;
|
||||||
std::string model = "meshes\\" + getFallback()->getFallbackString(modelName.str());
|
std::string model = "meshes\\" + getFallback()->getFallbackString(modelName.str());
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ add_component_dir (esmterrain
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_component_dir (misc
|
add_component_dir (misc
|
||||||
utf8stream stringops resourcehelpers
|
utf8stream stringops resourcehelpers rng
|
||||||
)
|
)
|
||||||
|
|
||||||
IF(NOT WIN32 AND NOT APPLE)
|
IF(NOT WIN32 AND NOT APPLE)
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include "runtime.hpp"
|
#include "runtime.hpp"
|
||||||
#include "defines.hpp"
|
#include "defines.hpp"
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
namespace Interpreter
|
namespace Interpreter
|
||||||
{
|
{
|
||||||
@ -148,7 +148,7 @@ namespace Interpreter
|
|||||||
throw std::runtime_error (
|
throw std::runtime_error (
|
||||||
"random: argument out of range (Don't be so negative!)");
|
"random: argument out of range (Don't be so negative!)");
|
||||||
|
|
||||||
Type_Integer value = OEngine::Misc::Rng::rollDice(limit); // [o, limit)
|
Type_Integer value = Misc::Rng::rollDice(limit); // [o, limit)
|
||||||
|
|
||||||
runtime[0].mInteger = value;
|
runtime[0].mInteger = value;
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
namespace OEngine {
|
namespace Misc
|
||||||
namespace Misc {
|
{
|
||||||
|
|
||||||
void Rng::init()
|
void Rng::init()
|
||||||
{
|
{
|
||||||
@ -26,4 +26,3 @@ namespace Misc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
@ -1,9 +1,8 @@
|
|||||||
#ifndef MISC_RNG_H
|
#ifndef OPENMW_COMPONENTS_MISC_RNG_H
|
||||||
#define MISC_RNG_H
|
#define OPENMW_COMPONENTS_MISC_RNG_H
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
namespace OEngine {
|
|
||||||
namespace Misc
|
namespace Misc
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -30,7 +29,6 @@ public:
|
|||||||
static int roll0to99() { return rollDice(100); }
|
static int roll0to99() { return rollDice(100); }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include <components/sceneutil/lightmanager.hpp>
|
#include <components/sceneutil/lightmanager.hpp>
|
||||||
|
|
||||||
#include <libs/openengine/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -46,7 +46,7 @@ namespace SceneUtil
|
|||||||
|
|
||||||
LightController::LightController()
|
LightController::LightController()
|
||||||
: mType(LT_Normal)
|
: mType(LT_Normal)
|
||||||
, mPhase((OEngine::Misc::Rng::rollClosedProbability() * 2.f - 1.f) * 500.f)
|
, mPhase((Misc::Rng::rollClosedProbability() * 2.f - 1.f) * 500.f)
|
||||||
, mLastTime(0.0)
|
, mLastTime(0.0)
|
||||||
, mDeltaCount(0.f)
|
, mDeltaCount(0.f)
|
||||||
, mDirection(1.f)
|
, mDirection(1.f)
|
||||||
|
@ -17,12 +17,7 @@ set(OENGINE_BULLET
|
|||||||
bullet/trace.h
|
bullet/trace.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(OENGINE_MISC
|
set(OENGINE_ALL ${OENGINE_GUI} ${OENGINE_BULLET})
|
||||||
misc/rng.cpp
|
|
||||||
misc/rng.hpp
|
|
||||||
)
|
|
||||||
|
|
||||||
set(OENGINE_ALL ${OENGINE_GUI} ${OENGINE_BULLET} ${OENGINE_MISC})
|
|
||||||
|
|
||||||
set(OENGINE_LIBRARY "oengine")
|
set(OENGINE_LIBRARY "oengine")
|
||||||
set(OENGINE_LIBRARY ${OENGINE_LIBRARY} PARENT_SCOPE)
|
set(OENGINE_LIBRARY ${OENGINE_LIBRARY} PARENT_SCOPE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user