Current time: 14.04.2024, 23:48 Hello There, Guest! (LoginRegister)
Language: english | russian  

Post Reply 
Threaded Mode | Linear Mode
Ваши вопросы по ERM-скриптам
Author Message
Archer30 Offline
Moderators

Posts: 1104
Post: #7906

Hi! Looking for help with good practice and algorithm

Here's my function of henchman selection for AI player, x1 = hero id:

Priority is with
1. Creature with more shots
2. If shots are the same, then the creature with less fight value

Say that there are Archers, Maskmen and Titans, Maskmen would be chosen.

Thoughts? 102
didn't write in ERM 2 for compatibility reason

____

Edit: Been thinking of adding priority for the creature that matches the hero's specialty. But how can I check whether a creature is buffed by the hero spec efficiently? By comparing creature id with the result from HE:X?


Latest ERA mods and scripts in development - My GitHub
(This post was last modified: 22.03.2021 21:32 by Archer30.)
17.03.2021 22:23
Find all posts by this user Quote this message in a reply
SergOz Offline

Posts: 1287
Post: #7907

Второй день парюсь, никак не могу сообразить...165
Есть арты, которым ERM'ом добавлены свойства. По окончании боя все арты проигравшего переходят к победителю.
Но, при переигровке боя (плагин BattleReplay) получается следующее: арты остаются у прежних героев (судя по картинке героев), а свойства артов, имеющих ERM настройки переходят к победителю.
Приведу пример кода, может, в нём ошибка.
Или нужно что-то прописать в !?FU(OnBeforeBattleReplay), чтобы вернуть изначальное положение вещей?


U.P.D. Заметил, что стоит мне только задать вопрос на форуме, сразу башка варит круче.
Наверное, посылы (в хорошем смысле слова) форумчан благоприятно действуют на мои мыслительные процессы.
Вопрос снят. Dance3


Карта-мод "Война на Холсте"
(This post was last modified: 18.03.2021 00:07 by SergOz.)
17.03.2021 23:22
Find all posts by this user Quote this message in a reply
Berserker Offline
Administrators

Posts: 16471
Post: #7908

Archer30, generic linear min/max function is

minFV = 2 000 000 000
minFvSlot = -1
maxShots = 0
maxShotsSlot = -1

loop through each slot, process only those with creatures

get slot Fv and Shots
if Fx < minFvSlot then { minFvSlot = current slot index, minFv = Fv }
if Shots > maxShots { maxShotsSlot = current slot index, maxShots = Shots }

Here "=" is assignment operator (:S in ERM)


Скачать Герои 3 Эра и всё, что с ней связано / ERA 2.46f для старых модов
Поддержать проект
18.03.2021 01:26
Find all posts by this user Quote this message in a reply
Archer30 Offline
Moderators

Posts: 1104
Post: #7909

Thanks Berserker, in short, my code looks efficient I guess :D


Latest ERA mods and scripts in development - My GitHub
22.03.2021 21:32
Find all posts by this user Quote this message in a reply
Berserker Offline
Administrators

Posts: 16471
Post: #7910

You can write ERM 2 code and for old engine users use F11 to export the script in ERM-1 format. Otherwise it's always hard to read ERM.


Скачать Герои 3 Эра и всё, что с ней связано / ERA 2.46f для старых модов
Поддержать проект
22.03.2021 22:03
Find all posts by this user Quote this message in a reply
Archer30 Offline
Moderators

Posts: 1104
Post: #7911

Aha. ok. Here comes my ERM 2 code:

I wrote a simple IF:N dialogue that presents the army of Malcom. And I need help with writing.

It looks like picType = (NO_PIC_TYPE) blocks the rest of the items in IF:N, instead of a specific one. That says if Malcom has no creature from slot #4, slot #5 and #6 won't be displayed from the IF:N dialogue. Is there a way to fix this?



Latest ERA mods and scripts in development - My GitHub
(This post was last modified: 22.03.2021 23:01 by Archer30.)
22.03.2021 22:46
Find all posts by this user Quote this message in a reply
Berserker Offline
Administrators

Posts: 16471
Post: #7912

We need to pass already compacted list/array to IF:N without -1 types.


Скачать Герои 3 Эра и всё, что с ней связано / ERA 2.46f для старых модов
Поддержать проект
23.03.2021 03:56
Find all posts by this user Quote this message in a reply
igrik Offline
Administrators

Posts: 2814
Post: #7913

Новый функционал просто прелесть, потому что видимо только я один до этого танцы с бубном вёл (через указатели)((


game bug fixes extended.dll || My Plugins || My GitHub
24.03.2021 00:48
Visit this user's website Find all posts by this user Quote this message in a reply
Berserker Offline
Administrators

Posts: 16471
Post: #7914

Почему же ты один, глянь код Mixed Neutrals. Там много массивов и сплошные указатели. Разгребал и баги некорректных/неинициализированных указателей тоже. Та ещё радость ) А к массивам Эры в следующем выпуске я прикручу обязательную проверку на выход за границы массива.

!#VA(array[3]:y);
!!VR(array[3]):S7; ошибка на стадии компиляции

!!VRi:S7;
!!VR(array[i]):S100; ошибка на стадии выполнения


Скачать Герои 3 Эра и всё, что с ней связано / ERA 2.46f для старых модов
Поддержать проект
24.03.2021 03:29
Find all posts by this user Quote this message in a reply
Archer30 Offline
Moderators

Posts: 1104
Post: #7915

Thanks Berserker, works like a charm 132

A new question from me - weeks ago I mentioned henchman carry over campaign zones. What is the best trigger for saving henchman stats? Is there a trigger for the victory of a map?
Guess I have to save stats at OnSavegameWrite (it must trigger with each victory of campaign zone), but clearly it also trigger with any saving event :/


Latest ERA mods and scripts in development - My GitHub
(This post was last modified: 24.03.2021 15:33 by Archer30.)
24.03.2021 15:30
Find all posts by this user Quote this message in a reply
SergOz Offline

Posts: 1287
Post: #7916

Хочу сделать усиленные гарнизоны, в которых будет больше, чем обычно, защитников.
Написал код, который работает, но, очень сильно увеличивает время между нападением на гарнизон и появлением поля битвы (в это время идёт вызов существ на поле боя).
Подскажите, пожалуйста, как ускорить процесс, или, может, можно по другому добавить существ на поле боя.


Карта-мод "Война на Холсте"
(This post was last modified: 24.03.2021 15:58 by SergOz.)
24.03.2021 15:57
Find all posts by this user Quote this message in a reply
XEPOMAHT Offline
Moderators

Posts: 2271
Post: #7917

(24.03.2021 15:57)SergOz Wrote:  Подскажите, пожалуйста, как ускорить процесс, или, может, можно по другому добавить существ на поле боя.

Напрямую в гарнизон добавляй монстров вместо призыва перед боем (так например ИИ будет адекватно видеть гарнизон, да и для человека тоже не будет "нежданчиков" при взятии гарнизона).
24.03.2021 16:07
Find all posts by this user Quote this message in a reply
SergOz Offline

Posts: 1287
Post: #7918

XEPOMAHT, не совсем понял как это сделать.
В редакторе гарнизону выставлена защита - все семь слотов.
Ресивером !!GR#1/#2/#3:XXXX; уже не добавить охранников.
Я же хочу, чтобы было 18-21 стеков охраны гарнизона.
https://i.ibb.co/1RL00Zg/ice-screenshot-...133421.png


Карта-мод "Война на Холсте"
(This post was last modified: 24.03.2021 16:39 by SergOz.)
24.03.2021 16:25
Find all posts by this user Quote this message in a reply
XEPOMAHT Offline
Moderators

Posts: 2271
Post: #7919

(24.03.2021 16:25)SergOz Wrote:  Я же хочу, чтобы было 18-21 стеков охраны гарнизона.

Тогда только призывом. По-другому никак. 105
24.03.2021 16:31
Find all posts by this user Quote this message in a reply
Berserker Offline
Administrators

Posts: 16471
Post: #7920

Archer30, in campaigns you don't want, that all heroes henchmen be transfered to the next scenario. Maybe it would be better to add export to ini/import from ini functionality?


Скачать Герои 3 Эра и всё, что с ней связано / ERA 2.46f для старых модов
Поддержать проект
24.03.2021 18:08
Find all posts by this user Quote this message in a reply
« Next Oldest | Next Newest »
Post Reply 


Forum Jump:

Powered by MyBB Copyright © 2002-2024 MyBB Group