SRL Archive - MSI Archives

TODO: MSI_SetupMagic();


nickrules

2010-09-28 17:19:27

So, a SetupMagic function needs to be made.

MSI_SetupMagic
  • Get skill level, make sure it's high enough to cast the required spell
  • Make sure we have the required runes (we have a spell to get the required runes, just not a method of making sure we have them, and if not, get them.
  • I think it'd be cool to also calculate how many spells we can cast depending on how many runes there are.
  • We also need an idea for staffs.. like if we have a fire staff equipped, then we don't need fire runes.

Green = Done :D
Blue = Function made for this, but not put in SetupMagic.
Orange = Sort of done…. A function to do this was made, but has not been 'setup' to do this….
Red = Not done at all.

NCDS

2010-09-28 17:27:32

Have already been looking into this between doing other things the past few days.

I was debating putting the level check in SetupPlayer, but I think it's best not to do that now.

All of this is in the other thread, which is why I was waiting to make this thread until I had actually done some of the code. Not a big deal though.

Does this mean your beginning work on SetupMagic? I'm quite pre-occupied with randoms ATM, but MSI remains my priority, especially since my fixes seem to be somewhat a waste of time…

Coh3n

2010-09-28 20:06:07

I don't think anything should be in setupPlayer. I don't even think we need that function. We can use a pointer in the TScript record (PlayerSetup).

PlayerSetup := @MSI_SetupFishing();
I've been thinking about that for a while, but don't worry about it now. For now, just make an MSI_SetupMagic function. :p

The staff function can be made easily enough, just look in the inventory then equipment tab. If found, set the corresponding runes to 0 in the requiredRunes global variable.

It may be a good idea to gather some small comments from the other threads regarding what you have here and add them to the first post.

nickrules

2010-09-30 23:45:35

Function MSI_SetupMagic: boolean;
begin
MSI_GetRequiredRunes(MSI_Player[currentplayer].Spell);
MSI_Debug('We can cast '+ SpellToStr(MSI_Player[currentplayer].Spell)+' '+IntToStr(CalculateCasts)+' times.');
MSI_ItemToSpellSlot(MSI_Player[currentplayer].Spell)
end;

Made that in like two seconds. Was too easy, which leads me to believe im forgetting something important.

Now we need to check the levels. Idea's anyone? Also, SRL Has a TSpell with the level in it. If we can use that, would save a buttload of time :P

Coh3n

2010-10-01 02:26:23

From: nickrules
Function MSI_SetupMagic: boolean;
begin
MSI_GetRequiredRunes(MSI_Player[currentplayer].Spell);
MSI_Debug('We can cast '+ SpellToStr(MSI_Player[currentplayer].Spell)+' '+IntToStr(CalculateCasts)+' times.');
MSI_ItemToSpellSlot(MSI_Player[currentplayer].Spell)
end;

Made that in like two seconds. Was too easy, which leads me to believe im forgetting something important.

Now we need to check the levels. Idea's anyone? Also, SRL Has a TSpell with the level in it. If we can use that, would save a buttload of time :P

We should utilize SRL's type as much as possible. If needed, we can make our own, but I don't think it's necessary.

Nava2

2010-10-01 10:12:11

MSI Debug should use Format, sorry for the off topic.

nickrules

2010-10-01 10:19:17

From: Nava2
MSI Debug should use Format, sorry for the off topic.


I no longer know the format. Has changed far too much. Nor is it really important to developmental code. It can be fixed later. What is important, is the fact that a way needs to be figured out how to use SRLs TSpell, which doesn't make sense to me….

Coh3n

2010-10-01 14:32:21

From: Nava2
MSI Debug should use Format, sorry for the off topic.

What do you mean?

From: nickrules
I no longer know the format. Has changed far too much. Nor is it really important to developmental code. It can be fixed later. What is important, is the fact that a way needs to be figured out how to use SRLs TSpell, which doesn't make sense to me….

Look over Magic.scar. IIRC, there are procedures that need to be called to set the spell records.

Gu3st...

2010-10-01 14:42:38

From: Coh3n
What do you mean?
He means that we should do WriteLn(Format(…)); instead of WriteLn(…IntToStr()…);

Coh3n

2010-10-01 14:45:19

From: Zyt3x
He means that we should do WriteLn(Format(…)); instead of WriteLn(…IntToStr()…);

Oh lol, care to expand on Format() a little more? :o

Gu3st...

2010-10-01 15:02:09

From: Coh3n
Oh lol, care to expand on Format() a little more? :o
Hehe, sure :p
With Format() you can do
var
DollarWon, Name : string;

begin
Name := 'Sir Muchodollar';
DollarWon := '100 million';
WriteLn(Format('Hello %s, How are you today? I hear you won %s million dollar yesterday. If you don''t give me 50%%, I''ll kill you.', [Name, DollarWon]));
end.

instead of
var
DollarWon, Name : string;

begin
Name := 'Sir Muchodollar';
DollarWon := '100 million';
WriteLn('Hello ' + Name + ', How are you today? I hear you won ' + DollarWon + ' million dollar yesterday. If you don''t give me 50%, I''ll kill you.');
end.

Basically it formats the text with the variables you enter

Tbh I don't see the point why we should do Format() rather than IntToStr() and so forth..

Coh3n

2010-10-01 18:21:33

Look like it would be shorter in some cases, but other than that I'm not sure.

Nava2

2010-10-01 18:55:43

From: Coh3n
Look like it would be shorter in some cases, but other than that I'm not sure.


Try this:


writeln(format('hai %5f', [9.9999999999999999999]));

E: It appears its not as useful as python's fmt. :(

Gu3st...

2010-10-02 09:53:33

From: Coh3n
Look like it would be shorter in some cases, but other than that I'm not sure.
I think the same.. I don't really see why it would be better to use Format

nickrules

2010-10-02 12:08:56

Right. now that we're back on topic ;)…

Bonfield

2010-10-04 02:56:18

what has actually been done, has any code been written? i would like to start to contribute to this

Overtime

2010-10-04 04:05:22

I know NCDS, has been working on this for a while now, you might want to get with Coh3n, Zyt3x, and NCDS and see how far they have gone to share with you.

If not, just start from scratch :D

Coh3n

2010-10-04 20:43:00

I think this is the current state of the include. The rest has just been discussion and planning.

{==============================================================================\
| MSI Group Scripting Include |
| Magic.scar |
|==============================================================================|
| For all magic routines. |
\ _____________________________________________________________________________}
{$i SRL/SRL.scar}
{$i SRL/SRL/skill/Magic.scar}

var
RequiredRunes: array[0..(RUNE_COUNT - 1)] of Integer;

{******************************************************************************}
{ function SpellToString(Spell:integer): boolean; }
{ By: nickrules }
{ Date: 5 August 2010 }
{ Description: turns a spell into a useable string. }
{******************************************************************************}
Function SpellToStr(Spell: integer): string;
begin
case Spell 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_WATER_STRIKE : result := 'water strike';
SPELL_WATER_BOLT : result := 'water bolt';
SPELL_WATER_BLAST : result := 'water blast';
SPELL_WATER_WAVE : result := 'water wave';

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_FIRE_STRIKE : result := 'fire strike';
SPELL_FIRE_BOLT : result := 'fire bolt';
SPELL_FIRE_BLAST : result := 'fire blast';
SPELL_FIRE_WAVE : result := 'fire wave';

SPELL_STATE_CONFUSE: result := 'confuse';
SPELL_STATE_WEAKE : result := 'weaken';
SPELL_STATE_CURSE : result := 'curse';
SPELL_STATE_BIND : result := 'bind';

SPELL_TELE_HOME : result := 'lumbridge home teleport';
SPELL_TELE_VARROCK : result := 'varrock teleport';
SPELL_TELE_LUMBY : result := 'lumbridge teleport';
SPELL_TELE_FALLY : result := 'falador teleport';

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

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

else
MSI_SubDebug('Invalid spell. Check /msi/skill/magic.simba for a list.');
end;
end;

{******************************************************************************}
{ procedure MSI_GetRequiredRunes(Spell: Integer); }
{ By: nickrules & Coh3n }
{ Date: 5 August 2010 }
{ Description: Sets the RequiredRunes array depending on the user set spells }
{******************************************************************************}
procedure MSI_GetRequiredRunes(Spell: Integer);
begin
case Spell of
SPELL_WIND_STRIKE:
begin
RequiredRunes[RUNE_AIR] := 1; // All other runes would be set to 0 since they're not being used
RequiredRunes[RUNE_MIND] := 1;
end;

SPELL_WATER_STRIKE:
begin
RequiredRunes[RUNE_AIR] := 1;
RequiredRunes[RUNE_MIND] := 1;
RequiredRunes[RUNE_WATER] := 1;
end;

SPELL_EARTH_STRIKE:
begin
RequiredRunes[RUNE_AIR] := 1;
RequiredRunes[RUNE_MIND] := 1;
RequiredRunes[RUNE_EARTH] := 2;
end;

SPELL_FIRE_STRIKE:
begin
RequiredRunes[RUNE_AIR] := 1;
RequiredRunes[RUNE_MIND] := 1;
RequiredRunes[RUNE_FIRE] := 2;
end;

SPELL_WIND_BOLT:
begin
RequiredRunes[RUNE_AIR] := 2;
RequiredRunes[RUNE_CHAOS] := 1;
end;

SPELL_WATER_BOLT:
begin
RequiredRunes[RUNE_AIR] := 2;
RequiredRunes[RUNE_CHAOS] := 1;
RequiredRunes[RUNE_WATER] := 2;
end;

SPELL_EARTH_BOLT:
begin
RequiredRunes[RUNE_AIR] := 2;
RequiredRunes[RUNE_CHAOS] := 1;
RequiredRunes[RUNE_EARTH] := 3;
end;

SPELL_FIRE_BOLT:
begin
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_CHAOS] := 1;
RequiredRunes[RUNE_FIRE] := 4;
end;

SPELL_WIND_BLAST:
begin
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_DEATH] := 1;
end;

SPELL_WATER_BLAST:
begin
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_DEATH] := 1;
RequiredRunes[RUNE_WATER] := 3;
end;

SPELL_EARTH_BLAST:
begin
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_DEATH] := 1;
RequiredRunes[RUNE_EARTH] := 4;
end;

SPELL_FIRE_BLAST:
begin
RequiredRunes[RUNE_AIR] := 4;
RequiredRunes[RUNE_DEATH] := 1;
RequiredRunes[RUNE_FIRE] := 5;
end;

SPELL_STATE_CONFUSE:
begin
RequiredRunes[RUNE_WATER] := 3;
RequiredRunes[RUNE_EARTH] := 2;
RequiredRunes[RUNE_BODY] := 1;
end;

SPELL_STATE_WEAKE:
begin
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_MIND] := 2;
RequiredRunes[RUNE_BODY] := 1;
end;

SPELL_STATE_CURSE:
begin
RequiredRunes[RUNE_WATER] := 2;
RequiredRunes[RUNE_EARTH] := 3;
RequiredRunes[RUNE_BODY] := 1;
end;

SPELL_STATE_BIND:
begin
RequiredRunes[RUNE_EARTH] := 3;
RequiredRunes[RUNE_WATER] := 3;
RequiredRunes[RUNE_NATURE] := 2;
end;

SPELL_TELE_HOME:
begin
end;

SPELL_TELE_VARROCK:
begin
RequiredRunes[RUNE_FIRE] := 1;
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_LAW] := 1;
end;

SPELL_TELE_LUMBY:
begin
RequiredRunes[RUNE_EARTH] := 1;
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_LAW] := 1;
end;

SPELL_TELE_FALLY:
begin
RequiredRunes[RUNE_WATER] := 1;
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_LAW] := 1;
end;

SPELL_ALCH_LOW:
begin
RequiredRunes[RUNE_FIRE] := 3;
RequiredRunes[RUNE_NATURE] := 1;
end;

SPELL_ALCH_HIGH:
begin
RequiredRunes[RUNE_FIRE] := 5;
RequiredRunes[RUNE_NATURE] := 1;
end;

SPELL_TELEGRAB:
begin
RequiredRunes[RUNE_AIR] := 1;
RequiredRunes[RUNE_LAW] := 1;
end;

SPELL_SUPERHEAT:
begin
RequiredRunes[RUNE_AIR] := 4;
RequiredRunes[RUNE_NATURE] := 1;
end;

else
MSI_SubDebug('Invalid spell in MSI_GetRequiredRunes');
end;
end;

{******************************************************************************}
{ function MSI_ItemToSpellSlot(tem, spell: integer): boolean; }
{ By: Nickrules }
{ Date: 5 August 2010 }
{ Description: Moves the item to the most ideal slot }
{******************************************************************************}
function MSI_ItemToSpellSlot(item, spell: integer): boolean;
begin
case spell of
SPELL_ALCH_LOW:
result := MSI_DragItem(item, 6);

SPELL_ALCH_HIGH:
result := MSI_DragItem(item, 15);

SPELL_SUPERHEAT:
result := MSI_DragItem(item, 13);

else
MSI_SubDebug('MSI_ItemToSpellSlot: Invalid spell');
end;
end;

{******************************************************************************}
{ function MSI_Cast(spell, which: integer; isObject: boolean): boolean; }
{ By: Nickrules & Coh3n }
{ Date: 22 August 2010 }
{ Description: Casts 'spell' on item/object 'which' }
{******************************************************************************}
function MSI_Cast(spell, which: integer; isObject: boolean): boolean;
var
s, spellName: string;
spellInfo: TSpell;
didCast: boolean;
begin
spellName := MSI_SpellToText(spell);
spellInfo := GetSpellInfo(spellName);

if (not Cast(spellName, spellInfo.autoCast) then
begin
MSI_SubDebug('Failed to cast spell: ' + spellName);
exit;
end;

if (isObject) then
begin
didCast := MSI_FindObject(MSI_Objects[which], ClickLeft);
s := MSI_Objects[which].Name;
end else
begin
didCast := MSI_ClickItem(which, ['ast']);
s := MSI_Items[which].Name;
end;

if (didCast) then
begin
Result := True;
MSI_SubDebug('Cast ' + spellName + ' on ' + s);
end else
MSI_SubDebug('Failed to cast ' + spellName + ' on ' + s);
end;

begin
SetupSRL;
ClearDebug;
end.

Nava2

2010-10-05 07:59:40

I don't like how the runes are a global array… :| Seems really unsafe to me. Especially when each rune is only being set if needed, what if there are multiple spells being used over multiple accounts?

Coh3n

2010-10-05 16:37:43

From: Nava2
I don't like how the runes are a global array… :| Seems really unsafe to me. Especially when each rune is only being set if needed, what if there are multiple spells being used over multiple accounts?

There was a reason for it being global, but I can't think of it now.

I guess the function could be rewritten to return the array, rather than setting a global one.

nickrules

2010-10-05 18:52:05

{==============================================================================\
| MSI Group Scripting Include |
| Magic.scar |
|==============================================================================|
| For all magic routines. |
\ _____________________________________________
Options
Show your signature
Quote message in reply?
________________________________}
{$i SRL/SRL.scar}
{$i SRL/SRL/skill/Magic.scar}

Type
TRuneCount = Record
Air: Integer;
Water: Integer;
Earth: Integer;
Fire: Integer;
Death: Integer;
Cosmic: Integer;
Chaos: Integer;
Body: Integer;
Mind: Integer;
Nature: Integer;
Law: Integer;
end;


var
RequiredRunes: array[0..(RUNE_COUNT - 1)] of Integer;
RuneCount: array[RUNE_LOW..RUNE_HIGH] of integer;


{******************************************************************************}
{ function CalculateCasts: Integer; }
{ By: nickrules }
{ Date: 17 September 2010 }
{ Description: turns a spell into a useable string. }
{******************************************************************************}
Function CalculateCasts: Integer;
var RuneCount : TRuneCount;
begin
with RuneCount do
begin
Air := RuneAmount('inv','air');
Water := RuneAmount('inv','water');
Farth := RuneAmount('inv','earth');
Fire := RuneAmount('inv','Fire');
Mind := RuneAmount('inv','mind');
Body := RuneAmount('inv','body');
Chaos := RuneAmount('inv','chaos');
Death := RuneAmount('inv','death');
Cosmic := RuneAmount('inv','cosmic');
Nature := RuneAmount('inv','nature');
Law := RuneAmount('inv','law');
end;

for i:= RUNE_LOW to RUNE_HIGH do
if RequiredRunes[i] > 0 then
begin
TheThing[i] := round(RuneCount[i] / RequiredRunes[i]);
Result := min(Result, TheThing[i]);
end;
end;


{******************************************************************************}
{ function GetStaff: String; }
{ By: nickrules }
{ Date: 17 September 2010 }
{ Description: turns a spell into a useable string. }
{******************************************************************************}
Function GetStaff(): String;
var x,y:integer;
begin
GameTab(tab_Equip)
if MSI_FindTool(STAFF_AIR, Tab_Equip, X, Y) then
begin
result := 'Staff of Air';
exit;
end else
begin
result := '';
end;
if MSI_FindTool(STAFF_WATER, Tab_Equip, X, Y) then
begin
result := 'Staff of Water';
exit;
end else
begin
result := '';
end;
if MSI_FindTool(STAFF_EARTH, Tab_Equip, X, Y) then
begin
result := 'Staff of Earth';
exit;
end else
begin
result := '';
end;
if MSI_FindTool(STAFF_FIRE, Tab_Equip, X, Y) then
begin
result := 'Staff of Fire';
exit;
end else
begin
result := 'Staff not found!';
end;
end;


{******************************************************************************}
{ function SpellToString(Spell:integer): boolean; }
{ By: nickrules }
{ Date: 5 August 2010 }
{ Description: turns a spell into a useable string. }
{******************************************************************************}
Function SpellToStr(Spell: integer): string;
begin
case Spell 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_WATER_STRIKE : result := 'water strike';
SPELL_WATER_BOLT : result := 'water bolt';
SPELL_WATER_BLAST : result := 'water blast';
SPELL_WATER_WAVE : result := 'water wave';

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_FIRE_STRIKE : result := 'fire strike';
SPELL_FIRE_BOLT : result := 'fire bolt';
SPELL_FIRE_BLAST : result := 'fire blast';
SPELL_FIRE_WAVE : result := 'fire wave';

SPELL_STATE_CONFUSE: result := 'confuse';
SPELL_STATE_WEAKE : result := 'weaken';
SPELL_STATE_CURSE : result := 'curse';
SPELL_STATE_BIND : result := 'bind';

SPELL_TELE_HOME : result := 'lumbridge home teleport';
SPELL_TELE_VARROCK : result := 'varrock teleport';
SPELL_TELE_LUMBY : result := 'lumbridge teleport';
SPELL_TELE_FALLY : result := 'falador teleport';

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

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

else
MSI_SubDebug('Invalid spell. Check /msi/skill/magic.simba for a list.');
end;
end;

{******************************************************************************}
{ procedure MSI_GetRequiredRunes(Spell: Integer); }
{ By: nickrules & Coh3n }
{ Date: 17 September 2010 }
{ Description: Sets the RequiredRunes array depending on the user set spells }
{******************************************************************************}
procedure MSI_GetRequiredRunes(Spell: Integer);
begin
case Spell of
SPELL_WIND_STRIKE:
begin
RequiredRunes[RUNE_AIR] := 1; // All other runes would be set to 0 since they're not being used
RequiredRunes[RUNE_MIND] := 1;
end;

SPELL_WATER_STRIKE:
begin
RequiredRunes[RUNE_AIR] := 1;
RequiredRunes[RUNE_MIND] := 1;
RequiredRunes[RUNE_WATER] := 1;
end;

SPELL_EARTH_STRIKE:
begin
RequiredRunes[RUNE_AIR] := 1;
RequiredRunes[RUNE_MIND] := 1;
RequiredRunes[RUNE_EARTH] := 2;
end;

SPELL_FIRE_STRIKE:
begin
RequiredRunes[RUNE_AIR] := 1;
RequiredRunes[RUNE_MIND] := 1;
RequiredRunes[RUNE_FIRE] := 2;
end;

SPELL_WIND_BOLT:
begin
RequiredRunes[RUNE_AIR] := 2;
RequiredRunes[RUNE_CHAOS] := 1;
end;

SPELL_WATER_BOLT:
begin
RequiredRunes[RUNE_AIR] := 2;
RequiredRunes[RUNE_CHAOS] := 1;
RequiredRunes[RUNE_WATER] := 2;
end;

SPELL_EARTH_BOLT:
begin
RequiredRunes[RUNE_AIR] := 2;
RequiredRunes[RUNE_CHAOS] := 1;
RequiredRunes[RUNE_EARTH] := 3;
end;

SPELL_FIRE_BOLT:
begin
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_CHAOS] := 1;
RequiredRunes[RUNE_FIRE] := 4;
end;

