Skip to content

Posts from Scripts

4.8 (8 ratings)
In reply to Лоли Никита
User Avatar
6 years ago
Auto-translated
Could you please provide instructions on how to create a script that changes the lighting every day, for example: Monday - dawn, Tuesday - morning, Wednesday - daytime, Thursday - sunset, Friday - midnight.
In reply to Лоли Никита
User Avatar
6 years ago
Auto-translated
Loli Nikita
Please tell me how to create a script so that the lighting changes every day: for example, Monday - dawn, Tuesday - morning, Wednesday - daytime, Thursday - sunset, Friday - midnight.
Hello. In MapProperties => GroundAmbientLights => right-click => Add. Then, in the line that appears, click on the three dots and select a light setting or click New and create your own lighting, whether it's sunset or midnight. But most importantly: for each new AmbientLight, enter an appropriate name in English into the InternalName parameter – for example, SunRaise. Next, in the script
function NewDayCheck()
if GetDate(DAY_OF_WEEK)==1 *(Monday) then
SetAmbientLight("SunRaise", GROUND, 5);
end;
if GetDate(DAY_OF_WEEK)==2 *(Tuesday) then
SetAmbientLight("SunMiddle", GROUND, 5);
end;
...
end;

Trigger(NEW_DAY_TRIGGER, "NewDayCheck");
Read more about AmbientLight in the manual of the highly respected Jack_of_shadows. Here and further I will refer to his guide and my own.
FAQ by Jack of Shadows, see the section "How to dynamically change map lighting?".
It is mandatory to familiarize yourself with this section; everything that I have not mentioned here to save space and time (due to some work, I am now a little busy) can be found in his guide.
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
In reply to }{0TT@6bI4
User Avatar
6 years ago
Auto-translated
How do I create a script so that when interacting with an object, a battle starts with specific enemies (in my case, 3 groups of 5 knights), but the number of creatures depends on the difficulty level (for example, 5 knights on Warrior difficulty, and 7 on Hero difficulty)? Thanks in advance to whoever answers. And one more thing. I wanted to create a StartCombat script for a battle with orcs, but I couldn't find the IDs for orcs and tier 3 creatures for all factions except humans. Where can I find and view these IDs?
In reply to Лоли Никита
User Avatar
6 years ago
Auto-translated
Loli Nikita
How do I create a script so that when interacting with an object, a battle starts with specific enemies (in my case, 3 groups of 5 infantry units each), but the number of creatures depends on the difficulty level (for example, 5 infantry units on Warrior difficulty, and 7 on Hero difficulty)? Thanks in advance to whoever answers.
First, assign a script name to the object by clicking on it on the map and entering this name in the object's Name property. Let's say it's nObject. And MyHeroScriptName is the script name of the main hero; you can find it by selecting the hero and pressing the spacebar, in the Settings tab.
In the script:

diff=GetDifficulty();
--diff == 1 on Recruit, 2 on Warrior, 3 on Veteran, 4 on Hero

function MyCombat(heroname, objectname)
if heroname == "MyHeroScriptName" then--Check if the correct hero touched the object
StartCombat(heroname, nil, 3, 6, 5+2*diff, 6, 5+2*diff, 6, 5+2*diff, nil, "resultsf"--Function that runs after the battle, needed if something should happen after the battle);
Trigger(OBJECT_TOUCH_TRIGGER, "nObject", nil); --Resets the function
end;
end;

Trigger(OBJECT_TOUCH_TRIGGER, "nObject", "MyCombat");

function results(hero, result)
if result == not nil then
--Script that runs after victory...
else --Script that runs in case of defeat...
end;
end;
6 is the ID of the infantry unit; there will be 3 stacks of 5 plus 2 for each difficulty level.
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
In reply to }{0TT@6bI4
User Avatar
6 years ago
Auto-translated
diff=GetDifficulty();
function bitva_1(heroname, objectname)
if heroname == "Raelag" then
StartCombat(heroname, nil, 3, 6, 5+2*diff, 6, 5+2*diff, 6, 5+2*diff, nil);
sleep(5);
RemoveObject('q7');
RemoveObject('q8');
RemoveObject('q9');
end;
end;
Trigger(OBJECT_TOUCH_TRIGGER,'q7','bitva_1');
Trigger(OBJECT_TOUCH_TRIGGER,'q8','bitva_1');
Trigger(OBJECT_TOUCH_TRIGGER,'q9','bitva_1');
I think I did it correctly, but the hero ends up with 9 armor, and I need 7. As I understand it, 5+2*diff means 5 armor + the amount multiplied by the difficulty. If the difficulty is Recruit, then diff=1, and it turns out that on Recruit difficulty, there will be 7 armor. If the difficulty is Warrior, then diff=2, and then it's already 5+2*2=9. Can you please explain what the error is here? Thank you in advance.

Added 25 minutes later
I would also like to ask something else. Does the OpenCircleFog function exist? It reveals the fog of war, and with it, you can reveal part of the map. Is it possible to use some function to make it not reveal, but close the fog of war, thus preventing the hero from seeing certain areas that he has already visited, and so that this part of the map is also not visible on the minimap in the lower left corner of the game?
In reply to Лоли Никита
User Avatar
6 years ago
Auto-translated
Lol Nikita
diff=GetDifficulty();
function bitva_1(heroname, objectname)
if heroname == "Raelag" then
StartCombat(heroname, nil, 3, 6, 5+2*diff, 6, 5+2*diff, 6, 5+2*diff, nil);
sleep(5);
RemoveObject('q7');
RemoveObject('q8');
RemoveObject('q9');
end;
end;
Trigger(OBJECT_TOUCH_TRIGGER,'q7','bitva_1');
Trigger(OBJECT_TOUCH_TRIGGER,'q8','bitva_1');
Trigger(OBJECT_TOUCH_TRIGGER,'q9','bitva_1');
I think I did it right, but the hero ends up with 9 lamellar armor, and I need 7. As I understand it, 5+2*diff means 5 lamellar armor + the amount multiplied by the difficulty. If the difficulty is Recruit, then diff=1, and it turns out that on Recruit there will be 7 lamellar armor, if the difficulty is Warrior, then diff=2, and there are already 5+2*2=9. Can you please explain what the error is here? Thank you in advance.

Added 25 minutes ago
I would also like to ask something else. Does the OpenCircleFog function exist? It reveals the fog of war, and with it you can reveal part of the map. Is it possible to use some function to make it not reveal, but close the fog of war, thus preventing the hero from seeing certain places that he has already visited, and so that this part of the map is not visible on the minimap in the lower left corner of the game?
Sorry, I made a mistake out of habit. On Recruit, diff will be 0, on Warrior 1, on Veteran 2, on Hero 3, so on Recruit there will be 5 lamellar armor in each stack, on Warrior - 7, on Veteran 9, and on Hero 11. But using a simple GetDifficulty for calculations is often inconvenient due to its zero value on Recruit, so I recommend changing
diff = GetDifficulty();
to
diff = GetDifficulty()+1
. If you really need 7 on the Hero, then write inside the function before Start Combat
diff= GetDifficulty()+1;
...

...
local amount=0;
local i=1;
for i,4 do
if diff == i then
amount=i;
end;
end;
...
It seems that this is correct, but I'm not 100% sure...
And in the formula for calculating the number of lamellar armor, put 3+amount. If it doesn't work (and I can't guarantee 100% that what I wrote is correct - I'm working from my phone and therefore relying on my memory), just bluntly write the conditions

diff=GetDifficulty()+1;
...

...
local amount=0;
if diff == 1 then
amount=5;
end;
if diff == 2 then
amount=5;
end;
if diff == 3 then
amount=6;
end;
if diff == 4 then
amount=7
end;
And in the formula for calculating the number of lamellar armor, just write amount.
Choose any method.

Regarding closing the fog of war, I have never seen such a thing, so I declare that such a function does not exist. But I am not immune to errors, maybe it does exist. Then try either
CloseCircleFog(x, y, floor, radius, PLAYER_ID); 
or ask Jack_of_shadows in a private message
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
User Avatar
6 years ago
Auto-translated
Thanks, it seems like everything is working. Where can I find the IDs for the Stronghold and the 3rd tier units of all other factions besides Humans?
In reply to Лоли Никита
User Avatar
6 years ago
Auto-translated
Loli Nikita
Thank you, it seems to be working. Where can I find the IDs for the Stronghold and the 3rd tier units of all other factions besides Humans?
.../Game folder/data/data.pak => look for the types.xml file in this archive, it's not inside any other folders, it's directly in data.pak. Open it with Notepad, and when it loads, press Ctrl + F and search for DRUID until you reach the lines with the creature's name and its ID, then scroll down with the mouse wheel.
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
User Avatar
6 years ago
Auto-translated
Is it possible to manipulate weeks using scripts? For example, to set specific weeks to appear at a certain point in time, and then have the normal random week selection resume after certain conditions are met?
User Avatar
6 years ago
Auto-translated
Please tell me what is wrong with the script. When you enter a specific region, it resets, and a message appears. After clicking the 'OK' button, a battle against the dwarves begins, 6 objects disappear from the map, 1 message appears, I am given 15 scouts, a dialog box appears, I click on one of the answers, and none of them work, and the quest also does not appear in the active quests. I am working with the message box function with multiple answers for the first time.

----Battle with the Dwarves (Starting Location)-----
function MessageBox3()
Trigger(REGION_ENTER_AND_STOP_TRIGGER, 'reg8',nil)
MessageBox("/Maps/SingleMissions/richman2/message_3.txt","OK_1");
end;
Trigger(REGION_ENTER_AND_STOP_TRIGGER, 'reg8','MessageBox3')

function OK_1()
sleep (1);
StartCombat("Raelag", nil, 4, 100, 3, 167, 15, 167, 15, 167, 15, nil);
sleep(5);
RemoveObject('q1');
RemoveObject('q2');
RemoveObject('q3');
RemoveObject('q4');
RemoveObject('q5');
RemoveObject('q6');
AddHeroCreatures("Raelag", 71, 15);
MessageBox("/Maps/SingleMissions/richman2/message_4.txt");
TalkBoxForPlayers(PLAYER_1,nil, nil,'/Maps/SingleMissions/richman2/dialog_1.txt',nil, 0,1,'/Maps/SingleMissions/richman2/zag1.txt', nil,0,'/Maps/SingleMissions/richman2/otvet1.txt','/Maps/SingleMissions/richman2/otvet2.txt','/Maps/SingleMissions/richman2/otvet3.txt','/Maps/SingleMissions/richman2/otvet4.txt')
end;

function MyTalkBoxCallback(player, answer)
if (answer < 1) then
return
end
if (answer == 1) then
MessageBox("/Maps/SingleMissions/richman2/message_5.txt");
elseif (answer == 2) then
MessageBox("/Maps/SingleMissions/richman2/message_5.txt");
elseif (answer == 3) then
MessageBox("/Maps/SingleMissions/richman2/message_6.txt");
elseif (answer == 4) then
MessageBox("/Maps/SingleMissions/richman2/message_7.txt");
StartCombat("Raelag", nil, 2, 121, 5, 121, 5, nil);
end
end;
GetObjectiveState('kv_1',OBJECTIVE_ACTIVE);
User Avatar
6 years ago
Auto-translated
Is it possible to manipulate weeks using scripts?
No, that is not possible.
The dialogue appears, I click on one of the answers, and none of them work.
In your call to TalkBoxForPlayers, you haven't specified which function should be called when an answer is selected. Check the list of parameters. In my manual, I suggested a hack to reduce the number of customizable parameters for it to the minimum possible.
РПГ-сценарий для HoMM5: Путь героя
ЧаВо по созданию карт для HoMM5: ЧаВо
User Avatar
6 years ago
Auto-translated
I realized that I don't understand something about how IsObjectExists works. ``` function P0_check() while 1 do if IsObjectExists('T1')==false then if IsObjectExists('T2')==false then if IsObjectExists('T3')==false then if IsObjectExists('T4')==false then sleep(5) if (not GetObjectiveState('P0')==OBJECTIVE_COMPLETED) then startThread( P0_change_state ); break; end; end; end; end; end; sleep(1); end; end; ``` All four towns (T1, T2, T3, T4) are present on the map. The thread happily goes through all the if statements and starts a new function, even though it shouldn't. How is this possible?
 

К А
Стикеры GBF в Telegram
User Avatar
6 years ago
Auto-translated
doesn't the console complain that the value `false` is undefined? Try using a regular `nil` instead.
Нет войне.
User Avatar
6 years ago
Auto-translated
Didn't get angry, and the same problem occurs with the `not IsObjectExists('T1')` construct.
But I'll try, thanks.
 

К А
Стикеры GBF в Telegram
User Avatar
6 years ago
Auto-translated
in general, the entry that is present by default in advmap-startup(false = nil) actually triggers a warning that the value false is undefined. It is logical to assume that you have a redefinition of false somewhere. However, if the same result is obtained with not IsObjectExists('T1'), then the problem is clearly not in this (when I try to reproduce a similar situation, I get an adequate result, i.e., the existence is correctly determined).
Нет войне.

Statistics

Welcome our newest member: recijeb