📄 castle.pas
字号:
for i := Low(m_Archer) to High(m_Archer) do
begin
if (m_Archer[i].BaseObject <> nil) and (m_Archer[i].BaseObject.m_boGhost)
then
begin
m_Archer[i].BaseObject := nil;
end;
end;
if m_boUnderWar then
begin
if m_LeftWall.BaseObject <> nil then
m_LeftWall.BaseObject.m_boStoneMode := False;
if m_CenterWall.BaseObject <> nil then
m_CenterWall.BaseObject.m_boStoneMode := False;
if m_RightWall.BaseObject <> nil then
m_RightWall.BaseObject.m_boStoneMode := False;
if not m_boShowOverMsg then
begin //00490181
if (GetTickCount - m_dwStartCastleWarTick) > (g_Config.dwCastleWarTime -
g_Config.dwShowCastleWarEndMsgTime)
{3 * 60 * 60 * 1000 - 10 * 60 * 1000}
then
begin
m_boShowOverMsg := True;
s20 := format(sWarStopTimeMsg, [m_sName,
g_Config.dwShowCastleWarEndMsgTime div (60 * 1000)]);
UserEngine.SendBroadCastMsgExt(s20, t_System);
UserEngine.SendServerGroupMsg(SS_204, nServerIndex, s20);
MainOutMessage(s20);
end;
end;
if (GetTickCount - m_dwStartCastleWarTick) > g_Config.dwCastleWarTime
{3 * 60 * 60 * 1000}then
begin
StopWallconquestWar();
end;
end
else
begin
if m_LeftWall.BaseObject <> nil then
m_LeftWall.BaseObject.m_boStoneMode := True;
if m_CenterWall.BaseObject <> nil then
m_CenterWall.BaseObject.m_boStoneMode := True;
if m_RightWall.BaseObject <> nil then
m_RightWall.BaseObject.m_boStoneMode := True;
end;
{$IFEND}
except
MainOutMessage(sExceptionMsg);
end;
end;
procedure TUserCastle.Save; //0048EBA4
begin
Try
SaveConfigFile();
SaveAttackSabukWall();
finally
ENd;
end;
function TUserCastle.InCastleWarArea(Envir: TEnvirnoment; nX, nY: Integer):
Boolean; //004910F4
var
i : Integer;
begin
Result := False;
if (Envir = m_MapCastle) and
(abs(m_nHomeX - nX) < m_nWarRangeX {100}) and
(abs(m_nHomeY - nY) < m_nWarRangeY {100}) then
begin
Result := True;
exit;
end;
if (Envir = m_MapPalace) or (Envir = m_MapSecret) then
begin
Result := True;
exit;
end;
//增加取得城堡所有地图列表
for i := 0 to m_EnvirList.Count - 1 do
begin
if m_EnvirList.Objects[i] = Envir then
begin
Result := True;
break;
end;
end;
end;
function TUserCastle.IsMember(Cert: TBaseObject): Boolean; //00490438
begin
Result := IsMasterGuild(TGUild(Cert.m_MyGuild));
end;
//检查是否为攻城方行会的联盟行会
function TUserCastle.IsAttackAllyGuild(Guild: TGUild): Boolean;
var
i : Integer;
AttackGuild : TGUild;
begin
Result := False;
for i := 0 to m_AttackGuildList.Count - 1 do
begin
AttackGuild := TGUild(m_AttackGuildList.Items[i]);
if (AttackGuild <> m_MasterGuild) and AttackGuild.IsAllyGuild(Guild) then
begin
Result := True;
break;
end;
end;
end;
//检查是否为攻城方行会
function TUserCastle.IsAttackGuild(Guild: TGUild): Boolean; //00491160
var
i : Integer;
AttackGuild : TGUild;
begin
Result := False;
for i := 0 to m_AttackGuildList.Count - 1 do
begin
AttackGuild := TGUild(m_AttackGuildList.Items[i]);
if (AttackGuild <> m_MasterGuild) and (AttackGuild = Guild) then
begin
Result := True;
break;
end;
end;
end;
function TUserCastle.CanGetCastle(Guild: TGUild): Boolean; //004911D0
var
i : Integer;
List14 : TMyList;
PlayObject : TPlayObject;
hasSaBak : Boolean;
begin
HasSaBak:=False;
Result := False;
if (GetTickCount - m_dwStartCastleWarTick) > g_Config.dwGetCastleTime {10 * 60 * 1000}then
begin
List14 := TMyList.create;
UserEngine.GetMapRageHuman(m_MapPalace, 0, 0, 1000, List14);
Result := True;
for i := 0 to List14.Count - 1 do
begin
PlayObject := TPlayObject(List14.Items[i]);
if not PlayObject.m_boDeath and (m_MasterGuild<>nil)and(PlayObject.m_MyGuild = m_MasterGuild) then
HasSaBak:=True;
if not PlayObject.m_boDeath and (PlayObject.m_MyGuild <> Guild) then
begin
Result := False;
end;
end;
//2005-11-08
if Not HasSabak and g_Config.boCastleCanNull and (not Result)and(m_MasterGuild<>nil) then
Begin
GetCastle(nil);
End;
List14.Free;
end;
end;
procedure TUserCastle.GetCastle(Guild: TGUild); //00491290
var
OldGuild : TGUild;
s10 : string;
CastleDoor : pTObjUnit;
resourcestring
sGetCastleMsg = '[%s 已被 %s 占领]';
begin
OldGuild := m_MasterGuild;
m_MasterGuild := Guild;
if Guild<>nil then
m_sOwnGuild := Guild.sGuildName;
m_ChangeDate := Now();
SaveConfigFile();
if OldGuild <> nil then
OldGuild.RefMemberName;
if m_MasterGuild <> nil then
Begin
m_MasterGuild.RefMemberName;
s10 := format(sGetCastleMsg, [m_sName, m_sOwnGuild]);
End
else
s10:='[沙巴克已为空城] ';
UserEngine.SendBroadCastMsgExt(s10, t_System);
UserEngine.SendServerGroupMsg(SS_204, nServerIndex, s10);
CastleDoor := @m_MainDoor;
MainOutMessage(s10);
//防止攻城没有结束时修城门
if (Guild<>nil)and(CastleDoor.BaseObject <> nil) then
begin
CastleDoor.BaseObject.m_WAbil.HP := Max(50,
CastleDoor.BaseObject.m_WAbil.HP);
TCastleDoor(CastleDoor.BaseObject).RefStatus();
end;
end;
procedure TUserCastle.StartWallconquestWar; //00491074
var
ListC : TMyList;
i : Integer;
PlayObject : TPlayObject;
begin
ListC := TMyList.create;
UserEngine.GetMapRageHuman(m_MapPalace, m_nHomeX, m_nHomeY, 100, ListC);
for i := 0 to ListC.Count - 1 do
begin
PlayObject := TPlayObject(ListC.Items[i]);
PlayObject.RefShowName();
end;
ListC.Free;
end;
procedure TUserCastle.StopWallconquestWar; //00491408
var
i : Integer;
ListC : TMyList;
PlayObject : TPlayObject;
s14 : string;
resourcestring
sWallWarStop = '[%s 攻城战已经结束]';
begin
m_boUnderWar := False;
m_AttackGuildList.Clear;
ListC := TMyList.create;
UserEngine.GetMapOfRangeHumanCount(m_MapCastle, m_nHomeX, m_nHomeY, 100);
for i := 0 to ListC.Count - 1 do
begin
PlayObject := TPlayObject(ListC.Items[i]);
PlayObject.ChangePKStatus(False);
if PlayObject.m_MyGuild <> m_MasterGuild then
PlayObject.MapRandomMove(PlayObject.m_sHomeMap, 0);
end;
ListC.Free;
s14 := format(sWallWarStop, [m_sName]);
UserEngine.SendBroadCastMsgExt(s14, t_System);
UserEngine.SendServerGroupMsg(SS_204, nServerIndex, s14);
MainOutMessage(s14);
end;
function TUserCastle.InPalaceGuildCount: Integer; //004911B4
begin
Result := m_AttackGuildList.Count;
end;
function TUserCastle.IsDefenseAllyGuild(Guild: TGUild): Boolean;
begin
Result := False;
if not m_boUnderWar then
exit; //如果未开始攻城,则无效
if m_MasterGuild <> nil then
Result := m_MasterGuild.IsAllyGuild(Guild);
end;
//检查是否为守城方行会
function TUserCastle.IsDefenseGuild(Guild: TGUild): Boolean;
begin
Result := False;
if not m_boUnderWar then
exit; //如果未开始攻城,则无效
if Guild = m_MasterGuild then
Result := True;
end;
function TUserCastle.IsMasterGuild(Guild: TGUild): Boolean; //00490400
begin
Result := False;
if (m_MasterGuild <> nil) and (m_MasterGuild = Guild) then
Result := True;
end;
function TUserCastle.GetHomeX: Integer; //004902B0
begin
Result := (m_nHomeX - 4) + Random(9);
end;
function TUserCastle.GetHomeY: Integer; //004902D8
begin
Result := (m_nHomeY - 4) + Random(9);
end;
function TUserCastle.GetMapName: string; //00490290
begin
Result := m_sMapName;
end;
function TUserCastle.CheckInPalace(nX, nY: Integer; Cert: TBaseObject): Boolean;
//490300
var
ObjUnit : pTObjUnit;
begin
Result := IsMasterGuild(TGUild(Cert.m_MyGuild));
if Result then
exit;
ObjUnit := @m_LeftWall;
if (ObjUnit.BaseObject <> nil) and
(ObjUnit.BaseObject.m_boDeath) and
(ObjUnit.BaseObject.m_nCurrX = nX) and
(ObjUnit.BaseObject.m_nCurrY = nY) then
begin
Result := True;
end;
ObjUnit := @m_CenterWall;
if (ObjUnit.BaseObject <> nil) and
(ObjUnit.BaseObject.m_boDeath) and
(ObjUnit.BaseObject.m_nCurrX = nX) and
(ObjUnit.BaseObject.m_nCurrY = nY) then
begin
Result := True;
end;
ObjUnit := @m_RightWall;
if (ObjUnit.BaseObject <> nil) and
(ObjUnit.BaseObject.m_boDeath) and
(ObjUnit.BaseObject.m_nCurrX = nX) and
(ObjUnit.BaseObject.m_nCurrY = nY) then
begin
Result := True;
end;
end;
function TUserCastle.GetWarDate: string; //00490D7C
var
AttackerInfo : pTAttackerInfo;
Year : Word;
Month : Word;
Day : Word;
resourcestring
sMsg = '%d年%d月%d日';
begin
Result := '';
if m_AttackWarList.Count <= 0 then
exit;
if WarDateIndex < 0 then
WarDateIndex := 0;
AttackerInfo := m_AttackWarList.Items[WarDateIndex];
DecodeDate(AttackerInfo.AttackDate, Year, Month, Day);
Result := format(sMsg, [Year, Month, Day]);
WarDateIndex := 0;
end;
function TUserCastle.GetAttackWarList: string; //00490E68
var
i, n10 : Integer;
AttackerInfo : pTAttackerInfo;
Year, Month, Day : Word;
wYear, wMonth, wDay : Word;
s20 : string;
begin
Result := '';
wYear := 0;
wMonth := 0;
wDay := 0;
n10 := 0;
for i := 0 to m_AttackWarList.Count - 1 do
begin
AttackerInfo := m_AttackWarList.Items[i];
DecodeDate(AttackerInfo.AttackDate, Year, Month, Day);
if (Year <> wYear) or (Month <> wMonth) or (Day <> wDay) then
begin
wYear := Year;
wMonth := Month;
wDay := Day;
if Result <> '' then
Result := Result + '\';
Result := Result + IntToStr(wYear) + '年' + IntToStr(wMonth) + '月' +
IntToStr(wDay) + '日\';
n10 := 0;
end;
if n10 > 40 then
begin
Result := Result + '\';
n10 := 0;
end;
s20 := '"' + AttackerInfo.sGuildName + '"';
Inc(n10, length(s20));
Result := Result + s20;
end; // for
end;
procedure TUserCastle.IncRateGold(Tariff,ReBate,nGold: Integer); //004904C4
var
nInGold : Integer;
begin
if ReBate>0 then
nInGold:=Round(nInGold/g_Config.REBATE[ReBate]*100);
nInGold := ROUND(ngold-nGold /(g_Config.Tariff[Tariff]+100)*100) ;
if (m_nTodayIncome + nInGold) <= g_Config.nCastleOneDayGold then
begin
Inc(m_nTodayIncome, nInGold);
end
else
begin
if m_nTodayIncome >= g_Config.nCastleOneDayGold then
begin
nInGold := 0;
end
else
begin
nInGold := g_Config.nCastleOneDayGold - m_nTodayIncome;
m_nTodayIncome := g_Config.nCastleOneDayGold;
end;
end;
if nInGold > 0 then
begin
if (m_nTotalGold + nInGold) < g_Config.nCastleGoldMax then
begin
Inc(m_nTotalGold, nInGold);
end
else
begin
m_nTotalGold := g_Config.nCastleGoldMax;
end;
end;
if (GetTickCount - m_dwSaveTick) > 10 * 60 * 1000 then
begin
m_dwSaveTick := GetTickCount();
if g_boGameLogGold then
AddGameDataLog('23' + #9 +
'0' + #9 +
'0' + #9 +
'0' + #9 +
'autosave' + #9 +
sSTRING_GOLDNAME + #9 +
IntToStr(m_nTotalGold) + #9 +
'1' + #9 +
'0');
end;
end;
function TUserCastle.WithDrawalGolds(PlayObject: TPlayObject; nGold: Integer):
Integer; //0049066C
begin
Result := -1;
if nGold <= 0 then
begin
Result := -4;
exit;
end;
if (m_MasterGuild = PlayObject.m_MyGuild) and (PlayObject.m_nGuildRankNo = 1)
and (nGold > 0) then
begin
if (nGold > 0) and (nGold <= m_nTotalGold) then
begin
if (PlayObject.m_nGold + nGold) <= PlayObject.m_nGoldMax then
begin
Dec(m_nTotalGold, nGold);
PlayObject.IncGold(nGold);
//004907C8
if g_boGameLogGold then
AddGameDataLog('22' + #9 +
PlayObject.m_sMapName + #9 +
IntToStr(PlayObject.m_nCurrX) + #9 +
IntToStr(PlayObject.m_nCurrY) + #9 +
PlayObject.m_sCharName + #9 +
sSTRING_GOLDNAME + #9 +
IntToStr(nGold) + #9 +
'1' + #9 +
'0');
PlayObject.GoldChanged;
Result := 1;
end
else
Result := -3;
end
else
Result := -2;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -