Jump to content

Dune 2000 Singleplayer game patching + new features


Recommended Posts

Posted (edited)

Hello all, so finally I got into Dune 2000 patching and fixing up things and adding new features!

I had a talk with FunkyFr3sh and got some useful information and stuff needed for continuation of game pathing. I'm going to use the latest FunkyFr3sh's Cncnet version as a base (not the Gruntmods version which is not the latest one and can miss some important features), which should be fine and work well. I'm using the same patching methods and tools, which is pretty easy to use and only Dune2000.exe needs to be distributed. The latest version of cncnet's ddraw.dll needs to be used so I'm putting it in the zip file as well.

I would also like to say many thanks to Tomsons26 and The Code Conqueors team for his hard work on reverse engineering Dune2000 with IDA, which helped me very much with seeing and understanding the code and which made game patching easier than it ever could be. Patching, which is practically kind of "source code modding" is lot of fun and can bring lot of new possibilities into the game.

Download here: dune2000-sp-patches_2021-06-05.7z

Put the misc_objects.ini file into your D2kEditor (latest version) config folder in order to be able to place static crates!

Feature list:

- Added support for static pre-placed crates in maps + extended crates functionality and customization
  - Crates can be pre-placed using special values
  - You can place any crate/spice bloom types using any of 8 available graphics (4 crate sprites, 4 spice bloom sprites)
  - Extended Cash crate: Can give you customizable amount of money (multiplies by 100)
  - Extended Explosion crate: You can specify which "weapon" is used and use that weapon's hit explosion
  - Extended Unit crate: You can specify which unit exactly it will give, for infantry it can give either 1 or 5
  - How to use extended crates is described below

- Fixed disappearing crates and spice blooms when AI-controlled units are nearby

- Fixed some of the event types
  - Reveal map event with radius=0 will reveal whole map including radar map
  - Set tech event will also immediately update available buildings and units
  - Set cash event should work without crashes
  
- Extended maximum length of in-game briefing loaded from mission ini file (from 4096 to 65536 characters)

How to place crates with special values:

Spoiler

For the basic crate types you can simply use predefined low-number special values. These are selectible in the editor's Misc objects list 
(i.e. special value 6 = cash crate, 7 = explosion crate etc). The basic crates have predefined graphics sprite.

For the extended crates you use "generalized" special values. The special value is used as a 16-bit bitfield, 
where specific bits determine crate type, sprite and other values.
The 16 bits are used in this way: 1TTTTSSSEEEEEEEE
- The leftmost bit needs to be set to 1
- T (4 bits, values 0-10) = Crate type
- S (3 bits, values 0-7) = Crate sprite 
- E (8 bits) = Extension data, these are specific for each crate type

Crate types:
0 = Cash
1 = Explosion
2 = Show map
3 = Hide map
4 = Unit
5 = Stealth
6 = Unsupported
7 = Spice Bloom spawner
8 = Spice Bloom (small)
9 = Spice Bloom (medium)
10 = Spice Bloom (large)

Crate sprites:
0 = Blue crate
1 = Red crate
2 = Green crate
3 = Purple crate
4 = Invisible (one white pixel)
5 = Spice Bloom (small)
6 = Spice Bloom (medium)
7 = Spice Bloom (large)

Cash crate:
- Amount of cash = Extension data * 100
- If extension data is 0, then default amount of cash (1000), which is determined by "CrateCash" rule, is used
- Possible cash amount range: from 100 to 25500

Explosion crate:
- Extension data bitfield: SEWWWWWW
  S = Use specific weapon? (1 = yes / 0 = no, "CRATE" is used)
  E = Use weapon's hit explosion? (1 = yes / 0 = no, "EX_WHITEN1" is used)
  W = Weapon type (6 bits, values 0-63)
  
Unit crate:
- Extension data bitfield: VIUUUUUU
  V = Call MyVersionOfUnit? (1 = yes / 0 = no)
  I = Infantry amount (0 = one infantry / 1 = five infantry)
  U = Unit type (6 bits, values 0-59)
- If extension data is all zero, then default behavior (random unit) is used
- If "V" bit is 1, then "U" value specifies item from "Unit types" list in structures editor
  i.e. value 9 will give you either Atr, Ord or Hark combat tank depending on side you play as
- If "V" bit is 0, then "U" value specifies item from "Units" list in structures editor
  i.e. value 9 will give you Atr tank, 10 Hark tank, 11 Ord tank

Examples of use:
Special value = 32768 + (crate type * 2048) + (crate sprite * 256) + extension data

Example 1: 
Cash crate, Purple sprite, gives 3000 credits
Special value = 32768 + (0 * 2048) + (3 * 256) + 30 = 33566

Example 2:
Unit crate, Red sprite, gives Ordos tank
Special value = 32768 + (4 * 2048) + (1 * 256) + 11 = 41227

Example 3:
Unit crate, Blue sprite, gives 5 non-stealth Fremen:
Special value = 32768 + (4 * 2048) + (0 * 256) + 64 + 22 = 41046 (without MyVersionOfUnit)
Special value = 32768 + (4 * 2048) + (0 * 256) + 128 + 64 + 19 = 41171 (with MyVersionOfUnit)

Example 4:
Explosion crate, Small Bloom sprite, uses "DEVASTATOR" weapon and its hit explosion
Special value = 32768 + (1 * 2048) + (5 * 256) + 128 + 64 + 18 = 36306

 

Please test the new features and let me know if you see any problems.

Here is github repository with my own added patches: https://github.com/jkoncick/dune2000-sp-patches

Edited by Klofkac
  • Upvote 2
Link to post
Share on other sites
Posted (edited)

Update from 2021-05-20:

- Extended maximum length of in-game briefing loaded from mission ini file (from 4096 to 65536 characters)
- Fixed disappearing crates and spice blooms when AI-controlled units are nearby
- Made set cash event set the cash instead of add

First post edited and download link updated.

Edited by Klofkac
Link to post
Share on other sites

Update from 2021-06-05:

Extended crates functionality and customization
- You can place any crate/spice bloom types using any of 8 available graphics (4 crate sprites, 4 spice bloom sprites)
- Extended Cash crate: Can give you customizable amount of money (multiplies by 100)
- Extended Explosion crate: You can specify which "weapon" is used and use that weapon's hit explosion
- Extended Unit crate: You can specify which unit exactly it will give, for infantry it can give either 1 or 5

First post edited and download link updated.

The first post contains description how to use the extended crates.

Link to post
Share on other sites
Posted (edited)

This is a suggestion I would like to do.

I feel like to place any crate that it doesn't use any default value (1000 credits, a random unit, reveal map) it is going to be really hard doing all the calculation needed and triple checking the values one by one (if base, this + that x the-other + more), and instead going for a friendly user way to achieve this, although this could be tons of work for you.

My idea was when I pick the crate that is about money and about to place it into the map, apearing a windown similar to the "new map", where you manually write the value of the crate that will worth when being picked, just indicating that the value needs to be "X00", in a line on that windown or as an error if somebody writes a non valid value, just like this:image.png.e1e90ac8d539a9c96a17cba8227038e0.png 

Either appearing this kind of windown everytime you place a crate, or double clicking into the graphic of the crate to change; the editor will use whatever value used.


Similar for making to appear a custom unit: If I want a MCV, I need to apply a formula and checking all the specific values just to make it to appear; so I was thinking in some sort of windown that contain a list of the available units, which could reuse the list of the unit spawn-drops-deliveries (so if any custom unit were added it appears there too), and after clicking on the desired unit, maybe a second check with the "only 1 unit / 5 units, but only for infantry" or whatever that part was refering. Dunno if really possible for the editor, doing this, to check if the unit is a vehicle or an infantry to disabled or not the "spawn 5 units", so only with infantry people can mark the "spawn 5", but if this are beyond the limit, then just leaving it available for all but informing somewhere on that windown that will only work with infantry units.


With this, the editor will do the map for the modder, and will help new people to add this, if they want, more easily withouth needing to read another manual.

Edited by Cm_blast
Link to post
Share on other sites
Posted (edited)

Hey Klof, dropping some junk here from the Discord.

Here's the to-do list:
 - Investigate the crash with many unit crates next to each other? Perhaps that's not too difficult a fix. Maybe worth a cursory glance.
 - Add check for hit explosion when placing a crate using a weapon without a hit explosion.
 - (Explosive only?) Crates destroyed by firing on them.
 - Explosive barrel and Grenadier death explosions don't occur at the center of the structure or unit itself. Can cause crashes.
 - Would it also be possible to stop the AI from scanning for and attempting to pick up explosive crates, for one?
 - Unknown side for winning / losing movie error needs investigation.
 - Devastator self destruct doesn't make a sound. Can that be fixed?
 - APCs possible now? xD (impractical, not bothering with this)
 - Messages persist for a shorter time now. The duration before was 400 tics; this could use a fix.
 - On that note, perhaps message duration could be another custom [Vars] thing? Or an event parameter?
 - There appears to be a problem with saving custom messages in the editor. Changes won't apply sometimes.
 - The AI loses its ability to order units from the Starport if it tries with low cash, until an event delivers one. Bug?
 - Units slow down after half HP, then speed up with low HP. Could this be changed? Perhaps through a new [Vars]?
 - MCVs can deploy where crates are. Structures can't be built atop crates, but ConYards spawn with some funny results.
 - Structure tech trees remain intact even if you sell dependencies, but units don't. Is it possible to fix the structure tech tree?
 - Did you happen to fix the issue where teams allied with a sandworm will keep force-firing on the sand where the worm was killed?
 - Can guard mode radius be changed? If possible, perhaps it can be made to be affected through a new .ini [Vars] behavior?
 - For that matter, can the [Vars] list be made a given for any maps using a certain mod?

