Don't interrupt compilation when spell/effect functions are used for non-actors

pull/541/head
Capostrophic 6 years ago
parent d1e0a10136
commit 92d7f21926

@ -14,6 +14,7 @@
Bug #4746: Non-solid player can't run or sneak
Bug #4750: Sneaking doesn't work in first person view if the player is in attack ready state
Bug #4768: Fallback numerical value recovery chokes on invalid arguments
Bug #4778: Interiors of Illusion puzzle in Sotha Sil Expanded mod is broken
Feature #2229: Improve pathfinding AI
Feature #3442: Default values for fallbacks from ini file
Feature #3610: Option to invert X axis

@ -431,6 +431,12 @@ namespace MWScript
std::string effect = runtime.getStringLiteral(runtime[0].mInteger);
runtime.pop();
if (!ptr.getClass().isActor())
{
runtime.push(0);
return;
}
char *end;
long key = strtol(effect.c_str(), &end, 10);
if(key < 0 || key > 32767 || *end != '\0')
@ -659,6 +665,12 @@ namespace MWScript
std::string id = runtime.getStringLiteral(runtime[0].mInteger);
runtime.pop();
if (!ptr.getClass().isActor())
{
runtime.push(0);
return;
}
const MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr);
runtime.push(stats.getActiveSpells().isSpellActive(id) || stats.getSpells().isSpellActive(id));
}

@ -536,7 +536,7 @@ namespace MWScript
Interpreter::Type_Integer value = 0;
if (ptr.getClass().getCreatureStats(ptr).getSpells().hasSpell(id))
if (ptr.getClass().isActor() && ptr.getClass().getCreatureStats(ptr).getSpells().hasSpell(id))
value = 1;
runtime.push (value);

Loading…
Cancel
Save