How can you have the player automatically attack a near by enemy or have the player attack an enemy that attacks the players.

I have set the enemy to attack the player automatically which works fine but I can't get the player to auto attack back.

I seen on the enemy you can select when player collides and have a script run so I thought I could then run a script that makes the player attack however the option is not running a script when the player collides anyone got any ideas?

Is there a way to have the enemy collide trigger a script when the enemy attacks or do they both have to be on the same tile?

One way to get this done would be having a "while" loop that runs if the enemy is next to the player, this script would have to check all cardinal directions and select a target in the vicinity, you have the likes of "player.front_tile" to reference those tiles, and you can use something like this.

$mob_to_attack = $player.right_tile.characters.pop_front();

This will give you the first character on the right tile.

Anyhow there is several ways to approach this and I'd like to ask what is your main combat loop? does it happen in the overworld? is it real time? rouge like? tick based?

For the collision script is necessary for both to be on the same tile.

Best regards from the Worlak team.

I currently have only done the attack enemy code which now gets run when your on the same tile as an enemy.

I Just wanted to have a play around and see what can be done within the demo before purchasing.