Jump to content

Recommended Posts

The average damage and skill damage ratios are calculated in this function. I’ve updated the code to make it more up to date. You don’t have to implement this update; it’s just something I did out of boredom and wanted to share. It’s up to you whether you add it or not.

item_addon.cpp;

#include "stdafx.h"
#include "constants.h"
#include "utils.h"
#include "item.h"
#include "item_addon.h"
#include <random>
#include <cmath>

CItemAddonManager::CItemAddonManager()
{
}

CItemAddonManager::~CItemAddonManager()
{
}

void CItemAddonManager::ApplyAddonTo(int iAddonType, LPITEM pItem)
{
    if (!pItem)
    {
        sys_err("ApplyAddonTo: item pointer null");
        return;
    }

    std::random_device rd;
    std::mt19937 gen(rd());

    std::normal_distribution<> gauss_dist(0.0, 5.0);
    int iSkillBonus = MINMAX(-30, static_cast<int>(std::round(gauss_dist(gen))), 30);

    int iNormalHitBonus = 0;

    if (std::abs(iSkillBonus) <= 20)
    {
        std::uniform_int_distribution<> dist_8_8(-8, 8);
        std::uniform_int_distribution<> dist_1_4(1, 4);

        iNormalHitBonus = -2 * iSkillBonus + std::abs(dist_8_8(gen) + dist_8_8(gen)) + dist_1_4(gen);
    }
    else
    {
        std::uniform_int_distribution<> dist_1_5(1, 5);

        iNormalHitBonus = -2 * iSkillBonus + dist_1_5(gen);
    }

    pItem->RemoveAttributeType(APPLY_SKILL_DAMAGE_BONUS);
    pItem->RemoveAttributeType(APPLY_NORMAL_HIT_DAMAGE_BONUS);
    pItem->AddAttribute(APPLY_NORMAL_HIT_DAMAGE_BONUS, iNormalHitBonus);
    pItem->AddAttribute(APPLY_SKILL_DAMAGE_BONUS, iSkillBonus);
}

 

Link to comment
https://metin2.dev/topic/33915-applyaddonto-upgrade/
Share on other sites

  • 3 weeks later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Active Member

This uniform random has disappointed me over time, the effects were too bad, too much harder, best way is ymir original random, and many successful pservers have been using the ymir random.
Even if the ymir random sometimes give weird tendencies.

For example :
- 
if you upgrade items and you get successfull upgrades in a row, or getting failed upgrades in a row.
- You turn on the server and Azrael (2598) gives bigger damages at the beginning (for some hours maybe), like giving you insta kill due to different tendencies in the random of the deathblow damage.

Link to comment
https://metin2.dev/topic/33915-applyaddonto-upgrade/#findComment-171999
Share on other sites

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.