Author Topic: Fishing 4x4 Version 0.1 for Public testing  (Read 3447 times)

0 Members and 1 Guest are viewing this topic.

Offline VicVegaTopic starter

  • Jr. Member
  • **
  • Posts: 71
  • Activity:
    0%
  • Reputation Power: 0
  • VicVega has no influence.
  • Respect: +8
  • Referrals: 0
    • View Profile
Fishing 4x4 Version 0.1 for Public testing
« on: May 13, 2009, 06:56:54 AM »
0
Fishing 4x4


The script works fine but I wanna post it here for a while before posting it on the Submit Your Script section, in case anyone has any suggestions about the code and how to improve it.

Purpose

  • Fishes in a harbor or a boat till you are overloaded

Current features

  • If you are in a harbor near a vendor, sells the steaks using Razor Sells Agent (you have to set the Razor Agent to do this).
  • If you are in a boat, moves the boat 12 tiles back or forward each time the fish it's depleted on the 4x4 zone around.
  • Cuts the fish with a dagger.
  • Drops boots on the ground.
  • Drops special fishes on the ground
  • Saves the fishing data in a file called fishing4x4Data.txt

Version History

new in 0.1  (13/5/09)

  • Published the first script's version.

Posible Future Features

  • Add support for Runebooks in order to drop money and white pearls in the Bank

Notes

  • How fishing4x4Data.txt looks like, in case you activate this option:

Quote
Time: 145210
Time fishing: 436 s 7 min
Total time fishing: 2705 s 45 min
Total Steaks: 860
Steaks Gained This Loop: 132
Total Steaks Gained: 860
Steaks Per Hour: 1144
...


  • Explanation how the 4x4 fishing works extracted from here. Warning: This only works with RunUO or OSI shards, not with Sphere ones.

Quote
8x8 resource blocks are how UO handles resources that respawn.  Resources don't restock in a tile/tile basis.  So when you just fish in 4x4 blocks around you, you are depleting all possible resources by only fishing in 4 spots!

Actually it works out pretty close actually.  If you fish one 4x4 square to being empty, then the other 3, you are really close to having the resources replenished.  Trust me, I have a couple fishing scripts out there and have been doing the fishing thing for just about the beginning of my scripting life, so I've tweaked it a bunch.  It's all come to successful fishing attempts/hr so if you over-fish an area, you'll waste a lot of time in that same area knowing you won't fish anything up.

Instructions

  • You need wearing a pole in the paperdoll, you also need a dagger in the backpack.
  • %sellFishsteaks - set #true for sell the fish steaks or #false, it's #false by default, you need to add fishSteaks at the Razor's Sell Agent.
  • %saveData - set #true for save data in fishing4x4Data.txt or #false, it's #true by default.
  • %boatFishing - set #true for fishing from a boat or #false, it's #false by default.

Code: [Select]
;=================================================================
; Script Name: Fishing 4x4
; Author: VicVega
; Version: 0.1
; Shard OSI / FS: UO Legends
; Revision Date: 13/5/2009
; Purpose: Fish in a port or a boat till you are overloaded
; Globals: None
;=================================================================
; Instructions:
; You need wearing a pole in the paperdoll, you also need a dagger
; in the backpack.
; %sellFishsteaks - set #true for sell the fish steaks or #false
;                   it's #false by default, you need to add fishSteaks
;                   at the Razor's Sell Agent
; %saveData - set #true for save data in fishing4x4Data.txt or #false
;             it's #true by default
; %boatFishing - set #true for fishing from a boat or #false
;                it's #false by default
;************************ Setup **********************************
gosub setup
;*********************** Main Loop *******************************
repeat
  gosub fishing
  gosub saveData
  gosub moveBoat
  gosub dropBoots
  gosub dropSpecialFishes
until #CharGhost = YES
halt
;************************* Subs **********************************
sub setup
  set %sellFishSteaks #false
  set %saveData #true
  set %boatFishing #false
  set %poleType KDF
  set %daggerType WSF
  set %maxTimeOutScan 15
  set %maxweight 570
  set %totalTimeFishing 0
  set %fishSteaksType IND
  set %forward #true
  finditem %poleType C_ , #charID
  set %poleID #findID
  finditem %daggerType C_ , #backpackID
  set %daggerID #findID
  gosub saveStartingData
return

sub saveData
  if %saveData
  {
    set %loopTime #scnt - %startingLoopTime
    set %totalTimeFishing %totalTimeFishing + %loopTime
    set %loopTimeMinutes %loopTime / 60
    set %totalTimeFishingMinutes %totalTimeFishing / 60
    finditem %fishSteaksType C_ , #backpackID
    set %nSteaks #findStack
    set %nSteaksLoop %nSteaks - %nSteaksStartingLoop
    set %totalSteaks %nSteaks
    set %nSteaks %nSteaks - %nStartingSteaks
    set %steaksPerHour ( %nSteaks * 3600 ) / %totalTimeFishing
    execute SaveTextToFile.Vbs #false #false #curPath fishing4x4Data.txt
    + Time: #time $
    + Time fishing: %loopTime s %loopTimeMinutes min $
    + Total time fishing: %totalTimeFishing s %totalTimeFishingMinutes min $
    + Total Steaks: %totalSteaks $
    + Steaks Gained This Loop: %nSteaksLoop $
    + Total Steaks Gained: %nSteaks $
    + Steaks Per Hour: %steaksPerHour $
  }
return

sub saveStartingData
  if %saveData
  {
    finditem %fishSteaksType C_ , #backpackID
    set %nStartingSteaks #findStack
    set %startingTime #time
    execute SaveTextToFile.Vbs #false #false #curPath fishing4x4Data.txt
    + Starting time: %startingTime $
    + Starting steaks: %nStartingSteaks
  }
