How do I create a battle system with Arrays and Functions?

0 favourites
  • 6 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • I'll keep it brief. I'm trying to create a battle system using an array, groups and functions.

    I have an array to set the order of actions determined by the players stamina stat (speed).

    Once an action is completed it updates the list. But after the first action the games stops. But when I run in de-bug mode, I can see it's not mapping WHO should attack. Just how much stamina they have. Which brings up the question of how does the first turn play out if it's not mapping who should go next in the first place? I don't understand this at all. I just want make a game. If anyone could nudge me in the right direction it would be greatly appreciated.

    .capx link

    https://mega.nz/#F!9ZNkiCbQ!UP76ob_Y_IW0gGPw3afFBQ

  • Trigger once doesn't work alone. You need some other variable to check that that value is checked just once. Your Player1 group is constantly calling those top events (#7), which is why the menu selection gets reset.

    Also checkturn() always checks TurnOrder(0,0), but it doesn't change in the context of Player1.

  • blackhornet

    Thank you for the response and yes, I wanted to make it work like that, so it only checks the 0,0 and after every action is completed it will shift everything up, so 1,0 is moved to 0,0. 2,0 is moved to 1,0 and so forth. Will that work or will I have to check 0,0 then once the move is executed shift to 1,0 manually? So rather than replacing 0,0 with 1,0 , I just check 1,0 then 2,0 in order are separate events? I'd prefer to do the 0,0 method since it'll use less events but if that doesn't work i'll change method.

    I thought that the moment you enabled the group the "Trigger Once" would trigger it the moment the group is activated once. Guess not.

    Thank you for the help. It's very much appreciated.

  • This is a start: http://www.blackhornettechnologies.com/Construct2Stuff/rpghelp_BHTc.capx

    You can pop items off of the top of the array, so they move up. Watch out for running out of items though.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Upon playing It's not quite what i'm going for, the turn variable was for testing so I could see in de-bug mode what was currently being done. I'm testing 1v1 but I want it to be changeable so it could be 3v3. However the way you've mapped the Array is that it destroys itself when I want the game to keep going until someone has died. I haven't implemented that since this is just a turn based test, I wanted to just get an infinite battle system which every time you launch the game the stamina stat in different. so sometimes the enemy will outpace you, other times it won't. Once that's working i'll implement more enemies so it's proper.

    The way I've mapped it is that X contains the enemy type (1 = player1 , 2 = player2, 3 = player3, 4 = enemy1, 5 = enemy2, 6 = enemy3). And Y contains the enemies stamina of the player/enemy. The reason I'm using Arrays is because it saves me makes 10 million variables and it has a nice sort feature. So I can sort by the y which is the stamina stat. But my question is, if I sort the Y will it move the X too? because otherwise player 1 will end up with someone else's stamina.

    Thank you for replying.

  • blackhornet

    Don't worry, I sorted it by setting it to instead of finding 0,0. It finds 6,0.

    But I've encountered something new.

    I've added in players 2 and 3 now, so there's 4 units in all. The only problem is it's re-ordering the Y (stamina) but because the x and y (0,0 and 0,1 for example) aren't tied together it's not actually changing the battle order. It's just assigning the quickest stamina to enemy 1 so it'll always go first. Is there a way to group them together so when I move enemy1's stamina, enemy1's position in the que moves with it?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)