Set Mission Goal/Score Using Lua - ED Forums
 


Notices

Reply
 
Thread Tools Display Modes
Old 01-13-2018, 02:43 AM   #1
Bearfoot
Member
 
Join Date: Jan 2016
Location: Michigan, USA
Posts: 967
Reputation power: 10
Bearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really nice
Default Set Mission Goal/Score Using Lua

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).
Bearfoot is online now   Reply With Quote
Old 01-13-2018, 04:09 AM   #2
Grimes
ED Testers Team
 
Grimes's Avatar
 
Join Date: Jan 2006
Location: Black Mesa
Posts: 7,118
Reputation power: 150
Grimes has much to be proud ofGrimes has much to be proud ofGrimes has much to be proud ofGrimes has much to be proud ofGrimes has much to be proud ofGrimes has much to be proud ofGrimes has much to be proud ofGrimes has much to be proud ofGrimes has much to be proud ofGrimes has much to be proud ofGrimes has much to be proud of
Default

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.
__________________
You can only tie the world record for lowest flight.
Current Projects: Scripting Wiki, Something...
Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD for DCS 1.5/2.0, IADScript, Mission Editing Wiki!, Mission Building Forum
Grimes is offline   Reply With Quote
Old 01-13-2018, 04:19 AM   #3
Bearfoot
Member
 
Join Date: Jan 2016
Location: Michigan, USA
Posts: 967
Reputation power: 10
Bearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really nice
Default

Quote:
Originally Posted by Grimes View Post
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?
Bearfoot is online now   Reply With Quote
Old 01-13-2018, 04:40 AM   #4
Grimes
ED Testers Team
 
Grimes's Avatar
 
Join Date: Jan 2006
Location: Black Mesa
Posts: 7,118
Reputation power: 150
Grimes has much to be proud ofGrimes has much to be proud ofGrimes has much to be proud ofGrimes has much to be proud ofGrimes has much to be proud ofGrimes has much to be proud ofGrimes has much to be proud ofGrimes has much to be proud ofGrimes has much to be proud ofGrimes has much to be proud ofGrimes has much to be proud of
Default

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.
__________________
You can only tie the world record for lowest flight.
Current Projects: Scripting Wiki, Something...
Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD for DCS 1.5/2.0, IADScript, Mission Editing Wiki!, Mission Building Forum
Grimes is offline   Reply With Quote
Old 01-13-2018, 05:27 AM   #5
feefifofum
3rd Party Developer
 
feefifofum's Avatar
 
Join Date: Jan 2015
Location: USA
Posts: 1,598
Reputation power: 13
feefifofum is just really nicefeefifofum is just really nicefeefifofum is just really nicefeefifofum is just really nicefeefifofum is just really nicefeefifofum is just really nicefeefifofum is just really nicefeefifofum is just really nicefeefifofum is just really nicefeefifofum is just really nicefeefifofum is just really nice
Default

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...91&postcount=2
feefifofum is offline   Reply With Quote
Old 01-13-2018, 05:49 AM   #6
Bearfoot
Member
 
Join Date: Jan 2016
Location: Michigan, USA
Posts: 967
Reputation power: 10
Bearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really nice
Default

Quote:
Originally Posted by Grimes View Post
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):

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?

Quote:
Originally Posted by feefifofum View Post
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...91&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.
Bearfoot is online now   Reply With Quote
Old 01-13-2018, 06:45 PM   #7
Wrecking Crew
Senior Member
 
Wrecking Crew's Avatar
 
Join Date: Apr 2011
Location: Colorado
Posts: 1,729
Reputation power: 11
Wrecking Crew is a jewel in the roughWrecking Crew is a jewel in the roughWrecking Crew is a jewel in the roughWrecking Crew is a jewel in the roughWrecking Crew is a jewel in the roughWrecking Crew is a jewel in the rough
Default

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) -
Code:
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)
===
Wrecking Crew is offline   Reply With Quote
Old 01-13-2018, 07:34 PM   #8
Bearfoot
Member
 
Join Date: Jan 2016
Location: Michigan, USA
Posts: 967
Reputation power: 10
Bearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really niceBearfoot is just really nice
Default

Quote:
Originally Posted by Wrecking Crew View Post
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) -
Code:
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.
Bearfoot is online now   Reply With Quote
Old 01-13-2018, 08:14 PM   #9
Wrecking Crew
Senior Member
 
Wrecking Crew's Avatar
 
Join Date: Apr 2011
Location: Colorado
Posts: 1,729
Reputation power: 11
Wrecking Crew is a jewel in the roughWrecking Crew is a jewel in the roughWrecking Crew is a jewel in the roughWrecking Crew is a jewel in the roughWrecking Crew is a jewel in the roughWrecking Crew is a jewel in the rough
Default

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.
Wrecking Crew is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 02:49 PM. vBulletin Skin by ForumMonkeys. Powered by vBulletin®.
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.