• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Detect if a unit is invisble under Shadow Meld

Status
Not open for further replies.
Level 18
Joined
Nov 1, 2006
Messages
1,612
I'm having trouble determining whether or not a unit is "hidden" via the Shadow Meld ability. The ability is passive and does not create a buff on the affected unit. So far, I've found the following functions inadequate for this particular type of check.

IsUnitVisible() This checks if a target unit is visible within the sight range of any of the units of the designated player.

IsUnitInvisible() This checks if the target unit is not visible within the sight range of any of the units of the designated player.

IsUnitDetected() This checks if the target unit has been detected by any of the units of the designated player.

IsUnitHidden() This checks if the target unit is hidden via the ShowUnit() function.

So with that information in hand, does anyone have a solution to determining whether or not a unit is currently under the effect of shadow meld?
 
Last edited:
Level 12
Joined
Mar 13, 2012
Messages
1,121
Shadow Meld is a problem, no order, no buff, no nothing.

In my opinion replace it by a Permanent Invisibility with a periodic check whether the unit has an order currently. If yes, remove the invisibility by trigger. If no, add it. Depending on your map you might have to use additional triggers of course.
 
Level 18
Joined
Nov 1, 2006
Messages
1,612
I think you can check for the current game time and combine that with a condition that checks if the level of shadow meld is greater than 0 (with a unit group)

I could try and combine this suggestion with Ezekiel12's. You would still need to check if the unit has an order (other than hold position). If they do, then they will be visible. If they don't, then they will be under the effect of shadow meld.
 
Level 18
Joined
Nov 1, 2006
Messages
1,612
if IsUnitVisible(unit, Player(PLAYER_NEUTRAL_AGGRESSIVE)) then
It should work..

Dalvengyr, if you look at the OP you'll see I tried that solution already. It doesn't work.

IsUnitVisible(): This checks if a target unit is visible within the sight range of any of the units of the designated player.
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
I don't know exactly how your spell works, or even what it is...

Doesn't it use any buff on units ?

If the spell already reveals all nearby units, then you should pick all units around the caster and do whatever you want..
I'd be glad to help if you have a description for the spell ^^
 
Level 18
Joined
Nov 1, 2006
Messages
1,612
Jonhysone, I'm not currently incorporating this check into a spell. It's part of an AI system which will prevent a unit from attempting to target another unit if it is invisible via Shadow Meld.

The AI system I've created evaluates all units within a base 1000 (+100 in loop) range and picks a random enemy to head in the direction of to attempt an attack. However, if that unit is under the affect of Shadow Meld, my AI unit will simply stay in the same place and not move since it is unable to target an invisible unit. And I don't want to solve this by giving vision to the unit because they should remain invisible and untargetable.
 
I've recently run an issue like this and had to come up with an alternative. Basically I used IsUnitMoving by Bribe and then a timer to have an effect taking place. In your case, you can issue boolean saving on the unit (via hashtable for example), once the timer expires; when you want to see if the unit is visible, simply load the respective value from the hashtable and if it's true, it's under the effect of Shadow Meld (and thus invisible). In my case I am only adding two abilities to the unit.

Unfortunately you need to run this under multiple events so as to catch every possible case.

The script is in GUI, but you can get the idea of how it should work.

Best of luck.
 

Attachments

  • AutomaticShadowMeld1.w3x
    25.7 KB · Views: 42

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
Dalvengyr, if you look at the OP you'll see I tried that solution already. It doesn't work.

Guys, please. That line is enough to check unit's any invisibility. Remember that my script above will only return true if checked unit is an enemy of desired player and unable to be seen by the player.

Read carefully, try it. Solved ;)

Jonhysone, I'm not currently incorporating this check into a spell. It's part of an AI system which will prevent a unit from attempting to target another unit if it is invisible via Shadow Meld.

The AI system I've created evaluates all units within a base 1000 (+100 in loop) range and picks a random enemy to head in the direction of to attempt an attack. However, if that unit is under the affect of Shadow Meld, my AI unit will simply stay in the same place and not move since it is unable to target an invisible unit. And I don't want to solve this by giving vision to the unit because they should remain invisible and untargetable.

Well, you want to remove shadow-meld-ed-only units or any invisible unit? If it's "any", then that script should be enough.

Here is a test map if you are too busy to test it by yourself. And it works.
 

Attachments

  • test.w3x
    16.4 KB · Views: 62
Last edited:
Level 18
Joined
Nov 1, 2006
Messages
1,612
cant you just check buff, since the unit should get shadow meld buff, or am I mistaken?

Shadow Meld does not create a buff on the unit.

Read carefully, try it. Solved ;)

If the unit is behind Fog of War then IsUnitVisible() will always be FALSE. As a result, the script won't work for me.

Scenario: A Murloc is stationary, out of sight range of the AI Hero. My AI script targets the Murloc to attempt an attack. Calling IsUnitVisible() will always return FALSE because that unit is behind Fog of War and out of sight range.
 
Level 18
Joined
Nov 1, 2006
Messages
1,612
Hmm, you can use one unused player slot then, just like Player(15). Give it global sight, then use that script above.

if IsUnitVisible(unit, Player(15)) then

I believe that global sight shows invisible units, or am I wrong? Either way, you make a good point. I could hypothetically create a dummy unit for an unused player slot and put it in range of the target unit and then call IsUnitVisible(). I'll try that tonight and see if it works!
 
Level 12
Joined
Mar 13, 2012
Messages
1,121
Dalvengyr your proposal is by far not enough for every situation as there are countless other ways to be invisible apart from Shadow Meld. Also global sight for a player 15 (which is used in some maps) can mess things up. Depends on 1)ark_NiTe's map.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
it was posted before, check if time is between 18:00 and 6:00 and check if level of shadowmeld(every variation you have on the map) is > 0. Also download Bribe's library that checks if unit is moving or not, and if it isnt moving, there is very high chance it is shadowmelded(there is the fade delay, but meh, nothing is perfect :D)
 

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
Dalvengyr your proposal is by far not enough for every situation as there are countless other ways to be invisible apart from Shadow Meld. Also global sight for a player 15 (which is used in some maps) can mess things up. Depends on 1)ark_NiTe's map.

I've told you that script works for any kind of unit's invisibility, if the unit can't be seen in player's screen => return false.
Also global sight for a player 15 (which is used in some maps) can mess things up.
Elaborate?

It's the easiest way I can offer, if you want to pick the other it's up to you ;)

Have a good day...
 

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
Nothing interesting to elaborate. A player having vision over the whole map, also when computer, can potentially mess things up. Just a reminder to exercise caution.

Okay, anyway, I didn't say it should be player 15. But one unused player slot. And dummy unit can't do anything if you use it.
 
Status
Not open for further replies.
Top