Jump to content

CnCNet Forums

Search In
  • More options...
Find results that contain...
Find results in...
lovalmidas

Dune 2000 Campaign.UIB format

Recommended Posts

Posted (edited)

Hi, I come from https://forum.dune2k.com/forum/11-dune-2000/ so I am rather new here. Please be patient with me :D

Also, I don't see a separate subforum for modding information, hence I post it here. If there is a more appropriate place for this information, please help inform me so I can make future posts there.

My content is catered more to the single player aspect and modders so those in the multiplayer scene, I'm sorry but I don't have much for you.

Information is also shown here: https://forum.dune2k.com/topic/28787-campaignuib-research/ 
And summarized here: https://github.com/nguoiyoujie/Spice2k/blob/master/doc/spec/uibCampaign.md

I have made an editor that allows you to inspect and modify a campaign.uib file: https://github.com/nguoiyoujie/Spice2k . It is still under development, so use with caution and many backups!

-------------------

When you first start a new campaign, you see the campaign map evolve from a globe of Arrakis (or if you did not have a working cutscene file, just the map). Then the following occur:

  • The game announcer (SFX voice) opens the campaign with three statements. One for Atreides, one for Harkonnen, one for Ordos. The order depends on which house you chose to play as.

Let's say you picked Atreides. In fact, we may use this video as reference: https://www.youtube.com/watch?v=-x9MahcVn7k

  • The game announcer opens with the first statement about Atreides. Concurrently, the map animates, and some regions are colored blue, left to right.
  • The game announcer delivers a second statement about the Ordos. Concurrently, the map animates, and some regions are colored green, left to right.
  • The game announcer delivers a second statement about the Harkonnen. Concurrently, the map animates, and some regions are colored red, left to right.
  • Two Atreides icons appear on the map.
  • The game releases control to the player. The player may select the regions where the icons are, or perform other actions (Save, Load, Quit).
  • If the player selects a playable region, the game takes the player to the briefing for that mission.

For the most part, these actions are controlled by the campaign.uib file, I have found out roughly how it works, and other interesting tidbits related to the single-player campaign. 

My findings are summarized in the image below:

Spoiler

Campaign.uib
3 Houses x 10 Missions x 104 bytes = 3120 bytes

Offsets

00 / 0x00 (byte): Version 1 Region ID. Determines which region can be clicked to load version 1 of the mission. Awarded to the player's house when won. If set to 00, disables Version 1.
01 / 0x01 (byte): Version 2 Region ID. Determines which region can be clicked to load version 2 of the mission. Awarded to the player's house when won. If set to 00, disables Version 2.
02 / 0x02 (5 bytes, null-terminated string): Version 1 Mission ID. Technically a null-terminated string, but only 5 bytes (thus 4 characters, are available) 
07 / 0x07 (5 bytes, null-terminated string): Version 2 Mission ID. Technically a null-terminated string, but only 5 bytes (thus 4 characters, are available) 
12 / 0x0c (int): Unused. Takes in values from 00 to 07. The executable has some parser suggesting this is related to the 8 directions (N,NE,E,SE,S,SW,W,NW), but it does not appear to be used in the executable. I hazard a guess that it was supposed to have a similar behavior to the arrows in the mission maps of C&C and RA1.
16 / 0x10 (int): Same as Offset 12 / 0x0c. This could be the equivalent for Version 2.
20 / 0x14 (int): Version 1 Icon X Position. The X position of the animated icon. This is for visual purposes and the icon is not the clickable hitbox.
24 / 0x18 (int): Version 1 Icon Y Position. The Y position of the animated icon. 
28 / 0x1c (int): Version 2 Icon X Position. The X position of the animated icon. 
32 / 0x20 (int): Version 2 Icon Y Position. The Y position of the animated icon. 
36 / 0x24 (3 bytes): Regions awarded to Atreides. Up to 3 region IDs will be transferred to Atreides ownership after successfully completing this mission. 00 values are ignored.
39 / 0x27 (3 bytes): Regions awarded to Harkonnen. 
42 / 0x2a (3 bytes): Regions awarded to Ordos. 
48 / 0x30 (float): Score multipler for the mission. Base score (multiplier 1x) is 200 points. 
52 / 0x34 (int): Animation order of map regions, the first House to update the map. The map after initializing to the previous mission state, plays audio tracks as 'storytelling', and animates the maps.
56 / 0x38 (int): Animation order of map regions, the second House to update the map.
60 / 0x3c (int): Animation order of map regions, the third House to update the map.
64 / 0x40 (null-terminated string): The first SFX to be played. If set to NONE, skip the SFX.
124 / 0x7c (null-terminated string): The second SFX to be played. If set to NONE, skip the SFX.
184 / 0xB8 (null-terminated string): The third SFX to be played. If set to NONE, skip the SFX.
224 / 0xF4 (8 bytes): The initial theme to play when starting the mission.
256 / 0x100 (4 bytes): The enemy house. Used to color the enemy score bars in the score screen after completing the information

RegionID: hardcoded to 27 entries, 0x01-0x1B. Corresponds to the map regional graphics in /data/UI_GFX/Regions. 00 indicates a null region.
The entire campaign.uib contents is loaded into the game at address 0x00795708. It is loaded only once, changes to the file require restarting the game to be applied
The region hitboxes are hardcoded as what appears to be POINT structures (int x, int y) from addresses 0x004be3fc to 0x004beb84.

 

