Solved How can I learn more about default enemy behavior?

Question that is answered or resolved.

SuperJojoDev

New member
Hi everyone! I'm so happy to have found this community and a little frustrated for not having gotten into OpenBOR before. I'm a game dev with some experience and I'm very interested in using OpenBOR for some new projects, but I still have a lot to learn. I've been playing with the engine for a couple days now, replacing assets and character properties to see them working. Right now, I'm trying to have a deeper understanding on the entities behavior. I see how they move in game but I'd love to maybe read the script or a detailed description for the default entities behavior, specially the enemies. Sorry in advance if I'm asking something redundant or if this is the wrong place, but is there a place I can find this information? I've already been reading the wiki manual and got some understanding of the engine's structures, and I can already bring some levels to life, but I'd love to have a better understanding of what I'm doing.

For example, when I spawn enemies, they walk around a lot, sometimes attack the enemy fairly quick, sometimes take a step back when the player approaches. I know where to edit properties like hp, animations and attackboxes, but where can I edit (if possible) the basic behavior for enemies? Why exactly do they move the way they do?

Thanks in advance. I hope I can make something cool to contribute to this wonderful community!
 
Good evening Jojodev and welcome to the forum.
I'd be interested to know what kind of game you've developed.

Perhaps you could start by exploring the following avenues:
Code:
aimove {type}

    This command sets enemy's walk AI. IOW it sets how enemy walks around in evels.
    Default AI is enemy will go after player or other entity he/she/it is hostile to
    Accepted types for {type} are:
        Chase = Enemy will always chase player and this allows enemy to use RUN and RUNATTACK if enemy has it.
        Chasex = Enemy will chase player but it only lines up enemy's X axis with player's.
        Chasez = Enemy will chase player but it only lines up enemy's Z axis with player's.
        Avoid = Enemy will always avoid player.
        Avoidx = Enemy will always avoid player but enemy only avoids lining up X axis with player's.
        Avoidz = Enemy will always avoid player but enemy only avoids lining up Z axis with player's.
        Wander = Enemy walks without certain destination (hence the name).
        Boomerang = Enemy assume a boomerang moving.

* Accepted 2nd params for {type} are:

        Ignoreholes = Enemy walks without ignoring holes. This makes enemy walks to holes stupidly.
        Notargetidle = Enemies ignore players when players are in idle animation.
    Example: aimove chase notargetidle
    Can be declared more than once but combine proper ones. avoid and chase are bad combination but avoidx and chasez are good one
Code:
aggression {value}

    For enemy spawns.
    Spawned enemy's aggression will use this {value} instead of the enemy's normal aggression.
Code:
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 ATTACK{#} is 0 75, for JUMPATTACK and JUMPATTACK2 is 0 150, for UPPER -10 120 and for BLOCK is 1 100. The last one only has effect if enemy uses 'nopassiveblock'.
    Use it into GETBOOMERANG or GETBOOMERANGINAIR to get the boomerang by range

These three commands will already allow you to determine your enemies' behavior.
For example, the `range` function in an animation will determine when it activates based on its distance in pixels from the player.

You can always try paxploding some games and observe how others are designed.

I hope you have lots of fun exploring OpenBor.
 
Good evening Jojodev and welcome to the forum.
I'd be interested to know what kind of game you've developed.

Perhaps you could start by exploring the following avenues:
Code:
aimove {type}

    This command sets enemy's walk AI. IOW it sets how enemy walks around in evels.
    Default AI is enemy will go after player or other entity he/she/it is hostile to
    Accepted types for {type} are:
        Chase = Enemy will always chase player and this allows enemy to use RUN and RUNATTACK if enemy has it.
        Chasex = Enemy will chase player but it only lines up enemy's X axis with player's.
        Chasez = Enemy will chase player but it only lines up enemy's Z axis with player's.
        Avoid = Enemy will always avoid player.
        Avoidx = Enemy will always avoid player but enemy only avoids lining up X axis with player's.
        Avoidz = Enemy will always avoid player but enemy only avoids lining up Z axis with player's.
        Wander = Enemy walks without certain destination (hence the name).
        Boomerang = Enemy assume a boomerang moving.

* Accepted 2nd params for {type} are:

        Ignoreholes = Enemy walks without ignoring holes. This makes enemy walks to holes stupidly.
        Notargetidle = Enemies ignore players when players are in idle animation.
    Example: aimove chase notargetidle
    Can be declared more than once but combine proper ones. avoid and chase are bad combination but avoidx and chasez are good one
Code:
aggression {value}

    For enemy spawns.
    Spawned enemy's aggression will use this {value} instead of the enemy's normal aggression.
Code:
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 ATTACK{#} is 0 75, for JUMPATTACK and JUMPATTACK2 is 0 150, for UPPER -10 120 and for BLOCK is 1 100. The last one only has effect if enemy uses 'nopassiveblock'.
    Use it into GETBOOMERANG or GETBOOMERANGINAIR to get the boomerang by range

These three commands will already allow you to determine your enemies' behavior.
For example, the `range` function in an animation will determine when it activates based on its distance in pixels from the player.

You can always try paxploding some games and observe how others are designed.

I hope you have lots of fun exploring OpenBor.
Thank you very much for your answer, this has definitely set me on tracks.

About games I've developed: some personal projects can be found on my itch.io, one of them having an updated version available for free on steam but I've also worked as a contractor in some other projects using unity and godot, the latest one was a endless survivor that should be on steam next year. I also have some experience as a front end developer, but making games is more my thing.

I'm excited in exploring OpenBOR and I'm considering the possibility of using it in a commercial project next year as well.

P.S.: apparently I can't link my itch and steam game here, but I use the same username I have here on itch and the steam game is called "One's Own Exile", so feel free to take a look"
 
Thank you very much for your answer, this has definitely set me on tracks.

About games I've developed: some personal projects can be found on my itch.io, one of them having an updated version available for free on steam but I've also worked as a contractor in some other projects using unity and godot, the latest one was a endless survivor that should be on steam next year. I also have some experience as a front end developer, but making games is more my thing.

I'm excited in exploring OpenBOR and I'm considering the possibility of using it in a commercial project next year as well.

P.S.: apparently I can't link my itch and steam game here, but I use the same username I have here on itch and the steam game is called "One's Own Exile", so feel free to take a look"

Welcome to the community @SuperJojoDev! About the AI, there's not really a practical way to explain everything in one post without just dumping the code base. It would be kind of like trying to explain what all you can make with a Lego set. If you are willing to work with script, the answer is "anything you can think of", but even the vanilla native options are not far from infinite. It's probably a better idea to give us an overview of what you want the AI to do and we'll go from there.

Just as a very quick primer, here are the three most common basic movement modes:
  • Chase - Always tries to approach the nearest hostile target directly as possible. If the target is far away (more than 150 pixels on X axis) and running is available, the entity will run to try and close distance.
  • Normal - Generally approaches the nearest hostile, but with a bit of randomness to give it more organic behavior.
  • Wander - Movement is fully random.
Each animation has a min/max range setting for X, Y, Z, and Base, with baked in defaults if you don't override them. If a hostile target falls within the range, the AI will fire said animation. AI is subject to same rules as players concerning resource costs to perform a move, but by default those costs are set to 0. When more than one range detects a target, there is an algorithm that selects one at random, but favors certain animations over others. Ex: Regular attacks favor lowered numbered over higher numbered.

The default AI also knows how to negotiate basic terrain, by using ranges in its jump animations to decide if and when to attempt jumps over or onto pits and platforms.

Then there are other settings to play with, like how fast the AI can attack initially, and how fast it can attack consecutively. Mix all those together and you can make an amazingly diverse set of AI behaviors, and that again is before getting script involved.

DC
 
Welcome to the community @SuperJojoDev! About the AI, there's not really a practical way to explain everything in one post without just dumping the code base. It would be kind of like trying to explain what all you can make with a Lego set. If you are willing to work with script, the answer is "anything you can think of", but even the vanilla native options are not far from infinite. It's probably a better idea to give us an overview of what you want the AI to do and we'll go from there.

Just as a very quick primer, here are the three most common basic movement modes:
  • Chase - Always tries to approach the nearest hostile target directly as possible. If the target is far away (more than 150 pixels on X axis) and running is available, the entity will run to try and close distance.
  • Normal - Generally approaches the nearest hostile, but with a bit of randomness to give it more organic behavior.
  • Wander - Movement is fully random.
Each animation has a min/max range setting for X, Y, Z, and Base, with baked in defaults if you don't override them. If a hostile target falls within the range, the AI will fire said animation. AI is subject to same rules as players concerning resource costs to perform a move, but by default those costs are set to 0. When more than one range detects a target, there is an algorithm that selects one at random, but favors certain animations over others. Ex: Regular attacks favor lowered numbered over higher numbered.

The default AI also knows how to negotiate basic terrain, by using ranges in its jump animations to decide if and when to attempt jumps over or onto pits and platforms.

Then there are other settings to play with, like how fast the AI can attack initially, and how fast it can attack consecutively. Mix all those together and you can make an amazingly diverse set of AI behaviors, and that again is before getting script involved.

DC
Thank you very much! My question wasn't about what can be done with enemy AI, but what enemy AI does by default, and you explained it very clearly to me, so thanks again. I hope to be dropping some fun prototypes soon!
 
Back
Top Bottom