mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Fix reported spellcasting discrepancies
Make ExplodeSpell behavior closer to Cast behavior (#5242) Nullify on-self absorb spells in a different way (#5241) Allow casting permanent spells through Cast/ExplodeSpell
This commit is contained in:
parent
7a4caaf5bf
commit
42cc27194b
@ -188,6 +188,8 @@
|
||||
Bug #5226: Reputation should be capped
|
||||
Bug #5229: Crash if mesh controller node has no data node
|
||||
Bug #5239: OpenMW-CS does not support non-ASCII characters in path names
|
||||
Bug #5241: On-self absorb spells cannot be detected
|
||||
Bug #5242: ExplodeSpell behavior differs from Cast behavior
|
||||
Feature #1774: Handle AvoidNode
|
||||
Feature #2229: Improve pathfinding AI
|
||||
Feature #3025: Analogue gamepad movement controls
|
||||
|
@ -447,9 +447,9 @@ namespace MWMechanics
|
||||
if (!checkEffectTarget(effectIt->mEffectID, target, caster, castByPlayer))
|
||||
continue;
|
||||
|
||||
// caster needs to be an actor that's not the target for linked effects (e.g. Absorb)
|
||||
// caster needs to be an actor for linked effects (e.g. Absorb)
|
||||
if (magicEffect->mData.mFlags & ESM::MagicEffect::CasterLinked
|
||||
&& (caster.isEmpty() || !caster.getClass().isActor() || caster == target))
|
||||
&& (caster.isEmpty() || !caster.getClass().isActor()))
|
||||
continue;
|
||||
|
||||
// If player is healing someone, show the target's HP bar
|
||||
@ -552,6 +552,20 @@ namespace MWMechanics
|
||||
effect.mArg = MWMechanics::EffectKey(*effectIt).mArg;
|
||||
effect.mMagnitude = magnitude;
|
||||
|
||||
// Avoid applying absorb effects if the caster is the target
|
||||
// We still need the spell to be added
|
||||
if (caster == target)
|
||||
{
|
||||
for (int i=0; i<5; ++i)
|
||||
{
|
||||
if (effectIt->mEffectID == ESM::MagicEffect::AbsorbAttribute+i)
|
||||
{
|
||||
effect.mMagnitude = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool hasDuration = !(magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration);
|
||||
if (hasDuration && effectIt->mDuration == 0)
|
||||
{
|
||||
@ -614,6 +628,7 @@ namespace MWMechanics
|
||||
else
|
||||
caster.getClass().getCreatureStats(caster).getActiveSpells().addSpell("", true,
|
||||
absorbEffects, mSourceName, target.getClass().getCreatureStats(target).getActorId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1109,12 +1109,6 @@ namespace MWScript
|
||||
return;
|
||||
}
|
||||
|
||||
if (spell->mData.mType != ESM::Spell::ST_Spell && spell->mData.mType != ESM::Spell::ST_Power)
|
||||
{
|
||||
runtime.getContext().report("spellcasting failed: you can only cast spells and powers.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ptr == MWMechanics::getPlayer())
|
||||
{
|
||||
MWWorld::InventoryStore& store = ptr.getClass().getInventoryStore(ptr);
|
||||
@ -1152,9 +1146,32 @@ namespace MWScript
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
std::string spell = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
std::string spellId = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(spellId);
|
||||
if (!spell)
|
||||
{
|
||||
runtime.getContext().report("spellcasting failed: cannot find spell \""+spellId+"\"");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ptr == MWMechanics::getPlayer())
|
||||
{
|
||||
MWWorld::InventoryStore& store = ptr.getClass().getInventoryStore(ptr);
|
||||
store.setSelectedEnchantItem(store.end());
|
||||
MWBase::Environment::get().getWindowManager()->setSelectedSpell(spellId, int(MWMechanics::getSpellSuccessChance(spellId, ptr)));
|
||||
MWBase::Environment::get().getWindowManager()->updateSpellWindow();
|
||||
return;
|
||||
}
|
||||
|
||||
if (ptr.getClass().isActor())
|
||||
{
|
||||
MWMechanics::AiCast castPackage(ptr.getCellRef().getRefId(), spellId, true);
|
||||
ptr.getClass().getCreatureStats (ptr).getAiSequence().stack(castPackage, ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
MWMechanics::CastSpell cast(ptr, ptr, false, true);
|
||||
cast.mHitPosition = ptr.getRefData().getPosition().asVec3();
|
||||
cast.mAlwaysSucceed = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user