return

sub fishing
  gosub startingLoopData
  for %i 1 4
  {
    gosub sellFishSteaks
    gosub fishingSpot
    gosub tileName %1 %2
    event sysmessage %1 %2
    while #result = #true
    {
      gosub usePole
      gosub scan
    }
    gosub cutFish
  }
return

sub moveBoat
  if %boat
  {
    if %forward
    {
      for %k 0 3
      {
        msg forward one $
        wait 2s
        set %forward #false
      }
    }
    else
    {
      for %m 0 11
      {
        msg backwards one $
        wait 2s
        set %forward #true
      }
    }
  }
return

sub startingLoopData
  if %saveData
  {
    finditem %fishSteaksType C_ , #backpackID
    set %nSteaksStartingLoop #findStack
    set %startingLoopTime #scnt
  }
return

sub fishingSpot
  if %i = 1
    gosub setTargets 4 4
  if %i = 2
    gosub setTargets 4 -4
  if %i = 3
    gosub setTargets -4 4
  if %i = 4
    gosub setTargets -4 -4
return

sub setTargets
  set #lTargetKind 2
  set #lTargetX #charPosX + %1
  set #lTargetY #charPosY + %2
return

sub scan
  set %timeout #scnt + %maxTimeOutScan
  set %jrnl #jindex
  scanjournal %jrnl
 
  while #scnt < %timeout
  {
    if %jrnl < #jindex
    {
      set %jrnl %jrnl + 1
      scanjournal %jrnl
    }
    set %spotWithFish fail_to_catch in #journal || pull_out in #journal &&
    set %spotWithoutFish don't_seem_to_be_biting in #journal
    if %spotWithFish
      return #true
    if %spotWithoutFish
      return #false
  }
return

sub UsePole
  set #lTargetZ #tileZ
  set #lObjectID %poleID
  event macro 17
  target
  event macro 22
return

sub tileName
  set %fishingPosX #charPosX + %1
  set %fishingPosY #charPosY + %2
  tile init
  tile cnt %fishingPosX %fishingPosY
  for %j 1 #tilecnt
  {
    tile get %fishingPosX %fishingPosY %j
    set %canFish water in #tileName || jungle in #tileName
    if %canFish
      return #true
  }
return

sub dropSpecialFishes
  set %fishType YDF
  finditem %fishType C_ , #backpackID
  while #findKind <> -1
  {
    exevent drag #findID #findStack
    wait 1s
    exevent dropg #charPosX #charPosY
    wait 1s
    finditem %fishType C_ , #backpackID
  }
return

sub cutFish
  set %fishType FQD_DQD_GQD_EQD
  set #lTargetKind 1
  set #lObjectID %daggerID
  finditem %fishType C_ , #backpackID
  while #findKind <> -1
  {
    set #lTargetID #findID
    event macro 17
    target
    event macro 22
    wait 1s
    finditem %fishType C_ , #backpackID
  }
return

sub dropBoots
  set %bootsType TVI_ZVI_ZVI_PVI_NVI
  finditem %bootsType C_ , #backpackID
  while #findKind <> -1
  {
    exevent drag #findID #findStack
    wait 1s
    exevent dropg #charPosX #charPosY
    wait 1s
    finditem %bootsType C_ , #backpackID
  }
return

sub sellFishSteaks
  set %shouldSellFishSteaks %sellFishSteaks && #weight > #maxWeight
  if %shouldSellFishSteaks = #true
  {
    finditem %fishSteaksType C_ , #backpackID
    if #findKind <> -1
      msg vendor sell $
    wait 1s
    if %saveData
      gosub saveStartingData
  }
  else
  {
    if #weight > %maxWeight
      halt
  }
return
« Last Edit: May 13, 2009, 07:22:22 AM by VicVega »
To learn, read.
To know, write.
To master, teach.

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Fishing 4x4 Version 0.1 for Public testing
« Reply #1 on: May 13, 2009, 08:38:30 AM »
0
Wow its so nice to see nice clean indented code... Im going to start a fisher and give it a twirl just because of that
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Fishing 4x4 Version 0.1 for Public testing
« Reply #2 on: May 13, 2009, 10:57:35 AM »
0
Here's a couple esthetic suggestions:

Suppose you want to display your skills with the decimal?  So 132 becomes 13.2:

Code: [Select]
; %1 = input - Skill to convert
; #RESULT -  Skill converted to ###.# format
sub ConvertSkill
  namespace push
  namespace local CS
  set !intpart %1 / 10
  set !decpart %1 % 10
  set #RESULT !intpart , #dot , !decpart
  namespace pop
return #RESULT

And the same goes for time:

Code: [Select]
;-------------------------------------------------------------------------------
; %1 = input - Time to convert
; #RESULT -  Time converted to H:MM:SS format
sub ConvertTimeHourMinSec
  namespace push
  namespace local ctime
  set !hourpart %1 / 3600
  set !secpart ( %1 % 3600 ) % 60
  set !minpart ( ( %1 % 3600 ) / 60 )

  if !hourpart >= 10
    set #RESULT !hourpart , :
  else
    set #RESULT 0 , !hourpart , :
  if !minpart < 10
    set #RESULT #RESULT , 0
  set #RESULT #RESULT , !minpart , :
  if !secpart < 10
    set #RESULT #RESULT , 0
  set #RESULT #RESULT , !secpart
  namespace pop
return #RESULT
Please read the ScriptUO site RULES
Come play RIFT with me!

Tags: