Post Reply 
 
Thread Rating:
  • 1 Votes - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Anyway to add or remove certain music?
Author Message
City Builder Offline
Awesome Member
******

Posts: 880
Joined: Feb 2008
Post: #1
Anyway to add or remove certain music?
Does anybody know how to add more music tracks and or remove some of the music tracks that are present in the game?

[Image: 2hxu04o.png] Minecraft Schematics at: MCschematics.com
-A growing community of Minecraft (MCedit) Schematics .  Now with 180,000+ members & thousands of schematics for Minecraft.
21-11-2009 08:20 PM
Find all posts by this user Quote this message in a reply
topleya Offline
Owner of Tropico3.co.uk
***

Posts: 129
Joined: Jul 2009
Post: #2
RE: Anyway to add or remove certain music?
Not that I am aware of, which is a shame as I would love to put the music from Tropico 1 into Tropico 3.

[Image: Aye+Jaye.png]
21-11-2009 08:52 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Landstander Offline
Junior Member
**

Posts: 23
Joined: Nov 2009
Post: #3
RE: Anyway to add or remove certain music?
Not that I know of either, but I wish! I have to say, the soundtrack is lacking. Most of what they have is great, but there isn't enough variety for a game like this. I've been turning off the music and playing my own during recent games.
22-11-2009 11:26 AM
Find all posts by this user Quote this message in a reply
degrees57 Offline
Junior Member
**

Posts: 12
Joined: Nov 2009
Post: #4
RE: Anyway to add or remove certain music?
I too, would love to have a little program that reads the music files out of my existing Tropico discs (or installed games) and merge them into Tropico 3. Variety is the spice of life. Smile
22-11-2009 10:23 PM
Find all posts by this user Quote this message in a reply
tropicotim Offline
Pamela Anderson has become a rebel!
*****

Posts: 311
Joined: Sep 2009
Post: #5
RE: Anyway to add or remove certain music?
still noone got a hold on "hpack"? its a tool that is believed to be able to pack hpk files. with that and the "hpk extractor", found on haemimont forums, you should be able to exchange the .ogg files, at least if you create soundfiles with the exact same sizes.
27-11-2009 01:48 AM
Find all posts by this user Quote this message in a reply
degrees57 Offline
Junior Member
**

Posts: 12
Joined: Nov 2009
Post: #6
RE: Anyway to add or remove certain music?
(27-11-2009 01:48 AM)tropicotim Wrote:  still noone got a hold on "hpack"? its a tool that is believed to be able to pack hpk files. with that and the "hpk extractor", found on haemimont forums, you should be able to exchange the .ogg files, at least if you create soundfiles with the exact same sizes.

Thank you. I like the music that came with Tropico3 - I was just hoping to add to the selection. What I want is a way for the current engine to see and play all the music files that have been shipped with the various versions of Tropico over the years.

I'd like to copy the .xdt files from my old versions, and add them to the new version. Apparently, the .xdt files are in a weird format.

From what you say, if I were to get, say Flamenco music off of Jamendo in .ogg format, with the hpack tools, I could replace the current music. Do we know if we can add new music and keep the current music?

Thanks!
29-11-2009 06:51 PM
Find all posts by this user Quote this message in a reply
CoconutKid Offline
Has Been or Never Was?
*******

Posts: 2,010
Joined: Nov 2008
Post: #7
Wink RE: Anyway to add or remove certain music?
(29-11-2009 06:51 PM)degrees57 Wrote:  ... I'd like to copy the .xdt files from my old versions, and add them to the new version. Apparently, the .xdt files are in a weird format. ...

That has been discussed at Cafe Tropico. Wink
29-11-2009 07:43 PM
Find all posts by this user Quote this message in a reply
degrees57 Offline
Junior Member
**

Posts: 12
Joined: Nov 2009
Post: #8
RE: Anyway to add or remove certain music?
(29-11-2009 07:43 PM)CoconutKid Wrote:  
(29-11-2009 06:51 PM)degrees57 Wrote:  ... I'd like to copy the .xdt files from my old versions, and add them to the new version. Apparently, the .xdt files are in a weird format. ...

That has been discussed at Cafe Tropico. Wink

Is it just me, or are the forums at Cafe Tropico (@strategyplanet) down?
(This post was last modified: 29-11-2009 10:41 PM by degrees57.)
29-11-2009 09:08 PM
Find all posts by this user Quote this message in a reply
Pi-Xerxes Offline
Posting Freak
*****

Posts: 301
Joined: Feb 2009
Post: #9
RE: Anyway to add or remove certain music?
'hpack' works? (where, I never found one)?......Cafe Tropico is down for the count.

Unpacking the files will not work unless you can re-pack them. exactly. ASFAIK.
30-11-2009 03:21 AM
Find all posts by this user Quote this message in a reply
cafetropicobean Offline
Member
***

Posts: 118
Joined: Aug 2009
Post: #10
RE: Anyway to add or remove certain music?
(30-11-2009 03:21 AM)Pi-Xerxes Wrote:  ......Cafe Tropico is down for the count.

No it's not! It moved.Big Grin

http://www.the-nextlevel.com/tropico/cafe/index.php
30-11-2009 10:59 AM
Find all posts by this user Quote this message in a reply
CoconutKid Offline
Has Been or Never Was?
*******

Posts: 2,010
Joined: Nov 2008
Post: #11
Wink RE: Anyway to add or remove certain music?
(29-11-2009 09:08 PM)degrees57 Wrote:  Is it just me, or are the forums at Cafe Tropico (@strategyplanet) down?

As Coffeebean says, the Cafe has moved. Strategy Planet dumped a number of forums they used to host.

http://www.the-nextlevel.com/tropico/cafe/index.php

The Next Level is the new host.

Cool

A snip from an old (about T1) email in my old (five years ago) file:

Quote:Yep yep, according to the discussions on the subject (as well as from Phil himself), the MAC version indeed used MP3 format music files vs those infernal XDT proprietary compressed files for the Windows version. Do a search through the old messages over at the Cafe for MP3, there was quite a bit of discussion there eons ago on the subject (always drove me crazy that the MAC version used MP3 files).

Big Grin enjoy Big Grin
(This post was last modified: 30-11-2009 02:37 PM by CoconutKid.)
30-11-2009 01:42 PM
Find all posts by this user Quote this message in a reply
Morticcia Offline
Junior Member
**

Posts: 24
Joined: Oct 2009
Post: #12
RE: Anyway to add or remove certain music?
(21-11-2009 08:52 PM)topleya Wrote:  I would love to put the music from Tropico 1 into Tropico 3.

That was my first thought upon loading the game. I so miss T1s music.

War does not determine who is right - only who is left ~ Bertrand Russell
02-12-2009 05:47 PM
Visit this user's website Find all posts by this user Quote this message in a reply
slserpent Offline
Junior Member
**

Posts: 11
Joined: Feb 2010
Post: #13
RE: Anyway to add or remove certain music?
so far, i've been able to successfully replace Tropico 3's music. i also know how to change the filenames of the music files, but that's not particularly helpful unless i can also figure out how to add new music files--that whole compiled LUA script and all. i'll keep working on it, though.

but to replace the music files, just put an OGG format audio file into "tropico 3\Music" and rename it to TrackN.ogg where N is a number 1 to 15. this will override the music files in the Music.hpk archive. Simple if you already have some OGGs. if you need to create OGGs from MP3s, try LAME plus LameDropXPd or Razorlame to get the MP3 to WAV, then OGGdropXPd to get the WAV to OGG. if you want to know what music files to replace, you'll have to give the extracted original files a listen. get one of the HPK extractors floating around and extract "tropico 3\Packs\boot\Music.hpk".

on adding new music, thus far i know that the "Data\Sounds\Playlists\Playlists.lua" file extracted from Data.hpk controls what files are played. the filenames are easy enough to edit: at the end of the file, they're in a string resource block where each string is formatted thus:
  • byte 04
  • integer of the size of the string (plus terminating null, little-endian)
  • the string itself
  • terminating null byte

in the beginning of the playlists file, i know there's a pattern that corresponds to the number of tracks (15) but i can't quite figure out the original code or what to modify. my intuition says it's probably a random number put into a switch-case statement, though.

here's what i've found so far in the code in case anyone better at asm wants to take a look:
[Image: playlist.png]
05-02-2010 12:41 AM
Visit this user's website Find all posts by this user Quote this message in a reply
FordGT90Concept Offline
Senior Member
****

Posts: 202
Joined: Oct 2009
Post: #14
RE: Anyway to add or remove certain music?
I think what you picked up on there is a list of static data.

Code:
enum DataType : byte {
  Integer = 3,
  String = 4
}

struct DataString {
  int Length;
  char[] Value; // null terminated
}

struct DataObject {
  DataType Type;
  object Value;  //int and DataString known
}

Just before that static list is a count of how many items exist in the list. In the case of Playlists.lua, it is 33.

There clearly is a structure before that as well. It is a good start, nevertheless.

Edit: The structure before it appears to be byte-instructions. It will take a lot of work to decompile it.
(This post was last modified: 06-02-2010 05:47 AM by FordGT90Concept.)
06-02-2010 05:28 AM
Find all posts by this user Quote this message in a reply
slserpent Offline
Junior Member
**

Posts: 11
Joined: Feb 2010
Post: #15
RE: Anyway to add or remove certain music?
(06-02-2010 05:28 AM)FordGT90Concept Wrote:  It will take a lot of work to decompile it.

