Merge pull request #890 from noudess/spawn2

Allow single spawn2 locations to filter based on condition (in spawn-entry).
This commit is contained in:
Chris Miles 2019-09-03 04:26:53 -05:00 committed by GitHub
commit eb4592c3ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 46 additions and 21 deletions

View File

@ -31,7 +31,7 @@
*/ */
#define CURRENT_BINARY_DATABASE_VERSION 9141 #define CURRENT_BINARY_DATABASE_VERSION 9142
#ifdef BOTS #ifdef BOTS
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9025 #define CURRENT_BINARY_BOTS_DATABASE_VERSION 9025

View File

@ -395,6 +395,7 @@
9139|2019_03_25_optional_npc_model.sql|SHOW COLUMNS FROM `npc_types` LIKE 'model'|empty| 9139|2019_03_25_optional_npc_model.sql|SHOW COLUMNS FROM `npc_types` LIKE 'model'|empty|
9140|2019_07_03_update_range.sql|SHOW COLUMNS FROM `zone` LIKE 'max_movement_update_range'|empty| 9140|2019_07_03_update_range.sql|SHOW COLUMNS FROM `zone` LIKE 'max_movement_update_range'|empty|
9141|2019_07_10_npc_flymode.sql|SHOW COLUMNS FROM `npc_types` LIKE 'flymode'|empty| 9141|2019_07_10_npc_flymode.sql|SHOW COLUMNS FROM `npc_types` LIKE 'flymode'|empty|
9142|2019_09_02_required_spawn_filter.sql|SHOW COLUMNS FROM `spawnentry` LIKE 'condition_value_filter'|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 `spawnentry` ADD COLUMN `condition_value_filter` MEDIUMINT(9) NOT NULL DEFAULT '1' AFTER `chance`;

View File

@ -258,7 +258,16 @@ Mob *QuestManager::spawn_from_spawn2(uint32 spawn2_id)
return nullptr; return nullptr;
} }
} }
uint32 npcid = spawn_group->GetNPCType();
uint16 condition_value=1;
uint16 condition_id=found_spawn->GetSpawnCondition();
if (condition_id > 0) {
condition_value = zone->spawn_conditions.GetCondition(zone->GetShortName(), zone->GetInstanceID(), condition_id);
}
uint32 npcid = spawn_group->GetNPCType(condition_value);
if (npcid == 0) { if (npcid == 0) {
return nullptr; return nullptr;
} }

View File

@ -184,12 +184,18 @@ bool Spawn2::Process() {
return false; return false;
} }
uint16 condition_value=1;
if (condition_id > 0) {
condition_value = zone->spawn_conditions.GetCondition(zone->GetShortName(), zone->GetInstanceID(), condition_id);
}
//have the spawn group pick an NPC for us //have the spawn group pick an NPC for us
uint32 npcid = spawn_group->GetNPCType(); uint32 npcid = spawn_group->GetNPCType(condition_value);
if (npcid == 0) { if (npcid == 0) {
Log(Logs::Detail, Log(Logs::Detail,
Logs::Spawns, Logs::Spawns,
"Spawn2 %d: Spawn group %d did not yeild an NPC! not spawning.", "Spawn2 %d: Spawn group %d did not yield an NPC! not spawning.",
spawn2_id, spawn2_id,
spawngroup_id_); spawngroup_id_);
@ -202,7 +208,7 @@ bool Spawn2::Process() {
if (tmp == nullptr) { if (tmp == nullptr) {
Log(Logs::Detail, Log(Logs::Detail,
Logs::Spawns, Logs::Spawns,
"Spawn2 %d: Spawn group %d yeilded an invalid NPC type %d", "Spawn2 %d: Spawn group %d yielded an invalid NPC type %d",
spawn2_id, spawn2_id,
spawngroup_id_, spawngroup_id_,
npcid); npcid);
@ -214,7 +220,7 @@ bool Spawn2::Process() {
if (!entity_list.LimitCheckName(tmp->name)) { if (!entity_list.LimitCheckName(tmp->name)) {
Log(Logs::Detail, Log(Logs::Detail,
Logs::Spawns, Logs::Spawns,
"Spawn2 %d: Spawn group %d yeilded NPC type %d, which is unique and one already exists.", "Spawn2 %d: Spawn group %d yielded NPC type %d, which is unique and one already exists.",
spawn2_id, spawn2_id,
spawngroup_id_, spawngroup_id_,
npcid); npcid);
@ -227,7 +233,7 @@ bool Spawn2::Process() {
if (!entity_list.LimitCheckType(npcid, tmp->spawn_limit)) { if (!entity_list.LimitCheckType(npcid, tmp->spawn_limit)) {
Log(Logs::Detail, Log(Logs::Detail,
Logs::Spawns, Logs::Spawns,
"Spawn2 %d: Spawn group %d yeilded NPC type %d, which is over its spawn limit (%d)", "Spawn2 %d: Spawn group %d yielded NPC type %d, which is over its spawn limit (%d)",
spawn2_id, spawn2_id,
spawngroup_id_, spawngroup_id_,
npcid, npcid,
@ -881,19 +887,19 @@ void SpawnConditionManager::ExecEvent(SpawnEvent &event, bool send_update) {
break; break;
case SpawnEvent::ActionAdd: case SpawnEvent::ActionAdd:
new_value += event.argument; new_value += event.argument;
Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Adding %d to condition %d, yeilding %d.", event.id, event.argument, event.condition_id, new_value); Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Adding %d to condition %d, yielding %d.", event.id, event.argument, event.condition_id, new_value);
break; break;
case SpawnEvent::ActionSubtract: case SpawnEvent::ActionSubtract:
new_value -= event.argument; new_value -= event.argument;
Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Subtracting %d from condition %d, yeilding %d.", event.id, event.argument, event.condition_id, new_value); Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Subtracting %d from condition %d, yielding %d.", event.id, event.argument, event.condition_id, new_value);
break; break;
case SpawnEvent::ActionMultiply: case SpawnEvent::ActionMultiply:
new_value *= event.argument; new_value *= event.argument;
Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Multiplying condition %d by %d, yeilding %d.", event.id, event.condition_id, event.argument, new_value); Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Multiplying condition %d by %d, yielding %d.", event.id, event.condition_id, event.argument, new_value);
break; break;
case SpawnEvent::ActionDivide: case SpawnEvent::ActionDivide:
new_value /= event.argument; new_value /= event.argument;
Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Dividing condition %d by %d, yeilding %d.", event.id, event.condition_id, event.argument, new_value); Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Dividing condition %d by %d, yielding %d.", event.id, event.condition_id, event.argument, new_value);
break; break;
default: default:
Log(Logs::Detail, Logs::Spawns, "Event %d: Invalid event action type %d", event.id, event.action); Log(Logs::Detail, Logs::Spawns, "Event %d: Invalid event action type %d", event.id, event.action);

View File

@ -28,11 +28,12 @@
extern EntityList entity_list; extern EntityList entity_list;
extern Zone *zone; extern Zone *zone;
SpawnEntry::SpawnEntry(uint32 in_NPCType, int in_chance, uint8 in_npc_spawn_limit) SpawnEntry::SpawnEntry(uint32 in_NPCType, int in_chance, uint16 in_filter, uint8 in_npc_spawn_limit)
{ {
NPCType = in_NPCType; NPCType = in_NPCType;
chance = in_chance; chance = in_chance;
npc_spawn_limit = in_npc_spawn_limit; condition_value_filter = in_filter;
npc_spawn_limit = in_npc_spawn_limit;
} }
SpawnGroup::SpawnGroup( SpawnGroup::SpawnGroup(
@ -64,7 +65,7 @@ SpawnGroup::SpawnGroup(
despawn_timer = despawn_timer_in; despawn_timer = despawn_timer_in;
} }
uint32 SpawnGroup::GetNPCType() uint32 SpawnGroup::GetNPCType(uint16 in_filter)
{ {
#if EQDEBUG >= 10 #if EQDEBUG >= 10
Log(Logs::General, Logs::None, "SpawnGroup[%08x]::GetNPCType()", (uint32) this); Log(Logs::General, Logs::None, "SpawnGroup[%08x]::GetNPCType()", (uint32) this);
@ -87,6 +88,9 @@ uint32 SpawnGroup::GetNPCType()
continue; continue;
} }
if (se->condition_value_filter != in_filter)
continue;
totalchance += se->chance; totalchance += se->chance;
possible.push_back(se); possible.push_back(se);
} }
@ -94,7 +98,6 @@ uint32 SpawnGroup::GetNPCType()
return 0; return 0;
} }
int32 roll = 0; int32 roll = 0;
roll = zone->random.Int(0, totalchance - 1); roll = zone->random.Int(0, totalchance - 1);
@ -242,6 +245,7 @@ bool ZoneDatabase::LoadSpawnGroups(const char *zone_name, uint16 version, SpawnG
spawnentry.spawngroupID, spawnentry.spawngroupID,
npcid, npcid,
chance, chance,
condition_value_filter,
npc_types.spawn_limit npc_types.spawn_limit
AS sl AS sl
FROM FROM
@ -266,7 +270,8 @@ bool ZoneDatabase::LoadSpawnGroups(const char *zone_name, uint16 version, SpawnG
auto new_spawn_entry = new SpawnEntry( auto new_spawn_entry = new SpawnEntry(
atoi(row[1]), atoi(row[1]),
atoi(row[2]), atoi(row[2]),
(row[3] ? atoi(row[3]) : 0) atoi(row[3]),
(row[4] ? atoi(row[4]) : 0)
); );
SpawnGroup *spawn_group = spawn_group_list->GetSpawnGroup(atoi(row[0])); SpawnGroup *spawn_group = spawn_group_list->GetSpawnGroup(atoi(row[0]));
@ -342,6 +347,7 @@ bool ZoneDatabase::LoadSpawnGroupsByID(int spawn_group_id, SpawnGroupList *spawn
(spawnentry.spawngroupID), (spawnentry.spawngroupID),
spawnentry.npcid, spawnentry.npcid,
spawnentry.chance, spawnentry.chance,
spawnentry.condition_value_filter,
spawngroup.spawn_limit spawngroup.spawn_limit
FROM FROM
spawnentry, spawnentry,
@ -362,7 +368,8 @@ bool ZoneDatabase::LoadSpawnGroupsByID(int spawn_group_id, SpawnGroupList *spawn
auto new_spawn_entry = new SpawnEntry( auto new_spawn_entry = new SpawnEntry(
atoi(row[1]), atoi(row[1]),
atoi(row[2]), atoi(row[2]),
(row[3] ? atoi(row[3]) : 0) atoi(row[3]),
(row[4] ? atoi(row[4]) : 0)
); );
SpawnGroup *spawn_group = spawn_group_list->GetSpawnGroup(atoi(row[0])); SpawnGroup *spawn_group = spawn_group_list->GetSpawnGroup(atoi(row[0]));

View File

@ -25,10 +25,11 @@
class SpawnEntry { class SpawnEntry {
public: public:
SpawnEntry(uint32 in_NPCType, int in_chance, uint8 in_npc_spawn_limit); SpawnEntry(uint32 in_NPCType, int in_chance, uint16 in_filter, uint8 in_npc_spawn_limit);
~SpawnEntry() {} ~SpawnEntry() {}
uint32 NPCType; uint32 NPCType;
int chance; int chance;
uint16 condition_value_filter;
//this is a cached value from npc_types, for speed //this is a cached value from npc_types, for speed
uint8 npc_spawn_limit; //max # of this entry which can be spawned in this zone uint8 npc_spawn_limit; //max # of this entry which can be spawned in this zone
@ -52,7 +53,7 @@ public:
); );
~SpawnGroup(); ~SpawnGroup();
uint32 GetNPCType(); uint32 GetNPCType(uint16 condition_value_filter=1);
void AddSpawnEntry(SpawnEntry *newEntry); void AddSpawnEntry(SpawnEntry *newEntry);
uint32 id; uint32 id;
float roamdist; float roamdist;