Core/SAI: Improved SMART_ACTION_JUMP_TO_POS to mirror behavior similar to SMART_ACTION_MOVE_TO_POS

Port From (https://github.com/TrinityCore/TrinityCore/commit/f291ca97962e087f9d87077b1ee6fa5b386937ed)
This commit is contained in:
hondacrx
2023-01-06 15:59:08 -05:00
parent f2f765d650
commit 6b344e9a09
3 changed files with 28 additions and 7 deletions
+1 -1
View File
@@ -344,7 +344,7 @@ namespace Framework.Constants
SetDynamicFlag = 94, // UNUSED, DO NOT REUSE
AddDynamicFlag = 95, // UNUSED, DO NOT REUSE
RemoveDynamicFlag = 96, // UNUSED, DO NOT REUSE
JumpToPos = 97, // Speedxy, Speedz, Targetx, Targety, Targetz
JumpToPos = 97, // SpeedXY, SpeedZ, Gravity, UseDefaultGravity, PointId, ContactDistance
SendGossipMenu = 98, // Menuid, optionIndex
GoSetLootState = 99, // State
SendTargetToTarget = 100, // Id
@@ -3483,8 +3483,12 @@ namespace Game.AI
}
public struct Jump
{
public uint speedxy;
public uint speedz;
public uint SpeedXY;
public uint SpeedZ;
public uint Gravity;
public uint UseDefaultGravity;
public uint PointId;
public uint ContactDistance;
}
public struct FleeAssist
{
+21 -4
View File
@@ -22,6 +22,7 @@ using Game.Entities;
using Game.Groups;
using Game.Maps;
using Game.Misc;
using Game.Movement;
using Game.Spells;
using System;
using System.Collections.Generic;
@@ -1824,12 +1825,28 @@ namespace Game.AI
}
case SmartActions.JumpToPos:
{
foreach (var target in targets)
WorldObject target = null;
if (!targets.Empty())
target = targets.SelectRandom();
Position pos = new(e.Target.x, e.Target.y, e.Target.z);
if (target)
{
Creature creature = target.ToCreature();
if (creature != null)
creature.GetMotionMaster().MoveJump(e.Target.x, e.Target.y, e.Target.z, 0.0f, e.Action.jump.speedxy, e.Action.jump.speedz);
float x, y, z;
target.GetPosition(out x, out y, out z);
if (e.Action.jump.ContactDistance > 0)
target.GetContactPoint(_me, out x, out y, out z, e.Action.jump.ContactDistance);
pos = new Position(x + e.Target.x, y + e.Target.y, z + e.Target.z);
}
if (e.Action.jump.Gravity != 0 || e.Action.jump.UseDefaultGravity != 0)
{
float gravity = e.Action.jump.UseDefaultGravity != 0 ? (float)MotionMaster.gravity : e.Action.jump.Gravity;
_me.GetMotionMaster().MoveJumpWithGravity(pos, e.Action.jump.SpeedXY, gravity, e.Action.jump.PointId);
}
else
_me.GetMotionMaster().MoveJump(pos, e.Action.jump.SpeedXY, e.Action.jump.SpeedZ, e.Action.jump.PointId);
break;
}
case SmartActions.GoSetLootState: