Limit the range of a SkullAttack?

Archive of the old editing forum
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.
Locked
User avatar
Milian
Posts: 124
Joined: Fri Sep 17, 2004 5:24 pm
Contact:

Limit the range of a SkullAttack?

Post by Milian »

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
User avatar
Phobus
Posts: 5984
Joined: Thu May 05, 2005 10:56 am
Location: London
Contact:

Post by Phobus »

Can't you do the following:

A_SkullAttack for a certain amount of time and then have the next step as the melee attack or the jump to state?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49252
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Post by Graf Zahl »

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
User avatar
Milian
Posts: 124
Joined: Fri Sep 17, 2004 5:24 pm
Contact:

Post by Milian »

Graf Zahl wrote: But this might help:

http://www.zdoom.org/wiki/index.php?tit ... mpIfCloser
Hmm. I don't know if I understand this function right.
It forces the monster to attack if the distance is small enough. But does it prevent from an attack, if the distance is too big?
Dr_Ian
Posts: 41
Joined: Wed Sep 07, 2005 4:19 pm
Location: Edinburgh

Post by Dr_Ian »

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.
User avatar
Phobus
Posts: 5984
Joined: Thu May 05, 2005 10:56 am
Location: London
Contact:

Post by Phobus »

You could set that to allow the monster to only jump when it gets within a certain distance. Looks worth looking into, as that's how solarsnowfall sets up his varied attacks on monsters.
User avatar
Milian
Posts: 124
Joined: Fri Sep 17, 2004 5:24 pm
Contact:

Post by Milian »

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:

Code: Select all

Missile:
Goto See
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)?
User avatar
ferentix
Posts: 96
Joined: Tue Jun 14, 2005 6:32 am
Location: Riding an Intestellar Chicken
Contact:

Post by ferentix »

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:

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.
User avatar
Milian
Posts: 124
Joined: Fri Sep 17, 2004 5:24 pm
Contact:

Post by Milian »

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:

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 
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?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49252
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Post by Graf Zahl »

7 is correct. Each letter counts separately.
User avatar
Milian
Posts: 124
Joined: Fri Sep 17, 2004 5:24 pm
Contact:

Post by Milian »

Ok, thank you all very much!

It works perfectly now.
The result can be seen in two weeks in Biovite 3 :-)
Locked

Return to “Editing (Archive)”