Official Damage Info

  • Konuyu açan Konuyu açan Reached
  • Açılış Tarihi Açılış Tarihi
  • Yanıt Yanıt 5
  • Gösterim Gösterim 367

Reached

Geliştirici
Geliştirici
Emekli Üye
Usta Üye
Editör
Mesaj
839
Çözümler
29
Beğeni
823
Puan
839
Ticaret Puanı
0
InstanceBaseEffect.cpp
C++:
Genişlet Daralt Kopyala
// Search
bool g_isEmpireNameMode=false;

// Add under
static DWORD gs_dwDamagePrefixCriticalCRC = 0;
static DWORD gs_dwDamagePrefixPenetrationCRC = 0;
static DWORD gs_dwDamagePrefixMixCRC = 0;


// Search
    DWORD index = 0;
    DWORD num = 0;
// Add under
    const DWORD originalDamage = damage;


// Search func
void CInstanceBase::ProcessDamage()

// Add at the end of the function
    const bool isCritical = (flag & DAMAGE_CRITICAL) != 0;
    const bool isPenetrate = (flag & DAMAGE_PENETRATE) != 0;
    if (isCritical || isPenetrate)
    {
        DWORD* pdwPrefixCRC = NULL;
        const char* c_szPrefixEffectPath = NULL;
        if (isCritical && isPenetrate)
        {
            pdwPrefixCRC = &gs_dwDamagePrefixMixCRC;
            c_szPrefixEffectPath = "d:/ymir work/effect/affect/damage_mix.mse";
        }
        else if (isCritical)
        {
            pdwPrefixCRC = &gs_dwDamagePrefixCriticalCRC;
            c_szPrefixEffectPath = "d:/ymir work/effect/affect/damage_critical.mse";
        }
        else
        {
            pdwPrefixCRC = &gs_dwDamagePrefixPenetrationCRC;
            c_szPrefixEffectPath = "d:/ymir work/effect/affect/damage_penetration.mse";
        }
        if (pdwPrefixCRC && *pdwPrefixCRC == 0)
        {
            if (!rkEftMgr.RegisterEffect2(c_szPrefixEffectPath, pdwPrefixCRC, true))
                TraceError("CInstanceBase::ProcessDamage - RegisterEffect2 failed (%s)", c_szPrefixEffectPath);
        }
        if (pdwPrefixCRC && *pdwPrefixCRC)
        {
            DWORD digitCount = 0;
            DWORD tempDamage = originalDamage;
            constexpr float fPrefixPadding = 18.0f;
            while (tempDamage > 0)
            {
                ++digitCount;
                tempDamage /= 10;
            }
            D3DXMATRIX matrix, matTrans;
            D3DXMatrixIdentity(&matrix);
            matrix._41 = v3Pos.x;
            matrix._42 = v3Pos.y;
            matrix._43 = v3Pos.z;
            D3DXMatrixTranslation(&matrix, v3Pos.x, v3Pos.y, v3Pos.z);
            D3DXMatrixMultiply(&matrix, &pCamera->GetInverseViewMatrix(), &matrix);
            D3DXMatrixTranslation(&matTrans, (FONT_WIDTH * digitCount) + fPrefixPadding, 0, 0);
            matTrans._41 = -matTrans._41;
            matrix = matTrans * matrix;
            D3DXMatrixMultiply(&matrix, &pCamera->GetViewMatrix(), &matrix);
            rkEftMgr.CreateEffect(*pdwPrefixCRC, D3DXVECTOR3(matrix._41, matrix._42, matrix._43), v3Rot);
        }
    }
Screenshot_164.webp

Screenshot_165.webp

Screenshot_166.webp
 

Dosya Eklentileri

yazıyı kırmızı yapmaktan daha iyi bi fikir eline sağlık
 
genişletilebilirlik, type-safety, okunabilirlik, hata yönetimi gibi durumlardan ötürü şöyle bir yaklaşım daha iyi olabilir, paylaşım için teşekkürler

hooklanan fonksiyonun implementasyonuna göre `string_view` yerine `const char*` kullanılabilir. kullanım senaryosunu dikkate alın nullstring ile başınız belaya girmesin. C++20(attribute'u kaldırırsanız 17'de de well-formed), üst sürümler için farklı yaklaşımlar konuşulabilir, isimlendirmeye takılmayın ayak üstü yazılmış kod. kendinize göre düzenleyebilirsiniz.

C++:
Genişlet Daralt Kopyala
enum class DamageType : std::uint8_t
{
    NONE,
    CRITICAL_AND_PENETRATE,
    CRITICAL,
    PENETRATE,
    COUNT,
};

[[nodiscard]] constexpr std::size_t to_index(DamageType t) noexcept // normally return type should same with "underlying_type" but for this case just using for array size
{
    return static_cast<std::size_t>(t);
}

static constexpr auto damage_type_size{to_index(DamageType::COUNT)};

static constexpr std::array<std::string_view/*!!!*/, damage_type_size> damage_effects{
    "", // NONE
    "d:/ymir work/effect/affect/damage_mix.mse",
    "d:/ymir work/effect/affect/damage_critical.mse",
    "d:/ymir work/effect/affect/damage_penetration.mse",
};

static_assert(damage_effects.size() == damage_type_size);


[[nodiscard]] constexpr DamageType resolve_damage_type(bool crit, bool pen) noexcept
{
    constexpr std::array<DamageType, damage_type_size> lut{
        DamageType::NONE, // 00
        DamageType::PENETRATE, // 01
        DamageType::CRITICAL, // 10
        DamageType::CRITICAL_AND_PENETRATE, // 11
    };
    
    using ret_t = std::size_t;
    const ret_t index{(static_cast<ret_t>(crit) << 1) | static_cast<ret_t>(pen)};
    
    return lut[index];
}

int main()
{
    const bool critical{/**/};
    const bool penetrate{/**/};

    const auto type{resolve_damage_type(critical, penetrate)};

    if (type == DamageType::NONE)
    {
        return EXIT_FAILURE;
    }

    const auto effect{damage_effects[to_index(type)]};

    assert(!effect.empty());

    if (effect.empty()) [[unlikely]]
    {
        return EXIT_FAILURE;
    }

    // registereffect2, blablabla

    return EXIT_SUCCESS;
}
 
Is this a system from the official server?

Can you post a screenshot of the system?
 
Geri
Üst