📄 castle.pas
字号:
function TUserCastle.RepairWall(nWallIndex: Integer):Boolean; //00490B78
var
Wall:TBaseObject;
begin
Result:=False;
Wall:=nil;
case nWallIndex of
1: Wall:=m_LeftWall.BaseObject;
2: Wall:=m_CenterWall.BaseObject;
3: Wall:=m_RightWall.BaseObject;
end;
if (Wall = nil) or
(m_boUnderWar) or
(Wall.m_WAbil.HP >= Wall.m_WAbil.MaxHP) then begin
exit;
end;
if not Wall.m_boDeath then begin
if (GetTickCount - Wall.m_dwStruckTick) > 60 * 1000 then begin
Wall.m_WAbil.HP:=Wall.m_WAbil.MaxHP;
TWallStructure(Wall).RefStatus();
Result:=True;
end;
end else begin
if (GetTickCount - Wall.m_dwStruckTick) > 60 * 1000 then begin
Wall.m_WAbil.HP:=Wall.m_WAbil.MaxHP;
Wall.m_boDeath:=False;
TWallStructure(Wall).RefStatus();
Result:=True;
end;
end;
end;
function TUserCastle.AddAttackerInfo(Guild: TGuild): Boolean; //00490CD8
var
AttackerInfo:pTAttackerInfo;
begin
Result:=False;
if InAttackerList(Guild) then exit;
New(AttackerInfo);
AttackerInfo.AttackDate:=AddDateTimeOfDay(Now,g_Config.nStartCastleWarDays);
AttackerInfo.sGuildName:=Guild.sGuildName;
AttackerInfo.Guild:=Guild;
m_AttackWarList.Add(AttackerInfo);
SaveAttackSabukWall();
UserEngine.SendServerGroupMsg(SS_212,nServerIndex,'');
Result:=True;
end;
function TUserCastle.InAttackerList(Guild: TGuild): Boolean;//00490C84
var
I: Integer;
begin
Result:=False;
for I := 0 to m_AttackWarList.Count - 1 do begin
if pTAttackerInfo(m_AttackWarList.Items[I]).Guild = Guild then begin
Result:=True;
break;
end;
end;
end;
function TUserCastle.m_nChiefItemCount: Integer;
begin
end;
procedure TUserCastle.SetPower(nPower: Integer);
begin
m_nPower:=nPower;
end;
procedure TUserCastle.SetTechLevel(nLevel: Integer);
begin
m_nTechLevel:=nLevel;
end;
{ TCastleManager }
constructor TCastleManager.Create;
begin
m_CastleList:=TList.Create;
InitializeCriticalSection(CriticalSection);
end;
destructor TCastleManager.Destroy;
var
I: Integer;
UserCastle:TUserCastle;
begin
for I := 0 to m_CastleList.Count - 1 do begin
UserCastle:=TUserCastle(m_CastleList.Items[I]);
UserCastle.Save;
UserCastle.Free;
end;
m_CastleList.Free;
DeleteCriticalSection(CriticalSection);
inherited;
end;
function TCastleManager.Find(sCastleName: String): TUserCastle;
var
I: Integer;
Castle:TUserCastle;
begin
Result:=nil;
for I := 0 to m_CastleList.Count - 1 do begin
Castle:=TUserCastle(m_CastleList.Items[I]);
if CompareText(Castle.m_sName,sCastleName) = 0 then begin
Result:=Castle;
break;
end;
end;
end;
//取得角色所在座标的城堡
function TCastleManager.InCastleWarArea(
BaseObject: TBaseObject): TUserCastle;
var
I: Integer;
Castle:TUserCastle;
begin
Result:=nil;
for I := 0 to m_CastleList.Count - 1 do begin
Castle:=TUserCastle(m_CastleList.Items[I]);
if Castle.InCastleWarArea(BaseObject.m_PEnvir,BaseObject.m_nCurrX,BaseObject.m_nCurrY) then begin
Result:=Castle;
break;
end;
end;
end;
function TCastleManager.InCastleWarArea(Envir: TEnvirnoment; nX,
nY: Integer): TUserCastle;
var
I: Integer;
Castle:TUserCastle;
begin
Result:=nil;
for I := 0 to m_CastleList.Count - 1 do begin
Castle:=TUserCastle(m_CastleList.Items[I]);
if Castle.InCastleWarArea(Envir,nX,nY) then begin
Result:=Castle;
break;
end;
end;
end;
procedure TCastleManager.Initialize;
var
I: Integer;
Castle:TUserCastle;
begin
if m_CastleList.Count <= 0 then begin
Castle:=TUserCastle.Create(g_Config.sCastleDir);
m_CastleList.Add(Castle);
Castle.Initialize;
Castle.m_sConfigDir:='0';
Castle.m_EnvirList.Add('0151');
Castle.m_EnvirList.Add('0152');
Castle.m_EnvirList.Add('0153');
Castle.m_EnvirList.Add('0154');
Castle.m_EnvirList.Add('0155');
Castle.m_EnvirList.Add('0156');
for I := 0 to Castle.m_EnvirList.Count - 1 do begin
Castle.m_EnvirList.Objects[I]:=g_MapManager.FindMap(Castle.m_EnvirList.Strings[I]);
end;
Save();
exit;
end;
for I := 0 to m_CastleList.Count - 1 do begin
Castle:=TUserCastle(m_CastleList.Items[I]);
Castle.Initialize;
end;
end;
//城堡皇宫所在地图
function TCastleManager.IsCastlePalaceEnvir(Envir: TEnvirnoment): TUserCastle;
var
I: Integer;
Castle:TUserCastle;
begin
Result:=nil;
for I := 0 to m_CastleList.Count - 1 do begin
Castle:=TUserCastle(m_CastleList.Items[I]);
if Castle.m_MapPalace = Envir then begin
Result:=Castle;
break;
end;
end;
end;
//城堡所在地图
function TCastleManager.IsCastleEnvir(Envir: TEnvirnoment): TUserCastle;
var
I: Integer;
Castle:TUserCastle;
begin
Result:=nil;
for I := 0 to m_CastleList.Count - 1 do begin
Castle:=TUserCastle(m_CastleList.Items[I]);
if Castle.m_MapCastle = Envir then begin
Result:=Castle;
break;
end;
end;
end;
function TCastleManager.IsCastleMember(
BaseObject: TBaseObject): TUserCastle;
var
I: Integer;
Castle:TUserCastle;
begin
Result:=nil;
for I := 0 to m_CastleList.Count - 1 do begin
Castle:=TUserCastle(m_CastleList.Items[I]);
if Castle.IsMember(BaseObject) then begin
Result:=Castle;
break;
end;
end;
end;
procedure TCastleManager.Run;
var
I: Integer;
UserCastle:TUserCastle;
begin
Lock;
try
for I := 0 to m_CastleList.Count - 1 do begin
UserCastle:=TUserCastle(m_CastleList.Items[I]);
UserCastle.Run;
end;
finally
UnLock;
end;
end;
procedure TCastleManager.GetCastleGoldInfo(List:TStringList);
var
I: Integer;
Castle:TUserCastle;
begin
for I := 0 to m_CastleList.Count - 1 do begin
Castle:=TUserCastle(m_CastleList.Items[I]);
List.Add(format(g_sGameCommandSbkGoldShowMsg,[Castle.m_sName,Castle.m_nTotalGold,Castle.m_nTodayIncome]));
end;
end;
procedure TCastleManager.Save;
var
I: Integer;
Castle:TUserCastle;
begin
SaveCastleList();
for I := 0 to m_CastleList.Count - 1 do begin
Castle:=TUserCastle(m_CastleList.Items[I]);
Castle.Save;
end;
end;
procedure TCastleManager.LoadCastleList;
var
LoadList:TStringList;
Castle:TUserCastle;
sCastleDir:String;
i:integer;
begin
if FileExists(g_Config.sCastleFile) then begin
LoadList:=TStringList.Create;
LoadList.LoadFromFile(g_Config.sCastleFile);
for i:=0 to LoadList.Count -1 do begin
sCastleDir:=Trim(LoadList.Strings[i]);
if sCastleDir <> '' then begin
Castle:=TUserCastle.Create(sCastleDir);
m_CastleList.Add(Castle);
end;
end;
LoadList.Free;
MainOutMessage('Castles: ' + IntToStr(m_CastleList.Count));
end else begin
MainOutMessage('Castle file could not be found!!');
end;
end;
procedure TCastleManager.SaveCastleList;
var
I: Integer;
LoadList:TStringList;
begin
if not DirectoryExists(g_Config.sCastleDir) then begin
CreateDir(g_Config.sCastleDir);
end;
LoadList:=TStringList.Create;
for I := 0 to m_CastleList.Count - 1 do begin
LoadList.Add(IntToStr(I));
end;
LoadList.SaveToFile(g_Config.sCastleFile);
LoadList.Free;
end;
function TCastleManager.GetCastle(nIndex: Integer): TUserCastle;
begin
Result:=nil;
if (nIndex >= 0) and (nIndex < m_CastleList.Count) then
Result:=TUserCastle(m_CastleList.Items[nIndex]);
end;
procedure TCastleManager.GetCastleNameList(List: TStringList);
var
I: Integer;
Castle:TUserCastle;
begin
for I := 0 to m_CastleList.Count - 1 do begin
Castle:=TUserCastle(m_CastleList.Items[I]);
List.Add(Castle.m_sName);
end;
end;
procedure TCastleManager.IncRateGold(nGold: Integer);
var
I: Integer;
Castle:TUserCastle;
begin
Lock;
try
for I := 0 to m_CastleList.Count - 1 do begin
Castle:=TUserCastle(m_CastleList.Items[I]);
Castle.IncRateGold(nGold);
end;
finally
UnLock;
end;
end;
procedure TCastleManager.Lock;
begin
EnterCriticalSection(CriticalSection);
end;
procedure TCastleManager.UnLock;
begin
LeaveCriticalSection(CriticalSection);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -