Random Mixed Neutrals on any map by Asheera
In this tutorial I’ll give you (the map makers especially) the possibility to place random mixed neutrals on any map. I’ll use the script for this.
First, add this piece of code to “scripts/common.lua” file (my creation):
– Function for handling the generation of neutrals function CreateCreeps(creeps, creep_groups) local additional_stacks = {} local x = 1
– go through all creeps for i, creep in creeps do
local creep_name = “Creep_” .. i
local groups = creep_groups[creep.group] local group = groups[random(length(groups))+1]
local stack = group[1]
CreateMonster(creep_name, stack.type, stack.min+random(stack.max-stack.min+1), creep.x, creep.y, creep.u or 0, creep.mood or 1, creep.courage or 2, creep.rot)
local numStacks = length(group)
for j = 2, numStacks do stack = group[j] additional_stacks[x] = {Name = creep_name, Id = stack.type, Num = stack.min+random(stack.max-stack.min+1)} x = x + 1 end
end
– pause the script so the engine can place the neutrals on the map sleep(2)
– add additional stacks (NOTE: only the first stack’s size is adjusted by the difficulty of the game, we need to do it here manually) x = GetDifficulty(); local y = 1.0 if x == 0 then y = 0.5 elseif x == 2 then y = 1.12 elseif x == 3 then y = 1.4 end
for i, v in additional_stacks do
AddObjectCreatures(v.Name, v.Id, v.Num*y)
end end
Now for each map you want random mixed neutrals, you’ll need to place a map script in it. And also, don’t place any neutrals on the map, the script will handle that for you.
The Map script should look like the following (this is only an example - the possibilities are endless)
– define neutrals NeutralGroups = { – group 1 [1] = {
[1] = { [1] = {min = 50, max = 60, type = 1}, -- Peasants }, [2] = { [1] = {min = 20, max = 30, type = 2}, -- Conscripts [2] = {min = 15, max = 35, type = 106}, -- Brutes },
},
– group 2 [2] = {
[1] = { [1] = {min = 7, max = 11, type = 3}, -- Archers [2] = {min = 5, max = 8, type = 5}, -- Footmen [3] = {min = 1, max = 2, type = 108}, -- Vindicators }, [2] = { [1] = {min = 5, max = 7, type = 108}, -- Vindicators [2] = {min = 13, max = 19, type = 106}, -- Brutes }, [3] = { [1] = {min = 14, max = 20, type = 43}, -- Pixies }, [4] = { [1] = {min = 7, max = 11, type = 146}, -- Wind Dancers }, [5] = { [1] = {min = 7, max = 9, type = 93}, -- Shield Guards [2] = {min = 2, max = 4, type = 167}, -- Harpooners }, [6] = { [1] = {min = 16, max = 24, type = 57}, -- Gremlins [2] = {min = 6, max = 9, type = 159}, -- Gremlin Saboteurs }, [7] = { [1] = {min = 10, max = 15, type = 71}, -- Scouts }, [8] = { [1] = {min = 3, max = 6, type = 73}, -- Blood Maidens [2] = {min = 3, max = 3, type = 139}, -- Blood Sisters }, [9] = { [1] = {min = 12, max = 17, type = 16}, -- Familiars }, [10] = { [1] = {min = 17, max = 27, type = 29}, -- Skeletons [2] = {min = 9, max = 12, type = 152}, -- Skeleton Warriors },
},
– group 3 [3] = {
[1] = { [1] = {min = 30, max = 50, type = 3}, -- Archers }, [2] = { [1] = {min = 6, max = 20, type = 71}, -- Scouts },
},
– group 4 [4] = {
[1] = { [1] = {min = 30, max = 50, type = 4}, -- Marksmen },
},
– group 5 [5] = {
[1] = { [1] = {min = 20, max = 40, type = 5}, -- Footmen },
},
– group 6 [6] = {
[1] = { [1] = {min = 10, max = 15, type = 7}, -- Griffins },
},
– group 7 [7] = {
[1] = { [1] = {min = 10, max = 15, type = 8}, -- Imperial Griffins },
},
– group 8 [8] = {
[1] = { [1] = {min = 6, max = 9, type = 10}, -- Inquisitors },
},
– group 9 [9] = {
[1] = { [1] = {min = 4, max = 6, type = 11}, -- Cavaliers },
},
– group 10 [10] = {
[1] = { [1] = {min = 4, max = 6, type = 111}, -- Champions },
},
– group 11 [11] = {
[1] = { [1] = {min = 1, max = 3, type = 14}, -- ArchAngels },
}, } MapNeutrals = { [1] = {group = 1, x = 5, y = 76, rot = 90}, [2] = {group = 2, x = 17, y = 83, rot = 0}, [3] = {group = 3, x = 26, y = 91, rot = 0}, [4] = {group = 4, x = 76, y = 90, rot = 90, u=1}, [5] = {group = 1, x = 80, y = 99, rot = 0}, [6] = {group = 1, x = 55, y = 1, rot = 270, u=1}, [7] = {group = 3, x = 32, y = 44, rot = 0}, [8] = {group = 8, x = 11, y = 37, rot = 180}, [9] = {group = 5, x = 4, y = 82, rot = 90, u=1}, }
– place neutrals on the map CreateCreeps(MapNeutrals, NeutralGroups)
The MapNeutrals table holds the neutral “objects” on the map. You have to specify the position (x, y), if it is underground (u=1 means it’s underground) and the group of the neutrals. The group is a look up in the NeutralGroups table. For example, we see that group 1 spawns two possible neutrals (chosen randomly with equal chance at the start of the map):
1. 50-60 Peasants not mixed with anything 2. 20-30 Conscripts AND 15-35 Brutes mixed neutral stack
The same for the other groups (group 2 is an interesting one, it has a lot of possible “choices” at the start of the map to choose from - some mixed, some not)
(yes, type is the creature ID)
NOTE: it takes some time to generate the neutrals at the start of the map (if there are a lot) - please be patient and wait until you can enter the town - that’s a sign that the neutrals have been successfully added
I hope Map Makers will like to create maps with mixed neutrals from now on (no more Garrisons mixed neutrals only, etc)