forked from mirror/openmw-tes3mp
Say an attack phrase when combat starts
Move combat start to a helper method Added some todo comments
This commit is contained in:
parent
d4492b56db
commit
dd9117809d
5 changed files with 26 additions and 13 deletions
|
@ -96,6 +96,9 @@ namespace MWBase
|
|||
/// Check if \a observer is potentially aware of \a ptr. Does not do a line of sight check!
|
||||
virtual bool awarenessCheck (const MWWorld::Ptr& ptr, const MWWorld::Ptr& observer) = 0;
|
||||
|
||||
/// Makes \a ptr fight \a target. Also shouts a combat taunt.
|
||||
virtual void startCombat (const MWWorld::Ptr& ptr, const MWWorld::Ptr& target) = 0;
|
||||
|
||||
enum OffenseType
|
||||
{
|
||||
OT_Theft, // Taking items owned by an NPC or a faction you are not a member of
|
||||
|
|
|
@ -206,8 +206,7 @@ namespace MWMechanics
|
|||
|
||||
if (LOS)
|
||||
{
|
||||
creatureStats.getAiSequence().stack(AiCombat(MWBase::Environment::get().getWorld()->getPlayerPtr()), ptr);
|
||||
creatureStats.setHostile(true);
|
||||
MWBase::Environment::get().getMechanicsManager()->startCombat(ptr, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -784,15 +783,16 @@ namespace MWMechanics
|
|||
if (ptr.getClass().isClass(ptr, "Guard"))
|
||||
creatureStats.getAiSequence().stack(AiPursue(player.getClass().getId(player)), ptr);
|
||||
else
|
||||
creatureStats.getAiSequence().stack(AiCombat(player), ptr);
|
||||
creatureStats.setHostile(true);
|
||||
{
|
||||
MWBase::Environment::get().getMechanicsManager()->startCombat(ptr, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if I didn't report a crime was I attacked?
|
||||
// TODO: this is incorrect, getAttacked also triggers if attacked by other non-player actors.
|
||||
else if (creatureStats.getAttacked() && !creatureStats.isHostile())
|
||||
{
|
||||
creatureStats.getAiSequence().stack(AiCombat(player), ptr);
|
||||
creatureStats.setHostile(true);
|
||||
MWBase::Environment::get().getMechanicsManager()->startCombat(ptr, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1073,6 +1073,8 @@ namespace MWMechanics
|
|||
if(!stats.isDead() && stats.getAiSequence().getTypeId() == AiPackage::TypeIdCombat)
|
||||
{
|
||||
MWMechanics::AiCombat* package = static_cast<MWMechanics::AiCombat*>(stats.getAiSequence().getActivePackage());
|
||||
// TODO: This is wrong! It's comparing Ref IDs with Ogre handles. The only case where this (coincidentally) works is the player.
|
||||
// possibly applies to other code using getTargetId.
|
||||
if(package->getTargetId() == actor.getCellRef().mRefID)
|
||||
list.push_front(*iter);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
|
||||
#include "../mwmechanics/aicombat.hpp"
|
||||
|
||||
#include <OgreSceneNode.h>
|
||||
|
||||
#include "spellcasting.hpp"
|
||||
|
@ -1007,6 +1009,14 @@ namespace MWMechanics
|
|||
return (roll >= target);
|
||||
}
|
||||
|
||||
void MechanicsManager::startCombat(const MWWorld::Ptr &ptr, const MWWorld::Ptr &target)
|
||||
{
|
||||
MWBase::Environment::get().getDialogueManager()->say(ptr, "attack");
|
||||
ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(MWMechanics::AiCombat(target), ptr);
|
||||
if (target == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||
ptr.getClass().getCreatureStats(ptr).setHostile(true);
|
||||
}
|
||||
|
||||
void MechanicsManager::getObjectsInRange(const Ogre::Vector3 &position, float radius, std::vector<MWWorld::Ptr> &objects)
|
||||
{
|
||||
mActors.getObjectsInRange(position, radius, objects);
|
||||
|
|
|
@ -105,6 +105,9 @@ namespace MWMechanics
|
|||
/// Check if \a observer is potentially aware of \a ptr. Does not do a line of sight check!
|
||||
virtual bool awarenessCheck (const MWWorld::Ptr& ptr, const MWWorld::Ptr& observer);
|
||||
|
||||
/// Makes \a ptr fight \a target. Also shouts a combat taunt.
|
||||
virtual void startCombat (const MWWorld::Ptr& ptr, const MWWorld::Ptr& target);
|
||||
|
||||
/**
|
||||
* @brief Commit a crime. If any actors witness the crime and report it,
|
||||
* reportCrime will be called automatically.
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "../mwmechanics/aifollow.hpp"
|
||||
#include "../mwmechanics/aitravel.hpp"
|
||||
#include "../mwmechanics/aiwander.hpp"
|
||||
#include "../mwmechanics/aicombat.hpp"
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
@ -435,12 +434,8 @@ namespace MWScript
|
|||
std::string targetID = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWMechanics::CreatureStats& creatureStats = actor.getClass().getCreatureStats(actor);
|
||||
|
||||
|
||||
creatureStats.setHostile(true);
|
||||
creatureStats.getAiSequence().stack(
|
||||
MWMechanics::AiCombat(MWBase::Environment::get().getWorld()->getPtr(targetID, true) ), actor);
|
||||
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getPtr(targetID, true);
|
||||
MWBase::Environment::get().getMechanicsManager()->startCombat(actor, target);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue