keith5475 Posted November 14, 2023 Posted November 14, 2023 So I have a multiplayer map with over 600 units to be destroyed on each side. ( Its a race to destroy more material on the other side, while protecting yours.) There seems to be no way of building a scoring system that works. I have tried using Scores to decide the winner, and flags that keep ticking up until the amount needed is reached. However this seems to be too much to make work. Assigning points per object only works in single player. And it seems that flags will only work for a small amount of targets. (under 100?) not sure. I just dont seem to find any information on building multiplayer scoring systems. Single player seems very straight forward and functional. Multiplayer seems to only work if you have a small amount of objectives or targets. Where should i be looking or, reading to make this stuff work with large multiplayer servers? Thanks for any help you can give me in advance, or direction to be pointed...
cfrag Posted November 16, 2023 Posted November 16, 2023 On 11/14/2023 at 11:06 PM, keith5475 said: There seems to be no way of building a scoring system that works. There probably is, but perhaps your current approach is based on a (very understandable) misapprehension. On 11/14/2023 at 11:06 PM, keith5475 said: I have tried using Scores to decide the winner, I'm guessing that this is where you were misled if by "Scores" you mean the built-in and very ill documented "mission goals" tools. One thing you may have over-read (because it is not natural to look there is this section in the manual under "Define Mission Goals": Quote If total points at the end of a mission are 49 or less, the mission is a failure; if total points equal 50, the mission is a draw. If total points are 51 or higher, the mission is deemed a success So if you have messing with the mission goals and are incrementing the score each time a unit dies, you will unfortunately never accomplish your goal because the built-in "score" system is something completely different from what almost everyone expects. A workable approach to solve your attempt at competitive unit hunt would very likely require a small modicum of scripting: for each side we set aside a flag, say "redScore" and "blueScore" that are set to 0 at mission start (trivial, happens automatically) when the flag redScore exceeds a number (say 400), red side wins, and the mission ends (simple trigger + action) when the flag blueScore exceeds a number (again, 400?), blue side wins and the mission ends (simple trigger + action) So far, we are good. But how can we count kills? well, this will require a small amount of scripting, using code to tap into world events, and get notified of kill events. Each time that a unit is killed, you then increase the other side's score. If scripting is not (yet) your forte, I'm sure that we quickly throw something together for you that works. (personal note: 1200 units on a server? Your server is mighty indeed, and hopefully stand-alone... ) So, let us know if you are willing to try a slightly different approach from what you are doing now.
cfrag Posted November 16, 2023 Posted November 16, 2023 On 11/14/2023 at 11:06 PM, keith5475 said: There seems to be no way of building a scoring system that works. Ok, rather than just talking, I thought that we could get the ball rolling on this. The kill counting script is this: kk = {} kk.version = "1.0.0" kk.redScoreFlag = "redScore" kk.blueScoreFlag = "blueScore" function kk:onEvent(event) if not event then return end -- bugged, bye! if not event.target then return end -- not interesting if event.target:getCategory() == 2 then return end -- filter weapon dead events if event.id == 28 then -- kill event, interesting! local theUnit = event.target if not theUnit.getCoalition then return end -- scenery objects have no coalition, bye local coa = theUnit:getCoalition() if coa == 1 then -- red object was killed, blue scores local score = trigger.misc.getUserFlag(kk.blueScoreFlag) + 1 trigger.action.setUserFlag(kk.blueScoreFlag, score) trigger.action.outText("Blue killed a <" .. theUnit:getTypeName() .. "> and Scores! Score is now <" .. trigger.misc.getUserFlag(kk.redScoreFlag) .. "> : to <" .. score .. "> blue", 30) elseif coa == 2 then local score = trigger.misc.getUserFlag(kk.redScoreFlag) + 1 trigger.action.setUserFlag(kk.redScoreFlag, score) trigger.action.outText("Red killed a <" .. theUnit:getTypeName() .. "> and Scores! Score is now <" .. score .. "> : to <" .. trigger.misc.getUserFlag(kk.blueScoreFlag) .. "> blue", 30) else trigger.action.outText("Neutral kill registered on <" .. theUnit:getTypeName() .. "> and discarded. Please do not kill bystanders", 30) end end end -- start the event watcher world.addEventHandler(kk) And a proof of concept mission "kill kount (no c required)" that works and detects 4 kills as win condition is attached. Hope this helps kill kount (no c required).miz
keith5475 Posted November 17, 2023 Author Posted November 17, 2023 Ok, first I want to say thank you for your reply. I know im new and that's a lot to explain for someone who is used to a different systems. I got it to work in a very basic way. I had to use the built in 1 to 100 system which made me resort to a percentage of group killed in order to divide the units down low enough to have 100 points on each side... What you have supplied here looks great. I just need to get my head around it and learn how to properly implement it. Thanks a million!!! On 11/16/2023 at 8:28 AM, cfrag said: And a proof of concept mission "kill kount (no c required)" that works and detects 4 kills as win condition is attached. Hope this helps
Awger Posted November 19, 2023 Posted November 19, 2023 Nota Bene: The "Mission Goals" set in the mission editor are only evaluated when the mission ends... the conditions aren't evaluated continuously like they would be for a trigger. If you have multiple events that effect scoring, I'd suggest setting flags as those events occur during the mission, and then setting mission goals that check the flag values and add up the points. This confused me for quite a while before I figured it out ... would be so much simpler if we could just set the score from a script.
cfrag Posted November 28, 2023 Posted November 28, 2023 DCS 2.9 killed my code. Below a replacement for the demo mission kill kount (no c required).miz
Recommended Posts