tiag0_bn
Well-Known Member
- Joined
- Dec 8, 2011
- Messages
- 198
- Reaction score
- 59
Good evening, i'm using otx2
I needed help to double the speed of the 'interval' of the monster attacks when the distance is greater than 1 sqm.
For example: if the interval is "2000" to "1000".
i'm tried to put in
i put
However, the attack does not divide the value of the attack intervals.
I needed help to double the speed of the 'interval' of the monster attacks when the distance is greater than 1 sqm.
For example: if the interval is "2000" to "1000".
i'm tried to put in
void Monster::doAttacking(uint32_t interval)
{
if(!attackedCreature || (isSummon() && attackedCreature == this))
return;
bool updateLook = true;
resetTicks = (interval != 0);
attackTicks += interval;
const Position& myPos = getPosition();
for(SpellList::iterator it = mType->spellAttackList.begin(); it != mType->spellAttackList.end(); ++it)
{
if(!attackedCreature || attackedCreature->isRemoved())
break;
const Position& targetPos = attackedCreature->getPosition();
if(it->isMelee && isFleeing())
continue;
bool inRange = false;
if(canUseSpell(myPos, targetPos, *it, interval, inRange))
{
if(it->chance >= (uint32_t)random_range(1, 100))
{
if(updateLook)
{
updateLookDirection();
updateLook = false;
}
double multiplier;
if(maxCombatValue > 0) //defense
multiplier = g_config.getDouble(ConfigManager::RATE_MONSTER_DEFENSE);
else //attack
multiplier = g_config.getDouble(ConfigManager::RATE_MONSTER_ATTACK);
minCombatValue = (int32_t)(it->minCombatValue * multiplier);
maxCombatValue = (int32_t)(it->maxCombatValue * multiplier);
it->spell->castSpell(this, attackedCreature);
if(it->isMelee)
extraMeleeAttack = false;
#ifdef DEBUG
static uint64_t prevTicks = OTSYS_TIME();
std::clog << "doAttacking ticks: " << OTSYS_TIME() - prevTicks << std::endl;
prevTicks = OTSYS_TIME();
#endif
}
}
if(!inRange && it->isMelee) //melee swing out of reach
extraMeleeAttack = true;
}
if(updateLook)
updateLookDirection();
if(resetTicks)
attackTicks = 0;
}
i put
Code:
uint32_t adjustedInterval = it->speed;
if (std::max(std::abs(myPos.x - targetPos.x), std::abs(myPos.y - targetPos.y)) > 2) {
adjustedInterval /= 2;
}
However, the attack does not divide the value of the attack intervals.