BFQ Posted November 26, 2019 Posted November 26, 2019 I'm trying to simulate a "Depth charge" dropped from a helicopter (via the F10 menu) with an explosion on the surface of the sea. Three questions: 1. How do I make the explosion at the helicopters position, but at sea level? I know it is not this way: do local pelican42_vector = Unit.getByName('Pelican 4-2'):getPosition().p trigger.action.explosion(pelican42_vector, 10 ) end That will make the "Depth charge" explode inside the helicopter :-) 2. Is it possible to delay the explosion with approx. 10 sec? 3. How do I check if the "Depth charge" was dropped within a trigger zone?
Grimes Posted November 26, 2019 Posted November 26, 2019 1. Insert this line after you define the value but before you explode it. pelican42_vector.y = 0 2. To delay you have to schedule a function that will create an explosion. Either directly like below or another function that you create that calls the trigger.action.explosion. timer.scheduleFunction(trigger.action.explosion, {pelican42_vector, 10}, timer.getTime() + 10) 3. Math! With the formula ((A.x - B.x)^2 + (A.z - B.z)^2)^0.5 and checking if that value is less than the radius. In other words. local dZone= trigger.misc.getZone('dCharge') if ((pelican42_vector.x - dZone.x)^2 + (pelican42_vector .z - dZone.z)^2)^0.5 < dZone.radius then -- it is in the zone. end 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 November 26, 2019 Posted November 26, 2019 @Grimes To make sure the explosion happens at sea level, shouldn't we set the y value from the position subtable, rather than the orientation subtable? pelican42_vector.[b]p[/b].y = 0 [sIGPIC][/sIGPIC]
Grimes Posted November 26, 2019 Posted November 26, 2019 Its already position. local pelican42_vector = Unit.getByName('Pelican 4-2'):getPosition()[b].p[/b] 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
BFQ Posted November 26, 2019 Author Posted November 26, 2019 1. Insert this line after you define the value but before you explode it. pelican42_vector.y = 0 2. To delay you have to schedule a function that will create an explosion. Either directly like below or another function that you create that calls the trigger.action.explosion. timer.scheduleFunction(trigger.action.explosion, {pelican42_vector, 10}, timer.getTime() + 10) 3. Math! With the formula ((A.x - B.x)^2 + (A.z - B.z)^2)^0.5 and checking if that value is less than the radius. In other words. local dZone= trigger.misc.getZone('dCharge') if ((pelican42_vector.x - dZone.x)^2 + (pelican42_vector .z - dZone.z)^2)^0.5 < dZone.radius then -- it is in the zone. end Thank you very much! You are a hero! Works perfect :-)
Mith86Arg Posted November 27, 2019 Posted November 27, 2019 hero? nah, the dude its just an scripting demon... lol another level of awesomeness
Hardcard Posted November 27, 2019 Posted November 27, 2019 @Grimes Yup, somehow I managed to forget that the variable already contained the position subtable, :doh: Thanks bud! [sIGPIC][/sIGPIC]
johnv2pt0 Posted February 12, 2020 Posted February 12, 2020 Hey guys, great idea OP! I'm trying to make it work with a scheduled delay to no avail. If I use trigger.action.explosion everything's fine, but as soon as I try to schedule it with timer.scheduleFunction or mist.scheduleFunction, nothing happens (no errors). Anyone know what's happening here? function Ped1() if trigger.misc.getUserFlag(311) == 1 then local Pedro1 = Unit.getByName('ROT PEDRO 1') local Pedro1ID = Unit.getByName('ROT PEDRO 1'):getID() Ped1Pos = Pedro1:getPosition().p Ped1Pos.y = 0 trigger.action.setUserFlag( 301, false ) timer.scheduleFunction( trigger.action.explosion, { Ped1Pos , 100 } , timer.getTime() + 10 ) --trigger.action.explosion( Ped1Pos , 100 ) --mist.scheduleFuntion( trigger.action.explosion, {Ped1Pos,100}, timer.getTime() + 1, 10, 1 ) end end Also, I can't get outTextForGroup to work...are the group level functions still broken?
Hardcard Posted February 12, 2020 Posted February 12, 2020 local function Explosion(Ped1Pos) local Expl_vec3 = { x = Ped1Pos.x , y = 0 , z = Ped1Pos.z } trigger.action.explosion(Expl_vec3 , 100) end function Ped1() if trigger.misc.getUserFlag("311") == 1 and Unit.getByName('ROT PEDRO 1') then local Pedro1 = Unit.getByName('ROT PEDRO 1') local Ped1Pos = Pedro1:getPosition().p timer.scheduleFunction( Explosion, Ped1Pos , timer.getTime() + 10 ) trigger.action.setUserFlag( "301", false ) end end [sIGPIC][/sIGPIC]
johnv2pt0 Posted February 12, 2020 Posted February 12, 2020 (edited) Thanks Hardcard, for my education, is there a reason you can't use the raw function and arguments in the scheduleFunction? EDIT: Also nevermind on the outTextForGroup question...I was using Unit.getByName():getID() instead of Group.getByName():getID() Edited February 12, 2020 by johnv2pt0
BaD CrC Posted February 13, 2020 Posted February 13, 2020 Veryyyyyy interresting guys! https://www.blacksharkden.com http://discord.gg/blacksharkden
Hardcard Posted February 14, 2020 Posted February 14, 2020 is there a reason you can't use the raw function and arguments in the scheduleFunction? That's a question for Grimes ;) I only know what works (or doesn't) based on trial and error, not intimate knowledge of the workings of the DCS scripting engine. Also, the functions I schedule most of the time are too long to "compress" in a single scheduler line, so writing a separate function above the scheduler is always the best option for me (I'm a big fan of code readabililty). [sIGPIC][/sIGPIC]
Recommended Posts