Preventing the player from grouping certain units

Post new mods and scenarios here.

Moderator: MOD_Command

Post Reply
User avatar
nukkxx5058
Posts: 3141
Joined: Thu Feb 03, 2005 2:57 pm
Location: France

Preventing the player from grouping certain units

Post 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
Winner of the first edition of the Command: Modern Operations COMPLEX PBEM Tournament (IKE) (April 2022) :-)
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

Re: Preventing the player from grouping certain units

Post 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");

User avatar
Gunner98
Posts: 5948
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

Re: Preventing the player from grouping certain units

Post 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
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

Re: Preventing the player from grouping certain units

Post 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.
User avatar
nukkxx5058
Posts: 3141
Joined: Thu Feb 03, 2005 2:57 pm
Location: France

Re: Preventing the player from grouping certain units

Post 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
Winner of the first edition of the Command: Modern Operations COMPLEX PBEM Tournament (IKE) (April 2022) :-)
User avatar
nukkxx5058
Posts: 3141
Joined: Thu Feb 03, 2005 2:57 pm
Location: France

Re: Preventing the player from grouping certain units

Post 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.
Winner of the first edition of the Command: Modern Operations COMPLEX PBEM Tournament (IKE) (April 2022) :-)
User avatar
Gunner98
Posts: 5948
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

Re: Preventing the player from grouping certain units

Post 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
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
User avatar
nukkxx5058
Posts: 3141
Joined: Thu Feb 03, 2005 2:57 pm
Location: France

Re: Preventing the player from grouping certain units

Post 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.
Winner of the first edition of the Command: Modern Operations COMPLEX PBEM Tournament (IKE) (April 2022) :-)
boogabooga
Posts: 976
Joined: Wed Jul 18, 2018 12:05 am

Re: Preventing the player from grouping certain units

Post 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... :lol:
The boogabooga doctrine for CMO: Any intentional human intervention needs to be able to completely and reliably over-ride anything that the AI is doing at any time.
Post Reply

Return to “Mods and Scenarios”