Auto Gold Pickup

Post here about all aspects of D2 mod making whether it's information, problems or whatever. Please specify whether your post is relating to Classic D2 or the Expansion.

Moderator: Nizari

Post Reply
User avatar
TehFisharmahn
Posts: 80
Joined: Sun Dec 01, 2013 12:46 pm

Auto Gold Pickup

Post by TehFisharmahn » Mon Dec 02, 2013 2:28 am

Heloes
Okay, I'm pretty sure somebody HAD TO ask about it, but I searched and couldn't find anything, so, if I'm reposting, sorry for that.

Anyway, apart from being apologetic, I'd like to ask about one thing - is there a way to make gold auto pickupable in Diablo 2? I like this feature in third part, but it's one of very few things Diablo 3 excells at. I'm making a small mod for myself and I'd really like to have this one on it.

Thanks in advance!
"Answers fishing is kinda tough to make the living from."
~Me


I am making a mod, but won't post anything about it here until I have some playable beta as I know myself too much to give any hopes :D

User avatar
kingpin
Senior Admin
Cherub
Posts: 10903
Joined: Sat Jan 11, 2003 12:51 pm
Contact:
Sweden

Hand-picked

Re: Auto Gold Pickup

Post by kingpin » Thu Dec 12, 2013 11:06 pm

this require code editing to get work.

In basic you need to hook the char movement code and add your own custom code from there to let it automatically pick up gold.

User avatar
Xaphan
Hosted Forum Moderator
Arch-Angel
Posts: 1113
Joined: Fri Oct 08, 2010 10:55 am
France

Re: Auto Gold Pickup

Post by Xaphan » Fri Dec 13, 2013 4:09 pm

Maybe just remove gold completely from droping, and then have a skill on kill on your character that increase gold based of monster level, with something like 20% chance to give gold ?

Just an idea, and seems way more easy :)

User avatar
TehFisharmahn
Posts: 80
Joined: Sun Dec 01, 2013 12:46 pm

Re: Auto Gold Pickup

Post by TehFisharmahn » Sat Dec 14, 2013 2:45 pm

Hmm... well, that would be kinda epic, I'll think this through. Thanks for the idea :D
"Answers fishing is kinda tough to make the living from."
~Me


I am making a mod, but won't post anything about it here until I have some playable beta as I know myself too much to give any hopes :D

User avatar
weapon-x
Forum Legend
Arch-Angel
Posts: 1045
Joined: Wed Mar 18, 2009 4:52 am
Location: Mindanao, Philippines
Contact:
Philippines

Re: Auto Gold Pickup

Post by weapon-x » Sat Dec 14, 2013 3:10 pm

hmmm, pehaps telekenisis is a good base-skill for this...

i remember hooking the game iterate events,
casting Enchant Level 1 when a specific stat is less than 1...
which worked quite nice... but triggers a c0000005 crash when you save and exit :mrgreen:

it was just an experiment on my part, but would work quite well when hooked in a good place...
perhaps on the code that negates stamina when running? or somewhere close there


other than making an on-kill event item, why not a monster death-skill ?
made something like this on my early modding days, hehehe

:)
" It's not the size of the dog in the fight, it's the size of the fight in the dog. "

~Mark Twain

User avatar
TehFisharmahn
Posts: 80
Joined: Sun Dec 01, 2013 12:46 pm

Re: Auto Gold Pickup

Post by TehFisharmahn » Sat Dec 14, 2013 3:31 pm

Xaphan said the same, actually :D

Is there a way to make the game show how much gold drops? Like text '+xxx' floating above monster body for 2 sec and then disappearing? Because simply giving the gold and not showing how much is pratical, but, to my mind at least, breaks the game a bit.
"Answers fishing is kinda tough to make the living from."
~Me


I am making a mod, but won't post anything about it here until I have some playable beta as I know myself too much to give any hopes :D

User avatar
Mnw1995
Junior Member
Paladin
Posts: 100
Joined: Sat Apr 02, 2011 6:28 pm

Re: Auto Gold Pickup

Post by Mnw1995 » Sat Dec 14, 2013 4:20 pm

Coding a simple auto gold pickup system is pretty easy.. Could be done with ~20 lines of C-code... It works but it misses distance, line of sight,... checks then..

