• 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] Can unit go on a region only?

Status
Not open for further replies.
Hi all, I am newbie in these triggers and scripts (except that i know how to make variables :) ) and I wonder is there a way that i can make a unit(unit0001) to be able to go(or to move in,to bounce against) only on region0001 or MAYBE to make region001 a blind spot(line of sight blocker) for only unit0001?
 
Last edited:
Level 23
Joined
Apr 16, 2012
Messages
4,041
the line blockers is afaik not possible, only if the game is singleplayer it is safe to do such a thing.

You can restrict unit to a region by this:
  • move to center
    • Events
      • Unit - A unit leaves Region 000 <gen>
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Footman
    • Actions
      • Unit - Move (Triggering unit) instantly to (Center of Region 000 <gen>)
be aware that this leaks a location, for leakless and configurable version check this:
  • move to configurable
    • Events
      • Unit - A unit leaves Region 000 <gen>
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Footman
    • Actions
      • Set realX = 144.00
      • Set realY = 241.00
      • Set loc = (Point(realX, realY))
      • Unit - Move (Triggering unit) instantly to loc
      • Custom script: call RemoveLocation(udg_loc)
The realX and realY are variables of type Real, and loc is of type Point
Change the real values to make the unit apper somewhere else

If you want it to be relative to the region:
  • move to relative
    • Events
      • Unit - A unit leaves Region 000 <gen>
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Footman
    • Actions
      • Set realX = 15.00
      • Set realY = 17.00
      • Set loc = (Point(((Min X of Region 000 <gen>) + realX), ((Min Y of Region 000 <gen>) + realY)))
      • Unit - Move (Triggering unit) instantly to loc
      • Custom script: call RemoveLocation(udg_loc)
This will move units relative to the bottom-left corner(correct me if Im wrong, but Min Y should return coordinate of bottom) of the region by realX on X axis, and realY on Y axis

Hope this will help you
 
Unit leaves region --> add unit to UnitGroup

periodic trigger: (0.1 seconds or something like that)
local unit u
pick all units in UnitGroup
if (picked unit is in YourRegion = false)
set u = picked unit
order picked unit to run to CentreOfRegion
wait 0 seconds
set udg_Unit = u
order udg_Unit to stop
else
remove picked unit from UnitGroup

u = local unit variable
udg_Unit = global unit variable

Edit:

create a point varibale (P) and set in your Init-trigger = CentreOfRegion
and order unit to run to P so you dont leak each run
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
make something like this:
Events - A unit leaves the region
Condition - Triggering unit is the specific unit you want
Actions -
calculate the distance of which the unit is OFF the region, something like Distance from the position of the unit to the center of the region - half of the Region coordinates (total length)
then you will use this:
JASS:
call SetUnitX(Unit, X)
call SetUnitY(Unit, Y)
to move the unit backward rendering him into the region again without interrupting his order
 
Status
Not open for further replies.
Top