void Spawn2::SpawnConditionChanged(const SpawnCondition &c, int16 old_value) { if(GetSpawnCondition() != c.condition_id) return; Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Notified that our spawn condition %d has changed from %d to %d. Our min value is %d.", spawn2_id, c.condition_id, old_value, c.value, condition_min_value); bool old_state = (old_value >= condition_min_value); bool new_state = (c.value >= condition_min_value); if(old_state == new_state) { Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our threshold for this condition was not crossed. Doing nothing.", spawn2_id); return; //no change } uint32 timer_remaining = 0; switch(c.on_change) { case SpawnCondition::DoNothing: //that was easy. Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Taking no action on existing spawn.", spawn2_id, new_state?"enabled":"disabled"); break; case SpawnCondition::DoDepop: Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Depoping our mob.", spawn2_id, new_state?"enabled":"disabled"); if(npcthis != nullptr) npcthis->Depop(false); //remove the current mob Reset(); //reset our spawn timer break; case SpawnCondition::DoRepop: Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Forcing a repop.", spawn2_id, new_state?"enabled":"disabled"); if(npcthis != nullptr) npcthis->Depop(false); //remove the current mob Repop(); //repop break; case SpawnCondition::DoRepopIfReady: Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Forcing a repop if repsawn timer is expired.", spawn2_id, new_state?"enabled":"disabled"); if(npcthis != nullptr) { Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our npcthis is currently not null. The zone thinks it is %s. Forcing a depop.", spawn2_id, npcthis->GetName()); npcthis->Depop(false); //remove the current mob npcthis = nullptr; } if(new_state) { // only get repawn timer remaining when the SpawnCondition is enabled. timer_remaining = database.GetSpawnTimeLeft(spawn2_id,zone->GetInstanceID()); Log(Logs::Detail, Logs::Spawns,"Spawn2 %d: Our condition is now %s. The respawn timer_remaining is %d. Forcing a repop if it is <= 0.", spawn2_id, new_state?"enabled":"disabled", timer_remaining); if(timer_remaining <= 0) Repop(); } else { Log(Logs::Detail, Logs::Spawns,"Spawn2 %d: Our condition is now %s. Not checking respawn timer.", spawn2_id, new_state?"enabled":"disabled"); } break; default: if(c.on_change < SpawnCondition::DoSignalMin) { Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Invalid on-change action %d.", spawn2_id, new_state?"enabled":"disabled", c.on_change); return; //unknown onchange action } int signal_id = c.on_change - SpawnCondition::DoSignalMin; Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Signaling our mob with %d.", spawn2_id, new_state?"enabled":"disabled", signal_id); if(npcthis != nullptr) npcthis->SignalNPC(signal_id); } }
void Spawn2::SpawnConditionChanged(const SpawnCondition &c, int16 old_value) { if(GetSpawnCondition() != c.condition_id) return; _log(SPAWNS__CONDITIONS, "Spawn2 %d: Notified that our spawn condition %d has changed from %d to %d. Our min value is %d.", spawn2_id, c.condition_id, old_value, c.value, condition_min_value); bool old_state = (old_value >= condition_min_value); bool new_state = (c.value >= condition_min_value); if(old_state == new_state) { _log(SPAWNS__CONDITIONS, "Spawn2 %d: Our threshold for this condition was not crossed. Doing nothing.", spawn2_id); return; //no change } switch(c.on_change) { case SpawnCondition::DoNothing: //that was easy. _log(SPAWNS__CONDITIONS, "Spawn2 %d: Our condition is now %s. Taking no action on existing spawn.", spawn2_id, new_state?"enabed":"disabled"); break; case SpawnCondition::DoDepop: _log(SPAWNS__CONDITIONS, "Spawn2 %d: Our condition is now %s. Depoping our mob.", spawn2_id, new_state?"enabed":"disabled"); if(npcthis != NULL) npcthis->Depop(false); //remove the current mob Reset(); //reset our spawn timer break; case SpawnCondition::DoRepop: _log(SPAWNS__CONDITIONS, "Spawn2 %d: Our condition is now %s. Preforming a repop.", spawn2_id, new_state?"enabed":"disabled"); if(npcthis != NULL) npcthis->Depop(false); //remove the current mob Repop(); //repop break; default: if(c.on_change < SpawnCondition::DoSignalMin) { _log(SPAWNS__CONDITIONS, "Spawn2 %d: Our condition is now %s. Invalid on-change action %d.", spawn2_id, new_state?"enabed":"disabled", c.on_change); return; //unknown onchange action } int signal_id = c.on_change - SpawnCondition::DoSignalMin; _log(SPAWNS__CONDITIONS, "Spawn2 %d: Our condition is now %s. Signaling our mob with %d.", spawn2_id, new_state?"enabed":"disabled", signal_id); if(npcthis != NULL) npcthis->SignalNPC(signal_id); } }