如何获取坐标上指定范围内的全部怪物
unit Q2;
inte**ce
uses Classes, SysUtils;
procedure Main(Npc: TNormNpc; Player: TPlayObject; Args: TArgs);
implementation
procedure Main(Npc: TNormNpc; Player: TPlayObject; Args: TArgs);
var
AActorList: TActorList;
AActor: TActor;
I: Integer;
begin
//取出指定范围里的对象列表
AActorList := Player.Map.GetActorListAt(Player.MapX + 1, Player.MapY, '白野猪'{如果不指定名称则取出的是全部对象}); //取出一个坐标上的全部白野猪列表
try
for I := 0 to AActorList.Count - 1 do //循环处理列表中的对象
begin
AActor := AActorList.Items[I];
try
//针对AActor做些处理
except
end;
end;
finally
AActorList.Free; //这个列表需要执行Free释放掉
end;
//取出以某坐标为中心范围内的怪物列表
AActorList := Player.Map.GetActorListInRange(Player.MapX, Player.MapY, 3{3格范围}, '白野猪'{如果不指定名称则取出的是全部对象});
try
for I := 0 to AActorList.Count - 1 do //循环处理列表中的对象
begin
AActor := AActorList.Items[I];
try
//针对AActor做些处理
except
end;
end;
finally
AActorList.Free;
end;
end;
end.
|
|