📄 uguild.pas
字号:
unit uGuild;
interface
uses
Windows, Classes, SysUtils, svClass, subutil, uAnsTick, AnsUnit,
BasicObj, FieldMsg, MapUnit, DefType, Autil32, uMonster, uGramerid, UUser,
IniFiles, uLevelexp, uGuildSub, uManager, AnsStringCls, UserSDB;
const
// DEC_GUILD_DURA_TICK = 200;
DEC_GUILD_DURA_TICK = 500;
// 2000.09.16 巩颇檬籍狼 郴备己 刘啊摹 5000栏肺 荐沥 by Lee.S.G
// ADD_GUILD_DURA_BY_SYSOP = 4000;
ADD_GUILD_DURA_BY_SYSOP = 5000;
ADD_GUILD_DURA_BY_SUBSYSOP = 1000;
DEC_GUILD_DURA_BY_HIT = 20;
MAX_GUILD_DURA = 1100000;
GUILDSTONE_IMAGE_NUMBER = 67;
MAX_SUBSYSOP_COUNT = 3;
MAX_GUILDNPC_COUNT = 5;
MAX_GUILDWEAR_COUNT = 2;
type
TGuildObject = class (TBasicObject)
private
FGuildName : String;
FWarAlarmStr : String;
FWarAlarmStartTick : Integer;
FWarAlarmTick : Integer;
SelfData : TCreateGuildData;
GuildNpcList : TList;
DieGuildNpcList : TList;
GuildUserList : TGuildUserList;
DuraTick : integer;
boAddGuildMagic : Boolean;
function AddGuildNpc (aName : String; aX, aY : Integer; aSex : Byte): Boolean;
protected
procedure Initial;
procedure StartProcess; override;
procedure EndProcess; override;
function FieldProc (hfu: Longint; Msg: word; var SenderInfo: TBasicData; var aSubData: TSubData): Integer; override;
function GetUserGrade (uname: string): string;
function GetGuildNpcbyName (aname: string): integer;
public
constructor Create;
destructor Destroy; override;
procedure Clear;
procedure LoadFromFile (aGuildName: String);
procedure SaveToFile;
procedure GetGuildInfo (aUser: TUser);
function MoveStone (aServerID, ax, ay: integer) : Boolean;
function CreateStone (aSysopName : String; aServerID, ax, ay: integer) : Boolean;
procedure Update (CurTick: integer); override;
function IsGuildSysop (aName : String) : Boolean;
function IsGuildSubSysop (aName : String) : Boolean;
function IsGuildUser (aName : String) : Boolean;
function IsGuildNpc (aName : String) : Boolean;
function GetSelfData : PTCreateGuildData;
function GetGuildMagicString : String;
function GetInformation : String;
procedure AddGuildMagic (aMagicName : String);
procedure ChangeGuildNpcName (aOldName, aNewName : String);
procedure SetWarAlarm (aName, aStr : String);
property GuildName : String read FGuildName;
end;
TGuildList = class
private
CurProcessPos : Integer;
DataList : TList;
function GetCount: Integer;
public
constructor Create;
destructor Destroy; override;
procedure Clear;
procedure LoadFromFile (aFileName : String);
procedure SaveToFile (aFileName : String);
procedure CompactGuild;
// function isGuildSysop (aGuildName, aName : String) : Boolean;
procedure AllowGuildName (gid: integer; aboAllow: Boolean; aGuildName, aSysopName: string);
function AllowGuildCondition (gname, uname: string): Boolean;
function AddGuildObject (aGuildName, aOwnerName : String; aServerID, aX, aY: integer): TGuildObject;
function GetUserGrade (aGuildName, uname: string): string;
function GetGuildServerID (aGuildName : String): Integer;
procedure GetGuildInfo (aGuildName: string; aUser: TUser);
function CheckGuildUser(aGuildName, aName : String) : Boolean;
function MoveStone (aGuildName : string; aServerID, ax, ay: integer) : Boolean;
function CreateStone (aGuildName, aSysopName : string; aServerID, ax, ay: integer) : Boolean;
procedure DeleteStone (aGuildName : String);
function GetGuildObject (aGuildName : String) : TGuildObject;
function GetGuildObjectByMagicName (aMagicName : String) : TGuildObject;
function GetCharInformation (aName : String) : String;
function GetInformation (aName : String) : String;
procedure Update (CurTick: integer);
property Count : integer read GetCount;
end;
var
GuildList : TGuildList;
implementation
uses
SVMain, FSockets;
////////////////////////////////////////////////////
//
// === GuildObject ===
//
////////////////////////////////////////////////////
constructor TGuildObject.Create;
begin
inherited Create;
FGuildName := '';
FWarAlarmStr := '';
FWarAlarmTick := 0;
FWarAlarmStartTick := 0;
FillChar (SelfData, SizeOf (TCreateGuildData), 0);
GuildNpcList := TList.Create;
DieGuildNpcList := TList.Create;
GuildUserList := TGuildUserList.Create;
end;
destructor TGuildObject.Destroy;
begin
Clear;
GuildUserList.Free;
GuildNpcList.Free;
DieGuildNpcList.Free;
inherited Destroy;
end;
procedure TGuildObject.Clear;
var
i : Integer;
GuildNpc : TGuildNpc;
begin
for i := 0 to DieGuildNpcList.Count - 1 do begin
GuildNpc := DieGuildNpcList.Items [i];
GuildNpc.Free;
end;
DieGuildNpcList.Clear;
for i := 0 to GuildNpcList.Count - 1 do begin
GuildNpc := GuildNpcList.Items [i];
GuildNpc.EndProcess;
GuildNpc.Free;
end;
GuildNpcList.Clear;
GuildUserList.Clear;
end;
function TGuildObject.GetSelfData : PTCreateGuildData;
begin
Result := @SelfData;
end;
function TGuildObject.GetInformation : String;
var
i : Integer;
Str : String;
begin
Result := '';
Str := format ('<%s 巩颇沥焊>', [GuildName]) + #13;
Str := Str + format ('巩林 : %s', [SelfData.Sysop]) + #13;
for i := 0 to 3 - 1 do begin
Str := Str + format ('何巩林%d : %s', [i + 1, SelfData.SubSysop[i]]) + #13;
end;
Str := Str + format ('困摹 : %d,%d', [BasicData.X, BasicData.Y]) + #13;
Str := Str + format ('郴备己 : %d', [SelfData.Durability]) + #13;
Str := Str + format ('巩颇公傍 : %s 荐访摹 : %d', [SelfData.GuildMagic, SelfData.MagicExp]) + #13;
for i := 0 to 5 - 1 do begin
Str := Str + format ('%s : %d,%d', [SelfData.GuildNpc[i].rName, SelfData.GuildNpc [i].rX, SelfData.GuildNpc [i].rY]) + #13;
end;
Result := Str;
end;
function TGuildObject.GetGuildMagicString : String;
begin
Result := SelfData.GuildMagic;
end;
procedure TGuildObject.AddGuildMagic (aMagicName : String);
var
GuildNpc : TGuildNpc;
begin
GuildNpc := nil;
SelfData.GuildMagic := aMagicName;
SelfData.MagicExp := 100;
if GuildNpcList.Count > 0 then begin
GuildNpc := GuildNpcList.Items [0];
end else if DieGuildNpcList.Count > 0 then begin
GuildNpc := DieGuildNpcList.Items [0];
end;
if GuildNpc <> nil then begin
GuildNpc.boMagicNpc := true;
StrPCopy (@GuildNpc.BasicData.Guild, SelfData.GuildMagic);
MagicClass.GetMagicData (SelfData.GuildMagic, GuildNpc.GuildMagicData, SelfData.MagicExp);
GuildNpc.BocChangeProperty;
end;
end;
function TGuildObject.IsGuildUser (aName : String) : boolean;
begin
Result := GuildUserList.IsGuildUser(aName);
end;
function TGuildObject.IsGuildSysop (aName : String) : Boolean;
begin
Result := false;
if SelfData.Sysop = aName then Result := true;
end;
function TGuildObject.IsGuildSubSysop (aName : String) : Boolean;
var
i : Integer;
begin
Result := false;
for i := 0 to 3 - 1 do begin
if SelfData.SubSysop [i] = aName then begin
Result := true;
exit;
end;
end;
end;
function TGuildObject.IsGuildNpc (aName : String) : Boolean;
var
i : Integer;
GuildNpc : TGuildNpc;
begin
Result := false;
if aName = '' then exit;
for i := 0 to GuildNpcList.Count - 1 do begin
GuildNpc := GuildNpcList.Items [i];
if GuildNpc.GuildNpcName = aName then begin
Result := true;
exit;
end;
end;
for i := 0 to DieGuildNpcList.Count - 1 do begin
GuildNpc := DieGuildNpcList.Items [i];
if GuildNpc.GuildNpcName = aName then begin
Result := true;
exit;
end;
end;
end;
procedure TGuildObject.SaveToFile;
var
i, j, nIndex : Integer;
GuildNpc : TGuildNpc;
begin
if SelfData.Name = '' then exit;
FillChar (SelfData.GuildNpc, SizeOf (SelfData.GuildNpc), 0);
nIndex := 0;
for i := 0 to GuildNpcList.Count - 1 do begin
GuildNpc := GuildNpcList.Items [i];
if GuildNpc.boMagicNpc = true then begin
SelfData.MagicExp := GuildNpc.GuildMagicData.rSkillExp;
SelfData.GuildNpc[nIndex].rName := GuildNpc.GuildNpcName;
SelfData.GuildNpc[nIndex].rX := GuildNpc.StartX;
SelfData.GuildNpc[nIndex].rY := GuildNpc.StartY;
SelfData.GuildNpc[nIndex].rSex := GuildNpc.Sex;
Inc (nIndex);
end;
end;
for i := 0 to DieGuildNpcList.Count - 1 do begin
GuildNpc := DieGuildNpcList.Items [i];
if GuildNpc.boMagicNpc = true then begin
SelfData.MagicExp := GuildNpc.GuildMagicData.rSkillExp;
SelfData.GuildNpc[nIndex].rName := GuildNpc.GuildNpcName;
SelfData.GuildNpc[nIndex].rX := GuildNpc.StartX;
SelfData.GuildNpc[nIndex].rY := GuildNpc.StartY;
SelfData.GuildNpc[nIndex].rSex := GuildNpc.Sex;
Inc (nIndex);
end;
end;
for i := 0 to GuildNpcList.Count - 1 do begin
GuildNpc := GuildNpcList.Items [i];
if GuildNpc.boMagicNpc = false then begin
SelfData.GuildNpc[nIndex].rName := GuildNpc.GuildNpcName;
SelfData.GuildNpc[nIndex].rX := GuildNpc.StartX;
SelfData.GuildNpc[nIndex].rY := GuildNpc.StartY;
SelfData.GuildNpc[nIndex].rSex := GuildNpc.Sex;
Inc (nIndex);
end;
end;
for i := 0 to DieGuildNpcList.Count - 1 do begin
GuildNpc := DieGuildNpcList.Items [i];
if GuildNpc.boMagicNpc = false then begin
SelfData.MagicExp := GuildNpc.GuildMagicData.rSkillExp;
SelfData.GuildNpc[nIndex].rName := GuildNpc.GuildNpcName;
SelfData.GuildNpc[nIndex].rX := GuildNpc.StartX;
SelfData.GuildNpc[nIndex].rY := GuildNpc.StartY;
SelfData.GuildNpc[nIndex].rSex := GuildNpc.Sex;
Inc (nIndex);
end;
end;
GuildUserList.SaveToFile ('.\Guild\' + SelfData.Name + 'GUser.sdb');
end;
procedure TGuildObject.LoadFromFile;
begin
if not FileExists ('.\Guild\' + SelfData.Name + 'GUser.SDB') then exit;
GuildUserList.LoadFromFile ('.\Guild\' + SelfData.Name + 'GUser.sdb');
end;
function TGuildObject.GetUserGrade (uName: String) : String;
var
i : Integer;
begin
if SelfData.Durability < SelfData.MaxDurability + 100000 then begin
if uName = SelfData.Sysop then
Inc (SelfData.Durability, ADD_GUILD_DURA_BY_SYSOP);
for i := 0 to MAX_SUBSYSOP_COUNT - 1 do begin
if uName = SelfData.SubSysop[i] then
Inc (SelfData.Durability, ADD_GUILD_DURA_BY_SUBSYSOP);
end;
SelfData.Durability := SelfData.MaxDurability;
end;
Result := GuildUserList.GetGradeName (uName);
end;
procedure TGuildObject.GetGuildInfo (aUser: TUser);
var
i : Integer;
tmpStr, Sep : String;
begin
tmpStr := SelfData.Name + ' (' + IntToStr (BasicData.X) + ',' + IntToStr (BasicData.Y) + ')';
aUser.SendClass.SendChatMessage ('巩颇捞抚 : ' + tmpStr, SAY_COLOR_NORMAL);
aUser.SendClass.SendChatMessage ('巩林 : ' + SelfData.Sysop, SAY_COLOR_NORMAL);
tmpStr := '何巩林 : ';
Sep := '';
for i := 0 to MAX_SUBSYSOP_COUNT - 1 do begin
if SelfData.SubSysop[i] <> '' then begin
tmpStr := tmpStr + Sep + SelfData.SubSysop[i];
Sep := ', ';
end;
end;
aUser.SendClass.SendChatMessage (tmpStr, SAY_COLOR_NORMAL);
end;
function TGuildObject.AddGuildNpc (aName: string; ax, ay: integer; aSex : Byte): Boolean;
var
i : integer;
GuildNpc : TGuildNpc;
begin
Result := FALSE;
if GetGuildNpcByName (aName) <> -1 then exit;
if aSex <> 2 then aSex := 1;
for i := 0 to MAX_GUILDNPC_COUNT - 1 do begin
if SelfData.GuildNpc[i].rName = '' then begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -