Dynamically placed buttons

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
Okay, dynamically might be the wrong word. Here's what I am trying to do:

A unit has an inventory. The items can give abilities that only show up if you have the item. The problem is that there will be a lot of items, more than there are slots on the command card so a button has to be able to appear in several places.

Now I could do this in several ways but all ways I can think of are incredibly messy and takes a lot of extra work.

First of all, I'm pretty sure I have to add the button of all abilities to all slots where they can appear. I then have to make sure I only show one of the buttons of the same abilities and only if the unit has that item.

If anyone could think up a good solution for this, I'd be grateful.

If you have a solution that includes triggers, that's fine too but I prefer data.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
have you considered making dialog buttons and positioning them correctly to simulate buttons? that way you could move them arround as you please
 

Kyuft

Member
Reaction score
11
Wait... that's not normal?
And Siretu, you will probably have to do something with triggers and custom functions. Something like,
If
That slot on the card is not full,
then put it there
else,
put it somewhere else.

-Kyuft:shades:
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
I am usually very good at finding the answer myself so I rarely ask for help.

The problem with doing this with triggers(if I don't do it with dialogs as GFreak suggested, which by the way is a solution but it's not a good one) is that there's no way that I know of to interact with the command card with triggers.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
???
you mean you cant use the command card natives?
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
the trigger actions dealing with command cards, ie: Disable Command Card, etc.
 

Kyuft

Member
Reaction score
11
If i remember correctly, there is a few command card actions. However, I cannot remember where i saw them.

-Kyuft:shades:
 

Dave312

Censored for your safe viewing
Reaction score
269
the trigger actions dealing with command cards, ie: Disable Command Card, etc.

I think you may be thinking of Enable/Disable Command Type which is used for disabling ability commands. I recall no functions/actions that deal directly with the command card.
 

Jokker

Member
Reaction score
16
Depends on how many abilities there are...
If you don't want to mess around with buttons at all, you could add a hotkey in item description, so it would be activated with hotkeys only.
 

Dave312

Censored for your safe viewing
Reaction score
269
Have you tried using the Catalog function to set the positions of the buttons? That would probably be the easiest way of doing it (if it works).
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
I actually thought of using the catalog functions yesterday and spent a lot of time yesterday trying to get it to work and I didn't want to post about it until I was sure it'd work.

From my testings, it seems like moving the positions of buttons is not allowed(since catalog field value set has some fields it can't set because they're protected). What I did instead was to have 6 dummy buttons and 6 dummy abilities. One for each slot. I can then keep track of which items the unit has and change the name and description of the dummy abilities to reflect that.

This works as of now. If I have 3 of item A and 3 of item B, I'll get one button(not 3) for ability A and one button for ability B.

There are still some problems though that I think I can solve but which will take some time. Right now, the dummy abilities are all of the type "Effect - instant". I need some abilities to be "Effect - Target". I can't change the type so I probably need to have 6 more abilities and switch between them. There's also the problem that my "Effect - target" abilities can either have a unit target or a point target and I wasn't able to change between the two with catalog set. This means I'll probably need 6 more abilities(18 in total, sigh). Fortunately, it's still just a constant amount of work and adding a new item wont be a ton of work when the initial work is done.

There's one final thing I also have to do, I have to make a dialog overlay with images for the buttons since unfortunately, "Catalog field value set" can't modify the icon of a button so I'll just skip the icon for the button and do it with dialogs.

The reason I cant do the entire thing in dialogs is that some abilities require targeting and if I press an ability that requires a target, I can't by triggers get it to enter the targeting mode. I could fake it and overlay a picture of a target cursor on the cursor and change everything but that'd be stupid.
 

Dave312

Censored for your safe viewing
Reaction score
269
There's one final thing I also have to do, I have to make a dialog overlay with images for the buttons since unfortunately, "Catalog field value set" can't modify the icon of a button so I'll just skip the icon for the button and do it with dialogs.

What about using the Command Card: Level Button Image property on the dummy abilities to set the button image and setting the ability level to 2? With any luck you will have access to that.

Sounds like no matter which way you do it, it is going to be a lot of work. I wonder whether it might just be easier to scrap the command card and use an inventory to act as one instead.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top