Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
Auto-translated
SetAIHeroAttractor("DungeonTown", "Oddrema", 2);

You specify the town, the hero, and the priority. 2 is the highest (meaning it will try to capture it regardless of the risk of dying).

It looks good, but it doesn't always work as expected.
However, the fact that it works has been verified by me personally in the map "Astralia" :D
Всё, что сейчас происходит во мне, тоже является частью Вселенной. (с) Иванов Александр.
Цикл кампаний "Дыхание Смерти" из трёшки в четвёртом исполнении
Учебная карта
Астралия
За Королеву!
Подземелья и Дьяволы
Отголоски войны
Освобождение
In reply to Победитель
User Avatar
Auto-translated
After the cutscene, I need to teleport the "Enabled" hero to another position.
SetObjectPosition ;) this is the function for teleporting.
And with the attractor: it should apply to disabled heroes. Will they move on the next turn, or do I need to enable them somehow?
Just enable them in this trigger. They won't go anywhere during the player's turn anyway. And on the next turn, they will move towards the town.
Клан "Вершители Асхана" - "Masters of Ashan"
User Avatar
Auto-translated
Quant
But the fact is that it works, and I personally verified it in the map "Astralia".
I don't know how it works for you in Astralia, but I did something similar in Gnomania. It worked in 90% of cases, but in 10% of cases, the computer moved in the opposite direction. I had to add the MoveHero function. That's how it is.
 

К А
Стикеры GBF в Telegram
User Avatar
Auto-translated
So, in the first batch, everything worked except for the AI attractor. They run wherever they want. Is there no other way? And, before the battle starts, could a message pop up?

Part two. I need the following: when you approach a unit, a message pops up, the unit disappears from the map, and troops are added to your army. It's a specific hero. Second: when you defeat a monster, a message pops up.

And finally, the last thing: quests. The first one doesn't have much meaning and sounds like this: reach the road to Al-Safir. Just so it appears and is considered completed after the trigger with the cutscene in the previous part. Two more: the main one is to kill the enemy hero, and the secondary one is to collect groups of creatures from the map (this also includes the previous scripts for adding them to the army). How can this be done? Please help!
Карты для Heroes of Might and Magic V
Цикл "Закадычные враги": "Особенное гостеприимство, "Супероружие", "Меж молотом и наковальней"
"Падение Шантири"

Кампания для "Кодекса Войны"
"Выбор Сагиттеля"
User Avatar
Auto-translated
Gilraen
Okay, out of the first batch, everything worked except for the AI attractor. They run wherever they want.
This was predictable. If possible, it should be replaced with MoveHero(hero,x,y);
Gilraen
And, before the battle starts, a message should pop up?
I would set a "town" region so that it needs to be crossed before attacking the town. Then:
function show_mes(hero)
if hero=="EnemyHero" then
MessageBox(GetMapDataPath().."mes.txt");
end;
end;
Trigger(REGION_ENTER_WITHOUT_STOP_TRIGGER,"town","show_mes");
Gilraen
I also need this: you approach a unit, a message pops up, the unit disappears from the map, and troops are added to your army. + collect groups of creatures from the map.
function Add(hero)
if hero=="YourHero" then
MessageBox(GetMapDataPath().."mes2.txt");
AddHeroCreatures("YourHero",CR_ID,QUANTITY);
k=k+1;
if k==n then --number of creatures to collect
SetObjectiveState("Obj",OBJECTIVE_COMPLETED);
end;
end;
end;
SetObjectEnabled("monster",nil);
Trigger(OBJECT_TOUCH_TRIGGER,"monster","Add");
Gilraen
Second: you defeat a monster and a message pops up.
You can simply write a script in the monster's properties, in the script tab. Write MessageBox there, and that's it.
Gilraen
Just so that it appears and is marked as completed after the trigger with the video in the previous part.
SetObjectiveState("PrimObj0",OBJECTIVE_COMPLETED);--completion
SetObjectiveState("PrimObj0",OBJECTIVE_ACTIVE);--appearance
Gilraen
kill an enemy hero
There is a standard task for that -- Defeat Hero.
 

К А
Стикеры GBF в Telegram
User Avatar
Auto-translated
Thanks, I'll try in the evening. I just didn't quite understand how to add creatures – what are the variables k and n, and what does CREATURE_ID look like?
Карты для Heroes of Might and Magic V
Цикл "Закадычные враги": "Особенное гостеприимство, "Супероружие", "Меж молотом и наковальней"
"Падение Шантири"

Кампания для "Кодекса Войны"
"Выбор Сагиттеля"
User Avatar
Auto-translated
k -- the number of joined units. n -- the number required to complete the task.
CREATURE_ID -- the creature's ID (can be found in the ID's_for_script.pdf file or something similar).
 

К А
Стикеры GBF в Telegram
User Avatar
Auto-translated
Okay. Regarding SetObjectEnabled – this doesn't make the unit disappear, but I need it to disappear (the hero revives dead warriors, and they join him). The task is as follows: two revived groups and three recruited groups. Revived: Thunderbirds, Mages; recruited: Golems, Mages, Thunderbirds. Is it possible to combine them into one variable? And where can I find DefeatHero?

Tasks. Does SetObjectiveState need a function? Does it work just like that? And how do I add a description to the task?
Карты для Heroes of Might and Magic V
Цикл "Закадычные враги": "Особенное гостеприимство, "Супероружие", "Меж молотом и наковальней"
"Падение Шантири"