SPELL_WIND_BLAST:
begin
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_DEATH] := 1;
end;

SPELL_WATER_BLAST:
begin
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_DEATH] := 1;
RequiredRunes[RUNE_WATER] := 3;
end;

SPELL_EARTH_BLAST:
begin
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_DEATH] := 1;
RequiredRunes[RUNE_EARTH] := 4;
end;

SPELL_FIRE_BLAST:
begin
RequiredRunes[RUNE_AIR] := 4;
RequiredRunes[RUNE_DEATH] := 1;
RequiredRunes[RUNE_FIRE] := 5;
end;

SPELL_STATE_CONFUSE:
begin
RequiredRunes[RUNE_WATER] := 3;
RequiredRunes[RUNE_EARTH] := 2;
RequiredRunes[RUNE_BODY] := 1;
end;

SPELL_STATE_WEAKE:
begin
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_MIND] := 2;
RequiredRunes[RUNE_BODY] := 1;
end;

SPELL_STATE_CURSE:
begin
RequiredRunes[RUNE_WATER] := 2;
RequiredRunes[RUNE_EARTH] := 3;
RequiredRunes[RUNE_BODY] := 1;
end;

SPELL_STATE_BIND:
begin
RequiredRunes[RUNE_EARTH] := 3;
RequiredRunes[RUNE_WATER] := 3;
RequiredRunes[RUNE_NATURE] := 2;
end;

SPELL_TELE_HOME:
begin
end;

SPELL_TELE_VARROCK:
begin
RequiredRunes[RUNE_FIRE] := 1;
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_LAW] := 1;
end;

SPELL_TELE_LUMBY:
begin
RequiredRunes[RUNE_EARTH] := 1;
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_LAW] := 1;
end;

SPELL_TELE_FALLY:
begin
RequiredRunes[RUNE_WATER] := 1;
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_LAW] := 1;
end;

SPELL_ALCH_LOW:
begin
RequiredRunes[RUNE_FIRE] := 3;
RequiredRunes[RUNE_NATURE] := 1;
end;

SPELL_ALCH_HIGH:
begin
RequiredRunes[RUNE_FIRE] := 5;
RequiredRunes[RUNE_NATURE] := 1;
end;

SPELL_TELEGRAB:
begin
RequiredRunes[RUNE_AIR] := 1;
RequiredRunes[RUNE_LAW] := 1;
end;

SPELL_SUPERHEAT:
begin
RequiredRunes[RUNE_AIR] := 4;
RequiredRunes[RUNE_NATURE] := 1;
end;

else
MSI_SubDebug('Invalid spell in MSI_GetRequiredRunes');
end;
case getStaff of
'Staff of Fire': RequiredRunes[RUNE_FIRE] := 0;
'Staff of Earth': RequiredRunes[RUNE_EARTH] := 0;
'Staff of Water': RequiredRunes[RUNE_WATER] := 0;
'Staff of Wind': RequiredRunes[RUNE_AIR] := 0;
end;
end;

{******************************************************************************}
{ function MSI_ItemToSpellSlot(spell: integer): boolean; }
{ By: Nickrules }
{ Date: 5 August 2010 }
{ Description: Moves the item to the most ideal slot }
{******************************************************************************}
function MSI_ItemToSpellSlot(spell: integer): boolean;
begin
case spell of
SPELL_ALCH_LOW:
result := MSI_DragItem(STAFF_FIRE, 6);

SPELL_ALCH_HIGH:
result := MSI_DragItem(STAFF_FIRE, 15);

SPELL_SUPERHEAT:
result := MSI_DragItem(STAFF_FIRE, 13);

else
MSI_Debug('Item manipulation not nessicary...');
end;
end;


Function MSI_SetupMagic: boolean;
begin
MSI_GetRequiredRunes(MSI_Player[currentplayer].Spell);
MSI_Debug('We can cast '+ SpellToStr(MSI_Player[currentplayer].Spell)+' '+IntToStr(CalculateCasts)+' times.');
MSI_ItemToSpellSlot(MSI_Player[currentplayer].Spell)
GetSpellInfo(SpellToStr(MSI_Player[currentplayer].Spell))
//If <resulting TSpell>.level > Getlevel(magic) //IgnLargeore the fact that this makes no sense :P
end;

{******************************************************************************}
{ function MSI_Cast(spell, which: integer; isObject: boolean): boolean; }
{ By: Nickrules & Coh3n }
{ Date: 22 August 2010 }
{ Description: Casts 'spell' on item/object 'which' }
{******************************************************************************}
function MSI_Cast(spell, which: integer; isObject: boolean): boolean;
var
s, spellName: string;
spellInfo: TSpell;
didCast: boolean;
begin
spellName := MSI_SpellToText(spell);
spellInfo := GetSpellInfo(spellName);

if (not Cast(spellName, spellInfo.autoCast) then
begin
MSI_SubDebug('Failed to cast spell: ' + spellName);
exit;
end;

if (isObject) then
begin
didCast := MSI_FindObject(MSI_Objects[which], ClickLeft);
s := MSI_Objects[which].Name;
end else
begin
didCast := MSI_ClickItem(which, ['ast']);
s := MSI_Items[which].Name;
end;

if (didCast) then
begin
Result := True;
MSI_SubDebug('Cast ' + spellName + ' on ' + s);
end else
MSI_SubDebug('Failed to cast ' + spellName + ' on ' + s);
end;

begin
SetupSRL;
ClearDebug;
end.

Is the current state of the include. Not sure if thats what coh3n posted.


Also bonfield/squancy: As for help, I don't think i will be wanting any more help physically making the include. But thanks anyways! Anywho, suggestions and ideas are always welcome…. As well as updating the TItems ;)

Also, a good deal of this was made by me, and if you were really, really determined to help, just post it here or PM me. (Giving credit to those who deserve it however, I would just like to say, thanks to RM, coh3n, zytex, and NCDS (as well as the people that I already know I've forgotten :P) for help when I was stuck, a smidge of motivation, and brilliant ideas as well as planning.
Cookies for you, brilliant people .)

nickrules

2010-10-05 18:55:43

On a far more related topic, I just got around to looking at magic.scar. I found GetSpellInfo(): TSpell;
I'll look around some tuts and the include for an idea on how to use it.

EDIT: 200th post. Which means that I've made like 150 posts in the MSI board xD

Edit2:

{==============================================================================\
| MSI Group Scripting Include |
| Magic.scar |
|==============================================================================|
| For all magic routines. |
\ _____________________________________________________________________________}
{$i SRL/SRL.scar}
{$i SRL/SRL/skill/Magic.scar}

Type
TRuneCount = Record
Air: Integer;
Water: Integer;
Earth: Integer;
Fire: Integer;
Death: Integer;
Cosmic: Integer;
Chaos: Integer;
Body: Integer;
Mind: Integer;
Nature: Integer;
Law: Integer;
end;


var
RequiredRunes: array[0..(RUNE_COUNT - 1)] of Integer;
RuneCount: array[RUNE_LOW..RUNE_HIGH] of integer;


{******************************************************************************}
{ function CalculateCasts: Integer; }
{ By: nickrules }
{ Date: 17 September 2010 }
{ Description: turns a spell into a useable string. }
{******************************************************************************}
Function CalculateCasts: Integer;
var RuneCount : TRuneCount;
begin
with RuneCount do
begin
Air := RuneAmount('inv','air');
Water := RuneAmount('inv','water');
Farth := RuneAmount('inv','earth');
Fire := RuneAmount('inv','Fire');
Mind := RuneAmount('inv','mind');
Body := RuneAmount('inv','body');
Chaos := RuneAmount('inv','chaos');
Death := RuneAmount('inv','death');
Cosmic := RuneAmount('inv','cosmic');
Nature := RuneAmount('inv','nature');
Law := RuneAmount('inv','law');
end;

for i:= RUNE_LOW to RUNE_HIGH do
if RequiredRunes[i] > 0 then
begin
TheThing[i] := round(RuneCount[i] / RequiredRunes[i]);
Result := min(Result, TheThing[i]);
end;
end;


{******************************************************************************}
{ function GetStaff: String; }
{ By: nickrules }
{ Date: 17 September 2010 }
{ Description: turns a spell into a useable string. }
{******************************************************************************}
Function GetStaff(): String;
var x,y:integer;
begin
GameTab(tab_Equip)
if MSI_FindTool(STAFF_AIR, Tab_Equip, X, Y) then
begin
result := 'Staff of Air';
exit;
end else
begin
result := '';
end;
if MSI_FindTool(STAFF_WATER, Tab_Equip, X, Y) then
begin
result := 'Staff of Water';
exit;
end else
begin
result := '';
end;
if MSI_FindTool(STAFF_EARTH, Tab_Equip, X, Y) then
begin
result := 'Staff of Earth';
exit;
end else
begin
result := '';
end;
if MSI_FindTool(STAFF_FIRE, Tab_Equip, X, Y) then
begin
result := 'Staff of Fire';
exit;
end else
begin
result := 'Staff not found!';
end;
end;


{******************************************************************************}
{ function SpellToString(Spell:integer): boolean; }
{ By: nickrules }
{ Date: 5 August 2010 }
{ Description: turns a spell into a useable string. }
{******************************************************************************}
Function SpellToStr(Spell: integer): string;
begin
case Spell 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_WATER_STRIKE : result := 'water strike';
SPELL_WATER_BOLT : result := 'water bolt';
SPELL_WATER_BLAST : result := 'water blast';
SPELL_WATER_WAVE : result := 'water wave';

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_FIRE_STRIKE : result := 'fire strike';
SPELL_FIRE_BOLT : result := 'fire bolt';
SPELL_FIRE_BLAST : result := 'fire blast';
SPELL_FIRE_WAVE : result := 'fire wave';

SPELL_STATE_CONFUSE: result := 'confuse';
SPELL_STATE_WEAKE : result := 'weaken';
SPELL_STATE_CURSE : result := 'curse';
SPELL_STATE_BIND : result := 'bind';

SPELL_TELE_HOME : result := 'lumbridge home teleport';
SPELL_TELE_VARROCK : result := 'varrock teleport';
SPELL_TELE_LUMBY : result := 'lumbridge teleport';
SPELL_TELE_FALLY : result := 'falador teleport';

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

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

else
MSI_SubDebug('Invalid spell. Check /msi/skill/magic.simba for a list.');
end;
end;

{******************************************************************************}
{ procedure MSI_GetRequiredRunes(Spell: Integer); }
{ By: nickrules & Coh3n }
{ Date: 17 September 2010 }
{ Description: Sets the RequiredRunes array depending on the user set spells }
{******************************************************************************}
procedure MSI_GetRequiredRunes(Spell: Integer);
begin
case Spell of
SPELL_WIND_STRIKE:
begin
RequiredRunes[RUNE_AIR] := 1; // All other runes would be set to 0 since they're not being used
RequiredRunes[RUNE_MIND] := 1;
end;

SPELL_WATER_STRIKE:
begin
RequiredRunes[RUNE_AIR] := 1;
RequiredRunes[RUNE_MIND] := 1;
RequiredRunes[RUNE_WATER] := 1;
end;

SPELL_EARTH_STRIKE:
begin
RequiredRunes[RUNE_AIR] := 1;
RequiredRunes[RUNE_MIND] := 1;
RequiredRunes[RUNE_EARTH] := 2;
end;

SPELL_FIRE_STRIKE:
begin
RequiredRunes[RUNE_AIR] := 1;
RequiredRunes[RUNE_MIND] := 1;
RequiredRunes[RUNE_FIRE] := 2;
end;

SPELL_WIND_BOLT:
begin
RequiredRunes[RUNE_AIR] := 2;
RequiredRunes[RUNE_CHAOS] := 1;
end;

SPELL_WATER_BOLT:
begin
RequiredRunes[RUNE_AIR] := 2;
RequiredRunes[RUNE_CHAOS] := 1;
RequiredRunes[RUNE_WATER] := 2;
end;

SPELL_EARTH_BOLT:
begin
RequiredRunes[RUNE_AIR] := 2;
RequiredRunes[RUNE_CHAOS] := 1;
RequiredRunes[RUNE_EARTH] := 3;
end;

SPELL_FIRE_BOLT:
begin
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_CHAOS] := 1;
RequiredRunes[RUNE_FIRE] := 4;
end;

SPELL_WIND_BLAST:
begin
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_DEATH] := 1;
end;

SPELL_WATER_BLAST:
begin
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_DEATH] := 1;
RequiredRunes[RUNE_WATER] := 3;
end;

SPELL_EARTH_BLAST:
begin
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_DEATH] := 1;
RequiredRunes[RUNE_EARTH] := 4;
end;

SPELL_FIRE_BLAST:
begin
RequiredRunes[RUNE_AIR] := 4;
RequiredRunes[RUNE_DEATH] := 1;
RequiredRunes[RUNE_FIRE] := 5;
end;

SPELL_STATE_CONFUSE:
begin
RequiredRunes[RUNE_WATER] := 3;
RequiredRunes[RUNE_EARTH] := 2;
RequiredRunes[RUNE_BODY] := 1;
end;

SPELL_STATE_WEAKE:
begin
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_MIND] := 2;
RequiredRunes[RUNE_BODY] := 1;
end;

SPELL_STATE_CURSE:
begin
RequiredRunes[RUNE_WATER] := 2;
RequiredRunes[RUNE_EARTH] := 3;
RequiredRunes[RUNE_BODY] := 1;
end;

SPELL_STATE_BIND:
begin
RequiredRunes[RUNE_EARTH] := 3;
RequiredRunes[RUNE_WATER] := 3;
RequiredRunes[RUNE_NATURE] := 2;
end;

SPELL_TELE_HOME:
begin
end;

SPELL_TELE_VARROCK:
begin
RequiredRunes[RUNE_FIRE] := 1;
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_LAW] := 1;
end;

SPELL_TELE_LUMBY:
begin
RequiredRunes[RUNE_EARTH] := 1;
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_LAW] := 1;
end;

SPELL_TELE_FALLY:
begin
RequiredRunes[RUNE_WATER] := 1;
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_LAW] := 1;
end;

SPELL_ALCH_LOW:
begin
RequiredRunes[RUNE_FIRE] := 3;
RequiredRunes[RUNE_NATURE] := 1;
end;

SPELL_ALCH_HIGH:
begin
RequiredRunes[RUNE_FIRE] := 5;
RequiredRunes[RUNE_NATURE] := 1;
end;

SPELL_TELEGRAB:
begin
RequiredRunes[RUNE_AIR] := 1;
RequiredRunes[RUNE_LAW] := 1;
end;

SPELL_SUPERHEAT:
begin
RequiredRunes[RUNE_AIR] := 4;
RequiredRunes[RUNE_NATURE] := 1;
end;

else
MSI_SubDebug('Invalid spell in MSI_GetRequiredRunes');
end;
case getStaff of
'Staff of Fire': RequiredRunes[RUNE_FIRE] := 0;
'Staff of Earth': RequiredRunes[RUNE_EARTH] := 0;
'Staff of Water': RequiredRunes[RUNE_WATER] := 0;
'Staff of Wind': RequiredRunes[RUNE_AIR] := 0;
end;
end;

{******************************************************************************}
{ function MSI_ItemToSpellSlot(spell: integer): boolean; }
{ By: Nickrules }
{ Date: 5 August 2010 }
{ Description: Moves the item to the most ideal slot }
{******************************************************************************}
function MSI_ItemToSpellSlot(spell: integer): boolean;
begin
case spell of
SPELL_ALCH_LOW:
result := MSI_DragItem(STAFF_FIRE, 6);

SPELL_ALCH_HIGH:
result := MSI_DragItem(STAFF_FIRE, 15);

SPELL_SUPERHEAT:
result := MSI_DragItem(STAFF_FIRE, 13);

else
MSI_Debug('Item manipulation not nessicary...');
end;
end;

{******************************************************************************}
{ function MSI_SetupMagic: Boolean; }
{ By: Nickrules }
{ Date: 5 October 2010 }
{ Description: Sets up stuff for magic }
{******************************************************************************}
Function MSI_SetupMagic: boolean;
SpellUsed : TSpell;
begin
MSI_GetRequiredRunes(MSI_Player[currentplayer].Spell);
MSI_Debug('We can cast '+ SpellToStr(MSI_Player[currentplayer].Spell)+' '+IntToStr(CalculateCasts)+' times.');
MSI_ItemToSpellSlot(MSI_Player[currentplayer].Spell)
SpellUsed := GetSpellInfo(SpellToStr(MSI_Player[currentplayer].Spell));
If SpellUsed.Level > GetSkillLevel('magic') then
begin
MSIDebug('Cannot Cast that spell! The level used for it is too high!');
TerminateScript;
end;
end;

{******************************************************************************}
{ function MSI_Cast(spell, which: integer; isObject: boolean): boolean; }
{ By: Nickrules & Coh3n }
{ Date: 22 August 2010 }
{ Description: Casts 'spell' on item/object 'which' }
{******************************************************************************}
function MSI_Cast(spell, which: integer; isObject: boolean): boolean;
var
s, spellName: string;
spellInfo: TSpell;
didCast: boolean;
begin
spellName := MSI_SpellToText(spell);
spellInfo := GetSpellInfo(spellName);

if (not Cast(spellName, spellInfo.autoCast) then
begin
MSI_SubDebug('Failed to cast spell: ' + spellName);
exit;
end;

if (isObject) then
begin
didCast := MSI_FindObject(MSI_Objects[which], ClickLeft);
s := MSI_Objects[which].Name;
end else
begin
didCast := MSI_ClickItem(which, ['ast']);
s := MSI_Items[which].Name;
end;

if (didCast) then
begin
Result := True;
MSI_SubDebug('Cast ' + spellName + ' on ' + s);
end else
MSI_SubDebug('Failed to cast ' + spellName + ' on ' + s);
end;

begin
SetupSRL;
ClearDebug;
end.
I think the skill level check is good to go now.

Coh3n

2010-10-05 22:35:54

Nice job nick. I'll have to take a better look at it when I have time, but here's a couple things I noticed.
  • A new type isn't really necessary. The same function can be done like this:

  • function CalculateCasts: Integer;
    var
    i: Integer;
    runes: TStringArray;
    runeAmount: TIntegerArray;
    begin
    runes := ['air', 'water', 'earth', 'mind', 'body', 'chaos', 'death', 'cosmic',
    'nature', 'law'];

    for i := 0 to High(runes) do
    runeAmount[i] := RuneAmount('inv', runes[i]);
    I'm not exactly sure what you're doing with the last part of that function. :unsure:
  • The same idea can be applied to your GetStaff function. Using arrays you can turn it into 4-5 lines.
Everything else looks fine. Good job. :)

Bonfield

2010-10-06 04:10:29

^ i had the exact same idea, i wrote some stuff but you beat me to it

i was also thinking something like this, i know it wont work how it is but this is what i thought
function SpellToStr(Spell: integer; out Required_Runes : array of Integer): string;
var
Spell_Arr: Array of Integer;
String_Arr: Array of String;
begin
SetArrayLength(Spell_Arr, NUMBER_OF_SPELLS);
SetArrayLength(String_Arr, NUMBER_OF_SPELLS)

Spell_Arr := [SPELL_WIND_STRIKE , SPELL_WIND_BOLT, SPELL_WIND_BLAST, SPELL_WIND_WAVE, SPELL_WATER_STRIKE,
SPELL_WATER_BOLT, SPELL_WATER_BLAST, SPELL_WATER_WAVE, SPELL_EARTH_STRIKE, SPELL_EARTH_BOLT,
SPELL_EARTH_BLAST, SPELL_EARTH_WAVE, SPELL_FIRE_STRIKE, SPELL_FIRE_BOLT, SPELL_FIRE_BLAST,
SPELL_FIRE_WAVE, SPELL_STATE_CONFUSE, SPELL_STATE_WEAKEN, SPELL_STATE_CURSE, SPELL_STATE_BIND,
SPELL_TELE_HOME, SPELL_TELE_VARROCK, SPELL_TELE_LUMBY, SPELL_TELE_FALLY, SPELL_ALCH_LOW,
SPELL_ALCH_HIGH, SPELL_TELEGRAB, SPELL_SUPERHEAT];

String_Arr := ['wind strike', 'wind bolt', 'wind blast', 'wind wave', 'water strike', 'water bolt',
'water blast', 'water wave', 'earth strike', 'earth bolt', 'earth blast', 'earth wave',
'fire strike', 'fire bolt', 'fire blast', 'fire wave', 'confuse', 'weaken', 'curse',
'bind', 'lumbridge home teleport', 'varrock teleport', 'lumbridge teleport', 'falador teleport',
'low level alchemy', 'high level alchemy', 'telekinetic grab', 'superheat item'];

if (not InIntArray(Spell_Arr, Spell)) then
Writeln('Invalid spell. Check /msi/skill/magic.simba for a list.');

Result := String_Arr[Spell];
Required_Runes := Load_Spell(Result);
end;

where Load_Spell will load a record of how many runes each spell uses

  for i:= RUNE_LOW to RUNE_HIGH do
if RequiredRunes[i] > 0 then
begin
TheThing[i] := round(RuneCount[i] / RequiredRunes[i]);
Result := min(Result, TheThing[i]);
end;

im guessing that calculates how many casts a player can do based on the amount of runes in the inventory, i cant follow it though


it looks pretty good, have you tested MSI_Cast? i started making a script last week and im pretty sure SRL's cast procedure could be broken

Gu3st...

2010-10-06 04:24:56

Good job :)
I'll have a look at it when I get home from school

Coh3n

2010-10-06 12:49:52

From: Bonfield
it looks pretty good, have you tested MSI_Cast? i started making a script last week and im pretty sure SRL's cast procedure could be broken

I've never tested it myself, not sure about Nick.

As for your code, I've never used out so I don't know exactly how it works.

Looking at SRL's magic.scar, I see that the only thing TSpell needs is a RequiredRunes attribute. Perhaps it can be added, then the runes set when SetupSpells is called?

NCDS

2010-10-06 13:00:57

From: Coh3n

As for your code, I've never used out so I don't know exactly how it works.

Quite positive it's the same as 'var' but the variable isn't used in the function, just carries an output value.

nickrules

2010-10-06 17:53:34

Wow, kinda depressing to see the bulk of your work reduced to a few lines in less than a day :\

From: Bonfield


it looks pretty good, have you tested MSI_Cast?


It has never been tested, by anyone as far as I know. Its not supported by MSI, nor has any idea for making it supported been developed (without adding another line to the player setup that is). Bonfield, honestly, i really don't want any more help with this right now.

I'll edit this post with more thoughts eventually. Or maybe never. Who knows…

mormonman

2010-10-06 18:30:49


{******************************************************************************}
{ function GetStaff: String; }
{ By: mormonman }
{ Date: 6 October 2010 }
{ Description: Checks for elemental staff in equipment tab. }
{******************************************************************************}
Function GetStaff(): String;
var x,y,i:integer;
staffArray:TIntegerArray;
nameArray:TStringArray;
begin
GameTab(tab_Equip);
staffArray := [STAFF_AIR, STAFF_WATER, STAFF_EARTH, STAFF_FIRE];
nameArray := ['Staff of Air', 'Staff of Water', 'Staff of Earth',
'Staff of Fire'];
for i:=0 to 3 do
begin
if MSI_FindTool(staffArray[i], Tab_Equip, X, Y) then
begin
result := nameArray[i];
exit;
end;
result := 'Staff not found!';
end;
end;

I don't know the variable naming conventions for MSI, but nick you need to learn how to use arrays. They are awesome!

Bonfield

2010-10-06 19:26:52

out explained coh3n I had no idea about it either, until dans the man helped me with a function

So you don't need help with this nick? Arrays would shorten alot in this instance

So if your done with this how can I help with MSI? What else needs doing?

Coh3n

2010-10-06 19:55:41

From: Bonfield

So if your done with this how can I help with MSI? What else needs doing?

Continue with this (if Nick is done). There's also Runecrafting and Cooking, but I think Zytex is doing Cooking.

You could also make some TScript records for new locations, but if you're looking do write more code then there's the skills. I think someone made a thread about Fighting also.

I'm going to make a thread in the Public SVN suggesting adding RequiredRunes to SRL's magic.scar. That will allow us to really utilize the TSpell record + the other SRL functions.

Bonfield

2010-10-07 04:04:23


function CalculateCasts: Integer;
var
i, h: Integer;
Rune_Names: Array of String;
Runes_Needed: Array of Integer;
begin
SetArrayLength(Rune_Names, RUNE_TYPES_F2P);
Rune_Names := ['air', 'water', 'earth', 'mind', 'body', 'chaos', 'death', 'cosmic',
'nature', 'law'];
h := High(Rune_Names);
for i := 0 to h do
Runes_Needed[i] := RuneAmount('inv', Rune_Names[i]);

for i:= RUNE_LOW to RUNE_HIGH do
if Runes_Needed[i] > 0 then
begin
TheThing[i] := round(RuneCount[i] / Runes_Needed[i]);
Result := min(Result, TheThing[i]);
end;
end;

function GetStaff(): String;
var
x, y, i, h:integer;
Staff_Equiped: Array of String;
Staff_Int_Arr: Array of Integer;
begin
SetArrayLength(Staff_Equiped, NUMBER_OF_STAFFS);
SetArrayLength(Staff_Int_Arr, NUMBER_OF_STAFFS);

Staff_Int_Arr := [STAFF_AIR, STAFF_WATER, STAFF_EARTH, STAFF_FIRE];
Staff_Equiped := ['Staff of Air', 'Staff of Water', 'Staff of Earth', 'Staff of Fire'];

GameTab(tab_Equip);
h := High(Staff_Int_Arr);

for i := 0 to h do
MSI_FindTool[Staff_Equiped[i]] := RuneAmount('inv', i);
begin
Result := Staff_Int_Arr[i];
writeln(Staff_Equiped[i]+' equiped.');
Exit;
end else
Result := '';
writeln('Could not find staff in Inventory');
Exit;
end;

function SpellToStr(Spell: integer; out Required_Runes :Integer): string;
var
Spell_Arr: Array of Integer;
String_Arr: Array of String;
begin
SetArrayLength(Spell_Arr, NUMBER_OF_SPELLS);
SetArrayLength(String_Arr, NUMBER_OF_SPELLS)

Spell_Arr := [SPELL_WIND_STRIKE , SPELL_WIND_BOLT, SPELL_WIND_BLAST, SPELL_WIND_WAVE, SPELL_WATER_STRIKE,
SPELL_WATER_BOLT, SPELL_WATER_BLAST, SPELL_WATER_WAVE, SPELL_EARTH_STRIKE, SPELL_EARTH_BOLT,
SPELL_EARTH_BLAST, SPELL_EARTH_WAVE, SPELL_FIRE_STRIKE, SPELL_FIRE_BOLT, SPELL_FIRE_BLAST,
SPELL_FIRE_WAVE, SPELL_STATE_CONFUSE, SPELL_STATE_WEAKEN, SPELL_STATE_CURSE, SPELL_STATE_BIND,
SPELL_TELE_HOME, SPELL_TELE_VARROCK, SPELL_TELE_LUMBY, SPELL_TELE_FALLY, SPELL_ALCH_LOW,
SPELL_ALCH_HIGH, SPELL_TELEGRAB, SPELL_SUPERHEAT];

String_Arr := ['wind strike', 'wind bolt', 'wind blast', 'wind wave', 'water strike', 'water bolt',
'water blast', 'water wave', 'earth strike', 'earth bolt', 'earth blast', 'earth wave',
'fire strike', 'fire bolt', 'fire blast', 'fire wave', 'confuse', 'weaken', 'curse',
'bind', 'lumbridge home teleport', 'varrock teleport', 'lumbridge teleport', 'falador teleport',
'low level alchemy', 'high level alchemy', 'telekinetic grab', 'superheat item'];

if (not InIntArray(Spell_Arr, Spell)) then
Writeln('Invalid spell. Check /msi/skill/magic.simba for a list.');

Result := String_Arr[Spell];
//Required_Runes := Load_Spell(Result); // need to make this
end;

function MSI_ItemToSpellSlot(spell: integer): boolean;
var
i, h: Integer;
Spell_Arr, Inv_Slot_Arr : Array of Integer;

begin
SetArrayLength(Spell_Arr, NUMBER_OF_NAT_SPELLS);
SetArrayLength(Inv_Slot_Arr, NUMBER_OF_NAT_SPELLS);

Spell_Arr := [SPELL_ALCH_LOW, SPELL_ALCH_HIGH, SPELL_SUPERHEAT];
Inv_Slot_Arr := [6, 15, 13];

h := High(Spell_Arr);
for i:= 0 to h do
if (i = Spell) then
Result := MSI_DragItem(STAFF_FIRE, Inv_Slot_Arr[i]) // wouldnt that move the fire staff??
end;
]

thats what i have thought of so far, im still thinking of a way of calculate how many cast a player can do

Daniel

2010-10-07 04:58:02

From: Coh3n
Oh lol, care to expand on Format() a little more? :o


http://delphibasics.co.uk/RTL.asp?Name=Format

:)

nickrules

2010-10-07 15:48:36

Close this thread.

NCDS

2010-10-07 15:50:48

From: nickrules
Close this thread.


…why?

Bonfield

2010-10-07 16:01:44

He doesn't want help making this

NCDS

2010-10-07 16:04:15

From: nickrules

I'll edit this post with more thoughts eventually. Or maybe never. Who knows…

nick, if you want to work on it alone, that's fine, but don't say the above quote and not expect people to continue development. MSI is a community project after all..

nickrules

2010-10-07 16:36:42

From: NCDS
nick, if you want to work on it alone, that's fine, but don't say the above quote and not expect people to continue development. MSI is a community project after all..


First of all, It wasn't supposed to be like that. I said that simply because i might not have to doublepost.

And I never said I wanted to work on this alone. Nor would I ever expect to be able to work on it alone, at least not after publicly releasing that I'm working on it. And, on that note, it wouldn't be where it is now, if it weren't for others help.

What I have a problem with, is my all my work being hijacked. Over half of it, has be rewritten, in two days. Its like saying "Here, this is the work you've done, but its all useless, so I've redone it all."
I don't give a shit about botting, RS, or anything like that. I just like to write the code. and when pretty much everything I've worked on is rendered useless, its a bit upsetting. I've tried to state that I don't want help from even more people, and I understand that the people who are trying to help, are trying to do just that - help. I want to work on this, just to make the code. To make it work. to see the final product.

But, when that gets taken away, what more do I have to do? nothing. The only reason I've stuck around here, and continued to work on this, is because I want to finish it. But now, I can't even do that. And I can't just ignore the work they've done, I've already seen it. And its obviously more efficient, and better written. I could just not put it in there, but it would bother me, know that there is a much better way to do it, and im simply ignoring it out of choice.

What I don't mind, is having someone say something like "Oh hey, nick, This right here can be shortened a bunch with blah blah blah. Read this/it works better because…."
But this? This doesn't help me become better at all. I don't learn anything, I don't gain any pride it what I've done, I don't get a sense of accomplishment, copy-pasting some function someone else made.

I've never had a problem with being helped. But what people have done isn't help. Its not help at all. It just defeats the whole point of what i've done.

NCDS

2010-10-07 16:45:21

From: nickrules
First of all, It wasn't supposed to be like that. I said that simply because i might not have to doublepost.

And I never said I wanted to work on this alone. Nor would I ever expect to be able to work on it alone, at least not after publicly releasing that I'm working on it. And, on that note, it wouldn't be where it is now, if it weren't for others help.

What I have a problem with, is my all my work being hijacked. Over half of it, has be rewritten, in two days. Its like saying "Here, this is the work you've done, but its all useless, so I've redone it all."
I don't give a shit about botting, RS, or anything like that. I just like to write the code. and when pretty much everything I've worked on is rendered useless, its a bit upsetting. I've tried to state that I don't want help from even more people, and I understand that the people who are trying to help, are trying to do just that - help. I want to work on this, just to make the code. To make it work. to see the final product.

But, when that gets taken away, what more do I have to do? nothing. The only reason I've stuck around here, and continued to work on this, is because I want to finish it. But now, I can't even do that. And I can't just ignore the work they've done, I've already seen it. And its obviously more efficient, and better written. I could just not put it in there, but it would bother me, know that there is a much better way to do it, and im simply ignoring it out of choice.

What I don't mind, is having someone say something like "Oh hey, nick, This right here can be shortened a bunch with blah blah blah. Read this/it works better because…."
But this? This doesn't help me become better at all. I don't learn anything, I don't gain any pride it what I've done, I don't get a sense of accomplishment, copy-pasting some function someone else made.

I've never had a problem with being helped. But what people have done isn't help. Its not help at all. It just defeats the whole point of what i've done.


That's understandable as it has happened to all of us at least once. What makes the difference though is if you take the time to study their code and learn from it, and if you don't understand something, don't ever be afraid to ask about it :)

It's honestly better that changes happen now, rather than when you say it's finished, then one of us goes to commit it, and we would have to change it before committing anyways.

Don't take it so harsh, there are plenty more skills to be added to MSI that you can always work on if you feel like it. Your efforts are clearly not over-looked, hence the MSI cup. Just relax and have fun with it :)

Bonfield

2010-10-07 17:05:16

Sorry if it looked like I was trying to change your work, I was just trying to help the MSI include, I wasn't trying to say you did anything wrong or my code is better than yours, I still have a bit of work to do to make it actually work, the main reason I wanted to do this was to improve the way I code.

It seems like you think this was personal, I'm sorry for that I never meant for it, I thought this idea had been forgotten about

mormonman

2010-10-07 17:32:44

From: nickrules
First of all, It wasn't supposed to be like that. I said that simply because i might not have to doublepost.

And I never said I wanted to work on this alone. Nor would I ever expect to be able to work on it alone, at least not after publicly releasing that I'm working on it. And, on that note, it wouldn't be where it is now, if it weren't for others help.

What I have a problem with, is my all my work being hijacked. Over half of it, has be rewritten, in two days. Its like saying "Here, this is the work you've done, but its all useless, so I've redone it all."
I don't give a shit about botting, RS, or anything like that. I just like to write the code. and when pretty much everything I've worked on is rendered useless, its a bit upsetting. I've tried to state that I don't want help from even more people, and I understand that the people who are trying to help, are trying to do just that - help. I want to work on this, just to make the code. To make it work. to see the final product.

But, when that gets taken away, what more do I have to do? nothing. The only reason I've stuck around here, and continued to work on this, is because I want to finish it. But now, I can't even do that. And I can't just ignore the work they've done, I've already seen it. And its obviously more efficient, and better written. I could just not put it in there, but it would bother me, know that there is a much better way to do it, and im simply ignoring it out of choice.

What I don't mind, is having someone say something like "Oh hey, nick, This right here can be shortened a bunch with blah blah blah. Read this/it works better because…."
But this? This doesn't help me become better at all. I don't learn anything, I don't gain any pride it what I've done, I don't get a sense of accomplishment, copy-pasting some function someone else made.

I've never had a problem with being helped. But what people have done isn't help. Its not help at all. It just defeats the whole point of what i've done.


There was a reason I only fixed one of your functions….so that you would take the hint and incorporate what I did into your other ones!

Coh3n

2010-10-07 17:32:47

From: Bonfield


function GetStaff(): String;
var
x, y, i, h:integer;
Staff_Equiped: Array of String;
Staff_Int_Arr: Array of Integer;
begin
SetArrayLength(Staff_Equiped, NUMBER_OF_STAFFS);
SetArrayLength(Staff_Int_Arr, NUMBER_OF_STAFFS);

Staff_Int_Arr := [STAFF_AIR, STAFF_WATER, STAFF_EARTH, STAFF_FIRE];
Staff_Equiped := ['Staff of Air', 'Staff of Water', 'Staff of Earth', 'Staff of Fire'];

GameTab(tab_Equip);
h := High(Staff_Int_Arr);

for i := 0 to h do
MSI_FindTool[Staff_Equiped[i]] := RuneAmount('inv', i);
begin
Result := Staff_Int_Arr[i];
writeln(Staff_Equiped[i]+' equiped.');
Exit;
end else
Result := '';
writeln('Could not find staff in Inventory');
Exit;
end;

You don't need those arrays as all that information is already stored in MSI types. I think it's the same for your first function also. It should also be edited to check both the inventory and equipment tabs. If in the inventory, it should equip. :)

function GetStaff(): String;
var
x, y, i, h:integer;
begin
for i := STAFF_AIR to STAFF_FIRE do
if (MSI_FindTool(i, tab_Equip, x, y)) then
begin
Result := MSI_Items[i].Name;
writeln(MSI_Items[i].Name+' equiped.');
end else begin
Result := '';
writeln('Could not find staff in Inventory');
end;
end;

From: Bonfield


function SpellToStr(Spell: integer; out Required_Runes :Integer): string;
var
Spell_Arr: Array of Integer;
String_Arr: Array of String;
begin
SetArrayLength(Spell_Arr, NUMBER_OF_SPELLS);
SetArrayLength(String_Arr, NUMBER_OF_SPELLS)

Spell_Arr := [SPELL_WIND_STRIKE , SPELL_WIND_BOLT, SPELL_WIND_BLAST, SPELL_WIND_WAVE, SPELL_WATER_STRIKE,
SPELL_WATER_BOLT, SPELL_WATER_BLAST, SPELL_WATER_WAVE, SPELL_EARTH_STRIKE, SPELL_EARTH_BOLT,
SPELL_EARTH_BLAST, SPELL_EARTH_WAVE, SPELL_FIRE_STRIKE, SPELL_FIRE_BOLT, SPELL_FIRE_BLAST,
SPELL_FIRE_WAVE, SPELL_STATE_CONFUSE, SPELL_STATE_WEAKEN, SPELL_STATE_CURSE, SPELL_STATE_BIND,
SPELL_TELE_HOME, SPELL_TELE_VARROCK, SPELL_TELE_LUMBY, SPELL_TELE_FALLY, SPELL_ALCH_LOW,
SPELL_ALCH_HIGH, SPELL_TELEGRAB, SPELL_SUPERHEAT];

String_Arr := ['wind strike', 'wind bolt', 'wind blast', 'wind wave', 'water strike', 'water bolt',
'water blast', 'water wave', 'earth strike', 'earth bolt', 'earth blast', 'earth wave',
'fire strike', 'fire bolt', 'fire blast', 'fire wave', 'confuse', 'weaken', 'curse',
'bind', 'lumbridge home teleport', 'varrock teleport', 'lumbridge teleport', 'falador teleport',
'low level alchemy', 'high level alchemy', 'telekinetic grab', 'superheat item'];

if (not InIntArray(Spell_Arr, Spell)) then
Writeln('Invalid spell. Check /msi/skill/magic.simba for a list.');

Result := String_Arr[Spell];
//Required_Runes := Load_Spell(Result); // need to make this
end;


function MSI_ItemToSpellSlot(spell: integer): boolean;
var
i, h: Integer;
Spell_Arr, Inv_Slot_Arr : Array of Integer;

begin
SetArrayLength(Spell_Arr, NUMBER_OF_NAT_SPELLS);
SetArrayLength(Inv_Slot_Arr, NUMBER_OF_NAT_SPELLS);

Spell_Arr := [SPELL_ALCH_LOW, SPELL_ALCH_HIGH, SPELL_SUPERHEAT];
Inv_Slot_Arr := [6, 15, 13];

h := High(Spell_Arr);
for i:= 0 to h do
if (i = Spell) then
Result := MSI_DragItem(STAFF_FIRE, Inv_Slot_Arr[i]) // wouldnt that move the fire staff??
end;
]

thats what i have thought of so far, im still thinking of a way of calculate how many cast a player can do

Those are shorter, yes, but I think they're cuttered and harder to follow. Just my opinion, but I think they should be left the way they were. Easier to understand for everyone and much easier to add new spells, etc.
_______________________

@Nick: Just because someone rewrote your work, doesn't necessarily mean it's better or that it's going to be used. I like your SpellToStr and ItemToSpellSlot better for the reasons I stated above. I do understand where you're coming from, and from what I read, Bonfield didn't meant to make you feel that way.

E: Oh and Nick, I'm going to add the stuff you did for getRequiredRunes to SRL's magic.scar. :)

nickrules

2010-10-07 17:51:23

@Bofield Its alright, I understand you were just trying to help. But magic is far from forgotten. It might be on the back burner at times, but its always there.

@mormonman Its fine, post wasn't directed at you really ;)

@Coh3n Thanks. not much else I can say, haha.

Sorry for my crazy long rant people. Not exactly the most enjoyable week in the world for me ;)

EDIT:
From: Coh3n

E: Oh and Nick, I'm going to add the stuff you did for getRequiredRunes to SRL's magic.scar. :)


:OO

Coh3n

2010-10-07 17:53:32

From: nickrules
@Bofield Its alright, I understand you were just trying to help. But magic is far from forgotten. It might be on the back burner at times, but its always there.

@mormonman Its fine, post wasn't directed at you really ;)

@Coh3n Thanks. not much else I can say, haha.

Sorry for my crazy long rant people. Not exactly the most enjoyable week in the world for me ;)

EDIT:


:OO

Happens to everyone. ;)

mormonman

2010-10-07 17:54:58

From: nickrules
Sorry for my crazy long rant people. Not exactly the most enjoyable week in the world for me ;)


Oh I know how that shit goes.

Bonfield

2010-10-08 05:12:24

Pretty sure that post was meant to me…

All i wanted to do was try to get back into scripting and try to improve my skills, I didn't want to tread on anyones toes, so I will think of something else to contribute to MSI

Coh3n

2010-10-08 11:55:16

From: Bonfield
Pretty sure that post was meant to me…

All i wanted to do was try to get back into scripting and try to improve my skills, I didn't want to tread on anyones toes, so I will think of something else to contribute to MSI

That's not what we want either. We want everyone to be able to work on what they want. There are still other things you can do to work on Magic such as testing MSI_Cast or any of the other functions that have been made. Just because they're not implemented into MSI yet doesn't mean they can't be tested. ;)

If you're looking to write some new code, you can take a look at this thread. I'm not sure when I'll get time to do it, so if you can make it work you'll be helping out SRL and MSI. :) Any questions you have about it can be posted on that thread.

nickrules

2010-10-10 19:27:48

From: Bonfield


function GetStaff(): String;
var
x, y, i, h:integer;
Staff_Equiped: Array of String;
Staff_Int_Arr: Array of Integer;
begin
SetArrayLength(Staff_Equiped, NUMBER_OF_STAFFS);
SetArrayLength(Staff_Int_Arr, NUMBER_OF_STAFFS);

Staff_Int_Arr := [STAFF_AIR, STAFF_WATER, STAFF_EARTH, STAFF_FIRE];
Staff_Equiped := ['Staff of Air', 'Staff of Water', 'Staff of Earth', 'Staff of Fire'];

GameTab(tab_Equip);
h := High(Staff_Int_Arr);

for i := 0 to h do
MSI_FindTool[Staff_Equiped[i]] := RuneAmount('inv', i);
begin
Result := Staff_Int_Arr[i];
writeln(Staff_Equiped[i]+' equiped.');
Exit;
end else
Result := '';
writeln('Could not find staff in Inventory');
Exit;
end;


Care to explain how this works? or more specifically :

 for i := 0 to h do
MSI_FindTool[Staff_Equiped[i]] := RuneAmount('inv', i); //this part
begin
Result := Staff_Int_Arr[i];
writeln(Staff_Equiped[i]+' equiped.');
Exit;
end else

Other than that, I think magic is just about done.

Current version:
{==============================================================================\
| MSI Group Scripting Include |
| Magic.scar |
|==============================================================================|
| For all magic routines. |
\ _____________________________________________________________________________}
{$i SRL/SRL.scar}
{$i SRL/SRL/skill/Magic.scar}

Type
TRuneCount = Record
Air: Integer;
Water: Integer;
Earth: Integer;
Fire: Integer;
Death: Integer;
Cosmic: Integer;
Chaos: Integer;
Body: Integer;
Mind: Integer;
Nature: Integer;
Law: Integer;
end;


var
RequiredRunes: array[0..(RUNE_COUNT - 1)] of Integer;
RuneCount: array[RUNE_LOW..RUNE_HIGH] of integer;


{******************************************************************************}
{ function CalculateCasts: Integer; }
{ By: nickrules }
{ Date: 17 September 2010 }
{ Description: turns a spell into a useable string. }
{******************************************************************************}
Function CalculateCasts: Integer;
var RuneCount : TIntegerArray;
RuneName: TStringArray;
begin
For RUNE_LOW to RUNE_HIGH do
RuneAmount('inv',RuneName[i]);
with RuneCount do
begin
Air := RuneAmount('inv','air');
Water := RuneAmount('inv','water');
Farth := RuneAmount('inv','earth');
Fire := RuneAmount('inv','Fire');
Mind := RuneAmount('inv','mind');
Body := RuneAmount('inv','body');
Chaos := RuneAmount('inv','chaos');
Death := RuneAmount('inv','death');
Cosmic := RuneAmount('inv','cosmic');
Nature := RuneAmount('inv','nature');
Law := RuneAmount('inv','law');
end;

for i:= RUNE_LOW to RUNE_HIGH do
if RequiredRunes[i] > 0 then
begin
TheThing[i] := round(RuneCount[i] / RequiredRunes[i]);
Result := min(Result, TheThing[i]);
end;
end;


{******************************************************************************}
{ function GetStaff: String; }
{ By: nickrules }
{ Date: 17 September 2010 }
{ Description: turns a spell into a useable string. }
{******************************************************************************}
Function GetStaff(): String;
var x,y:integer;
begin
GameTab(tab_Equip)
if MSI_FindTool(STAFF_AIR, Tab_Equip, X, Y) then
begin
result := 'Staff of Air';
exit;
end else
begin
result := '';
end;
if MSI_FindTool(STAFF_WATER, Tab_Equip, X, Y) then
begin
result := 'Staff of Water';
exit;
end else
begin
result := '';
end;
if MSI_FindTool(STAFF_EARTH, Tab_Equip, X, Y) then
begin
result := 'Staff of Earth';
exit;
end else
begin
result := '';
end;
if MSI_FindTool(STAFF_FIRE, Tab_Equip, X, Y) then
begin
result := 'Staff of Fire';
exit;
end else
begin
result := 'Staff not found!';
end;
end;


{******************************************************************************}
{ function SpellToString(Spell:integer): boolean; }
{ By: nickrules }
{ Date: 5 August 2010 }
{ Description: turns a spell into a useable string. }
{******************************************************************************}
Function SpellToStr(Spell: integer): string;
begin
case Spell 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_WATER_STRIKE : result := 'water strike';
SPELL_WATER_BOLT : result := 'water bolt';
SPELL_WATER_BLAST : result := 'water blast';
SPELL_WATER_WAVE : result := 'water wave';

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_FIRE_STRIKE : result := 'fire strike';
SPELL_FIRE_BOLT : result := 'fire bolt';
SPELL_FIRE_BLAST : result := 'fire blast';
SPELL_FIRE_WAVE : result := 'fire wave';

SPELL_STATE_CONFUSE: result := 'confuse';
SPELL_STATE_WEAKE : result := 'weaken';
SPELL_STATE_CURSE : result := 'curse';
SPELL_STATE_BIND : result := 'bind';

SPELL_TELE_HOME : result := 'lumbridge home teleport';
SPELL_TELE_VARROCK : result := 'varrock teleport';
SPELL_TELE_LUMBY : result := 'lumbridge teleport';
SPELL_TELE_FALLY : result := 'falador teleport';

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

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

else
MSI_SubDebug('Invalid spell. Check /msi/skill/magic.simba for a list.');
end;
end;

{******************************************************************************}
{ procedure MSI_GetRequiredRunes(Spell: Integer); }
{ By: nickrules & Coh3n }
{ Date: 17 September 2010 }
{ Description: Sets the RequiredRunes array depending on the user set spells }
{******************************************************************************}
procedure MSI_GetRequiredRunes(Spell: Integer);
begin
case Spell of
SPELL_WIND_STRIKE:
begin
RequiredRunes[RUNE_AIR] := 1; // All other runes would be set to 0 since they're not being used
RequiredRunes[RUNE_MIND] := 1;
end;

SPELL_WATER_STRIKE:
begin
RequiredRunes[RUNE_AIR] := 1;
RequiredRunes[RUNE_MIND] := 1;
RequiredRunes[RUNE_WATER] := 1;
end;

SPELL_EARTH_STRIKE:
begin
RequiredRunes[RUNE_AIR] := 1;
RequiredRunes[RUNE_MIND] := 1;
RequiredRunes[RUNE_EARTH] := 2;
end;

SPELL_FIRE_STRIKE:
begin
RequiredRunes[RUNE_AIR] := 1;
RequiredRunes[RUNE_MIND] := 1;
RequiredRunes[RUNE_FIRE] := 2;
end;

SPELL_WIND_BOLT:
begin
RequiredRunes[RUNE_AIR] := 2;
RequiredRunes[RUNE_CHAOS] := 1;
end;

SPELL_WATER_BOLT:
begin
RequiredRunes[RUNE_AIR] := 2;
RequiredRunes[RUNE_CHAOS] := 1;
RequiredRunes[RUNE_WATER] := 2;
end;

SPELL_EARTH_BOLT:
begin
RequiredRunes[RUNE_AIR] := 2;
RequiredRunes[RUNE_CHAOS] := 1;
RequiredRunes[RUNE_EARTH] := 3;
end;

SPELL_FIRE_BOLT:
begin
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_CHAOS] := 1;
RequiredRunes[RUNE_FIRE] := 4;
end;

SPELL_WIND_BLAST:
begin
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_DEATH] := 1;
end;

SPELL_WATER_BLAST:
begin
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_DEATH] := 1;
RequiredRunes[RUNE_WATER] := 3;
end;

SPELL_EARTH_BLAST:
begin
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_DEATH] := 1;
RequiredRunes[RUNE_EARTH] := 4;
end;

SPELL_FIRE_BLAST:
begin
RequiredRunes[RUNE_AIR] := 4;
RequiredRunes[RUNE_DEATH] := 1;
RequiredRunes[RUNE_FIRE] := 5;
end;

SPELL_STATE_CONFUSE:
begin
RequiredRunes[RUNE_WATER] := 3;
RequiredRunes[RUNE_EARTH] := 2;
RequiredRunes[RUNE_BODY] := 1;
end;

SPELL_STATE_WEAKE:
begin
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_MIND] := 2;
RequiredRunes[RUNE_BODY] := 1;
end;

SPELL_STATE_CURSE:
begin
RequiredRunes[RUNE_WATER] := 2;
RequiredRunes[RUNE_EARTH] := 3;
RequiredRunes[RUNE_BODY] := 1;
end;

SPELL_STATE_BIND:
begin
RequiredRunes[RUNE_EARTH] := 3;
RequiredRunes[RUNE_WATER] := 3;
RequiredRunes[RUNE_NATURE] := 2;
end;

SPELL_TELE_HOME:
begin
end;

SPELL_TELE_VARROCK:
begin
RequiredRunes[RUNE_FIRE] := 1;
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_LAW] := 1;
end;

SPELL_TELE_LUMBY:
begin
RequiredRunes[RUNE_EARTH] := 1;
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_LAW] := 1;
end;

SPELL_TELE_FALLY:
begin
RequiredRunes[RUNE_WATER] := 1;
RequiredRunes[RUNE_AIR] := 3;
RequiredRunes[RUNE_LAW] := 1;
end;

SPELL_ALCH_LOW:
begin
RequiredRunes[RUNE_FIRE] := 3;
RequiredRunes[RUNE_NATURE] := 1;
end;

SPELL_ALCH_HIGH:
begin
RequiredRunes[RUNE_FIRE] := 5;
RequiredRunes[RUNE_NATURE] := 1;
end;

SPELL_TELEGRAB:
begin
RequiredRunes[RUNE_AIR] := 1;
RequiredRunes[RUNE_LAW] := 1;
end;

SPELL_SUPERHEAT:
begin
RequiredRunes[RUNE_AIR] := 4;
RequiredRunes[RUNE_NATURE] := 1;
end;

else
MSI_SubDebug('Invalid spell in MSI_GetRequiredRunes');
end;
case getStaff of
'Staff of Fire': RequiredRunes[RUNE_FIRE] := 0;
'Staff of Earth': RequiredRunes[RUNE_EARTH] := 0;
'Staff of Water': RequiredRunes[RUNE_WATER] := 0;
'Staff of Wind': RequiredRunes[RUNE_AIR] := 0;
end;
end;

{******************************************************************************}
{ function MSI_ItemToSpellSlot(spell: integer): boolean; }
{ By: Nickrules }
{ Date: 5 August 2010 }
{ Description: Moves the item to the most ideal slot }
{******************************************************************************}
function MSI_ItemToSpellSlot(spell: integer): boolean;
begin
case spell of
SPELL_ALCH_LOW:
result := MSI_DragItem(STAFF_FIRE, 6);

SPELL_ALCH_HIGH:
result := MSI_DragItem(STAFF_FIRE, 15);

SPELL_SUPERHEAT:
result := MSI_DragItem(STAFF_FIRE, 13);

else
MSI_Debug('Item manipulation not nessicary...');
end;
end;

{******************************************************************************}
{ function MSI_SetupMagic: Boolean; }
{ By: Nickrules }
{ Date: 5 October 2010 }
{ Description: Sets up stuff for magic }
{******************************************************************************}
Function MSI_SetupMagic: boolean;
SpellUsed : TSpell;
begin
MSI_GetRequiredRunes(MSI_Player[currentplayer].Spell);
MSI_Debug('We can cast '+ SpellToStr(MSI_Player[currentplayer].Spell)+' '+IntToStr(CalculateCasts)+' times.');
MSI_ItemToSpellSlot(MSI_Player[currentplayer].Spell)
SpellUsed := GetSpellInfo(SpellToStr(MSI_Player[currentplayer].Spell));
If SpellUsed.Level > GetSkillLevel('magic') then
begin
MSIDebug('Cannot Cast that spell! The level used for it is too high!');
TerminateScript;
end;
end;

{******************************************************************************}
{ function MSI_Cast(spell, which: integer; isObject: boolean): boolean; }
{ By: Nickrules & Coh3n }
{ Date: 22 August 2010 }
{ Description: Casts 'spell' on item/object 'which' }
{******************************************************************************}
function MSI_Cast(spell, which: integer; isObject: boolean): boolean;
var
s, spellName: string;
spellInfo: TSpell;
didCast: boolean;
begin
spellName := MSI_SpellToText(spell);
spellInfo := GetSpellInfo(spellName);

if (not Cast(spellName, spellInfo.autoCast) then
begin
MSI_SubDebug('Failed to cast spell: ' + spellName);
exit;
end;

if (isObject) then
begin
didCast := MSI_FindObject(MSI_Objects[which], ClickLeft);
s := MSI_Objects[which].Name;
end else
begin
didCast := MSI_ClickItem(which, ['ast']);
s := MSI_Items[which].Name;
end;

if (didCast) then
begin
Result := True;
MSI_SubDebug('Cast ' + spellName + ' on ' + s);
end else
MSI_SubDebug('Failed to cast ' + spellName + ' on ' + s);
end;

begin
SetupSRL;
ClearDebug;
end.

NCDS

2010-10-10 19:37:43

From: nickrules
Care to explain how this works? or more specifically :

 for i := 0 to h do
MSI_FindTool[Staff_Equiped[i]] := RuneAmount('inv', i); //this part
begin
Result := Staff_Int_Arr[i];
writeln(Staff_Equiped[i]+' equiped.');
Exit;
end else


Is supposed to be:
 for i := 0 to h do
if MSI_FindTool[Staff_Equiped[i]] = RuneAmount('inv', i) then
begin
Result := Staff_Int_Arr[i];
writeln(Staff_Equiped[i]+' equiped.');
Exit;
end else
I would imagine.

Edit:

function MSI_ItemToSpellSlot(spell: integer): boolean;
begin
case spell of
SPELL_ALCH_LOW:
result := MSI_DragItem(STAFF_FIRE, 6);

SPELL_ALCH_HIGH:
result := MSI_DragItem(STAFF_FIRE, 15);

SPELL_SUPERHEAT:
result := MSI_DragItem(STAFF_FIRE, 13);

else
MSI_Debug('Item manipulation not nessicary...');
end;
end;
Is MSI_DragItem a real function :confused:

Looks like it's coming along nicely! Just please be sure to test it before you post a "final copy", as I can see a few things a t quick glance that would stop if from compiling.

Good job though :)

nickrules

2010-10-10 21:33:28

From: NCDS
Is supposed to be:
 for i := 0 to h do
if MSI_FindTool[Staff_Equiped[i]] = RuneAmount('inv', i) then
begin
Result := Staff_Int_Arr[i];
writeln(Staff_Equiped[i]+' equiped.');
Exit;
end else
I would imagine.

Edit:

function MSI_ItemToSpellSlot(spell: integer): boolean;
begin
case spell of
SPELL_ALCH_LOW:
result := MSI_DragItem(STAFF_FIRE, 6);

SPELL_ALCH_HIGH:
result := MSI_DragItem(STAFF_FIRE, 15);

SPELL_SUPERHEAT:
result := MSI_DragItem(STAFF_FIRE, 13);

else
MSI_Debug('Item manipulation not nessicary...');
end;
end;
Is MSI_DragItem a real function :confused:

Looks like it's coming along nicely! Just please be sure to test it before you post a "final copy", as I can see a few things a t quick glance that would stop if from compiling.

Good job though :)


I can't compile…. There's a billion unknown identifiers, due to the spells.

As for MSI_DragItem, it does not appear to exist. I thought it did, or maybe it used to, and no longer does? or maybe there was discussion of making one. Wouldn't be hard to do…

On the topic of the spell to slot function, I need to fix that. it shouldn't be moving the players staff, it should be moving the item. MSI_Player[currentplayer].item ?

Bonfield

2010-10-13 03:07:09

yeah i forgot the if… then, i still had some work to do but those were the ideas in my head, i agree with the fact its pretty cluttered and makes adding new spells a little hard

i thought i wrote back but it looks like i didnt, sorry i have no access to a computer atm

i thought MSI_DragItem existed, if it doesnt has it been made yet?

Nick how is this all going? anything that needs to be coded?

Gu3st...

2010-10-13 03:16:20

function MSI_DragItem(Item, TargetSlot: Integer): Boolean;
var
slots: TIntegerArray;
begin
Result := True;
slots := MSI_FindItemSlots(Item);
if (Length(slots) > 0) then
DragItem(slots[0], TargetSlot);
else begin
MSI_SubDebug(MSI_Items[Item].Name + ' not found!');
Result := False;
Exit;
end;

if (not Result) then
MSI_SubDebug('MSI_DragItem: Failed to click item: '+MSI_Items[Item].Name)
else
MSI_SubDebug('MSI_DragItem: Succesfully clicked ' + MSI_Items[Item].Name);
end;
Committed

EDIT: (soon.. gotta download tortoise svn for my new win7 :P)

EDIT2: Is MSI_ClickItem and MSI_ClickItemSlot supposed to return True if it's not finding the item?

nickrules

2010-10-14 20:37:21

@Zyt3x, I have no idea about the true/false thing… But probably not if I had to guess…

@Bonfield, I can't think of anything at the moment, but I know for a fact that the TItems need to be updated and committed. It doesn't take *too* long to do. And spells need to be added to the globals. By spells i mean the things like SPELL_ALCH_LOW, not the strings. I'll find that list of semi-recent ones.
E: http://villavu.com/forum/showpost.php?p=734302&postcount=78