Remove pre-placed buildings from game map if disabled

Ideas and suggestions for how to improve the Warzone 2100 base game only. Ideas for mods go in Mapping/Modding instead. Read sticky posts first!
Post Reply
User avatar
Arreon
Trained
Trained
Posts: 324
Joined: 15 Feb 2009, 05:57
Contact:

Remove pre-placed buildings from game map if disabled

Post by Arreon » 24 Dec 2012, 15:44

One thing that bothers me is when I go to disable VTOL factories and sometimes Cyborg factories too, the ones that were already placed on the map at the start of the game still remain. There should be a fix where any buildings that are placed on the map which are disabled in the Structure Limits menu disappear once the game starts.
OS: Windows 7 Home Premium 64-bit
Processor: AMD Phenom II X6 1045T (6 CPUs), ~2.7GHz
Memory: 8192MB RAM

User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: Remove pre-placed buildings from game map if disabled

Post by aubergine » 24 Dec 2012, 16:12

It's possible to do that in WZ 3.2 via rules.js, but not yet implemented.

Code: Select all

// something like this would need adding to rules.js during eventGameInit()
// note: if .name doesn't contain structure string id (eg. "A0LightFactory") then we'd need a property to expose that

// cycle through each player
playerData.forEach(function(data, player) {
   var structures = {};
   var limit;
   // build list of types of structures pre-placed by map for this player
   enumStruct(player).forEach(function(structure) {
     if (!structures.hasOwnProperty(structure.name)) structures[structure.name] = [];
     structures[structure.name].push(structure);
   }
   // now remove excess structures owned by this player
   Object.keys(structures).forEach(function(structureID) {
      limit = getStructureLimit(structureID, player);
      while (structures[structureID].length > limit) removeObject(structures[structureID].pop());
   });
});
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO

User avatar
effigy
Regular
Regular
Posts: 1217
Joined: 22 Jan 2010, 03:21
Contact:

Re: Remove pre-placed buildings from game map if disabled

Post by effigy » 27 Dec 2012, 04:08

This would be great.
This is why some features aren't implemented: http://forums.wz2100.net/viewtopic.php?f=30&t=7490&view=unread#p87241

Post Reply