green belly, generally speaking, this isn't the thread where such things are discussed (after all, this thread is specifically for scripts), but still: in what sense are your combat scripts(?) and console not working? Is the system preventing you from editing game files?
Regarding percentages — I haven't actually worked with them, but I assume that since we have a 25% deduction here, which won't always be a whole number (for example, the calculation might yield 0.25 or 0.75), it is advisable to perform this calculation so that a whole number always remains. For instance, let's take the ceil(n) command, which returns the nearest integer rounded up (so that even 1 unit can be removed with this code). It would look something like this:
function procent( heroName )
if heroName == "Alaric" then
RemoveHeroCreatures("Alaric", 110, ceil(0.25*GetHeroCreatures("Alaric", 110)))
RemoveHeroCreatures("Alaric", 111, ceil(0.25*GetHeroCreatures("Alaric", 111)))
RemoveHeroCreatures("Alaric", 112, ceil(0.25*GetHeroCreatures("Alaric", 112)))
end
end
Trigger( PLAYER_ADD_HERO_TRIGGER, PLAYER_2, "procent" )
Alaric somehow becomes the blue player (either hired or transferred via script), and 25% of his units will be subtracted (provided they are already in his army. Otherwise, the script will throw an error due to their absence). But this is simple code that will work specifically for these creatures if they already exist, like if we just need to weaken a conditional map "boss". If you need an actual list of creatures to be cut, and more than once per scenario, it's better to create an array with IDs that is run through a for loop, and then calculate who can be subtracted and who cannot. Something like this:
function procent( heroName )
if heroName == "Alaric" then
units = {106, 107, 108, 109, 110, 111, 112} --тут у нас список ID существ, которых будет проверять и удалять. Для теста вписал всех красных юнитов
procent_units = length(units)
for i = 1, procent_units do
ready_to_reduce = GetHeroCreatures( "Alaric", units)
if ready_to_reduce > 0 then
print("Отнимем ", ceil(0.25*GetHeroCreatures( "Alaric", units)) ," из существ ", units)
RemoveHeroCreatures("Alaric", units, ceil(0.25*GetHeroCreatures( "Alaric", units)))
end
sleep(2)
end
end
end
Trigger( PLAYER_ADD_HERO_TRIGGER, PLAYER_2, "procent" )
It will turn out that even upon repeated hiring by the blue player, Alaric will lose creatures. Well, this is just for your information; you can edit it to suit your needs :)
As for the rest:
1) I think you should put all heroes (that can be hired in the tavern) into reserve, list them in an array, randomly choose which one of them to spawn, and then bring everyone out of reserve. Well, that's probably possible, though I don't know how the tavern will work with such heroes.
2) And what did you write? Stats are checked via GetHeroStat(heroName, STAT_)
3) If the game doesn't launch, most likely you have a texture setting that is incompatible with the game engine. It simply cannot process it and crashes on startup. Open one existing in the game and compare it with yours. Specifically, try saving with different parameters so that your texture size becomes equal to or very close to the original
4) Try editing the spell configs, maybe it'll speed up) Just not in the original resource folder, but in your own, like for a mod. Don't touch the original data and its patched versions)
5) There was info on tables, either here or in general questions about the editor. Perhaps it's in Hottabych's group among the documents) Another option — it's embedded with the script editor files (by the way, I recommend using them, they help)