Wake of Gods Forum | Форум Во Имя Богов
ERA BattleQueue - Printable Version

+- Wake of Gods Forum | Форум Во Имя Богов (http://wforum.heroes35.net)
+-- Forum: Герои Меча и Магии 3.5 WoG/ERA (/forumdisplay.php?fid=99)
+--- Forum: Моды (/forumdisplay.php?fid=104)
+--- Thread: ERA BattleQueue (/showthread.php?tid=5638)

ERA BattleQueue - RoseKavalier - 16.06.2020 08:24


[current version = 1.03]

Image: cJqNmKd.png Image: lR432pa.png

Download sfx from above links and install to ERA root folder.

Creates an initiative panel on the right side of the combat dialog to show upcoming creatures' turn and the matching round number.
Provides additional information on cursor interaction.

Turret towers language available in English and Russian, with automatic detection based on presence of WoG Rus mod.

For the mod to work, your game resolution must be at least 1076x630 pixels wide.
If you do not meet this requirement, the mod will not install and you will get a warning popup.

Image: R4Si3g5.png

No. Not now at least.

It's a bit different from my SoD_SP version for those used to it but should work just as well(?)
Testing done with ERA 2.9.10 with no gameplay mods.

Consider this a beta version while customizations breaking the initiative bar pile up.

...it only took 5 months after friendly request to get it done, but here we are)

RE: ERA BattleQueue - Grossmaster - 16.06.2020 08:46

Это запредельно здорово!20
   Удобнее, чем другой мод Z Battle order

Image: 3ACv_0SqpoI.jpg

RE: ERA BattleQueue - Bes - 16.06.2020 10:07

119 wow, RoseKavalier, 36Dance3Gamer1132
brilliant, mega respect for your work
espacialy from my wife Rolleyes

RE: ERA BattleQueue - planetavril - 16.06.2020 10:29

good work

RE: ERA BattleQueue - Valery - 16.06.2020 10:43

Great work

RE: ERA BattleQueue - igrik - 16.06.2020 10:45

Oh my God! Ну наконец-то! Dance3

upd: я нашел один маленький остаток от разработки:
1. Навести курсор меча на вражеский стек
2. Отвести курсор от вражеского стека на одну клетку
... в логе битвы будут отображаться цифры, а не надпись "лететь/идти сюда"

Image: 2b.jpg

RE: ERA BattleQueue - Archer30 - 16.06.2020 11:35

Hi RK, great work!

Could you please tell how I can add Chinese localization to turrets, please?

I have WoG Chn mod (caption: 追随神迹汉化, language code: Cn_Simp). Edited BattleQueue.json but didn't work :/

RE: ERA BattleQueue - Algor - 16.06.2020 11:43

RoseKavalier, 132

С BattleHeroes работает нормально.
Для использования дописать BattleQueue в Mods\BattleHeroes\BattleHeroes.mods
Только состав войск обновляется, иногда с небольшой задержкой (после действия?). Не сильно критично, но хотелось бы знать, к каким событиям привязано обновление полосы.

RE: ERA BattleQueue - XEPOMAHT - 16.06.2020 13:42

С ERA PLUS так же работает без глюков.

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

А так, BattleQueue - однозначно плагин года. 132

RE: ERA BattleQueue - Berserker - 16.06.2020 13:47

RoseKavalier, brilliant work!
I recomment to use only translation keys in json in English.
"caption": "have a nive day"
All other translations can be released by enthusiasts as standalone mods and they will virtually overwrite your file.

