SRL Archive - MSI Archives

Magic.Scar?


nickrules

2010-06-07 21:09:26

Would a magic skill include be useful? I began work on one that can alch, or curse NPCs (like the monk of zammorak in varrock castle). I can see little use to teleporting, although I can add it, and attacking seems less than useful, as NPCs would have to be added as objects for each new monster.

Just wanted to know if it would be of use at all, or if not, should I just abandon this little project?

Awkwardsaw

2010-06-07 21:26:59

there already is one, :)

srl/srl/skills/magic.scar

Sir R. M8gic1an

2010-06-08 04:41:36

Have a look through SRL's Magic.scar ;

And have a look through MSI's WoodCutting.scar

We're not expecting a function to cast a spell in MSI, rather for it to cast several of them or so on.

Function AlchItem(i: integer): boolean;
Function AlchAll(i, NatureRuneSpot: integer): boolean;


As for attacking the monsters.. It's not so hard as MSI has a whole setup for it. For us they are MSObjects like any others. There is not a distinction between object and NPC as there is for reflection.

I'll let you think about it, feel free to ask any questions :)

~RM

Sir R. M8gic1an

2010-06-08 13:10:19

I just re-read your post. Your little project sounds good ;)

~RM

nickrules

2010-06-08 16:41:22

From: Rasta Magician
I just re-read your post. Your little project sounds good ;)

~RM


ah, thanks :P anybody want to suggest something to add?

@RM
I can't remember where I read this, but there was a poll about supporting personal projects like SPAMS2. Anyway, my thought was, what if you used SPAMS2 once at the beginning of the script, and as it walked, you logged where/when you clicked the mouse on the minimap, storing it into an array of some sort. This array could be used as a path, loaded into a walking procedure, and then reverse the array and use it for a return path.

Sir R. M8gic1an

2010-06-08 17:40:05

From: nickrules
ah, thanks :P anybody want to suggest something to add?

@RM
I can't remember where I read this, but there was a poll about supporting personal projects like SPAMS2. Anyway, my thought was, what if you used SPAMS2 once at the beginning of the script, and as it walked, you logged where/when you clicked the mouse on the minimap, storing it into an array of some sort. This array could be used as a path, loaded into a walking procedure, and then reverse the array and use it for a return path.


This has been thought of before, but it is not viable, because the minimap slightly rotates without changing the angle, (randomly).

~RM

nickrules

2010-06-08 21:45:23

Does anybody have any more suggestions for this? otherwise, I wouldn't mind some assistance on how to add this into the MSI, so that it can be tested.
And, for adding items, I don't understand how (D)DTMs are set up for items in MSI.

    HATCHET_BRONZE..HATCHET_RUNE:
Result := [ 586, 243, 587, 249, 574, 261, 575, 248, 587, 240 ];
in that little example from iteminfo.scar's MSI_GetDTMInfo function, what are the numbers for?
is 586, and 243 the x and y for one point?
and then 587 the x for another point, and 247 the y?

Coh3n

2010-06-08 22:37:12

From: nickrules
Does anybody have any more suggestions for this? otherwise, I wouldn't mind some assistance on how to add this into the MSI, so that it can be tested.
And, for adding items, I don't understand how (D)DTMs are set up for items in MSI.

    HATCHET_BRONZE..HATCHET_RUNE:
Result := [ 586, 243, 587, 249, 574, 261, 575, 248, 587, 240 ];
in that little example from iteminfo.scar's MSI_GetDTMInfo function, what are the numbers for?
is 586, and 243 the x and y for one point?
and then 587 the x for another point, and 247 the y?

Yes, sorry. I'm not sure if that's explained in the guide or not, but that was my fault for not making it more clear. The first 2 numbers are the coordinates of the first point of the DTM and so on. However, it depends on what item you're making a record for. I don't think we plan on having DDTMs for every item. Only those that are the same shape and are differentiated only by colour (like hatchets, and pickaxes).

As for making the script work, you need to make a list of exactly what you want the script to do. For example,

A NPC Fighter
  • An NPC TMSObject record
  • DDTMs of all the staffs (one DTM with the mainPoint color being different for each staff)
  • Functions
    • MSI_MageNPC(which: Integer); Just an example, where 'which' would be the object constant. Inside that function you would call MSI_LoadObject(which); (not sure if that's the exact function).

There are other things that would need to be changed as a new skill would be added to the include, such as the editing of some progress report functions and the addition of some constants.

This may seem like a lot right now, but what I think you should do is begin small. So begin by making an item record of the items you'll need (staffs, runes, food maybe?), and test them. You can then move on to casting the spell, etc.

Be sure to post everything here for discussion. After all, we want everyone to help. :)

Sir R. M8gic1an

2010-06-09 11:08:05

http://villavu.com/forum/showthread.php?t=57205

You might find this useful when starting to write new modules ;)

~RM

Frement

2010-06-09 11:11:15

So we can write new scripts to MSI?

Sir R. M8gic1an

2010-06-09 11:16:24

From: Frement
So we can write new scripts to MSI?


Yes. Pretty much.

Read through the guide and you will know what is already there.
eg: Use MSI's banking system over any of the SRL banking systems.

If you find there is something that could be added to the MSI Core, then go ahead and make it / post it / so on.

You can't make "new" scripts, you can "add" scripts to the "main script".

(I guess you could make new scripts, using the MSI Include on top of the SRL Include, but these wouldn't be part of MSI.)

MSI is expandable :) So yes, go ahead and add stuff! Post it up and the SLs will take care of it ;)

~RM

Coh3n

2010-06-09 17:16:50

To add to what RM said, there's a lot of specific things that need to be done when adding scripts/skills. Those really aren't something you need to worry about, but would be helpful to have that information in the back of your mind. Also, a lot of it is required for, say, the progress report to work properly.

nickrules

2010-06-10 00:16:39

FOR ITEMINFO.SCAR

Here is the DDTM for runes:
    RUNES_AIR..RUNES_CHAOS:
Result := [ 912, 435, 912, 449, 919, 423, 898, 439, 926, 435 ];

Colors:
RUNE_AIR:        Result := 13882333;
RUNE_BODY: Result := 855309;
RUNE_MIND: Result := 472373;
RUNE_EARTH: Result := 801369;
RUNE_WATER: Result := 10164502;
RUNE_FIRE: Result := 1450139;
RUNE_LAW: Result := 13968158;
RUNE_NATURE: Result := 1342481;
RUNE_CHAOS: Result := 2005717;

Some of those colors may return false positives on the wrong rune, as the white is used in several, and the black in a few too….

Staff DDTM
    STAFF_AIR..STAFF_FIRE:
Result := [ 869, 598, 868, 596, 865, 604, 879, 583, 860, 610 ];

Colors: (note, I assume they are all the same, but have not checked…)
    STAFF_AIR:       Result := 1003888;
STAFF_WATER: Result := 1003888;
STAFF_EARTH: Result := 1003888;
STAFF_FIRE: Result := 1003888;

OBJECTS.SCAR
     OBJ_ENEMY_EVILMONK: // nickrules
With Result Do
Begin
Name := 'Evil Monk';
UpText := 'onk of Zam';
Option := 'Cast';
Colors := [10058855,8809562,7889233,10518892];
Exp := 29;
Tol := 14;
Hue := 0.6;
Sat := 0.11;
FindAllColors := False;
W := 20;
H := 30;
Accuracy := 10;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := true;
WaitToMove := False;
BadColors := [];
BadColorTolerance := 10;
End;

I attached magic.scar (for the skills folder of MSI).

Feedback? suggestions? improvements? Note that none of htis has been tested (except for reset spellbook….)

Before I post this, I already know I'm forgetting something, but I cant think of it at the moment, so whatever :P

Sir R. M8gic1an

2010-06-10 07:16:51


{==============================================================================\
| MSI Group Scripting Include |
| Magic.scar |
|==============================================================================|
| For all woodcutting routines. |
| |
| * function MSI_ResetSpellbook(); * by nickrules |
| * function MSI_Curse(): Boolean; * by nickrules |
| * function MSI_Alch(): Boolean; * by nickrules |
\ _____________________________________________________________________________}


//http://villavu.com/repositories/srl-opendev/SRL/skill/Magic.scar
//Spellbook functions are already available
//took the time to fix standards as well
function MSI_ResetSpellbook: boolean;
var
DTM,x,y: integer;
begin
//gametab(28);
gametab(tab_magic);

//these DTMs should be loaded from somewhere central.
//Maybe we need to make MSI_LoadDTM
DTM := DTMFromString('78DA630C60626038C0C8800C5EDD3C0AA661A' +
'28CEE986AFEFDFB87AA2618A8E60C01358140353BF1AB010073E3' +
'0FCB');
{
if not finddtm(dtm,x,y,MIX1,MIY1,MIX2,MIY2) then
//begin --> no need for being & end, as it is only one line
mouse(592,451,5,5,true);
//end;
}
if not findDTM(DTM, x, y, MIX1, MIY1, MIX2, MIY2) then
mouse(592, 451, 5, 5, true);

FreeDTM(DTM);
{
you have to free the DTM,
because when you load another one you lose the
'refference' to this one and therefore
memory leak
}

DTM := DTMFromString('78DA634C63626038C2C8800A189148209D025' +
'4B31355CDBF7FFF50D5E4639A83A12615A8E60C0135B140358750' +
'D58808F1A0A8010073BD0F05');
if(not(finddtm(dtm,x,y,MIX1,MIY1,MIX2,MIY2)))then
begin
mouse(614,451,5,5,true);
end;
DTM := DTMFromString('78DA63AC62626038C2C88002BA0F832998286' +
'32150CD515435FFFEFD43550332672701352D4035878830E734AA' +
'1A11211E14350068D510BA');
if(not(finddtm(dtm,x,y,MIX1,MIY1,MIX2,MIY2)))then
begin
mouse(634,451,5,5,true);
end;
DTM := DTMFromString('78DA639CC0C4C070849101196C8BF402D3305' +
'1C6764C3522423CA86AFA816ACEA0AAF9F7EF1FAA9A3EA09A5D04' +
'CC9909547310BF3900E5CD0E67');
if(not(finddtm(dtm,x,y,MIX1,MIY1,MIX2,MIY2)))then
begin
mouse(654,451,5,5,true);
end;
DTM := DTMFromString('78DA639CC0C4C070849101196C8BF402D3305' +
'1C6764C3522423CA86AFA816ACEA0AAF9F7EF1FAA9A3EA09A5D04' +
'CC9909547310BF3900E5CD0E67');
if(not(finddtm(dtm,x,y,MIX1,MIY1,MIX2,MIY2)))then
begin
mouse(684,451,5,5,true);
end;
DTM := DTMFromString('78DA633462626038CCC88002422AC1144C945' +
'113A8E620AA9A7FFFFEA1AA0199B393801A2BA09A43A86A9ACA53' +
'50D59863BAA7B212D53D003EED0E63');
if(finddtm(dtm,x,y,MIX1,MIY1,MIX2,MIY2))then
begin
mouse(562,451,5,5,true);
end;
result := true;
FreeDTM(DTM);
end;

Function MSI_Curse(which: Integer): boolean;
var
x, y: integer;
monk: TMSObject;
begin
monk := MSI_GetObject(Which);

repeat
MSI_FindRandoms;
MSI_AntiBan(RandomRange(0, 5000), ANTI_BAN_CHANCE);
MSI_ResetSpellbook;

if(FindColorTolerance(x,y,14165953,679,243,704,264,10))then //Is the spell lit up? (castable)
begin
mouse(692,255,8,8,true);
if(not(MSI_FindObject(monk, ClickLeft))) then
begin
//you might want failsafes instead of just setting the player to false
writeln(':| something failed...');
result := false;
NextPlayer(false);
exit;
end;
end;
until(false);
end;

Function MSI_Alch(item: integer): boolean;
var
x,y, DTM: integer;
begin

//MSI_LoadDTM
DTM := DTMFromString('78DA633CCECCC070929101196832338169982' + //high alch DTM
'8E30EA09A0BA86AA418D1D49C01AA398FAA86119D3E0954B31FBF1A0' +
'0473706A1');


MSI_ResetSpellbook;
repeat
MSI_FindRandoms;
MSI_AntiBan(RandomRange(0, 4000), ANTI_BAN_CHANCE);

if(not(finddtm(DTM,x,y,MIX1,MIY1,MIX2,MIY2)))then
begin
writeln('couldn''t find the high alch spell. exiting...');
result := false;
exit;
end;

mouse(x,y,8,8,true);
wait(randomrange(150,500));
MSI_ClickItems([item], ['Cast','High','ast','igh','evel']);
wait(randomrange(1500,2000));

until(false);

freedtm(dtm);
end;

About the rune & staff DTMS:
when choosing the main point color, try to choose a color unique to that item.

eg
Staff of air -> white partof staff
Astral rune -> bue part of rune

I'll post some more thoughts later. Good job so far :)

Read through Magic.scar ;)

~RM

nickrules

2010-06-10 08:56:10

From: Rasta Magician

About the rune & staff DTMS:
when choosing the main point color, try to choose a color unique to that item.

~RM


Oh wow, thanks.

fixed the colors for staves
STAFF_AIR: Result := 12235185;
STAFF_WATER: Result := 13115676;
STAFF_EARTH: Result := 4544635;
STAFF_FIRE: Result := 1845704;
and the dtm
STAFF_AIR..STAFF_FIRE:
Result := [ 878, 503, 859, 527, 877, 499, 871, 514, 874, 507 ];

All the colors on the runes should not be too similar, except for chaos… Could always just comment it out, as the air rune has the exact same color as the center of the chaos rune.

As for the begins and ends, I know its not needed, but I keep them there, because for me personally, its easier to follow whats happening in the code.

I was aware that SRL had its own reset spellbook, but I didn't want to include something else, and tbh, wanted to make my own.

Frement

2010-06-10 09:20:55

From: nickrules
Oh wow, thanks.

fixed the colors for staves
STAFF_AIR: Result := 12235185;
STAFF_WATER: Result := 13115676;
STAFF_EARTH: Result := 4544635;
STAFF_FIRE: Result := 1845704;
and the dtm
STAFF_AIR..STAFF_FIRE:
Result := [ 878, 503, 859, 527, 877, 499, 871, 514, 874, 507 ];

All the colors on the runes should not be too similar, except for chaos… Could always just comment it out, as the air rune has the exact same color as the center of the chaos rune.

As for the begins and ends, I know its not needed, but I keep them there, because for me personally, its easier to follow whats happening in the code.

I was aware that SRL had its own reset spellbook, but I didn't want to include something else, and tbh, wanted to make my own.


You know, there is a function called Cast() in SRL's Magic.scar

EDIT: Actually, are you doing a Monk of Zamorak curser? You might want to check out http://villavu.com/forum/showthread.php?t=56273 in that case, or in that case why not just port my script to MSI with the additions you want?

nickrules

2010-06-10 10:09:59

Although I did not entirely want to use magic.scar in the srl/skills folder, I figured I might as well use whats given to me. But I still plan on keeping my reset spellbook, lol.

Anyway, here is my more-than-likely unstable magic.scar for MSI.

{==============================================================================\
| MSI Group Scripting Include |
| Magic.scar |
|==============================================================================|
| For all woodcutting routines. |
| |
| * function MSI_ResetSpellbook(); * by nickrules |
| * function MSI_Curse(): Boolean; * by nickrules |
| * function MSI_Alch(): Boolean; * by nickrules |
\ _____________________________________________________________________________}
//{.include srl/srl/msi/setup.scar} //used to see if it compiled....
{.include srl/srl/skill/magic.scar}

{*****************************************************************************}
{ function MSI_ResetSpellbook: boolean; }
{ By: Nickrules }
{ Date: 10 June 2010 }
{ Description: Resets the spellbook to defaults. Yes, I know SRL has one too. }
{*****************************************************************************}

function MSI_ResetSpellbook: boolean;
var
DTM,x,y: integer;
begin
gametab(tab_magic);

DTM := DTMFromString('78DA630C60626038C0C8800C5EDD3C0AA661A' +
'28CEE986AFEFDFB87AA2618A8E60C01358140353BF1AB010073E3' +
'0FCB');
if not findDTM(DTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
mouse(592, 451, 5, 5, true);
end;
FreeDTM(DTM);

DTM := DTMFromString('78DA634C63626038C2C8800A189148209D025' +
'4B31355CDBF7FFF50D5E4639A83A12615A8E60C0135B140358750' +
'D58808F1A0A8010073BD0F05');
if not finddtm(dtm,x,y,MIX1,MIY1,MIX2,MIY2) then
begin
mouse(614,451,5,5,true);
end;
FreeDTM(DTM);
DTM := DTMFromString('78DA63AC62626038C2C88002BA0F832998286' +
'32150CD515435FFFEFD43550332672701352D4035878830E734AA' +
'1A11211E14350068D510BA');
if(not(finddtm(dtm,x,y,MIX1,MIY1,MIX2,MIY2)))then
begin
mouse(634,451,5,5,true);
end;
FreeDTM(DTM);
DTM := DTMFromString('78DA639CC0C4C070849101196C8BF402D3305' +
'1C6764C3522423CA86AFA816ACEA0AAF9F7EF1FAA9A3EA09A5D04' +
'CC9909547310BF3900E5CD0E67');
if(not(finddtm(dtm,x,y,MIX1,MIY1,MIX2,MIY2)))then
begin
mouse(654,451,5,5,true);
end;
FreeDTM(DTM);
DTM := DTMFromString('78DA639CC0C4C070849101196C8BF402D3305' +
'1C6764C3522423CA86AFA816ACEA0AAF9F7EF1FAA9A3EA09A5D04' +
'CC9909547310BF3900E5CD0E67');
if(not(finddtm(dtm,x,y,MIX1,MIY1,MIX2,MIY2)))then
begin
mouse(684,451,5,5,true);
end;
FreeDTM(DTM);
DTM := DTMFromString('78DA633462626038CCC88002422AC1144C945' +
'113A8E620AA9A7FFFFEA1AA0199B393801A2BA09A43A86A9ACA53' +
'50D59863BAA7B212D53D003EED0E63');
if(finddtm(dtm,x,y,MIX1,MIY1,MIX2,MIY2))then
begin
mouse(562,451,5,5,true);
end;
result := true;
FreeDTM(DTM);
end;


{*****************************************************************************}
{ function MSI_Curse(which: Integer): boolean; }
{ By: Nickrules }
{ Date: 10 June 2010 }
{ Description: Curses the NPC defined by which. }
{*****************************************************************************}

Function MSI_Curse(which: Integer): boolean;
var
x, y: integer;
NPC: TMSObject;
begin
MSI_Debug('MSI_Curse','Starting cursing...', Debug_Functions);
NPC := MSI_GetObject(Which);
makecompass('w');
MSI_ResetSpellbook;
repeat
MSI_FindRandoms;
MSI_AntiBan(RandomRange(0, 5000), ANTI_BAN_CHANCE);

if not cast('curse',false) then
begin
MSI_Debug('MSI_Curse','Couldn''t cast curse for whatever reason.', 10);
nextplayer(false);
result := false;
end;
MSI_FindObject(NPC,ClickLeft);
until(false);
end;

{*****************************************************************************}
{ function MSI_Alch(item: Integer): boolean; }
{ By: Nickrules }
{ Date: 10 June 2010 }
{ Description: High Alchs the item defined by item }
{*****************************************************************************}


Function MSI_Alch(item: integer): boolean;
var
x,y, DTM: integer;
begin

//MSI_LoadDTM
DTM := DTMFromString('78DA633CCECCC070929101196832338169982' + //high alch DTM
'8E30EA09A0BA86AA418D1D49C01AA398FAA86119D3E0954B31FBF1A0' +
'0473706A1');

MSI_Debug('MSI_Alch','Alching time :D', Debug_Functions);
MSI_ResetSpellbook;
repeat
MSI_FindRandoms;
MSI_AntiBan(RandomRange(0, 4000), ANTI_BAN_CHANCE);

if not cast('high level alchemy',false) then
begin
MSI_Debug('MSI_Alch','Couldn''t cast high level alchemy.', 10);
result := false;
exit;
end;

mouse(x,y,8,8,true);
wait(randomrange(150,500));
MSI_ClickItems([item], ['Cast','High','ast','igh','evel']);
wait(randomrange(1500,2000));

until(false);

freedtm(dtm);
end;

Sir R. M8gic1an

2010-06-10 10:34:58

nickrules, I think you will love a project that boreas will be running in the future - barebones. Me and boreas have discussed it an it is likely he will use MSI as a base.

Barebones will allow you to have a 'general script' for which you can just re-write the parts you want to re-write. (Giving you the opportunity to practice whatever you wish).

As for MSI, we will soon be using the GIT versioning system, which will allow you to have your own copy of MSI and pass it around to other people.

You are making a good use of the MSI functions already, but it seems to me that your player management could be improved. I would suggest you read some tutorials on multiplayer and read through the player management parts of MSI ;)

Great job so far!

As I am sure you can understand, your code isn't exactly amazing, although it is extremely good for a junior member. Due to this, I'll be discussing with the SLs how and under what conditions could we add your code to MSI.

There will need to be talks about what sort of code to allow into MSI, under what conditions and so on. (I already have a small idea in mind, but it has quite a few flaws / issues).

Have you tested your script yet?

~RM

nickrules

2010-06-10 11:58:27

I've tested everything that can be tested without modifying a ton of things in MSI (basically, if its an MSI function, I've commented it out.). and it works well. I think I will get around to making it run with MSI later today (or tomorrow, as I have plenty of plans for today), that way I can truly test it.

Frement

2010-06-10 12:18:32

From: nickrules
I've tested everything that can be tested without modifying a ton of things in MSI (basically, if its an MSI function, I've commented it out.). and it works well. I think I will get around to making it run with MSI later today (or tomorrow, as I have plenty of plans for today), that way I can truly test it.


What are you exactly making? Cause I was thinking of porting my Monk of Zamorak Abuser to MSI.

Coh3n

2010-06-10 12:23:55

Nick, you may find this thread useful when trying to make it work within MSI. Don't be afraid to post anything I've missed. I'll also have to add a whole section on what to do when adding new skills.

nickrules

2010-06-17 11:27:35

I'm back, and i finally got around to adding magic.scar. This is probably going to be a semi-long post.
——-
@Frement, feel free to port your script, as I made that one in like 5 minuets.

@Coh3n, Thanks for the link. It was fairly helpful, but I get an unknown identifier 'SKILL_MAGIC'. This shows up first in the mainloops Getbesttool function. So where exactly would I add skill_magic in this, so that I don't get that error?

—–

Also, multiple tools? Many skills require more than just one tool. Magic requires multiple runes, fishing needs bait/feathers (sometimes). Firemaking would require logs and a tinderbox. My point is, what about an array of tools? I don't think it would take too much work to modify the functions, but I'm not too sure…

I was getting an error (probably just my fault….) in reflection walking (unknown identifier reflectionbroken, or thereabouts), so i just tinkered around with that and *fixed* it.

I attached what I've done to my MSI folder if anyone is interested, although I've only modified
setup
objects
iteminfo
debug
mainloop
and globals

Also, MSI_ObjToText was removed(?), so I wont need to do anything with that anymore? (refering to this thread)

Coh3n

2010-06-17 17:52:40

From: nickrules

@Coh3n, Thanks for the link. It was fairly helpful, but I get an unknown identifier 'SKILL_MAGIC'. This shows up first in the mainloops Getbesttool function. So where exactly would I add skill_magic in this, so that I don't get that error?

You need to add it as a constant in Globals.scar. It will be set one greater than the previous item in the list. :)

From: nickrules

Also, multiple tools? Many skills require more than just one tool. Magic requires multiple runes, fishing needs bait/feathers (sometimes). Firemaking would require logs and a tinderbox. My point is, what about an array of tools? I don't think it would take too much work to modify the functions, but I'm not too sure…

Yeah you're right. I can't remember if it supports multiple tools, but it's definitely something we need to look at. I'm also going to be adding another part to DeclarePlayers that lets you choose the "Scripts" you want to run so you could run both a Varrock East Woodcutter and have it run Yew trees and Oak trees (just an example).


From: nickrules

I was getting an error (probably just my fault….) in reflection walking (unknown identifier reflectionbroken, or thereabouts), so i just tinkered around with that and *fixed* it.

That shouldn't happen… what did you do to fix it?

From: nickrules

I attached what I've done to my MSI folder if anyone is interested, although I've only modified
setup
objects
iteminfo
debug
mainloop
and globals

Also, MSI_ObjToText was removed(?), so I wont need to do anything with that anymore? (refering to this thread)

I've updated that thread and I also added the constants thing. Also, is there any way you can post the individual procedures you wrote/changed? It would make it a lot easier for us and it is a big include. I don't have the time to looks through all the files right now, but hopefully we can get this added soon. :)

Oh, and what "Script" did you add exactly? Like what exactly does it do when you choose to do Magic in the DeclarePlayers? Have you tested this script? Does the progress report work with what you changed? Just things I'd like to know so I can help along the developing process. :)

Sir R. M8gic1an

2010-06-17 19:16:04

skill_magic is in srl already. No need to add it in msi.

~RM

Coh3n

2010-06-17 23:12:05

From: Rasta Magician
skill_magic is in srl already. No need to add it in msi.

~RM

I forgot about those constants. :p It's actually SKILL_MAGE, so that's why you were getting an unknown identifier, nick.

nickrules

2010-06-18 10:31:31

From: Coh3n

That shouldn't happen… what did you do to fix it?


function MSI_PerformWalk(startLoc, endLoc: Integer): Boolean;
begin
MakeCompass('n');
RunEnergy(20);

{$IFDEF REFLECTION}
Result := MSI_ReflectionWalk(startLoc, endLoc);
{$ELSE}
Result := MSI_ColorWalk(startLoc, endLoc);
{$ENDIF}

end;
Thats what I did. Its a lot more flawed with a higher chance for something to go wrong, but I don't use reflection anyway, as I have found colour walking to be many times more reliable. is it because i'm running scar? I'll have to try it out in simba later…

From: Coh3n

I've updated that thread and I also added the constants thing. Also, is there any way you can post the individual procedures you wrote/changed? It would make it a lot easier for us and it is a big include. I don't have the time to looks through all the files right now, but hopefully we can get this added soon. :)



DEBUG.SCAR
I commented this line in MSI_ProgressReport;
//MSI_PrintSave(FileH, '{ ' + PadR('City: ' + PlayerCity, 59) + '}');

uncommented this in MSI_SkillActions(what: variant): TStringArray;
SKILL_MAGE : Result := ['Magic', 'Maged'];

SETUP.SCAR
Just added my magic.scar to the include list…

GLOBALS.SCAR
OBJ_ENEMY_EVILMONK = 10;
MSI_ITEM_COUNT = 24; //Is this number even correct?
RUNE_AIR = 17;
RUNE_BODY = 18;
RUNE_MIND = 19;
RUNE_EARTH = 20;
RUNE_WATER = 21;
RUNE_FIRE = 22;
RUNE_LAW = 23;
RUNE_NATURE = 24;
//RUNE_CHAOS = 26

STAFF_AIR = 27;
STAFF_WATER = 28;
STAFF_EARTH = 29;
STAFF_FIRE = 30;

REQ_HIGHALCH = 55; //I might add a
REQ_CURSE = 19;

ITEMINFO.SCAR
Added a bunch of crap, much of which is in one of my previous posts, as well as all this crap…. Which i will not be putting this this post, lol. I'll edit it in later…

From: Coh3n

Oh, and what "Script" did you add exactly? Like what exactly does it do when you choose to do Magic in the DeclarePlayers? Have you tested this script? Does the progress report work with what you changed? Just things I'd like to know so I can help along the developing process. :)


Well, ima go eat, and i've got some stuff to do, so i'll finish this post later.

Coh3n

2010-06-18 15:42:02

From: nickrules
function MSI_PerformWalk(startLoc, endLoc: Integer): Boolean;
begin
MakeCompass('n');
RunEnergy(20);

{$IFDEF REFLECTION}
Result := MSI_ReflectionWalk(startLoc, endLoc);
{$ELSE}
Result := MSI_ColorWalk(startLoc, endLoc);
{$ENDIF}

end;
Thats what I did. Its a lot more flawed with a higher chance for something to go wrong, but I don't use reflection anyway, as I have found colour walking to be many times more reliable. is it because i'm running scar? I'll have to try it out in simba later…

Yes, reflection is Simba only, that'll be why it wasn't working. However, that doesn't explain the unknown identifier error. Make sure you have a ReflectionBroken variable in Globals.scar.

From: nickrules

DEBUG.SCAR
I commented this line in MSI_ProgressReport;
//MSI_PrintSave(FileH, '{ ' + PadR('City: ' + PlayerCity, 59) + '}');

Why? I'm guessing that was for your own personal use?


From: nickrules

SETUP.SCAR
Just added my magic.scar to the include list…

You didn't take my advise earlier when I said to make a general function that will click all the spells. If we have more than one, we get into repeating code, which we don't want. :) Also, you said you know there's already a reset spell book function in SRL; does it not work?

From: nickrules

GLOBALS.SCAR
OBJ_ENEMY_EVILMONK = 10;
MSI_ITEM_COUNT = 24; //Is this number even correct?
RUNE_AIR = 17;
RUNE_BODY = 18;
RUNE_MIND = 19;
RUNE_EARTH = 20;
RUNE_WATER = 21;
RUNE_FIRE = 22;
RUNE_LAW = 23;
RUNE_NATURE = 24;
//RUNE_CHAOS = 26

STAFF_AIR = 27;
STAFF_WATER = 28;
STAFF_EARTH = 29;
STAFF_FIRE = 30;

REQ_HIGHALCH = 55; //I might add a
REQ_CURSE = 19;

That's good. I'd say you got all the naming right for the most part. I will probably make them OBJ_NPC_MONK_EVIL, and REQ_SPELL_ALCH_HIGH. Yes, I know they're long, but they need to be very specific. :)

To sum things up, awesome job! I'm really glad to see you contributing, and I'm excited to add Magic to MSI. :)

Sir R. M8gic1an

2010-06-19 15:04:24

SRL's magic.scar could have a nice TSpell type… humm.

~RM

nickrules

2010-06-20 09:25:33

problem fixed (disregard this is you didn't read the unedited post…)


How exactly would I make a general spell casting function? did you mean from scratch? I mean, with little effort, i could make a cheepo function that used cast from SRLs magic include that would look like this:?
——
Function MSI_Cast(spell :string; which, clicktype: integer; object: boolean): boolean;

spell would be the string of the spell, which is what object/item. clicktype could be a value of 0, 1 , or 2 (0 = nothing, 1 = left, 2 = right) object determines if it searches for an object or interacts with the inventory.
——

@RM what exactly would a TSpell be? and how would it be used? sorry, im noob :P

Coh3n

2010-06-20 20:02:18

From: nickrules
@RM what exactly would a TSpell be? and how would it be used? sorry, im noob :P

If you don't know types, search for types in the scripting guide in my signature. Basically it would be a type to store all the attributes of each spell.

type
TSpell = record
name: string;
requiredLevel: integer;
bookLocation: TBox;
end;
Something like that.

Frement

2010-06-20 20:05:43

Basically a structure in other languages :) (C++)

Coh3n

2010-06-20 20:11:44

From: Frement
Basically a structure in other languages :) (C++)

Yeah, like the attributes of a class in any OOP language (I think).

E: Magic.scar actually already has a TSpell type.

nickrules

2010-06-20 23:04:20

So would a TSpell even be needed? Although, with a TSpell, coords could be stored for every spell, name, etc.

My point is, a generic spell casting gizmo of sorts could be made (from scratch) with this. However, if SRL already has something for casting any spell, does the MSI project have any need for a new one?

Frement

2010-06-20 23:58:03

From: nickrules
So would a TSpell even be needed? Although, with a TSpell, coords could be stored for every spell, name, etc.

My point is, a generic spell casting gizmo of sorts could be made (from scratch) with this. However, if SRL already has something for casting any spell, does the MSI project have any need for a new one?


Well it has Cast()? My script doesn't use any custom functions, so it should work as long as SRL works.

Coh3n

2010-06-21 06:03:45

From: nickrules
So would a TSpell even be needed? Although, with a TSpell, coords could be stored for every spell, name, etc.

My point is, a generic spell casting gizmo of sorts could be made (from scratch) with this. However, if SRL already has something for casting any spell, does the MSI project have any need for a new one?

Well, MSI_Cast would be a function that casts a spell on any TMSObject. So, it would use SRL's Cast, along with the other necessary code for casting on an object.

nickrules

2010-06-21 10:12:57

From: Coh3n
Well, MSI_Cast would be a function that casts a spell on any TMSObject. So, it would use SRL's Cast, along with the other necessary code for casting on an object.


I figured thats what you intended. I'll get to work on that in a smidge. I'll also try an make it capable of interacting with the inventory….

Frement

2010-06-21 10:57:29

From: nickrules
I figured thats what you intended. I'll get to work on that in a smidge. I'll also try an make it capable of interacting with the inventory….


Can you explain why it needs to interact with the inventory?

nickrules

2010-06-21 11:13:32

From: Frement
Can you explain why it needs to interact with the inventory?


several spells interact with the inventory. alchs, superheat, enchants, etc.

Frement

2010-06-21 11:26:27

From: nickrules
several spells interact with the inventory. alchs, superheat, enchants, etc.


So the TSPell should have some kind of interact variable? Which could be used to identify that.

I don't think it needs coords as the SRL's Cast() already does that.

nickrules

2010-06-21 11:49:10

From: Frement
So the TSPell should have some kind of interact variable? Which could be used to identify that.


Maybe, by my original thought was the function itself would have a variable for that, and then, if it equals x then do _______.


From: Frement

I don't think it needs coords as the SRL's Cast() already does that.


I think we've decided there's no use for a TSpell, as SRL already has one.

Coh3n

2010-06-21 18:08:41

If the spell is one that switches right to the inventory, you can then just use MSI_ClickItems to click the item you want.

nickrules

2010-06-21 21:59:29

Well I'm going to be gone untill saturday, so untill then i wont be able to work on this or post about it.

Also, Coh3n, I was under the impression that the casting function (for MSI) should automatically interact with a given object, right? What I was saying is that it should automatically be capable of also interacting with the inventory using the MSI clickitems function. Sorry if i was unclear about that.

Anywho, I'll be back soon enough.

Coh3n

2010-06-22 06:01:59

From: nickrules
Also, Coh3n, I was under the impression that the casting function (for MSI) should automatically interact with a given object, right? What I was saying is that it should automatically be capable of also interacting with the inventory using the MSI clickitems function. Sorry if i was unclear about that.

Yes, it should. :) We may need to have a boolean parameter to determine whether the object to click is a TMSObject or a TItem.

nickrules

2010-06-29 10:06:46

Well, this is what I have so far, and its pretty much complete, just needs some testing/debugging, as I'm fairly sure it wont compile. lol.
Function MSI_Cast(spellname: string; which: TIntegerArray; IsObject: boolean): boolean;
var
NPC: TMSObject;
begin
if not cast(spellname, false) then
begin
MSI_DEBUG('MSI_Cast','Casting failed',10);
exit;
end;
if IsObject then
begin
NPC := MSI_GetObjects([Which]);
if MSI_FindObject(NPC,ClickLeft) then
begin
result := true;
exit;
end;
MSI_Debug('MSI_Cast','Object finding failed',5);
result := false;
exit;
end;
if MSI_ClickItems([which],'ast') then
begin
result := true;
exit;
end;
MSI_Debug('MSI_Cast','Item finding failed',5);
result := false;
exit;
end;

Always open for feedback, criticism, and improvements.

Coh3n

2010-06-29 19:58:53


//the parameter which needs to be just an integer as you've put it in [] in the function
function MSI_Cast(spellname: string; which: integer; IsObject: boolean): boolean;
var
NPC: TMSObject;
begin
if not cast(spellname, false) then
begin
MSI_DEBUG('MSI_Cast','Casting failed', DEBUG_FUNCTIONS); //use constants here
exit;
end;

if IsObject then
begin
NPC := MSI_GetObjects([Which]);
result := MSI_FindObject(NPC, ClickLeft);
if (not result) then
MSI_Debug('MSI_Cast','Object finding failed', DEBUG_FUNCTIONS);
end else
if MSI_ClickItems([which],'ast') then
begin
result := true;
exit;
end else
MSI_Debug('MSI_Cast','Item finding failed',5);
end;

Looks good, I don't see why it wouldn't work. Just needs testing. :)

nickrules

2010-07-15 22:41:12

blah. Its been awhile since I've been on SRL. MSI seems to be about 40 revisions ahead of me xD
I'll see what needs updating and update it. Then, unless there is an amazing tutorial on how to, i'll need help on making it "work" with MSI. And finally, someone would need to commit it.

Coh3n

2010-07-15 23:26:29

From: nickrules
blah. Its been awhile since I've been on SRL. MSI seems to be about 40 revisions ahead of me xD
I'll see what needs updating and update it. Then, unless there is an amazing tutorial on how to, i'll need help on making it "work" with MSI. And finally, someone would need to commit it.

A guide is here. The only thing you really need to worry about is making sure it works. :) Us SL's will worry about making all the necessary changes to the include to make it work. Of course, it won't hurt for you to try to add it yourself as it will make you more knowledgeable of the include. ;)

nickrules

2010-07-16 23:44:06

Bleh, I'm not sure how well the new function (MSI_Loop_Cast, just added it) will work, or, if it even compiles (running xubuntu, simba doesn't seem to work well…)

Doh! (forgot to upload file.) Have fun SLs

Coh3n

2010-07-17 00:45:09

From: nickrules
Bleh, I'm not sure how well the new function (MSI_Loop_Cast, just added it) will work, or, if it even compiles (running xubuntu, simba doesn't seem to work well…)

Doh! (forgot to upload file.) Have fun SLs

Awesome, I'm glad to see you're still working on this. I"m going to try and take a better look at this within the next few days. I'm pretty busy this weekend, but I should be able to find some time. :)

E: I've added my comments. I only did until the end of MSI_Cast.

{==============================================================================\
| MSI Group Scripting Include |
| Magic.scar |
|==============================================================================|
| For all woodcutting routines. |
| |
| * function MSI_ResetSpellbook(); * by nickrules |
| * function MSI_Curse(): Boolean; * by nickrules |
| * function MSI_Alch(): Boolean; * by nickrules |
\ _____________________________________________________________________________}
{.include srl/srl/msi/setup.scar} //used to see if it compiled....
{.include srl/srl/skill/magic.scar}

{*****************************************************************************}
{ function MSI_ResetSpellbook: boolean; }
{ By: Nickrules }
{ Date: 10 June 2010 }
{ Description: Resets the spellbook to defaults. }
{*****************************************************************************}


function MSI_ResetSpellbook: boolean; //is this still needed?
var
DTM,x,y: integer;
begin
gametab(tab_magic);
SortBook(0);
SetSpellMode(True, True, True, True);
ToggleDefCast(False);
{DTM := DTMFromString('78DA630C60626038C0C8800C5EDD3C0AA661A' +
'28CEE986AFEFDFB87AA2618A8E60C01358140353BF1AB010073E3' +
'0FCB');
if not findDTM(DTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
mouse(592, 451, 5, 5, true);
end;
FreeDTM(DTM);

DTM := DTMFromString('78DA634C63626038C2C8800A189148209D025' +
'4B31355CDBF7FFF50D5E4639A83A12615A8E60C0135B140358750' +
'D58808F1A0A8010073BD0F05');
if not finddtm(dtm,x,y,MIX1,MIY1,MIX2,MIY2) then
begin
mouse(614,451,5,5,true);
end;
FreeDTM(DTM);
DTM := DTMFromString('78DA63AC62626038C2C88002BA0F832998286' +
'32150CD515435FFFEFD43550332672701352D4035878830E734AA' +
'1A11211E14350068D510BA');
if(not(finddtm(dtm,x,y,MIX1,MIY1,MIX2,MIY2)))then
begin
mouse(634,451,5,5,true);
end;
FreeDTM(DTM);
DTM := DTMFromString('78DA639CC0C4C070849101196C8BF402D3305' +
'1C6764C3522423CA86AFA816ACEA0AAF9F7EF1FAA9A3EA09A5D04' +
'CC9909547310BF3900E5CD0E67');
if(not(finddtm(dtm,x,y,MIX1,MIY1,MIX2,MIY2)))then
begin
mouse(654,451,5,5,true);
end;
FreeDTM(DTM);
DTM := DTMFromString('78DA639CC0C4C070849101196C8BF402D3305' +
'1C6764C3522423CA86AFA816ACEA0AAF9F7EF1FAA9A3EA09A5D04' +
'CC9909547310BF3900E5CD0E67');
if(not(finddtm(dtm,x,y,MIX1,MIY1,MIX2,MIY2)))then
begin
mouse(684,451,5,5,true);
end;
FreeDTM(DTM);
DTM := DTMFromString('78DA633462626038CCC88002422AC1144C945' +
'113A8E620AA9A7FFFFEA1AA0199B393801A2BA09A43A86A9ACA53' +
'50D59863BAA7B212D53D003EED0E63');
if(finddtm(dtm,x,y,MIX1,MIY1,MIX2,MIY2))then
begin
mouse(562,451,5,5,true);
end;
result := true;
FreeDTM(DTM); }
end;

{*****************************************************************************}
{ function MSI_Cast(spellname: string; which: integer; IsObject: boolean): boolean;}
{ By: Nickrules }
{ Date: 28 June 2010 }
{ Description: Casts a given spell on a given object/item. }
{*****************************************************************************}
Function MSI_Cast(spellname: string; which: Integer; IsObject: boolean): boolean;
var
NPC: TMSObject; //don't need this since we can use MSI_Objects
begin
if not cast(spellname, false) then
begin
MSI_DEBUG('MSI_Cast','Casting failed', DEBUG_FUNCTIONS); //always use the debug constants here
exit;
end;

if IsObject then
begin
if MSI_FindObject(MSI_Objects[Which], ClickLeft) then
begin
result := true;
exit;
end;
MSI_Debug('MSI_Cast','Object finding failed',5);
result := false;
exit;

//the above part can be written better; no exit is required because we'll be using an else
Result := MSI_FindObject(NPC, ClickLeft);
if (not Result) then
MSI_Debug('MSI_Cast', 'Object finding failed', DEBUG_FUNCTIONS);
end else //see how now exit will be necessary
begin //this part can also be written better (like above)
if MSI_ClickItems(which, ['ast']) then
begin
result := true;
exit;
end;
MSI_Debug('MSI_Cast','Item finding failed',5);
result := false;
exit;
end;
end;

//shortened version
function MSI_Cast(spellName: string; castOn: Integer; isObject: Boolean): Boolean;
begin
if (not Cast(spellName, false)) then
begin
MSI_Debug('MSI_Cast','Casting failed', DEBUG_FUNCTIONS);
exit;
end;

if (isObject) then
begin
Result := MSI_FindObject(MSI_Objects[castOn], ClickLeft);
if (not Result) then
MSI_Debug('MSI_Cast', 'Object finding failed', DEBUG_FUNCTIONS);
end else
begin
Result := MSI_ClickItems(castOn, ['ast']);
if (not Result) then
MSI_Debug('MSI_Cast','Item finding failed',5);
end;
end;


Procedure MSI_Loop_Cast(spellname: string; which, waittime, totalcasts: Integer; IsObject: boolean);
var
CastSoFar, fails: intger;
anotherVar: boolean;
begin
if totalcasts = 0 then
begin
totalcasts := 9999999999;
end;
while castssofar to totalcasts do
begin //point 1
If not MSI_Cast(spellname, which,IsObject) then //if it fails, do all this shit
begin
inc(fails);
MSI_DEBUG('MSI_Loop_Cast','something failed. Fails so far: '+inttostr(fails), 3);
MSI_DEBUG('MSI_Loop_Cast','trying 5 more times.', 3);
repeat
//point 2
AnotherVar := MSI_Cast(spellname, which,IsObject); //determine the result, storing it to be tested
if anotherVar then //if we got it, do this, and break the loop, returning to point 1
begin
Writeln('MSI_Cast Returned true. Breaking failsafe loop');
Writeln('We got it on try number '+inttostr(failsafe)+' out of 5');
MSI_DEBUG('MSI_Loop_Cast','unce unce ucne - meltdown averted', 10);
failsafe := 0
break;
end;

If not AnotherVar then //if the failsafe cast failed...
begin
inc(failsafe); //increase var and write crap
writeln('Returned false on try number '+inttostr(failsafe)+'out of 5');
if (failsafe >= 5) then //but, if failsafe is 5 or greater...
begin
MSI_DEBUG('MSI_Loop_Cast','Casting failed 5 times. Terminating script', 10);
TerminateScript; //blow it up.
end;
end; //of course if its not, go to point two, and try, try again.
until((failsafe >= 5) or anotherVar = true);// uh... yeah.

end else //If it worked fine, increase some crap, do some waiting, etc.
begin
Wait(waittime);
inc(CastSoFar);
end; // and then back to the while to do loop :D
end;
MSI_DEBUG('MSI_Loop_Cast', inttostr(CastsSoFar)+' casts, with '+IntToStr(fails)+' failed casts.', 7)
end;

//////////////////////////////////
/////unnessisary procedures(?)////
//////////////////////////////////
{*****************************************************************************}
{ function MSI_Curse(which: Integer): boolean; }
{ By: Nickrules }
{ Date: 10 June 2010 }
{ Description: Curses the NPC defined by which. }
{*****************************************************************************}
Function MSI_Curse(which: Integer): boolean;
var
x, y: integer;
NPC: TMSObject;
begin
MSI_Debug('MSI_Curse','Starting cursing...', Debug_Functions);
NPC := MSI_GetObject(Which);
makecompass('w');
MSI_ResetSpellbook;
repeat
MSI_FindRandoms;
MSI_AntiBan(RandomRange(0, 5000), ANTI_BAN_CHANCE);

if not cast('curse',false) then
begin
MSI_Debug('MSI_Curse','Couldn''t cast curse for whatever reason.', 10);
nextplayer(false);
result := false;
end;
MSI_FindObject(NPC,ClickLeft);
until(false);
end;



{*****************************************************************************}
{ function MSI_Alch(item: Integer): boolean; }
{ By: Nickrules }
{ Date: 10 June 2010 }
{ Description: High Alchs the item defined by item }
{*****************************************************************************}
Function MSI_Alch(item: TIntegerArray): boolean;
var
x,y, DTM: integer;
begin

//MSI_LoadDTM
DTM := DTMFromString('78DA633CCECCC070929101196832338169982' + //high alch DTM
'8E30EA09A0BA86AA418D1D49C01AA398FAA86119D3E0954B31FBF1A0' +
'0473706A1');

MSI_Debug('MSI_Alch','Alching time :D', Debug_Functions);
MSI_ResetSpellbook;
repeat
MSI_FindRandoms;
MSI_AntiBan(RandomRange(0, 4000), ANTI_BAN_CHANCE);

if not cast('high level alchemy',false) then
begin
MSI_Debug('MSI_Alch','Couldn''t cast high level alchemy.', 10);
result := false;
exit;
end;

mouse(x,y,8,8,true);
wait(randomrange(150,500));
MSI_ClickItems([item], 'gh al');
wait(randomrange(1500,2000));

until(false);

freedtm(dtm);
end;
Now, what's MSI_Loop_Cast suppose to do? Just repeatedly cast the same spell a certain amount of times? If so, I was thinking maybe we could have an MSI_CastObject and MSI_CastItem, and have repeating loops in those functions. There would also be a parameter for how many spells to cast. What do you think?

nickrules

2010-07-18 10:19:19

you are correct, it does just cast a given spell - the number of times in the parameter "totalCasts". If totalcasts is set to 0, it is basically infinite.

@cast item/cast object idea, that is an excellent idea, lol, wish i had thought of that :doh:

I'll get to that. and update the headers.

Edit:
{==============================================================================\
| MSI Group Scripting Include |
| Magic.scar |
|==============================================================================|
| For all magic routines. |
| |
| * function MSI_ResetSpellbook(); * by nickrules |
| * function MSI_Cast(): Boolean; * by nickrules |
| * function MSI_Cast_item(): Boolean; * by nickrules |
| * function MSI_Cast_Obj(): Boolean; * by nickrules |
| * function MSI_Loop_Cast(): Boolean; * by nickrules |
| * function MSI_Curse(): Boolean; * by nickrules |
| * function MSI_Alch(): Boolean; * by nickrules |
\ _____________________________________________________________________________}
{.include srl/srl/msi/setup.scar} //for test compiling. no touchy.
{.include srl/srl/skill/magic.scar}
//Quick shoutout to Coh3n, Thanks for the help/ideas. really helped this
//include get to where it is. -NR
{*****************************************************************************}
{ function MSI_ResetSpellbook: boolean; }
{ By: Nickrules }
{ Date: 10 June 2010 }
{ Description: Resets the spellbook to defaults. }
{*****************************************************************************}

function MSI_ResetSpellbook: boolean; //is this still needed?
var
DTM,x,y: integer;
begin
gametab(tab_magic);
SortBook(0);
SetSpellMode(True, True, True, True);
ToggleDefCast(False);
{DTM := DTMFromString('78DA630C60626038C0C8800C5EDD3C0AA661A' +
'28CEE986AFEFDFB87AA2618A8E60C01358140353BF1AB010073E3' +
'0FCB');
if not findDTM(DTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
mouse(592, 451, 5, 5, true);
end;
FreeDTM(DTM);

DTM := DTMFromString('78DA634C63626038C2C8800A189148209D025' +
'4B31355CDBF7FFF50D5E4639A83A12615A8E60C0135B140358750' +
'D58808F1A0A8010073BD0F05');
if not finddtm(dtm,x,y,MIX1,MIY1,MIX2,MIY2) then
begin
mouse(614,451,5,5,true);
end;
FreeDTM(DTM);
DTM := DTMFromString('78DA63AC62626038C2C88002BA0F832998286' +
'32150CD515435FFFEFD43550332672701352D4035878830E734AA' +
'1A11211E14350068D510BA');
if(not(finddtm(dtm,x,y,MIX1,MIY1,MIX2,MIY2)))then
begin
mouse(634,451,5,5,true);
end;
FreeDTM(DTM);
DTM := DTMFromString('78DA639CC0C4C070849101196C8BF402D3305' +
'1C6764C3522423CA86AFA816ACEA0AAF9F7EF1FAA9A3EA09A5D04' +
'CC9909547310BF3900E5CD0E67');
if(not(finddtm(dtm,x,y,MIX1,MIY1,MIX2,MIY2)))then
begin
mouse(654,451,5,5,true);
end;
FreeDTM(DTM);
DTM := DTMFromString('78DA639CC0C4C070849101196C8BF402D3305' +
'1C6764C3522423CA86AFA816ACEA0AAF9F7EF1FAA9A3EA09A5D04' +
'CC9909547310BF3900E5CD0E67');
if(not(finddtm(dtm,x,y,MIX1,MIY1,MIX2,MIY2)))then
begin
mouse(684,451,5,5,true);
end;
FreeDTM(DTM);
DTM := DTMFromString('78DA633462626038CCC88002422AC1144C945' +
'113A8E620AA9A7FFFFEA1AA0199B393801A2BA09A43A86A9ACA53' +
'50D59863BAA7B212D53D003EED0E63');
if(finddtm(dtm,x,y,MIX1,MIY1,MIX2,MIY2))then
begin
mouse(562,451,5,5,true);
end;
result := true;
FreeDTM(DTM); }
end;


{*****************************************************************************}
{ function MSI_Cast_Item(spellname: string; what: integer): boolean; }
{ By: Nickrules }
{ Date: 28 June 2010 }
{ Description: Casts a given spell on a given object/item. }
{*****************************************************************************}
function MSI_Cast_Item(spellname: string; what: integer): boolean;
begin
if (not Cast(spellName, false)) then
begin
MSI_Debug('MSI_Cast_Item','Casting failed', DEBUG_FUNCTIONS);
exit;
end;
Result := MSI_ClickItems(what, ['ast']);
if (not Result) then
begin
MSI_Debug('MSI_Cast_Item','Item finding failed',5);
end;
end;


{*****************************************************************************}
{ function MSI_Cast_Obj(spellname: string; what: integer): boolean; }
{ By: Nickrules, shortened by Coh3n. Thanks. }
{ Date: 28 June 2010 }
{ Description: Casts a given spell on a given object/item. }
{*****************************************************************************}
function MSI_Cast_Obj(spellname: string; what: integer): boolean;
begin
if (not Cast(spellName, false)) then
begin
MSI_Debug('MSI_Cast_Obj','Casting failed', DEBUG_FUNCTIONS);
exit;
end;
Result := MSI_FindObject(MSI_Objects[castOn], ClickLeft);
if (not Result) then
MSI_Debug('MSI_Cast_Obj', 'Object finding failed', DEBUG_FUNCTIONS);
end;

{*****************************************************************************}
{ function MSI_Cast(spellname: string; castOn: integer; IsObject: boolean): boolean;}
{ By: Nickrules }
{ Date: 28 June 2010 }
{ Description: Casts a given spell on a given object/item. }
{*****************************************************************************}
function MSI_Cast(spellName: string; castOn: Integer; isObject: Boolean): Boolean;
begin
MSI_AntiBan(5000, 40);
if (isObject) then
begin
Result := MSI_Cast_Obj(spellName, CastOn);
end else
begin
Result := MSI_Cast_Item(spellName, castOn);
end;
end;


{*****************************************************************************}
{ function MSI_Loop_Cast(spellname: string; which: integer; IsObject: boolean): boolean;}
{ By: Nickrules } }
{ Date: 17 July 2010 }
{ Description: Casts a given spell on a given object/item, the number }
{ *of times, as determined by totalCasts, with a wait of waitTime(ms) }
{ *in between. set totalCasts to 0 to cast forever(kinda) }
{*****************************************************************************}
Procedure MSI_Loop_Cast(spellname: string; which, waitTime, totalCasts: Integer; IsObject: boolean);
var
CastSoFar, fails: intger;
anotherVar: boolean;
begin
if (totalcasts = 0) then
begin
totalcasts := 9999999999; //If you can actually cast this many times in one proggy, i will mail you a cookie (maybe) lol.
end;
while castssofar to totalcasts do
begin //point 1
If not MSI_Cast(spellname, which,IsObject) then //if it fails, do all this shit
begin
inc(fails);
MSI_DEBUG('MSI_Loop_Cast','something failed. Fails so far: '+inttostr(fails), 3);
MSI_DEBUG('MSI_Loop_Cast','trying 5 more times.', 3);
repeat
//point 2
AnotherVar := MSI_Cast(spellname, which,IsObject); //determine the result, storing it to be tested
if anotherVar then //if we got it, do this, and break the loop, returning to point 1
begin
Writeln('MSI_Cast Returned true. Breaking failsafe loop');
Writeln('We got it on try number '+inttostr(failsafe)+' out of 5');
MSI_DEBUG('MSI_Loop_Cast','unce unce ucne - meltdown averted', 10);
failsafe := 0
break;
end;

If not AnotherVar then //if the failsafe cast failed...
begin
inc(failsafe); //increase var and write crap
writeln('Returned false on try number '+inttostr(failsafe)+'out of 5');
if (failsafe >= 5) then //but, if failsafe is 5 or greater...
begin
MSI_DEBUG('MSI_Loop_Cast','Casting failed 5 times. Terminating script', 10);
TerminateScript; //blow it up.
end;
end; //of course if its not, go to point two, and try, try again.
until((failsafe >= 5) or anotherVar = true);// uh... yeah.

end else //If it worked fine, increase some crap, do some waiting, etc.
begin
Wait(waittime);
inc(CastSoFar);
end; // and then back to the while to do loop :D
end;
MSI_DEBUG('MSI_Loop_Cast', inttostr(CastsSoFar)+' casts, with '+IntToStr(fails)+' failed casts.', 7)
end;

//////////////////////////////////
/////unnessisary procedures(?)////
//////////////////////////////////
{*****************************************************************************}
{ function MSI_Curse(which: Integer): boolean; }
{ By: Nickrules }
{ Date: 10 June 2010 }
{ Description: Curses the NPC defined by which. }
{*****************************************************************************}
Function MSI_Curse(which: Integer): boolean;
var
x, y: integer;
NPC: TMSObject;
begin
MSI_Debug('MSI_Curse','Starting cursing...', Debug_Functions);
NPC := MSI_GetObject(Which);
makecompass('w');
MSI_ResetSpellbook;
repeat
MSI_FindRandoms;
MSI_AntiBan(RandomRange(0, 5000), ANTI_BAN_CHANCE);

if not cast('curse',false) then
begin
MSI_Debug('MSI_Curse','Couldn''t cast curse for whatever reason.', 10);
nextplayer(false);
result := false;
end;
MSI_FindObject(NPC,ClickLeft);
until(false);
end;



{*****************************************************************************}
{ function MSI_Alch(item: Integer): boolean; }
{ By: Nickrules }
{ Date: 10 June 2010 }
{ Description: High Alchs the item defined by item }
{*****************************************************************************}
Function MSI_Alch(item: TIntegerArray): boolean;
var
x,y, DTM: integer;
begin

//MSI_LoadDTM
DTM := DTMFromString('78DA633CCECCC070929101196832338169982' + //high alch DTM
'8E30EA09A0BA86AA418D1D49C01AA398FAA86119D3E0954B31FBF1A0' +
'0473706A1');

MSI_Debug('MSI_Alch','Alching time :D', Debug_Functions);
MSI_ResetSpellbook;
repeat
MSI_FindRandoms;
MSI_AntiBan(RandomRange(0, 4000), ANTI_BAN_CHANCE);

if not cast('high level alchemy',false) then
begin
MSI_Debug('MSI_Alch','Couldn''t cast high level alchemy.', 10);
result := false;
exit;
end;

mouse(x,y,8,8,true);
wait(randomrange(150,500));
MSI_ClickItems([item], 'gh al');
wait(randomrange(1500,2000));

until(false);

freedtm(dtm);
end;

This is what i've done so far. When you said that a cast time and a cast object would be a good idea, did you mean, one for a single cast, or, a looping function which repeatedly casts on either objects or items?
I'll do both for now.

edit (again, lol): The MSI_Loop_Cast should be capable of doing both, by the way.

Sir R. M8gic1an

2010-07-31 09:18:03

This is nearly ready to be added.

I'll be editing magic.scar in SRL to have constants. Then this will be perfect.

The Alching & etc functions will need some editing.
We'll need some script records. I'll be looking into this.

~RM

Sir R. M8gic1an

2010-07-31 09:45:54

Ok, so I went ahead and did the constants magic.scar would need.

[php]
SPELL_WIND_STRIKE = 1;
SPELL_WIND_BOLT = 2;
SPELL_WIND_BLAST = 3;
SPELL_WIND_WAVE = 4;
SPELL_WIND_SURGE = 5;

SPELL_WATER_STRIKE = 10;
SPELL_WATER_BOLT = 11;
SPELL_WATER_BLAST = 12;
SPELL_WATER_WAVE = 13;
SPELL_WATER_SURGE = 14;

SPELL_EARTH_STRIKE = 20;
SPELL_EARTH_BOLT = 21;
SPELL_EARTH_BLAST = 22;
SPELL_EARTH_WAVE = 23;
SPELL_EARTH_SURGE = 24;

SPELL_FIRE_STRIKE = 30;
SPELL_FIRE_BOLT = 31;
SPELL_FIRE_BLAST = 32;
SPELL_FIRE_WAVE = 33;
SPELL_FIRE_SURGE = 34;

SPELL_GOD_SARA = 40;
SPELL_GOD_GUTHIX = 41;
SPELL_GOD_ZAMMY = 42;

SPELL_HIT_CRUMBLE = 50; //crumble undead
SPELL_HIT_IBAN = 51; //iban blast

SPELL_SLAYER_DART = 60;

SPELL_STATE_CONFUSE = 70;
SPELL_STATE_WEAKE = 71;
SPELL_STATE_CURSE = 72;
SPELL_STATE_BIND = 73;
SPELL_STATE_SNARE = 74;
SPELL_STATE_VULNERABILITY = 75;
SPELL_STATE_ENFEEBLE = 76;
SPELL_STATE_ENTANGLE = 77;
SPELL_STATE_STUN = 78;
SPELL_STATE_CHARGE = 79;
SPELL_STATE_TELEBLOCK = 80;

SPELL_TELE_HOME = 90;
SPELL_TELE_ARMY = 91; //mobilizing armies
SPELL_TELE_VARROCK = 92;
SPELL_TELE_LUMBY = 93;
SPELL_TELE_FALLY = 94;
SPELL_TELE_HOUSE = 95;
SPELL_TELE_CAMMY = 96;
SPELL_TELE_ARDOUGNE = 97;
SPELL_TELE_WATCHTOWER = 98;
SPELL_TELE_TROLLHEIM = 99;
SPELL_TELE_APE = 100;

SPELL_TELEOTHER_LUMBY = 110;
SPELL_TELEOTHER_FALLY = 111;
SPELL_TELEOTHER_CAMMY = 112;

SPELL_ALCH_LOW = 120;
SPELL_ALCH_HIGH = 121;

SPELL_TELEGRAB = 130;
SPELL_SUPERHEAT = 131;

SPELL_BONES_BANANAS = 140;
SPELL_BONES_PEACHS = 141;

SPELL_ENCHANT_BOLT = 150;
SPELL_ENCHANT_LVL1 = 151;
SPELL_ENCHANT_LVL2 = 152;
SPELL_ENCHANT_LVL3 = 153;
SPELL_ENCHANT_LVL4 = 154;
SPELL_ENCHANT_LVL5 = 155;
SPELL_ENCHANT_LVL6 = 156;

SPELL_CHARGE_WATER = 160;
SPELL_CHARGE_EARTH = 161;
SPELL_CHARGE_FIRE = 162;
SPELL_CHARGE_AIR = 163;
[/php]

I'll now be looking at compatibility with SRL.

The only compatibility layer it needs is SpellToText; Magic.scar (SRL's) seems quite vulnerable to breaking, if not broken already by any spell additions.

~RM

Coh3n

2010-07-31 11:16:14

From: Rasta Magician


I'll now be looking at compatibility with SRL.

The only compatibility layer it needs is SpellToText; Magic.scar (SRL's) seems quite vulnerable to breaking, if not broken already by any spell additions.

~RM

How difficult is it to edit them to use constants instead of strings? Would probably break a lot of script though…

A SpellToText wouldn't be that bad I guess. We could also just have a TSpell type (or is there one in SRL?).

Sir R. M8gic1an

2010-07-31 11:19:05

From: Coh3n
How difficult is it to edit them to use constants instead of strings? Would probably break a lot of script though…

A SpellToText wouldn't be that bad I guess. We could also just have a TSpell type (or is there one in SRL?).


There is one in SRL.

We could edit SRL to use Variants, but it looks like a LOT of trouble.

I'd say that in terms of that we wait for SRL 5, and that for now we just do SpellToText.

~RM

Coh3n

2010-07-31 11:22:49

From: Rasta Magician
There is one in SRL.

We could edit SRL to use Variants, but it looks like a LOT of trouble.

I'd say that in terms of that we wait for SRL 5, and that for now we just do SpellToText.

~RM

Okay works for me.

nickrules

2010-07-31 20:44:26

Woah, A good deal seems to have happened while i was on vacation. So if i understand this correctly, a spellToText function is needed, because SRLs is vournable to breaking because of spell additions.
But why is one needed?

marpis

2010-08-01 06:15:44

From: nickrules
Woah, A good deal seems to have happened while i was on vacation. So if i understand this correctly, a spellToText function is needed, because SRLs is vournable to breaking because of spell additions.
But why is one needed?


Because we use integer constants, like SPELL_WIND_STRIKE = 1; and Cast() won't understand that because Cast() want's string parameter.

function Cast(whatSpell: string): boolean;

therefore we need to do this

var
str: string;
begin
str := SpellToStr(SPELL_WIND_STRIKE);
Cast(str);
end;

nickrules

2010-08-01 09:34:10

Ahhh, I see. Thanks. I can work on that (i think:redface:).
Cases?

nickrules

2010-08-01 17:42:32

Done.

Function SpellToStr(lolwut:integer): string;
begin
case lolwut of


SPELL_WIND_STRIKE: result := 'wind strike';
SPELL_WIND_BOLT: result := 'wind bolt';
SPELL_WIND_BLAST: result := 'wind blast';
SPELL_WIND_WAVE: result := 'wind wave';
SPELL_WIND_SURGE: result := 'wind surge';

SPELL_WATER_STRIKE: result := 'water strike';
SPELL_WATER_BOLT: result := 'water bolt';
SPELL_WATER_BLAST: result := 'water blast';
SPELL_WATER_WAVE: result := 'water wave';
SPELL_WATER_SURGE: result := 'water surge';

SPELL_EARTH_STRIKE: result := 'earth strike';
SPELL_EARTH_BOLT: result := 'earth bolt';
SPELL_EARTH_BLAST: result := 'earth blast';
SPELL_EARTH_WAVE: result := 'earth wave';
SPELL_EARTH_SURGE: result := 'earth surge';

SPELL_FIRE_STRIKE: result := 'fire strike';
SPELL_FIRE_BOLT: result := 'fire bolt';
SPELL_FIRE_BLAST: result := 'fire blast';
SPELL_FIRE_WAVE: result := 'fire wave';
SPELL_FIRE_SURGE: result := 'fire surge';

SPELL_GOD_SARA: result := 'saradomin strike';
SPELL_GOD_GUTHIX: result := 'claws of guthix';
SPELL_GOD_ZAMMY: result := 'flames of zamorak';

SPELL_HIT_CRUMBLE: result := 'crumble undead'; //crumble undead
SPELL_HIT_IBAN: result := 'iban blast'; //iban blast

SPELL_SLAYER_DART: result := 'slayer dart';

SPELL_STATE_CONFUSE: result := 'confuse';
SPELL_STATE_WEAKE: result := 'weaken';
SPELL_STATE_CURSE: result := 'curse';
SPELL_STATE_BIND: result := 'bind';
SPELL_STATE_SNARE: result := 'snare';
SPELL_STATE_VULNERABILITY: result := 'vulnerability';
SPELL_STATE_ENFEEBLE: result := 'enfeeble';
SPELL_STATE_ENTANGLE: result := 'entangle';
SPELL_STATE_STUN: result := 'stun';
SPELL_STATE_CHARGE: result := 'charge';
SPELL_STATE_TELEBLOCK: result := 'teleport block';

SPELL_TELE_HOME: result := 'lumbridge home teleport';
SPELL_TELE_ARMY: result := 'mobilising armies teleport'; //mobilizing armies
SPELL_TELE_VARROCK: result := 'varrock teleport';
SPELL_TELE_LUMBY: result := 'lumbridge teleport';
SPELL_TELE_FALLY: result := 'falador teleport';
SPELL_TELE_HOUSE: result := 'teleport to house';
SPELL_TELE_CAMMY: result := 'camelot teleport';
SPELL_TELE_ARDOUGNE: result := 'ardougne teleport';
SPELL_TELE_WATCHTOWER: result := 'watchtower teleport';
SPELL_TELE_TROLLHEIM: result := 'trollheim teleport';
SPELL_TELE_APE: result := 'teleport to ape atoll';

SPELL_TELEOTHER_LUMBY: result := 'teleother lumbridge';
SPELL_TELEOTHER_FALLY: result := 'teleother falador';
SPELL_TELEOTHER_CAMMY: result := 'teleother camelot';

SPELL_ALCH_LOW: result := 'low level alchemy';
SPELL_ALCH_HIGH: result := 'high level alchemy';

SPELL_TELEGRAB: result := 'telekinetic grab';
SPELL_SUPERHEAT: result := 'superheat item';

SPELL_BONES_BANANAS: result := 'bones to bananas';
SPELL_BONES_PEACHS: result := 'bones to peaches';

SPELL_ENCHANT_BOLT: result := 'enchant crossbow bolt';
SPELL_ENCHANT_LVL1: result := 'lvl-1 enchant';
SPELL_ENCHANT_LVL2: result := 'lvl-2 enchant';
SPELL_ENCHANT_LVL3: result := 'lvl-3 enchant';
SPELL_ENCHANT_LVL4: result := 'lvl-4 enchant';
SPELL_ENCHANT_LVL5: result := 'lvl-5 enchant';
SPELL_ENCHANT_LVL6: result := 'lvl-6 enchant';

SPELL_CHARGE_WATER: result := 'charge water orb';
SPELL_CHARGE_EARTH: result := 'charge earth orb';
SPELL_CHARGE_FIRE: result := 'charge fire orb';
SPELL_CHARGE_AIR: result := 'charge air orb';
end;
should work.

Sir R. M8gic1an

2010-08-02 06:25:27

Ok, so I'm thinking that out of Magic.scar we'll be getting several scripts.

1. Low & High Alcher.
2. SuperHeater
3. Teleporter
4. Curser & Weaken & whatever else
5. Magic Fighter

I still need to have a look.

~RM

nickrules

2010-08-02 09:48:39

Yeah, i came to pretty much the same conclusion too.
What about a hybrid script? like, mining and then superheating, and then banking? might get a bit complicated.

Sir R. M8gic1an

2010-08-02 10:24:16

From: nickrules
Yeah, i came to pretty much the same conclusion too.
What about a hybrid script? like, mining and then superheating, and then banking? might get a bit complicated.


That'll come later.

~RM

Sir R. M8gic1an

2010-08-03 14:17:48

I gave magic its own little section. Nick, would you like to do the honours of creating the necessary threads to discuss the code & possible scripts? ;) I'll give you a hand with whatever you need.

~RM

Awkwardsaw

2010-08-03 14:48:08

wouldnt an array work just as well for the SpellToString function?


somevariablenameforspells := ['all spell names ect'];
cast(somevariablenameforspells[SPELL_WIND_STRIKE]);

or would it take to long to load/to much memory to load into a single array?

Coh3n

2010-08-03 14:59:08

From: Awkwardsaw
wouldnt an array work just as well for the SpellToString function?


somevariablenameforspells := ['all spell names ect'];
cast(somevariablenameforspells[SPELL_WIND_STRIKE]);

or would it take to long to load/to much memory to load into a single array?

Actually I did this is a farming script I never finished. Have a function return an array with the indexes as the constants. That would make it shorter, but I think it could be a pain to update. I like how the current method is readable and organized though.

Awkwardsaw

2010-08-03 16:16:14

From: Coh3n
Actually I did this is a farming script I never finished. Have a function return an array with the indexes as the constants. That would make it shorter, but I think it could be a pain to update. I like how the current method is readable and organized though.


yes, i supose readability and organization is a good plus :)

nickrules

2010-08-04 12:38:42

From: Rasta Magician
I gave magic its own little section. Nick, would you like to do the honours of creating the necessary threads to discuss the code & possible scripts? ;) I'll give you a hand with whatever you need.

~RM


I would be honored :norris:


someone lock this thread if possible. information here can be found in other threads in the magic section.