Skip to content

Posts from Scripts

4.8 (8 ratings)
In reply to RedHeavenHero
User Avatar
Auto-translated
Added the `table.copy` function to `lualib`; `math.root` can now calculate the odd root of a negative number, and it no longer freezes. The `string.*` functions now run on average 16 times faster.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
Auto-translated
hello
help me
write a script
basically, its purpose is that
on the battlefield, in the battle window
a certain number of monsters appear
after they are killed, 2 more squads are summoned, and their number is multiplied by 2
the ideal option
is to have a button
to escape
the battle ends, and you receive a prize depending on the number of spawned monsters killed
if this is not possible,
just have a certain number of spawns
I had an idea
the battle ends after you lose more than half of your troops.
In reply to JORAJAN
User Avatar
Auto-translated
JORAJAN
Hello,
please help me write a script.
Basically, the idea is that on the battlefield, in the battle window, a certain number of monsters appear.
After they are killed, 2 more squads are summoned, and their quantity is multiplied by 2.
The ideal option would be to have an escape key pressed,
the battle ends, and you receive a prize depending on the number of spawned enemies killed.
If this isn't possible, just have a certain number of spawns.
Here's another idea:
the battle ends after you lose more than half of your troops.

I don't know about bonuses for the number of enemies killed, but you can see the spawn itself in my map /topic/11089/. (Open the map with an archiver, view the CombatScript.lua file). After the death of n stacks, new, more powerful ones appear there
Кампании для Heroes V 3.1 (Трилогия):

Пробуждение зла
Нашествие из Преисподней
Смена эпох

Скачать все кампании одним архивом: Яндекс.Диск Google.Диск

You can download the set of 3 Campaigns (English version) here


Одиночные сценарии Heroes V 3.1:


Незваные гости
Красный кристалл
Синий кристалл
Закат тьмы

Мультиплеерные карты для Heroes V 3.1:

Легендарная война
Сердце вулкана
Передел мира
In reply to MasteR
Auto-translated
Since I'm a newbie with scripts, I couldn't adapt your script to my map. I tried copying this file into my map and also pasting this text into the map's scripts, but I didn't notice any effect.
User Avatar
Auto-translated
simply copying is not enough, of course. You need to remove all the unnecessary parts, define your own hero instead of the one that's there. Remove global variables or create them in the main script and connect the combat script to the hero.
Кампании для Heroes V 3.1 (Трилогия):

Пробуждение зла
Нашествие из Преисподней
Смена эпох

Скачать все кампании одним архивом: Яндекс.Диск Google.Диск

You can download the set of 3 Campaigns (English version) here


Одиночные сценарии Heroes V 3.1:


Незваные гости
Красный кристалл
Синий кристалл
Закат тьмы

Мультиплеерные карты для Heroes V 3.1:

Легендарная война
Сердце вулкана
Передел мира
Auto-translated
Damn, I thought it would be easier.
Maybe someone has a script that would make a hero appear on the map.
If you defeat him, he would randomly appear on the map with a stronger army, without wandering around.
User Avatar
Auto-translated
I'm working on this combat script: The idea is that, periodically during the battle, a random creature belonging to the player should be affected by the Blindness spell. The composition of the enemy army is unknown in advance. Implementation: I tried to call UnitCastAimedSpell on behalf of enemy creatures during their turn. As it turned out, if the creature is not initially a spellcaster, this command will not execute. I tried a workaround: during the creature's turn (detected via a UnitMove trigger), I summon a spellcasting creature, say a Lich, onto the battlefield using SummonCreature or AddCreature commands, wait for it to appear using sleep commands, cast Blindness with it, and then delete it. All functions are called in the main thread, but as a result, I get a desynchronization of the ATB scale with reality – you look at the properties of a creature on the battlefield, and it says, for example, "Blindness will last 0.5/1 turn." You look at the properties of the same creature through the icon on the ATB scale, and it shows something like "Blindness will last 0.8/1 turn." Because of this, the turn sometimes passes to a creature that is still displayed as blinded on the ATB scale. Has anyone encountered this?
User Avatar
Auto-translated
Hmm, indeed. Previously, following the manuals, I would replenish mana and set a delay of sleep(1), but the spell cast after that wouldn't go through. I increased the delay by an order of magnitude – the creature gained mana, and the spell was cast. However, the desynchronization of the battlefield and the ATB scale remains the same as I described.
Simplified code:
function DefenderCreatureMove(unit)
local last_mana = GetUnitManaPoints(unit);
SetUnitManaPoints(unit, 100);
sleep(30);
local player_units = GetCreatures(ATTACKER);
UnitCastAimedSpell(unit, SPELL_BLIND, player_units[0]);
sleep(1);
SetUnitManaPoints(unit, last_mana);
end


Added 22 minutes later
Although it seems that there is some more general mechanic at play here – when I cast a regular spell with a hero, the remaining duration of its effect also differs if you look at it through the creature on the battlefield and through the icon on the scale. But it occasionally synchronizes.
User Avatar
Auto-translated
Passing the turn to a blinded creature is also possible. However, after a few minutes of inactivity, the turn is passed to the next one.
Here's how I slightly modified it so that the turn isn't given to particularly active units:
function BlindAttackerUnit()
repeat sleep() until combatStarted()
local unit = GetCreatures(DEFENDER)[0]
local last_mana = GetUnitManaPoints(unit);
SetUnitManaPoints(unit, 100);
repeat sleep() until GetUnitManaPoints(unit) == 100
local player_unit = GetCreatures(ATTACKER)[0]
setATB(player_unit, 0)
UnitCastAimedSpell(unit, SPELL_BLIND, player_unit);
sleep(1);
SetUnitManaPoints(unit, last_mana);
end

startThread(BlindAttackerUnit)


Added 1 minute ago
I can't guarantee that it will always work, but just in case, I tested it on dogs.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
Sorry for the simple question, but could you please tell me how to create a NEW_DAY_TRIGGER so that every 14th day of the month, on the surface level, at coordinate x1y1, a caravan named car_1 is created with creatures (for example, with 1 angel) and it travels to the city at coordinates x2y2? And if it's not too much trouble, please write an example of such a trigger... Because it seems like I'm writing everything correctly, but it still doesn't work; maybe there's an error somewhere.
User Avatar
Auto-translated
here is a snippet from my script: ``` k=GetDifficulty(); dd=0; urv=0; function newDayF() dd=GetDate(0); if mod(dd, 14)==0 then OpenCircleFog(1, 59, 1, 4, 1); MoveCamera(1, 59, 1, 50, 1.2, 0, 0, 0); CreateCaravan("Carav"..urv, 1, 1, 1, 59, 1, 12, 21); sleep(2); AddObjectCreatures("Carav"..urv, 131, 20+20*urv+10*(3-k)); AddObjectCreatures("Carav"..urv, 132, 17+17*urv+9*(3-k)); AddObjectCreatures("Carav"..urv, 133, 12+12*urv+6*(3-k)); AddObjectCreatures("Carav"..urv, 134, 6+6*urv+4*(3-k)); AddObjectCreatures("Carav"..urv, 135, 3+3*urv+3*(3-k)); AddObjectCreatures("Carav"..urv, 136, 5+2*urv-k); AddObjectCreatures("Carav"..urv, 137, 1+urv); urv=urv+1; end; end; Trigger(0, "newDayF");
Кампании для Heroes V 3.1 (Трилогия):

Пробуждение зла
Нашествие из Преисподней
Смена эпох

Скачать все кампании одним архивом: Яндекс.Диск Google.Диск

You can download the set of 3 Campaigns (English version) here


Одиночные сценарии Heroes V 3.1:


Незваные гости
Красный кристалл
Синий кристалл
Закат тьмы

Мультиплеерные карты для Heroes V 3.1:

Легендарная война
Сердце вулкана
Передел мира
User Avatar
Auto-translated
Please tell me how to make it so that building a Grail changes the weekly effects (using scripts or a patch for Heroes of Might and Magic V - anything works).
For example, I want to make it like in Heroes of Might and Magic III: when Inferno builds a Grail, instead of getting bonuses to magic and other things, each week would be a "demon week."
I think I need to look at the weekly effect in the files (like with the astrologer option).
User Avatar
Auto-translated
The effect of the weekly demon event can be simulated with scripts, but the event itself will remain as it should be.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
In reply to MasteR
User Avatar
Auto-translated
MasteR
Here's a snippet from my script:

k=GetDifficulty();
dd=0;
urv=0;
function newDayF()
dd=GetDate(0);
if mod(dd, 14)==0 then
OpenCircleFog(1, 59, 1, 4, 1);
MoveCamera(1, 59, 1, 50, 1.2, 0, 0, 0);
CreateCaravan("Carav"..urv, 1, 1, 1, 59, 1, 12, 21);
sleep(2);
AddObjectCreatures("Carav"..urv, 131, 20+20*urv+10*(3-k));
AddObjectCreatures("Carav"..urv, 132, 17+17*urv+9*(3-k));
AddObjectCreatures("Carav"..urv, 133, 12+12*urv+6*(3-k));
AddObjectCreatures("Carav"..urv, 134, 6+6*urv+4*(3-k));
AddObjectCreatures("Carav"..urv, 135, 3+3*urv+3*(3-k));
AddObjectCreatures("Carav"..urv, 136, 5+2*urv-k);
AddObjectCreatures("Carav"..urv, 137, 1+urv);
urv=urv+1;
end;
end;

Trigger(0, "newDayF");


Thank you so much, it finally worked!).
And if it's not too much trouble, could you show me an example of any working QuestionBox script? Because I'm having the same problems as with the caravan, and I can't figure out what's wrong... Thank you in advance.

Statistics

Welcome our newest member: Emil