Added ignore_despawn column to npc_types to have NPCs ignore the despawn column in spawngroup.

This commit is contained in:
regneq 2017-04-07 19:45:26 -07:00
parent 75d759fb77
commit 4600844336
7 changed files with 32 additions and 5 deletions

View File

@ -361,6 +361,7 @@
9105|2017_02_15_bot_spells_entries.sql|SELECT `id` FROM `npc_spells_entries` WHERE `npc_spells_id` >= 701 AND `npc_spells_id` <= 712|not_empty| 9105|2017_02_15_bot_spells_entries.sql|SELECT `id` FROM `npc_spells_entries` WHERE `npc_spells_id` >= 701 AND `npc_spells_id` <= 712|not_empty|
9106|2017_02_26_npc_spells_update_for_bots.sql|SELECT * FROM `npc_spells` WHERE `id` = '701' AND `name` = 'Cleric Bot'|not_empty| 9106|2017_02_26_npc_spells_update_for_bots.sql|SELECT * FROM `npc_spells` WHERE `id` = '701' AND `name` = 'Cleric Bot'|not_empty|
9107|2017_03_09_inventory_version.sql|SHOW TABLES LIKE 'inventory_version'|empty| 9107|2017_03_09_inventory_version.sql|SHOW TABLES LIKE 'inventory_version'|empty|
9107|2017_04_07_ignore_despawn|SHOW COLUMNS FROM `npc_types` LIKE 'ignore_despawn'|empty|
# Upgrade conditions: # Upgrade conditions:
# This won't be needed after this system is implemented, but it is used database that are not # This won't be needed after this system is implemented, but it is used database that are not

View File

@ -0,0 +1 @@
alter table npc_types add column `ignore_despawn` tinyint(2) not null default 0;

View File

@ -374,6 +374,7 @@ NPC::NPC(const NPCType* d, Spawn2* in_respawn, const glm::vec4& position, int if
InitializeBuffSlots(); InitializeBuffSlots();
CalcBonuses(); CalcBonuses();
raid_target = d->raid_target; raid_target = d->raid_target;
ignore_despawn = d->ignore_despawn;
} }
NPC::~NPC() NPC::~NPC()

View File

@ -417,6 +417,8 @@ public:
bool IsRaidTarget() const { return raid_target; }; bool IsRaidTarget() const { return raid_target; };
void ResetHPUpdateTimer() { sendhpupdate_timer.Start(); } void ResetHPUpdateTimer() { sendhpupdate_timer.Start(); }
bool IgnoreDespawn() { return ignore_despawn; }
protected: protected:
const NPCType* NPCTypedata; const NPCType* NPCTypedata;
@ -532,6 +534,7 @@ protected:
bool raid_target; bool raid_target;
uint8 probability; uint8 probability;
bool ignore_despawn; //NPCs with this set to 1 will ignore the despawn value in spawngroup
private: private:
uint32 loottable_id; uint32 loottable_id;

View File

@ -208,11 +208,26 @@ bool Spawn2::Process() {
} }
} }
if(sg->despawn != 0 && condition_id == 0) bool ignore_despawn = false;
zone->Despawn(spawn2_id); if (npcthis)
{
ignore_despawn = npcthis->IgnoreDespawn();
}
if(IsDespawned) if (ignore_despawn)
{
return true; return true;
}
if (sg->despawn != 0 && condition_id == 0 && !ignore_despawn)
{
zone->Despawn(spawn2_id);
}
if (IsDespawned)
{
return true;
}
currentnpcid = npcid; currentnpcid = npcid;
NPC* npc = new NPC(tmp, this, glm::vec4(x, y, z, heading), FlyMode3); NPC* npc = new NPC(tmp, this, glm::vec4(x, y, z, heading), FlyMode3);
@ -295,6 +310,9 @@ void Spawn2::ForceDespawn()
if(npcthis != nullptr) if(npcthis != nullptr)
{ {
if (npcthis->IgnoreDespawn())
return;
if(!npcthis->IsEngaged()) if(!npcthis->IsEngaged())
{ {
if(sg->despawn == 3 || sg->despawn == 4) if(sg->despawn == 3 || sg->despawn == 4)

View File

@ -1966,7 +1966,8 @@ const NPCType* ZoneDatabase::LoadNPCTypesData(uint32 npc_type_id, bool bulk_load
"npc_types.bracertexture, " "npc_types.bracertexture, "
"npc_types.handtexture, " "npc_types.handtexture, "
"npc_types.legtexture, " "npc_types.legtexture, "
"npc_types.feettexture " "npc_types.feettexture, "
"npc_types.ignore_despawn "
"FROM npc_types %s", "FROM npc_types %s",
where_condition.c_str() where_condition.c_str()
); );
@ -2141,6 +2142,7 @@ const NPCType* ZoneDatabase::LoadNPCTypesData(uint32 npc_type_id, bool bulk_load
temp_npctype_data->handtexture = atoi(row[94]); temp_npctype_data->handtexture = atoi(row[94]);
temp_npctype_data->legtexture = atoi(row[95]); temp_npctype_data->legtexture = atoi(row[95]);
temp_npctype_data->feettexture = atoi(row[96]); temp_npctype_data->feettexture = atoi(row[96]);
temp_npctype_data->ignore_despawn = atoi(row[97]) == 1 ? true : false;
// If NPC with duplicate NPC id already in table, // If NPC with duplicate NPC id already in table,
// free item we attempted to add. // free item we attempted to add.

View File

@ -132,6 +132,7 @@ struct NPCType
uint8 handtexture; uint8 handtexture;
uint8 legtexture; uint8 legtexture;
uint8 feettexture; uint8 feettexture;
bool ignore_despawn;
}; };
namespace player_lootitem { namespace player_lootitem {