Skip to content

Posts from Scripts for beginners.

4.5 (2 ratings)
User Avatar
#355
Auto-translated
You're mistaken, BlueHeavenHero. It's not necessary to explicitly specify passing `nil` as a parameter (except in rare cases, which I can explain), as any undeclared value is initially considered `nil`. Therefore, the last three (or four) `nil` values can be omitted altogether. Furthermore, `REGION_ENTER_...` is a variable with a mnemonic name that stores the numerical ID of the trigger. And this number can be passed manually, as Loli Nikita did. Of course, if he made a mistake with the number and 6 refers to the trigger that changes the quest state, then you are right.
С уважением, }{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
#357
Auto-translated
}{0TT@6bI4
You made a mistake, dear BlueHeavenHero. It's not necessary to explicitly specify passing nil as a parameter (except in rare cases, which I can explain), as any undeclared value is initially considered nil. That is, the last three (four) nil values can be omitted altogether. Furthermore, REGION_ENTER_... is a variable with a mnemonic name that stores the trigger's ID number. And this number can be passed manually, as Loli Nikita did. Of course, if he made a mistake with the number and 6 refers to the trigger that changes the quest state, then you are right.
Yes...
That's the kind of assistant I am.
After one UNpleasant incident in a script, I always specify all nil values, and I practically don't use numerical values.
By the way, regarding the region and battle, this is the simplest function, in my opinion.

Мои карты:
Падший рыцарь
Сердце Хаоса

Мои моды:
Визуальные:
Изменение внешнего вида героев-некромантов
Существа-жители и кое-что по мелочи в городах Ордена Порядка, Некрополиса и Инферно

NCF-существа:
Странствующие рыцари
Наемники

In reply to BlueHeavenHero
User Avatar
#358
Auto-translated
Could you please advise me on one thing? On my map, there is a Castle belonging to the fourth player, but the city lacks a Tavern, and there are no heroes belonging to that player on the map. However, he is still summoning troops from buildings on the map, and caravans are traveling to his Castle. Is there a way to prevent him from doing this, perhaps with a script?
In reply to Лоли Никита
User Avatar
#359
Auto-translated
Loli Nikita
Please advise on one thing. On my map, there is a castle belonging to the fourth player, but the city lacks a tavern, and there are no heroes on the map. However, he summons troops from buildings on the map, and caravans travel to his castle. Is there a way to prevent him from doing this, perhaps with a script?
As an alternative: place a region in front of the city and block it for the fourth player.
In reply to Азгалор
User Avatar
#360
Auto-translated
Azgalor
As an alternative: place a region in front of the city and block it for the fourth player.

Thank you very much for your help.
User Avatar
#361
Auto-translated
Could you please tell me, fellow players, if it’s possible to read a regular .txt file from a script?
User Avatar
#362
Auto-translated
No, just display it through a message box, for example, MessageBox.
С уважением, }{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
#363
Auto-translated
}{0TT@6bI4
No, just output it through a message box, for example, MessageBox.
No, I meant interaction with the file system. The console writes to a file. So, there's a way to write to it. But is there a way to read from it? Maybe the console can do something similar. I saw the OpenFile function, but it's disabled.

Added 14 minutes later
This would open up many interesting possibilities.

Added 3 minutes later
So to speak, communication between the script and the outside world.
#364
Auto-translated
Hello. Can anyone help me with a script? I don't understand how the StartCombat command works at all. For example, I want a message to appear when entering a region, and then a battle to begin. I came up with the following script: function Region1F () sleep(5); MessageBox ("/Maps/SingleMissions/MapochkaTEST3/battletext.txt"); sleep(5); StartCombat ( "RedHeavenHero04", "Ottar", 4, 166, 100, 166, 100, 167, 75, 169, 50, 170, 15); Trigger(REGION_ENTER_AND_STOP_TRIGGER,"Region1",nil); end; Trigger(REGION_ENTER_AND_STOP_TRIGGER,"Region1","Region1F");

But it doesn't work - the message appears, but the battle doesn't start. And my second question is - how can I make creatures play animations on the map? For example, I want two stacks of creatures on the map to play attack animations against each other. Please tell me how I can implement this. Thank you in advance.
In reply to AngryTapok1337
User Avatar
#365
Auto-translated
AngryTapok1337

Hello. Can anyone help me with a script? I don't understand how the StartCombat command works at all. For example, I want a message to appear when entering a region, and then a battle to begin. I came up with the following script:

 

function Region1F()
   
    sleep(5);
    MessageBox("/Maps/SingleMissions/MapochkaTEST3/battletext.txt");
    sleep(5);
    StartCombat("RedHeavenHero04", "Ottar", 4, 166, 100, 166, 100, 167, 75, 169, 50, 170, 15);
    Trigger(REGION_ENTER_AND_STOP_TRIGGER,"Region1",nil);
end;
Trigger(REGION_ENTER_AND_STOP_TRIGGER,"Region1","Region1F");

 

But it doesn't work - the message appears, but the battle doesn't start.

 

And my second question is - how can I make creatures play animations on the map? For example, I want two stacks of creatures on the map to play attack animations against each other. Please tell me how I can implement this.

 

Thank you in advance.

Today I will send you a script for creature attack animations

Мои карты:
Падший рыцарь
Сердце Хаоса

Мои моды:
Визуальные:
Изменение внешнего вида героев-некромантов
Существа-жители и кое-что по мелочи в городах Ордена Порядка, Некрополиса и Инферно

NCF-существа:
Странствующие рыцари
Наемники

In reply to BlueHeavenHero
#366
Auto-translated

BlueHeavenHero
Today I'll share a script for creature attack animations.

I'd be grateful 😊

In reply to AngryTapok1337
User Avatar
#367
Auto-translated
AngryTapok1337

 

I'll be grateful 😊

Sorry, I forgot about my promise. Here's the script:
function battle()
local PlayObjectAnimation = function(mob, anim)
if IsObjectExists(mob) then
PlayObjectAnimation(mob, anim, 3)
end
end
while IsObjectExists("name of attacking creature") do
if IsObjectVisible(1, "name of attacking creature") then
PlayObjectAnimation("name of attacking creature", "attack00")
sleep(4)
PlayObjectAnimation("name of defending creature", "hit")
sleep(15 + random(15))
PlayObjectAnimation("name of defending creature", "attack00")
sleep(4)
PlayObjectAnimation("name of attacking creature", "hit")
end
sleep(15 + random(15))
end
end
startThread(battle)

Мои карты:
Падший рыцарь
Сердце Хаоса

Мои моды:
Визуальные:
Изменение внешнего вида героев-некромантов
Существа-жители и кое-что по мелочи в городах Ордена Порядка, Некрополиса и Инферно

NCF-существа:
Странствующие рыцари
Наемники

In reply to BlueHeavenHero
#368
Auto-translated
BlueHeavenHero
Sorry, I completely forgot about my promise. Here's the script:
function battle()
local PlayObjectAnimation = function(mob, anim)
if IsObjectExists(mob) then
PlayObjectAnimation(mob, anim, 3)
end
end
while IsObjectExists("name of attacking creature") do
if IsObjectVisible(1, "name of attacking creature") then
PlayObjectAnimation("name of attacking creature", "attack00")
sleep(4)
PlayObjectAnimation("name of defending creature", "hit")
sleep(15 + random(15))
PlayObjectAnimation("name of defending creature", "attack00")
sleep(4)
PlayObjectAnimation("name of attacking creature", "hit")
end
sleep(15 + random(15))
end
end
startThread(battle)


Thanks, I'll give it a try!

No worries about the time. To be honest, I didn't expect a response in the next few days.)

In reply to AngryTapok1337
User Avatar
#369
Auto-translated
AngryTapok1337

Hello. Can anyone help me with a script? I don't understand how the StartCombat command works at all. For example, I want a message to appear when entering a region, and then a battle to begin. I came up with the following script:

 

function Region1F()
   
    sleep(5);
    MessageBox ("/Maps/SingleMissions/MapochkaTEST3/battletext.txt");
    sleep(5);
    StartCombat ( "RedHeavenHero04", "Ottar", 4, 166, 100, 166, 100, 167, 75, 169, 50, 170, 15);
    Trigger(REGION_ENTER_AND_STOP_TRIGGER,"Region1",nil);
end;
Trigger(REGION_ENTER_AND_STOP_TRIGGER,"Region1","Region1F");

 

But it doesn't work - the message appears, but the battle doesn't start.

 

And my second question is - how can I make creatures play animations on the map? For example, I want two stacks of creatures on the map to play attack animations against each other. Please tell me how I can implement this.

 

Thank you in advance.

Try using this instead of your StartCombat:
StartCombat ( "RedHeavenHero04", "Ottar", 5, 166, 100, 166, 100, 167, 75, 169, 50, 170, 15);
If it doesn't work, it means that either the hero Ottar is not on the map at all, or he is not in the enemy player's reserve. If Ottar is on the global map as just a hero, the battle will not start - you need to put him in the enemy player's reserve.

Мои карты:
Падший рыцарь
Сердце Хаоса

Мои моды:
Визуальные:
Изменение внешнего вида героев-некромантов
Существа-жители и кое-что по мелочи в городах Ордена Порядка, Некрополиса и Инферно

NCF-существа:
Странствующие рыцари
Наемники

In reply to BlueHeavenHero
#370
Auto-translated

BlueHeavenHero
Try using this instead of your current start combat:
StartCombat ( "RedHeavenHero04", "Ottar", 5,166, 100, 166, 100, 167, 75, 169, 50, 170, 15);
If it doesn't work, it means that either the hero Ottar doesn't exist in the map, or he is NOT in the enemy player's reserve. If Ottar is on the global map as just a hero, the battle won't start - you need to put him in the enemy player's reserve.

Thank you, I didn't know about the reserve, and indeed, he wasn't reserved. I'll try to redo it tomorrow, I've temporarily removed Ottar completely. I just put a strong group of neutral gnomes as a temporary fix.