Jump to content

How to add an Animation to an Area


erebusant

Recommended Posts

The structure is 76 bytes for BG2 areas, if that's what you're asking.

So is all you need to do is to total up the number of bytes for each of the offsets in a subsection of the ieformats file in the iesdp in order to calculate the bytes to insert or delete for whichever section of a file you're working on??

Link to comment

Assuming they're correct, which isn't always the case.

 

Given a file with two subsequent structures of the same type, you can simply use NI to see the offsets of both structures and subtract the first from the second (given animation A at 0h and animation B at 4Ch, the size of animation structures is 0x4c - 0x0 = 76).

 

Or you could just ask. ;)

Link to comment
Assuming they're correct, which isn't always the case.

 

Given a file with two subsequent structures of the same type, you can simply use NI to see the offsets of both structures and subtract the first from the second (given animation A at 0h and animation B at 4Ch, the size of animation structures is 0x4c - 0x0 = 76).

 

Or you could just ask. :D

Well Damn! I obviously have something totally hosed with the below code. At least with the 4c I don't get the illegal 10-byte read from offset 47718 of the 47628 byte file anymore, and it patches. Unfortunately it patches so well the file is completely corrupted and won't even open anymore,,, :) Anyway, I could use some insight.

 

//	~azenMOD/AR0602.are~	~override/AR0602.are~	// Adds Entrance "EXIT03JC" and changes script of the Jail Portal at 3873x 2436y to TELE02JC from original of TELE0603 or TELE2IWD if NEJ2 is installed. This Portal needs location changed and entrance changed to a different location. (ie; somewhere up in the Library, or something).

COPY_EXISTING ~AR0602.ARE~ ~override~
READ_LONG  0x54  "actors_offset"
READ_SHORT 0x58  "actors_num"
READ_SHORT 0x5a  "infotrig_num"
READ_LONG  0x5c  "infotrig_offset"
READ_LONG  0x60  "spawns_offset"
READ_LONG  0x64  "spawns_num"
READ_LONG  0x68  "entrances_offset"
READ_LONG  0x6c  "entrances_num"
READ_LONG  0x70  "cont_offset"
READ_SHORT 0x74  "cont_num"
READ_SHORT 0x76  "items_num"
READ_LONG  0x78  "items_offset"
READ_LONG  0x7c  "vert_offset"
READ_SHORT 0x80  "vert_num"
READ_SHORT 0x82  "amb_num"
READ_LONG  0x84  "amb_offset"
READ_LONG  0x88  "vars_offset"
READ_LONG  0x8c  "vars_num"
READ_LONG  0xa0  "expbmp_offset"
READ_LONG  0xa4  "doors_num"
READ_LONG  0xa8  "doors_offset"
READ_LONG  0xac  "anim_num"
READ_LONG  0xb0  "anim_offset"
READ_LONG  0xb4  "tiled_num"
READ_LONG  0xb8  "tiled_offset"
READ_LONG  0xbc  "songs_offset"
READ_LONG  0xc0  "rest_spawns_offset"
READ_LONG  0xc4  "automap_offset"
READ_LONG  0xc8  "automap_num"

SET info_1=1
FOR( cnt=0; cnt<"%anim_num%"; cnt=cnt+1 ) BEGIN  //animations loop
  READ_ASCII ("%anim_offset%"+0x4c*cnt)	   "anim_name" (10)
  PATCH_IF (("%anim_name%" STRING_COMPARE_CASE "AzenPortal")=0) BEGIN  //if already exists
 info_1=0
  END
END

PATCH_IF (info_1=1) BEGIN			 //adding new animation  *******************************
  SET offset = ("%anim_offset%"+0x4c*"%anim_num%")
  INSERT_BYTES offset 0x4c
  WRITE_ASCII offset ~AzenPortal~
//   WRITE_SHORT (offset+0x4) 487		   //X
//   WRITE_SHORT (offset+0x6) 942		   //Y
//   WRITE_LONG  (offset+0x8) 0xfffc003f	//schedule
//   WRITE_ASCII (offset+0x12) ~PORTL2A~	//Animation
//   WRITE_BYTE  (offset+0x14) 0			//Animation #
//   WRITE_BYTE  (offset+0x16) 0			//Frame #
//   WRITE_LONG  (offset+0x18) 0			//Flags
  SET "anim_num"="%anim_num%"+1
  WRITE_SHORT 0xac  "%anim_num%"
END

SET "info_ext"=0x4c
PATCH_IF ("%infotrig_offset%">="%actors_offset%") BEGIN
  "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
  WRITE_LONG  0x5c "%infotrig_offset%"
END
PATCH_IF ("%spawns_offset%">="%actors_offset%") BEGIN
  "spawns_offset"="%spawns_offset%"+"%info_ext%"
  WRITE_LONG  0x60  "%spawns_offset%"
END
PATCH_IF ("%entrances_offset%">="%actors_offset%") BEGIN
  "entrances_offset"="%entrances_offset%"+"%info_ext%"
  WRITE_LONG  0x68  "%entrances_offset%"
END
PATCH_IF ("%cont_offset%">="%actors_offset%") BEGIN
  "cont_offset"="%cont_offset%"+"%info_ext%"
  WRITE_LONG  0x70  "%cont_offset%"
END
PATCH_IF ("%items_offset%">="%actors_offset%") BEGIN
  "items_offset"="%items_offset%"+"%info_ext%"
  WRITE_LONG  0x78  "%items_offset%"
END
PATCH_IF ("%vert_offset%">="%actors_offset%") BEGIN
  "vert_offset"="%vert_offset%"+"%info_ext%"
  WRITE_LONG  0x7c  "%vert_offset%"
END
PATCH_IF ("%amb_offset%">="%actors_offset%") BEGIN
  "amb_offset"="%amb_offset%"+"%info_ext%"
  WRITE_LONG  0x84  "%amb_offset%"
END
PATCH_IF ("%vars_offset%">="%actors_offset%") BEGIN
  "vars_offset"="%vars_offset%"+"%info_ext%"
  WRITE_LONG  0x88  "%vars_offset%"
END
PATCH_IF ("%expbmp_offset%">="%actors_offset%") BEGIN
  "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
  WRITE_LONG  0xa0  "%expbmp_offset%"
END
PATCH_IF ("%doors_offset%">="%actors_offset%") BEGIN
  "doors_offset"="%doors_offset%"+"%info_ext%"
  WRITE_LONG  0xa8  "%doors_offset%"
END
PATCH_IF ("%anim_offset%">="%actors_offset%") BEGIN
  "anim_offset"="%anim_offset%"+"%info_ext%"
  WRITE_LONG  0xb0  "%anim_offset%"
END
PATCH_IF ("%tiled_offset%">="%actors_offset%") BEGIN
  "tiled_offset"="%tiled_offset%"+"%info_ext%"
  WRITE_LONG  0xb8  "%tiled_offset%"
END
PATCH_IF ("%songs_offset%">="%actors_offset%") BEGIN
  "songs_offset"="%songs_offset%"+"%info_ext%"
  WRITE_LONG  0xbc  "%songs_offset%"
END
PATCH_IF ("%rest_spawns_offset%">="%actors_offset%") BEGIN
  "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
  WRITE_LONG  0xc0  "%rest_spawns_offset%"
END
PATCH_IF ("%automap_offset%">="%actors_offset%") BEGIN
  "automap_offset"="%automap_offset%"+"%info_ext%"
  WRITE_LONG  0xc4  "%automap_offset%"
END
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR0602.are~

Link to comment

It looks like you're updating incorrect offsets (very few structures follow animations, but your %offset% > %actors_offset% is going to update them all anyway -- which will have all these prior structures pointing at random locations further into the file than is correct).

 

Try %blah_offset% > %anim_offset%

Link to comment
It looks like you're updating incorrect offsets (very few structures follow animations, but your %offset% > %actors_offset% is going to update them all anyway -- which will have all these prior structures pointing at random locations further into the file than is correct).

 

Try %blah_offset% > %anim_offset%

Hah!! This works now!! Thanks for the tips. If found I also needed to cut the "PATCH_IF" block releated to the anim_offset and paste it at the top of the "PATCH_IF" section and rename all references of "anim" to "actor" or it would add an additional empty animation into the file. Working code as follows:

COPY_EXISTING ~AR0602.ARE~ ~override~
READ_LONG  0x54  "actors_offset"
READ_SHORT 0x58  "actors_num"
READ_SHORT 0x5a  "infotrig_num"
READ_LONG  0x5c  "infotrig_offset"
READ_LONG  0x60  "spawns_offset"
READ_LONG  0x64  "spawns_num"
READ_LONG  0x68  "entrances_offset"
READ_LONG  0x6c  "entrances_num"
READ_LONG  0x70  "cont_offset"
READ_SHORT 0x74  "cont_num"
READ_SHORT 0x76  "items_num"
READ_LONG  0x78  "items_offset"
READ_LONG  0x7c  "vert_offset"
READ_SHORT 0x80  "vert_num"
READ_SHORT 0x82  "amb_num"
READ_LONG  0x84  "amb_offset"
READ_LONG  0x88  "vars_offset"
READ_LONG  0x8c  "vars_num"
READ_LONG  0xa0  "expbmp_offset"
READ_LONG  0xa4  "doors_num"
READ_LONG  0xa8  "doors_offset"
READ_LONG  0xac  "anim_num"
READ_LONG  0xb0  "anim_offset"
READ_LONG  0xb4  "tiled_num"
READ_LONG  0xb8  "tiled_offset"
READ_LONG  0xbc  "songs_offset"
READ_LONG  0xc0  "rest_spawns_offset"
READ_LONG  0xc4  "automap_offset"
READ_LONG  0xc8  "automap_num"

