viewing paste Unknown #57315 | C++

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
struct AMOUNT_INFO { 
    unsigned time;
    int amount;
};
class CharacterInfo {
    // ...
    int ATKPercent, DEFPercent, MATKPercent, MDEFPercent;
}
class CPCBattle {
    // ...
    std::map<int, AMOUNT_INFO> m_ATKPercentList; // key = skid
};
void CPCBattle::SetATKPercentInfo(_SKILL_ID skid, unsigned duration, int val)
{
    auto info = &m_pc->m_characterInfo;
    
    auto entry = info.find(skid);
    if (auto entry = m_ATKPercentList.find(skid); entry != m_ATKPercentList.end())
    {
        auto entry_amount = entry->second.amount;
        if (std::abs(val) < std::abs(entry_amount))
            return;
        info->ATKPercent -= entry_amount;
    }
    
    auto stored = info->ATKPercent;
    if (stored + val < 0)
        val = -stored;
    
    unsigned timeout = 9999;
    info->ATKPercent = val + stored;
    if (duration != 9999)
        timeout = timeGetTime() + duration;
    
    auto pair = m_ATKPercentList[skid];
    pair->time = timeout;
    pair->amount = val;
    Trace("%s's ATKPercent: %d\n", info->characterName, info->ATKPercent);
    m_pc->NotifyParameter(VARR_ATTPOWER, 0);
}
Viewed 674 times, submitted by Guest.