Skip to content

Posts from Scripts

4.8 (8 ratings)
In reply to Аскет2
User Avatar
11 years ago
Auto-translated
Ascet2
How can I make it so that a certain number of resources are deducted from a player on a specific day? Thanks in advance.
I don't know the script completely, but it can be done using the New_Day_Trigger. If this exists in any of the campaigns from "Tribes of the East", please remind me. Then, I might be able to help if I can.
...И справедливость я несу
На острие меча.


Кампания "Искупление" - 15%



О кампании

"Искупление" - это мой амбициозный проект. Давняя мечта. С детства играя в героев, я восхищался персонажами и ландшафтами, сюжетом и стилем оригинальной трилогии, я мечтал привнести что-то свое в эту игру,  и наконец, более-менее освоив нелегкий труд картостроителя, взялся за воплощение мечты. Кампания расскажет о будущем выживших рыцарей Кровавой Стали, о пути, который они избрали, и о том, куда этот путь их приведет. К слову, мне нужен тестер-оценщик. Если хочешь принять участие в создании и есть определенный опыт, то - добро пожаловать!



11 years ago
Auto-translated
I remember about the experience, but not about the resources.
In reply to Аскет2
User Avatar
11 years ago
Auto-translated
Aescet2
I remember about the experience, but not about the resources.
I also wanted to create a StartCombat script in my map, but it's not popular – it's not used in either custom maps or Nival maps... I just replaced it. In your case, I don't even know how to replace it...
...И справедливость я несу
На острие меча.


Кампания "Искупление" - 15%



О кампании

"Искупление" - это мой амбициозный проект. Давняя мечта. С детства играя в героев, я восхищался персонажами и ландшафтами, сюжетом и стилем оригинальной трилогии, я мечтал привнести что-то свое в эту игру,  и наконец, более-менее освоив нелегкий труд картостроителя, взялся за воплощение мечты. Кампания расскажет о будущем выживших рыцарей Кровавой Стали, о пути, который они избрали, и о том, куда этот путь их приведет. К слову, мне нужен тестер-оценщик. Если хочешь принять участие в создании и есть определенный опыт, то - добро пожаловать!



User Avatar
11 years ago
Auto-translated
Here are many examples using this trigger: https://www.google.ru/search?q=NEW_DAY_TRIGGER+forum.heroesworld.ru&oq=NEW_DAY_TRIGGER+forum.heroesworld.ru&aqs=chrome..69i57.2887j0j4&sourceid=chrome&es_sm=93&ie=UTF-8#q=NEW_DAY_TRIGGER+forum.heroesworld.ru&newwindow=1&filter=0 Here's how to change resources: SetPlayerResource(nPlayerID, nResID, nCount) Sets the current amount of resource nResID to nCount for player nPlayerID. Based on this function, a higher-level primitive is implemented in the /scripts/advmap-startup.lua file – void SetPlayerStartResource(nPlayerID, nResID, nCount), which distributes starting resources to the player depending on the difficulty level. And here's how to find out the current amount of resources: GetPlayerResource(nPlayerID, nResID) Returns the current amount of resource nResID for player nPlayerID. Resource IDs are defined in /scripts/advmap-startup.lua and are as follows: WOOD = 0 ORE = 1 MERCURY = 2 CRYSTAL = 3 SULFUR = 4 GEM = 5 GOLD = 6 Example: Add 10000 gold to the first player: SetPlayerResource(1, GOLD, GetPlayerResource(1, GOLD) + 10000).
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...
11 years ago
Auto-translated
I need all the resources; it would take too long to write out their names completely.
In reply to Аскет2
User Avatar
11 years ago
Auto-translated
Ascet2
I need all the resources; it takes too long to write out their names completely.
Too long? Is copying too long?

