forked from mirror/openmw-tes3mp
fixing MSVC 2013 warning C4244: & C4305
conversion from 'const float' to 'int', possible loss of data conversion from 'double' to 'int', possible loss of data conversion from 'float' to 'int', possible loss of data
This commit is contained in:
parent
e6cd8484a2
commit
ca8c8c6aa4
28 changed files with 213 additions and 221 deletions
|
@ -150,10 +150,10 @@ void Repair::onRepairItem(MyGUI::Widget *sender)
|
|||
|
||||
void Repair::onMouseWheel(MyGUI::Widget* _sender, int _rel)
|
||||
{
|
||||
if (mRepairView->getViewOffset().top + _rel*0.3 > 0)
|
||||
if (mRepairView->getViewOffset().top + _rel*0.3f > 0)
|
||||
mRepairView->setViewOffset(MyGUI::IntPoint(0, 0));
|
||||
else
|
||||
mRepairView->setViewOffset(MyGUI::IntPoint(0, mRepairView->getViewOffset().top + _rel*0.3));
|
||||
mRepairView->setViewOffset(MyGUI::IntPoint(0, static_cast<int>(mRepairView->getViewOffset().top + _rel*0.3f)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -74,9 +74,9 @@ namespace MWMechanics
|
|||
|
||||
for (std::vector<ActiveEffect>::const_iterator effectIt = effects.begin(); effectIt != effects.end(); ++effectIt)
|
||||
{
|
||||
int duration = effectIt->mDuration;
|
||||
double duration = effectIt->mDuration;
|
||||
MWWorld::TimeStamp end = start;
|
||||
end += static_cast<double> (duration)*
|
||||
end += duration *
|
||||
MWBase::Environment::get().getWorld()->getTimeScaleFactor()/(60*60);
|
||||
|
||||
if (end>now)
|
||||
|
@ -110,7 +110,7 @@ namespace MWMechanics
|
|||
{
|
||||
const std::vector<ActiveEffect>& effects = iterator->second.mEffects;
|
||||
|
||||
int duration = 0;
|
||||
float duration = 0;
|
||||
|
||||
for (std::vector<ActiveEffect>::const_iterator iter (effects.begin());
|
||||
iter!=effects.end(); ++iter)
|
||||
|
@ -216,7 +216,7 @@ namespace MWMechanics
|
|||
std::string name = it->second.mDisplayName;
|
||||
|
||||
float remainingTime = effectIt->mDuration +
|
||||
(it->second.mTimeStamp - MWBase::Environment::get().getWorld()->getTimeStamp())*3600/timeScale;
|
||||
static_cast<float>(it->second.mTimeStamp - MWBase::Environment::get().getWorld()->getTimeStamp())*3600/timeScale;
|
||||
float magnitude = effectIt->mMagnitude;
|
||||
|
||||
if (magnitude)
|
||||
|
@ -229,7 +229,7 @@ namespace MWMechanics
|
|||
{
|
||||
for (TContainer::iterator it = mSpells.begin(); it != mSpells.end(); )
|
||||
{
|
||||
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99]
|
||||
int roll = static_cast<int>(std::rand() / (static_cast<double> (RAND_MAX)+1) * 100); // [0, 99]
|
||||
if (roll < chance)
|
||||
mSpells.erase(it++);
|
||||
else
|
||||
|
|
|
@ -84,8 +84,8 @@ bool disintegrateSlot (MWWorld::Ptr ptr, int slot, float disintegrate)
|
|||
// FIXME: charge should be a float, not int so that damage < 1 per frame can be applied.
|
||||
// This was also a bug in the original engine.
|
||||
charge -=
|
||||
std::min(disintegrate,
|
||||
static_cast<float>(charge));
|
||||
std::min(static_cast<int>(disintegrate),
|
||||
charge);
|
||||
item->getCellRef().setCharge(charge);
|
||||
|
||||
if (charge == 0)
|
||||
|
@ -163,7 +163,7 @@ void getRestorationPerHourOfSleep (const MWWorld::Ptr& ptr, float& health, float
|
|||
bool stunted = stats.getMagicEffects ().get(ESM::MagicEffect::StuntedMagicka).getMagnitude() > 0;
|
||||
int endurance = stats.getAttribute (ESM::Attribute::Endurance).getModified ();
|
||||
|
||||
health = 0.1 * endurance;
|
||||
health = 0.1f * endurance;
|
||||
|
||||
magicka = 0;
|
||||
if (!stunted)
|
||||
|
@ -203,7 +203,7 @@ namespace MWMechanics
|
|||
|
||||
static const float fSoulgemMult = world->getStore().get<ESM::GameSetting>().find("fSoulgemMult")->getFloat();
|
||||
|
||||
float creatureSoulValue = mCreature.get<ESM::Creature>()->mBase->mData.mSoul;
|
||||
int creatureSoulValue = mCreature.get<ESM::Creature>()->mBase->mData.mSoul;
|
||||
if (creatureSoulValue == 0)
|
||||
return;
|
||||
|
||||
|
@ -519,8 +519,8 @@ namespace MWMechanics
|
|||
effects.get(EffectKey(ESM::MagicEffect::DrainAttribute, i)).getMagnitude(),
|
||||
effects.get(EffectKey(ESM::MagicEffect::AbsorbAttribute, i)).getMagnitude());
|
||||
|
||||
stat.damage(effects.get(EffectKey(ESM::MagicEffect::DamageAttribute, i)).getMagnitude() * duration * 1.5);
|
||||
stat.restore(effects.get(EffectKey(ESM::MagicEffect::RestoreAttribute, i)).getMagnitude() * duration * 1.5);
|
||||
stat.damage(effects.get(EffectKey(ESM::MagicEffect::DamageAttribute, i)).getMagnitude() * duration * 1.5f);
|
||||
stat.restore(effects.get(EffectKey(ESM::MagicEffect::RestoreAttribute, i)).getMagnitude() * duration * 1.5f);
|
||||
|
||||
creatureStats.setAttribute(i, stat);
|
||||
}
|
||||
|
@ -566,19 +566,19 @@ namespace MWMechanics
|
|||
if (!creature || ptr.get<ESM::Creature>()->mBase->mData.mType == ESM::Creature::Creatures)
|
||||
{
|
||||
Stat<int> stat = creatureStats.getAiSetting(CreatureStats::AI_Fight);
|
||||
stat.setModifier(creatureStats.getMagicEffects().get(ESM::MagicEffect::FrenzyHumanoid+creature).getMagnitude()
|
||||
- creatureStats.getMagicEffects().get(ESM::MagicEffect::CalmHumanoid+creature).getMagnitude());
|
||||
stat.setModifier(static_cast<int>(creatureStats.getMagicEffects().get(ESM::MagicEffect::FrenzyHumanoid + creature).getMagnitude()
|
||||
- creatureStats.getMagicEffects().get(ESM::MagicEffect::CalmHumanoid+creature).getMagnitude()));
|
||||
creatureStats.setAiSetting(CreatureStats::AI_Fight, stat);
|
||||
|
||||
stat = creatureStats.getAiSetting(CreatureStats::AI_Flee);
|
||||
stat.setModifier(creatureStats.getMagicEffects().get(ESM::MagicEffect::DemoralizeHumanoid+creature).getMagnitude()
|
||||
- creatureStats.getMagicEffects().get(ESM::MagicEffect::RallyHumanoid+creature).getMagnitude());
|
||||
stat.setModifier(static_cast<int>(creatureStats.getMagicEffects().get(ESM::MagicEffect::DemoralizeHumanoid + creature).getMagnitude()
|
||||
- creatureStats.getMagicEffects().get(ESM::MagicEffect::RallyHumanoid+creature).getMagnitude()));
|
||||
creatureStats.setAiSetting(CreatureStats::AI_Flee, stat);
|
||||
}
|
||||
if (creature && ptr.get<ESM::Creature>()->mBase->mData.mType == ESM::Creature::Undead)
|
||||
{
|
||||
Stat<int> stat = creatureStats.getAiSetting(CreatureStats::AI_Flee);
|
||||
stat.setModifier(creatureStats.getMagicEffects().get(ESM::MagicEffect::TurnUndead).getMagnitude());
|
||||
stat.setModifier(static_cast<int>(creatureStats.getMagicEffects().get(ESM::MagicEffect::TurnUndead).getMagnitude()));
|
||||
creatureStats.setAiSetting(CreatureStats::AI_Flee, stat);
|
||||
}
|
||||
|
||||
|
@ -741,7 +741,7 @@ namespace MWMechanics
|
|||
for (std::map<int, std::string>::iterator it = boundItemsMap.begin(); it != boundItemsMap.end(); ++it)
|
||||
{
|
||||
bool found = creatureStats.mBoundItems.find(it->first) != creatureStats.mBoundItems.end();
|
||||
int magnitude = creatureStats.getMagicEffects().get(it->first).getMagnitude();
|
||||
float magnitude = creatureStats.getMagicEffects().get(it->first).getMagnitude();
|
||||
if (found != (magnitude > 0))
|
||||
{
|
||||
std::string itemGmst = it->second;
|
||||
|
@ -786,8 +786,8 @@ namespace MWMechanics
|
|||
effects.get(EffectKey(ESM::MagicEffect::DrainSkill, i)).getMagnitude(),
|
||||
effects.get(EffectKey(ESM::MagicEffect::AbsorbSkill, i)).getMagnitude());
|
||||
|
||||
skill.damage(effects.get(EffectKey(ESM::MagicEffect::DamageSkill, i)).getMagnitude() * duration * 1.5);
|
||||
skill.restore(effects.get(EffectKey(ESM::MagicEffect::RestoreSkill, i)).getMagnitude() * duration * 1.5);
|
||||
skill.damage(effects.get(EffectKey(ESM::MagicEffect::DamageSkill, i)).getMagnitude() * duration * 1.5f);
|
||||
skill.restore(effects.get(EffectKey(ESM::MagicEffect::RestoreSkill, i)).getMagnitude() * duration * 1.5f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1331,7 +1331,7 @@ namespace MWMechanics
|
|||
? (stats.getMagicka().getModified() - stats.getMagicka().getCurrent()) / magickaPerHour
|
||||
: 1.0f;
|
||||
|
||||
int autoHours = std::ceil(std::max(1.f, std::max(healthHours, magickaHours)));
|
||||
int autoHours = static_cast<int>(std::ceil(std::max(1.f, std::max(healthHours, magickaHours))));
|
||||
return autoHours;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,12 +31,12 @@ bool MWMechanics::AiAvoidDoor::execute (const MWWorld::Ptr& actor, AiState& stat
|
|||
float x = pos.pos[0] - mLastPos.pos[0];
|
||||
float y = pos.pos[1] - mLastPos.pos[1];
|
||||
float z = pos.pos[2] - mLastPos.pos[2];
|
||||
int distance = x * x + y * y + z * z;
|
||||
float distance = x * x + y * y + z * z;
|
||||
if(distance < 10 * 10) { //Got stuck, didn't move
|
||||
if(mAdjAngle == 0) //Try going in various directions
|
||||
mAdjAngle = 1.57079632679f; //pi/2
|
||||
else if (mAdjAngle == 1.57079632679f)
|
||||
mAdjAngle = -1.57079632679;
|
||||
mAdjAngle = -1.57079632679f;
|
||||
else
|
||||
mAdjAngle = 0;
|
||||
mDuration = 1; //reset timer
|
||||
|
|
|
@ -404,7 +404,7 @@ namespace MWMechanics
|
|||
{
|
||||
const MWWorld::ESMStore &store = world->getStore();
|
||||
int chance = store.get<ESM::GameSetting>().find("iVoiceAttackOdds")->getInt();
|
||||
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99]
|
||||
int roll = static_cast<int>(std::rand() / (static_cast<double> (RAND_MAX)+1) * 100); // [0, 99]
|
||||
if (roll < chance)
|
||||
{
|
||||
MWBase::Environment::get().getDialogueManager()->say(actor, "attack");
|
||||
|
@ -521,7 +521,7 @@ namespace MWMechanics
|
|||
//apply sideway movement (kind of dodging) with some probability
|
||||
if(static_cast<float>(rand())/RAND_MAX < 0.25)
|
||||
{
|
||||
movement.mPosition[0] = static_cast<float>(rand())/RAND_MAX < 0.5? 1: -1;
|
||||
movement.mPosition[0] = static_cast<float>(rand())/RAND_MAX < 0.5? 1.0f : -1.0f;
|
||||
timerCombatMove = 0.05f + 0.15f * static_cast<float>(rand())/RAND_MAX;
|
||||
combatMove = true;
|
||||
}
|
||||
|
@ -588,7 +588,7 @@ namespace MWMechanics
|
|||
// get point just before target
|
||||
std::list<ESM::Pathgrid::Point>::const_iterator pntIter = --mPathFinder.getPath().end();
|
||||
--pntIter;
|
||||
Ogre::Vector3 vBeforeTarget = Ogre::Vector3(pntIter->mX, pntIter->mY, pntIter->mZ);
|
||||
Ogre::Vector3 vBeforeTarget(PathFinder::MakeOgreVector3(*pntIter));
|
||||
|
||||
// if current actor pos is closer to target then last point of path (excluding target itself) then go straight on target
|
||||
if(distToTarget <= (vTargetPos - vBeforeTarget).length())
|
||||
|
@ -685,27 +685,21 @@ namespace MWMechanics
|
|||
if(!mPathFinder.getPath().empty())
|
||||
{
|
||||
ESM::Pathgrid::Point lastPt = mPathFinder.getPath().back();
|
||||
Ogre::Vector3 currPathTarget(lastPt.mX, lastPt.mY, lastPt.mZ);
|
||||
Ogre::Vector3 currPathTarget(PathFinder::MakeOgreVector3(lastPt));
|
||||
dist = (newPathTarget - currPathTarget).length();
|
||||
}
|
||||
else dist = 1e+38F; // necessarily construct a new path
|
||||
|
||||
float targetPosThreshold = (actor.getCell()->getCell()->isExterior())? 300 : 100;
|
||||
float targetPosThreshold = (actor.getCell()->getCell()->isExterior())? 300.0f : 100.0f;
|
||||
|
||||
//construct new path only if target has moved away more than on [targetPosThreshold]
|
||||
if(dist > targetPosThreshold)
|
||||
{
|
||||
ESM::Position pos = actor.getRefData().getPosition();
|
||||
|
||||
ESM::Pathgrid::Point start;
|
||||
start.mX = pos.pos[0];
|
||||
start.mY = pos.pos[1];
|
||||
start.mZ = pos.pos[2];
|
||||
ESM::Pathgrid::Point start(PathFinder::MakePathgridPoint(pos));
|
||||
|
||||
ESM::Pathgrid::Point dest;
|
||||
dest.mX = newPathTarget.x;
|
||||
dest.mY = newPathTarget.y;
|
||||
dest.mZ = newPathTarget.z;
|
||||
ESM::Pathgrid::Point dest(PathFinder::MakePathgridPoint(newPathTarget));
|
||||
|
||||
if(!mPathFinder.isPathConstructed())
|
||||
mPathFinder.buildPath(start, dest, actor.getCell(), false);
|
||||
|
@ -770,7 +764,7 @@ ESM::Weapon::AttackType chooseBestAttack(const ESM::Weapon* weapon, MWMechanics:
|
|||
float roll = static_cast<float>(rand())/RAND_MAX;
|
||||
if(roll <= 0.333f) //side punch
|
||||
{
|
||||
movement.mPosition[0] = (static_cast<float>(rand())/RAND_MAX < 0.5f)? 1: -1;
|
||||
movement.mPosition[0] = (static_cast<float>(rand())/RAND_MAX < 0.5f)? 1.0f : -1.0f;
|
||||
movement.mPosition[1] = 0;
|
||||
attackType = ESM::Weapon::AT_Slash;
|
||||
}
|
||||
|
@ -792,16 +786,16 @@ ESM::Weapon::AttackType chooseBestAttack(const ESM::Weapon* weapon, MWMechanics:
|
|||
int chop = (weapon->mData.mChop[0] + weapon->mData.mChop[1])/2;
|
||||
int thrust = (weapon->mData.mThrust[0] + weapon->mData.mThrust[1])/2;
|
||||
|
||||
float total = slash + chop + thrust;
|
||||
float total = static_cast<float>(slash + chop + thrust);
|
||||
|
||||
float roll = static_cast<float>(rand())/RAND_MAX;
|
||||
if(roll <= static_cast<float>(slash)/total)
|
||||
if(roll <= (slash/total))
|
||||
{
|
||||
movement.mPosition[0] = (static_cast<float>(rand())/RAND_MAX < 0.5f)? 1: -1;
|
||||
movement.mPosition[0] = (static_cast<float>(rand())/RAND_MAX < 0.5f)? 1.0f : -1.0f;
|
||||
movement.mPosition[1] = 0;
|
||||
attackType = ESM::Weapon::AT_Slash;
|
||||
}
|
||||
else if(roll <= (static_cast<float>(slash) + static_cast<float>(thrust))/total)
|
||||
else if(roll <= (slash + (thrust/total)))
|
||||
{
|
||||
movement.mPosition[1] = 1;
|
||||
attackType = ESM::Weapon::AT_Thrust;
|
||||
|
|
|
@ -323,14 +323,14 @@ namespace MWMechanics
|
|||
if (effect.mAttribute >= 0 && effect.mAttribute < ESM::Attribute::Length)
|
||||
{
|
||||
const float attributePriorities[ESM::Attribute::Length] = {
|
||||
1.f, // Strength
|
||||
0.5, // Intelligence
|
||||
0.6, // Willpower
|
||||
0.7, // Agility
|
||||
0.5, // Speed
|
||||
0.8, // Endurance
|
||||
0.7, // Personality
|
||||
0.3 // Luck
|
||||
1.0f, // Strength
|
||||
0.5f, // Intelligence
|
||||
0.6f, // Willpower
|
||||
0.7f, // Agility
|
||||
0.5f, // Speed
|
||||
0.8f, // Endurance
|
||||
0.7f, // Personality
|
||||
0.3f // Luck
|
||||
};
|
||||
rating *= attributePriorities[effect.mAttribute];
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
namespace MWMechanics
|
||||
{
|
||||
AiEscort::AiEscort(const std::string &actorId, int duration, float x, float y, float z)
|
||||
: mActorId(actorId), mX(x), mY(y), mZ(z), mRemainingDuration(duration)
|
||||
: mActorId(actorId), mX(x), mY(y), mZ(z), mRemainingDuration(static_cast<float>(duration))
|
||||
, mCellX(std::numeric_limits<int>::max())
|
||||
, mCellY(std::numeric_limits<int>::max())
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ namespace MWMechanics
|
|||
}
|
||||
|
||||
AiEscort::AiEscort(const std::string &actorId, const std::string &cellId,int duration, float x, float y, float z)
|
||||
: mActorId(actorId), mCellId(cellId), mX(x), mY(y), mZ(z), mRemainingDuration(duration)
|
||||
: mActorId(actorId), mCellId(cellId), mX(x), mY(y), mZ(z), mRemainingDuration(static_cast<float>(duration))
|
||||
, mCellX(std::numeric_limits<int>::max())
|
||||
, mCellY(std::numeric_limits<int>::max())
|
||||
{
|
||||
|
@ -86,13 +86,13 @@ namespace MWMechanics
|
|||
for (short counter = 0; counter < 3; counter++)
|
||||
differenceBetween[counter] = (leaderPos[counter] - followerPos[counter]);
|
||||
|
||||
float distanceBetweenResult =
|
||||
double distanceBetweenResult =
|
||||
(differenceBetween[0] * differenceBetween[0]) + (differenceBetween[1] * differenceBetween[1]) + (differenceBetween[2] *
|
||||
differenceBetween[2]);
|
||||
|
||||
if(distanceBetweenResult <= mMaxDist * mMaxDist)
|
||||
{
|
||||
ESM::Pathgrid::Point point(mX,mY,mZ);
|
||||
ESM::Pathgrid::Point point(static_cast<int>(mX), static_cast<int>(mY), static_cast<int>(mZ));
|
||||
point.mAutogenerated = 0;
|
||||
point.mConnectionNum = 0;
|
||||
point.mUnknown = 0;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
MWMechanics::AiPackage::~AiPackage() {}
|
||||
|
||||
MWMechanics::AiPackage::AiPackage() : mTimer(.26), mStuckTimer(0) { //mTimer starts at .26 to force initial pathbuild
|
||||
MWMechanics::AiPackage::AiPackage() : mTimer(0.26f), mStuckTimer(0) { //mTimer starts at .26 to force initial pathbuild
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -93,15 +93,9 @@ namespace MWMechanics
|
|||
mCellX = cell->mData.mX;
|
||||
mCellY = cell->mData.mY;
|
||||
|
||||
ESM::Pathgrid::Point dest;
|
||||
dest.mX = mX;
|
||||
dest.mY = mY;
|
||||
dest.mZ = mZ;
|
||||
ESM::Pathgrid::Point dest(static_cast<int>(mX), static_cast<int>(mY), static_cast<int>(mZ));
|
||||
|
||||
ESM::Pathgrid::Point start;
|
||||
start.mX = pos.pos[0];
|
||||
start.mY = pos.pos[1];
|
||||
start.mZ = pos.pos[2];
|
||||
ESM::Pathgrid::Point start(PathFinder::MakePathgridPoint(pos));
|
||||
|
||||
mPathFinder.buildPath(start, dest, actor.getCell(), true);
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ namespace MWMechanics
|
|||
if(mDistance && // actor is not intended to be stationary
|
||||
idleNow && // but is in idle
|
||||
!walking && // FIXME: some actors are idle while walking
|
||||
proximityToDoor(actor, MIN_DIST_TO_DOOR_SQUARED*1.6*1.6)) // NOTE: checks interior cells only
|
||||
proximityToDoor(actor, MIN_DIST_TO_DOOR_SQUARED*1.6f*1.6f)) // NOTE: checks interior cells only
|
||||
{
|
||||
idleNow = false;
|
||||
moveNow = true;
|
||||
|
@ -315,13 +315,13 @@ namespace MWMechanics
|
|||
static float fVoiceIdleOdds = MWBase::Environment::get().getWorld()->getStore()
|
||||
.get<ESM::GameSetting>().find("fVoiceIdleOdds")->getFloat();
|
||||
|
||||
float roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 10000;
|
||||
float roll = std::rand()/ (static_cast<float> (RAND_MAX) + 1) * 10000;
|
||||
|
||||
// In vanilla MW the chance was FPS dependent, and did not allow proper changing of fVoiceIdleOdds
|
||||
// due to the roll being an integer.
|
||||
// Our implementation does not have these issues, so needs to be recalibrated. We chose to
|
||||
// use the chance MW would have when run at 60 FPS with the default value of the GMST for calibration.
|
||||
float x = fVoiceIdleOdds * 0.6 * (MWBase::Environment::get().getFrameDuration() / 0.1);
|
||||
float x = fVoiceIdleOdds * 0.6f * (MWBase::Environment::get().getFrameDuration() / 0.1f);
|
||||
|
||||
// Only say Idle voices when player is in LOS
|
||||
// A bit counterintuitive, likely vanilla did this to reduce the appearance of
|
||||
|
@ -393,18 +393,10 @@ namespace MWMechanics
|
|||
|
||||
if (!storage.mPathFinder.isPathConstructed())
|
||||
{
|
||||
Ogre::Vector3 destNodePos = mReturnPosition;
|
||||
|
||||
ESM::Pathgrid::Point dest;
|
||||
dest.mX = destNodePos[0];
|
||||
dest.mY = destNodePos[1];
|
||||
dest.mZ = destNodePos[2];
|
||||
ESM::Pathgrid::Point dest(PathFinder::MakePathgridPoint(mReturnPosition));
|
||||
|
||||
// actor position is already in world co-ordinates
|
||||
ESM::Pathgrid::Point start;
|
||||
start.mX = pos.pos[0];
|
||||
start.mY = pos.pos[1];
|
||||
start.mZ = pos.pos[2];
|
||||
ESM::Pathgrid::Point start(PathFinder::MakePathgridPoint(pos));
|
||||
|
||||
// don't take shortcuts for wandering
|
||||
storage.mPathFinder.buildPath(start, dest, actor.getCell(), false);
|
||||
|
@ -422,7 +414,7 @@ namespace MWMechanics
|
|||
{
|
||||
// Play a random voice greeting if the player gets too close
|
||||
int hello = cStats.getAiSetting(CreatureStats::AI_Hello).getModified();
|
||||
float helloDistance = hello;
|
||||
float helloDistance = static_cast<float>(hello);
|
||||
static int iGreetDistanceMultiplier =MWBase::Environment::get().getWorld()->getStore()
|
||||
.get<ESM::GameSetting>().find("iGreetDistanceMultiplier")->getInt();
|
||||
|
||||
|
@ -500,15 +492,10 @@ namespace MWMechanics
|
|||
assert(mAllowedNodes.size());
|
||||
unsigned int randNode = (int)(rand() / ((double)RAND_MAX + 1) * mAllowedNodes.size());
|
||||
// NOTE: initially constructed with local (i.e. cell) co-ordinates
|
||||
Ogre::Vector3 destNodePos(mAllowedNodes[randNode].mX,
|
||||
mAllowedNodes[randNode].mY,
|
||||
mAllowedNodes[randNode].mZ);
|
||||
Ogre::Vector3 destNodePos(PathFinder::MakeOgreVector3(mAllowedNodes[randNode]));
|
||||
|
||||
// convert dest to use world co-ordinates
|
||||
ESM::Pathgrid::Point dest;
|
||||
dest.mX = destNodePos[0];
|
||||
dest.mY = destNodePos[1];
|
||||
dest.mZ = destNodePos[2];
|
||||
ESM::Pathgrid::Point dest(PathFinder::MakePathgridPoint(destNodePos));
|
||||
if (currentCell->getCell()->isExterior())
|
||||
{
|
||||
dest.mX += currentCell->getCell()->mData.mX * ESM::Land::REAL_SIZE;
|
||||
|
@ -516,10 +503,7 @@ namespace MWMechanics
|
|||
}
|
||||
|
||||
// actor position is already in world co-ordinates
|
||||
ESM::Pathgrid::Point start;
|
||||
start.mX = pos.pos[0];
|
||||
start.mY = pos.pos[1];
|
||||
start.mZ = pos.pos[2];
|
||||
ESM::Pathgrid::Point start(PathFinder::MakePathgridPoint(pos));
|
||||
|
||||
// don't take shortcuts for wandering
|
||||
storage.mPathFinder.buildPath(start, dest, actor.getCell(), false);
|
||||
|
@ -652,7 +636,7 @@ namespace MWMechanics
|
|||
static float fIdleChanceMultiplier = MWBase::Environment::get().getWorld()->getStore()
|
||||
.get<ESM::GameSetting>().find("fIdleChanceMultiplier")->getFloat();
|
||||
|
||||
unsigned short idleChance = fIdleChanceMultiplier * mIdle[counter];
|
||||
unsigned short idleChance = static_cast<unsigned short>(fIdleChanceMultiplier * mIdle[counter]);
|
||||
unsigned short randSelect = (int)(rand() / ((double)RAND_MAX + 1) * int(100 / fIdleChanceMultiplier));
|
||||
if(randSelect < idleChance && randSelect > idleRoll)
|
||||
{
|
||||
|
@ -675,12 +659,12 @@ namespace MWMechanics
|
|||
|
||||
state.moveIn(new AiWanderStorage());
|
||||
|
||||
int index = std::rand() / (static_cast<double> (RAND_MAX) + 1) * mAllowedNodes.size();
|
||||
int index = static_cast<int>(std::rand() / (static_cast<double> (RAND_MAX)+1) * mAllowedNodes.size());
|
||||
ESM::Pathgrid::Point dest = mAllowedNodes[index];
|
||||
|
||||
// apply a slight offset to prevent overcrowding
|
||||
dest.mX += Ogre::Math::RangeRandom(-64, 64);
|
||||
dest.mY += Ogre::Math::RangeRandom(-64, 64);
|
||||
dest.mX += static_cast<int>(Ogre::Math::RangeRandom(-64, 64));
|
||||
dest.mY += static_cast<int>(Ogre::Math::RangeRandom(-64, 64));
|
||||
|
||||
if (actor.getCell()->isExterior())
|
||||
{
|
||||
|
@ -688,7 +672,8 @@ namespace MWMechanics
|
|||
dest.mY += actor.getCell()->getCell()->mData.mY * ESM::Land::REAL_SIZE;
|
||||
}
|
||||
|
||||
MWBase::Environment::get().getWorld()->moveObject(actor, dest.mX, dest.mY, dest.mZ);
|
||||
MWBase::Environment::get().getWorld()->moveObject(actor, static_cast<float>(dest.mX),
|
||||
static_cast<float>(dest.mY), static_cast<float>(dest.mZ));
|
||||
actor.getClass().adjustPosition(actor, false);
|
||||
}
|
||||
|
||||
|
@ -720,8 +705,8 @@ namespace MWMechanics
|
|||
float cellYOffset = 0;
|
||||
if(cell->isExterior())
|
||||
{
|
||||
cellXOffset = cell->mData.mX * ESM::Land::REAL_SIZE;
|
||||
cellYOffset = cell->mData.mY * ESM::Land::REAL_SIZE;
|
||||
cellXOffset = static_cast<float>(cell->mData.mX * ESM::Land::REAL_SIZE);
|
||||
cellYOffset = static_cast<float>(cell->mData.mY * ESM::Land::REAL_SIZE);
|
||||
}
|
||||
|
||||
// convert npcPos to local (i.e. cell) co-ordinates
|
||||
|
@ -733,20 +718,18 @@ namespace MWMechanics
|
|||
// NOTE: mPoints and mAllowedNodes are in local co-ordinates
|
||||
for(unsigned int counter = 0; counter < pathgrid->mPoints.size(); counter++)
|
||||
{
|
||||
Ogre::Vector3 nodePos(pathgrid->mPoints[counter].mX, pathgrid->mPoints[counter].mY,
|
||||
pathgrid->mPoints[counter].mZ);
|
||||
Ogre::Vector3 nodePos(PathFinder::MakeOgreVector3(pathgrid->mPoints[counter]));
|
||||
if(npcPos.squaredDistance(nodePos) <= mDistance * mDistance)
|
||||
mAllowedNodes.push_back(pathgrid->mPoints[counter]);
|
||||
}
|
||||
if(!mAllowedNodes.empty())
|
||||
{
|
||||
Ogre::Vector3 firstNodePos(mAllowedNodes[0].mX, mAllowedNodes[0].mY, mAllowedNodes[0].mZ);
|
||||
Ogre::Vector3 firstNodePos(PathFinder::MakeOgreVector3(mAllowedNodes[0]));
|
||||
float closestNode = npcPos.squaredDistance(firstNodePos);
|
||||
unsigned int index = 0;
|
||||
for(unsigned int counterThree = 1; counterThree < mAllowedNodes.size(); counterThree++)
|
||||
{
|
||||
Ogre::Vector3 nodePos(mAllowedNodes[counterThree].mX, mAllowedNodes[counterThree].mY,
|
||||
mAllowedNodes[counterThree].mZ);
|
||||
Ogre::Vector3 nodePos(PathFinder::MakeOgreVector3(mAllowedNodes[counterThree]));
|
||||
float tempDist = npcPos.squaredDistance(nodePos);
|
||||
if(tempDist < closestNode)
|
||||
index = counterThree;
|
||||
|
|
|
@ -94,17 +94,17 @@ void MWMechanics::Alchemy::applyTools (int flags, float& value) const
|
|||
|
||||
quality = negative ? 2 * toolQuality + 3 * calcinatorQuality :
|
||||
(magnitude && duration ?
|
||||
2 * toolQuality + calcinatorQuality : 2/3.0 * (toolQuality + calcinatorQuality) + 0.5);
|
||||
2 * toolQuality + calcinatorQuality : 2/3.0f * (toolQuality + calcinatorQuality) + 0.5f);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
quality = negative ? 1+toolQuality : (magnitude && duration ? toolQuality : toolQuality + 0.5);
|
||||
quality = negative ? 1+toolQuality : (magnitude && duration ? toolQuality : toolQuality + 0.5f);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
|
||||
quality = magnitude && duration ? calcinatorQuality : calcinatorQuality + 0.5;
|
||||
quality = magnitude && duration ? calcinatorQuality : calcinatorQuality + 0.5f;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -178,8 +178,8 @@ void MWMechanics::Alchemy::updateEffects()
|
|||
if (!(magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration))
|
||||
applyTools (magicEffect->mData.mFlags, duration);
|
||||
|
||||
duration = static_cast<int> (duration+0.5);
|
||||
magnitude = static_cast<int> (magnitude+0.5);
|
||||
duration = roundf(duration);
|
||||
magnitude = roundf(magnitude);
|
||||
|
||||
if (magnitude>0 && duration>0)
|
||||
{
|
||||
|
@ -197,8 +197,8 @@ void MWMechanics::Alchemy::updateEffects()
|
|||
effect.mRange = 0;
|
||||
effect.mArea = 0;
|
||||
|
||||
effect.mDuration = duration;
|
||||
effect.mMagnMin = effect.mMagnMax = magnitude;
|
||||
effect.mDuration = static_cast<int>(duration);
|
||||
effect.mMagnMin = effect.mMagnMax = static_cast<int>(magnitude);
|
||||
|
||||
mEffects.push_back (effect);
|
||||
}
|
||||
|
@ -323,8 +323,8 @@ float MWMechanics::Alchemy::getAlchemyFactor() const
|
|||
|
||||
return
|
||||
(npcStats.getSkill (ESM::Skill::Alchemy).getModified() +
|
||||
0.1 * creatureStats.getAttribute (ESM::Attribute::Intelligence).getModified()
|
||||
+ 0.1 * creatureStats.getAttribute (ESM::Attribute::Luck).getModified());
|
||||
0.1f * creatureStats.getAttribute (ESM::Attribute::Intelligence).getModified()
|
||||
+ 0.1f * creatureStats.getAttribute (ESM::Attribute::Luck).getModified());
|
||||
}
|
||||
|
||||
int MWMechanics::Alchemy::countIngredients() const
|
||||
|
|
|
@ -187,7 +187,7 @@ namespace MWMechanics
|
|||
for (std::vector<ESM::ENAMstruct>::const_iterator it = effects.mList.begin(); it != effects.mList.end(); ++it)
|
||||
{
|
||||
const ESM::ENAMstruct& effect = *it;
|
||||
float x = effect.mDuration;
|
||||
float x = static_cast<float>(effect.mDuration);
|
||||
|
||||
const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(effect.mEffectID);
|
||||
if (!(magicEffect->mData.mFlags & ESM::MagicEffect::UncappedDamage))
|
||||
|
|
|
@ -112,7 +112,7 @@ float getFallDamage(const MWWorld::Ptr& ptr, float fallHeight)
|
|||
|
||||
if (fallHeight >= fallDistanceMin)
|
||||
{
|
||||
const float acrobaticsSkill = ptr.getClass().getSkill(ptr, ESM::Skill::Acrobatics);
|
||||
const float acrobaticsSkill = static_cast<float>(ptr.getClass().getSkill(ptr, ESM::Skill::Acrobatics));
|
||||
const float jumpSpellBonus = ptr.getClass().getCreatureStats(ptr).getMagicEffects().get(ESM::MagicEffect::Jump).getMagnitude();
|
||||
const float fallAcroBase = store.find("fFallAcroBase")->getFloat();
|
||||
const float fallAcroMult = store.find("fFallAcroMult")->getFloat();
|
||||
|
@ -120,7 +120,7 @@ float getFallDamage(const MWWorld::Ptr& ptr, float fallHeight)
|
|||
const float fallDistanceMult = store.find("fFallDistanceMult")->getFloat();
|
||||
|
||||
float x = fallHeight - fallDistanceMin;
|
||||
x -= (1.5 * acrobaticsSkill) + jumpSpellBonus;
|
||||
x -= (1.5f * acrobaticsSkill) + jumpSpellBonus;
|
||||
x = std::max(0.0f, x);
|
||||
|
||||
float a = fallAcroBase + fallAcroMult * (100 - acrobaticsSkill);
|
||||
|
@ -220,7 +220,7 @@ std::string CharacterController::chooseRandomGroup (const std::string& prefix, i
|
|||
while (mAnimation->hasAnimation(prefix + Ogre::StringConverter::toString(numAnims+1)))
|
||||
++numAnims;
|
||||
|
||||
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * numAnims + 1; // [1, numAnims]
|
||||
int roll = static_cast<int>(std::rand() / (static_cast<double> (RAND_MAX)+1) * numAnims) + 1; // [1, numAnims]
|
||||
if (num)
|
||||
*num = roll;
|
||||
return prefix + Ogre::StringConverter::toString(roll);
|
||||
|
@ -829,7 +829,7 @@ bool CharacterController::updateCreatureState()
|
|||
}
|
||||
if (weapType != WeapType_Spell || !mAnimation->hasAnimation("spellcast")) // Not all creatures have a dedicated spellcast animation
|
||||
{
|
||||
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 3; // [0, 2]
|
||||
int roll = static_cast<int>(std::rand() / (static_cast<double> (RAND_MAX)+1) * 3); // [0, 2]
|
||||
if (roll == 0)
|
||||
mCurrentWeapon = "attack1";
|
||||
else if (roll == 1)
|
||||
|
@ -1531,7 +1531,7 @@ void CharacterController::update(float duration)
|
|||
float normalizedEncumbrance = mPtr.getClass().getNormalizedEncumbrance(mPtr);
|
||||
if (normalizedEncumbrance > 1)
|
||||
normalizedEncumbrance = 1;
|
||||
const int fatigueDecrease = fatigueJumpBase + (1 - normalizedEncumbrance) * fatigueJumpMult;
|
||||
const float fatigueDecrease = fatigueJumpBase + (1 - normalizedEncumbrance) * fatigueJumpMult;
|
||||
DynamicStat<float> fatigue = cls.getCreatureStats(mPtr).getFatigue();
|
||||
fatigue.setCurrent(fatigue.getCurrent() - fatigueDecrease);
|
||||
cls.getCreatureStats(mPtr).setFatigue(fatigue);
|
||||
|
@ -1551,12 +1551,12 @@ void CharacterController::update(float duration)
|
|||
|
||||
// inflict fall damages
|
||||
DynamicStat<float> health = cls.getCreatureStats(mPtr).getHealth();
|
||||
int realHealthLost = healthLost * (1.0f - 0.25 * fatigueTerm);
|
||||
float realHealthLost = static_cast<float>(healthLost * (1.0f - 0.25f * fatigueTerm));
|
||||
health.setCurrent(health.getCurrent() - realHealthLost);
|
||||
cls.getCreatureStats(mPtr).setHealth(health);
|
||||
cls.onHit(mPtr, realHealthLost, true, MWWorld::Ptr(), MWWorld::Ptr(), true);
|
||||
|
||||
const float acrobaticsSkill = cls.getSkill(mPtr, ESM::Skill::Acrobatics);
|
||||
const int acrobaticsSkill = cls.getSkill(mPtr, ESM::Skill::Acrobatics);
|
||||
if (healthLost > (acrobaticsSkill * fatigueTerm))
|
||||
{
|
||||
cls.getCreatureStats(mPtr).setKnockedDown(true);
|
||||
|
@ -1612,7 +1612,7 @@ void CharacterController::update(float duration)
|
|||
|
||||
mTurnAnimationThreshold -= duration;
|
||||
if (movestate == CharState_TurnRight || movestate == CharState_TurnLeft)
|
||||
mTurnAnimationThreshold = 0.05;
|
||||
mTurnAnimationThreshold = 0.05f;
|
||||
else if (movestate == CharState_None && (mMovementState == CharState_TurnRight || mMovementState == CharState_TurnLeft)
|
||||
&& mTurnAnimationThreshold > 0)
|
||||
{
|
||||
|
|
|
@ -83,8 +83,8 @@ namespace MWMechanics
|
|||
|
||||
MWMechanics::CreatureStats& attackerStats = attacker.getClass().getCreatureStats(attacker);
|
||||
|
||||
float blockTerm = blocker.getClass().getSkill(blocker, ESM::Skill::Block) + 0.2 * blockerStats.getAttribute(ESM::Attribute::Agility).getModified()
|
||||
+ 0.1 * blockerStats.getAttribute(ESM::Attribute::Luck).getModified();
|
||||
float blockTerm = blocker.getClass().getSkill(blocker, ESM::Skill::Block) + 0.2f * blockerStats.getAttribute(ESM::Attribute::Agility).getModified()
|
||||
+ 0.1f * blockerStats.getAttribute(ESM::Attribute::Luck).getModified();
|
||||
float enemySwing = attackerStats.getAttackStrength();
|
||||
float swingTerm = enemySwing * gmst.find("fSwingBlockMult")->getFloat() + gmst.find("fSwingBlockBase")->getFloat();
|
||||
|
||||
|
@ -93,13 +93,13 @@ namespace MWMechanics
|
|||
blockerTerm *= gmst.find("fBlockStillBonus")->getFloat();
|
||||
blockerTerm *= blockerStats.getFatigueTerm();
|
||||
|
||||
float attackerSkill = 0.f;
|
||||
int attackerSkill = 0;
|
||||
if (weapon.isEmpty())
|
||||
attackerSkill = attacker.getClass().getSkill(attacker, ESM::Skill::HandToHand);
|
||||
else
|
||||
attackerSkill = attacker.getClass().getSkill(attacker, weapon.getClass().getEquipmentSkill(weapon));
|
||||
float attackerTerm = attackerSkill + 0.2 * attackerStats.getAttribute(ESM::Attribute::Agility).getModified()
|
||||
+ 0.1 * attackerStats.getAttribute(ESM::Attribute::Luck).getModified();
|
||||
float attackerTerm = attackerSkill + 0.2f * attackerStats.getAttribute(ESM::Attribute::Agility).getModified()
|
||||
+ 0.1f * attackerStats.getAttribute(ESM::Attribute::Luck).getModified();
|
||||
attackerTerm *= attackerStats.getFatigueTerm();
|
||||
|
||||
int x = int(blockerTerm - attackerTerm);
|
||||
|
@ -107,7 +107,7 @@ namespace MWMechanics
|
|||
int iBlockMinChance = gmst.find("iBlockMinChance")->getInt();
|
||||
x = std::min(iBlockMaxChance, std::max(iBlockMinChance, x));
|
||||
|
||||
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99]
|
||||
int roll = static_cast<int>(std::rand() / (static_cast<double> (RAND_MAX)+1) * 100); // [0, 99]
|
||||
if (roll < x)
|
||||
{
|
||||
// Reduce shield durability by incoming damage
|
||||
|
@ -183,7 +183,7 @@ namespace MWMechanics
|
|||
if(!weapon.isEmpty())
|
||||
weapskill = weapon.getClass().getEquipmentSkill(weapon);
|
||||
|
||||
float skillValue = attacker.getClass().getSkill(attacker,
|
||||
int skillValue = attacker.getClass().getSkill(attacker,
|
||||
weapon.getClass().getEquipmentSkill(weapon));
|
||||
|
||||
if((::rand()/(RAND_MAX+1.0)) > getHitChance(attacker, victim, skillValue)/100.0f)
|
||||
|
@ -206,7 +206,7 @@ namespace MWMechanics
|
|||
}
|
||||
|
||||
damage *= fDamageStrengthBase +
|
||||
(attackerStats.getAttribute(ESM::Attribute::Strength).getModified() * fDamageStrengthMult * 0.1);
|
||||
(attackerStats.getAttribute(ESM::Attribute::Strength).getModified() * fDamageStrengthMult * 0.1f);
|
||||
|
||||
adjustWeaponDamage(damage, weapon);
|
||||
reduceWeaponCondition(damage, true, weapon, attacker);
|
||||
|
@ -265,14 +265,14 @@ namespace MWMechanics
|
|||
+ 0.2f * attackerStats.getAttribute(ESM::Attribute::Willpower).getModified()
|
||||
+ 0.1f * attackerStats.getAttribute(ESM::Attribute::Luck).getModified();
|
||||
|
||||
int fatigueMax = attackerStats.getFatigue().getModified();
|
||||
int fatigueCurrent = attackerStats.getFatigue().getCurrent();
|
||||
float fatigueMax = attackerStats.getFatigue().getModified();
|
||||
float fatigueCurrent = attackerStats.getFatigue().getCurrent();
|
||||
|
||||
float normalisedFatigue = fatigueMax==0 ? 1 : std::max (0.0f, static_cast<float> (fatigueCurrent)/fatigueMax);
|
||||
float normalisedFatigue = floor(fatigueMax)==0 ? 1 : std::max (0.0f, (fatigueCurrent/fatigueMax));
|
||||
|
||||
saveTerm *= 1.25f * normalisedFatigue;
|
||||
|
||||
float roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99]
|
||||
float roll = std::rand()/ (static_cast<float> (RAND_MAX) + 1) * 100; // [0, 99]
|
||||
float x = std::max(0.f, saveTerm - roll);
|
||||
|
||||
int element = ESM::MagicEffect::FireDamage;
|
||||
|
@ -344,7 +344,7 @@ namespace MWMechanics
|
|||
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
||||
float minstrike = store.get<ESM::GameSetting>().find("fMinHandToHandMult")->getFloat();
|
||||
float maxstrike = store.get<ESM::GameSetting>().find("fMaxHandToHandMult")->getFloat();
|
||||
damage = attacker.getClass().getSkill(attacker, ESM::Skill::HandToHand);
|
||||
damage = static_cast<float>(attacker.getClass().getSkill(attacker, ESM::Skill::HandToHand));
|
||||
damage *= minstrike + ((maxstrike-minstrike)*attacker.getClass().getCreatureStats(attacker).getAttackStrength());
|
||||
|
||||
MWMechanics::CreatureStats& otherstats = victim.getClass().getCreatureStats(victim);
|
||||
|
|
|
@ -42,10 +42,10 @@ namespace MWMechanics
|
|||
|
||||
float CreatureStats::getFatigueTerm() const
|
||||
{
|
||||
int max = getFatigue().getModified();
|
||||
int current = getFatigue().getCurrent();
|
||||
float max = getFatigue().getModified();
|
||||
float current = getFatigue().getCurrent();
|
||||
|
||||
float normalised = max==0 ? 1 : std::max (0.0f, static_cast<float> (current)/max);
|
||||
float normalised = floor(max) == 0 ? 1 : std::max (0.0f, current / max);
|
||||
|
||||
const MWWorld::Store<ESM::GameSetting> &gmst =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||
|
|
|
@ -176,7 +176,7 @@ namespace MWMechanics
|
|||
int magMax = (it->mMagnMax == 0) ? 1 : it->mMagnMax;
|
||||
int area = (it->mArea == 0) ? 1 : it->mArea;
|
||||
|
||||
float magnitudeCost = (magMin + magMax) * baseCost * 0.05;
|
||||
float magnitudeCost = (magMin + magMax) * baseCost * 0.05f;
|
||||
if (mCastStyle == ESM::Enchantment::ConstantEffect)
|
||||
{
|
||||
magnitudeCost *= store.get<ESM::GameSetting>().find("fEnchantmentConstantDurationMult")->getFloat();
|
||||
|
@ -186,7 +186,7 @@ namespace MWMechanics
|
|||
magnitudeCost *= it->mDuration;
|
||||
}
|
||||
|
||||
float areaCost = area * 0.05 * baseCost;
|
||||
float areaCost = area * 0.05f * baseCost;
|
||||
|
||||
const float fEffectCostMult = store.get<ESM::GameSetting>().find("fEffectCostMult")->getFloat();
|
||||
|
||||
|
@ -215,7 +215,7 @@ namespace MWMechanics
|
|||
{
|
||||
int baseCost = getBaseCastCost();
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||
return getEffectiveEnchantmentCastCost(baseCost, player);
|
||||
return getEffectiveEnchantmentCastCost(static_cast<float>(baseCost), player);
|
||||
}
|
||||
|
||||
|
||||
|
@ -225,7 +225,7 @@ namespace MWMechanics
|
|||
return 0;
|
||||
|
||||
float priceMultipler = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("fEnchantmentValueMult")->getFloat();
|
||||
int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mEnchanter, (getEnchantPoints() * priceMultipler), true);
|
||||
int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mEnchanter, static_cast<int>(getEnchantPoints() * priceMultipler), true);
|
||||
return price;
|
||||
}
|
||||
|
||||
|
@ -247,7 +247,7 @@ namespace MWMechanics
|
|||
|
||||
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
||||
|
||||
return mOldItemPtr.getClass().getEnchantmentPoints(mOldItemPtr) * store.get<ESM::GameSetting>().find("fEnchantmentMult")->getFloat();
|
||||
return static_cast<int>(mOldItemPtr.getClass().getEnchantmentPoints(mOldItemPtr) * store.get<ESM::GameSetting>().find("fEnchantmentMult")->getFloat());
|
||||
}
|
||||
bool Enchanting::soulEmpty() const
|
||||
{
|
||||
|
@ -274,13 +274,13 @@ namespace MWMechanics
|
|||
const NpcStats& npcStats = mEnchanter.getClass().getNpcStats (mEnchanter);
|
||||
|
||||
float chance1 = (npcStats.getSkill (ESM::Skill::Enchant).getModified() +
|
||||
(0.25 * npcStats.getAttribute (ESM::Attribute::Intelligence).getModified())
|
||||
+ (0.125 * npcStats.getAttribute (ESM::Attribute::Luck).getModified()));
|
||||
(0.25f * npcStats.getAttribute (ESM::Attribute::Intelligence).getModified())
|
||||
+ (0.125f * npcStats.getAttribute (ESM::Attribute::Luck).getModified()));
|
||||
|
||||
const MWWorld::Store<ESM::GameSetting>& gmst = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||
|
||||
float chance2 = 7.5 / (gmst.find("fEnchantmentChanceMult")->getFloat() * ((mCastStyle == ESM::Enchantment::ConstantEffect) ?
|
||||
gmst.find("fEnchantmentConstantChanceMult")->getFloat() : 1 ))
|
||||
float chance2 = 7.5f / (gmst.find("fEnchantmentChanceMult")->getFloat() * ((mCastStyle == ESM::Enchantment::ConstantEffect) ?
|
||||
gmst.find("fEnchantmentConstantChanceMult")->getFloat() : 1.0f ))
|
||||
* getEnchantPoints();
|
||||
|
||||
return (chance1-chance2);
|
||||
|
|
|
@ -142,7 +142,7 @@ void MWMechanics::NpcStats::setFactionReputation (const std::string& faction, in
|
|||
|
||||
float MWMechanics::NpcStats::getSkillProgressRequirement (int skillIndex, const ESM::Class& class_) const
|
||||
{
|
||||
float progressRequirement = 1 + getSkill (skillIndex).getBase();
|
||||
float progressRequirement = static_cast<float>(1 + getSkill(skillIndex).getBase());
|
||||
|
||||
const MWWorld::Store<ESM::GameSetting> &gmst =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||
|
@ -303,7 +303,7 @@ void MWMechanics::NpcStats::updateHealth()
|
|||
const int endurance = getAttribute(ESM::Attribute::Endurance).getBase();
|
||||
const int strength = getAttribute(ESM::Attribute::Strength).getBase();
|
||||
|
||||
setHealth(static_cast<int> (0.5 * (strength + endurance)));
|
||||
setHealth(floor(0.5f * (strength + endurance)));
|
||||
}
|
||||
|
||||
int MWMechanics::NpcStats::getLevelupAttributeMultiplier(int attribute) const
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace
|
|||
//
|
||||
float distanceSquared(ESM::Pathgrid::Point point, Ogre::Vector3 pos)
|
||||
{
|
||||
return Ogre::Vector3(point.mX, point.mY, point.mZ).squaredDistance(pos);
|
||||
return MWMechanics::PathFinder::MakeOgreVector3(point).squaredDistance(pos);
|
||||
}
|
||||
|
||||
// Return the closest pathgrid point index from the specified position co
|
||||
|
@ -95,7 +95,7 @@ namespace MWMechanics
|
|||
x -= point.mX;
|
||||
y -= point.mY;
|
||||
z -= point.mZ;
|
||||
return (x * x + y * y + 0.1 * z * z);
|
||||
return (x * x + y * y + 0.1f * z * z);
|
||||
}
|
||||
|
||||
float distance(ESM::Pathgrid::Point point, float x, float y, float z)
|
||||
|
@ -108,9 +108,9 @@ namespace MWMechanics
|
|||
|
||||
float distance(ESM::Pathgrid::Point a, ESM::Pathgrid::Point b)
|
||||
{
|
||||
float x = a.mX - b.mX;
|
||||
float y = a.mY - b.mY;
|
||||
float z = a.mZ - b.mZ;
|
||||
float x = static_cast<float>(a.mX - b.mX);
|
||||
float y = static_cast<float>(a.mY - b.mY);
|
||||
float z = static_cast<float>(a.mZ - b.mZ);
|
||||
return sqrt(x * x + y * y + z * z);
|
||||
}
|
||||
|
||||
|
@ -176,8 +176,9 @@ namespace MWMechanics
|
|||
if(allowShortcuts)
|
||||
{
|
||||
// if there's a ray cast hit, can't take a direct path
|
||||
if(!MWBase::Environment::get().getWorld()->castRay(startPoint.mX, startPoint.mY, startPoint.mZ,
|
||||
endPoint.mX, endPoint.mY, endPoint.mZ))
|
||||
if (!MWBase::Environment::get().getWorld()->castRay(
|
||||
static_cast<float>(startPoint.mX), static_cast<float>(startPoint.mY), static_cast<float>(startPoint.mZ),
|
||||
static_cast<float>(endPoint.mX), static_cast<float>(endPoint.mY), static_cast<float>(endPoint.mZ)))
|
||||
{
|
||||
mPath.push_back(endPoint);
|
||||
mIsPathConstructed = true;
|
||||
|
@ -206,8 +207,8 @@ namespace MWMechanics
|
|||
float yCell = 0;
|
||||
if (mCell->isExterior())
|
||||
{
|
||||
xCell = mCell->getCell()->mData.mX * ESM::Land::REAL_SIZE;
|
||||
yCell = mCell->getCell()->mData.mY * ESM::Land::REAL_SIZE;
|
||||
xCell = static_cast<float>(mCell->getCell()->mData.mX * ESM::Land::REAL_SIZE);
|
||||
yCell = static_cast<float>(mCell->getCell()->mData.mY * ESM::Land::REAL_SIZE);
|
||||
}
|
||||
|
||||
// NOTE: It is possible that getClosestPoint returns a pathgrind point index
|
||||
|
@ -216,12 +217,12 @@ namespace MWMechanics
|
|||
// point right behind the wall that is closer than any pathgrid
|
||||
// point outside the wall
|
||||
int startNode = getClosestPoint(mPathgrid,
|
||||
Ogre::Vector3(startPoint.mX - xCell, startPoint.mY - yCell, startPoint.mZ));
|
||||
Ogre::Vector3(startPoint.mX - xCell, startPoint.mY - yCell, static_cast<float>(startPoint.mZ)));
|
||||
// Some cells don't have any pathgrids at all
|
||||
if(startNode != -1)
|
||||
{
|
||||
std::pair<int, bool> endNode = getClosestReachablePoint(mPathgrid, cell,
|
||||
Ogre::Vector3(endPoint.mX - xCell, endPoint.mY - yCell, endPoint.mZ),
|
||||
Ogre::Vector3(endPoint.mX - xCell, endPoint.mY - yCell, static_cast<float>(endPoint.mZ)),
|
||||
startNode);
|
||||
|
||||
// this shouldn't really happen, but just in case
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
#ifndef GAME_MWMECHANICS_PATHFINDING_H
|
||||
#define GAME_MWMECHANICS_PATHFINDING_H
|
||||
|
||||
#include <components/esm/defs.hpp>
|
||||
#include <components/esm/loadpgrd.hpp>
|
||||
#include <list>
|
||||
|
||||
#include <OgreMath.h>
|
||||
#include <OgreVector3.h>
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
|
@ -27,11 +29,11 @@ namespace MWMechanics
|
|||
return -1.0;
|
||||
}
|
||||
|
||||
static float sgn(float a)
|
||||
static int sgn(int a)
|
||||
{
|
||||
if(a > 0)
|
||||
return 1.0;
|
||||
return -1.0;
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void clearPath();
|
||||
|
@ -74,6 +76,24 @@ namespace MWMechanics
|
|||
mPath.push_back(point);
|
||||
}
|
||||
|
||||
/// utility function to convert a Ogre::Vector3 to a Pathgrid::Point
|
||||
static ESM::Pathgrid::Point MakePathgridPoint(const Ogre::Vector3& v)
|
||||
{
|
||||
return ESM::Pathgrid::Point(static_cast<int>(v[0]), static_cast<int>(v[1]), static_cast<int>(v[2]));
|
||||
}
|
||||
|
||||
/// utility function to convert an ESM::Position to a Pathgrid::Point
|
||||
static ESM::Pathgrid::Point MakePathgridPoint(const ESM::Position& p)
|
||||
{
|
||||
return ESM::Pathgrid::Point(static_cast<int>(p.pos[0]), static_cast<int>(p.pos[1]), static_cast<int>(p.pos[2]));
|
||||
}
|
||||
|
||||
/// utility function to convert a Pathgrid::Point to a Ogre::Vector3
|
||||
static Ogre::Vector3 MakeOgreVector3(const ESM::Pathgrid::Point& p)
|
||||
{
|
||||
return Ogre::Vector3(static_cast<Ogre::Real>(p.mX), static_cast<Ogre::Real>(p.mY), static_cast<Ogre::Real>(p.mZ));
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
bool mIsPathConstructed;
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace
|
|||
//
|
||||
float manhattan(const ESM::Pathgrid::Point& a, const ESM::Pathgrid::Point& b)
|
||||
{
|
||||
return 300 * (abs(a.mX - b.mX) + abs(a.mY - b.mY) + abs(a.mZ - b.mZ));
|
||||
return 300.0f * (abs(a.mX - b.mX) + abs(a.mY - b.mY) + abs(a.mZ - b.mZ));
|
||||
}
|
||||
|
||||
// Choose a heuristics - Note that these may not be the best for directed
|
||||
|
@ -317,23 +317,23 @@ namespace MWMechanics
|
|||
float yCell = 0;
|
||||
if (mIsExterior)
|
||||
{
|
||||
xCell = mPathgrid->mData.mX * ESM::Land::REAL_SIZE;
|
||||
yCell = mPathgrid->mData.mY * ESM::Land::REAL_SIZE;
|
||||
xCell = static_cast<float>(mPathgrid->mData.mX * ESM::Land::REAL_SIZE);
|
||||
yCell = static_cast<float>(mPathgrid->mData.mY * ESM::Land::REAL_SIZE);
|
||||
}
|
||||
|
||||
while(graphParent[current] != -1)
|
||||
{
|
||||
ESM::Pathgrid::Point pt = mPathgrid->mPoints[current];
|
||||
pt.mX += xCell;
|
||||
pt.mY += yCell;
|
||||
pt.mX += static_cast<int>(xCell);
|
||||
pt.mY += static_cast<int>(yCell);
|
||||
path.push_front(pt);
|
||||
current = graphParent[current];
|
||||
}
|
||||
|
||||
// add first node to path explicitly
|
||||
ESM::Pathgrid::Point pt = mPathgrid->mPoints[start];
|
||||
pt.mX += xCell;
|
||||
pt.mY += yCell;
|
||||
pt.mX += static_cast<int>(xCell);
|
||||
pt.mY += static_cast<int>(yCell);
|
||||
path.push_front(pt);
|
||||
return path;
|
||||
}
|
||||
|
|
|
@ -20,10 +20,10 @@ namespace MWMechanics
|
|||
float Pickpocket::getChanceModifier(const MWWorld::Ptr &ptr, float add)
|
||||
{
|
||||
NpcStats& stats = ptr.getClass().getNpcStats(ptr);
|
||||
float agility = stats.getAttribute(ESM::Attribute::Agility).getModified();
|
||||
float luck = stats.getAttribute(ESM::Attribute::Luck).getModified();
|
||||
float sneak = ptr.getClass().getSkill(ptr, ESM::Skill::Sneak);
|
||||
return (add + 0.2 * agility + 0.1 * luck + sneak) * stats.getFatigueTerm();
|
||||
float agility = static_cast<float>(stats.getAttribute(ESM::Attribute::Agility).getModified());
|
||||
float luck = static_cast<float>(stats.getAttribute(ESM::Attribute::Luck).getModified());
|
||||
float sneak = static_cast<float>(ptr.getClass().getSkill(ptr, ESM::Skill::Sneak));
|
||||
return (add + 0.2f * agility + 0.1f * luck + sneak) * stats.getFatigueTerm();
|
||||
}
|
||||
|
||||
bool Pickpocket::getDetected(float valueTerm)
|
||||
|
@ -33,13 +33,13 @@ namespace MWMechanics
|
|||
|
||||
float t = 2*x - y;
|
||||
|
||||
float pcSneak = mThief.getClass().getSkill(mThief, ESM::Skill::Sneak);
|
||||
float pcSneak = static_cast<float>(mThief.getClass().getSkill(mThief, ESM::Skill::Sneak));
|
||||
int iPickMinChance = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
|
||||
.find("iPickMinChance")->getInt();
|
||||
int iPickMaxChance = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
|
||||
.find("iPickMaxChance")->getInt();
|
||||
|
||||
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99]
|
||||
int roll = static_cast<int>(std::rand() / (static_cast<double> (RAND_MAX)+1) * 100); // [0, 99]
|
||||
if (t < pcSneak / iPickMinChance)
|
||||
{
|
||||
return (roll > int(pcSneak / iPickMinChance));
|
||||
|
@ -53,7 +53,7 @@ namespace MWMechanics
|
|||
|
||||
bool Pickpocket::pick(MWWorld::Ptr item, int count)
|
||||
{
|
||||
float stackValue = item.getClass().getValue(item) * count;
|
||||
float stackValue = static_cast<float>(item.getClass().getValue(item) * count);
|
||||
float fPickPocketMod = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
|
||||
.find("fPickPocketMod")->getFloat();
|
||||
float valueTerm = 10 * fPickPocketMod * stackValue;
|
||||
|
|
|
@ -44,12 +44,12 @@ void Repair::repair(const MWWorld::Ptr &itemToRepair)
|
|||
|
||||
float toolQuality = ref->mBase->mData.mQuality;
|
||||
|
||||
float x = (0.1 * pcStrength + 0.1 * pcLuck + armorerSkill) * fatigueTerm;
|
||||
float x = (0.1f * pcStrength + 0.1f * pcLuck + armorerSkill) * fatigueTerm;
|
||||
|
||||
int roll = static_cast<float> (std::rand()) / RAND_MAX * 100;
|
||||
int roll = static_cast<int>(static_cast<float> (std::rand()) / RAND_MAX * 100);
|
||||
if (roll <= x)
|
||||
{
|
||||
int y = fRepairAmountMult * toolQuality * roll;
|
||||
int y = static_cast<int>(fRepairAmountMult * toolQuality * roll);
|
||||
y = std::max(1, y);
|
||||
|
||||
// repair by 'y' points
|
||||
|
|
|
@ -20,9 +20,9 @@ namespace MWMechanics
|
|||
{
|
||||
CreatureStats& creatureStats = actor.getClass().getCreatureStats(actor);
|
||||
NpcStats& npcStats = actor.getClass().getNpcStats(actor);
|
||||
mAgility = creatureStats.getAttribute(ESM::Attribute::Agility).getModified();
|
||||
mLuck = creatureStats.getAttribute(ESM::Attribute::Luck).getModified();
|
||||
mSecuritySkill = npcStats.getSkill(ESM::Skill::Security).getModified();
|
||||
mAgility = static_cast<float>(creatureStats.getAttribute(ESM::Attribute::Agility).getModified());
|
||||
mLuck = static_cast<float>(creatureStats.getAttribute(ESM::Attribute::Luck).getModified());
|
||||
mSecuritySkill = static_cast<float>(npcStats.getSkill(ESM::Skill::Security).getModified());
|
||||
mFatigueTerm = creatureStats.getFatigueTerm();
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ namespace MWMechanics
|
|||
|
||||
float fPickLockMult = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fPickLockMult")->getFloat();
|
||||
|
||||
float x = 0.2 * mAgility + 0.1 * mLuck + mSecuritySkill;
|
||||
float x = 0.2f * mAgility + 0.1f * mLuck + mSecuritySkill;
|
||||
x *= pickQuality * mFatigueTerm;
|
||||
x += fPickLockMult * lockStrength;
|
||||
|
||||
|
@ -48,7 +48,7 @@ namespace MWMechanics
|
|||
else
|
||||
{
|
||||
MWBase::Environment::get().getMechanicsManager()->objectOpened(mActor, lock);
|
||||
int roll = static_cast<float> (std::rand()) / RAND_MAX * 100;
|
||||
int roll = static_cast<int>(static_cast<float> (std::rand()) / RAND_MAX * 100);
|
||||
if (roll <= x)
|
||||
{
|
||||
lock.getClass().unlock(lock);
|
||||
|
@ -76,11 +76,11 @@ namespace MWMechanics
|
|||
float probeQuality = probe.get<ESM::Probe>()->mBase->mData.mQuality;
|
||||
|
||||
const ESM::Spell* trapSpell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(trap.getCellRef().getTrap());
|
||||
float trapSpellPoints = trapSpell->mData.mCost;
|
||||
int trapSpellPoints = trapSpell->mData.mCost;
|
||||
|
||||
float fTrapCostMult = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fTrapCostMult")->getFloat();
|
||||
|
||||
float x = 0.2 * mAgility + 0.1 * mLuck + mSecuritySkill;
|
||||
float x = 0.2f * mAgility + 0.1f * mLuck + mSecuritySkill;
|
||||
x += fTrapCostMult * trapSpellPoints;
|
||||
x *= probeQuality * mFatigueTerm;
|
||||
|
||||
|
@ -90,7 +90,7 @@ namespace MWMechanics
|
|||
else
|
||||
{
|
||||
MWBase::Environment::get().getMechanicsManager()->objectOpened(mActor, trap);
|
||||
int roll = static_cast<float> (std::rand()) / RAND_MAX * 100;
|
||||
int roll = static_cast<int>(static_cast<float> (std::rand()) / RAND_MAX * 100);
|
||||
if (roll <= x)
|
||||
{
|
||||
trap.getCellRef().setTrap("");
|
||||
|
|
|
@ -144,21 +144,21 @@ namespace MWMechanics
|
|||
|
||||
for (std::vector<ESM::ENAMstruct>::const_iterator it = spell->mEffects.mList.begin(); it != spell->mEffects.mList.end(); ++it)
|
||||
{
|
||||
float x = it->mDuration;
|
||||
float x = static_cast<float>(it->mDuration);
|
||||
const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(
|
||||
it->mEffectID);
|
||||
if (!(magicEffect->mData.mFlags & ESM::MagicEffect::UncappedDamage))
|
||||
x = std::max(1.f, x);
|
||||
x *= 0.1 * magicEffect->mData.mBaseCost;
|
||||
x *= 0.5 * (it->mMagnMin + it->mMagnMax);
|
||||
x *= it->mArea * 0.05 * magicEffect->mData.mBaseCost;
|
||||
x *= 0.1f * magicEffect->mData.mBaseCost;
|
||||
x *= 0.5f * (it->mMagnMin + it->mMagnMax);
|
||||
x *= it->mArea * 0.05f * magicEffect->mData.mBaseCost;
|
||||
if (it->mRange == ESM::RT_Target)
|
||||
x *= 1.5;
|
||||
x *= 1.5f;
|
||||
static const float fEffectCostMult = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(
|
||||
"fEffectCostMult")->getFloat();
|
||||
x *= fEffectCostMult;
|
||||
|
||||
float s = 2 * actor.getClass().getSkill(actor, spellSchoolToSkill(magicEffect->mData.mSchool));
|
||||
float s = 2.0f * actor.getClass().getSkill(actor, spellSchoolToSkill(magicEffect->mData.mSchool));
|
||||
if (s - x < y)
|
||||
{
|
||||
y = s - x;
|
||||
|
@ -174,12 +174,12 @@ namespace MWMechanics
|
|||
if (spell->mData.mFlags & ESM::Spell::F_Always)
|
||||
return 100;
|
||||
|
||||
int castBonus = -stats.getMagicEffects().get(ESM::MagicEffect::Sound).getMagnitude();
|
||||
float castBonus = -stats.getMagicEffects().get(ESM::MagicEffect::Sound).getMagnitude();
|
||||
|
||||
int actorWillpower = stats.getAttribute(ESM::Attribute::Willpower).getModified();
|
||||
int actorLuck = stats.getAttribute(ESM::Attribute::Luck).getModified();
|
||||
|
||||
float castChance = (lowestSkill - spell->mData.mCost + castBonus + 0.2 * actorWillpower + 0.1 * actorLuck) * stats.getFatigueTerm();
|
||||
float castChance = (lowestSkill - spell->mData.mCost + castBonus + 0.2f * actorWillpower + 0.1f * actorLuck) * stats.getFatigueTerm();
|
||||
if (MWBase::Environment::get().getWorld()->getGodModeState() && actor.getRefData().getHandle() == "player")
|
||||
castChance = 100;
|
||||
|
||||
|
@ -267,9 +267,9 @@ namespace MWMechanics
|
|||
|
||||
float resistance = getEffectResistanceAttribute(effectId, magicEffects);
|
||||
|
||||
float willpower = stats.getAttribute(ESM::Attribute::Willpower).getModified();
|
||||
float luck = stats.getAttribute(ESM::Attribute::Luck).getModified();
|
||||
float x = (willpower + 0.1 * luck) * stats.getFatigueTerm();
|
||||
int willpower = stats.getAttribute(ESM::Attribute::Willpower).getModified();
|
||||
float luck = static_cast<float>(stats.getAttribute(ESM::Attribute::Luck).getModified());
|
||||
float x = (willpower + 0.1f * luck) * stats.getFatigueTerm();
|
||||
|
||||
// This makes spells that are easy to cast harder to resist and vice versa
|
||||
float castChance = 100.f;
|
||||
|
@ -383,7 +383,7 @@ namespace MWMechanics
|
|||
target.getClass().getCreatureStats(target).getMagicEffects().get(ESM::MagicEffect::ResistCommonDisease).getMagnitude()
|
||||
: target.getClass().getCreatureStats(target).getMagicEffects().get(ESM::MagicEffect::ResistBlightDisease).getMagnitude();
|
||||
|
||||
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99]
|
||||
int roll = static_cast<int>(std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100); // [0, 99]
|
||||
if (roll <= x)
|
||||
{
|
||||
// Fully resisted, show message
|
||||
|
@ -413,8 +413,8 @@ namespace MWMechanics
|
|||
bool absorbed = false;
|
||||
if (spell && caster != target && target.getClass().isActor())
|
||||
{
|
||||
int absorb = target.getClass().getCreatureStats(target).getMagicEffects().get(ESM::MagicEffect::SpellAbsorption).getMagnitude();
|
||||
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99]
|
||||
float absorb = target.getClass().getCreatureStats(target).getMagicEffects().get(ESM::MagicEffect::SpellAbsorption).getMagnitude();
|
||||
int roll = static_cast<int>(std::rand() / (static_cast<double> (RAND_MAX)+1) * 100); // [0, 99]
|
||||
absorbed = (roll < absorb);
|
||||
if (absorbed)
|
||||
{
|
||||
|
@ -462,8 +462,8 @@ namespace MWMechanics
|
|||
// Try reflecting
|
||||
if (!reflected && magnitudeMult > 0 && !caster.isEmpty() && caster != target && !(magicEffect->mData.mFlags & ESM::MagicEffect::Unreflectable))
|
||||
{
|
||||
int reflect = target.getClass().getCreatureStats(target).getMagicEffects().get(ESM::MagicEffect::Reflect).getMagnitude();
|
||||
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99]
|
||||
float reflect = target.getClass().getCreatureStats(target).getMagicEffects().get(ESM::MagicEffect::Reflect).getMagnitude();
|
||||
int roll = static_cast<int>(std::rand() / (static_cast<double> (RAND_MAX)+1) * 100); // [0, 99]
|
||||
bool isReflected = (roll < reflect);
|
||||
if (isReflected)
|
||||
{
|
||||
|
@ -502,7 +502,7 @@ namespace MWMechanics
|
|||
ActiveSpells::ActiveEffect effect;
|
||||
effect.mEffectId = effectIt->mEffectID;
|
||||
effect.mArg = MWMechanics::EffectKey(*effectIt).mArg;
|
||||
effect.mDuration = effectIt->mDuration;
|
||||
effect.mDuration = static_cast<float>(effectIt->mDuration);
|
||||
effect.mMagnitude = magnitude;
|
||||
|
||||
targetEffects.add(MWMechanics::EffectKey(*effectIt), MWMechanics::EffectParam(effect.mMagnitude));
|
||||
|
@ -613,7 +613,7 @@ namespace MWMechanics
|
|||
{
|
||||
if (caster.getRefData().getHandle() == "player")
|
||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicLockSuccess}");
|
||||
target.getCellRef().setLockLevel(magnitude);
|
||||
target.getCellRef().setLockLevel(static_cast<int>(magnitude));
|
||||
}
|
||||
}
|
||||
else if (effectId == ESM::MagicEffect::Open)
|
||||
|
@ -721,10 +721,10 @@ namespace MWMechanics
|
|||
// Check if there's enough charge left
|
||||
if (enchantment->mData.mType == ESM::Enchantment::WhenUsed || enchantment->mData.mType == ESM::Enchantment::WhenStrikes)
|
||||
{
|
||||
const int castCost = getEffectiveEnchantmentCastCost(enchantment->mData.mCost, mCaster);
|
||||
const int castCost = getEffectiveEnchantmentCastCost(static_cast<float>(enchantment->mData.mCost), mCaster);
|
||||
|
||||
if (item.getCellRef().getEnchantmentCharge() == -1)
|
||||
item.getCellRef().setEnchantmentCharge(enchantment->mData.mCharge);
|
||||
item.getCellRef().setEnchantmentCharge(static_cast<float>(enchantment->mData.mCharge));
|
||||
|
||||
if (item.getCellRef().getEnchantmentCharge() < castCost)
|
||||
{
|
||||
|
@ -823,8 +823,8 @@ namespace MWMechanics
|
|||
bool fail = false;
|
||||
|
||||
// Check success
|
||||
int successChance = getSpellSuccessChance(spell, mCaster);
|
||||
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99]
|
||||
float successChance = getSpellSuccessChance(spell, mCaster);
|
||||
int roll = static_cast<int>(std::rand() / (static_cast<double> (RAND_MAX)+1) * 100); // [0, 99]
|
||||
if (!fail && roll >= successChance)
|
||||
{
|
||||
if (mCaster.getRefData().getHandle() == "player")
|
||||
|
@ -899,11 +899,11 @@ namespace MWMechanics
|
|||
const MWMechanics::CreatureStats& creatureStats = mCaster.getClass().getCreatureStats(mCaster);
|
||||
|
||||
float x = (npcStats.getSkill (ESM::Skill::Alchemy).getModified() +
|
||||
0.2 * creatureStats.getAttribute (ESM::Attribute::Intelligence).getModified()
|
||||
+ 0.1 * creatureStats.getAttribute (ESM::Attribute::Luck).getModified())
|
||||
0.2f * creatureStats.getAttribute (ESM::Attribute::Intelligence).getModified()
|
||||
+ 0.1f * creatureStats.getAttribute (ESM::Attribute::Luck).getModified())
|
||||
* creatureStats.getFatigueTerm();
|
||||
|
||||
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99]
|
||||
int roll = static_cast<int>(std::rand() / (static_cast<double> (RAND_MAX)+1) * 100); // [0, 99]
|
||||
if (roll > x)
|
||||
{
|
||||
// "X has no effect on you"
|
||||
|
@ -915,24 +915,24 @@ namespace MWMechanics
|
|||
|
||||
float magnitude = 0;
|
||||
float y = roll / std::min(x, 100.f);
|
||||
y *= 0.25 * x;
|
||||
y *= 0.25f * x;
|
||||
if (magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration)
|
||||
effect.mDuration = int(y);
|
||||
effect.mDuration = static_cast<int>(y);
|
||||
else
|
||||
effect.mDuration = 1;
|
||||
if (!(magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude))
|
||||
{
|
||||
if (!(magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration))
|
||||
magnitude = int((0.05 * y) / (0.1 * magicEffect->mData.mBaseCost));
|
||||
magnitude = floor((0.05f * y) / (0.1f * magicEffect->mData.mBaseCost));
|
||||
else
|
||||
magnitude = int(y / (0.1 * magicEffect->mData.mBaseCost));
|
||||
magnitude = floor(y / (0.1f * magicEffect->mData.mBaseCost));
|
||||
magnitude = std::max(1.f, magnitude);
|
||||
}
|
||||
else
|
||||
magnitude = 1;
|
||||
|
||||
effect.mMagnMax = magnitude;
|
||||
effect.mMagnMin = magnitude;
|
||||
effect.mMagnMax = static_cast<int>(magnitude);
|
||||
effect.mMagnMin = static_cast<int>(magnitude);
|
||||
|
||||
ESM::EffectList effects;
|
||||
effects.mList.push_back(effect);
|
||||
|
|
|
@ -15,10 +15,10 @@ void MWMechanics::AttributeValue::readState (const ESM::StatState<int>& state)
|
|||
mDamage = state.mDamage;
|
||||
}
|
||||
|
||||
void MWMechanics::AttributeValue::setModifiers(int fortify, int drain, int absorb)
|
||||
void MWMechanics::AttributeValue::setModifiers(float fortify, float drain, float absorb)
|
||||
{
|
||||
mFortified = fortify;
|
||||
mModifier = (fortify - drain) - absorb;
|
||||
mFortified = static_cast<int>(fortify);
|
||||
mModifier = mFortified - static_cast<int>(drain + absorb);
|
||||
}
|
||||
|
||||
void MWMechanics::SkillValue::writeState (ESM::StatState<int>& state) const
|
||||
|
|
|
@ -247,7 +247,7 @@ namespace MWMechanics
|
|||
int getModifier() const { return mModifier; }
|
||||
|
||||
void setBase(int base) { mBase = std::max(0, base); }
|
||||
void setModifiers(int fortify, int drain, int absorb);
|
||||
void setModifiers(float fortify, float drain, float absorb);
|
||||
|
||||
void damage(float damage) { mDamage = std::min(mDamage + damage, (float)(mBase + mFortified)); }
|
||||
void restore(float amount) { mDamage -= std::min(mDamage, amount); }
|
||||
|
|
|
@ -111,7 +111,7 @@ void Objects::insertModel(const MWWorld::Ptr &ptr, const std::string &mesh, bool
|
|||
sg->setOrigin(ptr.getRefData().getBaseNode()->getPosition());
|
||||
mStaticGeometrySmall[ptr.getCell()] = sg;
|
||||
|
||||
sg->setRenderingDistance(Settings::Manager::getInt("small object distance", "Viewing distance"));
|
||||
sg->setRenderingDistance(static_cast<Ogre::Real>(Settings::Manager::getInt("small object distance", "Viewing distance")));
|
||||
}
|
||||
else
|
||||
sg = mStaticGeometrySmall[ptr.getCell()];
|
||||
|
|
|
@ -630,7 +630,7 @@ void MWWorld::InventoryStore::updateRechargingItems()
|
|||
it->getClass().getEnchantment(*it));
|
||||
if (enchantment->mData.mType == ESM::Enchantment::WhenUsed
|
||||
|| enchantment->mData.mType == ESM::Enchantment::WhenStrikes)
|
||||
mRechargingItems.push_back(std::make_pair(it, enchantment->mData.mCharge));
|
||||
mRechargingItems.push_back(std::make_pair(it, static_cast<float>(enchantment->mData.mCharge)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue