mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-12 13:13:27 +00:00
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
@ -96,6 +96,9 @@ namespace MWBase
|
|||||||
/// Check if \a observer is potentially aware of \a ptr. Does not do a line of sight check!
|
/// 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;
|
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
|
enum OffenseType
|
||||||
{
|
{
|
||||||
OT_Theft, // Taking items owned by an NPC or a faction you are not a member of
|
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)
|
if (LOS)
|
||||||
{
|
{
|
||||||
creatureStats.getAiSequence().stack(AiCombat(MWBase::Environment::get().getWorld()->getPlayerPtr()), ptr);
|
MWBase::Environment::get().getMechanicsManager()->startCombat(ptr, player);
|
||||||
creatureStats.setHostile(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -784,15 +783,16 @@ namespace MWMechanics
|
|||||||
if (ptr.getClass().isClass(ptr, "Guard"))
|
if (ptr.getClass().isClass(ptr, "Guard"))
|
||||||
creatureStats.getAiSequence().stack(AiPursue(player.getClass().getId(player)), ptr);
|
creatureStats.getAiSequence().stack(AiPursue(player.getClass().getId(player)), ptr);
|
||||||
else
|
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?
|
// 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())
|
else if (creatureStats.getAttacked() && !creatureStats.isHostile())
|
||||||
{
|
{
|
||||||
creatureStats.getAiSequence().stack(AiCombat(player), ptr);
|
MWBase::Environment::get().getMechanicsManager()->startCombat(ptr, player);
|
||||||
creatureStats.setHostile(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1073,6 +1073,8 @@ namespace MWMechanics
|
|||||||
if(!stats.isDead() && stats.getAiSequence().getTypeId() == AiPackage::TypeIdCombat)
|
if(!stats.isDead() && stats.getAiSequence().getTypeId() == AiPackage::TypeIdCombat)
|
||||||
{
|
{
|
||||||
MWMechanics::AiCombat* package = static_cast<MWMechanics::AiCombat*>(stats.getAiSequence().getActivePackage());
|
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)
|
if(package->getTargetId() == actor.getCellRef().mRefID)
|
||||||
list.push_front(*iter);
|
list.push_front(*iter);
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwworld/player.hpp"
|
#include "../mwworld/player.hpp"
|
||||||
|
|
||||||
|
#include "../mwmechanics/aicombat.hpp"
|
||||||
|
|
||||||
#include <OgreSceneNode.h>
|
#include <OgreSceneNode.h>
|
||||||
|
|
||||||
#include "spellcasting.hpp"
|
#include "spellcasting.hpp"
|
||||||
@ -1007,6 +1009,14 @@ namespace MWMechanics
|
|||||||
return (roll >= target);
|
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)
|
void MechanicsManager::getObjectsInRange(const Ogre::Vector3 &position, float radius, std::vector<MWWorld::Ptr> &objects)
|
||||||
{
|
{
|
||||||
mActors.getObjectsInRange(position, radius, 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!
|
/// 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);
|
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,
|
* @brief Commit a crime. If any actors witness the crime and report it,
|
||||||
* reportCrime will be called automatically.
|
* reportCrime will be called automatically.
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#include "../mwmechanics/aifollow.hpp"
|
#include "../mwmechanics/aifollow.hpp"
|
||||||
#include "../mwmechanics/aitravel.hpp"
|
#include "../mwmechanics/aitravel.hpp"
|
||||||
#include "../mwmechanics/aiwander.hpp"
|
#include "../mwmechanics/aiwander.hpp"
|
||||||
#include "../mwmechanics/aicombat.hpp"
|
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
@ -435,12 +434,8 @@ namespace MWScript
|
|||||||
std::string targetID = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string targetID = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWMechanics::CreatureStats& creatureStats = actor.getClass().getCreatureStats(actor);
|
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getPtr(targetID, true);
|
||||||
|
MWBase::Environment::get().getMechanicsManager()->startCombat(actor, target);
|
||||||
|
|
||||||
creatureStats.setHostile(true);
|
|
||||||
creatureStats.getAiSequence().stack(
|
|
||||||
MWMechanics::AiCombat(MWBase::Environment::get().getWorld()->getPtr(targetID, true) ), actor);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user