Is it possible to add travel spells to an Orc through a script? It doesn't work with the standard command.
Posts from Scripts
Hey guys, I have a question. Can you tell me what's wrong?
The situation: there's an elven city belonging to an elf (player 3). If player 2 captures it, the quest fails, and the game is lost.
...
This team isn't working. After the city is captured, nothing happens. There are no errors. Where could I have made a mistake? Thanks in advance.
In general, using a looped check for this isn't the most optimal solution.
Something like this, perhaps (I haven't tested it in the game)
In general, the implementation with a looped check is not the most optimal option.
Something like this, perhaps (haven't checked in the game)
It doesn't help; the problem remains the same – the quest doesn't fail, no one loses, and the console doesn't show any errors.
And the "1" is there because the quest fails for the first player.
function onObjectCapture( prevOwner, newOwner, hero, object )
if prewOwner == PLAYER_3 and newOwner == PLAYER_2 then
Trigger( OBJECT_CAPTURE_TRIGGER, 'houseElf', nil )
SetObjectiveState ('q4', OBJECTIVE_FAILED, PLAYER_1 )
sleep(10)
Loose()
end
end
Trigger(OBJECT_CAPTURE_TRIGGER, 'houseElf', 'onObjectCapture' )
It doesn't help, the problem is still the same – the quest doesn't fail, no one loses, and the console doesn't see any errors.
And the "1" is there because the quest fails for the first player.function onObjectCapture( prevOwner, newOwner, hero, object )
if prewOwner == PLAYER_3 and newOwner == PLAYER_2 then
Trigger( OBJECT_CAPTURE_TRIGGER, 'houseElf', nil )
SetObjectiveState ('q4', OBJECTIVE_FAILED, PLAYER_1 )
sleep(10)
Loose()
end
end
Trigger(OBJECT_CAPTURE_TRIGGER, 'houseElf', 'onObjectCapture' )
function onObjectCapture(PrevOwner, NewOwner)
if PrevOwner == 3 and NewOwner == 2 then
Trigger(5, 'houseElf', nil)
SetObjectiveState ('q4', 4, 1)
sleep(10)
Loose()
end
end
Trigger(5, 'houseElf', 'onObjectCapture')
You need to be more careful with variable names
Пробуждение зла
Нашествие из Преисподней
Смена эпох
Скачать все кампании одним архивом: Яндекс.Диск Google.Диск
You can download the set of 3 Campaigns (English version) here
Одиночные сценарии Heroes V 3.1:
Незваные гости
Красный кристалл
Синий кристалл
Закат тьмы
Мультиплеерные карты для Heroes V 3.1:
Легендарная война
Сердце вулкана
Передел мира
It doesn't help; the problem remains the same – the task isn't failing, no one is losing, and the console isn't showing any errors.
Try adding some "print" statements to see what the console shows.
...And the number 1, by the way, is because the task fails for the first player.
...The conditions: there's an elven town belonging to an elf (Player 3). If Player 2 captures it, the task fails, and Player 2 loses.
There weren't any such conditions, so I considered it an error, but it's not really important.
...You need to be more careful with variable names.
Hello! Please help. I want it so that after a certain amount of time, the player who has captured a town can buy all the accumulated troops in the neutral town, and the "neutral town" gets money from somewhere and buys them itself. I even disabled the option to build a town hall in the settings, but it still didn't help.
Maybe there's an easier way to do this, but in this situation, I wouldn't build any buildings with creatures in that town initially. After the town is taken over by a player, scripts can be used to build any buildings in that town, and also (I think) add creatures for recruitment.
Пробуждение зла
Нашествие из Преисподней
Смена эпох
Скачать все кампании одним архивом: Яндекс.Диск Google.Диск
You can download the set of 3 Campaigns (English version) here
Одиночные сценарии Heroes V 3.1:
Незваные гости
Красный кристалл
Синий кристалл
Закат тьмы
Мультиплеерные карты для Heroes V 3.1:
Легендарная война
Сердце вулкана
Передел мира
Maybe there's an easier way to do it, but in this situation, I wouldn't build any creature-producing buildings in that town initially. After the town is transferred to the player, scripts can be used to build any buildings in that town, and also (apparently) add creatures for recruitment.
Can't remember which command is used to build structures in a town?
Regarding adding creatures that can be recruited – there's a function for that: SetObjectDwellingCreatures(town_name, creature_id, number).
What do you mean? I don't see any differences. If you're talking about the style of writing variables, it doesn't matter (PascalCase or camelCase).
In the function parameter, it's prevOwner, and in the function body, it's prewOwner.
Пробуждение зла
Нашествие из Преисподней
Смена эпох
Скачать все кампании одним архивом: Яндекс.Диск Google.Диск
You can download the set of 3 Campaigns (English version) here
Одиночные сценарии Heroes V 3.1:
Незваные гости
Красный кристалл
Синий кристалл
Закат тьмы
Мультиплеерные карты для Heroes V 3.1:
Легендарная война
Сердце вулкана
Передел мира
UpgradeTownBuilding(town_name, building_id)
regarding adding creatures for recruitment – there is a function for this: SetObjectDwellingCreatures(town_name, creature_id, number)
local a=0;
function Armia()
local day=GetDate(3);
if day == 0
then a=a+1;
end;
end;
Trigger(NEW_DAY_TRIGGER, "Armia");
function zoloto()
if prewOwner == PLAYER_NOON and newOwner == PLAYER_NAME
then SetObjectDwellingCreatures('houseInferno', 16, 35*a);
SetObjectDwellingCreatures('houseInferno', 18, 34*a);
SetObjectDwellingCreatures('houseInferno', 20, 18*a);
SetObjectDwellingCreatures('houseInferno', 22, 10*a);
SetObjectDwellingCreatures('houseInferno', 24, 7*a);
SetObjectDwellingCreatures('houseInferno', 26, 4*a);
SetObjectDwellingCreatures('houseInferno', 28, 2*a);
end;
end;
Trigger( OBJECT_CAPTURE_TRIGGER, 'houseInferno', "zoloto")
What could be the error? Please advise
I wrote this script (it doesn't work):
local a=0;
function Armia()
local day=GetDate(3);
if day == 0
then a=a+1;
end;
end;
Trigger(NEW_DAY_TRIGGER, "Armia");
function zoloto()
if prewOwner == PLAYER_NOON and newOwner == PLAYER_NAME
then SetObjectDwellingCreatures('houseInferno', 16, 35*a);
SetObjectDwellingCreatures('houseInferno', 18, 34*a);
SetObjectDwellingCreatures('houseInferno', 20, 18*a);
SetObjectDwellingCreatures('houseInferno', 22, 10*a);
SetObjectDwellingCreatures('houseInferno', 24, 7*a);
SetObjectDwellingCreatures('houseInferno', 26, 4*a);
SetObjectDwellingCreatures('houseInferno', 28, 2*a);
end;
end;
Trigger( OBJECT_CAPTURE_TRIGGER, 'houseInferno', "zoloto")
What could be the error? Please help.
Firstly, it's better not to write like this:
local a = 0outside of functions.Secondly, this line:
if prewOwner == PLAYER_NOON and newOwner == PLAYER_NAMEThe neutral player is PLAYER_NONE. What is PLAYER_NAME? You need to use player number constants, for example, PLAYER_1.Also, in the definition of the zoloto function, you need to specify that it has the parameters prewOwner and newOwner:
function zoloto(prewOwner, newOwner)
first, here's how it should be:it's better not to write anything outside of functions.local a = 0
second, here's this line:a neutral player is PLAYER_NONE. What is PLAYER_NAME, anyway? You need to use constant player numbers, for example, PLAYER_1.if prewOwner == PLAYER_NOON and newOwner == PLAYER_NAME
also, in the definition of the zoloto function, you need to specify that it has the parameters prewOwner and newOwner:function zoloto(prewOwner, newOwner)
PLAYER_NAME is any player. I want the script to work when any player captures this town.
then there's absolutely no need to check the player number capturing the city
local a = 0
function Armia()
local day=GetDate(3);
if day == 0
then a=a+1;
end;
end;
Trigger(NEW_DAY_TRIGGER, "Armia");
function zoloto()
SetObjectDwellingCreatures('houseInferno', 16, 35*a);
SetObjectDwellingCreatures('houseInferno', 18, 34*a);
SetObjectDwellingCreatures('houseInferno', 20, 18*a);
SetObjectDwellingCreatures('houseInferno', 22, 10*a);
SetObjectDwellingCreatures('houseInferno', 24, 7*a);
SetObjectDwellingCreatures('houseInferno', 26, 4*a);
SetObjectDwellingCreatures('houseInferno', 28, 2*a);
end;
Trigger( OBJECT_CAPTURE_TRIGGER, 'houseInferno', "zoloto")
Added 2 minutes later
then there's absolutely no need to check the player number capturing the city
local a = 0
function Armia()
local day=GetDate(3);
if day == 0
then a=a+1;
end;
end;
Trigger(NEW_DAY_TRIGGER, "Armia");
function zoloto()
SetObjectDwellingCreatures('houseInferno', 16, 35*a);
SetObjectDwellingCreatures('houseInferno', 18, 34*a);
SetObjectDwellingCreatures('houseInferno', 20, 18*a);
SetObjectDwellingCreatures('houseInferno', 22, 10*a);
SetObjectDwellingCreatures('houseInferno', 24, 7*a);
SetObjectDwellingCreatures('houseInferno', 26, 4*a);
SetObjectDwellingCreatures('houseInferno', 28, 2*a);
end;
Trigger( OBJECT_CAPTURE_TRIGGER, 'houseInferno', "zoloto")