Skip to content

Commit

Permalink
-fix get ip function
Browse files Browse the repository at this point in the history
-change getskill to ignore charge skills by default, added new arg to if you want charge skills specifically
-add print fix in console from assembla "Fix print issue -r57shell"
  • Loading branch information
noah- committed Jun 10, 2018
1 parent 9508648 commit c4d3659
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 25 deletions.
1 change: 1 addition & 0 deletions Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ void Print(const char * szFormat, ...)
for(list<string>::iterator it = lines.begin(); it != lines.end(); ++it)
{
wchar_t * output = AnsiToUnicode(it->c_str());
replace(output, output+it->length(), 0xFFFF, 0xFF);
D2CLIENT_PrintGameString(output, 0);
delete [] output;
}
Expand Down
2 changes: 1 addition & 1 deletion D2BS.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#define XP_WIN

#define D2BS_VERSION "1.5.1867" //uptodate with d branch 1765 ff 20b
#define D2BS_VERSION "1.5.1868"

#include <windows.h>
#include <vector>
Expand Down
4 changes: 2 additions & 2 deletions JSCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,17 +681,17 @@ JSAPI_FUNC(my_getIP)
char buffer[32];

hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
hFile = InternetOpenUrl(hInternet, "http://automation.whatismyip.com/n09230945.asp", NULL, 0, INTERNET_FLAG_RELOAD, 0);
hFile = InternetOpenUrl(hInternet, "http://ipv4bot.whatismyipaddress.com", NULL, 0, INTERNET_FLAG_RELOAD, 0);
InternetReadFile(hFile, &buffer, sizeof(buffer), &rSize);
buffer[rSize] = '\0';

InternetCloseHandle(hFile);
InternetCloseHandle(hInternet);
JS_BeginRequest(cx);
JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(JS_NewStringCopyZ(cx, (char *)buffer)));
JS_EndRequest(cx);
return JS_TRUE;
}

JSAPI_FUNC(my_sendClick)
{
JS_SET_RVAL(cx, vp, JSVAL_NULL);
Expand Down
54 changes: 32 additions & 22 deletions JSUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,25 +755,25 @@ JSAPI_FUNC(unit_getNext)
}

JSAPI_FUNC(unit_cancel)
{
{
if(!WaitForGameReady())
THROW_WARNING(cx, vp, "Game not ready");

DWORD automapOn = *p_D2CLIENT_AutomapOn;


DWORD automapOn =*p_D2CLIENT_AutomapOn;

if(IsScrollingText())
if(argc > 0)
D2CLIENT_CloseInteract();
else if(IsScrollingText())
D2CLIENT_ClearScreen();
else if(D2CLIENT_GetCurrentInteractingNPC())
else if(D2CLIENT_GetCurrentInteractingNPC())
D2CLIENT_CloseNPCInteract();
else if(D2CLIENT_GetCursorItem())
D2CLIENT_ClickMap(0, 10, 10, 0x08);
else
D2CLIENT_CloseInteract();
*p_D2CLIENT_AutomapOn =automapOn;

*p_D2CLIENT_AutomapOn = automapOn;

return JS_TRUE;
}

Expand Down Expand Up @@ -1421,37 +1421,48 @@ JSAPI_FUNC(unit_getItems)

JSAPI_FUNC(unit_getSkill)
{
if(argc == NULL || argc > 3)
return JS_TRUE;

if(!WaitForGameReady())
THROW_WARNING(cx, vp, "Game not ready");

bool nCharge = false;
jsint nSkillId = NULL;
jsint nExt = NULL;

myUnit* pmyUnit = (myUnit*)JS_GetPrivate(cx, JS_THIS_OBJECT(cx, vp));
if(!pmyUnit)
return JS_TRUE;

UnitAny* pUnit = D2CLIENT_FindUnit(pmyUnit->dwUnitId, pmyUnit->dwType);
if(!pUnit)
return JS_TRUE;

if(argc == NULL)
return JS_TRUE;

if(argc == 1)
if(argc >= 1)
{
if(!JSVAL_IS_INT(JS_ARGV(cx, vp)[0]))
return JS_TRUE;

nSkillId = JSVAL_TO_INT(JS_ARGV(cx, vp)[0]);
}
else if(argc == 2)

if(argc >= 2)
{
if(!JSVAL_IS_INT(JS_ARGV(cx, vp)[0]) || !JSVAL_IS_INT(JS_ARGV(cx, vp)[1]))
if(!JSVAL_IS_INT(JS_ARGV(cx, vp)[1]))
return JS_TRUE;

nSkillId = JSVAL_TO_INT(JS_ARGV(cx, vp)[0]);
nExt = JSVAL_TO_INT(JS_ARGV(cx, vp)[1]);
}

if(argc == 3)
{
if(!JSVAL_IS_BOOLEAN(JS_ARGV(cx, vp)[2]))
return JS_TRUE;

nCharge = !!JSVAL_TO_BOOLEAN(JS_ARGV(cx, vp)[2]);
}

if(argc == 1)
{
WORD wLeftSkillId = pUnit->pInfo->pLeftSkill->pSkillInfo->wSkillId;
Expand Down Expand Up @@ -1521,24 +1532,23 @@ JSAPI_FUNC(unit_getSkill)
}
return JS_TRUE;
}
else if(argc == 2)

if(pUnit && pUnit->pInfo && pUnit->pInfo->pFirstSkill)
{
if(pUnit && pUnit->pInfo && pUnit->pInfo->pFirstSkill)
for(Skill* pSkill = pUnit->pInfo->pFirstSkill; pSkill; pSkill = pSkill->pNextSkill)
{
for(Skill* pSkill = pUnit->pInfo->pFirstSkill; pSkill; pSkill = pSkill->pNextSkill)
if(pSkill->pSkillInfo && pSkill->pSkillInfo->wSkillId == nSkillId)
{
if(pSkill->pSkillInfo && pSkill->pSkillInfo->wSkillId == nSkillId)
if((argc == 2 && pSkill->IsCharge == 0) || (argc == 3 && (nCharge == false || pSkill->IsCharge == 1)))
{
JS_SET_RVAL(cx, vp, INT_TO_JSVAL(D2COMMON_GetSkillLevel(pUnit, pSkill, nExt)));
return JS_TRUE;
}
}
}

}

JS_SET_RVAL(cx, vp, JSVAL_FALSE);

return JS_TRUE;
}

Expand Down

0 comments on commit c4d3659

Please sign in to comment.