Skip to main content
gamedev.net
🔒 Locked

Implementing Battle Queue

Started by PaulCesar Jun 27, 2007 at 6:43 AM 2 replies 1.2k views
Original Post
PaulCesar
PaulCesar
Hello, Understand this post is a little... haphazard. My thoughts are so here and there on it may be hard to grasp more then the general idea. Im working on a small game (more of a tech demo) to get me familiar with flex. Anyways, the small game im designing is like a turn based RPG battle (just the battle... not the RPG part of it... lol). Now what im looking to do is replicate a "battle queue" similar to what is used in "Wild Arms 4/5". By this I mean a way to organize and display the order in which people get to make there move. I know the first thing any half decent programmer on here is thinking. Simple circular linked list implementation with removal lookup. There are a few problems with this, and this is actualy based on the feature set of the battle system. 1. Enemies and players can have a varying speed parameter. So action patterns will often be interwoven, with some players attacking twice per action of another. (in my minds eye I was trying to work something out using the inverse of that on a 1k scale, which would give me a delay param... but im not sure how exactly that will help with all the features I need) 2. Some "attacks" can swap actions in the queue, and some can even duplicate the number of moves you can make. 3. Some moves will raise or lower a creatures speed, or even stop it for a period of time. So the list is going to have to be able to reorder itself when a particular items speed changes. (this seems simple , but when you add the feature in number 2, this problem seems difficult to approch. #2 is easily solvable with linked lists, but the rest will have alot of trouble with it) 4. There will always be a set number of visable "moves" on the screen, so in many cases you will see multiple actions of players, and sometimes you wont see a players action at all. Now, I have thought of a few things with this, but im looking for a nice sound design for it. I have a feeling this is rather simple and im making too much of it. I have brainstormed both linked list , and an array implementation with something like FF's ABS bar (internaly). Then parsing that to determine the queue. But this makes the ability to have multiple moves much more difficult. Help? LOL. Richard Cesar [Edited by - PaulCesar on June 29, 2007 10:11:55 PM]
choffstein
choffstein
Assuming you have access to the collection of all characters on screen, why not, every frame, just calculate their 'distance until action' and render that on a time line? You can even store all their times in an array and sort that array any way you wish for funky rendering. Why even keep them in a persistant list? Seems to me like you would spend more time manipulating it than anything.

Keep it simple!
PaulCesar
PaulCesar
I mentioned that with the (ABS) concept. There are two problems with it I see, although that wont necessaraly make it harder then the LL.

The problems with that solution is

It should always show the next 10 moves, even if that means that multiple moves will be available for that player. Since these will not all be synchronized we MAY have a problem. I suppose a solution would be to to calculate multiple 'distance untill action' for multiple charactor, store that in an array, and then sort and cap at 10 though.

The other problem would be with the ability to have a move that does such things as move swapping and duplicating turns. This is the #1 reason I was trying to work with a stack based approch. Its easy to do a copy/insert on a linked list, and affect just one node or turn. Can you think of some sort of structure that would work with ATB that would allow me to implement move swapping and duplicating? (while obviously only affecting the one move).

for instance, lets say we have an action pattern as follows

[Jerrold][Demon][Henry][Jerrold][Monkey][Henry][Demon][Jerrold]

Now Jerrold can swap moves with the next person on his team, so now it will be

[Henry][Demon][Jerrold][Jerrold][Monkey]...

This is easy to do with the linked list... so I would need some sort of structure to make it work with an array
choffstein
choffstein
Change your thought paradigm a bit -- with events like swaps, the queue isn't affected, the character is, right? The queue isn't so much a game entity as an internal storage unit. For example, Evil Orc will not cast "swap turn" on the "turn bar," will it? No! It casts it on Good Knight.

So we should create our structures in such a way. Perhaps you could give each character a priority queue of 'future actions', which contain a time until completed (the priority) and the action.

When Evil Orc casts "swap turns" with Good Knight, we just take the top element from the Good Knights's queue, pop it, then do the same to the Evil Orcs. We take the times of each of these actions, swap them, and reinsert them in the queue.

That should work, right?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.