Объявления

Друзья, если не получается зарегистрироваться, напишите на почту vdv_forever@bk.ru.
Я оторву свою задницу от всех дел и обязательно Вас активирую! :smile10:
Добро пожаловать на геройский форум! :smile25:

Как создать плагин для HD мода

Герои Меча и Магии III: Возрождение Эрафии, Герои Меча и Магии III Дыхание Смерти, Герои Меча и Магии III Клинок Армагеддона, Герои Меча и Магии III Хроники Героев
offlineRolex  
имя: Alex
Ветеран
Ветеран
 
Сообщения: 898
Зарегистрирован: 22 сен 2020, 18:58
Откуда: УКРАИНА
Пол: Мужчина
Поблагодарили: 53 раз.

Re: Как создать плагин для HD мода

Сообщение Rolex » 20 фев 2021, 10:00

RoseKavalier писал(а):

I'd suggest you use "single_header/H3API.hpp"unless you wish to set up the api as a static library.

VS 2015 - Error C3837: attributes not allowed in this context (line in H3API.hpp - 12 638).

Код: Выделить всё
   struct _H3API_DEPRECATED_("Use H3LoadedDef::DefGroup") H3DefGroup;

   _H3API_TYPE_DECLARE_(H3BinaryLoader<H3Font>,        FontLoader);
   _H3API_TYPE_DECLARE_(H3BinaryLoader<H3LoadedDef>,   DefLoader);
   _H3API_TYPE_DECLARE_(H3BinaryLoader<H3Palette565>,  PaletteLoader);
   _H3API_TYPE_DECLARE_(H3BinaryLoader<H3LoadedPcx>,   PcxLoader);
   _H3API_TYPE_DECLARE_(H3BinaryLoader<H3LoadedPcx16>, Pcx16Loader);
   _H3API_TYPE_DECLARE_(H3BinaryLoader<H3TextFile>,    TextFileLoader);
   _H3API_TYPE_DECLARE_(H3BinaryLoader<H3TextTable>,   TextTableLoader);
   _H3API_TYPE_DECLARE_(H3BinaryLoader<H3WavFile>,     WavLoader);

+

 Errors in H3API.hpp: class "h3 :: X" does not contain member "Get" (line)
Error (active) class "h3 :: H3MapSize" does not contain member "Get" (24531)
Error (active) class "h3 :: H3MapSize" does not contain member "Get" (24641)
Error (active) class "h3 :: H3CurrentPlayerID" does not contain member "Get" (27747)
Error (active) class "h3 :: H3CurrentPlayerID" does not contain member "Get" (27764)
Error (active) class "h3 :: H3MapSize" does not contain member "Get" (27780)
Error (active) class "h3 :: H3MapSize" does not contain member "Get" (27785)
Error (active) class "h3 :: H3MapSize" does not contain member "Get" (27809)
Error (active) class "h3 :: H3MapSize" does not contain member "Get" (27813)
Error (active) class "h3 :: H3BitMode" does not contain member "Get" (30841)
Error (active) class "h3 :: H3BitMode" does not contain member "Get" (31000)
Error (active) class "h3 :: H3BitMode" does not contain member "Get" (31061)
Error (active) class "h3 :: H3BitMode" does not contain member "Get" (31098)
Error (active) class "h3 :: H3BitMode" does not contain member "Get" (31135)
Error (active) class "h3 :: H3BitMode" does not contain member "Get" (31403)
Error (active) class "h3 :: H3ArtifactCount" does not contain member "Get" (32367)
Error (active) class "h3 :: H3ArtifactCount" does not contain member "Get" (32390)
Error (active) class "h3 :: H3GameWidth" does not contain member "Get" (33336)
Error (active) class "h3 :: H3GameHeight" does not contain member "Get" (33338)
Error (active) class "h3 :: H3GameWidth" does not contain member "Get" (33353)
Error (active) class "h3 :: H3GameHeight" does not contain member "Get" (33354)
Error (active) class "h3 :: H3MapSize" does not contain member "Get" (34316)
Error (active) class "h3 :: H3MapSize" does not contain member "Get" (34316)
Error (active) class "h3 :: H3GameEdgeHorizontal" does not contain member "Get" (34318)
Error (active) class "h3 :: H3GameEdgeVertical" does not contain member "Get" (34319)
Error (active) class "h3 :: H3MapSize" does not contain member "Get" (34358)
Error (active) class "h3 :: H3MapSize" does not contain member "Get" (34362)
Error (active) class "h3 :: H3BitMode" does not contain member "Get" (35920)
Вернуться к началу

offlineRoseKavalier  
Мастер
Мастер
 
Сообщения: 331
Зарегистрирован: 23 сен 2017, 17:00
Пол: Не указан
Поблагодарили: 234 раз.

Re: Как создать плагин для HD мода

Сообщение RoseKavalier » 20 фев 2021, 21:25

Цитата:
VS 2015 - Error C3837: attributes not allowed in this context (line in H3API.hpp - 12 638).

You can safely delete this line as well as any other line marked with _H3API_DEPRECATED_, they're just there to signal that something has changed name.
You're getting this "error" (really a warning) because of the way your project is set up. I'll add a conditional switch for deprecation in the future so it just gets ignored by default in single_header.

Цитата:
Errors in H3API.hpp: class "h3 :: X" does not contain member "Get" (line)

That's Intellisense being unable to process the file correctly, the compiler is smarter and recognizes the macro and compiles even with these false errors. I can change the script to write them out long instead... just takes a few extra lines in tens of thousands :smile6:
Вернуться к началу

offlineRolex  
имя: Alex
Ветеран
Ветеран
 
Сообщения: 898
Зарегистрирован: 22 сен 2020, 18:58
Откуда: УКРАИНА
Пол: Мужчина
Поблагодарили: 53 раз.

Re: Как создать плагин для HD мода

Сообщение Rolex » 20 фев 2021, 21:57

RoseKavalier писал(а):

You can safely delete this line as well as any other line marked with _H3API_DEPRECATED_, they're just there to signal that something has changed name.

Thanks. I commented out this line (12 638):
Код: Выделить всё
//   struct _H3API_DEPRECATED_("Use H3LoadedDef::DefGroup") H3DefGroup;

And everything compiled.

But the plugin doesn't work...

When visiting a creature dwelling. Instead:
 Creature Upgrade
Изображение


I get the default window:
 Default
Изображение


Код: Выделить всё
#define _CRT_SECURE_NO_WARNINGS
#define _H3API_PATCHER_X86_

#include "H3API-master\single_header\H3API.hpp"

using namespace h3;


Patcher* _P;
PatcherInstance* _PI;


int __stdcall AdvMapGeneratorUpgrades(LoHook *h, HookContext *c)
{
   auto& dwelling = c->Ebx<H3Dwelling>();
   if (dwelling.creatureTypes[1] != -1) // not GENERATOR_1 type
      return EXEC_DEFAULT;

   int upgrade = H3Creature::GetUpgrade(dwelling.creatureTypes[0]); // was F_GetCreatureUpgrade(int), I am deprecating all F_ functions in upcoming update...
   if (upgrade == -1) // neutral creature
      return EXEC_DEFAULT;

   c->Pop();
   c->Pop();
   c->Push(int(&dwelling.creatureCounts[0])); // share creature count with unupgraded type
   c->Push(upgrade);

   return EXEC_DEFAULT;
}

void HooksInit()
{
   // Hook
   _PI->WriteLoHook(0x4ABA2F, AdvMapGeneratorUpgrades);
}

const char* PLUGIN_NAME = "CreatureUpgrade";

BOOL APIENTRY DllMain(HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
{
   static BOOL pluginOn = FALSE;
   switch (ul_reason_for_call)
   {
   case DLL_PROCESS_ATTACH:
      if (!pluginOn)
      {
         _P = GetPatcher();
         _PI = _P->CreateInstance(PLUGIN_NAME);


         HooksInit();
      }
      break;
   case DLL_THREAD_ATTACH:
   case DLL_THREAD_DETACH:
   case DLL_PROCESS_DETACH:
      break;
   }
   return TRUE;
}
Вернуться к началу

offlineRoseKavalier  
Мастер
Мастер
 
Сообщения: 331
Зарегистрирован: 23 сен 2017, 17:00
Пол: Не указан
Поблагодарили: 234 раз.

Re: Как создать плагин для HD мода

Сообщение RoseKavalier » 20 фев 2021, 22:46

My bad, forgot it was a pointer.
Код: Выделить всё
 auto& dwelling = *c->Ebx<h3::H3Dwelling*>();
Вернуться к началу

offlineRolex  
имя: Alex
Ветеран
Ветеран
 
Сообщения: 898
Зарегистрирован: 22 сен 2020, 18:58
Откуда: УКРАИНА
Пол: Мужчина
Поблагодарили: 53 раз.

Re: Как создать плагин для HD мода

Сообщение Rolex » 21 фев 2021, 12:10

Now it works. But there are a number of problems:

1. After clicking on the Buy button, the creatures purchase window does not close. Gold and resources for purchase are withdrawn only after you manually close the window. In the original, the window closes.

 spoiler_1
Изображение ===> Изображение


2. There is a problem you mentioned. If use this plugin with a plugin for accumulating creatures. How can this be fixed?
RoseKavalier писал(а):

But you'd still need to patch some things to handle resources cost if 2nd-3rd or 4th creature don't cost the same (e.g. no gems vs gems).
If no change in resource cost then it appears fine without modification.


 spoiler_2
Изображение ===> Изображение


3. Level 1 dwellings necessary a paid window with a choice of creatures. And also remove the dialogue with free join.

 spoiler_3
Изображение
Изображение ===> Изображение
Последний раз редактировалось Rolex 21 фев 2021, 20:07, всего редактировалось 1 раз.
Вернуться к началу

offlineRoseKavalier  
Мастер
Мастер
 
Сообщения: 331
Зарегистрирован: 23 сен 2017, 17:00
Пол: Не указан
Поблагодарили: 234 раз.

Re: Как создать плагин для HD мода

Сообщение RoseKavalier » 21 фев 2021, 15:33

1. That's how it works for dwellings with more than 1 creature, you'll have to search the dialog proc or recruit mgr proc.
2. Don't see the issue, the second creature is just pooling its quantity from the unupgraded creature. If the first goes up, so does upgraded.
3. Look around in Olly/IDA you'll see the check for level 0 (1) creatures.
Вернуться к началу

offlineArmageddets  
Новичок
Новичок
 
Сообщения: 21
Зарегистрирован: 31 окт 2018, 15:05
Пол: Не указан
Поблагодарили: 2 раз.

Re: Как создать плагин для HD мода

Сообщение Armageddets » 21 фев 2021, 16:05

AlexSpl писал(а):

Цитата:
Один из способов автоскипа хода игрока:

1 - это номер (цвет) игрока, можно задать в условии сразу несколько.

* * *
Кода выше достаточно для рандомных карт, но если нужно скипать сообщения на фиксах, то необходимо также пропускать DisplayComplexDialog():


Спасибо огромное!
Вернуться к началу

offlineRolex  
имя: Alex
Ветеран
Ветеран
 
Сообщения: 898
Зарегистрирован: 22 сен 2020, 18:58
Откуда: УКРАИНА
Пол: Мужчина
Поблагодарили: 53 раз.

Re: Как создать плагин для HD мода

Сообщение Rolex » 21 фев 2021, 16:46

RoseKavalier писал(а):

1. That's how it works for dwellings with more than 1 creature, you'll have to search the dialog proc or recruit mgr proc.

Gold and resources for purchase are withdrawn only after you manually close the window. Can you publish a code snippet that solves this problem?

RoseKavalier писал(а):

2. Don't see the issue, the second creature is just pooling its quantity from the unupgraded creature. If the first goes up, so does upgraded.

Yes, indeed, there is no problem with that. But there is another problem.

Weak level 7 non-upgraded creatures do not require particularly valuable resources (mercury / sulfur / crystals / gems). Only gold.
Upgraded ones require 1 particularly valuable resource per creature. Behemoths / Ancient Behemoths, Bone Dragons / Ghost Dragons, Hydras / Chaos Hydras, Firebirds / Phoenixes

The rest of the 7th level creatures:
non-upgraded - 1 particularly valuable resources
upgraded - 2 particularly valuable resources

When buying upgraded creatures ones, the amount of especially valuable resources is not displayed (for Behemoths / Ancient Behemoths, Bone Dragons / Ghost Dragons, Hydras / Chaos Hydras, Firebirds / Phoenixes).
 SPOILER
Изображение ===> Изображение

Изображение ===> Изображение


RoseKavalier писал(а):

3. Look around in Olly/IDA you'll see the check for level 0 (1) creatures.

I am just learning to work with IDA. At this time, I can't do it myself without your help. Can you post the code snippet that solves this problem most properly?

Or the updated code of the AdvMapGeneratorUpgrades function, which solves the 3 problems described above. Thanks.
Вернуться к началу

offlineRoseKavalier  
Мастер
Мастер
 
Сообщения: 331
Зарегистрирован: 23 сен 2017, 17:00
Пол: Не указан
Поблагодарили: 234 раз.

Re: Как создать плагин для HD мода

Сообщение RoseKavalier » 21 фев 2021, 18:08

Sorry, I really don't have time this week. I took a lot of hours last Friday to release single_header and now I have to catch up with work.

1. There's probably a setting somewhere so that it behaves like in town, not sure.
2. You could do like towns do and swap upgraded/non-upgraded - that way upgraded gets its resource cost and the other just shows as 0.
3. Open IDA at the hook address, scroll up and search for (if level == 0 or if level or if level != 0 or if !level). Then do a nop patch over the jump.
Вернуться к началу

offlineRolex  
имя: Alex
Ветеран
Ветеран
 
Сообщения: 898
Зарегистрирован: 22 сен 2020, 18:58
Откуда: УКРАИНА
Пол: Мужчина
Поблагодарили: 53 раз.

Re: Как создать плагин для HD мода

Сообщение Rolex » 21 фев 2021, 18:30

RoseKavalier писал(а):

Sorry, I really don't have time this week. I took a lot of hours last Friday to release single_header and now I have to catch up with work.

That's all right. How will the time be. Maybe next week there will be time. :smile2:
Вернуться к началу

Пред.След.

Вернуться в Общий раздел

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 6