mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
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
This commit is contained in:
2
sql/updates/world/master/2022_12_30_02_world.sql
Normal file
2
sql/updates/world/master/2022_12_30_02_world.sql
Normal file
@@ -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;
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user