Keep score of certain group - ED Forums
 


Notices

Reply
 
Thread Tools Display Modes
Old 09-16-2018, 04:51 PM   #1
Speedywrx
Junior Member
 
Speedywrx's Avatar
 
Join Date: Nov 2017
Posts: 41
Default Keep score of certain group

I'm trying to create a multiplayer mission for a few friends.

The premise is I'll have 30 vehicles on each side (blue and red). The objective is simple - destroy all 30 vehicles and you win. I'll have an A-10C spawn every 10 minutes that will go attack the other side's vehicles. Players can choose a variety of aircraft: A2A to escort their A-10C and shoot down the enemy A-10C (and other players); or A2G to push in and assist taking out the 30 vehicles.

The problem is score keeping. I originally had 2 flags set (blue and red). For example:

CONTINUOUS ACTION(Blue increment, ON DESTROY) // UNIT DEAD(Red vehicles) // FLAG INCREASE(1,1)

paired with these other triggers:
ONCE(Blue 5, NO EVENT) // UNIT DEAD(Red vehicles), FLAG EQUALS(1,5) // MESSAGE TO ALL(Blue team score: 5, 10, false)
ONCE(Blue 10, NO EVENT) // UNIT DEAD(Red vehicles), FLAG EQUALS(1,10) // MESSAGE TO ALL(Blue team score: 10, 10, false)
ONCE(Blue 15, NO EVENT) // UNIT DEAD(Red vehicles), FLAG EQUALS(1,15) // MESSAGE TO ALL(Blue team score: 15, 10, false)
... and so on until 30 points.

It seems to act fine in the beginning, but if another vehicle that is not part of the "red vehicle" group nearby is hit, it will count that as well. At the end it will announce "30 kills" but there will still be 1 "red vehicle" left.

What am I doing wrong? Is there a better, but simple, way of doing this?
__________________
i7-7700k OC'd to 5.0 GHz (1.31 vcore), ASUS 1080ti OC, 32 GB 3200 MHz G.Skill, Samsung 960 pro M.2, Thrustmaster Warthog, Saitek pedals, Samsung Odyssey HMD
Speedywrx is offline   Reply With Quote
Old 09-17-2018, 12:44 AM   #2
Wrench
Member
 
Join Date: Feb 2015
Posts: 441
Default

Are you at all familiar with scripting?
This is exactly the kind of thing it's good at.
Or you could create a triggerzone that covers the whole map and set a condition for your players win scenario to NONE OF COALITION IN ZONE.
Wrench is offline   Reply With Quote
Old 09-17-2018, 12:55 AM   #3
Wrench
Member
 
Join Date: Feb 2015
Posts: 441
Default

Haven't tested this, but something like this should work.
Bear in mind this uses Mist (a script you'll have to load, it's pretty easy to find in the mission editor's sub-forum.)

Code:
deadunits = 0
redunits = mist.makeUnitTable('[red][vehicle]')
function Wrench_table_contains(table, element)
  for _, value in pairs(table) do
    if value == element then
      return true
    else
		return false
	end
end


Wrench_DeadHandler = {}
function Wrench_DeadHandler:onEvent(event)
	if event.id == world.event.S_EVENT_DEAD then
		local initr = event.initiator
		if Wrench_table_contains(redunits, initr) then
			deadunits = deadunits + 1
			trigger.action.outText(tostring(deadunits .. 'have been killed!'), 10, false)
			if deadunits >= 30 then
				trigger.action.outText('Blue has Won!'), 10, false)
			end
		end
		end
	end
end
end
world.addEventHandler(Wrench_DeadHandler)
I might have made a mistake in there somewhere, but that should get you close.

That'll create a table of all red ground units, and will create an event handler so that if anyone dies, it'll check if they're in that table.
If they are, it'll tally up the number of total kills.
If that reaches 30, it'll tell you that blue has won.

Last edited by Wrench; 09-17-2018 at 12:57 AM.
Wrench is offline   Reply With Quote
Old 09-17-2018, 12:58 PM   #4
Speedywrx
Junior Member
 
Speedywrx's Avatar
 
Join Date: Nov 2017
Posts: 41
Default

Awesome! I'm familiar with MIST in the sense that I have the necessary files and able to utilize already scripted material (not creating my own content yet).

I have loaded MIST by:
MISSION START "MIST" // // DO SCRIPT FILE (mist_4_3_74.lua)

Then with your script, created a new trigger:
CONTINUOUS ACTION (Check units, ON DESTROY) // // DO SCRIPT(*your script above*)

However at the first red vehicle destroy, a pop up box comes up stating:
[string "deadunits = 0...']:21: unexpected symbol near ','

I'm still trying to figure out how to debug that.
__________________
i7-7700k OC'd to 5.0 GHz (1.31 vcore), ASUS 1080ti OC, 32 GB 3200 MHz G.Skill, Samsung 960 pro M.2, Thrustmaster Warthog, Saitek pedals, Samsung Odyssey HMD
Speedywrx is offline   Reply With Quote
Old 09-17-2018, 01:10 PM   #5
Speedywrx
Junior Member
 
Speedywrx's Avatar
 
Join Date: Nov 2017
Posts: 41
Default

On the other hand, if I wanted to keep it simple, your suggestion of using a trigger zone and "ALL OF GROUP OUT OF ZONE" works very well. I just can't display the score as they start dying - only the end result after they're all dead and it sends "Blue wins!"
__________________
i7-7700k OC'd to 5.0 GHz (1.31 vcore), ASUS 1080ti OC, 32 GB 3200 MHz G.Skill, Samsung 960 pro M.2, Thrustmaster Warthog, Saitek pedals, Samsung Odyssey HMD
Speedywrx is offline   Reply With Quote
Old 09-17-2018, 01:24 PM   #6
Speedywrx
Junior Member
 
Speedywrx's Avatar
 
Join Date: Nov 2017
Posts: 41
Default

Ahh! With your "ALL OF GROUP OUT OF ZONE" suggestion, I also found the condition "GROUP ALIVE LESS THAN" for a percentage of the group.

So it's probably not as pretty as MIST scripting, but I did this:

CONTINUOUS ACTION (Check red units, ON DESTROY) // ALL OF GROUP OUT OF ZONE(Red vehicles, Red vehicle zone) // MESSAGE TO ALL (Blue wins!, 10, false)

ONCE (Blue points 5, NO EVENT) // GROUP ALIVE LESS THAN (Red vehicles, 85) // MESSAGE TO ALL (Blue score: 5, 10, false)
ONCE (Blue points 10, NO EVENT) // GROUP ALIVE LESS THAN (Red vehicles, 6 // MESSAGE TO ALL (Blue score: 10, 10, false)
ONCE (Blue points 15, NO EVENT) // GROUP ALIVE LESS THAN (Red vehicles, 51) // MESSAGE TO ALL (Blue score: 15, 10, false)
...and so on until 30 points

Edit: I just tested this out and it appears to work well. I can also destroy other vehicles nearby that are not part of the group and it does not affect the score (unlike my first attempt in the first post).

I think for what I'm trying to do, this is a simple approach that works - I'm not creating a big fancy mission - just something quick and fun for a few friends. Thanks for the help and ideas, Wrench!
__________________
i7-7700k OC'd to 5.0 GHz (1.31 vcore), ASUS 1080ti OC, 32 GB 3200 MHz G.Skill, Samsung 960 pro M.2, Thrustmaster Warthog, Saitek pedals, Samsung Odyssey HMD

Last edited by Speedywrx; 09-17-2018 at 01:34 PM.
Speedywrx is offline   Reply With Quote
Old 09-17-2018, 10:54 PM   #7
Wrench
Member
 
Join Date: Feb 2015
Posts: 441
Default

Yup, that'll work too. Note that because that script uses an event handler, you only need to runs the script once, and it'll run the rest of the code automatically whenever you (or anyone if used in MP) scores a kill.

So I took a look at the script, and I made some mistakes. (I did write that without even having DCS open)

Here's a mission with a fixed version so you can see how it works.

Note that on lines 25 and 27 there's a reference to the number 4, just change that to however many you want to have to kill.
Attached Files
File Type: miz dead handler.miz (53.7 KB, 9 views)
File Type: lua wrench_dead_handler.lua (982 Bytes, 52 views)
Wrench is offline   Reply With Quote
Old 09-18-2018, 12:24 PM   #8
Speedywrx
Junior Member
 
Speedywrx's Avatar
 
Join Date: Nov 2017
Posts: 41
Default

Quote:
Originally Posted by Wrench View Post
Yup, that'll work too. Note that because that script uses an event handler, you only need to runs the script once, and it'll run the rest of the code automatically whenever you (or anyone if used in MP) scores a kill.

So I took a look at the script, and I made some mistakes. (I did write that without even having DCS open)

Here's a mission with a fixed version so you can see how it works.

Note that on lines 25 and 27 there's a reference to the number 4, just change that to however many you want to have to kill.
Great! Maybe this will help me understand scripting a bit more - I really appreciate your advice and help, Wrench.
__________________
i7-7700k OC'd to 5.0 GHz (1.31 vcore), ASUS 1080ti OC, 32 GB 3200 MHz G.Skill, Samsung 960 pro M.2, Thrustmaster Warthog, Saitek pedals, Samsung Odyssey HMD
Speedywrx is offline   Reply With Quote
Old 09-18-2018, 09:12 PM   #9
Wrench
Member
 
Join Date: Feb 2015
Posts: 441
Default

No problem. Let me know how it works out for you.
Wrench 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 04:42 PM. vBulletin Skin by ForumMonkeys. Powered by vBulletin®.
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.