VladimirMakeev / D2ModdingToolset

Mss32 proxy DLL for Disciples 2
GNU General Public License v3.0
32 stars 13 forks source link

Different costs of Rod-planting for every race #152

Open Positiff88 opened 2 years ago

Positiff88 commented 2 years ago

At the moment Rod-planting cost is the same for all races and specified in GVars.dbf in a ROD_COST column. Please add an ability to specify different costs for every race, so it can be possible to require some amount of mana to plant a rod (land transformation seems to be some magic-involved action, so it is logical to spend mana for it).

Positiff88 commented 1 year ago

Do you have a hook for the function which control rod planting and its cost, so I can implement this issue myself? Or it needs to be reverse engineered first? I was unable to find such a hook in a project.

VladimirMakeev commented 1 year ago

There is no such hook since library does not change rod planting cost, you need to find it yourself.

VladimirMakeev commented 1 year ago

You will need to hook at least 4 functions for this. In terms of Akella or Russobit-M game executables, their addresses are:

Positiff88 commented 1 year ago

Thank you. It will help. By the way, do you have C code file or IDA Pro database with all other game functions you already know about? Please share if any. It is hard to understand the logic of needed functions from scratch if all other functions have no meaningful names, especially with my pretty low level of knowledge about Assembler and C languages. Is there any documentation about D2ModdingToolset possibilities in function hooks? For example, can I modify only part of the function (which takes rod planting cost from the value taken from ROD_COST column) and then return back to its execution, or I need to rewrite it's code completely (so I need to hook also all functions it is using inside)?

VladimirMakeev commented 1 year ago

You can upload data structures and function from this repo into your IDA db to simplify things, but you will need some understanding of asm and low-level c++ implementation to do the modding. Make sure you upload only those in namespace game or namespace <Something>Api. The only possibility of mss32 is to change data in running game process memory. With this you can hook functions (for convenience this does Detours library), you can change single instructions (first version of crit chance was implemented this way) or you can change data, for example maximum damage value. I and Unven agreed we will not mess with changes of single instructions and inline asm, but it is up to you what tools to choose. Sometimes it easier to change couple of instructions to get desired effect, but when we need to change game function behavior we hook it and reimplement it with our logic. There is no need to reimplement all nested functions, they can be described as function pointers and called - just make sure function signature is the same or behaves the same (no stack corruptions)