Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
I was trying to have a custom "chasing" function for a monster.
What I wanted to achieve is a monster moving away from its target when it's too close, but with specific escaping routes and the possibility to attack like it was in a normal chasing (this is why I completely put aside the easy way of just using the FRIGHTENED flag and call it a day).
I got the "avoid the target" and "avoid obstacles" done, working pretty well too, but then I tested the creature with normal steps... and it broke.
Basically, what happens is that the monster doesn't get block by the step like an actual obstacle, but he won't move forward anymore and won't climb the step, but only if the total height of the steps to climb exceeds the standard Doom monster limit of 24... even though the monster MaxStepHeight is 32... I even tried raising it up to 64, but this behavior didn't change.
Not to mention that if the monster target gets closer, sometimes the monster will climb up the steps...
To me even weirder, is when the monster tries to go downstairs instead, because in this case it will recognize the "stepping down" as an obstacle and just avoid it like a wall etc.
Class WarrensBase : Actor
{
int steps;
Default
{
//$Category Monsters
MaxStepHeight 64;
BloodColor "Dark Red";
Monster;
+FORCEXYBILLBOARD
+JUMPDOWN
+FLOORCLIP
+DROPOFF
}
}
Class TheUnclean : WarrensBase
{
Default
{
Health 1200;
Radius 48;
Height 64;
Mass 2000;
Speed 8;
PainChance 96;
PainChance "Acid", 4;
PainChance "Silver", 16;
PainChance "Fire", 16;
DamageFactor "Poison", 0.0;
DamageFactor "Disease", 0.25;
DamageFactor "Acid", 0.25;
DamageFactor "Silver", 0.5;
DamageFactor "Bludge", 1.25;
DamageFactor "Pierce", 0.75;
+BOSS
+LOOKALLAROUND
SeeSound "unclean/sight";
PainSound "unclean/pain";
DeathSound "unclean/death";
ActiveSound "unclean/active";
HitObituary "%o was smuthered by The Unclean.";
Species "Resistant";
Tag "The Unclean";
}
States
{
Spawn:
Idle:
TOAD AABB 3 {
//A_Wander();
A_LookEx(fov: 180);
}
Loop;
See:
TOAD AABBCCDDEEFF 2 A_DistantChase(1000, 900, null, "Stand", null);
Loop;
[...]
I'd like to know if what I'm trying to do is possible without having to rewrite the zdoom chasing functions, otherwise I'll just surrender and use the FRIGHTENED flag T_T
Last edited by Kan3x on Thu Apr 04, 2024 12:34 pm, edited 1 time in total.
Interesting enough, I guess, if I replace CheckMove() with TryMove() it "almost" works, but the guy is having a lot of jittering while moving D:
Any help on this? I'm totally stuck T_T like the monster...
I coded my own chase function too and the way I fixed the TryMove jitteriness was to use variables to track the direction and distance the monster wants to move, then use those values to move the monster in its Tick() function. So for example if the monster wants to move 8 units and its animation frame lasts 4 frames, it'll move 2 unit per tick 4 times, so it moves as smoothly as possible
This is a function that calculates the distance from the current position to the position the enemy wants to get to (nextPos) and sets the variables. You call this instead of TryMove
animSpeed is the length of the walk animation, you pass that value when you call it. This makes so the monster's position changes faster or slower depending on the animation speed
7Soul wrote: ↑Tue Mar 19, 2024 8:05 am
I coded my own chase function too and the way I fixed the TryMove jitteriness was to use variables to track the direction and distance the monster wants to move, then use those values to move the monster in its Tick() function. So for example if the monster wants to move 8 units and its animation frame lasts 4 frames, it'll move 2 unit per tick 4 times, so it moves as smoothly as possible
This is a function that calculates the distance from the current position to the position the enemy wants to get to (nextPos) and sets the variables. You call this instead of TryMove
animSpeed is the length of the walk animation, you pass that value when you call it. This makes so the monster's position changes faster or slower depending on the animation speed
Thanks for the help!
This is quite an interesting route and it actually solved the "step up" issue! (I still can't understand the "magic" behind it, why do I need to take this detour?)
Although it cannot get rid of the "step down" one D: Because that's caused directly by the CheckMove() (or TryMove()) checks for obstacles that will always detect a "step down" bigger than the common 24 units as a wall, no matter the MaxStepHeight the monster has.
Ok, I finally found a solution to apparently every glitch that I had.
The major issue, which was the monster not being able to go upstairs, despite the MaxStepHeight property value being big, and downstairs has been solved by the use of the MaxDropOffHeight property (which still doesn't really makes too much sense for the step up to me, I clearly understand the step down, of course, but to go up I should only need the Step height, or am I missing something?)
For the rest being a bit buggy, now I made some tweaks here and there and the function works just wonderfully fine: