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

[Trigger] Hazardous terrain?

Status
Not open for further replies.
Level 23
Joined
Nov 20, 2005
Messages
1,251
I'm planning on making hazardous terrain, like standing in area with lava will deal damage to units until they get off the area where it is, but stading in lava = take damage over time (hazard), not standing in lava = no damage (safe). How do I create a continuous event which detects whether a unit enters (and damaging it) and/ot exit(thus stop damaging it)?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,871
If the lava is conveniently shaped to fit a region you can easily have a trigger that runs every X seconds which Damages units inside of it. You can also look for units in a circle radius by putting a Point at the center of the lava and using the Pick Every Unit function along with Units within range of Point. Alternatively, you can track all of your units in a unit group and periodically check if they're standing on Lava, and if so Damage them. The best solution depends on how your map works.

Here's an example of the last solution I mentioned. This trigger will damage units inside of LavaUnitGroup (a Unit Group variable) if they're standing on Lava:
  • Lava Damage
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in LavaUnitGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet LavaUnit = (Picked unit)
          • Set VariableSet LavaPoint = (Position of LavaUnit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain type at LavaPoint) Equal to Dungeon - Lava
            • Then - Actions
              • Unit - Cause LavaUnit to damage LavaUnit, dealing 50.00 damage of attack type Spells and damage type Normal
            • Else - Actions
          • Custom script: call RemoveLocation(udg_LavaPoint)
Here's an example of adding a unit to the Unit Group:
  • Lava Add Example
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • Unit Group - Add (Trained unit) to LavaUnitGroup
You can use the Add To Unit Group action to fill the Unit Group with all of your desired units. You can also Set the LavaUnitGroup variable in order to fill it with units that meet certain conditions, for example Set Variable LavaUnitGroup = Units owned by Player 1 (red).
 

Attachments

  • Lava Example.w3m
    18.4 KB · Views: 6
Last edited:
Status
Not open for further replies.
Top