Skip to content

Commit

Permalink
Add multiquest_enabled flag to NPCs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinglykrab authored and Akkadius committed Oct 20, 2024
1 parent 682e8e8 commit 06fc61b
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 5 deletions.
11 changes: 11 additions & 0 deletions common/database/database_update_manifest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5758,6 +5758,17 @@ ALTER TABLE `inventory_snapshots`
ALTER TABLE `character_exp_modifiers`
MODIFY COLUMN `aa_modifier` float NOT NULL DEFAULT 1.0 AFTER `instance_version`,
MODIFY COLUMN `exp_modifier` float NOT NULL DEFAULT 1.0 AFTER `aa_modifier`;
)"
},
ManifestEntry{
.version = 9285,
.description = "2024_10_15_npc_types_multiquest_enabled.sql",
.check = "SHOW COLUMNS FROM `npc_types` LIKE 'multiquest_enabled'",
.condition = "empty",
.match = "",
.sql = R"(
ALTER TABLE `npc_types`
ADD COLUMN `multiquest_enabled` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 AFTER `is_parcel_merchant`;
)"
}
// -- template; copy/paste this when you need to create a new entry
Expand Down
12 changes: 12 additions & 0 deletions common/repositories/base/base_npc_types_repository.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class BaseNpcTypesRepository {
int32_t faction_amount;
uint8_t keeps_sold_items;
uint8_t is_parcel_merchant;
uint8_t multiquest_enabled;
};

static std::string PrimaryKey()
Expand Down Expand Up @@ -287,6 +288,7 @@ class BaseNpcTypesRepository {
"faction_amount",
"keeps_sold_items",
"is_parcel_merchant",
"multiquest_enabled",
};
}

Expand Down Expand Up @@ -422,6 +424,7 @@ class BaseNpcTypesRepository {
"faction_amount",
"keeps_sold_items",
"is_parcel_merchant",
"multiquest_enabled",
};
}

