Current time: 20.04.2024, 20:22 Hello There, Guest! (LoginRegister)
Language: english | russian  

Post Reply 
Threaded Mode | Linear Mode
Школа ERM 2
» ERM 2.0 для ERA III
Author Message
Berserker Offline
Administrators

Posts: 16486
Post: #136

feanor, понял, спасибо.
daemon_n, меня когда спрашивают, я первым делом переключаюсь на era iii changelog.txt и вбиваю в поиск SN:B Ab

Code:
[+] Added new ERM command SN:B to work with binary buffers on a low level. It allows to:
    - get address of local or static global ERM variable;
    - read/write integer/string from/to specific address.

    !!SN:B(intAddress) or ?(intVar) or (strVar) or ?(strVar)[/?(addressValue) or (dummy)/$valueAtAddress]

    The first argument determines variable address to work with. For strings it's always first string character address, regardless GET/SET syntax.
    For floats/ints SET syntax mean value of variable as address. GET syntax means address of specified variable.

    !!VR(test:y):S8943200;
    !!SN:B(test);  means use 8943200 as address
    !!SN:B?(test); means use address of (test) y-variable.

    !!VR(text:z):S^hello world^;
    !!SN:B(text);  means use address of (text) first character
    !!SN:B?(text); means use address of (text) first character too.

    Example:
    Let us declare integer y-variable and determine its address to use with external API function.
    !!VR(fileHandle:y):S(INVALID_HANDLE_VALUE);
    !!SN:B?(fileHandle)/?(fileHandleAddr:y); (fileHandlerAddr) is now address of (fileHandle) variable.

    Let us read last savegame name from H3 static buffer
    !!SN:B(ADDR_MARKED_SAVEGAME_NAME)/d/?(lastSavegameName:z);
    !!IF:M^You last savegame name was %(lastSavegameName)^;

Это удобная замена SN:X хакам для работы с адресами ЕРМ переменных, строками по произвольным адресам и частично аналог UN:C для int32-чисел.


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

Posts: 4338
Post: #137

(10.01.2021 21:37)Berserker Wrote:  

Berserker, спасибо.

Так понимаю, здесь ты сделал вид, что не знаешь номера навыков вообще, потому сообразил безопасный "псевдодинамический обратный массив" 148?


Image: widget.png?style=banner2

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

Posts: 16486
Post: #138

daemon_n, нет. Если тебе нужно сгенерировать число, скажем, от 0 до 99, но исключить 50 и 70, то есть алгоритм лучше вечного перебора:

1) Сгененерируй число от МИН до МАКС - 2, где 2 — число дыр или запрещённых чисел.
2) Если выпало 50, то результат будет МАКС - 1. Если выпало 70, то результат будет МАКС.
То есть ты создаёшь ссылки с отсутствующих элементов на реальные, а сами реальные из начальной генерации исключаешь.

Я запоминаю максимальный индекс для генерации как МАКС - 2. Затем навигацию отсылаю на этот индекс + 1 = МАКС - 1, а некромантию на индекс + 2 = МАКС.

Или играешь ты в броски кубика 1-6. Нужно получить число 1-7, исключая 5. Тогда если выпадет 5, ты зачтёшь это за 7.


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

Posts: 4338
Post: #139

Berserker, о как. Когда объяснил, я сразу понял)
   Спасибо)Ab


Image: widget.png?style=banner2

Новейший Heroes 3 Launcher
10.01.2021 23:58
Visit this user's website Find all posts by this user Quote this message in a reply
igrik Offline
Administrators

Posts: 2814
Post: #140

Berserker, замечания по оформлению кода есть?

Рынок времени (Click to View)


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

Posts: 16486
Post: #141

Есть пожелания:

Quote:!#VA(x:x) (y:x) (z:x) (objtype:x) (objsubtype:x) (yellowSquare:x) (passability:x);
Аргументы функции лучше размещать первыми командами сразу под !?FU(XX) или комментарием описания функции.
Если аргументы не x/y/z и более трёх, то лучше каждый с отдельной строки. Так можно дать описание наиболее сложным хотя бы.

objtype => objType, objsubtype => objSubtype (два слова в camelCase, subtype исключение, так как sub — приставка).

Если переменная логического типа «является проходимым», то за исключением некоторым случаев выразительнее именование
isYellowSquare (это жёлтая клетка?). Иногда глаголом в прошлом времени: checksPassed = TRUE (проверки пройдены).

WOG_OnPassThroughAllObjects — возможно, имелось в виду OnIterateAllMapObjects. «Пройтись по чём-то» чаще всего именуют IterateSomething.
Quote:!!VR(random:y):S0 T9;
Более ёмкая команда сразу устанавливающая значение переменной в случайное в заданном произвольном диапазоне:
Quote:!!SN:T^wog_109.objName^/?(objName:z);
Альтернатива для простых переводов по фиксированному ключу:
Quote:!!IF:M1/(title);
Оптимальный вызов:
Quote:!!HE(ANY_HERO)
Бывает, что -1 в контексте любой, но в данном нужен текущий.
Quote:(movePoints)<500
500 в константу !#DC(OPT_MARKET_OF_TIME_MIN_MOVEPOINTS) = 500
Это, вероятнее всего, именно скриптовое требование на наличие определённого числа очков хода.

Ниже под (iterator) имеется в виду secSkillPicInd, то есть индекс картинки вторичного навыка в массива.
или (numMatchedSecSkills) — счётчик подходящих вторичных навыков, который используется и для индексирования.
Просто iterator — слишком общее имя, чаще всего имеющее некомую объектную структуру.
Quote:!!if&(iterator)<(TRUE):;
; result - id вторичного навыка или -1
Quote:!#VA(arrayPicType:x) (arrayPicSubType:x) (firstItem:x) (result:x);
; init vars
!#VA(picType[8]:y) (picSubType[8]:y) (pType:y) (pSType:y) (currentItem:y);
; get pictures: type and subtype
Добавлю !#DC(NO_SKILLL) = -1;
Quote:!!en:;
; configure message
После окончания блока и комментария для дальнейших команд пустая строка.

Quote:!!SN:T^wog_109.choice^/?(choice:z);
!!IF:N(MSG_TYPE_CHOOSE_PIC_OR_CANCEL)/^%(choice)^/?(result);
Quote:!!if&(gold)<5000:;
Quote:!!IF:M1/(noMoney);
Quote:!!UN:R(REDRAW_ADV_MAP);


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

Posts: 16486
Post: #142

Code:
[+] ERM syntax can be safely beautified for all Era 3.X versions by skipping trailing ":" before ";".
  !!re 0/7/1;
    ...
  !!en;

  !!if&(heroId)=(HERO_XERON);
    ...
  !!en;


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

Posts: 2814
Post: #143

Berserker, спасибо. Сделано.


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

Posts: 16486
Post: #144

Отлично! 132

Попробуй ещё выделить
Quote:!#DC(WOG_OPT_MARKET_OF_TIME) = 109;
!#DC(OBJ_OPT_MARKET_OF_TIME) = 51;
!#DC(OPT_MARKET_OF_TIME_MIN_MOVEPOINTS) = 500;
!#DC(OPT_MARKET_OF_TIME_PRICE_GOLD) = 5000;
И нажать CTRL + ALT + A. Сработает установленный плагин на выравнивание по =.

Quote:; increse numMatchedSecSkills
increase

Quote:; third message display
!!FU(WOG_109_Msg_Show8SSkills):P(arrayPicType)/(arraySSkillPic)/16/?(forgetSkillId);
!!if&(forgetSkillId)<>-1:;

Quote:; calculating id of the selected skill
!!VR(picture:y):S(@picSubType) +(result);
; return skill id
!!VR(result):Sy(picture) -3 :3;
Комментарий идёт для одной или нескольких команд, образующих смысловой блок. Блоки лучше отделять друг от друга пустыми строками.
Хороший код должен быть самодокументирующим. Комментировать каждую элементарную операцию не нужно. В данном случае блок простой. Достаточно хороших имён переменных.


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

Posts: 1117
Post: #145

Berserker, any comment to my code?
I made some alteration to igrik's henchman script by some players' requests. All the modification I made was in ERM 2 96-copy
The idea is to add in stack exp/warlord's Banner to the henchman, also allows to adjust how fast exp gains based on playstyle. All these freatures can be configured in json.
Henchman Mod beta 0.9

I would also like to report a bug here. I notice this bug when I made the feature "returning banner from henchman". Please search for "Berserker" in my script.
The bug: It looks like UN:R3 changes the value of i^henchman_banner_%(hero)^ secretly.
How it should behave: Right click on the colour flag from hero screen and give your Warlord's Banner to henchman, return it to the hero after. Right-click again on the flag, and you would be asked whether to give the banner again to the henchman.
How it mess up: Enables the three lines marked with "Berserker" in my code, repeat the process above. After giving back the banner to the hero, when you click on the colour flag again, you would still be able to acess to the Warlord's banner configuration dialogue, which allows you to duplicate banners.


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

Posts: 16486
Post: #146

Hi. I will try to look into it. By the way, you json file is invalid. New lines are forbidden. Use "\n" escape sequence inside a string to insert new line.
Image: image.png


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

Posts: 1117
Post: #147

Berserker, nice chats on Discord. Much appreaciate for your help! A valuable lesson of good practice. 132

PS: I learned about "Enter for a new line" from ACM Spiteful


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

Posts: 16486
Post: #148

Archer30, thanks for constructive discussion.


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

Posts: 1292
Post: #149

Поддерживается ли сейчас анимация картинок в сообщениях?
Если нет, то будет ли поддерживаться в дальнейшем?


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

Posts: 16486
Post: #150

Нет. Нет.


Скачать Герои 3 Эра и всё, что с ней связано / ERA 2.46f для старых модов
Поддержать проект
20.02.2021 17:56
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