Skip to content
#1285
Auto-translated
crazy_kill
How to change the creature growth rate in a castle, or "CreatureHired" using a script and the SetObjectDwellingCreatures function?

Here's a simple example:

SetObjectDwellingCreatures('HeavenTown', CREATURE_ARCHER, GetObjectDwellingCreatures('HeavenTown', CREATURE_ARCHER)+12);
A more complex example (here, the growth rate is increased randomly for a random level of creatures in a town named TOWN_DWARVEN):

dwellingRnd = random(6);
if IsObjectExists(TOWN_DWARVEN) == true then
		if dwellingRnd == 0 then
			dwellingCreatures = 92;
			text = GetMapDataPath()..'dwelling_d01.txt';
		elseif dwellingRnd == 1 then
			dwellingCreatures = 94;
			text = GetMapDataPath()..'dwelling_d02.txt';
		elseif dwellingRnd == 2 then
			dwellingCreatures = 96;
			text = GetMapDataPath()..'dwelling_d03.txt';
		elseif dwellingRnd == 3 then
			dwellingCreatures = 98;
			text = GetMapDataPath()..'dwelling_d04.txt';
		elseif dwellingRnd == 4 then
			dwellingCreatures = 100;
			text = GetMapDataPath()..'dwelling_d05.txt';
		elseif dwellingRnd == 5 then
			dwellingCreatures = 102;
			text = GetMapDataPath()..'dwelling_d06.txt';
		elseif dwellingRnd == 6 then
			dwellingCreatures = 104;
			text = GetMapDataPath()..'dwelling_d07.txt';
		end;
		count = GetObjectDwellingCreatures(TOWN_DWARVEN, dwellingCreatures);
		if count > 0 then
			dwellingCount = count*3;
			SetObjectDwellingCreatures(TOWN_DWARVEN, dwellingCreatures, dwellingCount);
			MessageBox(text);
		else
			print('addDwellingCreatures: Dwelling (creatures id: '..dwellingCreatures..' in Dwarven town not found');
		end;
end;

You can also do this with a mod, but in that case, the growth rate will be increased for all towns on all maps (not recommended :smile28: )

Statistics

Welcome our newest member: Emil

Users Online 4 users 1308 guests