Skip to content

Commit

Permalink
Speedy gold picking mode that Hoyt added
Browse files Browse the repository at this point in the history
  • Loading branch information
nooperation committed Sep 13, 2022
1 parent 102dc11 commit 449d14a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
20 changes: 19 additions & 1 deletion D2Hackit/Modules/pick/ItemWatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#define PICK_SETTINGS_PATH ".\\plugin\\pick.ini"

int goldPicksThisFrame = 0;

bool operator==(const WatchedItemData &lhs, const WatchedItemData &rhs)
{
return lhs.id == rhs.id &&
Expand All @@ -18,6 +20,7 @@ ItemWatcher::ItemWatcher()
minGold = 50;
townPickup = true;
isPickingItems = true;
goldSpeed = 1;
isMute = false;
}

Expand Down Expand Up @@ -107,9 +110,16 @@ void ItemWatcher::CheckWatchedItems()
if(itemIter->isGold)
{
me->PickGroundItem(itemIter->id, TRUE);
return;

goldPicksThisFrame++;
if (goldPicksThisFrame > goldSpeed) {
return;
}
++itemIter;
continue;
}


if (itemIter->isIdScroll)
{
TomeInfo info{ 0, 0, 0 };
Expand Down Expand Up @@ -225,6 +235,12 @@ void ItemWatcher::SetRadius(int radius)
this->radius = radius;
}

void ItemWatcher::SetGoldSpeed(int goldSpeed)
{
server->GameInfof("Pick: Setting gold pickup speed to %d", goldSpeed);
this->goldSpeed = goldSpeed;
}

void ItemWatcher::SetMinGold(int amount)
{
server->GameInfof("Pick: Setting minimum gold amount to %d", amount);
Expand Down Expand Up @@ -270,6 +286,7 @@ bool ItemWatcher::LoadItems()
minGold = GetPrivateProfileInt("Pick", "MinGold", 50, PICK_SETTINGS_PATH);
townPickup = GetPrivateProfileInt("Pick", "Town", 1, PICK_SETTINGS_PATH) == TRUE;
isPickingItems = GetPrivateProfileInt("Pick", "Items", 1, PICK_SETTINGS_PATH) == TRUE;
goldSpeed = GetPrivateProfileInt("Pick", "GoldSpeed", 1, PICK_SETTINGS_PATH);

return true;
}
Expand Down Expand Up @@ -402,6 +419,7 @@ void ItemWatcher::OnTick()
return;
}

goldPicksThisFrame = 0;
CheckWatchedItems();
}

Expand Down
2 changes: 2 additions & 0 deletions D2Hackit/Modules/pick/ItemWatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ItemWatcher
void SetRadius(int radius);
void SetMinGold(int amount);
void SetTownPickup(bool enabled);
void SetGoldSpeed(int goldSpeed);
void TogglePickItems();
void Mute();
bool LoadItems();
Expand Down Expand Up @@ -62,6 +63,7 @@ class ItemWatcher
unsigned int minGold;
bool townPickup;
bool isPickingItems;
unsigned int goldSpeed;
bool isInGame;
bool isMute;
bool isAnnouncingAllSets;
Expand Down
18 changes: 18 additions & 0 deletions D2Hackit/Modules/pick/Pick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "ItemWatcher.h"

BOOL PRIVATE Radius(char** argv, int argc);
BOOL PRIVATE GoldSpeed(char** argv, int argc);
BOOL PRIVATE MinGold(char** argv, int argc);
BOOL PRIVATE ToggleShowItemLevel(char** argv, int argc);
BOOL PRIVATE ReloadItemDefs(char** argv, int argc);
Expand Down Expand Up @@ -62,6 +63,18 @@ BOOL PRIVATE Radius(char** argv, int argc)
return FALSE;
}

BOOL PRIVATE GoldSpeed(char** argv, int argc)
{
if (argc == 3)
{
itemWatcher.SetGoldSpeed(atoi(argv[2]));
return TRUE;
}

server->GameErrorf("Invalid input, correct usage is .pick goldspeed n");
return FALSE;
}

BOOL PRIVATE Mute(char** argv, int argc)
{
itemWatcher.Mute();
Expand Down Expand Up @@ -190,6 +203,11 @@ MODULECOMMANDSTRUCT ModuleCommands[]=
Radius,
"Set radius, default = 4"
},
{
"goldspeed",
GoldSpeed,
"Set gold pickup speed, default = 1. 3 risks disconnects, above will disconnect."
},
{
"min",
MinGold,
Expand Down
1 change: 1 addition & 0 deletions D2Hackit/Modules/pick/Resources/pick.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Items = 1
MinGold = 50
Radius = 4
Town = 1
GoldSpeed = 1

[Pick.Announce]
AllCrafted = 1
Expand Down

0 comments on commit 449d14a

Please sign in to comment.