Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
6 years ago
Auto-translated
build is a local counter variable for the loop; it sequentially takes values from TOWN_BUILDING_DWELLING_1 (its numerical value is 7) to TOWN_BUILDING_DWELLING_7 (13), and the line SetTownBuildingLimitLevel('houseInferno', build, 0) is executed for each of these values. i is a similar counter, but with values from 1 to 2, so that the upgrade of each building is performed twice (construction + upgrade).
In reply to Gerter
6 years ago
Auto-translated
Gerter
build is a local variable-counter for the loop; it sequentially takes values from TOWN_BUILDING_DWELLING_1 (its numerical value is 7) to TOWN_BUILDING_DWELLING_7 (13), and the line SetTownBuildingLimitLevel('houseInferno', build, 0) is executed for each of these values. i is the same counter, but with values from 1 to 2, so that the upgrade of each building is performed twice (construction + upgrade).
Unfortunately, the function does not work correctly. For example, in my case, 2 months, 4 weeks, and 5 days have passed, so after capturing a city, there will only be 4 times more creatures in the garrison, not 9. Please tell me how to fix this.
User Avatar
6 years ago
Auto-translated
yes, that was my mistake. GetDate(WEEK) will return the week number of the month, so it will be 4 times larger on any 4th week. It should be rewritten like this:
local week = ceil(GetDate(DAY)/7)
In reply to Gerter
6 years ago
Auto-translated
Gerter
yes, that was my mistake. GetDate(WEEK) returns the week number of the month, so it will be 4 times higher on any 4th week. It should be rewritten like this:
local week = ceil(GetDate(DAY)/7)
Now the growth multiplier doesn't work at all.
User Avatar
6 years ago
Auto-translated
game version 3.1?
In reply to Gerter
6 years ago
Auto-translated
Gerter
Is this version 3.1 of the game?
No, it's 3.0.
User Avatar
6 years ago
Auto-translated
install patch 3.1; it doesn't work for you because the ceil function doesn't exist in version 3.0.
In reply to Gerter
User Avatar
6 years ago
Auto-translated
Gerter
yes, that was my mistake. GetDate(WEEK) will return the week number of the month, i.e., it will be 4 times larger on any 4th week. It needs to be rewritten like this:
local week = ceil(GetDate(DAY)/7)


-- global variable
week = 1

function NewDayF()

dow = GetDate(3)

if dow == 1 then
week = week + 1
end

end

Trigger(0, "NewDayF")

I usually do it this way.
In reply to MasteR
6 years ago
Auto-translated
MasteR


-- global variable
week = 1

function NewDayF()

dow = GetDate(3)

if dow == 1 then
week = week + 1
end

end

Trigger(0, "NewDayF")

I usually do it this way.

Is this supposed to be added at the very top of the code? So that everything happens in order?
In reply to MasteR
User Avatar
6 years ago
Auto-translated
MasteR


-- global variable
week = 1

function NewDayF()

dow = GetDate(3)

if dow == 1 then
week = week + 1
end

end

Trigger(0, "NewDayF")

I usually do it this way.

Well, there's not much difference, of course, but without 3.1, you still won't get very far. And I always try to get rid of global variables.
User Avatar
6 years ago
Auto-translated
Could you please tell me if there's a way to make an elf enchant an arrow with a specific spell? I understand that enchanting arrows during battle is possible, but I don't know how to specify which spell should be used.
User Avatar
6 years ago
Auto-translated
it won't work. It's hard to explain, but the functions of the combat script imply a single action/cast; here, there are actually two (selecting the enchanted arrow + selecting the spell). That is, there is no suitable function. For the same reason, you cannot, for example, cast teleport with a script (selecting a target + selecting a location). But you can try to emulate the arrow action - first, cast a rain of arrows, and then the desired spell on the units that will take damage after the volley.
In reply to Gerter
User Avatar
6 years ago
Auto-translated
Gerter
It won't work. It's hard to explain, but the combat script functions imply a single action/cast. Here, there are actually two (selecting the type of arrow + selecting the spell). This means there isn't a suitable function. For the same reason, you can't cast teleport with a script (selecting the target + selecting the location). But you can try to emulate the arrow action – first, cast "Rain of Arrows," and then the desired spell on the units that will take damage after the volley.
Ah, that's a shame. Thank you for the answer, as well as for the suggestion.

Added 1 hour and 4 minutes ago
Gerter
It won't work. It's hard to explain, but the combat script functions imply a single action/cast. Here, there are actually two (selecting the type of arrow + selecting the spell). This means there isn't a suitable function. For the same reason, you can't cast teleport with a script (selecting the target + selecting the location). But you can try to emulate the arrow action – first, cast "Rain of Arrows," and then the desired spell on the units that will take damage after the volley.
Damn, it doesn't work – even "Rain of Arrows" only targets a single unit
User Avatar
6 years ago
Auto-translated
and how many sworn enemies have been chosen?
In reply to Gerter
User Avatar
6 years ago
Auto-translated
Gerter
How many arch-enemies did you choose?
I put four.

Statistics

Welcome our newest member: recijeb