New pSpell

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
Havvoric
Moderator
Champion of the Light
Posts: 392
Joined: Mon Apr 12, 2004 1:12 am
Location: Newcastle upon Tyne
Contact:
Great Britain

New pSpell

Post by Havvoric » Tue Jan 25, 2005 10:08 pm

Can anyone give me a clue as to how I'd go about adding a new pSpell?

User avatar
Myhrginoc
Retired Admin
Cherub
Posts: 12100
Joined: Sat May 25, 2002 7:28 am
Location: Percussion U
United States of America

Hand-picked

Re: New pSpell

Post by Myhrginoc » Wed Jan 26, 2005 2:37 am

Watch the behavior of an existing pSpell. This can be done with a debugger such as Ollydbg. Attach the debugger to a running game, after you appear in a town. Now look at the module list (E button in Ollydbg) and find d2common.dll. This dll relocates normally so it won't be the same all the time. (There is a rebased version in our File Center that doesn't get shoved around.) Make note of the base address the dll actually loaded at. Now open a dump window and go to that base address + offset AA2E0, so if the dll loaded at 03E10000 then go to 03EBA2E0. You should see a structure like this:

Code: Select all

03EBA2E0  [color=#6400ff]87 02 00 00 44 A9 80 02[/color] [color=#00bfff]44 A9 80 02 32 01 00 00[/color]  ‡..D©€D©€2..
03EBA2F0  [color=#d100ff]14 A4 82 02 CA 00 00 00[/color] [color=#ad0000]A4 F2 83 02 8B 00 00 00[/color]  ¤‚Ê...¤òƒ‹...
The structure is

+00 - number of all items records
+04 - pointer to all items table base
+08 - pointer to weapons table base (always has been same as +04 for me)
+0C - number of weapons records
+10 - pointer to armor table base
+14 - number of armor records
+18 - pointer to misc items table base
+1C - number of misc item records

Now get the pointer to the misc items table. Then add the value from the table below to find out where you want to set a memory breakpoint. This will be the actual pSpell value from misc.txt. The values will be dwords. (Hint: the dwords in front of these are the alternategfx field values.)

+08DC Stamina (pSpell = 9)
+0A84 Antidote (pSpell = 6)
+0C2C Rejuvenation (pSpell = 5)
+1124 Book of Town Portal (pSpell = 2)
+12CC Book of Identify (pSpell = 1)

Once you have set a memory breakpoint, try using the item and you should get stopped at the code using that pSpell value. You should be at a switch structure or similar table that will direct you to different functions based on pSpell value.
Last edited by Myhrginoc on Wed Jan 26, 2005 2:44 am, edited 1 time in total.
Do the right thing. It will gratify some people and astonish the rest.
~ Mark Twain
Run Diablo II in any version for mods: tutorial
The Terms of Service!! Know them, abide by them, and enjoy the forums at peace.
The Beginner's Guide v1.4: (MS Word | PDF) || Mod Running Scripts || TFW: Awakening

User avatar
Havvoric
Moderator
Champion of the Light
Posts: 392
Joined: Mon Apr 12, 2004 1:12 am
Location: Newcastle upon Tyne
Contact:
Great Britain

Re: New pSpell

Post by Havvoric » Wed Jan 26, 2005 7:57 pm

Thanks, exactly what I needed.
In case anyone else needs this, there's a table at D2Game + 110688,
of eight-byte long elements.
In all cases, other that pSpell=1, the first four bytes = 0. The next four bytes are the address of the method to action that pSpell.

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

Hand-picked

Re: New pSpell

Post by kingpin » Thu Jan 27, 2005 1:11 am

The first 4 bytes is init (handles arrow mouse pointer for identify as example)

as you have wrote next 4 bytes is action.

User avatar
Havvoric
Moderator
Champion of the Light
Posts: 392
Joined: Mon Apr 12, 2004 1:12 am
Location: Newcastle upon Tyne
Contact:
Great Britain

Post by Havvoric » Thu Jan 27, 2005 8:50 am

Thanks, couldn't work out what the purpose of the first four was, only knew it was only for pSpell = 1.

Pandaman130
Posts: 9
Joined: Sun Nov 25, 2018 8:39 am
United States of America

Re: New pSpell

Post by Pandaman130 » Fri Dec 07, 2018 7:40 pm

is the pSpell code located in the the dll files?

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

Re: New pSpell

Post by thaison » Sat Dec 08, 2018 9:30 am

Pandaman130 wrote:
Fri Dec 07, 2018 7:40 pm
is the pSpell code located in the the dll files?
yep :D

Pandaman130
Posts: 9
Joined: Sun Nov 25, 2018 8:39 am
United States of America

Re: New pSpell

Post by Pandaman130 » Sun Dec 09, 2018 3:15 am

okay thank you i appreciate the answer

Pandaman130
Posts: 9
Joined: Sun Nov 25, 2018 8:39 am
United States of America

Re: New pSpell

Post by Pandaman130 » Tue Dec 11, 2018 12:15 am

how does one go about adding a new pspell for lets say stacking and unstacking potions? im learning new things and this is one that im stuck on.

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

Hand-picked

Re: New pSpell

Post by Necrolis » Tue Dec 11, 2018 7:28 am

Firstly, please avoid double posting; for something like this, creating a new topic might be a option.
Pandaman130 wrote:
Tue Dec 11, 2018 12:15 am
how does one go about adding a new pspell for lets say stacking and unstacking potions? im learning new things and this is one that im stuck on.
pspells tend to consume the item (and thus dont interact well with stacked items), if you want to unstack things, I'd suggest hooking the item interaction code rather than making a new pspell.
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

nnsky2011
Posts: 4
Joined: Thu Jan 05, 2017 9:36 am

Re: New pSpell

Post by nnsky2011 » Wed Jan 02, 2019 6:17 am

Code: Select all

#include <Windows.h>
BOOL _fastcall NewpSpell(DWORD Room, DWORD Character, DWORD Item1, DWORD Item2, DWORD, DWORD, DWORD) {
	return true;//返回真销毁物品,返回假不销毁
}
extern "C" int APIENTRY _DllMainCRTStartup(HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved) {
	if (ul_reason_for_call == DLL_PROCESS_ATTACH) {
		struct pSpell {
			void* ClientFunc;
			void* GameFunc;
		}*pspell = (pSpell*)((DWORD)GetModuleHandle("d2game.dll") + 0x110688);
		DWORD op = 8;
		void* temp = &NewpSpell;
		WriteProcessMemory(GetCurrentProcess(), &pspell[op].GameFunc, &temp, sizeof(temp), 0);
	}
	return 0;
}

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

Re: New pSpell

Post by karlock » Tue Jan 08, 2019 4:07 am

1.13d Pspell Func Table
d2game.dll+0x108690
I'm not sure, is that right?

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

Re: New pSpell

Post by devurandom » Tue Jan 08, 2019 9:44 am

Code: Select all

6FC5DF11  |.  8B0CDD 9086D26F   MOV ECX,DWORD PTR DS:[EBX*8+6FD28690]
D2Game.0x108690
Looks correct
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..

Pandaman130
Posts: 9
Joined: Sun Nov 25, 2018 8:39 am
United States of America

Re: New pSpell

Post by Pandaman130 » Thu Aug 29, 2019 2:28 am

can anyone tell me the line for the dclone laser? trying to find it in hardcode but cant seem to find it.

JayBrainDead
Posts: 58
Joined: Fri Mar 09, 2018 10:43 pm

Re: New pSpell

Post by JayBrainDead » Thu Aug 29, 2019 4:47 am

Pandaman130 wrote:
Thu Aug 29, 2019 2:28 am
can anyone tell me the line for the dclone laser? trying to find it in hardcode but cant seem to find it.
Kinda way off topic but :

What you are looking for is not hardcoded, you have to open up MonStats.txt to see what skills monsters are using
Diablo clone is row 334 and I believe the skill you are looking for is "DiabLight" which is probably the same for regular Diablo and Uber Diablo
If you want to mess with this skill open up Skills.txt and look for a skill named DiabLight

No coding involved good luck

Post Reply

Return to “Code Editing”