mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-14 01:19:59 +00:00
Merge branch 'suijutsu' into 'master'
Underwater projectile fixes (#7622, #8303) Closes #7622 and #8303 See merge request OpenMW/openmw!4567
This commit is contained in:
commit
4211c833f9
@ -274,8 +274,8 @@ namespace MWWorld
|
||||
pos.z() += mPhysics->getRenderingHalfExtents(caster).z() * 2 * Constants::TorsoHeight;
|
||||
}
|
||||
|
||||
if (MWBase::Environment::get().getWorld()->isUnderwater(
|
||||
caster.getCell(), pos)) // Underwater casting not possible
|
||||
// Actors can't cast target spells underwater
|
||||
if (caster.getClass().isActor() && MWBase::Environment::get().getWorld()->isUnderwater(caster.getCell(), pos))
|
||||
return;
|
||||
|
||||
osg::Quat orient;
|
||||
@ -564,15 +564,19 @@ namespace MWWorld
|
||||
for (const auto& sound : magicBoltState.mSounds)
|
||||
sound->setPosition(pos);
|
||||
|
||||
if (projectile->isActive())
|
||||
const Ptr caster = magicBoltState.getCaster();
|
||||
|
||||
const MWBase::World& world = *MWBase::Environment::get().getWorld();
|
||||
const bool active = projectile->isActive();
|
||||
if (active && !world.isUnderwater(caster.getCell(), pos))
|
||||
continue;
|
||||
|
||||
const auto target = projectile->getTarget();
|
||||
const auto caster = magicBoltState.getCaster();
|
||||
const Ptr target = !active ? projectile->getTarget() : Ptr();
|
||||
|
||||
assert(target != caster);
|
||||
|
||||
MWMechanics::CastSpell cast(caster, target);
|
||||
cast.mHitPosition = Misc::Convert::toOsg(projectile->getHitPosition());
|
||||
cast.mHitPosition = !active ? Misc::Convert::toOsg(projectile->getHitPosition()) : pos;
|
||||
cast.mId = magicBoltState.mSpellId;
|
||||
cast.mSourceName = magicBoltState.mSourceName;
|
||||
cast.mItem = magicBoltState.mItem;
|
||||
|
@ -3047,28 +3047,31 @@ namespace MWWorld
|
||||
// TODO: as a better solutuon we should handle projectiles during physics update, not during world update.
|
||||
const osg::Vec3f sourcePos = worldPos + orient * osg::Vec3f(0, -1, 0) * 64.f;
|
||||
|
||||
// Early out if the launch position is underwater
|
||||
bool underwater = isUnderwater(MWMechanics::getPlayer().getCell(), worldPos);
|
||||
if (underwater)
|
||||
{
|
||||
MWMechanics::projectileHit(actor, Ptr(), bow, projectile, worldPos, attackStrength);
|
||||
mRendering->emitWaterRipple(worldPos);
|
||||
return;
|
||||
}
|
||||
|
||||
// For AI actors, get combat targets to use in the ray cast. Only those targets will return a positive hit
|
||||
// result.
|
||||
std::vector<MWWorld::Ptr> targetActors;
|
||||
if (!actor.isEmpty() && actor.getClass().isActor() && actor != MWMechanics::getPlayer())
|
||||
actor.getClass().getCreatureStats(actor).getAiSequence().getCombatTargets(targetActors);
|
||||
|
||||
// Check for impact, if yes, handle hit, if not, launch projectile
|
||||
// Check for impact, if yes, handle hit
|
||||
MWPhysics::RayCastingResult result = mPhysics->castRay(
|
||||
sourcePos, worldPos, { actor }, targetActors, 0xff, MWPhysics::CollisionType_Projectile);
|
||||
|
||||
if (result.mHit)
|
||||
{
|
||||
MWMechanics::projectileHit(actor, result.mHitObject, bow, projectile, result.mHitPos, attackStrength);
|
||||
else
|
||||
mProjectileManager->launchProjectile(actor, projectile, worldPos, orient, bow, speed, attackStrength);
|
||||
return;
|
||||
}
|
||||
|
||||
// Bail out if the launch position is underwater
|
||||
if (isUnderwater(MWMechanics::getPlayer().getCell(), worldPos))
|
||||
{
|
||||
MWMechanics::projectileHit(actor, Ptr(), bow, projectile, worldPos, attackStrength);
|
||||
mRendering->emitWaterRipple(worldPos);
|
||||
return;
|
||||
}
|
||||
|
||||
mProjectileManager->launchProjectile(actor, projectile, worldPos, orient, bow, speed, attackStrength);
|
||||
}
|
||||
|
||||
void World::launchMagicBolt(
|
||||
|
Loading…
x
Reference in New Issue
Block a user