mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 21:40:05 +00:00
Attack logic and various balance changes
- combatStep was altered, the mob can attack and give chase at the same time. Kiting melee mobs around is much harder. - Mobs in general are more harder, closer to how it was in retro. - Nanos styles are less detrimental to battle.
This commit is contained in:
parent
8d1bc94b7e
commit
4fc5c092f8
@ -556,29 +556,17 @@ void MobManager::combatStep(Mob *mob, time_t currTime) {
|
|||||||
if (mob->target == nullptr)
|
if (mob->target == nullptr)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* If the mob is close enough to attack, do so. If not, get closer.
|
int distanceToTravel = 20000;
|
||||||
* No, I'm not 100% sure this is how it's supposed to work.
|
int speed = mob->data["m_iRunSpeed"];
|
||||||
*/
|
// movement logic: move when out of range but don't move while casting a skill
|
||||||
if (distance <= mobRange) {
|
if (distance > mobRange && mob->skillStyle == -1) {
|
||||||
// attack logic
|
|
||||||
if (mob->nextAttack == 0) {
|
|
||||||
mob->nextAttack = currTime + (int)mob->data["m_iInitalTime"] * 100; //I *think* this is what this is
|
|
||||||
npcAttackPc(mob, currTime);
|
|
||||||
} else if (mob->nextAttack != 0 && currTime >= mob->nextAttack) {
|
|
||||||
mob->nextAttack = currTime + (int)mob->data["m_iDelayTime"] * 100;
|
|
||||||
npcAttackPc(mob, currTime);
|
|
||||||
}
|
|
||||||
} else if (mob->skillStyle == -1) { // don't move while casting a skill
|
|
||||||
// movement logic
|
|
||||||
if (mob->nextMovement != 0 && currTime < mob->nextMovement)
|
if (mob->nextMovement != 0 && currTime < mob->nextMovement)
|
||||||
return;
|
return;
|
||||||
mob->nextMovement = currTime + 400;
|
mob->nextMovement = currTime + 400;
|
||||||
if (currTime >= mob->nextAttack)
|
if (currTime >= mob->nextAttack)
|
||||||
mob->nextAttack = 0;
|
mob->nextAttack = 0;
|
||||||
|
|
||||||
int speed = mob->data["m_iRunSpeed"];
|
|
||||||
|
|
||||||
// halve movement speed if snared
|
// halve movement speed if snared
|
||||||
if (mob->appearanceData.iConditionBitFlag & CSB_BIT_DN_MOVE_SPEED)
|
if (mob->appearanceData.iConditionBitFlag & CSB_BIT_DN_MOVE_SPEED)
|
||||||
speed /= 2;
|
speed /= 2;
|
||||||
@ -590,7 +578,10 @@ void MobManager::combatStep(Mob *mob, time_t currTime) {
|
|||||||
targetY += mob->offsetY*distance/(mob->idleRange + 1);
|
targetY += mob->offsetY*distance/(mob->idleRange + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto targ = lerp(mob->appearanceData.iX, mob->appearanceData.iY, targetX, targetY, std::min(distance-mobRange+1, speed*2/5));
|
distanceToTravel = std::min(distance-mobRange+1, speed*2/5);
|
||||||
|
auto targ = lerp(mob->appearanceData.iX, mob->appearanceData.iY, targetX, targetY, distanceToTravel);
|
||||||
|
if (distanceToTravel < speed*2/5 && currTime >= mob->nextAttack)
|
||||||
|
mob->nextAttack = 0;
|
||||||
|
|
||||||
NPCManager::updateNPCPosition(mob->appearanceData.iNPC_ID, targ.first, targ.second, mob->appearanceData.iZ, mob->instanceID, mob->appearanceData.iAngle);
|
NPCManager::updateNPCPosition(mob->appearanceData.iNPC_ID, targ.first, targ.second, mob->appearanceData.iZ, mob->instanceID, mob->appearanceData.iAngle);
|
||||||
|
|
||||||
@ -607,6 +598,14 @@ void MobManager::combatStep(Mob *mob, time_t currTime) {
|
|||||||
NPCManager::sendToViewable(mob, &pkt, P_FE2CL_NPC_MOVE, sizeof(sP_FE2CL_NPC_MOVE));
|
NPCManager::sendToViewable(mob, &pkt, P_FE2CL_NPC_MOVE, sizeof(sP_FE2CL_NPC_MOVE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// attack logic
|
||||||
|
if (distance <= mobRange || distanceToTravel < speed*2/5) {
|
||||||
|
if (mob->nextAttack == 0 || currTime >= mob->nextAttack) {
|
||||||
|
mob->nextAttack = currTime + (int)mob->data["m_iDelayTime"] * 100;
|
||||||
|
npcAttackPc(mob, currTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// retreat if the player leaves combat range
|
// retreat if the player leaves combat range
|
||||||
int xyDistance = hypot(plr->x - mob->roamX, plr->y - mob->roamY);
|
int xyDistance = hypot(plr->x - mob->roamX, plr->y - mob->roamY);
|
||||||
distance = hypot(xyDistance, plr->z - mob->roamZ);
|
distance = hypot(xyDistance, plr->z - mob->roamZ);
|
||||||
@ -989,7 +988,7 @@ std::pair<int,int> MobManager::getDamage(int attackPower, int defensePower, bool
|
|||||||
|
|
||||||
// base calculation
|
// base calculation
|
||||||
int damage = attackPower * attackPower / (attackPower + defensePower);
|
int damage = attackPower * attackPower / (attackPower + defensePower);
|
||||||
damage = std::max(10 + attackPower / 10, damage - (defensePower - attackPower / 2) * difficulty / 72);
|
damage = std::max(10 + attackPower / 10, damage - (defensePower - attackPower / 6) * difficulty / 100);
|
||||||
damage = damage * (rand() % 40 + 80) / 100;
|
damage = damage * (rand() % 40 + 80) / 100;
|
||||||
|
|
||||||
// Adaptium/Blastons/Cosmix
|
// Adaptium/Blastons/Cosmix
|
||||||
@ -999,9 +998,9 @@ std::pair<int,int> MobManager::getDamage(int attackPower, int defensePower, bool
|
|||||||
if (defenderStyle - attackerStyle == 2)
|
if (defenderStyle - attackerStyle == 2)
|
||||||
defenderStyle -= 3;
|
defenderStyle -= 3;
|
||||||
if (attackerStyle < defenderStyle)
|
if (attackerStyle < defenderStyle)
|
||||||
damage = damage * 3 / 2;
|
damage = damage * 5 / 4;
|
||||||
else
|
else
|
||||||
damage = damage * 2 / 3;
|
damage = damage * 4 / 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// weapon boosts
|
// weapon boosts
|
||||||
|
Loading…
Reference in New Issue
Block a user