Shipwrecks - ilikegoodfood/CommunityLib GitHub Wiki

Shipwrecks

The Community Library implements Shipwrecks as a ruin-like subsettlment that can appear during the course of play. These shipwrecks can be restored to functioning order, if their integrity is high enough, and provided to an empty orc shipyard, at the cost of 40 gold. Alternatively, they can be plundered for loot, which fires an event much like those found in ruins.

The spawning of shipwrecks is disabled in the mod options by default. They can be turned on by players who wish to experience them even with no mods that specifically seek to use them, or they can be force-enabled by a mod that specifically intends to use them.

NOTE: Creating events for shipwrecks, does not require your mnod to be dependent on the Community Library.

Integrity

Rather than exploration percentage, shipwrecks have integrity, initial value range of 40-60, which falls over time (1 per turn). Plundering a shipwreck also damages the shipwreck through the use of the "PLUNDER_SHIPWRECK" event outcome effect.

Reinforcement

Through the use of the "REINFORCE_SHIPWRECK" event outcome effect, a shipwreck can be reinforced, preventing natural decay, and preventing damage from AI agents plundering the wreck. Loss of Integrity caused by the "PLUNDER_SHIPWRECK" event outcome effect still applies.

A shipwreck that has been reinforced cannot be restored for use in a shipyard. This feature is intended to support longer quest chains at shipyards, not as a casual means of making them perminant.

Challenges

By default a wreck has four challenges that can be performed at it.

Recover Shipwreck

Recover ships from the wreck, repair them, and transport them to an empty orc shipyard. Costs 50 gold.

Plunder Shipwreck

Functionally similar to exploring a ruin.

Destroy Shipwreck

Allows a player controlled agent to quickly and cheaply destroy a shipwreck. This may be useful if they do not like the event chain that has appeared there, or hostile AI agents are making use of it.

Lay Low

Shipwrecks serve as an additional, albiet temporary, location in which a player agent may safely lay low.

Functions

In the Community Library's mod kernel (CommunityLib.ModCore) there are two vital functions, these are:

forceShipwrecks

void forceShipwrecks()

When called in a mod's beforeMapGen and afterLoading hooks, this function will enable the default spawn logic for shipwrecks.

spawnShipwreck

void spawnShipwreck(Location location)

When called, this function will place a shipwreck in the settlement at the provided location. If none-exists, it will create a shipwreck settlement, whcih is a subtype of Set_CityRuins, which contains the new shipwreck. This settlement type does not interfere with the ability of nations or orcs to expand to new territory.

If a shipwreck already exists at that location, it will instead increase the shipwrecks identity by between 20 and 30.

removeWreck

void removeWreck(string v = "Shipwreck Degraded to Nothing", object killer = null)

In the Wreck class itself is another vital function. It can be called from any wreck instance, and will immediately remove the shipwreck subsettlement and, only if it is in a shipwreck settlement, the shipwreck settlement that it is part of.

Event Structure

Just like events that are designed for ancient ruins, the events designed for shipwrecks require a certain ID structure and type, and they make use of a fixed environment variable name to handle event chains.

ID

The ID must contain "plunderWreck_" in any portion of the ID string. For example, the following is the ID of the first generic exploration event included in the Community Library:

"id": "CLib.plunderWreck_Generic1",

Image

The default image and Image credits used for shipwreck events in the COmmuntiy Library are as follows:

"imgCredit": "Cornish Shipwreck By Millson Hunt",
"image": "CLib.shipwreck_full.jpg",

This is an 19th century oil painting of a wrecked ship, believed to be on the Cornish COastline of the United Kingdom. Digital images of the painting are outside of copywrite.

Event Type.

Just like with ancient ruins, the event type must be "INERT".

This, combined with the ID, ensures that it will never fire at any other time in the game, and that it can be found by the shipwreck. This also means that it is safe to make events for these shipwrecks without knowing if they will be enabled, or even if the COmmunityLibrary will be present, as they won't do anything if either of those cases are true.

NOTE: Creating events for shipwrecks, does not require your mnod to be dependent on the Community Library.

Environment Variable

Just like ancient ruins, shipwrecks use an envrionment variable to control event chains.

The variable used is FOG_WRECK_ID.

Note: When a shipwreck is detoryed, and a new shipwreck is later placed at the same location, the new shipwreck will reset the environment variable's value to 0.

Event Outcome Effects

  • "CREATE_SHIPWRECK" - This calls the createShipwreck function at the location of the event.
  • "PLUNDER_SHIPWRECK" - This causes integrity damage to the shipwreck at the event's location, destroying it if the shipwreck's integrity reaches 0, by calling the wreck's removeWreck function.
  • "INCREASE_SHIPWRECK_ALLURE" - This increases the allure of the shipwreck, increasing the likelyhood of AI agents to plunder it.
  • "REINFORCE_SHIPRECK" - This sets the value of the reinforced boolean on the shipwreck to the value passed into this effect. If set to true, a shipwreck will no longer decay over time, or suffer damage when an AI agent plunders the wreck, but will also be invalid for restoration and use in an empty orc shipyard.
  • "DESTROY_SHIPWRECK" - This destroyes the shipwreck, using the string value as the cause of destruction in settlement.fallIntoRuin if it needs to also remove a shipwreck settlement.

Example Event:

The following is one of the generic exploration events included in the Community Library:

{
	"id": "CLib.plunderWreck_Generic4",
	"modCredit": "ILikeGoodFood",
	"imgCredit": "Cornish Shipwreck By Millson Hunt",
	"image": "CLib.shipwreck_full.jpg",
	
	"type": "INERT",
	"conditional": "($FOG_WRECK_ID = 0)",
	"probability": 1,

	"name": "Exploring Shipwreck at %LOCATION_NAME",
	"description": "In what remains of the midships, %PERSON_NAME finds a vast pile of ancient clay jars, mostly sealed. They are surrounded by the bodies of the dead, in various states of decay. Should %PERSON_NAME attempt to open the jars, or should they trick others into openning them?\n\n(Agent HP is currently %HP)",


	"choices": [
		{
			"name": "Begin looting",
			"description":"-50% change to gain 100 gold\n\n-25% chance to suffer 2 damage, 75% chance to suffer 5 damage",
			"outcomes": [
			
				{
					"weight": 0.125,
					"description":"%PERSON_NAME carefully examines each jar in turn, only opening those they are certain are safe. They are not always correct, but their caution prevents serious harm from the poisonous gases within.\n(100 gold gained, 2 HP lost)",
					"effects": [
						{"command": "PLUNDER_SHIPWRECK", "argument": "1"},
						{"command": "GAIN_GOLD", "argument": "100"},
						{"command": "ADD_HP", "argument": "-2"}
					]
				},
				{
					"weight": 0.375,
					"description":"%PERSON_NAME carefully examines each jar in turn, only opening those they are certain are safe. While successful at first, their luck doesn't hold, and they are forced to withdraw after inhaling a dangerous amount of poisonous gas.\n(100 gold gained, 5 HP lost)",
					"effects": [
						{"command": "PLUNDER_SHIPWRECK", "argument": "1"},
						{"command": "GAIN_GOLD", "argument": "100"},
						{"command": "ADD_HP", "argument": "-5"}
					]
				},
				{
					"weight": 0.125,
					"description":"%PERSON_NAME carefully examines each jar in turn, only opening those they are certain are safe. They are immediately prooven wrong, but manage to escape the rapidly expanding cloud of poisinous gas without serious harm.\n(2 HP lost)",
					"effects": [
						{"command": "PLUNDER_SHIPWRECK", "argument": "1"},
						{"command": "ADD_HP", "argument": "-2"}
					]
				},
				{
					"weight": 0.375,
					"description":"%Despite their best efforts to differentiate the safe jars from the trapped ones, PERSON_NAME immediately finds themselves engulfed in an expanding cloud of poisonous gas.\n(5 HP lost)",
					"effects": [
						{"command": "PLUNDER_SHIPWRECK", "argument": "1"},
						{"command": "ADD_HP", "argument": "-5"}
					]
				}
			]
		},
		{
			"name": "Trick others into openning the jars",
			"condition":"stat_intrigue > 3",
			"description":"[Requires: 4 Intrigue]\n\nAdds 100 Death Magic to this location.",
			"outcomes": [
			
				{
					"weight": 1,
					"description":"%PERSON_NAME convinces the populace of the nearest settlement that a vast treasure lies unclaimed in the shipwreck at %LOCATION_NAME, and an expedition is sent to retrieve it. None return alive.",
					"effects": [
						{"command": "PLUNDER_SHIPWRECK", "argument": "1"},
						{"command": "ADD_MODIFIER_DEATH", "argument": "100"}
					]
				}
			]
		},
		{
			"name": "Best to leave this place",
			"description":"Escape unharmed, but none the richer.",
			"outcomes": [
			
				{
					"weight": 1,
					"description":"%PERSON_NAME finds themselves empty handed but unharmed after the expedition",
					"effects": [
						{"command": "PLUNDER_SHIPWRECK", "argument": "1"}
					]
				}
			]
		}
	]
}