• 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.

Any way to avoid Channel based abilities waking enemies?

Level 9
Joined
Aug 16, 2019
Messages
83
I assume the answer to this question is no, but I have to ask since it's a rather annoying little issue that really shouldn't work like that. Channel based abillities with a unit target will wake the target even if they have no effect and worst of all at the start of the follow through time rather than after. Even just for an ability with regular cast time it's an issue since other abilities wouldn't wake them like that.
Any solutions?
 

Remixer

Map Reviewer
Level 33
Joined
Feb 19, 2011
Messages
2,112
Mmmh. Curious question and from quick testing and checking of natives I'd say that's impossible.

The game seems to differentiate nocturnal and spell-sleep, and since (as far as I know) there's no native to put a unit to sleep, then I think the easiest solution is to never actually act any effects on the sleeping unit, but just pretend to.

Essentially, detect when your Channel is cast on a sleeping unit ( that would wake up ), interrupt the Channel cast and cast something else (on the unit's location) and handle the effects without the Unit Target-Channel.
 
Level 9
Joined
Aug 16, 2019
Messages
83
I tried to be smart and use a beneficial spell like Rejuvenation with enemy targeting, but even that causes them to wake up, so it might just not be Channel but some hard coded shenanigans at play
Hmm I'm pretty sure most targeted spells won't wake them before the actual effect hits though, but the really frustrating part about Channel is that even if it's just set to "Unit or Point Target", targeting a unit will wake it up immediately.

As for Remixer thanks for the suggestion, but I fear that's just to many steps for it to make sense to use Channel in the first place at that point, at least for me.
 

Remixer

Map Reviewer
Level 33
Joined
Feb 19, 2011
Messages
2,112
As for Remixer thanks for the suggestion, but I fear that's just to many steps for it to make sense to use Channel in the first place at that point, at least for me.
It doesn't really matter which ability you use to detect the event, since the ability would never a really get casted, but only acts as a way for players to trigger the event.
 
Level 29
Joined
Sep 26, 2009
Messages
2,596
I tried to be smart and use a beneficial spell like Rejuvenation with enemy targeting, but even that causes them to wake up, so it might just not be Channel but some hard coded shenanigans at play
The reason why that happens is because any time a unit starts the effect of an ability on an enemy the target of the ability takes 0.00 damage.
I tried to bypass that by ordering the enemy unit to stop and then calling on it Doc - UnitAddSleep (even with a delay after it wakes up) but it did not seem to do anything - seems the unit's hardcoded behavior is to remain awake as long as it has enemy nearby it can attack.

One possible way to solve this is to use Channel's 'Casting Time' field. When unit is channeling the spell, it does not yet wake the target. So possibly, instead of having this event:
  • Unit - A unit Starts the effect of an ability
You set the 'Casting Time' to have same value as your 'Follow through Time' and detect start of the spell via event
  • Unit - A unit Begins channeling an ability
and finally, stop the unit's actual cast of the ability (which would wake the target) using
  • Begin Cast
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
    • Actions
      • Unit - Order (Triggering unit) to Stop.
The issue with this approach is I think only a single one - if the spell requires mana and unit loses that mana (i.e. via mana burn, etc.) then it immediately stops channeling the spell.
As you wrote, you need to manage mana removal and cooldown yourself.

Second approach I could think of is a bit more convoluted. You create two versions of your ability - one requires unit target and second is set to require no target (i.e. it is instant cast).
The targeting spell is a dummy spell, the instant cast is the actual spell.
Give both spell to your unit, but hide the instant-cast version.
Detect start of cast of the targeting/dummy ability via 'Beings channeling' event, hide the dummy/targeting ability, show the actual/instant one and issue the caster an order with no target - to cast the actual spell.
Use an event 'Unit stops casting an ability' to detect when the instant version has been stopped, hide it and show back the dummy/targeting version of the ability.
While with this approach you don't need to care for mana like in the previous option, you still need to manage cooldown on your own. It is also a bit more complicated because you need to keep track of the target of the ability.


Edit:
After writing my post, I've found out that the following seems to work just OK - the unit continued on sleeping:
  • Untitled Trigger 001
    • Events
      • Unit - A unit About to take damage
    • Conditions
      • ((Triggering unit) is sleeping) Equal to True
    • Actions
      • Custom script: if GetEventDamage() < 0.001 then
      • Set VariableSet sleepingUnit = (Triggering unit)
      • Unit - Pause sleepingUnit
      • Custom script: endif
  • Untitled Trigger 002
    • Events
      • Unit - A unit Takes damage
    • Conditions
      • (Triggering unit) Equal to sleepingUnit
    • Actions
      • Unit - Unpause sleepingUnit
 
Last edited:

Remixer

Map Reviewer
Level 33
Joined
Feb 19, 2011
Messages
2,112
I know but then you have to do manual cooldown, mana cost, cast time etc. You lose everything built into abilities except the targeting.
That's not entirely true, since you would only lose the cooldown which you would have to trigger - the rest you can include in the second ability that the unit is ordered to cast at the position of the unit (instead of on the unit itself), which means that the sleeping unit is not actually targeted and only used for player event detection.
Manacost, cast time, and the rest of the ability parameters are included in the second ability (which the unit would have to mimic casting behavior).
 
Level 9
Joined
Aug 16, 2019
Messages
83
Interesting, the Casting Time part might should be pretty useful to at least delay the wake and it's good to know the pause option exists as well.
Oh boy while the pause thing was kind of ingenius, it doesn't really work in practice because ofc the whole camp is pulled if you "damage" one of the units even if that unit stays asleep... I guess you can work around it by picking other sleeping units in a certain radius and doing the same for them, but you need to store the group so you can unpause them again afterwards. Also needs to check if the units are already paused so we don't accidentally unpause them then. Haven't decided yet if I'll use it but I think that's the best answer we'll find to solving this.
 
Level 24
Joined
Feb 27, 2019
Messages
833
I love to dabble with these kind of problems, especially when I find a solution.
Heres how it works: When a sleeping target is detected, for a frame when the effect occurs, swaps out the Channel Unit/Point ability for a Channel Point ability which causes the effect to occur on a point.
Channel 1 -> Unit/Point target
Channel 2 -> Point target (Instant works too)
Engineering upgrade -> Channel 1 to Channel 2
  • Sleepy Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Channel Unit/Point
    • Actions
      • Game - Display to (All players) the text: Starts the effect
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Target unit of ability being cast) is sleeping) Equal to True
        • Then - Actions
          • Unit - Add Engineering Upgrade to (Triggering unit)
          • Unit Group - Add (Triggering unit) to SleepyGroup
          • Countdown Timer - Start SleepyTimer as a One-shot timer that will expire in 0.00 seconds
        • Else - Actions
  • Sleepy Timer
    • Events
      • Time - SleepyTimer expires
    • Conditions
    • Actions
      • Game - Display to (All players) the text: Timer expires
      • Unit Group - Pick every unit in SleepyGroup and do (Actions)
        • Loop - Actions
          • Unit - Remove Engineering Upgrade from (Picked unit)
          • Unit Group - Remove (Picked unit) from SleepyGroup.
An alternative is to use the Stops casting event to remove the Engineering upgrade.
  • Sleepy Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Channel Unit/Point
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Target unit of ability being cast) is sleeping) Equal to True
        • Then - Actions
          • Unit - Add Engineering Upgrade to (Triggering unit)
        • Else - Actions
  • Sleepy Cast Stop
    • Events
      • Unit - A unit Stops casting an ability
    • Conditions
      • (Ability being cast) Equal to Channel Point
    • Actions
      • Unit - Remove Engineering Upgrade from (Triggering unit)
 

Remixer

Map Reviewer
Level 33
Joined
Feb 19, 2011
Messages
2,112
Heres how it works: When a sleeping target is detected, for a frame when the effect occurs, swaps out the Channel Unit/Point ability for a Channel Point ability which causes the effect to occur on a point.
This is what I've been proposing, but the poster doesn't want to gimmick with other abilities included. The pausing seems the second most practical solution, though it does indeed come with the downside of alarming other creeps and need of groups.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,876
I imagine the best solution would be your very own custom Sleep system.

Ideas:
1) Create unit groups for each creep camp, that way you can reference all units in a camp at once. (IE: Waking them all up when an individual is awoken)
2) Use the Sleep ability, or something like it, to disable the creeps at night.
3) Use a Damage Event to wake the units up, but with your own Conditions to allow certain effects to not wake them up.

This could open the door to other interesting mechanics as well. It could also be a major pain in the ass to get right, lol.
 
Level 24
Joined
Feb 27, 2019
Messages
833
This is what I've been proposing, but the poster doesn't want to gimmick with other abilities included.
Righty then. I got rid of the extra messy abilities for Stang. Id also want to stress that this is the full method, nothing else is required.
  • Sleepy Cast 1 Copy
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Channel Unit/Point
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Target unit of ability being cast) is sleeping) Equal to True
        • Then - Actions
          • Ability - Set Ability: (Unit: (Triggering unit)'s Ability with Ability Code: Channel Unit/Point)'s Integer Level Field: Target Type ('Ncl2') of Level: ((Level of Channel Unit/Point for (Triggering unit)) - 1) to 2
          • Unit Group - Add (Triggering unit) to SleepyGroup
          • Countdown Timer - Start SleepyTimer as a One-shot timer that will expire in 0.00 seconds
        • Else - Actions
  • Sleepy Timer Copy
    • Events
      • Time - SleepyTimer expires
    • Conditions
    • Actions
      • Unit Group - Pick every unit in SleepyGroup and do (Actions)
        • Loop - Actions
          • Ability - Set Ability: (Unit: (Picked unit)'s Ability with Ability Code: Channel Unit/Point)'s Integer Level Field: Target Type ('Ncl2') of Level: ((Level of Channel Unit/Point for (Picked unit)) - 1) to 3
          • Unit Group - Remove (Picked unit) from SleepyGroup.
 
Top