SRL Archive - MSI Archives

Fishing.scar - Commits


3Garrett3

2010-07-09 20:17:29

So I'm sure some people know that I've been planning on adding Fishing to the include, since a lot of mining is done or in progress.

So far I have DTMS (may be replaced :( ) colors, names and experience for all of the 11 fish which are f2p. I have most of the data for TItem record, but I don't know exactly what colors and tolerances to use.

Something that I need to add is the fishing spot objects (Cohen and I decided to make individual objects for each spot because of the AssociatedItems var, as well as making it easier to create the actual fishing include. This should be fairly easy.

I also need to create the actual include itself, but I want the objects and items to be solid before that. There are three steps to the include:

  1. Fishing Spot Waiting
  2. Finding the Fishing Spot
  3. Fishing Until Full Inventory

The waiting should be the hardest part, because fishing spots can overlap and are dynamic, so color counting wont work. I'm not sure how I'll do this yet..

The last thing I can think of is getting the tools set up, which I haven't started yet.

If anyone wants to help with this, or has other things that I need to work on, just post here. I would imagine this will be moved somewhere that it belongs sometime, but there isn't any fishing section, so here is good enough.

Thank you kindly,
Garrett

E: Read to the bottom of this page to see what I've done, I cba updating main post :p

3Garrett3

2010-07-09 21:53:42

So it's a double post, yeah. So shoot me. In the face, with…. yeah.

Anyway.

Here is what I have. I'm done for the night, really tired from waking up at 5am all week and working 8 hours every day.

Complete :

Global Item Vars

FISH_SHRIMP = 21;
FISH_CRAYFISH = 22;
FISH_SARDINE = 23;
FISH_HERRING = 24;
FISH_ANCHOVIE = 25;
FISH_TROUT = 26;
FISH_PIKE = 27;
FISH_SALMON = 28;
FISH_TUNA = 29;
FISH_LOBSTER = 30;
FISH_SWORDFISH = 31;

These can be added directly into the Globals.scar under the items, the ItemCount should be changed to 32.

Item Experience

SKILL_FISHING:
case Items[i] of
FISH_SHRIMP : e := 10.0;
FISH_CRAYFISH : e := 10.0;
FISH_SARDINE : e := 20.0;
FISH_HERRING : e := 30.0;
FISH_ANCHOVIE : e := 40.0;
FISH_TROUT : e := 50.0;
FISH_PIKE : e := 60.0;
FISH_SALMON : e := 70.0;
FISH_TUNA : e := 80.0;
FISH_LOBSTER : e := 90.0;
FISH_SWORDFISH : e := 100.0;

else
MSI_Debug('MSI_GetItemExperiences', 'Invalid object for fishing', DEBUG_FORCE);
end;

This goes in "MSI_GetItemExperiences" which is in ItemInfo.scar

Item Names

FISH_SHRIMP : s := 'Shrimp';
FISH_CRAYFISH : s := 'Crayfish';
FISH_ANCHOVIE : s := 'Anchovies';
FISH_SARDINE : s := 'Sardines';
FISH_HERRING : s := 'Herring';
FISH_TROUT : s := 'Trout';
FISH_PIKE : s := 'Pike';
FISH_SALMON : s := 'Salmon';
FISH_TUNA : s := 'Tuna';
FISH_LOBSTER : s := 'Lobster';
FISH_SWORDFISH : s := 'Swordfish';

This goes in "MSI_GetItemNames" which is in ItemInfo.scar

Item DTMs

FISH_SHRIMP, FISH_ANCHOVIE :
Result := [
Point(462, 70),
Point(461, 77),
Point(456, 81),
Point(464, 64),
Point(477, 65)
];

FISH_CRAYFISH :
Result := [
Point(910, 538),
Point(907, 545),
Point(914, 516),
Point(928, 526),
Point(914, 528)
];
FISH_SARDINE :
Result := [
Point(48, 134),
Point(50, 127),
Point(58, 131),
Point(45, 140),
Point(40, 140)
];
FISH_HERRING :
Result := [
Point(98, 138),
Point(87, 143),
Point(108, 124),
Point(113, 134),
Point(89, 134)
];
FISH_TROUT, FISH_PIKE, FISH_SALMON :
Result := [
Point(194, 141),
Point(214, 122),
Point(218, 129),
Point(203, 126),
Point(191, 146)
];
FISH_TUNA :
Result := [
Point(357, 136),
Point(359, 124),
Point(372, 136),
Point(347, 146),
Point(344, 127)
];
FISH_LOBSTER :
Result := [
Point(414, 133),
Point(424, 144),
Point(463, 121),
Point(478, 134),
Point(472, 140)
];
FISH_SWORDFISH :
Result := [
Point(357, 136),
Point(359, 124),
Point(372, 136),
Point(347, 146),
Point(344, 127)
];

These are all untested, because I just finished typing them up. They go in "MSI_GetDTMPoints" in ItemInfo.scar

Item Color

FISH_SHRIMP : Result := 1712955;

FISH_CRAYFISH : Result := 1914462;

FISH_ANCHOVIE : Result := 7696496;

FISH_SARDINE : Result := 6466656;

FISH_HERRING : Result := 11053232;

FISH_TROUT : Result := 11843005;

FISH_PIKE : Result := 10269852;

FISH_SALMON : Result := 9606569;

FISH_TUNA : Result := 9408662;

FISH_LOBSTER : Result := 2046823;

FISH_SWORDFISH : Result := 9264774;

What good are dtms without colours. These go in the function below the DTM point thing. ItemInfo.scar

Fish Spot Globals

FISHSPOT_NET = 12;
FISHSPOT_BAIT = 13;
FISHSPOT_LURE = 14;
FISHSPOT_CAGE = 15;
FISHSPOT_HARPOON = 16;

Goes in the objects section, the new count is 17.

Fish Spot TObjects

{ FISHING SPOTS ============================== ]
[============================================= }
FISHSPOT_NET: // 3Garrett3
with MSI_Objects[FISHSPOT_NET] do
begin
Name := 'Net Spot';
UpText := 'ishing';
Option := 'Net';
Colors := [11248543];
Tol := 7;
Hue := 0.23;
Sat := 0.36;
FindAllColors := False;
W := 15;
H := 15;
Accuracy := 10;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
AssociatedItems := [FISH_SHRIMP, FISH_CRAYFISH, FISH_ANCHOVIES];
end;

FISHSPOT_BAIT: // 3Garrett3
with MSI_Objects[FISHSPOT_BAIT] do
begin
Name := 'Bait Spot';
UpText := 'ishing';
Option := 'Bait';
Colors := [11248543];
Tol := 7;
Hue := 0.23;
Sat := 0.36;
FindAllColors := False;
W := 15;
H := 15;
Accuracy := 10;
ExcludeSelf := True;
RightClickOnly := True;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
AssociatedItems := [FISH_SARDINES, FISH_HERRING, FISH_PIKE];
end;

FISHSPOT_LURE: // 3Garrett3
with MSI_Objects[FISHSPOT_LURE] do
begin
Name := 'Lure Spot';
UpText := 'ishing';
Option := 'Lure';
Colors := [11248543];
Tol := 7;
Hue := 0.23;
Sat := 0.36;
FindAllColors := False;
W := 15;
H := 15;
Accuracy := 10;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
AssociatedItems := [FISH_TROUT, FISH_SALMON];
end;

FISHSPOT_CAGE: // 3Garrett3
with MSI_Objects[FISHSPOT_CAGE] do
begin
Name := 'Cage Spot';
UpText := 'ishing';
Option := 'Cage';
Colors := [11248543];
Tol := 7;
Hue := 0.23;
Sat := 0.36;
FindAllColors := False;
W := 15;
H := 15;
Accuracy := 10;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
AssociatedItems := [FISH_LOBSTER];
end;

FISHSPOT_HARPOON: // 3Garrett3
with MSI_Objects[FISHSPOT_HARPOON] do
begin
Name := 'Harpooning Spot';
UpText := 'ishing';
Option := 'Harpoon';
Colors := [11248543];
Tol := 7;
Hue := 0.23;
Sat := 0.36;
FindAllColors := False;
W := 15;
H := 15;
Accuracy := 10;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
AssociatedItems := [FISH_TUNA, FISH_SWORDFISH];
end;

Semi Complete

TItem Record

{ Fish ======================================== ]
[============================================= }

FISH_SHRIMP : //3Garrett3
with MSI_Items[FISH_SHRIMP] do
begin
Name := 'Shrimp';
UpText := ['aw shrimps'];
ItemP := Point(0, 0);
Colors := [];
Tol := ;
Stackable := False;
DTM := MSI_LoadDTM(FISH_SHRIMP);
end;
FISH_CRAYFISH : //3Garrett3
with MSI_Items[FISH_CRAYFISH] do
begin
Name := 'Crayfish';
UpText := ['aw crayfish'];
ItemP := Point(0, 0);
Colors := [];
Tol := ;
Stackable := False;
DTM := MSI_LoadDTM(FISH_CRAYFISH);
end;
FISH_ANCHOVIE : //3Garrett3
with MSI_Items[FISH_ANCHOVIE] do
begin
Name := 'Anchovies';
UpText := ['aw anchovies'];
ItemP := Point(0, 0);
Colors := [];
Tol := ;
Stackable := False;
DTM := MSI_LoadDTM(FISH_ANCHOVIE);
end;
FISH_SARDINE : //3Garrett3
with MSI_Items[FISH_SARDINE] do
begin
Name := 'Sardines';
UpText := ['aw sardine'];
ItemP := Point(0, 0);
Colors := [];
Tol := ;
Stackable := False;
DTM := MSI_LoadDTM(FISH_SARDINE);
end;
FISH_HERRING : //3Garrett3
with MSI_Items[FISH_HERRING] do
begin
Name := 'Herring';
UpText := ['aw herring'];
ItemP := Point(0, 0);
Colors := [];
Tol := ;
Stackable := False;
DTM := MSI_LoadDTM(FISH_HERRING);
end;
FISH_TROUT : //3Garrett3
with MSI_Items[FISH_TROUT] do
begin
Name := 'Trout';
UpText := ['aw trout'];
ItemP := Point(0, 0);
Colors := [];
Tol := ;
Stackable := False;
DTM := MSI_LoadDTM(FISH_TROUT);
end;
FISH_PIKE : //3Garrett3
with MSI_Items[FISH_PIKE] do
begin
Name := 'Pike';
UpText := ['aw pike'];
ItemP := Point(0, 0);
Colors := [];
Tol := ;
Stackable := False;
DTM := MSI_LoadDTM(FISH_PIKE);
end;
FISH_SALMON : //3Garrett3
with MSI_Items[FISH_SALMON] do
begin
Name := 'Salmon';
UpText := ['aw salmon'];
ItemP := Point(0, 0);
Colors := [];
Tol := ;
Stackable := False;
DTM := MSI_LoadDTM(FISH_SALMON);
end;
FISH_TUNA : //3Garrett3
with MSI_Items[FISH_TUNA] do
begin
Name := 'Tuna';
UpText := ['aw tuna'];
ItemP := Point(0, 0);
Colors := [];
Tol := ;
Stackable := False;
DTM := MSI_LoadDTM(FISH_TUNA);
end;
FISH_LOBSTER : //3Garrett3
with MSI_Items[FISH_LOBSTER] do
begin
Name := 'Lobster';
UpText := ['aw lobster'];
ItemP := Point(0, 0);
Colors := [];
Tol := ;
Stackable := False;
DTM := MSI_LoadDTM(FISH_LOBSTER);
end;
FISH_SWORDFISH : //3Garrett3
with MSI_Items[FISH_SWORDFISH] do
begin
Name := 'Swordfish';
UpText := ['aw swordfish'];
ItemP := Point(0, 0);
Colors := [];
Tol := ;
Stackable := False;
DTM := MSI_LoadDTM(FISH_SWORDFISH);
end;

These are done except I didn't know what colours and tolerances to use. Someone can add those in or wait until I find Cohen in the morning.

Not Done

Tools
I need the tool globals and tool records, there should be:

  • Net
  • Fishing Rod
  • Fly Fishing Rod
  • Feathers
  • Fishing Bait
  • Harpoon
  • Cage

Maybe more, I'm exhausted now, I've spent like 30 minutes writing this post.

Anyways, goodnight other SL's. I hope to hear a reply in the morning.

-Garrett

Sir R. M8gic1an

2010-07-10 04:47:23

[php]
{ FISHING SPOTS ============================== ]
[============================================= }
FISHSPOT_NET..FISHSPOT_HARPOON:
begin
//same color info for all spots
with MSI_Objects[whichObject] do
begin
Colors := [11248543];
Tol := 7;
Hue := 0.23;
Sat := 0.36;
FindAllColors := False;
W := 15;
H := 15;
Accuracy := 10;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
end;

case whichObject of

FISHSPOT_NET: // 3Garrett3
with MSI_Objects[FISHSPOT_NET] do
begin
Name := 'Net Spot';
UpText := 'ishing';
Option := 'Net';
AssociatedItems := [FISH_SHRIMP, FISH_CRAYFISH, FISH_ANCHOVIES];
end;

FISHSPOT_BAIT: // 3Garrett3
with MSI_Objects[FISHSPOT_BAIT] do
begin
Name := 'Bait Spot';
UpText := 'ishing';
Option := 'Bait';
AssociatedItems := [FISH_SARDINES, FISH_HERRING, FISH_PIKE];
end;

FISHSPOT_LURE: // 3Garrett3
with MSI_Objects[FISHSPOT_LURE] do
begin
Name := 'Lure Spot';
UpText := 'ishing';
Option := 'Lure';
AssociatedItems := [FISH_TROUT, FISH_SALMON];
end;

FISHSPOT_CAGE: // 3Garrett3
with MSI_Objects[FISHSPOT_CAGE] do
begin
Name := 'Cage Spot';
UpText := 'ishing';
Option := 'Cage';
AssociatedItems := [FISH_LOBSTER];
end;

FISHSPOT_HARPOON: // 3Garrett3
with MSI_Objects[FISHSPOT_HARPOON] do
begin
Name := 'Harpooning Spot';
UpText := 'ishing';
Option := 'Harpoon';
AssociatedItems := [FISH_TUNA, FISH_SWORDFISH];
end;

end;
end;

// next skill here
[/php]

I'll post my thoughts on WhileFishing in a bit.

~RM

3Garrett3

2010-07-10 09:08:01

Right, thanks. I never think of code shortening as I'm making the code.

Can someone tell me how to know which colours to use and what tolerance to use? Just whatever colour I'd use for FindColorTolerance?

Coh3n

2010-07-10 11:36:34

From: 3Garrett3
Right, thanks. I never think of code shortening as I'm making the code.

Can someone tell me how to know which colours to use and what tolerance to use? Just whatever colour I'd use for FindColorTolerance?

I'm assuming I answered this earlier?

Also, looking awesome so far! :D

3Garrett3

2010-07-10 17:07:36

Yeah, I know what to do now. I'm taking a break, it's a lot of work :p.

I'll get back on it later tonight or tomorrow.

Coh3n

2010-07-10 17:31:59

From: 3Garrett3
Yeah, I know what to do now. I'm taking a break, it's a lot of work :p.

I'll get back on it later tonight or tomorrow.

Yes, it is a lot of work. Now you know what we've been doing since MSI started. :p

3Garrett3

2010-07-23 14:35:12

Reviving this thread. I'm adding all the stuff in now, so yeah. I'll commit when I'm done it, just so I dont have to worry about more conflicts.

Still have to add:

Object file for Crayfish spot
All of the tools
Colours for the fish
Actual include

That seems like a short list but it's kinda not going to be fun or short, but I'm working on it now.

Coh3n

2010-07-23 15:49:17

From: 3Garrett3
Reviving this thread. I'm adding all the stuff in now, so yeah. I'll commit when I'm done it, just so I dont have to worry about more conflicts.

Still have to add:

Object file for Crayfish spot
All of the tools
Colours for the fish
Actual include

That seems like a short list but it's kinda not going to be fun or short, but I'm working on it now.

Yeah, just commit a few things at a time. Be sure to make sure it compiles (I know you know that, I'm just saying), that way you save yourself the stress of adding everything at once.

Also, for the item colors, you can just use the color in MSI_GetItemColor and set the tolerance to 5. That's worked for every item I've added.

3Garrett3

2010-07-25 10:28:21

So I've added tools to it now, as well as fish colours.

I need to figure out where the crayfish spot is. I'm guessing the uptext will be to cage?

Coh3n

2010-07-25 10:36:26

From: 3Garrett3
So I've added tools to it now, as well as fish colours.

I need to figure out where the crayfish spot is. I'm guessing the uptext will be to cage?

I have absolutely not idea to be honest. Are crayfish even F2P? If they're P2P only, there's no harm in leaving them out for now.

3Garrett3

2010-07-25 10:40:11

From: Coh3n
I have absolutely not idea to be honest. Are crayfish even F2P? If they're P2P only, there's no harm in leaving them out for now.


I thought that they were F2P but I'm not really sure. I have no idea where to find the spot, I guess I'll google it or something :p.

3Garrett3

2010-07-25 12:31:59

So here is what I've got now:

Fishing.scar:


{==============================================================================\
| MSI Group Scripting Include |
| Fishing.scar |
|==============================================================================|
| For all fishing routines. |
| |
| * procedure MSI_FishingTools(); * by 3Garrett3 |
| |
| |
\ _____________________________________________________________________________}

{******************************************************************************}
{ Function MSI_FishingTools : TIntegerArray }
{ By: 3Garrett3 }
{ Date: 25 July 2010 }
{ Description: Figures out which tool the script needs to use }
{******************************************************************************}
Function MSI_FishingTools : TIntegerArray;
var
script: TScript;
begin
script := MSI_Scripts[MSI_Players[CurrentPlayer].Scripts[CurrentScript]];
case (script.ObjectConstants) of
FISHSPOT_NET:
Result := [FISH_SMALLNET];

FISHSPOT_BAIT:
Result := [FISH_ROD, FISH_BAIT];

FISHSPOT_LURE:
Result := [FISH_FLY, FISH_FEATHER];

FISHSPOT_CAGE:
Result := [FISH_CAGE];

FISHSPOT_HARPOON:
Result := [FISH_HARPOON];

else
MSI_Debug('MSI_FishingTools', 'Invalid Fishing Spot', DEBUG_FUNCTIONS);
end;
end;

Here is the new globals:


const
TOOL_HATCHET = 0;
TOOL_PICKAXE = 1;
TOOL_FISH = 2;


//Fishing
REQ_NET = 1;
REQ_POT = 1;
REQ_BAIT = 5;
REQ_LURE = 20;
REQ_HARPOON = 35;
REQ_CAGE = 40;


const
ITEM_COUNT = 41;

PICKAXE_BRONZE = 0;
PICKAXE_IRON = 1;
PICKAXE_STEEL = 2;
PICKAXE_MITHRIL = 3;
PICKAXE_ADAMANT = 4;
PICKAXE_RUNE = 5;

HATCHET_BRONZE = 6;
HATCHET_IRON = 7;
HATCHET_STEEL = 8;
HATCHET_MITHRIL = 9;
HATCHET_ADAMANT = 10;
HATCHET_RUNE = 11;

LOGS_NORMAL = 12;
LOGS_OAK = 13;
LOGS_WILLOW = 14;
LOGS_MAPLE = 15;
LOGS_YEW = 16;
LOGS_MAGIC = 17;

ORE_COPPER = 18;
ORE_TIN = 19;
ORE_IRON = 20;

FISH_SHRIMP = 21;
FISH_CRAYFISH = 22;
FISH_SARDINE = 23;
FISH_HERRING = 24;
FISH_ANCHOVIE = 25;
FISH_TROUT = 26;
FISH_PIKE = 27;
FISH_SALMON = 28;
FISH_TUNA = 29;
FISH_LOBSTER = 30;
FISH_SWORDFISH = 31;

FISH_SMALLNET = 32;
FISH_CRAYPOT = 33;
FISH_ROD = 34;
FISH_BAIT = 35;
FISH_FLY = 36;
FISH_FEATHER = 37;
FISH_HARPOON = 38;
FISH_CAGE = 39;

ITEM_BIRD_NEST = 40;


const
OBJ_COUNT = 20;

TREE_NORMAL = 0;
TREE_OAK = 1;
TREE_WILLOW = 2;
TREE_MAPLE = 3;
TREE_YEW = 4;
TREE_MAGIC = 5;

ROCK_TIN = 6;
ROCK_COPPER = 7;
ROCK_IRON = 8;

MSI_BANK_VE = 9; // Includes the 'MSI_' because there are bank constants in SRL's Bank.scar
MSI_BANK_DB = 10;
MSI_BANK_GE = 11;
MSI_BANK_FE = 12;

DBOX_PS = 13;

FISHSPOT_NET = 14;
FISHSPOT_BAIT = 15;
FISHSPOT_LURE = 16;
FISHSPOT_CAGE = 17;
FISHSPOT_HARPOON = 18;

OBJ_BIRD_NEST = 19;
BIRD_NEST_CBMESSAGE = 'nest falls out of';


Here is the ItemInfo:


FISH_SHRIMP, FISH_ANCHOVIE:
Result := [ Point(462, 70), Point(461, 77), Point(456, 81),
Point(464, 64), Point(477, 65) ];

FISH_CRAYFISH:
Result := [ Point(910, 538), Point(907, 545), Point(914, 516),
Point(928, 526), Point(914, 528) ];

FISH_SARDINE:
Result := [ Point(48, 134), Point(50, 127), Point(58, 131),
Point(45, 140), Point(40, 140) ];

FISH_HERRING:
Result := [ Point(98, 138), Point(87, 143), Point(108, 124),
Point(113, 134), Point(89, 134) ];

FISH_TROUT, FISH_PIKE, FISH_SALMON:
Result := [ Point(194, 141), Point(214, 122), Point(218, 129),
Point(203, 126), Point(191, 146) ];

FISH_TUNA:
Result := [ Point(357, 136), Point(359, 124), Point(372, 136),
Point(347, 146), Point(344, 127) ];

FISH_LOBSTER:
Result := [ Point(414, 133), Point(424, 144), Point(463, 121),
Point(478, 134), Point(472, 140) ];

FISH_SWORDFISH:
Result := [ Point(357, 136), Point(359, 124), Point(372, 136),
Point(347, 146), Point(344, 127) ];

FISH_SMALLNET:
Result := [ Point(621, 229), Point(617, 217), Point(607, 230),
Point(634, 224), Point(630, 240) ];

FISH_CRAYPOT:
Result := [ Point(704, 340), Point(700, 326), Point(706, 347),
Point(715, 331), Point(694, 344) ];

FISH_ROD:
Result := [ Point(567, 341), Point(576, 350), Point(577, 329),
Point(573, 343), Point(590, 323) ];

FISH_BAIT:
Result := [ Point(665, 376), Point(649, 372), Point(667, 370),
Point(675, 373), Point(652, 381) ];

FISH_FLY:
Result := [ Point(615, 373), Point(632, 357), Point(617, 385),
Point(608, 381), Point(619, 365) ];

FISH_FEATHER:
Result := [ Point(580, 370), Point(564, 388), Point(594, 359),
Point(576, 365), Point(586, 374) ];

FISH_HARPOON:
Result := [ Point(629, 321), Point(612, 351), Point(622, 323),
Point(633, 324), Point(618, 335) ];

FISH_CAGE:
Result := [ Point(665, 343), Point(676, 328), Point(649, 345),
Point(666, 350), Point(658, 324) ];


FISH_SHRIMP : Result := 1712955;
FISH_CRAYFISH : Result := 1914462;
FISH_ANCHOVIE : Result := 7696496;
FISH_SARDINE : Result := 6466656;
FISH_HERRING : Result := 11053232;
FISH_TROUT : Result := 11843005;
FISH_PIKE : Result := 10269852;
FISH_SALMON : Result := 9606569;
FISH_TUNA : Result := 9408662;
FISH_LOBSTER : Result := 2046823;
FISH_SWORDFISH : Result := 9264774;

FISH_SMALLNET : Result := 2569539;
FISH_CRAYPOT : Result := 5461079;
FISH_ROD : Result := 5197651;
FISH_BAIT : Result := 1605551;
FISH_FLY : Result := 3355445;
FISH_FEATHER : Result := 530952;
FISH_HARPOON : Result := 6052960;
FISH_CAGE : Result := 6184546;


{ FISH ======================================== ]
[============================================== }
FISH_SHRIMP :
with MSI_Items[whichItem] do
begin
Name := 'Shrimp';
UpText := ['aw shrimps'];
ItemP := Point(0, 0);
Colors := [1712955];
Tol := 5;
Stackable := False;
DTM := MSI_LoadDTM(whichItem);
end;

FISH_CRAYFISH :
with MSI_Items[whichItem] do
begin
Name := 'Crayfish';
UpText := ['aw crayfish'];
ItemP := Point(0, 0);
Colors := [1914462];
Tol := 5;
Stackable := False;
DTM := MSI_LoadDTM(whichItem);
end;

FISH_ANCHOVIE :
with MSI_Items[whichItem] do
begin
Name := 'Anchovies';
UpText := ['aw anchovies'];
ItemP := Point(0, 0);
Colors := [7696496];
Tol := 5;
Stackable := False;
DTM := MSI_LoadDTM(whichItem);
end;

FISH_SARDINE :
with MSI_Items[whichItem] do
begin
Name := 'Sardines';
UpText := ['aw sardine'];
ItemP := Point(0, 0);
Colors := [6466656];
Tol := 5;
Stackable := False;
DTM := MSI_LoadDTM(whichItem);
end;

FISH_HERRING :
with MSI_Items[whichItem] do
begin
Name := 'Herring';
UpText := ['aw herring'];
ItemP := Point(0, 0);
Colors := [11053232];
Tol := 5;
Stackable := False;
DTM := MSI_LoadDTM(whichItem);
end;

FISH_TROUT :
with MSI_Items[whichItem] do
begin
Name := 'Trout';
UpText := ['aw trout'];
ItemP := Point(0, 0);
Colors := [11843005];
Tol := 5;
Stackable := False;
DTM := MSI_LoadDTM(whichItem);
end;

FISH_PIKE :
with MSI_Items[whichItem] do
begin
Name := 'Pike';
UpText := ['aw pike'];
ItemP := Point(0, 0);
Colors := [10269852];
Tol := 5;
Stackable := False;
DTM := MSI_LoadDTM(whichItem);
end;

FISH_SALMON :
with MSI_Items[whichItem] do
begin
Name := 'Salmon';
UpText := ['aw salmon'];
ItemP := Point(0, 0);
Colors := [9606569];
Tol := 5;
Stackable := False;
DTM := MSI_LoadDTM(whichItem);
end;

FISH_TUNA :
with MSI_Items[whichItem] do
begin
Name := 'Tuna';
UpText := ['aw tuna'];
ItemP := Point(0, 0);
Colors := [9408662];
Tol := 5;
Stackable := False;
DTM := MSI_LoadDTM(whichItem);
end;

FISH_LOBSTER :
with MSI_Items[whichItem] do
begin
Name := 'Lobster';
UpText := ['aw lobster'];
ItemP := Point(0, 0);
Colors := [2046823];
Tol := 5;
Stackable := False;
DTM := MSI_LoadDTM(whichItem);
end;

FISH_SWORDFISH :
with MSI_Items[whichItem] do
begin
Name := 'Swordfish';
UpText := ['aw swordfish'];
ItemP := Point(0, 0);
Colors := [9264774];
Tol := 5;
Stackable := False;
DTM := MSI_LoadDTM(whichItem);
end;

{ FISH TOOLS ================================= ]
[============================================= }
FISH_SMALLNET:
with MSI_Items[whichItem] do
begin
Name := 'Small Fishing Net';
UpText := ['ishing net'];
ItemP := Point(0, 0);
Colors := [2569539];
Tol := 5;
Stackable := False;
DTM := MSI_LoadDTM(whichItem);
end;

FISH_CRAYPOT:
with MSI_Items[whichItem] do
begin
Name := 'Crayfish Cage';
UpText := ['rayfish cage'];
ItemP := Point(0, 0);
Colors := [5461079];
Tol := 5;
Stackable := False;
DTM := MSI_LoadDTM(whichItem);
end;

FISH_ROD:
with MSI_Items[whichItem] do
begin
Name := 'Fishing Rod';
UpText := ['ishing rod'];
ItemP := Point(0, 0);
Colors := [5197651];
Tol := 5;
Stackable := False;
DTM := MSI_LoadDTM(whichItem);
end;

FISH_BAIT:
with MSI_Items[whichItem] do
begin
Name := 'Fishing Bait';
UpText := ['ishing bait'];
ItemP := Point(0, 0);
Colors := [1605551];
Tol := 5;
Stackable := True;
DTM := MSI_LoadDTM(whichItem);
end;

FISH_FLY:
with MSI_Items[whichItem] do
begin
Name := 'Fly Fishing Rod';
UpText := ['ly fishing'];
ItemP := Point(0, 0);
Colors := [3355445];
Tol := 5;
Stackable := False;
DTM := MSI_LoadDTM(whichItem);
end;

FISH_FEATHER:
with MSI_Items[whichItem] do
begin
Name := 'Feather';
UpText := ['eather'];
ItemP := Point(0, 0);
Colors := [530952];
Tol := 5;
Stackable := False;
DTM := MSI_LoadDTM(whichItem);
end;

FISH_HARPOON:
with MSI_Items[whichItem] do
begin
Name := 'Harpoon';
UpText := ['arpoon'];
ItemP := Point(0, 0);
Colors := [6052960];
Tol := 5;
Stackable := False;
DTM := MSI_LoadDTM(whichItem);
end;

FISH_CAGE:
with MSI_Items[whichItem] do
begin
Name := 'Lobster Pot';
UpText := ['obster pot'];
ItemP := Point(0, 0);
Colors := [6184546];
Tol := 5;
Stackable := False;
DTM := MSI_LoadDTM(whichItem);
end;


SKILL_FISHING:
case Items[i] of
FISH_SHRIMP : e := 10.0;
FISH_CRAYFISH : e := 10.0;
FISH_SARDINE : e := 20.0;
FISH_HERRING : e := 30.0;
FISH_ANCHOVIE : e := 40.0;
FISH_TROUT : e := 50.0;
FISH_PIKE : e := 60.0;
FISH_SALMON : e := 70.0;
FISH_TUNA : e := 80.0;
FISH_LOBSTER : e := 90.0;
FISH_SWORDFISH : e := 100.0;


TOOL_FISH:
for j := FISH_SMALLNET to FISH_CAGE do
Result := CombineIntArray(Result, MSI_FindItemSlots(j));


And this goes in mainloop.scar (SetupPlayer)

I need feedback on this function:

TOOL_FISH:
begin
gameTabs := [TAB_EQUIP, TAB_INV];
FishingTool := MSI_FishingTools;
if (Length(FishingTool) <= 0) then Exit;

for j := 0 to High(gameTabs) do
begin
Result := MSI_FindTool(FishingTool[0], gameTabs[j], x, y);
if (Length(FishingTool) > 1) then
Result := MSI_FindTool(FishingTool[1], gameTabs[j], x, y); // There are only ever two tools.
end;

//if tool isn't found, will attempt to withdraw from bank
if (not Result) then
begin
if (script.BankType = NoBank) then
begin
MSI_Debug('MSI_SetupPlayer', 'Failed to find required tool', DEBUG_FUNCTIONS);
Exit;
end;

case (MSI_Players[CurrentPlayer].Location) of
LOC_VE_BANK:
bankCheck := MSI_OpenBank(MSI_BANK_VE, MSI_Players[CurrentPlayer].Pin);

LOC_DB_BANK:
bankCheck := MSI_OpenBank(MSI_BANK_DB, MSI_Players[CurrentPlayer].Pin);

LOC_FE_BANK:
bankCheck := MSI_OpenBank(MSI_BANK_FE, MSI_Players[CurrentPlayer].Pin);

LOC_GE_BANK:
bankCheck := MSI_OpenBank(MSI_BANK_GE, MSI_Players[CurrentPlayer].Pin);

LOC_PS_DBOX:
bankCheck := MSI_OpenBank(DBOX_PS, MSI_Players[CurrentPlayer].Pin);

else
MSI_Debug('MSI_SetupPlayer', 'Invalid PlayerLocation', DEBUG_FUNCTIONS);
end;

if bankCheck then
if MSI_Withdraw([FishingTool], [1]) then
begin
Result := True;
Break;
end else begin
CloseBank;
MSI_Debug('MSI_PlayerSetup', 'Couldn''t Withdraw Tool', DEBUG_FUNCTIONS);
end
else
MSI_Debug('MSI_SetupPlayer', 'Unable to Open Bank', DEBUG_FUNCTIONS);
end;
end;
Some of these things have already been put in this thread, but this is a complete list (I think) of what I have added so far.

Still todo:

Fishspot finding
Waiting while fishing
Fish full inventory

Will all go in Fishing.scar

Other than that, I don't know if anything else is needed. If someone would like to help me with waiting for the fishing, I would really appreciate it, but other than that, I should have everything ready for beta powerfishing testing pretty soon.

Coh3n

2010-07-25 13:37:08

MSI_FishingTools needs to be edited a little in case the user wants to fish at multiple fishing spots (i.e. bait and net). You're missing a for loop anyway because ObjectConstants is an array, not just an integer.

{******************************************************************************}
{ Function MSI_FishingTools : TIntegerArray }
{ By: 3Garrett3 }
{ Date: 25 July 2010 }
{ Description: Figures out which tool the script needs to use }
{******************************************************************************}
Function MSI_FishingTools : TIntegerArray;
var
script: TScript;
i: Integer;
begin
script := MSI_Scripts[MSI_Players[CurrentPlayer].Scripts[CurrentScript]];

for i := 0 to High(script.ObjectConstants) do
case (script.ObjectConstants[i]) of
FISHSPOT_NET:
Result := CombineIntArray(Result, [FISH_SMALLNET]);

FISHSPOT_BAIT:
Result := CombineIntArray(Result, [FISH_ROD, FISH_BAIT]);

FISHSPOT_LURE:
Result := CombineIntArray(Result, [FISH_FLY, FISH_FEATHER]);

FISHSPOT_CAGE:
Result := CombineIntArray(Result, [FISH_CAGE]);

FISHSPOT_HARPOON:
Result := CombineIntArray(Result, [FISH_HARPOON]);

else
MSI_Debug('MSI_FishingTools', 'Invalid Fishing Spot', DEBUG_FUNCTIONS);
end;

ClearSameIntegers(Result);
end;
This way it will get all the required tools for all the spots the user wants to fish at. :)

I said this in the thread Shut made, but we should rename the fish constants to include "RAW" –> FISH_RAW_SHRIMP. In that part you added to MSI_SetupPlayer you repeated a lot of unnecessary code. We should only need that banking stuff written once. And in your MSI_Withdraw part, you don't need FishingTool in square brackets as it's an integer array. Also, the var should probably be called FishingTools as it does hold the multiple tools.


for j := 0 to High(gameTabs) do
begin
Result := MSI_FindTool(FishingTool[0], gameTabs[j], x, y);
if (Length(FishingTool) > 1) then
Result := MSI_FindTool(FishingTool[1], gameTabs[j], x, y); // There are only ever two tools.
end;
^ You don't need to gameTabs thing as none of the fishing tools can be equipped. You should also have if (Length(FishingTool)>1) and Result then because otherwise it could still result true if the first tool isn't found.

{******************************************************************************}
{ function MSI_SetupPlayer: Boolean; }
{ By: Coh3n }
{ Date: 17 July 2010 }
{ Description: Sets up the player for autoing }
{******************************************************************************}
function MSI_SetupPlayer: Boolean;
var
bestTool, worstTool, x, y, i, j , k: Integer;
bankCheck: Boolean;
gameTabs, FishingTool: TIntegerArray;
script: TScript;
begin
if (not LoggedIn) then
LoginPlayer;

script := MSI_Scripts[MSI_Players[CurrentPlayer].Scripts[CurrentScript]];
Inc(Stats_CustomVars[STATS_LOGINS]);
MSI_SendStats;

SetAngle(True);
RunEnergy(20);

for i := 0 to High(script.ScriptTools) do
case script.ScriptTools[i] of
//first looks for the best tool depending on the player's skill level
TOOL_HATCHET, TOOL_PICKAXE:
begin
bestTool := MSI_BestTool;
worstTool := MSI_WorstTool;
gameTabs := [TAB_EQUIP, TAB_INV];

for j := 0 to High(gameTabs) do
for k := bestTool downto worstTool do
if (MSI_FindTool(k, gameTabs[j], x, y)) then
begin
Result := True;
Exit;
end;

for i := bestTool downto worstTool do
begin
l := Length(withdrawArr);
SetLength(withdrawArr, l + 1);
withdrawArr[l] := i;
end;
end;

TOOL_FISH:
begin
FishingTools := MSI_FishingTools;

if (Length(FishingTools) <= 0) then
Exit;

Result := MSI_FindTool(FishingTool[0], TAB_INV, x, y);
if (Length(FishingTool) > 1) and Result then
Result := MSI_FindTool(FishingTool[1], TAB_INV, x, y); // There are only ever two tools.

withdrawArr := FishingTools;
end;

else
MSI_Debug('MSI_SetupPlayer', 'Invalid tool option in script: ' + script.ScriptName, DEBUG_FUNCTIONS);
end;

//if tools aren't found, will attempt to withdraw from bank
if (not Result) then
begin
if (script.BankType = NoBank) then
begin
MSI_Debug('MSI_SetupPlayer', 'Failed to find required tool', DEBUG_FUNCTIONS);
Exit;
end;

case (MSI_Players[CurrentPlayer].Location) of
LOC_VE_BANK:
bankCheck := MSI_OpenBank(MSI_BANK_VE, MSI_Players[CurrentPlayer].Pin);

LOC_DB_BANK:
bankCheck := MSI_OpenBank(MSI_BANK_DB, MSI_Players[CurrentPlayer].Pin);

LOC_FE_BANK:
bankCheck := MSI_OpenBank(MSI_BANK_FE, MSI_Players[CurrentPlayer].Pin);

LOC_GE_BANK:
bankCheck := MSI_OpenBank(MSI_BANK_GE, MSI_Players[CurrentPlayer].Pin);

LOC_PS_DBOX:
bankCheck := MSI_OpenBank(DBOX_PS, MSI_Players[CurrentPlayer].Pin);

else
MSI_Debug('MSI_SetupPlayer', 'Invalid PlayerLocation', DEBUG_FUNCTIONS);
end;

if bankCheck then
for k := bestTool downto worstTool do
if (MSI_Withdraw([k], [1])) then
begin
Result := True;
Break;
end else begin
CloseBank;
MSI_Debug('MSI_PlayerSetup', 'Couldn''t Withdraw Tool', DEBUG_FUNCTIONS);
end
else
MSI_Debug('MSI_SetupPlayer', 'Unable to Open Bank', DEBUG_FUNCTIONS);
end;
end;
You know what, that whole function basically needs to be rewritten because it wouldn't really work for multiple tools. I'm going to work on it now.

E: NVM, it doesn't need to be rewritten. The above one just needs to be tweaked and tested with multiple tools. :)

3Garrett3

2010-07-25 20:50:28


{==============================================================================\
| MSI Group Scripting Include |
| Fishing.scar |
|==============================================================================|
| For all fishing routines. |
| |
| * function MSI_FishingTools() * by 3Garrett3 |
| * procedure MSI_WaitWhileFishing(); * by 3Garrett3 |
| * function MSI_Fish(); * by 3Garrett3 |
| * function MSI_FishInvFull(); * by 3Garrett3 |
| |
| |
\ _____________________________________________________________________________}

{******************************************************************************}
{ Function MSI_FishingTools : TIntegerArray }
{ By: 3Garrett3 }
{ Date: 25 July 2010 }
{ Description: Figures out which tool the script needs to use }
{******************************************************************************}
Function MSI_FishingTools : TIntegerArray;
var
script: TScript;
i: Integer;
begin
script := MSI_Scripts[MSI_Players[CurrentPlayer].Scripts[CurrentScript]];

for i := 0 to High(script.ObjectConstants) do
case (script.ObjectConstants[i]) of
FISHSPOT_NET:
Result := CombineIntArray(Result, [FISH_SMALLNET]);

FISHSPOT_BAIT:
Result := CombineIntArray(Result, [FISH_ROD, FISH_BAIT]);

FISHSPOT_LURE:
Result := CombineIntArray(Result, [FISH_FLY, FISH_FEATHER]);

FISHSPOT_CAGE:
Result := CombineIntArray(Result, [FISH_CAGE]);

FISHSPOT_HARPOON:
Result := CombineIntArray(Result, [FISH_HARPOON]);

else
MSI_Debug('MSI_FishingTools', 'Invalid Fishing Spot', DEBUG_FUNCTIONS);
end;

ClearSameIntegers(Result);
end;

{******************************************************************************}
{ Procedure MSI_WaitWhileFishing }
{ By: 3Garrett3 }
{ Date: 25 July 2010 }
{ Description: Waits while fishing }
{******************************************************************************}
procedure MSI_WaitWhileFishing;
var
OldInvCount, WaitTime, InvTimer, cts, CheckTime : Integer;
MyChar : TBox;
script: TScript;
TColour, TTol, THue, TSat, TCount, AvCount, i : Integer;
Tools : TPointArray;
ToolAmount : TIntegerArray;
begin
Flag;
Wait(RandomRange(300, 450));
if InvFull then
Exit;
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
MyChar := IntToBox( 205, 121, 338, 219);
script := MSI_Scripts[MSI_Players[CurrentPlayer].Scripts[CurrentScript]];

// Have a case to determine what colours/tols/hue/sat to look for and what counts of it

case (script.ObjectConstants[i]) of
FISHSPOT_NET:
begin
TColour:= 2108472;
TTol := 11;
THue := 0.09;
TSat := 0.27;
TCount := 50;
end;

FISHSPOT_BAIT:
begin
TColour:= 727589;
TTol := 4;
THue := 0.17;
TSat := 0.65;
TCount := 50;
end;

FISHSPOT_LURE: // Still not done
begin
TColour:= 2108472;
TTol := 11;
THue := 0.09;
TSat := 0.27;
TCount := 50;
end;

FISHSPOT_CAGE: // Still not done
begin
TColour:= 2108472;
TTol := 11;
THue := 0.09;
TSat := 0.27;
TCount := 50;
end;

FISHSPOT_HARPOON: // Still not done
begin
TColour:= 2108472;
TTol := 11;
THue := 0.09;
TSat := 0.27;
TCount := 50;
end;
end;

SetToleranceSpeed2Modifiers(THue, TSat); // Set the vars and such
WaitTime := GetSystemTime + 90000;
OldInvCount := InvCount;
MarkTime(InvTimer);

repeat

MSI_FindRandoms;
MSI_AntiBan(RandomRange(0, 3000), ANTI_BAN_CHANCE);

if (TimeFromMark(InvTimer) > 30000) then // If no new fish in inv after 30 seconds, spot probably moved
if (OldInvCount = InvCount) then break
else begin
OldInvCount := InvCount;
MarkTime(InvTimer);
end;

MarkTime(CheckTime);
repeat // Counts the occurance of a tool colour on the MS
FindColorsSpiralTolerance(MMCX, MMCY, Tools, TColour, Me.X1, Me.Y1, Me.X2, Me.Y2, TTol);
CombineIntArray(ToolAmount, [Length(Tools)]); // adds the length of the tool array (how many instances found)
Wait(55);
until(TimefromMark(CheckTime) > 1000)
AvCount := AverageTIA(ToolAmount);
if AvCount < TCount then break; // If count of tool on MS is less, it should be done fishing

Wait(RandomRange(200, 500));

until(t > GetSystemTime)

ColorToleranceSpeed(cts);
end;

{******************************************************************************}
{ Function MSI_Fish : Boolean }
{ By: 3Garrett3 }
{ Date: 25 July 2010 }
{ Description: Finds the fishing spot }
{******************************************************************************}
function MSI_Fish(Which: TIntegerArray): Boolean;
var
Fish: TMSObjectArray;
SearchBox: TBox;
Index: Integer;
begin
Fish := MSI_GetObjects(Which);
SearchBox := MSBox;

if MSI_FindObjectsIn(Fish, Index, SearchBox, ClickLeft) then
begin
Result := True;
MSI_WaitWhileFishing;
end;
end;

{******************************************************************************}
{ Function MSI_FishInvFull : Boolean }
{ By: 3Garrett3 }
{ Date: 25 July 2010 }
{ Description: Fishes until full inventory }
{******************************************************************************}
function MSI_FishInvFull(Which: TIntegerArray): Boolean;
var
t: Integer;
Begin
t := (GetSystemTime + (5 * 60000));
while (not InvFull) and (LoggedIn) and (GetSystemTime < T) do
begin
if MSI_Fish(Which) then
t := (GetSystemTime + (5 * 60000));
Wait(RandomRange(300, 800));
end;
Result := InvFull;
end;

This is what I have so far, it doesn't compile and Simba keeps telling me the wrong line, but it's a type mismatch of some sort, so I'll have to look through it sometime.

If anyone has any suggestions for this, then I'd greatly appreciate it, if not, I'll be testing it tomorrow :)

Coh3n

2010-07-25 22:55:11

The Color, Tol, Hue, Sat in there - are those the same as the object records? Or are they of the fishing equipment? Also, where's the "Me" type come from?

Nava2

2010-07-25 23:59:51

So, this wasn't really an issue back in the day..

But you're getting a lot of constants. Perhaps its time to start using bitwise constants, they allow you to do some cool things you probably didn't think you could do with a simple number ;)

http://compsci.ca/v3/viewtopic.php?t=9893

3Garrett3

2010-07-26 04:30:29

From: Coh3n
The Color, Tol, Hue, Sat in there - are those the same as the object records? Or are they of the fishing equipment? Also, where's the "Me" type come from?


They are seperate colours, they have a different colour on the main screen. The "Me" type was "MyChar" to start, it just got lost in the transfer I guess. I'll have to fix that, obviously :P

From: Nava2
So, this wasn't really an issue back in the day..

But you're getting a lot of constants. Perhaps its time to start using bitwise constants, they allow you to do some cool things you probably didn't think you could do with a simple number ;)

http://compsci.ca/v3/viewtopic.php?t=9893


I'll have to look through that too, after work :(

Edit:

So I've looked through the bitwise operator stuff, it's wayy over my head, and I dont have time to read it in extreme detail until later tonight, hopefully I understand then..