コード例 #1
0
DWORD __stdcall searchthread(PVOID pData)
{
	lockit lk(bzsrchhandle);
	if (CSidlScreenWnd *ptr = (CSidlScreenWnd *)pBazaarSearchWnd->GetChildItem("BZR_QueryButton")) {
		ULONGLONG startwait = MQGetTickCount64();
		startwait += 5000;
		while (ptr->Enabled == 0) {
			Sleep(100);
			if (startwait < MQGetTickCount64()) {
				MacroError("timed out in /bzsrch waiting for BZR_QueryButton to enable.");
				break;
			}
		}
		if (ptr->Enabled) {
			if (CListWnd *ptr = (CListWnd *)pBazaarSearchWnd->GetChildItem("BZR_ItemList")) {
				ptr->DeleteAll();
			}
			BzCount = 0;
			BzDone = 0;
			SendWndClick2((CXWnd*)ptr, "leftmouseup");
		} else {
			MacroError("woah! hold your horses there bazaarmule... BZR_QueryButton is not enabled, I suggest you check that in your macro before you issue a /bzsrch command.");
		}
	}
	return 0;
}
コード例 #2
0
DWORD __stdcall searchthread(PVOID pData)
{
	lockit lk(bzsrchhandle,"searchthread");
	if (CSidlScreenWnd *pQueryButton = (CSidlScreenWnd *)pBazaarSearchWnd->GetChildItem("BZR_QueryButton")) {
		ULONGLONG startwait = MQGetTickCount64();
		startwait += 7000;
		while (pQueryButton->Enabled == 0) {
			Sleep(0);
			if (startwait < MQGetTickCount64()) {
				WriteChatfSafe("1. timed out in /bzsrch waiting for BZR_QueryButton to enable.");
				break;
			}
		}
		if (pQueryButton->Enabled) {
			HideDoCommand((PSPAWNINFO)pLocalPlayer,"/bzquery",true);	
			startwait = MQGetTickCount64() + 2000;
			while (pQueryButton && pQueryButton->Enabled == 0 && BzDone==FALSE) {
				Sleep(0);
				if (startwait < MQGetTickCount64()) {
					break;
				}
			}
			if (BzDone == FALSE) {
				BzDone = TRUE;
			}
		} else {
			WriteChatfSafe("woah! hold your horses there bazaarmule... BZR_QueryButton is not enabled, I suggest you check that in your macro before you issue a /bzsrch command.");
		}
	} else {
		WriteChatfSafe("Whats wrong? couldnt find the BZR_QueryButton window.");
	}
	return 0;
}
コード例 #3
0
ファイル: MQ2CommandAPI.cpp プロジェクト: isxGames/ISXEQ
VOID TimedCommand(PCHAR Command, DWORD msDelay)
{
    PTIMEDCOMMAND pNew= new TIMEDCOMMAND;
    pNew->Time=msDelay+MQGetTickCount64();
    strcpy(pNew->Command,Command);

    // insert into list

    if (!pTimedCommands || pTimedCommands->Time>=pNew->Time)
    {
        pNew->pNext=pTimedCommands;
        pNew->pLast=0;
        pTimedCommands=pNew;
        return;
    }

    PTIMEDCOMMAND pLast=pTimedCommands;
    PTIMEDCOMMAND pNode=pTimedCommands->pNext;
    while(pNode)
    {
        if (pNew->Time<=pNode->Time)
        {
            break;
        }
        pLast=pNode;
        pNode=pNode->pNext;
    }
    pLast->pNext=pNew;
    pNew->pLast=pLast;
    pNew->pNext=pNode;
}
コード例 #4
0
ファイル: MQ2CommandAPI.cpp プロジェクト: isxGames/ISXEQ
VOID DoTimedCommands()
{
    ULONGLONG Now=MQGetTickCount64();
    while(pTimedCommands && pTimedCommands->Time<=Now)
    {
        PTIMEDCOMMAND pNext=pTimedCommands->pNext;
        DoCommand(((PCHARINFO)pCharData)->pSpawn,pTimedCommands->Command);
        delete pTimedCommands;
        pTimedCommands=pNext;
    }
}
コード例 #5
0
ファイル: MQ2Pulse.cpp プロジェクト: clausjensen/mq
void Pulse()
{
	if (!ppCharSpawn || !pCharSpawn) return;
	PSPAWNINFO pCharOrMount = NULL;
	PCHARINFO pCharInfo = GetCharInfo();
	PSPAWNINFO pChar = pCharOrMount = (PSPAWNINFO)pCharSpawn;
	if (pCharInfo && pCharInfo->pSpawn) pChar = pCharInfo->pSpawn;

	static WORD LastZone = -1;

	static PSPAWNINFO pCharOld = NULL;
	static FLOAT LastX = 0.0f;
	static FLOAT LastY = 0.0f;
	static ULONGLONG LastMoveTick = 0;
	static DWORD MapDelay = 0;

	static DWORD LastHealth = 0;
	static DWORD LastMana = 0;
	static DWORD LastEndurance = 0;



	// Drop out here if we're waiting for something.
	if (!pChar || gZoning /* || gDelayZoning*/) return;
	if (!pCharInfo) {
		//DebugSpew("Pulse: no charinfo returning\n");
		return;
	}

	if ((unsigned int)GetCharInfo()->charinfo_info & 0x80000000) return;

	if (pChar != pCharOld && WereWeZoning)
	{
		WereWeZoning = FALSE;
		pCharOld = pChar;
		gFaceAngle = 10000.0f;
		gLookAngle = 10000.0f;
		gbMoving = FALSE;
		LastX = pChar->X;
		LastY = pChar->Y;
		LastMoveTick = MQGetTickCount64();
		EnviroTarget.Name[0] = 0;
		pGroundTarget = 0;
		DoorEnviroTarget.Name[0] = 0;
		pDoorTarget = 0;
		LastHealth = GetCurHPS();
		LastMana = GetCharInfo2()->Mana;
		LastEndurance = GetCharInfo2()->Endurance;
		ManaGained = 0;
		HealthGained = 0;
		EnduranceGained = 0;
		// see if we're on a pvp server
		if (!_strnicmp(EQADDR_SERVERNAME, "tallon", 6) || !_strnicmp(EQADDR_SERVERNAME, "vallon", 6))
		{
			PVPServer = PVP_TEAM;
		}
		else if (!_strnicmp(EQADDR_SERVERNAME, "sullon", 6))
		{
			PVPServer = PVP_SULLON;
		}
		else if (!_strnicmp(EQADDR_SERVERNAME, "rallos", 6))
		{
			PVPServer = PVP_RALLOS;
		}
		else
			PVPServer = PVP_NONE;
		srand((unsigned int)time(NULL) + (unsigned int)GetCurrentProcessId()); // reseed
		Benchmark(bmPluginsOnZoned, PluginsZoned());

	}
	else if ((LastX != pChar->X) || (LastY != pChar->Y) || LastMoveTick>MQGetTickCount64() - 100) {
		if ((LastX != pChar->X) || (LastY != pChar->Y)) LastMoveTick = MQGetTickCount64();
		gbMoving = TRUE;
		LastX = pChar->X;
		LastY = pChar->Y;
	}
	else {
		gbMoving = FALSE;
	}

	DWORD CurrentHealth = GetCurHPS();
	if (LastHealth && CurrentHealth>LastHealth)
	{
		if ((int)pChar->HPCurrent != GetMaxHPS())
		{ // gained health, and not max
			HealthGained = CurrentHealth - LastHealth;
		}
	}
	LastHealth = CurrentHealth;

	if (LastMana && GetCharInfo2()->Mana > LastMana)
	{
		if ((int)GetCharInfo2()->Mana - LastMana > 0)
		{
			ManaGained = GetCharInfo2()->Mana - LastMana;
		}
	}
	LastMana = GetCharInfo2()->Mana;

	if (LastEndurance && GetCharInfo2()->Endurance > LastEndurance)
	{
		if (GetCharInfo2()->Endurance != GetMaxEndurance())
		{
			EnduranceGained = GetCharInfo2()->Endurance - LastEndurance;
		}
	}
	LastEndurance = GetCharInfo2()->Endurance;

	if (gbDoAutoRun && pChar && pCharInfo) {
		gbDoAutoRun = FALSE;
#ifndef EMU
		InitKeyRings();
#endif
		CHAR szServerAndName[MAX_STRING] = { 0 };
		CHAR szAutoRun[MAX_STRING] = { 0 };
		PCHAR pAutoRun = szAutoRun;
		/* autorun for everyone */
		GetPrivateProfileString("AutoRun", "ALL", "", szAutoRun, MAX_STRING, gszINIFilename);
		while (pAutoRun[0] == ' ' || pAutoRun[0] == '\t') pAutoRun++;
		if (szAutoRun[0] != 0) DoCommand(pChar, pAutoRun);
		/* autorun for toon */
		ZeroMemory(szAutoRun, MAX_STRING); pAutoRun = szAutoRun;
		sprintf(szServerAndName, "%s.%s", EQADDR_SERVERNAME, pCharInfo->Name);
		GetPrivateProfileString("AutoRun", szServerAndName, "", szAutoRun, MAX_STRING, gszINIFilename);
		while (pAutoRun[0] == ' ' || pAutoRun[0] == '\t') pAutoRun++;
		if (szAutoRun[0] != 0) DoCommand(pChar, pAutoRun);
	}

	if ((gFaceAngle != 10000.0f) || (gLookAngle != 10000.0f)) {
		TurnNotDone = FALSE;
		if (gFaceAngle != 10000.0f) {
			if (abs((INT)(pCharOrMount->Heading - gFaceAngle)) < 10.0f) {
				pCharOrMount->Heading = (FLOAT)gFaceAngle;
				pCharOrMount->SpeedHeading = 0.0f;
				gFaceAngle = 10000.0f;
			}
			else {
				TurnNotDone = TRUE;
				DOUBLE c1 = pCharOrMount->Heading + 256.0f;
				DOUBLE c2 = gFaceAngle;
				if (c2<pChar->Heading) c2 += 512.0f;
				DOUBLE turn = (DOUBLE)(rand() % 200) / 10;
				if (c2<c1) {
					pCharOrMount->Heading += (FLOAT)turn;
					pCharOrMount->SpeedHeading = 12.0f;
					if (pCharOrMount->Heading >= 512.0f) pCharOrMount->Heading -= 512.0f;
				}
				else {
					pCharOrMount->Heading -= (FLOAT)turn;
					pCharOrMount->SpeedHeading = -12.0f;
					if (pCharOrMount->Heading<0.0f) pCharOrMount->Heading += 512.0f;
				}
			}
		}

		if (gLookAngle != 10000.0f) {
			if (abs((INT)(pChar->CameraAngle - gLookAngle)) < 5.0f) {
				pChar->CameraAngle = (FLOAT)gLookAngle;
				gLookAngle = 10000.0f;
				TurnNotDone = FALSE;
			}
			else {
				TurnNotDone = TRUE;
				FLOAT c1 = pChar->CameraAngle;
				FLOAT c2 = (FLOAT)gLookAngle;

				DOUBLE turn = (DOUBLE)(rand() % 200) / 20;
				if (c1<c2) {
					pChar->CameraAngle += (FLOAT)turn;
					if (pChar->CameraAngle >= 128.0f) pChar->CameraAngle -= 128.0f;
				}
				else {
					pChar->CameraAngle -= (FLOAT)turn;
					if (pChar->CameraAngle <= -128.0f) pChar->CameraAngle += 128.0f;
				}
			}
		}

		if (TurnNotDone) {
			bRunNextCommand = FALSE;
			IsMouseWaiting();
			return;
		}
	}
}
コード例 #6
0
ファイル: MQ2Pulse.cpp プロジェクト: clausjensen/mq
void Heartbeat()
{
	if (gbUnload)
		return;
	static ULONGLONG LastGetTick = 0;
	static bool bFirstHeartBeat = true;
	static ULONGLONG TickDiff = 0;
	static fMQPulse pEQPlayNicePulse = NULL;
	static DWORD BeatCount = 0;

	ULONGLONG Tick = MQGetTickCount64();

	BeatCount++;

	if (bFirstHeartBeat)
	{
		LastGetTick = Tick;
		bFirstHeartBeat = false;
	}
	// This accounts for rollover
	TickDiff += (Tick - LastGetTick);
	LastGetTick = Tick;
#ifndef ISXEQ
	while (TickDiff >= 100) {
		TickDiff -= 100;
		if (gDelay>0) gDelay--;
		DropTimers();
	}
#endif
	if (!gStringTableFixed && pStringTable) // Please dont remove the second condition
	{
		FixStringTable();
		gStringTableFixed = TRUE;
	}

	DebugTry(int GameState = GetGameState());
	if (GameState != -1)
	{
		if ((DWORD)GameState != gGameState)
		{
			DebugSpew("GetGameState()=%d vs %d", GameState, gGameState);
			gGameState = GameState;
			DebugTry(Benchmark(bmPluginsSetGameState, PluginsSetGameState(GameState)));
		}
	}
	else
		return;
	DebugTry(UpdateMQ2SpawnSort());
#ifndef ISXEQ_LEGACY
#ifndef ISXEQ
	DebugTry(DrawHUD());
	//if (gGameState==GAMESTATE_INGAME && !bMouseLook && ScreenMode==3)
	//{
	//    DebugTry(pWndMgr->DrawCursor());
	//}
#endif
#endif

	bRunNextCommand = TRUE;
	DebugTry(Pulse());
#ifndef ISXEQ_LEGACY
#ifndef ISXEQ
	DebugTry(Benchmark(bmPluginsPulse, DebugTry(PulsePlugins())));
#endif
	if (pEQPlayNicePulse) {
		pEQPlayNicePulse();
	}
	else {
		HMODULE hmEQPlayNice;
		if (((BeatCount % 63) == 0) && (hmEQPlayNice = GetModuleHandle("EQPlayNice.dll"))) {
			if (pEQPlayNicePulse = (fMQPulse)GetProcAddress(hmEQPlayNice, "Compat_ProcessFrame"))
				pEQPlayNicePulse();
		}
	}
#endif
	DebugTry(ProcessPendingGroundItems());


	static bool ShownNews = false;
	if (gGameState == GAMESTATE_CHARSELECT && !ShownNews)
	{
		ShownNews = true;
		if (gCreateMQ2NewsWindow)
			CreateMQ2NewsWindow();
	}

#ifndef ISXEQ
	DWORD CurTurbo = 0;

	if (gDelayedCommands)
	{// delayed commands
		lockit lk(ghLockDelayCommand);
		DoCommand((PSPAWNINFO)pLocalPlayer, gDelayedCommands->szText);
		PCHATBUF pNext = gDelayedCommands->pNext;
		LocalFree(gDelayedCommands);
		gDelayedCommands = pNext;
	}
	while (bRunNextCommand) {
		if (!DoNextCommand()) break;
		if (!gTurbo) break;//bRunNextCommand = FALSE;
		if (++CurTurbo>gMaxTurbo) break;//bRunNextCommand =   FALSE;
	}
	DoTimedCommands();
#endif
}
コード例 #7
0
// ***************************************************************************
// Function:    Macro
// Description: Our '/macro' command
// Usage:       /macro <filename>
// ***************************************************************************
VOID Macro(PSPAWNINFO pChar, PCHAR szLine)
{
    bRunNextCommand = TRUE;
    CHAR szTemp[MAX_STRING] = {0};
    CHAR Filename[MAX_STRING] = {0};
    PCHAR Params = NULL;
    PCHAR szNext = NULL;
    BOOL InBlockComment = FALSE;
    if (szLine[0] == 0) {
        SyntaxError("Usage: /macro <filename> [param [param...]]");
        return;
    }
    if (gMacroBlock) 
    {
        gReturn = false;
        EndMacro(pChar,"");//"keep keys vars arrays timers");
        gReturn = true;
    }
    gMaxTurbo=20;
    gTurbo=true;
    GetArg(szTemp,szLine,1);
    Params = GetNextArg(szLine);

    strcpy(gszMacroName,szTemp);
#ifdef ISXEQ_LEGACY
    strcpy(Filename,szTemp);
    FILE *fMacro = fopen(szTemp,"rt");
#else
    if (!strstr(szTemp,".")) strcat(szTemp,".mac");
    sprintf(Filename,"%s\\%s",gszMacroPath, szTemp);

    FILE *fMacro = fopen(Filename,"rt");
#endif
    if (!fMacro) {
        FatalError("Couldn't open macro file: %s",Filename);
        gszMacroName[0]=0;
        gRunning = 0;
        return;
    }
    gRunning = MQGetTickCount64();
    gEventChat = 0;
    strcpy(gszMacroName,szTemp);
    DebugSpew("Macro - Loading macro: %s",Filename);
    DWORD LineNumber = 0;
    PMACROBLOCK pAddedLine = NULL;
    while (!feof(fMacro)) {
        fgets(szTemp,MAX_STRING,fMacro);
        CleanMacroLine(szTemp);
        LineNumber++;
        if (!strncmp(szTemp,"|**",3)) {
            InBlockComment=TRUE;
        }
        if (!InBlockComment) {
            if (NULL == (pAddedLine=AddMacroLine(szTemp))) {
                MacroError("Unable to add macro line.");
                fclose(fMacro);
                gszMacroName[0]=0;
                gRunning = 0;
                return;
            } else if (1 != (DWORD)pAddedLine) {
                pAddedLine->LineNumber = LineNumber;
                strcpy(pAddedLine->SourceFile, GetFilenameFromFullPath(Filename));
            }
        } else {
            DebugSpew("Macro - BlockComment: %s",szTemp);
            if (!strncmp(&szTemp[strlen(szTemp)-3],"**|",3)) {
                InBlockComment=FALSE;
            }
        }
    }
    fclose(fMacro);
    PDEFINE pDef;
    while (pDefines) {
        pDef = pDefines->pNext;
        free(pDefines);
        pDefines = pDef;
    }
    strcpy(szTemp, "Main");
    if (Params[0] !=0) {
        strcat(szTemp, " ");
        strcat(szTemp, Params);
    }
    DebugSpew("Macro - Starting macro with '/call %s'",szTemp);
    Call(pChar, szTemp);
    if ((gMacroBlock) && (gMacroBlock->pNext)) gMacroBlock = gMacroBlock->pNext;
    if (gMacroBlock) gMacroBlock->MacroCmd = 1;
    if ((!gMacroBlock) || (!gMacroStack)) {
        gszMacroName[0]=0;
        gRunning = 0;
    }
#ifdef ISXEQ_LEGACY
    else
    {
        char ShortName[128];
        ShortName[0]=0;
        _splitpath(Filename,0,0,ShortName,0);
        IS_ScriptEngineScriptBegins(pExtension,pISInterface,hScriptEngineService,&g_LegacyEngine,ShortName);
    }
#endif
}