New pSpell
Moderators: Nefarius, Havvoric
- Havvoric
- Champion of the Light
- Posts: 392
- Joined: Mon Apr 12, 2004 1:12 am
- Location: Newcastle upon Tyne
- Contact:
New pSpell
Can anyone give me a clue as to how I'd go about adding a new pSpell?
Re: New pSpell
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:
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.
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] ¤‚Ê...¤òƒ‹...
+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
~ 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
- Havvoric
- Champion of the Light
- Posts: 392
- Joined: Mon Apr 12, 2004 1:12 am
- Location: Newcastle upon Tyne
- Contact:
Re: New pSpell
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.
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.
Re: New pSpell
The first 4 bytes is init (handles arrow mouse pointer for identify as example)
as you have wrote next 4 bytes is action.
as you have wrote next 4 bytes is action.
-
- Posts: 9
- Joined: Sun Nov 25, 2018 8:39 am
Re: New pSpell
is the pSpell code located in the the dll files?
Re: New pSpell
yep
-
- Posts: 9
- Joined: Sun Nov 25, 2018 8:39 am
Re: New pSpell
okay thank you i appreciate the answer
-
- Posts: 9
- Joined: Sun Nov 25, 2018 8:39 am
Re: New pSpell
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.
- Necrolis
- Throne
- Posts: 9125
- Joined: Sat Mar 25, 2006 1:22 pm
- Location: The Land of the Dead
- Contact:
Re: New pSpell
Firstly, please avoid double posting; for something like this, creating a new topic might be a option.
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.Pandaman130 wrote: ↑Tue Dec 11, 2018 12:15 amhow 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.
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
Re: New pSpell
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;
}
Re: New pSpell
1.13d Pspell Func Table
d2game.dll+0x108690
I'm not sure, is that right?
d2game.dll+0x108690
I'm not sure, is that right?
- devurandom
- Angel
- Posts: 897
- Joined: Sat Mar 07, 2015 9:07 pm
Re: New pSpell
Code: Select all
6FC5DF11 |. 8B0CDD 9086D26F MOV ECX,DWORD PTR DS:[EBX*8+6FD28690]
D2Game.0x108690
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..
Fiat paper money is the most elaborate and well devised form of slavery the world has ever seen..
-
- Posts: 9
- Joined: Sun Nov 25, 2018 8:39 am
Re: New pSpell
can anyone tell me the line for the dclone laser? trying to find it in hardcode but cant seem to find it.
-
- Posts: 58
- Joined: Fri Mar 09, 2018 10:43 pm
Re: New pSpell
Kinda way off topic but :Pandaman130 wrote: ↑Thu Aug 29, 2019 2:28 amcan anyone tell me the line for the dclone laser? trying to find it in hardcode but cant seem to find it.
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