⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 objrobot.pas

📁 乐都SQL版传奇全套代码,绝对可编译
💻 PAS
📖 第 1 页 / 共 2 页
字号:
    end;
  end;

end;

procedure TRobotObject.ClearScript;
var
  i                                     : Integer;
begin
  for i := 0 to m_AutoRunList.Count - 1 do
  begin
    DisPose(pTAutoRunInfo(m_AutoRunList.Items[i]));
  end;
  m_AutoRunList.Clear;
end;

constructor TRobotObject.Create;
begin
  inherited;
  m_AutoRunList := TMyList.create;
  m_boSuperMan := True;
  m_boRunOnWeek := False;
end;

destructor TRobotObject.Destroy;
begin
  ClearScript();
  m_AutoRunList.Free;
  inherited;
end;

procedure TRobotObject.LoadScript;
var
  i                                     : Integer;
  LoadList                              : TStringList;
  sFileName                             : string;
  sLineText                             : string;
  sActionType                           : string;
  sRunCmd                               : string;
  sMoethod                              : string;
  sParam1                               : string;
  sParam2                               : string;
  sParam3                               : string;
  sParam4                               : string;
  AutoRunInfo                           : pTAutoRunInfo;
begin
  sFileName := g_Config.sEnvirDir + 'Robot_def\' + m_sScriptFileName + '.txt';
  if FileExists(sFileName) then
  begin
    LoadList := TStringList.Create;
    LoadList.LoadFromFile(sFileName);
    for i := 0 to LoadList.Count - 1 do
    begin
      sLineText := LoadList.Strings[i];
      if (sLineText <> '') and (sLineText[1] <> ';') then
      begin
        sLineText := GetValidStr3(sLineText, sActionType, [' ', '/', #9]);
        sLineText := GetValidStr3(sLineText, sRunCmd, [' ', '/', #9]);
        sLineText := GetValidStr3(sLineText, sMoethod, [' ', '/', #9]);
        sLineText := GetValidStr3(sLineText, sParam1, [' ', '/', #9]);
        sLineText := GetValidStr3(sLineText, sParam2, [' ', '/', #9]);
        sLineText := GetValidStr3(sLineText, sParam3, [' ', '/', #9]);
        sLineText := GetValidStr3(sLineText, sParam4, [' ', '/', #9]);
        if CompareText(sActionType, sROAUTORUN) = 0 then
        begin
          if CompareText(sRunCmd, sRONPCLABLEJMP) = 0 then
          begin
            New(AutoRunInfo);
            AutoRunInfo.dwRunTick := GetTickCount;
            AutoRunInfo.dwRunTimeLen := 0;
            AutoRunInfo.boStatus := False;
            AutoRunInfo.nRunCmd := nRONPCLABLEJMP;
            if CompareText(sMoethod, sRODAY) = 0 then
              AutoRunInfo.nMoethod := nRODAY;
            if CompareText(sMoethod, sROHOUR) = 0 then
              AutoRunInfo.nMoethod := nROHOUR;
            if CompareText(sMoethod, sROMIN) = 0 then
              AutoRunInfo.nMoethod := nROMIN;
            if CompareText(sMoethod, sROSEC) = 0 then
              AutoRunInfo.nMoethod := nROSEC;
            if CompareText(sMoethod, sRUNONWEEK) = 0 then
              AutoRunInfo.nMoethod := nRUNONWEEK;
            if CompareText(sMoethod, sRUNONDAY) = 0 then
              AutoRunInfo.nMoethod := nRUNONDAY;
            if CompareText(sMoethod, sRUNONHOUR) = 0 then
              AutoRunInfo.nMoethod := nRUNONHOUR;
            if CompareText(sMoethod, sRUNONMIN) = 0 then
              AutoRunInfo.nMoethod := nRUNONMIN;
            if CompareText(sMoethod, sRUNONSEC) = 0 then
              AutoRunInfo.nMoethod := nRUNONSEC;

            AutoRunInfo.sParam1 := sParam1;
            AutoRunInfo.sParam2 := sParam2;
            AutoRunInfo.sParam3 := sParam3;
            AutoRunInfo.sParam4 := sParam4;
            AutoRunInfo.nParam1 := Str_ToInt(sParam1, 1);
            m_AutoRunList.Add(AutoRunInfo);
          end;
        end;

      end;
    end;
    LoadList.Free;
  end;
end;

procedure TRobotObject.ProcessAutoRun;
var
  i                                     : Integer;
  AutoRunInfo                           : pTAutoRunInfo;
  code                                  : Integer;
resourcestring
  sExceptionMsg                         = '[Exception] TRobotManage::ProcessAutoRun ';
begin
 Try
  for i := 0 to m_AutoRunList.Count - 1 do
  begin
    Code:=1;
    AutoRunInfo := m_AutoRunList.Items[i];
    code:=2;
    if assigned(AutoRunInfo) then
       AutoRun(AutoRunInfo);
    code:=3;
  end;
  except
    on E: Exception do
    begin
      MainOutMessage(sExceptionMsg+Inttostr(Code));
          {$IF SHowErr = 1}
           MainOutMessage(E.Message);
          {$IFEND}
    end;
  end;
end;

procedure TRobotObject.ReloadScript;
begin
  ClearScript();
  LoadScript();
end;

procedure TRobotObject.Run;
begin
  ProcessAutoRun();
  //  inherited;

end;

procedure TRobotObject.SendSocket(DefMsg: pTDefaultMessage; sMsg: string);
begin

end;

{ TRobotManage }

constructor TRobotManage.Create;
begin
  RobotHumanList := TStringList.Create;
  LoadRobot();
end;

destructor TRobotManage.Destroy;
begin
  UnLoadRobot();
  RobotHumanList.Free;
  inherited;
end;

procedure TRobotManage.LoadRobot;
var
  i                                     : Integer;
  LoadList                              : TStringList;
  sFileName                             : string;
  sLineText                             : string;
  sRobotName                            : string;
  sScriptFileName                       : string;
  RobotHuman                            : TRobotObject;
begin
  sFileName := g_Config.sEnvirDir + 'Robot.txt';
  if FileExists(sFileName) then
  begin
    LoadList := TStringList.Create;
    LoadList.LoadFromFile(sFileName);
    for i := 0 to LoadList.Count - 1 do
    begin
      sLineText := LoadList.Strings[i];
      if (sLineText <> '') and (sLineText[1] <> ';') then
      begin
        sLineText := GetValidStr3(sLineText, sRobotName, [' ', '/', #9]);
        sLineText := GetValidStr3(sLineText, sScriptFileName, [' ', '/', #9]);
        if (sRobotName <> '') and (sScriptFileName <> '') then
        begin
          RobotHuman := TRobotObject.Create;
          RobotHuman.m_sCharName := sRobotName;
          RobotHuman.m_sScriptFileName := sScriptFileName;
          RobotHuman.LoadScript;
          RobotHumanList.AddObject(RobotHuman.m_sCharName, RobotHuman);
        end;

      end;
    end;
    LoadList.Free;
  end;
end;

procedure TRobotManage.RELOADROBOT;
begin
  UnLoadRobot();
  LoadRobot();
end;

procedure TRobotManage.Run;
var
  i                                     : Integer;
resourcestring
  sExceptionMsg                         = '[Exception] TRobotManage::Run';
begin
  try
    for i := 0 to RobotHumanList.Count - 1 do
    begin
//    FindMerchant
      if assigned(RobotHumanList.Objects[i]) Then
        TRobotObject(RobotHumanList.Objects[i]).Run;
    end;
  except
    on E: Exception do
    begin
      MainOutMessage(sExceptionMsg);
          {$IF SHowErr = 1}
           MainOutMessage(E.Message);
          {$IFEND}
    end;
  end;
end;

procedure TRobotManage.UnLoadRobot;
var
  i                                     : Integer;
begin
  for i := 0 to RobotHumanList.Count - 1 do
  begin
    TRobotObject(RobotHumanList.Objects[i]).Free;
  end;
  RobotHumanList.Clear;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -