D&D initiative tracker program

I been trying to make a program for my charter and I got it all down so I can just type in afew words to look up states or spells but now I wanted to add a combat system where I can add and remove(kill) players and NPC the problem is I have no idea how to do that. I know I can just type in each player name into a string and assiassen the turn order that way but I wont be able to change that from the code and it wont change if we have to roll initiative twice. So what Im asking is how can I make it so it asks for How many players how many NPC's and turn order.
if you are not going to do the whole D&D logic for initiative (which isnt that bad... everyone rolls 1-10, subtracts any bonus for their (dex? feats?) and the lowest result goes first, then next, etc) then the next best thing is round robin based of input. EG input the human(s) first, and they go in the order they were input, then the AI/NPC go next, in the order they were input. Option 3, where you provide the order, is doable too .. when a character is 'input' make one of the input fields its 'turn number' or 'initiative'. eg mog the barbarian has 1, so he goes first... these are just cin-statements that you will put into your *whatever it is* data storage / containers for your program. 1&3 are the hardest as you have to deal with the order 'manually'. 2 is easy, order is the natural result of input.
Last edited on
I am using the D&D logic of it. I just wanted to make a programe that followed it

ex. of the program would be

-What did you roll on intive

is it your turn(y/n)
who's turn is it?
is (name) friend or foe
did anyone die(y/n)
is the round over?
*back to second question*

Do you get it or is it still confusing how I worded it?
yes, I get it.

I would store all the players in a vector.
roll/ compute all their initiatives.
sort the vector by initiative. humans win tie, so put that logic in your comparison function for the sort.
iterate the vector -- its player[0]'s action. after that its player[1]'s action. Who they are is contained in their object... player[0].type may be NPC, player[1].type may be human. and so on.

Does that make sense?
Topic archived. No new replies allowed.