void ThreatMap::addDamage(CreatureObject* target, uint32 damage, String xp) { Locker locker(&lockMutex); ManagedReference<TangibleObject*> strongSelf = self.get(); if (strongSelf == NULL || strongSelf.get() == target) return; int idx = find(target); String xpToAward = ""; if (xp == "") { WeaponObject* weapon = target->getWeapon(); xpToAward = weapon->getXpType(); } else xpToAward = xp; if (idx == -1) { ThreatMapEntry entry; entry.addDamage(xpToAward, damage); entry.addAggro(1); put(target, entry); registerObserver(target); } else { ThreatMapEntry* entry = &elementAt(idx).getValue(); entry->addDamage(xpToAward, damage); entry->addAggro(1); } }
void ThreatMap::addDamage(CreatureObject* target, uint32 damage, String xp) { Locker locker(&lockMutex); int idx = find(target); String xpToAward = ""; if (xp == "") { WeaponObject* weapon = target->getWeapon(); xpToAward = weapon->getXpType(); } else xpToAward = xp; if (idx == -1) { ThreatMapEntry entry; entry.addDamage(xpToAward, damage); entry.addAggro(1); put(target, entry); registerObserver(target); } else { ThreatMapEntry* entry = &elementAt(idx).getValue(); entry->addDamage(xpToAward, damage); entry->addAggro(1); } // randomly change target everytime threatmap is added to, TODO: keep this in mind and perhaps make it slightly more complicated if (System::random(5) == 0) currentThreat = target; }
void ThreatMap::addAggro(CreatureObject* target, int value, uint64 duration) { Locker locker(&lockMutex); ManagedReference<TangibleObject*> strongSelf = self.get(); if (strongSelf == NULL || strongSelf.get() == target) return; int idx = find(target); if (idx == -1) { ThreatMapEntry entry; entry.addAggro(value); put(target, entry); registerObserver(target); } else { ThreatMapEntry* entry = &elementAt(idx).getValue(); entry->addAggro(value); } if(duration > 0) { Reference<RemoveAggroTask*> removeAggroTask = new RemoveAggroTask(self.get(), target, value); removeAggroTask->schedule(duration); } }
void ThreatMap::addHeal(CreatureObject* target, int value) { Locker locker(&lockMutex); int idx = find(target); if (idx == -1) { ThreatMapEntry entry; entry.addHeal(value); entry.addAggro(2); put(target, entry); registerObserver(target); } else { ThreatMapEntry* entry = &elementAt(idx).getValue(); entry->addHeal(value); entry->addAggro(2); } }
void ThreatMap::addHeal(CreatureObject* target, int value) { Locker locker(&lockMutex); ManagedReference<TangibleObject*> strongSelf = self.get(); if (strongSelf == NULL || strongSelf.get() == target) return; int idx = find(target); if (idx == -1) { ThreatMapEntry entry; entry.addHeal(value); entry.addAggro(1); put(target, entry); registerObserver(target); } else { ThreatMapEntry* entry = &elementAt(idx).getValue(); entry->addHeal(value); entry->addAggro(1); } }