Skip to content

Posts from NHF – new heroes for Heroes V 3.1.

4.9 (16 ratings)
User Avatar
Auto-translated
Hmm... I'm not sure, but when creating maps for single-player mode, I always put `sleep()` after creating something (a monster, a caravan, etc.) or after placing a hero on the map. Otherwise, the next function won't see the created object and will cause an error, and it always happens. Many functions behave this way, and maybe all of them do.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
Everything is bad here)))
But why is it different in the multiplayer version?
Is it to prevent desynchronization?

Added after 43 seconds
Then, make it sleep(time), where time is higher if it's a single-player game?

Added after 2 minutes
For example, I tested sleep() and sleep(0.1), and sleep(1)
The first one sometimes doesn't have enough time. The second one is good, the third one is too long))
Does it really discard the decimal? Something is wrong here. Multiplayer.
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...
User Avatar
Auto-translated
For example, I tested sleep() and sleep(0.1), and sleep(1).
The first one sometimes doesn't have enough time. The second one is fine, the third one takes too long.))
Does it really discard the decimal part? Something's not right here. Multithreading.
sleep() is analogous to sleep(1).
sleep(0.1) is analogous to sleep(intg(0.1)), i.e., sleep(0).
I just tried a simple script:
for i=1,1000 do
print(""..i)
sleep(1)
print(""..i)
sleep(.999)
end

Mode: network. The numbers appear in pairs - blue i-1 and red i - with an interval of 1/5 second.
If sleep accepted decimal values, the numbers would appear one at a time.

Added after 48 minutes
Here's a more illustrative example.
while 1 do
local effect = "/Effects/_(Effect)/Spells/Bloodlust.xdb#xpointer(/Effect)"
for i=1,20 do
PlayVisualEffect(effect, '', '', 24+i, 20)
sleep(.999)
end
for i=1,20 do
PlayVisualEffect(effect, '', '', 24+i, 24)
sleep(1)
end
sleep(20)
end
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
Should we check the replays for differences in single-player and multiplayer modes? Or perhaps the functions?
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...
User Avatar
Auto-translated
What prevents placing `sleep(1)` after creating an elf?

Added after 32 seconds
The image shows a multiplayer game.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
So, you'll have to do that after creating each one.
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...
User Avatar
Auto-translated
Why after each one? ) After you add all the new names to the array, right? Or did you do it differently?
 

К А
Стикеры GBF в Telegram
In reply to Dyrman
User Avatar
Auto-translated
Dyrman
You'll have to do that after creating each one.
You can create them all first, wait, and then apply triggers to all the created ones.

Added 4 minutes later
Ment
Why after each one? ) After you've added all the new names to the array, right? Or did you do it differently?
I don't see the point in storing all the names in an array, unless it's a temporary one for newly created ones.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
Yes, actually, they aren't needed; a sequential number is sufficient.
 

К А
Стикеры GBF в Telegram
In reply to Ment
User Avatar
Auto-translated
For example, you can do it like this:
----------------KIINA---------------------
NHF_Kiina_week = 0;
--NHF_Kiina_mass = {};
NHF_Kiina_mass_i = 0;
NHF_Kiina_mass_i_bad = 0;
NHF_Kiina_mass_preserv_creature = {{{44,145},{46,146},{48,147},{50,148},{52,149},{54,150},{56,151}},{10,9,7,4,3,2,1}};
function error_NHF_Kiina_F ()
print("error:NHF_Kiina_F");
end;
function NHF_HERO_F.Kiina (hero, mob)
errorHook(error_NHF_Kiina_F);
if hero then
NHF_Kiina_frendly_F(hero, mob)
return
end
if NHF_Kiina_week < ceil(GetDate(ABSOLUTE_DAY)/7) then
NHF_Kiina_week = ceil(GetDate(ABSOLUTE_DAY)/7);
local SizeMap = GetTerrainSize();
local count_mob = NHF_Kiina_mass_i_bad + (GetHeroLevel("Kiina")*NHF_Kiina_persent);
local temp_name = NHF_tempName_F("Kiina")
NHF_Kiina_mass_i_bad = 0;
local new_mobs = {n=0}
for i = 0, count_mob do
local x = random(SizeMap);
local y = random(SizeMap);
local z = random(GetMaxFloor()+1);
if IsTilePassable(x,y,z) == true then
NHF_Kiina_mass_i = NHF_Kiina_mass_i + 1;
local lvl_creature = floor((GetHeroLevel("Kiina")/5)+1)+random(3);
if lvl_creature > 7 then
lvl_creature = 7;
end;
local ID_creature = NHF_Kiina_mass_preserv_creature[1][lvl_creature][random(2)+1];
local name = "NHF_Kiina_creatures_"..NHF_Kiina_mass_i;
new_mobs.n = new_mobs.n + 1
new_mobs[new_mobs.n] = name
CreateMonster(name, ID_creature, NHF_Kiina_mass_preserv_creature[2][lvl_creature],x,y,z, MONSTER_MOOD_AGGRESSIVE, MONSTER_COURAGE_ALWAYS_FIGHT,(random(360)));
else
NHF_Kiina_mass_i_bad = NHF_Kiina_mass_i_bad +1;
end;
end;
sleep()
for i = 1, new_mobs.n do
local name = new_mobs
PlayVisualEffect("/Effects/_(Effect)/Objects/Water/Siren.(Effect).xdb#xpointer(/Effect)", name, name.."_Effect_Tag");
SetObjectEnabled(name, nil);
SetTrigger(OBJECT_TOUCH_TRIGGER, name, "NHF_Touch_mobs_F");
end
ShowFlyingSign("/MapObjects/Preserve/NewHeroes/Kiina/Spawn_creatures.txt",temp_name,GetObjectOwner(temp_name), 5);
end;
end;
function NHF_Kiina_frendly_F(hero,mob)
local temp_name = NHF_tempName_F(hero);
if (IsAIPlayer(GetObjectOwner(temp_name)) ~= 1) and (hero == "Kiina") and mob > "NHF_Kiina_creatures_" and mob < "NHF_Kiina_creatures`" then
SetMonsterCourageAndMood(mob, GetObjectOwner(temp_name), MONSTER_MOOD_FRIENDLY, MONSTER_COURAGE_ALWAYS_JOIN);
end;
end;


