SRL Archive - MSI Bugs

/MSI/Skill functions


NCDS

2010-07-05 16:10:47

Looking at the functions we have in Woodcutting.scar currently, I see no reason why those same functions wouldn't work for Mining.scar.

The only thing I can see that makes them specifically Woodcutting functions is the var/function names themselves. Everything else all comes back to what TMSObjInfo is used.

That begin said, assuming that marpis' FindObjectsTPA can find the Iron rocks at VEM, which it looks like it should be able to, I don't see a reason why these functions couldn't be used for both Mining and Woodcutting.

Unless I'm missing something, the only thing that would need to be done is generalize the function and var names. Otherwise, I would basically be writing the same functions, just with different names to put into Mining.scar.

Please discuss and let me know your feeling's on this.

3Garrett3

2010-07-05 20:38:09

From: NCDS
Looking at the functions we have in Woodcutting.scar currently, I see no reason why those same functions wouldn't work for Mining.scar.

The only thing I can see that makes them specifically Woodcutting functions is the var/function names themselves. Everything else all comes back to what TMSObjInfo is used.

That begin said, assuming that marpis' FindObjectsTPA can find the Iron rocks at VEM, which it looks like it should be able to, I don't see a reason why these functions couldn't be used for both Mining and Woodcutting.

Unless I'm missing something, the only thing that would need to be done is generalize the function and var names. Otherwise, I would basically be writing the same functions, just with different names to put into Mining.scar.

Please discuss and let me know your feeling's on this.


Just waiting for the rock is different, except it's much easier than woodcutting because there is only one ore per rock.

I was thinking about this today for fishing, I have everything except waiting down, and I don't know how to do it.

NCDS

2010-07-05 20:42:59

From: 3Garrett3
Just waiting for the rock is different, except it's much easier than woodcutting because there is only one ore per rock.

But incase someone else get's the ore before you, the rock itself should also be watched, not just the inventory. In which case, I would use the same method marpis used for the woodcutting.

Although, seeing as the Woodcutting functions don't watch the Inventory I guess this may not work as I had thought. I would still like to hear from others as well though.

From: 3Garrett3

I was thinking about this today for fishing, I have everything except waiting down, and I don't know how to do it.


Do a CountColor of the fishing spot in front of you, then when the color decreases drastically, it is gone.

3Garrett3

2010-07-05 20:46:57

From: NCDS
But incase someone else get's the ore before you, the rock itself should also be watched, not just the inventory.


True, true.

The function can be relatively the same as the woodcutting one then, is what you're getting at, right?

I have you on msn but you aren't online. I'd like to chat about the fishing part because it isn't that simple, without threadjacking.

maniac234 at hotmail

NCDS

2010-07-05 20:57:24

From: 3Garrett3
True, true.

The function can be relatively the same as the woodcutting one then, is what you're getting at, right?

Yes, it would be basically the same exact thing, just watching the inventory too I guess.

From: 3Garrett3

I have you on msn but you aren't online. I'd like to chat about the fishing part because it isn't that simple, without threadjacking.

maniac234 at hotmail

Added you.

Coh3n

2010-07-05 21:53:30

From: NCDS
But incase someone else get's the ore before you, the rock itself should also be watched, not just the inventory. In which case, I would use the same method marpis used for the woodcutting.

Although, seeing as the Woodcutting functions don't watch the Inventory I guess this may not work as I had thought. I would still like to hear from others as well though.

Pretty sure the WaitWhileChopping function has an inventory check in it as a failsafe incase the player isn't actually cutting, but the script thinks it is (but it's not the primary waiting method). I see no reason why the WaitWhileChopping wouldn't work for mining, but we'd have to test.

Also, yes, try to avoid duplicating code. If the same functions can be used, then use them. :)

NCDS

2010-07-05 21:55:20

From: Coh3n
Pretty sure the WaitWhileChopping function has an inventory check in it as a failsafe incase the player isn't actually cutting, but the script thinks it is (but it's not the primary waiting method). I see no reason why the WaitWhileChopping wouldn't work for mining, but we'd have to test.

Also, yes, try to avoid duplicating code. If the same functions can be used, then use them. :)


Sounds good.

As far as the name of the function and the var names go…what am I to do about that? As well as placement of the functions that will be used for both?

Coh3n

2010-07-05 22:01:20

From: NCDS
Sounds good.

As far as the name of the function and the var names go…what am I to do about that? As well as placement of the functions that will be used for both?

MSI_WaitWhileMinecutting; MSI_AutoTrock, MSI_TrineInvFull. :p

No, but seriously I don't now. The file could be renamed to Woodcutting_Mining.scar I guess. Or, if these functions can't be used for several skills, we could just use the Skills.scar file and get rid of /Skills/Woodcutting.scar altogether.

Blumblebee

2010-07-05 22:04:54

From: NCDS
Sounds good.

As far as the name of the function and the var names go…what am I to do about that? As well as placement of the functions that will be used for both?


could we use something like pointers?


WaitStyle[X] := @WaitWhileTask;

alternatively we could complicate it by adding

a) More Constants/Variables
b) More Parameters to the function

or instead of bunging up the include and making things hard to read we can make a specialized WaitWhileMining() which in my opinion is the smartest way to go seeing as our goal with MSI was making this easily communicative and readable. Recycling functions starts to add confusion.

even if we went


function WaitWhileMining(Parameters): Boolean;
begin
WaitWhileChopping();
end;

that would be more readable imo.

NCDS

2010-07-05 22:06:21

From: Coh3n
MSI_WaitWhileMinecutting; MSI_AutoTrock, MSI_TrineInvFull. :p

No, but seriously I don't now. The file could be renamed to Woodcutting_Mining.scar I guess. Or, if these functions can't be used for several skills, we could just use the Skills.scar file and get rid of /Skills/Woodcutting.scar altogether.

:p
Do you mean can? Cause that's kinda what I was thinking at first since the original Skills.scar is empty still.

From: Blumblebee

even if we went


function WaitWhileMining(Parameters): Boolean;
begin
WaitWhileChopping();
end;

that would be more readable imo.

That's not a bad idea if we can't think of a way to name them together or anything. I may actually like that better anyways, just for clarity.

Coh3n

2010-07-06 05:55:59

From: NCDS
:p
Do you mean can? Cause that's kinda what I was thinking at first since the original Skills.scar is empty still.

Lol, wow what's that? The 100th time you've corrected me? :rolleyes:

From: NCDS

That's not a bad idea if we can't think of a way to name them together or anything. I may actually like that better anyways, just for clarity.

I actually don't mind that either. :)

marpis

2010-07-06 07:16:30

The easiest and simplest thing is just to write own functions for Mining.
  1. WaitWhileChopping and WaitWhileMining will have different color checks.
  2. Avoiding stupid and hard to understand function names, such as "AutoObjInvFull(..)"
  3. In Mining we could have it hover the next rock already while mining? In Woodcutting that's not necessary.
  4. Makes things easier for people trying to study Mining.simba/Woodcutting.simba

NCDS

2010-07-06 13:11:29

From: Coh3n
Lol, wow what's that? The 100th time you've corrected me? :rolleyes:


I actually don't mind that either. :)

You work hard though, no worries ;)

From: marpis
The easiest and simplest thing is just to write own functions for Mining.
  1. WaitWhileChopping and WaitWhileMining will have different color checks.
  2. Avoiding stupid and hard to understand function names, such as "AutoObjInvFull(..)"
  3. In Mining we could have it hover the next rock already while mining? In Woodcutting that's not necessary.
  4. Makes things easier for people trying to study Mining.simba/Woodcutting.simba

I can do that without a problem, it's just that Mining.simba will basically be a copy of Woodcutting.simba.

Sir R. M8gic1an

2010-07-09 07:03:08

From: NCDS

I can do that without a problem, it's just that Mining.simba will basically be a copy of Woodcutting.simba.


Rather that than a massive confusion. I'll have a look later and see what I can come up with as well.

~RM

marpis

2010-07-15 15:10:48

So, why is there a whole new finder system for rocks?

NCDS

2010-07-15 15:31:27

From: marpis
So, why is there a whole new finder system for rocks?


Accuracy and ease of use.

By MSI_FindRock returning a Boolean and a T2DArray, it can be used in multiple way's.

The finding work's excellent, have you tried it? :)

I still have a bit of editing to do with WaitWhileMining; I want to add in a Text check as well as make the InvCount check more reliable.

Coh3n

2010-07-15 17:21:14

From: NCDS
By MSI_FindRock returning a Boolean and a T2DArray, it can be used in multiple way's.

Shouldn't it be able to work the same way ChopTree does?

NCDS

2010-07-15 18:19:24

From: Coh3n
Shouldn't it be able to work the same way ChopTree does?


MineRock does operate very similar to ChopTree. MSI_FindRock is really the only difference.

Coh3n

