Cornwallis
Member
- Joined
- Jan 3, 2010
- Messages
- 480
- Reaction score
- 16
Hello, so I tried to make a workaround because at first it would crash everytime I used my fist, but now it only happens whenever I attack with a weapon and then unequip the weapon to hit with fist. Oddly though, if I switch between weapons with different attack speeds it acts accordingly. Here's the part that I presume is messing up:
Code:
void Player::doAttacking(uint32_t)
{
Item* tool = getWeapon();
const Weapon* weapon = g_weapons->getWeapon(tool);
uint32_t atkspd = 0;
if (tool) {
if (tool->getAttackSpeed()) {
atkspd = tool->getAttackSpeed();
} else {
atkspd = 1500;
}
} else {
atkspd = 1500;
}
if (lastAttack == 0) {
lastAttack = OTSYS_TIME() - atkspd*getAttackFactor() - 1;
}
if (hasCondition(CONDITION_PACIFIED)) {
return;
}
if ((OTSYS_TIME() - lastAttack) >= atkspd*getAttackFactor()) {
bool result = false;
if (weapon) {
result = weapon->useWeapon(this, tool, attackedCreature);
} else {
result = Weapon::useFist(this, attackedCreature);
}
if (result) {
lastAttack = OTSYS_TIME();
}
}
}
Last edited: