How do I create an rpg like initiative system

Get help using Construct 2

Post » Sun Feb 22, 2015 7:33 pm

i want to create a dnd like initiative order where the players score gets put into an array and then sorted by that number. i also want to attach the name to the number but when i do it sorts alpha-numerically rather than just numerically. if someone coould show me an example of how to do that i would greatly appreciate it, as i have been struggling with it for about a week.
B
5
Posts: 9
Reputation: 243

Post » Sun Feb 22, 2015 8:30 pm

Without a .capx we have to take some guesses. But assuming you have a 2D array where the scores in the array are at y=0, and names are at y=1, then the array should sort numerically by score, ascending. Otherwise please provide more information. Alternatively you could give each player an instance variables 'initiative' and then pick by highest value using the initiative variable.
Last edited by codah on Sun Feb 22, 2015 9:02 pm, edited 1 time in total.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sun Feb 22, 2015 8:59 pm

@codah thank you and i will try the alternate way, if that doesn't work then i will send the .capx if i can figure out how to do that. thank you once again
B
5
Posts: 9
Reputation: 243

Post » Sun Feb 22, 2015 9:26 pm

@codah

here is the .capx
You do not have the required permissions to view the files attached to this post.
B
5
Posts: 9
Reputation: 243

Post » Sun Feb 22, 2015 10:04 pm

Sorry had to step out for a bit. See if this helps

These are ordered on-the-fly with a "For each .. order by". If you need to store the order you might want to go back to an array.
I made a Family for the Sprites and put the 'initiative' variable on that. In my opinion ALWAYS put instance variables on a Family, not an object, for non-trivial objects.
Similarly I made a Family for the Text objects. I gave each Family an 'ID' variable so that I could associate Sprite object with Text object. Could use containers but then I'd need to do it for each Sprite object type.
Click the button and the Sprites are given an initiative as per your code, and displayed in order from highest to lowest inititative.
You do not have the required permissions to view the files attached to this post.
Last edited by codah on Sun Feb 22, 2015 10:10 pm, edited 1 time in total.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sun Feb 22, 2015 10:09 pm

your problem is that you have 3 different sprite types, when you use pick instance with highest initiative your only doing it for the orange sprite..

Add them to a family and set initiative as an instance variable for the family...

Check the capx..
You do not have the required permissions to view the files attached to this post.
B
7
S
1
Posts: 27
Reputation: 479

Post » Sun Feb 22, 2015 10:14 pm

thank you both for replying, as both of your corrections are working the way i need them to. thank you once again
B
5
Posts: 9
Reputation: 243


Return to How do I....?

Who is online

Users browsing this forum: Darth Crusher, Madave96, RobertMKD and 5 guests