📄 objnpc.pas
字号:
PlayObject.SendMsg(Self, RM_MENU_OK, 0, Integer(Self), 0, 0, s18);
end;
end;
except
MainOutMessage(sExceptionMsg);
end;
// inherited;
end;
procedure TCastleOfficial.HireGuard(sIndex: string; PlayObject: TPlayObject); //004A413C
var
n10: Integer;
ObjUnit: pTObjUnit;
begin
if m_Castle = nil then
begin
PlayObject.SysMsg('NPC不属于城堡!!!', c_Red, t_Hint);
Exit;
end;
if TUserCastle(m_Castle).m_nTotalGold >= g_Config.nHireGuardPrice then
begin
n10 := Str_ToInt(sIndex, 0) - 1;
if n10 <= MAXCALSTEGUARD then
begin
if TUserCastle(m_Castle).m_Guard[n10].BaseObject = nil then
begin
if not TUserCastle(m_Castle).m_boUnderWar then
begin
ObjUnit := @TUserCastle(m_Castle).m_Guard[n10];
ObjUnit.BaseObject := UserEngine.RegenMonsterByName(TUserCastle(m_Castle).m_sMapName,
ObjUnit.nX,
ObjUnit.nY,
ObjUnit.sName);
if ObjUnit.BaseObject <> nil then
begin
Dec(TUserCastle(m_Castle).m_nTotalGold, g_Config.nHireGuardPrice);
ObjUnit.BaseObject.m_Castle := TUserCastle(m_Castle);
TGuardUnit(ObjUnit.BaseObject).m_nX550 := ObjUnit.nX;
TGuardUnit(ObjUnit.BaseObject).m_nY554 := ObjUnit.nY;
TGuardUnit(ObjUnit.BaseObject).m_nDirection := 3;
PlayObject.SysMsg('雇佣成功.', c_Green, t_Hint);
end;
end else
begin
PlayObject.SysMsg('现在无法雇佣!!!', c_Red, t_Hint);
end;
end else
begin
PlayObject.SysMsg('早已雇佣!!!', c_Red, t_Hint);
end;
end else
begin
PlayObject.SysMsg('指令错误!!!', c_Red, t_Hint);
end;
end else
begin
PlayObject.SysMsg('城内资金不足!!!', c_Red, t_Hint);
end;
{
if UserCastle.m_nTotalGold >= g_Config.nHireGuardPrice then begin
n10:=Str_ToInt(sIndex,0) - 1;
if n10 <= MAXCALSTEGUARD then begin
if UserCastle.m_Guard[n10].BaseObject = nil then begin
if not UserCastle.m_boUnderWar then begin
ObjUnit:=@UserCastle.m_Guard[n10];
ObjUnit.BaseObject:=UserEngine.RegenMonsterByName(UserCastle.m_sMapName,
ObjUnit.nX,
ObjUnit.nY,
ObjUnit.sName);
if ObjUnit.BaseObject <> nil then begin
Dec(UserCastle.m_nTotalGold,g_Config.nHireGuardPrice);
ObjUnit.BaseObject.m_Castle:=UserCastle;
TGuardUnit(ObjUnit.BaseObject).m_nX550:=ObjUnit.nX;
TGuardUnit(ObjUnit.BaseObject).m_nY554:=ObjUnit.nY;
TGuardUnit(ObjUnit.BaseObject).m_n558:=3;
PlayObject.SysMsg('雇佣成功.',c_Green,t_Hint);
end;
end else begin
PlayObject.SysMsg('现在无法雇佣!!!',c_Red,t_Hint);
end;
end
end else begin
PlayObject.SysMsg('指令错误!!!',c_Red,t_Hint);
end;
end else begin
PlayObject.SysMsg('城内资金不足!!!',c_Red,t_Hint);
end;
}
end;
procedure TCastleOfficial.HireArcher(sIndex: string; PlayObject: TPlayObject); //004A433C
var
n10: Integer;
ObjUnit: pTObjUnit;
begin
if m_Castle = nil then
begin
PlayObject.SysMsg('NPC不属于城堡!!!', c_Red, t_Hint);
Exit;
end;
if TUserCastle(m_Castle).m_nTotalGold >= g_Config.nHireArcherPrice then
begin
n10 := Str_ToInt(sIndex, 0) - 1;
if n10 <= MAXCASTLEARCHER then
begin
if TUserCastle(m_Castle).m_Archer[n10].BaseObject = nil then
begin
if not TUserCastle(m_Castle).m_boUnderWar then
begin
ObjUnit := @TUserCastle(m_Castle).m_Archer[n10];
ObjUnit.BaseObject := UserEngine.RegenMonsterByName(TUserCastle(m_Castle).m_sMapName,
ObjUnit.nX,
ObjUnit.nY,
ObjUnit.sName);
if ObjUnit.BaseObject <> nil then
begin
Dec(TUserCastle(m_Castle).m_nTotalGold, g_Config.nHireArcherPrice);
ObjUnit.BaseObject.m_Castle := TUserCastle(m_Castle);
TGuardUnit(ObjUnit.BaseObject).m_nX550 := ObjUnit.nX;
TGuardUnit(ObjUnit.BaseObject).m_nY554 := ObjUnit.nY;
TGuardUnit(ObjUnit.BaseObject).m_nDirection := 3;
PlayObject.SysMsg('雇佣成功...', c_Green, t_Hint);
end;
end else
begin
PlayObject.SysMsg('现在无法雇佣!!!', c_Red, t_Hint);
end;
end else
begin
PlayObject.SysMsg('早已雇佣!!!', c_Red, t_Hint);
end;
end else
begin
PlayObject.SysMsg('指令错误!!!', c_Red, t_Hint);
end;
end else
begin
PlayObject.SysMsg('城内资金不足!!!', c_Red, t_Hint);
end;
{
if UserCastle.m_nTotalGold >= g_Config.nHireArcherPrice then begin
n10:=Str_ToInt(sIndex,0) - 1;
if n10 <= MAXCASTLEARCHER then begin
if UserCastle.m_Archer[n10].BaseObject = nil then begin
if not UserCastle.m_boUnderWar then begin
ObjUnit:=@UserCastle.m_Archer[n10];
ObjUnit.BaseObject:=UserEngine.RegenMonsterByName(UserCastle.m_sMapName,
ObjUnit.nX,
ObjUnit.nY,
ObjUnit.sName);
if ObjUnit.BaseObject <> nil then begin
Dec(UserCastle.m_nTotalGold,g_Config.nHireArcherPrice);
ObjUnit.BaseObject.m_Castle:=UserCastle;
TGuardUnit(ObjUnit.BaseObject).m_nX550:=ObjUnit.nX;
TGuardUnit(ObjUnit.BaseObject).m_nY554:=ObjUnit.nY;
TGuardUnit(ObjUnit.BaseObject).m_n558:=3;
PlayObject.SysMsg('雇佣成功.',c_Green,t_Hint);
end;
end else begin
PlayObject.SysMsg('现在无法雇佣!!!',c_Red,t_Hint);
end;
end else begin
PlayObject.SysMsg('早已雇佣!!!',c_Red,t_Hint);
end;
end else begin
PlayObject.SysMsg('指令错误!!!',c_Red,t_Hint);
end;
end else begin
PlayObject.SysMsg('城内资金不足!!!',c_Red,t_Hint);
end;
}
end;
{ TMerchant }
procedure TMerchant.AddItemPrice(nIndex: Integer; nPrice: Integer); //0049F2AC
var
ItemPrice: pTItemPrice;
begin
New(ItemPrice);
ItemPrice.wIndex := nIndex;
ItemPrice.nPrice := nPrice;
m_ItemPriceList.Add(ItemPrice);
FrmDB.SaveGoodPriceRecord(Self, m_sScript + '-' + m_sMapName);
end;
procedure TMerchant.CheckItemPrice(nIndex: Integer); //0049F1BC
var
i: Integer;
ItemPrice: pTItemPrice;
n10: Integer;
StdItem: TItem;
begin
for i := 0 to m_ItemPriceList.Count - 1 do
begin
ItemPrice := m_ItemPriceList.Items[i];
if ItemPrice.wIndex = nIndex then
begin
n10 := ItemPrice.nPrice;
if Round(n10 * 1.1) > n10 then
begin
n10 := Round(n10 * 1.1);
end else Inc(n10);
Exit;
end;
end;
StdItem := UserEngine.GetStdItem(nIndex);
if StdItem <> nil then
begin
AddItemPrice(nIndex, Round(StdItem.Price * 1.1));
end;
end;
function TMerchant.GetRefillList(nIndex: Integer): TList; //0049F118
var
i: Integer;
List: TList;
begin
Result := nil;
if nIndex <= 0 then Exit;
for i := 0 to m_GoodsList.Count - 1 do
begin
List := TList(m_GoodsList.Items[i]);
if List.Count > 0 then
begin
if pTUserItem(List.Items[0]).wIndex = nIndex then
begin
Result := List;
Break;
end;
end;
end;
end;
procedure TMerchant.RefillGoods; //0049F950
procedure RefillItems(var List: TList; sItemName: string; nInt: Integer); //0049F824
var
i: Integer;
UserItem: pTUserItem;
begin
if List = nil then
begin
List := TList.Create;
m_GoodsList.Add(List);
end;
for i := 0 to nInt - 1 do
begin
New(UserItem);
if UserEngine.CopyToUserItemFromName(sItemName, UserItem) then
begin
List.Insert(0, UserItem);
end else Dispose(UserItem);
end;
end;
procedure DelReFillItem(var List: TList; nInt: Integer); //0049F8F8
var
i: Integer;
begin
for i := List.Count - 1 downto 0 do
begin
if nInt <= 0 then Break;
Dispose(pTUserItem(List.Items[i]));
List.Delete(i);
Dec(nInt);
end;
end;
var
i, ii: Integer;
Goods: pTGoods;
nIndex, nRefillCount: Integer;
RefillList, RefillList20: TList;
bo21: Boolean;
resourcestring
sExceptionMsg = '[Exception] TMerchant::RefillGoods %s/%d:%d [%s] Code:%d';
begin //0049F950
try
for i := 0 to m_RefillGoodsList.Count - 1 do
begin
Goods := m_RefillGoodsList.Items[i];
if (GetTickCount - Goods.dwRefillTick) > Goods.dwRefillTime * 60 * 1000 then
begin
Goods.dwRefillTick := GetTickCount();
nIndex := UserEngine.GetStdItemIdx(Goods.sItemName);
if nIndex >= 0 then
begin
// memo.Lines.Add('test');
RefillList := GetRefillList(nIndex);
nRefillCount := 0;
if RefillList <> nil then nRefillCount := RefillList.Count;
if Goods.nCount > nRefillCount then
begin
CheckItemPrice(nIndex);
RefillItems(RefillList, Goods.sItemName, Goods.nCount - nRefillCount);
FrmDB.SaveGoodRecord(Self, m_sScript + '-' + m_sMapName);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -