mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 03:08:26 +00:00
[Spawn] (imported from takp) Added min_time and max_time to spawnentry. This will prevent a NPC from… (#3685)
* Added mintime and maxtime to spawnentry. This will prevent a NPC from spawning outside of the times specified. NPCs spawned in this way will then behave like normal NPCs. They will not despawn on their own, unlike spawn_events/spawn_conditions. NPCs using this that are alone in their spawngroup will attempt to spawn after their respawn timer has expired if the time of day is outside their range. Otherwise, another NPC in the spawngroup will be chosen to spawn. The normal rules (chance, spawn_limit) still apply to these NPCs, this is just another rule added to the system. mintime and maxtime both represent the in-game EQ Hour. Valid values are 1-24. If either or both of the values are 0, then the NPC will not have any time restriction. Added a new rule World:BootHour. This allows server admins to specify the EQ hour the server will boot to. Valid options are 1-24. Setting this rule to 0 (default) disables it and world will use whatever time is specified in the DB. * generated base_spawnentry_repository.h from script * removed the rule insert from database_update_manifest.cpp. * Add logging, initializers, minor cleanup * Remove if/else branch * Update eqtime.cpp * Initializers, logging --------- Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
+1
-1
@@ -1440,7 +1440,7 @@ void PerlembParser::ExportZoneVariables(std::string &package_name)
|
||||
ExportVar(package_name.c_str(), "zonesn", zone->GetShortName());
|
||||
ExportVar(package_name.c_str(), "instanceid", zone->GetInstanceID());
|
||||
ExportVar(package_name.c_str(), "instanceversion", zone->GetInstanceVersion());
|
||||
TimeOfDay_Struct eqTime;
|
||||
TimeOfDay_Struct eqTime{};
|
||||
zone->zone_time.GetCurrentEQTimeOfDay(time(0), &eqTime);
|
||||
ExportVar(package_name.c_str(), "zonehour", eqTime.hour - 1);
|
||||
ExportVar(package_name.c_str(), "zonemin", eqTime.minute);
|
||||
|
||||
@@ -14,14 +14,14 @@ void SetDate(Client *c, const Seperator *sep)
|
||||
return;
|
||||
}
|
||||
|
||||
TimeOfDay_Struct eq_time;
|
||||
zone->zone_time.GetCurrentEQTimeOfDay(time(0), &eq_time);
|
||||
TimeOfDay_Struct t{};
|
||||
zone->zone_time.GetCurrentEQTimeOfDay(time(0), &t);
|
||||
|
||||
const uint16 year = Strings::ToUnsignedInt(sep->arg[2]);
|
||||
const uint8 month = Strings::ToUnsignedInt(sep->arg[3]);
|
||||
const uint8 day = Strings::ToUnsignedInt(sep->arg[4]);
|
||||
const uint8 hour = !sep->IsNumber(5) ? eq_time.hour : Strings::ToUnsignedInt(sep->arg[5]) + 1;
|
||||
const uint8 minute = !sep->IsNumber(6) ? eq_time.minute : Strings::ToUnsignedInt(sep->arg[6]);
|
||||
const uint8 hour = !sep->IsNumber(5) ? t.hour : Strings::ToUnsignedInt(sep->arg[5]) + 1;
|
||||
const uint8 minute = !sep->IsNumber(6) ? t.minute : Strings::ToUnsignedInt(sep->arg[6]);
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
|
||||
@@ -6,7 +6,7 @@ void SetTime(Client *c, const Seperator *sep)
|
||||
if (arguments < 2 || !sep->IsNumber(2)) {
|
||||
c->Message(Chat::White, "Usage: #set time [Hour] [Minute]");
|
||||
|
||||
TimeOfDay_Struct world_time;
|
||||
TimeOfDay_Struct world_time{};
|
||||
zone->zone_time.GetCurrentEQTimeOfDay(time(0), &world_time);
|
||||
|
||||
auto time_string = fmt::format(
|
||||
|
||||
@@ -1273,7 +1273,7 @@ int lua_get_zone_weather() {
|
||||
}
|
||||
|
||||
luabind::adl::object lua_get_zone_time(lua_State *L) {
|
||||
TimeOfDay_Struct eqTime;
|
||||
TimeOfDay_Struct eqTime{};
|
||||
zone->zone_time.GetCurrentEQTimeOfDay(time(0), &eqTime);
|
||||
|
||||
luabind::adl::object ret = luabind::newtable(L);
|
||||
|
||||
+3
-3
@@ -692,7 +692,7 @@ void SpawnConditionManager::Process() {
|
||||
//check each spawn event.
|
||||
|
||||
//get our current time
|
||||
TimeOfDay_Struct tod;
|
||||
TimeOfDay_Struct tod{};
|
||||
zone->zone_time.GetCurrentEQTimeOfDay(&tod);
|
||||
|
||||
//see if time is past our nearest event.
|
||||
@@ -745,7 +745,7 @@ void SpawnConditionManager::ExecEvent(SpawnEvent &event, bool send_update) {
|
||||
return; //unable to find the spawn condition to operate on
|
||||
}
|
||||
|
||||
TimeOfDay_Struct tod;
|
||||
TimeOfDay_Struct tod{};
|
||||
zone->zone_time.GetCurrentEQTimeOfDay(&tod);
|
||||
if(event.strict && (event.next.hour != tod.hour || event.next.day != tod.day || event.next.month != tod.month || event.next.year != tod.year))
|
||||
{
|
||||
@@ -956,7 +956,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in
|
||||
//spawn points which get turned on. Im too lazy to figure out a
|
||||
//better solution, and I just dont care thats much.
|
||||
//get our current time
|
||||
TimeOfDay_Struct tod;
|
||||
TimeOfDay_Struct tod{};
|
||||
zone->zone_time.GetCurrentEQTimeOfDay(&tod);
|
||||
|
||||
for(auto cur = spawn_events.begin(); cur != spawn_events.end(); ++cur) {
|
||||
|
||||
+27
-9
@@ -29,12 +29,13 @@
|
||||
extern EntityList entity_list;
|
||||
extern Zone *zone;
|
||||
|
||||
SpawnEntry::SpawnEntry(uint32 in_NPCType, int in_chance, uint16 in_filter, uint8 in_npc_spawn_limit)
|
||||
{
|
||||
SpawnEntry::SpawnEntry(uint32 in_NPCType, int in_chance, uint16 in_filter, uint8 in_npc_spawn_limit, uint8 in_min_time, uint8 in_max_time) {
|
||||
NPCType = in_NPCType;
|
||||
chance = in_chance;
|
||||
condition_value_filter = in_filter;
|
||||
npc_spawn_limit = in_npc_spawn_limit;
|
||||
min_time = in_min_time;
|
||||
max_time = in_max_time;
|
||||
}
|
||||
|
||||
SpawnGroup::SpawnGroup(
|
||||
@@ -85,8 +86,15 @@ uint32 SpawnGroup::GetNPCType(uint16 in_filter)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (se->condition_value_filter != in_filter)
|
||||
if (se->min_time != 0 && se->max_time != 0 && se->min_time <= 24 && se->max_time <= 24) {
|
||||
if (!zone->zone_time.IsInbetweenTime(se->min_time, se->max_time)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (se->condition_value_filter != in_filter) {
|
||||
continue;
|
||||
}
|
||||
|
||||
totalchance += se->chance;
|
||||
possible.push_back(se);
|
||||
@@ -224,7 +232,9 @@ bool ZoneDatabase::LoadSpawnGroups(const char *zone_name, uint16 version, SpawnG
|
||||
chance,
|
||||
condition_value_filter,
|
||||
npc_types.spawn_limit
|
||||
AS sl
|
||||
AS sl,
|
||||
min_time,
|
||||
max_time
|
||||
FROM
|
||||
spawnentry,
|
||||
spawn2,
|
||||
@@ -251,7 +261,9 @@ bool ZoneDatabase::LoadSpawnGroups(const char *zone_name, uint16 version, SpawnG
|
||||
Strings::ToInt(row[1]),
|
||||
Strings::ToInt(row[2]),
|
||||
Strings::ToInt(row[3]),
|
||||
(row[4] ? Strings::ToInt(row[4]) : 0)
|
||||
(row[4] ? Strings::ToInt(row[4]) : 0),
|
||||
Strings::ToInt(row[5]),
|
||||
Strings::ToInt(row[6])
|
||||
);
|
||||
|
||||
SpawnGroup *spawn_group = spawn_group_list->GetSpawnGroup(Strings::ToInt(row[0]));
|
||||
@@ -340,7 +352,9 @@ bool ZoneDatabase::LoadSpawnGroupsByID(int spawn_group_id, SpawnGroupList *spawn
|
||||
spawnentry.npcid,
|
||||
spawnentry.chance,
|
||||
spawnentry.condition_value_filter,
|
||||
spawngroup.spawn_limit
|
||||
spawngroup.spawn_limit,
|
||||
spawnentry.min_time,
|
||||
spawnentry.max_time
|
||||
FROM
|
||||
spawnentry,
|
||||
spawngroup
|
||||
@@ -361,16 +375,20 @@ bool ZoneDatabase::LoadSpawnGroupsByID(int spawn_group_id, SpawnGroupList *spawn
|
||||
Strings::ToInt(row[1]),
|
||||
Strings::ToInt(row[2]),
|
||||
Strings::ToInt(row[3]),
|
||||
(row[4] ? Strings::ToInt(row[4]) : 0)
|
||||
(row[4] ? Strings::ToInt(row[4]) : 0),
|
||||
Strings::ToInt(row[5]),
|
||||
Strings::ToInt(row[6])
|
||||
);
|
||||
|
||||
LogSpawnsDetail(
|
||||
"Loading spawn_entry spawn_group_id [{}] npc_id [{}] chance [{}] condition_value_filter [{}] spawn_limit [{}]",
|
||||
"Loading spawn_entry spawn_group_id [{}] npc_id [{}] chance [{}] condition_value_filter [{}] spawn_limit [{}] min_time [{}] max_time [{}] ",
|
||||
row[0],
|
||||
row[1],
|
||||
row[2],
|
||||
row[3],
|
||||
row[4]
|
||||
row[4],
|
||||
row[5],
|
||||
row[6]
|
||||
);
|
||||
|
||||
SpawnGroup *spawn_group = spawn_group_list->GetSpawnGroup(Strings::ToInt(row[0]));
|
||||
|
||||
+3
-1
@@ -26,10 +26,12 @@
|
||||
|
||||
class SpawnEntry {
|
||||
public:
|
||||
SpawnEntry(uint32 in_NPCType, int in_chance, uint16 in_filter, uint8 in_npc_spawn_limit);
|
||||
SpawnEntry(uint32 in_NPCType, int in_chance, uint16 in_filter, uint8 in_npc_spawn_limit, uint8 in_min_time, uint8 in_max_time);
|
||||
~SpawnEntry() {}
|
||||
uint32 NPCType;
|
||||
int chance;
|
||||
uint8 min_time;
|
||||
uint8 max_time;
|
||||
uint16 condition_value_filter;
|
||||
|
||||
//this is a cached value from npc_types, for speed
|
||||
|
||||
@@ -965,7 +965,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
|
||||
char time_message[255];
|
||||
time_t current_time = time(nullptr);
|
||||
TimeOfDay_Struct eq_time;
|
||||
TimeOfDay_Struct eq_time{};
|
||||
zone->zone_time.GetCurrentEQTimeOfDay(current_time, &eq_time);
|
||||
|
||||
sprintf(time_message, "EQTime [%02d:%s%d %s]",
|
||||
|
||||
Reference in New Issue
Block a user