User avatar
weapon-x
Forum Legend
Arch-Angel
Posts: 1045
Joined: Wed Mar 18, 2009 4:52 am
Location: Mindanao, Philippines
Contact:
Philippines

Re: Auto Gold Pickup

Post by weapon-x » Sat Dec 14, 2013 5:05 pm

TehFisharmahn" wrote: Is there a way to make the game show how much gold drops? Like text '+xxx' floating above monster body for 2 sec and then disappearing? Because simply giving the gold and not showing how much is pratical, but, to my mind at least, breaks the game a bit.
yep, pretty simple... you just take the previous value of gold - the new amount, then
use a notification to display the result.
Mnw1995" wrote:Coding a simple auto gold pickup system is pretty easy.. Could be done with ~20 lines of C-code... It works but it misses distance, line of sight,... checks then..
demon9ne, i think set his range close enough to the character,
auto-pickup is kinda cool :)
" It's not the size of the dog in the fight, it's the size of the fight in the dog. "

~Mark Twain

User avatar
Xaphan
Hosted Forum Moderator
Arch-Angel
Posts: 1113
Joined: Fri Oct 08, 2010 10:55 am
France

Re: Auto Gold Pickup

Post by Xaphan » Sat Dec 14, 2013 5:13 pm

I did this in my mod. Well, it dosen't show when you get gold and how many, but I don't care, you got the gold and don't need to click everywhere, that's all I wanted :p

User avatar
Sir Xavius
Junior Member
Paladin
Posts: 177
Joined: Mon Oct 04, 2004 6:27 pm

Re: Auto Gold Pickup

Post by Sir Xavius » Sun Dec 15, 2013 7:15 pm

Perhaps each new player is created with a +1 Telekinesis (or non-mana clone of it) charm when they start out...

User avatar
Kuss
Posts: 82
Joined: Tue Jun 23, 2015 11:29 am

Re: Auto Gold Pickup

Post by Kuss » Fri Jun 26, 2015 1:29 pm

Xaphan" wrote:I did this in my mod. Well, it dosen't show when you get gold and how many, but I don't care, you got the gold and don't need to click everywhere, that's all I wanted :p
Sorry for the necrobump but I don't think there's reason to open a new thread when there's one already

Would somebody explain how Xaphan managed to do this?
Or, if now, someone managed to make an actual auto gold pickup system?

I'm talking for single player obviously. Since I'm trying to make gold more valuable, it'd be kinda cool not to waste 10 minutes clicking everywhere :mrgreen: :mrgreen:

User avatar
weapon-x
Forum Legend
Arch-Angel
Posts: 1045
Joined: Wed Mar 18, 2009 4:52 am
Location: Mindanao, Philippines
Contact:
Philippines

Re: Auto Gold Pickup

Post by weapon-x » Sat Jun 27, 2015 7:08 am

Kuss" wrote:
Xaphan" wrote:I did this in my mod. Well, it dosen't show when you get gold and how many, but I don't care, you got the gold and don't need to click everywhere, that's all I wanted :p
Sorry for the necrobump but I don't think there's reason to open a new thread when there's one already

Would somebody explain how Xaphan managed to do this?
Or, if now, someone managed to make an actual auto gold pickup system?

I'm talking for single player obviously. Since I'm trying to make gold more valuable, it'd be kinda cool not to waste 10 minutes clicking everywhere :mrgreen: :mrgreen:
i managed to code this auto gold pickup...

i think Xaphan is referring to the skill-on event method, gold is also a stat so, a skill-on event ex: pulse_on_death skill which adds gold instead of a certain penalty, gold value can be set to random in skills.txt

the code way is more simpler and more efficient :)
" It's not the size of the dog in the fight, it's the size of the fight in the dog. "

~Mark Twain

User avatar
Kuss
Posts: 82
Joined: Tue Jun 23, 2015 11:29 am

Re: Auto Gold Pickup

Post by Kuss » Sat Jun 27, 2015 10:43 am

the code way is more simpler and more efficient :)
Wait you actually did it? :O
Why isn't this on the news or something? :x

:mrgreen:

Do you implemented it in a mod or you released something like a plugin or a tutorial?

User avatar
kingpin
Senior Admin
Cherub
Posts: 10903
Joined: Sat Jan 11, 2003 12:51 pm
Contact:
Sweden

Hand-picked

Re: Auto Gold Pickup

Post by kingpin » Sat Jun 27, 2015 11:38 am

Kuss" wrote:
the code way is more simpler and more efficient :)
Wait you actually did it? :O
Why isn't this on the news or something? :x

:mrgreen:

Do you implemented it in a mod or you released something like a plugin or a tutorial?
Immersion done it long time ago, he done it for his own mod.

User avatar
weapon-x
Forum Legend
Arch-Angel
Posts: 1045
Joined: Wed Mar 18, 2009 4:52 am
Location: Mindanao, Philippines
Contact:
Philippines

Re: Auto Gold Pickup

Post by weapon-x » Sat Jun 27, 2015 12:43 pm

Kuss" wrote:
the code way is more simpler and more efficient :)
Wait you actually did it? :O
Why isn't this on the news or something? :x

:mrgreen:

Do you implemented it in a mod or you released something like a plugin or a tutorial?
i just copied the idea of Demon9ne's Emmersion, i liked his mod alot ;)

i assure you the code i used was written by me except for a d2vanilla function which MWN1995 shared with me
(*i asked for some help from him about this sometime ago)

the function he gave basically calculates the subtiles between 2 units :) aka 'distance'

which is very important to make the code work as intended (*my old distance calculation logic is... well erroneous :mrgreen: )

well since d2 is old and we all love the game

here is my code

Code: Select all

char pMsg[256];
	int GAP;	
	int INVENTORY_GOLD =  D2COMMON_GetStat(pUnit,STAT_GOLD,0);
	int GOLD_LIMIT = D2COMMON_GetGoldLimitInInventory(pUnit);
	int GOLD_QUANTITY;
	unsigned int nSpawnedItems = pGame->dwSpawnedItems + 1;

	DWORD ITEM_GOLD = D2REVOLUTION_ItemCode("gld");
	D2RoomStrc* pPlayerRoom = D2COMMON_GetRoomFromUnit(pUnit);
	BOOL inTown = D2COMMON_TestRoomIfTown(pPlayerRoom);

	if(inTown == FALSE) //prevent autoloot in town
	{
		if(pUnit->dwUnitType == UNIT_PLAYER)
		{
		
			if(pPlayerRoom == NULL) return;

			for(unsigned int i = 0; i <= nSpawnedItems; i++)
			{
				D2UnitStrc* pFloorItem = pPlayerRoom->pUnitFirst;

				if(pFloorItem == NULL) return;

				while(pFloorItem != NULL)
				{
					D2ItemsTxt* pFloorItemTxt = D2COMMON_GetItemText(pFloorItem->dwClassId);
					GOLD_QUANTITY = D2COMMON_GetStat(pFloorItem,STAT_GOLD,0);
					GAP = D2GAME_GetDistanceBetweenUnits(pFloorItem, pUnit);
	
					if((pFloorItem->dwUnitType == UNIT_ITEM) && (pFloorItemTxt->dwcode == ITEM_GOLD ) && (GAP <= 3))
					{
				
						if(	(INVENTORY_GOLD + GOLD_QUANTITY) <= GOLD_LIMIT)		//gold limit check
						{
							D2GAME_PickUpGold(pGame, pUnit, pFloorItem);
							D2GAME_AttachSound(pUnit, SFX_PICKUP_ITEM, pUnit);	

							sprintf_s(pMsg,sizeof(pMsg),"Auto-picked %d Gold !", (D2COMMON_GetStat(pUnit,STAT_GOLD,0)-INVENTORY_GOLD) );
							CHAT_SendServerMessage(pGame, pUnit, COL_BLUE,FALSE, pMsg, TRUE);
						}


						if(	(INVENTORY_GOLD + GOLD_QUANTITY) > GOLD_LIMIT)	
						{
							sprintf_s(pMsg,sizeof(pMsg),"Gold Limit Reached !");
							CHAT_SendServerMessage(pGame,pUnit,COL_GREY,FALSE,pMsg,TRUE);
						}
					}

					pFloorItem = pFloorItem->pListNext;
				}

			} 

		}
	}
i am planning to revise the code as i think it is very dirty in its current state, its been long since i coded *very dirty code :D
" It's not the size of the dog in the fight, it's the size of the fight in the dog. "

~Mark Twain

User avatar
kidpaddle94
Forum Legend
Principality
Posts: 2056
Joined: Thu Aug 13, 2009 2:54 pm
Location: localhost
Canada

Re: Auto Gold Pickup

Post by kidpaddle94 » Sat Jun 27, 2015 1:34 pm

Code: Select all

void __fastcall GOLDPICKUP_PickupInRangeGold(D2GameStrc* pGame, D2UnitStrc* pPlayer)
{
	if (!pGame || !pPlayer || pPlayer->dwType != UNIT_PLAYER)
		return;

	D2RoomStrc* pRoom = DRLG_GetRoomFromUnit(pPlayer);
	if (!pRoom) return;

	if (pPlayer->dwMode == PLRMODE_DEATH || pPlayer->dwMode == PLRMODE_DEAD)
		return;

	if (D2COMMON_GetUnitState(pPlayer, STATE_UNINTERRUPTABLE))
		return;

	for (D2UnitStrc* pUnit = pRoom->pFirstUnit; pUnit; pUnit = pUnit->pRoomNext)
	{
		if (pUnit->dwType != UNIT_ITEM)
			continue;

		D2ItemsTXT* pItemRecord = TXT_GetItemRecord(pUnit->dwClass);
		if (!pItemRecord) continue;

		if (pItemRecord->dwCode != CODE32('gld '))
			continue;

		D2CoordStrc pPlayerCoords, pItemCoords = {};
		if (!DRLG_GetUnitCoords(pPlayer, &pPlayerCoords) || !DRLG_GetUnitCoords(pUnit, &pItemCoords))
			continue;

		if (D2COMMON_GetDistance(pPlayerCoords.nX, pPlayerCoords.nY, pItemCoords.nX, pItemCoords.nY) > 16)
			continue;

		DWORD dwCurrentGold = D2COMMON_GetUnitStat(pPlayer, STAT_GOLD, NULL);
		if (dwCurrentGold >= STATS_GetBeltGoldLimit(pPlayer))
			continue;

		D2GAME_PickGoldPile(pGame, pPlayer, pUnit);
	}
}

User avatar
Kuss
Posts: 82
Joined: Tue Jun 23, 2015 11:29 am

Post by Kuss » Sat Jun 27, 2015 2:19 pm

I did try Immersion days ago, and the auto-gold pickup didn't work.
You guys are posting codes (that, strangely, I can understand, since I did some basic programming in C when I was young). But I have no idea how this would relate to Diablo.
My best guess would be to put these somewhere in the .dll of the game? I think I need to start learning these things :mrgreen:

Oh and thanks for sharing the resources, now it's just about how to use them ^^

User avatar
weapon-x
Forum Legend
Arch-Angel
Posts: 1045
Joined: Wed Mar 18, 2009 4:52 am
Location: Mindanao, Philippines
Contact:
Philippines

Re:

Post by weapon-x » Sat Jun 27, 2015 2:31 pm

Kuss" wrote:I did try Immersion days ago, and the auto-gold pickup didn't work.
You guys are posting codes (that, strangely, I can understand, since I did some basic programming in C when I was young). But I have no idea how this would relate to Diablo.
My best guess would be to put these somewhere in the .dll of the game? I think I need to start learning these things :mrgreen:

Oh and thanks for sharing the resources, now it's just about how to use them ^^
We are using a Code-Base written in C++ I in particular use d2template (shared by kidpaddle) which compiles into a .dll
i also used the d2modsdk before and d2external system too

then you need to find a way for Diablo2 to load your new dll, as for me i use the d2mod system by SVR [D2 v1.10]

i think you should visit the d2template thread *code-editing forum

the community needs more Coders :)

as the more advance our community, the better the mods that come out :) which means more fun :mrgreen:
" It's not the size of the dog in the fight, it's the size of the fight in the dog. "

~Mark Twain

User avatar
Kuss
Posts: 82
Joined: Tue Jun 23, 2015 11:29 am

Re: Auto Gold Pickup

Post by Kuss » Sat Jun 27, 2015 2:56 pm

Thanks mate!
I got myself the d2Template but I just read that there's no 1.13 version of the d2mod System, so I ask: is D2SE an alternative? Or is it a totally different thing?

As for now, I'm going to start messing things up with my 1.10 (brb downgrading :mrgreen: )

EDIT ---- Ok I found NefEx that does the exact same thing and works with 1.11.

Post Reply

Return to “General Mod Making”