-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathItemName.cpp
222 lines (187 loc) · 5.92 KB
/
ItemName.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#include "stdafx.h"
#ifdef MODULE_ITEMNAME
BOOL ItemHaveLevel(BYTE nType)
{
if (nType==74)return FALSE;
if (nType==4)return FALSE;
if (nType==22)return FALSE;
if (nType>=76 && nType<=81)return FALSE;
if (nType>=91 && nType<=102)return FALSE;
return TRUE;
}
void __fastcall ItemNamePatch(wchar_t *wscNameOld, UnitAny *pItem ,ItemTxt *pItemTxt ){
wchar_t wscTemp[0x40];
memset(wscTemp,0,sizeof(wscTemp));
wchar_t wscName[0x100];
memset(wscName,0,sizeof(wscName));
wcscpy(wscName,wscNameOld);
BYTE nColour = GetItemColour(pItem,0);
int itemIndex = GetItemIndex(pItem->dwTxtFileNo);
trimspaces(wscName);
if (pItemTxt->nType==4) {// gold
wcsrcat(wscName, wsprintfW2(wscTemp, "%d ", D2GetUnitStat(pItem, STAT_GOLD, 0) ) );
}else{
DWORD dwQuality =(pItem->pItemData->dwQuality-1)&7;
if ( (nColour == (BYTE)-1 ) && pItemTxt->fQuest) {
nColour = nQuestItemColour; //任务物品
}
if ( pItemTxt->fQuest && pItemTxt->fDiffCheck && D2GetUnitStat(pItem, STAT_ITEMDIFFICULTY, 0)< DIFFICULTY ){
nColour = (BYTE)-1 ; //无效任务道具,原代码会校验,不着色
}
if ( D2CheckItemFlag(pItem, ITEMFLAG_BROKEN, 0, "?") ){
nColour = 1 ; //损坏的道具
};
// ethereal
if ( D2CheckItemFlag(pItem, ITEMFLAG_ETHEREAL, 0, "?") )
{
if (pItemTxt->dwMinDef>0 && (wszEtherealBugItemPrefix[0]||wszEtherealBugItemPostfix[0])){
int mDef = D2GetUnitBaseStat(pItem, 31,0);
int mMinDef = pItemTxt->dwMinDef;
int mMaxDef = pItemTxt->dwMaxDef ;
mMinDef = (int)(mMinDef * 1.5) ;
mMaxDef = (int)(mMaxDef * 1.5) ;
if ( mDef>mMaxDef && pItem->pItemData->dwQuality==2 && D2CheckItemFlag(pItem, ITEMFLAG_SOCKETED, 0, "?") ){
if (wszEtherealBugItemPrefix[0]){
wcsrcat(wscName, wscolorcpy(wscTemp,wszEtherealBugItemPrefix,nColour));
}
if (wszEtherealBugItemPostfix[0]){
wscolorcpy(wscName+wcslen(wscName),wszEtherealBugItemPostfix,nColour);
}
}
}
if (wszEtherealItemPrefix[0]){
wcsrcat(wscName, wscolorcpy(wscTemp,wszEtherealItemPrefix,nColour));
}
if (wszEtherealItemPostfix[0]){
wscolorcpy(wscName+wcslen(wscName),wszEtherealItemPostfix,nColour);
}
}
// rune numbers
if (tRuneNumbers.isOn && (pItemTxt->nType == 74)) {
int bktnum = (pItemTxt->szCode[1]-'0')*10+(pItemTxt->szCode[2]-'0');
wsprintfW(wscName+wcslen(wscName), L" (%d)", bktnum);
}
// socket number
if (tSocketNumbers.isOn && D2CheckItemFlag(pItem, ITEMFLAG_SOCKETED, 0, "?") ) {
wsprintfW(wscName+wcslen(wscName), L" (%d)", D2GetUnitStat(pItem, STAT_NUMSOCKETS, 0) );
}
// item level
if (tItemLevel.isOn && ItemHaveLevel(pItemTxt->nType)) {
wsprintfW(wscName+wcslen(wscName), L" (%ld)", pItem->pItemData->dwItemLevel);
}
// item value
if (tItemValue.isOn && (pItemTxt->fQuest == 0) && D2CheckUiStatus(UIVAR_NPCTRADE)==0 ) {
wsprintfW(wscName+wcslen(wscName), L" ($%d)", D2GetItemValue( PLAYER, pItem, DIFFICULTY, QUESTDATA, dwItemValueNpc[ACTNO], 1));
}
// unit number
if (tUnitNumber.isOn) {
wsprintfW(wscName+wcslen(wscName), L" [0x%X]", pItem->dwUnitId);
}
// item index
if (tItemIndex.isOn) {
wsprintfW(wscName+wcslen(wscName), L" [i%d]", itemIndex + 1 );
}
// item type
if (tItemType.isOn) {
wsprintfW(wscName+wcslen(wscName), L" [T%d]", pItemTxt->nType );
}
// item Qlevel
if (tItemQLevel.isOn) {
wsprintfW(wscName+wcslen(wscName), L" (Q:%ld)", pItemTxt->nQLevel);
}
// item Magiclevel
if (tItemMLevel.isOn) {
wsprintfW(wscName+wcslen(wscName), L" (M:%ld)", pItemTxt->nMagicLvl);
}
// item Alevel
if (tItemALevel.isOn) {
if (dwQuality==3 || dwQuality==5 || dwQuality==7){
wsprintfW(wscName+wcslen(wscName), L" (A:%ld)", GetItemAlvl( pItem->pItemData->dwItemLevel,pItemTxt->nQLevel,pItemTxt->nMagicLvl) );
}
}
if (tAfterCube.isOn)
{
if (dwQuality==3)
{
int iLvl = GetItemILvlAfterCube( 1 , pItem->pItemData->dwItemLevel ,D2GetUnitStat(PLAYER, STAT_LEVEL, 0) );
wcsrcat(wscName, wsprintfW2(wscTemp, "[After Craft Ilvl: %ld Alvl: %ld]\n",iLvl,GetItemAlvl(iLvl,pItemTxt->nQLevel,pItemTxt->nMagicLvl)) );
}
else if (dwQuality==5)
{
int iLvl = GetItemILvlAfterCube( 2 , pItem->pItemData->dwItemLevel ,D2GetUnitStat(PLAYER, STAT_LEVEL, 0));
wcsrcat(wscName, wsprintfW2(wscTemp, "[After Cube Ilvl: %ld Alvl: %ld]\n",iLvl,GetItemAlvl(iLvl,pItemTxt->nQLevel,pItemTxt->nMagicLvl)) );
}
}
if ( D2CheckItemFlag(pItem, ITEMFLAG_RUNEWORD, 0, "?") ){
if ( tLifePerLevel.isOn ){
int iPerlvValue=D2GetUnitStat(pItem, 216, 0);
if (iPerlvValue)
{
char strVal [10] ;
DblToStr(((double)iPerlvValue)/2048,3,strVal);
wcsrcat(wscName, wsprintfW2(wscTemp, "[%s life/level]\n",strVal) );
}
}
if (tShowBaseED.isOn){
int ed = 0 ;
if( itemIndex<1000 ){//武器
ed = GetUnitMagicStat(pItem, 0x11);
}else{//防具
ed = GetUnitMagicStat(pItem, 0x10);
}
wcsrcat(wscName, wsprintfW2(wscTemp, "[Base Ed: %ld%%]\n",ed) );
}
}
// item file index
if (tItemFileIndex.isOn) {
wcsrcat(wscName, wsprintfW2(wscTemp, " [TXT:%d F:%d Type:%d]\n",pItem->dwTxtFileNo, D2GetItemFileIndex(pItem) ,pItemTxt->nType ) );
}
}
if (nColour != (BYTE)-1) ColourD2String(wscName, nColour);
wscName[124] = 0 ;
wcscpy(wscNameOld,wscName);
}
void __declspec(naked) ItemNamePatch_ASM()
{
__asm {
//ebx = ptr unit item
//edi = ptr item name string
//ebp = pItemTxt
push ebx
push ebp
push edi
mov ecx, edi
mov edx, ebx
push ebp
call ItemNamePatch
pop edi
pop ebp
pop ebx
mov al, [ebp+0x12A]
ret
}
}
wchar_t * __fastcall OpenCubeStringPatch(wchar_t *wcstr, DWORD dwColour)
{
BYTE nColour = (BYTE)anItemColours[2041][0][0][0][0];
if ( nColour != (BYTE)-1){
return ColourD2String(wcstr, nColour);
}
if ( nQuestItemColour != (BYTE)-1 ){
return ColourD2String(wcstr, nQuestItemColour);
}else{
return wcstr;
}
}
void __declspec(naked) OpenCubeStringPatch_ASM()
{
__asm {
//edi = str
//esi = col
mov ecx, edi
mov edx, esi
call OpenCubeStringPatch
ret 4
}
}
#endif