Limit the range of a SkullAttack?
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Limit the range of a SkullAttack?
Hi!
I'm working on a monster that attacks by jumping towards the player. I used the A_SkullAttack pointer for this. The problem is, that sometimes the monster starts its attack from very far and jumps over large distances which looks a bit strange.
Is there a possibility to make the A_SkullAttack valid for smaller distances only? Something like "Jump from See to Missile state only when the distance is smaller than 128 units" or something?
Any suggestions?
Milian
I'm working on a monster that attacks by jumping towards the player. I used the A_SkullAttack pointer for this. The problem is, that sometimes the monster starts its attack from very far and jumps over large distances which looks a bit strange.
Is there a possibility to make the A_SkullAttack valid for smaller distances only? Something like "Jump from See to Missile state only when the distance is smaller than 128 units" or something?
Any suggestions?
Milian
- Graf Zahl
- Lead GZDoom+Raze Developer

- Posts: 49252
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
No. A_SkullAttack adds some momentum and unless the monster hits something or is affected by friction it won't slow do.
Bu this might help:
http://www.zdoom.org/wiki/index.php?tit ... mpIfCloser
Bu this might help:
http://www.zdoom.org/wiki/index.php?tit ... mpIfCloser
It's just a conditional jump, not an actual jump, I think. As in, it doesn't make the monster jump, it changes the position of execution of its AI. You can use it to make sure the monster only jumps at the player if it is within a certain range by using two of these and if I actually knew anything about decorate I could probably help you more.
Hm, ok, but now I have the problem to define a new state.
If the AI decides to attack, it jumps to "Missile", which would be a fake-attack:
And if the distance is below 128, it should jump to the "real" attack state, with A_JumpIfCloser. But then, how can I define a new state and make ZDoom detect it as an attack (with health damage to the player)?
If the AI decides to attack, it jumps to "Missile", which would be a fake-attack:
Code: Select all
Missile:
Goto See
- ferentix
- Posts: 96
- Joined: Tue Jun 14, 2005 6:32 am
- Location: Riding an Intestellar Chicken
- Contact:
A_JumpIfcloser jumps a specified number of frames, then you execute all your attack stuff. So I guess, for what you're doing you could do this in your missile state:
So, when the monster tries to missile the player, this will check if the player is within a certain distance of the monster, defined by the first parameter. If the player IS less than that distance (512), it jumps forwards a number of frames specified by the second parameter, in this case 2. Count 2 frames on, and you get to the frame that has A_Skullattack on, then Goto See. Else, if the player is further than 512 , it doesn't do the jump, and goes straight to the next line, which is just a frame with A_Chase, then Goto See.
Hope that helps
ATM, you cannot add new states, but you can do lots of different behavoiur inside a single state with various actions like A_Jump, A_Jumpifcloser etc.
Code: Select all
Missile:
SPIT A 1 A_JumpIfCloser(512, 2)
SPIT A 1 A_Chase
Goto See
SPIT B 1 A_Skullattack
Goto See
So, when the monster tries to missile the player, this will check if the player is within a certain distance of the monster, defined by the first parameter. If the player IS less than that distance (512), it jumps forwards a number of frames specified by the second parameter, in this case 2. Count 2 frames on, and you get to the frame that has A_Skullattack on, then Goto See. Else, if the player is further than 512 , it doesn't do the jump, and goes straight to the next line, which is just a frame with A_Chase, then Goto See.
Hope that helps
ATM, you cannot add new states, but you can do lots of different behavoiur inside a single state with various actions like A_Jump, A_Jumpifcloser etc.
Wow! That's looking elegant.
Now I've only one question regarding the frame jumps, which I've never understood completely.
Does it count the lines of a state or the individual sprites?
For example with your code:
Would the counting be correct in this code? ABCABC = 6 frames +1?
Or is it still (512, 2), because the SPIT ABCABC is one unit?
Now I've only one question regarding the frame jumps, which I've never understood completely.
Does it count the lines of a state or the individual sprites?
For example with your code:
Code: Select all
Missile:
SPIT A 1 A_JumpIfCloser(512, 7)
SPIT ABCABC 1 A_Chase
Goto See
SPIT B 1 A_Skullattack
Goto See
Or is it still (512, 2), because the SPIT ABCABC is one unit?