From 6e3fdc58164fb37b475a1e4bf61790bbc453cb4a Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 28 Jul 2010 19:38:14 +0200 Subject: [PATCH] added special case implementation for GetHealth (max weapon and armor health) --- apps/openmw/mwscript/statsextensions.cpp | 53 ++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) 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();