cestus
Corporal
Posts: 45
Joined: Sun Oct 14, 2012 9:40 pm

Modding Events, remove specifc unit

Sun Oct 14, 2012 10:04 pm

Hallo,

I'm currently experimenting with event modding. I want to remove the CSA Potomac HQ (Army HQ), disbanding the CSA Army of the Potomac. A second event creates Lee's Army of Northern Virginia. The problem is, not only the CSA HQ is removed, the HQ of the USA Army of the Potomac is removed as well.
How can I ensure the script is only removing the CSA HQ and leaving the USA HQ untouched ?
Can somebody help ?

Code: Select all

StartEvent = evt_KICSA_ArmyPotomacEnd|1|0|NULL|NULL|$Richmond, VA|NULL

Conditions
  MinDate = 1862/04/01
  MaxDate = 1862/06/01
  CheckAILevel = 1
  EvalUnqUnit = Army of the Potomac
 
Actions
  [B][size=134]SelectFaction = $CSA
  SelUnqSubUnit = Potomac HQ
  AlterCuSubUnit = ApplyToList;Kill[/size][/B]
 
EndEvent



StartEvent = evt_KICSA_ArmyNVLee|1|0|NULL|NULL|$Richmond, VA|NULL

Conditions
  MinDate = 1862/04/01
  MaxDate = 1862/06/01
  CheckAILevel = 1
  EvalUnqUnit = Robert E. Lee
  EvalUnqUnit = Army of Northern Virginia;NOT
 
Actions
  SelectFaction = $CSA
  SelUnqSubUnit = Robert E. Lee
  RemoveCuSubUnit = NULL
  AddToRegList = $Richmond, VA;$Dinwiddie, VA;$Norfolk, VA;$Granville, NC;$Sampson, NC;$Wake, NC
  PickFromRegList = NotEnemy;NotAdj

CreateGroup
  Posture = $Defensive
  SetKind = $Land
  Entranch = 4
  InCS = 0
  FixType = 1
  SetName = Army of Northern Virginia
Apply
CreateUnit
  GMEParam = Army of Northern Virginia
  SetType = $uni_CSA_Hq2
  SetLevel = 6
  SetName = Army of Northern Virginia
Apply
CreateUnit
  SetCommit = 1
  SetType = $uni_CSA_RELee4
  SetName = Robert E. Lee
Apply
CreateUnit
  SetType = $uni_CSA_VolBde
  SetLevel = 6
Apply
CreateUnit
  SetType = $uni_CSA_VolBde
  SetLevel = 6
Apply
CreateUnit
  SetType = $uni_CSA_Art5VA
  SetLevel = 6
Apply
CreateUnit
  SetType = $uni_CSA_Sup1VA
  SetLevel = 2
Apply

EndEvent

User avatar
Pocus
Posts: 25659
Joined: Wed Oct 19, 2005 7:37 am
Location: Lyon (France)

Mon Oct 15, 2012 10:12 am

Instead of SelUnqSubUnit, which is not good here as the name is not unique, use the Swiss knife command SelectSubUnits where you can filter with many more criterias. Check the Wiki, see my sig (which is incidentally your friend)
Image


Hofstadter's Law: "It always takes longer than you expect, even when you take into account Hofstadter's law."

cestus
Corporal
Posts: 45
Joined: Sun Oct 14, 2012 9:40 pm

Mon Oct 15, 2012 7:10 pm

The SelectSubUnits didn't do the trick, but i found one other command - SelUnqUnit.
Thanks for the Wiki.
The Event now looks like this.

Code: Select all

StartEvent = evt_KICSA_ArmyPotomacEnd|1|0|NULL|NULL|$Richmond, VA|NULL

Conditions
  MinDate = 1862/04/01
  MaxDate = 1862/06/01
  CheckAILevel = 1
  EvalUnqUnit = Army of the Potomac
 
Actions
  SelectFaction = $CSA 
  SelUnqUnit = Potomac HQ;RestrictFac CSA
  RemoveCuSubUnit = NULL
 
EndEvent

User avatar
Pocus
Posts: 25659
Joined: Wed Oct 19, 2005 7:37 am
Location: Lyon (France)

Tue Oct 16, 2012 2:11 pm

I don't get why it did not do the trick, it does all tricks!

The command you are using is dangerous to me, as a subunit merged into a unit won't be seen.
Image


Hofstadter's Law: "It always takes longer than you expect, even when you take into account Hofstadter's law."

cestus
Corporal
Posts: 45
Joined: Sun Oct 14, 2012 9:40 pm

Wed Oct 17, 2012 3:39 pm

Of course it is possible to select the unit with SelectSubUnits command. But I think there is a limit. I define the Area to Virginia and the model to CSA HQ, but what if there is more than one CSA HQ in Virginia, then all HQs would be selected.
I tested the command above Beauregard was merged with the Potomac HQ and it worked.

Return to “AACW Mods”

Who is online

Users browsing this forum: No registered users and 2 guests