From bf3593a60dbc152f935780ec572b74ee00e25251 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 23 Feb 2021 09:50:38 -0800 Subject: [PATCH] [Experience] Add exp mod to npc types to let a server op change the exp modifier (#1252) * Add exp mod to npc types to let a server op change the exp modifier a npc gives (useful for custom content) * Updated version.h --- common/version.h | 2 +- utils/sql/db_update_manifest.txt | 1 + utils/sql/git/required/2021_02_14_npc_exp_mod.sql | 1 + zone/exp.cpp | 10 +++++++++- zone/mob.h | 1 + zone/npc.h | 8 +++++--- zone/zonedb.cpp | 4 +++- zone/zonedump.h | 1 + 8 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 utils/sql/git/required/2021_02_14_npc_exp_mod.sql diff --git a/common/version.h b/common/version.h index d6647f2c1..9bdfa1984 100644 --- a/common/version.h +++ b/common/version.h @@ -34,7 +34,7 @@ * Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt */ -#define CURRENT_BINARY_DATABASE_VERSION 9159 +#define CURRENT_BINARY_DATABASE_VERSION 9160 #ifdef BOTS #define CURRENT_BINARY_BOTS_DATABASE_VERSION 9027 diff --git a/utils/sql/db_update_manifest.txt b/utils/sql/db_update_manifest.txt index bdc41a337..d02536a2b 100644 --- a/utils/sql/db_update_manifest.txt +++ b/utils/sql/db_update_manifest.txt @@ -413,6 +413,7 @@ 9157|2020_09_02_pet_taunting.sql|SHOW COLUMNS from `character_pet_info` LIKE 'taunting'|empty| 9158|2020_12_09_underworld.sql|SHOW COLUMNS from `zone` LIKE 'underworld_teleport_index'|empty| 9159|2020_12_22_expedition_system.sql|SELECT * FROM db_version WHERE version >= 9159|empty| +9160|2021_02_14_npc_exp_mod.sql|SHOW COLUMNS from `npc_types` LIKE 'exp_mod'|empty| # Upgrade conditions: # This won't be needed after this system is implemented, but it is used database that are not diff --git a/utils/sql/git/required/2021_02_14_npc_exp_mod.sql b/utils/sql/git/required/2021_02_14_npc_exp_mod.sql new file mode 100644 index 000000000..8cd8372e2 --- /dev/null +++ b/utils/sql/git/required/2021_02_14_npc_exp_mod.sql @@ -0,0 +1 @@ +ALTER TABLE `npc_types` ADD COLUMN `exp_mod` INT NOT NULL DEFAULT '100' AFTER `always_aggro`; diff --git a/zone/exp.cpp b/zone/exp.cpp index f6c682b21..608a7c4ad 100644 --- a/zone/exp.cpp +++ b/zone/exp.cpp @@ -215,7 +215,15 @@ uint32 Client::GetExperienceForKill(Mob *against) if (against && against->IsNPC()) { uint32 level = (uint32)against->GetLevel(); - return EXP_FORMULA; + uint32 ret = EXP_FORMULA; + + auto mod = against->GetKillExpMod(); + if(mod >= 0) { + ret *= mod; + ret /= 100; + } + + return ret; } return 0; diff --git a/zone/mob.h b/zone/mob.h index e3fe058d9..69f487c5d 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -695,6 +695,7 @@ public: bool PlotPositionOnArcInFrontOfTarget(Mob *target, float &x_dest, float &y_dest, float &z_dest, float distance, float min_deg = 5.0f, float max_deg = 150.0f); bool PlotPositionOnArcBehindTarget(Mob *target, float &x_dest, float &y_dest, float &z_dest, float distance); bool PlotPositionBehindMeFacingTarget(Mob *target, float &x_dest, float &y_dest, float &z_dest, float min_dist = 1.0f, float max_dist = 5.0f); + virtual int GetKillExpMod() const { return 100; } // aura functions void MakeAura(uint16 spell_id); diff --git a/zone/npc.h b/zone/npc.h index 271b6549a..92e6b6775 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -422,10 +422,12 @@ public: void SetCombatEvent(bool b) { combat_event = b; } /* Only allows players that killed corpse to loot */ - const bool HasPrivateCorpse() const { return NPCTypedata->private_corpse; } + const bool HasPrivateCorpse() const { return NPCTypedata_ours ? NPCTypedata_ours->private_corpse : NPCTypedata->private_corpse; } - virtual const bool IsUnderwaterOnly() const { return NPCTypedata->underwater; } - const char* GetRawNPCTypeName() const { return NPCTypedata->name; } + virtual const bool IsUnderwaterOnly() const { return NPCTypedata_ours ? NPCTypedata_ours->underwater : NPCTypedata->underwater; } + const char* GetRawNPCTypeName() const { return NPCTypedata_ours ? NPCTypedata_ours->name : NPCTypedata->name; } + + virtual int GetKillExpMod() const { return NPCTypedata_ours ? NPCTypedata_ours->exp_mod : NPCTypedata->exp_mod; } void ChangeLastName(const char* in_lastname); void ClearLastName(); diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index bbd929450..447d75ba2 100755 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -2525,7 +2525,8 @@ const NPCType *ZoneDatabase::LoadNPCTypesData(uint32 npc_type_id, bool bulk_load "npc_types.stuck_behavior, " "npc_types.model, " "npc_types.flymode, " - "npc_types.always_aggro " + "npc_types.always_aggro, " + "npc_types.exp_mod " "FROM npc_types %s", where_condition.c_str() ); @@ -2728,6 +2729,7 @@ const NPCType *ZoneDatabase::LoadNPCTypesData(uint32 npc_type_id, bool bulk_load temp_npctype_data->use_model = atoi(row[110]); temp_npctype_data->flymode = atoi(row[111]); temp_npctype_data->always_aggro = atoi(row[112]); + temp_npctype_data->exp_mod = atoi(row[113]); temp_npctype_data->skip_auto_scale = false; // hardcoded here for now diff --git a/zone/zonedump.h b/zone/zonedump.h index a30ec9f5f..09f11b65b 100644 --- a/zone/zonedump.h +++ b/zone/zonedump.h @@ -148,6 +148,7 @@ struct NPCType uint16 use_model; int8 flymode; bool always_aggro; + int exp_mod; }; namespace player_lootitem {