声明时钟的代码:
unit Q2;
inte**ce
uses Classes, SysUtils;
procedure Main(Npc: TNormNpc; Player: TPlayObject; Args: TArgs);
implementation
procedure Main(Npc: TNormNpc; Player: TPlayObject; Args: TArgs);
begin
//增加一个无限循环的时钟,需要使用ClearDelayGoto来停止时钟
Player.DelayGoto(100{时钟ID}, 60{执行时钟的间隔时间}, True{切换地图时时钟失效且被删除}, False{不是一个只执行一次的时钟});
Player.ClearDelayGoto(100);
//增加一个值使用一次的时钟,不需要手工清除
Player.DelayGoto(101{时钟ID}, 60{执行时钟的间隔时间}, False{切换地图时时钟不失效}, True{只执行一次});
//个人时钟执行时候调用TimeManageNpc单元的PrivyEventExecute函数,个人时钟移除时调用TimeManageNpc的PrivyEventRemove函数
end;
end.
时钟NPC执行代码:
unit TimeManageNpc;
inte**ce
uses Classes, SysUtils, DefiniensConst, Q38;
//个人的时钟事件
procedure PrivyEventExecute(Npc: TNormNpc; Player: TPlayObject; TimeID: Integer);
procedure PrivyEventRemove(Npc: TNormNpc; Player: TPlayObject; TimeID: Integer);
//全局的时钟事件
procedure GlobalEventExecute(Npc: TNormNpc; TimeID: Integer);
procedure GlobalEventRemove(Npc: TNormNpc; TimeID: Integer);
implementation
procedure PrivyEventExecute(Npc: TNormNpc; Player: TPlayObject; TimeID: Integer);
begin
case TimeID of
100: Player.Messagebox('100:时钟被执行');
101: Player.Messagebox('101:时钟被执行');
end;
end;
procedure PrivyEventRemove(Npc: TNormNpc; Player: TPlayObject; TimeID: Integer);
begin
case TimeID of
100: Player.Messagebox('100:时钟结束');
101: Player.Messagebox('101:时钟结束');
end;
end;
procedure GlobalEventExecute(Npc: TNormNpc; TimeID: Integer);
begin
//这个是全局时钟执行的地方
end;
procedure GlobalEventRemove(Npc: TNormNpc; TimeID: Integer);
begin
//这个是全局时钟结束
end;
end.
注:时钟需要配合TimeManageNpc使用
|