Jump to content

Set Mission Goal/Score Using Lua


Bearfoot

Recommended Posts

Can someone point me in the right direction of where to look for this? I've searched through the docs of all the various classes and objects of "stock"/native DCS, and cannot find anything that references how scores can be adjusted. Is it a specific flag that I have to adjust the value of?

 

Related: mission success/failure setting programmatically (i.e., not through the ME).

Link to comment
Share on other sites

Setting the score, nope. There is a lua predicate in there but it suffers from the same longstanding bug as the same trigger condition. My solution to it was to just set aside several flags with assorted values assigned to them.

 

As far as I am aware there are no scripting commands to set success or failure states like that.

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

Setting the score, nope. There is a lua predicate in there but it suffers from the same longstanding bug as the same trigger condition. My solution to it was to just set aside several flags with assorted values assigned to them.

 

As far as I am aware there are no scripting commands to set success or failure states like that.

 

So you say, for e.g., flag 1001 tracks the red score and flag 1002 tracks the blue score. How do you let the engine know that these flags are the score value, so that the player sees these values in the score window when s/he hits the '`' key?

Link to comment
Share on other sites

No it was more like setting a flag is true score however many points and then telling the script which flags set different point values. So could have 100 goals setup each with a different flag and each set to add 1 point. Then the script would have a addScore() function and go through the flags and set however many flags needed to be true.

 

Its not exactly efficient, but its the only way currently.

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

No it was more like setting a flag is true score however many points and then telling the script which flags set different point values. So could have 100 goals setup each with a different flag and each set to add 1 point. Then the script would have a addScore() function and go through the flags and set however many flags needed to be true.

 

Its not exactly efficient, but its the only way currently.

 

Ah, OK. So in the ME you essentially tell the engine to track particular flags as contributing to the score, while in the script you update the flags to true as required as particular conditions are met etc. Is that correct? So, if I my mission success condition is, e.g., player lands in zone "x" and destroys unit "y" without damaging unit "z", in the Lua I could schedule a function that (pseudo-code):

 

if player in zone "x" then
  set flag 1000
end
if unit y is dead then
  set flag 1001
end
if unit z is dead then
  unset flag 1002
end

 

Then in the ME, I would put:

 

(1) Mission goal: (100, Red), Condition: Flag 1000 = 1

(2) Mission goal: (100, Red), Condition: Flag 1001 = 1

(3) Mission goal: (100, Red), Condition: Flag 1002 = 0

 

Or something like that?

 

You could output the value of that flag as text using a radio option as a workaround, perhaps?

 

To quote Mr. Grimes :)

 

https://forums.eagle.ru/showpost.php?p=1589191&postcount=2

 

Yep, I know I can currently independently track and report a mission score using my own internal Lua variables along those lines ... but what I was hoping to do was to "hook into" the native game engine scoring and reporting system.

Link to comment
Share on other sites

Here is an example of displaying flag values. This can be triggered with an event or using the radio menu -

 

===

 

-- Displaying Flag Values With Text Messages

-- Use a Do Script Action (does not require Mist) -

local msg = {}
msg[#msg + 1]='Blue All Points Flag 10000 value = '
msg[#msg + 1]=trigger.misc.getUserFlag('10000')
msg[#msg + 1]='. \n'
msg[#msg + 1]='Blue Vehicles In Zone Points Flag 20000 value = '
msg[#msg + 1]=trigger.misc.getUserFlag('20000')
msg[#msg + 1]='. \n'
msg[#msg + 1]='. \n'
msg[#msg + 1]='Blue Aircraft Points Flag 50000 value = '
msg[#msg + 1]=trigger.misc.getUserFlag('50000')
msg[#msg + 1]='. \n'
msg[#msg + 1]='Blue Heli Points Flag 60000 value = '
msg[#msg + 1]=trigger.misc.getUserFlag('60000')
msg[#msg + 1]='. \n'
msg[#msg + 1]='Blue Vehicle Points Flag 70000 value = '
msg[#msg + 1]=trigger.misc.getUserFlag('70000')
msg[#msg + 1]='. \n'
msg[#msg + 1]='Blue Ship Points Flag 80000 value = '
msg[#msg + 1]=trigger.misc.getUserFlag('80000')
msg[#msg + 1]='. \n'
msg[#msg + 1]='\n'
msg[#msg + 1]='Press Pause to freeze the action. \n'
trigger.action.outText(table.concat(msg), 6)

local msg = {}
msg[#msg + 1]='Flag 1 value = '
msg[#msg + 1]=trigger.misc.getUserFlag('1')
msg[#msg + 1]='. \n'
msg[#msg + 1]='Flag 2 value = '
msg[#msg + 1]=trigger.misc.getUserFlag('2')
msg[#msg + 1]='. \n'
msg[#msg + 1]='. \n'
trigger.action.outText(table.concat(msg), 6)

 

===

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.

Link to comment
Share on other sites

Here is an example of displaying flag values. This can be triggered with an event or using the radio menu -

 

===

 

-- Displaying Flag Values With Text Messages

-- Use a Do Script Action (does not require Mist) -

local msg = {}
msg[#msg + 1]='Blue All Points Flag 10000 value = '
msg[#msg + 1]=trigger.misc.getUserFlag('10000')
msg[#msg + 1]='. \n'
msg[#msg + 1]='Blue Vehicles In Zone Points Flag 20000 value = '
msg[#msg + 1]=trigger.misc.getUserFlag('20000')
msg[#msg + 1]='. \n'
msg[#msg + 1]='. \n'
msg[#msg + 1]='Blue Aircraft Points Flag 50000 value = '
msg[#msg + 1]=trigger.misc.getUserFlag('50000')
msg[#msg + 1]='. \n'
msg[#msg + 1]='Blue Heli Points Flag 60000 value = '
msg[#msg + 1]=trigger.misc.getUserFlag('60000')
msg[#msg + 1]='. \n'
msg[#msg + 1]='Blue Vehicle Points Flag 70000 value = '
msg[#msg + 1]=trigger.misc.getUserFlag('70000')
msg[#msg + 1]='. \n'
msg[#msg + 1]='Blue Ship Points Flag 80000 value = '
msg[#msg + 1]=trigger.misc.getUserFlag('80000')
msg[#msg + 1]='. \n'
msg[#msg + 1]='\n'
msg[#msg + 1]='Press Pause to freeze the action. \n'
trigger.action.outText(table.concat(msg), 6)

local msg = {}
msg[#msg + 1]='Flag 1 value = '
msg[#msg + 1]=trigger.misc.getUserFlag('1')
msg[#msg + 1]='. \n'
msg[#msg + 1]='Flag 2 value = '
msg[#msg + 1]=trigger.misc.getUserFlag('2')
msg[#msg + 1]='. \n'
msg[#msg + 1]='. \n'
trigger.action.outText(table.concat(msg), 6)

 

===

 

Do these hook into the "Score" display on the score window (as called up by the player with "`")? Otherwise I typically would just an internal Lua variable to keep track of these rather than flags (e.g., "red_coalition_score", "mission_objective1_success", etc.). But the principle is the same, just less cryptic.

Link to comment
Share on other sites

No, it lets you check the values of the flags. In some cases I will increment a flag to show a 'score'. Like if I have ten targets then I'll increment Flag 10000 by 10 for each target destroyed. Ten targets = 100 points. Then you can use the ME's Define Mission Goals - I haven't used this feature much, rather I code in the scoring and determine the win for Blue or Red using events, with scripting where I need it.

 

You are talking about the "'" feature that shows everyone's kills and deaths, and the scores associated with those categories. Sorry, I don't know how to capture that.

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.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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