Jump to content

MOOSE - Mission Object Oriented Scripting Framework


Recommended Posts

Yes. I have. I spent yesterday 5 hours trying to find the reason. It is simple. Ground units cannot be cleaned when they burn... It is the sim. Airplanes are okay, ground units is a problem. Found many topics on the forum about this. That being said, it might be possible to have a workaround like xcom mentions on one of his posts. Capture the hit event I guess, destroy the unit yourself so it disappears and generate an explosion. This could be implemented for units within the zones. It is not ideal. Disappointed.

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Link to comment
Share on other sites

Sven, I still haven't tested everything, but with the destroygroupstask, should the task % raise according to the group being dead or units in the group being dead? do I need to set the % manually or is it automatically updating?

 

unfortunately it does not work for any of the tasks I set in the last mission I uploaded here.

 

Secondly, a nice to have - make the mission/task/goal messages look better, right now they are kind of hard to read and not sorted, it would be nice to see them in a table for example.

 

I still think this framework is amazing, and eventually after I get how this works, I'll most definitely use it in most of my missions!

Link to comment
Share on other sites

Working on the cleanup stuff. Got a demo setup and I think you will be pleased somehow. I'll try to post this evening. Fine-tuned the code and cannot guarantee that cleanup will work 100%, but trying to achieve 90% of the cases.

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Link to comment
Share on other sites

  • 2 weeks later...

Okay gents,

 

Was a bit away the last weeks. But silently working in the background on some "stuff" on this framework.

 

Lets talk about the CLEANUP class in the framework. First of all, the DCS World Object.destroy(self) method is kind of a mess... Once units are burning, it is impossible to destroy them and remove them from the simulator. Feedback was that the cleanup function does not work, and to be honest, i think i am hallucinating, because i tested the CLEANUP class thoroughly and i have really seen with my own eyes a burning plane being removed from the simulator... But now i could just not resimulate this again after the complaints... Strange. So, i sticked with the fact that burning units just cannot be removed from the sim.

 

The consequence of all of this: how can i prevent ANY Unit, be it a ground, helicopter or airplane, from crashing and exploding onto an airfield???

So I read a few posts, and looked at some of the code other wrote and had some ideas myself additionally...

 

This has ended-up with a complete revision of the CLEANUP class. I have actually redeveloped it completely...

Find attached in this post a DEMO of a mission, where the CLEANUP class is demonstrated...

 

The mission is active in 2 airfields: Batumi and Kobuleti... Batume has a medium battle above the airfield, Kobuleti has more battle going on, including ground troops...

You don't need to play, just enjoy the scenery. Planes are taking off from the airfield, and should normally continue to take-off... You'll observe helicopters from dissapearing when they are hit. Note however, that i've really tried to make them dissapear when they are damaged or almost DEAD. Not just when they were hit... The consequence of this was that when they are hit, i am starting a 'scheduler' to monitor the HEIGHT of damaged units. Once the height becomes too low and they airborne units have the danger to crash, CLEANUP removes them. Healthy AI units normally don't crash and simply fly low, no problem. Ground units and helicopters and planes taxiing, and just monitored on speed. Once they are damaged they will also be removed from the sim.

Before you try this mission, you must re-install the MOOSE framework.

Download the new version of MOOSE from the first post here: http://forums.eagle.ru/showpost.php?p=2300792&postcount=1

 

Find below also a new explanation of some of the aspects of the new CLEANUP class (or should it name it now KEEPITCLEAN class???)

 

 

Class CLEANUP

 

CLEANUP will keep a CleanUp Zone or multiple CleanUp Zones clean.

This class can be used to KEEP airbases or farps clean (note the word KEEP here, it cannot destroy units that are already dead), so it tries to keep as long as possible the units alive to allow for battle and defenses, until a certaini health limit is reached.

Note that this situation is not ideal. The right logic should be that Units or Groups should be removable even when burning (see notes). But for now, this is the best that can be done, and the CLEANUP class can really keep an airbase clean for a while (even when in direct combat). That being said, using the CLEANUP class to keep an airbase clean, will have consequences on the defense strength of units positioned within the CleanUp zone(s). As they are destroyed a bit earlier then normally would be the case.

The CleanUp class works with 2 validation logic components:

HIT detection
: CleanUp detects units being HIT within the CleanUp zone, and validates units of
removal conditions
. Once a unit is HIT, it is registered in a TIMED validation logic.

TIMED validation
: Units registered in a TIMED validation, are repeatedly validated of certain
removal conditions
.

When the removal conditions are valid, the unit will be removed, and the group will be removed. The removal conditions vary depending on:

 

  • The type of the unit: Airplanes, Helicopters, Ground. Airplanes and Helicopters have a different logic than Ground units.
  • If the unit is Airborne or on the ground.
  • The HEALTH of the unit.
  • The height of airborne units, and when damaged. Units below a certain safety height above an airfield are removed if damaged. This to prevent the unit from crashing into the ground. When this occurs, the unit cannot be cleaned anymore from the airbase.
  • The speed of units not airborne. Once damages units have a speed below 1, the unit is removed.

The CLEANUP class is not perfect, and the underlying notes must be considered. There are certain aspects within DCS World that are a mess at this moment (bugs, logic not working as it should etc.). So the CLEANUP class has implemented workarounds to try to solve or deal with these aspects of DCS World:

 

  • Units or Groups need to be removed BEFORE they are burning. Burning units CANNOT be removed anymore, and if destroyed near a runway blocking AI airplanes, the AI airplane movement will be halted forever...
  • The Object.destroy(Object) does not work properly depending on the kind of object behind... When executing a Unit:destroy() (when in an event), then DCS World will CRASH ... So, for now, if one Unit is damaged and needs to be removed, the WHOLE GROUP will be removed. Group:destroy() does not result in a CRASH at this moment!
  • getLife0() is a mess for Ground unit. The getLife() values are much bigger than the getLife0() values after SEVENTBIRTH!!! This needs further investigation and a proper escalation to ED is required here!
  • These 3 points need to be escalated to ED, and I'll kindly make a report of these 3 points with examples, so that the ED development team can deal with these. But for now, this is how it works.

MOOSE_Cleanup_Test.miz


Edited by FlightControl

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Link to comment
Share on other sites

Likiki, what you are trying to do with a unit is simply not possible within DCS World. Burning units cannot be destroyed anymore, once burning. Unless somebody on this forum proves the other, this is true.

 

Suggest you find other methods of simulating fire... F.e., use SMOKE??? There is a WHITE SMOKE trigger that you could use, and you could fire it off several different places...

 

function trigger.action.smoke(Vec3 point, enum trigger.smokeColor color)

 

 

Sven

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Link to comment
Share on other sites

Hi Sven,

 

