魔法、攻击、武器buff都配置在 buff.json 里。配置内容如下:
攻击buff
"attack_buff": {
"buffs": {
"1": {
"buffPercent": 10,
"active_role": 0,
"style": "zm1"
},
"2": {
"buffPercent": 100,
"active_role": 0,
"style": "zm"
}
}
},
buffs:buff清单,buff编号组,这里的1、2可以自己任意命名,不一定是数字
buffPercent:触发概率,不建议设置太高
active_role:0 应用在自身 1 用到目标上
style:buff特效id,配置方法参见
buff如何激活
攻击类buff的激活方法比较简单,总体还是在服务端控制。服务端经过一定逻辑判断后,向客户端输出获得的buffs清单即可。
比如上面例子中,玩家通过活动,获得了buffid为 1、2 的buff,则在服务端向客户端下发内容:
This_Player.PlayerNotice('buffs=1,2',5);
下发成功后,玩家在发起攻击时,会根据你配置的buff,轮询按约定概率触发,但同时只能命中1个,所以不建议把当中的某个buff概率设置的太高。
客户端触发后,会自动调用服务端函数 _attackHit,此函数写在 extendUIs.pas 里。
//物理攻击buff触发
//参数说明:buffid~触发buff样式名称~锁定对象名称~锁定对象是否为人物,1表示人物 0表示怪物
procedure _attackHit(params:string);
var player:TPlayer;
buffId,buffName,playerName,isPlayer:string;
begin
buffId := GetParam(params,'~',1);
buffName := GetParam(params,'~',2);
playerName := GetParam(params,'~',3);
isPlayer := GetParam(params,'~',4);
if (playerName <> nil) and (playerName <> 'notset') and (isPlayer <> nil) and (isPlayer = '1') then
begin
player := This_Player.FindPlayerByName(playerName);
end;
if player <> nil then
begin
//此处处理玩家属性,比如增加掉血之类。。
end;
This_Player.PlayerNotice('物理攻击buff触发',5);
end;
魔法buff
"skill_buff": {
"11": { //这是技能id
"buffs": {
"3": {
"buffPercent": 100,
"active_role": 0,
"style": "zm"
}
}
}
},
与攻击buff不同的是,魔法buff需要配置 魔法技能id,并且只有当玩家学习了对应魔法,并且所配置的buff特效id也在本地激活后,才能被触发。
客户端触发后,会自动调用服务端函数 _magicHit,此函数写在 extendUIs.pas 里。
//魔法技能buff触发
//参数说明:buffid~触发buff样式名称~锁定对象名称~锁定对象是否为人物,1表示人物 0表示怪物
procedure _magicHit(params:string);
var player:TPlayer;
buffId,buffName,playerName,isPlayer:string;
begin
buffId := GetParam(params,'~',1);
buffName := GetParam(params,'~',2);
playerName := GetParam(params,'~',3);
isPlayer := GetParam(params,'~',4);
if (playerName <> nil) and (playerName <> 'notset') and (isPlayer <> nil) and (isPlayer = '1') then
begin
player := This_Player.FindPlayerByName(playerName);
end;
if player <> nil then
begin
//此处处理玩家属性
end;
This_Player.PlayerNotice('魔法技能buff触发',5);
end;
武器buff
点此查看武器铭文介绍
成功镶嵌铭文的武器,在攻击时会自动触发配置好的buff,并按配置参数概率触发。
客户端触发后,会自动调用服务端函数 _weaponHit,此函数写在 extendUIs.pas 里。
//武器buff触发
//参数说明:buffid~触发buff样式名称~锁定对象名称~锁定对象是否为人物,1表示人物 0表示怪物
procedure _weaponHit(params:string);
var player:TPlayer;
buffId,buffName,playerName,isPlayer:string;
begin
buffId := GetParam(params,'~',1);
buffName := GetParam(params,'~',2);
playerName := GetParam(params,'~',3);
isPlayer := GetParam(params,'~',4);
if (playerName <> nil) and (playerName <> 'notset') and (isPlayer <> nil) and (isPlayer = '1') then
begin
player := This_Player.FindPlayerByName(playerName);
end;
if player <> nil then
begin
//此处处理玩家属性
end;
This_Player.PlayerNotice('武器buff触发',5);
end;
吸血buff
吸血需要做一些基础配置。吸血的概率通过 mainsetting.json 修改,具体如下:
recoverHPPercent:吸血概率触发,当攻击对方,且造成一定伤害后,需要按照一定概率触发自身吸血,这里的30代表 30% 的概率。
当客户端触发了吸血buff,会调用服务端函数 _canRecover,此函数写在 extendUIs.pas 里。
procedure _canRecover(hp:string);
var ihp,rechp,currhp :integer;
rcp:double;
begin
if hp <> nil then
begin
rcp := This_Player.GetS(2,1);
if rcp > 0 then
begin
rechp := integer(trunc(StrToFloat(hp) * (rcp / 100)));
This_Player.DoScriptHpMpRecover(rechp, 0, 0, 0);
This_Player.PlayerNotice('BUFFME=recover',5); //吸血特效
end;
end;
end;
函数说明:
参数 hp:客户端向服务端发送的血量伤害值。
rcp:这个是一个变量,是指改玩家获得的吸血比例,比如设置为 50,则表示,每次获得伤害血量的50%。举个例子:你攻击对方,本次攻击伤害对方10000血,按照50%的吸血量,本次可吸血 10000*0.5=5000血。
整个函数只需要修改 rcp 这个值即可,控制下吸血量。
如何开启?
需要在服务端为用户开启掉血触发功能
//开启
This_Player.PlayerNotice('STATUS=Recover:1',5);
//关闭
This_Player.PlayerNotice('STATUS=Recover:0',5);
虚弱buff
所谓虚弱buff,是指自身血量下降到一定水平后,触发的buff效果以及函数调用。
开启方式以及参数配置通过修改 mainsetting.json 实现。
"lostHPHitRate": 100,
"lostHPPercent": 0.5,
lostHPHitRate:虚弱buff概率,100表示 100%触发
lostHPPercent:表示血量下降到多少时生效,0.5表示下降到自身血量的50%后触发
客户端触发后,会自动调用服务端函数 _lostHPHit,此函数写在 extendUIs.pas 里。
//自身掉血触发
procedure _lostHPHit;
begin
This_Player.PlayerNotice('BUFFME=lost',5); //比如可以增加金钟罩特效
//增加一些防御类属性等,看自己怎么写
end;
如何开启?
需要在服务端为用户开启掉血触发功能
//开启
This_Player.PlayerNotice('STATUS=canLostHPHit:1',5);
//关闭
This_Player.PlayerNotice('STATUS=canLostHPHit:0',5);