Skip to content

Commit 94fad0f

Browse files
committed
Fix Terraria OW Mod Audio (#3161)
1 parent 23d0373 commit 94fad0f

File tree

1 file changed

+137
-5
lines changed

1 file changed

+137
-5
lines changed

patches/tModLoader/Terraria/Main.cs.patch

Lines changed: 137 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,19 @@
11761176
float num2 = musicFade[i] * musicVolume * num;
11771177
if (i >= 62 && i <= 88) {
11781178
num2 *= 0.9f;
1179+
@@ -9022,7 +_,11 @@
1180+
bool flag14 = false;
1181+
bool flag15 = false;
1182+
bool flag16 = false;
1183+
- if (!showSplash) {
1184+
+
1185+
+ int modMusic = -1;
1186+
+ ModLoader.SceneEffectPriority modPriority = ModLoader.SceneEffectPriority.None;
1187+
+
1188+
+ if (!gameMenu) { // showSplash -> gameMenu. Fix crash iterating active NPCs while unloading mods
1189+
Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle((int)screenPosition.X, (int)screenPosition.Y, screenWidth, screenHeight);
1190+
int num = 5000;
1191+
for (int i = 0; i < 200; i++) {
11791192
@@ -9129,17 +_,22 @@
11801193
break;
11811194
}
@@ -1193,14 +1206,133 @@
11931206

11941207
Microsoft.Xna.Framework.Rectangle value = new Microsoft.Xna.Framework.Rectangle((int)(npc[i].position.X + (float)(npc[i].width / 2)) - num, (int)(npc[i].position.Y + (float)(npc[i].height / 2)) - num, num * 2, num * 2);
11951208
if (rectangle.Intersects(value)) {
1196-
+ //TODO: Implement modMusic and modPriority
1197-
+ //if (npc[i].modNPC != null && npc[i].modNPC.music >= 0 && (modMusic < 0 || npc[i].modNPC.SceneEffectPriority > modPriority)) {
1198-
+ // modMusic = npc[i].modNPC.music;
1199-
+ // modPriority = npc[i].modNPC.SceneEffectPriority;
1200-
+ //}
1209+
+ //TODO: Can we simplify these two Decide music methods?
1210+
+ if (npc[i].ModNPC != null && npc[i].ModNPC.Music >= 0 && (modMusic < 0 || npc[i].ModNPC.SceneEffectPriority > modPriority)) {
1211+
+ modMusic = npc[i].ModNPC.Music;
1212+
+ modPriority = npc[i].ModNPC.SceneEffectPriority;
1213+
+ }
12011214
switch (num2) {
12021215
case 1:
12031216
flag = true;
1217+
@@ -9194,6 +_,8 @@
1218+
break;
1219+
}
1220+
}
1221+
+
1222+
+ LoaderManager.Get<SceneEffectLoader>().UpdateMusic(ref modMusic, ref modPriority);
1223+
}
1224+
1225+
_ = (screenPosition.X + (float)(screenWidth / 2)) / 16f;
1226+
@@ -9201,6 +_,30 @@
1227+
newMusic = 0;
1228+
return;
1229+
}
1230+
+
1231+
+ //TODO: Re-implment game menu/menuloader audio in Other World soundtrack???
1232+
+ /*if (gameMenu) {
1233+
+ if (netMode != 2) {
1234+
+ if (WorldGen.drunkWorldGen) {
1235+
+ newMusic = 60;
1236+
+ }
1237+
+ else if (menuMode == 3000) {
1238+
+ newMusic = 89;
1239+
+ }
1240+
+ else {
1241+
+ newMusic = MenuLoader.CurrentMenu.Music;
1242+
+ }
1243+
+ if (_isAsyncLoadComplete && newMusic == 50 && !audioSystem.IsTrackPlaying(50)) {
1244+
+ newMusic = 51;
1245+
+ if (musicNoCrossFade[51])
1246+
+ musicFade[51] = 1f;
1247+
+ }
1248+
+ }
1249+
+ else {
1250+
+ newMusic = 0;
1251+
+ }
1252+
+ return;
1253+
+ }*/
1254+
1255+
float num3 = maxTilesX / 4200;
1256+
num3 *= num3;
1257+
@@ -9208,12 +_,18 @@
1258+
if (CreditsRollEvent.IsEventOngoing) {
1259+
newMusic = 89;
1260+
}
1261+
+ else if (modPriority >= SceneEffectPriority.BossHigh) { //Should this be before credits or nah?
1262+
+ newMusic = modMusic;
1263+
+ }
1264+
else if (player[myPlayer].happyFunTorchTime) {
1265+
newMusic = 87;
1266+
}
1267+
else if (flag8) {
1268+
newMusic = 84;
1269+
}
1270+
+ else if (modPriority >= SceneEffectPriority.BossMedium) {
1271+
+ newMusic = modMusic;
1272+
+ }
1273+
else if (flag10) {
1274+
newMusic = 82;
1275+
}
1276+
@@ -9223,6 +_,9 @@
1277+
else if (flag7) {
1278+
newMusic = 85;
1279+
}
1280+
+ else if (modPriority >= SceneEffectPriority.BossLow) {
1281+
+ newMusic = modMusic;
1282+
+ }
1283+
else if (flag15) {
1284+
newMusic = 80;
1285+
}
1286+
@@ -9244,6 +_,9 @@
1287+
else if (flag6) {
1288+
newMusic = 81;
1289+
}
1290+
+ else if (modPriority >= SceneEffectPriority.Event) {
1291+
+ newMusic = modMusic;
1292+
+ }
1293+
else if (flag14) {
1294+
newMusic = 80;
1295+
}
1296+
@@ -9258,6 +_,9 @@
1297+
}
1298+
else if (flag13) {
1299+
newMusic = 82;
1300+
+ }
1301+
+ else if (modPriority >= SceneEffectPriority.Environment) {
1302+
+ newMusic = modMusic;
1303+
}
1304+
else if (eclipse && (double)player[myPlayer].position.Y < worldSurface * 16.0 + (double)(screenHeight / 2)) {
1305+
newMusic = 79;
1306+
@@ -9271,6 +_,9 @@
1307+
else if (num4 < 1f) {
1308+
newMusic = 70;
1309+
}
1310+
+ else if (modPriority >= SceneEffectPriority.BiomeHigh) {
1311+
+ newMusic = modMusic;
1312+
+ }
1313+
else if (tile[(int)(player[myPlayer].Center.X / 16f), (int)(player[myPlayer].Center.Y / 16f)].wall == 87) {
1314+
newMusic = 69;
1315+
}
1316+
@@ -9300,6 +_,9 @@
1317+
else
1318+
newMusic = 75;
1319+
}
1320+
+ else if (modPriority >= SceneEffectPriority.BiomeMedium) {
1321+
+ newMusic = modMusic;
1322+
+ }
1323+
else if (player[myPlayer].ZoneMeteor) {
1324+
newMusic = 79;
1325+
}
1326+
@@ -9315,6 +_,9 @@
1327+
else
1328+
newMusic = 72;
1329+
}
1330+
+ else if (modPriority >= SceneEffectPriority.BiomeLow) {
1331+
+ newMusic = modMusic;
1332+
+ }
1333+
else if ((double)player[myPlayer].position.Y >= worldSurface * 16.0 + (double)(screenHeight / 2) && !WorldGen.oceanDepths((int)(screenPosition.X + (float)(screenWidth / 2)) / 16, (int)(screenPosition.Y + (float)(screenHeight / 2)) / 16)) {
1334+
if (player[myPlayer].ZoneHallow)
1335+
newMusic = 78;
12041336
@@ -9397,7 +_,10 @@
12051337
if (lastMusicPlayed == 50)
12061338
musicNoCrossFade[51] = true;

0 commit comments

Comments
 (0)