[1.10] Different Inventory Graphics for Each Class

This forum is for discussions on how to edit what can not be edited through the txt files, needless to say this isn't about battle net hacking.

Moderators: Nefarius, Havvoric

Post Reply
User avatar
Xibalba
Dark Alliance Beta Test
Champion of the Light
Posts: 282
Joined: Thu Aug 29, 2013 2:38 pm
Location: Skyrim

[1.10] Different Inventory Graphics for Each Class

Post by Xibalba » Sun Mar 29, 2015 1:38 pm

Hello,

The thing i want to achieve is make the game load different dc6 images (inventory) for each class. I want to say that im absolute beginner on code editing. I found this link.

This is what i feel as a beginner :)
Image

Can someone explain it a little more "step by step" maybe? Im asking for too much thing, i know, sorry. Just trying my luck here :)

Thanks
Life is too short to drive boring cars.

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

Re: [1.10] Different Inventory Graphics for Each Class

Post by kidpaddle94 » Sun Mar 29, 2015 4:54 pm

You hook into the code that loads the character inventory graphics, and replace it to load a different file, based on which class is used. You get the current class from the same variable used by the skill tree images loading procedure. Then, instead of passing a static string to the function that loads the image, you pass a formatted string, something along those lines:

Code: Select all

sprintf(szBuffer, "data\\global\\ui\\panel\\invchar%d", D2CLIENT_gdwCharacterClass);
D2CLIENT_LoadCellFile(szBuffer);

User avatar
Xibalba
Dark Alliance Beta Test
Champion of the Light
Posts: 282
Joined: Thu Aug 29, 2013 2:38 pm
Location: Skyrim

Re: [1.10] Different Inventory Graphics for Each Class

Post by Xibalba » Sun Mar 29, 2015 5:19 pm

i already thinked using char class check from skills but instead of using c++ i thinked in asm. Maybe conditional jump (checks char class same as skill tree) then passes the string but didnt really know how to do it, i can mess things up.

so in your way, (in d2template) i can (lol im sure i cant) make an if statement that checks char class then use the code you gave me?
Life is too short to drive boring cars.

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

Re: [1.10] Different Inventory Graphics for Each Class

Post by kidpaddle94 » Sun Mar 29, 2015 5:41 pm

In my project I did exactly what you want to do, but for the mana orb (I wanted different resources for every class as in Diablo III)
Also as a bonus, it also shows how to achieve an animated orb graphic ;)

Code: Select all

/*
	Function:		BOTTOMPANEL_DrawResourceOrb
	Address:		D2Client.0x27A90
	Notes:
*/
void __fastcall BOTTOMPANEL_DrawResourceOrb()
{
	D2UnitStrc* pPlayer = *D2CLIENT_sgptClientPlayer;
	int nEnergy = D2COMMON_GetUnitStat(pPlayer, D2STAT_MANA, 0);
	int nMaxEnergy = D2COMMON_GetUnitStat(pPlayer, D2STAT_MAXMANA, 0);

	if (!sgptResourceOrbDc6)
	{
		char szBuffer[256] = {};

		sprintf(szBuffer, "Data\\Global\\Themes\\%s\\ResourceOrbs\\Resource%d", gszGuiThemes[sgdwSelectedGuiTheme], pPlayer->dwTxtClass);
		sgptResourceOrbDc6 = D2CLIENT_LoadCellFile(szBuffer, CELLFILETYPE_DC6);
	}

	if (!sgptOrbOverlapDc6)
	{
		char szBuffer[256] = {};

		sprintf(szBuffer, "Data\\Global\\Themes\\%s\\Panels\\BottomPanelOverlap", gszGuiThemes[sgdwSelectedGuiTheme]);
		sgptOrbOverlapDc6 = D2CLIENT_LoadCellFile(szBuffer, CELLFILETYPE_DC6);
	}

	int nOrbSize = GFX_GetStatBarLength(nEnergy, nMaxEnergy, 140);
	int nFrames = D2CMP_GetFrameCount(sgptResourceOrbDc6);

	D2GfxDataStrc EnergyGfx = {};
	D2GfxDataStrc OverlapGfx = {};

	EnergyGfx.pCellFile = sgptResourceOrbDc6;
	EnergyGfx.nFrame = (GetTickCount() >> 6) % nFrames;

	OverlapGfx.pCellFile = sgptOrbOverlapDc6;

	D2GFX_DrawVerticalCropImage(&EnergyGfx, 837, 780, 12, nOrbSize, DRAWMODE_NORMAL);

	OverlapGfx.nFrame = 0x03;
	D2GFX_DrawImage(&OverlapGfx, 768, 768, -1, DRAWMODE_NORMAL, NULL);

	OverlapGfx.nFrame = 0x01;
	D2GFX_DrawImage(&OverlapGfx, 768, 768, -1, DRAWMODE_NORMAL, NULL);
}
As you can see, it's all about passing a formatted string to the function that loads the graphic. Basically, in memory the class is represented by an integer.
0 = amazon
1 = sorceress
[ ... ]

And my code formats this integer into the string, so the %d gets replaced by the class integer. And so it loads Resource0.dc6 when it's an amazon, Resource1.dc6 when it's a sorceress, and so on.

User avatar
Xibalba
Dark Alliance Beta Test
Champion of the Light
Posts: 282
Joined: Thu Aug 29, 2013 2:38 pm
Location: Skyrim

Re: [1.10] Different Inventory Graphics for Each Class

Post by Xibalba » Sun Mar 29, 2015 5:52 pm

Thanks a lot, the code you gave me clears most of the questions that i have in my mind. I will try as sson as i can and report back what i did (i hope you will see again). Thanks!
Life is too short to drive boring cars.

User avatar
huohuowu2
Junior Member
Paladin
Posts: 152
Joined: Sat Feb 28, 2015 4:20 am
China

Re: [1.10] Different Inventory Graphics for Each Class

Post by huohuowu2 » Sat Oct 06, 2018 6:32 am

kidpaddle94 wrote:
Sun Mar 29, 2015 5:41 pm
In my project I did exactly what you want to do, but for the mana orb (I wanted different resources for every class as in Diablo III)
Also as a bonus, it also shows how to achieve an animated orb graphic ;)

Code: Select all

/*
	Function:		BOTTOMPANEL_DrawResourceOrb
	Address:		D2Client.0x27A90
	Notes:
*/
void __fastcall BOTTOMPANEL_DrawResourceOrb()
{
	D2UnitStrc* pPlayer = *D2CLIENT_sgptClientPlayer;
	int nEnergy = D2COMMON_GetUnitStat(pPlayer, D2STAT_MANA, 0);
	int nMaxEnergy = D2COMMON_GetUnitStat(pPlayer, D2STAT_MAXMANA, 0);

	if (!sgptResourceOrbDc6)
	{
		char szBuffer[256] = {};

		sprintf(szBuffer, "Data\\Global\\Themes\\%s\\ResourceOrbs\\Resource%d", gszGuiThemes[sgdwSelectedGuiTheme], pPlayer->dwTxtClass);
		sgptResourceOrbDc6 = D2CLIENT_LoadCellFile(szBuffer, CELLFILETYPE_DC6);
	}

	if (!sgptOrbOverlapDc6)
	{
		char szBuffer[256] = {};

		sprintf(szBuffer, "Data\\Global\\Themes\\%s\\Panels\\BottomPanelOverlap", gszGuiThemes[sgdwSelectedGuiTheme]);
		sgptOrbOverlapDc6 = D2CLIENT_LoadCellFile(szBuffer, CELLFILETYPE_DC6);
	}

	int nOrbSize = GFX_GetStatBarLength(nEnergy, nMaxEnergy, 140);
	int nFrames = D2CMP_GetFrameCount(sgptResourceOrbDc6);

	D2GfxDataStrc EnergyGfx = {};
	D2GfxDataStrc OverlapGfx = {};

	EnergyGfx.pCellFile = sgptResourceOrbDc6;
	EnergyGfx.nFrame = (GetTickCount() >> 6) % nFrames;

	OverlapGfx.pCellFile = sgptOrbOverlapDc6;

	D2GFX_DrawVerticalCropImage(&EnergyGfx, 837, 780, 12, nOrbSize, DRAWMODE_NORMAL);

	OverlapGfx.nFrame = 0x03;
	D2GFX_DrawImage(&OverlapGfx, 768, 768, -1, DRAWMODE_NORMAL, NULL);

	OverlapGfx.nFrame = 0x01;
	D2GFX_DrawImage(&OverlapGfx, 768, 768, -1, DRAWMODE_NORMAL, NULL);
}
As you can see, it's all about passing a formatted string to the function that loads the graphic. Basically, in memory the class is represented by an integer.
0 = amazon
1 = sorceress
[ ... ]

And my code formats this integer into the string, so the %d gets replaced by the class integer. And so it loads Resource0.dc6 when it's an amazon, Resource1.dc6 when it's a sorceress, and so on.
How to use ollydbg to do this?

User avatar
Necrolis
Site Admin
Throne
Posts: 9085
Joined: Sat Mar 25, 2006 1:22 pm
Location: The Land of the Dead
Contact:
South Africa

Hand-picked

Re: [1.10] Different Inventory Graphics for Each Class

Post by Necrolis » Sat Oct 06, 2018 9:16 am

huohuowu2 wrote:
Sat Oct 06, 2018 6:32 am
How to use ollydbg to do this?
If you want to use olly to do this, you will need to code it in assembly, you'll probably also need a bit of slack space depending on the version you are editing.
Image
Netiquette, Do you USE it?!?! | Nefarius' Fixed TXT Files | Terms Of Service
Blackened | Day of Death | D2GFEx
"What was yours is mine. Your land, your people, and now your life." - Lim-Dul, the Necromancer
Judgement is Final, Death is Eternal

User avatar
huohuowu2
Junior Member
Paladin
Posts: 152
Joined: Sat Feb 28, 2015 4:20 am
China

Re: [1.10] Different Inventory Graphics for Each Class

Post by huohuowu2 » Sun Oct 07, 2018 12:50 am

Necrolis wrote:
Sat Oct 06, 2018 9:16 am
huohuowu2 wrote:
Sat Oct 06, 2018 6:32 am
How to use ollydbg to do this?
If you want to use olly to do this, you will need to code it in assembly, you'll probably also need a bit of slack space depending on the version you are editing.
This is harder than copy this code.
I will try to learn how to make a new dll.
Thank you.

User avatar
huohuowu2
Junior Member
Paladin
Posts: 152
Joined: Sat Feb 28, 2015 4:20 am
China

Re: [1.10] Different Inventory Graphics for Each Class

Post by huohuowu2 » Mon Oct 08, 2018 1:10 am

:cry:
I readed sir_generals Advanced Code Editing Tutorial.sir_general's HeavanStorm C++ Coding Editing Tutorials and Joel's Advanced C++ Code Editing Tutorial.
But i don't know how to copy this code in dll.
I tried to load D2Client.dll by visual studio 2012.But can't find any code.
Have I missed some tutorials?

User avatar
Ichikun
Posts: 3
Joined: Thu Aug 27, 2020 10:17 am

Re: [1.10] Different Inventory Graphics for Each Class

Post by Ichikun » Fri Sep 18, 2020 9:05 pm

Can i have ur dll for diablo 1.13d? Please or please help with my dll http://www.mediafire.com/file/tmmq53yyc ... s.rar/file
Just wanna try like diablo3 diffrent globes for every character. Thanks

Post Reply

Return to “Code Editing”