aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMeji <alvaro.megias@outlook.com>2022-12-30 17:48:33 +0100
committerGitHub <noreply@github.com>2022-12-30 17:48:33 +0100
commitf291ca97962e087f9d87077b1ee6fa5b386937ed (patch)
tree56eeab00939e5c15e87c8e56fa3a0f30caf61b2b
parent09591fbdb0a81f8565c6a16f844953752f597f18 (diff)
Core/SAI: Improved SMART_ACTION_JUMP_TO_POS to mirror behavior similar to SMART_ACTION_MOVE_TO_POS (#28547)
* Support for targets other than positions * Added param3 Gravity, to use MoveJumpWithGravity (priority over SpeedZ) * Added param4 UseDefaultGravity (priority over Gravity): 19.29110527038574 * Added param5 PointId, useful for linking the jump to the event SMART_EVENT_MOVEMENTINFORM (Type: 16) * Added param6 ContactDistance * If the target is different from a position, target params for coords allow to add offsets
-rw-r--r--sql/updates/world/master/2022_12_30_02_world.sql2
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp27
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.h10
3 files changed, 33 insertions, 6 deletions
diff --git a/sql/updates/world/master/2022_12_30_02_world.sql b/sql/updates/world/master/2022_12_30_02_world.sql
new file mode 100644
index 00000000000..1e04a919b69
--- /dev/null
+++ b/sql/updates/world/master/2022_12_30_02_world.sql
@@ -0,0 +1,2 @@
+-- Update SMART_ACTION_JUMP_TO_POS
+UPDATE `smart_scripts` SET `target_type`=8 WHERE `action_type`=97 AND `target_type`=1 AND `target_x`!=0;
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index a3f20b9856b..5bd3d704a7a 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -32,6 +32,7 @@
#include "Log.h"
#include "Map.h"
#include "MotionMaster.h"
+#include "MovementTypedefs.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "PhasingHandler.h"
@@ -1850,9 +1851,29 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
}
case SMART_ACTION_JUMP_TO_POS:
{
- 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?
+ WorldObject* target = nullptr;
+
+ if (!targets.empty())
+ target = Trinity::Containers::SelectRandomContainerElement(targets);
+
+ Position pos(e.target.x, e.target.y, e.target.z);
+ if (target)
+ {
+ float x, y, z;
+ target->GetPosition(x, y, z);
+ if (e.action.jump.ContactDistance > 0)
+ target->GetContactPoint(me, x, y, z, e.action.jump.ContactDistance);
+ pos = Position(x + e.target.x, y + e.target.y, z + e.target.z);
+ }
+
+ if (e.action.jump.Gravity || e.action.jump.UseDefaultGravity)
+ {
+ float gravity = e.action.jump.UseDefaultGravity ? Movement::gravity : e.action.jump.Gravity;
+ me->GetMotionMaster()->MoveJumpWithGravity(pos, float(e.action.jump.SpeedXY), gravity, e.action.jump.PointId);
+ }
+ else
+ me->GetMotionMaster()->MoveJump(pos, float(e.action.jump.SpeedXY), float(e.action.jump.SpeedZ), e.action.jump.PointId);
+
break;
}
case SMART_ACTION_GO_SET_LOOT_STATE:
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
index 858b3043c77..d4af11f7dad 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
@@ -551,7 +551,7 @@ enum SMART_ACTION
SMART_ACTION_SET_DYNAMIC_FLAG = 94, // UNUSED, DO NOT REUSE
SMART_ACTION_ADD_DYNAMIC_FLAG = 95, // UNUSED, DO NOT REUSE
SMART_ACTION_REMOVE_DYNAMIC_FLAG = 96, // UNUSED, DO NOT REUSE
- SMART_ACTION_JUMP_TO_POS = 97, // speedXY, speedZ, targetX, targetY, targetZ
+ SMART_ACTION_JUMP_TO_POS = 97, // SpeedXY, SpeedZ, Gravity, UseDefaultGravity, PointId, ContactDistance
SMART_ACTION_SEND_GOSSIP_MENU = 98, // menuId, optionId
SMART_ACTION_GO_SET_LOOT_STATE = 99, // state
SMART_ACTION_SEND_TARGET_TO_TARGET = 100, // id
@@ -986,8 +986,12 @@ struct SmartAction
struct
{
- uint32 speedxy;
- uint32 speedz;
+ uint32 SpeedXY;
+ uint32 SpeedZ;
+ uint32 Gravity;
+ SAIBool UseDefaultGravity;
+ uint32 PointId;
+ uint32 ContactDistance;
} jump;
struct