SetPlayerResource(1, 0, GetPlayerResource(1,0)+10)
SetPlayerResource(1, 1, GetPlayerResource(1,1)+10)
SetPlayerResource(1, 2, GetPlayerResource(1,2)+5)
SetPlayerResource(1, 3, GetPlayerResource(1,3)+5)
SetPlayerResource(1, 4, GetPlayerResource(1,4)+5)
SetPlayerResource(1, 5, GetPlayerResource(1,5)+5)
SetPlayerResource(1, 6, GetPlayerResource(1,6)+10000)

Added 34 minutes ago
inQizitOr
I also wanted to create a StartCombat script in my map, but it's not popular – it's not used in custom maps or in Nival's maps...
http://forum.heroesworld.net/forum//topic/at/518870/

Example:
MasteR
StartCombat (hero, nil, 2,CREATURE_THANE, 20,CREATURE_WARLORD, 20, nil);


Added 19 minutes ago
For convenience, you can use this program:
http://hmm5.sklabs.ru/

It has many hints and syntax checking.

Added 5 hours 7 minutes ago
And this map is suitable for studying scripts:
http://hmm5.sklabs.ru/woe.html
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...
User Avatar
11 years ago
Auto-translated
Hello, hello fellow experts in this thread! :)\n\nActually, I just started learning scripting today and decided to try my hand at something small.\n\nSo, there are two objects named cr1 and cr2. The idea is that when a hero touches the first one, they receive 10 units of sulfur, and when they touch the second one, they receive 10 gems.\n\nSo, here's the question: what's wrong here? :/\n
SetObjectEnabled("cr1", nil);\nSetObjectEnabled("cr2", nil);\n\nTrigger(OBJECT_TOUCH_TRIGGER, "cr1", "fn");\nTrigger(OBJECT_TOUCH_TRIGGER, "cr2", "fn);\n\nfunction fn(heroName, objectName)\n\tif (objectName == "cr1") then\n\tdo\n\t\tlocal sulfur = GetPlayerResource(PLAYER_1, 4);\n\t\tMessageBox(path.."text1.txt);\n\t\tSetPlayerResource(PLAYER_1, 4, sulfur + 10);\n\tend else\n\tdo\n\t\tlocal gem = GetPlayerResource(PLAYER_1, 5);\n\t\tMessageBox(path.."text1.txt);\n\t\tSetPlayerResource(PLAYER_1, 5, gem + 10);\n\tend;\n\tend;\nend;
\nAnd yes, I would be very grateful to anyone who explains to me what parameters are actually passed to the function associated with the touch trigger:smile20:
Злой пещерный демон:smile24:
In reply to LordRaia
User Avatar
11 years ago
Auto-translated
The 'path' variable is not defined. The script should work if you add the following at the beginning: `
path = GetMapDataPath()
`. You can also remove two unnecessary do-end pairs, but this is purely for aesthetics.
And yes, I would be very grateful to anyone who could explain to me which parameters are actually passed to the function related to the touch trigger.
The name of the hero who touched the object and the name of the object that was touched.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
In reply to RedHeavenHero
User Avatar
11 years ago
Auto-translated
RedHeavenHero
The 'path' variable is not defined.
The script should work if you add the following to the beginning:
path = GetMapDataPath()
You can also remove two extra do-end pairs, but that's just for aesthetics.

It displays the name of the hero who touched the object and the name of the object itself.
Thank you :)

Another question: for some reason, the built-in script checker complains about the function (not defined) and the 'heroname' parameter (also not defined).

What could be undefined there?

I got a little confused with do-end: based on my experience with Pascal and C, I'm used to 'else' not being the beginning of a code block.
Злой пещерный демон:smile24:
User Avatar
11 years ago
Auto-translated
This checker is quite unreliable. It doesn't really check anything; it just pretends to. It's best to forget about its existence.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
11 years ago
Auto-translated
I need a script that awards the victory to the first player if a hero flees from a specific enemy hero after a certain number of turns.

Added 31 seconds ago
I mean, during a battle.

Added 08/04/2015 10:39


Is anyone here?

Added 08/08/2015 08:43


Will anyone help me?
In reply to Аскет2
User Avatar
11 years ago
Auto-translated
Aскет2
Can anyone help me?

