mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 10:31:29 +00:00
Merge pull request #890 from noudess/spawn2
Allow single spawn2 locations to filter based on condition (in spawn-entry).
This commit is contained in:
commit
eb4592c3ae
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -0,0 +1 @@
|
||||
ALTER TABLE `spawnentry` ADD COLUMN `condition_value_filter` MEDIUMINT(9) NOT NULL DEFAULT '1' AFTER `chance`;
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -184,12 +184,18 @@ 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) {
|
||||
Log(Logs::Detail,
|
||||
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,
|
||||
spawngroup_id_);
|
||||
|
||||
@ -202,7 +208,7 @@ bool Spawn2::Process() {
|
||||
if (tmp == nullptr) {
|
||||
Log(Logs::Detail,
|
||||
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,
|
||||
spawngroup_id_,
|
||||
npcid);
|
||||
@ -214,7 +220,7 @@ bool Spawn2::Process() {
|
||||
if (!entity_list.LimitCheckName(tmp->name)) {
|
||||
Log(Logs::Detail,
|
||||
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,
|
||||
spawngroup_id_,
|
||||
npcid);
|
||||
@ -227,7 +233,7 @@ bool Spawn2::Process() {
|
||||
if (!entity_list.LimitCheckType(npcid, tmp->spawn_limit)) {
|
||||
Log(Logs::Detail,
|
||||
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,
|
||||
spawngroup_id_,
|
||||
npcid,
|
||||
@ -881,19 +887,19 @@ void SpawnConditionManager::ExecEvent(SpawnEvent &event, bool send_update) {
|
||||
break;
|
||||
case SpawnEvent::ActionAdd:
|
||||
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;
|
||||
case SpawnEvent::ActionSubtract:
|
||||
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;
|
||||
case SpawnEvent::ActionMultiply:
|
||||
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;
|
||||
case SpawnEvent::ActionDivide:
|
||||
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;
|
||||
default:
|
||||
Log(Logs::Detail, Logs::Spawns, "Event %d: Invalid event action type %d", event.id, event.action);
|
||||
|
||||
@ -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)
|
||||
{
|
||||
#if EQDEBUG >= 10
|
||||
Log(Logs::General, Logs::None, "SpawnGroup[%08x]::GetNPCType()", (uint32) this);
|
||||
@ -87,6 +88,9 @@ uint32 SpawnGroup::GetNPCType()
|
||||
continue;
|
||||
}
|
||||
|
||||
if (se->condition_value_filter != in_filter)
|
||||
continue;
|
||||
|
||||
totalchance += se->chance;
|
||||
possible.push_back(se);
|
||||
}
|
||||
@ -94,7 +98,6 @@ uint32 SpawnGroup::GetNPCType()
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32 roll = 0;
|
||||
roll = zone->random.Int(0, totalchance - 1);
|
||||
|
||||
@ -242,6 +245,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
|
||||
@ -266,7 +270,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]));
|
||||
@ -342,6 +347,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,
|
||||
@ -362,7 +368,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]));
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user