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

Is there a way to make a player team sleep like creeps do?

Level 5
Joined
Nov 17, 2022
Messages
84
This might be simple but I'm not sure where to start. I have a team that's played by the computer that represents Wildlife the players hunt. I'd like to figure out a way to make them sleep at night like creeps do, is that possible perhaps via triggers?
 
Level 30
Joined
Aug 29, 2012
Messages
1,383
I don't think it's possible to use the creep sleep, even with this function where they specifically say player units can't sleep

1721848256614.png


I suppose you could recreate it somehow by having a dummy casting a custom sleep spell on every unit of said player when it's night time, but that would need some additional work (recast it if they're attacked and then left alone, etc)
 
Level 5
Joined
Nov 17, 2022
Messages
84
what is your reasoning for not making them creeps? maybe that is easier to work around
Mostly because I got a system where if a player is killed by someone it tells you who killed them. But when I had them be natural hostiles it'd just be like "WolfChalk was killed by " with no name so it looked jarring.
 
Level 5
Joined
Nov 17, 2022
Messages
84
Do you think you could show me a screenshot example? I'm still learning triggers, this is my first major undertaking with them to challenge myself so it'd help a lot educational wise for me.
 
Level 12
Joined
Nov 13, 2010
Messages
277
  • Events
    • Unit - A unit Dies
  • Conditions
    • (Killing unit) Not equal to No unit
    • ((Owner of (Killing unit)) controller) Equal to User
    • ((Owner of (Killing unit)) slot status) Equal to Is playing
  • Actions
now you can just make them creeps
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
There's an ability called Sleep Always that you can use.
1721854170922.png


Here's a system I threw together to make it easy to setup for your map.
  • Sleep System Config
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • -------- Configure these to match the two custom abilitiies used by the PSS: --------
      • Set VariableSet Sleep_Ability_Always = Sleep Always (PSS)
      • Set VariableSet Sleep_Ability_Class = Sleep Class (PSS)
      • -------- --------
      • -------- Configure this to match the Player that has units which sleep: --------
      • Set VariableSet Sleep_Player = Player 2 (Blue)
  • Sleep System Day
    • Events
      • Game - TOD_Event becomes Equal to 1.00
    • Conditions
      • TOD_Is_Night_Time Equal to False
    • Actions
      • Set VariableSet Sleep_Group = (Units owned by Sleep_Player.)
      • -------- --------
      • Unit Group - Pick every unit in Sleep_Group and do (Actions)
        • Loop - Actions
          • Set VariableSet Sleep_Unit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Sleep_Ability_Class for Sleep_Unit) Equal to 1
            • Then - Actions
              • Unit - Remove Sleep_Ability_Always from Sleep_Unit
            • Else - Actions
      • -------- --------
      • Custom script: call DestroyGroup( udg_Sleep_Group )
  • Sleep System Night
    • Events
      • Game - TOD_Event becomes Equal to 1.00
    • Conditions
      • TOD_Is_Night_Time Equal to True
    • Actions
      • Set VariableSet Sleep_Group = (Units owned by Sleep_Player.)
      • -------- --------
      • Unit Group - Pick every unit in Sleep_Group and do (Actions)
        • Loop - Actions
          • Set VariableSet Sleep_Unit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Sleep_Ability_Class for Sleep_Unit) Equal to 1
            • Then - Actions
              • Unit - Add Sleep_Ability_Always to Sleep_Unit
            • Else - Actions
      • -------- --------
      • Custom script: call DestroyGroup( udg_Sleep_Group )
1721854199322.png

There's a Time Of Day system included in the map as well which enables all of this to work. It's a little bit of code that automatically tracks the Day/Night cycle and allows you to know whether it's Day/Night by using a Boolean variable. It also gives you a custom Event that runs when switching from Day -> Night and Night -> Day since there isn't an Event for this already.

So looking at the TOD variables being used in my triggers...
- TOD_Event becomes equal to 1.00 happens whenever there's a cycle change (day -> night).
- TOD_Is_Night_Time tells us whether it's Night (true) or Day (false) which can be checked whenever you want.

Also, you can delete this Condition to simplify things. Without it, ALL units owned by Sleep_Player will automatically fall asleep at night:
  • If - Conditions
    • (Level of Sleep_Ability_Class for Sleep_Unit) Equal to 1
Otherwise, this Sleep_Ability_Class ability can be added to units in the Object Editor to mark them as "Sleepers", meaning that they will fall asleep at night. It's a hidden passive ability that has no interfering effects, it simply exists as a way for you to specify which units can and cannot sleep at night.

How to import this into your map:
1) Copy and paste the two custom Sleep abilities with the (PSS) suffix from the Object Editor.
2) Copy and paste the Sleep System folder from the Trigger Editor.
 

Attachments

  • Player Sleep System 2.w3m
    20.7 KB · Views: 8
Last edited:
Level 5
Joined
Nov 17, 2022
Messages
84
There's an ability called Sleep Always that you can use.
View attachment 481205

Here's a system I threw together to make it easy to setup for your map.
  • Sleep System Config
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • -------- Configure these to match the two custom abilitiies used by the PSS: --------
      • Set VariableSet Sleep_Ability_Always = Sleep Always (PSS)
      • Set VariableSet Sleep_Ability_Class = Sleep Class (PSS)
      • -------- --------
      • -------- Configure this to match the Player that has units which sleep: --------
      • Set VariableSet Sleep_Player = Player 2 (Blue)
  • Sleep System Day
    • Events
      • Game - TOD_Event becomes Equal to 1.00
    • Conditions
      • TOD_Is_Night_Time Equal to False
    • Actions
      • Set VariableSet Sleep_Group = (Units owned by Sleep_Player.)
      • -------- --------
      • Unit Group - Pick every unit in Sleep_Group and do (Actions)
        • Loop - Actions
          • Set VariableSet Sleep_Unit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Sleep_Ability_Class for Sleep_Unit) Equal to 1
            • Then - Actions
              • Unit - Remove Sleep_Ability_Always from Sleep_Unit
            • Else - Actions
      • -------- --------
      • Custom script: call DestroyGroup( udg_Sleep_Group )
  • Sleep System Night
    • Events
      • Game - TOD_Event becomes Equal to 1.00
    • Conditions
      • TOD_Is_Night_Time Equal to True
    • Actions
      • Set VariableSet Sleep_Group = (Units owned by Sleep_Player.)
      • -------- --------
      • Unit Group - Pick every unit in Sleep_Group and do (Actions)
        • Loop - Actions
          • Set VariableSet Sleep_Unit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Sleep_Ability_Class for Sleep_Unit) Equal to 1
            • Then - Actions
              • Unit - Add Sleep_Ability_Always to Sleep_Unit
            • Else - Actions
      • -------- --------
      • Custom script: call DestroyGroup( udg_Sleep_Group )
View attachment 481206
There's a Time Of Day system included in the map as well which enables all of this to work. It's just a little bit of code that automatically tracks the time of day for you and allows you to know whether it's Day/Night using a Boolean variable. It also gives you a custom Event that runs when switching from Day -> Night and Night -> Day since there isn't a simple Event for this already. You can see the TOD variables being used in my triggers. The TOD_Event becomes equal to 1.00 happens whenever there's a cycle change (day -> night) and the TOD_Is_Night_Time Boolean tells us whether it's Night (true) or Day (false).
Oh wow, thank you, this is really nice of you. Its amazing what you can do with triggers.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Oh wow, thank you, this is really nice of you. Its amazing what you can do with triggers.
No problem.

Note that this Sleep Always ability has some quirks. For example, if you wanted to issue a triggered Order to a sleeping unit you'd have to wake it up first:
  • Actions
    • Unit - Wake up Footman 0004 <gen>
    • Unit - Order Footman 0004 <gen> to Attack-Move To (Center of Region 000 <gen>)
Otherwise, it'll ignore the Order.

But there's another issue here. The Footman won't fall back asleep once it's reached it's destination. You'll have to "refresh" the ability:
  • -------- Footman is now at it's destination ---------
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • TOD_Is_Night_Time Equal to True
    • Then - Actions
      • Unit - Remove Sleep_Ability_Always from Footman 0004 <gen>
      • Unit - Add Sleep_Ability_Always to Footman 0004 <gen>
    • Else - Actions
Of course, this may never be an issue for you, it all depends on how you handle your "wildlife".
 
Last edited:
Level 5
Joined
Nov 17, 2022
Messages
84
I still think that in your specific case, just making them creeps and triggering around the kill announcement system is the much simpler option.
Yeah I've been weighing my options on either just forgoing a sleep system or figuring out how to evade the trigger system like you say. Tho I am super grateful for what Uncle came up with regardless, that's some creative thinking. I'm just trying to think what triggers to remove the text, since I am admittedly not super familiar with triggers but I am learning as I go.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Yeah I've been weighing my options on either just forgoing a sleep system or figuring out how to evade the trigger system like you say. Tho I am super grateful for what Uncle came up with regardless, that's some creative thinking. I'm just trying to think what triggers to remove the text, since I am admittedly not super familiar with triggers but I am learning as I go.
I would only use what I suggested if you NEED the Wildlife to be owned by a non-Neutral Hostile Player. There could be good reason for that, but it doesn't sound like that's the case. Anyway, I wouldn't be offended if you didn't use my suggestion, so I hope that's not a motivating factor in your decision ;) I can throw these systems together pretty quickly, I have already made stuff like this before so it's no hassle.
 
Level 5
Joined
Nov 17, 2022
Messages
84
I would only use what I suggested if you NEED the Wildlife to be owned by a non-Neutral Hostile Player. There could be good reason for that, but it doesn't sound like that's the case. Anyway, I wouldn't be offended if you didn't use my suggestion, so I hope that's not a motivating factor in your decision ;) I can throw these systems together pretty quickly, I have already made stuff like this before so it's no hassle.
Nah, its not so no worries, I just wanted to make sure you knew I appreciated what you tried doing, it was super nice of you and honestly educational for me in my endeavors of trigger learning.
 
Top