Кампания для "Кодекса Войны"
"Выбор Сагиттеля"
User Avatar
Auto-translated
Yes, I forgot... `RemoveObject('monster')` – removes the object. Regarding resurrection, please provide more details. `DefeatHero` – in the map properties tree, under objectives, objective kind. `SetObjectiveState` works like this. Objective description – objectives, objective description.
 

К А
Стикеры GBF в Telegram
User Avatar
Auto-translated
Regarding resurrection – this is a plot point. But here’s what else I need. Move Hero: can it be made to work on the opponent’s turn, or the day after the item is received? How can I make it so that player heroes don’t have action points? And the collection quest: it’s completed when the triggers for the message and joining are activated – how do I write that?

Wow, so much work for such a small map! Should I somehow diversify it? And thank you, Ment, Ser9K.
Карты для Heroes of Might and Magic V
Цикл "Закадычные враги": "Особенное гостеприимство, "Супероружие", "Меж молотом и наковальней"
"Падение Шантири"

Кампания для "Кодекса Войны"
"Выбор Сагиттеля"
User Avatar
Auto-translated
Gilraen
Move Hero: is it possible to make it work on the opponent's turn, or on the day after the item is received?
MoveHero always works on the opponent's turn. Don't confuse it with MoveHeroRealTime ;)
Gilraen
How do I make it so that player heroes don't have movement points?
x=-GetHeroStat("EnemyHero",STAT_MOVE_POINTS);
ChangeHeroStat("EnemyHero",STAT_MOVE_POINTS,x);
Gilraen
And the collection quest: it's completed when the triggers for the message and joining have triggered: how do I write that?
If I understand correctly, it's already written, see earlier. It checks if k and n are equal. If they are equal, the "Obj" quest is completed.
 

К А
Стикеры GBF в Telegram
User Avatar
Auto-translated
My MessageBox isn't working. Never mind, I'll figure it out.

Is there a way to describe how to set up a quest in as much detail as possible? A simple one, without any specific meaning, just entering a region where the text for the quest is displayed? And how do I configure DefeatHero: description, activation, and so that a video plays and the mission ends upon completion?

Now, about other maps. I'm curious, how does "Summon Ilm-Hijra" from Tribes of the East work? Is it about moving objects?

And how do I take troops away from a hero? I just want to prepare a special map for November of this year (a little hint: what will happen in November?), and the main part of it should also be scripted. And what I said is the most important thing. Can you help me?
Карты для Heroes of Might and Magic V
Цикл "Закадычные враги": "Особенное гостеприимство, "Супероружие", "Меж молотом и наковальней"
"Падение Шантири"

Кампания для "Кодекса Войны"
"Выбор Сагиттеля"
User Avatar
Auto-translated
Gilraen
Something isn't working with my MessageBox.
I also had to figure it out for a long time. The problem was that I was typing messages in Notepad, and it automatically chooses the wrong format. Anyway, take a look at this topic; it has everything written about MessageBox.
Gilraen

Is it possible to describe in as much detail as possible how to set a task?
Do you mean, including the name and description of the task? Or did I misunderstand? Because the scripting part is exhausted by the SetObjectiveState function. You can also sometimes use SetObjectiveProgress.
Gilraen
How to configure DefeatHero: description, launch, and so that a video plays and the mission ends upon completion?
Here's how (+screenshot):

function P0_end()
StartDialogScene("bla-bla");
Win(1);
end;

function P0_start()
SetObjectiveState("P0",OBJECTIVE_ACTIVE);
Trigger(OBJECTIVE_STATE_CHANGE_TRIGGER,"P0","P0_end");
end;

Trigger(Trigger Type, parameters,"P0_start");
Gilraen
It's interesting how "Summon Ilm-Hijdra" from Lords works. Is it moving objects?
Yes, it seems to be a scripted spell that moves an object. Although I didn't delve into the script there.:)
Gilraen
And how do you take troops away from a hero?
Manualchik
RemoveHeroCreatures(heroname, creatureID, quantity);
I advise you to check the source mentioned above more often. It's a really great thing – I don't understand why people ignore it ;)
Attachments 1
1 file attached • Total size: 139.4 KB
 

К А
Стикеры GBF в Telegram
User Avatar
Auto-translated
Oh my God! This MoveHero doesn't work either!! I can understand these two heroes – no one wants to die, but they should still work with scripts!!! My enemy heroes either do whatever they want (until I set up blocks) or just stand there (like in the last three cases). I've already tried calling them with MoveHero and attracting them with AiAttractor, but no – they're just stubborn!
Карты для Heroes of Might and Magic V
Цикл "Закадычные враги": "Особенное гостеприимство, "Супероружие", "Меж молотом и наковальней"
"Падение Шантири"

Кампания для "Кодекса Войны"
"Выбор Сагиттеля"
In reply to Победитель
User Avatar
Auto-translated
Gilraen
Oh Lord! This MoveHero doesn't work either!! I can understand these two heroes – no one wants to die, but they should work with scripts!!! My enemy heroes either do whatever they want (until I set up blocks) or just stand there (like in the last three cases). I've already tried calling them with MoveHero and attracting them with AiAttractor, but no – they're stuck!
From a fan-made scripting guide:
if you want the
computer player to rush to a certain object on the map and only follow a
specific path, block all other paths and give that
object the highest priority. However, don't forget to remove the priority as soon as the player reaches it, otherwise the AI
will keep bumping into it in the most inappropriate way for the rest of its days.

Statistics

Welcome our newest member: Emil