Help With Enemy Range

Psykai

Well-known member
I started making a test enemy just to practice and everything's gone well so far but one thing that's bugging me is that despite the enemy having a projectile attack, they insist on coming pretty close before using it, when they could easily be on the other side of the screen and shoot if they wanted to be.

It's almost like the engine won't allow them to attack unless they're at a certain range from the player. I'm wondering if there's a way to increase that so that they can also shoot from a longer range?
 
It's almost like the engine won't allow them to attack unless they're at a certain range from the player.
The engine will take the range in action. If you want an enemy to use a projectile from long range, you need to set the right range.
Make the long range move to have a bigger RANGE than the close attack and the enemy will use it,

So if you have a attack2 with range 0-40 and a freespecial2 with range 0-100 and you are 80px from the target, the enemy will try to use freespecial2 instead. When you are in the range of both attacks, the enemy will use more attack than freepspecial,

And it you have freespecial1 and freepsecial3, both with same range, the engine will use the smaller number (freespecial1) more often. Works for attacks too.

Read the maual about range:
range {min} {max}

~Used for AI controlled entities' attacks and jump. Usually used by enemy, NPC and homing projectile.
~This command lets the entities know when to perform their attacks or to jump on platforms.
~For the entity to use the attack, its opponent must be more than {min} away, but less than {max} away in x axis.
~Entity's opponent is determined by 'hostile' setting (see Header Data above).
~For the enemy to jump on a platform, the enemy must be within {min} pixels of the platform, and the platform must be less than {max} pixels high.
~This is measured in pixels, starting at the entity's offset point and moving towards the opponent's offset.
~If not included, the first number will default to -10, and the second to 20 times the entity's jumpheight variable.
~For homing projectiles, this determines their targeting range.
~If this command is declared together with 'rangez' and/or 'rangea', opponent's location must be within ALL of them before attack animation is performed.
~Default 'range' for A

 
O Ilusionista said:
So if you have a attack2 with range 0-40 and a freespecial2 with range 0-100 and you are 80px from the target, the enemy will try to use freespecial2 instead. When you are in the range of both attacks, the enemy will use more attack than freepspecial,

And it you have freespecial1 and freepsecial3, both with same range, the engine will use the smaller number (freespecial1) more often. Works for attacks too.
I didn't know about the order from smaller to bigger numbers. It will help me a lot to manage my enemies/npc partner freespecials, thanks!
 
O Ilusionista said:
So if you have a attack2 with range 0-40 and a freespecial2 with range 0-100 and you are 80px from the target, the enemy will try to use freespecial2 instead. When you are in the range of both attacks, the enemy will use more attack than freepspecial,

And it you have freespecial1 and freepsecial3, both with same range, the engine will use the smaller number (freespecial1) more often. Works for attacks too.

By the way, freespecial1 is not a valid animation. Its  right name is freespecial.

The order for the enemies basic default attack animations works like you said that the engine is always giving priority from the smaller number of the attack animations to the bigger numbers. So the right order to setup rage on the normal "anim attack#" animations is like:
"anim attack1" = shorter rage
"anim attack2"= biger rage
"anim attack3"= much bigger rage
and so on..

So if you have an enemy with a short punch attack and an projectile throw attack, then you should make it like this:
"anim attack1" = punch attack with shorter rage
"anim attack2"= projectile throw with bigger rage
(the atanim attack numbers can be set to be different than my example of course, but the order of how to set their rage must be like that.)

I hope that helps.
 
Kratus said:
O Ilusionista said:
So if you have a attack2 with range 0-40 and a freespecial2 with range 0-100 and you are 80px from the target, the enemy will try to use freespecial2 instead. When you are in the range of both attacks, the enemy will use more attack than freepspecial,

And it you have freespecial1 and freepsecial3, both with same range, the engine will use the smaller number (freespecial1) more often. Works for attacks too.
I didn't know about the order from smaller to bigger numbers. It will help me a lot to manage my enemies/npc partner freespecials, thanks!

I wouldn't worry about it - the favoritism is very slight. The AI chooses attacks by looping from lowest to highest index of attacks, then specials. Along the way each animation is checked against the target for range and in the case of free specials, energy cost (yes, the AI is subject to energy cost rules). If those pass, the ID goes into an array. When all available moves are evaluated a random attack is selected from the array. Also, it should go without saying, but the default AI doesn't think about energy management - if it can do a special, it will.

Jump attack and Upper are also tested, and they take priority over the others. That's why enemies with jump attacks tend to spam them, and Upper is always used as a counter to incoming jump attacks.

DC
 
magggas said:
2. If you just make a freespecial animation and just set it up with a rage, this animation will not used by the AI at all! This because the freespecials on enemies can only be activated by scripts and their given contitions, and not just by the defaul AI, no matter what rage they have.

magggas this isn't correct at all.  The default AI can and will use freespecials. It's follow animations the AI can't use on its own.

DC
 
Damon Caskey said:
magggas this isn't correct at all.  The default AI can and will use freespecials. It's follow animations the AI can't use on its own.

DC

Ups, sorry  :-[
It seems i missed something all these years or i just forgot about it altogether. I will correct my post then  ;)
 
Gurtag said:
well..  i have an enemy with freespecial1 and it works just fine, no invalid anim name or otter error, just my 2 cents  :P

Yeah, this is because Plombo at some point changed the behavior of the engine to not shotdown for such minor errors. But freespecial1 is still wrong and it might cause you problems in the future or wwhen you will try to use it with script. Because script is less forgiven and does not accepting even minor errors.
 
Psykai: Hi, could you post please the anim attack of your enemy so we can see how do you configure it?

I resolved this kind of range problem in my project like this:
Code:
range -400 400
-400 0, the enemy can shoot on his left up to 400 pixels; 0 400 enemy can shoot up to 400 pixels on his right side.
 
kimono said:
I resolved this kind of range problem in my project like this:
Code:
range -400 400
-400 0, the enemy can shoot on his left up to 400 pixels; 0 400 enemy can shoot up to 400 pixels on his right side.

Sorry but your explanation is wrong. The  hardcoded rage x command is not working like that. For rage(x)  command  the negative value always means how far from the back of your entity no matter its facing direction. Do not confuse that with rage setted up with script because thats another story.
So if you will setup a projectile throw move with a range -400 400, then the character will throw its projectile normally forward even if you are behind him within the - 400 rage. That means your example is bad too for what he wanted to do, and you should also change it.
 
Thanks everyone ^_^ It turned out I simply hadn't set my maximum range for the attack high enough. I had it at 100 which I thought sounded like a lot but only covered just under half the screen 'cause I didn't realize it was in pixels at first. Kiinda embarrassing ::). I increased it to 200 and now the enemy's fire at long range as I wanted.
 
Back
Top Bottom