Jump to content

"GetHealers" and "GetDamagers" functions


Guest lillecarl

Recommended Posts

Hello, i would like to write up 2 functions "GetHealers" and "GetDamagers", basically it shall be something like a "unknown ranged array" so it shall basically contain this.

Player* player

uint32 DamageCount/Healcount

Im not sure if its hard to create smth like this but im pretty sure someone can gimme a hint :)

The _array_ shall be cleared on leave combat, and filled each time you are in combat and someone id healing/damaging you :)

This would help me out dang much creating the ultimate pvp system for mah repo (yepsie opensource :))

Link to comment
Share on other sites

Not tested but should answer what you ask

// Add this in Player.h
struct DamageHealData
{
   DamageHealData() : damage(0), healing(0) { }

   uint32 damage;
   uint32 healing;
};

// Add this to Player class
std::map<uint64, DamageHealData*> m_DamagersAndHealers;

// Unit::DealDamage
if (GetTypeId() == TYPEID_PLAYER && pVictim->GetTypeId() == TYPEID_PLAYER)
   ((Player*)pVictim)->DamagedOrHealed(GetGUID(), damage, 0);

// Unit::DealHeal
if (GetTypeId() == TYPEID_PLAYER && pVictim->GetTypeId() == TYPEID_PLAYER)
   ((Player*)pVictim)->DamagedOrHealed(GetGUID(), 0, addhealth);

// Unit::ClearInCombat
if (GetTypeId() == TYPEID_PLAYER)
{
   Player *p = ((Player*)this);

   for (std::map<uint64, DamageHealData*>::iterator itr = p->m_DamagersAndHealers.begin(); itr != p->m_DamagersAndHealers.end(); ++itr)
       delete itr->second;
   p->m_DamagersAndHealers.clear();
}

void Player::DamagedOrHealed(uint64 guid, uint32 damage, uint32 heal)
{
   DamageHealData *data = NULL;
   if (!data = m_DamagersAndHealers[guid])
       m_DamagersAndHealers[guid] = new DamageHealData();

   data->damage += damage;
   data->healing += heal;
}

// Example
for (std::map<uint64, DamageHealData*>::iterator itr = m_DamagersAndHealers.begin(); itr != m_DamagersAndHealers.end(); ++itr)
{
   if (itr->second->damage > itr->second->healing)
       sLog->outString("Player with GUID %u is damager");
   else
       sLog->outString("Player with GUID %u is healer");
}

Link to comment
Share on other sites

Would there be a possibility to add the healer/damagers points into the struct? and then use it in some kind of loop, the idea is when someone kills someone everyone who have healed the attacker or damaged the victim and is in 50 yds range from the killing blow shall get "currency" in this case gold

Anyways thank you alot for helping me out, i will test this later as my girlfriend is joining me later ^^,

- LilleCarl

Link to comment
Share on other sites

4>..\\..\\..\\src\\game\\Player.cpp(20468) : error C2106: '=' : left operand must be l-value

void Player::DamagedOrHealed(uint64 guid, uint32 damage, uint32 heal)

{

DamageHealData *data = NULL; // This line gave the compiling error

if (!data = m_DamagersAndHealers[guid])

m_DamagersAndHealers[guid] = new DamageHealData();

data->damage += damage;

data->healing += heal;

}

Just as response, i have no idea about hao to fix it :/

Link to comment
Share on other sites

  • 7 months later...
Well, you could use the honor or xp reward system as a template for creating your gold system, you just need to have it apply to a party instead of an individual.

That would not do what i want, i do not want them to need to be in a group to get the gold, you should get gold if you are for example, assisting with dmh in gurubashi arena and are not in group with eachother, if you understand me:) But thank you for the showed interest :)

And i solved the compiling error, now it crashes on damage, ill spend some time doing this when im finished with a few other things, or when someone pops a new idea up

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

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. Privacy Policy Terms of Use