C
CrackedGamer§
Guest
So, I am working on a Top-Down explorer game (is that a real genre?), I need some help with my enemy AI. Every enemy has the following states:
The stuff that I have already gotten down is:
scr_enemyAttack
&
scr_enemyDie
The huntspd variable is set in the create event for the enemy, which in this case is: obj_player.movespd + 3
The corpsetype variable is also set in the enemy's create event, which in this case is: obj_medium_corpse
So the states that are left are:
Idle & Cooldown
I really have no idea how to do either of these efficiently, I could probably make a code for the Idle state with an alarm but I want to avoid that and keep everything (except setting variables, of course) in the step event so that everything can be in one script per state.
And I also want the enemy to detect the player if they are x amount of pixels away in front of them, my suggestion would be ray-casting but if you have a better idea go for it.
Also, I am not asking for anyone to write a script! But if you know of a function or technique that could be useful for this then please help me
--- THANK YOU IN ADVANCE ---
Idle - Wander randomly
Attack/Hunt - Run towards player while avoiding solid objects
Dead - Replace itself with a corpse
Cooldown - Stand completely still for 60 frames / 1 sec
Attack/Hunt - Run towards player while avoiding solid objects
Dead - Replace itself with a corpse
Cooldown - Stand completely still for 60 frames / 1 sec
The stuff that I have already gotten down is:
scr_enemyAttack
Code:
mp_potential_step(obj_player.x, obj_player.y, huntspd, false)
scr_enemyDie
Code:
instance_create_layer(x,y,"corpses",corpsetype);
instance_create_layer(x,y,"ui_invisible_objs",obj_enemy_loot);
instance_destroy(self);
The corpsetype variable is also set in the enemy's create event, which in this case is: obj_medium_corpse
So the states that are left are:
Idle & Cooldown
I really have no idea how to do either of these efficiently, I could probably make a code for the Idle state with an alarm but I want to avoid that and keep everything (except setting variables, of course) in the step event so that everything can be in one script per state.
And I also want the enemy to detect the player if they are x amount of pixels away in front of them, my suggestion would be ray-casting but if you have a better idea go for it.
Also, I am not asking for anyone to write a script! But if you know of a function or technique that could be useful for this then please help me
--- THANK YOU IN ADVANCE ---
Last edited by a moderator: