生活情怀-神话暗黑-暗黑破坏神2

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
逗破暗黑Mod群:67994934逗破暗黑Mod客户端及补丁逗破暗黑Mod新手攻略逗破暗黑Mod赞助菜单
神话怀旧MOD群:67994934神话怀旧Mod客户端及补丁神话怀旧Mod新手攻略神话怀旧Mod赞助菜单
圣者归来Mod群:558972013圣者归来Mod客户端及补丁圣者归来Mod新手攻略圣者归来Mod赞助菜单
查看: 2335|回复: 0
收起左侧

[转载]限制护身符区域制作

[复制链接]

428

回帖

830

元宝

1

管理员

Rank: 9Rank: 9Rank: 9

积分
830
发表于 2021-10-30 23:43:58 | 显示全部楼层 |阅读模式
/*----------------------------------------------------------------分割线----------------------------------------------------------------------*/

D2Ptrs.h中:

FUNCPTR(D2COMMON, IsItemOfItemType, bool, __stdcall, (UnitAny* pItem, DWORD ItemType), 0x24430)
FUNCPTR(D2COMMON, AreCharmReqsMet, int, __stdcall, (UnitAny* pItem, UnitAny* pUnit), 0x287D0)


D2Vars.h中:

static   const char* DEFAULT_CONFIG_PATH = "D2CharmLimit.ini";
static   const char* SECTION_NAME = "D2CharmLimit";

struct Configuration
{
       int BagLeft;
       int BagRight;
       int BagTop;
       int BagBottem;
};


VAR(Configuration, Config)

void __fastcall Config_Load();

D2Vars.cpp中:

void __fastcall Config_Load()
{

       INIReader ConfigReader(DEFAULT_CONFIG_PATH);

       Config.BagLeft = ConfigReader.GetInteger(SECTION_NAME, "BagLeft", 0);
       Config.BagRight = ConfigReader.GetInteger(SECTION_NAME, "BagRight", 0);
       Config.BagTop = ConfigReader.GetInteger(SECTION_NAME, "BagTop", 0);
       Config.BagBottem = ConfigReader.GetInteger(SECTION_NAME, "BagBottem", 0);

}

CharmInv.cpp中:

const DWORD DrawRedContinue = (DLLBASE_D2CLIENT + 0x95B47);            //背包里不能用显示红色的地方
const DWORD NoDrawRedContinue = (DLLBASE_D2CLIENT + 0x95AD4);        //背包里能用显示蓝色的地方
const DWORD InvCppAddress = (DLLBASE_D2CLIENT + 0xD476C);

void __declspec (naked) __stdcall CharmInventory()
{
       __asm
       {
               test eax, eax                                                              
               jne IsCharmInventory                                                
               retn 8
IsCharmInventory:
               mov eax,[esp+4]                                                         //eax = UnitAny
               mov eax,[eax+0x2C]                                                    //eax = ItemPath
               push ebx                                                                     //此处为了读配置里的内容,以下同理
               mov ebx, Config.BagLeft                                               //ebx = 左边界
               cmp [eax+0xC],ebx                                                      //pItem与eax+C也就是dwPosX限制分界左边相比较
               pop ebx
               jb NoCharmInventory                                                    //小于就返回
               push ebx                                                                      //同上
               mov ebx, Config.BagRight
               cmp [eax+0xC],ebx
               pop ebx
               ja NoCharmInventory
               push ebx                                                                     //同上
               mov ebx, Config.BagTop
               cmp [eax+0x10],ebx
               pop ebx
               jb NoCharmInventory
               push ebx                                                                      //同上
               mov ebx, Config.BagBottem
               cmp [eax+0x10],ebx
               pop ebx
               ja NoCharmInventory
               mov eax,1                                                                    //可用
               retn 8
NoCharmInventory:
               xor eax, eax
               retn 8
       }
}

void __declspec (naked) __stdcall DrawRed()
{
       __asm
       {
               test eax,eax                                                                                //这里感觉没啥要解释的
               je DrawRed1
               push TYPE_CHARM
               push ebx
               call D2COMMON_IsItemOfItemType                                             //参数在D2Ptrs.h中明确标出
               test eax,eax
               je NoDrawRed
               mov eax,dword ptr ss:[esp+0x1C]
               push eax
               push ebx
               call D2COMMON_AreCharmReqsMet                                              //参数在D2Ptrs.h中明确标出
               test eax,eax
               je DrawRed1
               push InvCppAddress
               jmp NoDrawRedContinue

NoDrawRed:
               push InvCppAddress
               jmp NoDrawRedContinue

DrawRed1:
               jmp DrawRedContinue
       }
}


/*----------------------------------------------------------------分割线----------------------------------------------------------------------*/


文中已注释讲解

附:
D2Ptrs.h中的两Func自然不用多说
D2Vars.h和D2Vars.cpp中都是为了读写配置
此处有个BUG就是LC和GC的第一个格子所处位置有效
此BUG我会在以后尽量修复


/*----------------------------------------------------------------分割线----------------------------------------------------------------------*/

用法:
加载DLL利用大箱子或者是D2Win.dll
INI文件中四个参数很明显是定义边界的,但是需要注意的是第一格是从0开始的

此篇内容大概就酱紫吧
神话战网出品,必出精品!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|神话暗黑 ( 陕ICP备18004004号-1 )

GMT+8, 2026-1-15 06:23 , Processed in 0.062695 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表