SRL Archive - MSI Suggestions

Multiple Script Support


Coh3n

2010-12-15 03:16:41

Due to this topic being brought up here recently, I thought it would be a good idea to actually suggest it in case someone would like to try to get it working. :) It's been talked about in the SL section, but was never outlined to the community. It is also one of our earliest "Coming Soon" features that no one has really gotten around to doing. Now that we have Cstrike's World Walker implemented as an Extra, it can be used to walk to the next script location if necessary.

MSI is already written to support multiple scripts as (if you've looked through the code) you've probably noticed that MSI_Players[].Scripts is an array of TScriptSetup, and the variable CurrentScript is used throughout the include. So, with the include already written like that, this really shouldn't be a difficult feature to finish up.

The original plan was to have CurrentScript work basically the same as CurrentPlayer (in SRL), and I see no reason why that can't be done. Since all the skill setup functions include withdrawing the required tools, only a few functions need to be written.
  • MSI_NextScript
  • I think this would be best suited in Scripts.simba, and all it would do is the necessary steps to move on to the next script in the player's scripts array. Let's look at an example of a player setup to run 3 different scripts:

    with MSI_Players[1] do
    begin
    Name := '';
    Pass := '';
    Nick := '';
    Pin := '';
    Active := True;
    Member := False;
    Location := ;
    BreakLoads := 0;
    BreakTime := 0;
    TotalLoads := 0;
    TotalTime := 0;

    with Scripts[0] do
    begin
    Name := SCRIPT_VE_MINER;
    end;

    with Scripts[1] do
    begin
    Name := SCRIPT_VE_OAKS;
    end;

    with Scripts[2] do
    begin
    Name := SCRIPT_BBV_FISHER;
    end;
    end;
    MSI_NextScript would have to Inc(CurrentScript) and then walk to the starting location for the next script. In the case of the first two scripts, that wouldn't be necessary since they have the same starting location. If MSI's setup procedures were done correctly, all MSI_NextScript would have to do is increase CurrentScript and then start at the beginning of the mainloop. In the case of Script[1] to Script[2], Cstrike's World Walker would be called to walk from Varrock East Bank to Draynor Bank. Once in Draynor bank, all you should have to do is start back at the beginning of the mainloop.
  • Knowing when to switch to the next script
  • Like NCDS suggested in the other thread:
    From: NCDS
    We could just make LoadsToDo and TimeToRun be script specific vars, then TotalTime and Time/LoadsBeforeBreak be global. Doesn't seem like that would take too much at all.
    Sounds pretty good to me. :) We will have to remember to set CurrentScript back to 0 after switching players to avoid out of range errors. We would then check (after switching players) the new player's Script's LoadsToDo and/or TimeToRun attributes and set CurrentScript accordingly to ensure we start with the right script.
  • The smaller, yet important things
  • We have to be sure that if there is any walking involved in changing scripts, that the player's location is reset, otherwise the new script won't work. A LevelBeforeSwitch variable would be nice so the player will use that script until it's at a certain level.
  • Additional Features
  • These don't have to be done, but they are nice ideas that have been suggested.
    From: lordsaturn
    How about the user can create their own function to handle script switching.
    Scripts[1].SwitchFunc := @SwitchFunc;
    Scripts[2].SwitchFunc := @SwitchFunc2;
    Scripts[3].SwitchFunc := @SwitchOnLevel;

    function SwitchFunc: Boolean;
    begin
    Result := LoadsDone > 50 or TimeFromMark(ScriptStart) > 10*60*1000;
    end;

    function SwitchFunc2: Boolean;
    begin
    Result := TookABreak;
    end;
Like always, things will be added as they come up. If you think about it, this really isn't difficult at all and I think it's a pretty good project if you're interested to familiarize yourself with the MSI include.

Gu3st...

2010-12-15 10:49:53

Sounds good :)
I'd like a LevelBeforeSwitch variable too, so that I could auto wc to level 40 then go mining to level 60 in one go.

I am not too sure about cstrikes world walker now that he's gone offline…

One thing I am wondering about; Scripts[0] for Player1 isn't the same as Script[0] for player2, is it?
In the tutorial it says "Note that Scripts[0] does not correspond to the player number. It will be Scripts[0] for EVERY player! If you confuse this, you will get an Out of range error." that's why I am so confused about this..

mormonman

2010-12-15 11:53:09

From: Zyt3x
Sounds good :)
I'd like a LevelBeforeSwitch variable too, so that I could auto wc to level 40 then go mining to level 60 in one go.

I am not too sure about cstrikes world walker now that he's gone offline…


I like the level switching idea. CStrike's walker will be fine.

lordsaturn

2010-12-15 13:09:56

How about the user can create their own function to handle script switching.
Scripts[1].SwitchFunc := @SwitchFunc;
Scripts[2].SwitchFunc := @SwitchFunc2;
Scripts[3].SwitchFunc := @SwitchOnLevel;

function SwitchFunc: Boolean;
begin
Result := LoadsDone > 50 or TimeFromMark(ScriptStart) > 10*60*1000;
end;

function SwitchFunc2: Boolean;
begin
Result := TookABreak;
end;

Gu3st...

2010-12-15 13:32:42

That seems like a good idea lordsaturn :)

mormonman

2010-12-15 13:54:03

But also have some default ones that will be in the include.

Gu3st...

2010-12-15 14:17:44

From: mormonman
But also have some default ones that will be in the include.
Yes, of course :)

Coh3n

2010-12-15 14:38:58

From: Zyt3x
Sounds good :)
I'd like a LevelBeforeSwitch variable too, so that I could auto wc to level 40 then go mining to level 60 in one go.

I am not too sure about cstrikes world walker now that he's gone offline…

One thing I am wondering about; Scripts[0] for Player1 isn't the same as Script[0] for player2, is it?
In the tutorial it says "Note that Scripts[0] does not correspond to the player number. It will be Scripts[0] for EVERY player! If you confuse this, you will get an Out of range error." that's why I am so confused about this..

I added the LevelToSwitch to the first post.

I don't understand what you're confused about… the scripts array for each player have nothing to do with each other.

From: lordsaturn
How about the user can create their own function to handle script switching.
Scripts[1].SwitchFunc := @SwitchFunc;
Scripts[2].SwitchFunc := @SwitchFunc2;
Scripts[3].SwitchFunc := @SwitchOnLevel;

function SwitchFunc: Boolean;
begin
Result := LoadsDone > 50 or TimeFromMark(ScriptStart) > 10*60*1000;
end;

function SwitchFunc2: Boolean;
begin
Result := TookABreak;
end;

I like the idea, but we'll have to make sure that the custom switch functions also handle the walking and stuff when necessary. I would rather concentrate on getting it working, then worry about extra stuff. I'll still add it to the first post. :)

NCDS

2010-12-15 15:28:01

From: Zyt3x

One thing I am wondering about; Scripts[0] for Player1 isn't the same as Script[0] for player2, is it?
In the tutorial it says "Note that Scripts[0] does not correspond to the player number. It will be Scripts[0] for EVERY player! If you confuse this, you will get an Out of range error." that's why I am so confused about this..


Every player has their own script array starting at 0. ;)

Gu3st...

2010-12-15 15:37:01

From: Coh3n
I don't understand what you're confused about… the scripts array for each player have nothing to do with each other.
Thanks, that's what I though :)

edggy

2011-01-24 21:20:23

I was playing around / looking at the msi code and I got cstrike's walker to work. I am able to go from script to script without worrying about my player being in the right place. It is very cool. cstrike's script works it is just missing a "SetupNodesAndPaths" at he beginning. Hope to see this work!

Coh3n

2011-01-24 21:33:45

From: edggy
I was playing around / looking at the msi code and I got cstrike's walker to work. I am able to go from script to script without worrying about my player being in the right place. It is very cool. cstrike's script works it is just missing a "SetupNodesAndPaths" at he beginning. Hope to see this work!

Wo wo wo, it walks from the first script to the second and starts autoing?

Gu3st...

2011-01-25 09:31:56

I though it was unfinished…. :O

edggy

2011-01-25 11:48:36

It doesn't go from script to script. But any of the banking scripts can start anywhere in the free world. It walks to the bank and then starts the script. It in theory could go from script to script I haven't tried.

tom99

2011-01-25 12:34:56

why not just interscarmessage to provoke another script ?

Gu3st...

2011-01-25 14:03:41

From: tom99
why not just interscarmessage to provoke another script ?
There is no interscarmessage in Simba, and I don't think you get the main point of this thread, which is how to add suport for multiple scripts in MSI :)

Coh3n

2011-01-25 14:35:35

From: edggy
It doesn't go from script to script. But any of the banking scripts can start anywhere in the free world. It walks to the bank and then starts the script. It in theory could go from script to script I haven't tried.

Oh, nice. Mind posting the .diff?

(without the space)