Or create Lang directory in your mod with *.json,
    "ebq": {
    all key value pairs
And use

typedef char* (__stdcall *TTr) (const char* key, const char** params, int highParams);

  TTr _tr = NULL;

   * Returns translation for given complex key ('xxx.yyy.zzz') with substituted parameters.
   * Pass vector of (parameter name, parameter value) pairs to substiture named parameters.
   * Example: Mod\Lang\*.json file: { "eqs": { "greeting": "Hello, @name@" } }
   * Example: ShowMessage(tr("eqs.greeting", { "name", "igrik" }).c_str());
   * @param  key    Key to get translation for.
   * @param  params Vector of (parameter name, parameter value pairs).
   * @return        Translation string.
  std::string tr (const char *key, const std::vector<std::string> params = {}) {
    const int MAX_PARAMS = 64;
    const char* _params[MAX_PARAMS];
    int numParams = params.size() <= MAX_PARAMS ? params.size() : MAX_PARAMS;

    for (int i = 0; i < numParams; i++) {
      _params[i] = params[i].c_str();

    char* buf = _tr(key, _params, numParams - 1);

    return buf;

hEra                  = LoadLibrary("era.dll");
_tr                   = (TTr)                   GetProcAddress(hEra, "tr");

RE: ERA BattleQueue - daemon_n - 16.06.2020 16:43

Me to wanna say "Thanks!!!"
Now ERA >> HotA in battlequeue
Baratorch's variant is incorrect still102

anyway - Great Job!!!
(spellsbinding Rolleyes)

UPD: posted in discord - i am responsible for this channel, so don't worryYes

RE: ERA BattleQueue - RoseKavalier - 16.06.2020 17:08

Round printing was done through h3_TextBuffer, I'll change it to something else to remove interference.

At this time the plugin only has Eng/Rus and swaps between if you have Rus mod or not.
I've not worked with CN text yet while modding h3; how is it handled by the game - unicode? utf8?

Update comes after BattleAction is complete and is contingent on battle not being finished (which is why you will see stacks that are still alive at end of combat). It was the easiest solution to figure out when to stop updating.

I've never used BattleHeroes; there is a separate state considered during Tactics, maybe this is what happens here. I'll have to look at it sometimes.

Autotranslate failed to capture the exact essence of your words(
The "cursor" as in mouse cursor is being delayed?
This happens with hover on creature or panel?

I have a winXP virtual machine with limited ram/gpu, I'll have a look through that to see if anything shows up.

I'm sorry there are some things in that code snippet that don't work so I'm not sure how this works? Example in Pascal would be fine or another mod using said setup.

RE: ERA BattleQueue - Algor - 16.06.2020 17:41

RoseKavalier, there is no tactical phase in BattleHeroes. All player actions occur between BG1 and BG0.
If it is possible to update the queue when updating the battlefield via !!BU:R, it will be great.

RE: ERA BattleQueue - RoseKavalier - 16.06.2020 22:39

I'll take a look; don't know ERM-related addresses unfortunately, if anyone has a handy-list could be helpful.

RE: ERA BattleQueue - daemon_n - 16.06.2020 23:02

RoseKavalier, last spoiler in message, if i did understand correctly
Link on message

RE: ERA BattleQueue - Berserker - 17.06.2020 00:11

Try to use era.h https://gofile.io/d/KXWJqA
Example of language file can be found in Era II\Mods\WoG\Lang\era.json
  "era": {
    "global_scripts_vs_map_scripts_warning": "{Skip global scripts?}\n\nThe map has its own set of ERM scripts. Do you wish to skip loading global ERM scripts (they may cause errors, if map was not intended to be played with other ERM scripts)?",
    "no_memory_for_erm_optimization": "Sorry, but compiled ERM scripts size exceeds @limit@ MB limit. ERM optimization failed. ERM will be disabled"

Calling tr('era.no_memory_for_erm_optimization') will return std::string with translation in ANSI (current active page) encoding (json files use UTF-8). String can be stored anywere and .c_str() method returns null terminated string pointer then.
If you need parameters in string, you can write in json:
"no_memory_for_erm_optimization": "There are only @mem_free@ MB left"
And call something like tr('era.no_memory_for_erm_optimization', { "mem_free", IntToStr(100) });

Quote:how is it handled by the game - unicode? utf8?
Json are in UTF-8. Era translation API always returns ANSI version.

RoseKavalier, there is no tactical phase in BattleHeroes. All player actions occur between BG1 and BG0.
If it is possible to update the queue when updating the battlefield via !!BU:R, it will be great.
BG0 - event before stack action
BG1 - event after stack action when another stack already obtained turn
BACall3 in ERM.

{0x473F6B,0,DP(Monster2Battle)}, // hook address

void _MonsterAfterBattle(void)
  __asm pusha
//asm int 3
  #include "templ.h"
  if((*(int *)&((Byte *)M2B_BatMan)[0x132F8])==1){
//    for(int i=0;i<(21*2);i++) *(Dword *)&M2B_BatMan[0x54CC+0x548*i+0x84]|=0x00200000;
    CheckForAliveNPCAfterBattle((Byte *)M2B_BatMan);
//  BACall3(1,*(int *)&((Byte *)M2B_BatMan)[0x13D6C]);
  __asm popa
  __asm mov  eax,MAB_ret

void __stdcall Monster2Battle(Dword Pv2,Dword Pv1)
  #include "templ.h"
  __asm  push   Pv1
  __asm  push   Pv2
  __asm  mov    ecx,M2B_BatMan
  __asm  mov    eax,0x4786B0
  __asm  call   eax

BU:R — redraw battlefield, executes:

void RedrawBF(void)
  #include "templ.h"
    mov    ecx,0x699420 //-> CombatManager
    mov    ecx,[ecx]
    push   0
    push   -1
    mov    eax,0x468570
    call   eax

RE: ERA BattleQueue - RoseKavalier - 17.06.2020 01:50

std::string tr (const char *key, const std::vector<std::string> params = {}) {
    const int MAX_PARAMS = 64;
    const char* _params[MAX_PARAMS];
    int numParams = params.size() <= MAX_PARAMS ? params.size() : MAX_PARAMS;

    for (int i = 0; i < numParams; i++) {
      _params[i] = params[i].c_str();

    char* buf = _tr(key, _params, numParams - 1);

    return buf;

This function is undefined behaviour.
It returns buf which was just MemFree, this is definitely not safe.

Thanks for the addresses!

My question related to CN-specifically was what encoding the game used... GB or GBK codepage 936.

RE: ERA BattleQueue - Berserker - 17.06.2020 02:23

RoseKavalier, thanks, my fail:
char *pcharRes = _tr(key, _params, numParams - 1);
std::string result = pcharRes;

return buf;

Something like that would be better. Anyway, the best case is not to detect language (what will you do with Polish and Italian?), but provide single translation English.
Other languages can be released as translation mods, not a task for main maintener, imho.

RE: ERA BattleQueue - RoseKavalier - 17.06.2020 03:03

No worries, I rewrote that file a bit) It works as advertised otherwise!
You are right of course, leave the language to others.

I hooked BG0 and BGR. BG1 should already be calling BattleQueue update... I'll post another version in a bit, not tested with extra mods ~ if someone could verify that then I can make a proper release again.

Downlaod 1.01
[+] BattleQueue updates through BG0 and BG1
[*] Text is now read through ERA from Lang/BattleQueue.json

RE: ERA BattleQueue - Berserker - 17.06.2020 03:25

Nice! 132 Thank you very much, tested a bit without mods, everything works (right click info, first/second player numbers, updates).
In tactics after first turn em, numbers in the right top corner change to #2, #3, then #3, #4.

RE: ERA BattleQueue - RoseKavalier - 17.06.2020 04:37

I have to revise tactics rounds, thanks for reminding :D

RE: ERA BattleQueue - RoseKavalier - 17.06.2020 07:12

So what's the preferred showing during tactics phase?
Rounds of tactics show correctly based on the number of turns you've spent in tactics.

I tested placing '*' instead of round number... alternatively I can just have nothing be shown.
Image: sgJX3pF.png

RE: ERA BattleQueue - daemon_n - 17.06.2020 07:35

RoseKavalier, is that compatible with " tactical phase fast troop selection", i mean dynamic order switch after mouse click?

And yes, i think " * " is good.

RE: ERA BattleQueue - RoseKavalier - 17.06.2020 09:26

During tactics phase, all enemy troops (without tactic) are removed from consideration; the initiative logic is otherwise the same.

RE: ERA BattleQueue - Berserker - 17.06.2020 15:00

RoseKavalier, got it, sorry. It's round number and nothing wrong to count it in tactics, though, maybe display space ' ' instead? No round number at all.

RE: ERA BattleQueue - RoseKavalier - 22.06.2020 03:58

Updated opening post to version 1.02.
I haven't had time to check on winXP for lag issues... problem for future me.

Quote:Arrow towers text was not showing up correctly (thanks daemon_n)
Arrow towers order was incorrect (thanks daemon_n)
Tactics turns are no longer counted, '*' is shown instead (thanks Berserker, daemon_n)
Adjusted round text position to prevent some overlap during tactics

RE: ERA BattleQueue - Berserker - 22.06.2020 04:22

RoseKavalier, great update, thank you!

RE: ERA BattleQueue - Archer30 - 22.06.2020 12:04

Great update RoseKavalier! Just notice now your mod shows Chinese character flawlessly. Awesome! 96-copy

RE: ERA BattleQueue - Archer30 - 09.07.2020 11:27

Hi RK, a little suggestion to your mod about auto-switching language for turrets - how about reading names of turrets from ...\Data\Wall.txt? These are internal names of walls (including turrets), should match up different languages of H3.

RE: ERA BattleQueue - RoseKavalier - 09.07.2020 17:29

Simply because the names may be too wide.
'Keep' is just fine but 'Upper Tower' and 'Lower Tower' would be cut off (or overflow on the sides if I didn't set a width limit).

RE: ERA BattleQueue - daemon_n - 08.08.2020 16:24

Фикс раздражающего сообщения о недостаточном разрешении экрана - thanks to RoseKavalier, Archer30;
Поместить ERA.BattleQueue.dll в \Mods\BattleQueue\EraPlugins с заменой
Это может привести к неожиданнму результатут, поэтому о любых проблемах вам следует сообщать только мне, а не автору мода!

Fix annoying message about insufficient screen resolution - thanks to RoseKavalier, Archer30;
Place ERA.BattleQueue.dll in \Mods\BattleQueue\EraPlugins with replacement
it can provide to unexpected effects, so about any issues you should worry only me
Скачать / Download

RE: ERA BattleQueue - Bes - 08.08.2020 23:10

daemon_n, спасибо, добавил в первом сообщении.

P.S. у меня с этой версией библиотеки игра вообще не запускается
Game crashed...

RE: ERA BattleQueue - daemon_n - 08.08.2020 23:35

Bes, перезагрузи компьютер - у меня тоже был краш, пока не перезагрузил.

RE: ERA BattleQueue - Bes - 09.08.2020 00:05

Unsure не совсем понимаю, почему это требуется , но помогло.
P.S. переигровка тоже заработала

RE: ERA BattleQueue - RoseKavalier - 09.08.2020 07:43

I want to stress that this is not a supported hack and that any subsequent updates will keep the MessageBox warning on insufficient resolution, however this hack allows the plugin to fail silently which was sought for the assembly, so any questions about assembly-version will not be resolved here, tyvm!

RE: ERA BattleQueue - daemon_n - 09.08.2020 12:04

RoseKavalier, np, i will send original dll for them, who will has any problems, and if issue will not dissapaer, then will be your timeRolleyes
Thanks you for the solution anyway) mod is great!!!

RE: ERA BattleQueue - Bes - 09.08.2020 15:44

RoseKavalier, хм, я думал это был официальный отказ от предупреждающего окна.
В таком случае, daemon_n, укажи этот момент в своём вчерашнем посте с ссылкой, дабы люди были предупреждены о рисках "потери лицензии" Spiteful
RoseKavalier, я убрал вчерашний коммент из первого поста, который поспешил в твоё отсутствие вставить Sorry

RE: ERA BattleQueue - RoseKavalier - 10.08.2020 01:15

No worries, thanks for your work))

RE: ERA BattleQueue - ilya - 07.05.2021 20:14

RoseKavalier Thank you so much! Ab

RE: ERA BattleQueue - helgtla - 20.12.2021 19:43

Если ли возможность добавить в данный мод поддержку отображения кадров иконок существ, заменённых png вариантами посредством ресивера !!SN:R; ?
    я изменяю кадры оригинального CPRSMALL.def, который имеет png вариации иконок существ (идентичные оригинальным, только в формате png и находящиеся в папке с названием CPRSMALL.def по пути ..Data\Defs\), на необходимые мне (для конкретного боя), посредством ресивера !!SN:R;
   (архив CPRSMAL2.def - содержит bmp кадры (полный набор кадров и размещён в одном из архивов мода), а в одноимённой папке с модом ( по пути ..Data\Defs\CPRSMAL2.def) - размещены необходимые для замены png кадры).

Замена работает корректно и на карте приключений и в диалоге с результатами боя. Но не работает в данном моде (отображаются только оригинальные bmp из CPRSMALL.def).
    Надеюсь при переводе смысл моего вопроса будет вам понятен. Если же нет, возможно о принципе подмены и работе с png файлами, вам будет лучше поговорить с Berserker.
Image: BQ-png.jpg
    Для более наглядного примера, прилагаю тестовый мод с примером вышеописанной проблемы.

RE: ERA BattleQueue - Berserker - 20.12.2021 23:01

In order to complete this task, the plugin should call def frame drawign functions right before battlefield becomes visible.

RE: ERA BattleQueue - RoseKavalier - 21.12.2021 05:54

It's on my todo-list, the bad news is the list is very lengthy at this time and I have little time with work crunch-time Bad

RE: ERA BattleQueue - RoseKavalier - 31.12.2021 07:33

Best wishes for the new year!

Modified rendering to allow ERA png interception.

RE: ERA BattleQueue - Berserker - 31.12.2021 11:31

RoseKavalier, thank you 20

RE: ERA BattleQueue - Raistlin - 31.12.2021 21:29