Jump to content

Alternative to trigger unit in moving zone?


Recommended Posts

Hmm, may need to just do it with just scripting. Frankly I'm surprised any of the trigger conditions still work with units spawned via scripting.

 

Ultimately it is just the Pythagorean theorem. if square root of difference of pointA.x and pointB.x added to the difference of pointA.y and pointB.y is smaller than the radius, then a unit is in zone. While that may look complicated it really isn't that bad.

 

Here is a really simple example in lua:

 

local u1 = Unit.getByName('unit1'):getPositon().p

local u2 = Unit.getByName('unit2'):getPositon().p

 

if ((u1.x - u2.x)^2 + (u1.z - u2.z)^2)^0.5 <= 5000 then

-- units are within 5000 meters of each other

end

 

There is a flagFunc built into mist that sort of mimics the trigger condition to get the same overall result.

The right man in the wrong place makes all the difference in the world.

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Thanks. I can't give you any more rep.

Hmm, may need to just do it with just scripting. Frankly I'm surprised any of the trigger conditions still work with units spawned via scripting.

 

Ultimately it is just the Pythagorean theorem. if square root of difference of pointA.x and pointB.x added to the difference of pointA.y and pointB.y is smaller than the radius, then a unit is in zone. While that may look complicated it really isn't that bad.

 

Here is a really simple example in lua:

 

local u1 = Unit.getByName('unit1'):getPositon().p

local u2 = Unit.getByName('unit2'):getPositon().p

 

if ((u1.x - u2.x)^2 + (u1.z - u2.z)^2)^0.5 <= 5000 then

-- units are within 5000 meters of each other

end

 

There is a flagFunc built into mist that sort of mimics the trigger condition to get the same overall result.

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...