Page 1 of 1
Preventing the player from grouping certain units
Posted: Tue Mar 08, 2022 11:07 pm
by nukkxx5058
Hi, in a scenario I'm developing, I'd like to prevent the player from grouping certain types of units together. Any idea if it's possible ? (with Lua or other)
thx
Re: Preventing the player from grouping certain units
Posted: Fri Mar 11, 2022 6:55 am
by KnightHawk75
Prevent, no.
Undo after it's been done, yes but it'll be kind of messy in that you'll need to be scanning all units (unitsBy doesn't do 'groups') and looking for all the types you want to compare against, and when found remove the group relationship for the unit. You'll need to do it basically non-stop at an intervals like 15sec 30 or every minute whatever works for you.
Code: Select all
---- Global code executed on scenario loaded ----
gKH = {};
gKH.listOfTypes = {'3201','3202','3203','3204','3205','3206','3207','3208','3209','3210','3211','3212'}; --all destroyers
function gKH.TableContains(t,tbl)
for _,v in pairs(tbl) do
if v == t then return true; end
end
return false;
end
function gKH.HandleUnitTypeCheck(g)
local u = ScenEdit_GetUnit({guid=g});
--compares with subtype, change to category or dbid if needed
if ((u ~=nil) and u.type ~="Group" and u.group ~=nil) and gKH.TableContains(u.subtype,gKH.listOfTypes) then
u.group = "none";
ScenEdit_SpecialMessage("playerside",string.format("Unit %s is of type %s and is not allowed to be grouped in this scene. It has been removed from it's group",u.name,u.type));
end
end
function gKH.ProcessGroupCheck(sidename)
local su = VP_GetSide({side=sidename}).units;
for i=1,#su do gKH.HandleUnitTypeCheck(su[i].guid); end
end
-- end global functions --
---- action code ----
--place this in a action that is runs say every 30 seconds --
--If done correctly every 30 seconds any of the units that exist with the matching subtypes and who are also grouped will be ungrouped and a message for each unit generated.
gKH.ProcessGroupCheck("NameOfValidSideHere");
Re: Preventing the player from grouping certain units
Posted: Fri Mar 11, 2022 10:53 am
by Gunner98
From experience, players generally don't like being prevented from doing something they want to do.
Perhaps an explanation why something shouldn't be done would help
Re: Preventing the player from grouping certain units
Posted: Mon Mar 14, 2022 2:25 am
by KnightHawk75
Gunner98 wrote: Fri Mar 11, 2022 10:53 am
From experience, players generally don't like being prevented from doing something they want to do.
Perhaps an explanation why something shouldn't be done would help
Yeah I 100% agree, was just providing a way in case there is some overriding need/reason for it.
Re: Preventing the player from grouping certain units
Posted: Sat Mar 19, 2022 9:29 am
by nukkxx5058
Gunner98 wrote: Fri Mar 11, 2022 10:53 am
From experience, players generally don't like being prevented from doing something they want to do.
Perhaps an explanation why something shouldn't be done would help
Yes sorry, here's the reason:
In the tech forum I reported a bug (?) that occurs when grouping arty units and ammo trucks. The problem is explained here>
https://www.matrixgames.com/forums/view ... 0&t=380324
So preventing the user from grouping arty and ammo trucks together would be a solution. I was wondering if Lua could help. Hence my question. Should have been more clear in my initial message ...
Thanks
Re: Preventing the player from grouping certain units
Posted: Sat Mar 19, 2022 9:32 am
by nukkxx5058
And I forgot to add that the scen I'm developing is PBEM-only so grouping ammo truck and arty will lead to unfair situations.
Re: Preventing the player from grouping certain units
Posted: Sat Mar 19, 2022 12:16 pm
by Gunner98
OK,
I think you'll find that the devs update the game pretty regularly. It may be worth asking where on their priority list this issue is and, if soon I wouldn't bother putting design effort around a bug because you'll keep chasing your tail.
You may be better off using a Special Action. If you want the player to have a certain amount of ammo, instead of putting in an Ammo truck unit, just build a special action and when the player wants to resupply they use that an if it is not repeatable then it adds the ammo and disappears.
B
Re: Preventing the player from grouping certain units
Posted: Sat Mar 19, 2022 1:19 pm
by nukkxx5058
Gunner98 wrote: Sat Mar 19, 2022 12:16 pm
OK,
I think you'll find that the devs update the game pretty regularly. It may be worth asking where on their priority list this issue is and, if soon I wouldn't bother putting design effort around a bug because you'll keep chasing your tail.
You may be better off using a Special Action. If you want the player to have a certain amount of ammo, instead of putting in an Ammo truck unit, just build a special action and when the player wants to resupply they use that an if it is not repeatable then it adds the ammo and disappears.
B
You may be better off using a Special Action. If you want the player to have a certain amount of ammo, instead of putting in an Ammo truck unit, just build a special action and when the player wants to resupply they use that an if it is not repeatable then it adds the ammo and disappears.
Yeah, that's great idea ! Brilliant, thanks !
Otherwise I agree I'd better wait that the devs to fix it. It's true that they usually are very efficient at fixing issue so I should not be waiting too long.
Re: Preventing the player from grouping certain units
Posted: Tue Mar 22, 2022 12:51 am
by boogabooga
You might not "prevent", but you could monitor for some condition and "punish" if detected. That might be a loss of points or warning the other player that the other side has "cheated". Something like that.
Gunner98 wrote: Fri Mar 11, 2022 10:53 am
From experience, players generally don't like being prevented from doing something they want to do.
That's a
life thing...
