传奇猫  --    ≧◠‿●‿◠≦   --  做一个安静的传奇平台

全部分类
全部分类

战神引擎常用脚本接口


GowLom2战神引擎常用脚本接口




给物品:




This_Player.Give('屠龙',2);




***给物品前务必判断包裹中是否有足够的空间,否则将不能给予物品,但相应货币或者材料将会正常扣除***




空包裹:




This_Player.FreeBagNum




如要给玩家2个屠龙,屠龙不可堆叠,所以至少需要两个包裹空位:




ifThis_Player.FreeBagNum>=2then




This_Player.Give('屠龙',2);




包裹中物品数量:




This_Player.GetBagItemCount('物品')




扣除物品




This_Player.Take('屠龙',2');




***扣除物品前物品判断包裹中是否有足够的物品,切记在扣除的方法中判断***




ifThis_Player.GetBagItemCount('屠龙')>=2then




This_Player.Take('屠龙',2');








随机数:




random(x)返回值为0到x-1中的随机一个整数数




比如random(10)返回值为0-9中随机一个整数




*综合以上常用接口,活动为使用100个金刚石可抽取随机一个武器,1%的概率抽取屠龙档武器19%怒斩档80%裁决




procedure_getRdmWP;




varRdm_int:integer;




WpName:string;




begin




Rdm_int:=random(100);//获取随机数,随机数为0-99中随机一个数字








ifThis_Player.GetBagItemCount('金刚石')>=100then//查看包裹中是否有足够的金刚石




begin




ifThis_Player.FreeBagNum>=1then//查看是否有足够的包裹空间




begin




ifRdm_int<1then//随机到0的概率为1%




begin




caserandom(3)of




0:WpName:='屠龙';




1:WpName:='嗜魂法杖';




2:WpName:='逍遥扇';




end;




endelseifRdm_int<20then//随机到1-19的概率为19%




begin




caserandom(3)of




0:WpName:='怒斩';




1:WpName:='龙牙';




2:WpName:='龙纹剑';




end;




endelseifRdm_int<100then//随机到20-99的概率为80%




begin




caserandom(3)of




0:WpName:='裁决之杖';




1:WpName:='骨玉权杖';




2:WpName:='无极棍';




end;




end;








This_Player.Take('金刚石',100);




This_Player.Give(WpName,1);




This_NPC.NpcDialog(This_Player,




WpName+'已放入您的包裹!\|'




+'{cmd}<继续使用100个金刚石抽取武器/@getRdmWP>');




endelse




This_NPC.NpcDialog(This_Player,




'没有足够的包裹空间!\|'




+'{cmd}<返回/@main>');




endelse




This_NPC.NpcDialog(This_Player,




'没有足够的金刚石,不可抽取\|'




+'{cmd}<返回/@main>');




end;








begin//脚本入口使用<返回/@main>可跳转到此处




This_NPC.NpcDialog(This_Player,




'巴拉巴拉巴拉一堆废话\|'




+'{cmd}<100金刚石抽取武器/@getRdmWP>');




end.








获取时间:




GetYear:返回当前年份




GetMonth:返回当前月份




GetDay:返回当前日期




GetDayOfWeek:返回星期几




GetHour:返回当前小时数




GetMin:返回当前分钟数




GetNow():获取当前时间浮点数,返回值为double




GetDateNum(datatime:double)返回值为datatime所对应的数字




如2019年1月1日使用GetDateNum(GetNow)返回值为43466




查改变量:




私人变量为V,S,服务器变量为G




使用方法详见《程序变量操作指南》




增加、查询、扣除灵符:




增加:This_Player.AddLF(nType,LF_NUM);




查询:This_Player.MyLFnum




扣除:This_Player.DecLF(nType,LF_NUM,false);




LF_NUM:灵符数量




nType:编号,一般为0




***扣除前务必查询是否有足够的灵符***




增加、查询、扣除金币:




增加:This_Player.AddGold(GoldNum);




查询:This_Player.GoldNum




扣除:This_Player.DecGold(GoldNum);




GoldNum:金币数量




***扣除前务必查询是否有足够的金币***




增加、查询、扣除声望:




查询:This_Player.MyShengwan




声望的增加和扣除直接赋值即可




如扣除10点声望




ifThis_Player.MyShengwan>=10then




This_Player.MyShengwan:=This_Player.MyShengwan-10;




增加10点声望




This_Player.MyShengwan:=This_Player.MyShengwan+10;




***扣除前务必查询是否有足够的声望***




元宝购买:




This_Player.PsYBConsum(This_NPC,'回调函数名称',交易编号,元宝数量,购买个数);




交易编号为大于20000的整数,建议每次活动使用不同的编号,方便后期统计使用




回调函数必须返回boolean值,回调函数名称及逻辑都需自定义编写,请参照下面例子中的functionYB_NewComeBag(price,num:Integer):boolean;




***调用该接口时请判断好前置条件,该接口一经调用先扣除元宝,再执行回调函数***




如:2018年10月1日至7日每天12:00-19:00可使用2元宝或2灵符随机抽奖(优先扣除灵符),奖励为5灵符(9%)、10声望(20%)、10000经验(40%)、10万金币(30%)、2个金条(1%)












proceduregiveYBprz();//灵符和元宝抽取奖励完全一样,自定义一个方法,方便调用,*****自定义方法内容需要写在调用之前*****




varrmd:integer;




itemStr:string;




begin








rmd:=random(100);




ifrmd<9then




begin




This_Player.AddLF(0,5);




itemStr:='5灵符';




endelseifrmd<29then




begin




This_Player.MyShengwan:=This_Player.MyShengwan+10;




itemStr:='10声望';




endelseifrmd<69then




begin




This_Player.Give('经验',10000);




itemStr:='1万经验';




endelseifrmd<99then




begin




This_Player.AddGold(100000);




itemStr:='10万金币';




endelse




begin




This_Player.Give('金条',2);




itemStr:='2个金条';




This_NPC.NpcNotice('恭喜“'+This_Player.Name+'”参加两元宝抽奖时获得了'+itemStr+'!!!');//系统公告红字,全服可见




end;




This_Npc.NpcDialog(This_Player,




'你获得了:'+itemStr+'\|'+




'{cmd}<继续使用2元宝抽奖/@RdmYBPrz>'




);




end;




procedure_RdmYBPrz;




begin




if(GetYear=2018)and(GetMonth=10)and(GetDay>=1)and(GetDay<=7)then




begin




if(GetHour>=12)and(GetHour<19)then//注意结束时间,19:00:00-19:59:59GetHour均返回19




begin




ifThis_Player.FreeBagNum>=2then




begin




ifThis_Player.MyLFnum>=2then//优先使用灵符,灵符足够直接扣除灵符并给与奖励




begin




This_Player.DecLF(0,2,false);




giveYBprz();//直接调用给奖励方法*****自定义方法内容需要写在调用之前*****




endelse//灵符不足则使用元宝




This_Player.PsYBConsum(This_NPC,'YB_NewComeBag',20001,2,1);//YB_NewComeBag为自定义回调函数名称,20001为扣除编号,方便统计,2为元宝数量,1为个数(一般使用1即可)




本帖隐藏的内容




endelse




This_NPC.NpcDialog(This_Player,'包裹空间不足,请整理后再来抽取奖励!');




endelse




This_NPC.NpcDialog(This_Player,'每日抽奖时间为12:00-19:00!');




endelse




This_NPC.NpcDialog(This_Player,'活动时间为10月1日至7日!');




end;




functionYB_NewComeBag(price,num:Integer):boolean;//YB_NewComeBag为自定义回调函数名称,其余参数为固定格式,不可以改变




begin




result:=true;




giveYBprz();//直接调用给奖励方法*****自定义方法内容需要写在调用之前*****




end;




begin




This_NPC.NpcDialog(This_Player,'巴拉巴拉巴拉巴拉废话先来一段\|'




+'{cmd}<2元宝抽奖/@RdmYBPrz>');




end.








地图刷怪检测地图怪物数量:




检测某地图指定怪物数量:This_NPC.CheckMapMonByName(mapName,monName)




检测指定地图所有怪物数量:CheckOtherMapMon(mapname);该接口不需要npc调用




指定地图刷怪:This_NPC.CreateMon(地图名,X,Y,R,怪物名称,数量);




如:This_NPC.CreateMon('D5071',20,23,10,'混沌牛魔王',1);








传送:




This_Player.Flyto(地图名,x,y);将角色传送至某地图的x、y点




This_Player.RandomFlyTo(地图名);将角色传送至某地图的随机点




如:




This_Player.Flyto('D711',200+random(3)-1,204+random(3)-1);




表示将角色传送至地图D711的200,204的3*3范围内随机点












获取角色信息:




This_Player.Name角色名称




This_Player.Gender角色性别0:男1:女




This_Player.Level角色等级




This_Player.Job角色职业0:战士1:法师2:道士












行会相关:




This_Player.IsCastle是否为沙巴克行会




This_Player.GuildName返回行会名称,没有行会返回''




This_npc.GetCastleGuildName获取沙巴克行会行会名称












组队,for循环:








Procedure_doexit;




begin




This_Npc.CloseDialog(This_Player);




end;




procedure_SP_Wealth_5_1;




begin




This_NPC.NpcDialog(This_Player,




'<财神宝库一/@SP_Wealth_5_1_1><财神宝库二/@SP_Wealth_5_1_2><财神宝库三/@SP_Wealth_5_1_3>'




);




end;




procedureSP_Wealth_open(roomIdx:integer);




var




Group:TBaseGroup;




MemberCount,i:Integer;




APlayer:TPlayer;




bIsstu:boolean;




s:string;




begin




ifThis_Player.MapName<>'GA0'then




Exit;




Group:=This_Player.MyGroup;




ifGroup=nilthen




begin




This_NPC.NpcDialog(This_Player,




'财神宝库需要组队才能进入。');




exit;




end








ifnotThis_Player.IsGroupOwnerthen




begin




This_Npc.NpcDialog(This_Player,




'您不是所在队伍的队长,不能进入。'




);




Exit;




end;








ifThis_Player.Level<35then




begin




This_Npc.NpcDialog(This_Player,




'你的等级未到35级,不能带领大家进入宝库。'




);




Exit;




end;








if(This_Player.MyLFnum<10)then




begin




This_Npc.NpcDialog(This_Player,




'你身上携带的灵符不足10张,不能带领大家进入宝库。'




);




Exit;




end








MemberCount:=Group.GetMemberCount;




//整队飞到房间中




bIsstu:=True;




fori:=0toMemberCount-1do




begin




APlayer:=TPlayer(Group.GetMember(i));




ifAPlayer<>This_Playerthen




begin




ifcompareText(APlayer.MapName,'GA0')<>0then




begin




s:='你队伍里'+APlayer.Name+'不在庄园,不能进入。\';




bIsstu:=false;




break;




end;




end;




end;








ifbIsstu=falsethen




begin




This_NPC.NpcDialog(This_Player,s);




exit;




end




else




begin




This_Player.DecLF(30018,10,false);




This_Player.CallOut(This_NPC,1800,'callOutFlyBack');




fori:=0toMemberCount-1do




begin




APlayer:=TPlayer(Group.GetMember(i));




ifAPlayer<>This_Playerthen




begin




ifcompareText(APlayer.MapName,'GA0')=0then




begin




APlayer.CallOut(This_NPC,1800,'callOutFlyBack');//1800秒后执行传出房间的函数




end;




end;




end;








caseroomIdxof




1:This_Player.GroupFly('D5074~04');




2:This_Player.GroupFly('D5074~02');




3:This_Player.GroupFly('D5074~03');




end;




end;








end;




procedurecallOutFlyBack;//传出房间的函数,判断是否在活动地图,如果在活动地图,传送回庄园




begin




if(CompareText(This_Player.MapName,'D5074~04')=0)or(CompareText(This_Player.MapName,'D5074~02')=0)




or(CompareText(This_Player.MapName,'D5074~03')=0)then








This_Player.RandomFlyTo('GA0');




end;




procedure_SP_Wealth_5_1_1;




begin




SP_Wealth_open(1);




end;




procedure_SP_Wealth_5_1_2;




begin




SP_Wealth_open(2);




end;




procedure_SP_Wealth_5_1_3;




begin




SP_Wealth_open(3);




end;




begin




This_NPC.NpcDialog(This_Player,




'宝库中每过一段时间出现守卫,击败守卫掉落大量珍贵道具,\'




+'还可能出现传说中的“夕兽”,记得要带够足量的“爆竹”哦。\'




+'进入条件:35级玩家为队长,由35级玩家消耗10张灵符,\'




+'带领小队进入,进入后,你的小队有30分钟探宝时间。\\'




+'<财神宝库一/@SP_Wealth_5_1_1><财神宝库二/@SP_Wealth_5_1_2><财神宝库三/@SP_Wealth_5_1_3>'




);




end.


展开 收缩

在线客服

微信客服

微信扫码咨询

用户中心
我的足迹
我的收藏
0 种商品 共计: ¥0.00

您的购物车还是空的,您可以

  • 微信公众号

    微信公众号
返回顶部