From df4df5b0946708a5e8d98de8bac7c998a964e1fd Mon Sep 17 00:00:00 2001 From: mrcheko Date: Fri, 17 Jan 2014 23:30:28 +0200 Subject: [PATCH] fixed weapRange for creatures/startcombat script(?) --- apps/openmw/mwmechanics/aicombat.cpp | 6 ++++++ apps/openmw/mwscript/aiextensions.cpp | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwmechanics/aicombat.cpp b/apps/openmw/mwmechanics/aicombat.cpp index 9a78e44ffd..6bf97f6ace 100644 --- a/apps/openmw/mwmechanics/aicombat.cpp +++ b/apps/openmw/mwmechanics/aicombat.cpp @@ -151,6 +151,11 @@ namespace MWMechanics } weapRange *= 100.0f; } + else //is creature + { + weaptype = WeapType_HandToHand; //doesn't matter, should only reflect if it is melee or distant weapon + weapRange = 100; //TODO: use true attack range (the same problem in Creature::hit) + } //MWWorld::Class::get(actor).getCreatureStats(actor).setAttackingOrSpell(false); @@ -381,6 +386,7 @@ void chooseBestAttack(const ESM::Weapon* weapon, MWMechanics::Movement &movement if (weapon == NULL) { + //hand-to-hand and creatures' attacks handled here //hand-to-hand deals equal damage float roll = static_cast(rand())/RAND_MAX; if(roll <= 0.333f) //side punch diff --git a/apps/openmw/mwscript/aiextensions.cpp b/apps/openmw/mwscript/aiextensions.cpp index d09a72acc2..53b757d76f 100644 --- a/apps/openmw/mwscript/aiextensions.cpp +++ b/apps/openmw/mwscript/aiextensions.cpp @@ -435,10 +435,14 @@ namespace MWScript std::string actorID = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get(actor).getCreatureStats(actor); - creatureStats.getAiSequence().stack(MWMechanics::AiCombat(actor)); + MWMechanics::CreatureStats& creatureStats = actor.getClass().getCreatureStats(actor); + if (actorID == "player") + { creatureStats.setHostile(true); + creatureStats.getAiSequence().stack( + MWMechanics::AiCombat(MWBase::Environment::get().getWorld()->getPtr(actorID,true))); + } } };