LFCChameleon_Silk Posted May 12, 2014 Posted May 12, 2014 (edited) PROBLEM SOLVED! Anyone wishing to incorporate destroying map objects can use this as a reference, added demo mission as well to show it at work... now if only everyone was so kind to do the same about other MIST functions -- we wouldn't have 10 people knowing what they are doing and the rest scratching their heads -- start posting some examples that are simple and easy to understand! -- make sure you have a mission start trigger in the editor that loads MIST 3.3 on mission start -- and make sure you place TEST1 trigger zone on top of the object you wish to demonstrate the function on ------------------------------------------------ function check_obj_destroyed(arg, time) ------------------------------------------------ check_this_obj_flag = trigger.misc.getUserFlag(9999) -- grab the userflag that is being used by mist.flagFunc.mapobjs_dead_zones if check_this_obj_flag == 0 then -- condition that check_this_obj_flag is equal to 0 (alive) trigger.action.outText(check_this_obj_flag .. ' Object is ALIVE' , 2) -- debug output to say when the bridge/object has been killed -- script to execute when object is alive -- if you wish something to happen then end if check_this_obj_flag ~= 0 then -- condition that check_this_obj_flag is not equal to 0 (dead) trigger.action.outText(check_this_obj_flag.. ' Object is DEAD ' , 2) -- debug output to say when the bridge/object has been killed -- script to execute upon the targets death, -- once dead its dead and MIST does not make -- mist.flagFunc.mapobjs_dead_zones flag value -- true again. end return time + 2 -- reschedule for 2 seconds to show if object has been killed end ------------------------------------------------ function obj_destroy_start(arg, time) -- function to cause an explosion that will destroy the object ------------------------------------------------ local zonePos= mist.utils.zoneToVec3('TEST1') -- insert your own zone name here trigger.action.explosion(zonePos, 95000) -- test explosion so that the player doesn't have to kill object himself, if your using a bridge make sure to place on a the start of bridge where the land is! return time + 10 -- reschedule another explosion (not needed but was usefull in testing, takes 3 volleys to kill a large bridge so wait it out till flag gets set!) end ------------------------------------------------ function start_obj_checks(arg, time) -- begin the check on the specified zone (make sure to change the zone name here to the one used previously, and also to place in the editor) ------------------------------------------------ mist.flagFunc.mapobjs_dead_zones{ zones = {'TEST1'}, flag = 9999 } -- starts checking return -- returns back to normal flow, doesn't need to be scheduled for rechecking, MIST handles this end --- timer.scheduleFunction(start_obj_checks, {}, timer.getTime() + 1) -- schedule the functions to run to demonstrate the object destruction logic this section is run only once at start of mission file -- timer.scheduleFunction(check_obj_destroyed, {}, timer.getTime() + 2) -- print the state of the object every 2 seconds timer.scheduleFunction(obj_destroy_start, {}, timer.getTime() + 10) -- cause explosion every 10 seconds detected_obj_death.miz Edited May 12, 2014 by =LFC=Chameleon_Silk added working example and cleaned up the thread
chromium Posted May 12, 2014 Posted May 12, 2014 maybe it's this: mist.flagFunc.mapobjs_dead_zones{ zones = {'TEST2'}, flag = 1 } ---> mist.flagFunc.mapobjs_dead_zones({ zones = {'TEST2'}, flag = 1 }) Also, for every scheduling function sobstitute "nil" with "{}" Give a try :) PS: sorry for the fast answer, I'm writing on a hurry... I'll check again later ;) Author of DSMC, mod to enable scenario persistency and save updated miz file Stable version & site: https://dsmcfordcs.wordpress.com/ Openbeta: https://github.com/Chromium18/DSMC The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.
chromium Posted May 13, 2014 Posted May 13, 2014 Ah, i didn't understand that you wanted to check every n seconds. I thought that you were using the script on a ON HIT event :) Author of DSMC, mod to enable scenario persistency and save updated miz file Stable version & site: https://dsmcfordcs.wordpress.com/ Openbeta: https://github.com/Chromium18/DSMC The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.
Recommended Posts