I did it. I decompiled 37 unique operations out of the 126 in total. My results from that follow. Since I had to do this manually (none of the decompilers work apparently), the format is a little peculiar. But it basically reads as follows: BinaryCode: (Operation A B C) Assembler; // Psuedocode
Code:
Offset 20 -> Op:000101 A:00000000 B:000000000000000000: (GetGlobal 0 0) Register_A = Global(Constant_0); // "namespace"
Op:000001 A:00000001 B:000000000000000001: (LoadK 1 1) Register_B = Constant_1; // "Playlists"
Op:011100 A:00000000 C:000000001 B:000000010: (Call 0 2 1) Call Func_A(Register_B); // namespace(Playlists)
Op:000001 A:00000000 B:000000000000000011: (LoadK 0 3) Register_A = Constant_3; // 25
Op:000111 A:00000000 B:000000000000000010: (SetGlobal 0 2) Global(Constant_2) = Register_A; // Global(DefaultSilenceChance) = 25
Op:000001 A:00000000 B:000000000000000101: (LoadK 0 5) Register_A = Constant_5; // 15000
Op:000111 A:00000000 B:000000000000000100: (SetGlobal 0 4) Global(Constant_4) = Register_A; // Global(DefaultSilenceDuration) = 15000
Op:000001 A:00000000 B:000000000000000111: (LoadK 0 7) Register_A = Constant_7; // 3000
Op:000111 A:00000000 B:000000000000000110: (SetGlobal 0 6) Global(Constant_6) = Register_A; // Global(DefaultCrossfadeTime) = 3000
Op:000001 A:00000000 B:000000000000001001: (LoadK 0 9) Register_A = Constant_9; // 60000
Op:000111 A:00000000 B:000000000000001000: (SetGlobal 0 8) Global(Constant_8) = Register_A; // Global(BattleMusicTimeout) = 60000
Offset 4C -> Op:001010 A:00000000 C:000000000 B:000001111: (NewTable 0 15 0) Register_A = Array[15];
Op:001010 A:00000001 C:000000100 B:000000000: (NewTable 1 0 4) Register_B = Array[0][4];
Op:001001 A:00000001 C:1-00001100 B:1-00001011: (SetTable 1 11 12) Register_B[Constant_11] = Constant_12; // B["path"] = "Music/Track1.ogg"
Op:001001 A:00000001 C:1-00001110 B:1-00001101: (SetTable 1 13 14) Register_B[Constant_13] = Constant_14; // B["frequency"] = 100
Op:001001 A:00000001 C:1-00000101 B:1-00001111: (SetTable 1 15 5) Register_B[Constant_15] = Constant_5; // B["SilenceDuration"] = 15000
Op:001001 A:00000001 C:1-00000011 B:1-00010000: (SetTable 1 16 3) Register_B[Constant_16] = Constant_3; // B["SilenceChance"] = 25
Op:001010 A:00000010 C:000000100 B:000000000: (NewTable 2 0 4) Register_C = Array[0][4];
Op:001001 A:00000010 C:1-00010001 B:1-00001011: (SetTable 2 11 17) Register_C[Constant_11] = Constant_17; // B["path"] = "Music/Track2.ogg"
    Last 5 operations repeat 14 times
Offset 17C -> Op:100010 A:00000000 C:000000001 B:000001111: (SetList 0 15 1) Register_A[i] = Register_B..P; // for (int i = 0; i < 15; i++) A[i] = *B + i
Op:000111 A:00000000 B:000000000000001010: (SetGlobal 0 10) Global(Constant_10) = Register_A; // Global(AllTracks) = Register_A
Op:001010 A:00000000 C:000000000 B:000000101: (NewTable 0 5 0) Register_A = Array[5];
    Repeats as before, loading the array structure except this time with the following tracks loaded for path:
    Constant_11, Constant_27, Constant_28, Constant_29, Constant_30
    "Music/Track1.ogg", Music/Track12.ogg, Music/Track13.ogg, Music/Track14.ogg, Music/Track15.ogg
Offset 1EC ->  Op:100010 A:00000000 C:000000001 B:000000101: (SetList 0 5 1) Register_A[i] = Register_B..G; // for (int i = 0; i < 5; i++) A[i] = *B + i
Op:000111 A:00000000 B:000000000000011111: (SetGlobal 0 31) Global(Constant_31) = Register_A; // Global(Tutorial) = Register_A
Op:000101 A:00000000 B:000000000000100000: (GetGlobal 0 32) Register_A = Global(Constant_32); // "IsDemo"
Op:011100 A:00000000 C:000000010 B:000000001: (Call 0 1 2) Register_A = Func_A(); // Register_A = IsDemo()
Op:011010 A:00000000 C:000000000 B:000000000: (Test 0 0) if not Register_A == 0 then //takes the next jump
Op:010110 A:00000000 B:100000000000000001: (Jump +1) // goto instruction after next
Op:000101 A:00000000 B:000000000000011111: (GetGlobal 0 0) Register_A = Global(Constant_31); // "Tutorial"
Op:000111 A:00000000 B:000000000000001010: (SetGlobal 0 10) Global(Constant_10) = Register_A; // Global(AllTracks) = Register_A
Op:001010 A:00000000 C:000000000 B:000000000: (NewTable 0 0 0) Register_A = Array[0];
Op:000111 A:00000000 B:000000000000100001: (SetGlobal 0 33) Global(Constant_33) = Register_A; // Global(Empty) = Register_A

