Jump to content

Hardcard

Members
  • Posts

    1080
  • Joined

  • Last visited

Everything posted by Hardcard

  1. @hydrawind Looks like the MFD issue is fixed now. Thanks a lot! Could you please share the specific changes you made to fix the issue? Which lua files did you modify? With 500 lua files in there, it's like finding a needle in a haystack...:cry:
  2. That's the problem, statics and scenery objects belong to different classes... also, scenery objects only have a handful of methods available. You can still use AttackMapObject task with scenery objects, the tricky part is to find them and filter them out by type name. Here, this script will order individual AI planes to attack scenery radar found at the closest enemy airbase (just need to provide the unit names of the chosen planes. Also, they must be set to Ground Attack or CAS): local Striker_Name_SET = { "[color="Red"]Name of the first unit in ME[/color]", "[color="red"]Name of the second unit in ME[/color]" , }[color="Blue"] -- etc.[/color] local function Get_Closest_Enemy_Airbase(Unit_Object) if Unit_Object:getCoalition() == coalition.side.BLUE then Airbase_Coalition = coalition.side.RED elseif Unit_Object:getCoalition() == coalition.side.RED then Airbase_Coalition = coalition.side.BLUE end Distance_Table = {} for i, Airbase_Obj in ipairs( coalition.getAirbases(Airbase_Coalition) ) do if Airbase_Obj then local Airbase_Object = Airbase_Obj local Airbase_Coord = Airbase_Object:getPoint() local Unit_Coord = Unit_Object:getPoint() local Distance2D = math.floor( ( ( Airbase_Coord.x - Unit_Coord.x ) ^ 2 + ( Airbase_Coord.z - Unit_Coord.z ) ^ 2 ) ^ 0.5, 0 ) table.insert(Distance_Table, Distance2D) end end local Threshold = 1000000000 local Closest_Index = 0 for k = 1 , #Distance_Table do local asNum = Distance_Table[k] if ( asNum and asNum < Threshold ) then Threshold = asNum Closest_Index = k end end local Closest_Object = coalition.getAirbases(Airbase_Coalition)[Closest_Index] local Closest_Name = Closest_Object:getName() local Closest_Distance = Distance_Table[Closest_Index] local Closest_Point = Closest_Object:getPoint() return Closest_Object , Closest_Point end local function Search_Destroy_EWR(Striker) local Closest_Airbase_Object , Closest_Airbase_Coord = Get_Closest_Enemy_Airbase(Striker) local Search_Area = {id = world.VolumeType.SPHERE, params = {point = Closest_Airbase_Coord , radius = 2000}} [color="Blue"]-- Radius must be at least 500 meters (~1600 feet) for the volume search to work!!![/color] local function Evaluate_Zone(Scenery_Object) if Scenery_Object then if Scenery_Object:getCategory() == Object.Category.SCENERY and Scenery_Object:getName() and Scenery_Object:getTypeName() and Scenery_Object:getPoint() then local Scenery_Type = Scenery_Object:getTypeName() if Scenery_Type == "RLS-37" then [color="blue"]-- RLS-37 is a radar scenery object found at Caucasus airbases[/color] Radar_Coord = Scenery_Object:getPoint() Radar_Vec2 = { x = Radar_Coord.x , y = Radar_Coord.z } end end end end world.searchObjects(Object.Category.SCENERY, Search_Area, Evaluate_Zone) if Radar_Vec2 then local Strike_EWR_Task = { id = 'AttackMapObject', params = { point = Radar_Vec2, groupAttack = false, expend = "ALL" } } local Striker_Controller = Striker:getController() Striker_Controller:pushTask(Strike_EWR_Task) elseif Radar_Vec2 == nil then trigger.action.outText("No RLS-37 found on "..Closest_Airbase_Object:getName().." airbase (closest)", 10) end end for i, Striker_Name in pairs( Striker_Name_SET ) do if Unit.getByName(Striker_Name) and Unit.getByName(Striker_Name):isExist() then Search_Destroy_EWR(Unit.getByName(Striker_Name)) end end
  3. You could extract the coordinates of the waypoint you're interested in, then write a coordinate distance check (which would go inside a scheduler)
  4. You can try event.initiator:getID() instead, but chances are you'll get nil (since the object will be dead) Alternatively, take the id from a HIT event instead: function checkHit(event) if event.id == world.event.S_EVENT_HIT then trigger.action.outText("HIT: ",10) trigger.action.outText("EVENT: "..event.target:getID(), 10) end end mist.addEventHandler(checkHit)
  5. The DCS object, which you need to provide as first parameter for :knowTarget(). Use standard DCS code instead of ATME: leadGroup = Group.getByName("A10") [color="Blue"]-- get the group[/color] leader = leadGroup:getUnit(1) [color="blue"]-- get pilot1 unit object[/color] leader_Controller = leader:getController() [color="blue"]-- get pilot1 unit controller[/color] target = StaticObject.getByName("Reserv1") [color="blue"] -- get target object[/color] leader_Controller:knowTarget(target,true,true) Both parameters are booleans (they can be set to either true or false) Boolean type = If set to true, target type is known Boolean distance = If set to true, distance to target is known Probably won't, but it doesn't hurt to try. You mean this line? target = ATME.C_StaticObject.getByName("Reserv1") If it gives you an error, either the name is incorrect, syntax is incorrect, the object is not a static / it's not reachable. Try with standard DCS code, if you still get an error, name is incorrect or object isn't reachable: StaticObject.getByName("Reserv1")
  6. @Careos The demo mission works for me. Keep in mind that it's configured for multiplayer (needs to run on a server) Also, you need to place SWAPR_Server_Hook_1_2.lua (provided inside the demo mission folder) in System_Drive:\Users\YOUR_USERNAME\Saved Games\DCS.openbeta\Scripts\Hooks If you're having problems with one of your own missions, please include your mission file, dcs.log and server hook (if MP) in your report
  7. Says who? The OP didn't specify. That EWR could be one of these units:
  8. @mattag08 Alternatively, you could try swapping friendly for foe at a given distance. Example: - Spawn friendly F5 at an arbitrary distance from the player - When player gets within a given radius, that friendly F5 will despawn. - Enemy F5 will then spawn at that approximate location - Enemy F5 will then engage the player
  9. You should be able to push a scripted attack unit task... with the right parameters and the right loadout. https://wiki.hoggitworld.com/view/DCS_task_attackUnit Note: Contrary to what the wiki says, I don't think attackQty parameter is optional. If the AI aircraft RTB instead of performing the attack, that might be due to either weapon incompatibility with the selected task or incorrect parameters.
  10. I don't know any command that would do that, but you can try to do it "indirectly". Try pushing evasive task, changing ROE / Alarm state, etc. you might get lucky.
  11. It's a pretty annoying bug, happens every time you modify existing payload profiles on the A10C. To "fix" it, you need to open the miz file using winrar (or similar), then delete the DSMS folder inside it and save. Next time you load the mission, the DSMS page should show the correct payload (use "Fly Mission" instead of "Prepare Mission" in ME).
  12. @trampi I see, you want to create a gadget, like the BuddySpike people did -->http://gadget.buddyspike.net/ Xcom and Ciribob should be able to help you with it, you can contact them on the BF Discord channel, just keep in mind they're busy. I only have limited experience with the DCS Control API, but I guess I can offer you my 2 cents: Make sure that :inAir() works with carrier-based aircraft. Alternatively, use land events, I think they're more reliable (and work for helicopters as well). Note that land events also contain the landing location (provided it's an airbase area or carrier / warship) I'd try to use custom flags to provide the environment information that you need for each unit. For instance, you could periodically populate a table with all active clients and then iterate that table to create / modify the status flags for each unit. Here's an example (contains MOOSE code): local function Status_Check() local Client_SET = SET_CLIENT:New():FilterActive(Active):FilterOnce() [color="Blue"]-- This set should be automatically populated with all active clients in the mission[/color] local Active_Unit_Table = Client_SET:GetSetObjects() [color="blue"]-- This should return a table containing all active clients in the mission[/color] for i, Active_Unit in pairs(Active_Unit_Table) do if Active_Unit and Active_Unit:GetDCSObject() then local DCS_Object = Active_Unit:GetDCSObject() [color="blue"]-- Convert MOOSE objects to DCS[/color] local DCS_Object_Name = DCS_Object:getName() if DCS_Object:inAir() then trigger.action.setUserFlag( "inAir_Flag_"..DCS_Object_Name , 1)[color="blue"] -- The server hook should be able to access this custom flag[/color] elseif DCS_Object:inAir() == false then trigger.action.setUserFlag( "inAir_Flag_"..DCS_Object_Name , 0) [color="blue"]-- The server hook should be able to access this custom flag[/color] end end end return timer.getTime() + 10 [color="blue"] -- Refresh is set to 10 seconds, feel free to experiment with lower values [/color] end timer.scheduleFunction(Status_Check, nil , timer.getTime() + 1)
  13. I may be wrong about this, but IIRC, net.dostring_in() only works with mission environment flags. For instance, this should return the value of a given mission environment flag (note that both parameters must be valid strings): net.dostring_in('server', " return trigger.misc.getUserFlag(\"[color="Red"]Name of the flag in ME[/color]\"); ") What are you trying to accomplish with that serializer? EDIT: I see that you already sorted it out on the MOOSE discord channel, which would've been my recommendation :thumbup:
  14. @wernst I think you misunderstood my earlier comment. Yes, we'll obviously need to replace these files after each update, that's not what I meant. I meant that perhaps it will come a time when these files are no longer compatible. @hydrawind I think I've found an issue (not sure if it's due to incorrect installation on my part). I'm getting duplicated data on the MFDs (upper and lower sections only, middle section seems to be "aligned"):
  15. Like I said, I couldn't care less, the old cockpit is good enough ;) Also, tomcat cockpit probably has a higher poly count and way better textures as well, yet runs smoothly.
  16. Buying better hardware just to run a poorly optimized cockpit is misguided at best. Tomcat has a new and very detailed cockpit, yet runs as it should on older hardware, so it's not a hardware problem (or shouldn't be). Also, your settings are way too high for people running older hardware (resolution is too high, visib range is too high, shadows are too high, preload radius is set to max, etc.) @Everyone having issues with the new cockpit Hydrawind was kind enough to modify and share the old cockpit script files. https://forums.eagle.ru/showthread.php?t=260085 All you need to do is place the contents of the rar file inside x:\DCS World\Mods\aircraft\A-10C\Cockpit and replace all required files (make a backup first, just in case) I've tested it and works (also passes the integrity check in MP), I'm back on the old cockpit, enjoying proper performance (I couldn't care less about the slightly reduced texture quality :thumbup:)
  17. Performance issues with the new cockpit, for instance. @hydrawind A thousand thanks man! Works and passes the integrity check in MP. I hope it'll keep working with future updates, since the new cockpit runs like crap on my rig.
  18. @wraith70 There are two problems in your mission Incorrect pilot name in the function call, you wrote "Pilot# 001" instead of "Pilot #001" MissionFunctions.lua needs more than 1 second to be fully loaded. If you start calling functions just one second after loading it, you'll get errors. As a rule of thumb, load your function libraries at mission start (no conditions) and give them a few seconds to load, before you start calling stuff from other scripts.
  19. @wraith70 Units of measure are passed as strings, not variables, the if conditions in your function should reflect this. Also, you don't need MIST (or MOOSE) to round up values, standard Lua math.floor() is all you need. Here's a corrected version of your script (haven't tested it, but I don't see why it shouldn't work): function AGL(pilot_name,unit_of_measure) [color="Blue"]--[[ Return Aircraft AGL altitude in Meters or Feet Arguments pilot_name = Name of Pilot/Unit in ME unit_of_measure = Meters or Feet ]]--[/color] local Huey = Unit.getByName(pilot_name) local Huey_Altitude_MSL = Huey:getPoint().y -- Altitude MSL, in meters -- Huey's altitude from ground local Huey_Vec3 = Huey:getPoint() local Huey_Land_Height = land.getHeight({x = Huey_Vec3.x , y = Huey_Vec3.z}) -- Altitude from ground in meters local Huey_Altitude_Ground = Huey_Altitude_MSL - Huey_Land_Height --AGL in Meters local Huey_AGL_Meters = math.floor(Huey_Altitude_Ground , 0) [color="blue"]--Round to 0 decimal places[/color] --Convert AGL from Meters to Feet local Huey_AGL_Feet = math.floor(Huey_Altitude_Ground * 3.28084 , 0) [color="blue"]--Round to 0 decimal places[/color] if unit_of_measure == 'meters' then [color="Blue"]-- Notice the quotation marks[/color] return Huey_AGL_Meters end if unit_of_measure == 'feet' then [color="Blue"]-- Notice the quotation marks[/color] return Huey_AGL_Feet end end
  20. @Yurgon I don't have Nevada map installed due to limited space in my SSD, so I can't test your mission atm. The problem you're describing could be caused by some obscure scripting error that only appears in certain situations (when several players connect, for instance)... or it could be caused by processing times getting longer (as players join and the mission runs). Key question #1: Are those problematic replacements being removed at all, or do they remain and make clients go boom? If they are being removed, the problem is likely caused by increased processing time. If not, there's probably a scripting error, somewhere (I'll need log info). Key question #2: Does this happen only with specific types of replacements or not? Static, AI...both? Any specific airframe types? Key question #3: Solving this problem will probably require dozens of failed tests on your dedicated server... are you willing to endure the torture? :D
  21. You need to find the relevant existing units (they must be alive when the script runs) and task them the same way you did with the spawned groups. There's a chance the AI won't switch tasks when doing FollowingGP:SetTask( GP_Task, 1 ), in that case, you can try clearing their current tasks immediately before, using :ClearTasks() Also, if you define the offsets in vec3 format, there's no need to use :GetVec3() in the task declaration. [color="blue"]-- Define offsets in DCS Vec3 format[/color] local LARGCL = { x = 0, y = 0, z = 914.4 } local LARCL = { x = 0, y = 0, z = 1828.8 } local LAROL = { x = 0, y = 0, z = 2743.2 } [color="blue"]-- Define GP_FOLLOW function[/color] function GP_FOLLOW( Followed_GP, Following_GP, Vec3 ) local FollowedGP = Followed_GP local FollowingGP = Following_GP local GP_Offset = Vec3 local GP_Task = FollowingGP:TaskFollow( FollowedGP, GP_Offset ) [color="blue"]-- Note that [i][b]:GetVec3()[/b][/i] is no longer needed, since the offsets are already declared in Vec3 format[/color] ---FollowingGP:ClearTasks() [color="Blue"]-- Use this line ONLY if you have trouble getting the following groups to switch task[/color] FollowingGP:SetTask( GP_Task, 1 ) end [color="blue"]-- Define following and followed groups (they all must be alive when this script runs)[/color] local Following_Grp_1 = GROUP:FindByName("[color="Red"]name of the first following group in ME[/color]") local Following_Grp_2 = GROUP:FindByName("[color="Red"]name of the second following group in ME[/color]") local Following_Grp_3 = GROUP:FindByName("[color="Red"]name of the third following group in ME[/color]") local Following_Grp_4 = GROUP:FindByName("[color="Red"]name of the fourth following group in ME[/color]") [color="Blue"]-- etc...[/color] local Followed_Grp_1 = GROUP:FindByName("[color="Red"]name of the first followed group in ME[/color]") [color="Blue"]-- etc...[/color] [color="blue"]-- Call GP_FOLLOW function with the desired parameters[/color] GP_FOLLOW( Followed_Grp_1 , Following_Grp_1 , LARGCL ) GP_FOLLOW( Followed_Grp_1 , Following_Grp_2 , LARCL ) GP_FOLLOW( Followed_Grp_1 , Following_Grp_3 , LAROL ) GP_FOLLOW( Followed_Grp_1 , Following_Grp_4 , LAROL )
  22. @Kappa You almost got it, but you seem to be missing another important concept. RecceSet:ForEachGroup( function ([color="Red"][b]RecceGroup[/b][/color]) [color="Blue"]-- [b][i]RecceGroup[/i][/b] represents each GROUP OBJECT contained in [i][b]RecceSet[/b][/i]. Consider it a GROUP object [/color] RecceGroupName = RecceGroup[color="Red"]:GetSetName()[/color] [color="Blue"]-- This isn't a valid method for a GROUP object, it'll error. Also, the correct syntax is GetSetName[u][b]s[/b][/u](), in plural[/color] [color="Blue"]-- Simply get the name of each group in the usual way:[/color] RecceGroupName = RecceGroup:GetName() local SpawnRecce = SPAWN:New(RecceGroupName) :InitLimit(1,0) :InitRepeatOnLanding() :InitDelayOff() :SpawnScheduled(10,0) end ) Keep in mind that the script I wrote uses standard Lua for loops, which is why I had to use :GetSetNames() in order to get all the group names in the set. Your script uses MOOSE iterators (fancier for loops), which allow you to work directly with the MOOSE objects in the set, so you can just get the names using typical MOOSE methods.
  23. @wraith70 Works for me, you're doing something wrong. Post your mission file, we'll see what the problem is
  24. @wraith70 It definitely made it better, but there are other problems. Is there an existing UNIT called "UH1H" when the script runs? (It must be the PILOT name) If there isn't, you'll get that error. Also, as a general rule, refrain from giving variables the exact same names of DCS classes and common parameters, otherwise you'll have problems all the time. (Avoid names like Unit, Group, pos, id, etc.) As for getting the unit's altitude, do this: local Huey = Unit.getByName('UH1H') [color="Blue"]-- A unit called [i][b]UH1H[/b][/i] (PILOT name) must exist when this runs, otherwise it'll error[/color] local Huey_Altitude_MSL = Huey:getPoint().y [color="blue"]-- Altitude MSL, in meters[/color] [color="Blue"]-- Now, if you also want to know the huey's altitude from ground, do this:[/color] local Huey_Vec3 = Huey:getPoint() local Huey_Land_Height = land.getHeight({x = Huey_Vec3.x , y = Huey_Vec3.z}) local Huey_Altitude_Ground = Huey_Altitude_MSL - Huey_Land_Height [color="blue"]-- Altitude from ground in meters[/color]
  25. @Kappa function SetScroll ( [color="red"]group[/color] ) local SpawnRecce = SPAWN:New( [color="red"]group[/color] ) [color="Blue"]-- SPAWN:New() requires a [u][i][b]string[/b][/i][/u] as parameter (the template group name in ME), NOT a group object[/color] :InitLimit(1,0) :InitRepeatOnLanding() :InitDelayOff() :SpawnScheduled(10,0) end RecceSetTable = [color="Red"]RecceSet:GetSetObjects()[/color] [color="Blue"]-- This will return a table containing all GROUP OBJECTS in the set, not their group names[/color] for i = #RecceSetTable, 1, -1 do RecceGroup = RecceSetTable[i] [color="blue"] -- [b]RecceSetTable[i][/b] will return a group object, NOT a group name[/color] SetScroll([color="red"]RecceGroup[/color]) [color="Blue"]-- RecceGroup contains a group object, not a group name[/color] end [color="blue"]-- In order for RecceGroup to contain the group name, do this instead:[/color] for i = #RecceSetTable, 1, -1 do if RecceSetTable[i] and RecceSetTable[i]:GetName() then RecceGroup = RecceSetTable[i]:GetName() SetScroll(RecceGroup) end end [color="Blue"]-- Note that this script will only work if RecceSet is populated... if the set is empty, it won't work.[/color] I'll run some tests, see if late-activated groups are reachable, things might've changed since I last tried this... UPDATE: As I suspected, late-activated group templates can't be reached by SET_GROUPs when declared in the usual way... however, I've found a solution. In order for late-activated group templates to be reachable by SET_GROUPs, you'll need to get them directly from a database object. Here's how you need to declare the SET_GROUP (required parameter marked in red): RecceSET = SET_GROUP:New(DATABASE:New()):FilterPrefixes('[color="Red"]Chosen common prefix/suffix in ME[/color]'):FilterOnce() This set will include ALL objects in the mission (late-activated or not) whose names contain the specified prefix/suffix. Once the set has been properly declared, you can get the table containing all set object names, which you will need for the SPAWN object declarations: local Groupname_Table = RecceSET:GetSetNames() You can apply this to your initial script, or simply use the script I wrote (updated & tested):
×
×
  • Create New...