Jump to content

Recommended Posts

Posted

Unfortunately, map objects and static objects do not share an ID namespace, so replacing a map object with a static object (by specifying the same ID) doesn't work either.

 

Looks like explosions are the way to go until (if ever) destroy() gets fixed for map objects.

It's really annoying that the scripting API is not considered an official feature. ED only needs to take one look at ArmA to see how much value a decent scripting API would add to the game.

Posted
I would be interested.

 

Try this:

 

-- PSSS_beta vers.0089
-- require MIST 3.4 or earlier
-- require to disable the sanitization module

PSSS = {}
local tss = ";"
-- this function store in a file the destroyed map objects table
PSSS.deadMapObjCollect = function() 
 local deadOBJ = "" 
 -- add to the previous data stored in "deadOBJ" string the new data
 for deadId,deadData in pairs(mist.DBs.deadObjects) do
  if deadData.objectType == "building" then -- filter map Objects
   local Id = deadId
   local Pos = deadData.objectPos
   deadOBJ = deadOBJ .. Id .. tss .. Pos.x .. tss  .. Pos.y .. tss  .. Pos.z .. "\n"
  end
 end 
 -- now overwrite the old file (erase previous data)
 local o = io.open(lfs.writedir() .. "\Logs\deadobjects.csv", "w") 
 o:write(deadOBJ)
 o:close()
end

-- this function will destroy objects indicated in the 
PSSS.deadMapObjDestroy = function()
 
 -- retrieve dead objects data
 local destroyMethod = 1 -- 0 means by destroy, 1 by explosion. 0 does not work due to a scripting engine bug.
 local u = io.open(lfs.writedir() .. "\Logs\deadobjects.csv", "r")  
 
 for line in io.lines(u) do
  local rdeadID, rdeadPosX, rdeadPosY, rdeadPosZ = line:match("(%d-)"..tss.."(.-)"..tss.."(.-)"..tss.."(.-)$")
   if (rdeadID) then 
   DeadMapObjects[#DeadMapObjects + 1] = { deadID = rdeadID, deadPosX = rdeadPosX, deadPosY = rdeadPosY, deadPosZ = rdeadPosZ}
  end
 end
 u:close()  
 
 
 -- exec the deletion
 for id, DeadData in pairs(DeadMapObjects) do
  local deadX = tonumber(DeadData.deadPosX)
  local deadY = tonumber(DeadData.deadPosY)
  local deadZ = tonumber(DeadData.deadPosZ)
 
  local ExpPos = {
      x = deadX,
      y = deadY,
      z = deadZ
      }
      
  local volume =  {
      id = world.VolumeType.SPHERE,
      params = {
         point = ExpPos,
         radius = 0.2
        }
      }   
 
  local function handler(object, data)
   Object.destroy(object)
  end  
 
  if destroyMethod == 0 then -- does not work due to scripting bug.
   if ExpPos then
    world.searchObjects(Object.Category.SCENERY, volume, handler, nil)
   end
  elseif destroyMethod == 1 then
   if id then
    trigger.action.explosion(ExpPos, 3000)
   end
  end
 end
end

-- run code
mist.scheduleFunction(PSSS.deadMapObjDestroy,{},timer.getTime() + 2) -- re-destroy the previously destroyed building once code is loaded
mist.scheduleFunction(PSSS.deadMapObjCollect,{},timer.getTime() + 5*60 + 110, 60, (4*60*60)) -- since you get into the 6th minute of mission, every minute the function will update the destroyed building log file, till missiong get at 4 hour run (you may change parameters if you want)

 

It's untested, and you should disable the sanitization module in the hosting computer or you'll get an error and the script won't work. Also, this require MIST 3.4 or earlier. (It may work with previous releases but I didn't test it).

 

Please let me know for any problem, I'll correct it asap.

ChromiumDis.png

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.

  • 2 weeks later...
Posted

chromium,

 

Thanks for the script. I finally had a moment to give it a run and here is what happened.

 

mist and your script both loaded without any errors. Flew around for 8 minutes and the bombed a building and flew around 4 more minutes then exited the game.

 

First thing I noticed was that there was no deadobjects.csv file in the Saved Games\DCS\Logs directory but the was a file called

 

Logsdeadobjects.csv in the Saved Games\DCS directory.

 

When running the second mission the building I had bombed in the first mission was not destroyed. probably due to the above issue

 

Thanks

Eric

Posted (edited)

I'll check it ASAP

 

EDIT

 

yes I used slash instead of backslash. Please try the attached one or, if you prefer, wait till monday when I can get to a computer suitable for testing (home) :)

Nuovo documento di testo.lua

Edited by chromium

ChromiumDis.png

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.

Posted

chromium,

 

Thanks for the updated script.

 

I put it into my test mission and destroyed a building at the 10 minute mark and the waited several more minutes and exited.

 

the csv file was created in the correct directory. I then started the second mission but the building was not destroyed.

 

here is there error in the log file

 

00040.362 INFO SCRIPTING: mist.scheduleFunction, error in scheduled function: [string "-- PSSS_beta vers.0089..."]:34: attempt to get length of global 'DeadMapObjects' (a nil value)

 

and I'm attaching the deadobjects.csv from the initial mission just in case you need it.

 

Let me know if there is anything you need to me test while we wait for you to get to your testing machine.

 

Eric

deadobjects.zip

Posted

Yes I forgot to declare the table. Re-try... I really can't test or review in details till monday and I'm really sorry, but those are very busy days.

 

Here it is the "fix".

ObjDestroy2014.11.06.lua

ChromiumDis.png

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.

Posted

Very much looking forward to testing this when I have the chance. The idea itself is beyond cool. Also curious to see how you are doing it.

Posted

You can find it in the previous posts: as it's currently impossibile due to a bug to simply make buildings disappear (and then, maybe, repleace them with some destroyed building 3D model), the script store the data extracted by a MIST db to a file. The next time you start a mission that load the script, it will read this file and instantly destroy every building previously destroyed.

 

That is obviously not a great solution, due to the multiple explosions, a lot of smoke (that shouldn't be there), etc etc... but it's the only way up to date. When the bug will be fixed, it will be changed the way of "removing" the destroyed buildings

ChromiumDis.png

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.

Posted

only scenery map object in my purpose. But they don't stay destroyed, they will be re-destroyed at every mission start. Also please have a look at the previous posts cause you may find some important information, as the need of MIST and to disable the sanitization module.

ChromiumDis.png

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.

Posted

bridges, houses, etc.

 

sanitization module is a chunk in the missionscripting.lua file located in your C:\ DCS folder\Scripts, witch prevents harmful script to being executed and damage your PC or your files. i.e., if I would execute some sort of "format c:" function by script, the sanitization module will prevent it.

 

but, also, it prevent file writing in the only way I know to do that. So, as the mechanism used by my script is to write a file and the read it at next mission start, you need to disable the sanitization module to get it work.

 

Use search function to see how to disable it and some additional information :)

ChromiumDis.png

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.

  • 2 months later...
Posted

I'm going to resurrect a bit this thread cause I didn't think about a very interesting workaround to get what I want whitout having to wait the object: Destroy() to be fixed.

 

Do you think is it possible to terminate fire&smoke by script once a building has been destroyed? If so, I may go on with the "explosion" pattern and simply terminate fire and smoke few seconds after.

ChromiumDis.png

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.

  • 4 weeks later...
Posted

Does maybe someone know if in DCS 1.2.15 the Object:destroy bug is fixed?

(I can't test it my own since monday.... :( )

ChromiumDis.png

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.

  • 4 months later...
Posted

in the end I decided to post the mod even if it's almost alpha:

http://forums.eagle.ru/showthread.php?p=2425275#post2425275

 

The mod won't disable the sanitization module, and it provide itself a copy of one of the most recent "mist" version, which is loaded if no mist version has been loaded in the first second of simulation.

ChromiumDis.png

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...