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

📄 localdb.pas

📁 翎风世界..传奇服务端..DELPHI源代码 包括DBServer,LogDataServer,LoginGate,LoginSrv,M2Server等..内容齐全.
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    QuestNPC.m_sCharName:=sName;
    QuestNPC.m_nFlag:=0;
    QuestNPC.m_wAppr:=0;
    QuestNPC.m_sFilePath:='MapQuest_def\';
    QuestNPC.m_boIsHide:=True;
    QuestNPC.m_boIsQuest:=False;
    UserEngine.QuestNPCList.Add(QuestNPC);

    Result:=QuestNPC;
  end;

var
  i:Integer;

  sFlag,s34,s38,sMapName,sMapDesc,sReConnectMap:String;
  nIdx,nServerIndex:Integer;

  MapFlag:TMapFlag;
  QuestNPC:TMerchant;
ResourceString
  sSQLString = 'SELECT * FROM TBL_MAPINFO';
begin
  Result:= -1;
  try
    EnterCriticalSection(ProcessHumanCriticalSection);
  try
    Query.SQL.Clear;
    Query.SQL.Add(sSQLString);
    MiniMapList.Clear;
    try
      Query.Open;
    finally
      Result:= -2;
    end;
    for i:=0 to Query.RecordCount -1 do begin
      sMapName      := Trim(Query.FieldByName('FLD_MAPFILENAME').AsString);
      sMapDesc      := Trim(Query.FieldByName('FLD_MAPNAME').AsString);
      sFlag         := Trim(Query.FieldByName('FLD_FLAGS').AsString);
      nServerIndex  := Query.FieldByName('FLD_SERVERINDEX').AsInteger;
      
      //if sMapName = '' then Continue;

      nIdx          := Query.FieldByName('FLD_MINIMAP').AsInteger;
      if nIdx > 0 then
        MiniMapList.AddObject(sMapName,TObject(nIdx));

      FillChar(MapFlag,SizeOf(TMapFlag),#0);
      MapFlag.nL:=1;
      QuestNPC:=nil;
      MapFlag.boSAFE:=False;
      MapFlag.nNEEDSETONFlag:= -1;
      MapFlag.nNeedONOFF:= -1;
      MapFlag.nMUSICID:=-1;

      while (True) do begin
        if sFlag = '' then break;
        sFlag:=GetValidStr3(sFlag,s34,[' ', ',', #9]);
        if s34 = '' then break;

        if CompareText(s34,'SAFE') = 0 then begin
          MapFlag.boSAFE:=True;
          Continue;
        end;
        if CompareText(s34,'DARK') = 0 then begin
          MapFlag.boDarkness:=True;
          Continue;
        end;
        if CompareText(s34,'FIGHT') = 0 then begin
          MapFlag.boFightZone:=True;
          Continue;
        end;
        if CompareText(s34,'FIGHT3') = 0 then begin
          MapFlag.boFight3Zone:=True;
          Continue;
        end;
        if CompareText(s34,'DAY') = 0 then begin
          MapFlag.boDayLight:=True;
          Continue;
        end;
        if CompareText(s34,'QUIZ') = 0 then begin
          MapFlag.boQUIZ:=True;
          Continue;
        end;
        if CompareLStr(s34,'NORECONNECT',length('NORECONNECT')) then begin
          MapFlag.boNORECONNECT:=True;
          ArrestStringEx(s34,'(',')',sReConnectMap);
          MapFlag.sNoReConnectMap:=sReConnectMap;
          if MapFlag.sNoReConnectMap = '' then Result:= -11;
          Continue;
        end;
        if CompareLStr(s34,'CHECKQUEST',length('CHECKQUEST')) then begin
          ArrestStringEx(s34,'(',')',s38);
          QuestNPC:=LoadMapQuest(s38);
          Continue;
        end;
        if CompareLStr(s34,'NEEDSET_ON',length('NEEDSET_ON')) then begin
          MapFlag.nNeedONOFF:=1;
          ArrestStringEx(s34,'(',')',s38);
          MapFlag.nNEEDSETONFlag:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'NEEDSET_OFF',length('NEEDSET_OFF')) then begin
          MapFlag.nNeedONOFF:=0;
          ArrestStringEx(s34,'(',')',s38);
          MapFlag.nNEEDSETONFlag:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'MUSIC',length('MUSIC')) then begin
          MapFlag.boMUSIC:=True;
          ArrestStringEx(s34,'(',')',s38);
          MapFlag.nMUSICID:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'EXPRATE',length('EXPRATE')) then begin
          MapFlag.boEXPRATE:=True;
          ArrestStringEx(s34,'(',')',s38);
          MapFlag.nEXPRATE:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'PKWINLEVEL',length('PKWINLEVEL')) then begin
          MapFlag.boPKWINLEVEL:=True;
          ArrestStringEx(s34,'(',')',s38);
          MapFlag.nPKWINLEVEL:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'PKWINEXP',length('PKWINEXP')) then begin
          MapFlag.boPKWINEXP:=True;
          ArrestStringEx(s34,'(',')',s38);
          MapFlag.nPKWINEXP:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'PKLOSTLEVEL',length('PKLOSTLEVEL')) then begin
          MapFlag.boPKLOSTLEVEL:=True;
          ArrestStringEx(s34,'(',')',s38);
          MapFlag.nPKLOSTLEVEL:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'PKLOSTEXP',length('PKLOSTEXP')) then begin
          MapFlag.boPKLOSTEXP:=True;
          ArrestStringEx(s34,'(',')',s38);
          MapFlag.nPKLOSTEXP:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'DECHP',length('DECHP')) then begin
          MapFlag.boDECHP:=True;
          ArrestStringEx(s34,'(',')',s38);

          MapFlag.nDECHPPOINT:=Str_ToInt(GetValidStr3(s38,s38,['/']),-1);
          MapFlag.nDECHPTIME:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'INCHP',length('INCHP')) then begin
          MapFlag.boINCHP:=True;
          ArrestStringEx(s34,'(',')',s38);

          MapFlag.nINCHPPOINT:=Str_ToInt(GetValidStr3(s38,s38,['/']),-1);
          MapFlag.nINCHPTIME:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'DECGAMEGOLD',length('DECGAMEGOLD')) then begin
          MapFlag.boDECGAMEGOLD:=True;
          ArrestStringEx(s34,'(',')',s38);

          MapFlag.nDECGAMEGOLD:=Str_ToInt(GetValidStr3(s38,s38,['/']),-1);
          MapFlag.nDECGAMEGOLDTIME:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'DECGAMEPOINT',length('DECGAMEPOINT')) then begin
          MapFlag.boDECGAMEPOINT:=True;
          ArrestStringEx(s34,'(',')',s38);

          MapFlag.nDECGAMEPOINT:=Str_ToInt(GetValidStr3(s38,s38,['/']),-1);
          MapFlag.nDECGAMEPOINTTIME:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'INCGAMEGOLD',length('INCGAMEGOLD')) then begin
          MapFlag.boINCGAMEGOLD:=True;
          ArrestStringEx(s34,'(',')',s38);

          MapFlag.nINCGAMEGOLD:=Str_ToInt(GetValidStr3(s38,s38,['/']),-1);
          MapFlag.nINCGAMEGOLDTIME:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'INCGAMEPOINT',length('INCGAMEPOINT')) then begin
          MapFlag.boINCGAMEPOINT:=True;
          ArrestStringEx(s34,'(',')',s38);

          MapFlag.nINCGAMEPOINT:=Str_ToInt(GetValidStr3(s38,s38,['/']),-1);
          MapFlag.nINCGAMEPOINTTIME:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareText(s34,'RUNHUMAN') = 0 then begin
          MapFlag.boRUNHUMAN:= True;
          Continue;
        end;
        if CompareText(s34,'RUNMON') = 0 then begin
          MapFlag.boRUNMON:= True;
          Continue;
        end;
        if CompareText(s34,'NEEDHOLE') = 0 then begin
          MapFlag.boNEEDHOLE := True;
          Continue;
        end;
        if CompareText(s34,'NORECALL') = 0 then begin
          MapFlag.boNORECALL := True;
          Continue;
        end;
        if CompareText(s34,'NOGUILDRECALL') = 0 then begin
          MapFlag.boNOGUILDRECALL := True;
          Continue;
        end;
        if CompareText(s34,'NODEARRECALL') = 0 then begin
          MapFlag.boNODEARRECALL := True;
          Continue;
        end;
        if CompareText(s34,'NOMASTERRECALL') = 0 then begin
          MapFlag.boNOMASTERRECALL := True;
          Continue;
        end;
        if CompareText(s34,'NORANDOMMOVE') = 0 then begin
          MapFlag.boNORANDOMMOVE := True;
          Continue;
        end;
        if CompareText(s34,'NODRUG') = 0 then begin
          MapFlag.boNODRUG := True;
          Continue;
        end;
        if CompareText(s34,'MINE') = 0 then begin
          MapFlag.boMINE := True;
          Continue;
        end;
        if CompareText(s34,'MINE2') = 0 then begin
          MapFlag.boMINE2 := True;
          Continue;
        end;
        if CompareText(s34,'NOTHROWITEM') = 0 then begin
          MapFlag.boNOTHROWITEM := True;
          Continue;
        end;
        if CompareText(s34,'NODROPITEM') = 0 then begin
          MapFlag.boNODROPITEM := True;
          Continue;
        end;
        if CompareText(s34,'NOPOSITIONMOVE') = 0 then begin
          MapFlag.boNOPOSITIONMOVE := True;
          Continue;
        end;
        if CompareText(s34,'NOHORSE') = 0 then begin
          MapFlag.boNOPOSITIONMOVE := True;
          Continue;
        end;
        if CompareText(s34,'NOCHAT') = 0 then begin
          MapFlag.boNOCHAT := True;
          Continue;
        end;
        if (s34[1] = 'L') then begin
          MapFlag.nL:= Str_ToInt(Copy(s34,2,Length(s34) -1),1);
        end;
      end;
      if g_MapManager.AddMapInfo(sMapName,sMapDesc,nServerIndex,@MapFlag,QuestNPC) = nil then Result:= -10;
      
      Result := 1;
      Query.Next;
    end;
  finally
    Query.Close;
  end;
  finally
    LeaveCriticalSection(ProcessHumanCriticalSection);
  end;

  LoadMapRoute();
