[English] Creating Group / Squad Measures

  • A Group / squad measure is a measure you can start when you have selected multiple sims. Those measures/actions will only appear in your action bar if you have set "selectionmode" in MeasureToObjects.dbt to "1". However the tricky part is making that work for workersims (type 1) and dynastysims (type 6) or with any other object type together.


    At the moment, dynasty chars and workers are seperated and can not start the same action if you multiselected, cause they use different filters. To make it work, workers and dynastychars (or any other type you want) have to use the same filter-IDs (target filter and object filter).


    A good example for that is the burglary-measure. In Vanilla it uses ID 215 for workers (Filter.dbt: 'IsMyThief') and 380 for dynasty sims ('HasThievesHut')
    The seperation is done, cause 'IsMyThief' uses the Profession function, which dynasty chars obviously haven't.


    Code
    380   "HasThievesHut"   "__F((Object.CanBeControlled())AND(Object.IsClass(4))AND(Object.MinAge(16))AND(Object.GetOwnedBuildings())AND(Object.IsType(101)))"   |



    Code
    215   "IsMyThief"   "__F((Object.CanBeControlled())AND(Object.GetProfession()== 26)AND(Object.MinAge(16)))"   |


    Now, because of how the statement 'OR' works in Filter.dbt it is not possible to make 2 filters into one with the simple usage of (). In Fact, besides the outer () and the ones you need for parameters, I am pretty sure they are mostly ignored (unless you miss one). But then we have a problem, cause we can't compare 'GetProfession()' and 'GetOwnedBuildings' AND 'IsType' together. Or just compares the functions directly connected. So it will just compare: Profession? Okay. Getownedbuildings? Okay. ObjectType? Wait, Professions don't have object types! So it will not work for workers anymore.


    Basicly you have to find a filter that fits both object types. Easier said than done! But I found 2 very good ways.
    First: if you have a building measure (let's say 'assign to service'), you can use the Filter-function "Object.CanWorkHere()". That works if your measure only appears if you are inside a building. Great, now you can use it for both of your cases, cause it also works with dynasty chars who own the building. But what with the burglary? Now, we could use this filter-function, but that would require the strange change of only beeing able to start a burglary from inside of your thiefs building. Weird!


    Better is the second solution, I came up with. Use 'GetOwnedBuildings' for the dynasty case and 'GetWorkBuilding' for your employees. We can easily connect them with an OR and then can go for the buildingType. Fantastic!


    Final solution:


    Code
    215   "IsMyThief"   "__F((Object.CanBeControlled())AND(Object.GetOwnedBuildings())OR(Object.GetWorkBuilding())AND(Object.IsType(101)))"   |

    You can apply this to many actions. You really don't need the profession-filter-function, unless maybe as a target filter. But object-filter are way better with Building-filter-functions!


    Enjoy!