📄 database.pas
字号:
unit Database;interfaceuses Windows, MMSystem, Forms, Classes, SysUtils, IniFiles, Common;//==============================================================================// 娭悢掕媊 procedure DatabaseLoad(Handle:HWND); //edited by The Harbinger -- darkWeiss version procedure DataLoad(); //edited by The Harbinger -- darkWeiss version procedure PlayerDataLoad(); //added by The Harbinger -- darkWeiss version procedure DataSave(); //edited by The Harbinger -- darkWeiss version//==============================================================================implementation//==============================================================================// 僨乕僞儀乕僗撉傒崬傒procedure DatabaseLoad(Handle:HWND);var i,j,k,l :integer; w :word; xy :TPoint; str :string; mystr:string; txt :TextFile; txt2:TextFile; sl :TStringList; sl1 :TStringList; ta :TMapList; td :TItemDB;{捛壛} wj :Int64;{捛壛僐僐傑偱}{傾僀僥儉惢憿捛壛} tma :TMaterialDB;{傾僀僥儉惢憿捛壛僐僐傑偱}{巵{敔捛壛} tsmn :TSummon; tss :TSlaveDB; tid :TIDTbl; ma :TMArrowDB; tk :TKafra; tbn :TBan;{巵{敔捛壛僐僐傑偱}{僉儏乕儁僢僩} tp :TPetDB;{僉儏乕儁僢僩偙偙傑偱}{NPC僀儀儞僩捛壛} mi :MapTbl;{NPC僀儀儞僩捛壛僐僐傑偱} tb :TMobDB; tl :TSkillDB; sr :TSearchRec; dat :TFileStream; jf :array[0..20] of boolean;begin sl := TStringList.Create; sl1 := TStringList.Create; //sl.QuoteChar := '"'; //sl.Delimiter := ','; //奺庬僨乕僞僼傽僀儖偺懚嵼傪僠僃僢僋 if not (FileExists(AppPath + 'database\item_db.txt') and{巵{敔捛壛僐僐傑偱} FileExists(AppPath + 'database\summon_item.txt') and //FileExists(AppPath + 'database\summon_slave.txt') and FileExists(AppPath + 'database\summon_mob.txt') and //FileExists(AppPath + 'database\make_arrow.txt') and{巵{敔捛壛僐僐傑偱}{傾僀僥儉惢憿捛壛} FileExists(AppPath + 'database\metalprocess_db.txt') and{傾僀僥儉惢憿捛壛僐僐傑偱}{僉儏乕儁僢僩} FileExists( AppPath + 'database\pet_db.txt' ) and{僉儏乕儁僢僩偙偙傑偱} FileExists(AppPath + 'database\mob_db.txt') and FileExists(AppPath + 'database\skill_db.txt') and{僊儖僪婡擻捛壛} FileExists(AppPath + 'database\skill_guild_db.txt') and FileExists(AppPath + 'database\exp_guild_db.txt') and{僊儖僪婡擻捛壛僐僐傑偱} FileExists(AppPath + 'database\exp_db.txt')) then begin MessageBox(Handle, 'You have missing files. Go to http://dwiess.sigh.org/forum', 'darkWeiss', MB_OK or MB_ICONSTOP); Application.Terminate; exit; end; //gat僼傽僀儖偺懚嵼傪僠僃僢僋 DebugOut.Lines.Add('Map data loading...'); Application.ProcessMessages; if FindFirst(AppPath + 'map\*.dwm', $27, sr) = 0 then begin repeat dat := TFileStream.Create(AppPath + 'map\' + sr.Name, fmOpenRead, fmShareDenyWrite); SetLength(str, 3); dat.Read(str[1], 3); if str <> 'DWM' then begin MessageBox(Handle, PChar('Map Format Error : ' + sr.Name), 'darkWeiss', MB_OK or MB_ICONSTOP); Application.Terminate; exit; end; dat.Read(w, 2); dat.Read(xy.X, 4); dat.Read(xy.Y, 4); dat.Free; if (xy.X < 0) or (xy.X > 511) or (xy.Y < 0) or (xy.Y > 511) then begin MessageBox(Handle, PChar('Map Size Error : ' + sr.Name), 'darkWeiss', MB_OK or MB_ICONSTOP); Application.Terminate; exit; end; //txtDebug.Lines.Add(Format('MapData: %s [%dx%d]', [sr.Name, xy.X, xy.Y])); //Application.ProcessMessages; ta := TMapList.Create; ta.Name := LowerCase(ChangeFileExt(sr.Name, '')); ta.Size := xy; ta.Mode := 0; MapList.AddObject(ta.Name, ta); until FindNext(sr) <> 0; FindClose(sr); end else begin //gat僼傽僀儖偑1屄傕側偄応崌 MessageBox(Handle, 'map files missing', 'darkWeiss', MB_OK or MB_ICONSTOP); Application.Terminate; exit; end; if MapList.IndexOf('prontera') = -1 then begin //嵟掅尷丄prontera.gat偑側偄偲婲摦偟側偄 MessageBox(Handle, 'prontera.dwm missing', 'darkWeiss', MB_OK or MB_ICONSTOP); Application.Terminate; exit; end; DebugOut.Lines.Add(Format('-> Total %d map(s) loaded.', [MapList.Count])); Application.ProcessMessages; //傾僀僥儉僨乕僞儘乕僪 DebugOut.Lines.Add('Item database loading...'); Application.ProcessMessages; AssignFile(txt, AppPath + 'database\item_db.txt'); Reset(txt); Readln(txt, str); while not eof(txt) do begin sl.Clear; Readln(txt, str); sl.DelimitedText := str; for i := sl.Count to 43 do sl.Add('0'); for i := 0 to 43 do if (i <> 1) and (i <> 2) and (sl.Strings[i] = '') then sl.Strings[i] := '0'; td := TItemDB.Create; with td do begin ID := StrToInt(sl.Strings[0]); Name := sl.Strings[1]; JName := sl.Strings[2]; IType := StrToInt(sl.Strings[3]); IEquip := ((IType = 4) or (IType = 5)); Price := StrToInt(sl.Strings[4]); Sell := StrToInt(sl.Strings[5]); Weight := StrToInt(sl.Strings[6]); ATK := StrToInt(sl.Strings[7]); MATK := StrToInt(sl.Strings[8]); DEF := StrToInt(sl.Strings[9]); MDEF := StrToInt(sl.Strings[10]); Range := StrToInt(sl.Strings[11]); Slot := StrToInt(sl.Strings[12]); for i := 0 to 5 do Param[i] := StrToInt(sl.Strings[13+i]); HIT := StrToInt(sl.Strings[19]); FLEE := StrToInt(sl.Strings[20]); Crit := StrToInt(sl.Strings[21]); Avoid := StrToInt(sl.Strings[22]); Cast := StrToInt(sl.Strings[23]); Gender := StrToInt(sl.Strings[25]); Loc := StrToInt(sl.Strings[26]); wLV := StrToInt(sl.Strings[27]); eLV := StrToInt(sl.Strings[28]); View := StrToInt(sl.Strings[29]); Element := StrToInt(sl.Strings[30]); Effect := StrToInt(sl.Strings[31]); {Fix} Job := StrToInt64(sl.Strings[24]); if Job <> 0 then begin //Bit recombination for i := 0 to 20 do begin jf[i] := boolean((Job and (1 shl i)) <> 0); end; // Novice swordsman mage archer Job := Int64(jf[ 0]) * $0001 + Int64(jf[ 1]) * $0002 + Int64(jf[ 2]) * $0004 + Int64(jf[ 3]) * $0008; // aco merchant thief knight Job := Job + Int64(jf[ 4]) * $0010 + Int64(jf[ 5]) * $0020 + Int64(jf[ 6]) * $0040 + Int64(jf[ 7]) * $0080; // priest Wizard blacksmith hunter Job := Job + Int64(jf[10]) * $0100 + Int64(jf[ 8]) * $0200 + Int64(jf[ 11]) * $0400 + Int64(jf[ 9]) * $0800; // Asassin Job := Job + Int64(jf[12]) * $1000; //巄掕 Job := Job or Int64(jf[14]) * $004000; //Crusader Job := Job or Int64(jf[15]) * $008000; //Monk Job := Job or Int64(jf[16]) * $010000; //Sage Job := Job or Int64(jf[17]) * $020000; //Rouge Job := Job or Int64(jf[18]) * $040000; //Alchemist Job := Job or Int64(jf[19]) * $080000; //Bard Job := Job or Int64(jf[20]) * $100000; //Dancer //Crusader Same as a swordsman and knight. if Boolean(Job and $0002) or Boolean(Job and $0080) then Job := Job or $4000; //Monk if IType = 5 then begin //Same as aco if Boolean(Job and $0010) or Boolean(Job and $0100) then Job := Job or $8000; end else if IType = 4 then begin //weapons same as aco, knuckle system if Boolean(Job and $0010) then Job := Job or $8000; if View = 12 then Job := Job or $8000; end; //Sage Same attribute as mage if Boolean(Job and $0004) or Boolean(Job and $0200) then Job := Job or $10000; //Possible equiptment if (IType = 4) and (View = 15) then Job := Job or $10000; //Rogue same as hunter. uses bow if Boolean(Job and $0040) then Job := Job or $20000; //Alchemist Same as Blacksmith if Boolean(Job and $0020) or Boolean(Job and $0400) then Job := Job or $40000; //Bard //Dancer if IType = 5 then begin //Same defence equiptment as hunter if Boolean(Job and $0008) or Boolean(Job and $0800) then Job := Job or $180000; end; if IType = 4 then begin if View = 13 then Job := Job or $080000; //Music instrument if View = 14 then Job := Job or $100000; //Whip if View = 11 then begin //Bows equip for both? if Boolean(Job and $0008) or Boolean(Job and $0800) then Job := Job or $180000; end; end; end;{FIX Stop} HP1 := StrToInt(sl.Strings[32]); HP2 := StrToInt(sl.Strings[33]); SP1 := StrToInt(sl.Strings[34]); SP2 := StrToInt(sl.Strings[35]); //Rare := StrToBool(sl.Strings[36]); //Box := StrToInt(sl.Strings[37]);{曄峏} for i := 0 to 9 do begin DamageFixR[i] := 0; DamageFixE[i] := 0; end; DamageFixR[StrToInt(sl.Strings[36])] := StrToInt(sl.Strings[37]); DamageFixE[StrToInt(sl.Strings[38])] := StrToInt(sl.Strings[39]); i := StrToInt(sl.Strings[40]); if i <> 0 then begin if (i mod 10) = 0 then begin SFixPer2[(i div 10)-1] := StrToInt(sl.Strings[41]) div 100; end else begin SFixPer1[(i mod 10)-1] := StrToInt(sl.Strings[41]) mod 100; end; end; for i := 0 to 330 do AddSkill[i] := 0; AddSkill[StrToInt(sl.Strings[42])] := StrToInt(sl.Strings[43]); case ID of 4115: begin //僴儞僞乕僼儔僀 DrainFix[0] := 3; //僶僌巇條 DrainPer[0] := 15; end; //vs僒僀僘15%宯 4082: DamageFixS[0] := 15; //恊僨僓 4092: DamageFixS[1] := 15; //僗働儚僇 4126: DamageFixS[2] := 15; //儈僲僞僂儘僗 //摿庩 4122: //僨價傾僗 begin DamageFixR[2] := 5; DamageFixR[3] := 5; DamageFixR[4] := 5; DamageFixR[7] := 5; end; 4147: SplashAttack := true; //僶僼僅 end;{曄峏僐僐傑偱} end; ItemDB.AddObject(td.ID, td); ItemDBName.AddObject(td.Name, td); end; CloseFile(txt); DebugOut.Lines.Add(Format('-> Total %d item(s) database loaded.', [ItemDB.Count])); Application.ProcessMessages;{捛壛} //傾僀僥儉摿庩掕媊 DebugOut.Lines.Add('Special database loading...'); Application.ProcessMessages; if FileExists(AppPath + 'database\special_db.txt') then begin AssignFile(txt, AppPath + 'database\special_db.txt'); Reset(txt); Readln(txt, str); k := 0; while not eof(txt) do begin sl.Clear; Readln(txt, str); sl.DelimitedText := str; j := StrToInt(sl[0]); if j = 0 then continue; i := ItemDB.IndexOf(j); if i <> -1 then begin td := ItemDB.Objects[i] as TItemDB; with td do begin for i :=1 to sl.Count - 1 do begin //XYZZ w := StrToInt(sl.Strings[i]); if w > 10000 then begin w := w - 10000; AddSkill[w div 10] := w mod 10 + 1; end else begin //X = 1:庬懓 2:懏惈 3:僒僀僘 case ( w div 1000 ) of //庬懓 Y = 0:柍宍 1:晄巰 2:摦暔 3:怉暔 4:崺拵 5:悈惐 6:埆杺 7:恖娫 8:揤巊 9:棾懓 1: DamageFixR[( w mod 1000 ) div 100] := w mod 100; //懏惈 Y = 0:柍, 1:悈, 2:抧, 3:壩, 4:晽, 5:撆, 6:惞, 7:埮, 8:擮, 9:晄巰 2: DamageFixE[( w mod 1000 ) div 100] := w mod 100; //僒僀僘 Y = 0:彫, 1:拞, 2:戝 3: DamageFixS[( w mod 1000 ) div 100] := w mod 100; //忬懺1 Y = 01:愇壔 02:搥寢 03:僗僞儞 04:悋柊 05:LexA? 06:愇壔慜偺堏峴忬懺 4: SFixPer1[( w mod 1000 ) div 100 -1] := w mod 100; //忬懺2 Y = 01:撆 02:庺偄 03:捑栙 04:崿棎丠 05:埫埮 5: SFixPer2[( w mod 1000 ) div 100 -1 ] := w mod 100; 6: begin //HP媧廂 XYYZ YY:媧廂検 Z:媧廂妋棪 DrainFix[0] := w mod 10; DrainPer[0] := ( w mod 1000 ) div 10; end; 7: begin //SP媧廂 XYYZ YY:媧廂検 Z:媧廂妋棪 DrainFix[1] := w mod 10; DrainPer[1] := ( w mod 1000 ) div 10; end; 8: begin //偦偺懠 case ( ( w mod 1000 ) div 100 ) of 0: SplashAttack := True; 1: NoJamstone := True; else //壗傕偟側偄 end; end; else //壗傕偟側偄 end; // "case ( w div 1000 ) of" end; end; // "for i :=0 to 3 do" end end; Inc(k); end; CloseFile(txt); DebugOut.Lines.Add(Format('-> Total %d item(s) database change.', [k])); Application.ProcessMessages; end else begin DebugOut.Lines.Add('-> Special database Not Find.'); Application.ProcessMessages; end;{捛壛僐僐傑偱}{傾僀僥儉惢憿捛壛} //傾僀僥儉惢憿僨乕僞儀乕僗撉傒崬傒 DebugOut.Lines.Add('MetalProcess database loading...'); Application.ProcessMessages; AssignFile(txt, AppPath + 'database\metalprocess_db.txt'); Reset(txt); Readln(txt, str); while not eof(txt) do begin sl.Clear; Readln(txt, str); sl.DelimitedText := str; for i := sl.Count to 8 do sl.Add('0'); for i := 0 to 8 do if (i <> 0) and (sl.Strings[i] = '') then sl.Strings[i] := '0'; tma := TMaterialDB.Create; with tma do begin ID := StrToInt(sl.Strings[0]); ItemLv := StrToInt(sl.Strings[1]); RequireSkill := StrToInt(sl.Strings[2]); for j := 0 to 2 do begin MaterialID[j] := StrToInt(sl.Strings[3+j*2]); MaterialAmount[j] := StrToInt(sl.Strings[4+j*2]); end; end; MaterialDB.AddObject(tma.ID, tma); end; CloseFile(txt); DebugOut.Lines.Add(Format('-> Total %d metalprocess(s) database loaded.', [MaterialDB.Count])); Application.ProcessMessages;{傾僀僥儉惢憿捛壛僐僐傑偱} //儌儞僗僞乕僨乕僞儀乕僗撉傒崬傒 DebugOut.Lines.Add('Monster database loading...'); Application.ProcessMessages; AssignFile(txt, AppPath + 'database\mob_db.txt'); Reset(txt); Readln(txt, str); while not eof(txt) do begin sl.Clear; Readln(txt, str); sl.DelimitedText := str; for i := sl.Count to 54 do
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -