michelip Posted October 2, 2018 Posted October 2, 2018 In M.E. creating either stationary or AI trains you create a steam loco. and attached rolling stock. You can designate each component as a separate unit (e.g. "Loco" ,"Wagons 1, 2, 3" etc.) Now you may want to trigger an explosion in one of the wagons, so you create a CONDITION ( e.g. "Unit Damaged - Wagon 2" and an ACTION (e.g. "Explode Unit - Wagon 2"). You test the mission by shooting the hell out of Wagon 2 and nothing happens. Has anyone else noticed this and if so is there a remedy?? Regards, Mich.
Habu_69 Posted October 3, 2018 Posted October 3, 2018 I encountered a similar problem developing a WWII Normandy mission for P-51. Aircraft could attack AAA units, pummel it with 20mm and the thing would not die. You have an unprotected AAA gunner clobbered with 20mm and he just keeps firing. So I wrote a small MOOSE script that exploded the AAA unit when it is HIT. Here is the script: MG_Group = GROUP:FindByName( "mg1" ) -- mg1 is target group, 3 units, of interest in ME MG_Live = 3 -- Initilize MG dead counter, the number of units in the ME group mg1 MG_Group:HandleEvent( EVENTS.Hit ) -- Monitor EVENTS.hit on MGSet function MG_Group:OnEventHit( EventData ) local Target = EventData.TgtUnit -- Identify unit hit MG_Live = MG_Live -1 -- increment counter on hit Target:destroy() -- Destroys target unit, when hit Target_Loc = Target:GetVec2() -- Returns Vec2 location of event target Target_Coord = COORDINATE:NewFromVec2( Target_Loc ) -- Convert Vec2 to coordinate Target_Coord:Explosion(75) -- Create explosion, intensity 75 at target coordinate. MESSAGE:New( "MG unit destroyed. Continue attack.", 15 ):ToAllIf( MG_Live >= 1 ) if MG_Live < 1 then MG_Group:UnHandleEvent( EVENTS.Hit ) MESSAGE:New( "All MG units destroyed. Great job.", 15 ):ToAll() -- Message when all spawned groups destroyed end end Perhaps you can adapt it to your needs. Load the MOOSE.lua script at mission start then this script at TIME MORE 5.
Grimes Posted October 4, 2018 Posted October 4, 2018 Trains are weird to the triggers/scripting engine in that only the lead vehicle "exists" and can be checked for assorted triggers/scripting you may want to do on it. Simply put if you add units to the group those units do not exist. At present your idea would only work with trains added as static objects because its the only way for each object to be accessible. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Hardcard Posted October 4, 2018 Posted October 4, 2018 @Habu_69 I see that your script uses a "Hit" event handler for "MG_Group". Does ":UnHandleEvent( EVENTS.Hit )" successfully unsubscribe "MG_Group" from the "Hit" event? I remember getting this MOOSE error whenever I tried to unsubscribe groups from events like that. Do you get it too? [sIGPIC][/sIGPIC]
SUNTSAG Posted October 4, 2018 Posted October 4, 2018 Why not use whats available in the mission editor try this, it's a recent addition: https://forums.eagle.ru/showpost.php?p=3634765&postcount=63 Callsign: NAKED My YouTube Channel [sIGPIC][/sIGPIC]
Habu_69 Posted October 4, 2018 Posted October 4, 2018 @Habu_69 I see that your script uses a "Hit" event handler for "MG_Group". Does ":UnHandleEvent( EVENTS.Hit )" successfully unsubscribe "MG_Group" from the "Hit" event? I remember getting this MOOSE error whenever I tried to unsubscribe groups from events like that. Do you get it too? I do not recall getting such errors, but can't really say, as it has been months since I used this. I do know the script functioned as intended. May fly the mission again soon, but was flying P-51 as filler until F-18 published.
Recommended Posts