Current time: 11.04.2024, 05:39 Hello There, Guest! (LoginRegister)
Language: english | russian  

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

Posts: 16466
Post: #8101

SergOz, и он перестаёт быть командирским?


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

Posts: 1287
Post: #8102

Ну да - это не отменит его передачу командиру.
Сказалось то, что никогда не играю с командирами - слишком они имбовые, особенно с командирскими артами. В данном случае я вижу два пути: в окне героя заблокировать через !!СМ:R0; действие клика на арте #149, или в начале карты найти все арты #149 и заменить их (если это рандомная карта)


Карта-мод "Война на Холсте"
29.05.2021 19:02
Find all posts by this user Quote this message in a reply
Berserker Offline
Administrators

Posts: 16466
Post: #8103

Если передача арта через ПКМ на артефакте в рюкзаке героя, то вопрос из разряда CM:I => HE:A => CM:R0.


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

Posts: 1103
Post: #8104

Berserker mentioned the bug of losing stack exp with Ctrl + LMB on HD Mod can be fixed by script. But what's a good approach? As I know, the HD mod feature is executed before ERM. Do you suggest turning off HD Ctrl + LMB feature completely, use ERM for it instead?


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

Posts: 16466
Post: #8105

Did you check it? I thought ERM handler is executed first.


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

Posts: 4338
Post: #8106

Berserker, no, erm doesn't even notice. HD functions intercept all clicks on themselves


Image: widget.png?style=banner2

Новейший Heroes 3 Launcher
31.05.2021 16:20
Visit this user's website Find all posts by this user Quote this message in a reply
Berserker Offline
Administrators

Posts: 16466
Post: #8107

daemon_n, too bad. Awful, I would say.


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

Posts: 1012
Post: #8108

Здравствуйте..

Не могу никак разобраться с 2-мя проблемами:

1. А возможно ли провести проверку: была ли нажата кнопка «уволить командира»? Меня интересует именно сама проверка, а была ли эта кнопка нажата!
Или это невозможно сделать никак?

S.P. к сожалению не получится произвести проверку на наличие мёртвого или уволенного командира, поскольку командир является не увольняемо бессмертным в моём случае и проверка такая !!CO:D и E просто-напросто не сработает! Bad

2.
Quote:CM:I => HE:A => CM:R0.
- я как раз пытался вчера подобное сделать, но почему то всё запрещать стало передавать командиру! Bad
Мой код
но он запрещает передачу всех артефактов командира в его иконку Bad

Quote:в окне героя заблокировать через !!СМ:R0; действие клика на арте #149,
- сама то беда как раз что я не могу никак определить этот арт. Не вижу нигде ресиверов, которые бы его определили при этом чтобы на нём прошло нажатие левой кнопки мыши! Bad

При открытии окна героя в триггере !?CO2 можно ли провести проверку на нажатие левой кнопкой мыши на артефакте именно 149 (то есть проверить коснулась ли левая кнопка мыши артефакта 149 или нет)?
Возможно ли сделать только один шлем в запрет передачи в иконку?

Заранее благодарен за совет или помощь….

P.S. как всегда если кто-то и пытается чем-то подсказать или помочь не требуя при этом ничего взамен или оплаты, то это всегда только Вы "SergOz". Спасибо..

Давайте тогда так поступим, раз консультировать просто так никто не будет, то сделайте мне этих два кода, но только не те, у которых я в чёрном списке + один обязательный (не совсем простой), который я позже напишу и я заплачу.. но всё надо на классическом ЕРМ
(This post was last modified: 31.05.2021 19:54 by fatsawhorse.)
31.05.2021 18:45
Find all posts by this user Quote this message in a reply
Archer30 Offline
Moderators

Posts: 1103
Post: #8109

Hi, I'm getting really addicted to fast variables (f, i, t, etc.). How many are there?

Second question:
Just wrote a script by request. Good practice or nah?

Edit: The script is just updated. Now jumps to the next town if a town is with a hero.
The purpose of the script is to prevent taking a town without a fight


Latest ERA mods and scripts in development - My GitHub
(This post was last modified: 01.06.2021 02:58 by Archer30.)
31.05.2021 23:33
Find all posts by this user Quote this message in a reply
Berserker Offline
Administrators

Posts: 16466
Post: #8110
Лампочка 
fatsawhorse, ERM 1 — это ассемблер. Мне лично тяжело читать и пытаться понять логику, за минуту тут не ответишь. Как не понять и что должны делать команды:
!!FU&y2<>0:E; выход если не щелчок на фоне???

!!VRy9|y4=149/y5=149/y6=149/y7=149/y8=149:S9;
Здесь используется переменная y9, которой ранее не задали значения по умолчанию, например 0.

!!CM&y9=9/y3=12:R0;
!!CM&y9=9/y3=13:R1;

Условия нужно проверять в начале триггера, а не размазывать по коду.
Если щелчок не там-то и там или не левой кнопкой мыши или с доп. кнопками клавиатуры, то выход.

Archer30,
Quick Vars (f..t): f g h i j k l m n o p q r s t

F^FindNextObject^ is not necessary anymore, I already fixed UN:U

Code:
[+] Improved UN:U command. It does not raise error if no more objects are found, but sets x-coordinate to -1 instead. Thus no premature
    objects counting is required. A new syntax with 6 parameters was added to allow using arbitrary integer variables instead of v-variables.
    !!UN:U(objectType)/(objectSubtype)/(direction like -1/-2 or object index)/(x)/(y)/(z).

    Example:
    ; Let's traverse through all map monsters, doubling their quantity

    !#VA(x:y) (y:y) (z:y); define variables to store object coordinates
    !!VR(x):S-1;           setting x-coordinate to -1 will force to start search from scratch

    !!re i; endless loop
      !!UN:U(OBJ_MONSTER)/(ANY_OBJ)/-1/(x)/(y)/(z); find next monster, (x) = -1 on failure
      !!br&(x)<0:;                                  exit loop if nothing found
      !!MO(x)/(y)/(z):Gd*2;                         double monsters quantity
    !!en:;

Suggestions:
-) Name functions using verbs/actions:

"EnsureTownsHaveArmy"
"EnsureNonEmptyTownGarrisons"
"EnsureTownsHaveGuards"
"AddTroopsToEmptyTowns"

-) Prefix your new functions with unique mod/script prefix to protect from same function name usage in different scripts/mods.
!?FU(arch_EnsureTownsHaveGuards)

-) Separate function arguments and any block-controls (if/el/en/re) with empty lines from the rest fo the code to improve readability.

-) Prefer to use local named variables to quick vars, unless it's single level loop with "i"-var. "g" does not tell anything.
(slotInd:y) is better then "g".

-) Try to use br/co as rare as possible and not to jump to outer level. The logics becomes less clear.

-) Use quick vars as rare as possible. Prefer local named variables. (townType:y) is better than "t".

-) Don't comment obvious things like "[define variables to store object coordinates]".
Better leave comment before complex loops or serious of actions, describing what is intended to be done.

-) Declare local arrays before usage on a separate line. Initialize static arrays outside of loops to not repeat the same heavy task in each iteration.

-) Give plural name to arrays. "firstLevelMons" instead of "firstLevelMon".

Educational version:

Final version:



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

Posts: 1103
Post: #8111

Berserker, amazing work! I just added this post to my bookmark. This has to be read every time I start scripting! 132

A few questions:
1. This is supposed to be a single script mod. Say the mod is called Ensure Towns are Guarded, what do you suggest the main function to be named? prefix "etag", full fucntion name FU(etag_Main)?
2. Somehow I still like my !!co 2 line, I feel the logic is clearer (with comment). 96-copy
I'm confused with your last loop a bit. (SlotInd:y) was fixed in the range (ARMY_SLOT_FIRST) -> (ARMY_SLOT_LAST) from the previous loop, but in the last loop you checked for the condition when SlotInd > (ARMY_SLOT_LAST)


Latest ERA mods and scripts in development - My GitHub
(This post was last modified: 01.06.2021 02:52 by Archer30.)
01.06.2021 02:06
Find all posts by this user Quote this message in a reply
Berserker Offline
Administrators

Posts: 16466
Post: #8112

Archer30,

1) Generate random prefix in this case. cc2h_, for instance. It's unique and easy to replace with anything else any time.
2) Ok, if you like co 2.

"for i from 0 to 6 by 1" works in the following way

i = 0

while (i <= 6) do
    ...your code ...
    i = i + 1
end;

So i will become 7 and the loop will end. 7 > 6.



Here is classical linear search algorithm:

Code:
Initialize counters

while (check if we still in physical bounds of array) and (check if current item does not match our demands)
  Increase counter (go to the next counter)
end;

To check, if search succeeded, use the same physical bounds condition. If we still in array bounds, then something was found.


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

Posts: 16466
Post: #8113

Example in ERM: search for number 999 in local array.



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

Posts: 1103
Post: #8114

Very helpful example, Berserker JC_snack


Latest ERA mods and scripts in development - My GitHub
01.06.2021 03:04
Find all posts by this user Quote this message in a reply
Archer30 Offline
Moderators

Posts: 1103
Post: #8115

Just wrote the script requested by Elmore.

Is the structure better?

Circular Mobile Darkness.erm

Question: In what scenario would you prefer variables to be announced at the beginning of a function?


Latest ERA mods and scripts in development - My GitHub
(This post was last modified: 17.06.2021 16:58 by Archer30.)
02.06.2021 03:41
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