Auto-translated
Is it possible to add travel spells to an Orc through a script? It doesn't work with the standard command.
Нет войне.
New here? I'm Roha — want a quick tour?
Is it possible to add travel spells to an Orc through a script? It doesn't work with the standard command.
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, the implementation with a looped check is not the most optimal option.
Something like this, perhaps (haven't checked in the game)
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' )
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.
...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.
...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 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?
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).
UpgradeTownBuilding(town_name, building_id)
regarding adding creatures for recruitment – there is a function for this: SetObjectDwellingCreatures(town_name, creature_id, number)
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.
local a = 0outside of functions.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.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)
then there's absolutely no need to check the player number capturing the city
then there's absolutely no need to check the player number capturing the city