• 🏆 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!

JASS function to make an invisible unit revealed

Status
Not open for further replies.
Level 12
Joined
May 22, 2015
Messages
1,051
Hello.

I am working with a custom buff system in my map and I want to have it so a particular buff reveals invisible enemies that have it placed on them.

Functionally, it is the same as the faerie fire ability with some extra custom effects on it. I could make a dummy cast the faerie fire spell on them, but it will look a bit ugly with my custom buff system (it will show 2 buffs and purging the buff will not be as straight forward).

I am currently doing something like this:
JASS:
    call UnitShareVision(targetUnit, castingPlayer, true)

This shares what the unit sees with me, but it does not reveal the unit if it is invisible.

Is there a different function I can use that does what I want? If not, I will try to throw something together with the faerie fire spell, but I'd rather do that as a last resort.

Thanks in advance!
 
Level 39
Joined
Feb 27, 2007
Messages
5,023
Probably use Faerie Fire. I think your only other solution would be to create locust dummy units with minimum non-zero sight radius and true sight and then periodically move them to be on top of the unit that should be revealed.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,567
How does your custom buff system work? Does it use abilities as the buffs (hidden Auras) or are you sticking with dummy units that cast slow, stun, etc...?

I found that working with abilities as buffs is a lot more flexible. For example, you can base the buff off of the Slow Aura ability, which is a hidden ability that will display a buff. Then you can add this ability to units to mimic buffs and use a timer to remove the ability (buff) after X seconds.

Then if you wanted the buff to be hidden you could do something like this:
  • Unit - Add Buff (Test) to Archmage 0066 <gen>
  • Unit - For Archmage 0066 <gen>, Ability Buff (Test), Disable ability: True, Hide UI: True
  • Unit - Remove Buff (Test) buff from Archmage 0066 <gen>
This prevents the buff from being applied to the unit since the ability is disabled. What's nice about this is that the unit still has the ability, so you can still check things like "If level of "Buff (Test) for triggering unit = to 1" to check if a unit has the ability (buff).

With this setup you can use the Faerie Fire ability without having two buffs since you can hide one of them.

Obviously this might not work for what you have planned, but I don't think it'd be too cumbersome to add in some extra functionality for cases like these. There's no other quick and easy solution as far as I know.
 
Last edited:
Level 12
Joined
May 22, 2015
Messages
1,051
How does your custom buff system work? Does it use abilities as the buffs (hidden Auras) or are you sticking with dummy units that cast slow, stun, etc...?

I found that working with abilities as buffs is a lot more flexible. For example, you can base the buff off of the Slow Aura ability, which is a hidden ability that will display a buff. Then you can add this ability to units to mimic buffs and use a timer to remove the ability (buff) after X seconds.

Then if you wanted the buff to be hidden you could do something like this:
  • Unit - Add Buff (Test) to Archmage 0066 <gen>
  • Unit - For Archmage 0066 <gen>, Ability Buff (Test), Disable ability: True, Hide UI: True
  • Unit - Remove Buff (Test) buff from Archmage 0066 <gen>
This prevents the buff from being applied to the unit since the ability is disabled. What's nice about this is that the unit still has the ability, so you can still check things like "If level of "Buff (Test) for triggering unit = to 1" to check if a unit has the ability (buff).

With this setup you can use the Faerie Fire ability without having two buffs since you can hide one of them.

Obviously this might not work for what you have planned, but I don't think it'd be too cumbersome to add in some extra functionality for cases like these. There's no other quick and easy solution as far as I know.

Thanks for the idea! I am, indeed, using the slow aura ability to apply buffs.

I hadn't heard about hiding the buffs like that before, but I think I can hack something together a little bit. As is, I already pass the slow aura ability ID along with the buff ID when applying a buff so that they can be removed together automatically (the buff from the aura lingers if you don't do that). I think I can make a dummy cast the faerie fire spell on the target and pass an ability ID for some do-nothing passive (like item damage bonus that gives 0 damage). Then my buff system will remove it together like normal (ability ID is for the do-nothing passive, buff ID is for the faerie fire buff).

It should work, at least, and it's not that much of a hassle this way. Maybe I can see what happens if I just pass 0 for the ability ID and skip the do-nothing passive.
 
Status
Not open for further replies.
Top