Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EM Updates #335

Merged
merged 4 commits into from
May 21, 2022
Merged

EM Updates #335

merged 4 commits into from
May 21, 2022

Conversation

lahm86
Copy link
Collaborator

@lahm86 lahm86 commented May 20, 2022

#333 Improved EM Serialization

Default values will no longer be included in serialized EM data. This applies to standard EM files, along with TR3 secret and boss mappings. All JSON files have been reserialized with this new format. Thanks to @makotocchi and @chreden for assistance with this.

The files are also ordered in the way that the various groups are applied within the actual randomizer classes - purely for reference if looking anything up manually.

#241 TR3 Environment Randomization

All functions have now been implemented for TR3, so for example we can flood/drain rooms and the water surface textures will be handled, raise/lower platforms, move keyholes/slots and their triggers will follow, and so on. Only the logic has been implemented, no actual function data has been added to the JSON files yet.

Other Improvements

The following improvements have also been made for general EM definitions.

Reverse Lookup

Previously for such things as adding reward rooms, we would use short.Max to reference the new room's index. Instead, negative values are now used to reference an item in an array searching backwards. So for example, we might add two rooms within the same set of functions, and want to link them with portals, so we would in that case use -1 and -2 to reference them:

{
  "EMType": 83,
  "Ceiling": {
    "X": 59904,
    "Y": 512,
    "Z": 67072,
    "Room": -1
  },
  "Floor": {
    "X": 59904,
    "Y": 5376,
    "Z": 67072,
    "Room": -2
  }
}

This can be applied to rooms, cameras and entities.

Location Expander

In EMTriggerFunction it's now possible to define one location along with an X and Z value indicating that we want to cover all tiles within that range. This avoids having to specify the location for every sector. So you could specify a location and tell it to go 8 tiles in the +X and 8 in the +Z and hey presto, you have 64 triggers. You can also specify an entire room just by referencing the room number, but there may be times when we only want to cover a portion of the room so the expander can be used in that instance.

EM Triggers

Rather than defining FDTriggerEntry objects in JSON, a new wrapper class is now used - EMTrigger. This takes the basics of what's required to make a trigger and results in much less JSON, as we don't need to specify the various values that are taken care of in FDControl (the actual ushort values, EndData etc). You can set the trigger type, mask, timer, OneShot and SwitchOrKeyRef properties and populate the action list, Another benefit is that the SwitchOrKeyRef and Parameter action properties are signed, so we can use negative values if we wish to reference newly added items.

The comparison below hopefully shows how simple it will be to define triggers going forward. The before section refers to before the introduction of EMTrigger but after the reserialization in relation to #333, rather than referring to the current release. The alternative to this was changing the source in FDControl to add DefaultValue attributes so that the system would know what to ignore when serializing, or further customising the serialization settings to ignore specific values for specific classes, but I don't think either of these approaches would be appropriate.

Before

{
   "EMType": 61,
   "Rooms": [
      155
   ],
   "TriggerEntry": {
      "TrigSetup": {
         "Value": 15872,
         "Mask": 31
      },
      "TrigType": 5,
      "TrigActionList": [
         {
            "Value": 73,
            "Parameter": 73,
            "Continue": true
         },
         {
            "Value": 74,
            "Parameter": 74,
            "Continue": true
         },
         {
            "Value": 8232,
            "Parameter": 40,
            "TrigAction": 8,
            "Continue": true
         }
      ],
      "SwitchKeyContinue": true,
      "Setup": {
         "Value": 1284,
         "Function": 4,
         "ExtendedFunction": 4,
         "SubFunction": 5,
         "H1": 8,
         "H2": 1
      }
   }
}

After

{
   "EMType": 61,
   "Rooms": [
      155
   ],
   "Trigger": {
      "TrigType": 5,
      "Mask": 31,
      "Actions": [
         {
            "Parameter": 73
         },
         {
            "Parameter": 74
         },
         {
            "Action": 8,
            "Parameter": 40
         }
      ]
   }
}

- Tidying of EM serialization output to remove default values.
- New EMTrigger and EMVisibilityPortal wrappers created to allow for simpler definitions.
- Ability to expand locations for triggers - so we can create one anchor location and tell it to extend so many tiles in X/Z directions.
- Rather than short.max being used to reference the last item in a list (rooms, entities etc) we now use negative offsets. So -1 will be the last item, -2 the second to last etc.
- Application order of environment mods adjusted and order defined in the data itself set to match this for ease of reference.
- All environment JSON has been reserialized.
All environment functions are now available for TR3.
Update to EMTrigger to use EMLevelData to convert SwitchOrKeyRef.
@DanzaG DanzaG merged commit 23f9099 into LostArtefacts:master May 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants