Prototype ranges and adding new prototypes

Discussion in 'Modding and Scripting Support' started by Anonymous, Sep 5, 2009.

Remove all ads!
Support Terra-Arcanum:

GOG.com

PayPal - The safer, easier way to pay online!
  1. Anonymous

    Anonymous Guest

    Here's a few notes on the inner working of the engine that I'd like to share with the community. (Please note that this is aimed at advanced users only. This isn't a tutorial for beginners.)

    How prototypes are generated:

    Let's take a look at how the engine generates prototypes. First, the engine creates empty templates (which are based on the object type) with default values and also assigns the prototype and description (linked to description.mes) numbers to each of them.

    Next it fills the templates with content. Most of the content is hardcoded and cannot be easily altered, moreover, it's all included in one long subroutine, which patches only required object fields and sometimes patches several prototypes at once. E.g. it can assign the same WIELD_ON and WIELD_OFF scripts to three suits of armor (all sizes) at once, so if you hex edit the script numbers in the code it will affect all three suits of armor. (In theory, the subroutine can be exported to a .DLL, so that we can recompile it, but it's a lot of work.)

    Fortunately, not all content is hardcoded. The generation of the critter prototypes (NPCs, monsters and unique NPCs) is controlled by the three corresponding files in the 'rules' folder (monster.txt, npc.txt and unique.txt).

    Prototype ranges:

    The number of generated prototypes is controlled by the hardcoded ranges. The vanilla version has the following ranges:
    NOTE: The last prototype in a range is already considered 'wrong'. Thus, e.g. walls go only up to 1007.

    <table border="1" width="100%">
    <tr><td><td>Offsets (Arcanum.exe 1.0.7.4)<td>Offsets (WorldEd.exe 1.0.6.9)
    <tr><td>Wall: 1000-1008<td>1B37FC, 1B384C<td>178138, 178188
    <tr><td>Portal: 2008-2023<td>1B3800, 1B3850<td>17813C, 17818C
    <tr><td>Container: 3023-3061<td>1B3804, 1B3854<td>178140, 178190
    <tr><td>Scenery: 4006-4051<td>1B3808, 1B3858<td>178144, 178194
    <tr><td>Projectile: 5028-5029<td>1B380C, 1B385C<td>178148, 178198
    <tr><td>Weapon: 6029-6179<td>1B3810, 1B3860<td>17814C, 17819C
    <tr><td>Ammo: 7038-7042<td>1B3814, 1B3864<td>178150, 1781A0
    <tr><td>Armor: 8042-8293<td>1B3818, 1B3868<td>178154, 1781A4
    <tr><td>Gold: 9056-9057<td>1B381C, 1B386C<td>178158, 1781A8
    <tr><td>Food: 10057-10145<td>1B3820, 1B3870<td>17815C, 1781AC
    <tr><td>Scroll: 11059-11143<td>1B3824, 1B3874<td>178160, 1781B0
    <tr><td>Key: 12060-12063<td>1B3828, 1B3878<td>178164, 1781B4
    <tr><td>Key Ring: 13061-13062<td>1B382C, 1B387C<td>178168, 1781B8
    <tr><td>Written: 14062-14130<td>1B3830, 1B3880<td>17816C, 1781BC
    <tr><td>Generic Item: 15065-15213<td>1B3834, 1B3884<td>178170, 1781C0
    <tr><td>PC: 16066-16080<td>1B3838, 1B3888<td>178174, 1781C4
    <tr><td>NPC: 17067-17317<td>1B383C, 1B388C<td>178178, 1781C8
    <tr><td>Trap: 26000-26008<td>1B3840, 1B3890<td>17817C, 1781CC
    <tr><td>Unique NPC: 27309-27394<td>1B3844, 1B3894<td>178180, 1781D0
    <tr><td>Monster: 28310-28472<td>1B3848, 1B3898<td>178184, 1781D4
    </table>

    You can notice that once you increase a range, the game starts generating new, empty prototypes (from templates).

    Using this table you can edit the proto ranges, and thus add entirely new prototypes to the game, the proper way. If you add new item prototypes without increasing a range, then InvenSource won't accept them.

    Adding new prototypes:

    The critter prototypes are the easiest to add. All you need to do is just increase a range, add a new entry to description.mes and a new entry to one of the critter tables in the 'rules' folder. However, in order for the game to read new entries in the critter tables, another set of ranges must be increased:

    <table border="1" width="100%">
    <tr><td><td>Offsets (Arcanum.exe 1.0.7.4)<td>Offsets (WorldEd.exe 1.0.6.9)
    <tr><td>monster.txt: 28310-28472<td>9B34C, 9B354<td>50BCC, 50BD4
    <tr><td>unique.txt: 27309-27394<td>9B37B, 9B383<td>50BFB, 50C03
    <tr><td>npc.txt: 17067-17317<td>9B3A8, 9B3B4<td>50C28, 50C34
    </table>

    For other object types, you will have to edit .pro files by hand.
     
  2. rroyo

    rroyo Active Member

    Messages:
    3,319
    Likes Received:
    0
    Joined:
    Oct 13, 2006
  3. Wims

    Wims New Member

    Messages:
    161
    Likes Received:
    0
    Joined:
    Jun 13, 2011
    I'm currently trying to "restore" the purple robe you can see below but there is not sign of it on the undat game.

    [​IMG]

    I had a look at the art animated frame for the robe and there is only frames for one color of robe so I assume that the palette do the trick to make all brown/blue/white/black animations.

    Since I cannot change the palettes (or can I?), I was thinking about adding a new prototype and linked it to the robe frames to get the right animation but with a purple robe. Is that the best solution ? Is it possible ?

    Also, Drog, could you please tell me more about "editing proto by hands" ?

    Thank you.

    - Wim's
     
  4. Drog Alt

    Drog Alt Member

    Messages:
    593
    Likes Received:
    16
    Joined:
    Jun 30, 2010
    Early in the development robes had different colors, including purple and green, among others. The robe colors were later standardized as white/black/brown/blue (each sprite can have max 4 palettes in Arcanum). These are just earlier palettes, there's nothing to "restore", you can't re-add them without overwriting the standard colors.
     
  5. Wims

    Wims New Member

    Messages:
    161
    Likes Received:
    0
    Joined:
    Jun 13, 2011
    Well... I guess overwriting those palettes will affect all armors... And those palettes are hardcoded.

    So you think there is no way to do that Drog ? Is it possible to change a palette ?

    Thanks.
     
  6. Drog Alt

    Drog Alt Member

    Messages:
    593
    Likes Received:
    16
    Joined:
    Jun 30, 2010
    Palettes are stored within .art files, at 0x84-0x1084 (0x1000 in total, if all 4 palettes are used). You have to patch every single animation, so I suggest you write a script or something.

    The .art format uses standard 8-bit .bmp palettes, so you can export any frame to .bmp, edit its palette in your favorite graphics editor, then put the new palette back into the .art file (you have to do this by hand, in your favorite hex editor, as there are no .art editors that let you import palettes).
     
  7. Wims

    Wims New Member

    Messages:
    161
    Likes Received:
    0
    Joined:
    Jun 13, 2011
    Thanks for your help. With Crypton help, I actualy managed to get purple and green robes from beta restored content patch so it's ok.

    I had a look at ART file with an hex editor and... Well, let's say I'm happy to find those robes with the patch... :roll:

    Thank you for your help !
     
Our Host!