HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

targetable UI icon

01-24-2011, 11:59 AM#1
Ignifex
Hello all,

I have been trying to get some icons on the screen, showing the status of allied units, and allowing the player to click the icons, instead of the allied unit, to target spells.
I used a method similar to a UI technique posted on these boards, using units as icons and continuously setting their position to remain in front of the camera. So far so good, the icons show up where I want them and are selectable/targetable.

The problem I am now having is making sure they do only what I intended them for, without acting as units themselves.
Adding locust won't work, as they can no longer be targeted/selected, making them useless.
I tried making them invulnerable, which keeps the enemy units away at least, but spell targeting no longer seems to work then.
Visibility is something I have now solved by setting their scaling value to 0 for all but the viewing player. Drag-select will still work then of course.

Any ideas on how to get these units the way I want them?
They should remain alive, not be targetable by enemy or allied units/players, not be selectable preferably (can be undone..), but remain targetable by the viewing player.
01-24-2011, 12:18 PM#2
Here-b-Trollz
Make them invisible (buff/ability) + massive health regen and paused?

Oh duh, detection.

My other suggestion would be to give them to player 15 (neutral passive)


EDIT 2:
Non-selectable bleh... I'm so off my game. It's been too long.
01-24-2011, 02:42 PM#3
Anitarf
I recall dealing with targetable, but not selectable units before. I posted my findings in the documentation of my Glacial Wall spell. Note that a unit like that can still be attacked by enemies (unless made invulnerable, in which case you can't target them yourself as you noted), but there are other ways of dealing with that.

One way is to use an unused classification for those units, such as ancient or suicidal. These two classifications can be selected in the "targets allowed" field for attacks and spells, so it is possible to make attacks and spells unable to affect such units.

Another method, in case you have no units that deal magic damage, would be to make these units ethereal, although the colour change that comes with the ethereal ability may be hardcoded so it can not be removed.
01-24-2011, 02:54 PM#4
Ignifex
Here-b-Trollz:
I tried all of those, unfortunately. Selection is probably the biggest problem though.

Very interesting Anitarf, I will have a look at it shortly.

As I was working on it some more, I noticed a second related problem which may be even more important to solve first. If I direct a spell at the icon-unit, how to redirect it to the actual unit. This would normally not be so much of a problem (pause, stop, unpause, recast), but my spells are mainly inside spellbooks.
So in short, I also need to figure out how to order a unit to cast a spell from inside a spellbook, which can't be done for as far as I know.
01-24-2011, 07:08 PM#5
Anitarf
The only thing that comes to mind is completely triggering all the effects of the spell, that way it doesn't matter if it's actually cast on your relay unit instead of the actual unit. However, this would complicate your system somewhat as the dummy unit would need to be temporarily moved to the position of the actual unit from the point when the spell order is given to the point when the spell is cast so that the spell's cast range is properly observed. In the meantime, a new dummy unit would need to be put in its place on the screen, which can itself do the same thing. So, all in all, you would need a stack of such dummy icon units that you would constantly recycle.

By the way, I assume this is a singleplayer project. It has just occurred to me that moving units to the position of a player's camera would cause a server split in multiplayer (unless players' cameras were locked and thus synced).
01-25-2011, 11:08 PM#6
Ignifex
Nope, it's multiplayer, and it works nicely.
I'm creating the units for each player, but apparently SetUnitScale with different scaling values doesn't cause desyncs. So I simply use 0 for the other players. : )

I just thought of something that hadn't even crossed my mind yet. Using default hero icons failed before, since I have 6 heroes (5 others), owned by different players. The maximum amount of friendly hero icons across players is 4. But if I use a more regular dummy for each other hero/unit, created for each player and owned by himself, then the hero icon limit does not apply! (since you would be seeing them as though they were your own)
So at the moment I use a normal dummy unit with locust, based on a dummy showing a hero icon. This seems to work exactly as I like, because apparently, the unit is still targetable through its icon.

I'll still be using the "icon units" for onscreen text and images though. But without any interactivity I'll just give them locust and be done with it.

I guess faking the spell effect is probably the best option. All of my spells are custom scripted, so I guess I'll give the hero/unit, or perhaps each player, a "unit icontarget" property or something, so I know to use a different target than GetSpellTarget(). Keeping the dummy's location equal to its respective hero/unit solves distance and such, as you proposed.

Thanks for sharing your thoughts. I think I can get this to work now. : )
And I'll just take this opportunity to thank you for your systems, which have been really helpful.
01-26-2011, 12:29 AM#7
Fledermaus
You can get 7 Hero icons on screen at once. All except Pink (the 8th hero) will show up as an icon in this testmap
Attached Files
File type: w3xAllied Targeting.w3x (10.8 KB)
01-26-2011, 09:39 PM#8
Anitarf
Quote:
Originally Posted by Ignifex
Nope, it's multiplayer, and it works nicely.
I'm creating the units for each player, but apparently SetUnitScale with different scaling values doesn't cause desyncs. So I simply use 0 for the other players. : )
Oh, I didn't mean the scaling, I meant the unit position. The positions of players' cameras are not synced in a multiplayer game, so getting the camera's position will simply return the values for the local player. I'm not sure if moving a unit to a different position for each player causes a desync in and of itself, but it certainy does once those units block pathing for other units/attack/die. Of course, if your dummy units do none of that, perhaps moving them to a local coordinate won't desync the game.

Quote:
I guess faking the spell effect is probably the best option. All of my spells are custom scripted, so I guess I'll give the hero/unit, or perhaps each player, a "unit icontarget" property or something, so I know to use a different target than GetSpellTarget(). Keeping the dummy's location equal to its respective hero/unit solves distance and such, as you proposed.
I would recommend using SpellEvent; it's fairly easy to modify triggered spells to use it instead of native triggers, it is more efficient and most importantly it makes the kind of systematic redirection of triggered spell effects that you need here a piece of cake (see the second example).
01-27-2011, 11:33 AM#9
Ignifex
To Fledermaus:
Oh wow, I completely missed the SetReservedLocalHeroButtons function. It seems that does indeed solve the issue completely. I also never knew you can use just shared advanced unit control to get the icons to show, without gaining control over the other's units. Thanks! This is perfect for what I need. : )

To Anitarf:
I should probably say I am creating the icons for each player, for each player. : )
I'm using a custom camera system (similar to Oppicam, but more flexible, integrated with other functionality and with correct zoffset handling) so that I know exactly where the camera is at each moment in time. I am also tracking its position for each player, so that each local player knows where all the player cameras are. Then it's simple to get the uniticons to show up for each player's camera and hide those that aren't your own.
I'm pretty sure moving a unit already uses nettraffic -> desync.

SpellEvent looks like it will be a good asset to my map as it will save me the trouble of writing a lot of the same code and for improved performance too! Thanks again.

Regards,
Ignifex
01-27-2011, 12:37 PM#10
Fledermaus
No problem :) You could even set it to 2 since you only have 6 players, then you'd have a gap between your hero and everyone else's.