Basically CHF_BEELINE would simply be a nice alternative to monsters simply zigzagging everywhere (which is possibly part of the reason they're pretty hopeless in pathing)
More or less, unless the player is at a different "horizontal coordinate" (i.e not straight ahead) they will move straight towards the player/target without constantly changing angles (unless they need to)
A feature such as this would be very useful, especially in allowing for better monster pathing/intelligence.
"CHF_BEELINE" for A_Chase/A_Wander
Moderator: GZDoom Developers
-
- Posts: 382
- Joined: Mon May 09, 2016 1:38 am
- Location: Anywhere but here
-
- Lead GZDoom+Raze Developer
- Posts: 48657
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: "CHF_BEELINE" for A_Chase/A_Wander
'simply' indeed... 

-
- Posts: 3886
- Joined: Fri Feb 08, 2008 9:15 am
- Preferred Pronouns: She/Her
- Operating System Version (Optional): (btw I use) Arch
- Graphics Processor: nVidia with Vulkan support
- Location: Vigo, Galicia
Re: "CHF_BEELINE" for A_Chase/A_Wander
I'd swap that No for a DIY. Excluding DECORATE, this would be fairly easy in ZScript (and has been done before).
-
- Posts: 1987
- Joined: Mon Aug 11, 2003 1:50 pm
- Location: Waveney, United Kingdom
Re: "CHF_BEELINE" for A_Chase/A_Wander
To get the OP started, this is how I did it for the cats. Would also suggest to OP posting their request in the Scripting help thread. Essentially, it consists of using the built-in functions and then correcting the angle bit by bit.
Code: Select all
// Customised wander function for the cats; they
// will navigate to the specified actor, but by
// default, do so less randomly than as normal.
//
// 1. The argument wanderPerson specifies the actor
// to wander to; the default is null and means
// use the cat's goal.
// 2. The argument wanderSpeed specifies the speed
// with which to wander; the default is zero and
// means use the cat's normal speed.
// 3. The argument wanderDirChance specifies the
// probability out of 256 of the actor changing
// direction towards wanderPerson while
// wandering; this controls how erratically the
// cat wanders; the default is 16.
// 4. The argument wanderDirAngle specifies the
// maximum absolute value (zero to 180) of the
// angle that should be allowed to exist between
// wanderPerson and the cat; the default is 180
// (no limit).
//
protected virtual void A_BlackCatWander(
actor wanderPerson = null,
uint wanderSpeed = 0,
uint wanderDirChance = 16,
double wanderDirAngle = 180)
{
// Determine who we navigate to
let navigatePerson = (wanderPerson ? wanderPerson : goal);
let navigateSpeed = (wanderSpeed ? wanderSpeed : speed);
// Navigate to the actor
let oldGoal = goal;
let oldSpeed = speed;
let oldTarget = target;
goal = navigatePerson;
speed = navigateSpeed;
if ( (wanderDirAngle < 180) && (Abs(AngleTo(navigatePerson)) > wanderDirAngle))
{
target = navigatePerson;
NewChaseDir();
}
target = null;
A_Wander();
if (wanderDirChance && (random[BlackCatWander]() < wanderDirChance - 1))
{
target = navigatePerson;
NewChaseDir();
}
if ( (wanderDirAngle < 180) && (Abs(AngleTo(navigatePerson)) > wanderDirAngle))
{
target = navigatePerson;
NewChaseDir();
}
goal = oldGoal;
speed = oldSpeed;
target = oldTarget;
}
-
- Posts: 9695
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Re: "CHF_BEELINE" for A_Chase/A_Wander
> More or less,
> unless the player is at a different "horizontal coordinate" (i.e not straight ahead)
> (unless they need to)
These are the hard parts.
> unless the player is at a different "horizontal coordinate" (i.e not straight ahead)
> (unless they need to)
These are the hard parts.