Jump to content

ESAc_matador

Members
  • Posts

    1605
  • Joined

  • Last visited

Everything posted by ESAc_matador

  1. i did it!!!!!! --[[reconscript v1.0: THanks to Grimes, Ciribob, Chromium, Steggles, and so many others, that have fullfilled the forums with examples or even direct help!!! Require MIST. 4.3.72 or further. To install just, make do script after Mist is installed. This script is to help aircrafts, (Planes, or Helos) to have a more entertaining experience, and probably more realistic. One of the issues in DCS, when plying in single, or even in multiplayer is the lack of a Ground Command that reports to you what is going on... or even the ground units, asking for help, Situational awarness, etc. With this script you will be able to have a clearer picture of what is going on. It is in early stages and probably is everything but "elegant" in terms of scripting. I have never, ever programmed until today. So, feel free to improve, or to add things. This is CTLD compatible, as far as I have tested. I want you to help me to improve and to find out any problems you find. The script works through F10 menu, and has two possibilities. A) Mark enemy groups that are Line of Sight and inside a zone of any ground friendly troops the zone is 1800m. THis is because is a range where you can shoot in most of Commando 60mm mortars. Many Commandos, or Special Forces uses them, also many infantry platoons. Feell free to look for greater distances, if you want to simulate that you have a 155mm/52 caliber guns. B) Report position Lat Long of enemy groups, this is awesome script. With this, you will have many information: - Position Lat Long of any enemy group that is Line of Sight and 5 km of our troops (feel free to change the radius) - Ammount of enemy units in that group. - Entity of the group... it will not give you numbers, but it will give you the unit type inside the group... for instance "Ground Command reporting: 15 Enemies AT 43º34,34N 42º02,23E Entitiy: Soldier M4, Stinger Manpad, Soldier M242" you see its a lot of information!!! So, feel free to test!!!!! ]] function reconmarkerred() function table_count(tt, item) local count count = 0 for ii,xx in pairs(tt) do if item == xx then count = count + 1 end end return count end function table_unique(tt) local newtable newtable = {} for ii,xx in ipairs(tt) do if(table_count(newtable, xx) == 0) then newtable[#newtable+1] = xx end end return newtable end local redunits = mist.makeUnitTable({'[red][vehicle]'}) local blueunits = mist.makeUnitTable({'[blue][vehicle]'}) LOSData = mist.getUnitsLOS(redunits,2,blueunits,2,1800) local targets = {} for k, v in pairs (LOSData) do local tabledata = LOSData[k] for j, w in pairs (tabledata.vis)do local targetinLOS = tabledata.vis[j] targets[#targets+1] = targetinLOS end end --trigger.action.outText(mist.utils.tableShow(targets),20) local targetgrouptable = {} -- table with all units-groups for k, v in pairs(targets) do local unit = targets[k] local unitname = unit:getGroup() targetgrouptable[#targetgrouptable+1] = unitname end --trigger.action.outText(mist.utils.tableShow(targetgrouptable),20) tabletarget = table_unique(targetgrouptable) for k, v in pairs(tabletarget) do local group = tabletarget[k] local groupname = group:getName() trigger.action.smoke(mist.getAvgPos(mist.makeUnitTable{tostring('[g]'.. groupname)}), trigger.smokeColor.Blue) trigger.action.outText("Roger, marking with blue smoke", 20) end end function reconadvisered() function table_count(tt, item) local count count = 0 for ii,xx in pairs(tt) do if item == xx then count = count + 1 end end return count end function table_unique(tt) local newtable newtable = {} for ii,xx in ipairs(tt) do if(table_count(newtable, xx) == 0) then newtable[#newtable+1] = xx end end return newtable end local redunits = mist.makeUnitTable({'[red][vehicle]'}) local blueunits = mist.makeUnitTable({'[blue][vehicle]'}) LOSData = mist.getUnitsLOS(redunits,2,blueunits,2,5000) local targets = {} for k, v in pairs (LOSData) do local tabledata = LOSData[k] for j, w in pairs (tabledata.vis)do local targetinLOS = tabledata.vis[j] targets[#targets+1] = targetinLOS end end --trigger.action.outText(mist.utils.tableShow(targets),20) local targetgrouptable = {} -- table with all units-groups for k, v in pairs(targets) do local unit = targets[k] local unitname = unit:getGroup() targetgrouptable[#targetgrouptable+1] = unitname end --trigger.action.outText(mist.utils.tableShow(targetgrouptable),20) tabletarget = table_unique(targetgrouptable) -- all duplicated groups removed local tabletypes ={} for k, v in pairs(tabletarget) do local group = tabletarget[k] local groupname = group:getName() local targetgrouppos = mist.getLLString({units = mist.makeUnitTable{tostring('[g]'.. groupname)} , acc = 3,}) local unitsingroups = group:getUnits() local tabletypes ={} for i, j in pairs(unitsingroups) do -- To see what is the higher threat... I local unit=unitsingroups[i] local unitnames = unit:getTypeName(unit) tabletypes[#tabletypes+1] = unitnames tablesingletype = table_unique(tabletypes) end do trigger.action.outText("Ground Command reporting: "..#unitsingroups.." Enemies AT "..targetgrouppos.." :Entity " ..table.concat(tablesingletype, ", "), 20) end end end function adviseenemies() local redunits = mist.makeUnitTable({'[red][vehicle]'}) local blueunits = mist.makeUnitTable({'[blue][vehicle]'}) mist.flagFunc.units_LOS{ unitset1 = blueunits, altoffset1 = 2, unitset2 = redunits, altoffset2 = 2, flag = 'enemiesblue', radius = 5000, req_num = 3, interval = 20, toggle = true, } if trigger.misc.getUserFlag('enemiesblue')== 1 then trigger.action.outTextForCoalition(coalition.side.RED, "Ground troops, to all flights,"..#blueunits.. " enemies detected (further info in F10)", 30) end timer.scheduleFunction(adviseenemies, {}, timer.getTime() + 300) end do adviseenemies() local _path1 = missionCommands.addSubMenuForCoalition(coalition.side.RED,"Ground units", nil) local _path2 = missionCommands.addSubMenuForCoalition(coalition.side.RED,"All groups", _path1) missionCommands.addCommandForCoalition(coalition.side.RED, "Mark enemy troops with blue smoke",_path2, function ()reconmarkerred ()end, nil) missionCommands.addCommandForCoalition(coalition.side.RED, "Report enemy situation",_path2, function ()reconadvisered ()end, nil) end -- trigger.action.outText(mist.utils.tableShow(tabletarget),20)
  2. If you don't want submenus, or strange things.... you better go for the ME it's very simple. I am now all lua scripting, but just for fun... but before going to lua, you have to dominate the ME , to understand the philosophy of DCS
  3. That I can help! If needed asistance ;) I have to pay Grimes by teaching others what I learn! The most we are scripting the better!
  4. I think cannot.
  5. Thaaanks! I am doing something really interesting, you will see. It almost done... it will need some tweaking, and refinement, but, the idea is really funny for all type of missions involving ground units.
  6. Thanks Grimes!! again and again and again, I did was finnally able to to do it by myself... Today I was going to share, itis a really interesting function to improve the AI behaviour. What I did is below. (by the why, what is better?? in terms of memory and CPU resources? to make loops with i=1.... or pairs/ipairs) local targets = {} for k, v in pairs (LOSData) do local tabledata = LOSData[k] for j, w in pairs (tabledata.vis)do local targetinLOS = tabledata.vis[j] targets[#targets+1] = targetinLOS end end I found a fantanstic tool in Mist "mist.utils.tableShow" so i did my work and deducted it!!! Grimes you should open a donation account!!! I cant stop thanking you for your advise "you should learn Lua!!!". I am doing really interesting things... I am in the process of a recon infantry script were the ground units report the situation of closer enemy GROUPS... in LAT LONG. It is in early stage and only work for blue coalition... but it is a starting point. i wil put it in a thread I opened about it. One of my main problems is making tables and using the proper sintax in your functions... for instance in this function, I am not able to make it work. It happens all the time... sometimes I get it to work, but others... it is impossible. check this... I tryed to use a solution you gave few days ago but... nope. local bluegroups = {'extract1','extract2'} for k, v in pairs(bluegroups) do local group = bluegroups[k] local groupname = group:getName() trigger.action.smoke(mist.getAvgPos(mist.makeUnitTable{('[g]'.. groupname)}, trigger.smokeColor.Blue)) end regarding the IADS, that would be great!!! As you mentioned, I made some experimenting, I know that making mistakes, researching, reading, makes you improve your lua skills... For instance, I finnally learnt and understand the Loops!!! and I now understand the tables. My problem now is how to use the results... In any case, I guess I just need to learn and to study!
  7. does anyone know how to make a table with the units that are LOS? I use mist.getunitLOS, and i have a table with all values. Ibdont know how to put all [vis] values into antoyher table.
  8. You. Dont receive a messge or the flg just dorsnt change?
  9. Beautifull!
  10. Newton 3rd law is every accition has a proportional reaction in the oposite side... Now, tell me were the recoill is suposed to come from since rocket launchers are open in both extremes.;)
  11. Hello, Grimes AGAIN ME¡¡¡ It is really annoying, it seems that my script works well with human player, and with AI aircrafts UNTIL one is destroyed. Then it seems that the scripit is blocked, and the SAMs does not switch off. The scripit is as follows... IF aircrafts are detected by EWR radar and are helicopters or Planes, AND are inside a moving zone, the SAM units goes to AUTO (ON) And, if there is not aircrafts or planes inside the moving zone the SAM goes to GREEN (off) It works perfect when I do the test, but when I put some extra IA in the test, they activated well, but once destroyed, they stay ON until you are well outside its range. this is my script (it is some simple IADS... hehehe since I cant make your script to work in 1.5) function findTargets() function getGroupCategory(unit) -- THIS FUNCTION TO GET AROUND CLIENT GROUPS NOT ACCESSABLE IF USING IN A MULTIPLAYER ENVIRONMENT local unitDB = mist.DBs.unitsById[tonumber(unit:getID())] if unitDB ~= nil and unitDB.category then return unitDB.category end return nil end local samsites = {'sam1','sam2','sam3'} local ewrsites = {'ewr1','ewr2'} for i,j in pairs(ewrsites) do ewr = ewrsites[i] local unit = Unit.getByName(ewr) if unit ~= nil then local unitController = unit:getGroup():getController() --be careful, I'm not sure if the bug where client groups are not accessable will stuff this up if a player is in the vehicle at the time local detectedTargets = unitController:getDetectedTargets(Controller.Detection.RADAR) -- Controller.Detection.RADAR is the type of detection (radar in this case) -- leave it blank for all types (it includes RWR if the unit has one ie AWACS) -- for a list of detection types see here: http://wiki.hoggit.us/view/DCS_func_getDetectedTargets for k,v in pairs (detectedTargets) do if v["object"]:getCategory() == Object.Category.UNIT then --ensure the detected object is a unit, ive had it detect weapons local category = getGroupCategory(v["object"]) -- pull category using workaround if category == "plane" or category == "helicopter" then --check category as returned by MIST trigger.action.setUserFlag('400',1) detectedblue = v["object"]:getName() for f,c in pairs(samsites) do sam = samsites[f] mist.flagFunc.units_in_moving_zones{ units = {detectedblue}, zone_units = {sam}, flag = tostring(sam), radius = 10000, stopflag = 9999, req_num = 1, zone_type = 'cylinder', interval = 1, toggle = true } if trigger.misc.getUserFlag('400') == 1 and -- if planes or helos are detected trigger.misc.getUserFlag(tostring(sam)) == 1 -- and are inside a moving SAM zone then _group = Group.getByName(sam) _controller = _group:getController() _controller:setOption(AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.AUTO)-- we change the status to ON --trigger.action.outText(detectedblue .. " detected by " .. sam .. ewr, 5) end end end end end end end for f,c in pairs(samsites) do sam = samsites[f] mist.flagFunc.units_in_moving_zones{ units = {'[blue][plane]','[blue][helicopter]',}, zone_units = {sam}, flag = tostring(sam), radius = 10000, stopflag = 9999, req_num = 1, zone_type = 'cylinder', interval = 1, toggle = true } if trigger.misc.getUserFlag(tostring(sam))== 0 then _group = Group.getByName(sam) _controller = _group:getController() _controller:setOption(AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.GREEN )-- we switch off the SAM trigger.action.setUserFlag('400',0) end end timer.scheduleFunction(findTargets, {}, timer.getTime() + 3)-- scan the function every 10 seconds end findTargets ()
  12. I dont really understand what you mean... I am doing some steps ang getting things to make this script to work, but still working on it.
  13. Grimes, you told me once that I should learn to do som .lua scripting!! and that is what I am doing. I am spending hours and days to learn the basics, I am studing the .lua manual, but sometimes I find somehting I cant solve by myself. Using mist, it is great!! but I need some clarifications yet. for instance, and this is very important to my future scripts. I want this to work... it is just, when units are in zone, smoke in each group. this code works fine, and I get the message. do redunits = mist.makeUnitTable({'[red][vehicles]'}) targets = mist.getUnitsInZones(redunits,{'North'} , 'cylinder') for k, v in pairs(targets) do local targetunit = targets[k] local targetgroup = targetunit:getGroup():getName() do trigger.action.outText(targetgroup .. " detectado ", 30) end end end but when I try to put some somoke in the group.... not. I seems that I am not naming properly the "targetgroup" because if I use let say ({'[g] Group A'}) the script is fine. What is wrong to this argument?? do redunits = mist.makeUnitTable({'[red][vehicles]'}) targets = mist.getUnitsInZones(redunits,{'N'} , 'cylinder') for k, v in pairs(targets) do local targetunit = targets[k] local targetgroup = targetunit:getGroup():getName() do trigger.action.smoke(gmist.getAvgPos(mist.makeUnitTable([b]targetgroup[/b])), "Orange") end end end
  14. I am having an issue with a script using this. If an aircraft its outside the zone the radar is in Green status (Off)... THere are other things, and works fine, but I realized that if an aircraft is shot down in the area, it look as if the script is still considering it inside the zone. Is it possible?? Or I should have doing something wrong?? local samsites = {'sam1','sam2','sam3'} for f,c in pairs(samsites) do sam = samsites[f] mist.flagFunc.units_in_moving_zones{ units = {'[blue][plane]','[blue][helicopter]'}, zone_units = {sam}, flag = 500, radius = 10000, stopflag = 9999, req_num = 1, zone_type = 'cylinder', interval = 1, toggle = true } if trigger.misc.getUserFlag('500')== 0 then _group = Group.getByName(sam) _controller = _group:getController() _controller:setOption(AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.GREEN )-- we switch off the SAM end by the way, can I use" flag = tonumber(sam)" to keep independant flags???
  15. Those ahould be, South vietnam F5 retired from the theatre...
  16. You can do it via mission editor. When unit inside a triggerzone flag value 1, when flag value 1 trigger smoke in trigger zone, when unit outside triggerzone flag value 0. Or via script. Mist. Unitsinzones activates a flag. And trigger.action. smoke.... if you need the script for something else, may be I can help you later.
  17. hello all, I am trying to use the range of a SAM as a radius for a mist.flag func unitinmovingzones. Since I dont want to put all the ranges manually, I want the script to get it automatically, but I am not getting there. THis is what I have done so far. But I guess I am doing something wrong... samsites = {'sam1','sam2'} for i, v in pairs(samsites) do local sam = samsites[i] if sam ~= nil then local unit = Unit.getByName(sam) local ammo = unit:Weapon.DescMissile(): local range = ammo["rangeMaxAltMin"] trigger.action.outText(" the radius is".. range, 5) end end
  18. Ill catch Morgans book. Falklands war its pretty cool to try to reproduce in DCS. I madr in my squadron few missions with Mi21. Sarting from Socchi, and then dead reckoning navigation across the sea, with no RSBN or ARK. Three fuel tanks and couple of big rockets to attack some sheeps in the little strait between Caucasus and Crimea... I should have ot ober therr, the problem is the briefing is in spanish. Although you have maps, flight plans and everything.
  19. ok, I finnally did it!!!! I will edit the first post so people can get the script directly from there and the explanations... it is not user friendly yet... but give me time!!! I am learning!!!
  20. Can anyone tell me how to make a table of units that has been detected? I am not able to do it, i am trying Targets=mist.makeUnitTable(detectedTargets:getByName()) but it does not seems to work. I needed to put in the second condition, simce detectedblue does not work with two or more planes. If there are two aircrafts, if in the second loop if detectedblue is outside the zone, the radar is off. Even if there is another aircraft in the zone. Then, it the function restart, and again the sam is on, and goes like that, on off on off... I want the sam once switched on, to be on until there is not ANY aircraft inside. Any suggestion?
  21. I am really close!!! but still does not work fully, because when there are two planes, it makes the loop twice, which is ok, but, if one is not in the zone... it is swithing the radar on, and off continuously, I dont know.... this is what I have got that works with just one plane, but several Sams function findTargets() local unit = Unit.getByName('ewr') -- You can define a table of unit names if you want, and run them thru a loop to check each one if unit ~= nil then local unitController = unit:getGroup():getController() --be careful, I'm not sure if the bug where client groups are not accessable will stuff this up if a player is in the vehicle at the time local detectedTargets = unitController:getDetectedTargets(Controller.Detection.RADAR) -- Controller.Detection.RADAR is the type of detection (radar in this case) -- leave it blank for all types (it includes RWR if the unit has one ie AWACS) -- for a list of detection types see here: http://wiki.hoggit.us/view/DCS_func_getDetectedTargets for k,v in pairs (detectedTargets) do if v["object"]:getCategory() == Object.Category.UNIT then --ensure the detected object is a unit, ive had it detect weapons local category = getGroupCategory(v["object"]) -- pull category using workaround if category == "plane" or category == "helicopter" then --check category as returned by MIST trigger.action.setUserFlag('400',1) --check category as returned by MIST detectedblue = v["object"]:getName() --set flag --replace flag number as you see fit, and value can be true / false or have a numeric value local samsites = {'sam1','sam2'} for k,v in pairs(samsites) do sam = samsites[k] mist.flagFunc.units_in_moving_zones{ units = {detectedblue}, zone_units = {sam}, flag = 500, radius = 10000, stopflag = 9999, req_num = 1, zone_type = 'cylinder', interval = 4, toggle = true } if trigger.misc.getUserFlag('400') == 1 and -- if planes or helos are detected trigger.misc.getUserFlag('500') == 1 -- and are inside a moving SAM zone then _group = Group.getByName(sam) _controller = _group:getController() _controller:setOption(AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.AUTO)-- we change the status to ON trigger.action.outText(detectedblue .. "es detectado por" .. sam , 30) end if trigger.misc.getUserFlag('500')== 0 -- but if the aircraft leaves the zone independently of the EWR since the EWR already informed that SAM that there is enamies. then _group = Group.getByName(sam) _controller = _group:getController() _controller:setOption(AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.GREEN )-- we switch off the SAM trigger.action.outText(detectedblue .. "no es detectado por" .. sam, 30) -- just a message end end end end end end timer.scheduleFunction(findTargets, {}, timer.getTime() + 10)-- scan the function every 10 seconds end function getGroupCategory(unit) -- THIS FUNCTION TO GET AROUND CLIENT GROUPS NOT ACCESSABLE IF USING IN A MULTIPLAYER ENVIRONMENT local unitDB = mist.DBs.unitsById[tonumber(unit:getID())] if unitDB ~= nil and unitDB.category then return unitDB.category end return nil end findTargets () I am learning a lot of the concepts in lua, so when I get this to work, I will try to make also the SAMs, to switch on randomly... and if they dont find anything, they will switch off, and move tto another point. things like that. I am not going to get close to the IADS but... since it does not work!!
  22. Does it has gunners?
×
×
  • Create New...