SRL Archive - MSI Bugs

Going to loc with InvFull


Sir R. M8gic1an

2010-09-06 05:27:29

The bug is what the thread tittle says.

The mainloop & high level procs need more logic

~RM

NCDS

2010-09-06 11:13:23

I'm assuming your talking about going from the bank?

Coh3n

2010-09-06 14:21:40

What…? Are you talking about right when the script is started? That's the only time I can think of this happening..

Sir R. M8gic1an

2010-09-07 03:11:34

Well.. I paused it and played around a little bit. I usually put logic in my scripts for it to always be able to detect what it should be doing, in case anything went strange, so that it never loses track of itself. Not really necessary I guess.

e: just checked, it does happen at script start as well

~RM

Coh3n

2010-09-07 14:40:35

From: Sir R. Magician
Well.. I paused it and played around a little bit. I usually put logic in my scripts for it to always be able to detect what it should be doing, in case anything went strange, so that it never loses track of itself. Not really necessary I guess.

e: just checked, it does happen at script start as well

~RM

Yeah, I don't think there's a InvFull check before it goes to the location.

NCDS

2010-09-07 19:18:27

Does anyone object to using a label? That's what I do in my personal scripts.

if we add the Slot attribute to the TScript record as being discussed in this thread: http://villavu.com/forum/showthread.php?t=58822
Then we could make the MainLoop go something like this:

repeat
MarkTime(time);

// Walk to location if using a bankable script
if (not (MSI_Scripts[MSI_Players[CurrentPlayer].Scripts[CurrentScript]].BankType = NoBank)) then
begin
//Could use something like this:
if ((Slot > 0) and (InvCount > 1)) or ((Slot = 0) and (InvCount > 0)) then
goto Bank;
//or something like this:
if Length(MSI_FindItemSlots(..)) > 1 then
goto Bank;
if (not MSI_Walk(True)) then
begin
if (MSI_TimedOut) then
Break;

MSI_UnsetPlayer('MSI_MainLoop', 'Failed to walk to location', False);
Break;
end;
end;

// Perform the skill
if (not MSI_AutoObjects) then
begin
if (MSI_TimedOut) then
Break;

MSI_UnsetPlayer('MSI_MainLoop', 'Failed to use script: ' + IntToStr(CurrentScript), True);
Break;
end;

Bank: //Could be here to make sure we are at the bank...
if (not (MSI_Scripts[MSI_Players[CurrentPlayer].Scripts[CurrentScript]].BankType = NoBank)) then
begin
if (not MSI_Walk(False)) then // Walk to the bank
begin
if (MSI_TimedOut) then
Break;

MSI_UnsetPlayer('MSI_MainLoop', 'Failed to walk to bank', False);
Break;
end;

//Or here to just assume we're at the bank.
if (not MSI_BankMaterials) then // Bank the materials
begin
if (MSI_TimedOut) then
Break;

MSI_UnsetPlayer('MSI_MainLoop', 'Failed to bank materials', False);
Break;
end;
end;

// Set the progress report times
with ProgressReportArray[CurrentPlayer] do
begin
IncEx(PlayerTime, TimeFromMark(time));
IncEx(ScriptInfo[CurrentScript].Runtime, TimeFromMark(time));
end;

MSI_ProgressReport;
MSI_WritePlayerINI;

with ProgressReportArray[CurrentPlayer] do
if (LoadsDone >= (MSI_Players[CurrentPlayer].Loads[L_TOTAL] + RandomRange(-10, 10))) then
begin
MSI_UnsetPlayer('MSI_MainLoop', 'Finished total loads!', True);
Break;
end;

Inc(tmpLoads);
if (tmpLoads >= (MSI_Players[CurrentPlayer].Loads[L_BREAK] + RandomRange(-2, 2))) then
begin
MSI_HandleBreaking;
MSI_FindRandoms;
Break;
end;

until(not MSI_Players[CurrentPlayer].Active);

Just throwing out an idea.

Coh3n

2010-09-07 21:21:04

I don't particularly like labels, but that looks like it should work. I think this would work better:

if (InvCount > Length(MSI_FindAllToolSlots)) then
goto Bank;
That way if there's more items than just the tools, it will bank. :)

NCDS

2010-09-08 00:34:00

From: Coh3n
I don't particularly like labels, but that looks like it should work. I think this would work better:

if (InvCount > Length(MSI_FindAllToolSlots)) then
goto Bank;
That way if there's more items than just the tools, it will bank. :)


Tested and committed :)

Gu3st...

2010-09-08 14:27:41

I honestly hate labels… I just use a repeat…until(True) loop, and use Break; or Continue;

NCDS

2010-09-08 14:30:00

From: Zyt3x
I honestly hate labels… I just use a repeat…until(True) loop, and use Break; or Continue;


Wouldn't work as well with MSI's MainLoop though. The label keeps it nice, neat, and clean.

Sir R. M8gic1an

2010-09-08 17:59:54

if not InvFull then walk … no?

e: well if we consider runecrafting, we'd be walking with a full inv..

~RM

Coh3n

2010-09-09 01:09:38

From: Sir R. Magician
if not InvFull then walk … no?

e: well if we consider runecrafting, we'd be walking with a full inv..

~RM

Could have a skill case in the mainloop so that depending on the skill, it would check for a full inventory. Fighting would be like runcrafting, you'd want a full inventory of food. I'm sure there are other examples also.

E: Just got an idea. Why not add an AtBank attribute to TLocation, then just call something like this in the mainloop?

if (MSI_Locations[MSI_Players[CurrentPlayer].Location].AtBank) then
Deposit
else
AutoObjects();

E: Committed. :)