EasyEB Posted February 22, 2017 Posted February 22, 2017 Hi! It's me again... Is it possible to make a message displaying the composition of a certain group to the player? The group is spawned with some elements of randomization so it may consist of between two and ten vehicles ranging from MBTs to trucks. I want for instance a message for ten seconds saying "Enemy group of 7 vehicles. 1x T-72B 3x BMP-1 3x URAL 375" Is this possible? If so, how? As always, thanks.
razo+r Posted February 22, 2017 Posted February 22, 2017 it is possible with scripting i believe... Already done in some missions, don't know which though...
Grimes Posted February 22, 2017 Posted February 22, 2017 Quick and dirty. May contain errors. Basically iterate the units in the group and build a table of unit names and count the number of each. Then build a message based on that table. local names = {} local units = Group.getByName('whatever'):getUnits() for i = 1, #units do local typeName = Unit.getByName(units[i]):getTypeName() if not names[typeName] then names[typeName] = 1 else names[typeName] = names[typeName] + 1 end end local msg = {} msg[#msg+1] = "Target consists of " .. #units .. "vehicles \n" for name, num in pairs(names) do msg[#msg+1] = num .. 'x ' .. name .. '\n' end trigger.action.outText(table.concat(msg), 20) The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
EasyEB Posted February 22, 2017 Author Posted February 22, 2017 Yeah, I got an error and no message in game.
Grimes Posted February 23, 2017 Posted February 23, 2017 As I said I wrote it fairly quickly so I'm not surprised there was an error. Probably just change the 4th line to this to fix it. local typeName = Unit.getTypeName(units) The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
EasyEB Posted February 23, 2017 Author Posted February 23, 2017 Thanks for trying to help man, you know I appreciate it but I don't say it as often as I should. local names = {} local units = Group.getByName('Group1'):getUnits() for i = 1, #units do local typeName = Unit.getTypeName(units) if not names[typeName] then names[typeName] = 1 else names[typeName] = names[typeName] + 1 end end local msg = {} msg[#msg+1] = "Target consists of " .. #units .. "vehicles \n" for name, num in pairs(names) do msg[#msg+1] = num .. 'x ' .. name .. '\n' end trigger.action.outText(table.concat(msg), 20) gave me [string "C:\Users\...\Temp\DCSV~mis000286A"]:4: Parameter #1 (unit name string) missed start traceback: [C]: ? [C]: in function 'getByName' [string "C:\Users\...\Temp\DCSV~mis0000286A":4: in main chunk] EDIT: I FORGOT TO UPDATE THE SCRIPT FILE! IT WORKS!!!
EasyEB Posted February 27, 2017 Author Posted February 27, 2017 Does this display the units in the order they are in the group? Bonus question: Is it possible to get the unit ID of say the third unit in a group of five?
gromit190 Posted March 1, 2017 Posted March 1, 2017 Hey EasyEB, I've scripted such a feature for my missions once before. Basically I added a radio command for players to ask for "Intel on closest enemy vehicles". When fired, it prints out a message saying type of units, number of units, heading and distance (from player group lead) to the closest "cluster" of enemy vehicles. I've recently broken the feature (because it was a part of a project where I changed some core stuff), but I'm quite eager to fix it again. I'll let you know when it is ready :) Here's the output format: 4 M-1 Abrams located 9nm N/NE of group lead What do you think of the format? The current "name" for this feature is "IOCEV" which is ugly af, so I'm looking for suggestions for a different name. Autonomous ground AI project
EasyEB Posted March 1, 2017 Author Posted March 1, 2017 Hey EasyEB, I've scripted such a feature for my missions once before. Basically I added a radio command for players to ask for "Intel on closest enemy vehicles". When fired, it prints out a message saying type of units, number of units, heading and distance (from player group lead) to the closest "cluster" of enemy vehicles. I've recently broken the feature (because it was a part of a project where I changed some core stuff), but I'm quite eager to fix it again. I'll let you know when it is ready :) Here's the output format: What do you think of the format? The current "name" for this feature is "IOCEV" which is ugly af, so I'm looking for suggestions for a different name. I think the output could be shortened a bit and perhaps a little clearer. Perhaps a bit like a BRA call like 4x M-1 Abrams bearing 22 for 9 from lead. As for the name, I think GUCK - Ground Unit Call Knowledge. Or perhaps Familiar Unit Call Knowledge.
gromit190 Posted March 2, 2017 Posted March 2, 2017 I think the output could be shortened a bit and perhaps a little clearer. Perhaps a bit like a BRA call like 4x M-1 Abrams bearing 22 for 9 from lead. I agree As for the name, I think GUCK - Ground Unit Call Knowledge. Or perhaps Familiar Unit Call Knowledge. :megalol: Autonomous ground AI project
EasyEB Posted March 2, 2017 Author Posted March 2, 2017 :megalol: We could go with Concentration of Units Nautical Tally System if you would prefer that.
SUNTSAG Posted March 2, 2017 Posted March 2, 2017 Hey Guys, why not go for the realism element and use this: "SALUTE Report" Callsign: NAKED My YouTube Channel [sIGPIC][/sIGPIC]
ESAc_matador Posted March 2, 2017 Posted March 2, 2017 Hi! It's me again... Is it possible to make a message displaying the composition of a certain group to the player? The group is spawned with some elements of randomization so it may consist of between two and ten vehicles ranging from MBTs to trucks. I want for instance a message for ten seconds saying "Enemy group of 7 vehicles. 1x T-72B 3x BMP-1 3x URAL 375" Is this possible? If so, how? As always, thanks. Hello. Just have a look at the C4SIR script.
Recommended Posts