Expand Down Expand Up @@ -591,6 +594,7 @@ class BaseNpcTypesRepository {
e.faction_amount = 0;
e.keeps_sold_items = 1;
e.is_parcel_merchant = 0;
e.multiquest_enabled = 0;

return e;
}
Expand Down Expand Up @@ -756,6 +760,7 @@ class BaseNpcTypesRepository {
e.faction_amount = row[126] ? static_cast<int32_t>(atoi(row[126])) : 0;
e.keeps_sold_items = row[127] ? static_cast<uint8_t>(strtoul(row[127], nullptr, 10)) : 1;
e.is_parcel_merchant = row[128] ? static_cast<uint8_t>(strtoul(row[128], nullptr, 10)) : 0;
e.multiquest_enabled = row[129] ? static_cast<uint8_t>(strtoul(row[129], nullptr, 10)) : 0;

return e;
}
Expand Down Expand Up @@ -917,6 +922,7 @@ class BaseNpcTypesRepository {
v.push_back(columns[126] + " = " + std::to_string(e.faction_amount));
v.push_back(columns[127] + " = " + std::to_string(e.keeps_sold_items));
v.push_back(columns[128] + " = " + std::to_string(e.is_parcel_merchant));
v.push_back(columns[129] + " = " + std::to_string(e.multiquest_enabled));

auto results = db.QueryDatabase(
fmt::format(
Expand Down Expand Up @@ -1067,6 +1073,7 @@ class BaseNpcTypesRepository {
v.push_back(std::to_string(e.faction_amount));
v.push_back(std::to_string(e.keeps_sold_items));
v.push_back(std::to_string(e.is_parcel_merchant));
v.push_back(std::to_string(e.multiquest_enabled));

auto results = db.QueryDatabase(
fmt::format(
Expand Down Expand Up @@ -1225,6 +1232,7 @@ class BaseNpcTypesRepository {
v.push_back(std::to_string(e.faction_amount));
v.push_back(std::to_string(e.keeps_sold_items));
v.push_back(std::to_string(e.is_parcel_merchant));
v.push_back(std::to_string(e.multiquest_enabled));

insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
Expand Down Expand Up @@ -1387,6 +1395,7 @@ class BaseNpcTypesRepository {
e.faction_amount = row[126] ? static_cast<int32_t>(atoi(row[126])) : 0;
e.keeps_sold_items = row[127] ? static_cast<uint8_t>(strtoul(row[127], nullptr, 10)) : 1;
e.is_parcel_merchant = row[128] ? static_cast<uint8_t>(strtoul(row[128], nullptr, 10)) : 0;
e.multiquest_enabled = row[129] ? static_cast<uint8_t>(strtoul(row[129], nullptr, 10)) : 0;

all_entries.push_back(e);
}
Expand Down Expand Up @@ -1540,6 +1549,7 @@ class BaseNpcTypesRepository {
e.faction_amount = row[126] ? static_cast<int32_t>(atoi(row[126])) : 0;
e.keeps_sold_items = row[127] ? static_cast<uint8_t>(strtoul(row[127], nullptr, 10)) : 1;
e.is_parcel_merchant = row[128] ? static_cast<uint8_t>(strtoul(row[128], nullptr, 10)) : 0;
e.multiquest_enabled = row[129] ? static_cast<uint8_t>(strtoul(row[129], nullptr, 10)) : 0;

all_entries.push_back(e);
}
Expand Down Expand Up @@ -1743,6 +1753,7 @@ class BaseNpcTypesRepository {
v.push_back(std::to_string(e.faction_amount));
v.push_back(std::to_string(e.keeps_sold_items));
v.push_back(std::to_string(e.is_parcel_merchant));
v.push_back(std::to_string(e.multiquest_enabled));

auto results = db.QueryDatabase(
fmt::format(
Expand Down Expand Up @@ -1894,6 +1905,7 @@ class BaseNpcTypesRepository {
v.push_back(std::to_string(e.faction_amount));
v.push_back(std::to_string(e.keeps_sold_items));
v.push_back(std::to_string(e.is_parcel_merchant));
v.push_back(std::to_string(e.multiquest_enabled));

insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
Expand Down
2 changes: 1 addition & 1 deletion common/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
*/

#define CURRENT_BINARY_DATABASE_VERSION 9284
#define CURRENT_BINARY_DATABASE_VERSION 9285
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9045

#endif
Expand Down
1 change: 1 addition & 0 deletions zone/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ NPC::NPC(const NPCType *npc_type_data, Spawn2 *in_respawn, const glm::vec4 &posi
ATK = npc_type_data->ATK;
heroic_strikethrough = npc_type_data->heroic_strikethrough;
keeps_sold_items = npc_type_data->keeps_sold_items;
multiquest_enabled = npc_type_data->multiquest_enabled;

// used for when switch back to charm
default_ac = npc_type_data->AC;
Expand Down
6 changes: 3 additions & 3 deletions zone/npc.h
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,8 @@ class NPC : public Mob

bool CanPetTakeItem(const EQ::ItemInstance *inst);

bool IsMultiQuest() { return m_is_multiquest_npc; }
void SetMultiQuest(bool b) { m_is_multiquest_npc = b; }
bool IsMultiQuest() { return multiquest_enabled; }
void SetMultiQuest(bool b) { multiquest_enabled = b; }

protected:

Expand Down Expand Up @@ -705,7 +705,7 @@ class NPC : public Mob
bool raid_target;
bool ignore_despawn; //NPCs with this set to 1 will ignore the despawn value in spawngroup

bool m_is_multiquest_npc;
bool multiquest_enabled;

private:
uint32 m_loottable_id;
Expand Down
1 change: 1 addition & 0 deletions zone/zonedb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1905,6 +1905,7 @@ const NPCType *ZoneDatabase::LoadNPCTypesData(uint32 npc_type_id, bool bulk_load
t->heroic_strikethrough = n.heroic_strikethrough;
t->faction_amount = n.faction_amount;
t->keeps_sold_items = n.keeps_sold_items;
t->multiquest_enabled = n.multiquest_enabled != 0;

// If NPC with duplicate NPC id already in table,
// free item we attempted to add.
Expand Down
3 changes: 2 additions & 1 deletion zone/zonedump.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ struct NPCType
int heroic_strikethrough;
bool keeps_sold_items;
bool is_parcel_merchant;
uint8 greed;
uint8 greed;
bool multiquest_enabled;
};

#pragma pack()
Expand Down

0 comments on commit 06fc61b

Please sign in to comment.