Jump to content

Recommended Posts

Posted

Aspects of the lua code were broken in a patch, I know some parts were restored, just not sure which.

 

 

 

At any rate, might as well post my new favorite way to spawn in random enemy groups. This relies on triggers only

 

Once> Time less than 2 seconds> Set Random Flag value (Flag 1, low x, high y)

 

Once>Random 5% and Flag is greater than 1> Activate group 1, Flag 1 decrease 1

Once>Random 5% and Flag is greater than 1> Activate group 2, Flag 1 decrease 1

and so on.

 

Basically allows me to decide precisely how many groups I want to spawn within a set range. It can be made a little more complex by assigning a different point value for each group. Perhaps a platoon of T-55 are worth 1 point, whereas a platoon of T-80 might be worth 2. This can create a healthy mix of fewer but stronger units, or more weaker units, and everywhere in between.

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

Posted

....

Flag is greater than 1

Flag 1 decrease 1

 

What does this mean, say you have FLAG 5 as you random value FLAG, will Decrease FLAG 5 mean it is now FLAG 4?

Playing: DCS World

Intel i7-13700KF, 64GB DDR5 @5600MHz, RTX 4080 ZOTAC Trinity, WIN 11 64Bit Prof.

Squadron "Serious Uglies" / Discord-Server: https://discord.gg/2WccwBh

Ghost0815

Posted (edited)
Anyone know if this script was broken in a patch somehow?

 

I could have swore this worked before and now I am having problems using it.

Sorry but after patch 1.1.0.9 a lot of Lua OS functions were restricted from being used in the ME due to security reasons, this included the function os.time. So unfortunately the line ... math.randomseed( os.time() ) no longer works. What this does is to seed a random number to the function math.randomseed. As its restricted none of the lua will execute either.

 

Hopefully os.time will make an appearance in a future patch but for now I would go with Grimes' .

Once>Random 5% and Flag is greater than 1> Activate group 1, Flag 1 decrease 1

Once>Random 5% and Flag is greater than 1> Activate group 2, Flag 1 decrease 1

and so on.

The only downside being thats its not instantaneous and not quite so random, but close enough. By that I mean the random5% triggers are evaluated once every second until one of them becomes true. increasing the number of triggers or increasing the value above 5% (not too much as higher triggers will activate first) will decrease the time taken to turn true.

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

Posted (edited)

If you DID want to go back to being able to use Lua randomness, you could always assemble your own random seed via flags being true or false... if you had 8 flags, each with a 50% probability of being true, then that's 256 random different configurations they could take. That's potentially 256 different random seeds.

 

It would take probably 17 triggers-

--Setting up the flags

Mission Start->Random(50)->Set Flag(1)

Mission Start->Random(50)->Set Flag(2)

Mission Start->Random(50)->Set Flag(3)

... ... ...

Mission Start->Random(50)->Set Flag(8 )

 

--Initializing randseed (1 trigger)

Once->Time More (1) -> AI TASK(Run Script(randseed = 0))

 

--assigning value to randseed (8 triggers)

Once->Flag is True(1) and Time More(2)-> AI TASK(Run Script(randseed = randseed + 1))

Once->Flag is True(2) and Time More(2)-> AI TASK(Run Script(randseed = randseed + 2))

Once->Flag is True(3) and Time More(2)-> AI TASK(Run Script(randseed = randseed + 4))

... ... ... ...

Once->Flag is True(8 ) and Time More(2)-> AI TASK(Run Script(randseed = randseed + 128 ))

 

So now, after these 17 triggers and 9 short Lua scripts, you'd have a random seed with 256 possible values (0-255) named "randseed".

 

So it's enough extra legwork now that unless you need to do a lot of randomizing, it's better to use triggers- but it's not impossible to use the Lua random with a random seed without os.time.

 

If you were going to use the mod I made, Slmod, it has some facilities for easy randomization of missions- but then you restrict your mission to multiplayer, and require the host to have a mod- not worth it solely for randomization.

Edited by Speed

Intelligent discourse can only begin with the honest admission of your own fallibility.

Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/

Lua scripts and mods:

MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616

Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979

Now includes remote server administration tools for kicking, banning, loading missions, etc.

Posted

Be advised: I've found out that under WH's 1.1.1.1 version the time delaying is needed only if you set "group activate".

If you instead set "AI task" with triggered action "start", you have NOT to delay the start time or it doesn't work.

Obviuosly this is only true about "uncontrolled" airplanes on ramp takeoff, the only unit kind that has that "AI off" mode from its activation.

 

However I'm not skilled either in .lua scripting and in mathematical funcions at all and flags true/false combination works fine and easy for me too.

I used also "group deactivate" with more flags and different % to get more randomization. Maybe it could seems complex, but it's actually easyer you can believe.

For ex.: flag 1 to 4 in true/true, false/false, false/true, true/false, then "group deactivate" correlated to flags 5 to 8 in similar combination.

If you put each group into a trigger zone, you can set a trigger's condition like that: "group in zone"+ flags' 5 to 8 true/false combination (maybe flag 5 is 50% true, 6 is 30% and so on) -> action: "group deactivate". The outcome is that some groups are activated randomly each mission start by the first flags but a lot of them are then immediately deactivated giving a more randomized environment.

Posted

^No probs, sorry lua is broken & you have to redo miz.

 

If you DID want to go back to being able to use Lua randomness, you could always assemble your own random seed via flags being true or false.......

At the moment I am using lua to create a task table with the trigger < set random flag value (x, lowVal, HighVal) > to seed it and that seems to work fine and needs less Triggers overall.

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

  • Recently Browsing   0 members

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