std::pair<SkillStateMachine*,ParameterStruct> Position::update(ParameterStruct iParam){ double distance = GameEvaluator::getDistanceBetweenPlayerAndCoord(iParam.playerId,iParam.teamId,iParam.target.Position); //INFO << "Robot's distance = " << distance; std::pair<SkillStateMachine*,ParameterStruct> skillSet(mActualSSM,iParam); return skillSet; }
void _d2Run::teleSet( POINT ptEnd , bool Abort = true) { size_t counter = 0; teleSteps = 0; Core->Debug(6, "Mapping Path..."); teleAbort = Abort; while(teleSteps == 0) { counter++; if(ptEnd.x < 3000) ptEnd.x = 3001; if(ptEnd.y < 5000) ptEnd.y = 5001; //teleSteps = GenerateTeleportPath(D2WindowTitle, (WORD) ptEnd.x, (WORD) ptEnd.y, telePath, TeleStepsMAX); teleSteps = TeleportGeneratePath(ptEnd); if(teleSteps == 0) { TP_RANGE -= 2; if(counter >= 8) break; if(TP_RANGE <= 8) TP_RANGE = 35; } } if(teleSteps == 0) { if(Abort) { Core->GameOver("Failed to map path", true); } return; } strTmp.str(""); strTmp << "Path Mapped: Steps: " << teleSteps << ", TP_RANGE: " << TP_RANGE; Core->Debug(5, strTmp.str()); skillSet(skillBlessedHammer, skillTeleport); teleStep = 0; teleportMoving = true; teleporting = true; teleportComplete = false; teleportCompleted = 0; teleportTimeout = 0; teleportFirstStep = true; }
bool _D2Baal_Run::Update(float Lag) { bool justLeftTown = true; ticksStart = GetTickCount(); // Get current system tick ticksDiff = ((float) (ticksStart - ticksEnd)) / 1000; // Calculate in seconds which have past since last execution if(town && manualMode) { if(currentStep < 15) throneEnable(); } if(baalDead) { throneChamber = false; if(!manualMode) Quit = true; pickTime = true; baalDead = false; ticksEnd = GetTickCount(); return true; } if( _d2Run::Update(Lag) == true) { //Sleep(10); return true; } if(firstTownLeave) { firstTownLeave = false; wsKeep = true; Sleep(100); cMap.GenerateMap(); } if(ticksDiff > 0.20f) { if( baalInThrone ) { // Find monsters in the throne monstersClear( 15118, 5076, 15072, 5000 ); if(baalInThrone && waveCount > 0 && !waveStarted && monstersAttack.size() > 0) { attackSpotX = attackSpotY = 0; waveStarted = true; } } // If wave is starting, ensure we go for it if(attacking && !waveStarting &&!teleporting) { if(monstersAttack.size() == 0 && MovePosition) { if(Core->WithinRangeLand(15093, 5030) == false) { if(!throneChamber && currentStep > 15) { if(waveCount == 0 || waveCount == 1 || waveCount == 2) teleSet(15093, 5030, false); if(waveCount == 3) teleSet(15093, 5032, false); if(waveCount == 4) teleSet(15093, 5034, false); //ticksEnd = GetTickCount(); if(teleporting) return true; } } } attackTheMonsters(); if(throneChamber && attackCounter && teleSteps) { //teleSet( unitBaal.posX, unitBaal.posY, false ); attackCounter = 30; } // Only if we havnt changed to teleport mode, makes us move faster :) //if(teleSteps == 0) ticksEnd = GetTickCount(); return true; } } if(ticksDiff > 0.40f) { if(wsKeep) { switch(currentStep) { case 0: Core->Debug(3, "Entered Level 2"); CTA(true); if(mercIsAlive) Core->mercFollow(); currentStep++; return true; case 1: if(doKeep() == false) { ticksEnd = GetTickCount(); return true; } LevelTarget = 130; ticksEnd = GetTickCount(); return true; case 2: // Tele to warp gotoWarp(); //ticksEnd = GetTickCount(); return true; case 3: // At warp interacting = true; Core->playerInteractObject( warpLocal[warpLocate].uID, 0x05 ); // Walk thro doorway ticksEnd = GetTickCount(); return true; case 4: // Lvl 3 if(doKeep() == false) { ticksEnd = GetTickCount(); return true; } Core->Debug(3, "Entered Level 3"); LevelTarget = 131; ticksEnd = GetTickCount(); return true; case 5: // Tele to warp gotoWarp(); //ticksEnd = GetTickCount(); return true; case 6: // At warp (Throne Entry) interacting = true; monsterTracking = true; Core->playerInteractObject( warpLocal[warpLocate].uID, 0x05 ); // Walk thro doorway ticksEnd = GetTickCount(); return true; case 7: // In Throne wsKeep = false; throne = true; warpLocate = 0; currentStep++; return true; } } // wsKeep if(throne) { switch(currentStep) { case 8: Core->Debug(3, "Entered Throne!... Get Ready"); teleSet(15120, 5001, true); //ticksEnd = GetTickCount(); return true; case 9: if(portalCast) { portalCast = false; currentStep++; return true; } portalCasting = true; //ticksEnd = GetTickCount(); return true; case 10: // In top right corner of throne room //monstersClear( 15118, 5070, 15072, 5000 ); Core->Debug(4, "Town Portal Up"); currentStep++; //ticksEnd = GetTickCount(); return true; case 11: // tele infront of stairs // One of these 2 has to be commented, the other not //teleSpot(15093, 5027); currentStep++; ticksEnd = GetTickCount(); return true; case 12: // start attack run partying = true; Core->partyAccept(); partyAll(); attacking = true; currentStep++; skillSet(skillBlessedHammer, skillConcentration); //ticksEnd = GetTickCount(); return true; case 13: { // Throne should be clear // HACK for weird bug that occurs sometimes Count++; if(Count > 1) { currentStep++; return true; } itemPickupClear(); // Core->Debug(0, "Throne is clear"); partyAll(); if(!manualMode) Core->SpeakToAll("safe"); teleSet(15093, 5044, false); // In front of stairs, for bots attacking = false; return true; } case 14: followBots = true; // Bots currentStep++; return true; case 15: if(!manualMode) Core->SpeakToAll("guard"); // Put the bots here teleSet(15093, 5031, false); // In front of stairs playersUnMuteAll(); playersMuteAll(true); Core->SpeakToAll("precast"); Core->SpeakToAll("!bo"); attackSpotX = 15093; attackSpotY = 5031; attackCounter = 50; attackWait = 18; attacking = true; //pickTime = true; throne = false; MovePosition = true; currentStep++; return true; } } // throne if(waveRunning) { attacking = true; if(waveCount == 1 && waveStarting) { playersUnMuteAll(); Core->Debug(2, "First Wave Starting"); //monstersAttack.clear(); } if(waveCount == 2 && waveStarting) { Core->Debug(2, "Second Wave Starting"); //monstersAttack.clear(); } if(waveCount == 3 && waveStarting) { Core->Debug(2, "Third Wave Starting"); //monstersAttack.clear(); } if(waveCount == 4 && waveStarting) { Core->Debug(2, "Fourth Wave Starting"); //monstersAttack.clear(); } // Starting final wave if(waveCount == 5 && waveStarting) { Core->Debug(2, "Final Wave Starting"); //monstersAttack.clear(); } // This should be the end of the last wave if(waveCount == 5 && !waveStarting && waveStarted && monstersAttack.size() == 0) { monsters.clear(); partying = false; pickTime = true; MovePosition = false; Core->Debug(1, "Baal"); attacking = false; TP_RANGE = 35; playersMuteAll(false); followBots = true; // Bots disabled CTA(false); skillSet(skillBlessedHammer, skillCleansing); throneChamber = true; waveRunning = false; waveOver = false; return true; } if(waveStarting) { attackWait = 0; attackCounter = 20; pickTime = false; waveStarting = false; waveOver = false; waveStarted = false; return true; } if(waveOver) { itemPickupClear(); pickTime = true; // Hydras... if(monstersAvoid.size() > 0) { skillSet(skillBlessedHammer, skillDefiance); return true; } waveOver = false; TP_RANGE = 35; // Baal laughed on monster spawn if(monstersAttack.size() > 0 || !waveStarted) return true; Core->Debug(2, "Wave Over"); waveStarted = false; attackCounter = 0; attackWait = 0; // End of wave1 if(waveCount == 1) if(!manualMode) if(Players.size() > 6) { if(!silentMode) Core->SpeakToAll("glitch"); partying = false; } // End of wave2, reparty for glitcher if(waveCount == 2) { partyAll(); Core->partyAccept(); partying = true; } if(waveCount < 4) { teleSet(15093, 5030, false); attackSpotX = 15093; attackSpotY = 5030; attackWait = 18; //9 } else if(waveCount < 5) { teleSet(15093, 5031, false); attackSpotX = 15093; attackSpotY = 5031; attackWait = 25; //11 } else if(waveCount < 6) { teleSet(15093, 5034, false); attackSpotX = 15093; attackSpotY = 5034; attackWait = 22; //11 } attacking = true; attackCounter = 60; ticksEnd = GetTickCount(); return true; } } // waveRunning if(throneChamber) { if(baalInThrone) { currentStep = 16; // HACK! Fix bug which sometimes made currentstep > 16 on entry return true; } switch(currentStep) { case 16: attacking = false; pickTime = false; teleSet(15090, 5009, false); //waitTimer = 5; // 1 second //currentStep++; break; case 17: interacting = true; LevelTarget = 0x84; // Worldstone Chamber Core->playerInteractObject( portalBaal.uID, 0x02 ); break; case 18: // In Chamber case 19: attacking = true; monstersAttack.insert( pair<DWORD, _d2Unit>( unitBaal.uID, unitBaal ) ); monsters.insert( pair<DWORD, _d2Unit>( unitBaal.uID, unitBaal ) ); currentStep=20; break; } ticksEnd = GetTickCount(); return true; } // throneChamber if(ticksDiff > 1.0f) { if(Quit) { realmCreateNewGame = true; Running = false; Quit = false; Core->GameOver("Throne Completed", false); return true; } } //ticksEnd = GetTickCount(); return true; } // ticksDiff return false; }
void _d2Run::Town() { static int counter = 0; if(waypointUsing) { stepTown++; waypointUsing = false; walkComplete = false; walking = false; } if(!walking && walkComplete) { stepTown++; walkComplete = false; walking = false; walkSteps = 0; return; } else if(walking) return; switch(stepTown) { case 0: // Goto Malah if(!noJuves) { Core->Debug(0, "Firing up..."); if(gameNumber > 1) { strTmp.str(""); strTmp << "Stats: Completed: " << gameSuccess << " of " << (gameNumber - 1); Core->Debug(2, strTmp.str()); strTmp.str(""); if(gameLastMsg.size() > 0) { strTmp << "LG: " << gameLastMsg; Core->Debug(2, strTmp.str()); strTmp.str(""); } strTmp << "Chickens: " << gameChickens << " LagOuts: " << gameLagOuts << " TeleFail: " << gameTeleTimeout; strTmp << " Timeouts: " << gameTimeOuts; Core->Debug(2, strTmp.str() ); strTmp.str(""); strTmp << "Monsters owned: " << monstersOwned; Core->Debug(2, strTmp.str() ); } skillSet(skillBlessedHammer, skillVigor); } // if(!Hero) return; float ticksDiffStart; ticksDiffStart = ((float) (GetTickCount() - ticksStartRun)) / 1000; if(beltPotionsRejuve.size() == 0 || noJuves) { if(beltPotionsRejuve.size() > 3) { noJuves = false; return; } else noJuves = true; if(!manualMode && ticksDiffStart > 15.0f) { ticksStartRun = GetTickCount(); //Core->SpeakToAll("I've got no juves"); strTmp.str(""); strTmp << "I require " << (3 - beltPotionsRejuve.size()); strTmp << " full juvies"; Core->SpeakToAll(strTmp.str().c_str()); //Paused = true; //Core->Debug(0, "Paused"); } return; } if( Hero->Life < BASELIFE || TownPortalBook.Quantity < 0x06 || (beltPotionsHealth.size() < 2) || (beltPotionsMana.size() < 2)) { walking = true; walkStep = 0; walkSteps = &walkSteps_ToAct5Malah[0]; walkComplete = true; LevelTarget = 0; } else { stepTown = 12; } break; case 1: // Ensure next to malah Core->Debug(1, "Speaking to Malah"); Core->playerMoveToObject(unitMalah.uID, 0x01); //interacting = true; // Can't use this due to whatever is wrong with the servers and when u first join a game // bizzare lack of packet responses sometimes... stepTown++; break; case 2: // town interact Core->TownInteract(unitMalah); // No response to this command talking = true; stepTown++; break; case 3: // Interact with malah interacting = true; Core->playerInteractObject(unitMalah.uID, 0x01); // 0x01 = NPC? // Reply GS: 0x27 break; case 4: // Finalise interact counter = 0; Core->TownInteractFinal(unitMalah); stepTown++; break; case 5: // Select Trade Menu // Wait a few seconds before using the menu if(counter>=5) { Core->Debug(3, "Trading"); Core->TownInteractMenu(unitMalah, 0x01, 0x00000000); // 0x01 = Trade shopping = true; stepTown++; counter = 0; } else counter++; break; case 6: // Wait for TPS and Health to load if(counter==0) Core->Debug(3, "Loading Store"); counter++; if(counter < 4) // Can't find items! if(itemScroll.Id == 0 || itemSHP.Id == 0) break; if(counter >= 10 && itemScroll.Id == 0 && itemSHP.Id == 0) { counter = 0; Core->Debug(1, "Store Failed, Skipping"); Core->TownInteractFinish(unitMalah); stepTown += 3; break; } // Atleast one item before we continue, otherwise we might not even be in shop if(counter >= 10 && itemScroll.Id != 0 || itemSHP.Id != 0) { counter = 0; stepTown++; } break; case 7: if(!shoppingPurchasing) { if(itemScroll.Id != 0) { if(TownPortalBook.Quantity < 0x20) { //if(TownPortalBook. Core->Debug(2, "Buying TPs"); purchasing = false; shoppingPurchasing = true; Core->TownPurchaseItem( unitMalah, itemScroll, true); TownPortalBook.Quantity = 0x40; } else stepTown++; // Tome already full } else { Core->Debug(0, "Hey, I have no TP Tome foo!"); stepTown++; // No tome in inventory } } break; case 8: if(beltPotionsHealth.size() < 4) { if(!shoppingPurchasing) { if(itemSHP.Id != 0) { shoppingPurchasing = true; purchasing = true; purchaseItem = itemSHP; purchaseAmount = 4 - beltPotionsHealth.size(); purchaseComplete = true; Core->Debug(2, "Buying SHPs"); //Core->TownPurchaseItem( unitMalah, itemSHP, false ); } else { Core->Debug(2, "Super HPs not available"); stepTown++; } } } else stepTown++; // < 4 break; case 9: if(beltPotionsMana.size() < 4) { if(!shoppingPurchasing) { if(itemSHP.Id != 0) { shoppingPurchasing = true; purchasing = true; purchaseAmount = 4 - beltPotionsMana.size(); purchaseItem = itemSMP; purchaseComplete = true; Core->Debug(2, "Buying SMPs"); //Core->TownPurchaseItem( unitMalah, itemSMP, false ); } else { Core->Debug(2, "Super MPs not available"); stepTown++; } } } else // < 8 stepTown++; break; case 10: // shopping finished! Core->Debug(1, "Shopping Complete"); shopping = false; Core->TownInteractFinish(unitMalah); talking = false; stepTown++; break; case 11: // Back to top of stairs walking = true; walkStep = 0; walkSteps = &walkSteps_ToAct5StartFromMalah[0]; walkComplete = true; break; case 12: if(mercIsAlive || ( goldAvailableInventory + goldAvailableStash) < 50001) { if(( goldAvailableInventory + goldAvailableStash) < 50001) Core->Debug(0, "No merc and no gold! things are looking poorly"); // if manual mode, stop at top of stairs if(manualMode) { Paused = true; Core->Debug(0, "Town Complete"); Core->Debug(0, "Paused"); } else stepTown = 20; break; } Core->Debug(2, "Let's get the merc back..."); walking = true; walkStep = 0; walkSteps = &walkSteps_ToAct5QualKehk[0]; break; case 13: // Ensure next to qual Core->Debug(1, "Speaking to Qual-Kehk"); Core->playerMoveToObject(unitQualKehk.uID, 0x01); //interacting = true; // Can't use this due to whatever is wrong with the servers and when u first join a game // bizzare lack of packet responses sometimes... stepTown++; break; case 14: // town interact Core->TownInteract(unitQualKehk); // No response to this command talking = true; stepTown++; break; case 15: // Interact with qual interacting = true; Core->playerInteractObject(unitQualKehk.uID, 0x01); // 0x01 = NPC? // Reply GS: 0x27 break; case 16: // Finalise interact counter = 0; Core->TownInteractFinal(unitQualKehk); stepTown++; break; case 17: // Select Trade Menu // Wait a few seconds before using the menu if(counter>=5) { Core->Debug(2, "Resurecting Merc"); Core->TownInteractMenu(unitQualKehk, 0x01, 0x00000000); // 0x01 = Trade shopping = true; stepTown++; counter = 0; } else counter++; break; case 18: Core->ResurrectMerc(unitQualKehk); stepTown++; break; case 19: // To WP Core->TownInteractFinish(unitQualKehk); talking = false; walking = true; walkStep = 0; walkSteps = &walkSteps_ToAct5WPFromQual[0]; stepTown++; // This will skip step 20 break; case 20: // Goto WP walking = true; walkStep = 0; // Walk back to the TPS in manual mode if(manualMode) walkSteps = &walkSteps_ToAct5TPs[0]; else walkSteps = &walkSteps_ToAct5WP[0]; walkComplete = true; // Make the first step happen break; case 21: if(manualMode) { Paused = true; Core->Debug(0, "Town Complete"); Core->Debug(0, "Paused"); break; } waypointDest = 0x81; // Wstone keep lvl2 waypointFinding = true; stepTown++; break; case 22: mercWeaponRemoved = false; Core->MercEquip(0x00, 0x04); // Right hand, unequip stepTown++; break; case 23: // Waiting for item remove //stepTown++; break; case 24: Core->MercEquip(0x00, 0x00); // Right hand, equip stepTown++; break; case 25: countRepairRuns++; if(countRepairRuns >= 10) { countRepairRuns = 0; Core->Debug(2, "Let's Repair"); walking = true; walkStep = 0; walkSteps = &walkSteps_ToAct5Larzuk[0]; } else stepTown = 33; break; case 26: // Ensure next to larzuk Core->Debug(1, "Speaking to Larzuk"); Core->playerMoveToObject(unitLarzuk.uID, 0x01); //interacting = true; // Can't use this due to whatever is wrong with the servers and when u first join a game // bizzare lack of packet responses sometimes... stepTown++; break; case 27: // town interact Core->TownInteract(unitLarzuk); // No response to this command talking = true; stepTown++; break; case 28: // Interact with qual interacting = true; Core->playerInteractObject(unitLarzuk.uID, 0x01); // 0x01 = NPC? // Reply GS: 0x27 break; case 29: // Finalise interact counter = 0; Core->TownInteractFinal(unitLarzuk); stepTown++; break; case 30: // Select Trade Menu // Wait a few seconds before using the menu if(counter>=5) { Core->Debug(2, "Repairing"); Core->TownInteractMenu(unitLarzuk, 0x01, 0x00000000); // 0x01 = Trade shopping = true; stepTown++; counter = 0; } else counter++; break; case 31: Core->RepairAll(unitLarzuk); stepTown++; break; case 32: // To WP Core->Debug(2, "Let's have some fun..."); Core->TownInteractFinish(unitLarzuk); talking = false; walking = true; walkStep = 0; walkSteps = &walkSteps_ToAct5WPFromLarzuk[0]; stepTown++; // This will skip step 20 break; case 33: // Open WP Core->wayPointTouch(); break; case 34: // WP Window Open waypointUsing = false; interacting = true; LevelTarget = 129; Core->wayPointUse( waypointDest ); break; case 35: // Inside WSKeep LVL2 town = false; currentStep = 0; firstTownLeave = true; break; } }
void _d2Run::attackTheMonsters() { _d2Unit *lastMonster = attackMonster; if(attackWait && monstersAttack.size() == 0) { skillSet(skillBlessedHammer, skillCleansing); attackWait--; if(attackWait < 0) attackWait = 0; return; } if(attackSpotX && attackSpotY) { // This is kinda like a fallback, if theres no monsters... and we are attacking, we just chuck hammers on the spot if( monstersAttack.size() == 0) { attackCounter--; skillSet(skillBlessedHammer, skillConcentration); if(!attackRecast) { attackRecast = true; Core->LeftSkillFire( Core->hero->posX, Core->hero->posY, false); } else Core->LeftSkillFire( Core->hero->posX, Core->hero->posY, true); Core->Debug(5, "Chucking Hammer"); if(attackCounter <= 0) { attackSpotX = 0; attackSpotY = 0; attackCounter = 0; attackRecast = false; return; } return; } // monstersAttack.size } if(attackMonster && monstersAttack.size() > 0) { attackCounter--; skillSet(skillBlessedHammer, skillConcentration); if(!attackRecast) { attackRecast = true; Core->LeftSkillFire( Hero->posX, Hero->posY, false); } else Core->LeftSkillFire( Hero->posX, Hero->posY, true); //Core->LeftSkillTarget( attackMonster ); Core->Debug(5, "Attacking monster"); // Attack done? if(attackCounter <= 0) { attackCounter = 0; // 5 attackMonster = 0; attackRecast = false; } else return; } // attackMonster if(lastMonster) attackMonster = monsterFind(lastMonster->uID); else attackMonster = monsterFind(0); if(attackMonster == 0 && monstersAttack.size() == 0) attacking = false; }