From d60dda3e41de37dc24702baed4088e8afab21a6f Mon Sep 17 00:00:00 2001 From: Sevi Date: Thu, 26 Jan 2023 15:17:14 +0100 Subject: [PATCH] Core/SmartScripts: add a way to use Jump With Gravity in SmartScripts --- .../game/AI/SmartScripts/SmartScript.cpp | 20 +++++++++++++++++-- .../game/AI/SmartScripts/SmartScriptMgr.h | 4 +++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 48e96f65c94..b89e0d0aac0 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1909,8 +1909,24 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { for (WorldObject* target : targets) { - if (Creature* creature = target->ToCreature()) - creature->GetMotionMaster()->MoveJump(e.target.x, e.target.y, e.target.z, 0.0f, (float)e.action.jump.speedxy, (float)e.action.jump.speedz); // @todo add optional jump orientation support? + if (!e.action.jump.useGravity) + { + if (Creature* creature = target->ToCreature()) + creature->GetMotionMaster()->MoveJump(e.target.x, e.target.y, e.target.z, 0.0f, (float)e.action.jump.speedxy, (float)e.action.jump.speedz); // @todo add optional jump orientation support? + } + else + { + if (Creature* creature = target->ToCreature()) + { + Position pos; + pos.m_positionX = e.target.x; + pos.m_positionY = e.target.y; + pos.m_positionZ = e.target.z; + pos.SetOrientation(e.target.o); + + creature->GetMotionMaster()->MoveJumpWithGravity(pos, (float)e.action.jump.speedxy, (float)e.action.jump.speedz); + } + } } break; diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index cb3b40e4a6e..9b50c38dd7e 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -27,6 +27,7 @@ class WorldObject; enum SpellEffIndex : uint8; +typedef uint32 SAIBool; enum eSmartAI { @@ -1009,7 +1010,8 @@ struct SmartAction struct { uint32 speedxy; - uint32 speedz; + uint32 speedz; // If useGravity true, speedZ is gravity + SAIBool useGravity; } jump; struct