Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
CreatureChat
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
Public
CreatureChat
Commits
07e7e336
Commit
07e7e336
authored
Aug 05, 2024
by
Jonathan Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding 30 degree randomness into LEAD behavior targeting.
parent
95c8aba4
Pipeline
#12713
passed with stages
in 2 minutes 21 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
LeadPlayerGoal.java
src/main/java/com/owlmaddie/goals/LeadPlayerGoal.java
+2
-2
RandomTargetFinder.java
src/main/java/com/owlmaddie/utils/RandomTargetFinder.java
+13
-7
No files found.
src/main/java/com/owlmaddie/goals/LeadPlayerGoal.java
View file @
07e7e336
...
...
@@ -111,7 +111,7 @@ public class LeadPlayerGoal extends PlayerBaseGoal {
currentSpeed
=
MathHelper
.
stepTowards
((
float
)
currentSpeed
,
(
float
)
this
.
speed
,
(
float
)
(
0.005
*
(
this
.
speed
/
Math
.
max
(
currentSpeed
,
0.1
))));
// Apply movement with the adjusted speed towards the target
Vec3d
newVelocity
=
new
Vec3d
(
moveDirection
.
x
*
currentSpeed
,
this
.
entity
.
getVelocity
().
y
,
moveDirection
.
z
*
currentSpeed
);
Vec3d
newVelocity
=
new
Vec3d
(
moveDirection
.
x
*
currentSpeed
,
moveDirection
.
y
*
currentSpeed
,
moveDirection
.
z
*
currentSpeed
);
this
.
entity
.
setVelocity
(
newVelocity
);
this
.
entity
.
velocityModified
=
true
;
...
...
@@ -123,7 +123,7 @@ public class LeadPlayerGoal extends PlayerBaseGoal {
// Increment waypoint
currentWaypoint
++;
LOGGER
.
info
(
"Waypoint "
+
currentWaypoint
+
" / "
+
this
.
totalWaypoints
);
this
.
currentTarget
=
RandomTargetFinder
.
findRandomTarget
(
this
.
entity
,
0
,
24
,
36
);
this
.
currentTarget
=
RandomTargetFinder
.
findRandomTarget
(
this
.
entity
,
3
0
,
24
,
36
);
if
(
this
.
currentTarget
!=
null
)
{
emitParticleAt
(
this
.
currentTarget
,
ParticleTypes
.
FLAME
);
emitParticlesAlongRaycast
(
this
.
entity
.
getPos
(),
this
.
currentTarget
,
ParticleTypes
.
CLOUD
,
0.5
);
...
...
src/main/java/com/owlmaddie/utils/RandomTargetFinder.java
View file @
07e7e336
...
...
@@ -52,15 +52,21 @@ public class RandomTargetFinder {
}
private
static
Vec3d
getConstrainedDirection
(
Vec3d
initialDirection
,
double
maxAngleOffset
)
{
double
currentAngle
=
Math
.
atan2
(
initialDirection
.
z
,
initialDirection
.
x
);
double
randomYawAngleOffset
=
(
random
.
nextDouble
()
*
Math
.
toRadians
(
maxAngleOffset
))
-
Math
.
toRadians
(
maxAngleOffset
/
2
);
double
randomPitchAngleOffset
=
(
random
.
nextDouble
()
*
Math
.
toRadians
(
maxAngleOffset
))
-
Math
.
toRadians
(
maxAngleOffset
/
2
);
double
randomHorizontalAngleOffset
=
(
random
.
nextDouble
()
*
Math
.
toRadians
(
maxAngleOffset
))
-
Math
.
toRadians
(
maxAngleOffset
/
2
);
double
constrainedAngle
=
currentAngle
+
randomHorizontalAngleOffset
;
// Apply the yaw rotation (around the Y axis)
double
cosYaw
=
Math
.
cos
(
randomYawAngleOffset
);
double
sinYaw
=
Math
.
sin
(
randomYawAngleOffset
);
double
xYaw
=
initialDirection
.
x
*
cosYaw
-
initialDirection
.
z
*
sinYaw
;
double
zYaw
=
initialDirection
.
x
*
sinYaw
+
initialDirection
.
z
*
cosYaw
;
double
x
=
Math
.
cos
(
constrainedAngle
);
double
z
=
Math
.
sin
(
constrainedAngle
);
return
new
Vec3d
(
x
,
initialDirection
.
y
,
z
).
normalize
();
// Apply the pitch rotation (around the X axis)
double
cosPitch
=
Math
.
cos
(
randomPitchAngleOffset
);
double
sinPitch
=
Math
.
sin
(
randomPitchAngleOffset
);
double
yPitch
=
initialDirection
.
y
*
cosPitch
-
zYaw
*
sinPitch
;
double
zPitch
=
zYaw
*
cosPitch
+
initialDirection
.
y
*
sinPitch
;
return
new
Vec3d
(
xYaw
,
yPitch
,
zPitch
).
normalize
();
}
private
static
Vec3d
getTargetInDirection
(
MobEntity
entity
,
Vec3d
direction
,
double
minDistance
,
double
maxDistance
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment