SRL Archive - Research & Development Lounge

Tv's Staff Spell Selecter


Tv-XxX

2008-06-09 12:19:24

Hey, I'm Currently Making a Mage Based Scipt, and Thus Came Across The Problem Of Selecting Which Spell To Use, So I Made This Procedure,

Bassically It Picks The Best Spell Avaluable, It Only Works For Mages Whom, Use A Staff, But Lets Be Honest Most Mages Do.

Function WhichStaffSpell : String;
Var
SLX1, SLY1, SLX2, SLY2 : Integer;
Tx, Ty, Px, Py : Integer;
SpellChoice, Elemant, SpType : String;

Begin
SLX1 := 552;
SLY1 := 268;
SLX2 := 730;
SLY2 := 288;
GameTab(1);
Mouse(656, 254, 50, 40, True);
While FindColorTolerance(Tx, Ty, 1777020, 560, 222, 727, 423, 10) Do
Wait(500);
Repeat
MMouse((705 - Px), (425 - Py), 4, 4)
wait(200+random(100))
If(Not(FindColorTolerance(Tx, Ty, 255, SLX1, SLY1, SLX2, SLY2, 5)))Then
Begin
Mouse((705 - Px), (425 - Py), 4, 4, True)
Break;
End Else
Begin
If(Px<110)Then
Begin
Px := Px + 40
End Else
Begin
Px := 0;
If(Py<170)Then
Begin
Py := Py + 60
End Else
Begin
Writeln('Could Not Find Any Spells')
Mouse(686, 450, 34, 7, True)
Result := 'None'
Exit;
End;
End;
If(Py>100)Then
Begin
SLY1 := 443;
SLY2 := 459;
End;
End;
Until(False)
If Px = 0 Then
Elemant := 'Fire';
If Px = 40 Then
Elemant := 'Earth';
If Px = 80 Then
Elemant := 'Water';
If Px = 120 Then
Elemant := 'Wind';
If Py = 0 Then
SpType := 'Wave';
If Py = 60 Then
SpType := 'Blast';
If Py = 120 Then
SpType := 'Bolt';
If Py = 180 Then
SpType := 'Strike';
SpellChoice := Elemant + ' ' + SpType
Writeln('Picked Spell : ' + SpellChoice)
Wait(1000+random(1000))
Result := SpellChoice;
End;

And For Use I'd Do This

{.include Srl/Srl/Skill/Magic.scar}

Cast(WhichStaffSpell)

Cheers

Tv.

Naum

2008-06-09 15:05:27

Px, Py Useless, you just wanna make it look professional ;)

FreakyMonkey

2008-06-09 18:49:10

From: NaumanAkhlaQ
Px, Py Useless, you just wanna make it look professional ;)


I concur, a lot of unnecessary things are occuring here that you only really add once into your script. Might cut down a few (very few at that) milliseconds, but it's not necessary. Like this…

    SLX1 := 552;
SLY1 := 268;
SLX2 := 730;
SLY2 := 288;

Why didn't you just use coordinates for the ONE function you used these with? Your kinda defying the purpose of presetting coordinates.

1: You made it longer to type out.

2: You only used it once in the whole function!

Standards look ok. Not sure how it compiles, but I'll be sure to try and work it later.

Keep it up!:f:

Tv-XxX

2008-06-10 05:36:03

I Think You May Find That Without Px, Py, SLX1 Ect…It Wouldn't Work…

Basically It Checks Wether You Have Enough Runes To Cast The Spell, So Px and Py, Are The Gaps Between Each Spell, and SlX1 ect… Is Where It Checks The Runes, The Values Of SLX1 Changes, Becouse Where It Should Be Looking Changes When You Get So Far Up The List.

Test It and See.

Yours Tv.

Naum

2008-06-10 12:21:23

From: freakymonkey
I concur, a lot of unnecessary things are occuring here that you only really add once into your script. Might cut down a few (very few at that) milliseconds, but it's not necessary. Like this…

    SLX1 := 552;
SLY1 := 268;
SLX2 := 730;
SLY2 := 288;

Why didn't you just use coordinates for the ONE function you used these with? Your kinda defying the purpose of presetting coordinates.

1: You made it longer to type out.

2: You only used it once in the whole function!

Standards look ok. Not sure how it compiles, but I'll be sure to try and work it later.

Keep it up!:f:


you just gave him your middle finger :eek:
:f:
:p

FreakyMonkey

2008-06-10 18:30:40

Sorry, Tv if I was kinda messed up. Rather unnecessary for me to do that :\.

Forgive me? :p.

However, I understand the "Px, Py" but, I still don't see why you need to do the SLX1, etc.

Tv-XxX

2008-06-11 07:32:33

Ok freakymonkey I forgive you XD
ok to try and explain the SLX1, firstly SLX1 stands for "Spell Location" X1, if you wield a staff then select to use cast (gametab(1)) you can then scan over each spell, when you do this a popup is made, showing which runes are needed and if you have enough runes, if you dont have enough runes, the text appears in red (color 255 i believe) but when you get to the bootem two rows of spells, the "Spell Location" changes, thus meaning SLX1 ect…. must change else the script will look for the color in the wrong place.

I hope that explained it a little better.

Yours Tv.