TEMPEST.114 Posted November 7, 2022 Posted November 7, 2022 (edited) I'm trying to spawn in new groups using a group created in the Mission Editor as a 'template'. I'm able to spawn in a new group by duplicating the 'template' and changing what I need changed, but when I add the second group the first vanishes. I think this is because they're all using the same 'ID' number. I can change the ID number on each of my newly created groups, but how do I know what is available? Is there a function or something I haven't found that gives me a number? Does the mission editor create them sequentially from 1 to #number of groups in M.E.? So just totalling the number of groups + 1 would be enough? Or is there a better way? CLARIFICATION: Let's say I create one individual infantry in the mission editor. But I actually want 200. I'm only going to create 1 in the M.E. but then use my duplicating/spawning script to use that 1 group, as a template and spawn in 200 of it at different places. But when I spawn in the 2nd, even if I manually change the group.Id and unit.Id on my newly created group before spawning it, the first of my spawns vanishes. When I spawn the 3rd, the 2nd vanishes, even though all three have unique group and unit it numbers... What have I missed? Edited November 7, 2022 by Elphaba
cfrag Posted November 7, 2022 Posted November 7, 2022 1 hour ago, Elphaba said: What have I missed? Their names must also be unique.
Grimes Posted November 7, 2022 Posted November 7, 2022 coalition.addGroup doesn't strictly need to have group and unit ids pre-generated when spawning a group. The game should come up with unique ids on its own. Outside of that if you mist or write your own code for it, you can check a lookup table of ids to know if a number is used. For example if not mist.DBs.unitsById[x] then -- that id is available 1 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
TEMPEST.114 Posted November 7, 2022 Author Posted November 7, 2022 Just now, Grimes said: coalition.addGroup doesn't strictly need to have group and unit ids pre-generated when spawning a group. The game should come up with unique ids on its own. Outside of that if you mist or write your own code for it, you can check a lookup table of ids to know if a number is used. For example if not mist.DBs.unitsById[x] then -- that id is available I don't use mist or moose. Trying to stay 'native'. So regardless, they have a unique name, I've given them (although you now say I don't need to) a unique group and unit ID, but the 2nd one always despawns the first so I can only have one 'alive' at a time... I'm now even more confused..
Grimes Posted November 7, 2022 Posted November 7, 2022 It doesn't take much to create and maintain a simple lookup table. Just use coalition.getGroups and iterate every group and unit to check Ids, add em to a table. Likewise use an event handler for birth events to add spawned groups and units. If it is replacing the existing objects then something isn't unique because that is the exact behavior that occurs. I guess post your code so fresh eyes might be able to pinpoint the problem. 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
TEMPEST.114 Posted November 8, 2022 Author Posted November 8, 2022 It was the unit name! Made that unique as well as the group name and it's working!
Recommended Posts