Skip to content

Commit fbcb7ec

Browse files
committed
Alter Ice Palace ending
Alters the end of Ice Palace if the chicken isn't there so that the enemy drops a puzzle 4 item rather than puzzle 1. Avoids being able to use the other puzzle 1 item.
1 parent 125c8ac commit fbcb7ec

4 files changed

Lines changed: 83 additions & 39 deletions

File tree

TRDataControl/Environment/Model/EMType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public enum EMType
9696
ImportNonGraphicsModel = 145,
9797
CopySpriteSequence = 146,
9898
RemoveStaticCollision = 147,
99+
CloneType = 148,
99100

100101
// NOOP/Placeholder
101102
NOOP = 1000
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using TRLevelControl.Model;
2+
3+
namespace TRDataControl.Environment;
4+
5+
public class EMCloneTypeFunction : BaseEMFunction
6+
{
7+
public Dictionary<uint, uint> ModelMap { get; set; }
8+
public Dictionary<uint, uint> SpriteMap { get; set; }
9+
10+
public override void ApplyToLevel(TR1Level level)
11+
=> Clone(level.Models, level.Sprites);
12+
13+
public override void ApplyToLevel(TR2Level level)
14+
=> Clone(level.Models, level.Sprites);
15+
16+
public override void ApplyToLevel(TR3Level level)
17+
=> Clone(level.Models, level.Sprites);
18+
19+
private void Clone<T>(TRDictionary<T, TRModel> models, TRDictionary<T, TRSpriteSequence> sprites)
20+
where T : Enum
21+
{
22+
Clone(models, ModelMap);
23+
Clone(sprites, SpriteMap);
24+
}
25+
26+
private static void Clone<T, V>(TRDictionary<T, V> levelMap, Dictionary<uint, uint> cloneMap)
27+
where T : Enum
28+
where V : class, ICloneable
29+
{
30+
if (cloneMap == null)
31+
{
32+
return;
33+
}
34+
35+
foreach (var (baseId, targetId) in cloneMap)
36+
{
37+
var baseType = (T)(object)baseId;
38+
var targetType = (T)(object)targetId;
39+
if (levelMap.TryGetValue(baseType, out var value))
40+
{
41+
levelMap[targetType] = (V)value.Clone();
42+
}
43+
}
44+
}
45+
}

TRDataControl/Environment/Parsing/EMConverter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ private object ReadEMType(JObject jo)
127127
EMType.ImportNonGraphicsModel => JsonConvert.DeserializeObject<EMImportNonGraphicsModelFunction>(jo.ToString(), this),
128128
EMType.CopySpriteSequence => JsonConvert.DeserializeObject<EMCopySpriteSequenceFunction>(jo.ToString(), this),
129129
EMType.RemoveStaticCollision => JsonConvert.DeserializeObject<EMRemoveStaticCollisionFunction>(jo.ToString(), this),
130+
EMType.CloneType => JsonConvert.DeserializeObject<EMCloneTypeFunction>(jo.ToString(), this),
130131

131132
// NOOP
132133
EMType.NOOP => JsonConvert.DeserializeObject<EMPlaceholderFunction>(jo.ToString(), this),

TRRandomizerCore/Resources/TR2/Environment/ICECAVE.TR2-Environment.json

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,16 +2276,23 @@
22762276
}
22772277
},
22782278
{
2279-
"Comments": "Convert the CoT slot into an empty one.",
2280-
"EMType": 45,
2281-
"EntityIndex": 10,
2282-
"NewEntityType": 182
2279+
"Comments": "Clone puzzle 1 objects into puzzle 4.",
2280+
"EMType": 148,
2281+
"ModelMap": {
2282+
"178": 181,
2283+
"182": 185,
2284+
"186": 189
2285+
},
2286+
"SpriteMap": {
2287+
"174": 177
2288+
}
22832289
},
22842290
{
2285-
"Comments": "Reposition it to the ladder.",
2286-
"EMType": 44,
2287-
"EntityIndex": 10,
2288-
"TargetLocation": {
2291+
"Comments": "Add a slot4 at the base of the ladder.",
2292+
"EMType": 51,
2293+
"TypeID": 185,
2294+
"Intensity": -1,
2295+
"Location": {
22892296
"X": 62976,
22902297
"Y": 11520,
22912298
"Z": 44544,
@@ -2294,16 +2301,11 @@
22942301
}
22952302
},
22962303
{
2297-
"Comments": "Convert one of the CoT doors into a smaller door.",
2298-
"EMType": 45,
2299-
"EntityIndex": 16,
2300-
"NewEntityType": 108
2301-
},
2302-
{
2303-
"Comments": "Reposition it to the exit.",
2304-
"EMType": 44,
2305-
"EntityIndex": 16,
2306-
"TargetLocation": {
2304+
"Comments": "Add a door.",
2305+
"EMType": 51,
2306+
"TypeID": 108,
2307+
"Intensity": -1,
2308+
"Location": {
23072309
"X": 62976,
23082310
"Y": 7424,
23092311
"Z": 43520,
@@ -2312,37 +2314,32 @@
23122314
}
23132315
},
23142316
{
2315-
"Comments": "Convert one of the CoT doors into a mask.",
2316-
"EMType": 45,
2317-
"EntityIndex": 15,
2318-
"NewEntityType": 174
2319-
},
2320-
{
2321-
"Comments": "The chicken stole it.",
2322-
"EMType": 44,
2323-
"EntityIndex": 15,
2324-
"TargetLocation": {
2325-
"X": 66048,
2326-
"Y": 11520,
2327-
"Z": 41472,
2328-
"Room": 143
2329-
}
2330-
},
2331-
{
2332-
"Comments": "Make a new trigger to open the final door.",
2317+
"Comments": "Make a trigger to open the final door.",
23332318
"EMType": 61,
2334-
"EntityLocation": 10,
2319+
"EntityLocation": -2,
23352320
"Trigger": {
23362321
"TrigType": 3,
23372322
"Mask": 31,
2338-
"SwitchOrKeyRef": 10,
2323+
"SwitchOrKeyRef": -2,
23392324
"Actions": [
23402325
{
2341-
"Parameter": 16
2326+
"Parameter": -1
23422327
}
23432328
]
23442329
}
23452330
},
2331+
{
2332+
"Comments": "Whatever the chicken is will drop a mask.",
2333+
"EMType": 51,
2334+
"TypeID": 177,
2335+
"Intensity": -1,
2336+
"Location": {
2337+
"X": 66048,
2338+
"Y": 11520,
2339+
"Z": 41472,
2340+
"Room": 143
2341+
}
2342+
},
23462343
{
23472344
"Comments": "Move the Talion to the new room.",
23482345
"EMType": 44,

0 commit comments

Comments
 (0)