mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 13:53:53 +00:00
AI now continue to hit you.
TODO: change the way time is handled
This commit is contained in:
parent
2537384c50
commit
83a375b55d
2 changed files with 15 additions and 3 deletions
|
@ -14,7 +14,7 @@ namespace MWMechanics
|
|||
{
|
||||
|
||||
AiCombat::AiCombat(const std::string &targetId)
|
||||
:mTargetId(targetId)
|
||||
:mTargetId(targetId),mStartingSecond(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ namespace MWMechanics
|
|||
MWMechanics::DrawState_ state = MWWorld::Class::get(actor).getNpcStats(actor).getDrawState();
|
||||
if (state == MWMechanics::DrawState_Spell || state == MWMechanics::DrawState_Nothing)
|
||||
MWWorld::Class::get(actor).getNpcStats(actor).setDrawState(MWMechanics::DrawState_Weapon);
|
||||
MWWorld::Class::get(actor).getCreatureStats(actor).setAttackingOrSpell(true);
|
||||
//MWWorld::Class::get(actor).getCreatureStats(actor).setAttackingOrSpell(true);
|
||||
|
||||
ESM::Position pos = actor.getRefData().getPosition();
|
||||
const ESM::Pathgrid *pathgrid =
|
||||
|
@ -59,7 +59,7 @@ namespace MWMechanics
|
|||
|
||||
mPathFinder.buildPath(start, dest, pathgrid, xCell, yCell, true);
|
||||
|
||||
mPathFinder.checkPathCompleted(pos.pos[0],pos.pos[1],pos.pos[2])
|
||||
mPathFinder.checkPathCompleted(pos.pos[0],pos.pos[1],pos.pos[2]);
|
||||
|
||||
float zAngle = mPathFinder.getZAngleToNext(pos.pos[0], pos.pos[1]);
|
||||
std::cout << zAngle;
|
||||
|
@ -71,6 +71,17 @@ namespace MWMechanics
|
|||
if((dest.mX - start.mX)*(dest.mX - start.mX)+(dest.mY - start.mY)*(dest.mY - start.mY)+(dest.mZ - start.mZ)*(dest.mZ - start.mZ)
|
||||
< range*range)
|
||||
{
|
||||
MWWorld::TimeStamp time = MWBase::Environment::get().getWorld()->getTimeStamp();
|
||||
if(mStartingSecond == 0)
|
||||
{
|
||||
MWWorld::Class::get(actor).getCreatureStats(actor).setAttackingOrSpell(false);
|
||||
mStartingSecond = ((time.getHour() - int(time.getHour())) * 100);
|
||||
}
|
||||
else if( ((time.getHour() - int(time.getHour())) * 100) - mStartingSecond > 1)
|
||||
{
|
||||
MWWorld::Class::get(actor).getCreatureStats(actor).setAttackingOrSpell(true);
|
||||
mStartingSecond = 0;
|
||||
}
|
||||
MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 0;
|
||||
//MWWorld::Class::get(actor).getCreatureStats(actor).setAttackingOrSpell(!MWWorld::Class::get(actor).getCreatureStats(actor).getAttackingOrSpell());
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ namespace MWMechanics
|
|||
std::string mTargetId;
|
||||
|
||||
PathFinder mPathFinder;
|
||||
unsigned int mStartingSecond;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue