WB Coding Formula for the final weapon speed

Users who are viewing this thread

Garedyr

Master Knight
WBVC
Hello guys,

I've been doing a lot of tests lately and the results were satisfying up to some point where the numbers stopped being accurate so my guess & proof method failed at sth.
What's the actual formula for the weapon speed that takes the speed rating, animation sequence duration and weapon proficiency into account? I would also appreciate the speed bonus formula (the one used in damage calculations).

Thank you all in advance.
 
Solution
Despite the fact that it's the formula from WSE2 so it might not match the original WB one in one hundred percent, K700 was kind enough to provide me this code below, problem solved.

C++:
float mbAgent::getActionSpeed(int hand, bool reloading)
{
    mbItem item;
    item.m_itemKindNo = -1;

    if (reloading)
    {
        const mbItem *temp = getItem(hand);
        if (temp)
            item = *temp;
    }
    else
    {
        item = getWieldedItem(hand);
    }

    if (!item.isValid())
        return 1.0f;
    
    mbItemKind *itemKind = item.getItemKind();
    int type = itemKind->getType();
    mbItem secondaryItem = getWieldedItem(ah_secondary);
    float speed = itemKind->getSpeedRating() * 0.01f;

    if...

Garedyr

Master Knight
WBVC
Despite the fact that it's the formula from WSE2 so it might not match the original WB one in one hundred percent, K700 was kind enough to provide me this code below, problem solved.

C++:
float mbAgent::getActionSpeed(int hand, bool reloading)
{
    mbItem item;
    item.m_itemKindNo = -1;

    if (reloading)
    {
        const mbItem *temp = getItem(hand);
        if (temp)
            item = *temp;
    }
    else
    {
        item = getWieldedItem(hand);
    }

    if (!item.isValid())
        return 1.0f;
    
    mbItemKind *itemKind = item.getItemKind();
    int type = itemKind->getType();
    mbItem secondaryItem = getWieldedItem(ah_secondary);
    float speed = itemKind->getSpeedRating() * 0.01f;

    if (itemKind->isWeapon())
    {
        float weaponFactor = type == itp_type_bow ? 0.11f : 0.07f;

        speed *= 0.01f * (int)getTroop()->getProficiency(itemKind->getProficiency(secondaryItem.isValid())) * weaponFactor + 1.0f - weaponFactor;
    }

    if (type == itp_type_two_handed || type == itp_type_polearm)
    {
        if (secondaryItem.isValid() || hasMount())
        {
            speed -= 0.15f;

            if (itemKind->m_properties & itp_two_handed)
                speed -= 0.05f;
        }
    }
    else if (type == itp_type_shield)
    {
        speed *= g_game->getTroopSkill(m_troopNo, skl_shield, true) * 0.03f + 1.0f;
    }

    if (g_basicGame.isMultiplayer())
        speed *= 0.03f * g_networkManager.m_combatSpeed + 0.94f;
    else if (itemKind->isMeleeWeapon() && (m_no != g_mission->m_playerAgentNo || rglConfig::Battle::iCombatSpeed > 2))
        speed *= 0.03f * rglConfig::Battle::iCombatSpeed + 0.94f;

    return speed;
}
 
Upvote 0
Solution
Top Bottom