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

Region Condition

Status
Not open for further replies.
Level 4
Joined
Aug 1, 2013
Messages
54
Is there possible to make a condition about a region?
For example i could imagine it something like:

Event
A unit dies

Condition:
Dying unit is within region ,001'

Action:
Random

Help will be appreciated :thumbs_up:
 
Level 15
Joined
Aug 7, 2013
Messages
1,338
Yes.

It might look something like this.

JASS:
library UnitDeathInRegion001 initializer init


private function main takes nothing returns boolean
  local unit u = GetTriggerUnit()
  //now run your check here
  //if u is in region 001 then:
     //your code here
  //endif
  return false
endfunction

private function init takes nothing returns nothing
  local trigger t = CreateTrigger()
  call TriggerRegisterPlayerEvent(t, Player(0), EVENT_UNIT_DEATH)
  call TriggerAddCondition(t, Condition(function main))
endfunction

endlibrary

Note I've probably made a few syntax errors. And I didn't put the native/code for checking if a unit is in a particular region. But from this code you should have the general idea.

But when a unit dies, it causes a leak I believe because its handle doesn't get deallocated automatically. So it still has coordinates--it's state just happens to be dead.

This is good for your case.
 
Level 4
Joined
Aug 1, 2013
Messages
54
Yes.

It might look something like this.

JASS:
library UnitDeathInRegion001 initializer init


private function main takes nothing returns boolean
  local unit u = GetTriggerUnit()
  //now run your check here
  //if u is in region 001 then:
     //your code here
  //endif
  return false
endfunction

private function init takes nothing returns nothing
  local trigger t = CreateTrigger()
  call TriggerRegisterPlayerEvent(t, Player(0), EVENT_UNIT_DEATH)
  call TriggerAddCondition(t, Condition(function main))
endfunction

endlibrary

This is perfect, thank you for help
 
Status
Not open for further replies.
Top