The control flow for the campaign map is a little arcane (I kinda dislike it), but here goes:

  • The campaign.uib file is divided into 3 Houses, each House with 10 104-byte sections. Each section represents a mission 0 to 9. Mission 0 appears to be a setup performed before animating Mission 1.
  • The campaign.uib file is loaded into the game memory (0x00795708) at startup, like other uib files. If changes are made to the file while the game is in progress, the game has to be restarted for the changes to apply.
  • The executable has hardcoded the following limits: 3 supported Houses, 9 supported missions, each mission having 2 supported versions (V1 and V2), and 27 map regions. Changing those require modifying the executable.
  • The campaign map is split into 27 map regions. 
    • The background piece is DUNEMAP2. 
    • The graphics for each map piece lies in /data/UI_GFX/regions. 
    • The position and polygon hitbox are hardcoded in the game. The polygon points appear to be a POINT (int x, int y) array in executable addresses 0x004be3fc to 0x004beb84.

 

Reference Flow: Atreides Mission 4 -  https://www.youtube.com/watch?v=_3hZzNg9TrA

Spoiler
  • When the player enters the campaign map, the game first notes which mission the player is going to play. (If the player just completed Mission 3, then the next mission is Mission 4)
  • The game notes which House the player is playing as. (E.g. this is an Atreides campaign)
  • The game will then load up the regions for all previous missions for the player's house. Specifically, it begins from a blank map, and starts awarding regions to each houses for each mission up to the previous mission map (right before the previous mission):
    • Atreides Setup (or 'Mission 0'): Atreides is awarded regions 2, 3, 4. Harkonnen is awarded regions 12, 18, 22. Ordos is awarded regions 21, 25, 27.
    • Atreides after Mission 1: Mission reward: regions 7, 8 to player House (Atreides). Atreides is awarded region 1. Harkonnen is awarded regions 13, 16, 19. Ordos is awarded regions 15, 17, 20.
    • Subtotal: A = 1,2,3,4,7,8. H = 12,13,16,18,19,22. O = 15,17,20,21,25,27.
    • Atreides after Mission 2: Mission reward: regions 5, 6 to player House (Atreides). Atreides is awarded nothing. Harkonnen is awarded regions 9, 26. Ordos is awarded regions 24, 11.
    • Subtotal: A = 1,2,3,4,5,6,7,8. H = 9,12,13,16,18,19,22,26. O = 11,15,17,20,21,24,25,27.
    • Player's previous mission was mission 3. Stop here.
       
  • The game renders this map.
    EBdiNjq.png
     
  • The game begins the first SFX / Animation cycle:
    • The first SFX for Atreides Mission 4 is C_A4a. Announcer plays the corresponding speech referred to in samples.uib (AI_MAP4A.AUD)
    • Concurrently, the first house to be animated is House ID 0 - Atreides. Since House Atreidies is also the player's house, the Mission 3 reward (regions 10, 11) and Atreides' own advancement (nothing) shall be given to House Atreides.
      • The map animates the colors of regions 10 (unoccupied) and 11 (Ordos) changing to the Atreides blue. (while the speech is ongoing)
    • First SFX / animation cycle end.
      FUtBR82.png
       
  • The game begins the second SFX / Animation cycle:
    • The second SFX for Atreides Mission 4 is NONE. Nothing is played
    • The second house to be animated is House ID 1 - Harkonnen.  Region 14 shall be given to House Harkonnen.
      • The map animates the colors of region 14 (unoccupied) changing to the Harkonnen red.
    • Second SFX / animation cycle end.
      BQ3k4FJ.png
       
  • The game begins the third SFX / Animation cycle:
    • The third SFX for Atreides Mission 4 is NONE. Nothing is played
    • The third house to be animated is House ID 2 - Ordos.  Region 23 shall be given to House Ordos.
      • The map animates the colors of region 23 (unoccupied) changing to the Ordos green.
    • Third SFX / animation cycle end.
      PXOMrHx.png
       
  • The game looks at the mission versions for Atreides Mission 4:
    • Version 1: Region 9, Mission: A4V1, Atreides Icon (AT_POINT) rendered at point 193, 75
    • Version 2: Region 0... Skip.
  • The game renders the animated Atreides icon, and activates the hardcoded polygon for Region 9 and links it to mission A4V1.
    i01XaZx.png
     
  • The game releases control to the player.
    • If the player hovers over Region 9, he'll get an attack cursor.
    • If the player clicks Region 9, he will be taken to the briefing for A4V1.
  • The player starts playing the mission
    • The initial music is indicated to be FREMEN. This will be first music that is played on starting the mission.
    • The mission score multiplier is 2.5 (byteform 00 00 20 40). If he wins the mission, the score screen will divide 2.5 x 200 = 500 points between the player and the enemy AI.
    • If the player wins the mission, the next campaign map will see Region 9 animated to turn to Atreides control.
       

 

Some items remain hardcoded in the game:

  • The maximum number of mission choices is 2. 
  • The maximum number of house campaigns, without modifying the executable, is 3. 
  • The maximum number of missions per house, without modifying the executable, is 9. 
  • The number of regions is hardcoded to be 27, excluding the null region (00)
  • The icons are for display only. The clickable regions are polygons hardcoded into the game at 0x04BE3FC, in an array of 27 72-byte structures, each structure containing a uint representing point count, and a sequence of POINT {x, y} structures denoting each point's location relative to the top left corner of the map.

 

Trivia:

  • The original game has a bug where region 26 overlaps with another region (see image below, the bottom right corner of the map). It has never been detected because the original campaign never used region 26 as a clickable region, and I am not sure if there ever has been a modded campaign.uib.

VOHxVdB.png

 

 

Edited by lovalmidas
Add images in reference flow for clarity

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...