rafaeru
Active Member
Hello, i have a problem with add delay of the first attack. I have attack speed on my server and i want this because players use script in elfbot on target and stop target very fast.
I try add lastAttack after new target but something doesn't work.
Piece of code:
void Player::doAttacking(uint32_t interval)
void Player:: onAttackedCreature(Creature* target)
I try add lastAttack after new target but something doesn't work.
Piece of code:
void Player::doAttacking(uint32_t interval)
C++:
void Player::doAttacking(uint32_t interval)
{
if(!lastAttack)
lastAttack = OTSYS_TIME() - getAttackSpeed() - 1;
else if((OTSYS_TIME() - lastAttack) < getAttackSpeed())
return;
if(hasCondition(CONDITION_PACIFIED) && !hasCustomFlag(PlayerCustomFlag_IgnorePacification))
{
lastAttack = OTSYS_TIME();
return;
}
Item* tool = getWeapon();
if(const Weapon* weapon = g_weapons->getWeapon(tool))
{
if(weapon->interruptSwing() && !canDoAction())
{
SchedulerTask* task = createSchedulerTask(getNextActionTime(), boost::bind(&Game::checkCreatureAttack, &g_game, getID()));
setNextActionTask(task);
}
else if((!weapon->hasExhaustion() || !hasCondition(CONDITION_EXHAUST, EXHAUST_COMBAT)) && weapon->useWeapon(this, tool, attackedCreature))
lastAttack = OTSYS_TIME();
}
else if(Weapon::useFist(this, attackedCreature))
lastAttack = OTSYS_TIME();
}
void Player:: onAttackedCreature(Creature* target)
C++:
void Player::onAttackedCreature(Creature* target)
{
Creature::onAttackedCreature(target);
if(hasFlag(PlayerFlag_NotGainInFight))
return;
addInFightTicks();
Player* targetPlayer = target->getPlayer();
if(!targetPlayer)
return;
addAttacked(targetPlayer);
if(targetPlayer == this && targetPlayer->getZone() != ZONE_PVP)
{
targetPlayer->sendCreatureSkull(this);
return;
}
if(Combat::isInPvpZone(this, targetPlayer) || isPartner(targetPlayer) || (g_config.getBool(
ConfigManager::ALLOW_FIGHTBACK) && targetPlayer->hasAttacked(this)))
return;
if(!pzLocked)
{
pzLocked = true;
sendIcons();
}
if(getZone() != target->getZone())
return;
if(skull == SKULL_NONE)
{
if(targetPlayer->getSkull() != SKULL_NONE)
targetPlayer->sendCreatureSkull(this);
else if(!hasCustomFlag(PlayerCustomFlag_NotGainSkull))
{
setSkull(SKULL_WHITE);
g_game.updateCreatureSkull(this);
}
}
}