enemy reaction..

starcatstarcat Member Posts: 107
edited November -1 in Working with GS (Mac)
im almost scared to ask..because if this isnt possible this ruins the entire concept of my first game..

i am trying to make a Turn based game.. where i do something, and the enemy reacts. it can be simultanious or instantly after i move.. but i cant seem to find any attributes that i can assign to the enemy or my own charicter that would make the enemy move in ANY capacity..

even if its a . when i do ANYTHING, the enemy moves twords.. or away.. or randomly in a direction.

imagine a grid of squares if you will. imagine if we were 2 pegs on the square and i wanted to go up and talk to him. but we had to move 1 square at a time. i move. then he moves.. i move then he moves.

if we cant move like this my game is already ruined. timers wont work. because if i just stand still eventually he will come to me. i want him to move up down left right or diagonally, then that was his turn.

now its my turn. etc. i know ive explained it a few times but i just wanna be clear. is such a thing possible?

Comments

  • PhoticsPhotics Member Posts: 4,172
    If it's just one enemy, it can be accomplished with a toggle.

    If enemy turn is true
    Then move towards player

    Attributes are needed to keep track of the following...
    • Player X Location
    • Player Y Location
    • Which turn is it enemy/player
  • starcatstarcat Member Posts: 107
    where are you seeing if enemy turn is true? also i should mention in the higher stages of the game um... actually going to send you a private message.
  • PhoticsPhotics Member Posts: 4,172
    Don't bother with private messages. It's better to keep the conversation here, where others can read and/or jump in.

    When the player makes their turn, then the attribute is changed.

    If up is pressed.
    Move player up one space
    Change enemy.turn to true

    It's a toggle. It's turned on and off... on when it's the enemy's turn, off when it's the player's turn.

    It's a lot of work. :)

    For multiple enemies, it wouldn't be a boolean/toggle it would be numbers.

    0 = player's turn
    1 = enemy #1's turn
    2 = enemy #2's turn
  • starcatstarcat Member Posts: 107
    ok so im going to be doing something like.. main attribute boolean. turn..

    then when my guy moves a square, move or some kind of action = change attribute to true / false.

    then i need to make a second attribute called enemy turn or something and do the same thing until one of us wins or runs away correct?
  • PhoticsPhotics Member Posts: 4,172
    It's one attribute. The two (or more) actors monitor it.

    ==Player Actor==
    If game.turn is 0
    Then run move behaviors
    Else run idle behaviors

    ==Enemy Actors==
    If game.turn is 1
    Then run move behaviors
    Else run idle behaviors

    ==Enemy Actors==
    If game.turn is 2
    Then run move behaviors
    Else run idle behaviors

    ==Enemy Actors==
    If game.turn is 3
    Then run move behaviors
    Else run idle behaviors
  • starcatstarcat Member Posts: 107
    ok, i forgot about the 1 and 0 part. im only doing single enemy for now.. your book as a LOT of info so i go back and forth a lot and i forget some stuff. ok ill try it and see how it goes. thanks
  • PhoticsPhotics Member Posts: 4,172
    Numbers allow for more enemies.

    Also, you could have a roll for initiative.

    If the player loses the roll, the game.turn attribute is changed to 1.

    This is not an easy thing to do. You'll have to keep track of dead enemies, handle the total number of enemies to start the loop again, add artificial intelligence to make the enemy moves seem logical. One of the reasons BOT is real-time is because it's easier than turn-based. HA!
  • DrGlickertDrGlickert Member Posts: 1,135
    I started a little project of a turn-based strategy game, sounds a little bit like what you are doing.

    Here's what I am working on. Bear in mind that Enemy AI is incredibly difficult, even in manual coding. To make a computer act like a human or have human reactions can be a serious challenge. So, that makes it no different in GameSalad.

    I have magnitudes set up on each enemy. So when the player comes within a certain distance of the enemy he starts doing his thing. (To save memory for the processor I have invisible actors that when the player overlaps them a game.trigger1, game.trigger2, game.trigger3, etc is switched to true and the enemy will start what he's supposed to do. I have a self.attribute called self.WhatToDo (integer type). The enemy has a change attribute self.WhatToDo to Random(1,5).

    (Keep following me here, it'll all make more sense in the end).
    I have 5 rules set up on each enemy, if self.WhatToDo = 1 AND EnemyTurn = true; do these behaviors; shoot, move, etc. Then 4 more similar behaviors, one is run away.

    I also have rules that if player is < 10 magnitude then do melee combat, etc. Lots of crazy things going on.

    The enemies have a lot of rules on them.

    Now, what I did was in each scene I went in and edited EACH enemy individually. I gave them different "moves" so one enemy may move down two grids and shoot, one may move down 4 grids and not shoot. Maybe one stays put and tries to shoot the player 3 times, etc.

    So each enemy has slightly different behaviors to give it some variability. That way, each enemy does something slightly different AND because they each have 5 general behaviors they won't typically do the same thing each turn.

    It takes a lot of planning as far as level design in Enemy AI. I'm trying to make it so that enemies will have a clear path to the player to avoid them hitting collidable objects (walls, trees, mountains, etc.).

    When making a turn-based strategy game there is a LOT to keep in mind. It's an incredibly ambitious project.

    Good luck!
  • starcatstarcat Member Posts: 107
    well luckly mine isnt AS complicated as yours.. and im no stranger to ambition. and im going to see this through.. this is probably the hardest part of the whole project.. so i figure i'd better get it out of the way now. you guys are a lot more advanced. ive only had my mac for 5 days and this is only my 4th day with gamesalad.
  • starcatstarcat Member Posts: 107
    and by the way, im not trying to get it to act like a human so much as just Obey 2 or 3 guidlines.. when low health <for certain enemies> run away.. otherwise. stay at range and shoot. or come in melee and fight. the part im strugglign with is the part pho is trying to help me out with. the moving and ending the turn part.
  • starcatstarcat Member Posts: 107
    ok, i know im probably doing something wrong. but my enemy wont budge.. to do a step by step..

    1 i made an attribute called Players turn. checked it for true.

    2 just to test it i made a change attribute <also tried constrain> to my movement commands.
    basically any direction i made it change player.turn to game.players turn 0.

    and on the enemy i made a rule, attribute game.players turn is false, move up.

    no budges yet. both charicters are movable. so im probably missing a step or doing something noobish.

    i have to admit.. as frustrating as this is.. this is really exciting.. i know that sounds kinda dumb.. but its invigorating working out these problems and seeing a direct result.
Sign In or Register to comment.