Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

get units in area?

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> get units in area? Page: [1]
Login
Message << Older Topic   Newer Topic >>
get units in area? - 8/28/2019 2:10:44 AM   
Whicker

 

Posts: 664
Joined: 6/20/2018
Status: offline
Is there an easy way to get what is inside of an area defined by some ref points?

I see that I can check if a unit is in an area, but I want to check the area and see what units are in it. Only thing I can think of is lopping thru all the units on a side and checking each one to see if it is in an area.

I'd like to see if there are more than x mobile facilities, or more than x tanks really.

this works per unit:
quote:


local u= SE_GetUnit({name='tank', guid='b87e998b-cca8-4e6d-beb0-8333cc3aeae6'})
print(u:inArea{"1","2","3"})--prints yes or no


but I want to do something more like:

quote:


local p = ScenEdit_GetReferencePoints({side="Crimson Commonwealth", area={"1","2","3"}})
print(p.unitsInArea)--no such thing
Post #: 1
RE: get units in area? - 8/28/2019 2:12:49 AM   
Whicker

 

Posts: 664
Joined: 6/20/2018
Status: offline
I guess I can see how this isn't possible - the game would have to do the same thing - loop thru all units to see what is in any given area of rps.

The units that I wanted to check were all in groups, so rather than loop thru all the units on the side I made a table of group names and then loop thru those to see if they are in the area. The goal is to pop up a message if none of the units are in the area so this is what I think works:

quote:


local t={'Group 3349','Group 3350','Group 3351','3rd Armored'}
for i = 1,#t do
local u = SE_GetUnit({name=t,side='Crimson Commonwealth'})
if u ~= nil then
unitsToCheck = u.group.unitlist
for i = 1, #unitsToCheck do
local uu = SE_GetUnit({guid=unitsToCheck})
if uu:inArea{"RP-4091","RP-4092","RP-4093","RP-4094"} then
--print(uu.name..' is it in the area? '..tostring(uu:inArea{"RP-4091","RP-4092","RP-4093","RP-4094"}))
return --there is a unit still in the area so exit
end
end
end--loop of unitlist
end--table of groups
ScenEdit_SetEvent('Sangster Recaptured', {IsActive=true})--if we get this far there are no units in the area
ScenEdit_SpecialMessage('playerside','Commander, <br><br>Our forces have cleared the area around Sangster of most major enemy units, we should have control of the Airport in the next hour.<br><br>(you must have ground forces occupying the base for 60 minutes)')


< Message edited by Whicker -- 8/28/2019 3:55:46 AM >

(in reply to Whicker)
Post #: 2
RE: get units in area? - 9/19/2019 4:47:25 PM   
KnightHawk75

 

Posts: 1450
Joined: 11/15/2018
Status: offline
Maybe unrelated I think but if you ever need to a generic isInArea sort of check without having to have RP's or even navzones or wanting to create a unit etc.. I had the following that your post reminded me I meant to share a while back in case someone else ever needed it. It was part of some ridiculous enhancements I did with my own unit spawner (also never shared).


The use case (among others) was where I needed it\preferred it over creating an unit just to call :inArea. I found better performance and less leakage as I recall. Particularly in a dynamic waypoint generator to target, among other things during pathfinding check it needed to check was if a possible next location was inside a no-nav zone that applied to a particular\potentially newly generated units. Another use was simply allowing me to do an 'inarea()' type call on any point within a given polygon I wanted without having to actually have navzones\rp's defined in the editor, sort of private easier to manage zones of my own if you will for a specific case or two.

text file attached to avoid forum garbling it.


Attachment (1)

< Message edited by KnightHawk75 -- 9/19/2019 4:54:48 PM >

(in reply to Whicker)
Post #: 3
RE: get units in area? - 9/20/2019 10:17:43 PM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
I haven't tried it, but couldn't a NOT UnitsInArea trigger do it for you, where the triggering type is any enemy unit???

_____________________________

Michael

(in reply to KnightHawk75)
Post #: 4
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> get units in area? Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

1.156