aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2021-11-28 00:05:38 +0100
committerShauren <shauren.trinity@gmail.com>2021-11-28 00:05:38 +0100
commita809932f5017c98092a02694e86e276add03f8b9 (patch)
tree1ba76f989a3082339832c2e50ad40d138f8d386d /src
parent684cd9d9681466019dcd06ad6f994890cff8cb2e (diff)
Core/Spells: Implemented spell effect 254 (SPELL_EFFECT_JUMP_CHARGE)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp86
-rw-r--r--src/server/game/Globals/ObjectMgr.h7
-rw-r--r--src/server/game/Movement/MovementDefines.h20
-rw-r--r--src/server/game/Spells/Spell.h1
-rw-r--r--src/server/game/Spells/SpellEffects.cpp45
-rw-r--r--src/server/game/World/World.cpp3
6 files changed, 160 insertions, 2 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 4cbe4830866..30e504635ed 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -43,6 +43,7 @@
#include "Mail.h"
#include "MapManager.h"
#include "MotionMaster.h"
+#include "MovementTypedefs.h"
#include "ObjectAccessor.h"
#include "ObjectDefines.h"
#include "PhasingHandler.h"
@@ -10432,6 +10433,11 @@ PlayerChoice const* ObjectMgr::GetPlayerChoice(int32 choiceId) const
return Trinity::Containers::MapGetValuePtr(_playerChoices, choiceId);
}
+JumpChargeParams const* ObjectMgr::GetJumpChargeParams(int32 id) const
+{
+ return Trinity::Containers::MapGetValuePtr(_jumpChargeParams, id);
+}
+
void ObjectMgr::LoadGameObjectQuestItems()
{
uint32 oldMSTime = getMSTime();
@@ -11048,3 +11054,83 @@ void ObjectMgr::LoadPlayerChoicesLocale()
TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " Player Choice Response locale strings in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
}
+
+void ObjectMgr::LoadJumpChargeParams()
+{
+ uint32 oldMSTime = getMSTime();
+
+ // need for reload case
+ _jumpChargeParams.clear();
+
+ // 0 1 2 3 4 5 6
+ QueryResult result = WorldDatabase.Query("SELECT id, speed, treatSpeedAsMoveTimeSeconds, jumpGravity, spellVisualId, progressCurveId, parabolicCurveId FROM jump_charge_params");
+ if (!result)
+ {
+ return;
+ }
+
+ do
+ {
+ Field* fields = result->Fetch();
+
+ int32 id = fields[0].GetInt32();
+ float speed = fields[1].GetFloat();
+ bool treatSpeedAsMoveTimeSeconds = fields[2].GetBool();
+ float jumpGravity = fields[3].GetFloat();
+ Optional<int32> spellVisualId;
+ Optional<int32> progressCurveId;
+ Optional<int32> parabolicCurveId;
+
+ if (speed <= 0.0f)
+ {
+ TC_LOG_ERROR("sql.sql", "Table `jump_charge_params` uses invalid speed %f for id %d, set to default charge speed %f.",
+ speed, id, SPEED_CHARGE);
+ speed = SPEED_CHARGE;
+ }
+
+ if (jumpGravity <= 0.0f)
+ {
+ TC_LOG_ERROR("sql.sql", "Table `jump_charge_params` uses invalid jump gravity %f for id %d, set to default %f.",
+ jumpGravity, id, Movement::gravity);
+ jumpGravity = Movement::gravity;
+ }
+
+ if (!fields[4].IsNull())
+ {
+ if (sSpellVisualStore.LookupEntry(fields[4].GetInt32()))
+ spellVisualId = fields[4].GetInt32();
+ else
+ TC_LOG_ERROR("sql.sql", "Table `jump_charge_params` references non-existing SpellVisual: %d for id %d, ignored.",
+ fields[4].GetInt32(), id);
+ }
+
+ if (!fields[5].IsNull())
+ {
+ if (sCurveStore.LookupEntry(fields[5].GetInt32()))
+ progressCurveId = fields[5].GetInt32();
+ else
+ TC_LOG_ERROR("sql.sql", "Table `jump_charge_params` references non-existing progress Curve: %d for id, ignored.",
+ fields[4].GetInt32(), id);
+ }
+
+ if (!fields[6].IsNull())
+ {
+ if (sCurveStore.LookupEntry(fields[6].GetInt32()))
+ parabolicCurveId = fields[6].GetInt32();
+ else
+ TC_LOG_ERROR("sql.sql", "Table `jump_charge_params` references non-existing parabolic Curve: %d for id, ignored.",
+ fields[6].GetInt32(), id);
+ }
+
+ JumpChargeParams& params = _jumpChargeParams[id];
+ params.Speed = speed;
+ params.TreatSpeedAsMoveTimeSeconds = treatSpeedAsMoveTimeSeconds;
+ params.JumpGravity = jumpGravity;
+ params.SpellVisualId = spellVisualId;
+ params.ProgressCurveId = progressCurveId;
+ params.ParabolicCurveId = parabolicCurveId;
+
+ } while (result->NextRow());
+
+ TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " Player Choice locale strings in %u ms", _jumpChargeParams.size(), GetMSTimeDiffToNow(oldMSTime));
+}
diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
index 45c1fb3d83b..24858f18b3b 100644
--- a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -26,6 +26,7 @@
#include "GameObjectData.h"
#include "ItemTemplate.h"
#include "IteratorPair.h"
+#include "MovementDefines.h"
#include "NPCHandler.h"
#include "ObjectDefines.h"
#include "ObjectGuid.h"
@@ -1365,6 +1366,8 @@ class TC_GAME_API ObjectMgr
void LoadPlayerChoices();
void LoadPlayerChoicesLocale();
+ void LoadJumpChargeParams();
+
void InitializeQueriesData(QueryDataGroup mask);
std::string GeneratePetName(uint32 entry);
@@ -1696,6 +1699,8 @@ class TC_GAME_API ObjectMgr
PlayerChoice const* GetPlayerChoice(int32 choiceId) const;
+ JumpChargeParams const* GetJumpChargeParams(int32 id) const;
+
private:
// first free id for selected id type
uint32 _auctionId;
@@ -1872,6 +1877,8 @@ class TC_GAME_API ObjectMgr
SceneTemplateContainer _sceneTemplateStore;
+ std::unordered_map<int32, JumpChargeParams> _jumpChargeParams;
+
std::set<uint32> _transportMaps; // Helper container storing map ids that are for transports only, loaded from gameobject_template
};
diff --git a/src/server/game/Movement/MovementDefines.h b/src/server/game/Movement/MovementDefines.h
index 3600e349aab..224d1399a31 100644
--- a/src/server/game/Movement/MovementDefines.h
+++ b/src/server/game/Movement/MovementDefines.h
@@ -20,6 +20,7 @@
#include "Common.h"
#include "ObjectGuid.h"
+#include "Optional.h"
#define SPEED_CHARGE 42.0f // assume it is 25 yard per 0.6 second
@@ -100,10 +101,27 @@ struct TC_GAME_API ChaseAngle
struct JumpArrivalCastArgs
{
- uint32 SpellId;
+ uint32 SpellId = 0;
ObjectGuid Target;
};
+struct JumpChargeParams
+{
+ union
+ {
+ float Speed;
+ float MoveTimeInSec;
+ };
+
+ bool TreatSpeedAsMoveTimeSeconds = false;
+
+ float JumpGravity = 0.0f;
+
+ Optional<uint32> SpellVisualId;
+ Optional<uint32> ProgressCurveId;
+ Optional<uint32> ParabolicCurveId;
+};
+
inline bool IsInvalidMovementGeneratorType(uint8 const type) { return type == MAX_DB_MOTION_TYPE || type >= MAX_MOTION_TYPE; }
inline bool IsInvalidMovementSlot(uint8 const slot) { return slot >= MAX_MOTION_SLOT; }
diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h
index 981d03f8232..0045fe37cb7 100644
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -391,6 +391,7 @@ class TC_GAME_API Spell
void EffectCreatePrivateSceneObject();
void EffectPlayScene();
void EffectGiveHonor();
+ void EffectJumpCharge();
void EffectLearnTransmogSet();
void EffectRespecAzeriteEmpoweredItem();
void EffectLearnAzeriteEssencePower();
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index e4930d40296..2d8fd4e2394 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -335,7 +335,7 @@ NonDefaultConstructible<SpellEffectHandlerFn> SpellEffectHandlers[TOTAL_SPELL_EF
&Spell::EffectNULL, //251 SPELL_EFFECT_SET_GARRISON_CACHE_SIZE
&Spell::EffectTeleportUnits, //252 SPELL_EFFECT_TELEPORT_UNITS
&Spell::EffectGiveHonor, //253 SPELL_EFFECT_GIVE_HONOR
- &Spell::EffectNULL, //254 SPELL_EFFECT_JUMP_CHARGE
+ &Spell::EffectJumpCharge, //254 SPELL_EFFECT_JUMP_CHARGE
&Spell::EffectLearnTransmogSet, //255 SPELL_EFFECT_LEARN_TRANSMOG_SET
&Spell::EffectUnused, //256 SPELL_EFFECT_256
&Spell::EffectUnused, //257 SPELL_EFFECT_257
@@ -5856,6 +5856,49 @@ void Spell::EffectGiveHonor()
playerTarget->SendDirectMessage(packet.Write());
}
+void Spell::EffectJumpCharge()
+{
+ if (effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH)
+ return;
+
+ if (!unitCaster)
+ return;
+
+ if (unitCaster->IsInFlight())
+ return;
+
+ JumpChargeParams const* params = sObjectMgr->GetJumpChargeParams(effectInfo->MiscValue);
+ if (!params)
+ return;
+
+ float speed = params->Speed;
+ if (params->TreatSpeedAsMoveTimeSeconds)
+ speed = unitCaster->GetExactDist2d(destTarget) / params->MoveTimeInSec;
+
+ Optional<JumpArrivalCastArgs> arrivalCast;
+ if (effectInfo->TriggerSpell)
+ {
+ arrivalCast.emplace();
+ arrivalCast->SpellId = effectInfo->TriggerSpell;
+ }
+
+ Optional<Movement::SpellEffectExtraData> effectExtra;
+ if (params->SpellVisualId || params->ProgressCurveId || params->ParabolicCurveId)
+ {
+ effectExtra.emplace();
+ if (params->SpellVisualId)
+ effectExtra->SpellVisualId = *params->SpellVisualId;
+
+ if (params->ProgressCurveId)
+ effectExtra->ProgressCurveId = *params->ProgressCurveId;
+
+ if (params->ParabolicCurveId)
+ effectExtra->ParabolicCurveId = *params->ParabolicCurveId;
+ }
+
+ unitCaster->GetMotionMaster()->MoveJumpWithGravity(*destTarget, speed, params->JumpGravity, EVENT_JUMP, false, arrivalCast.get_ptr(), effectExtra.get_ptr());
+}
+
void Spell::EffectLearnTransmogSet()
{
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index 6b20cbb9989..b4912ecf8d7 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -2061,6 +2061,9 @@ void World::SetInitialWorldSettings()
TC_LOG_INFO("server.loading", "Loading Player Choices Locales...");
sObjectMgr->LoadPlayerChoicesLocale();
+ TC_LOG_INFO("server.loading", "Loading Jump Charge Params...");
+ sObjectMgr->LoadJumpChargeParams();
+
CharacterDatabaseCleaner::CleanDatabase();
TC_LOG_INFO("server.loading", "Loading the max pet number...");