• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Help w/ Spell Purchase

Status
Not open for further replies.

sentrywiz

S

sentrywiz

Hi!

I got a problem. Atleast a moderate one:

-Heroes purchase spells. Each hero should at normal logic purchase more spells than possible, this also has a hotkey issue. Multiple spells, ment for different classes share the Q or W or E or R hotkey.

? How to make that hotkeys don't overlap, meaning a hero purchases two Q spells, but one of them is bound to a new hotkey. The only solution is a huge if else then that will check which abilities the hero has. But that solution means I have to make that huge if else then for every spell possible, create multiple instances of each spell with a different hotkey so they don't overlap.

Thoughts, ideas are welcomed. Thank you!
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
You could initialize things into a hashtable.

You store the hotkey(string) using the id of the bought thing as a parent key. Do this at map initialization.

When you buy stuff, get the handle id of the bought type and load the string with it. Then load a boolean for the buying unit using the loaded string as a key. If the boolean is false, the unit does not have an ability with that hotkey. Give it the ability and save the boolean as true. If the boolean is true, the unit alraedy has an ability with that hotkey.
 

sentrywiz

S

sentrywiz

Thanks Maker. Though, this I already know how to make and there is no problem with it. I was thinking some alternate solution if possible.
 
Status
Not open for further replies.
Top