Helix0's Forum Posts

  • I see, that doesn't seem all to great in practice. The solution you gave in https://www.construct.net/en/forum/construct-3/how-do-i-8/tactically-intelligent-ai-173259?kws=ai%2bline%2bof%2bsight sounds great, but I'm not sure how to cast rays at angles.

  • construct.net/en/forum/construct-3/how-do-i-8/tactically-intelligent-ai-173259

    I looked into past posts and did some digging and discovered this system made in Gamemaker, https://youtu.be/XuhkKmNyYTY

    It does everything I need it to do, but I can't figure out how it finds cover. I used to use GM a long time ago but I can't wrap my head around this function.

    This is the code that finds cover

    function scr_find_cover(argument0, argument1, argument2) {

    /*

    If there is line of site between the target enemy and yourself, then

    move behind the nearest wall.

    */

    can_shoot=0 //don't shoot while in this state

    if !collision_line(x+lengthdir_x(argument0.sprite_width,point_direction(argument0.x,argument0.y,x,y)),y+lengthdir_y(argument0.sprite_width,point_direction(argument0.x,argument0.y,x,y)),argument1.x,argument1.y,argument0,1,1)

    //if line of sight....

    {

    //pathfind to a point behind the nearest wall relative to the enemy

    mp_potential_step(argument0.x+lengthdir_x(argument0.sprite_width,point_direction(argument1.x,argument1.y,argument0.x,argument0.y)),argument0.y+lengthdir_y(argument0.sprite_width,point_direction(argument1.x,argument1.y,argument0.x,argument0.y)),argument2*2,0)

    }

    else

    {

    //if there is no line of sight (you are in cover), then decrease your fear level.

    fear-=1

    }

    }

    From my understanding, the fear level is a instance variable that makes enemies take cover when its high.

    "Argument0" is the nearest wall, "Argument1" is the target or the attacker and "Argument2" is the enemies speed.

    If you could translate this then that would be awesome, and if you need anymore details please ask me. Thank you

  • construct.net/en/forum/construct-3/how-do-i-8/tactically-intelligent-ai-173259

    I completely forgot about that post, thank you.

  • Is there a way to have an enemy take cover behind an object using calculations and without the use of nodes? I want the system to be as dynamic as possible.

    Any and all help is greatly appreciated!

  • Hello, I am making a top-down shooter game and I'm having some trouble making some enemy AI. I'm using a state machine and I the enemy to have 3 stages:

    An idle stage where the enemy roams around the map

    An attack stage where the enemy turns to the player or the players teammate (Whoever is in the enemies line of sight) and shoots at them

    A chase stage where the enemy goes to its target's last seen position once the target breaks the line of sight.

    The player is accompanied by teammates that are also targets for the enemy.

    Any help is greatly appreciated!

  • I have built my code and tested it in one layout, now that it works I've moved on to make a new map in a new layout. Upon putting my players (and all the required objects like bullets, guns, particles, etc.) the code fails to work. Some parts of the code work, some don't.

    For instance, my player can shoot his gun, and when he does, the screen shakes, the sound plays, but no bullet spawns. Am i making some kind of classic rookie mistake? Ill share more details if needed.

  • Refactor the events so that you set reloading to 1 as you already have, then do a separate event something like:

    Reloading = 1, every x seconds : play sfx etc, add 1 to ammo.

    - If ammo = max, set reloading to 0.

    For tighter control, use the timer behavior and add 1 to ammo on timer. If ammo < max, restart the timer. This way you can stop the timer instantly if needed (like a powerup or on picking up a new weapon).

    Thank you! This worked perfectly!

  • Hello! In my game, when the player reloads a shotgun I want the shells to be individually loaded. Kinda like in real life.

    This is my code, my problem is that it only loads once, ignoring the repeat loop

    For more context "GunSpecs.At(Player.Gun,6)" is the amount a full magazine can hold.

    "GunSpecs.At(Player.Gun,7)" basically means 1.

    The Reloading variable acts as a boolien, so when Reloading=1 then the player cant reload, that way a player cant reload WHILE relaoding.

    So if Reloading doesnt equal 0, then a player cant reload.

    Any help is greatly appreciated.

  • This is mostly a math question. But I want to have the allied AI in my game pathfind to the right side of the layout

    These are the parameters I use to move the enemies to the left side of the layout. But Im unsure how to get the oppiste effect, which is to pathfind to the right side of the layout

  • You're right! Im back on track now..thanks for the help!

  • Hello! I have some settings in my game that I want the player to be able to save, thus preventing the headache of having to reset them everytime they play..

    That is my broken code. I cant figure out whats wrong with it, but Im sure you guys can

    Here is the settings menu it goes to

    Any help is greatly appreciated!

  • Indeed I did...whoops

    Thank you for the help

  • Im making an animation that requires a sqaure the gradually shrinks in height. My problem is I need the square to shrink from the bottom and the top. Kinda like its getting pinched.

    Any and all feedback is greatly appreciated.

  • My apologies, When I say away I mean I want the enemy to find a position thats not overlaping an object, maybe 1000px away thats in the opposite direction to the player.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you to all who responded with advice, I think ill use Arisu51 idea of using an instance var