HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How to design a hotkey conflict resolver?

01-18-2007, 07:23 AM#1
Moss
Well for my Onslaught map players can customize their hero by learning from a variety of abilities. I already set up a kind of nice system that checks when an ability is being learned if they already have the spell that can conflict with that one and if so it pops up an "are you sure?" dialog box.

The problem is that this system will get tedious and ugly when there are more than two abilities sharing the same hotkey, which is a rapidly approaching situation. So I would like to know the best way to create a system that can handle n-way hotkey conflicts. All I got going so far is that I could create a sort of table/dictionary by initially attaching arrays to a dummy handle like:

Collapse JASS:
set abilities[0] = 'A001'
set abilities[1] = 'A002'
set abilities[2] = 'A003'
call AttachInt(udg_ability_dictionary, "B", abilities)
//insert code that clears out the abilities array
set abilities[0] = 'A0C1'
set abilities[1] = 'A02F'
set abilities[2] = 'A044'
call AttachInt(udg_ability_dictionary, "Z", abilities)

Except can I even attach arrays to things? So from then on I have my dictionary handle with arrays of conflicting abilities organized under their shared hotkey. Then I have triggers for every ability that can be learned (already done) and when the ability is attempted to be learned these triggers
call a function like:

Collapse JASS:
function hotkeyConflictCheck takes string key, unit hero, ability learnMe returns nothing
   local ability ability_array = GetAttachedInt(udg_ability_dictionary, key) //this can't work can it?
   //now a loop that goes thru the array checking if the hero already has any of the conflicting abilities
   //and if so pops up the dialog I already made
endfunction

So besides the fact that I don't think some of that works, it also seems a bit goofy to me, using attached variables. Any suggestions for a better method?
01-18-2007, 08:29 AM#2
DioD
You need to store start and end of global array sector
01-18-2007, 07:27 PM#3
Moss
Well I would make the triggers check the array slots 0 to 5, that would be more than enough to account for all the abilities with the same hotkey. Is that what you are talking about? That isn't what I am asking help for.
01-18-2007, 07:46 PM#4
Naakaloh
How exactly do you plan to go about doing this anyway? It seems like a tricky issue since you can't exactly detect when a particular hotkey is pressed.
01-18-2007, 08:00 PM#5
rulerofiron99
There are 26 hotkeys you can use (27 if you include esc), so do your heroes have 28 different spells?
01-18-2007, 08:30 PM#6
Mezzer
He means to plan out hotkeys in some array and check if the unit has an ability with a conflicting hotkey, and, if so, to give it the a different version of that ability with a non conflicting hotkey. Am I right?
01-18-2007, 09:35 PM#7
Ryude
There is a map on ROC called DOTA: Danites Hell. In that map it gives each hero a random set of abilities from all the DOTA abilities. It has 4 different versions of each ability with hotkeys as W,E,R, and F. Then it assigns the abilities by using Engineering Upgrade.

That's how we do it, not sure if there's a better way.
01-18-2007, 10:11 PM#8
Mapz_Maker
Quote:
Originally Posted by rulerofiron99
There are 26 hotkeys you can use (27 if you include esc), so do your heroes have 28 different spells?

Elaborate on what those keys are?
01-18-2007, 10:26 PM#9
WILL THE ALMIGHTY
26 letters.

minus A, S, H, P, M.

21 hotkeys. you might as well just check your hotkeys to fix it.
01-19-2007, 12:57 AM#10
Moss
Sorry, I thought it was obvious what I'm trying to do but I guess I will have to elaborate.

BTW, for my purposes there are 17 hotkeys. 26 - M,A,S,H,P,O (defaults on heroes) - T, U, Q (used for context sensitive, ultimate, and class abilities)

So what happens on my map is you pick a hero to begin and they just have one built-in class ability which uses the Q key. From then on they can pick new abilities from a large selection if they have skill points to spend. They only get 3 regular abilities and 1 ultimate like a usual Warcraft hero. The problem is if you picked, for example, Destructive Force and Destabilize, which both use the D hotkey it will only work for the first ability you learn. You can still use the second ability of course, just not with the hotkey, so I give the user a warning and an option to cancel or accept learning the new ability.

So I don't need to detect when hotkeys are pressed, just when the player tries to learn an ability that conflicts with an ability they already have. I figure the best way to keep track is to store conflicting abilities in some sort of groups arranged by hotkey.

Quote:
There is a map on ROC called DOTA: Danites Hell. In that map it gives each hero a random set of abilities from all the DOTA abilities. It has 4 different versions of each ability with hotkeys as W,E,R, and F. Then it assigns the abilities by using Engineering Upgrade.

You really do that?! I was considering such a solution for my map but I figured it would be too much work, bloatation, and possibly hurt performance to have three versions of the engineering upgrade plus three versions of the spell for every spell. By my calculations for just non-ultimate abilities 70 heroes * 3 abilities * 3 hotkey versions * 2 (for the 3 corresponding engineering upgrades) = 1260 abilities . Your ultimates could all use the same hotkey.
01-19-2007, 07:20 AM#11
Moss
Of course I could just have a big dumb function like so:

Collapse JASS:
function hotKeyConflictChecker takes string key, unit hero, ability learnMe returns nothing
local ability array abilitiesToCheck

if (key =  "B") then
   abilitiesToCheck[0] = 'A010'
   abilitiesToCheck[1] = 'A021'
   abilitiesToCheck[2] = 'A01A'
elseif (key = "C") then
   abilitiesToCheck[0] = 'A003'
   abilitiesToCheck[1] = 'A01F'
elseif (key = "D") then
   //etc for each key
endif

//then loop through the first 5 or so elements of the abilitiesToCheck array and see if the hero already has them
endfunction

But that seems clumsy to me too. At least I know that would work...

EDIT: it seemed dumber in my head, it doesn't look that bad typed out I guess. Not too hard to add new abilities. I guess I will go with this unless someone has a cooler idea.