• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Bow Attack

Helliot1

Owner of Empire Online
Joined
Jul 26, 2017
Messages
315
Solutions
1
Reaction score
60
Hello,

I wonder how I can put attack on a bow, like sword/axes/clubs...

I tried this, but don't works...

LUA:
<item id="1541" article="a" name="bow">
    <attribute key="attack" value="120" />
    <attribute key="defense" value="0" />       
    <attribute key="weaponType" value="distance" />
    <attribute key="ammoType" value="arrow" />
    <attribute key="range" value="7" />
</item>
 
Hello,

I wonder how I can put attack on a bow, like sword/axes/clubs...

I tried this, but don't works...

LUA:
<item id="1541" article="a" name="bow">
    <attribute key="attack" value="120" />
    <attribute key="defense" value="0" />      
    <attribute key="weaponType" value="distance" />
    <attribute key="ammoType" value="arrow" />
    <attribute key="range" value="7" />
</item>
Yeah, there are distance weapons with attack already.

Arbalest for example
XML:
    <item id="5803" article="an" name="arbalest">
        <attribute key="description" value="It is a bit heavy due to the iron mounting, but very precise." />
        <attribute key="weight" value="9500" />
        <attribute key="weaponType" value="distance" />
        <attribute key="ammoType" value="bolt" />
        <attribute key="range" value="6" />
        <attribute key="hitChance" value="2" />
        <attribute key="attack" value="2" />
    </item>

you need to set
<attribute key="weaponType" value="distance" />
to axe, club, fist, sword etc any already existing real atk type

also add it on weapons.xml
?????
 
In Tibia the bow is calculated by the arrow attack. But I wanted the bow to be calculated by the bow attack, not the arrow.

Found this on weapons.cpp (otxserver3 8.60), I think I have to change something here in this formula. But I'm still trying to read what it is.

C++:
int32_t WeaponDistance::getWeaponDamage(const Player* player, const Creature* target, const Item* item, bool maxDamage /*= false*/) const
{
    int32_t attackValue = item->getAttack();

    if (item->getWeaponType() == WEAPON_AMMO) {
        Item* weapon = player->getWeapon(true);
        if (weapon) {
            attackValue += weapon->getAttack();
        }
    }

    int32_t attackSkill = player->getSkillLevel(SKILL_DISTANCE);
    float attackFactor = player->getAttackFactor();

    int32_t maxValue = static_cast<int32_t>(Weapons::getMaxWeaponDamage(player->getLevel(), attackSkill, attackValue, attackFactor) * player->getVocation()->distDamageMultiplier);
    if (maxDamage) {
        return -maxValue;
    }

    int32_t minValue;
    if (target) {
        if (target->getPlayer()) {
            minValue = static_cast<int32_t>(std::ceil(player->getLevel() * 0.1));
        } else {
            minValue = static_cast<int32_t>(std::ceil(player->getLevel() * 0.2));
        }
    } else {
        minValue = 0;
    }
    return -normal_random(minValue, maxValue);
}
 
In Tibia the bow is calculated by the arrow attack. But I wanted the bow to be calculated by the bow attack, not the arrow.

Found this on weapons.cpp (otxserver3 8.60), I think I have to change something here in this formula. But I'm still trying to read what it is.

C++:
int32_t WeaponDistance::getWeaponDamage(const Player* player, const Creature* target, const Item* item, bool maxDamage /*= false*/) const
{
    int32_t attackValue = item->getAttack();

    if (item->getWeaponType() == WEAPON_AMMO) {
        Item* weapon = player->getWeapon(true);
        if (weapon) {
            attackValue += weapon->getAttack();
        }
    }

    int32_t attackSkill = player->getSkillLevel(SKILL_DISTANCE);
    float attackFactor = player->getAttackFactor();

    int32_t maxValue = static_cast<int32_t>(Weapons::getMaxWeaponDamage(player->getLevel(), attackSkill, attackValue, attackFactor) * player->getVocation()->distDamageMultiplier);
    if (maxDamage) {
        return -maxValue;
    }

    int32_t minValue;
    if (target) {
        if (target->getPlayer()) {
            minValue = static_cast<int32_t>(std::ceil(player->getLevel() * 0.1));
        } else {
            minValue = static_cast<int32_t>(std::ceil(player->getLevel() * 0.2));
        }
    } else {
        minValue = 0;
    }
    return -normal_random(minValue, maxValue);
}
C++:
int32_t attackValue = item->getAttack();
This is ammunition attack.

C++:
   if (item->getWeaponType() == WEAPON_AMMO) {
        Item* weapon = player->getWeapon(true);
        if (weapon) {
            attackValue += weapon->getAttack();
        }
    }
This is weapon in hand attack.

It's all there and your bow with attack should be working, try adding 99999 attack and see if anything changes.
 
C++:
int32_t attackValue = item->getAttack();
This is ammunition attack.

C++:
   if (item->getWeaponType() == WEAPON_AMMO) {
        Item* weapon = player->getWeapon(true);
        if (weapon) {
            attackValue += weapon->getAttack();
        }
    }
This is weapon in hand attack.

It's all there and your bow with attack should be working, try adding 99999 attack and see if anything changes.
Yea, but first I need change this formula.

I tried to change "WEAPON_AMMO" for "WEAPON_DISTANCE" or exclude this line "int32_t attackValue = item->getAttack();" but it didn't works
 
script on attack..
if weapon is bow then
item (bow) get attack
done

if you want to use charges from arrow slot

if weapon is bow and get item xxx arrow slot
item (bow) get attack
done

so easy. why you make it harder touching the sources?
 
He thinks it would be easier to hardcode the damage to the bows. Even though you would have to define what ammo the bow can use in all of the codes. Its not easier at all, I don't think he is thinking it through.
 

Similar threads

Back
Top