From ee618f70ab29df3953dc95f8fe80cd1c3819ebe2 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Fri, 14 Jul 2017 13:49:32 -0400 Subject: [PATCH] Add support for setting cast_time of aura --- utils/sql/git/required/2017_07_xx_aura.sql | 1 + zone/aura.cpp | 29 +++++++++++++++------- zone/zonedb.h | 1 + 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/utils/sql/git/required/2017_07_xx_aura.sql b/utils/sql/git/required/2017_07_xx_aura.sql index ed777d2e5..9437d1c7c 100644 --- a/utils/sql/git/required/2017_07_xx_aura.sql +++ b/utils/sql/git/required/2017_07_xx_aura.sql @@ -9,5 +9,6 @@ CREATE TABLE `auras` ( `movement` INT(10) NOT NULL DEFAULT 0, `duration` INT(10) NOT NULL DEFAULT 5400, `icon` INT(10) NOT NULL DEFAULT -1, + `cast_time` INT(10) NOT NULL DEFAULT 0, PRIMARY KEY(`type`) ) diff --git a/zone/aura.cpp b/zone/aura.cpp index 6b4e06323..7f9368008 100644 --- a/zone/aura.cpp +++ b/zone/aura.cpp @@ -12,6 +12,11 @@ Aura::Aura(NPCType *type_data, Mob *owner, AuraRecord &record) GiveNPCTypeData(type_data); // we will delete this later on m_owner = owner->GetID(); + if (record.cast_time) { + cast_timer.SetTimer(record.cast_time); + cast_timer.Disable(); // we don't want to be enabled yet + } + if (record.aura_type < static_cast(AuraType::Max)) type = static_cast(record.aura_type); else @@ -58,8 +63,6 @@ void Aura::ProcessOnAllFriendlies(Mob *owner) void Aura::ProcessOnAllGroupMembers(Mob *owner) { - if (!process_timer.Check()) - return; auto &mob_list = entity_list.GetMobList(); // read only reference so we can do it all inline std::set delayed_remove; if (owner->IsRaidGrouped() && owner->IsClient()) { // currently raids are just client, but safety check @@ -228,15 +231,19 @@ void Aura::ProcessOnAllGroupMembers(Mob *owner) casted_on.erase(e); } - if (cast_timer.Enabled() || !cast_timer.Check()) + // so if we have a cast timer and our set isn't empty and timer is disabled we need to enable it + if (cast_timer.GetDuration() > 0 && !cast_timer.Enabled() && !casted_on.empty()) + cast_timer.Start(); + + if (!cast_timer.Enabled() || !cast_timer.Check()) return; - // TODO: some auras have to recast (DRU for example, non-buff too) - /* for (auto &e : casted_on) { + // some auras have to recast (DRU for example, non-buff too) + for (auto &e : casted_on) { auto mob = entity_list.GetMob(e); - if (mob != nullptr && (!is_buff || !mob->IsAffectedByBuff(spell_id))) - - }*/ + if (mob != nullptr) + SpellFinished(spell_id, mob); + } } void Aura::ProcessOnGroupMembersPets(Mob *owner) @@ -277,6 +284,9 @@ bool Aura::Process() } // TODO: waypoints? + if (!process_timer.Check()) + return true; + if (process_func) process_func(*this, owner); @@ -356,7 +366,7 @@ void Mob::MakeAura(uint16 spell_id) bool ZoneDatabase::GetAuraEntry(uint16 spell_id, AuraRecord &record) { auto query = StringFormat("SELECT npc_type, name, spell_id, distance, aura_type, spawn_type, movement, " - "duration, icon FROM auras WHERE type='%d'", + "duration, icon, cast_time FROM auras WHERE type='%d'", spell_id); auto results = QueryDatabase(query); @@ -378,6 +388,7 @@ bool ZoneDatabase::GetAuraEntry(uint16 spell_id, AuraRecord &record) record.movement = atoi(row[6]); record.duration = atoi(row[7]) * 1000; // DB is in seconds record.icon = atoi(row[8]); + record.cast_time = atoi(row[9]) * 1000; // DB is in seconds return true; } diff --git a/zone/zonedb.h b/zone/zonedb.h index 50c924b02..b91ea3cdd 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -133,6 +133,7 @@ struct AuraRecord { int movement; int duration; // seconds some live for 90 mins (normal) others for 2 mins (traps) int icon; // -1 will use the buffs NEW_ICON + int cast_time; // seconds some auras recast on a timer, most seem to be every 12 seconds }; // Actual pet info for a client.