SRL Archive - SRL Archives

[Function]InChatNPC


Avaphi

2007-03-01 20:59:24

Notes: Hi all. While I was writing my tutorial island script I noticed I couldnt find a function in which it found if you were in chat with an npc. So I wrote one for SRL :) It uses bmp masks to increase speed and such :).

Description: Function InChatNPC(NPCName : string): boolean;

When you call it, you must enter in an argument for NPC name, and make sure the caps are exactly how they are in the game :) or it wont work :( It will return a boolean whether it has found it or not, Works perfect for me, so without further adieu here it is :

Function InChatNPC(NPCName : string): boolean;
var NPCText, OutPut : integer;
begin
NPCText := LoadChars2(AppPath + 'includes\SRL\CharsNPC\');
OutPut := CreateBitmapMaskFromText(NPCName, NPCText);
if (FindBitmapMaskTolerance(OutPut, x, y, 124, 356, 493, 411, 10, 2)) then
begin
Result := True;
end;
FreeBitmap(OutPut);
FreeChars2(NPCText);
end;

Ejjman

2007-03-01 21:00:31

Good job. :)

pwnaz0r

2007-03-01 21:04:25

Nice job I would ++ rep but no time :p

WhiteShadow

2007-03-01 21:05:02

function DoneChop(bottomText : String) : Boolean; //IsChatMessage was being a bitch.
var
get : Integer;
begin
get:= CreateBitmapMaskFromText(bottomText, SmallChars);
Result:= FindBitmapMaskTolerance(get, x, y, 41, 414, 73, 440, 50, 10);
end;

Here's my version I took out from my chopper.

Good job though.. ;D


EDIT

procedure SetupSRL;
begin

MarkTime ( ST );

RoadColor := 0;
WaterColor := 0;
BankColor := 0;
Banks := 0;
kLastChoice := -1;
DisguiseScar(MaskName);

UpChars := LoadChars2(AppPath + 'includes\SRL\UpChars\');
SmallChars := LoadChars2(AppPath + 'includes\SRL\SmallChars\');
StatChars := LoadChars2(AppPath + 'includes\SRL\StatChars\');
NpcChars := LoadChars2(AppPath + 'includes\SRL\CharsNPC\');

LoadSRLBitMaps;

TheFile := RewriteFile(AppPath + 'ChatLog.txt', False);

LoadSRLConfig;
SetMouseMode(false);
FindClient:=True;
loadcosinearrays;

if LampSkill = '' then LampSkill := 'Mining';

SymbolAccuracy:= 0.8;

InitFreddyPlugin(GetClientWindowHandle);
SetUpSRLReport;

MarkTime ( HoverMark );
Writeln ('SRL Compiled in '+ IntToStr ( HoverMark - ST ) + 'msec.');

MarkTime(LogOutMark);
MarkTime(RandomChatMark);
MarkTime(RandomClickMark);
MarkTime(RotateMark);
MarkTime(KillScriptMark);
MarkTime(LeaveScreenMark);
MarkTime(PickUpMouseMark);
MarkTime(HoverMark);
MarkTime(BoredMark);
MarkTime(MouseSpeedMark);
MarkTime(RCTimeMark);
MarkTime(ST);

end;

That is if your using SRL. SRL has all the chars loaded already.

Avaphi

2007-03-01 21:07:28

… except yours only uses small chars… Mine has a different purpose :) + Yours cant be used for what mine does.

WhiteShadow

2007-03-01 21:08:58

From: Avaphi
… except yours only uses small chars… Mine has a different purpose :) + Yours cant be used for what mine does.


Basically the same thing though? Change the Chars type, and the box.

In fact.

function multiPurpose(bText : String; theType, b1, b2, b3, b4 : Integer) : Boolean;
var
get : Integer;
begin
get:= CreateBitmapMaskFromText(bText, theType);
Result:= FindBitmapMaskTolerance(get, x, y, b1, b2, b3, b4, 50, 10);
end;

Well my note to you, is. DUDE MAN! Wtf, your way more intelligent than this! No more nubb functions pl0x! hahaha. <3 dude. Sorry I'm in a bad mood and msn me with this link…
sorry..

Avaphi

2007-03-01 21:12:33

They both recognize text yes, and if you edited it could do the same thing but it was my idea :P

Cheesehunk

2007-03-01 21:38:00

Good job, but it's been done.. ;)
{*******************************************************************************
function FindNpcChatText(txt: String): Boolean;
By: Kernel Klink or Stupid3000, font by Masquerader
Description: Get last chat message.
*******************************************************************************}

function FindNpcChatText(txt: string): Boolean;
var
S: Integer;
begin
S := CreateBitmapMaskFromText(txt, npcchars);
Result := FindBitmapMaskTolerance(S, x, y, 9, 348, 523, 471, 50, 10);
FreeBitmap(S);
end;

Avaphi

2007-03-01 21:47:22

hmm, sorry guys :( delete please

WhiteShadow

2007-03-01 21:52:34

From: Avaphi
hmm, sorry guys :( delete please


no need to say sorry fool. >:}

danrox2004

2007-03-02 04:47:33

When i made my tutorial island script to check if i was talking to an npc i checks for the face in the bottom left or bottom right - worked every time!

Cheesehunk

2007-03-02 16:48:29

From: danrox2004
When i made my tutorial island script to check if i was talking to an npc i checks for the face in the bottom left or bottom right - worked every time!

I just use this:
//********************Jacked from Fakawis BeerBuyer***********************//
Function InConversation: boolean; // checks for black separator line
begin
if ((not FindColor(x, y, 0, 21, 434, 21, 434)) and (not FindColor(x, y, 0, 475, 434, 475, 434))) then
Result:=True;
end;

Avaphi

2007-03-02 17:18:27

OooOoo nice function, ill borrow that one :D