Npc Hacking!

Apr 30, 2007 at 1:34 AM
Been here way too long...
"..."
Join Date: Jun 25, 2005
Location:
Posts: 372
They're hex values, they work differently.

Since one is big and first, they seem to be in little endian format. What this means is that the least significant digit is stored first - think of it like the number 123 being stored as 321(assuming that we are using the normal numbering system and each separate number is a single byte) There are advantages to this, but don't try to ask me about them.

If your digits are 232 and 3, or, rather, the bytes E8 and 03. Turn this around and you get the hex value of 0x03E8(The prefix of 0x is used to indicate it is a hex value). Since hex is a base 16 number system, the tens place is the number times 16, and the hundreds is the number times 16^2. E0 = 14 * 16 = 224, and 300 = 3 * 16 * 16 = 768. Thus, 768 + 224 + 8 = 1000. Is that Ballos? :eek:

You've got to keep in mind both that most numerical values are going to be stored in little endian order AND are in hex.
 
Apr 30, 2007 at 12:11 PM
Senior Member
"I, Ikachan. The Life and Documentary of the OrigiNAL SQuiD."
Join Date: Mar 9, 2007
Location:
Posts: 170
Thanks.
So what I should do is reverse the placement of the two hex values, bunch them togheter, and that gives me my health value (in hex)?
Also, are all other double byte values in the npc.tbl in this little endian order?

It's probably Ballos, yeah. I just picked a large number in the health segment randomly.
 
May 1, 2007 at 3:14 AM
Been here way too long...
"..."
Join Date: Jun 25, 2005
Location:
Posts: 372
If one is in little endian, it's safe to assume the rest are as well. So yes.
 
May 1, 2007 at 6:40 PM
Hoxtilicious
"Life begins and ends with Nu."
Join Date: Dec 30, 2005
Location: Germany
Posts: 3218
Age: 32
Orfvar Stöhtkonung said:
It's probably Ballos, yeah. I just picked a large number in the health segment randomly.

Osmose said:
Is that Ballos? :p

It isn't :eek:
There are enemies in the game like the butes who have a kinda high health number and I have no idea why...
 
May 22, 2007 at 2:13 AM
Neophyte Member
"Fresh from the Bakery"
Join Date: Feb 5, 2007
Location:
Posts: 8
Age: 33
Problem the file is missing... :C
 
May 22, 2007 at 12:38 PM
Hoxtilicious
"Life begins and ends with Nu."
Join Date: Dec 30, 2005
Location: Germany
Posts: 3218
Age: 32
Furion001 said:
Problem the file is missing... :C

Yep, I turned downloads down, because of some reasons.
 
May 22, 2007 at 11:54 PM
Been here way too long...
"..."
Join Date: Jan 21, 2006
Location:
Posts: 369
Furion001 said:
Problem the file is missing... :C
Imagine this is the first post.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

NPC HACKING FAQ
By ShInInG PhAnToM
additions by Kapow & Runelancer
4.2006

NPC.TBL has data for 361 entities (0000-0360). That's 169 in hex.

The data is stored in sets, one for each entity parameter, with values 1, 2, or 4 bytes in length.
Each set has 361 entries, one for each entity, then the next set begins back at entity 0000.
So, each set is a multiple of 169h bytes, and so the starting address of each set will be a multiple of 169h.


There are 11 sets:
0x0000 - 2 bytes (16 bit flags) [Special Values] [Look Down]
0x02D2 - 2 bytes (1 word) [Health Value]
0x05A4 - 1 byte [Tileset Value] [Look Down]
0x070D - 1 byte [Death Sound] [46, 47, or 48 are the most usual Sounds]
0x0876 - 1 byte [Hurt Sound] [32-36 are the most usual Sounds]
0x09DF - 1 byte [Death Animation] [Use 00 - 03]
0x0B48 - 4 bytes (1 dword) [Dropped Experience]
0x10EC - 4 bytes (1 dword) [Damage Value]
0x1690 - 4 bytes (seperate values) [Collsion Bounding Box]
0x1C34 - 4 bytes (seperate values) [Display Bounding Box]

The bounding boxes are 4 byte objects.

0x00 Left
0x01 Top
0x02 Right
0x03 Bottom

A sprite is always drawn using the top and left or right (depending on its direction) corner of the bounding box. This is offset from the center of the sprite, by the way: a 16x16 sprite with a bounding box of 8,8,8,8 is perfectly centered. 0,0,8,8 will offset it 8 pixels to the left/up.


Special Values:

01234567 89ABCDEF

