From b5b9f177999a4be67c7c74d6e95a38fbc4ab367c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 29 Jul 2010 01:38:14 +0800 Subject: [PATCH] added special case implementation for GetHealth (max weapon and armor health) --- apps/openmw/mwscript/statsextensions.cpp | 49 +++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 53ff1b1b31..727c48c71d 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();