dooom Posted May 30, 2014 Posted May 30, 2014 I don't profess to know how to write scripts, but is it possible to have a script that can report on an identified group's "health"... i.e. the Alive less than? I ask because i would like to develop a recon role for the TF51 in a mission where they overfly a ground battle to perform a Battle damage assessment and upon landing the script uses the flag to broadcast troop strength to the player side. Any ideas? Can I entice a friendly soul to offer up a script? :helpsmilie: ASUS Tuf Gaming Pro x570 / AMD Ryzen 7 5800X @ 3.8 / XFX Radeon 6900 XT / 64 GB DDR4 3200 "This was not in the Manual I did not read", cried the Noob" - BMBM, WWIIOL
ajax Posted May 30, 2014 Posted May 30, 2014 (edited) These functions are available. Used in combination they can determine group life. number function Group.getSize(Group self) returns initial size of the group. If some of the units will be destroyed, initial size of the group will not be changed. Initial size limits the unitNumber parameter for Group.getUnit() function. array of Unit function Group.getUnits(Group self) returns array of the units present in the group now. Destroyed units will not be enlisted at all. i.e. [count of Group.getUnits()]/Group.getSize() * 100 = % alive You could also refine the result by checking the life of each remaining unit. number function Unit.getLife(Unit self) returns the unit's health. Dead units has health <= 1.0 number function Unit.getLife0(Unit self) returns the unit's initial health. i.e. (Ʃ[unit.getLife()])/(Ʃ[unit.getLife0()] * 100 = avg %life remaining Edit: The above equation only works if all units have the same initial life, which isn't the case. So use this one instead: Ʃ[unit.getLife()/Unit.getLife0()]/n * 100 = avg %life So then for the group: "group health" = (% alive) * (avg %life remaining) The question is: How do you determine how many enemy units the scout "sees"? You could use a probabilistic approach: Assume time spent in zone increases probability of observing every unit. Calculate the result based on time in zone. Would have to think about the math more. Edited May 31, 2014 by ajax
dooom Posted May 30, 2014 Author Posted May 30, 2014 So how is the above used in the ME?.. Can you illustrate the logic ? Us it just a do script trigger.. I am unclear how it prints the info for clients... Ty jax! ASUS Tuf Gaming Pro x570 / AMD Ryzen 7 5800X @ 3.8 / XFX Radeon 6900 XT / 64 GB DDR4 3200 "This was not in the Manual I did not read", cried the Noob" - BMBM, WWIIOL
LFCChameleon_Silk Posted May 30, 2014 Posted May 30, 2014 (edited) your best bet dooom far as i can tell is to make a script file and create a function that checks for unit life and provides different if statements to do various things based on the condition of how much life is left, and then to have that function be scheduled to be re-run every x seconds till the group is destroyed. I know this is probably confusing but can't put it anymore simple then that, will link another peice of my script that checks for a destroyed group (even less advanced then what your trying to do) ------------------------------------------------------------------------------------------------------------------------------------------------------------------ function check_blue_complete_task_destruct(arg, time) ------------------------------------------------------------------------------------------------------------------------------------------------------------------ destroyed_obj_BD = Group.getByName(blueobj_destruct) local task_state = trigger.misc.getUserFlag(397) local check_this_obj_flag = trigger.misc.getUserFlag(396) if task_state >= 1 then if check_this_obj_flag ~= 0 then trigger.action.outSoundForCoalition(coalition.side.BLUE, 'WinFanfare.ogg') trigger.action.outSoundForCoalition(coalition.side.RED, 'wah.ogg') trigger.action.outSoundForCoalition(coalition.side.BLUE, 'radio.ogg') trigger.action.setUserFlag(104, 0) trigger.action.setUserFlag(397, 0) trigger.action.setUserFlag(396, 0) trigger.action.setUserFlag(1012, 1) do local msg = {} msg.text = ' American and Georgian forces have succeeded in destroying a tactical target!' msg.displayTime = 30 msg.msgFor = {coa = {'all'}} mist.message.add(msg) end do local msg = {} msg.text = ' The next strike mission will be available in 30 minutes provided no one is in the spawning area!' msg.displayTime = 30 msg.msgFor = {coa = {'blue'}} mist.message.add(msg) end timer.scheduleFunction(spawn_blue_task_destruct, nil, timer.getTime() + timetilstrike) timer.scheduleFunction(flavour_reward, 4, timer.getTime() + 30) end end return time + 10 end --- basically says that if the task has been started (determined by a flag) but the group in question is nil (not present) consider it destroyed and do the proper condition block, the function doesn't get scheduled to run until the task is started (elsewhere in the code) so therefore if its not present it clearly has been destroyed. I know its probably a lot to absorb took me months to get this far into the scripting and I am BY NO MEANS good at it. Edited May 30, 2014 by =LFC=Chameleon_Silk
ajax Posted May 31, 2014 Posted May 31, 2014 Sorry, I missed the responses somehow. I think using a script is unavoidable for this scenario. Off the top of my head, maybe: 1. Define a trigger zone over the battle area. 2. Use a switched condition trigger to fire off a timer script when the scout enters the zone. 3. Use another switched condition trigger to stop the timer script when the scout leaves the zone. 4. The timer script would behave like a stop watch, starting and stopping each time the scout enters and leaves the zone accumulating the total time. 5. Each time the scout leaves the zone, the script: a. Counts all enemy units in the trigger zone. b. Gets their health. 6. Upon landing another trigger fires a calculation script that: a. Retrieves the data from the last time the scout left the zone. b. Calculate the 'result' -- not sure what you want exactly. c. Whatever it is, apply some probability factor based on total time in zone relative to some arbitrary value you supply. d. Maybe apply some randomized 'noise' to the result to simulate fog of war. e. Stores the result in some variable or user flag that can be retrieved in the ME. 7. Output your status report base on that value. Just a broad outline how it could be done. Or, as Silk does, have the script do everything. It really depends on what you want. Do you want the report to go out immediately or only after the scout lands safely?
dooom Posted June 1, 2014 Author Posted June 1, 2014 (edited) I would like it to report enemy strength only each time the scout lands and taxis to tower. Wait 2 min... Report broadcast to coalition ... Ie ... The scout must keep relaunching for battle reports All I am looking for is a report that says " enemy sukhumi strength is 45%" etc. Can it calculate strength off a flag as opposed to entry/ exit of a zone? I have a nice set of triggers for recon photos already that generate a flag if photos are valid... If like the strength calculation be made when the recon photo is made but only reported on taxi to tower . My assumption is that high command knows there is 50 units in the town and will use the photos to confirm how many remain active ... No need for fog of war etc. just the count at time of photo divided by 50 Cheers! Edited June 1, 2014 by dooom ASUS Tuf Gaming Pro x570 / AMD Ryzen 7 5800X @ 3.8 / XFX Radeon 6900 XT / 64 GB DDR4 3200 "This was not in the Manual I did not read", cried the Noob" - BMBM, WWIIOL
ajax Posted June 1, 2014 Posted June 1, 2014 Okay, that simplifies things quite a bit. Basically, it looks like you can do almost everything with triggers and flags except get enemy strength. Am I correct in assuming you will have a zone defined in ME and you want enemy strength counted in that zone? Or would it be better to have a list of groups you want checked. Will you have multiple scouts or just one? Will the battle zone or target area change with each sortie?
ajax Posted June 1, 2014 Posted June 1, 2014 Well, just great... another scripting engine bug!:furious: It appears Group.getSize() doesn't return the initial size of the group as documented. It returns the current number of units. Gonna have to come up with a counting function that runs at mission start.
ajax Posted June 1, 2014 Posted June 1, 2014 Okay, dOoOm, Here is a very basic script and mission that does what you want. 1. The script needs to be loaded early. In the example it loads after 2 secs. Probably any time within the first minute is fine. 2. Edit the Lua file to define the list of group names that the script is supposed to check. 3. Use a trigger to fire off a very simple, one-liner 'do script' to check the current status. It can be done multiple times. Each time it runs it calculates % strength. 4. Then when you're ready, use another trigger to fire off another one-liner to output the message to coalition. Edit the Lua file to change the message, duration, and coalition. The attached mission has trigger and 'do script' examples. Enjoy!ScoutReportTest.mizScoutReport.lua
dooom Posted June 1, 2014 Author Posted June 1, 2014 Well, just great... another scripting engine bug!:furious: It appears Group.getSize() doesn't return the initial size of the group as documented. It returns the current number of units. Gonna have to come up with a counting function that runs at mission start. Not needed... i know the initial size is 50. and yeah - i have a zone that i want to count enemy within. You are a rock star Jax... makes me feel bad about creeping up on your ka50 with that roland.... ASUS Tuf Gaming Pro x570 / AMD Ryzen 7 5800X @ 3.8 / XFX Radeon 6900 XT / 64 GB DDR4 3200 "This was not in the Manual I did not read", cried the Noob" - BMBM, WWIIOL
dooom Posted June 1, 2014 Author Posted June 1, 2014 Yo Ajax... so i modified your miz to reflect my mission idea at a broad level... i randomize the ground units so only a few of the 7 groups spawn in. then i have a loose representation of flags to "take recon photo" (count) and one to report strength. But the script is counting all units whether they are spawned in by the randomization or not... thus my reported strength is stronger than it should be... Is there a way to count only what is spawned? my version attached below...ScoutReportTestd0o0m.miz ASUS Tuf Gaming Pro x570 / AMD Ryzen 7 5800X @ 3.8 / XFX Radeon 6900 XT / 64 GB DDR4 3200 "This was not in the Manual I did not read", cried the Noob" - BMBM, WWIIOL
ajax Posted June 1, 2014 Posted June 1, 2014 (edited) Easy to fix. Just have to add an if 'isActive()' check. Edit: Give me a little while, and I'll post a mod. Also, make sure you load the script after the groups have spawned in. Edited June 1, 2014 by ajax
ajax Posted June 1, 2014 Posted June 1, 2014 ... makes me feel bad about creeping up on your ka50 with that roland.... That was you?:thumbup:
ajax Posted June 1, 2014 Posted June 1, 2014 Modified script and mission attached. I adjusted your timings a bit. I can't believe how long it took to activate the groups -- I had to wait for a full 60 secs before loading the script.ScoutReport.zip
dooom Posted June 1, 2014 Author Posted June 1, 2014 you are the man ajax.... i dont care what jojo says about you :D i'll try the script out later today ... 60 sec for randomization??? dang, i'll have to dial that rand % up, 5 might be too small for my mission. thanks a million! ASUS Tuf Gaming Pro x570 / AMD Ryzen 7 5800X @ 3.8 / XFX Radeon 6900 XT / 64 GB DDR4 3200 "This was not in the Manual I did not read", cried the Noob" - BMBM, WWIIOL
dooom Posted June 1, 2014 Author Posted June 1, 2014 darn - still not quite there... sorry Ajax. i forgot to mention this was for a PvP mission.. I need the script to be able to count and report %s for RED and BLUE seperately ... right now it is counting all the units and using it against the total, reporting a % on the state of RED+BLUE against the total spawned. In my mission, i have red forces north of the rail line in sukhumi and blue forces south of that rail line. I then have a tf51 on each side flying recon to report on the health of opposing units that randomly spawned in... MEA CULPA for not elaborating on the PvP aspect. Can the script be modified to accomodate this? ASUS Tuf Gaming Pro x570 / AMD Ryzen 7 5800X @ 3.8 / XFX Radeon 6900 XT / 64 GB DDR4 3200 "This was not in the Manual I did not read", cried the Noob" - BMBM, WWIIOL
Flagrum Posted June 1, 2014 Posted June 1, 2014 When I first read the OPs initial request, I had a spontaneus idea - maybe you find it worth to be considered... I was thinking about the algorithm of how the scout detects the units. What about this: a unit is considered as detected if the scout maintains a line of sight to it. The time to successfully detect a unit is depending on the (slant) range of the LOS, i.e. the higher the scout flies, the longer it takes to sucessfully detect and count one unit. Example: A) Scout overflies the area at 20000ft: it takes 2 minutes to detect one unit and assess it's status. So he needs to spend at least 100 minutes over the area to get a complete picture of the area (50 units). Not very effective ... B) Scout flies at 500 ft - it takes 10 seconds per unit for the BDA. He could be done with the job within about 10 minutes ... if he survives. Risk vs. reward ...
dooom Posted June 1, 2014 Author Posted June 1, 2014 Important point there, dooom.:music_whistling: uh yeah/....:doh: ASUS Tuf Gaming Pro x570 / AMD Ryzen 7 5800X @ 3.8 / XFX Radeon 6900 XT / 64 GB DDR4 3200 "This was not in the Manual I did not read", cried the Noob" - BMBM, WWIIOL
ajax Posted June 2, 2014 Posted June 2, 2014 (edited) Alright, this is a bit of kludge... down-and-dirty, but it works. Edit: There are now RED and BLUE group lists, which might cause some confusion: The coalition refers to the scout's side. In other words, when you fill out the RED group list, it is comprised of BLUE groups -- targets for the RED side.ScoutReportMulti.zip Edited June 2, 2014 by ajax
ajax Posted June 2, 2014 Posted June 2, 2014 For sure, Flagrum, this script has a lot of neat possibilities. You're touching on the same point I was about time-over-target having an effect on recce 'quality' -- we're thinking along the same lines, anyway.
dooom Posted June 2, 2014 Author Posted June 2, 2014 ... you're my hero.... i can't even give yo rep... :( Seriously man... thanks a million. I'll check it our now. ASUS Tuf Gaming Pro x570 / AMD Ryzen 7 5800X @ 3.8 / XFX Radeon 6900 XT / 64 GB DDR4 3200 "This was not in the Manual I did not read", cried the Noob" - BMBM, WWIIOL
Recommended Posts