hanf wachstum
This commit is contained in:
@@ -12,7 +12,29 @@ const hanfPlantObjects = {
|
|||||||
stage4: mp.game.joaat('prop_weed_01')
|
stage4: mp.game.joaat('prop_weed_01')
|
||||||
};
|
};
|
||||||
|
|
||||||
const minimumPlantDistance = 5;
|
const hanfTimeToObject = [
|
||||||
|
{
|
||||||
|
minutes: 15,
|
||||||
|
object: hanfPlantObjects.stage1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
minutes: 60 * 1,
|
||||||
|
object: hanfPlantObjects.stage2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
minutes: 60 * 3,
|
||||||
|
object: hanfPlantObjects.stage3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
minutes: 60 * 4,
|
||||||
|
object: hanfPlantObjects.stage4
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
const minimumPlantDistance = 2;
|
||||||
|
|
||||||
|
const maximumPlantDuration = 6 * 60 * 60 * 1000; // 6 Stunden / 360 Minuten / 21600 Sekunden / 21600000 Millisekunden
|
||||||
|
const timeToHarvestPlant = 4 * 60 * 60 * 1000; // 4 Stunden
|
||||||
|
|
||||||
export default function hanfSystem(globalData: IGlobalData) {
|
export default function hanfSystem(globalData: IGlobalData) {
|
||||||
|
|
||||||
@@ -128,13 +150,13 @@ export default function hanfSystem(globalData: IGlobalData) {
|
|||||||
function isAbleToPlant() {
|
function isAbleToPlant() {
|
||||||
var player = mp.players.local;
|
var player = mp.players.local;
|
||||||
|
|
||||||
if (isNearPlant()) {
|
if (isNearPlant(minimumPlantDistance)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isSurfaceAllowed()) {
|
//if (!isSurfaceAllowed()) {
|
||||||
return false;
|
// return false;
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (currentPlantingPreviewObject) {
|
if (currentPlantingPreviewObject) {
|
||||||
var objectPos = getPlantPreviewPosition();
|
var objectPos = getPlantPreviewPosition();
|
||||||
@@ -144,7 +166,7 @@ export default function hanfSystem(globalData: IGlobalData) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.isSwimming() || player.isSwimmingUnderWater() || !player.isOnFoot()) {
|
if (player.isSwimming() || player.isSwimmingUnderWater() || !player.isOnFoot() || player.isSprinting() || player.isShooting()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +190,19 @@ export default function hanfSystem(globalData: IGlobalData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
KeyBinder.bind('e', _ => {
|
KeyBinder.bind('e', _ => {
|
||||||
if (!currentlyPlanting || globalData.InChat) {
|
if (globalData.InChat) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!currentlyPlanting) {
|
||||||
|
var nearPlant = isNearPlant(0.5);
|
||||||
|
|
||||||
|
if (!nearPlant) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mp.events.callRemote("CLIENT:Hanf_HarvestHanf", nearPlant.Id);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,52 +217,128 @@ export default function hanfSystem(globalData: IGlobalData) {
|
|||||||
|
|
||||||
if (currentPlantingPreviewObject) {
|
if (currentPlantingPreviewObject) {
|
||||||
currentPlantingPreviewObject.destroy();
|
currentPlantingPreviewObject.destroy();
|
||||||
|
currentPlantingPreviewObject = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentPlantingMarkerPreview) {
|
if (currentPlantingMarkerPreview) {
|
||||||
currentPlantingMarkerPreview.destroy();
|
currentPlantingMarkerPreview.destroy();
|
||||||
|
currentPlantingMarkerPreview = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var position = getPlantPreviewPosition();
|
var position = getPlantPreviewPosition();
|
||||||
var realZ = mp.game.gameplay.getGroundZFor3dCoord(position.x, position.y, position.z + 2, 0, false);
|
var realZ = mp.game.gameplay.getGroundZFor3dCoord(position.x, position.y, position.z + 2, 0, false);
|
||||||
|
|
||||||
mp.events.callRemote("CLIENT:Hanf_PlantHanf", position.x, position.z, realZ);
|
mp.events.callRemote("CLIENT:Hanf_PlantHanf", position.x, position.y, realZ);
|
||||||
});
|
});
|
||||||
|
|
||||||
function getPlantPreviewPosition(): Vector3Mp {
|
function getPlantPreviewPosition(): Vector3Mp {
|
||||||
return mp.players.local.getOffsetFromInWorldCoords(0, 0.2, -1);
|
return mp.players.local.getOffsetFromInWorldCoords(0, 0.2, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isNearPlant(): boolean {
|
function getPlantText(plant: CannabisData) {
|
||||||
var position = getPlantPreviewPosition();
|
var time = Date.now() - Date.parse(plant.Time);
|
||||||
var nearPlant = false;
|
if (time > maximumPlantDuration) {
|
||||||
|
return ("~g~Hanf~n~~r~Verrottet");
|
||||||
Object.keys(hanfPlantObjects).forEach(k => {
|
|
||||||
var hash = hanfPlantObjects[k];
|
|
||||||
var obj = mp.game.object.getClosestObjectOfType(position.x, position.y, position.z, minimumPlantDistance, hash, false, false, false);
|
|
||||||
if (obj && obj != currentPlantingPreviewObject.handle) {
|
|
||||||
nearPlant = true;
|
|
||||||
}
|
}
|
||||||
});
|
return (`~g~Hanf~n~Fortschritt: ${getPlantPercentage(plant).toFixed(2)}%`);
|
||||||
|
|
||||||
return nearPlant;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let currentHanfData: Array<CannabisData> = null;
|
function getPlantPercentage(plant: CannabisData) {
|
||||||
let hanfDataIdToObjectMap: Map<number, ObjectMp> = null;
|
var time = Date.now() - Date.parse(plant.Time);
|
||||||
|
return Math.min((time / timeToHarvestPlant) * 100, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isNearPlant(distance: number): CannabisData {
|
||||||
|
var pos = getPlantPreviewPosition();
|
||||||
|
var nearPlants = currentHanfData.filter(h =>
|
||||||
|
mp.game.gameplay.getDistanceBetweenCoords(pos.x, pos.y, pos.z, h.X, h.Y, h.Z, true) < distance);
|
||||||
|
|
||||||
|
if (!nearPlants || nearPlants.length == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
nearPlants = nearPlants.sort((a, b) =>
|
||||||
|
Number(mp.game.gameplay.getDistanceBetweenCoords(pos.x, pos.y, pos.z, a.X, a.Y, a.Z, true) <
|
||||||
|
mp.game.gameplay.getDistanceBetweenCoords(pos.x, pos.y, pos.z, b.X, b.Y, b.Z, true)));
|
||||||
|
|
||||||
|
return nearPlants[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
let currentHanfData: Array<CannabisData> = [];
|
||||||
|
let hanfDataIdToObjectMap: Map<number, ObjectMp> = new Map<number, ObjectMp>();
|
||||||
|
let hanfDataIdToTextLabelMap: Map<number, TextLabelMp> = new Map<number, TextLabelMp>();
|
||||||
|
|
||||||
mp.events.add("SERVER:Hanf_UpdateHanfData", dataJson => {
|
mp.events.add("SERVER:Hanf_UpdateHanfData", dataJson => {
|
||||||
|
mp.console.logInfo(dataJson);
|
||||||
var data: Array<CannabisData> = <Array<CannabisData>>JSON.parse(dataJson)
|
var data: Array<CannabisData> = <Array<CannabisData>>JSON.parse(dataJson)
|
||||||
if (currentHanfData == null) {
|
|
||||||
currentHanfData = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
var newPlants = data.filter(d => currentHanfData.filter(x => x.id === d.id).length == 0);
|
var newPlants = data.filter(d => currentHanfData.filter(x => x.Id === d.Id).length == 0);
|
||||||
var removedPlants = currentHanfData.filter(d => data.filter(x => x.id === d.id).length == 0);
|
var removedPlants = currentHanfData.filter(d => data.filter(x => x.Id === d.Id).length == 0);
|
||||||
var existingPlants = data.filter(d => currentHanfData.filter(x => x.id === d.id).length == 1);
|
var existingPlants = data.filter(d => currentHanfData.filter(x => x.Id === d.Id).length == 1);
|
||||||
|
|
||||||
mp.gui.chat.push(`new: ${newPlants.length}, removed: ${removedPlants.length}, existing: ${existingPlants.length}`);
|
mp.gui.chat.push(`new: ${newPlants.length}, removed: ${removedPlants.length}, existing: ${existingPlants.length}`);
|
||||||
|
|
||||||
|
newPlants.forEach(plant => {
|
||||||
|
var model = getPlantModel(plant);
|
||||||
|
mp.gui.chat.push("new id: " + plant.Id + ", model = " + model);
|
||||||
|
var object = mp.objects.new(getPlantModel(plant), new mp.Vector3(plant.X, plant.Y, plant.Z));
|
||||||
|
hanfDataIdToObjectMap.set(plant.Id, object);
|
||||||
|
|
||||||
|
var textLabel = mp.labels.new(getPlantText(plant), new mp.Vector3(plant.X, plant.Y, plant.Z + 1), {
|
||||||
|
los: true,
|
||||||
|
drawDistance: 2
|
||||||
|
});
|
||||||
|
hanfDataIdToTextLabelMap.set(plant.Id, textLabel);
|
||||||
|
});
|
||||||
|
|
||||||
|
removedPlants.forEach(plant => {
|
||||||
|
//mp.gui.chat.push("removed id: " + plant.Id);
|
||||||
|
var object = hanfDataIdToObjectMap.get(plant.Id);
|
||||||
|
hanfDataIdToObjectMap.delete(plant.Id);
|
||||||
|
object.destroy();
|
||||||
|
var textLabel = hanfDataIdToTextLabelMap.get(plant.Id);
|
||||||
|
textLabel.destroy();
|
||||||
|
hanfDataIdToTextLabelMap.delete(plant.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
existingPlants.forEach(plant => {
|
||||||
|
//mp.gui.chat.push("existing plant: " + plant.Id + ", plant time = " + new Date(plant.Time).toLocaleTimeString() + ", current time = " + new Date().toLocaleTimeString());
|
||||||
|
var object = hanfDataIdToObjectMap.get(plant.Id);
|
||||||
|
var model = getPlantModel(plant);
|
||||||
|
if (model != object.model) {
|
||||||
|
//mp.gui.chat.push("existing plant: " + plant.Id + ", changing model to = " + model);
|
||||||
|
object.destroy();
|
||||||
|
var object = mp.objects.new(model, new mp.Vector3(plant.X, plant.Y, plant.Z));
|
||||||
|
hanfDataIdToObjectMap.delete(plant.Id);
|
||||||
|
hanfDataIdToObjectMap.set(plant.Id, object);
|
||||||
|
}
|
||||||
|
|
||||||
|
var textLabel = hanfDataIdToTextLabelMap.get(plant.Id);
|
||||||
|
textLabel.text = getPlantText(plant);
|
||||||
|
});
|
||||||
|
|
||||||
currentHanfData = data;
|
currentHanfData = data;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function getPlantModel(plant: CannabisData): number {
|
||||||
|
var diff = Date.now() - Date.parse(plant.Time);
|
||||||
|
var model = -1;
|
||||||
|
|
||||||
|
var dbgTxt;
|
||||||
|
|
||||||
|
if (diff <= 30 * 60 * 1000) { // 0 - 30 Minuten
|
||||||
|
model = hanfPlantObjects.stage1;
|
||||||
|
dbgTxt = "30 Minuten";
|
||||||
|
} else if (diff <= 4 * 60 * 60 * 1000) { // 30 - 240 Minuten / 4 Stunden
|
||||||
|
model = hanfPlantObjects.stage3;
|
||||||
|
dbgTxt = "3 Stunden";
|
||||||
|
} else { // Ausgewachsen / Ab 4 Stunden
|
||||||
|
model = hanfPlantObjects.stage4;
|
||||||
|
dbgTxt = "4 Stunden";
|
||||||
|
}
|
||||||
|
|
||||||
|
//mp.gui.chat.push("plant id = " + plant.Id + ", age = " + dbgTxt);
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -168,5 +168,5 @@ export {
|
|||||||
EntityType,
|
EntityType,
|
||||||
AccountData,
|
AccountData,
|
||||||
VehicleData,
|
VehicleData,
|
||||||
DoorState
|
DoorState,
|
||||||
}
|
}
|
||||||
10
ReallifeGamemode.Client/global.d.ts
vendored
10
ReallifeGamemode.Client/global.d.ts
vendored
@@ -98,11 +98,11 @@ declare type RentcarProperty = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
declare type CannabisData = {
|
declare type CannabisData = {
|
||||||
id: number;
|
Id: number;
|
||||||
x: number;
|
X: number;
|
||||||
y: number;
|
Y: number;
|
||||||
z: number;
|
Z: number;
|
||||||
time: Date;
|
Time: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare type PlayerCharacterData = {
|
declare type PlayerCharacterData = {
|
||||||
|
|||||||
@@ -3391,6 +3391,19 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
ChatService.SendMessage(player, "~b~[ADMIN]~s~ Die Türen wurden erfolgreich neugeladen.");
|
ChatService.SendMessage(player, "~b~[ADMIN]~s~ Die Türen wurden erfolgreich neugeladen.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Command("reloadhanf", "~m~Benutzung: ~s~/reloadhanf")]
|
||||||
|
public void CmdAdminReloadHanf(Player player)
|
||||||
|
{
|
||||||
|
if (!player.GetUser().IsAdmin(AdminLevel.HEADADMIN))
|
||||||
|
{
|
||||||
|
ChatService.NotAuthorized(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HanfManager.UpdateHanfWorldData(new DatabaseContext());
|
||||||
|
ChatService.SendMessage(player, "~b~[ADMIN]~s~ Die Hanfpflanzen wurden erfolgreich neugeladen.");
|
||||||
|
}
|
||||||
|
|
||||||
//[Command("house", "~m~Benutzung: ~s~/house [add / remove / price / type / reloadhouses]", GreedyArg = true)]
|
//[Command("house", "~m~Benutzung: ~s~/house [add / remove / price / type / reloadhouses]", GreedyArg = true)]
|
||||||
//public void CmdAdminHouse(Player player, string option1 = null, string option2 = null)
|
//public void CmdAdminHouse(Player player, string option1 = null, string option2 = null)
|
||||||
//{
|
//{
|
||||||
|
|||||||
@@ -88,8 +88,6 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
NAPI.World.RequestIpl("ferris_finale_Anim"); // Riesenrad
|
NAPI.World.RequestIpl("ferris_finale_Anim"); // Riesenrad
|
||||||
NAPI.World.RequestIpl("Carwash_with_spinners"); // Carwash
|
NAPI.World.RequestIpl("Carwash_with_spinners"); // Carwash
|
||||||
|
|
||||||
HanfManager.UpdateHanfForPlayer(player);
|
|
||||||
|
|
||||||
TimeSpan currentTime = TimeManager.CurrentTime;
|
TimeSpan currentTime = TimeManager.CurrentTime;
|
||||||
bool disableLightMode = currentTime > LightModeTimeFrom && currentTime < LightModeTimeTo;
|
bool disableLightMode = currentTime > LightModeTimeFrom && currentTime < LightModeTimeTo;
|
||||||
|
|
||||||
|
|||||||
@@ -115,6 +115,8 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
ChatService.BroadcastGroup(msg, user.Group);
|
ChatService.BroadcastGroup(msg, user.Group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HanfManager.UpdateHanfForPlayer(player);
|
||||||
|
|
||||||
string message = string.Empty;
|
string message = string.Empty;
|
||||||
|
|
||||||
if (GlobalHelper.CustomJoinMessages.ContainsKey(player.SocialClubName))
|
if (GlobalHelper.CustomJoinMessages.ContainsKey(player.SocialClubName))
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using ReallifeGamemode.Server.Extensions;
|
|||||||
using ReallifeGamemode.Server.Util;
|
using ReallifeGamemode.Server.Util;
|
||||||
using System;
|
using System;
|
||||||
using ReallifeGamemode.Database.Entities.Logs;
|
using ReallifeGamemode.Database.Entities.Logs;
|
||||||
|
using ReallifeGamemode.Server.Managers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @overview Life of German Reallife - Event Register (Register.cs)
|
* @overview Life of German Reallife - Event Register (Register.cs)
|
||||||
@@ -83,6 +84,8 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
player.SafeTeleport(new Vector3(402.8664, -996.4108, -99.00027));
|
player.SafeTeleport(new Vector3(402.8664, -996.4108, -99.00027));
|
||||||
//player.Position = new Vector3(user.PositionX, user.PositionY, user.PositionZ);
|
//player.Position = new Vector3(user.PositionX, user.PositionY, user.PositionZ);
|
||||||
|
|
||||||
|
HanfManager.UpdateHanfForPlayer(player);
|
||||||
|
|
||||||
if (GlobalHelper.CountdownUntil > DateTime.Now)
|
if (GlobalHelper.CountdownUntil > DateTime.Now)
|
||||||
{
|
{
|
||||||
player.TriggerEvent("countdown", (GlobalHelper.CountdownUntil - DateTime.Now).TotalSeconds, GlobalHelper.CountdownText);
|
player.TriggerEvent("countdown", (GlobalHelper.CountdownUntil - DateTime.Now).TotalSeconds, GlobalHelper.CountdownText);
|
||||||
|
|||||||
@@ -53,11 +53,23 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private const string PLAYER_CURRENTLY_PLANTING_DATA_KEY = "isPlantingCannabis";
|
private const string PLAYER_CURRENTLY_PLANTING_DATA_KEY = "isPlantingCannabis";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ab welcher Zeit Pflanzen verwelken
|
||||||
|
/// </summary>
|
||||||
|
private static readonly TimeSpan MAX_PLANT_TIME = TimeSpan.FromHours(6);
|
||||||
|
|
||||||
|
private static readonly TimeSpan MIN_PLANT_TIME_TO_HARVEST = TimeSpan.FromHours(4);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Timer der den Status des Verarbeiters zurücksetzt
|
/// Timer der den Status des Verarbeiters zurücksetzt
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static Timer _manufacturerDoneTimer = new Timer(TimeSpan.FromSeconds(10).TotalMilliseconds);
|
private static Timer _manufacturerDoneTimer = new Timer(TimeSpan.FromSeconds(10).TotalMilliseconds);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Zufallsgenerator für weibliche Pflanze und erhaltenes Cannabis
|
||||||
|
/// </summary>
|
||||||
|
private static Random _random = new Random();
|
||||||
|
|
||||||
private static List<CannabisData> _currentCannabisData = new List<CannabisData>();
|
private static List<CannabisData> _currentCannabisData = new List<CannabisData>();
|
||||||
|
|
||||||
static HanfManager()
|
static HanfManager()
|
||||||
@@ -99,8 +111,13 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
|
|
||||||
private static void OnSeedBuyRangeColShapeEnter(ColShape colShape, Player player)
|
private static void OnSeedBuyRangeColShapeEnter(ColShape colShape, Player player)
|
||||||
{
|
{
|
||||||
|
if (!player.IsLoggedIn())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var user = player.GetUser();
|
var user = player.GetUser();
|
||||||
if (user.Faction.StateOwned)
|
if (user?.Faction?.StateOwned == true)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -245,6 +262,93 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
player.SendNotification($"Du hast {amount} Hanfsamen gekauft");
|
player.SendNotification($"Du hast {amount} Hanfsamen gekauft");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("CLIENT:Hanf_HarvestHanf")]
|
||||||
|
public void HanfManagerHarvestHanf(Player player, long hanfId)
|
||||||
|
{
|
||||||
|
if (!player.IsLoggedIn())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var dbContext = new DatabaseContext();
|
||||||
|
|
||||||
|
User user = player.GetUser(dbContext);
|
||||||
|
CannabisPlant plant = dbContext.CannabisPlants.Find(hanfId);
|
||||||
|
if (plant == null)
|
||||||
|
{
|
||||||
|
logger.LogError("Player {0} tried to harvest cannabis plant {1} but it was not found in database", player.Name, hanfId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user.Faction?.StateOwned == true && !(user.FactionId == 3 && player.IsDuty()))
|
||||||
|
{
|
||||||
|
player.SendNotification("~r~Du kannst kein Hanf ernten");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plant.Harvested)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
plant.Harvested = true;
|
||||||
|
|
||||||
|
if (user.FactionId != 3) // Zivi / Gangmember erntet ab
|
||||||
|
{
|
||||||
|
bool isPlantRotten = DateTime.Now - plant.PlantDate > MAX_PLANT_TIME;
|
||||||
|
if (isPlantRotten)
|
||||||
|
{
|
||||||
|
player.SendNotification("~r~Die Pflanze ist leider verrottet");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bool isPlantReadyToHarvest = DateTime.Now - plant.PlantDate > MIN_PLANT_TIME_TO_HARVEST;
|
||||||
|
if (!isPlantReadyToHarvest) // Wenn die Pflanze noch nicht ausgewachsen ist
|
||||||
|
{
|
||||||
|
bool getSeedBack = _random.Next(0, 2) == 1; // 50% Chance
|
||||||
|
if(getSeedBack)
|
||||||
|
{
|
||||||
|
IItem cannabisSeedItem = InventoryManager.GetItem<CannabisSeeds>();
|
||||||
|
InventoryManager.AddItemToInventory(player, cannabisSeedItem.Id, 1);
|
||||||
|
player.SendNotification("~g~Du konntest den Samen wieder ausgraben");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.SendNotification("~r~Du konntest den Samen leider nicht wieder ausgraben");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bool isFemalePlant = _random.Next(0, 10) + 1 <= 8; // 80% Chance dass es eine weibliche Pflanze ist
|
||||||
|
if (isFemalePlant)
|
||||||
|
{
|
||||||
|
int cannabisAmount = _random.Next(4, 10) + 1; // zwischen 5 und 10g Cannabis
|
||||||
|
IItem cannabisItem = InventoryManager.GetItem<Cannabis>();
|
||||||
|
var newWeight = cannabisAmount * cannabisItem.Gewicht;
|
||||||
|
if (!InventoryManager.CanPlayerHoldMoreWeight(player, newWeight))
|
||||||
|
{
|
||||||
|
int restWeightPlayerCanHold = InventoryManager.MAX_USER_INVENTORY - InventoryManager.GetUserInventoryWeight(player);
|
||||||
|
cannabisAmount = restWeightPlayerCanHold / cannabisItem.Gewicht;
|
||||||
|
player.SendNotification("~o~Warnung:~s~ Du hast nicht das komplette Cannabis der Pflanze erhalten, da dein Inventar voll ist");
|
||||||
|
}
|
||||||
|
player.SendNotification("~g~" + cannabisAmount + "g Cannabis geerntet");
|
||||||
|
InventoryManager.AddItemToInventory(player, cannabisItem.Id, cannabisAmount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.SendNotification("~r~Du hast die falschen Samen eingesät und keinen Ertrag aus dieser Pflanze erhalten");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // FIB erntet ab
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
UpdateHanfWorldData(dbContext);
|
||||||
|
}
|
||||||
|
|
||||||
internal static void BuildJointsFromCannabis(Player player)
|
internal static void BuildJointsFromCannabis(Player player)
|
||||||
{
|
{
|
||||||
if (player.HasAnimation(_manufacturerAnim) || _manufacturerCurrentlyUsed)
|
if (player.HasAnimation(_manufacturerAnim) || _manufacturerCurrentlyUsed)
|
||||||
|
|||||||
Reference in New Issue
Block a user