PDA

View Full Version : Fighting functions



mohua
10-20-2006, 01:33 PM
I am deciding which fighting function to use and was wondering which one you guys think would be the easiest/least likely to mess up. I think some of these might not work, if you know they dont work please post so.

FightNPC
AttackMonster
FindMonster / KAttackMonster
FindAttackableNpc
FindAttackableNpc2

dlsa
10-20-2006, 02:00 PM
I use KAttackMonster for mine and it works pretty well, i think that most fighting functions may mess up once in a while or often unless you choose unique colors.

WT-Fakawi
10-20-2006, 02:47 PM
This is my NPC Attacker. There is a function like that in skill/fighting.scar. It inputs six colors (try grabbing unique NPC-colors, not common green colors for exampe), a tolerance for the colors and a TimeOut (exit elapsetime). Works well for me, its pretty basic; it clicks the colors when it sees 'ttac' in the upperleft corner. Many variations can be created, and every script needs its own unique FightNPC, but this is an ok framework.


{************************************************* ******************************
function FightNPC(Color1, Color2, Color3, Color4, Color5, Color6, tol, TimeOut: Integer): Boolean;
By: WT-Fakawi
Description: Fights NPC. Inputs 6 NPC Colors. (May be the same colors),
tol = tolerance, TimeOut = amount of time before clicking on next NPC
************************************************** *****************************}

Function FightNPC(Color1, Color2, Color3, Color4, Color5, Color6, tol, TimeOut: Integer):
Boolean;
var I, Color: Integer;
begin
for I := 1 to 6 do
begin
case I of
1: Color := Color1;
2: Color := Color2;
3: Color := Color3;
4: Color := Color4;
5: Color := Color5;
6: Color := Color6;
end;

if (Loggedin) then
begin
if (FindObj(x,y,'ttac',Color,tol)) then
begin
Result := True;
if(not (Loggedin) or (WeAreDead)) then break;
GetMousePos(x, y);
Mouse(x, y, 0, 0, True);
FFlag(10);
FTWait(8);
MarkTime(Mark);
repeat
if(not (Loggedin) or (WeAreDead)) then break;
if (TimeFromMark(Mark) > TimeOut) then break;
FTWait(5);
until ( (not (inFight) or (WeAreDead) ));
Players[CurrentPlayer].Killed := Players[CurrentPlayer].Killed+1;
end
else
Result := False;
end
end
end;

mohua
10-20-2006, 07:10 PM
Im new to scripting, so this may sould pretty dumb.
when I use FightNPC, is that the only function I need?
or do I need other functions to tell it to find the colors, click etc.?

WT-Fakawi
10-20-2006, 08:35 PM
FightNPC does the following:


it looks for a color on the mainscreen
if it find it, it moves the mouse towards that color.
it checks if there is a text in the upper left corner of the screen saying "ttac" ( from Attack...)
if it does, it clicks the mouse. you atack the color.
It waits for the Flag to disappear from the screen ( We are probably moving)
next it enters a loop checking for either the green or the red color above your head.
it exits the loop when the green and/or red are gone or when TimeOut msecs have passed.
it returns true if t clicks a NPC, and false if it doenst.
It performs at least two checks to see if we are loggeout or died.


theoretically this might work:

setupsrl;
repeat
FightNPC(94224,84556,56675,345145,56367,22345, 10000);
until false;

though it is not very sophisticated.

mohua
10-20-2006, 08:52 PM
k thanks