Merge branch 'master' of https://github.com/EQEmu/Server into lsid

This commit is contained in:
Akkadius 2019-09-03 23:37:57 -05:00
commit fceca6e72f
7 changed files with 42 additions and 17 deletions

View File

@ -31,7 +31,7 @@
*/
#define CURRENT_BINARY_DATABASE_VERSION 9141
#define CURRENT_BINARY_DATABASE_VERSION 9142
#ifdef BOTS
#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|
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|
9142|2019_09_02_required_spawn_filter.sql|SHOW COLUMNS FROM `spawnentry` LIKE 'condition_value_filter'|empty|
# Upgrade conditions:
# 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;
}
}
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) {
return nullptr;
}

View File

@ -176,8 +176,14 @@ bool Spawn2::Process() {
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
uint32 npcid = spawn_group->GetNPCType();
uint32 npcid = spawn_group->GetNPCType(condition_value);
if (npcid == 0) {
LogSpawns("Spawn2 [{}]: Spawn group [{}] did not yeild an NPC! not spawning", spawn2_id, spawngroup_id_);
@ -850,19 +856,19 @@ void SpawnConditionManager::ExecEvent(SpawnEvent &event, bool send_update) {
break;
case SpawnEvent::ActionAdd:
new_value += event.argument;
LogSpawns("Event [{}]: Executing. Adding [{}] to condition [{}], yeilding [{}]", event.id, event.argument, event.condition_id, new_value);
LogSpawns("Event [{}]: Executing. Adding [{}] to condition [{}], yielding [{}]", event.id, event.argument, event.condition_id, new_value);
break;
case SpawnEvent::ActionSubtract:
new_value -= event.argument;
LogSpawns("Event [{}]: Executing. Subtracting [{}] from condition [{}], yeilding [{}]", event.id, event.argument, event.condition_id, new_value);
LogSpawns("Event [{}]: Executing. Subtracting [{}] from condition [{}], yielding [{}]", event.id, event.argument, event.condition_id, new_value);
break;
case SpawnEvent::ActionMultiply:
new_value *= event.argument;
LogSpawns("Event [{}]: Executing. Multiplying condition [{}] by [{}], yeilding [{}]", event.id, event.condition_id, event.argument, new_value);
LogSpawns("Event [{}]: Executing. Multiplying condition [{}] by [{}], yielding [{}]", event.id, event.condition_id, event.argument, new_value);
break;
case SpawnEvent::ActionDivide:
new_value /= event.argument;
LogSpawns("Event [{}]: Executing. Dividing condition [{}] by [{}], yeilding [{}]", event.id, event.condition_id, event.argument, new_value);
LogSpawns("Event [{}]: Executing. Dividing condition [{}] by [{}], yielding [{}]", event.id, event.condition_id, event.argument, new_value);
break;
default:
LogSpawns("Event [{}]: Invalid event action type [{}]", event.id, event.action);

View File

@ -28,11 +28,12 @@
extern EntityList entity_list;
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;
chance = in_chance;
npc_spawn_limit = in_npc_spawn_limit;
NPCType = in_NPCType;
chance = in_chance;
condition_value_filter = in_filter;
npc_spawn_limit = in_npc_spawn_limit;
}
SpawnGroup::SpawnGroup(
@ -64,7 +65,7 @@ SpawnGroup::SpawnGroup(
despawn_timer = despawn_timer_in;
}
uint32 SpawnGroup::GetNPCType()
uint32 SpawnGroup::GetNPCType(uint16 in_filter)
{
int npcType = 0;
int totalchance = 0;
@ -84,6 +85,9 @@ uint32 SpawnGroup::GetNPCType()
continue;
}
if (se->condition_value_filter != in_filter)
continue;
totalchance += se->chance;
possible.push_back(se);
}
@ -91,7 +95,6 @@ uint32 SpawnGroup::GetNPCType()
return 0;
}
int32 roll = 0;
roll = zone->random.Int(0, totalchance - 1);
@ -239,6 +242,7 @@ bool ZoneDatabase::LoadSpawnGroups(const char *zone_name, uint16 version, SpawnG
spawnentry.spawngroupID,
npcid,
chance,
condition_value_filter,
npc_types.spawn_limit
AS sl
FROM
@ -263,7 +267,8 @@ bool ZoneDatabase::LoadSpawnGroups(const char *zone_name, uint16 version, SpawnG
auto new_spawn_entry = new SpawnEntry(
atoi(row[1]),
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]));
@ -339,6 +344,7 @@ bool ZoneDatabase::LoadSpawnGroupsByID(int spawn_group_id, SpawnGroupList *spawn
(spawnentry.spawngroupID),
spawnentry.npcid,
spawnentry.chance,
spawnentry.condition_value_filter,
spawngroup.spawn_limit
FROM
spawnentry,
@ -359,7 +365,8 @@ bool ZoneDatabase::LoadSpawnGroupsByID(int spawn_group_id, SpawnGroupList *spawn
auto new_spawn_entry = new SpawnEntry(
atoi(row[1]),
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]));

View File

@ -25,10 +25,11 @@
class SpawnEntry {
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() {}
uint32 NPCType;
int chance;
uint16 condition_value_filter;
//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
@ -52,7 +53,7 @@ public:
);
~SpawnGroup();
uint32 GetNPCType();
uint32 GetNPCType(uint16 condition_value_filter=1);
void AddSpawnEntry(SpawnEntry *newEntry);
uint32 id;
float roamdist;