From 22eac37611121d7e6ed7027c1ede37928fea40c3 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Fri, 22 Apr 2016 15:50:33 -0400 Subject: Refactored fishing process code --- gamemode/init.lua | 2 -- gamemode/processes.lua | 26 +++++++++++++------------- 2 files changed, 13 insertions(+), 15 deletions(-) (limited to 'gamemode') diff --git a/gamemode/init.lua b/gamemode/init.lua index cd72b13..e8a8600 100644 --- a/gamemode/init.lua +++ b/gamemode/init.lua @@ -348,8 +348,6 @@ for k,v in pairs(GM.Plantables) do return end local trm = tr.MatType - PrintTable(tr) - print(Vector(tr.HitPos)) if( (trm != MAT_DIRT) and (trm != MAT_GRASS) and (trm != MAT_SAND) or (GMS.IsInWater(Vector(tr.HitPos)))) then ply:SendMessage( "You cannot plant on this terrain.", 3, Color( 200, 0, 0, 255 ) ) return diff --git a/gamemode/processes.lua b/gamemode/processes.lua index d898271..b75db3b 100644 --- a/gamemode/processes.lua +++ b/gamemode/processes.lua @@ -804,26 +804,26 @@ function PROCESS:OnStop() if ( !self.Owner.Resources['Baits'] or self.Owner.Resources['Baits'] < 1 ) then self.Data.Chance = self.Data.Chance * 0.25 end + local fishables = { + {"Bass",999,2}, + {"Trout",2,1.5}, + {"Salmon",1.5,1.2}, + {"Shark",1.2,1}, + } if ( num < self.Data.Chance + self.Owner:GetSkill( "Fishing" ) ) then if ( self.Owner.Resources['Baits'] and self.Owner.Resources['Baits'] > 0 ) then self.Owner:DecResource( "Baits", 1 ) end - if ( num < ( self.Data.Chance + self.Owner:GetSkill( "Fishing" ) ) / 2 ) then - self.Owner:IncResource( "Bass", 1 ) - self.Owner:SendMessage( "Bass ( 1x )", 3, Color( 10, 200, 10, 255 ) ) - elseif ( num >= ( self.Data.Chance + self.Owner:GetSkill( "Fishing" ) ) / 2 && num < ( self.Data.Chance + self.Owner:GetSkill( "Fishing" ) ) / 1.5 ) then - self.Owner:IncResource( "Trout", 1 ) - self.Owner:SendMessage( "Trout ( 1x )", 3, Color( 10, 200, 10, 255 ) ) - elseif ( num >= ( self.Data.Chance + self.Owner:GetSkill( "Fishing" ) ) / 1.5 && num < ( self.Data.Chance + self.Owner:GetSkill( "Fishing" ) ) / 1.2 ) then - self.Owner:IncResource( "Salmon", 1 ) - self.Owner:SendMessage( "Salmon ( 1x )", 3, Color( 10, 200, 10, 255 ) ) - elseif ( num >= ( self.Data.Chance + self.Owner:GetSkill( "Fishing" ) ) / 1.2 && num < self.Data.Chance + self.Owner:GetSkill( "Fishing" ) ) then - self.Owner:IncResource( "Shark", 1 ) - self.Owner:SendMessage( "Shark ( 1x )", 3, Color( 10, 200, 10, 255 ) ) + local sdc = self.Data.Chance + self.Owner:GetSkill("Fishing") + for k,v in pairs(fishables) do + if( (num >= (sdc/v[2])) and (num < (sdc/v[3])) ) then + self.Owner:IncResource(v[1],1) + self.Owner:SendMessage(v[1] .. "( 1x )", 3, Color(10,200,10,255)) + break + end end - self.Owner:IncXP( "Fishing", math.Clamp( math.Round( 250 / self.Owner:GetSkill( "Fishing" ) ), 1, 1000 ) ) self.Owner:EmitSound( Sound( "ambient/water/water_splash" .. math.random( 1, 3 ) .. ".wav" ) ) else -- cgit v1.2.3-70-g09d2