• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

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,337
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