Skip to content

Commit

Permalink
Pick should pick at max speed now, though it has issues when the rang…
Browse files Browse the repository at this point in the history
…e is extended (It can get in a loop, walking back and forth between to piles that are constantly 'closest', but disabling the walk animation should resolve that?)

Added 'IgnoreIdentifiedSetRingsAndAmulets' to autostocker, which is off by default. If you have identified set rings/amulets in your inventory, they will not be autostocked if this flag is set
Removed Mountain Dew and Nirvana Grass from AutoSell_items.txt
  • Loading branch information
nooperation committed Sep 22, 2022
1 parent 634bd69 commit aeb4e09
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 69 deletions.
2 changes: 0 additions & 2 deletions D2Hackit/Modules/autoSell/Resources/AutoSell_items.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
fkn Fake Note
po3 Mountain Dew
po4 Nirvana Grass
61 changes: 58 additions & 3 deletions D2Hackit/Modules/autoStocker/AutoStocker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ bool AutoStocker::Init(bool useChat)
IsTransmutingUnidentifiedSmallCharms = (GetPrivateProfileInt("Autostocker", "NonIDSmallCharms", 0, CONFIG_FILE) == 1);
IsTransmutingUnidentifiedLargeCharms = (GetPrivateProfileInt("Autostocker", "NonIDLargeCharms", 0, CONFIG_FILE) == 1);
IsTransmutingUnidentifiedGrandCharms = (GetPrivateProfileInt("Autostocker", "NonIDGrandCharms", 0, CONFIG_FILE) == 1);
IgnoreIdentifiedSetRingsAndAmulets = (GetPrivateProfileInt("Autostocker", "IgnoreIdentifiedSetRingsAndAmulets", 0, CONFIG_FILE) == 1);
MinPrefixCount = GetPrivateProfileInt("Autostocker", "PrefixCount", 0, CONFIG_FILE);
MinSuffixCount = GetPrivateProfileInt("Autostocker", "SuffixCount", 0, CONFIG_FILE);

return true;
}
Expand Down Expand Up @@ -800,6 +803,9 @@ bool AutoStocker::ReadAffixConfig(const std::string &configPath, std::unordered_
return true;
}

#include "../../Includes/itemPrefix.h"
#include "../../Includes/ItemSuffix.h"

/// <summary>
/// Determines if this item has a good affix and should be kept
/// </summary>
Expand All @@ -817,19 +823,60 @@ bool AutoStocker::CheckItemAffix(const ITEM &item)
if(goodPrefix.count(item.wPrefix[i]) > 0)
{
goodPrefixCount++;
//server->GameStringf("ÿc;Prefixÿc0 %s: %s", Prefix[item.wPrefix[i]], PrefixDetails[item.wPrefix[i]]);
//server->GameStringf("ÿc;AS Prefixÿc0 %s: %s", Prefix[item.wPrefix[i]], PrefixDetails[item.wPrefix[i]]);
}
if(goodSuffix.count(item.wSuffix[i]) > 0)
{
goodSuffixCount++;
//server->GameStringf("ÿc:Suffixÿc0 %s: %s", Suffix[item.wSuffix[i]], SuffixDetails[item.wSuffix[i]]);
//server->GameStringf("ÿc:AS Suffixÿc0 %s: %s", Suffix[item.wSuffix[i]], SuffixDetails[item.wSuffix[i]]);
}
}
}

if (IsRingAmulet(item.szItemCode))
{
if (item.iSocketed)
{
return true;
}
if (item.iPersonalized)
{
return true;
}

//server->GameStringf("Suffix=%d Prefix=%d Result=(%d)", goodPrefixCount, goodSuffixCount, (goodPrefixCount + goodSuffixCount) >= 2);
return (goodPrefixCount + goodSuffixCount) >= 2;
}

return goodPrefixCount >= 1 || goodSuffixCount >= 1;
}

bool AutoStocker::IsRingAmulet(LPCSTR itemCode)
{
if(strcmp(itemCode, "amu") == 0 ||
strcmp(itemCode, "rin") == 0 ||
strcmp(itemCode, "zrn") == 0 ||
strcmp(itemCode, "srn") == 0 ||
strcmp(itemCode, "nrn") == 0 ||
strcmp(itemCode, "prn") == 0 ||
strcmp(itemCode, "brg") == 0 ||
strcmp(itemCode, "drn") == 0 ||
strcmp(itemCode, "arn") == 0 ||
strcmp(itemCode, "zam") == 0 ||
strcmp(itemCode, "sam") == 0 ||
strcmp(itemCode, "nam") == 0 ||
strcmp(itemCode, "pam") == 0 ||
strcmp(itemCode, "bam") == 0 ||
strcmp(itemCode, "dam") == 0 ||
strcmp(itemCode, "aam") == 0)

{
return true;
}

return false;
}

/// <summary>
/// Determines if specified item should be stored in the gem can
/// </summary>
Expand Down Expand Up @@ -915,7 +962,7 @@ bool AutoStocker::IsCrystalItem(LPCSTR itemCode)
/// Determines if specified item should be stored in the rerolling orb
/// </summary>
/// <param name="item">Item being checked.</param>
/// <returns>true if item should be cubed a stocker.</returns>
/// <returns>true if item should be destroyed</returns>
bool AutoStocker::IsRerollItem(const ITEM &item)
{
if(!item.iIdentified)
Expand Down Expand Up @@ -953,6 +1000,14 @@ bool AutoStocker::IsRerollItem(const ITEM &item)
}
}

if (item.iIdentified)
{
if (item.iQuality == ITEM_LEVEL_SET && IgnoreIdentifiedSetRingsAndAmulets && IsRingAmulet(item.szItemCode))
{
return false;
}
}

if(item.iQuality == ITEM_LEVEL_MAGIC ||
(item.iQuality == ITEM_LEVEL_SET && transmuteSet) ||
(item.iQuality == ITEM_LEVEL_RARE && transmuteRare) ||
Expand Down
4 changes: 4 additions & 0 deletions D2Hackit/Modules/autoStocker/AutoStocker.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class AutoStocker
bool IsCrystalItem(LPCSTR itemCode);
bool IsGemCanItem(LPCSTR itemCode);
bool IsRerollItem(const ITEM &item);
bool AutoStocker::IsRingAmulet(LPCSTR itemCode);

std::vector<std::vector<DWORD>> itemsToTransmute;
std::vector<DWORD> restockers;
Expand All @@ -93,9 +94,12 @@ class AutoStocker
bool IsTransmutingUnidentifiedSmallCharms;
bool IsTransmutingUnidentifiedLargeCharms;
bool IsTransmutingUnidentifiedGrandCharms;
bool IgnoreIdentifiedSetRingsAndAmulets;
int MaxUnidentifiedSCharmLevel;
int MaxUnidentifiedLCharmLevel;
int MaxUnidentifiedGCharmLevel;
int MinPrefixCount;
int MinSuffixCount;

unsigned int currentItem;
unsigned int currentStocker;
Expand Down
3 changes: 2 additions & 1 deletion D2Hackit/Modules/autoStocker/Resources/autostockerMisc.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ MaxUnidentifiedLCharmLvl=44
MaxUnidentifiedGCharmLvl=44
NonIDSmallCharms = 0
NonIDLargeCharms = 0
NonIDGrandCharms = 0
NonIDGrandCharms = 0
IgnoreIdentifiedSetRingsAndAmulets = 1
1 change: 1 addition & 0 deletions D2Hackit/Modules/filter/ItemFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ bool ItemFilter::LoadItemMap(const std::string &fileName, std::unordered_map<std

if(!inFile)
{
server->GameErrorf("ÿc:Filterÿc0: ÿc1failed to read the follow item table:ÿc0 %s", fileName.c_str());
return false;
}

Expand Down
3 changes: 1 addition & 2 deletions D2Hackit/Modules/filter/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ BOOL EXPORT OnClientStart()
{
if(!ItemFilter.LoadItems())
{
server->GameErrorf("Failed to load item tables. Do you have filterTable.txt");
server->GameErrorf(" in the plugin directory?");
server->GameErrorf("Failed to load all item tables.");
return FALSE;
}

Expand Down
46 changes: 35 additions & 11 deletions D2Hackit/Modules/goto/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,24 @@ bool isLeftHandCasting = false;

#include "../../Core/definitions.h"

void Abort()
{
if (currentState == STATE_Idle)
{
return;
}


server->GameStringf("ÿc5Gotoÿc0: Complete");
currentState = STATE_Idle;

auto fleeModule = GetModuleHandle("Flee.d2h");
if (fleeModule != NULL)
{
server->GameCommandf("flee SuppressAutoTp 0");
}
}

void SetState(States newState)
{
/*
Expand Down Expand Up @@ -471,14 +489,12 @@ void NextRoomTransition()
{
//server->GameStringf("NextRoomTransition()");

SetState(STATE_Idle);

if(currentTravelData->CurrentStep + 1 < currentTravelData->NumSteps)
{
currentTravelData->CurrentStep++;
}
else {
server->GameStringf("Done");
Abort();
return;
}

Expand Down Expand Up @@ -552,7 +568,7 @@ void CalculatePathToStairsRoom()
}
}

SetState(States::STATE_Idle);
Abort();
server->GameStringf("Failed to find path to stairs. Returning to town");
server->GameCommandf(".flee tp");
}
Expand Down Expand Up @@ -612,6 +628,12 @@ BOOL PRIVATE Start(char** argv, int argc)
return TRUE;
}

auto fleeModule = GetModuleHandle("Flee.d2h");
if (fleeModule != NULL)
{
server->GameCommandf("flee SuppressAutoTp 1");
}

currentState = STATE_UsingWaypoint;
server->GameCommandf("load wp");
server->GameCommandf("wp start %d", currentTravelData->WaypointDestination);
Expand All @@ -628,17 +650,17 @@ BOOL PRIVATE Start(char** argv, int argc)

VOID EXPORT OnGameJoin(THISGAMESTRUCT* thisgame)
{
SetState(STATE_Idle);
Abort();
}

VOID EXPORT OnClientStop(THISGAMESTRUCT *thisgame)
{
server->GameStringf("OnClientStop");
SetState(STATE_Idle);
Abort();
}
VOID EXPORT OnGameLeave(THISGAMESTRUCT* thisgame)
{
SetState(STATE_Idle);
Abort();
}

BOOL EXPORT OnClientStart()
Expand Down Expand Up @@ -763,7 +785,8 @@ DWORD EXPORT OnGamePacketBeforeSent(BYTE* aPacket, DWORD aLen)
{
if(strcmp(chatMessage, "ÿc5Waypointÿc0: Complete") != 0)
{
SetState(STATE_Idle);
Abort();
return 0;
}

return 0;
Expand Down Expand Up @@ -828,7 +851,7 @@ VOID EXPORT OnThisPlayerMessage(UINT nMessage, WPARAM wParam, LPARAM lParam)
if (me->IsInTown())
{
server->GameStringf("Unexpected map change. Aborting.");
SetState(STATE_Idle);
Abort();
return;
}

Expand All @@ -848,16 +871,17 @@ VOID EXPORT OnThisPlayerMessage(UINT nMessage, WPARAM wParam, LPARAM lParam)
{
GoBackToTown();
}
SetState(STATE_Idle);
Abort();
}
}
}


BYTE EXPORT OnGameKeyDown(BYTE iKeyCode)
{
if(iKeyCode == VK_SPACE)
{
currentState = STATE_Idle;
Abort();
}
return iKeyCode;
}
Expand Down
Loading

0 comments on commit aeb4e09

Please sign in to comment.