Skip to content

Posts from Scripts for beginners. Auto-translated

4.5 (2 ratings)
In reply to Азгалор
User Avatar
#322
Auto-translated
Azgalor
BlueHeavenHero, I don't know who's giving dislikes here, but as I mentioned above: make sure everything is correct, and as Khottabych rightly pointed out, don't forget to add the option to disable the standard battle (if you haven't already), and then check the scripts in the game. We're waiting for your feedback.
I understand everything, thank you for your help.
Since "Fallen Knight" is my first work, I want everything to be done with quality and the scenario to be interesting.

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

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

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

In reply to AstralLein
User Avatar
#323
Auto-translated
AstralLein
You can see who is leaving dislikes in the Control Panel.
Oh, thank you! I'll keep that in mind 😊
User Avatar
#324
Auto-translated
Hello everyone. I recently learned that it is possible to control the enemy army using scripts, depending on the difficulty level. How exactly can this be done?

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

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

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

In reply to BlueHeavenHero
User Avatar
#325
Auto-translated
BlueHeavenHero
Hello everyone. I recently learned that it is possible to control the enemy army using scripts, depending on the difficulty level. How exactly can this be done?

Well, for example, like this:

function HeroesBuff()
local heroes = {"Duncan", "Biara"};
local diff = GetDifficulty();
for h,hero in heroes do
for creatureID = 1, CREATURES_COUNT - 1 do
if GetObjectCreatures( hero, creatureID) >= 1 then
HeroSetUp = GetObjectCreatures( hero, creatureID );
RemoveObjectCreatures( hero, creatureID, HeroSetUp );
AddObjectCreatures( hero, creatureID, HeroSetUp + ( HeroSetUp / 100 * 10) * diff );
end;
end;
end;
end;
In reply to Азгалор
User Avatar
#326
Auto-translated
Hi everyone! I don't want to spoil anything, but I really need help with a script. I want to make it so that during the final battle, the boss casts a special spell – summoning angels. Angels should appear in the arena with accompanying effects of rays from Divine power. How can I do this?

Added 3 hours 9 minutes ago
And also – I've had problems with the StartCombat script for a long time smile05. Can someone explain this script in detail? (preferably with examples)

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

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

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

User Avatar
#327
Auto-translated
StartCombat("ourHeroName", "enemyNameOrNil, numberOfUnits, id1, count1, ..., idN, countN, script, callback, arena, autobattle)

If any parameter seems confusing or is not needed, you write nil. For example, a battle without a hero against a unit of swordsmen + archers is described as follows:

StartCombat("Hero", nil, 2, CREATURE_SWORDSMAN, 10, CREATURE_ARCHER, 17)
С уважением, }{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
#328
Auto-translated
}{0TT@6bI4
StartCombat("ourHeroName", "enemyNameOrNil, numberOfUnits, id1, count1, ..., idN, countN, script, callback, arena, autobattle)

If any parameter is unclear or unnecessary, you can use nil. For example, a battle without a hero against a unit of swordsmen and archers is described as follows:

StartCombat("Hero", nil, 2, CREATURE_SWORDSMAN, 10, CREATURE_ARCHER, 17)
Now, let me explain what's going on. After capturing a certain town, a cutscene is played. Then, a scripted battle begins on a custom arena. After the battle, another cutscene is played. I implemented this as follows:
function CaptureTown() 
RazeTown("Haven")
sleep(2)
StartDialogScene("DialogScenes/S9/DialogScene.xdb#xpointer(/DialogScene)")
sleep(2)
StartCombat("HafadNecro", "Melhior", 4, 13, 22, 14, 22, 13, 22, 14, 22, MyScript, nil, MyArena, DisableAutobattle)



Added 3 minutes ago
But how do I start a battle on my arena, with my battle script and autobattle disabled?

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

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

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

User Avatar
#329
Auto-translated
Instead of myArena, specify the path to the xdb file of the AdventureFlybyScene for the arena, and instead of MyScript, specify the path to the xdb file of the script.
С уважением, }{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
#330
Auto-translated
}{0TT@6bI4
Instead of myArena, specify the path to the xdb file of the AdventureFlybyScene for the arena, and instead of MyScript, specify the path to the xdb file of the script.
So, is it like this?:
function CaptureMainHaven()
RazeTown("Boss")
sleep(1)
StartDialogScenee("\DialogScenes\FallenKnight\Final\DialogScene.xdb#x pointer(\DialogScene)")
sleep(3)
StartCombat(heroname, "MelhiorFinal", 5, 14, 22, 13, 22, 14, 22, 13, 22, 14, 22, "\Maps\SingleMissions\FallenKnight\FinalCombat.xdb# xpointer(\Script)", nil, "\Scenes\CombatArenas\FinalCombat.xdb#xpointer(\AdventureFlybyScene)", nil)
end;

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

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

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

User Avatar
#331
Auto-translated
It seems to be true, but in the starting combat, the heroname is not defined, unless you declared it as a global variable beforehand.
С уважением, }{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
#332
Auto-translated
}{0TT@6bI4
It seems correct, but in the starting combat, the heroname is not defined, unless you declared it as a global variable beforehand.
So, did I specify the path correctly?

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

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

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

User Avatar
#333
Auto-translated
How would I know? At least the slashes in (/Script) and (/AdventureFlyByscene) are definitely forward slashes, not backward slashes.
С уважением, }{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
#334
Auto-translated
}{0TT@6bI4
How would I know? But the slashes in (/Script) and (/AdventureFlyByscene) are definitely forward slashes, not backward ones.
Okay, I've finished writing the script completely, made the videos, and now I'm going to test it. I doubt everything will work, but if there are any problems, I'll ask for help in this or another thread about Scripts.

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

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

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

In reply to Азгалор
User Avatar
#335
Auto-translated
Azgalor

Well, basically it's easy. We reserve a Necromancer hero, create a quest to keep the main hero alive (OBJECTIVE_KIND_MANUAL) to control his actions through scripts. In the scripts, we'll write something like this:

NowNecromancer = 0 --Condition that we'll set when the hero becomes a Necromancer

function prim_save_gg( heroName ) --You can name this function differently; this is just for clarity
if ( heroName == Duncan ) and NowNecromancer ~= 1 then --Duncan is used as an example. Insert the script name of your hero here
SetObjectiveState("script name of the quest", OBJECTIVE_FAILED) --Fail the quest to keep the main hero alive
sleep(10) --Give the player time to see the quest failure and realize that they've lost the main hero
Loose() --Fail the mission, because our hero died before becoming a Necromancer
elseif ( heroName == Duncan ) and NowNecromancer == 1 then --We lose the hero, but we have the condition that we are now a Necromancer, so we don't lose
print("Everything is okay, the condition is met. He died, and that's that. Now I'm a Necromancer, maybe I'll go buy some skulls")
end
if ( heroName == DuncanNecro ) and NowNecromancer == 1 then --Our hero is a Necromancer, the condition that we made him a Necromancer is met
SetObjectiveState("script name of the quest", OBJECTIVE_FAILED) --Fail the quest to keep the main hero alive
sleep(10) --Give the player time to see the quest failure and realize that they've lost the main hero
Loose() --Fail the mission, because our hero died after becoming a Necromancer
end
end

function TransformToNecromancer() --Here we'll specify what happens after the main hero becomes a Necromancer. Where it will be called from is up to you
--All sorts of things from the author, who knows what conditions he has?
NowNecromancer = 1 --Set the condition so that the game doesn't fail after deleting the main hero
sleep(2) --Just in case, give the game time to process the information
DeployReserveHero("DuncanNecro", x, y, GROUND/UNDERGROUND) --Place the new main hero so that the game doesn't fail if the player only has one hero and no castle with a tavern
sleep(2) --Also just in case, give the game time to process everything
RemoveObject("Duncan") --Painlessly delete the main hero
end

Trigger(PLAYER_REMOVE_HERO_TRIGGER, PLAYER_1, "prim_save_gg") --Trigger to track the player's hero losses for PLAYER_1

Try it)

Okay, comrade Azgalor, I tested the script and have some disappointing news - the script doesn't work. If I write NowNecromanser = 0 at the beginning of the script, the rest of the script doesn't work

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

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

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

In reply to BlueHeavenHero
User Avatar
#336
Auto-translated

BlueHeavenHero
Okay, comrade Azgalor, I tested the script and have some disappointing news – the script doesn't work. If I write NowNecromancer = 0 at the beginning of the script, the rest of the script doesn't work.
What does the console complain about?