TrinityCore icon indicating copy to clipboard operation
TrinityCore copied to clipboard

[Vehicle] Bonus Player Items to Vehicle HP

Open click opened this issue 15 years ago • 7 comments

The Player Items don't give HP to Vehicle Life. I did some tests with this part of code (with some debug output i find two issues)

{{{ // hack: should be done by aura system if (VehicleScalingInfo const *scalingInfo = sObjectMgr->GetVehicleScalingInfo(m_vehicleInfo->m_ID)) { ...

        float currentHealthPct = float(me->GetHealth() / me->GetMaxHealth());
        m_bonusHP = uint32(me->GetMaxHealth() * (averageItemLevel * scalingInfo->scalingFactor));
        me->SetMaxHealth(me->GetMaxHealth() + m_bonusHP);
        me->SetHealth(uint32((me->GetHealth() + m_bonusHP) * currentHealthPct));
    }

}}}

The First issue is "float currentHealthPct = float(me->GetHealth() / me->GetMaxHealth());" if me->GetHealth() is < than me->GetMaxHealth(), currentHealthPct is 0 because float(uint32_1/uint32_2) if uint32_1<uint32_2, uint32_1/uint32_2 is 0. I tried "float currentHealthPct = float(me->GetHealth()) / float(me->GetMaxHealth());" and work.

The second issue is not in that part of code because "me->SetMaxHealth(me->GetMaxHealth() + m_bonusHP);" is set right and some output of me->GetMaxHealth() tell me that but then in some others part of core the HP of vehicle is set again to base (i see that ingame and when leave vehicle i did some ouput of me->GetMaxHealth()).

Rev: https://github.com/TrinityCore/TrinityCore/commit/eea7efa463a767f70022bae03c48e1839d0ed5d3 Compile under Ubuntu 9.10 x64

click avatar May 16 '11 22:05 click

Author: machiavelli Thanks for pointing this out, but as the comment states, this is one big hack. Proper vehicle scaling will have to be done trough the aura system.

click avatar May 16 '11 22:05 click

look in avarage item level calculation ... its bugget

unspike avatar May 28 '11 03:05 unspike

GetAverageItemLevel // don't check tabard, ranged, offhand or chest if (i == EQUIPMENT_SLOT_TABARD || i == EQUIPMENT_SLOT_RANGED || i == EQUIPMENT_SLOT_OFFHAND || i == EQUIPMENT_SLOT_CHEST) continue;

but....

EQUIPMENT_SLOT_BODY         = 3,  --- this is shirt
EQUIPMENT_SLOT_CHEST        = 4,  --- and this is Chest 

should be like this

// don't check tabard, ranged, offhand or chest if (i == EQUIPMENT_SLOT_TABARD || i == EQUIPMENT_SLOT_RANGED || i == EQUIPMENT_SLOT_OFFHAND || i == EQUIPMENT_SLOT_BODY) continue;

unspike avatar May 28 '11 03:05 unspike

and in this issue http://trinity-core.ru/project.php?issueid=10&page=2 i thy to fix bonus hp and damage

unspike avatar May 28 '11 03:05 unspike

bool Vehicle::AddPassenger(Unit *unit, int8 seatId)

    // hack: should be done by aura system

    if (VehicleScalingInfo const *scalingInfo = sObjectMgr->GetVehicleScalingInfo(m_vehicleInfo->m_ID))
    {
        Player *plr = unit->ToPlayer();
        float averageItemLevel = plr->GetAverageItemLevel();
        if (averageItemLevel < scalingInfo->baseItemLevel)
            averageItemLevel = scalingInfo->baseItemLevel;
        averageItemLevel -= scalingInfo->baseItemLevel;

        m_bonusHP = (averageItemLevel * 3);
        m_bonusDM = (averageItemLevel);
        me->CastCustomSpell(me, 62455, NULL, &m_bonusDM,  &m_bonusHP, true);
    }

void Vehicle::RemovePassenger(Unit *unit)

    if (m_bonusHP)
    {
        m_bonusHP = 0;
        m_bonusDM = 0;
        me->CastCustomSpell(me, 62455, NULL, &m_bonusDM,  &m_bonusHP, true);

// me->RemoveAurasDueToSpell(62455); }

and

float Player::GetAverageItemLevel() { float sum = 0; uint32 count = 0;

for (int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i)
{
    // don't check tabard, ranged, offhand or chest
    if (i == EQUIPMENT_SLOT_TABARD || i == EQUIPMENT_SLOT_RANGED || i == EQUIPMENT_SLOT_OFFHAND || i == EQUIPMENT_SLOT_BODY)
        continue;

    if (m_items[i] && m_items[i]->GetProto())
        sum += m_items[i]->GetProto()->GetItemLevelIncludingQuality();

    count++;
}

return ((float)sum) / count;

}

hack, but works

unspike avatar May 29 '11 21:05 unspike

Gear scaling is handled by linked aura's as a result of npc_spellclick_spells data. We don't need to manually cast these spells (yes, there are more than just one). We don't need CastCustomSpell either - we need spellscripts for correct amount calculation based on other factors.

Nice find on the GetAverageItemLevel() bug though, pushing that part.

Machiavell1 avatar Jun 12 '11 01:06 Machiavell1

This should be closed, no? As Machiavell1 stated these are handled spells and they need to be fixed, gear scaling is working as it should?

shipwithstef avatar Dec 19 '12 15:12 shipwithstef