diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 53ff1b1b3..727c48c71 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -170,9 +170,29 @@ namespace MWScript if (mIndex==0) { - // TODO health is a special case - - + // health is a special case + if (context.getReference().getType()== + typeid (ESMS::LiveCellRef *)) + { + ESMS::LiveCellRef *ref = + context.getReference().get(); + + Interpreter::Type_Integer value = ref->base->data.health; + runtime.push (value); + + return; + } + else if (context.getReference().getType()== + typeid (ESMS::LiveCellRef *)) + { + ESMS::LiveCellRef *ref = + context.getReference().get(); + + Interpreter::Type_Integer value = ref->base->data.health; + runtime.push (value); + + return; + } } Interpreter::Type_Integer value = @@ -199,6 +219,33 @@ namespace MWScript std::string id = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); + if (mIndex==0) + { + // health is a special case + if (context.getWorld().getPtr (id, false).getType()== + typeid (ESMS::LiveCellRef *)) + { + ESMS::LiveCellRef *ref = + context.getWorld().getPtr (id, false).get(); + + Interpreter::Type_Integer value = ref->base->data.health; + runtime.push (value); + + return; + } + else if (context.getWorld().getPtr (id, false).getType()== + typeid (ESMS::LiveCellRef *)) + { + ESMS::LiveCellRef *ref = + context.getWorld().getPtr (id, false).get(); + + Interpreter::Type_Integer value = ref->base->data.health; + runtime.push (value); + + return; + } + } + Interpreter::Type_Integer value = context.getWorld().getPtr (id, false).getCreatureStats().mDynamic[mIndex]. getCurrent();