mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-23 11:41:33 +00:00
Feature #1154 Not all NPCs get aggressive when one is attacked
Partially implemented
This commit is contained in:
parent
6b28c06b2c
commit
6c866deb1b
3 changed files with 48 additions and 27 deletions
|
@ -111,7 +111,7 @@ namespace MWBase
|
||||||
* @param arg Depends on \a type, e.g. for Theft, the value of the item that was stolen.
|
* @param arg Depends on \a type, e.g. for Theft, the value of the item that was stolen.
|
||||||
* @return was the crime reported?
|
* @return was the crime reported?
|
||||||
*/
|
*/
|
||||||
virtual bool commitCrime (const MWWorld::Ptr& ptr, const MWWorld::Ptr& victim,
|
virtual bool commitCrime (const MWWorld::Ptr& offender, const MWWorld::Ptr& victim,
|
||||||
OffenseType type, int arg=0) = 0;
|
OffenseType type, int arg=0) = 0;
|
||||||
virtual void reportCrime (const MWWorld::Ptr& ptr, const MWWorld::Ptr& victim,
|
virtual void reportCrime (const MWWorld::Ptr& ptr, const MWWorld::Ptr& victim,
|
||||||
OffenseType type, int arg=0) = 0;
|
OffenseType type, int arg=0) = 0;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "../mwworld/esmstore.hpp"
|
#include "../mwworld/esmstore.hpp"
|
||||||
#include "../mwworld/inventorystore.hpp"
|
#include "../mwworld/inventorystore.hpp"
|
||||||
|
#include "../mwworld/cellstore.hpp"
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
@ -12,6 +13,8 @@
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwworld/player.hpp"
|
#include "../mwworld/player.hpp"
|
||||||
|
|
||||||
|
#include "aicombat.hpp"
|
||||||
|
|
||||||
#include <OgreSceneNode.h>
|
#include <OgreSceneNode.h>
|
||||||
|
|
||||||
#include "spellcasting.hpp"
|
#include "spellcasting.hpp"
|
||||||
|
@ -799,36 +802,54 @@ namespace MWMechanics
|
||||||
commitCrime(ptr, victim, OT_Theft, item.getClass().getValue(item) * count);
|
commitCrime(ptr, victim, OT_Theft, item.getClass().getValue(item) * count);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MechanicsManager::commitCrime(const MWWorld::Ptr &ptr, const MWWorld::Ptr &victim, OffenseType type, int arg)
|
bool MechanicsManager::commitCrime(const MWWorld::Ptr& offender, const MWWorld::Ptr& victim, OffenseType type, int arg)
|
||||||
{
|
{
|
||||||
if (ptr.getRefData().getHandle() != "player")
|
if (offender.getRefData().getHandle() != "player")
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
MWWorld::Ptr ptr;
|
||||||
|
|
||||||
bool reported=false;
|
bool reported=false;
|
||||||
for (Actors::PtrControllerMap::const_iterator it = mActors.begin(); it != mActors.end(); ++it)
|
MWWorld::CellStore* cell = victim.getCell();
|
||||||
{
|
|
||||||
if (it->first != ptr &&
|
// TODO: implement and check the distance of actors to victim using fAlarmRadius
|
||||||
MWBase::Environment::get().getWorld()->getLOS(ptr, it->first) &&
|
// get all NPCs in victims cell
|
||||||
awarenessCheck(ptr, it->first))
|
for (MWWorld::CellRefList<ESM::NPC>::List::iterator it (cell->get<ESM::NPC>().mList.begin()); it != cell->get<ESM::NPC>().mList.end(); ++it)
|
||||||
{
|
|
||||||
// NPCs will always curse you when they notice you steal their items, even if they don't report the crime
|
|
||||||
if (it->first == victim && type == OT_Theft)
|
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr ptr (&*it, cell);
|
||||||
|
|
||||||
|
// offender can't be ally to themselves
|
||||||
|
if (ptr == offender)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
CreatureStats& creatureStats = MWWorld::Class::get(ptr).getCreatureStats(ptr);
|
||||||
|
|
||||||
|
// curse at the thief
|
||||||
|
if (ptr == victim && type == OT_Theft)
|
||||||
MWBase::Environment::get().getDialogueManager()->say(victim, "Thief");
|
MWBase::Environment::get().getDialogueManager()->say(victim, "Thief");
|
||||||
}
|
|
||||||
|
|
||||||
|
// TODO: Make guards persue unless other factors, such as bounty stops them
|
||||||
|
// If the actor is a guard
|
||||||
|
|
||||||
|
// TODO: An actor reacts differently based on different values of AI_Alarm.
|
||||||
// Actor has witnessed a crime. Will he report it?
|
// Actor has witnessed a crime. Will he report it?
|
||||||
// (not sure, is > 0 correct?)
|
if (creatureStats.getAiSetting(CreatureStats::AI_Alarm).getModified() > 0)
|
||||||
if (it->first.getClass().getCreatureStats(it->first).getAiSetting(CreatureStats::AI_Alarm).getModified() > 0)
|
|
||||||
{
|
{
|
||||||
// TODO: stats.setAlarmed(true) on NPCs within earshot
|
creatureStats.setAlarmed(true);
|
||||||
// fAlarmRadius ?
|
|
||||||
reported=true;
|
reported=true;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// TODO: An actor reacts differently based on different values of AI_Fight and AI_Flee.
|
||||||
|
// Actor has reported the crime, will the actor fight the offender?
|
||||||
|
if (creatureStats.getAiSetting(CreatureStats::AI_Fight).getModified > 0)
|
||||||
|
{
|
||||||
|
creatureStats.getAiSequence().stack(AiCombat(offender));
|
||||||
|
creatureStats.setHostile(true);
|
||||||
|
creatureStats.getAiSequence().execute(ptr, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (reported)
|
if (reported)
|
||||||
reportCrime(ptr, victim, type, arg);
|
reportCrime(ptr, victim, type, arg);
|
||||||
return reported;
|
return reported;
|
||||||
|
|
|
@ -111,7 +111,7 @@ namespace MWMechanics
|
||||||
* @param arg Depends on \a type, e.g. for Theft, the value of the item that was stolen.
|
* @param arg Depends on \a type, e.g. for Theft, the value of the item that was stolen.
|
||||||
* @return was the crime reported?
|
* @return was the crime reported?
|
||||||
*/
|
*/
|
||||||
virtual bool commitCrime (const MWWorld::Ptr& ptr, const MWWorld::Ptr& victim,
|
virtual bool commitCrime (const MWWorld::Ptr& offender, const MWWorld::Ptr& victim,
|
||||||
OffenseType type, int arg=0);
|
OffenseType type, int arg=0);
|
||||||
virtual void reportCrime (const MWWorld::Ptr& ptr, const MWWorld::Ptr& victim,
|
virtual void reportCrime (const MWWorld::Ptr& ptr, const MWWorld::Ptr& victim,
|
||||||
OffenseType type, int arg=0);
|
OffenseType type, int arg=0);
|
||||||
|
|
Loading…
Reference in a new issue