I think I can express the general opinion by saying that you should look for the answers yourself. Stop bothering others with trivial questions that you can easily find the answers to in 10 minutes, especially considering that it has already been discussed. It's as if others have nothing better to do than to write the entire script for someone else.
Кампании для Heroes V 3.1 (Трилогия):

Пробуждение зла
Нашествие из Преисподней
Смена эпох

Скачать все кампании одним архивом: Яндекс.Диск Google.Диск

You can download the set of 3 Campaigns (English version) here


Одиночные сценарии Heroes V 3.1:


Незваные гости
Красный кристалл
Синий кристалл
Закат тьмы

Мультиплеерные карты для Heroes V 3.1:

Легендарная война
Сердце вулкана
Передел мира
User Avatar
10 years ago
Auto-translated
Hello, great masters of the ancient Lua language. I've encountered some difficulties with restructuring a town... In general, everything works as intended with the trigger, but I would like to add some animation to the town's transformation. So, here's the essence of my question: what should I add to this trigger? ``` function transform () SetObjectiveState ( "obj3",OBJECTIVE_COMPLETED); sleep (5); TransformTown ( "necr1", TOWN_HAVEN ); Trigger ( OBJECT_TOUCH_TRIGGER, "lightwather", "transform", nil); end; Trigger ( OBJECT_TOUCH_TRIGGER, "lightwather", "transform" ); ``` To play a visual effect of the "Holy Word" spell over the town between completing the quest and transforming the town? Please help if it's not too much trouble. I would be very grateful.
User Avatar
10 years ago
Auto-translated
SetObjectiveState ( "obj3",OBJECTIVE_COMPLETED);
PlayVisualEffect('/Effects/_(Effect)/HolyWord.xdb#xpointer(/Effect)', 'necr1', '', X, Y, Z, 0, 0);
sleep (5);
Instead of X, Y, and Z, you need to choose an offset to your liking; you can set Z to 5-6 right away. And you will probably need to increase the sleep time several times, as the animation is quite long.
In reply to Jack_of_shadows
User Avatar
10 years ago
Auto-translated
Jack_of_shadows
SetObjectiveState ( "obj3",OBJECTIVE_COMPLETED);
PlayVisualEffect('/Effects/_(Effect)/HolyWord.xdb#xpointer(/Effect)', 'necr1', '', X, Y, Z, 0, 0);
sleep (5);
Instead of X, Y, Z, you need to choose an offset to your liking; you can set Z to 5-6 right away. And you will probably need to increase the sleep time several times, as the animation is quite long.

Thank you very much.

And can I ask another question?

The MessageBox function absolutely refuses to work.

function Question ()
MessageBox("Maps\Multiplayer\Vostok\Question.txt");
Trigger(REGION_ENTER_AND_STOP_TRIGGER,"reg_1","Question",nil);
end;
Trigger(REGION_ENTER_AND_STOP_TRIGGER,"reg_1","Question");

The region is specified correctly; when entering it, the hero stops, but the message is not displayed. The path to the text file also seems to be specified correctly; at least, this file is in the root of the map in Unicode encoding. Can you tell me what the problem might be?



Added 1 hour 18 minutes ago
Oops, sorry, I figured it out). I typed the slashes in the wrong direction... Now there's another problem: after reading the forum, I wrote the following script...

Function Question ()
QuestionBox("path to file","yes");
end;
Trigger(6,"reg1","Question");

function yes ()
local gold = GetPlayerResourse(1,6);
if gold >=3000 then
SetPlayerResourse(1,6,GetPlayerResourse(1,6)-3000)
SetObjectOwer("gar1",PLAYER_1)
else
MoveHeroRealTime("Diraya",75,25,0)
end;
end;

Please tell me, newbie, how to reset the trigger? Where should I insert Trigger(6,"reg1","Question",nil)?;

P.S. sorry for not following all the spacing in the script; I'm just writing from my phone, looking at the monitor, and I don't have the ability to simply copy and paste the text

Statistics

Welcome our newest member: recijeb