Tank50us Posted August 24, 2021 Share Posted August 24, 2021 So, one of the things I came up with for a new training map is to incorporate a war-factory of sorts. Basically a building that will 'constantly' produce units until it's destroyed. The problem is that the only way I know how to do that is with the "When unit dies" command, and having a 'supply' of replacements, but once that supply is exhausted, that's it. What I want to have is a way around that supply issue, so that as units get destroyed, they keep getting replaced, over and over, until that structure is destroyed. Is it realistic? Not really. Is it a way to ensure pilots have a constant supply of fresh tanks to kill? Very much yes. Anyone know how to do that? 1 Link to comment Share on other sites More sharing options...
cfrag Posted August 24, 2021 Share Posted August 24, 2021 With Lua script this can be done (not difficult, but spawning Units is tedious to implement the first time). In ME by itself: not to my knowledge. If you look into one of my 'Pushback' missions (see missions forum), you'll see how I implemented it via Zones: Once a side conquers that zone, it 'produces' an endless stream of defenders and attackers for that side. 1 Link to comment Share on other sites More sharing options...
Dangerzone Posted July 31, 2022 Share Posted July 31, 2022 On 8/24/2021 at 2:42 PM, Tank50us said: So, one of the things I came up with for a new training map is to incorporate a war-factory of sorts. Basically a building that will 'constantly' produce units until it's destroyed. The problem is that the only way I know how to do that is with the "When unit dies" command, and having a 'supply' of replacements, but once that supply is exhausted, that's it. What I want to have is a way around that supply issue, so that as units get destroyed, they keep getting replaced, over and over, until that structure is destroyed. Is it realistic? Not really. Is it a way to ensure pilots have a constant supply of fresh tanks to kill? Very much yes. Anyone know how to do that? Hi Tank, Just wondering if you ever managed to accomplish this, and if so - would you mind sharing the finished result? Cheers DZ Link to comment Share on other sites More sharing options...
cfrag Posted August 1, 2022 Share Posted August 1, 2022 9 hours ago, Dangerzone said: Just wondering if you ever managed to accomplish this, and if so - would you mind sharing the finished result? This is something I put together that should do what you want: - A 'Wasp Factory' (nod to Ian) to the west. Produces vehicles (here BTR-80, you can change that to anything you want) that drive towards Senaki - When you destroy the current group of vehicles, the Factory simply produces a new group within seconds and sends it your way - destroy the Factory to stop it producing new vehicles Mission logic is simple: The 'Factory' building has a destruct detector that sets flag 'factoryDead' if it is destroyed New vehicles are cloned once at start and then every time all clones are destroyed When the factory is destroyed (factoryDead flag is set), the cloner is turned off Built with DML, so you can change everything inside ME by looking at the two trigger zones that control the action. The Wasp Factory.miz 2 Link to comment Share on other sites More sharing options...
Dangerzone Posted August 2, 2022 Share Posted August 2, 2022 Nifty. I get the idea. Thanks CFrag! Link to comment Share on other sites More sharing options...
Dangerzone Posted November 1, 2022 Share Posted November 1, 2022 (edited) On 8/24/2021 at 2:42 PM, Tank50us said: So, one of the things I came up with for a new training map is to incorporate a war-factory of sorts. Basically a building that will 'constantly' produce units until it's destroyed. The problem is that the only way I know how to do that is with the "When unit dies" command, and having a 'supply' of replacements, but once that supply is exhausted, that's it. What I want to have is a way around that supply issue, so that as units get destroyed, they keep getting replaced, over and over, until that structure is destroyed. Is it realistic? Not really. Is it a way to ensure pilots have a constant supply of fresh tanks to kill? Very much yes. Anyone know how to do that? I've come up with a very simple stand-alone script after cfrag pointed me in the right direction of how to do it. This is a very basic function that I've written. (just checks groups on a certain interval and will respawn, or otherwise cancel the scheduler at that time. I'm sure it could be done better - but it is what it is ) To use the function I've written in your mission you just need to do the following (customising it to match your group names) local _factoryStaticName = 'NameOfStaticGroup' -- Group name of Static object considered to be the factory local _factoryGroups = {'BMP3Group-1', 'BMP3Group-2', 'SA19Group-1'} -- Group names of LATE activate units to spawn fact1 = MyFactory:New('MyFirstFactory', _factoryStaticName, _factorygroups) fact1:Start() How it Works You need to create a mission that includes a static object, as well as one or more late activate groups that will be the units that the factory creates. (Create relevant paths/objectives for the units) You then need to have MOOSE running fist in your mission, and then run the MyFactory script (or import with a file, etc) contained further below in this post that contains the full functions. (This does nothing except loads the function into memory ready to be used) You then need to run the script above (after modifying it to pass through the relevant units that you've created). The function is a class, so you can refer to it later, and/or stop it at any time yourself via it's functions - however it will stop automatically itself when the factory is destroyed. Once you start this, it will start spawning the groups that you have specified in the _factorygroups variable (table). At a particular interval it will check to see if the factory is alive. If it's not - it stops any future checks. Any units still alive remain alive but will not be respawned once killed. Otherwise if it's still alive - it will check each group to see if the group is alive. Any group that it finds that is not alive, it will respawn back at it's original location. Important Information: This requires the MOOSE library. (Sorry - I know it can be done without, but I don't have the time or the experience at this stage to try and change to non-moose) Usual disclaimer. (I'm no lua expert - make sure you read the code, that I haven't contained bad bugs, and you are satisfied it's not going to empty your bank accounts or start World War 3 before executing. I hold no responsibility for the use of this) I'm sure that this can be expanded on for different intervals for different units, the ability to add air units into the mix as well (might even work as is - I haven't tried), etc. It's very basic but should get people started if they want as a foundation. I only ask that in return if someone uses this code and if they modify/enhances it - that they please post enhancements back here in this thread for all to benefit. Please do not PM me about this code. If you have any questions, post back here and I or other community members may be able to assist. The code for the function: (There is no need to change any of this code for you to run the script - all your own settings are done in the code shown above. Leave this as is unless you want to change the core function of the code) MyFactory = { ClassName = "MyFactory" } function MyFactory:New(name, factoryname, factorygroupnames) local self = routines.utils.deepCopy(self) -- Create a new self instance self.name = name self.factoryname = factoryname self.factory = STATIC:FindByName(self.factoryname, false) self.factorygroupnames = factorygroupnames self.factorygroups = {} self.checkinterval = 359 -- Every 6 minutes (closest PRIME number to avoid multiple functions hitting at same time) for i = 1, #factorygroupnames do table.insert( self.factorygroups, {groupname = factorygroupnames[i], isspawned = false, coinstances = 1, maxinstances = 3} ) end return self end function MyFactory:CheckNow() if not self.factory then self:Stop() return false else if not self.factory:IsAlive() then self:Stop() return false end end for i = 1, #self.factorygroups do local fg = self.factorygroups[i] if fg.isspawned then --Check and clean up first! if not fg.activegroup then fg.isspawned = false else local IsAlive = false IsAlive = GROUP:FindByName(fg.activegroup):IsAlive() if not IsAlive then fg.isspawned = false end end end if not fg.isspawned then local _myspawn = SPAWN:New(fg.groupname):Spawn() fg.activegroup = _myspawn.GroupName fg.isspawned = true end end end function MyFactory:SetCheckInterval(checkinterval) self.checkinterval = checkinterval if self.running == true then self.scheduler:Stop() self.scheduler:Start() end end function MyFactory:Stop() self.scheduler:Stop() self.running = false end function MyFactory:Start() if self.factory then if self.factory:IsAlive() then self.scheduler = SCHEDULER:New( nil, function() self:CheckNow() end, {}, 1, self.checkinterval ) self.running = true end end end Hope this helps.... - DZ Edited November 1, 2022 by Dangerzone Link to comment Share on other sites More sharing options...
Recommended Posts