enemy reaction..
![starcat](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
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?
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
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
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
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?
==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
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!
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!
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.