Wake of Gods Forum | Форум Во Имя Богов

Full Version: ERA BattleQueue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
RoseKavalier,
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
Code:
{
  "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.
Code:
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
  _EAX(MAB_ret);
  #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);
    MAB_ret=2;
  }
//  BACall3(1,*(int *)&((Byte *)M2B_BatMan)[0x13D6C]);
  BACall3(1,BACall_Day);
  STOP
  __asm popa
  __asm mov  eax,MAB_ret
}

void __stdcall Monster2Battle(Dword Pv2,Dword Pv1)
{
  _ECX(M2B_BatMan);
  _Monster2Battle();
  #include "templ.h"
  __asm  push   Pv1
  __asm  push   Pv2
  __asm  mov    ecx,M2B_BatMan
  __asm  mov    eax,0x4786B0
  __asm  call   eax
  STOP
  _MonsterAfterBattle();
}

BU:R — redraw battlefield, executes:

Code:
void RedrawBF(void)
{
  #include "templ.h"
  __asm{
    mov    ecx,0x699420 //-> CombatManager
    mov    ecx,[ecx]
    push   0
    push   -1
    mov    eax,0x468570
    call   eax
  }
  RETURNV
}
Code:
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);
    MemFree(buf);

    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.
RoseKavalier, thanks, my fail:
Code:
char *pcharRes = _tr(key, _params, numParams - 1);
std::string result = pcharRes;
MemFree(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.
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
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.
https://yadi.sk/i/Exqn-lKbdk3hhw
I have to revise tactics rounds, thanks for reminding :D
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
RoseKavalier, is that compatible with " tactical phase fast troop selection", i mean dynamic order switch after mouse click?

And yes, i think " * " is good.
Yes.
During tactics phase, all enemy troops (without tactic) are removed from consideration; the initiative logic is otherwise the same.
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.
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
RoseKavalier, great update, thank you!
Great update RoseKavalier! Just notice now your mod shows Chinese character flawlessly. Awesome! 96-copy
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.
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).
Pages: 1 2 3
Reference URL's