0 - Solid! 1
1 - No Affect about Tile 44! 2
2 - Invincible (Blink Sound) 4
3 - Non Solid Affected! 8
4 - Bouncing! 10
5 - Hitable! 20
6 - Solid? 40
7 - No Damage at Back and Top! 80
8 - No Player Damage! 1
9 - ??? 2
A - ??? 4
B - ??? 8
C - ??? 10
D - Non Damage able! 20
E - ??? 40
F - Show Damage Numbers! 80

Tileset Value:

00 : Using the Title Tileset.
01 : Using ?????? Tileset.
02 : Using the Map Tileset.
03 : Using ?????? Tileset.
04 : Using ?????? Tileset.
05 : Using ?????? Tileset.
06 : Using Fade Tileset.
07 : Using ?????? Tileset.
08 : Using ItemImage Tileset.
09 : Using ?????? Tileset.
0A : Using ?????? Tileset.
0B : Using ?????? Tileset.
0C : Using ?????? Tileset.
0D : Using ?????? Tileset.
0E : Using ?????? Tileset.
0F : Using ?????? Tileset.
10 : Using the MyCharNPC.
11 : Using the BulletNPC.
12 : Using ?????? Tileset.
13 : Using the CaretNPC.
14 : Using the NPCSym.
15 : Using the First NPC Maps set.
16 : Using the Secound NPC Maps set.
17 : Using the NPCRegu.
 
May 23, 2007 at 1:20 AM
Hoxtilicious
"Life begins and ends with Nu."
Join Date: Dec 30, 2005
Location: Germany
Posts: 3218
Age: 32
SeriousFace said:
Imagine this is the first post.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Very helpful, posting an old outdated FAQ here :p



If you want a new version Furion, feel free to contact me.
 
Aug 8, 2008 at 3:34 PM
Luls
"Bleep, Bloop, Bleep, Bloop"
Join Date: Oct 6, 2007
Location: I dunnos
Posts: 1584
Well then sorry for bumping (though this isnt really bumping cause I've got a real question to ask here =/)

But I don't really understand the formula for finding the hex address where every npc's hps are.

SP said to convert the npc number into a hex value FIRST and THEN multiply it by 2 and finally add 0x02D2 to it to get the value.

However...

taifunbrowser said to double the npc number FIRST and THEN convert the doubled number to hex and finally add 0x02D2.

So.... Which formula is correct? >_>?
 
Aug 8, 2008 at 4:48 PM
In front of a computer
"Man, if only I had an apple..."
Join Date: Mar 1, 2008
Location: Grasstown
Posts: 1435
Both. It shouldn't make a difference whether you double it before or after converting it to hex.
 
Aug 8, 2008 at 6:43 PM
Hoxtilicious
"Life begins and ends with Nu."
Join Date: Dec 30, 2005
Location: Germany
Posts: 3218
Age: 32
It's the same. <_<
You think the wrong way.
Hexadecimal = Decimal
There is no difference, except the digits.
 
Aug 8, 2008 at 11:10 PM
In front of a computer
"Man, if only I had an apple..."
Join Date: Mar 1, 2008
Location: Grasstown
Posts: 1435
Like I said...
 
Aug 9, 2008 at 9:41 AM
Justin-chan
"Heavy swords for sale. Suitable for most RPG Protagonists. Apply now!"
Join Date: Oct 15, 2007
Location: Nowhere
Posts: 1921
Age: 30
Critter - sprite 64
Health value - 2D2

64 X 2 = 128
128 > Hex > 80
80 + 2D2 = 352

64 > Hex > 40
40 X 2 = 80
80 + 2D2 = 352
 
Aug 9, 2008 at 10:23 AM
Luls
"Bleep, Bloop, Bleep, Bloop"
Join Date: Oct 6, 2007
Location: I dunnos
Posts: 1584
Ololk I just found it out the long way.

Thanks! ^^"
 
Aug 15, 2008 at 3:21 PM
graters gonna grate
"Heavy swords for sale. Suitable for most RPG Protagonists. Apply now!"
Join Date: Jul 2, 2008
Location: &
Posts: 1886
Age: 31
Well, this has been very helpful. I am working on a mod which requires npc.tbl hacking, and was about to post a small demo on the mods section of the forum along with a cry for help with npc.tbl hacking, but just for giggles I decided to look at this part of the forum first, and now I'm very glad I did!
 
Aug 15, 2008 at 6:58 PM
graters gonna grate
"Heavy swords for sale. Suitable for most RPG Protagonists. Apply now!"
Join Date: Jul 2, 2008
Location: &
Posts: 1886
Age: 31
Ah... I spoke too soon. Could someone explain more thoroughly what exactly is meant by "Display bounding box"? I was under the impression that it indicated a rectangle on the *.pbm file where the image for the NPC would be found, but it seems that is not the case. What exactly would I do if I wanted to change the areas of the *.pbm files that the images for certain NPCs are taken from?
 
Aug 16, 2008 at 3:33 AM
Luls
"Bleep, Bloop, Bleep, Bloop"
Join Date: Oct 6, 2007
Location: I dunnos
Posts: 1584
wedge of cheese said:
Ah... I spoke too soon. Could someone explain more thoroughly what exactly is meant by "Display bounding box"? I was under the impression that it indicated a rectangle on the *.pbm file where the image for the NPC would be found, but it seems that is not the case. What exactly would I do if I wanted to change the areas of the *.pbm files that the images for certain NPCs are taken from?

Well there's always a search button! ^^"

(as S.P. always says...)

...

>_>
<_<
-_- (phew S.P. isn't here >=D)
 
Aug 17, 2008 at 9:41 PM
The Bartender
"All your forum are belong to us!"
Join Date: Jun 18, 2006
Location: Montreal, Canada
Posts: 581
Age: 39
wedge of cheese said:
Could someone explain more thoroughly what exactly is meant by "Display bounding box"? I was under the impression that it indicated a rectangle on the *.pbm file where the image for the NPC would be found, but it seems that is not the case. What exactly would I do if I wanted to change the areas of the *.pbm files that the images for certain NPCs are taken from?
That is correct. The display bounding box is an imaginary rectangular box that defines (binds) the image to display. Usually, it's stored as 4 32bit values indicating the left, top, right, and bottom positions of the rectangle, but sometimes "right" and "bottom" mean "width" and "height."

45 01 00 00 DC 00 00 00 20 00 00 00 40 00 00 00

This one, for instance, means...

Left: 45 01 00 00, or 0x00000145 (325)
Top: DC 00 00 00, or 0x000000DC (220)
Width: 20 00 00 00, or 0x00000020 (32)
Height: 40 00 00 00, or 0x00000040 (64)

So that would mean the sprite in the bitmap can be found at X:325 Y:220 and is 32x64.
 
Aug 17, 2008 at 10:08 PM
graters gonna grate
"Heavy swords for sale. Suitable for most RPG Protagonists. Apply now!"
Join Date: Jul 2, 2008
Location: &
Posts: 1886
Age: 31
RuneLancer said:
A few precisions.

0x0000 [2 bytes] Flags.
0x02D2 [2 bytes] Health
0x05A4 [1 byte] Tileset
0x070D [1 byte] Sound to play on death
0x0876 [1 byte] Sound to play on damage
0x09DF [1 byte] Animation to play when dead (0x00 - 0x03)
0x0B48 [4 bytes] Experience dropped by enemy. May also affect items.
0x10EC [4 bytes] Damage
0x1690 [4 bytes] Collsion Bounding Box
0x1C34 [4 bytes] Display Bounding Box

The bounding boxes are 4 byte objects.

0x00 Left
0x01 Top
0x02 Right
0x03 Bottom

A sprite is always drawn using the top and left or right (depending on its direction) corner of the bounding box. This is offset from the center of the sprite, by the way: a 16x16 sprite with a bounding box of 8,8,8,8 is perfectly centered. 0,0,8,8 will offset it 8 pixels to the left/up.

Ok, so according to this quote, the bounding boxes are 4-byte objects, but you just said that they are actually 16-byte objects (4-byte X, 4-byte Y, 4-byte width, 4-byte height), which wouldn't make sense because then there would be 36 bytes for each NPC rather than 24, and there have to be 24 because npc.tbl is 8664 bytes which is 361*24, not 361*36.

So, how exactly is the bounding box stored in npc.tbl?
 
Aug 17, 2008 at 10:21 PM
The Bartender
"All your forum are belong to us!"
Join Date: Jun 18, 2006
Location: Montreal, Canada
Posts: 581
Age: 39
wedge of cheese said:
So, how exactly is the bounding box stored in npc.tbl?
In this case it would be 1 byte per entry, indeed.

The display bounding box stored in the npc file is not the one used to locate the sprite in the .pbm but rather to display the sprite onscreen. It is used to offset its position in relation to its bounding box.

The sprite display bounding box is stored directly in the exe, hardcoded somewhere in each NPC's individual handler (this is the 4 byte per entry one). You'll have to do a bit more digging to edit those, unfortunately.
 
Top