Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
5 years ago
Auto-translated
Good day! I'm very glad that you are working on a map! smile03 There haven't been many "old-school" maps lately. Regarding your question, no, it's not possible. Although, theoretically, you could create an impassable static object with a very dense black cloud model and place it where you need it.
In reply to }{0TT@6bI4
User Avatar
5 years ago
Auto-translated
}{0TT@6bI4
Hello!
I'm very glad that you are working on a map! smile03 There haven't been many "old-school" maps lately. Regarding your question, no, it's not possible. Although, theoretically, you could create an impassable static object with a very dense black cloud model and place it where you need it.

Too bad, thanks for the answer. It's not an option for my idea, as it would put a huge load on the map. I'll have to make do with workarounds.
User Avatar
5 years ago
Auto-translated
You can remove the standard fog of war reveal and implement a custom reveal using a script (with minimal performance impact). This would allow you to determine if a hero is approaching the area of a specific object, and in that case, prevent the fog of war from being revealed. In other words, create a custom reveal range of 7 cells, and if the hero's coordinates are less than or equal to the equation of a circle around the object + 8 cells, then stop revealing the fog of war... Something like a forbidden city with a radius of 8 cells. Would this workaround be suitable?
User Avatar
5 years ago
Auto-translated
The idea is good, but it doesn't suit my needs. I have a general idea of what and how to do, but I was hoping there would be a proper mechanism for the fog of war; it's a pity the developers didn't provide such an option.
User Avatar
5 years ago
Auto-translated
Good day, I haven't worked with combat scripts for a while. I wrote a short and seemingly simple code, but the spell cast doesn't work, and I can't figure out why (I tried it with all light spells, it only works with regeneration; in darkness, it only works with slow; the rest also give errors). I'm asking for help from experts. Example below:
Title
function Start()
local creaturesList = GetAttackerCreatures();
local manaSave = GetUnitManaPoints(GetAttackerHero());
sleep(5);
SetUnitManaPoints(GetAttackerHero(), 500);
for i, target in creaturesList do
UnitCastAimedSpell(GetAttackerHero(), SPELL_BLESS, target);
print("Unit"..GetAttackerHero().."casted".. SPELL_BLESS.." to target"..target);
end;
sleep(5);
SetUnitManaPoints(GetAttackerHero(), manaSave);
startThread(checkWinAttacker);
startThread(checkWinDefender);
sleep(5);
EnableAutoFinish(nil);
end;

function checkWinAttacker()
repeat sleep(1); until length(GetDefenderCreatures()) == 0;

sleep(30);
Finish(ATTACKER);
end;

function checkWinDefender()
repeat sleep(1); until length(GetAttackerCreatures()) == 0;

sleep(30);
Finish(DEFENDER);
end;
User Avatar
5 years ago
Auto-translated
Why not simplify the script and use mass casts? UnitCastGlobalSpell(GetAttackerHero(), SPELL_MASS_BLESS).
function Start()
local mana = GetUnitManaPoints(GetAttackerHero())
SetUnitManaPoints(GetAttackerHero(), 200)
sleep(1)
UnitCastGlobalSpell(GetAttackerHero(), SPELL_MASS_BLESS)
sleep(1)
end

Your script probably lacks sleep commands within the for loop; after all, casting functions take time to execute, and it's a noticeable amount of time.

User Avatar
5 years ago
Auto-translated
The problem remains the same.
Attachments 1
1 file attached • Total size: 3.6 KB
In reply to }{0TT@6bI4
User Avatar
5 years ago
Auto-translated
}{0TT@6bI4
Why not simplify the script and use mass casts? UnitCastGlobalSpell(GetAttackerHero(), SPELL_MASS_BLESS).
function Start()
local mana = GetUnitManaPoints(GetAttackerHero())
SetUnitManaPoints(GetAttackerHero(), 200)
sleep(1)
UnitCastGlobalSpell(GetAttackerHero(), SPELL_MASS_BLESS)
sleep(1)
end

Your script probably lacks sleep commands within the for loop; after all, casting functions take time to execute, and it's a noticeable amount of time.

I won't be able to simplify it because the battle takes place between a hero and an army of neutrals, so buffs have to be cast on the neutrals by the hero.
User Avatar
5 years ago
Auto-translated
But our hero cannot apply the same speed boost to his opponent! This contradicts the game's logic.
In reply to KioM
User Avatar
5 years ago
Auto-translated
KioM
The problem remains the same.
The error message indicates that the spell was cast by a hero on the defending side, but that hero doesn't exist. This is likely caused by an attempt to apply a buff to an enemy.
User Avatar
5 years ago
Auto-translated
So, does that mean I need to emulate casting spells on mobs? Another question: is it possible to cast a spell on a mob, say, Haste, at the expert level without editing the mob itself? Only through a script?
In reply to KioM
User Avatar
5 years ago
Auto-translated
KioM
So, does this mean I need to emulate casting spells for the mobs?

Another question: is it possible to make a mob cast a spell, say, Haste, at an expert level without editing the mob itself? Only through a script.
No, if a creature doesn't explicitly have a spell assigned, it will cast it at the advanced level. If I need a creature to cast a spell under specific conditions or at a specific level, I use hidden creatures with spells explicitly assigned to them. In battle, I summon the hidden creature -> it casts the spell -> I remove the creature. With this scheme, the appearance of the creature remains unnoticed. Example code (a working example from NHF):
-- summon
AddCreature(side, HELPER, 30, -1, -1, nil, 'fiona_sorrow_helper')
while not exist('fiona_sorrow_helper') do
sleep()
end
-- cast
for creature, _ in enemy_stacks_to_sorrow do
pcall(UnitCastAimedSpell, 'fiona_sorrow_helper', SPELL_SORROW, creature)
end
-- remove the creature
removeUnit('fiona_sorrow_helper')
while exist('fiona_sorrow_helper') do
sleep()
end
User Avatar
5 years ago
Auto-translated
No. You can create a special mob with all the spells at the desired levels, summon it, have it cast spells (on your units), and then remove it. This is implemented, for example, in the map "Cursed".
User Avatar
5 years ago
Auto-translated
Gerter, }{0TT@6bI4, Thank you, I will look into it.
In reply to Florkingold
User Avatar
5 years ago
Auto-translated
I don't know if anyone has asked this before, but just in case. How can I make it so that when entering a region, the dialogue plays only once, and upon re-entering the same region, the dialogue no longer opens?

Statistics

Welcome our newest member: recijeb

Users Online 3 users 1597 guests