Skip to content
User Avatar
#3518
Auto-translated
}{0TT@6bI4
Hello. I tested your script variant, making a few changes. It works. But I recommend using a more convenient way to iterate through the array:

for key, id in enemy_creatures do
if GetHeroCreatures(hero, id)>=1 then
counter = counter - 1
end
end

 

Hello! I tested it, and for some reason, the more convenient version works correctly for me, while the first one gives an incorrect number. By the way, I tested it in the "extended" version of my script, that is...
reputation = 0;
player_heroes = { "RedHeavenHero03", "RedHeavenHero02" }
enemy_creatures = { 106, 107, 108, 109, 110, 111, 112, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28 }
friend_creatures = { 600, 601, 602, 603, 604, 605, 606, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }

function conditions()
print("reputation = ", reputation );
for h, heroes in player_heroes do
for e, enemy in enemy_creatures do
for f, friend in friend_creatures do
if GetHeroCreatures(heroes, enemy) > 0 and GetHeroCreatures(heroes, enemy) <= 99 then
reputation = reputation - 1
sleep(1)
elseif GetHeroCreatures(heroes, enemy) >= 100 then
reputation = reputation - 2
sleep(1)
elseif GetHeroCreatures(heroes, friend) > 0 then
reputation = reputation + 1
end
end
end
end
end

And here's what's strange. I have Valeria and Lorenzo (Knights from the array) on the map, and Valeria is also in reserve (this is kind of a bug, because for the reserve, she shouldn't be on the map initially. So I don't know if her presence in the reserve affects the script that checks the heroes' armies), and I test it like this: I give Valeria in reserve a green archangel and a paladin (which are in the array as "friends" for which +1 reputation per unit is added), and the one on the map only has a green archangel (+1 reputation), and Lorenzo has 40 land lords, 50 archers, 20 zealots, 10 combat griffins, 6 adepts, 4 knight isabelles, and 2 fallen angels. In total, Lorenzo should give -7 reputation, because each red creature is -1 and none of them are more than 100, but for some reason, the counter goes crazy, giving me -126 points. And it also starts to go crazy if I dismiss all creatures from Lorenzo except, for example, 40 land lords. Then it will gradually decrease the counter to a small negative number (16-36), and then completely reset it.

 

In general, my idea is this: the player will have a counter called reputation, which: decreases for "bad" creatures and increases for "good" ones, and I plan to add some more factors in the future, such as capturing treasure vaults owned by a certain player, a battle with "good" creatures (which I already asked about before, but haven't implemented yet). In general, I would like to put all this system with the counter into one function, but I don't know if this is a good idea. So, I need help  

Statistics

Welcome our newest member: leyu