SRL Archive - SRL Archives

Levels gained


Krazy_Meerkat

2006-02-21 18:00:03

I made this code a while ago to check if you have gained any levels in combat and how many.
                       //By krazy_meerkat
{^^^^^^^^^^^^^^^ CHECKCHATAREAMSG ^^^^^^^^^^^^^}
{Checks the last sentence in the chat box and returns true if any part of that matches
the string it's looking for}
{^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^}

Function CheckChatAreaMsg(Text: String) : Boolean;
Begin
result:= IsTextInAreaEx(20 , 415, 479, 433, x, y, Text, 40, CharChatChars, False, True, 0, 1, 0);
End;

And the main code:
procedure LevelCheck; //by Krazy_Meerkat, how many levels you have gained.
begin
If(CheckChatAreaMsg('hitpoints')=true)Then
begin
hitpoints:=hitpoints+1
e:=(random(4))
if(e=1)then
SendKeysHuman2('Alright, another hitpoint level!' + chr(13));
if(e=2)then
begin
if(hitpoints=1)then
nummy:=('')
if(not(hitpoints=1))then
nummy:=('s')
SendKeysHuman2('Sweet I got ' + (Inttostr(hitpoints)) + ' hitpoint level' + nummy + chr(13));
end;
if(e=3)then
SendKeysHuman2('I just hp leveled' + chr(13));
if(e=4)then
SendKeysHuman2('Nice' + chr(13));
wait(random(5000) + random(845));
end else;
If(CheckChatMsg('Congratulations')=true)Then
begin
other:=other+1
e:=(random(4))
if(e=1)then
SendKeysHuman2('Alright, another ' + speech + ' level!' + chr(13));
if(e=2)then
begin
if(other=1)then
nummy:=('')
if(not(other=1))then
nummy:=('s')
SendKeysHuman2('Yeah got ' + (Inttostr(other)) + ' ' + speech + ' level' + nummy + chr(13));
end;
if(e=3)then
SendKeysHuman2('About time -.-' + chr(13));
if(e=4)then
SendKeysHuman2('Yeah!!' + chr(13));
wait(random(5000) + random(845));
end;
end;

Use it in a report like this:
if(Combat=1)then
speech:=('attack')
if(Combat=2)then
speech:=('strength')
if(Combat>2)then
speech:=('defence')
AddToReport ('Gained ' + Inttostr(other) + ' ' + speech + ' levels')
AddToReport ('and ' + Inttostr(hitpoints) + ' hitpoints levels.')

The variables used:
speech,nummy,e: String;
speech is just the attack style, used for the report. Optional
nummy is a variable used for randomchat about gaining a level, depending on whether you've gained more than one level or not, it becomes an 's'. Optional
e is just a variable used for random numbers in randomchat. Optional

hitpoints,other,CharChatChars,Combat: Integer;
hitpoints, used to count how many hitpoints levels you have gained. Neccessary.
other, it will count how many attack,str,def levels you have gained (it does not need any input for your attack style). Neccessary.
CharChatChars is used for randomchat, add a line at the beginning of the main part of your script which says this:
CharChatChars:=  LoadChars2(AppPath  +  'CharsChat2\');
Optional.
Combat is just a number which represents your attack style (top to bottom). It is used for the report but can easily be replaced with your own variable. Replacable

Squig was used, so it should be completely compatable with SRL.

Sdcit

2006-02-21 19:01:30

erm that tex tis loaded in SRL? Err… i thought we had something like that… ill check.

Krazy_Meerkat

2006-02-21 22:21:58

Oh ok.. I was just putting in my two cents :)

Lorax

2006-02-22 02:44:31

From: Krazy_Meerkat
Oh ok.. I was just putting in my two cents :)

very nice of you, I must say..

JLewis

2006-02-28 17:34:36

this is one i have used that I made that is much simpler


Program Lvl;
{.include Srl/SRL.scar}

Var
J,T,L:integer;




Procedure CheckLvl1;
begin
J:= GetSkillAmount('mining')
Writeln('Current Mining Level Is '+inttostr(GetSkillAmount('mining')));
end;

Procedure CheckLvl;
begin
L:= GetSkillAmount('mining');
T:=L-J;
Writeln('Current Mining Level Is '+inttostr(GetSkillAmount('mining')));
Writeln('You have Gained '+inttostr(T)+' Levels');
end;

begin
SetupSrl;
checklvl1;
checklvl;
end.