|
|
I would say go for a thread that checks units in army(ies) and replaces them when necessary.
|
| |
|
|
|
From the HoF campaigns you can copy their script which is :
function transformTroops()
sleep(3);
print("function transformTroops for hero ", heroName ," has started...");
while IsHeroAlive ( heroName ) == true do
for i=1,14 do
creaturesCount = GetHeroCreatures( heroName, i );
if creaturesCount > 0 then
RemoveHeroCreatures( heroName, i, 10000);
n = i;
if mod(i,2) ~= 0 then n = i + 1; end;
AddHeroCreatures( heroName, 105 + (n/2), creaturesCount );
end;
end;
sleep(2);
end;
print("Hero ", heroName, " is dead. Function transformTroops terminated");
end;
startThread(transformTroops)
Just replace heroName in the function by the name of your hero. Follow the pattern if you want to change the creatures ids.
|
| |
|
|
|
There is no single command that replaces units. You first have to determine whether there is X type units at all, then how many of them are there, then remove all them and then add the same number of new creatures. quote: for i=1,14 do -- Haven creatures have code numbers 1-14 (1- peasant, 2- conscript ... 14 archangel) quote: creaturesCount = GetHeroCreatures( heroName, i );
-- determines how many creatures of the type that corresponds to "i" are in heros army. quote: RemoveHeroCreatures( heroName, i, 10000); n = i; if mod(i,2) ~= 0 then n = i + 1; end;
Removes all (unless there is more than 10000 creatures of that type) creatures. mod(i,2) determines whether the creature is base mod(i,2) ~= 0 or upgraded mod(i,2) = 0 quote: AddHeroCreatures( heroName, 105 + (n/2), creaturesCount ); Adds "red" haven units. 105+(n/2) gives you the nummerical code for red haven units.
|
| |
|
|
|
yeah its the internal hero name (see Pitsu h5 scripting guide for the name list). Here is an example for Biara : function transformTroops()
sleep(3);
print("function transformTroops for hero Biara has started...");
while IsHeroAlive ( "Biara" ) == true do
for i=1,14 do
creaturesCount = GetHeroCreatures( "Biara", i );
if creaturesCount > 0 then
RemoveHeroCreatures( "Biara", i, 10000);
n = i;
if mod(i,2) ~= 0 then n = i + 1; end;
AddHeroCreatures( "Biara", 105 + (n/2), creaturesCount );
end;
end;
sleep(2);
end;
print("Biara is dead. Function transformTroops terminated");
end;
startThread(transformTroops)
|
| |
|
|
|
Some advice: 1. Are you sure that it is a singleplayer map, not multiplayer? Multiplayer maps cannot have scripts. To verify it, open your h5m file with winzip or winrar archiver and look whether there is a Singlemission or MultiPlayer directory in it. 2. Note the sleep(3) or sleep(2) lines in the script. Change these values from 3 and 2 to anything higher (one or both of them, lets say to 30 or 20). 3. Try to enable console and see what kind of errormessage it gives at the start of the map. (IIRC instructions for console activations are in one of Editor documents) 4. Copy-paste your script here so that we can see it and point at misspellings or other errors.
|
| |
|