LOCAL utf8 [400h]:BYTE
LOCAL junk:DWORD
;native DisplayTimedTextToPlayer takes player toPlayer, real x, real y, real
duration, string message returns nothing
pushad
GetBase
RLCInvoke MultiByteToWideChar,CP_ACP,NULL,pString,-1,addr unicode,400h
RLCInvoke WideCharToMultiByte,CP_UTF8,NULL,addr unicode, -1, addr utf8,
400h, NULL, NULL
lea ecx, utf8
GameCall PSaveString
push eax ; string id -> SIdToPointer
mov ecx, 1
GameCall PGetCurrentJassEnv
mov ecx, eax ; jassenv -> SIdToPointer
GameCall PSIdToPointer
push eax ; message -> DisplayTimedTextToPlayer
fild dwDuration
fstp dwDuration
lea eax, dwDuration
push eax ; duration-> DisplayTimedTextToPlayer
xor eax, eax
lea ecx, junk
mov [ecx], eax
push ecx ; y -> DisplayTimedTextToPlayer
push ecx ; x -> DisplayTimedTextToPlayer
GameCall JNGetLocalPlayer
push eax ; player -> DisplayTimedTextToPlayer
GameCall JNDisplayTimedTextToPlayer
add esp, 20
popad
ret
DisplayText endp
;SetUnitX的 Hook,用来获取英雄的unit值
;native SetUnitX takes unit whichUnit, real newX returns nothing
JNSetUnitXHook proc whichUnit:DWORD, pnewX:DWORD
pushad
GetBase
push 0 ; type = hero
push whichUnit
GameCall JNIsUnitType
mov esi, eax
GameCall JNIsUnitIllusion
not eax
and esi, eax
add esp, 8
mov edx, whichUnit
.if esi
lea esi, RLC(dwHeroIds)
.while 1
lodsd
.break .if !eax
.if eax == edx
jmp _end
.endif
.endw
mov eax, edx
lea edi, [esi-4]
stosd
.endif
_end:
popad
leave
GetBase eax
GetGameAddr JNSetUnitX, eax, eax
jmp eax
JNSetUnitXHook endp
;CreateItem的Hook,用来提示神符位置
;native CreateItem takes integer itemid, real x, real y returns item
JNCreateItemHook proc itemid:DWORD, x:DWORD, y:DWORD
LOCAL buf[400h]:BYTE
pushad
GetBase
mov eax, itemid
.if eax == 'I00K'
lea edx, RLC(T("|c000042ff双倍伤害|r"))
mov esi, 0000042ffh
jmp powerup
.elseif eax == 'I006'
lea edx, RLC(T("|c00ff0303极速|r"))
mov esi, 000ff0303h
jmp powerup
.elseif eax == 'I007' lea edx, RLC(T("|c00fffc01幻象|r"))
mov esi, 000fffc01h
jmp powerup
.elseif eax == 'I008'
lea edx, RLC(T("|cff00ff00回复|r"))
mov esi, 0ff00ff00h
jmp powerup
.elseif eax == 'I00J'
lea edx, RLC(T("|cff99ccff隐形|r"))
mov esi, 0ff99ccffh
jmp powerup
.endif
jmp _end
powerup:
mov eax, y
mov eax, [eax]
push eax
fld DWORD ptr [esp]
fistp DWORD ptr [esp]
pop eax
;这里不能简单的判断神符的坐标是正还是负来判断神符是在上路还是下路,因为
使用瓶子内的神符实际上是创建一个神符然后立即吃掉,所以会误报。
.if eax == -2832
lea ecx, RLC(T("下路"))
.elseif eax == 1648
lea ecx, RLC(T("上路"))
.else
jmp _end
.endif
lea eax, RLC(T("神符 %s 在 |cfffffc00%s|r 刷新了!"))
RLCInvoke wsprintf, addr buf, eax, edx, ecx
add esp, 16 ;wsprintf是 C调用约定的
invoke DisplayText, addr buf, 10
mov eax, x
mov ecx, [eax]
mov eax, y
mov edx, [eax]
invoke PingMiniMapEx, ecx, edx, 41800000h, esi, 1 ; 10.0
jmp _end
_end:
popad
leave
GetBase eax
GetGameAddr JNCreateItem, eax, eax
jmp eax
JNCreateItemHook endp
;CreateUnit的Hook,用来决定游戏状态,添加AddNativesHook,提示Roshan复活
;native CreateUnit takes player id, integer unitid, real x, real y, real face
returns unit |