Объявления
Поздравляем
VDV_forever


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

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

Герои Меча и Магии III: Возрождение Эрафии, Герои Меча и Магии III Дыхание Смерти, Герои Меча и Магии III Клинок Армагеддона, Герои Меча и Магии III Хроники Героев
offlineas239  
имя: Анатолий
Ветеран
Ветеран
 
Сообщения: 527
Зарегистрирован: 29 дек 2018, 14:17
Пол: Мужчина
Поблагодарили: 38 раз.

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

Сообщение as239 » 16 мар 2019, 12:15

И еще вопрос - можно ли как-то получить массив охраняемых объектов монстром?
Вернуться к началу

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

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

Сообщение RoseKavalier » 16 мар 2019, 16:25

I copy pasted the address 0x4FDF6B from before, open debugger and look what you are trying to patch first!
 current spot image
Изображение


A quick recap on patcher_x86 HiHook and LoHook:

LoHook is best used to alter portion of a function, non-related data to current spot, or when you need access to specific registers or data from the stack (ESP values).
HiHook is best used to alter a function, entirely, or partly. The nicest thing about HiHook is that it can combine what several LoHooks would do into a single hook. You can completely skip what Heroes3 code does if you wish to.

They both have their uses, one is not better than the other.

LoHook can technically be placed anywhere in the code portion, but there are still 2 rules to follow.
1- LoHook must be placed at the start of an instruction, not in its middle.
2- LoHook cannot be placed halfway over a loop
There could also be specific cases where it's problematic but these are the 2 most relevant.
VALID
 valid LoHook image
Изображение


INVALID
 invalid LoHook images
Изображение

Изображение
But look if we scroll down a bit...
Изображение
All seems ok but let's see what happens if I force the code to take the jump at 0x4FDF81:
Изображение
**image *should say LoHook instead of HiHook***


HiHook can ONLY be placed on
* CALL instruction E8 12 34 56 78 ... this is CALL_ hooktype
* CALL DWORD instruction FF 15 88 77 66 55 ... this is also CALL_ hooktype
* PUSH EBP 55 ... or over other HiHook at start of function E9 12 34 56 78 *** this is SPLICE_ hooktype
* VIRTUAL TABLE or similar function pointer 88 77 66 55 ... for example it would be the address being called by case #2 CALL DWORD
 valid HiHooks image
Изображение


---

So in summary, 0x4FDF6B is not valid for either HiHook or LoHook!

If you absolutely want HiHook here, try SPLICE_ & THISCALL_ at 0x4FDF64, but a LoHook will do just as fine.
Вернуться к началу

offlineas239  
имя: Анатолий
Ветеран
Ветеран
 
Сообщения: 527
Зарегистрирован: 29 дек 2018, 14:17
Пол: Мужчина
Поблагодарили: 38 раз.

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

Сообщение as239 » 17 мар 2019, 04:58

Thanks for great description.
Made LowHook at 0x4FDF64.
This condition returns false:
Код: Выделить всё
if ( MapItem->GetReal__object_type() == 54 ) ++Count;
Вернуться к началу

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

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

Сообщение RoseKavalier » 17 мар 2019, 13:56

All you should need is if (MapItem->OType == 54) {}

Apologies this is not correct, objects are not yet written to Mapitems.
Instead it is required to go through o_GameMgr->Map.Positions and o_GameMgr->Map.Types or whatever they're called in homm3.h.

Positions give you x,y,z coordinates and a reference number to Types.
Types give you type, subtype and some more details.
Вернуться к началу

offlineas239  
имя: Анатолий
Ветеран
Ветеран
 
Сообщения: 527
Зарегистрирован: 29 дек 2018, 14:17
Пол: Мужчина
Поблагодарили: 38 раз.

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

Сообщение as239 » 17 мар 2019, 15:03

Don't see something similar at _GameMap_

Изображение
Вернуться к началу

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

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

Сообщение RoseKavalier » 17 мар 2019, 16:17

Here is some shell code, not tested.

Код: Выделить всё
void ParseMapItems()
{
   _GameMap_ *map = &o_GameMgr->Map;
   _List_<_Template_> *templates = &map->Templates;
   _List_<_Object_> *objects = &map->Objects;

   for (_Object_ *obj = objects->Data; obj < objects->EndData; obj++)
   {
      _Template_ *temp = &templates->Data[obj->template_id];
      if (temp->ObjType == 54)
      {
         sprintf(o_TextBuffer, "(%d, %d, %d) %s", obj->x, obj->y, obj->z, o_CreatureInfo[temp->ObjSubtype].name_plural);
         b_MsgBox(o_TextBuffer, 1);
      }
   }
}
Вернуться к началу

offlineas239  
имя: Анатолий
Ветеран
Ветеран
 
Сообщения: 527
Зарегистрирован: 29 дек 2018, 14:17
Пол: Мужчина
Поблагодарили: 38 раз.

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

Сообщение as239 » 17 мар 2019, 17:55

Цитата:
Here is some shell code, not tested.

It works! And monsters are removing by changing they coordinates!
"MapItem1->road" is working.
So the only thing I need is - how to get passability of the tile.
"MapItem1->attrib" doesn't work. Ben80s code looks too complicated.
Also it will be fine to know is it resource at the tile.
And how to remove resource from the tile.
Вернуться к началу

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

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

Сообщение RoseKavalier » 17 мар 2019, 20:01

At this point I believe you have to recreate your own passability grid, the h3m data is already gone and MapItems attribute not yet written.
This is one of the reason post-processing is not optimal, it adds a lot of code to execute!

Using the same _Object_ and _Template_, create a grid [mapsize][mapsize] then use _Template_->ImpassBitMask and _Template_->TriggerBitMask to map out passability.

To remove an item, the optimal way (at this stage in post-processing) is to remove it from _List_<_Object_>. To do this, you need to expand _List_::DeleteEntry() to work on all item sizes.
This can be done with memmove() or simply copy the last item into the place you wish to delete.
Last step, decrease _List_<_Object_>->EndData by 1 as the list is now shorter.
Another way to remove an item is to make a list of items to delete and then use the DeleteObjectOnMap() function 0x4AA820 from heroes3 after drawing is done, then clean up everything after.

Try to create a passability grid (entrance, impassable, road) and object types, then print it out to compare.
Вернуться к началу

offlineBen80  
имя: Сергей
Эксперт
Эксперт
 
Сообщения: 1315
Зарегистрирован: 18 июн 2017, 06:49
Пол: Не указан
Поблагодарили: 336 раз.

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

Сообщение Ben80 » 17 мар 2019, 20:06

RoseKavalier писал(а):

the h3m data is already gone and MapItems attribute not yet written.


May be, simply byte - int conversation issue ?
Вернуться к началу

offlineas239  
имя: Анатолий
Ветеран
Ветеран
 
Сообщения: 527
Зарегистрирован: 29 дек 2018, 14:17
Пол: Мужчина
Поблагодарили: 38 раз.

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

Сообщение as239 » 18 мар 2019, 06:24

Need a code example, how to get passability of the tile X,Y.
Tried different variants, bot didn't get a result.
Вернуться к началу

Пред.След.

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

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

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

cron