This object is in archive! 

[ModAPI] Add Missing Contract APIs and Interfaces

tuks shared this feedback 2 years ago
Under Consideration

While working on custom contracts I've noticed some missing interfaces, so starting this ticket to collect all of them in hopes this might get added in a patch at some point :)

bits that seem to have been missed in the implementation:

  • there's no IMyContractBlock interface (leading to some weird workarounds like `block?.FatBlock?.BlockDefinition.SubtypeId.Contains("ContractBlock")` for looking them up e.g.). This also leads to there being no way to clean up contracts if a mod adding them looses the reference for some reason (or even to delete existing/vanilla contracts if you want custom behaviour e.g.) because there's no access to 'getAvailableContracts' (even having it in `MyAPIGateway.ContractSystem` would be nice). In general i was expecting something akin to the IMyStoreBlock to be available.
  • Contract Type names are not read at all, even when a `.resx` file is created and show up as `LocalizationKey_..`, the current workaround being forcing a load in the mods session component's Load method (`VRage.MyTexts.LoadTexts(modContext.ModPath);`)
  • Icons and Header Images are also not loaded when defining an MyObjectBuilder_ContractTypeDefinition in sbc, the current workaround being creating an sbc with dummy `MyObjectBuilder_PhysicalItemDefinition`s that contain an Icon for Header and Contract Icon each so that they get loaded (consequently the Icon and Header in the contracts.sbc are respected and rendered). e.g.

<PhysicalItem xsi:type="MyObjectBuilder_PhysicalItemDefinition"> <Id> <TypeId>PhysicalObject</TypeId> <SubtypeId>IconBuffer_Bounty</SubtypeId> </Id> <DisplayName>IconBuffer_Bounty</DisplayName> <Description>IconBuffer_Bounty</Description> <Icon>Textures\GUI\Icons\Contracts\NPCBountyContract.dds</Icon> <Public>false</Public> <CanPlayerOrder>false</CanPlayerOrder> <CanSpawnFromScreen>false</CanSpawnFromScreen> </PhysicalItem> <PhysicalItem xsi:type="MyObjectBuilder_PhysicalItemDefinition"> <Id> <TypeId>PhysicalObject</TypeId> <SubtypeId>HeaderBuffer_Bounty</SubtypeId> </Id> <DisplayName>HeaderBuffer_Bounty</DisplayName> <Description>HeaderBuffer_Bounty</Description> <Icon>Textures\GUI\Icons\Contracts\NPCBountyContractHeader.dds</Icon> <Public>false</Public> <CanPlayerOrder>false</CanPlayerOrder> <CanSpawnFromScreen>false</CanSpawnFromScreen> </PhysicalItem>

additionally it would be nice to have:

  • an IMyStation interface (to use existing or even use the vanilla interface for mods using the concept of MyStation)
  • a way to access `Stations`, seeing as they get spawned based on player vicinity (and iirc despawn in certain situations?), so keeping track of them in a mod can be unreliable/and or lead to crashes (currently I turn vanilla economy off when i have custom contracts on and have no way to interact properly with the vanilla system)
  • the contract block's type filter loads all definitions. would be really nice to be able to have certain stations only show certain contracts, but at least to have an 'enabled' property/respect the 'enabled' flag from MyDefinitionManager.Static definitions and have certain types disabled in a save. Currently this just creates dead categories for types that are not being used.

Replies (3)

photo
11

This should be unarchived and reconsidered.

photo
4

Please fix this issue so we can have custom contracts. It would be really awesome if you would allow custom contracts to also have different rewards not just credits(example tier 4 tools or high end components like super conductors or thruster components or maybe top tier ore and ingots or even custom ships.

photo
3

Cleaning up and enhancing the interface would definitely be appreciated.

Paul, custom rewards are already possible; in the OnContractSucceeded event of a custom contract you could modders could do... almost anything. Upgrading tools in the player's inventory certainly would be possible, or dropping a few bonus items in (assuming they have space). And yes you could even spawn a grid (prefab or otherwise) and assign ownership to the player, if you wanted to be so generous! Topping up a ship's fuel or adding cargo is a neat idea as well but a bit more complicated, The issue would be somehow selecting the right grid to add fuel/cargo to. While you could search all the player's owned grids, maybe pick the closest, or check to see if they own any grids that are currently connected to the same grid the contract block is on, it's a cool concept and possible but may be a bit prone to unexpected issues ... sometimes cash is king

photo
photo
3

Please allow us to retrieve contracts as Patrick has suggested. Trying to create your own XML based tracking files and keep track of contracts is a major headache and not very reliable :(

Leave a Comment
 
Attach a file