Jump to content

Recommended Posts

Posted

I am organising victory conditions for my .miz based on the player's CAS performance, as measured by how many units in an armor group survive a battle. Once the group ("Combat Engineers"), or what is left of it, performs a specific action at the objective, a flag ("X") is switched on and victory conditions are assessed as follows:

 

Total Victory:

 

Flag X ON

Group COMBAT ENGINEERS is alive

 

Question #1 : Am I correct in assuming that, for the ALIVE condition to be met, 100% of the group must be alive when Flag X is switched on?

 

Victory:

 

Flag X ON

Group COMBAT ENGINEERS is alive less than 100%

 

Defeat:

 

Flag X ON

Group COMBAT ENGINEERS is alive less than 50%

 

Now, here's where I find a logical ambiguity:

 

Question #2: I want the player to lose the mission if Group X is attrited by more than 50% (depite it having accomplished the objective). However, let's say 3 out of the 8 vehicles survive; that's less than 50% but it is also less than 100%, so how do I know it will not be seen by the game's logic as a Victory instead of a Defeat?

 

Thanks, guys, as ever.

Posted (edited)

1. No, only a single unit in the group needs to be alive

(use GROUP ALIVE MORE THAN 95% for total victory)

2. " I want the player to lose the mission if Group X is attrited by more than 50%" you only need the 1 trigger condition (don't have flag x ON) as follows :-

 

'Group COMBAT ENGINEERS is alive less than 50% ' (= Defeat)

 

For just victory have

flag X ON

Group alive less than 95% and

Group alive more than 50%

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)

Thanks, Druid. But: "Group Alive More Than" no longer exists in the drop-down conditions menu! What to do?

 

Edit: Would "All of Group in Zone" work because if only one unit is dead, then it won't satisfy that condition? Otherwise, the only alternative appears to be A "Unit Alive" check on every unit in the group, which would be a real kludge.

 

Eliminating "Group Alive More Than" is such an odd, rather limiting decision; does anyone know why it was made? it's definitely not there and there's no reference to it in the latest DCS User Manual.

Edited by Bahger
Posted (edited)

Well, I managed to get a "Total Victory" condition to work as follows:

 

I made a trigger zone covering the whole battlefield: Y

 

I made this condition:

 

CONTINUOUS ACTION> All of group in "Y"> FLAG ON:99

 

Then, with Flag 98 being the one generated when the ground unit completes its mission:

 

ONCE: "Total Victory"

FLAG 98 = TRUE

FLAG 99 = TRUE

 

It seems to work. I'm hoping there are no contradictions between the above logic for "Total Victory" and using "Group Alive Less Than 100%" for "Victory" (i.e. the ground force has taken casualties.)

 

However, without a "Group Alive More Than" option in the conditions menu, I don't think it's possible to trigger a "Defeat" condition when the ground force is "Group Alive Less Than 50%" because < 50% is also <100%, so I assume that a "Group Alive Less than 40%" trigger alongside the mission completion trigger (Flag 98) will trigger the "Victory" result in the game instead of "Defeat". Or will it? Please advise, I'm not as sharp as most of you with this stuff and my head hurts.

Edited by Bahger
Posted

Got to add, this is really quite galling. The lack of a "Group Alive More Than" condition means that there can be no hierarchy of success/failure in a mission, i.e. no way to assign success or failure on a stepped scale. With only "Group Alive Less Than" it's binary. By removing this command, they've taken away a tool which made it possible to add some nuance into mission scoring. It's doctrinally realistic to assign Mission Total Victory to group 100% alive, Mission Victory to group <25% losses and Mission Failure to group >50% losses. Maybe there's a workaround, but I don't see it. Is there a way to do it with .lua (which is essentially beyond me)? Please ED, can we have "Group Alive More Than" back??

Posted (edited)
do
local unitNames = mist.makeUnitTable({'[g]M1s_1', '[g]M1s_2', '[g]M1s_3', '[g]M2s_1', '[g]M2s_2'})

local totNum = #unitNames
local numDead = 0

for i = 1, totNum do
	local unit = Unit.getByName(unitNames[i])
	if not unit then
		numDead = numDead + 1
	end
end

local fracDead = numDead/totNum

local fracAlive = (totNum - numDead)/totNum

--<Now do whatever...>

end

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

Thank you, Speed.

 

I promise I will read up on Mist. meanwhile, do I need to install anything to make this script work, where do I paste it to and what exactly does it do?

 

I have re-edited the mission with less ambitious, more binary victory conditions but will incorporate this code as soon as I know exactly what it does.

 

Sorry, I do not mean to sound either lazy or ignorant but I do not have a programmer's brain.

Posted (edited)

what exactly does it do?

 

It calculates the fraction of alive and dead units. You write a few lines of code below that would implement your victory conditions.

Example (pseudocode, i'm not familiar with lua, sorry)


if fracAlive >= 0.95
   // whatever funky stuff should happen for total victory
   print 'You're my hero, i want your children'

elseif fracAlive >= 0.5
    // whatever funky stuff should happen for victory
    print 'You're still my hero but you can keep the children'

else 
    // whatever funky stuff should happen for defeat
    print 'go die in a hole, loser'

end

Edit: I was bored so i tried to add it in lua, not sure if the relational operators are in correct syntax though. You would need to add handles that set the separate mission sucess states into the if-else construct, i'm sure that mist provides these but i wasn't able to find them at a quick glance.

 

do
   local unitNames = mist.makeUnitTable({'[g]M1s_1', '[g]M1s_2', '[g]M1s_3', '[g]M2s_1', '[g]M2s_2'})
   
   local totNum = #unitNames
   local numDead = 0
   
   for i = 1, totNum do
       local unit = Unit.getByName(unitNames[i])
       if not unit then
           numDead = numDead + 1
       end
   end
   
   local fracAlive = (totNum - numDead)/totNum
   
   if fracAlive >= 0.95 then
       --Total Vicory
       
   elseif fracAlive >= 0.5 then
       --Victory
       
   else
       --Defeat
       
   end

end

Edited by sobek

Good, fast, cheap. Choose any two.

Come let's eat grandpa!

Use punctuation, save lives!

Posted

Thanks very much Sobek, Speed. The above code makes some sense to me. Now I must either (i) study up on Mist/Lua so that I'm not bugging you guys with every elementary question I might have or (ii) make do with a more binary mission victory condition structure built entirely in the ME, which would be:

 

 

Major Victory: Ground group acheives its objective with zero casualties

Victory: Ground group acheives its objective with casualties

Defeat: Ground group is destroyed at any point in the mission

 

 

I'm sure you can see how my original plan was better. 50% losses in the course of achieving an objective is a failure by modern standards of warfare, as planned and waged by NATO.

 

 

OK, sorry but I'm going to ask one dumbass question: In which ME field is the above code pasted?

Posted

An alternative non lua solution would be to check for the death of each unit in yr group and add 1 to flag x.

Then you could add triggers to check the value of flag x.

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

Suggestion (but there may be a bug?) : have three flag TOTAL and PARTIAL and LOST set to TRUE (resp FALSE and FALSE) at beginning

Then

ONCE (GROUP ALIVE LESS THAN 95% ; FLAG TOTAL = OFF and SET FLAG PARTIAL=ON)

ONCE (GROUP ALIVE LESS THAN 50% ; SET FLAG PARTIAL=OFF and SET FLAG LOST=ON)

 

When reaching other victory condition you have situation of each flag

Details:

Asus Z-170E, Intel i5-6600K @ 4.2GHz, 16GB RAM

MSI GTX970 Gaming 4G

Win 10 Home

Posted (edited)

Very interesting non-lua solutions. By assigning flags to individual unit deaths, I think -- I'll have to check -- that I'd be able to make a condition for a mutually exclusive range of values i.e. with a minimum and maximum number, so:

 

Total Victory: Flag X = 8

Victory: Flag X is less than 8, Flag X is more than 4

Loss: Flag X is less than 4

 

Does that make sense?

Edited by Bahger
Posted

Spot on.

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)

OK, here is what I have done. I'd be very grateful if someone could confirm that it will work, or if not, why not.

 

I created a flag, FLAG 70, generated by a trigger:

 

ONCE>ALL OF GROUP IN ZONE>FLAG 70

 

The zone being a large area covering the battlefield and the group being my Combat Engineer group (CE) that spawns when the mission starts.

 

I gave names by the first eight letters of the alphabet to each unit within the CE group. I then created the following trigger for each member of this group:

 

ONCE> UNIT DEAD>FLAG IS LESS, 70 -1 (i.e. minus one)

 

Here is the .miz in case someone would like to look at the triggers/conditions. I'm stumped.

 

I then organised my victory conditions as follows:

 

TOTAL VICTORY: Group CE is 100% alive when it accomplishes its objective (Flag 11)

 

FLAG 11 ON

FLAG 70 = 70

 

VICTORY: Group CE has lost no more than 2 units when it accomplishes its objective (Flag 11)

 

FLAG 11 ON

FLAG 70 is less than 70

FLAG 70 is more than 67

 

DEFEAT: Group CE has lost more than 4 units (i.e. 50% of total strength) when it accomplishes its objective (Flag 11)

 

FLAG 11 ON

FLAG 70 is less than 67

 

There is also an additional defeat condition that will tell the player he has lost the mission before or after CE's accomplishment of its objective:

 

GROUP DEAD

 

I tried slightly different versions of this last night but it didn't work as planned, in most cases because I had made stupid mistakes that I think are corrected in the programming described above. However, I am capable of making large conceptual errors and would be very grateful if one of you could confirm that the conditions/triggers set out here are likely to produce the victory condition structure that I want. Thanks, as ever.

 

Gah, I just tested it twice, and both times I got a "Defeat" message when none of the CE units had been killed! What can I be doing wrong?? What is it that's triggering the "Defeat" condition when it's FLAG (70) IS LESS (67) and no unit has been killed, let alone three units that would then subtract 3 from Flag 70's value (70)?

 

Here is the .miz file in case someone would like to look at the trigger list. It's a large file because there are a few custom sounds. I'm stumped.

Broken Wing 06.miz

Edited by Bahger
Posted (edited)

Try putting in some temporary Message To All messages to let you know when your expected conditions are met.

 

I'd be inclined to test a Condition of Group Alive Less Than xx% instead of Flag 70. Eliminate a level...

 

I just finished edits on a mission where I used Set Mission Goals and gave different points for killing groups (with Group Alive < xx% conditions), and then gave status messages in the mission as to point progress in 5 point increments. I had to code for each 5 point value between 20 and 100 since some kills awarded more than 5 points.

 

I don't use 'All Of Group In Zone' because too many times a unit will get hung up on a bridge or in a building (naw, never happens) - instead I accept the alternative of 'Part Of Group In Zone'.

 

---

 

If you are getting a Defeat message and you think it is because Flag 70 is less than 67, did you initialize Flag 70 to a value above 67 before you tested this Condition?

 

WC

Edited by Wrecking Crew

Visit the Hollo Pointe DCS World server -- an open server with a variety of COOP & H2H missions including Combined Arms. All released missions are available for free download, modification and public hosting, from my Wrecking Crew Projects site.

Posted

I think I see the problem. Its the first trigger. You are setting flag 70 to true. Which is basically "1" in a mathematical sense. Your other triggers look at the value of flag 70, which by default is 1 based on the first trigger, so you will always get a failure. You will want to change it so it has a numerical value use either:

 

Flag 70 increase 70 (Flags start at 0 or false)

 

or

 

Set Flag random value(70, 70, 70) It sets a random value between 70 and 70.... its not exactly random, but thats how we have to do it for now.

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

Protip: Create a continuous trigger with time more than 0 and put the following in a "do script" action.

 

trigger.action.outText('Flag 70 has a value of ' .. tostring(trigger.misc.getUserFlag('70')) , 5)

 

It will output a text message to the top of your screen showing the current value of flag 70. It overwrites other text messages, but its a good debugger.

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

Thanks so much, guys.

 

Grimes, I'm sure you are right -- as usual -- but before I test it, may I just run this by you:

 

I'm going to address your point by making the first trigger as follows:

 

ONCE>ALL OF GROUP IN ZONE> FLAG ON 70, FLAG 70 INCREASE 70

 

(Where "Group" is my "CE" group and the zone is a huge one called Spawn that cover the whole beattlefield so Wrecking Crew's concerns about a unit not being seen as in-zone will not apply).

 

If I do the above< I assume I will not need another trigger, FLAG 70 = 70 because (i) it's covered in the previous trigger above and (ii) as you point out, this does not actually set a value for a flag, it merely switches it on, if my understanding is correct.

 

Finally, would I be correct in assuming that once I fix this, the logic in the remainder of my triggers is sound and that the victory conditions they cover will pan out as intended?

 

Wrecking Crew, thank you for your response. The interesting thing about your point re. using "Group alive less than" is that with "Group alive more than" no longer available in the ME, I cannot use a combination of those two conditions to set a range of numbers with a high and low limit. See, As long as I have a condition that sets "Group alive less than 100%", then any other condition referencing any number under 100% will register as True because I won't be able to set another high ceiling below 100% For that I'd need "Group alive more than 50% =FALSE" so that I can set a victory condition whereby the player won't fail for finishing with < 100% of the ground group ("CE") but >50%. Why they disposed of that condition I cannot fathom.

Posted (edited)

Protip gratefully received and implemented.

 

Using Grimes' script I ran the mission again. FYI, setting "FLAG 70 INCREASE 70" gives me a starting value for Flag 70 of 71.

 

I just had to laugh.

 

Trying again now with "FLAG 70 INCREASE 69"

Edited by Bahger
Posted

Flags are kind of weird as it holds two types of values, boolean and numerical, which can both be checked at any time by the "flag conditions."

 

Flag x = 0 Means its numerical value is 0 and its boolean value is false

Flag x = 5 means its numerical value is 5 and its boolean value is true

Set Flag x True should have a numerical value of 1 and boolean value of true

 

If I do the above< I assume I will not need another trigger, FLAG 70 = 70 because (i) it's covered in the previous trigger above and (ii) as you point out, this does not actually set a value for a flag, it merely switches it on, if my understanding is correct.

 

That was the condition checking if flag 70 had the value of 70. If it did, trigger action would set flag 80 to true. (Which before it never did) because flag 70 equaled 1.

 

I can't say for sure if your triggers will work 100% as you want them, but at the very least this might help you get in the right direction.

 

 

 

Another protip... you can just set the flag directly to 70 with do script> trigger.action.setUserFlag('70', 70)

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 (edited)

I tip my hat to guys like you who can wrap their brains around this kind of thing. I have an MA in Eng. Lit. from Cambridge but my ability to comprehend mathematical abstraction is inferior to that of my 9th-grade son (and he's no math whiz either).

 

I think the mission works now but the Flag value counter overwrote the message that would have confirmed it, so I'm going to run it again without the counter.

 

Aside from my own obstuseness, I think that some of these problems are caused by linguistic ambiguity in the descriptions of conditions; for example, who would ever assume that "Increase Flag 70 to 70" really means "Give Flag 70 a value of 71"?? Now I understand why you ME ninjas prefer to use lua; pure mathematical language eliminates all ambiguity.

Edited by Bahger
Posted

What I did was:

 

FLAG ON 70

FLAG 70 INCREASE 69

 

I guess I don't need the FLAG ON 70, huh?

 

Thanks for all your help, grimes, as ever. I think this is a good .miz, all the better for having layered victory conditions.

  • Recently Browsing   0 members

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