-
Notifications
You must be signed in to change notification settings - Fork 13
/
MonsterLifeBar.cpp
191 lines (164 loc) · 4.46 KB
/
MonsterLifeBar.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
#include "stdafx.h"
#ifdef MODULE_MONSTERLIFEBAR
//返回调整后的Xpos
long __fastcall MonsterNamePatch(wchar_t *wszName, long xPos , UnitAny *pMon ,long xDrawSize ,long xDrawOffset)
{
int orilen = wcslen(wszName);
int trimlen = orilen;
while (trimlen > 0 && wszName[trimlen-1] == L' ') {
trimlen--;
}
wszName[trimlen] = L'\0';
if ( tMonsterLevel.isOn || tMonsterRuneTC.isOn || tMonsterTC.isOn){
int lvl = 0;
MonsterTxt *pMonTxt= pMon->pMonsterData->pMonsterTxt;
if( pMonTxt->fBoss == 0 && DIFFICULTY && EXPANSION){
lvl = GetAreaLevel();
}
else{
lvl = D2GetUnitStat(pMon, STAT_LEVEL, 0);
}
if ( pMonTxt->fBoss == 1 && pMon->pMonsterData->wUniqueNo == 0 && !(pMonTxt->hcIdx>=546 && pMonTxt->hcIdx<=550 )) {
//Putrid Defiler 不受场景等级影响但受+2 +3影响
//超级金怪受+3规则影响
} else {
if ( pMon->pMonsterData->fChamp ){
lvl += 2;
} else if ( pMon->pMonsterData->fBoss || pMon->pMonsterData->fMinion ) {
lvl += 3;
}
}
if (tMonsterLevel.isOn) {
wsprintfW(wszName+wcslen(wszName), L" (L%d)", lvl);
}
if (tMonsterRuneTC.isOn || tMonsterTC.isOn) {
BYTE tcmode;
WORD nTc;
if (pMon->pMonsterData->fChamp )
tcmode=1;
else if ( pMon->pMonsterData->fBoss || pMon->pMonsterData->fMinion )
tcmode=2;
else
tcmode=0;
if ( pMon->pMonsterData->fUnique ){
SuperUniqueTxt *pSuperUniqueTxt = D2GetSuperUniqueTxt(pMon->pMonsterData->wUniqueNo);
nTc = pSuperUniqueTxt->Tcs[DIFFICULTY];
}else{
nTc = pMonTxt->Tcs[DIFFICULTY][tcmode];
}
MonTC *pMonTC = GetTcLevel(nTc , lvl);
if ( tMonsterTC.isOn )
wsprintfW(wszName+wcslen(wszName), L" (tc%d)", pMonTC->nTc);
if ( tMonsterRuneTC.isOn && EXPANSION )
wsprintfW(wszName+wcslen(wszName), L" (rtc%d)", pMonTC->nRtc);
}
}
if ( tMonsterHPPercent.isOn ){
wsprintfW(wszName+wcslen(wszName), L" (%d%%)", D2GetMonsterHpPercent(pMon));
}
if ( tMonsterDistance.isOn ){
char strVal [10] ;
DblToStr( GetUnitDistanceInSubtiles(pMon,PLAYER) ,2 , strVal);
wsprintfW2(wszName+wcslen(wszName), " (%s yards)", strVal);
}
if ( tMonsterID.isOn ){
wsprintfW(wszName+wcslen(wszName), L" (ID:%d)", pMon->dwTxtFileNo);
}
if(tMonsterResists.isOn){
int dr = D2GetUnitStat(pMon, STAT_DAMAGE_REDUCED, 0);
int mr = D2GetUnitStat(pMon, STAT_MAGIC_RESIST, 0);
int fr = D2GetUnitStat(pMon, STAT_FIRE_RESIST, 0);
int lr = D2GetUnitStat(pMon, STAT_LIGHTING_RESIST, 0);
int cr = D2GetUnitStat(pMon, STAT_COLD_RESIST, 0);
int pr = D2GetUnitStat(pMon, STAT_POSION_RESIST, 0);
if (dr| mr | fr | lr | cr | pr) {
wsprintfW(wszName+wcslen(wszName), L" (Res:");
if (dr) wsprintfW2Colour(wszName+wcslen(wszName), 7, " D%d", dr); // Golden
if (mr) wsprintfW2Colour(wszName+wcslen(wszName), 8, " M%d", mr); // Deep yellow
if (fr) wsprintfW2Colour(wszName+wcslen(wszName), 1, " F%d", fr); // Red
if (lr) wsprintfW2Colour(wszName+wcslen(wszName), 9, " L%d", lr); // Light yellow
if (cr) wsprintfW2Colour(wszName+wcslen(wszName), 3, " C%d", cr); // Blue
if (pr) wsprintfW2Colour(wszName+wcslen(wszName), 2, " P%d", pr); // Green
wsprintfW(wszName+wcslen(wszName), L")");
}
}
int l = orilen - trimlen;
while (l-- > 0) {
wcscat(wszName, L" ");
}
int newlen = GetTextWidth(wszName);
xPos = xDrawSize + xDrawOffset ;
if ( newlen > xPos) return 1;
return ( xPos - newlen ) /2;
}
void __declspec(naked) MonsterNamePatch_ASM()
{
//ecx wszName
//edx xpos
//ebx pUnit
//[esp+0x38] xpos offset
__asm {
push ecx
push [esp+0x3C]
push [esp+0x48]
push ebx
call MonsterNamePatch
pop ecx
mov edx , eax
jmp D2DrawUnitLifeBar
}
}
static wchar_t szMonsterDescComma[] = L", ";
void __declspec(naked) MonsterDescCommaPatch1_ASM()
{
__asm {
mov eax,offset szMonsterDescComma
ret
}
}
void __declspec(naked) MonsterDescCommaPatch2_ASM()
{
__asm {
mov edx,offset szMonsterDescComma
ret
}
}
void __fastcall MonsterDescCommaPatch3(wchar_t *wszStr, MonsterTxt *pMonTxt)
{
if (pMonTxt->wFlag == 0x1506) {
wcscat(wszStr, szMonsterDescComma);
}
}
void __declspec(naked) MonsterDescCommaPatch3_ASM()
{
__asm {
//ecx = ptr string
//[esp+0x20] = ptr monstats.txt
mov edx,[esp+0x20]
call MonsterDescCommaPatch3
mov ecx, [esp+0x20];
ret
}
}
void __declspec(naked) LifeBarPatch_ASM()
{
__asm {
pop ebp
//originalish code
movzx eax,[nLifeBarTrans]
cmp al,-1
jne nodefault1
mov al,1
nodefault1:
push eax
mov al,[nLifeBarColour]
cmp al,-1
jne nodefault2
mov al,5
nodefault2:
push eax
sar ecx,7
jmp ebp
}
}
#endif