NHF_mass_heroes_touch_mob = {"Hafad","Sandro","Fiona","Konstantin","Kiina"};


--Disabling and touching mobs
function NHF_Touch_mobs_F(hero,mob)
if (IsAIPlayer(GetObjectOwner(hero)) ~= 1) and (IsObjectExists(mob) == not nil) then
for i, hero_temp in NHF_mass_heroes_touch_mob do
if IsHeroAlive(hero_temp) == true then
if (hero == hero_temp) then
NHF_HERO_F[hero_temp](hero_temp,mob);
break;
end;
end;
end;
if mob > "NHF" and mob < "NHG" then
StopVisualEffects(mob.."_Effect_Tag");
end
Trigger(OBJECT_TOUCH_TRIGGER, mob, nil);
SetObjectEnabled(mob,true);
sleep(0.1);
MakeHeroInteractWithObject(hero,mob);
--sleep();
Trigger(OBJECT_TOUCH_TRIGGER, mob, "NHF_Touch_mobs_F");
end;
end;
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
Thank you. However, I don't like moving the effect deactivation into a general function: ``` if mob > "NHF" and mob < "NHG" then StopVisualEffects(mob.."_Effect_Tag"); end ``` Besides, I think it would be better to use: ``` if mob > "NHF_Kiina_creatures_" and mob < "NHF_Kiina_creatures`" then StopVisualEffects(mob.."_Effect_Tag"); end ``` In case there are new specialists for certain creatures or if we need to create creatures on the map. Perhaps we should revert to always removing the effect, but if the creature remains (our hero merged with the creatures), we add it back. Or was this done specifically because of delays? But then we would need to store the battle result as well.
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...
User Avatar
Auto-translated
The effect is disabled only because the NHF_Kiina_frendly_F function is called only if the hero is Kiina (to avoid breaking the system); otherwise, the effect would not be disabled.
StopVisualEffects does not raise an error if there are no effects, so a check is not necessary.

Effects do not need to be disabled while the mob exists.
function NHF_RemoveMobEffects(hero, mob)
while IsObjectExists(hero) and IsObjectExists(mob) do
sleep()
end
if not IsObjectExists(mob) then
StopVisualEffects(mob .. "_Effect_Tag")
end
end

function NHF_Touch_mobs_F(hero,mob)
-- ... --
if mob > "NHF" and mob < "NHG" then
startThread(NHF_RemoveMobEffects, hero, mob)
end
-- ... --
end
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
The added heroes stubbornly refuse to trade. A turn is wasted, and nothing else happens. Sometimes, it is impossible to view information about your own hero. When passing the turn, information about the opponent's hero is displayed.
Nulla è reale, tutto è lecito.
User Avatar
Auto-translated
I've encountered this issue occasionally even without NHF. I suspect that some other mod you have installed might be the cause.
User Avatar
Auto-translated
No, I installed it on a clean system. Without NHF, this didn't happen.
Nulla è reale, tutto è lecito.

Statistics

Welcome our newest member: Emil