📄 castle.pas
字号:
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:TList;
PlayObject:TPlayObject;
begin
Result:=False;
if (GetTickCount - m_dwStartCastleWarTick) > g_Config.dwGetCastleTime{10 * 60 * 1000} then begin
List14:=TList.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 (PlayObject.m_MyGuild <> Guild) then begin
Result:=False;
break;
end;
end;
List14.Free;
end;
end;
procedure TUserCastle.GetCastle(Guild: TGuild);//00491290
var
OldGuild:TGuild;
s10:String;
ResourceString
sGetCastleMsg = '[%s 已被 %s 占领]';
begin
OldGuild:=m_MasterGuild;
m_MasterGuild:=Guild;
m_sOwnGuild:=Guild.sGuildName;
m_ChangeDate:=Now();
SaveConfigFile();
if OldGuild <> nil then OldGuild.RefMemberName;
if m_MasterGuild <> nil then m_MasterGuild.RefMemberName;
s10:=format(sGetCastleMsg,[m_sName,m_sOwnGuild]);
UserEngine.SendBroadCastMsgExt(s10,t_System);
UserEngine.SendServerGroupMsg(SS_204,nServerIndex,s10);
MainOutMessage(s10);
end;
procedure TUserCastle.StartWallconquestWar;//00491074
var
ListC:TList;
I:Integer;
PlayObject:TPlayObject;
begin
ListC:=TList.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 :TList;
PlayObject :TPlayObject;
s14 :String;
ResourceString
sWallWarStop = '[%s 攻城战已经结束]';
begin
m_boUnderWar:=False;
m_AttackGuildList.Clear;
ListC:=TList.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;
AttackerInfo:=m_AttackWarList.Items[0];
DecodeDate(AttackerInfo.AttackDate,Year,Month,Day);
Result:=format(sMsg,[Year,Month,Day]);
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(nGold: Integer); //004904C4
var
nInGold:Integer;
begin
nInGold:=ROUND(nGold * (g_Config.nCastleTaxRate / 100){0.05});
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;
end;
function TUserCastle.ReceiptGolds(PlayObject:TPlayObject;nGold: Integer): Integer;//00490864
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 <= PlayObject.m_nGold) then begin
if (m_nTotalGold + nGold) <= g_Config.nCastleGoldMax then begin
Dec(PlayObject.m_nGold,nGold);
Inc(m_nTotalGold,nGold);
if g_boGameLogGold then
AddGameDataLog('23' + #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;
end;
procedure TUserCastle.MainDoorControl(boClose:Boolean);//00490460
begin
if (m_MainDoor.BaseObject <> nil) and not m_MainDoor.BaseObject.m_boGhost then begin
if boClose then begin
if TCastleDoor(m_MainDoor.BaseObject).m_boOpened then TCastleDoor(m_MainDoor.BaseObject).Close;
end else begin
if not TCastleDoor(m_MainDoor.BaseObject).m_boOpened then TCastleDoor(m_MainDoor.BaseObject).Open;
end;
end;
end;
function TUserCastle.RepairDoor():Boolean;//00490A70
var
CastleDoor:pTObjUnit;
begin
Result:=False;
CastleDoor:=@m_MainDoor;
if (CastleDoor.BaseObject = nil) or
(m_boUnderWar) or
(CastleDoor.BaseObject.m_WAbil.HP >= CastleDoor.BaseObject.m_WAbil.MaxHP) then begin
exit;
end;
if not CastleDoor.BaseObject.m_boDeath then begin
if (GetTickCount - CastleDoor.BaseObject.m_dwStruckTick) > 60 * 1000 then begin
CastleDoor.BaseObject.m_WAbil.HP:=CastleDoor.BaseObject.m_WAbil.MaxHP;
TCastleDoor(CastleDoor.BaseObject).RefStatus();
Result:=True;
end;
end else begin
if (GetTickCount - CastleDoor.BaseObject.m_dwStruckTick) > 60 * 1000 then begin
CastleDoor.BaseObject.m_WAbil.HP:=CastleDoor.BaseObject.m_WAbil.MaxHP;
CastleDoor.BaseObject.m_boDeath:=False;
TCastleDoor(CastleDoor.BaseObject).m_boOpened:=False;
TCastleDoor(CastleDoor.BaseObject).RefStatus();
Result:=True;
end;
end;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -