EDIT2:Uppdate of instructions below script.
Ok, this is what I have been enjoying my life with for a couple of days, eh, nights

I saw Asheeras random monster generator a couple of months back http://www.celestialheavens.com/forums/ ... om+monster, just when I had started to learn scripting - and it was just too complicated then

Now when I have a little bit more knowledge of scripting I looked at it again a couple of days ago and thought, great thing! It is just one thing, it places the monsters on the map totally random and I'm in need of control

The script will look messy here in the forum but just copy and paste it to your script editor. I have put some instructions and notes below the script that is important to read.
Code: Select all
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ COPY AND PASTE IN BEGINNING OF SCRIPT ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff = GetDifficulty()+1; -- 1=easy, 2=normal, 3=hard, 4=heroic
creaturetable = {{{1,2,106},{3,4,107},{5,6,108},{7,8,109},{9,10,110},{11,12,111},{13,14,112}}, -- haven=[1]
{{15,16,131},{17,18,132},{19,20,133},{21,22,134},{23,24,135},{25,26,136},{27,28,137}}, -- inferno=[2]
{{29,30,152},{31,32,153},{33,34,154},{35,36,155},{37,38,156},{39,40,157},{41,42,158}}, -- necro=[3]
{{43,44,145},{45,46,146},{47,48,147},{49,50,148},{51,52,149},{53,54,150},{55,56,151}}, -- sylvan=[4]
{{57,58,159},{59,60,160},{61,62,161},{63,64,162},{65,66,163},{67,68,164},{69,70,165}}, -- academy=[5]
{{71,72,138},{73,74,139},{75,76,140},{77,78,141},{79,80,142},{81,82,143},{83,84,144}}, -- dungeon=[6]
{{92,93,166},{94,95,167},{96,97,168},{98,99,169},{100,101,170},{102,103,171},{104,105,172}}, -- fortress=[7]
{{117,118,173},{119,120,174},{121,122,175},{123,124,176},{125,126,177},{127,128,178},{129,130,179}}, -- stronghold=[8]
{{113,113,113},{113,113,113},{88,88,88},{87,85,86},{116,116,116},{89,115,89},{91,91,91}}}; -- neutrals=[9]
function monsterGenerator()
local strenght = diff*0.8; -- variable for group strenght. Increase/decrease "0.8" for more/less creatures
local groups = 9; -- Change this value to the amount of "groups" you put on map
local factions = {}; -- stores placed creatures faction (objectName) to make right kind of addition
local tierqty = 0; -- variable for amount of tiers that should be added (total groups divided with total tiers)
local tier1 = 22; -- base amount of creatures/tier
local tier2 = 16; -- ''
local tier3 = 11; -- ''
local tier4 = 7; -- ''
local tier5 = 4; -- ''
local tier6 = 2; -- ''
local tier7 = 1; -- ''
for i=1,groups do
for j=1,9 do
factions[i] = GetObjectCreaturesTypes("gr"..i);
tierqty = groups/7;
if factions[i] == creaturetable[j][1][1] then
if i < tierqty then
AddObjectCreatures("gr"..i, creaturetable[j][1][1+random(3)], tier1+intg(i/tierqty*strenght*tier1));
sleep(1);
RemoveObjectCreatures("gr"..i, creaturetable[j][1][1], 1);
elseif i > tierqty and i < tierqty*2 then
AddObjectCreatures("gr"..i, creaturetable[j][1][1+random(3)], tier1+intg(i/tierqty*strenght*tier1));
sleep(1);
RemoveObjectCreatures("gr"..i, creaturetable[j][1][1], 1);
AddObjectCreatures("gr"..i, creaturetable[j][2][1+random(3)], tier2+intg(i/tierqty*strenght*tier2));
elseif i > tierqty*2 and i < tierqty*3 then
AddObjectCreatures("gr"..i, creaturetable[j][1][1+random(3)], tier1+intg(i/tierqty*strenght*tier1));
sleep(1);
RemoveObjectCreatures("gr"..i, creaturetable[j][1][1], 1);
AddObjectCreatures("gr"..i, creaturetable[j][2][1+random(3)], tier2+intg(i/tierqty*strenght*tier2));
AddObjectCreatures("gr"..i, creaturetable[j][3][1+random(3)], tier3+intg(i/tierqty*strenght*tier3));
elseif i > tierqty*3 and i < tierqty*4 then
AddObjectCreatures("gr"..i, creaturetable[j][1][1+random(3)], tier1+intg(i/tierqty*strenght*tier1));
sleep(1);
RemoveObjectCreatures("gr"..i, creaturetable[j][1][1], 1);
AddObjectCreatures("gr"..i, creaturetable[j][2][1+random(3)], tier2+intg(i/tierqty*strenght*tier2));
AddObjectCreatures("gr"..i, creaturetable[j][3][1+random(3)], tier3+intg(i/tierqty*strenght*tier3));
AddObjectCreatures("gr"..i, creaturetable[j][4][1+random(3)], tier4+intg(i/tierqty*strenght*tier4));
elseif i > tierqty*4 and i < tierqty*5 then
AddObjectCreatures("gr"..i, creaturetable[j][1][1+random(3)], tier1+intg(i/tierqty*strenght*tier1));
sleep(1);
RemoveObjectCreatures("gr"..i, creaturetable[j][1][1], 1);
AddObjectCreatures("gr"..i, creaturetable[j][2][1+random(3)], tier2+intg(i/tierqty*strenght*tier2));
AddObjectCreatures("gr"..i, creaturetable[j][3][1+random(3)], tier3+intg(i/tierqty*strenght*tier3));
AddObjectCreatures("gr"..i, creaturetable[j][4][1+random(3)], tier4+intg(i/tierqty*strenght*tier4));
AddObjectCreatures("gr"..i, creaturetable[j][5][1+random(3)], tier5+intg(i/tierqty*strenght*tier5));
elseif i > tierqty*5 and i < tierqty*6 then
AddObjectCreatures("gr"..i, creaturetable[j][1][1+random(3)], tier1+intg(i/tierqty*strenght*tier1));
sleep(1);
RemoveObjectCreatures("gr"..i, creaturetable[j][1][1], 1);
AddObjectCreatures("gr"..i, creaturetable[j][2][1+random(3)], tier2+intg(i/tierqty*strenght*tier2));
AddObjectCreatures("gr"..i, creaturetable[j][3][1+random(3)], tier3+intg(i/tierqty*strenght*tier3));
AddObjectCreatures("gr"..i, creaturetable[j][4][1+random(3)], tier4+intg(i/tierqty*strenght*tier4));
AddObjectCreatures("gr"..i, creaturetable[j][5][1+random(3)], tier5+intg(i/tierqty*strenght*tier5));
AddObjectCreatures("gr"..i, creaturetable[j][6][1+random(3)], tier6+intg(i/tierqty*strenght*tier6));
elseif i > tierqty*6 then
AddObjectCreatures("gr"..i, creaturetable[j][1][1+random(3)], tier1+intg(i/tierqty*strenght*tier1));
sleep(1);
RemoveObjectCreatures("gr"..i, creaturetable[j][1][1], 1);
AddObjectCreatures("gr"..i, creaturetable[j][2][1+random(3)], tier2+intg(i/tierqty*strenght*tier2));
AddObjectCreatures("gr"..i, creaturetable[j][3][1+random(3)], tier3+intg(i/tierqty*strenght*tier3));
AddObjectCreatures("gr"..i, creaturetable[j][4][1+random(3)], tier4+intg(i/tierqty*strenght*tier4));
AddObjectCreatures("gr"..i, creaturetable[j][5][1+random(3)], tier5+intg(i/tierqty*strenght*tier5));
AddObjectCreatures("gr"..i, creaturetable[j][6][1+random(3)], tier6+intg(i/tierqty*strenght*tier6));
AddObjectCreatures("gr"..i, creaturetable[j][7][1+random(3)], tier7+intg(i/tierqty*strenght*tier7));
end;
end;
end;
end;
end;
startThread(monsterGenerator);
This monster generator purpous is to make the script do the most time consuming work when placing armies on your map. All you have to do is to put tier 1 monsters of the lowest rank on your map on the locations you choose. When you have set it, mark it and hit the space-bar, set the the amount to custom 1 (this prevents unexpected high amounts if it's set to random). Close the box and then give the monster the script name, "gr1". Repeat this procedeur with all monsters but give the next one the name "gr2" and thereafter "gr3" and so on.
Change the local variable 'groups' in the script to the same number as your last monster (total monsters).
The theory is that the higher the number is in the monsters script names the stronger it will get when the generator runs. This feature does that you have control of the strenght of the armies. Start putting monsters at the "beginning" of your map and continue to the "end" of it.
Uppdate, more details abouth group strenght: The difference in strenght between the first and last group is always the same despite how many groups you put on map. If you want to cange the total strenght of the armies, change the strenght-variable in the script. If you want different strenght over the "timeline", change the base value variables.
You can choose any factions you want and the generator will handle the different ones, but it only put additional monters from the same faction in the army. NOTE: for neutrals (elementals etc) I have coosen the wolf as the lowest ranked creature.
All the tiers uppgrades will be randomly mixed.
Ask as many questions as you want and I'll try to help the best I can. If someone have any ideas of changes - please tell me.

Good luck,
Jonas