[DiscordArchive] well what is the purpose of this?
[DiscordArchive] well what is the purpose of this?
Archived author: Anchy • Posted: 2022-12-21T20:38:23.747000+00:00
Original source
right
Archived author: Anchy • Posted: 2022-12-21T20:38:36.409000+00:00
Original source
so something like this
Archived author: Anchy • Posted: 2022-12-21T20:44:16.601000+00:00
Original source
```cpp
void CreatureScript::OnUnitEnterCombat(Unit* unit, Unit* victim)
{
if(victim->IsPlayer() &&
!unit->IsPlayer())
return;
Player* player = unit->ToPlayer();
if(IsInCombat(player)) //Check if exist in combat cache
return;
combatCache.insert(player->GetGUID());
}
void CreatureScript::OnUnitEnterEvadeMode(Unit* unit, uint8 why)
{
combatCache.clear();
}
```
Archived author: Anchy • Posted: 2022-12-21T20:44:33.835000+00:00
Original source
you will probably have to create a new combatCache for every npc that has been attacked by a player
Archived author: Anchy • Posted: 2022-12-21T20:44:40.781000+00:00
Original source
as that is more of a global cache and will definitely have problems
Archived author: Anchy • Posted: 2022-12-21T20:44:50.235000+00:00
Original source
then you can scale based on combatCache size
Archived author: Anchy • Posted: 2022-12-21T20:45:09.152000+00:00
Original source
then delete it after it either evades or dies
tring test_message =Archived author: Rymercyble • Posted: 2022-12-21T20:45:58.974000+00:00
Original source
let me try that....i was experimenting few lines above in `Unit::CombatStart` with
```cpp
if (!victim->IsPlayer()) {
std:
tring test_message =
"combat started between " + victim->ToCreature()->GetGUID().ToString() + " and " +
this->ToPlayer()->GetGUID().ToString();
sWorld->SendServerMessage(SERVER_MSG_STRING, test_message);
}
```
but i was not able to solve its issues
Archived author: Anchy • Posted: 2022-12-21T20:46:26.045000+00:00
Original source
you can use Acore::FormatFmt if you want cleaner formats by the way
Archived author: Anchy • Posted: 2022-12-21T20:47:03.363000+00:00
Original source
```cpp
Acore::FormatFmt("Combat started between {} and {}", victim->ToCreature()->GetGUID, etc..);
```