-
Posts
1742 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by toutenglisse
-
-
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).
-
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
-
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).
- 1
-
On 3/30/2024 at 12:03 AM, Arktos said:
...Any thoughts on this?...
Hi, you should use instead this function : MIST groupIsDead - DCS World Wiki - Hoggitworld.com
Because Group.getByName() can still return Group Object for a dead group.
-
23 hours ago, Exorcet said:
...Essentially the code for STE, not using a zone, works fine...
I think your sdposV2 is wrong. It is a table of 2 values, when it should be a table of 2 indexed values (x and y) :
sdposV2 = {x=sdposV3.x,y=sdposV3.z}
- 1
-
@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).
-
@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.
- 1
-
You could get route from env.mission, remove points the same way with flag, and setTask Mission with updated route. I usually use Mist because of minimal workload with handy functions.
-
@dimitriov if you want to see a working example using it (in the example - replacement of an aircraft by same aircraft but from enemy coalition to act as defection, that continues the route of previous aircraft from the point where it is spawned - I use mist.getCurrentGroupData and mist.getGroupData instead of mist.getGroupRoute, but works the same) you can download this .miz :
-
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
-
@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.
-
On 11/10/2022 at 8:50 PM, Rudel_chw said:
...I tested this a lot of times and now seems to work well
Hey, I just took a look and still same flags values occures. No clue what's wrong though.
-
@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).
- 1
-
7 hours ago, Chump said:
for i = 1, 3 do trigger.action.setUserFlag(tostring(i), math.random(10)) end
In your example, nothing prevents results to be the same.
-
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
- 1
-
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 :
Spoilerlocal 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)
- 1
-
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
- 1
-
@ADHS I'd say you maybe try to access to respawned Unit at the same time that it is respawned. If so, put a 1 second delay after respawn before checking with "if Unit.getBy...."
- 1
-
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
- 1
-
10 minutes ago, Coupon4Coffin said:
Does anyone know whether this is a bug or perhaps this is not the correct way to query scenery objects? I encountered exactly the same issue, map is Syria if that matters.
Here is another thread on same topic :
- 1
-
hi @Flappie I don't think so as this other thread is only about ground vehicles.
-
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.
- 1
-
On 10/15/2022 at 9:49 PM, Snacko said:
... But when I spawn in the game's cockpit throttle is at about 80%...
Hi, you have to tick, in DCS Options -> Miscellanous -> "sync commands at mission start".
This way, if your throttle is physically at 30%, it will also be at 30% ingame at mission start.
- 1
-
I don't know. I fail to understand.
Getting Groups to return to their tasks
in Scripting Tips, Tricks & Issues
Posted
I can confirm that a scripted refueling task using pushtask does work like you describe , and after refueling the AI resumes previous task (in my case a follow task).