SET info_1=1
FOR( cnt=0; cnt<"%anim_num%"; cnt=cnt+1 ) BEGIN  //animations loop
  READ_ASCII ("%anim_offset%"+0x4c*cnt)	   "anim_name" //(10)
  PATCH_IF (("%anim_name%" STRING_COMPARE_CASE "AzenPortal")=0) BEGIN  //if already exists
 info_1=0
  END
END

PATCH_IF (info_1=1) BEGIN			 //adding new animation  *******************************
  SET offset = ("%anim_offset%"+0x4c*"%anim_num%")
  INSERT_BYTES offset 0x4c
  WRITE_ASCII offset ~AzenPortal~
  WRITE_SHORT (offset+0x20) 487		   //X
  WRITE_SHORT (offset+0x22) 942		   //Y
  WRITE_LONG  (offset+0x24) 0xfffc003f	//schedule
  WRITE_ASCII (offset+0x28) ~PORTL2A~	 //Animation
  WRITE_BYTE  (offset+0x30) 0			 //Animation #
  WRITE_BYTE  (offset+0x32) 0			 //Frame #
  WRITE_LONG  (offset+0x34) 1			 //Flags
  SET "anim_num"="%anim_num%"+1
  WRITE_SHORT 0xac  "%anim_num%"
END

SET "info_ext"=0x4c
PATCH_IF ("%actors_offset%">="%anim_offset%") BEGIN
  "actors_offset"="%actors_offset%"+"%info_ext%"
  WRITE_LONG  0x54  "%actors_offset%"
END
PATCH_IF ("%infotrig_offset%">="%anim_offset%") BEGIN
  "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
  WRITE_LONG  0x5c "%infotrig_offset%"
END
PATCH_IF ("%spawns_offset%">="%anim_offset%") BEGIN
  "spawns_offset"="%spawns_offset%"+"%info_ext%"
  WRITE_LONG  0x60  "%spawns_offset%"
END
PATCH_IF ("%entrances_offset%">="%anim_offset%") BEGIN
  "entrances_offset"="%entrances_offset%"+"%info_ext%"
  WRITE_LONG  0x68  "%entrances_offset%"
END
PATCH_IF ("%cont_offset%">="%anim_offset%") BEGIN
  "cont_offset"="%cont_offset%"+"%info_ext%"
  WRITE_LONG  0x70  "%cont_offset%"
END
PATCH_IF ("%items_offset%">="%anim_offset%") BEGIN
  "items_offset"="%items_offset%"+"%info_ext%"
  WRITE_LONG  0x78  "%items_offset%"
END
PATCH_IF ("%vert_offset%">="%anim_offset%") BEGIN
  "vert_offset"="%vert_offset%"+"%info_ext%"
  WRITE_LONG  0x7c  "%vert_offset%"
END
PATCH_IF ("%amb_offset%">="%anim_offset%") BEGIN
  "amb_offset"="%amb_offset%"+"%info_ext%"
  WRITE_LONG  0x84  "%amb_offset%"
END
PATCH_IF ("%vars_offset%">="%anim_offset%") BEGIN
  "vars_offset"="%vars_offset%"+"%info_ext%"
  WRITE_LONG  0x88  "%vars_offset%"
END
PATCH_IF ("%expbmp_offset%">="%anim_offset%") BEGIN
  "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
  WRITE_LONG  0xa0  "%expbmp_offset%"
END
PATCH_IF ("%doors_offset%">="%anim_offset%") BEGIN
  "doors_offset"="%doors_offset%"+"%info_ext%"
  WRITE_LONG  0xa8  "%doors_offset%"
END
PATCH_IF ("%tiled_offset%">="%anim_offset%") BEGIN
  "tiled_offset"="%tiled_offset%"+"%info_ext%"
  WRITE_LONG  0xb8  "%tiled_offset%"
END
PATCH_IF ("%songs_offset%">="%anim_offset%") BEGIN
  "songs_offset"="%songs_offset%"+"%info_ext%"
  WRITE_LONG  0xbc  "%songs_offset%"
END
PATCH_IF ("%rest_spawns_offset%">="%anim_offset%") BEGIN
  "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
  WRITE_LONG  0xc0  "%rest_spawns_offset%"
END
PATCH_IF ("%automap_offset%">="%anim_offset%") BEGIN
  "automap_offset"="%automap_offset%"+"%info_ext%"
  WRITE_LONG  0xc4  "%automap_offset%"
END
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR0602.are~

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...