Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
Auto-translated
Thank you, everything worked out great! =)

Added 6 minutes later
yes, by the way, is it possible to make an object inaccessible to only a specific player, like a region?

if I give an example, I need player 3 to be able to pass through the gate without any problems, while player 1 can only click on it and receive different quests, but without a battle or capturing the gate. Or will I have to put a mini-region in front of it?

Whatever
In reply to Heroist
User Avatar
Auto-translated
Heroist
Thank you, everything worked out great =)

Added 6 minutes ago
yes, by the way, is it possible to make an object inaccessible to only a specific player, like a region?

if I give an example, I need player 3 to be able to pass through the outpost without any problems, and player 1 can only click on it and receive different quests, but without a battle or capturing the outpost. Or will I have to put a mini-region in front of it?
You can, for example, by temporarily enabling/disabling the trigger:
function enabling()
while 1 do
SetObjectEnabled('garrison', nil);
Trigger(4, 'garrison', 'kvest');
while GetCurrentPlayer() == 1 do
sleep(1);
end;
SetObjectEnabled('garrison', 1);
Trigger(4, 'garrison', nil);
while GetCurrentPlayer() ~= 1 do
sleep(1);
end;
end;
end;
Then all players except the first will be able to pass through the outpost. And the first one will only be able to receive quests from it.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
yes, by the way, I'm also curious about this code:

function Prepare()
hero = GetDefenderHero()
x1 = GetDefenderCreatures()
end
function Start()
if GetCreatureType(x1[0]) == 114 then
SummonCreature(DEFENDER, 122, 1, 12, 1)
SummonCreature(DEFENDER, 122, 1, 12, 10)
end
end

But it says that there's an incorrect argument when calling the GetCreatureType function.
The thing is, before this, I activate startcombat; maybe it doesn't recognize creature 114 as a defending creature?

Whatever
In reply to Heroist
User Avatar
Auto-translated
You define the unit array during battle preparation, and the function doesn't "see" it at that point. You need to move the x1 definition to the very beginning of the start function.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
Hmm, that's strange, I remember it not working yesterday, but now it seems to be working fine...

Thanks again, you're really helping me out =)

Added 24 minutes later
RedHeavenHero
You can, for example, temporarily enable/disable the trigger:
function enabling()
while 1 do
SetObjectEnabled('garrison', nil);
Trigger(4, 'garrison', 'kvest');
while GetCurrentPlayer() == 1 do
sleep(1);
end;
SetObjectEnabled('garrison', 1);
Trigger(4, 'garrison', nil);
while GetCurrentPlayer() ~= 1 do
sleep(1);
end;
end;
end;
Then all players except the first will be able to pass through the outpost. And the first player will only be able to receive quests from it.


I didn't quite understand, how can I then remove the lock for player 1, for example, by adding a new variable.
That is, somewhere else I specify "a = 1", and not 0, and then the outpost will also open for me.

Whatever
In reply to Heroist
User Avatar
Auto-translated
Yes, approximately like that. When the variable `stop` equals 1, the loop will terminate at the desired point, and everyone will be able to use the garrison as usual. ``` stop = 0; function enabling() while 1 do SetObjectEnabled('garrison', nil); Trigger(4, 'garrison', 'kvest'); repeat sleep(1); until GetCurrentPlayer() ~= 1 or stop == 1; SetObjectEnabled('garrison', 1); Trigger(4, 'garrison', nil); repeat sleep(1); until GetCurrentPlayer() == 1 or stop == 1; if stop == 1 then break; end; end; end;
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
Auto-translated
r=random(5)

function cr()

if IsHeroAlive('Sun')
then
OpenCircleFog(r,r,0,10,PLAYER_1)
OpenCircleFog(0,0,0,9999,PLAYER_1)
end;
end;
Trigger(NEW_DAY_TRIGGER,'cr')

This script is supposed to reveal a random part of the map every day, as long as the hero Sun is alive (I'm creating a map, and this is one of the main new characters created from scratch), but it doesn't work:mad: :confused:!

Added 3 minutes later
Please tell me why. Otherwise, I won't be able to sleep peacefully (I've cured my insomnia:), I don't want to suffer again:().
User Avatar
Auto-translated
Sun – is this definitely the hero's name you need? Did you set it in Shared?
r=random(5) – this needs to be placed inside the function body; otherwise, it will only be called once.
OpenCircleFog(0,0,0,9999,PLAYER_1) – is this for testing purposes, as I understand it?
 

К А
Стикеры GBF в Telegram
In reply to Ment
Auto-translated
Is "Sun" really the right name for the hero? Did you set it in Shared?
r=random(5) -- this needs to be placed inside the function body, otherwise it will only be called once.
OpenCircleFog(0,0,0,9999,PLAYER_1) -- is this for testing, am I right?

Yes, it's set in shared.

Okay, I understand, I'll put it in the function body.

Yes, it's for testing.

Added 2 minutes later
And how do I make it generate a random number, because it only generates 5?
User Avatar
Auto-translated
I don't see any other reasons why it might not work right now. Does the console display any messages?
By the way, the script has a few drawbacks. In particular, it only reveals regions diagonally (to avoid this, you need two variables: r1 and r2). Also, it's better to multiply them by something in the OpenCircleFog(r, r, 0, 10, PLAYER_1) function, otherwise, a spread of five cells isn't very large. But these are just minor details.
 

К А
Стикеры GBF в Telegram
Auto-translated
I'll try now. Thank you.

Added 1 minute ago
I'll try now. Thank you.

P.S. Will a range of 700 be acceptable?
User Avatar
Auto-translated
Would a map size of 700 be acceptable?
I think that's quite large. I don't remember seeing maps of that size before.
 

К А
Стикеры GBF в Telegram
Auto-translated
And then, for example, after capturing a town, can you stop exploring the map?

Added 2 minutes later
Yes, 700 is a lot; the map size is 136x136.
User Avatar
Auto-translated
And then, for example, after capturing a town, can you stop the map from being revealed?
Yes, you can. Place a trigger on capturing an object and a variable that equals 0 if the object is not captured and 1 otherwise. Then, in the if IsHeroAlive('Sun') condition, add a check for this variable and its value.
 

К А
Стикеры GBF в Telegram
Auto-translated
Thank you. Can the same be done with a region? That is, if run=1, you can't pass through it. And if run=0, you can pass through it. However, this would be linked to the gatekeeper's tent, but I now know how to do that: disable the object and add a trigger that sets run=0 upon collision.

Statistics

Welcome our newest member: Emil