Edit 2: Figured out how to set hotkeys for inventory items. It turns out the new UI area of the editor does not allow you to modify the gamestrings.txt and gamehotkeys.txt file. For anyone else interested, you need to use an MPQ editor and open up your <map name>.SC2Map file. Then browse to <map name>.SC2Map/enUS.SC2Data/LocalizedData and edit the GameHotkeys.txt file. Remember to exit the SC2 editor and game first so that you can edit the files.
For example, I added the following lines to GameHotkeys.txt:
The above lines specify hotkey aliases that I can now use in my custom UI files.
So now that I've saved the updated GameHotkeys.txt file, I re-open the editor, go to the UI section, find the button that I want to add the hotkey for (in this example I had first created an override file to change the UI layout of inventory container buttons), and add the appropriate <Shortcut> tag line:
I'm trying to get this to work well with window re-sizing and without weirdness with offscreen buttons. For the inventory panel, why do you need to specify a height and width when you already have anchors? I would like everything to be relative, so is there a way around this?
p.s. For any other noobs trying to figure this out, note that (0,0) is in the UPPER LEFT of the screen. This fooled me for a while. That means that when specifying anchors for Top and Bottom, 'min' and 'max' probably mean the opposite of what you expect.
Is there a way to do this? I know about the 'unselectable' unit flag in data, but that makes the unit unselectable for all players. I want the player who controls the unit to be able to select it, but enemy players only able to target it.
(EDIT) Edward: I just read the end of your post where you say you know how to do this with triggers, so I guess my reply is redundant. Let me know if you find a better way though.
I second this. I think you will need to use triggers. Here's one idea:
1) First do a preliminary search on the 2d plane surrounding the unit using the cone ability. Probably just use a 2d circle which includes all the x and y points contained in the cone.
2) Collect all the units that are found in that preliminary search in to a list. Then for each of them, get their x, y, and z position values and plug those in to a function to validate if the unit is within the cone area (you might have a different function to validate each cone type, or just have some extra parameters for that).
3) Apply whatever effect you wish to all the units that were in the cone.
Do you have a physics engine implemented with triggers, or are you using the native collision detection? I will assume the latter. In that case, I am not sure of the best method, but a couple options are: 1) look in to 'attachment points' (sorry I haven't used them yet so I'm ignorant), 2) create a looping trigger or behavior for the latched unit which constantly updates it's position to be the same as the tentacle position.
Option 1 is probably your best bet as I think it's designed for this sort of thing.
My recommendation is to have a global array which keeps track of all of your dialog items, each indexed by a unique ID. In your "DestroyDialog" method, simply update this array, replacing True with False or <Dialog Item> with <No Dialog Item>, depending on the data type you choose to store in the array. This should let you easily check if it still exists.
For any who are interested, I have implemented a hack to accomplish this using Triggers. Note that I am using dialog boxes rather than command buttons for my spells, since they change frequently during game play.
This is not pretty and ideally I would like to be able to use the built-in methods to do this (i.e. whatever happens when you use targeted command card abilities). If you have a better method or idea of how I can more easily make it work like a command card ability, please post it!!
Here's how it works:
1) I have two global variables: TargetingPlayers = False <Boolean[16]> and PendingSpells = 0 <Integer[16]>.
2) I have a Trigger that runs on event "any player clicks a dialog box". If the dialog box clicked corresponds to a spell which requires a target, then TargetingPlayers[(Triggering Player)] = True and PendingSpells[(Triggering Player)] = spellID (the spell ID is looked up based on the dialog that was clicked).
3) I have a different Trigger that runs on event "any player clicks mouse button". Whenever a player clicks a mouse button, this checks all the values in TargetingPlayers. If any of the values in TargetingPlayers is True, then the coordinates of the mouse click are recorded in local variables and then the spell in PendingSpells[(Triggering Player)] is cast, passing the proper mouse coordinates in as a point. TargetingPlayers and PendingSpells are then reset to their default values since the spell has been cast.
ISSUES with this are:
- Requires Triggers that run all the time on all mouse clicks (and key clicks too because I want players to be able to set hotkeys for the dialog box spells). This generates a fair amount of traffic.
- I'm not sure how to change the player cursor to crosshairs to indicate they are in targeting mode. This happens automatically when targeted effects are applied by an ability being used from the command card.
Usually when a unit uses a targeted ability or effect, the player's cursor turns in to a crosshairs and allows them to select the target.
My question is, how do I do this with Triggers?
I am aware of the functions "Order Unit" and "Create Effect", but all of those seem to require a point be entered in the Trigger (no option to solicit player input).
I would like to give each player on my map a static 'inventory' of effects (which can trigger spells etc). When a unit is selected, I still want that unit's command card displayed, but the Player Inventory should be displayed at all times in addition regardless of unit selection.
Anyone experienced a similar issue? My current approach is to just use custom dialog boxes on screen. Even with the UI improvements in 1.5, I can't find a more elegant solution.
My way of doing is. Setting command card ability info by catalog set value (images, tooltips, names etc...).
Then I save the spell I wana use to data table (I use trigger based spells to make this work). And when the spell is cast it runs the trigger that is stored in the data table (it does transfer triggering unit, triggering player and all that good stuff if you run other triggers)
And I disable/allow abilities depending what type of spell it is (Unit target, Point target or Instant). So basically you need 3 different types of spells on unit and modify them with triggers.
This is only sollution for my own game. So if you think its something you could use, go ahead. I think its way easier to manage levels/damage etc...with triggers than in data.
This is sort of a work around stuff for sure. But it does function perfectly fine for me.
So assume that each player has 5 ability slots, which are changing throughout the game. Are you suggesting that I:
1) create three dummy effects for each slot (one for unit target, one for point target, and one for instant) - call them DE[1-5][a-c], 15 total since I'm assuming there are 5 ability slots
2) have a data table (call it DataTable) correlating each dummy ability to a spell trigger
3) when I wish to give a player a new spell trigger "PewPew" in slot 3, use Catalog Set to update the UI of commandbutton03 and update the effect (to say, DE3a), and then update the data table to so that DataTable[DE3a] = "PewPew" (the spell trigger that I want to run when the ability is used by clicking commandbutton03)
4) for each of the 15 dummy effects, there is a separate trigger. So if the player clicks commandbutton03, TriggerDE3a picks up that the dummy effect DE3a was just used, and then runs the trigger stored in DataTable[DE3a], which is the "PewPew" spell.
I think this would work, but I think my implementation is too complex, especially with the need for 3 effects for each command button and then a separate trigger for every event. Is there a way that I can append some metadata on to the events to at least consolidate the number of triggers I need?
Is it possible to use the items via hotkeys rather than clicking them individually by mouse? I'm having difficulty understanding the actual mechanism for this. Like Renee mentioned in OP, this would be able to simulate the Add Ability function from Warcraft3, which is essentially what I'm trying to accomplish. Or is that what's going to be in parts 2-4?
1) Can you specify how I can dynamically add and remove abilities for a unit using triggers? Should I just add all 300+ abilities to the unit initially and enable/disable them as necessary?
2) How to I tell the hero unit to use the ability when the corresponding dialog is clicked?
0
@Renee2islga: Go
Edit 2: Figured out how to set hotkeys for inventory items. It turns out the new UI area of the editor does not allow you to modify the gamestrings.txt and gamehotkeys.txt file. For anyone else interested, you need to use an MPQ editor and open up your <map name>.SC2Map file. Then browse to <map name>.SC2Map/enUS.SC2Data/LocalizedData and edit the GameHotkeys.txt file. Remember to exit the SC2 editor and game first so that you can edit the files.
For example, I added the following lines to GameHotkeys.txt:
UI/Hotkey/C00B01=1
UI/Hotkey/C00B02=2
UI/Hotkey/C00B03=3
UI/Hotkey/C00B04=4
UI/Hotkey/C00B05=5
UI/Hotkey/C00B06=6
UI/Hotkey/C00B07=7
UI/Hotkey/C00B08=8
UI/Hotkey/C00B09=9
The above lines specify hotkey aliases that I can now use in my custom UI files.
So now that I've saved the updated GameHotkeys.txt file, I re-open the editor, go to the UI section, find the button that I want to add the hotkey for (in this example I had first created an override file to change the UI layout of inventory container buttons), and add the appropriate <Shortcut> tag line:
<Frame type="CommandButton" name="Slot01">
<Anchor side="Left" relative="$parent" pos="Min" offset="0"/>
<Shortcut val="@UI/Hotkey/C00B01"/>
<Width val="120"/>
<Height val="120"/>
</Frame>
This sets the first inventory slot to have '1' as its hotkey (as specified in the GameHotkeys.txt file)
0
@Renee2islga: Go
I'm still not sure how to add hotkeys for the inventory slots. Even going to the menu in-game and assigning hot keys does not work for some reason.
0
I'm trying to get this to work well with window re-sizing and without weirdness with offscreen buttons. For the inventory panel, why do you need to specify a height and width when you already have anchors? I would like everything to be relative, so is there a way around this?
p.s. For any other noobs trying to figure this out, note that (0,0) is in the UPPER LEFT of the screen. This fooled me for a while. That means that when specifying anchors for Top and Bottom, 'min' and 'max' probably mean the opposite of what you expect.
0
@FuzzYD: Go
I was considering that. Thanks for the input!
0
Is there a way to do this? I know about the 'unselectable' unit flag in data, but that makes the unit unselectable for all players. I want the player who controls the unit to be able to select it, but enemy players only able to target it.
0
(EDIT) Edward: I just read the end of your post where you say you know how to do this with triggers, so I guess my reply is redundant. Let me know if you find a better way though.
@Kueken531: Go
I second this. I think you will need to use triggers. Here's one idea:
1) First do a preliminary search on the 2d plane surrounding the unit using the cone ability. Probably just use a 2d circle which includes all the x and y points contained in the cone.
2) Collect all the units that are found in that preliminary search in to a list. Then for each of them, get their x, y, and z position values and plug those in to a function to validate if the unit is within the cone area (you might have a different function to validate each cone type, or just have some extra parameters for that).
3) Apply whatever effect you wish to all the units that were in the cone.
0
@Mephs: Go
Do you have a physics engine implemented with triggers, or are you using the native collision detection? I will assume the latter. In that case, I am not sure of the best method, but a couple options are: 1) look in to 'attachment points' (sorry I haven't used them yet so I'm ignorant), 2) create a looping trigger or behavior for the latched unit which constantly updates it's position to be the same as the tentacle position.
Option 1 is probably your best bet as I think it's designed for this sort of thing.
0
My recommendation is to have a global array which keeps track of all of your dialog items, each indexed by a unique ID. In your "DestroyDialog" method, simply update this array, replacing True with False or <Dialog Item> with <No Dialog Item>, depending on the data type you choose to store in the array. This should let you easily check if it still exists.
0
@kappyd23s: Go
For any who are interested, I have implemented a hack to accomplish this using Triggers. Note that I am using dialog boxes rather than command buttons for my spells, since they change frequently during game play.
This is not pretty and ideally I would like to be able to use the built-in methods to do this (i.e. whatever happens when you use targeted command card abilities). If you have a better method or idea of how I can more easily make it work like a command card ability, please post it!!
Here's how it works:
1) I have two global variables: TargetingPlayers = False <Boolean[16]> and PendingSpells = 0 <Integer[16]>.
2) I have a Trigger that runs on event "any player clicks a dialog box". If the dialog box clicked corresponds to a spell which requires a target, then TargetingPlayers[(Triggering Player)] = True and PendingSpells[(Triggering Player)] = spellID (the spell ID is looked up based on the dialog that was clicked).
3) I have a different Trigger that runs on event "any player clicks mouse button". Whenever a player clicks a mouse button, this checks all the values in TargetingPlayers. If any of the values in TargetingPlayers is True, then the coordinates of the mouse click are recorded in local variables and then the spell in PendingSpells[(Triggering Player)] is cast, passing the proper mouse coordinates in as a point. TargetingPlayers and PendingSpells are then reset to their default values since the spell has been cast.
ISSUES with this are:
- Requires Triggers that run all the time on all mouse clicks (and key clicks too because I want players to be able to set hotkeys for the dialog box spells). This generates a fair amount of traffic.
- I'm not sure how to change the player cursor to crosshairs to indicate they are in targeting mode. This happens automatically when targeted effects are applied by an ability being used from the command card.
0
Usually when a unit uses a targeted ability or effect, the player's cursor turns in to a crosshairs and allows them to select the target.
My question is, how do I do this with Triggers?
I am aware of the functions "Order Unit" and "Create Effect", but all of those seem to require a point be entered in the Trigger (no option to solicit player input).
Does anyone know how to do this?
0
I would like to give each player on my map a static 'inventory' of effects (which can trigger spells etc). When a unit is selected, I still want that unit's command card displayed, but the Player Inventory should be displayed at all times in addition regardless of unit selection.
Anyone experienced a similar issue? My current approach is to just use custom dialog boxes on screen. Even with the UI improvements in 1.5, I can't find a more elegant solution.
0
So assume that each player has 5 ability slots, which are changing throughout the game. Are you suggesting that I:
1) create three dummy effects for each slot (one for unit target, one for point target, and one for instant) - call them DE[1-5][a-c], 15 total since I'm assuming there are 5 ability slots
2) have a data table (call it DataTable) correlating each dummy ability to a spell trigger
3) when I wish to give a player a new spell trigger "PewPew" in slot 3, use Catalog Set to update the UI of commandbutton03 and update the effect (to say, DE3a), and then update the data table to so that DataTable[DE3a] = "PewPew" (the spell trigger that I want to run when the ability is used by clicking commandbutton03)
4) for each of the 15 dummy effects, there is a separate trigger. So if the player clicks commandbutton03, TriggerDE3a picks up that the dummy effect DE3a was just used, and then runs the trigger stored in DataTable[DE3a], which is the "PewPew" spell.
I think this would work, but I think my implementation is too complex, especially with the need for 3 effects for each command button and then a separate trigger for every event. Is there a way that I can append some metadata on to the events to at least consolidate the number of triggers I need?
0
@Renee2islga: Go
Could you elaborate on how I would go about dynamically changing the ability in a command card slot (or other dialog button) using triggers?
0
I would like to know this as well.
0
@zenx1: Go
Alright, this may be what I end up doing.
1) Can you specify how I can dynamically add and remove abilities for a unit using triggers? Should I just add all 300+ abilities to the unit initially and enable/disable them as necessary?
2) How to I tell the hero unit to use the ability when the corresponding dialog is clicked?