end;


function TFrmDB.LoadMapRoute():Integer;
var
  i,nSMapX,nSMapY,nDMapX,nDMapY:Integer;
  sSMapNO,sDMapNO:String;
ResourceString
  sSQLString = 'SELECT * FROM TBL_MOVEMAPEVENT';
begin
  Result:= -1;
  EnterCriticalSection(ProcessHumanCriticalSection);
  try
  try
    Query.SQL.Clear;
    Query.SQL.Add(sSQLString);
    try
      Query.Open;
    finally
      Result:= -2;
    end;
    for i:=0 to Query.RecordCount -1 do begin
      sSMapNO       := Trim(Query.FieldByName('FLD_SMAPFILENAME').AsString);
      nSMapX        := Query.FieldByName('FLD_SX').AsInteger;
      nSMapY        := Query.FieldByName('FLD_SY').AsInteger;
      sDMapNO       := Trim(Query.FieldByName('FLD_DMAPFILENAME').AsString);
      nDMapX        := Query.FieldByName('FLD_DX').AsInteger;
      nDMapY        := Query.FieldByName('FLD_DY').AsInteger;

      g_MapManager.AddMapRoute(sSMapNO,nSMapX,nSMapY,sDMapNO,nDMapX,nDMapY);

      Result := 1;
      Query.Next;
    end;
  finally
    Query.Close;
  end;
  finally
    LeaveCriticalSection(ProcessHumanCriticalSection);
  end;
end;


procedure TFrmDB.QFunctionNPC;
var
  sScriptFile :String;
  sScritpDir  :String;
  SaveList    :TStringList;
  sShowFile   :String;
begin
try
  sScriptFile:=g_Config.sEnvirDir + sMarket_Def + 'QFunction-0.txt';
  sShowFile:=ReplaceChar(sScriptFile,'\','/');
  sScritpDir:=g_Config.sEnvirDir + sMarket_Def;
  if not DirectoryExists(sScritpDir) then
    mkdir(Pchar(sScritpDir));

  if not FileExists(sScriptFile) then begin
    SaveList:=TStringList.Create;
    SaveList.Add(';此脚为功能脚本,用于实现各种与脚本有关的功能');
    SaveList.SaveToFile(sScriptFile);
    SaveList.Free;
  end;
  if FileExists(sScriptFile) then begin
    g_FunctionNPC:=TMerchant.Create;
    g_FunctionNPC.m_sMapName  := '0';
    g_FunctionNPC.m_nCurrX    := 0;
    g_FunctionNPC.m_nCurrY    := 0;
    g_FunctionNPC.m_sCharName := 'QFunction';
    g_FunctionNPC.m_nFlag     := 0;
    g_FunctionNPC.m_wAppr     := 0;
    g_FunctionNPC.m_sFilePath := sMarket_Def;
    g_FunctionNPC.m_sScript   := 'QFunction';
    g_FunctionNPC.m_boIsHide  := True;
    g_FunctionNPC.m_boIsQuest := False;
    UserEngine.AddMerchant(g_FunctionNPC);
  end else begin
    g_FunctionNPC:=nil;
  end;
except
  g_FunctionNPC:=nil;
end;
end;

procedure TFrmDB.QMangeNPC();
var
  sScriptFile :String;
  sScritpDir  :String;
  SaveList    :TStringList;
  sShowFile   :String;
begin
try
  sScriptFile:=g_Config.sEnvirDir + 'MapQuest_def\' + 'QManage.txt';
  sShowFile:=ReplaceChar(sScriptFile,'\','/');
  sScritpDir:=g_Config.sEnvirDir + 'MapQuest_def\';
  if not DirectoryExists(sScritpDir) then
    mkdir(Pchar(sScritpDir));

  if not FileExists(sScriptFile) then begin
    SaveList:=TStringList.Create;
    SaveList.Add(';此脚为登录脚本,人物每次登录时都会执行此脚本,所有人物初始设置都可以放在此脚本中。');
    SaveList.Add(';修改脚本内容,可用@ReloadManage命令重新加载该脚本,不须重启程序。');
    SaveList.Add('[@Login]');
    SaveList.Add('#if');
    SaveList.Add('#act');
//    tSaveList.Add(';设置10倍杀怪经验');    
//    tSaveList.Add(';CANGETEXP 1 10');
    SaveList.Add('#say');
    SaveList.Add('翎风游戏登录脚本运行成功,欢迎进入本游戏!!!\ \');
    SaveList.Add('<关闭/@exit> \ \');
    SaveList.Add('登录脚本文件位于: \');
    SaveList.Add(sShowFile + '\');
    SaveList.Add('脚本内容请自行按自己的要求修改。');
    SaveList.SaveToFile(sScriptFile);
    SaveList.Free;
  end;
  if FileExists(sScriptFile) then begin
    g_ManageNPC:=TMerchant.Create;
    g_ManageNPC.m_sMapName:='0';
    g_ManageNPC.m_nCurrX:=0;
    g_ManageNPC.m_nCurrY:=0;
    g_ManageNPC.m_sCharName:='QManage';
    g_ManageNPC.m_nFlag:=0;
    g_ManageNPC.m_wAppr:=0;
    g_ManageNPC.m_sFilePath:='MapQuest_def\';
    g_ManageNPC.m_boIsHide:=True;
    g_ManageNPC.m_boIsQuest:=False;
    UserEngine.QuestNPCList.Add(g_ManageNPC);
  end else begin
    g_ManageNPC:=nil;
  end;
except
  g_ManageNPC:=nil;
end;
end;
procedure TFrmDB.RobotNPC();
var
  sScriptFile:String;
  sScritpDir :String;
  tSaveList:TStringList;

⌨️ 快捷键说明

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