Jump to content

toutenglisse

Members
  • Posts

    1742
  • Joined

  • Last visited

Posts posted by toutenglisse

  1. 16 hours ago, BCush83 said:

    I have an ACM combat zone with progressively harder enemies spawning; I'd like the players aircraft to re-arm and re-fuel when the enemy is killed as the next enemy spawns in, without having to land if still alive.  Is this possible?  Perhaps a command or line of code triggered by a flag or unit dead?

     

    There is an option with script, that is "respawning" your aircraft with updated position and vector, but can only work in single player, and is probably a bit "dirty" in action.

    Little test attached (2 client slots to choose from on runway, F16 and F18, and when you kill the mig29 you have a 10sec delay and respawn in air where you are - mig29 also respawns).

    test-restore-player-AC-on-kill.miz

  2. 4 hours ago, Arktos said:

    ...Any other thoughts?...

    I've just tried "sample test" using your description. I don't know why but both "if not Group.getByName('GROUP') then" and "if mist.groupIsDead('GROUP') == true then" return unexpected data.

    It does work with :

    local gp = Group.getByName('GROUP')
    if gp and gp:isExist() == true and #gp:getUnits() > 0 and gp:getUnit(1):isActive() then
    else
    mist.respawnGroup('GROUP', true)
    end

     

  3. Hi, here is a working edited version of your miz. I changed line 6.

    With your script, when the late activated group is destroyed, and then checked again by function, groupIsDead returns false (instead of true, probably because late activated group specificities?) and then the function tries to access to unit 1 that doesn't exist anymore and that creates the error. So the 1st 2 radio command pushes work and then error happens (activate - destroy - error).

    VKN_Marianas_Training_Mission_Forum-EDIT.miz

    • Thanks 1
  4. @dimitriov there is a flaw in my script. It works if used once by each vehicle groups, but issue raise if function is used multiple times by a group (due to flags values being manually set and to the way env.mission updates points when setTask Mission is used).

    Here is the updated miz example (script is updated and instead of manually set flag values for wpts > 0, each wpt need to set flag value = flag value +1).

    test-GroundVeh-resume-route-after-setTask.miz

  5. @dimitriov I wrote the script with env.mission datas and used setTask Mission to resume route and put it in this example. (so without using mist)

    The vehicle enters a zone ("debut tir") that activates a triggered task (fire on point) using AI SET TASK (so this task deletes the route, and without action when the task is complete the vehicle just stands on place without resuming). 45 seconds after "debut tir" task, the function ResumeRoute is used with groupname and flagname as parameters and the vehicle resumes its route toward remaining waypoints.

    Only requirement, apart using the function when needed to resume, is to set flag value for waypoints > 0 (value = 1 for wpt 1 etc...) by script in advanced wpt action.

     

    • Like 1
  6. 1 hour ago, dimitriov said:

    ...I therefore would like to create a table which would include:

    - The WP of the unit

    - Which is the active WP

    - Being able to get it to resume its route once the "maneuver" is finished...

     

    Hi Nicolas, the only way I actually found to handle that is :

    - get route/WP using mist function

    - get trace of WP already reached using a flag (value +1 when a new WP is reached)

    - and resume route, updated by removing already reached WP using this little function :

    function GoUDRoute()
    GroupRoute = mist.getGroupRoute(GroupName, true)
    for i = 1, trigger.misc.getUserFlag(FlagName) do
    table.remove(GroupRoute, 1)
    end
    mist.goRoute(GroupName, GroupRoute)
    end

    Have a nice day

    Pierre

  7. @dFlow, your local table plane does not respect the structure of an aircraft group (or any group, even ground group), for example you have have stacked in the root ("group" datas) datas that belong to "units" ("units" must be present with numerically indexed unit(s), and units datas inside). You also gave strings to entries that need number (groupId, unitId), or other kind of not valid values (you would even better get ridd of some entries like group/unit ID, callsign, onboard num, names, and let scripting engine create unique available values when spawning).

    To be safe at first, you should create the plane group using mission editor in a clean mission, save mission, unzip from mission.zip the file named "mission" and open it with notepad++ to get the aircraft group table as created by mission editor.

    From there you could copy the group table to your script and change the datas you want to be dynamically set (spawn position/orientation, route, names, payload, options, tasks, or whatever...) and be sure you use correct values type to feed it.

  8. @Presidium and @Rudel_chw, I've tested Rudel's random number miz and I can't say why, but same numbers still happen.

    Attached modified miz (modified the 3 flags trigger to fire every 4 seconds, and added a time message and made the messages continuous - updated every second)

    I tested because my hesitation with this method was : maybe flags would still be activated with potential same numbers and detected like this before being changed, due to "switched cond" triggers being evaluated every sec. But it seems that this is not an issue, while there is another one. (unidentified, but soon or late flags are activated with same numbers)

    FWIW with script the 2nd and 3rd flags can only be activated with values from 1 to 10 but without value(s) of previous flag(s).

    issue.jpg

    Test Random Numbers-every-4-sec.miz

    • Thanks 1
  9. 5 hours ago, Presidium said:

    ...Three different flags with three different values...

    Hi, here a script to do that (and a .miz to test -> flags are defined every 5 seconds with message that gives values) :

    local values = {1,2,3,4,5,6,7,8,9,10}
    for j = 1, 3 do
    local i = math.random(#values)
    trigger.action.setUserFlag("0"..j, values[i])
    table.remove(values, i)
    end

     

    test-3flags-unique-rand-value-1-10.miz

    • Thanks 1
  10. 5 hours ago, ADHS said:

    ...Hmm, so it's better to check for both cases at the same time: if Event.id == string or number. 👍...

    I think Grimes said it's better to only test the event "string", as number can change but not "string" :

    13 hours ago, Grimes said:

    ...if you used world.event.S_EVENT_DEAD then the only way that would break is if that event was deleted...

     

    5 hours ago, ADHS said:

    ...I am trying to setup a custom multi-event handler check and i am facing many problems (overlaping alarms etc)...Can you please give me a draft of the propper way to call them ?...

    Here is a script example where I check for SP player/client both "pilot dead" and "killed" events (so script works when player crashes, get killed, or eject from damaged aircraft). Both can happen at same time and so desired following schedulled functions (respawn and countdown messages) can overlap. So when 1 event occures I first remove schedulled functions of probable other event :

    Spoiler
    local MessageID = {}
    function WhenDEAD(player)
    		mist.removeFunction(RespawnID)
    		for i = 1, 5 do
    		mist.removeFunction(MessageID[i])
    		end
    		local playerDatas = mist.getGroupData(player:getGroup():getName())
    		for i = 1, 4 do
    		if playerDatas["units"][i] and playerDatas["units"][i]["skill"] == "Client" then
    		playerDatas["units"][i]["skill"] = "Player"
    		end
    		end
    		RespawnID = mist.scheduleFunction(mist.dynAdd,{playerDatas}, timer.getTime() + 6)
    		for i = 1, 5 do
    		MessageID[i] = mist.scheduleFunction(trigger.action.outText,{player:getPlayerName()..' you will be respawned in '..
    		(i==1 and '5' or i==2 and '4' or i==3 and '3' or i==4 and '2' or i==5 and '1')..' seconds.',1,true}, timer.getTime() + 0.5 + (i-1))
    		end
    end
    function DEAD(event)
    		if event.id == world.event.S_EVENT_PILOT_DEAD and event.initiator and event.initiator == world.getPlayer() then
    		player = event.initiator
    		WhenDEAD(player)
    		elseif event.id == world.event.S_EVENT_KILL and event.target and event.target == world.getPlayer() then
    		player = event.target
    		WhenDEAD(player)
    		end
    end
    mist.addEventHandler(DEAD)

     

     

    • Thanks 1
  11. 3 hours ago, ADHS said:

    ...I've noticed that ENTER and LEAVE worked ONLY with string   world.event.if Event.id == S_EVENT_PLAYER_ENTER_UNIT...

     

    I've just checked and both following sentences work :

    if event.id == 20 then

    if event.id == world.event.S_EVENT_PLAYER_ENTER_UNIT then

    • Thanks 1
  12. 3 hours ago, walt262 said:

    Yeah, the supercarrier module fix it. Now, I wonder why the AI aircraft likes to taxi through the static aircraft I place on the deck?

    From supercarrier manual :"It is important not to place static objects in locations they may interfere with flight operations so test your mission thoroughly to find any problems."

    You can find on this page pictures of all carrier types with all slots and taxiways used by AI :

    DCS editor carrier spawns - DCS World Wiki - Hoggitworld.com

    • Like 1
  13. 1 hour ago, ADHS said:

    😃

    In short:
    I am looking for the S_EVENT that triggers once an AI is dead.

    For everything that happens during the mission, the available events obviously can detect it (crash, kill, pilot dead, landing back at base, etc...). If you destroy() / deactivateGroup() by script there is no event but as your script uses these functions, you can also add anything you want for taking in account this destruction. (ex : get AI coalition before destruction, adjust counter for that coalition, and destruct)

    You also have the possibility to add a loop when AI spawns to periodically check if alive (MIST groupIsDead - DCS World Wiki - Hoggitworld.com or any similar function) but it's probably not what you want.

    Maybe if you want to share your script I can better understand your issue, but actually I can't get it.

    • Thanks 1
×
×
  • Create New...