Skip to content

Posts from Scripts

4.8 (8 ratings)
In reply to Gerter
#3074
Auto-translated
Gerter
you can try to fast-forward 1 week and see if it works at the beginning of the second week?
That's what I'm doing. At the beginning of the second week, the AI buys troops regardless of the script.
User Avatar
#3075
Auto-translated
maybe there’s something in the console? I don’t know, a similar script works perfectly in my map.
Нет войне.
In reply to Gerter
#3076
Auto-translated
Gerter
maybe there's something in the console? I don't know, a similar script works perfectly in my map.
How can I see what's in the console? I can't scroll up.
In reply to Gerter
#3077
Auto-translated
Gerter
maybe there's something in the console? I don't know, a similar script works perfectly in my map.
Let's check again, did I write the script in the right place? And why does it show a warning during the check: function NewDay not defined?
Attachments 1
1 file attached • Total size: 107.1 KB
User Avatar
#3078
Auto-translated
Better share the map, I'll take a look; it's really hard to understand otherwise.
Нет войне.
In reply to Gerter
#3079
Auto-translated
Gerter
It would be better if you shared the map, so I can take a look. It's really hard to understand without it.
https://yadi.sk/d/BDs_ZncXgvxaiQ Here, please take a look.
User Avatar
#3080
Auto-translated
I checked, and the growth values are reset correctly, both at the beginning of the game and when a new week starts.
Нет войне.
In reply to Gerter
#3081
Auto-translated
Gerter
I checked, and the growth values reset correctly for me, both at the beginning of the game and when a new week starts.
Hmm... what could be the problem then?
Attachments 1
1 file attached • Total size: 340.3 KB
In reply to Killer5029
#3082
Auto-translated
Does the game or editor version matter?
User Avatar
#3083
Auto-translated
No, I was wrong here. Although the function works, the AI still recognizes the increase. I think this is because the owner is a neutral player. Therefore, I see only one way to do this: remove all buildings initially and build them upon capturing the town:
for build = TOWN_BUILDING_DWELLING_1, TOWN_BUILDING_DWELLING_7 do
SetTownBuildingLimitLevel('houseInferno', build, 0)
end

function CaptureTown(p_owner, n_owner, hero, object)
for build = TOWN_BUILDING_DWELLING_1, TOWN_BUILDING_DWELLING_7 do
SetTownBuildingLimitLevel(object, build, 2)
for i = 1, 2 do
UpgradeTownBuilding(object, build)
end
end
local week = GetDate(WEEK)
SetObjectDwellingCreatures(object, 16, 35 * week)
SetObjectDwellingCreatures(object, 18, 34 * week)
SetObjectDwellingCreatures(object, 20, 18 * week)
SetObjectDwellingCreatures(object, 22, 10 * week)
SetObjectDwellingCreatures(object, 24, 7 * week)
SetObjectDwellingCreatures(object, 26, 4 * week)
SetObjectDwellingCreatures(object, 28, 2 * week)
end

Trigger(OBJECT_CAPTURE_TRIGGER, 'houseInferno', 'CaptureTown')
Нет войне.
In reply to Gerter
#3084
Auto-translated
Gerter
No, I made a mistake here. Although the function works, the AI still detects the increase. I think this is because the owner is a neutral player. Therefore, I see only one way to fix it: remove all buildings initially and build them upon capturing the town:
for build = TOWN_BUILDING_DWELLING_1, TOWN_BUILDING_DWELLING_7 do
SetTownBuildingLimitLevel('houseInferno', build, 0)
end

function CaptureTown(p_owner, n_owner, hero, object)
for build = TOWN_BUILDING_DWELLING_1, TOWN_BUILDING_DWELLING_7 do
SetTownBuildingLimitLevel(object, build, 2)
for i = 1, 2 do
UpgradeTownBuilding(object, build)
end
end
local week = GetDate(WEEK)
SetObjectDwellingCreatures(object, 16, 35 * week)
SetObjectDwellingCreatures(object, 18, 34 * week)
SetObjectDwellingCreatures(object, 20, 18 * week)
SetObjectDwellingCreatures(object, 22, 10 * week)
SetObjectDwellingCreatures(object, 24, 7 * week)
SetObjectDwellingCreatures(object, 26, 4 * week)
SetObjectDwellingCreatures(object, 28, 2 * week)
end

Trigger(OBJECT_CAPTURE_TRIGGER, 'houseInferno', 'CaptureTown')

Okay. Do I need to change anything in this code? I still don't understand much here
In reply to Killer5029
User Avatar
#3085
Auto-translated
Killer5029
Yeah, and do I need to change anything in this code? I still don't understand a lot of things here.
Well, this code removes the ability to build structures in a neutral town at the start of the map, and when the town is captured, it removes this restriction, builds all the necessary structures, and adds reinforcements for all the weeks that have passed. Does it work as planned?
Нет войне.
In reply to Gerter
#3086
Auto-translated
Gerter
No, I was wrong here. The function works, but the AI still takes advantage of the increase. I think this is because the owner is a neutral player. Therefore, I see only one way – to remove all buildings initially and build them upon capturing the town:
for build = TOWN_BUILDING_DWELLING_1, TOWN_BUILDING_DWELLING_7 do
SetTownBuildingLimitLevel('houseInferno', build, 0)
end

function CaptureTown(p_owner, n_owner, hero, object)
for build = TOWN_BUILDING_DWELLING_1, TOWN_BUILDING_DWELLING_7 do
SetTownBuildingLimitLevel(object, build, 2)
for i = 1, 2 do
UpgradeTownBuilding(object, build)
end
end
local week = GetDate(WEEK)
SetObjectDwellingCreatures(object, 16, 35 * week)
SetObjectDwellingCreatures(object, 18, 34 * week)
SetObjectDwellingCreatures(object, 20, 18 * week)
SetObjectDwellingCreatures(object, 22, 10 * week)
SetObjectDwellingCreatures(object, 24, 7 * week)
SetObjectDwellingCreatures(object, 26, 4 * week)
SetObjectDwellingCreatures(object, 28, 2 * week)
end

Trigger(OBJECT_CAPTURE_TRIGGER, 'houseInferno', 'CaptureTown')

It still doesn't work. The AI still recruits troops, and after capturing the town, creatures are not added
User Avatar
#3087
Auto-translated
I don't even know, everything works fine for me, I even tested this code on your map... maybe you forgot to remove all the buildings that provide resource bonuses in the city in the editor?
Нет войне.
#3088
Auto-translated
And also, in the map editor, it constantly displays the following when checking the script: “Function CaptureTown not defined
Function p_owner not defined
Function n_owner not defined
Function hero not defined
Function i not defined”
Could this be the reason why it’s not working?

Added 2 minutes later
Gerter
I don’t even know, everything works fine for me, I tested this code on your map... maybe you forgot to remove all the buildings that provide growth in the city in the editor?
And you need to remove all buildings related to growth, even the fort?

Added 2 minutes later
It works now) I removed all the buildings and it started working, thank you)))

Added 1 minute later
And could you please explain how this works? If it’s not too much trouble?
For example, what does build mean at the very beginning? Why didn’t you declare this variable?
What is i? Why didn’t you declare it either?

Statistics

Welcome our newest member: Emil