📄 game_master.pas
字号:
if ( (aegistype = 'B') and (Copy(str, 1, length(tc.Name) + 2) = (tc.Name + ': ')) and (not (Copy(str, 1, 4) = 'blue') ) and (check_level(tc. ID, GM_AEGIS_B)) ) then error_msg := command_aegis_b(str)
else if ( (aegistype = 'B') and (Copy(str, 1, length(tc.Name) + 2) <> (tc.Name + ': ')) and (not (Copy(str, 1, 4) = 'blue') ) and (check_level(tc. ID, GM_AEGIS_NB)) ) then error_msg := command_aegis_nb(str)
else if ( (aegistype = 'B') and (Copy(str, 1, 4) = 'blue') and (check_level(tc. ID, GM_AEGIS_BB)) ) then error_msg := command_aegis_bb(tc, str)
else if ( (aegistype = 'S') and (ItemDBName.IndexOf(str) <> -1) and (check_level(tc.ID, GM_AEGIS_ITEM)) ) then error_msg := command_aegis_item(tc, str)
else if ( (aegistype = 'S') and (MobDBName.IndexOf(str) <> -1) and (check_level(tc.ID, GM_AEGIS_MONSTER)) ) then error_msg := command_aegis_monster(tc, str)
else if ( (aegistype = 'R') and (StrToInt(str) = 0) and (check_level(tc.ID, GM_AEGIS_RESETSTATE)) ) then error_msg := command_aegis_resetstate(tc, str)
else if ( (aegistype = 'R') and (StrToInt(str) = 1) and (check_level(tc.ID, GM_AEGIS_RESETSKILL)) ) then error_msg := command_aegis_resetskill(tc, str)
else if ( (aegistype = 'H') and (check_level(tc.ID, GM_AEGIS_HIDE)) ) then error_msg := command_aegis_hide(tc)
end;
if (error_msg <> '') then error_message(tc, error_msg);
if ( (Option_GM_Logs) and (error_msg <> '') ) then save_gm_log(tc, error_msg);
end;
function check_level(id : Integer; cmd : Integer) : Boolean;
var
idx : Integer;
tGM : TGM_Table;
begin
Result := False;
idx := GM_Access_DB.IndexOf(id);
if (idx <> -1) then begin
tGM := GM_Access_DB.Objects[idx] as TGM_Table;
if ( (tGM.ID = id) and (tGM.Level >= cmd) ) then Result := True;
end else begin
if (cmd = 0) then Result := True;
end;
end;
procedure error_message(tc : TChara; str : String);
begin
WFIFOW(0, $009a);
WFIFOW(2, length(str) + 4);
WFIFOS(4, str, length(str));
tc.Socket.SendBuf(buf, length(str) + 4);
end;
{
save_gm_log()
Orig Author: AlexKreuz
2004/05/28
Revisions:
2004/05/31 [ChrstphrR] Added exception handling to gracefully handle file
errors that might occur. (Notice how try-except doesn't butcher the code :D )
}
procedure save_gm_log(tc : TChara; str : String);
var
logfile : TStringList;
timestamp : TDateTime;
filename : String;
begin
timestamp := Now;
filename := StringReplace(DateToStr(timestamp), '/', '_', [rfReplaceAll, rfIgnoreCase]);
logfile := TStringList.Create;
{ChrstphrR 2004/05/30 - try-except to handle nasty situations where
we can't open or write to the logfiles -- they won't be showstoppers.
Note that the Create and Free methods are outside of this.}
try
if FileExists(AppPath + 'logs\GM_COMMANDS-' + filename + '.txt') then begin
logfile.LoadFromFile(AppPath + 'logs\GM_COMMANDS-' + filename + '.txt');
end;
str := '[' + DateToStr(timestamp) + '-' + TimeToStr(timestamp) + '] ' + IntToStr(tc.ID) + ': ' + str + ' (' + tc.Name + ')';
logfile.Add(str);
CreateDir('logs');
logfile.SaveToFile(AppPath + 'logs\GM_COMMANDS-' + filename + '.txt');
except
on E : Exception do DebugOut.Lines.Add('[' + TimeToStr(Now) + '] ' + '*** GM Logfile Error : ' + E.Message);
end;
logfile.Free;
end;
function command_alive(tc : TChara) : String;
var
tm : TMap;
begin
Result := 'GM_ALIVE Success.';
tm := Map.Objects[Map.IndexOf(tc.Map)] as TMap;
tc.HP := tc.MAXHP;
tc.SP := tc.MAXSP;
tc.Sit := 3;
SendCStat1(tc, 0, 5, tc.HP);
SendCStat1(tc, 0, 7, tc.SP);
WFIFOW(0, $0148);
WFIFOL(2, tc.ID);
WFIFOW(6, 100);
SendBCmd(tm, tc.Point, 8);
end;
function command_item(tc : TChara; str : String) : String;
var
sl : TStringList;
td : TItemDB;
i, j, k : Integer;
begin
Result := 'GM_ITEM Success.';
sl := TStringList.Create;
sl.DelimitedText := Copy(str, 6, 256);
if sl.Count = 2 then begin
Val(sl[0], i, k);
if k <> 0 then Exit;
if ItemDB.IndexOf(i) = -1 then Exit;
Val(sl[1], j, k);
if k <> 0 then Exit;
if (j <= 0) or (j > 30000) then Exit;
td := ItemDB.IndexOfObject(i) as TItemDB;
if tc.MaxWeight >= tc.Weight + cardinal(td.Weight) * cardinal(j) then begin
k := SearchCInventory(tc, i, td.IEquip);
if k <> 0 then begin
if tc.Item[k].Amount + j > 30000 then Exit;
if td.IEquip then j := 1;
tc.Item[k].ID := i;
tc.Item[k].Amount := tc.Item[k].Amount + j;
tc.Item[k].Equip := 0;
tc.Item[k].Identify := 1;
tc.Item[k].Refine := 0;
tc.Item[k].Attr := 0;
tc.Item[k].Card[0] := 0;
tc.Item[k].Card[1] := 0;
tc.Item[k].Card[2] := 0;
tc.Item[k].Card[3] := 0;
tc.Item[k].Data := td;
tc.Weight := tc.Weight + cardinal(td.Weight) * cardinal(j);
SendCStat1(tc, 0, $0018, tc.Weight);
SendCGetItem(tc, k, j);
end;
end
else begin
WFIFOW( 0, $00a0);
WFIFOB(22, 2);
tc.Socket.SendBuf(buf, 23);
end;
end;
sl.Free;
end;
function command_save(tc : TChara) : String;
begin
Result := 'GM_SAVE Success.';
tc.SaveMap := tc.Map;
tc.SavePoint.X := tc.Point.X;
tc.SavePoint.Y := tc.Point.Y;
Result := 'Saved at ' + tc.Map + ' (' + IntToStr(tc.Point.X) + ',' + IntToStr(tc.Point.Y) + ')';
end;
function command_return(tc : TChara) : String;
begin
Result := 'GM_RETURN Success.';
SendCLeave(tc.Socket.Data, 2);
tc.Map := tc.SaveMap;
tc.Point := tc.SavePoint;
MapMove(tc.Socket, tc.Map, tc.Point);
end;
function command_die(tc : TChara) : String;
var
tm : TMap;
begin
Result := 'GM_DIE Success.';
tm := Map.Objects[Map.IndexOf(tc.Map)] as TMap;
CharaDie(tm, tc, 1);
end;
function command_auto(tc : TChara; str : String) : String;
var
sl : TStringList;
j, k : Integer;
begin
Result := 'GM_AUTO Success.';
sl := TStringList.Create;
sl.DelimitedText := Copy(str, 5, 256);
if sl.Count = 0 then Exit;
Val(sl.Strings[0], j, k);
if (k <> 0) or (j < 0) then Exit;
tc.Auto := j;
if sl.Count = 3 then begin
Val(sl.Strings[1], tc.A_Skill, k);
Val(sl.Strings[2], tc.A_Lv, k);
end;
sl.Free;
end;
function command_hcolor(tc : TChara; str : String) : String;
var
tm : TMap;
i, k : Integer;
begin
Result := 'GM_HCOLOR Success.';
tm := Map.Objects[Map.IndexOf(tc.Map)] as TMap;
Val(Copy(str, 8, 256), i, k);
if (k = 0) and (i >= 0) then begin
tc.HairColor := i;
UpdateLook(tm, tc, 6, i, 0, true);
end;
end;
function command_ccolor(tc : TChara; str : String) : String;
var
tm : TMap;
i, k : Integer;
begin
Result := 'GM_CCOLOR Success.';
tm := Map.Objects[Map.IndexOf(tc.Map)] as TMap;
Val(Copy(str, 8, 256), i, k);
if (k = 0) and (i >= 0) then begin
tc.ClothesColor := i;
UpdateLook(tm, tc, 7, i, 0, true);
end;
end;
function command_hstyle(tc : TChara; str : String) : String;
var
tm : TMap;
i, k : Integer;
begin
Result := 'GM_HSTYLE Success.';
tm := Map.Objects[Map.IndexOf(tc.Map)] as TMap;
Val(Copy(str, 8, 256), i, k);
if (k = 0) and (i >= 0) then begin
tc.Hair := i;
UpdateLook(tm, tc, 1, i, 0, true);
end;
end;
function command_kill(str : String) : String;
var
s : String;
tc1 : TChara;
tm : TMap;
begin
Result := 'GM_KILL Success.';
s := Copy(str, 6, 256);
if (CharaName.Indexof(s) <> -1) then begin
tc1 := CharaName.Objects[CharaName.Indexof(s)] as TChara;
if (tc1.Login = 2) then begin
tm := Map.Objects[Map.IndexOf(tc1.Map)] as TMap;
tc1.HP := 0;
tc1.Sit := 1;
SendCStat1(tc1, 0, 5, tc1.HP);
WFIFOW( 0, $0080);
WFIFOL( 2, tc1.ID);
WFIFOB( 6, 1);
SendBCmd(tm, tc1.Point, 7);
Result := 'GM_KILL Success. ' + s + ' has been killed.';
end else begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -