- 精华
- 阅读权限
- 180
- 好友
- 相册
- 分享
- 听众
- 收听
- 注册时间
- 2008-11-1
- 在线时间
- 小时
- 最后登录
- 1970-1-1
|
[77M2] 传奇引擎 废旧物品回收(特殊物品) 脚本
给会使用的朋友. 我不做任何解答. 77M2上手难度++++++
引擎的链接具体大家可以搜索一下 就不发类似广告的链接了.
unit Q39;
{
本单元里面的NPC都是怪物NPC
}
interface
uses Classes, SysUtils, G_RankNameUnit, G_AddAbility, g_Nation, DefiniensConst;
procedure Main(Npc: TActor; Player: TPlayObject; Args: TArgs);
procedure ViewNation(Npc: TActor; Player: TPlayObject; Args: TArgs);
procedure ViewLvlInfo(Npc: TActor; Player: TPlayObject; Args: TArgs);
procedure Recover(Npc: TActor; Player: TPlayObject; Args: TArgs);
procedure FastRecover(Npc: TActor; Player: TPlayObject; Args: TArgs); //一键回收
procedure ViewInfo(Npc: TActor; Player: TPlayObject; Args: TArgs); //查看可用的回收信息
procedure InputInteger001(Npc: TActor; Player: TPlayObject; Args: TArgs);
procedure GoHome(Npc: TActor; Player: TPlayObject; Args: TArgs);
procedure LeaveNation(Npc: TActor; Player: TPlayObject; Args: TArgs);
implementation
var
NameList,
PointList: TStrings;
procedure Main(Npc: TActor; Player: TPlayObject; Args: TArgs);
const
S=
[[
年轻人,为了帝国的强大,你们要不断的努力啊。不断的给帝国\
提供军需才是强大帝国军队的唯一办法!!!\\
<查看国家信息/@ViewNation>\
<{S=捐献资金(金币);C=253;CH=249}/@@InputInteger001(请输入你要捐献的金额:)>\
<回收装备/@Recover>\
<我要离开国家/@@Question(离开国家将丢失所有的荣誉点数,确定执行吗?,@LeaveNation)>\
<送我回盟重/@GoHome>\
<离开/@exit>
]];
begin
Player.Say(S);
end;
procedure ViewNation(Npc: TActor; Player: TPlayObject; Args: TArgs);
const
S=
[[
{S=国家资金总数:;C=243}{S=$NationGold$;C=250}\
{S=国家声望值:;C=243}{S=$NationCredit$;C=250}\
{S=国家等级:;C=243}{S=$NationLevel$;C=250} <[查看等级信息]/@ViewLvlInfo>\
{S=国家增加经验值加成:;C=243}{S=$NationExpAdd$%;C=250}\\
{S=我的荣誉点数:;C=243}{S=$RankPoit$;C=250}\
{S=我的荣誉称号:;C=243}{S=$RandkName$;C=250}\\
<返回/@main>
]];
var
Message: String;
begin
Message := '';
case Player.Nation of
NATION_DAHAN: //汉
begin
Message := ReplaceStr(S, '$NationGold$', Gamelib.G[_G_NATION_DH_GOLD]);
Message := ReplaceStr(Message, '$NationCredit$', Gamelib.G[_G_NATION_DH_CREDIT]);
Message := ReplaceStr(Message, '$NationLevel$', GetNationCreditLevel(Gamelib.G[_G_NATION_DH_CREDIT]));
Message := ReplaceStr(Message, '$NationExpAdd$', GetNationAddExp(Gamelib.G[_G_NATION_DH_CREDIT]));
Message := ReplaceStr(Message, '$RankPoit$', Player.N[_P_NATIONRANK]);
Message := ReplaceStr(Message, '$RandkName$', GetNationRank(Player, False));
end;
NATION_XICHU: //楚
begin
Message := ReplaceStr(S, '$NationGold$', Gamelib.G[_G_NATION_XC_GOLD]);
Message := ReplaceStr(Message, '$NationCredit$', Gamelib.G[_G_NATION_XC_CREDIT]);
Message := ReplaceStr(Message, '$NationLevel$', GetNationCreditLevel(Gamelib.G[_G_NATION_XC_CREDIT]));
Message := ReplaceStr(Message, '$NationExpAdd$', GetNationAddExp(Gamelib.G[_G_NATION_XC_CREDIT]));
Message := ReplaceStr(Message, '$RankPoit$', Player.N[_P_NATIONRANK]);
Message := ReplaceStr(Message, '$RandkName$', GetNationRank(Player, False));
end;
end;
Player.Say(Message);
end;
procedure ViewLvlInfo(Npc: TActor; Player: TPlayObject; Args: TArgs);
const
S=
[[
{S=国家等级信息;C=243}\
-----------------------------------------------------------\
等级 需要国家声望 国民经验加成\
1{S=$L1Exp$;x=90}{S=$L1AddExp$%;X=260}\
2{S=$L2Exp$;x=90}{S=$L2AddExp$%;X=260}\
3{S=$L3Exp$;x=90}{S=$L3AddExp$%;X=260}\
4{S=$L4Exp$;x=90}{S=$L4AddExp$%;X=260}\
5{S=$L5Exp$;x=90}{S=$L5AddExp$%;X=260}\
6{S=$L6Exp$;x=90}{S=$L6AddExp$%;X=260}\
7{S=$L7Exp$;x=90}{S=$L7AddExp$%;X=260}\
8{S=$L8Exp$;x=90}{S=$L8AddExp$%;X=260}\
9{S=$L9Exp$;x=90}{S=$L9AddExp$%;X=260}\
10{S=$L10Exp$;x=90}{S=$L10AddExp$%;X=260}\
-----------------------------------------------------------\
<返回/@ViewNation>
]];
var
AMessage: String;
begin
AMessage := ReplaceStr(S, '$L1Exp$', NATION_LVL1_Credit);
AMessage := ReplaceStr(AMessage, '$L1AddExp$', NATION_LVL1_AddExp);
AMessage := ReplaceStr(AMessage, '$L2Exp$', NATION_LVL2_Credit);
AMessage := ReplaceStr(AMessage, '$L2AddExp$', NATION_LVL2_AddExp);
AMessage := ReplaceStr(AMessage, '$L3Exp$', NATION_LVL3_Credit);
AMessage := ReplaceStr(AMessage, '$L3AddExp$', NATION_LVL3_AddExp);
AMessage := ReplaceStr(AMessage, '$L4Exp$', NATION_LVL4_Credit);
AMessage := ReplaceStr(AMessage, '$L4AddExp$', NATION_LVL4_AddExp);
AMessage := ReplaceStr(AMessage, '$L5Exp$', NATION_LVL5_Credit);
AMessage := ReplaceStr(AMessage, '$L5AddExp$', NATION_LVL5_AddExp);
AMessage := ReplaceStr(AMessage, '$L6Exp$', NATION_LVL6_Credit);
AMessage := ReplaceStr(AMessage, '$L6AddExp$', NATION_LVL6_AddExp);
AMessage := ReplaceStr(AMessage, '$L7Exp$', NATION_LVL7_Credit);
AMessage := ReplaceStr(AMessage, '$L7AddExp$', NATION_LVL7_AddExp);
AMessage := ReplaceStr(AMessage, '$L8Exp$', NATION_LVL8_Credit);
AMessage := ReplaceStr(AMessage, '$L8AddExp$', NATION_LVL8_AddExp);
AMessage := ReplaceStr(AMessage, '$L9Exp$', NATION_LVL9_Credit);
AMessage := ReplaceStr(AMessage, '$L9AddExp$', NATION_LVL9_AddExp);
AMessage := ReplaceStr(AMessage, '$L10Exp$', NATION_LVL10_Credit);
AMessage := ReplaceStr(AMessage, '$L10AddExp$', NATION_LVL10_AddExp);
Player.SayEx('NPC大窗口', AMessage);
end;
procedure Recover(Npc: TActor; Player: TPlayObject; Args: TArgs);
const
S=
[[
你好,你想获得更多的国家奖励荣誉点吗?哪就将你不要的装备\
都拿我这里回收吧。\\
<查看可回收装备信息/@ViewInfo(0)>\
<一键回收/@@Question(你是否将不需要回收的物品存放好,确定要执行一键回收吗?,@FastRecover)>\\\\
<返回/@main>
]];
begin
Player.Say(S);
end;
procedure FastRecover(Npc: TActor; Player: TPlayObject; Args: TArgs);
var
I, Idx, APoint: Integer;
OldNationRank: String;
begin
APoint := 0;
OldNationRank := GetNationRank(Player, False); //记录回收前的称号
for I := Player.ItemSize - 1 downto 0 do //循环处理包裹物品
begin
if Player.BagItem[I] <> nil then //如果该包裹为不为空
begin
Idx := NameList.IndexOf(Player.BagItem[I].Name); //查看是否有和该物品对应的回收信息
if Idx >= 0 then
begin
APoint := StrToIntDef(PointList[Idx], 0); //取出对应的回收点
Player.N[_P_NATIONRANK] := Player.N[_P_NATIONRANK] + APoint; //累加点数
Player.SendCenterMessage(Format('回收装备【%s】,获得国家荣誉点%d', [Player.BagItem[I].DisplayName, APoint]), 0); //发送回收信息
Player.DeleteItem(Player.BagItem[I]); //删除背包物品
end;
end;
end;
//回收前后如果称号不一样了
if OldNationRank <> GetNationRank(Player, False) then
begin
SetPlayRankName(Player); //重新设置称号
G_AddAbility.AddAbility(Player); //设置额外属性
Player.RecalcAbilitys; //通知更新属性
end;
end;
procedure ViewInfo(Npc: TActor; Player: TPlayObject; Args: TArgs);
const
S=
[[
{S=【国家物品回收信息】;C=254}\
{S=物品名 荣誉点 物品名 荣誉点;C=243}\
$INFO$
<{S=第一页;Y=130}/@ViewInfo(0)> <{S=上一页;Y=130}/@ViewInfo(1,$ForwardPage$)> <{S=下一页;Y=130}/@ViewInfo(2,$NextPage$)> <{S=末尾页;Y=130}/@ViewInfo(3)> <{S=返回;Y=130}/@Recover>
]];
LINESTR = '{S=$Name$;X=$NameX$}{S=$P$;X=$PX$}';
//{S=屠龙宝刀;X=0}{S=20;X=122}{S=屠龙宝刀;X=192}{S=20;X=320}\
var
Message, InfoStr, ANodeStr: String;
nForwardPage,
nNextPage,
nPage,
I, nStart, nEnd, nIndex: Integer;
begin
nPage := Args.Int[1]; //取出当前点击的页
case Args.Int[0] of //根据类型获得当前要返回的页
0: nPage := 0;
1: nPage := nPage - 1;
2: nPage := nPage + 1;
3: nPage := NameList.Count div 12; //最大页
end;
//取出将要返回的页信息
nForwardPage := nPage - 1;
nNextPage := nPage + 1;
if nForwardPage < 0 then
nForwardPage := 0;
if nNextPage > (NameList.Count div 12) then
nNextPage := NameList.Count div 12;
if nPage < 0 then
nPage := 0;
if nPage > (NameList.Count div 12) then
nPage := NameList.Count div 12;
InfoStr := '';
nStart := nPage * 12; //要取的物品位置为 页*12
nEnd := nStart + 11; //在当前位置上+11表示一共循环12个物品
for I := nStart to nEnd do
begin
if I < NameList.Count then
begin
//如果位置没超出回收表
ANodeStr := LINESTR;
ANodeStr := ReplaceStr(ANodeStr, '$Name$', NameList[I]); //替换物品名称
ANodeStr := ReplaceStr(ANodeStr, '$P$', PointList[I]); //替换物品可兑换的荣誉点数
if I mod 2 = 0 then
begin
ANodeStr := ReplaceStr(ANodeStr, '$NameX$', '0'); //设置每行的第一个物品名称的X坐标
ANodeStr := ReplaceStr(ANodeStr, '$PX$', '122'); //设置每行的第一个物品点数的X坐标
end
else
begin
ANodeStr := ReplaceStr(ANodeStr, '$NameX$', '192'); //设置每行的第二个物品名称的X坐标
ANodeStr := ReplaceStr(ANodeStr, '$PX$', '320'); //设置每行的第二个物品点数的X坐标
ANodeStr := ANodeStr + '\';
end;
InfoStr := InfoStr + ANodeStr;
end
else
begin
//超出的话在合适的位置加换行
if I mod 2 = 1 then
InfoStr := InfoStr + '\';
end;
end;
Message := S;
Message := ReplaceStr(Message, '$INFO$', InfoStr);
Message := ReplaceStr(Message, '$ForwardPage$', nForwardPage);
Message := ReplaceStr(Message, '$NextPage$', nNextPage);
Player.Say(Message);
end;
procedure InputInteger001(Npc: TActor; Player: TPlayObject; Args: TArgs);
var
Value: Integer;
OldNationCredit,
NewNationCredit: Integer;
OldNationRk: String;
begin
//捐献金币
Value := Args.Int[0];
if Value > 0 then
begin
if Player.Gold >= Value then
begin
if Value >= 1000 then
begin
OldNationRk := GetNationRank(Player, False); //先记录捐献前的国家称号
Player.Gold := Player.Gold - Value;
Player.GoldChanged;
case Player.Nation of
NATION_DAHAN:
begin
OldNationCredit := Gamelib.G[_G_NATION_DH_CREDIT];
Gamelib.G[_G_NATION_DH_GOLD] := Gamelib.G[_G_NATION_DH_GOLD] + Value; //所属国的资金增加
Gamelib.G[_G_NATION_DH_CREDIT] := Gamelib.G[_G_NATION_DH_CREDIT] + Value div 1000;
NewNationCredit := Gamelib.G[_G_NATION_DH_CREDIT];
end;
NATION_XICHU:
begin
OldNationCredit := Gamelib.G[_G_NATION_XC_CREDIT];
Gamelib.G[_G_NATION_XC_GOLD] := Gamelib.G[_G_NATION_XC_GOLD] + Value;
Gamelib.G[_G_NATION_XC_CREDIT] := Gamelib.G[_G_NATION_XC_CREDIT] + Value div 1000;
NewNationCredit := Gamelib.G[_G_NATION_XC_CREDIT];
end;
end;
Player.N[_P_NATIONRANK] := Player.N[_P_NATIONRANK] + Value div 1000; //捐献点增加,捐献金额 / 1000取整
CheckNationLevelUp(Player.Nation, OldNationCredit, NewNationCredit); //检查国家声望等级是否提升(位于“国家相关”单元)
Main(Npc, Player, Args);
if OldNationRk <> GetNationRank(Player, False) then //如果捐献前的国家称号和捐献后的称号不一样
begin
SetPlayRankName(Player); //重设称号
AddAbility(Player); //重新设置额外属性
Player.RecalcAbilitys; //通知更新属性
end;
end
else
Player.MessageBox('捐赠数量不得低于1000!!!');
end
else
begin
case Player.Gender of
0: Player.MessageBox('帅哥有这份心是不错的,但是也得有钱才行啊!!!');
1: Player.MessageBox('美女有这份心是不错的,但是也得有钱才行啊!!!');
end;
end;
end
else
Player.MessageBox('你这是干嘛?分文不捐,想黑我吗。。。');
end;
procedure GoHome(Npc: TActor; Player: TPlayObject; Args: TArgs);
begin
Player.MapMove('3', 327, 327);
end;
procedure ReadNationRecover;
var
List: TStrings;
ALine, AName, APoint: String;
I, DotPos, nPoint: Integer;
begin
List := Gamelib.TryGetResource('国家物品回收表'); //从版本文件中查找回收表,Gamelib.TryGetResource返回的对象永远不要自己去释放
if List <> nil then //如果找到了回收表
begin
for I := 0 to List.Count - 1 do
begin
ALine := Trim(List[I]); //取出一行
if (ALine <> '') and (ALine[1] <> ';') then //如果行不为空,并且第一个字符不是“;”
begin
DotPos := Pos(',', ALine); //查找分割装备名称和回收点的“,”
if DotPos > 0 then
begin
//取出装备名称和回收点
AName := Copy(ALine, 1, DotPos - 1);
APoint := Copy(ALine, DotPos + 1, Length(ALine) - DotPos);
nPoint := StrToIntDef(APoint, -1);
//如果装备名称不为空并且回收点正确
if (AName<>'') and (nPoint > -1) then
begin
//加入到临时列表信息
NameList.Add(AName);
PointList.Add(IntToStr(nPoint));
end;
end;
end;
end;
end;
end;
procedure LeaveNation(Npc: TActor; Player: TPlayObject; Args: TArgs);
begin
Player.N[_P_NATIONRANK] := 0;
Player.Nation := 0;
Player.UpdateName;
Player.GoHome;
end;
initialization
NameList := TStringList.Create;
PointList := TStringList.Create;
ReadNationRecover; //初始化的时候就加载回收表
finalization
FreeAndNil(NameList);
FreeAndNil(PointList);
end.
记得添加 Resource
' 国家物品回收表'
;物品名字,获得捐献点数
凝霜,1
井中月,3
银蛇,2
修罗,1
炼狱,2
魔杖,2
罗刹,1
无极棍,3
洛阳铲,10
祈祷之刃,3
血饮,3
裁决之杖,10
屠龙,20
骨玉权杖,15
龙纹剑,15
嗜魂法杖,20
龙牙,20
怒斩,20
逍遥扇,25
命运之刃,15
游龙剑,25
天龙圣剑,25
倚天剑,40
|
|