Edit: Updating the list as you report fixes on the Discord.

Edit 2: I spaced out the "spawn unit" crates by one tile each, and put walls between each one, and then sent a bunch of vehicles through them all. Still got the game-crashing error of "unit already in tile." Also, I can deploy an MCV on top of crates. The structure is created, it simply prevents the concrete from spawning where the crate is. Normal structures seem incapable of being placed on tiles occupied by crates. Seems like that first issue is kind of a big one and is more likely to happen than I thought.

I also discovered that crate graphics can't be realigned. Not really a problem, but it did require a bit of a workaround to get some unit graphics in there. Speaking of, been fucking around with some graphics too. Here are some landmines, incomplete Harvester and MCV, and TibSun crates:

Spoiler

If it's of any help, here are some screenshots of the area with the spread units so you know the circumstances under which I got that error again:

Spoiler

683663779_autogunsonRFGs.png.1e35044dff1e7c1d72b790207cccac68.png

Under these circumstances, I was NOT able to get the error by simply touching the Flame Tanks without breaking any walls or Munitions Silos. That was fine. However, when I destroyed the Munitions Silos and broke the walls, the two Duelist Tanks I began with and the ten Flame Tanks parked there were enough to cause the error at some point. On my first attempt to get the error.

When I removed some the Flame Tanks and sent a ton of existing units through the area however:
343666833_lessFlameTanks.png.a290f0e9e1d9e9fe90242e296b785750.png

That was fine. No error, multiple attempts to get the error. Even with that many units yeeting through the area, all of the Flame Tanks were spawned as intended and none of the tanks clipped through them.

Hopefully this helps get to the bottom of the most alarming error. :P

Good luck! And thanks again.

Edited by Fey
Link to post
Share on other sites
On 6/7/2021 at 1:51 AM, Fey said:

Messages persist for a shorter time now. The duration before was 400 tics; this could use a fix.

I can confirm this. If you want a quick test yourself, you only need to start my "The origin of the mercenaries" campaign first mission; That one start with a initial custom message and then a few seconds later another one; it used to stack, with a couple of seconds being the two together to make the player to know that they were chained and it wasn't any "empty" moment in bewteen messages since nothing is happening and it is not really a "rush anything" kind of mission.

With the lastest exe (not sure with the previous one) the messages are much shorter and it doesn't longer stack.

Maybe it can be added a way to control how long they are (but still keeping the default duration as it used to be).

Link to post
Share on other sites

Eh, you got crazy with the number of things I should look at and fix, lol. Not sure if I will manage everything, and I'll take my time. I got also my own ideas what new stuff to add, I believe you will like them.

On 6/7/2021 at 1:51 AM, Fey said:

- Messages persist for a shorter time now. The duration before was 400 tics; this could use a fix.

Oh, really strange, no idea, maybe the exe FunkyFr3sh provided to me is somehow different. I'll take a look at some time, thanks Cm_blast for the tip.

On 6/7/2021 at 1:51 AM, Fey said:

- There appears to be a problem with saving custom messages in the editor. Changes won't apply sometimes.

Yes I noticed that myself and fixed that, will be part of next editor release (the last release was a not the final v2.0, so luckily I still have place for such bug fixes). It was caused by the new auto-apply feature.

On 6/6/2021 at 10:57 PM, Cm_blast said:

I feel like to place any crate that it doesn't use any default value (1000 credits, a random unit, reveal map) it is going to be really hard doing all the calculation needed and triple checking the values one by one (if base, this + that x the-other + more), and instead going for a friendly user way to achieve this, although this could be tons of work for you.

I'm planning to implement a user-friendly way to place customized crates in the editor. But that will be done later, I still want to finalize (finally!) the version 2.0 which will not have this yet, but just after that I'll start v2.1 where I will only concentrate on adding stuff which I add within exe patching. Of course it will take time.

Link to post
Share on other sites
5 hours ago, Klofkac said:

you got crazy

Sorry :) Hey, take your time! I'm just, you know, putting all the stuff out there, we're entirely dependent on you for what happens and what doesn't. So have a cursory look, or not, and I'm grateful for whatever we get. Thank you!

I'll mark off crates destroyed by firing on them and the message saving thingy. And, uhh, I was asked if APC behavior could be created now, so I'll tack that on. According to tomsons26, that wouldn't be as simple as copy-pasting from RA code, but, we could take the design idea from the RA code to use as a framework for how it works.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...