Here's what that would look like in psuedocode:
Code:
call namespace(Playlists)

global DefaultSilenceChance = 25;
global DefaultSilenceDuration = 15000;
global DefaultCrossfadeTime = 3000;
global BattleMusicTimeout = 60000;

global AllTracks = New Array(15);
for (i = 0; i < 15; i++) {
    AllTracks[i].path = "Music/Track" + (i+1) + ".ogg";
    AllTracks[i].frequency = 100;
    AllTracks[i].SilenceDuration = DefaultSilenceDuration;
    AllTracks[i].SilenceChance = DefaultSilenceChance;
}

global Tutorial = New Array(5);
for (i = 0; i < 5; i++) {
    AllTracks[i].path = "Music/Track" + (i+1) + ".ogg";
    AllTracks[i].frequency = 100;
    AllTracks[i].SilenceDuration = DefaultSilenceDuration;
    AllTracks[i].SilenceChance = DefaultSilenceChance;
}

if (IsDemo() == 1) {
    AllTracks = Tutorial;
}

What you'll notice is that the global variable AllTracks holds all the track filenames. Also, the last two blocks of code aren't needed for the full version of the game and the randomization must be done in the calling function. So basically, as long as you create a global array called AllTracks with as many elements as tracks you want, the game will take your new track listing.

Each element in the AllTracks array needs to be an array with the following keys:
  • path - the path to the track relative to the tropico 3 directory. may also take absolute paths?
  • frequency - guessing this is a weight for how likely it is that the track is to be picked, but i haven't tested it
  • SilenceDuration - length of time in milliseconds of silence after the track has played?
  • SilenceChance - chance that there will be silence after the track is played?

You can use the following LUA script to get you started (it includes Tropico 1 filenames for if you converted those to OGG):
Code:
namespace("Playlists")

DefaultSilenceChance = 25
DefaultSilenceDuration = 15000
DefaultCrossfadeTime = 3000
BattleMusicTimeout = 60000

AllTracks = {}
AllTracks[1] = {path="Music/ADAT01.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[2] = {path="Music/Track1.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[3] = {path="Music/Track10.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[4] = {path="Music/Track11.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[5] = {path="Music/Track12.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[6] = {path="Music/Track13.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[7] = {path="Music/Track14.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[8] = {path="Music/Track15.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[9] = {path="Music/Track2.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[10] = {path="Music/Track3.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[11] = {path="Music/Track4.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[12] = {path="Music/Track5.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[13] = {path="Music/Track6.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[14] = {path="Music/Track7.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[15] = {path="Music/Track8.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[16] = {path="Music/Track9.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[17] = {path="Music/XDAT02.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[18] = {path="Music/XDAT03.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[19] = {path="Music/XDAT04.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[20] = {path="Music/XDAT05.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[21] = {path="Music/XDAT06.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[22] = {path="Music/XDAT07.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[23] = {path="Music/XDAT08.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[24] = {path="Music/XDAT09.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[25] = {path="Music/XDAT10.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[26] = {path="Music/XDAT12.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[27] = {path="Music/XDAT13.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[28] = {path="Music/XDAT14.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[29] = {path="Music/XDAT15.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[30] = {path="Music/XDAT16.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[31] = {path="Music/XDAT17.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[32] = {path="Music/Xdat18.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[33] = {path="Music/Xdat19.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[34] = {path="Music/Xdat20.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[35] = {path="Music/Xdat21.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[36] = {path="Music/Xdat22.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[37] = {path="Music/Xdat23.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[38] = {path="Music/Xdat25.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[39] = {path="Music/Xdat26.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[40] = {path="Music/Xdat27.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[41] = {path="Music/Xdat28.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[42] = {path="Music/Xdat29.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[43] = {path="Music/Xdat30.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[44] = {path="Music/Xdat31.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[45] = {path="Music/Xdat32.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[46] = {path="Music/Xdat33.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[47] = {path="Music/Xdat36.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[48] = {path="Music/Xdat37.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}
AllTracks[49] = {path="Music/Xdat39.ogg", frequency=100, SilenceDuration=DefaultSilenceDuration, SilenceChance=DefaultSilenceChance}

After you've edited the above script, adding or removing whatever tracks you want, you'll need to save and compile it so the game can read it. Unfortunately, the default LUA compiler won't work because it uses doubles for number data where Tropico 3 uses integers. So you'll have to download my special LUA compiler with that modification made. Extract the luac.exe file to wherever you saved your script to (desktop in the example below). Then to compile, run "cmd" and follow this procedure, making sure to substitute appropriate drive letters, directories, and filenames where underlined:
  • D:\Documents and Settings\User>C: #change current drive
  • C:\>cd Documents and Settings\User\Desktop #change current directory
  • C:\Documents and Settings\User\Desktop>luac -o "C:\Program Files\Valve\Steam\SteamApps\common\tropico 3\Data\Sounds\Playlists\Playlists.lua" Playlists.lua #compile the script and put the output in the correct directory

Then you should be all set. If you get a compile error, go back and check your syntax in the script. If you compile okay but get no music when starting a game, double check your script (it may have compiled okay, but the game still had troubles reading the array it output) and make sure your music files exist in the right place.

Good luck and happy modding!
(This post was last modified: 08-02-2010 02:28 AM by slserpent.)
07-02-2010 10:01 AM
Visit this user's website Find all posts by this user Quote this message in a reply
FordGT90Concept Offline
Senior Member
****

Posts: 202
Joined: Oct 2009
Post: #16
RE: Anyway to add or remove certain music?
Um, you gonna make an app to compile/decompile LUA files?

Also, what are the XDAT# files for?
08-02-2010 12:10 AM
Find all posts by this user Quote this message in a reply
slserpent Offline
Junior Member
**

Posts: 11
Joined: Feb 2010
Post: #17
RE: Anyway to add or remove certain music?
(08-02-2010 12:10 AM)FordGT90Concept Wrote:  Um, you gonna make an app to compile/decompile LUA files?

There are two apps that can decompile LUA 5.1: Luadec51 and ChunkSpy, but neither seem to work with Tropico's compiled LUA files. It could be the double vs integer number format or something else non-standard in the header. I certainly know enough about how LUA files are compiled now to make a decompiler just for Tropico 3, but I'll need a lot more motivation first.

As for a compiler, I just made one. (Okay, I only changed one line in the existing compiler source, but still.)

(08-02-2010 12:10 AM)FordGT90Concept Wrote:  Also, what are the XDAT# files for?

The original Tropico stored music in a bunch of XDAT##.xdt files, so that's just to simplify the process for people porting T1 music. Those lines can be replaced and deleted with whatever you want.
08-02-2010 02:24 AM
Visit this user's website Find all posts by this user Quote this message in a reply
FordGT90Concept Offline
Senior Member
****

Posts: 202
Joined: Oct 2009
Post: #18
RE: Anyway to add or remove certain music?
6-bits, seriously? That's gonna be a PITA. Sad

Do you have a list of all opcodes?
(This post was last modified: 08-02-2010 05:32 AM by FordGT90Concept.)
08-02-2010 05:26 AM
Find all posts by this user Quote this message in a reply
Pi-Xerxes Offline
Posting Freak
*****

Posts: 301
Joined: Feb 2009
Post: #19
RE: Anyway to add or remove certain music?
Yes, the opcodes are 6 bit and makes the original HEX bit code hard to read straight off since they are in 8 bit. Wow, you guys are good to spot that so obvious but not.

Here is a list of opcodes I got off from reading about LUA format....

http://luaforge.net/docman/view.php/83/9...ctions.pdf

Oh, that integer thing instead of a real number used in this LUA version is a good catch. I could never figure it out.

0000 ** source chunk: simple.lua
** global header start **
0000 1B4C7561 header signature: "\27Lua"
0004 51 version (major:minor hex digits)
0005 00 format (0=official)
0006 01 endianness (1=little endian)
0007 04 size of int (bytes)
0008 04 size of size_t (bytes)
0009 04 size of Instruction (bytes)
000A 08 size of number (bytes)-------> Topico 3 uses 04 as size.
000B 00 integral (1=integral) --------> Tropico 3 uses 01 as integer.
* number type: double
* x86 standard (32-bit, little endian, doubles)
** global header end **
---------------------------------------------
OPCODES LUA 5.1

Opcode Name Description
0 MOVE Copy a value between registers
1 LOADK Load a constant into a register
2 LOADBOOL Load a boolean into a register
3 LOADNIL Load nil values into a range of registers
4 GETUPVAL Read an upvalue into a register
5 GETGLOBAL Read a global variable into a register
6 GETTABLE Read a table element into a register
7 SETGLOBAL Write a register value into a global variable
8 SETUPVAL Write a register value into an upvalue
9 SETTABLE Write a register value into a table element
10 NEWTABLE Create a new table
11 SELF Prepare an object method for calling
12 ADD Addition operator
13 SUB Subtraction operator
14 MUL Multiplication operator
15 DIV Division operator
16 MOD Modulus (remainder) operator
17 POW Exponentiation operator
18 UNM Unary minus operator
19 NOT Logical NOT operator
20 LEN Length operator
21 CONCAT Concatenate a range of registers
22 JMP Unconditional jump
23 EQ Equality test
24 LT Less than test
25 LE Less than or equal to test
26 TEST Boolean test, with conditional jump
27 TESTSET Boolean test, with conditional jump and assignment
28 CALL Call a closure
29 TAILCALL Perform a tail call
30 RETURN Return from function call
31 FORLOOP Iterate a numeric for loop
32 FORPREP Initialization for a numeric for loop
33 TFORLOOP Iterate a generic for loop
34 SETLIST Set a range of array elements for a table
35 CLOSE Close a range of locals being used as upvalues
36 CLOSURE Create a closure of a function prototype
37 VARARG Assign vararg function arguments to registers
(This post was last modified: 08-02-2010 05:11 PM by Pi-Xerxes.)
08-02-2010 04:53 PM
Find all posts by this user Quote this message in a reply
thelife404 Offline
Newbie
*

Posts: 6
Joined: Feb 2010
Post: #20
RE: Anyway to add or remove certain music?
Hey,

I got Tropico 3 on steam a few weeks ago and just bought a video card last week so I can play it, but I am definitely missing the Tropico 1 songs. I have a few questions if you don't mind helping.

1. I have two data.hpk's
....\Steam\steamapps\common\tropico 3\Packs\boot\persist\data.hpk
.....\Steam\steamapps\common\tropico 3\Packs\Patches\Boot\data.hpk

I assume the one I am trying to modify is the Patches\Boot\data.hpk?

2. I used the hpk extractor on the music.hpk and found all the music. I assume I need to put the music I wanted to add in here and archive it and put it back in the folder where I found it?

3. I found the .lua file but how exactly should I go about modifying and decompiling. Can I just edit slserpent's .lua file for the songs I am going to add (e.g. change title name), use slserpent's comiplier, replace the old one, and archive it back, and replace the old data.hpk. Or is there more stuff in the playlists.lua that I need and doing this will do bad bad things?

Thanks for the help. Sorry for asking so many questions I am going to go ahead and try this. Thanks again I love this game hopefully it will get better. I swear if I have to hear that one song with the screaming lady.....

Edit: here is an .xdt ripper http://www.the-nextlevel.com/tropico/caf...pic=9183.0
(This post was last modified: 14-02-2010 05:17 PM by thelife404.)
14-02-2010 05:09 PM
Find all posts by this user Quote this message in a reply
JohnCub Offline
Junior Member
**

Posts: 17
Joined: Feb 2010
Post: #21
RE: Anyway to add or remove certain music?
I don't understand why people don't load up winamp, turn the music down in tropico 3, and listen to their own music. For my time and enjoyment it beats decompiling and fighting with it.
14-02-2010 05:16 PM
Find all posts by this user Quote this message in a reply
thelife404 Offline
Newbie
*

Posts: 6
Joined: Feb 2010
Post: #22
RE: Anyway to add or remove certain music?
I probably should do that but I don't know something about that I never liked. Also running less programs at a time would be better.
14-02-2010 05:25 PM
Find all posts by this user Quote this message in a reply
City Builder Offline
Awesome Member
******

Posts: 880
Joined: Feb 2008
Post: #23
RE: Anyway to add or remove certain music?
(14-02-2010 05:16 PM)JohnCub Wrote:  I don't understand why people don't load up winamp, turn the music down in tropico 3, and listen to their own music. For my time and enjoyment it beats decompiling and fighting with it.

When I started this thread, all I wanted to do was to remove a couple of the more annoying tunes, I don't generally want to swap the music out for something from my own collection. In fact I'm one of those rare people I guess that doesn't like to play my own music when I'm playing a game, doing so doesn't let me concentrate where as the music in many games is so generic that it allows one to concentrate, however there are a few really annoying songs to me in Tropico 3 that after I've heard it for the umpteenth time, I think I'd rather not hear it again the rest of my life

[Image: 2hxu04o.png] Minecraft Schematics at: MCschematics.com
-A growing community of Minecraft (MCedit) Schematics .  Now with 180,000+ members & thousands of schematics for Minecraft.
14-02-2010 05:44 PM
Find all posts by this user Quote this message in a reply
whybuybeta Offline
Member
***

Posts: 131
Joined: Feb 2008
Post: #24
RE: Anyway to add or remove certain music?
(14-02-2010 05:09 PM)thelife404 Wrote:  I swear if I have to hear that one song with the screaming lady.....

lol I don't understand how that song even made the cut, it's... obnoxious to me, and the worst part is that there's absolutely nothing we can do about it, short of actually shutting it off, unless you guys can get the lua's modded. the rest of the tracks are great, on the level of what we had for t1 imo. what it lacks in is variety, where t1 also had more mellow tracks to go with the upbeat ones, a real complete package.

I don't know enough to help out but I wish you good luck, you would be doing us a great service just by providing an edited playist minus that one song, it's really getting to me. even more awsome would be a "throwback mod" where we could drop in the songs from the old t1 in addition to the new tracks.

(14-02-2010 05:16 PM)JohnCub Wrote:  I don't understand why people don't load up winamp, turn the music down in tropico 3, and listen to their own music. For my time and enjoyment it beats decompiling and fighting with it.

well for those who know how, it's more like "because we can", and also you would keep the rest of the game features like auto fade for the radio guy intact. however annoying he is, and the improper greater than/less than value detection (he incorrectly warns you of events in both directions most of the time), it's still useful to let you know what's going on in the game.
(This post was last modified: 14-02-2010 11:22 PM by whybuybeta.)
14-02-2010 11:17 PM
Find all posts by this user Quote this message in a reply
thelife404 Offline
Newbie
*

Posts: 6
Joined: Feb 2010
Post: #25
RE: Anyway to add or remove certain music?
Well I figured out how to replace songs so i just replaced the new tropico songs with the old. Unfortunately you can only have 15 songs and I have yet to figure out how to add more.
14-02-2010 11:21 PM
Find all posts by this user Quote this message in a reply
whybuybeta Offline
Member
***

Posts: 131
Joined: Feb 2008
Post: #26
RE: Anyway to add or remove certain music?
(14-02-2010 11:21 PM)thelife404 Wrote:  Well I figured out how to replace songs so i just replaced the new tropico songs with the old. Unfortunately you can only have 15 songs and I have yet to figure out how to add more.

would you be so kind as to post a brief tutorial, I would love to be able to mix and match, even with a 15 song limit.
14-02-2010 11:25 PM
Find all posts by this user Quote this message in a reply
slserpent Offline
Junior Member
**

Posts: 11
Joined: Feb 2010
Post: #27
RE: Anyway to add or remove certain music?
(14-02-2010 05:09 PM)thelife404 Wrote:  1. I have two data.hpk's
....\Steam\steamapps\common\tropico 3\Packs\boot\persist\data.hpk
.....\Steam\steamapps\common\tropico 3\Packs\Patches\Boot\data.hpk

I assume the one I am trying to modify is the Patches\Boot\data.hpk?

You don't need to extract the Playlists.lua file to mod it. You only have to compile the script that I posted after making your own modifications.

(14-02-2010 05:09 PM)thelife404 Wrote:  2. I used the hpk extractor on the music.hpk and found all the music. I assume I need to put the music I wanted to add in here and archive it and put it back in the folder where I found it?

There's no need to re-archive the music after you make changes. The game just has to be able to find it in your Playlists script.

(14-02-2010 05:09 PM)thelife404 Wrote:  3. I found the .lua file but how exactly should I go about modifying and decompiling. Can I just edit slserpent's .lua file for the songs I am going to add (e.g. change title name), use slserpent's comiplier, replace the old one, and archive it back, and replace the old data.hpk. Or is there more stuff in the playlists.lua that I need and doing this will do bad bad things?

Again, no need to archive the modded playlists file either, just make sure it's in the right place (i.e. \tropico 3\Data\Sounds\Playlists) and compiled. If you screw anything up, you just won't hear music. To undo the mod, just delete the playlists.lua file.

(14-02-2010 05:09 PM)thelife404 Wrote:  I swear if I have to hear that one song with the screaming lady.....

Exactly why I went about doing this mod. IIRC, it's Track5.ogg, BTW.

And for those that would rather not fool with modding the music and just use another music player, let me just remind you that the in-game music will automatically fade out whenever the radio announcer or speeches occur.
(14-02-2010 11:25 PM)whybuybeta Wrote:  would you be so kind as to post a brief tutorial, I would love to be able to mix and match, even with a 15 song limit.

(05-02-2010 12:41 AM)slserpent Wrote:  but to replace the music files, just put an OGG format audio file into "tropico 3\Music" and rename it to TrackN.ogg where N is a number 1 to 15. this will override the music files in the Music.hpk archive. Simple if you already have some OGGs. if you need to create OGGs from MP3s, try LAME plus LameDropXPd or Razorlame to get the MP3 to WAV, then OGGdropXPd to get the WAV to OGG. if you want to know what music files to replace, you'll have to give the extracted original files a listen. get one of the HPK extractors floating around and extract "tropico 3\Packs\boot\Music.hpk".
(This post was last modified: 14-02-2010 11:38 PM by slserpent.)
14-02-2010 11:34 PM
Visit this user's website Find all posts by this user Quote this message in a reply
whybuybeta Offline
Member
***

Posts: 131
Joined: Feb 2008
Post: #28
RE: Anyway to add or remove certain music?
(05-02-2010 12:41 AM)slserpent Wrote:  but to replace the music files, just put an OGG format audio file into "tropico 3\Music" and rename it to TrackN.ogg where N is a number 1 to 15. this will override the music files in the Music.hpk archive. Simple if you already have some OGGs. if you need to create OGGs from MP3s, try LAME plus LameDropXPd or Razorlame to get the MP3 to WAV, then OGGdropXPd to get the WAV to OGG. if you want to know what music files to replace, you'll have to give the extracted original files a listen. get one of the HPK extractors floating around and extract "tropico 3\Packs\boot\Music.hpk".

yeah thanks got it working, missed that part on the first page.
15-02-2010 12:08 AM
Find all posts by this user Quote this message in a reply
thelife404 Offline
Newbie
*

Posts: 6
Joined: Feb 2010
Post: #29
RE: Anyway to add or remove certain music?
(14-02-2010 05:16 PM)JohnCub Wrote:  I don't understand why people don't load up winamp, turn the music down in tropico 3, and listen to their own music. For my time and enjoyment it beats decompiling and fighting with it.

(14-02-2010 11:25 PM)whybuybeta Wrote:  
(14-02-2010 11:21 PM)thelife404 Wrote:  Well I figured out how to replace songs so i just replaced the new tropico songs with the old. Unfortunately you can only have 15 songs and I have yet to figure out how to add more.

would you be so kind as to post a brief tutorial, I would love to be able to mix and match, even with a 15 song limit.


How to mix and match music in Tropico 3 (Replace not adding):
ALL CREDIT GOES TO: slserpent
Check her/his post on the first page for more info.

1. First you need to go to HPK Link and download the HPK Extractor.

2. Locate the Music.hpk file in your Tropico 3 Directory. Mine was
D:\Program Files\Steam\steamapps\common\tropico 3\Packs\boot\Music.Hpk (I have the steam version)

--Make a back up of the Music.hpk in case.

3. Use the extractor on the Music.hpk and it should extract to a Music Folder and in that folder you should see Track1-Track15.ogg Just replace what ever song you want with one of these and you are good. Make sure they are named correctly and they are .ogg *Goggle if you need to convert*

4. Archive it back up MAKE sure the directory system is the same ...extract it to make sure you have Music\*All the music files. The HPK extractor archives the current folder directory and everything else so be careful.

5. Replace your old Music.hpk in the tropico directory with the new one.


If you need to rip the old music from Tropico and have .xdt files use http://www.the-nextlevel.com/tropico/caf...pic=9183.0 (Click on the sig Viva la Tropico if the ripper link doesn't work. The instructions are a few pages down.)

Enjoy Smile Hopefully this helps post if this is not clear.



To slserpent:
This is where I was confused I dont have a tropico\data directory. Everything is in .hpk how about you? Yea track5.ogg was the first to go ..... the horror.
(This post was last modified: 15-02-2010 12:44 AM by thelife404.)
15-02-2010 12:40 AM
Find all posts by this user Quote this message in a reply
whybuybeta Offline
Member
***

Posts: 131
Joined: Feb 2008
Post: #30
RE: Anyway to add or remove certain music?
(15-02-2010 12:40 AM)thelife404 Wrote:  To slserpent:
This is where I was confused I dont have a tropico\data directory. Everything is in .hpk how about you? Yea track5.ogg was the first to go ..... the horror.

yeah I was hung up on the same part, I had the repack method working too but now that I got a bit of time and caffeine to wrap my head around his notes, going this route is much better since we're not limited in the number of tracks.

*sips coffee*

my steps for those of us less familiar with the lua data structure and methodology going on here, refer to the above posts for porting/extraction/conversion to ogg (I use audacity for audio manipulation):

1. create .\music directory in your install root, this is where all your desired tracks will go, same as from music.hpk

2. create .\data\sounds\playlists directories in your install root, this is where your new playlists.lua will go.

*edit - tried running the game off extracted data only, this will not work properly. had all sorts of problems like data corruption and crashing on save, so make sure you keep all your hpk files intact, and use only the modified playlist.

3. edit/compile slserpent's script as per his directions on the first page (be careful with the array order and filenames, make sure output goes to .\gamedir\data\sounds\playlists\playlists.lua). as he said if you got typo/syntax errors or somesuch then you will just not hear any music, took me a couple tries to get it working properly with all my files as well.

thanks to slserpent et al. for doing the legwork, now I got my oldschool/newschool combo for t3 playing here.
(This post was last modified: 15-02-2010 11:05 PM by whybuybeta.)
15-02-2010 07:01 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

Contact Us | kalypso media :: website | Return to Top | Return to Content | Lite (Archive) Mode | RSS Syndication