This is most unfortunate to hear :(

Thought we had a way to work around the destroyed units.

 

In anyhow, I had previously done a script with Steveof I think or RagnarDa, which checks constantly for units that are almost dead by checking the life, if life is beneath or equals 1, the unit is removed, it seemed to work nice, the main problem (which i think would affect your clean method) is that the units do not get cataloged as kills for example, so it will ruin statistics if any server runs statistics.

 

Here is the code we did back then -

function deactivate()
   for coalition, bases in pairs(deactivateUnits) do
       for base, units in pairs(bases) do
           for index, unit in pairs(units) do
               if Unit.getByName(unit) then
                   Unit.getByName(unit):destroy()
               end
           end
       end
   end
   
   for i, group in pairs(VDatabase) do
       for j, v in pairs(group.units) do
           local unit = Unit.getByName(v.name)
		if unit and unit:getLife() <= 1 then
			local unitpos = unit:getPoint()
               unit:destroy()
			trigger.action.explosion(unitpos, 3)
           end
       end
   end
end

Link to comment
Share on other sites

Hi xcom,

 

yep. Indeed. Object.destroy(self) does not generate any Event, which as a result messes up with other events in your code, and counters etc... Experienced this myself. And... i found a workaround :D. Within the DCS scripting, there is a function called world.onEvent (non-documented), which you can use to simulate events yourself... So, the underlying function f.e. documents how you can use this to try to simulate an S_EVENT_DEAD event from within your code, after a Unit.destroy call...

 

--- This function is required, and used a non-documented feature. The function world.onEvent will loop through all registered event handlers with the event structure given.
-- This is required to be done because the method Group.destroy(Group) does not generate the S_EVENT_DEAD through all the registered event handlers.
-- As such, the other classes using the S_EVENT_DEAD will get confused if this event is not catched properly...
function CLEANUP:_ExecuteDeadEvents( CleanUpUnitName )
local _T = trace.f( self, CleanUpUnitName )
   local event = {}
   event.id = world.event.S_EVENT_DEAD
   event.initiator = Unit.getByName( CleanUpUnitName )
   event.time = timer.getTime()
   [b][color=Red]world.onEvent( event )[/color][/b]
end

The CLEANUP class has much more logic behind, "keeping" the zone clean.

Have a look within MOOSE to the class. You'll enjoy it.

 

Sven

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Link to comment
Share on other sites

This is most unfortunate. I really had my hopes up for a cleanup routine. Our situation at the Virtual Aerobatics server is a bit different in that all (or at least most) or the wrecks are results of direct collision with the ground, resulting in instant death. Neither of these 2 workarounds are able to activate under these conditions. I do appreciate all efforts put into making these scripts and am sure a good number of mission creators will be able to make good use of the code.

 

Will keep hoping that ED can fix or implement their code to resolve these issues.

 

/Salute

Link to comment
Share on other sites

This is most unfortunate. I really had my hopes up for a cleanup routine. Our situation at the Virtual Aerobatics server is a bit different in that all (or at least most) or the wrecks are results of direct collision with the ground, resulting in instant death. Neither of these 2 workarounds are able to activate under these conditions. I do appreciate all efforts put into making these scripts and am sure a good number of mission creators will be able to make good use of the code.

 

Will keep hoping that ED can fix or implement their code to resolve these issues.

 

/Salute

 

nonono. Cleanup SHOULD give you a solution for that! Try it. because ONCE units are HIT, they will be cleaned. Install the demo mission, and run it. Enjoy!!!

The reason why i say this is, that IF a HIT event occurs, AND the life of the unit is <= 1, the unit is destroyed instanteneously. Should be.

We need not to give up hopes, but to keep searching man. Come on. Lets work together here.

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Link to comment
Share on other sites

Hi folks, can deletion work on items like weapons in flight, or is it limited to units like planes, ships, ground units?

 

I wanted to implement a way to nullify camping airfields and discharging at people taking off on a server. I can't see anything in MIST functions and searched for this in the forums generally.

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

Hi folks, can deletion work on items like weapons in flight, or is it limited to units like planes, ships, ground units?

 

I wanted to implement a way to nullify camping airfields and discharging at people taking off on a server. I can't see anything in MIST functions and searched for this in the forums generally.

 

haven't tried this but:

 

within an event catcher, you get a weapon member within the event structure. I guess this will be possible for S_EVENT_HIT or S_EVENT_SHOT events...

 

so you could try something like this within the event function:

 

event.weapon:destroy()

 

I'll try this myself when time comes... Because i think that is why planes are sometimes stopping because of weapons dropped on the airfield leaving debris...

 

I am just afraid that such a function call will result also in a crash or it simply will not work...

 

sven

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Link to comment
Share on other sites

Ok, will do, thanks

 

Shahdoh,

 

Note that i am not destroying any units where players are behind. IF you want to cleanup units with players behind, you need to change something within the code.

 

This is the code that tests for this in MOOSE CLEANUP.LUA:

 

function CLEANUP:_EventUnit( CleanUpUnit )
local _T = trace.f( self, CleanUpUnit )

   local CleanUpUnitName = CleanUpUnit:getName() -- return the name of the Unit
   local CleanUpGroup = Unit.getGroup( CleanUpUnit )-- Identify the Group 
   local CleanUpGroupName = CleanUpGroup:getName() -- return the name of the Group
   
[color=Red]    if CleanUpUnit:getPlayerName() == nil then
[/color]    --if not self.CleanUpList[CleanUpGroupName] then
       local AddForCleanUp = false
       if routines.IsUnitInZones( CleanUpUnit, self.ZoneNames ) ~= nil then
           local CleanUpUnitCategory = CleanUpUnit:getGroup():getCategory()
           if CleanUpUnitCategory ~=  Unit.Category.GROUND_UNIT then 
               if self:_CheckLife( CleanUpUnit, self.LifeLimit ) then
                   AddForCleanUp = true
               end
           else
               if CleanUpUnit:getLife() <= 1 then
                   AddForCleanUp = true
               end
           end
       end
       if AddForCleanUp == true then
           --self:_CleanUnit( CleanUpUnit )
           routines.scheduleFunction( self._CleanUnit, { self, CleanUpUnitName }, timer.getTime() + 0.1 )
       else
           if self.CleanUpList == nil then
               self.CleanUpList = {}
               self.CleanUpFunction = routines.scheduleFunction( self._Scheduler, { self }, timer.getTime() + self.TimeInterval, self.TimeInterval )
               trace.i( _T, "Started CleanUp Scheduler" )
           end
           if not self.CleanUpList[CleanUpUnitName] then
               trace.i( _T, "Adding " .. CleanUpUnitName .. " to CleanUpList" )
               self.CleanUpList[CleanUpUnitName] = {}
               self.CleanUpList[CleanUpUnitName].CleanUpUnit = CleanUpUnit
               self.CleanUpList[CleanUpUnitName].CleanUpUnitName = CleanUpUnitName
               self.CleanUpList[CleanUpUnitName].CleanUpStartTime = timer.getTime()
           end
       end
[color=Red]    end[/color]
end

 

Ensure to comment the RED lines out if you want also player units to be destroyed.

 

I will make member functions to control the behaviour of the cleanup class better, but for now it is hard coded. Just make sure you comment out these lines.

 

Sven

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Link to comment
Share on other sites

Hi folks, can deletion work on items like weapons in flight, or is it limited to units like planes, ships, ground units?

 

I wanted to implement a way to nullify camping airfields and discharging at people taking off on a server. I can't see anything in MIST functions and searched for this in the forums generally.

 

Hey Pikes,

 

Yes, it is possible.

A weapon is eventually an object that you can run the destroy function on.

For example, this little handler will check for any launches of radiation missiles such as - KH-58U or KH-25MPU or any other of the same type and will destroy them right away -

 

--Handler table
local eHandler = {}

function eHandler:onEvent(e)
if e.id == world.event.S_EVENT_SHOT then
	--Weapon variables	
	if e.weapon == nil then
		return
	else
		local eWeaponDesc = e.weapon:getDesc()
		if eWeaponDesc.missileCategory == 6 and eWeaponDesc.guidance == 5 then
			e.weapon:destroy()
		end
	end
end
end

world.addEventHandler(eHandler)

  • Like 1
Link to comment
Share on other sites

This could work for bombs, but guns may be a problem because you only get a "firing started" and "firing stopped" event -- AFAIK the individual bullets are not separate objects in the simulation world, but I may be wrong here.

 

In addition to trying to eliminate the bombs, you could detect people firing their gun within a certain distance of an airfield and simply destroy() their player aircraft so they get kicked back to spectator mode and have to hop into a new plane.

  • Like 1
Link to comment
Share on other sites

Thanks Xcom!

Thats a powerful snippet there, is it running globally on the server and can it be restricted to running only on objects in a zone for example pseudocode

 

for all objects in XYZ

Run XcomPacifierFunction

 

?

 

Also, is

eWeaponDesc.missileCategory == 6

eWeaponDesc.guidance == 5

 

Documented somewhere?

 

@[FSF]Ian

The guns are a really good point, might have to explore another way, like rmeoving their ammo after the first shot or damaging their guns permanently which i'm pretty sure can be done. What do you think?

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

To add, there are more aggressive ways of dealing with those people but I find the educational ways are better and doesn't make the server a target for frustration afterwards. Arma3 used something similar very well and I found after they gave up trying to shoot you they went off to kill something useful instead.

 

Additionally someone asked about some code for simulating a launch for dogfighting training scenarios without resorting to invulnerability. It migfht be useful for a training or safe zone.

  • Like 1

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

Yeah, we have used an anti-weapon code on the VA server quite successfully for a while now. It detects any type of launch/drop/trigger of a weapon, then simply removes the player and the weapon. As stated, a few rounds of gunfire can get through, but the player is removed so fast, little damage is usually done. And with them needing to start over, we see few repeat offenders.

  • Like 1
Link to comment
Share on other sites

Thanks Xcom!

Thats a powerful snippet there, is it running globally on the server and can it be restricted to running only on objects in a zone for example pseudocode

 

for all objects in XYZ

Run XcomPacifierFunction

 

?

 

Also, is

eWeaponDesc.missileCategory == 6

eWeaponDesc.guidance == 5

 

Documented somewhere?

 

@[FSF]Ian

The guns are a really good point, might have to explore another way, like rmeoving their ammo after the first shot or damaging their guns permanently which i'm pretty sure can be done. What do you think?

 

To put it to use in a zone, I would use MIST in the function, either - mist.getUnitsInZones or mist.flagFunc.units_in_zones should work, or you can just create a function that runs on an updated table and call it from inside the mission editor.

 

Documentation is in the DCS Scripting engine, for the weapons section - http://en.wiki.eagle.ru/wiki/Simulator_Scripting_Engine/DCS:_World/Part_2#Weapon

Such as -

Weapon.GuidanceType = {
  INS,
  IR,
  RADAR_ACTIVE,
  RADAR_SEMI_ACTIVE,
  RADAR_PASSIVE,
  TV,
  LASER,
  TELE
}

 

or

 

Weapon.MissileCategory = {
  AAM,
  SAM,
  BM,
  ANTI_SHIP,
  CRUISE,
  OTHER
}

 

 

About guns, unfortunately, there is no subtle way to stop them from shooting, you can detect it but there's nothing you can do about it other than remove his plane in my opinion.

 

 

 

To add, there are more aggressive ways of dealing with those people but I find the educational ways are better and doesn't make the server a target for frustration afterwards. Arma3 used something similar very well and I found after they gave up trying to shoot you they went off to kill something useful instead.

 

Additionally someone asked about some code for simulating a launch for dogfighting training scenarios without resorting to invulnerability. It migfht be useful for a training or safe zone.

 

 

I'm working on an Air to Air script that should allow for automatic administrating of a server to allow only for the relevant zones to be working, other plane slots would be deactivated to remove any trolling or annoyance.

 

BTW, there is a problem with invulnerability, it doesn't throw the relevant events, such as hit event, and therefore you cannot create a script for simulating a red flag event for example.

Link to comment
Share on other sites

I would enjoy coding for DCS if missions didn't take so long to run up and test!

 

If you haven't already, check out DCS Witchcraft (link in my sig). Its Lua Console lets you iterate much faster than coding in the mission editor. Have a syntax error in your code snippet? Correct it and try again within five seconds instead of waiting a minute for the mission to load again.

 

This post illustrates how I use it to speed up the creation of Lua scripts for DCS.


Edited by [FSF]Ian
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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