From d1bdc069fd987ea65fc0591e58d0012326b9021b Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Tue, 26 Jul 2022 01:00:25 -0500 Subject: [PATCH] Add player stream distance + fishing cast min/max strength to config --- scripts/server/config.js | 4 +++ scripts/server/fishing.js | 67 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 67 insertions(+), 4 deletions(-) diff --git a/scripts/server/config.js b/scripts/server/config.js index e7706ee8..1c48d889 100644 --- a/scripts/server/config.js +++ b/scripts/server/config.js @@ -227,6 +227,8 @@ let globalConfig = { houseBlipStreamOutDistance: 120, jobBlipStreamInDistance: -1, jobBlipStreamOutDistance: -1, + playerStreamInDistance: -1, + playerStreamOutDistance: -1, playerBlipStreamInDistance: -1, playerBlipStreamOutDistance: -1, handcuffPlayerDistance: 3, @@ -241,6 +243,8 @@ let globalConfig = { fishingSpotDistance: 10.0, atmDistance: 1.5, loginTimeout: 60000, + fishingCastMaxStrength: 100, + fishingCastMinStrength: 30, }; // =========================================================================== diff --git a/scripts/server/fishing.js b/scripts/server/fishing.js index 47f0283f..6fe0e00c 100644 --- a/scripts/server/fishing.js +++ b/scripts/server/fishing.js @@ -52,6 +52,40 @@ let fishingCollectables = [ // =========================================================================== +let fishingAnimations = { + [AGRP_GAME_GTA_III]: { + "fishingLineCasting": "bathit1", + "fishingLineReeling": "aimdown", + }, + [AGRP_GAME_GTA_VC]: { + "fishingLineCasting": "frontpunch", + "fishingLineReeling": "aimdown", + }, + [AGRP_GAME_GTA_SA]: { + "fishingLineCasting": "none", + "fishingLineReeling": "none", + } +}; + +// =========================================================================== + +let fishingParticleEffects = { + [AGRP_GAME_GTA_III]: { + "fishingLineCast": [ + "MediumSprayingWater", + 0.2, + 500 + ], + "fishingLineReel": [ + "MediumSprayingWater", + 0.2, + 500 + ] + } +}; + +// =========================================================================== + function initFishingScript() { logToConsole(LOG_INFO, "[VRR.Fishing]: Initializing fishing script ..."); logToConsole(LOG_INFO, "[VRR.Fishing]: Fishing script initialized successfully!"); @@ -59,7 +93,7 @@ function initFishingScript() { // =========================================================================== -function castFishingLineCommand(client) { +function castFishingLineCommand(command, params, client) { if (!isPlayerInFishingSpot(client)) { messagePlayerError(client, getLocaleString(client, "CantFishHere")); return false; @@ -70,14 +104,23 @@ function castFishingLineCommand(client) { return false; } - getPlayerData(client).fishingLineCastStart = getCurrentUnixTimestamp(); - makePedPlayAnimation(getPlayerPed(client), getAnimationFromParams("fishingcast")); + if (doesPlayerHaveFishingLineCast(client)) { + messagePlayerError(client, getLocaleString(client, "FishingLineAlreadyCast")); + return false; + } + + let maxStrength = getGlobalConfig().fishingCastMaxStrength; + let minStrength = getGlobalConfig().fishingCastMinStrength; + let keyDuration = getPlayerData(client).keyBindDuration; + + let strength = Math.round((maxStrength - minStrength) * (keyDuration / getGlobalConfig().fishingLineCastDuration)); + + castPlayerFishingLine(client, strength); let messageText = getLocaleString(client, "FishingCastCommandHelp"); if (doesPlayerHaveKeyBindForCommand(client, "fish")) { messageText = getLocaleString(client, "FishingCastKeyPressHelp"); } - showGameMessage(client, messageText); } @@ -120,6 +163,22 @@ function doesPlayerHaveFishingLineCast(client) { // =========================================================================== +function castPlayerFishingLine(client, strength) { + let frontPosition = getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), strength * 2); + + makePlayerPlayAnimation(client, getAnimationFromParams(fishingAnimations[getGame()]["fishingLineCasting"])); + + setTimeout(function () { + let particleEffectName = fishingParticleEffects[getGame()].fishingLineCast[1]; + showParticleEffect(frontPosition, getGameConfig().particleEffects[getGame()][particleEffectName], fishingParticleEffects[getGame()].fishingLineCast[1], fishingParticleEffects[getGame()].fishingLineCast[2]); + + getPlayerData(client).fishingLineCastPosition = frontPosition; + getPlayerData(client).fishingLineState = AGRP_FISHING_LINE_STATE_CASTED; + }, strength * 10); +} + +// =========================================================================== + function isPlayerInFishingSpot(client) { if (isPlayerOnBoat(client)) { return true;