Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,15 @@ All player commands of the Framework, grouped as in `/help`. `[argument]` is req

| Command | Groups | Description | Feature |
|---|---|---|---|
| `/park` | Default | Make your vehicle spawn here from now on; only the owner or a key holder can. | [Vehicles](features/vehicles.md) |
| `/park` | Default | Make your vehicle spawn here, in this virtual world and interior, from now on; only the owner or a key holder can. | [Vehicles](features/vehicles.md) |
| `/savecar` | Default | Park your currently owned vehicle. Use /savecar to save your vehicle in a new parking spot. | [Vehicles](features/vehicles.md) |

## Ungrouped

| Command | Groups | Description | Feature |
|---|---|---|---|
| `/createvehicle` | Admin | Create a persistent vehicle that can be owned. | [Vehicles](features/vehicles.md) |
| `/deletevehicle [vehicle id]` | Admin | Delete a persistent vehicle for good. Without an id, it deletes the vehicle you sit in, else the nearest saved one within 5 m in your virtual world and interior. | [Vehicles](features/vehicles.md) |
| `/deletevehicle <vehicle id>` | Admin | Delete a persistent vehicle for good. Without an id, it deletes the vehicle you sit in, else the nearest saved one within 5 m in your virtual world and interior. | [Vehicles](features/vehicles.md) |
| `/editvehicle` | Admin | Edit a persistent vehicle that can be owned. | [Vehicles](features/vehicles.md) |
| `/inv` | Default | Open your character's inventory. Use this command to view, manage, and interact with the items you possess. | [Inventories](features/inventories.md) |
| `/inventory` | Default | Open your character's inventory. Use this command to view, manage, and interact with the items you possess. | [Inventories](features/inventories.md) |
Expand Down
11 changes: 9 additions & 2 deletions docs/database.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ Persistent vehicles.
| `IsEngineOn`, `AreLightsOn`, `IsAlarmOn`, `AreDoorsLocked`, `IsBonnetOpen`, `IsBootOpen` | bool | State |
| `Is…DoorOpen`, `Is…WindowClosed` | bool | Per door and window |
| `CurrentHealth`, `MaxHealth` | float | |
| `ServerVehicle` | bool | Belongs to the server, not a player. No database default |
| `ServerVehicle` | bool | Belongs to the server, not a player. Database default false: an older Framework leaves the column out of an insert when it's false. Before, the default was true, so vehicles saved then may be marked as server vehicles by mistake |
| `OwnerCharacterId` | ulong? | → `Characters` |
| `VirtualWorld`, `Interior` | int | The virtual world and the GTA interior the vehicle is in. Default 0 |
| `JurisdictionId` | ulong? | → `Jurisdictions` (set null). Where it's registered; its plate starts with that country's tag. Null = none, an `SA` plate |
Expand Down Expand Up @@ -250,7 +250,14 @@ Table `FishLoot`, with the `DbSet` named `FishSpecies` (`FishLootModel`). Column
- `CatchWeight`: how likely it is, relative to the other possible catches;
- `ItemId` → `Items`.

The Framework seeds 26 rows. Hosts can add their own.
`LootKind`, `SizeClass`, `RequiredFishingLevel` and `IsNetOnly` have database defaults (Fish, None, 0, false), so servers on an older Framework sharing the database can still insert rows.

The Framework seeds ids 1 to 26. Hosts can add their own:
- **Ids from 1000 up.** The Framework may seed more of the low ids later.
- **Remove your own seeds of ids 1 to 26.** Hosts used to seed the fish themselves, and EF refuses two seeds with the same id.
- **Set `SizeClass` on your fish.** A trawl net only brings up Small, Medium and Large fish, so a row left at None is never caught by a net.

**`CatchWeight` used to be `OddsToCatch`**, with the opposite meaning: "1 in N", so a higher number was rarer. Now a higher number is more common. A migration that only renames the column turns rare fish into common ones. Convert your own rows, for example with `UPDATE FishLoot SET CatchWeight = GREATEST(1, ROUND(100 / CatchWeight))`, or set new weights.

Table `VehicleFishingNets` (`VehicleFishingNetModel`) holds the nets fitted to Reefers:
- `VehicleId` → `Vehicles` (cascade, unique);
Expand Down
4 changes: 3 additions & 1 deletion docs/features/fishing.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ The driver's fishing level decides the result, and the driver gets the experienc
- **"Use" wears out a rod.** Choosing Use on a rod in the inventory costs one use, like any item with a use limit.
- **Fish lost at sea.** A catch that doesn't fit lands below you, which from a boat is the sea floor.
- **Long catches.** `/netstorage` lists the first 50 fish, because a dialog holds a limited amount of text.
- **Net-only fish are stuck in the net.** They weigh 25 kg or more, and a character carries 10 kg, so they can't be taken out. A net with fish in it can't be removed with `/removenet`, so such a net stays on the Reefer until the vehicle is deleted.

## Deep dive

Expand All @@ -94,7 +95,8 @@ The driver's fishing level decides the result, and the driver gets the experienc
- `IFishHotspotService`: places and moves hotspots;
- `IFishingNetService` and `IFishingNetManager`: fitted nets and their storage;
- `ITrawlService`: the trawl;
- `IFishingNetDialogService`: the storage dialog.
- `IFishingNetDialogService`: the storage dialog. Each answer checks again that the player is still at the Reefer, still playing their character and still allowed to use the net.
- **Systems:** `FishingNetServerSystem` deletes the net of a deleted vehicle on [`OnVehicleDeleted`](../server-events.md#onvehicledeleted).
- **Water zones:** `Helpers/WaterTypeHelper`.
- **Skill:** the host seeds a skill named `Fishing`. Without it, players stay at level 0.
- **Tables:** [`FishLoot` and `VehicleFishingNets`](../database.md#fishing). The Framework seeds the catch table and its items.
Expand Down
2 changes: 1 addition & 1 deletion docs/features/radios.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Two-way radios on numbered frequencies: a handheld radio item, and a radio an ad
| `/giveearpiece [player]` | Admin | Gives the player a radio earpiece |
| `/editfrequencies` | Admin | Creates protected and encrypted frequencies and picks their factions. See [Frequencies](radios/frequencies.md) |

**Vehicle radios:** an admin sets the **Radio** row in [`/createvehicle` or `/editvehicle`](vehicles.md). Everyone inside can then use `/radio`, `/freq` and `/r`.
**Vehicle radios:** an admin sets the **Radio** row in [`/createvehicle` or `/editvehicle`](vehicles.md). Everyone inside can then use `/radio`, `/freq` and `/r`. Deleting the vehicle removes its radio too, on [`OnVehicleDeleted`](../server-events.md#onvehicledeleted).

## Who can use a frequency

Expand Down
10 changes: 6 additions & 4 deletions docs/features/vehicles.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Persistent vehicles: saved in the database, spawned at startup, started with a k
| `/repairvehicle`, `/fixveh` | Admin | Repairs the vehicle to full health. See [Repairing](#repairing) |
| `/createvehicle` | Admin | Creates a vehicle in front of you, in the [vehicle editor](vehicles/editor.md) |
| `/editvehicle` | Admin | Edits the vehicle you're in, in the [vehicle editor](vehicles/editor.md) |
| `/deletevehicle [vehicle id]` | Admin | Deletes a saved vehicle for good, after you confirm. Without an id, see [Deleting a vehicle](#deleting-a-vehicle) |
| `/deletevehicle <vehicle id>` | Admin | Deletes a saved vehicle for good, after you confirm. Without an id, see [Deleting a vehicle](#deleting-a-vehicle) |

Without a key: [Hotwire](hotwire.md). Turn signals: [Turn signals](vehicles/indicators.md). Temporary vehicles: `/sv` ([Admins](admins.md)).

Expand Down Expand Up @@ -51,7 +51,7 @@ Locking a locked vehicle says "The doors are already locked."

## Parking

`/park` and `/savecar` set the spot where the vehicle spawns from now on. Only the owner or a key holder can do it, and admins too. You must be in the driver's seat.
`/park` and `/savecar` set the spot where the vehicle spawns from now on, including your virtual world and interior, so a car parked inside a building stays there. Only the owner or a key holder can do it, and admins too. You must be in the driver's seat.

| Who | Saved vehicle | Server vehicle |
|---|---|---|
Expand Down Expand Up @@ -93,10 +93,12 @@ Temporary `/sv` vehicles can't be parked.
`/deletevehicle` (Admin) deletes a saved vehicle for good. With an id, it deletes that vehicle. Without one, it deletes the vehicle you sit in, else the nearest saved vehicle within 5 m of its body, in your virtual world and interior. If there's none, it says so. It then asks you to confirm. On Delete it:

- deletes the vehicle's row;
- removes its radio, and the vehicle keys that are loaded in the game;
- removes its [fishing net](fishing.md#reefer-net), with the net's storage and the fish in it;
- removes the vehicle keys that are loaded in the game;
- publishes [`OnVehicleDeleted`](../server-events.md#onvehicledeleted): its radio is removed, and its [fishing net](fishing.md#reefer-net) with the net's storage and the fish in it;
- ejects the people inside, and destroys the vehicle in the world.

**Why an event:** the radio and the net belong to other features, which clean up after themselves instead of Vehicles reaching into them.

Keys in the inventories of offline characters aren't removed (see the known limitations). A temporary `/spawnveh` vehicle has no row, so the command refuses it.

## Known limitations
Expand Down
1 change: 1 addition & 0 deletions docs/server-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public void OnCharacterSelected(OnCharacterSelectedEventArgs args, ISkillService
| <a id="onresourceharvested"></a>`OnResourceHarvested` | a player harvested a resource | [Harvestables](features/harvestables.md) | nothing yet: for gamemodes to give rewards |
| <a id="onfishcaught"></a>`OnFishCaught` | a player brought up a fish, junk or a treasure, with a rod or a net (`Loot`, `WeightInGrams`, `Method`) | [Fishing](features/fishing.md) | nothing yet: for gamemodes to give rewards |
| <a id="onpropertydeleted"></a>`OnPropertyDeleted` | an admin deleted a property | [Properties](features/properties.md) | [Actors](features/actors.md) (actors inside it move outside) |
| <a id="onvehicledeleted"></a>`OnVehicleDeleted` | an admin deleted a saved vehicle; its row is already gone (`VehicleId`). The loaded vehicle is destroyed right after publishing, so do your work before any `await` in the handler | [Vehicles](features/vehicles.md) | [Radios](features/radios.md) (forget its radio), [Fishing](features/fishing.md) (delete its net, storage and fish) |
| <a id="onjurisdictionsloaded"></a>`OnJurisdictionsLoaded` | the jurisdictions were loaded at startup | [Jurisdictions](features/jurisdictions.md) | [Vehicles](features/vehicles.md) (set plates again) |
| <a id="onjurisdictionplatetagchanged"></a>`OnJurisdictionPlateTagChanged` | a jurisdiction's tags changed, or it moved to another country | [Jurisdictions](features/jurisdictions.md) | [Vehicles](features/vehicles.md) (set plates again) |
| <a id="onjurisdictiongovernmentchanged"></a>`OnJurisdictionGovernmentChanged` | a jurisdiction got another government of its own (old and new faction id, null = none) | [Jurisdictions](features/jurisdictions.md) | nothing yet: for police, laws and taxes later |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ public MaxMonthlyFeeSetting(IJurisdictionService jurisdictionService, ICurrencyS

public override string Name => "Bank account fee cap";

public override string Prompt => "Enter the highest monthly fee a bank in this jurisdiction may charge per account, from 0 to 10,000:";
public override string Prompt => "Enter the highest monthly fee a bank in this jurisdiction may charge per account, from 0 to 10000:";

public override decimal Default => BankingRules.DefaultMaxMonthlyFee;

protected override string? TryParse(string input, Jurisdiction jurisdiction, out decimal value)
{
decimal? fee = BankAmounts.ParseFee(input, BankingRules.HighestMaxMonthlyFee);
value = fee ?? 0;
return fee.HasValue ? null : "The fee is an amount from 0 to 10,000, with at most 2 decimals.";
return fee.HasValue ? null : "The fee is an amount from 0 to 10000, with at most 2 decimals and no thousands separators.";
}

public override string Format(decimal value, Jurisdiction jurisdiction)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore;
using OpenRP.Framework.Database.Models;
using OpenRP.Framework.Features.Fishing.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -39,17 +40,22 @@ public void Configure(EntityTypeBuilder<FishLootModel> builder)
builder.Property(f => f.CatchWeight)
.IsRequired();

// Database defaults, so servers on an older Framework sharing the database can still insert rows.
builder.Property(f => f.LootKind)
.IsRequired();
.IsRequired()
.HasDefaultValue(FishLootKind.Fish);

builder.Property(f => f.SizeClass)
.IsRequired();
.IsRequired()
.HasDefaultValue(FishSizeClass.None);

builder.Property(f => f.RequiredFishingLevel)
.IsRequired();
.IsRequired()
.HasDefaultValue(0u);

builder.Property(f => f.IsNetOnly)
.IsRequired();
.IsRequired()
.HasDefaultValue(false);

// Configure the relationship with ItemModel.
builder.HasOne(f => f.Item)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class FishingNetDialogService : IFishingNetDialogService
{
private const string DialogTitle = "Net Storage";
private const string LeftTheBoatError = "You moved too far away from the Reefer.";
private const string NoLongerAllowedError = "You can no longer use the net of this Reefer.";

private readonly IDialogService _dialogService;
private readonly IFishingNetService _fishingNetService;
Expand Down Expand Up @@ -163,17 +164,24 @@ private void PutFish(Player player, Vehicle reefer, VehicleFishingNet net, Inven
}

/// <summary>
/// The player can walk off, or the net can be removed, while a dialog is open.
/// While a dialog is open the player can walk off, stop playing their character or lose their key, and the
/// net can be removed.
/// </summary>
private bool CanStillUseNet(Player player, Vehicle reefer, VehicleFishingNet net)
{
if (net.IsComponentAlive && !net.IsDeleted() && _fishingNetService.IsPlayerAtVehicle(player, reefer))
if (!net.IsComponentAlive || net.IsDeleted() || !_fishingNetService.IsPlayerAtVehicle(player, reefer))
{
return true;
player.SendPlayerInfoMessage(PlayerInfoMessageType.ERROR, LeftTheBoatError);
return false;
}

player.SendPlayerInfoMessage(PlayerInfoMessageType.ERROR, LeftTheBoatError);
return false;
if (!_fishingNetService.CanUseNetOf(player, reefer))
{
player.SendPlayerInfoMessage(PlayerInfoMessageType.ERROR, NoLongerAllowedError);
return false;
}

return true;
}

private static void SendMoveResult(Player player, string? error, string successMessage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void AddFishingExperience(Player player, uint experience)
return _entityManager.GetComponent<Item>(ItemEntities.GetItemId((int)loot.ItemId));
}

public async void PublishFishCaught(Player player, FishLootModel loot, uint weightInGrams, FishCatchMethod method)
public async Task PublishFishCaught(Player player, FishLootModel loot, uint weightInGrams, FishCatchMethod method)
{
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ public void FitNet(Player player)
}

ulong vehicleId = reefer!.GetComponent<VehicleDataComponent>()!.VehicleData.Id;
player.GetPlayerCurrentlyPlayingAsCharacter().GetInventory()!.TakeItem(GetNetItem()!, 1);
Inventory storage = _inventoryManager.CreateInventory($"Fishing Net of Vehicle {vehicleId}", FishingSettings.NetStorageMaxWeightInGrams);
_fishingNetManager.CreateNet(vehicleId, storage.GetId());
// Taken only once the net exists: creating it saves to the database and can fail.
player.GetPlayerCurrentlyPlayingAsCharacter().GetInventory()!.TakeItem(GetNetItem()!, 1);
// Saved now, like the net itself: a crash must not leave the player with both the item and a fitted net.
_inventoryItemManager.SaveNow();
player.SendPlayerInfoMessage(PlayerInfoMessageType.INFO, "The net is fitted. Use /trawl while driving to lower it, and /netstorage to see the catch.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ private void GiveCatch(Player player, FishLootModel loot)
_chatService.SendPlayerChatMessage(player, PlayerChatMessageType.ME, $"reels in the line and pulls up: {loot.Name}.");
SendCatchMessage(player, loot, weightInGrams, isInInventory);
_fishService.AddFishingExperience(player, _fishService.GetExperienceForCatch(loot));
_fishService.PublishFishCaught(player, loot, weightInGrams, FishCatchMethod.Rod);
_ = _fishService.PublishFishCaught(player, loot, weightInGrams, FishCatchMethod.Rod);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ public interface IFishService
/// <summary>
/// Tells other features that the player brought something up.
/// </summary>
void PublishFishCaught(Player player, FishLootModel loot, uint weightInGrams, FishCatchMethod method);
Task PublishFishCaught(Player player, FishLootModel loot, uint weightInGrams, FishCatchMethod method);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private int StoreCatches(Player player, Inventory storage, IReadOnlyList<FishLoo

storedFish++;
experience += _fishService.GetExperienceForCatch(loot);
_fishService.PublishFishCaught(player, loot, weightInGrams, FishCatchMethod.Net);
_ = _fishService.PublishFishCaught(player, loot, weightInGrams, FishCatchMethod.Net);
}

if (experience > 0)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using OpenRP.Framework.Features.Fishing.Services;
using OpenRP.Framework.Shared.ServerEvents.Attributes;
using OpenRP.Framework.Shared.ServerEvents.Entities;
using OpenRP.Framework.Shared.ServerEvents.Entities.EventArgs;

namespace OpenRP.Framework.Features.Fishing.Systems
{
public class FishingNetServerSystem : IServerSystem
{
/// <summary>
/// The net's row went with the vehicle (cascade), but its storage and the fish in it did not.
/// </summary>
[ServerEvent]
public void OnVehicleDeleted(OnVehicleDeletedEventArgs args, IFishingNetService fishingNetService)
{
fishingNetService.RemoveNetOfDeletedVehicle(args.VehicleId);
}
}
}
Loading
Loading