Keep aim offscreen

Keep aiming even if player is out of screen.
Lets say you attacked som1 and then he went out of your screen,
it would be anoyying to re-attacking for shooting him with hotkeys.
This script will solve the problem.

Const 
RuneD=3155;// rune id number for key Delete. 
RuneE=3174; // rune id number for key End. 
RunePD=5321;// rune id number for key Page Down. 

var 
LockID:integer; 

function GetCreatureByID(ID: integer): TCreature; 
var 
  x: integer; 
begin 
  Result := nil; 
  for x := 0 to Creatures.Count - 1 do 
  begin 
    if x >= Creatures.Count then Break; 
    if Creatures.Creature[x].ID = ID then 
    begin 
      Result := Creatures.Creature[x]; 
      Exit; 
    end; 
  end; 
end; 

procedure Event_KeyDown(Key: integer); 
Begin 
Case key of 
$22:begin 
     updateworld; 
     Creature:=GetCreatureByID(LockID); 
     if Creature <> nil then 
     Self.Containers.UseItemWithCreature(RunePD, Creature); 
     end; 
$23:begin 
     updateworld; 
     Creature:=GetCreatureByID(LockID); 
     if Creature <> nil then 
     Self.Containers.UseItemWithCreature(RuneE, Creature); 
     end; 
$2E:begin 
     updateworld; 
     Creature:=GetCreatureByID(LockID); 
     if Creature <> nil then 
     Self.Containers.UseItemWithCreature(RuneD, Creature); 
     end; 
end; 
end; 

begin 
updateworld; 
while self.attacking=0 do 
begin 
sleep(200); 
updateworld; 
end; 
LockID:=self.attacking; 
while not terminated do 
   begin 
   updateworld; 
   ProcessEvents; 
   if ((self.attacking)<>(LockID)) and ((self.attacking)<>(0))  then 
   LockID:=Self.Attacking; 
   sleep(100); 
   end; 
end;
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License