Jump to content

DCS: World Scripting Engine


Recommended Posts

  • Replies 148
  • Created
  • Last Reply

Top Posters In This Topic

I have updated from 1.2.1 to 1.2.2 with autoupdate.

Крайняя версия MSF 1.0.1 (для 1.2.6.): http://forums.eagle.ru/attachment.php?attachmentid=89817&d=1382379803

 

Новая версия MSF 1.0.2 beta: http://forums.eagle.ru/attachment.php?attachmentid=93422&d=1390584292

 

Миссия для тестирования возможностей MSF 1.0.2: http://forums.eagle.ru/attachment.php?attachmentid=91514&d=1386954362

----

Руководство по MSF (не полная версия для MSF 1.0.2): http://forums.eagle.ru/attachment.php?attachmentid=92959&d=1389558825

Link to comment
Share on other sites

I meant with the script you are using. Client aircraft will always return as 'nil' unless the client is spawned into the aircraft. I use the following script when checking anything with client aircraft

 

	
	if Unit.getByName(acName) then
		punit = Unit.getByName(acName)
--Now do the code relevant to the client aircraft

[indent][indent]end 
[/indent]

[/indent]

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Works for me

 

i have found my mistake.

i did mistake in unit's names. I thought, field 'name' is name of unit. In practice it's name of group.

 

I passed into function value form field "name", instead value form field "pilot".


Edited by BAntDit

Крайняя версия MSF 1.0.1 (для 1.2.6.): http://forums.eagle.ru/attachment.php?attachmentid=89817&d=1382379803

 

Новая версия MSF 1.0.2 beta: http://forums.eagle.ru/attachment.php?attachmentid=93422&d=1390584292

 

Миссия для тестирования возможностей MSF 1.0.2: http://forums.eagle.ru/attachment.php?attachmentid=91514&d=1386954362

----

Руководство по MSF (не полная версия для MSF 1.0.2): http://forums.eagle.ru/attachment.php?attachmentid=92959&d=1389558825

Link to comment
Share on other sites

a small question about function env.info:

 

function env.info(string message, bool showMessageBox = false)

 

add message to simulator log with caption "INFO", "WARNING" or "ERROR". Message box is optional.

 

Where does it write messages? I've checked all log's files in folder \Saved Games\DCS World\Logs and i didn't find my messages.

Could somebody tell me path to file, where i should seek messages written by function env.info.

Крайняя версия MSF 1.0.1 (для 1.2.6.): http://forums.eagle.ru/attachment.php?attachmentid=89817&d=1382379803

 

Новая версия MSF 1.0.2 beta: http://forums.eagle.ru/attachment.php?attachmentid=93422&d=1390584292

 

Миссия для тестирования возможностей MSF 1.0.2: http://forums.eagle.ru/attachment.php?attachmentid=91514&d=1386954362

----

Руководство по MSF (не полная версия для MSF 1.0.2): http://forums.eagle.ru/attachment.php?attachmentid=92959&d=1389558825

Link to comment
Share on other sites

Aside from changing the AI planes flare using options, you can have it deploy signal flares. Using :

 

trigger.action.signalFlare(Vec3 point, enum trigger.flareColor color, Azimuth azimuth)

 

do
   client1 = Unit.getByName('client1')
 if client1 then
       client1pos = client1:getPosition().p
       trigger.action.signalFlare(client1pos, trigger.color.Green, math.random()*2*math.pi)
end
end

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Maybe a stupid question but...

 

I'm a Kamov pilot, and like some of us I really hope to see some FARP-whitout-3D-model feature, to simulate landing zones, movable refuel and rearm positions, etc.

 

Is it possibile to attach the "FARP" attributes to something like a vehicle (even a static object) by script? or it's something beyond scripting engine capability?

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.

Link to comment
Share on other sites

Is it possibile to attach the "FARP" attributes to something like a vehicle (even a static object) by script? or it's something beyond scripting engine capability?

 

Not s stupid question at all. Not possible either via script or in ME at the moment I'm afraid.


Edited by Druid_

i7-7700K : 16Gb DDR4 2800 Mhz : Asus Mobo : 2TB HDD : Intel 520 SSD 240gb : RTX 2080ti: Win10 64pro : Dx10 : TrackiR4 : TM Warthog : ASUS ROG SWIFT PG348Q

Link to comment
Share on other sites

It felt stupit for me cause we already asked many many many times in some whislists :p.

 

I tried also to understand what exactly is a FARP in the sim but it seems that as I change the .edm file (es: sobstitute FARP.edm with an UAZ) I loose the refuel&rearm capability of the nearest support units... but the radio was active and also you see the "H" icon in ABRIS.

 

But... this is strongly OT, so I stop here cause the answer is already ok :).

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.

Link to comment
Share on other sites

  • 4 weeks later...

Hi,

 

I have found new bug in The Simulator Scripting Engine.

 

Event 'S_EVENT_BIRTH' is raised only for server side player and isn't raised if airplane of client's player has been born.

 

you can use following script for reproducing this error:

 

1. Add to mission following script:

 

customEventHandler = {};

function customEventHandler:onEvent(event)
   if (world.event.S_EVENT_BIRTH == event.id) then
       trigger.action.outText('Unit has been born', 10);
   end
end;

world.addEventHandler(customEventHandler);

 

2. Run the mission.

3. Resume game (switch off pause). Very important to do this before get in plane.

4. Join to mission form server - in this case you will see message 'Unit has been born'

every time you get in airplane.

5. then join to the mission as client - in this case you will see nothing, cause of

event 'S_EVENT_BIRTH' isn't raised for client's players.

 

I've attached mission for testing.

 

-------------------------

P.S.: could you stick this thread on forum - it's diffuclt to find this thread every time.

test_birth_event.miz

Крайняя версия MSF 1.0.1 (для 1.2.6.): http://forums.eagle.ru/attachment.php?attachmentid=89817&d=1382379803

 

Новая версия MSF 1.0.2 beta: http://forums.eagle.ru/attachment.php?attachmentid=93422&d=1390584292

 

Миссия для тестирования возможностей MSF 1.0.2: http://forums.eagle.ru/attachment.php?attachmentid=91514&d=1386954362

----

Руководство по MSF (не полная версия для MSF 1.0.2): http://forums.eagle.ru/attachment.php?attachmentid=92959&d=1389558825

Link to comment
Share on other sites

-------------------------

P.S.: could you stick this thread on forum - it's diffuclt to find this thread every time.

 

Thanks, it will be investigated.

 

Its probably safe to consider any bug with the scripting engine to be related to mission editing. So if you find a scripting engine bug, just make a thread here: http://forums.eagle.ru/forumdisplay.php?f=190

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

  • 2 weeks later...
The beauty of this is that the programmers can write the scripts, post them up with an explanation of their use. All the non-programmers need to do is copy the script and drop it into the Mission editor in the triggered action -> run script.

 

An example would be a line of sight script linked to a trigger zone. In the ME you would have

CONTINUOUS -> blank -> RUN SCRIPT (copy and paste script into box)

CONTINUOUS -> FLAG 1 SET -> Message to coalition ("scramble, zee enemy are approaching") ; FLAG 1 FALSE

 

The script would simply set flag 1 if any enemy aircraft that enters the trigger zone with LOS for say 5 seconds.

 

its a simple script that uses the functions

Unit.getByName(string name)

Object.getPosition(self)

land.isVisible(Vec3 from, Vec3 to)

 

Obviously gets a little more complicated when you start populating with lots of units and want to check for any enemy aircraft but again possible in lua.

 

 

Hi Druid,

 

I am trying to implement the function you describe above, but without success, land.isVisible always returns true, even if there is no LOS. If you can spare a couple of minutes, can you look at the attached (very simple) mission. Many thanks

LineOfSight.miz

[sIGPIC][/sIGPIC]

 

Intel Core I7 4820K @4.3 GHz, Asus P9X79 motherboard, 16 GB RAM @ 933 MHz, NVidia GTX 1070 with 8 GB VRAM, Windows 10 Pro

Link to comment
Share on other sites

I made a slight change. Mainly. Unitx = Unit.getPosition(Unit.getByName('vehiclename')) rather than Unitx = Unit.getByName('vehiclename')

 

Weirdly the LOS messages would alternate when the vehicles were LOS. This was actually my first time using an LOS function, so I will have to investigate this further.

 

Shameless Plug: Mist has 2 LOS functions built in. http://forums.eagle.ru/showthread.php?t=98616 One is the "flag functions" which will set a flag. The other is more complex and fun. :)

LineOfSight_edit.miz

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

I made a slight change. Mainly. Unitx = Unit.getPosition(Unit.getByName('vehiclename')) rather than Unitx = Unit.getByName('vehiclename')

 

Weirdly the LOS messages would alternate when the vehicles were LOS. This was actually my first time using an LOS function, so I will have to investigate this further.

 

Shameless Plug: Mist has 2 LOS functions built in. http://forums.eagle.ru/showthread.php?t=98616 One is the "flag functions" which will set a flag. The other is more complex and fun. :)

 

Hi Grimes,

 

Thanks very much for your response. I (think I) understand what you did: unit.p gives the position/orientation, not just the position as I thought. unit.p.p gives the position, right? Weirdly, now the LOS message on my install is always "No LOS", and on yours it alternates. Would be interesting to find out what causes that...

 

Shameless request: Could you rewrite my mission with the MIST LOS function you mentioned. This would help me understand how to use MIST...

[sIGPIC][/sIGPIC]

 

Intel Core I7 4820K @4.3 GHz, Asus P9X79 motherboard, 16 GB RAM @ 933 MHz, NVidia GTX 1070 with 8 GB VRAM, Windows 10 Pro

Link to comment
Share on other sites

Add Mist 1.1 to the mission on a mission start trigger using the "Script File" or copy/paste whole script into : run script

 

Change the first trigger to "once" and make the script be;

 

mist.flagFunc.units_LOS{unitset1= {'JTAC Unit #1'}, altoffset1 = 3, unitset2 = {'Target Unit #1'}, altoffset2 = 3, flag = 1, interval = 1}

 

Note it doesn't set the flag off if LOS does not exist. That might be a good idea for a future version of the mod as an optional variable possibly... I'll ask Speed about it because the flagfuncs functions are all made by him. Also the flagfuncs are "easy" to use in comparison with the other functions. So with some extra scripting to you easily set the flag false if you used mist.getUnitsLOS instead.

 

Upon further thinking, it might be a plausible realization that the alternating true/false of the LOS test was caused by checking a point that might have been below the terrain at a given moment due to rounding errors or simply how the sim is set up. By that I mean "Unit.getPosition()" returns the vec3 position of the unit. Most 3d ground objects in the sim have their "origin' at a coordinate of 0, 0, 0 for the object, so it appears to be placed on the ground. Aircraft typically have an origin in the center of the object. The origin is likely the point Unit.getPosition() will return. So for ground units it will always return ground level, which may or may not be "below" the actual geometry due to rounding error or just a strange position. This is why the offset variable exists within Mist. It will add x meters in the y axis (up in game) to the LOS check, thus rounding errors are eliminated and it can be more realistic as it checks radar/sensor/top of vehicle level rather than ground level.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

I made a slight change. Mainly. Unitx = Unit.getPosition(Unit.getByName('vehiclename')) rather than Unitx = Unit.getByName('vehiclename')

 

Weirdly the LOS messages would alternate when the vehicles were LOS. This was actually my first time using an LOS function, so I will have to investigate this further.

 

Shameless Plug: Mist has 2 LOS functions built in. http://forums.eagle.ru/showthread.php?t=98616 One is the "flag functions" which will set a flag. The other is more complex and fun. :)

 

Grimes, thank You very muh for script about LOS. I've almost reached my purpose, adapting your mission for my Ka-50's job.

LineOfSight_Ka-50.miz

LineOfSight_Ka-50_moving.miz

But, I've noticed that flag F1 is dinamyc, occuring only when LOS function is satisfied. Please, I'd like maintain flag F1= TRUE once happened, so to connect it with other triggers.

antonio.

Link to comment
Share on other sites

Hello,

could i add some wishes about scripting engine here?

 

Add function for groups and units to switch off\on AI:

 

For example:

Group.toggleAI(self, boolean OnOff)

Unit.toggleAI(self, boolean OnOff)

 

To use in scripts somethings like this:

_my_group:toggleAI(true); -- toggle on AI
_my_group:toggeAI(false); -- toggle off AI

 

Now, we can implement this thing, using flags and GROUP AI OFF, GROUP AI ON in mission editor, but this is very unconvenient and this way has another problems of implementation, which i can't explain, cause of my poor english :)

Крайняя версия MSF 1.0.1 (для 1.2.6.): http://forums.eagle.ru/attachment.php?attachmentid=89817&d=1382379803

 

Новая версия MSF 1.0.2 beta: http://forums.eagle.ru/attachment.php?attachmentid=93422&d=1390584292

 

Миссия для тестирования возможностей MSF 1.0.2: http://forums.eagle.ru/attachment.php?attachmentid=91514&d=1386954362

----

Руководство по MSF (не полная версия для MSF 1.0.2): http://forums.eagle.ru/attachment.php?attachmentid=92959&d=1389558825

Link to comment
Share on other sites

I think I've asked this before, but I don't remember the answer. Is it now possible to spawn new units, that has not been placed in the mission editor? I guess the answer is still no? Is it possible to move/teleporting units? What about moving waypoints? What would happen if I activate a unit, deactivate it and activate it again? Is it possible?

 

Edit: I see that it's possible to make waypoints with the "mission"-task. Is this only for air units?


Edited by RagnarDa

DCS AJS37 HACKERMAN

 

There will always be bugs. If everything is a priority nothing is.

Link to comment
Share on other sites

I see that it's possible to make waypoints with the "mission"-task. Is this only for air units?

 

It will possible after Update 1.2.3

 

Preliminary DCS Change Log 1.2.3:

...

• Scripting Engine: Added "Mission" Task for ground groups

 

http://forums.eagle.ru/showpost.php?p=1632049&postcount=1

  • Like 1

Крайняя версия MSF 1.0.1 (для 1.2.6.): http://forums.eagle.ru/attachment.php?attachmentid=89817&d=1382379803

 

Новая версия MSF 1.0.2 beta: http://forums.eagle.ru/attachment.php?attachmentid=93422&d=1390584292

 

Миссия для тестирования возможностей MSF 1.0.2: http://forums.eagle.ru/attachment.php?attachmentid=91514&d=1386954362

----

Руководство по MSF (не полная версия для MSF 1.0.2): http://forums.eagle.ru/attachment.php?attachmentid=92959&d=1389558825

Link to comment
Share on other sites

What would happen if I activate a unit, deactivate it and activate it again? Is it possible?

Just tried it and the units seem to disappear for good. :(

DCS AJS37 HACKERMAN

 

There will always be bugs. If everything is a priority nothing is.

Link to comment
Share on other sites

I have question about function land.isVisible(Vec3 from, Vec3 to).

 

boolean function land.isVisible(Vec3 from, Vec3 to) 

 

returns true if there is LOS between point from and point to. Function verifies only obstruction due the terrain and don't takes in account objects (units, static and terrain objects).

 

Does this function work?

As i understand, LOS means "Line of Sight" and function must return True if there is direct vision between points From and To, but this function always returns False.

 

for example,

 

local _is_unit_visible = land.isVisible(_ewr_position.p, _unit_position.p);

local _direct_vision = '';
if _is_unit_visible then 
_direct_vision = 'есть'; -- yes
else
_direct_vision = 'нет'; -- no
end

_debug_msg_text = _debug_msg_text .. 'Прямая видимость до цели: ' .. _direct_vision .. '\n\r'; -- always prints No!

 

Result:

ThereIsNoLos.thumb.jpg.615100e5e068eaafa7d10d92cc1e0d35.jpg

Крайняя версия MSF 1.0.1 (для 1.2.6.): http://forums.eagle.ru/attachment.php?attachmentid=89817&d=1382379803

 

Новая версия MSF 1.0.2 beta: http://forums.eagle.ru/attachment.php?attachmentid=93422&d=1390584292

 

Миссия для тестирования возможностей MSF 1.0.2: http://forums.eagle.ru/attachment.php?attachmentid=91514&d=1386954362

----

Руководство по MSF (не полная версия для MSF 1.0.2): http://forums.eagle.ru/attachment.php?attachmentid=92959&d=1389558825

Link to comment
Share on other sites

All spawned units must be placed in the editor and have either a group activation command or a delayed start. However with the mission task you can change fundamentally what the group might be doing once the game starts, the only issue is the group always has to start at the same spot.

 

Group Deactivate is basically a garbage can function and it removes the group entirely.

 

@Bandit regarding AI on/off. Its been requested.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

  • Recently Browsing   0 members

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