2010-07-15 23:23:41

From: NCDS
MineRock does operate very similar to ChopTree. MSI_FindRock is really the only difference.

But I mean the whole system. You may have told me this, but does it not work by just doing some thing like:

MSI_FindObjects(Objects, ...);
Or is it not accurate enough?

NCDS

2010-07-15 23:41:18

I don't think I ever tried.

After all the threads I was under the impression that there would be separate functions for the mining.

FindRock is also easier to work with due to the T2DArray it returns.

Sir R. M8gic1an

2010-07-16 08:03:15

I was relooking through it… And I couldn't find any reason as to why you would need a T2DArray.

MineRock does Middle TPA - therefore no need for 2D
WaitWhileMining has a small search box and doesn't really take into account the fact that it's a T2D array. And if you had a TPA with a length > 1 from FindObjs you would know you have several objects around you.

I say it should be reverted to FindObjs, as I see no reason for having a separate function.

As for accuracy, things can be added and manipulated inside FindObj ;)

~RM

NCDS

2010-07-16 12:11:20

From: Rasta Magician
I was relooking through it… And I couldn't find any reason as to why you would need a T2DArray.

MineRock does Middle TPA - therefore no need for 2D
WaitWhileMining has a small search box and doesn't really take into account the fact that it's a T2D array. And if you had a TPA with a length > 1 from FindObjs you would know you have several objects around you.

I say it should be reverted to FindObjs, as I see no reason for having a separate function.

As for accuracy, things can be added and manipulated inside FindObj ;)

~RM


That's so boring :(

I'll change it though that's not a problem :)

I'm going to try and take a nap for a little while, and I'm leaving later this afternoon for the weekend, but I'll try and get this done before I go.

Edit: I've started but I'm about out of time. I'll have it committed on Monday.

Coh3n

2010-07-18 15:58:49

Okay, let's try to straighten out this confusion (NCDS and I were talking, and we're both confused). Basically what I've gathered from this thread is that we've accomplished nothing. It was suggested to use wrapper functions for Mining.scar.

function MSI_WaitWhileMining(): Boolean;
begin
Result := MSI_WaitWhileChopping();
end;
It was also suggested that we create separate functions for Mining.scar to make them more customizable for that skill (which is what we currently have). Then once this was done, it was suggested to revert back to using MSI's object finding.

Now, when marpis suggested writing separate functions for Mining.scar, I don't know if he meant whole new object finding functions as well (currently MSI_FindRock). The thing is, if we were to write whole new functions, MSI_MineRock and MSI_MineInvFull would be identical to MSI_ChopTree and MSI_ChopInvFull. MSI_WaitWhileMining may be slightly different, but 90% of it would be the same.

I would like to get this all straightened out so we (NCDS, mainly) don't waste anymore of our time on something that may get completely rewritten the next day.

[INDENT]My suggestion
If MSI_ChopTree and MSI_ChopInvFull work well for mining, we should use them. I still don't mind the wrapper function idea. I do think we should write another WaitWhileMining because there are a few new things that can be added that apply only to mining.[/INDENT]

Now, let's get this sorted out. :rolleyes:

Sir R. M8gic1an

2010-07-18 16:03:56

If they are the same, wrap them.

If they differ anywhere, then keep them separate.

What I think will come out at the end (further on, with more skills added) is we'll find we can just group some of them together and make a generalized function.

~RM

NCDS

2010-07-18 20:05:20

Well here is what I have right now:

{==============================================================================\
| MSI Group Scripting Include |
| Mining.scar |
|==============================================================================|
| For all mining routines. |
| |
| * procedure MSI_WaitWhileMining(); * by NCDS |
| * function MSI_MineRock(); * by NCDS |
| * function MSI_MineInvFull(); * by NCDS & marpis |
\ _____________________________________________________________________________}

{******************************************************************************}
{ Procedure MSI_WaitWhileMining(RockInfo: TMSObject); }
{ By: NCDS }
{ Date: 11 July 2010 }
{ Description: Wait's until an Ore has been mined. }
{******************************************************************************}
Procedure MSI_WaitWhileMining(RockInfo: TMSObject);
var
cts, OldInvCount, t, i, RockColorCount: Integer;
MDAr: T2DPointArray;
Arr: array of TPoint;
SearchBox: TBox;
begin
Flag;
Wait(RandomRange(285, 450));

if InvFull then
Exit;

cts := GetColorToleranceSpeed;
SetToleranceSpeed2Modifiers(RockInfo.Hue, RockInfo.Sat);

t := GetSystemTime + 60000;

SearchBox := IntToBox(
MSCx - Round(RockInfo.W * 1.50),
MSCy - Round(RockInfo.H * 1.50),
MSCx + Round(RockInfo.W * 1.50),
MSCy + Round(RockInfo.H * 1.50));

OldInvCount := InvCount;

repeat
for i := 0 to High(RockInfo.Colors) do
begin
FindColorsTolerance(MDAr[i], RockInfo.Colors[i], SearchBox.x1,
SearchBox.y1, SearchBox.x2, SearchBox.y2, RockInfo.Tol);
if (Length(MDAr[i]) > RockInfo.Accuracy) then
Arr := CombineTPA(MDAr[i], Arr);
end;

if Length(Arr) < 1 then
Break;

RockColorCount := Length(Arr);

if (Length(Arr) < Round(RockColorCount * 0.50)) then
Break;

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

if (OldInvCount < InvCount) then
Break;

Wait(RandomRange(200, 500));

until(t > GetSystemTime) or (Length(Arr) < Round(RockColorCount * 0.50));

SetColorToleranceSpeed(cts);
end;

{******************************************************************************}
{ function MSI_MineRock(Which: TIntegerArray): Boolean; }
{ By: NCDS }
{ Date: 11 July 2010 }
{ Description: Mines Rock }
{******************************************************************************}
function MSI_MineRock(Which: TIntegerArray): Boolean;
var
Rocks: TMSObjectArray;
SearchBox: TBox;
Index: Integer;
begin
Rocks := MSI_GetObjects(Which);
SearchBox := IntToBox(MSx1, MSy1, MSx2, MSy2);

if MSI_FindObjectsIn(Rocks, Index, SearchBox, ClickLeft) then
begin
Result := True;
MSI_WaitWhileMining(Rocks[Index]);
end;
end;

{******************************************************************************}
{ function MSI_MineInvFull(Which: TIntegerArray): Boolean; }
{ By: NCDS & mapris }
{ Date: 11 July 2010 }
{ Description: Mines Rock's until Inventory is full. }
{******************************************************************************}
function MSI_MineInvFull(Which: TIntegerArray): Boolean;
var
t: Integer;
begin
t := (GetSystemTime + (5 * 60000));
while (not(InvFull)) and LoggedIn and (GetSystemTime < t) do
begin
if MSI_MineRock(Which) then
t := (GetSystemTime + (5000 * 60000));
Wait(RandomRange(300, 600));
end;
Result := InvFull;
end;

I keep getting an Invalid Number of parameters error on line 78, which is one of the function headers…not sur what's up with that.

I'll keep messing with it though.

Also, if that's not what you meant tell me and I'll change it to whatever.

Coh3n

2010-07-18 20:42:37

By wrappers we mean:

function MSI_WaitWhileMining(): Boolean;
begin
Result := MSI_WaitWhileChopping();
end;
Which by the looks of it would work for MineRock and MineInvFull. Also, I get a lot of errors like that in Simba. It highlights a line that's nowhere near the error.

Probably something that should be reported.

Good job, though. :)

NCDS

2010-07-18 20:45:44

From: Coh3n
By wrappers we mean:

function MSI_WaitWhileMining(): Boolean;
begin
Result := MSI_WaitWhileChopping();
end;
Which by the looks of it would work for MineRock and MineInvFull. Also, I get a lot of errors like that in Simba. It highlights a line that's nowhere near the error.

Probably something that should be reported.

Good job, though. :)


Yeah I know what you meant by wrappers, I just wanted to avoid it.

You could definitely use that for MineInvFull, I don't know as you would want to for MineRock though.

If you do want to however, I will just have to change around WaitWhileMining();

Sir R. M8gic1an

2010-07-19 06:23:48

you're calling WaitWhileChopping, but you have WaitWhileMining just above.. ;)

~RM

NCDS

2010-07-19 07:30:03

From: Rasta Magician
you're calling WaitWhileChopping, but you have WaitWhileMining just above.. ;)

~RM


Typo! :duh:

Fixed.

Coh3n

2010-07-19 09:40:50

From: NCDS
Yeah I know what you meant by wrappers, I just wanted to avoid it.

You could definitely use that for MineInvFull, I don't know as you would want to for MineRock though.

If you do want to however, I will just have to change around WaitWhileMining();

If they're different, leave them different. Just at a glance they looked the same. :p

But yeah, no sense in repeating code, use a wrapper for MineInvFull.