• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Identify If Building Stopped Attacking

Status
Not open for further replies.
Level 2
Joined
Jun 9, 2018
Messages
10
So I am currently working on my first map and as a newbie I am constantly being troubled especially on triggers.

And there was this periodic event where a swarm of units are created and issued an order to attack a gate. Towers will be attacking the swarm and after the swarm has been all killed the player will receive gold and lumber.

However I am trying to come up on a trigger where 'once a specific building stopped attacking it will give the player additional gold and lumber'

I have tried multiple events and conditions like:
- a unit dies and that unit is in a specified region
- the building is issued an order = stop

but nothing seemed to work :cry:
can someone please help me :cute:
 
Last edited:
Level 7
Joined
Dec 28, 2014
Messages
83
You could add the swarm into a unit group and every time one unit from the swarm dies, removed it into the unit group then check if you are finish spawning and if the unit group is empty. If it does, reward the player.

Here's my example:

  • Spawn Swarm
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • RemainingSwarm Greater than 0
    • Actions
      • Unit - Create 1 Footman for Neutral Hostile at (Center of (Playable map area)) facing Default building facing degrees
      • Unit Group - Add (Last created unit) to SwarmGroup
      • Unit - Order (Last created unit) to Attack (Gate <gen>)
      • Set RemainingSwarm = (RemainingSwarm - 1)
  • Remove Swarm To Group
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in SwarmGroup) Equal to True
    • Actions
      • Unit Group - Remove (Triggering unit) from SwarmGroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (SwarmGroup is empty) Equal to True
          • RemainingSwarm Equal to 0
        • Then - Actions
          • Game - Display to (All players) for 30.00 seconds the text: You cleared the wave! You earned 150 gold and lumber!
          • Player - Add 150 to Player 1 (Red) Current gold
          • Player - Add 150 to Player 1 (Red) Current lumber
        • Else - Actions
 
On map Initialization, mark all units with a flag that indicates that they are not in combat. They would have their own individual timers.

On an is unit attacked event or a spell cast event, you would start that timer instance, letting it expire after n seconds, where n is the attack cool down of the unit. Of course, that timer is refreshed on subsequent attacked events or spell events. This affects both the attacker and the target.

When the timer expires, if ever, enumerate nearby enemies within n units from the unit in question. If there are any, restart the timer. Otherwise, mark it as idle. (Not in combat)

You can check out Combat Systems in HIVE to see which one suits you best.
 
Level 2
Joined
Jun 9, 2018
Messages
10
You could add the swarm into a unit group and every time one unit from the swarm dies, removed it into the unit group then check if you are finish spawning and if the unit group is empty. If it does, reward the player.

Here's my example:

  • Spawn Swarm
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • RemainingSwarm Greater than 0
    • Actions
      • Unit - Create 1 Footman for Neutral Hostile at (Center of (Playable map area)) facing Default building facing degrees
      • Unit Group - Add (Last created unit) to SwarmGroup
      • Unit - Order (Last created unit) to Attack (Gate <gen>)
      • Set RemainingSwarm = (RemainingSwarm - 1)
  • Remove Swarm To Group
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in SwarmGroup) Equal to True
    • Actions
      • Unit Group - Remove (Triggering unit) from SwarmGroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (SwarmGroup is empty) Equal to True
          • RemainingSwarm Equal to 0
        • Then - Actions
          • Game - Display to (All players) for 30.00 seconds the text: You cleared the wave! You earned 150 gold and lumber!
          • Player - Add 150 to Player 1 (Red) Current gold
          • Player - Add 150 to Player 1 (Red) Current lumber
        • Else - Actions
Thank you so much!! :grin: it worked :thumbs_up:
 
Status
Not open for further replies.
Top