Follower by Darkmystery
Read this before using:
This is just a simple script, I recommend that u DON'T use it in caves/grown areas, at least, not with a high SQMDistance.
Please test it out with MC or something and look if it fits your needs, otherwise use it at own risk.
The script will ALWAYS try to walk behind the leader or in front of the leader (look in the config), that can be really helpfull for a knight - pally/mage comination.
With this information it should work very good with attack combo on, at least for me so that's why I am sharing this simple script xD
The script won't try to walk on holes/ladders/walls etc.
////////CONFIG:///////////
Leader = 'Eternal Oblivion'; // The person who can say the 'follow'/'stop' word.
FollowWord = 'follow'; // Word to follow, example: follow Darkmystery.
StopFollowWord = 'stop';// Word that stops the following.
SQMDistance = 4; // The distance that the char will be behind you. (1 = right behind you)
FollowMode = 2; // 1 = Walking Behind something, 2 = Walking in front of something.
//////////////////////////
var
X1: Integer;
Y1: Integer;
CreatureToFollow: string;
OK: Boolean;
Tile: TTile;
procedure Event_Message(Channel: integer; Name, Text: String);
var
Followname :string;
begin
if Name = Leader then begin
if Text = StopFollowWord then begin
OK := False
exit;
end;
updateworld;
FollowName := Text;
if Pos(FollowWord, FollowName)<>0 then
begin
OK := False;
Delete(FollowName, 1, length(FollowWord)+1);
CreatureToFollow := FollowName;
OK := True;
end;
end;
end;
function GetTileFromXYZ(X, Y, Z: integer): TTile;
begin
Result := nil;
if abs((Self.X - 7) - X) > 14 then Exit;
if abs((Self.Y - 5) - Y) > 11 then Exit;
if Self.Z <> Z then Exit;
Result := Screen.Tile[abs((Self.X - 7) - X), abs((Self.Y - 5) - Y)];
end;
function IsTileWalkable(Tile: TTile): boolean;
begin
Result := True;
for Z := 0 to Tile.Count - 1 do
begin
if Tile.Item[Z].Properties.Hole then
begin
Result := False;
end
else if Tile.Item[Z].Properties.Stairs then
begin
Result := False;
end
else if not Tile.Item[Z].Properties.Walkable then
begin
OutputDebugString('Not Walk: ' + IntToStr(Tile.Item[Z].ID));
Result := False;
end;
end;
end;
function GetCreature: byte;
var
x, Adjustment: integer;
begin
updateworld;
result := 0;
for x := 0 to Creatures.Count - 1 do
begin
if(Creatures.Creature[x].Name <> Self.Name) then begin
if(Creatures.Creature[x].Name = CreatureToFollow) then begin
X1 := Creatures.Creature[x].X
Y1 := Creatures.Creature[x].Y
if FollowMode = 1 then Adjustment := SQMDistance
if FollowMode = 2 then begin
Adjustment := SQMDistance * 2
Adjustment := SQMDistance - Adjustment
end;
case Creatures.Creature[x].Direction of
0 : Y1 := Y1 + Adjustment
1 : X1 := X1 - Adjustment
2 : Y1 := Y1 - Adjustment
3 : X1 := X1 + Adjustment
end;
result := 1;
exit;
end;
end;
end;
end;
begin
while not Terminated do
begin
processevents;
if OK then begin
if GetCreature = 1 then begin
Tile := GetTileFromXYZ(X1, Y1, Self.Z)
if IsTileWalkable(Tile) then
Self.MoveTo(X1, Y1, Self.Z);
end;
end;
sleep(500);
end;
end;
page revision: 0, last edited: 02 Jun 2007 11:37