Skip to content

Commit 2f2e3a8

Browse files
committed
fight algo-update
1 parent 4b2094b commit 2f2e3a8

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

game/game/fightalgo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void FightAlgo::fillQueue(Npc &npc, Npc &tg, GameScript& owner) {
3737

3838
const bool focus = isInFocusAngle(npc,tg);
3939

40-
if(tg.isPrehit() && isInWRange(tg,npc,owner) && isInFocusAngle(tg,npc)){
40+
if(tg.isPrehit() && isInWRange(tg,npc,owner) && isInFocusAngle(tg,npc) && focus){
4141
if(tg.bodyStateMasked()==BS_RUN)
4242
if(fillQueue(owner,ai.enemy_stormprehit))
4343
return;

game/world/objects/npc.cpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,11 @@ bool Npc::implAttack(uint64_t dt) {
14981498
FightAlgo::Action act = fghAlgo.nextFromQueue(*this,*currentTarget,owner.script());
14991499

15001500
if(act==FightAlgo::MV_BLOCK) {
1501+
if(!fghAlgo.isInFocusAngle(*this, *currentTarget)) {
1502+
fghAlgo.consumeAction();
1503+
return true;
1504+
}
1505+
15011506
switch(ws) {
15021507
case WeaponState::Fist: {
15031508
if(blockFist())
@@ -1623,6 +1628,20 @@ bool Npc::implAttack(uint64_t dt) {
16231628
}
16241629

16251630
if(act==FightAlgo::MV_JUMPBACK) {
1631+
if(isSwim()) {
1632+
fghAlgo.consumeAction();
1633+
return true;
1634+
}
1635+
if(bodyStateMasked()==BS_PARADE) {
1636+
fghAlgo.consumeAction();
1637+
return true;
1638+
}
1639+
if(!fghAlgo.isInFocusAngle(*this, *currentTarget)) {
1640+
//NOTE: jump-back is ultimate defence, so better to use it only if npc face player directly
1641+
fghAlgo.consumeAction();
1642+
aiState.loopNextTime = owner.tickCount(); // force ZS_MM_Attack_Loop call
1643+
return true;
1644+
}
16261645
if(setAnim(Npc::Anim::MoveBack)) {
16271646
implFaiWait(visual.pose().animationTotalTime());
16281647
fghAlgo.consumeAction();
@@ -1834,10 +1853,11 @@ void Npc::takeDamage(Npc &other, const Bullet* b) {
18341853
return;
18351854

18361855
assert(b==nullptr || !b->isSpell());
1837-
const bool isJumpb = visual.pose().isJumpBack();
1838-
const bool isBlock = (!other.isMonster() || other.inventory().activeWeapon()!=nullptr) &&
1839-
fghAlgo.isInFocusAngle(*this,other) &&
1840-
visual.pose().isDefence(owner.tickCount());
1856+
const auto& pose = visual.pose();
1857+
const bool isJumpb = pose.isJumpBack() && !pose.isDefence(owner.tickCount());
1858+
const bool isBlock = (!other.isMonster() || other.inventory().activeWeapon()!=nullptr) &&
1859+
fghAlgo.isInFocusAngle(*this,other) &&
1860+
pose.isDefence(owner.tickCount());
18411861

18421862
lastHit = &other;
18431863
if(!isPlayer())

0 commit comments

Comments
 (0)