Jump to content
  • Advertisement
Sign in to follow this  
BUnzaga

Quick bar psuedo concept

This topic is 3489 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am to the point where I am trying to implement a 'quick bar' for different actions and items, and I am having a hard time understanding how it is all handled. Everything I search for on google or here usually ends up being related to a 'quick bar' inside a program such as the windows quick launch bar, or the c++ quick bar, etc. I am interested to understand how something like the World of Warcraft or Dark Age of Camelot or other common/similar quick bar works. I have weapon attacks and items. Some items have a reuse timer, some actions have pre-requiste actions, cool down timers, spells have cool down timers, etc. When an item is 'used' or an attack is used, etc, I need it to somehow scan all of the icons in the quick bar to determins which, if any, need to be activated or deactivated based on the previous action, if it has a cool down timer, I need that to be updated based on the time the style or object was used, etc. I have tried to look into this on my own, and I have even tried to make my own version of this, but it seems very sloppy and uncoordinated. Can anyone give me some psuedo code, or any examples they have found, or class examples I can port from? I was thinking of trying to do some kind of event listener/handler system for the quick bar, but it is quite an abstract idea at the moment.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by BUnzaga
When an item is 'used' or an attack is used, etc, I need it to somehow scan all of the icons in the quick bar to determins which, if any, need to be activated or deactivated based on the previous action

That seems backwards. Given that you're redrawing all the icons every frame anyway, it makes a lot more sense for icons to pull their active/inactive state from the character state, rather than the character state pushing updates to the icons.

Share this post


Link to post
Share on other sites
Couldn't you just have each button stored in an array. Then when they "attack", you set the cool down for that button and loop through the array checking each buttons data for the same cool down type, and set that flag for cool down.

Something like:


enum cooldownType { attack, heal, rune, global };

struct button {
int cooldown; // how much cool down there is
int amountofcooldown; // When button pressed, how much cooldown is there
cooldownType type; // type of cooldown
Action action; //does whatever the button does
}

void main ()
{
button Attack;
button Heal;
button Whoopem;

// fill in the structs and in this case Whoopem and Attack have
// the same cooldownType
// then fill in an Array holding everything in the quick bar
// when a button is pressed do something like...
for (int i = 0; i < NumOfButtonsInQuickBar; i++)
{
if (i != numOfButtonPressed)
{
if (quickBarArray.type == quickBarArray[numOfButtonPressed].type)
{
quickBarArray.cooldown = quickBarArray.amountofcooldown;
}
}
}

Thats the first way it comes to my mind. Hopefully that helps.

Of course, like in WoW, there are talents that aren't in your action bars that receive cool down too. Then you could just have an array full of all the talents, then an array for the quickbar in which each index is set to the index of the talent in the first array for easy access.

Then when a button is pressed loop through the full talent array, the quickbar array will fix itself.

Edit: added that last bit

Share this post


Link to post
Share on other sites
I appreciate both of the replies, I am just hitting a mental block or something. I just can't get passed all of the 'what if' situations invloved here. Sneftel, your approach sounds right, but I was wonderring if you could expand the explination a little, or else if anyone has some reading material about this subject, I'd really appreciate it.

These are the 'what if' situations I am talking about.

The user clicks a health potion icon (usable object)
The user clicks a weapon icon to the quick bar (should swapp weapons)
The uer clicks a spell icon to the quick bar (should cast spell, if has mana, if has the spell, if pre-reqs are met)
The user clicks an attack icon to the quick bar
The user clicks an 'after parry' icon to the quick bar
The user clicks an 'after block' icon to the quick bar
The user clicks an 'after dodge' icon to the quick bar
The user clicks an attack icon with a random pre-req attack.
The user clicks a positional attack icon to the quick bar

The spell, item, attack, etc has a cool down timer, such as 5-10 mins to use again.

The spell, item, attack, etc has a time limit to use, such as if I block, I have 5 second to use the follow up, otherwise it deactivates.

Then there has to be a check if the user no longer has the spell or ability, the icon should be removed. If the user runs out of the health potion or whatever object, then it should be removed, etc.etc

Am I making this harder than it needs to be? Think of a game like EverQuest, Dark Age of Camelot, or World of Warcraft.

I am sure others have come accross this and have struggled with it too, so I am hoping someone can help shed some light on the subject.

Share this post


Link to post
Share on other sites
I think you are making this more difficult than it needs to be. Its a pretty straightforward thing. Remember, actions in the quickbar aren't the actual items, they're just facades for the actual items.

Every quickbar action has a few common elements:

An icon (picture)
A state to indicate whether its active or inactive
And a cooldown

Thats your base action. Its useless, but it serves as the template for your specific actions. Things like:

EquipItemAction
UseSkillAction
UseItemAction


Some actions will require a precondition to be met (parry, use of a different skill) before it actives. I preferr event polling for this. Each action should register for the types of events that it's looking for when it is first created. Each action that can act as a precondition should fire its event when happening.

If blocking an attack is a potential pre-condition, then any quickbar action requiring a block will register for BlockEvents when they are created. Then have every 'block' fire a BlockEvent.


The trick to this is to decide what type of action an item on the quickbar is when the action is created. When the user first drags a weapon from his inventory to the quickbar, create an EquipWeaponAction. If he drags a skill or spell, create a UseSkillAction. That way when the user clicks the action, you don't have to figure out what type of action it is - you'll already know.


Then, when drawing the action in the quickbar, you don't need to know anything about the action. Your renderer just needs to know:

Is the action in cooldown? Draw it with gray overlay and put cooldown time remaining.
Is the action disabled? Draw it with red overylay.
Is the action active and clickable? Draw it normally.

Share this post


Link to post
Share on other sites
Hey thanks kru, for the last couple days I have been waking up throughout the night repeating in my head 'everything is an event'. So it seems like my subconscious was onto the right track. :) Seriously though, it makes my nights restless and it feels like those times when you fall asleep with the TV left on, so when you finally wake up your scream 'Turn off that damn TV!!!'

I think I was onto the right track, I think it was just hard for me to see how it all works together, trying to look at each separate piece of the puzzle makes it hard to invision the larger picture as a whole.

I stumbled accross 'event polling' on my own one day, and it seemed like this crazy new way to do things, but appearantly everyone knows about it, and has been using it for a long time LOL. The idea first came to me when I was trying to figure out a quest system. Such as killing a certain monster, I didn't want to have tons of iterations for when I killed a rat, I just wanted to check the things I was interested in. So I had this awesome idea of creating my own event listeners/triggers and registering the events, yadda yadda. Event polling. At least now I have a name for it. :)

I think with all of your contributions, I am now finally, after several days and restless nights, able to create a quickbar. :)

Gamedev.net has yet to let me down. Thanks guys!

P.S. When I am using event polling for multiple things, such as area triggers, quest events, attacks, spells, etc, is it best to separate these up into different catagories, or just have one main 'listeners' array/map/linked list, etc?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!