A function stub for player stat update

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

User avatar
karlock
Posts: 42
Joined: Mon Mar 16, 2015 1:16 pm

A function stub for player stat update

Post by karlock » Fri Feb 01, 2019 3:41 pm

I found the function at D2GAME.0x6FD0DD80 for 1.13d. Used by -act X param.
I guess it need a ActIndex in eax and player Unit* in ecx, But crush...

Code: Select all

__declspec(naked) void __fastcall D2GAME_UpdatePlayerStats (UnitAny* pPlayer, WORD nAct)
{
	__asm
	{
		mov eax, nAct
		call D2GAME.0x6FD0DD80
	}
}
:oops: How to find the truly things needed for that kind of functions?

User avatar
thaison
Junior Member
Paladin
Posts: 108
Joined: Fri Apr 03, 2015 11:59 am
Location: Viet Nam
Vietnam

Re: A function stub for player stat update

Post by thaison » Sat Feb 02, 2019 4:01 am

delete
Last edited by thaison on Thu May 14, 2020 12:54 am, edited 1 time in total.

User avatar
misiek1294
Junior Member
Paladin
Posts: 168
Joined: Mon Dec 29, 2014 3:58 pm
Poland

Re: A function stub for player stat update

Post by misiek1294 » Sat Feb 02, 2019 7:42 am

Code: Select all

__declspec(naked) void __fastcall D2GAME_UpdatePlayerStats (UnitAny* pPlayer, WORD nAct)
{
	__asm
	{
		mov eax,edx // nAct will be in edx because it's fastcall
		call D2GAME.0x6FD0DD8
		retn
	}
}
If nAct should be in eax and pPlayer in ecx this will be correct.
I don't analyse it much but for me it looks like D2GAME_UpdatePlayerStats (game * pGame,UnitAny* pPlayer, BYTE nAct) so should be

Code: Select all

__declspec(naked) void __fastcall D2GAME_UpdatePlayerStats (game *pGame,UnitAny* pPlayer, BYTE nAct)
{
	__asm
	{
		push [esp +0x04] // nAct
		push ecx// pGame
		mov ecx,edx //pPlayer
		call D2GAME.0x6FD0DD8
		retn 4
	}
}

User avatar
devurandom
Forum Regular
Angel
Posts: 897
Joined: Sat Mar 07, 2015 9:07 pm
United States of America

Re: A function stub for player stat update

Post by devurandom » Sat Feb 02, 2019 1:57 pm

with stubs I put a break on the call to the function, then ID what each arg is.
Also good idea to look at the prolog and epilog of called function, incase you need to protect stack.
Thanks to Necrolis for that time saving technique.

This is 6FD0B2C0 in 1.13c if someone wants that. I changed the name to StartActPlayerStats for my notes.

Code: Select all

6FC4701F  |.  57            PUSH EDI                        ; /Arg1 = pGame
6FC47020  |.  8AC3          MOV AL,BL                       ; |     = nAct
6FC47022  |.  8BCE          MOV ECX,ESI                     ; |     = pPlayer
6FC47024  |.  E8 576D0C00   CALL 6FD0DD80                   ; \D2Game.6FD0DD80

Code: Select all

__declspec(naked) void __fastcall D2GAME_UpdatePlayerStats (D2Game *pGame, D2Unit* pPlayer, BYTE nAct)
{
	__asm{
	MOVZX EAX, BYTE [ESP+0x04]	// nAct
	PUSH ECX			// pGame  arg1 to func
	MOV ECX,EDX			// pPlayer
	CALL D2GAME_6FD0DD8		// pointer to 6FD0DD8
	RETN 4
	}
}
Last edited by devurandom on Sat Feb 02, 2019 2:09 pm, edited 2 times in total.
Assembly Reference | 1.13d Code Edits | UVLoD | BaseMod Plugin

Fiat paper money is the most elaborate and well devised form of slavery the world has ever seen..

User avatar
karlock
Posts: 42
Joined: Mon Mar 16, 2015 1:16 pm

Re: A function stub for player stat update

Post by karlock » Sat Feb 02, 2019 2:05 pm

Thanks! I wonder if it can make character of level down and empty the experience! :D
https://d2mods.info/forum/viewtopic.php ... 50#p217020
Kingpin's note for this function.(1.10)

User avatar
karlock
Posts: 42
Joined: Mon Mar 16, 2015 1:16 pm

Re: A function stub for player stat update

Post by karlock » Sat Feb 02, 2019 2:22 pm

devurandom wrote:
Sat Feb 02, 2019 1:57 pm
with stubs I put a break on the call to the function, then ID what each arg is.

This is 6FD0B2C0 in 1.13c if someone wants that. I changed the name to StartActPlayerStats for my notes.

Code: Select all

6FC4701F  |.  57            PUSH EDI                        ; /Arg1 = pGame
6FC47020  |.  8AC3          MOV AL,BL                       ; |     = nAct
6FC47022  |.  8BCE          MOV ECX,ESI                     ; |     = pPlayer
6FC47024  |.  E8 576D0C00   CALL 6FD0DD80                   ; \D2Game.6FD0DD80

Code: Select all

__declspec(naked) void __fastcall D2GAME_UpdatePlayerStats (D2Game *pGame, D2Unit* pPlayer, BYTE nAct)
{
	__asm{
	MOVZX EAX, BYTE [ESP+0x04]	// nAct
	PUSH ECX			// pGame  arg1 to func
	MOV ECX,EDX			// pPlayer
	CALL D2GAME_6FD0DD8		// pointer to 6FD0DD8
	RETN 4
	}
}
It worked!
D2GAME_UpdatePlayerStats(pGame, pPlayer, actNo);
D2COMMON_SetUnitStat(pPlayer, STATS_EXPERIENCE, 0, 0);
The character is back to level 1!

User avatar
devurandom
Forum Regular
Angel
Posts: 897
Joined: Sat Mar 07, 2015 9:07 pm
United States of America

Re: A function stub for player stat update

Post by devurandom » Sat Feb 02, 2019 5:56 pm

That's cool!

Was thinking you could run some loops and reset all the quests, but not sure about reset questdata.
Maybe someone else has a suggestion, or you could look into how its done for character create.
Assembly Reference | 1.13d Code Edits | UVLoD | BaseMod Plugin

Fiat paper money is the most elaborate and well devised form of slavery the world has ever seen..

User avatar
karlock
Posts: 42
Joined: Mon Mar 16, 2015 1:16 pm

Re: A function stub for player stat update

Post by karlock » Sun Feb 03, 2019 3:29 am

devurandom wrote:
Sat Feb 02, 2019 5:56 pm
That's cool!

Was thinking you could run some loops and reset all the quests, but not sure about reset questdata.
Maybe someone else has a suggestion, or you could look into how its done for character create.

Code: Select all


struct QuestFlags {
	void* pBuffer; // 0x00
	DWORD _1;     // 0x04
};

void __fastcall ResetPlayerAllQuestFlags(UnitAny* pPlayer)
{
	PlayerData* pPlayerData = pPlayer->pPlayerData;
	int diff = 3;
	do
	{
		auto pQuestFlags = pPlayerData->QuestsFlags[--diff];
		memset(pQuestFlags->pBuffer, 0, 0x60);
	} while (diff);
}

struct Waypoint {
    BYTE flags; // 0x00
};

void __fastcall ResetPlayerAllWaypoints(UnitAny* pPlayer)
{
	PlayerData* pPlayerData = pPlayer->pPlayerData;
	int diff = 3;
	do
	{
		auto pWaypoint = pPlayerData->pWaypoints[--diff];
		memset(pWaypoint, 0, 0x0D);
	} while (diff);
}
Try this? I dont know exactly size of those structs. But....data has been reset. Voodoo working :P

User avatar
devurandom
Forum Regular
Angel
Posts: 897
Joined: Sat Mar 07, 2015 9:07 pm
United States of America

Re: A function stub for player stat update

Post by devurandom » Sun Feb 03, 2019 5:44 am

https://d2mods.info/forum/viewtopic.php?t=63622
From this post but reading further down to MNW1995's comment.

Code: Select all

struct WaypointData		// size 0x10
{
	WORD nData[8];		//0x00
};
you may rework and test this:

Code: Select all

void __fastcall ResetPlayerAllWaypoints(UnitAny* pPlayer)
{
	PlayerData* pPlayerData = pPlayer->pPlayerData;
	int diff = 3;
	do
	{
		WaypointData* pWaypoint = pPlayerData->pWaypoints[--diff];
		memset(pWaypoint, 0, sizeof(pWaypoint));
	} while (diff);
}

This function ResetPlayerAllQuestFlags looks a little dangerous in its current state.
maybe look into character create see where size is allocated.
Assembly Reference | 1.13d Code Edits | UVLoD | BaseMod Plugin

Fiat paper money is the most elaborate and well devised form of slavery the world has ever seen..

User avatar
karlock
Posts: 42
Joined: Mon Mar 16, 2015 1:16 pm

Re: A function stub for player stat update

Post by karlock » Sun Feb 03, 2019 7:16 am

https://pastebin.com/HFBgJ7V4
I found this.

test with hours.

Code: Select all

struct D2ClientStrc
{
    DWORD dwClientId;                    //0x000
    DWORD dwClientState;               //0x004
    WORD wClassId;                         //0x008
    BYTE nPlayerStatus;                     //0x00A
    BYTE nCompleteActFlags;             //0x00B
    ...
}
Every act complete CompleteActFlags + 1. All 3 difficult completed is 0xF.
CompleteActFlags should be reset to 0, then the character's act completed data is fully reset. No difficulties can be chosen.

User avatar
devurandom
Forum Regular
Angel
Posts: 897
Joined: Sat Mar 07, 2015 9:07 pm
United States of America

Re: A function stub for player stat update

Post by devurandom » Sun Feb 03, 2019 8:49 am

part of the struct looks wrong in size

Code: Select all

	char szClanTag[4];			//0x460
	char szClanName[7];			//0x464
maybe it should be this instead.

Code: Select all

	char* szClanTag[4];			//0x460
	char* szClanName[7];			//0x470
Assembly Reference | 1.13d Code Edits | UVLoD | BaseMod Plugin

Fiat paper money is the most elaborate and well devised form of slavery the world has ever seen..

User avatar
karlock
Posts: 42
Joined: Mon Mar 16, 2015 1:16 pm

Re: A function stub for player stat update

Post by karlock » Mon Feb 04, 2019 2:34 am

Thanks! :)

Return to “Code Editing”