xy-server/game/battle/Battle.ts

3930 lines
134 KiB
TypeScript
Raw Normal View History

2025-04-23 09:34:08 +08:00
import SkillBase from '../skill/core/SkillBase';
import GameUtil from "../core/GameUtil";
import BattleMgr from "./BattleMgr";
import PlayerMgr from "../object/PlayerMgr";
import Buff from "../skill/core/Buff";
import GoodsMgr from "../item/GoodsMgr";
import MonsterMgr from "../core/MonsterMgr";
import SkillUtil from "../skill/core/SkillUtil";
import SKDataUtil from "../gear/SKDataUtil";
import SKLogger from '../gear/SKLogger';
import {
BattleDebug,
BattleType,
EActionType,
EActNumType,
EActType,
EAttrTypeL1,
EAttrTypeL2,
EBtlRespone,
EMagicType,
ESkillType,
ESubType
} from '../role/EEnum';
import BattleRole from './BattleRole';
import PetSupport from "../object/PetSupport";
import BangMgr from "../bang/BangMgr";
import TianTi from '../activity/TianTi';
import JIngChanSongFuMgr from '../JingChanSongFu/JIngChanSongFuMgr';
export default class Battle {
static isDebug: boolean = false;
static actionTime: number = 2;
battle_id: any;
plist: any;
deadpetlist: any;
petlist: any;
winteam: any;
turnList: any[];
campA: any;
campB: any;
timer: any;
// 当前回合数
currentRound: number;
player_can_oper: boolean;
monster_group_id: number;
battle_type: any;
source: number;
destroyTimer: any;
linghouInfo: any;
huhuo: number;
nilin: number;
jswk_count: number;
jswk_type: any;
taskGroup: any;
passive_times: any; //被动触发次数
huawu_flag: any; //是否有化无
debug: BattleDebug = BattleDebug.MY;
constructor(id: any) {
this.battle_id = id;
this.plist = {};
this.deadpetlist = {};
this.petlist = {};
this.winteam = [];
this.turnList = [];
this.campA = {
effect: {}, // 1 强化悬刃 2 强化遗患
broles: [],
}
this.campB = {
effect: {}, // 1 强化悬刃 2 强化遗患
broles: [],
}
this.timer = 0;
this.huhuo = 0;
this.nilin = 0;
this.jswk_count = 0;
this.currentRound = 0;
this.player_can_oper = false;
this.monster_group_id = 0;
this.taskGroup = 0;
this.passive_times = 0;
this.huawu_flag = 0;
this.battle_type = BattleType.Normal;
this.source = 0; // 战斗来源
this.destroyTimer = setTimeout(() => {
BattleMgr.shared.destroyBattle(this.battle_id);
}, GameUtil.battleSkipTime);
}
destroy() {
if (this.timer != 0) {
clearTimeout(this.timer);
this.timer = 0;
}
this.campA.broles = [];
this.campB.broles = [];
this.winteam = [];
this.turnList = [];
for (const onlyid in this.plist) {
if (this.plist.hasOwnProperty(onlyid)) {
delete this.plist[onlyid];
}
}
}
setBattleType(bt: any) {
this.battle_type = bt;
if (this.battle_type == BattleType.LingHou) {
this.linghouInfo = {
steal_money: 0,
wintype: 0, // 0 猴子死了 1 猴子跑了
}
}
}
setTeam(team1: any, team2: any) {
let self = this;
let team2brole = (team: any, teamtype: any) => {
let t1 = [];
for (let onlyId in team) {
if (team.hasOwnProperty(onlyId)) {
const role = team[onlyId];
let brole = new BattleRole();
brole.setObj(role);
brole.team_id = teamtype;
brole.battle_id = this.battle_id;
brole.init();
t1.push(brole);
self.plist[onlyId] = brole;
}
}
return t1;
};
this.campA.broles = team2brole(team1, 1);
this.campB.broles = team2brole(team2, 2);
}
setTeamBRole(team1: any, team2: any) {
this.campA.broles = team1;
this.campB.broles = team2;
for (const brole of this.campA.broles) {
brole.battle_id = this.battle_id;
brole.team_id = 1;
if (brole.pos == 0) {
this.petlist[brole.onlyid] = brole;
}
if (brole.pos > 0) {
this.turnList.push({
spd: brole.getAttr(EAttrTypeL1.SPD),
onlyid: brole.onlyid,
});
this.plist[brole.onlyid] = brole;
}
}
for (const brole of this.campB.broles) {
brole.battle_id = this.battle_id;
brole.team_id = 2;
if (brole.pos == 0) {
this.petlist[brole.onlyid] = brole;
}
if (brole.pos > 0) {
this.turnList.push({
spd: brole.getAttr(EAttrTypeL1.SPD),
onlyid: brole.onlyid,
});
if (this.battle_type == BattleType.AREAN) {
brole.online_state = 0;
}
this.plist[brole.onlyid] = brole;
}
}
}
getTeamData(aorb?: any) {
let team = this.campA.broles;
let camp = 1;
if (aorb == 2 || aorb == 'B' || aorb == 'b') {
team = this.campB.broles;
camp = 2;
}
let teamdata: any = {};
teamdata.camp = camp;
teamdata.list = [];
for (let brole of team) {
teamdata.list.push(brole.getData());
}
return teamdata;
}
/**
*
*/
getAPlayer(): any {
let pid: any = 0;
for (let onlyid in this.plist) {
let pinfo = this.plist[onlyid];
if (pinfo.isPlayer()) {
pid = onlyid;
break;
}
}
if (pid != 0) {
return PlayerMgr.shared.getPlayerByOnlyId(pid);
}
return null;
}
//是否有召唤兽
hasBB(): boolean {
for (const onlyid in this.plist) {
if (this.plist.hasOwnProperty(onlyid)) {
const brole = this.plist[onlyid];
if (!brole.isdead && brole.is_bb) {
return true;
}
}
}
return false;
}
// 是否有场景效果
hasStageEffect(camp: any, effect: any): any {
let eff = camp.effect[effect];
if (eff) {
return eff.hurt;
}
return 0;
}
//是否有化无
hasHuaWu(battleRole: any) {
for (let key in this.plist) {
let brole = this.plist[key];
if (brole.isPet() && brole.team_id != battleRole.team_id && this.huawu_flag == 1) {
return 1;
}
}
return 0;
}
// 设置场景效果
setStageEffect(camp: any, effect: any, value: any) {
let eff = camp.effect[effect];
if (eff) {
eff.hurt = value;
eff.role = value;
}
}
// 获得场景效果
getStageEffects(): any {
let ret: any = [];
let effectinfo: any = (effect: any) => {
for (const skillid in effect) {
if (effect.hasOwnProperty(skillid)) {
const info = effect[skillid];
if (info.hurt > 0) {
ret.push({
eff: skillid,
role: info.roleid
});
}
}
}
}
effectinfo(this.campA.effect);
effectinfo(this.campB.effect);
return ret;
}
// 检查场景效果
checkStageEffect() {
let checkEffect = (camp: any) => {
let team: BattleRole[] = camp.broles;
if (camp.effect[ESkillType.HuaWu] == null) {
camp.effect[ESkillType.HuaWu] = {
hurt: 0,
roles: [],
role: 0
};
}
if (camp.effect[ESkillType.XuanRen] == null) {
camp.effect[ESkillType.XuanRen] = {
hurt: 0,
roles: [],
role: 0
};
}
if (camp.effect[ESkillType.YiHuan] == null) {
camp.effect[ESkillType.YiHuan] = {
hurt: 0,
roles: [],
role: 0
};
}
if (camp.effect[ESkillType.BuLvWeiJian] == null) {
camp.effect[ESkillType.BuLvWeiJian] = {
hurt: 0,
roles: [],
role: 0
};
}
for (let brole of team) {
if (brole.pos > 0) {
let canHuaWu = SKDataUtil.atRange(this.battle_type, [BattleType.Force, BattleType.PK, BattleType.ShuiLu, BattleType.PALACE, BattleType.Sat, BattleType.FactionWarContest, BattleType.FactionWarFight, BattleType.AREAN, BattleType.TianTIFight]);
if (canHuaWu && brole.hasPassiveSkill(ESkillType.HuaWu) && camp.effect[ESkillType.HuaWu].roles.indexOf(brole.onlyid) == -1 && this.currentRound == 1) {
camp.effect[ESkillType.HuaWu].roles.push(brole.onlyid);
camp.effect[ESkillType.HuaWu].hurt = 1;
camp.effect[ESkillType.HuaWu].roleid = brole.onlyid;
camp.effect[ESkillType.XuanRen].roles.push(brole.onlyid);
camp.effect[ESkillType.YiHuan].roles.push(brole.onlyid);
}
// 如果存在化无 就没有 遗患或者悬刃
if (camp.effect[ESkillType.HuaWu].hurt == 0) {
if ((brole.hasPassiveSkill(ESkillType.QiangHuaXuanRen) || brole.hasPassiveSkill(ESkillType.XuanRen)) &&
(camp.effect[ESkillType.XuanRen] == null || camp.effect[ESkillType.XuanRen].roles.indexOf(brole.onlyid) == -1)) {
let hurtbase = 100;
if (brole.hasPassiveSkill(ESkillType.QiangHuaXuanRen)) {
hurtbase = 150;
}
let hurt = brole.level * hurtbase;
camp.effect[ESkillType.XuanRen].roles.push(brole.onlyid);
if (hurt > camp.effect[ESkillType.XuanRen].hurt) {
camp.effect[ESkillType.XuanRen].hurt = hurt;
camp.effect[ESkillType.XuanRen].roleid = brole.onlyid;
}
}
if ((brole.hasPassiveSkill(ESkillType.QiangHuaYiHuan) || brole.hasPassiveSkill(ESkillType.YiHuan)) &&
(camp.effect[ESkillType.YiHuan] == null || camp.effect[ESkillType.YiHuan].roles.indexOf(brole.onlyid) == -1)) {
let hurtbase = 100;
if (brole.hasPassiveSkill(ESkillType.QiangHuaYiHuan)) {
hurtbase = 150;
}
let hurt = brole.level * hurtbase;
camp.effect[ESkillType.YiHuan].roles.push(brole.onlyid);
if (hurt > camp.effect[ESkillType.YiHuan].hurt) {
camp.effect[ESkillType.YiHuan].hurt = hurt;
camp.effect[ESkillType.YiHuan].roleid = brole.onlyid;
}
}
}
}
}
}
checkEffect(this.campA);
checkEffect(this.campB);
}
delBattleRole(onlyid: any) {
delete this.plist[onlyid];
for (let i = 0; i < this.campA.broles.length; i++) {
const teamrole = this.campA.broles[i];
if (teamrole.onlyid == onlyid) {
this.campA.broles.splice(i, 1);
break;
}
}
for (let i = 0; i < this.campB.broles.length; i++) {
const teamrole = this.campB.broles[i];
if (teamrole.onlyid == onlyid) {
this.campB.broles.splice(i, 1);
break;
}
}
let index = this.turnList.indexOf(onlyid);
if (index != -1) {
this.turnList.splice(index, 1);
}
}
// 玩家动作
playerAction(data: any) {
let onlyid = data.onlyid;
let acttype = data.action;
let actionid = data.actionid;
let targetid = data.targetid;
if (this.player_can_oper == false) {
return;
}
let brole: BattleRole = this.plist[onlyid];
if (brole == null) {
for (let oid in this.deadpetlist) {
let petRole: BattleRole = this.deadpetlist[oid];
if (petRole.source.onlyid == onlyid) { //已死亡召唤兽
for (let onid in this.plist) {
let petRolea: BattleRole = this.plist[onid];
if (petRole.own_onlyid == petRolea.own_onlyid) {
brole = petRolea;
break;
}
}
break;
}
}
if (brole == null) {
return;
}
}
if (brole.isact && brole.act.actionid != ESkillType.NiLin) {
return;
}
if (actionid == ESkillType.NiLin) {
this.nilin = actionid;
}
brole.act = {
acttype: acttype,
actionid: actionid,
target: targetid,
}
brole.isact = true;
// SKLogger.debug(`战斗[${brole.onlyid}:${brole.name}]请求动作:${acttype},${actionid},${targetid}`);
this.broadcastCamp(brole.onlyid, 's2c_btl_act', {
action: acttype, // 1 技能 2 道具 3 召唤
actionid: actionid, // 随 action变化
targetid: targetid, //目标 onlyid
onlyid: brole.onlyid, //行动者id
});
if (this.checkAllAct()) {
let self = this;
setTimeout(() => {
self.round();
}, 0.5 * 1000);
}
}
// 召唤头兽进入效果
petEnterEffect(pet_onlyid: number): any {
let petdata: BattleRole = this.plist[pet_onlyid];
if (!petdata) {
petdata = this.petlist[pet_onlyid];
}
if (!petdata) {
return null;
}
let enterinfo: any = null;
let initEnterBuff = (skillid: any) => {
if (enterinfo == null) {
enterinfo = {};
enterinfo.buffs = {};
enterinfo.act = {};
}
if (enterinfo.buffs[skillid] == null) {
enterinfo.buffs[skillid] = [];
}
}
for (let key in petdata.skill_list) {
if (petdata.skill_list.hasOwnProperty(key)) {
// 如虎添翼
let skillId = SKDataUtil.numberBy(key);
if (skillId == ESkillType.RuHuTianYi) {
initEnterBuff(skillId);
let skill = SkillUtil.getSkill(skillId);
let effect = skill.getEffect();
let buff = new Buff(skill, effect);
buff.source = pet_onlyid;
buff.probability = 10000;
petdata.addBuff(buff);
enterinfo.buffs[skillId].push(pet_onlyid);
let owner = this.plist[petdata.own_onlyid];
if (owner && owner.isdead == false) {
let buff = new Buff(skill, effect);
buff.source = pet_onlyid;
buff.probability = 10000;
owner.addBuff(buff);
enterinfo.buffs[skillId].push(petdata.own_onlyid);
}
}
if (this.currentRound >= 1) {
// 隐身
if (skillId == ESkillType.YinShen) {
initEnterBuff(skillId);
let skill = SkillUtil.getSkill(skillId);
let effect = skill.getEffect();
let buff = new Buff(skill, effect);
buff.source = pet_onlyid;
buff.probability = 10000;
petdata.addBuff(buff);
enterinfo.buffs[skillId].push(pet_onlyid);
// 击其不意
} else if (skillId == ESkillType.JiQiBuYi) {
initEnterBuff(skillId);
enterinfo.act = skillId;
}
}
//当头棒喝
if (skillId == ESkillType.DangTouBangHe) {
for (let brid in this.plist) {
let brole = this.plist[brid];
if (brole.isPet() && brole.team_id == petdata.team_id) {
if (brole.hasBuff(EMagicType.FORGET)) {
brole.cleanBuff(EMagicType.FORGET);
}
if (brole.hasBuff(EMagicType.SLEEP)) {
brole.cleanBuff(EMagicType.SLEEP);
}
if (brole.hasBuff(EMagicType.CHAOS)) {
brole.cleanBuff(EMagicType.CHAOS);
}
if (brole.hasBuff(EMagicType.TOXIN)) {
brole.cleanBuff(EMagicType.TOXIN);
}
if (brole.hasBuff(EMagicType.SEAL)) {
brole.cleanBuff(EMagicType.SEAL);
}
SKLogger.debug("进入战斗清除异常状态");
}
}
}
//如沐春风
if (skillId == ESkillType.RuMuChunFeng) {
initEnterBuff(skillId);
let skill = SkillUtil.getSkill(skillId);
let effect = skill.getEffect();
let buff = new Buff(skill, effect);
buff.source = pet_onlyid;
buff.probability = 10000;
enterinfo.buffs[skillId].push(pet_onlyid);
let owner = this.plist[petdata.own_onlyid];
if (owner && owner.isdead == false) {
let buff = new Buff(skill, effect);
buff.source = pet_onlyid;
buff.probability = 10000;
owner.addBuff(buff);
enterinfo.buffs[skillId].push(petdata.own_onlyid);
}
}
//扭转乾坤
if (skillId == ESkillType.NiuZhuanQianKun) {
if (petdata.hasBuff(EMagicType.NIUZHUAN)) {
SKLogger.debug('=========================' + petdata.name + '添加化无');
initEnterBuff(skillId);
enterinfo.buffs[skillId].push(pet_onlyid);
enterinfo.act = ESkillType.NiuZhuanQianKun;
let camp = this.campA;
let camp2 = this.campB;
if (petdata.team_id == 1) {
camp = this.campB;
camp2 = this.campA;
}
let huawu = this.hasStageEffect(camp, ESkillType.HuaWu);
// 有场景化无特效
if (huawu > 0) {//敌方有化无的情况
this.setStageEffect(camp, ESkillType.HuaWu, 0);
let team: BattleRole[] = camp2.broles;
for (let brole of team) {
if (brole.pos > 0) {
//化无生效战斗类型范围camp.ishuawu=true;
let canHuaWu = SKDataUtil.atRange(this.battle_type, [BattleType.Force, BattleType.PK, BattleType.ShuiLu, BattleType.PALACE, BattleType.Sat, BattleType.FactionWarContest, BattleType.FactionWarFight, BattleType.TianTIFight]);
if (canHuaWu && brole.hasBuff(EMagicType.NIUZHUAN) && camp2.effect[ESkillType.HuaWu].roles.indexOf(brole.onlyid) == -1) {
camp2.effect[ESkillType.HuaWu].roles.push(brole.onlyid);
camp2.effect[ESkillType.HuaWu].hurt = 1;
camp2.effect[ESkillType.HuaWu].roleid = brole.onlyid;
camp2.effect[ESkillType.XuanRen].roles.push(brole.onlyid);
camp2.effect[ESkillType.YiHuan].roles.push(brole.onlyid);
}
}
}
this.setStageEffect(camp, ESkillType.HuaWu, 0);
continue;
}
let xuanren_hurt = this.hasStageEffect(camp, ESkillType.XuanRen);
if (xuanren_hurt > 0) {
this.setStageEffect(camp, ESkillType.XuanRen, 0);
}
let yihuan_hurt = this.hasStageEffect(camp, ESkillType.YiHuan);
if (yihuan_hurt > 0) {
this.setStageEffect(camp, ESkillType.YiHuan, 0);
}
}
}
//万家灯火
if (skillId == ESkillType.WanJiaDengHuo) {
for (let brid in this.plist) {
let brole = this.plist[brid];
if (brole.isPet()) {
let skill = SkillUtil.getSkill(ESkillType.WanJiaDengHuo_Hong);
let buff = new Buff(skill, skill.getEffect());
brole.addBuff(buff);
// SKLogger.debug("进入战斗万家灯火");
}
}
}
}
}
return enterinfo;
}
//对目标使用物品
onBroleUseItem(onlyid: any, targetid: any, itemid: any, tr: any) {
// let iteminfo = goodsMgr.getItemInfo(itemid);
let effect = GoodsMgr.shared.getMedicineEffect(itemid);
let target = this.plist[targetid];
let tlist = [];
let targetact = SKDataUtil.clone(tr);
targetact.respone = itemid;
targetact.targetid = targetid;
let acttype = 0; //EActNumType.HP;
let num = 0;
if (target && target.isPet() && target.isdead) {
return null;
}
if (effect && target) {
//穆如清风条件检测
if (effect.addhp > 0 || effect.addmp > 0 || effect.mulhp > 0 || effect.mulmp > 0) {
let role = this.plist[onlyid];
if (onlyid != targetid && role.teamid == target.teamid && role.isPet() && role.hasPassiveSkill(ESkillType.MuRuQingFeng)) {
this.muruqingfeng(onlyid, targetid);
}
}
if (effect.huoyan) {
let yinshen = target.getBuffByEffect(EMagicType.HIDING);
if (yinshen) {
target.removeBuff(yinshen.buff_id);
let tact = SKDataUtil.clone(tr);
tact.targetid = target.onlyid;
tact.isdead = target.isdead;
tact.hp = target.getHP();
tact.mp = target.getMP();
tact.bufflist = target.getBuffsSkillId();
tlist.push(tact);
}
}
if (effect.addhp) {
target.subHP(effect.addhp, ESubType.BUFFER);
num = effect.addhp;
}
if (effect.addmp) {
target.subMP(effect.addmp, ESubType.BUFFER);
if (num == 0) {
num = effect.addmp;
}
}
if (effect.mulhp) {
let basehp = target.getAttr(EAttrTypeL1.HP_MAX);
let addhp = Math.ceil(basehp * effect.mulhp / 100);
target.subHP(addhp, ESubType.MUL);
num = addhp;
}
if (effect.mulmp) {
let basemp = target.getAttr(EAttrTypeL1.MP_MAX);
let addmp = Math.ceil(basemp * effect.mulmp / 100);
target.subMP(addmp, ESubType.MUL);
if (num == 0) {
num = effect.addmp;
}
}
if (effect.addhp != 0 || effect.mulhp) {
acttype = EActNumType.HP;
if (target.isdead) {
target.isdead = false;
}
}
if (effect.addmp != 0 || effect.mulmp) {
if (acttype == 0) {
acttype = EActNumType.MP;
} else {
acttype = EActNumType.HPMP;
}
}
targetact.num = num;
targetact.acttype = acttype;
}
if (target) {
targetact.hp = target.getHP();
targetact.mp = target.getMP();
targetact.isdead = target.isDead() ? 1 : 0;
targetact.bufflist = target.getBuffsSkillId();
}
tlist.unshift(targetact);
return tlist;
}
onPetEnter(pet_onlyid: any, pos: any): number {
let summon_pet = this.petlist[pet_onlyid];
if (summon_pet && summon_pet.isPet() && summon_pet.isdead == false) {
summon_pet.pos = pos;
summon_pet.isroundact = true;
delete this.petlist[pet_onlyid];
this.plist[pet_onlyid] = summon_pet;
let owner = this.plist[summon_pet.bindid];
if (owner) {
let rand = GameUtil.random(0, 10000);
let params = { profic: 0 };
let skilllist = [ESkillType.MoShenHuTi, ESkillType.TianWaiFeiMo, ESkillType.ShouWangShenLi]
owner.bindid = pet_onlyid;
if (owner.hasOfudaSkill(ESkillType.SiHaiChengFeng1)) {
let buffskill = SkillUtil.getSkill(Math.floor(Math.random() * skilllist.length))
if (buffskill != null && buffskill != undefined) {
let buffeffect = buffskill.getEffect(params);
buffeffect.fangyu = Math.floor(25 * (summon_pet.level * 0.35 * 3 / 100 + 1))
buffeffect.spd = Math.floor(25 * (summon_pet.level * 0.35 * 3 / 100 + 1))
buffeffect.atk = Math.floor(55 * (summon_pet.level * 0.35 * 3 / 100 + 1))
buffeffect.round = 3;
let buff = new Buff(buffskill, buffeffect);
buff.source = summon_pet.onlyid
if (rand >= 1) {
summon_pet.addBuff(buff);
}
}
}
if (owner.hasOfudaSkill(ESkillType.SiHaiChengFeng2)) {
let buffskill = SkillUtil.getSkill(Math.floor(Math.random() * skilllist.length))
if (buffskill != null && buffskill != undefined) {
let buffeffect = buffskill.getEffect(params);
buffeffect.fangyu = Math.floor(25 * (summon_pet.level * 0.35 * 3 / 100 + 1))
buffeffect.spd = Math.floor(25 * (summon_pet.level * 0.35 * 3 / 100 + 1))
buffeffect.atk = Math.floor(55 * (summon_pet.level * 0.35 * 3 / 100 + 1))
buffeffect.round = 3;
let buff = new Buff(buffskill, buffeffect);
buff.source = summon_pet.onlyid
if (rand >= 1) {
summon_pet.addBuff(buff);
}
}
}
if (owner.hasOfudaSkill(ESkillType.SiHaiChengFeng3)) {
let buffskill = SkillUtil.getSkill(Math.floor(Math.random() * skilllist.length))
if (buffskill != null && buffskill != undefined) {
let buffeffect = buffskill.getEffect(params);
buffeffect.fangyu = Math.floor(25 * (summon_pet.level * 0.35 * 3 / 100 + 1))
buffeffect.spd = Math.floor(25 * (summon_pet.level * 0.35 * 3 / 100 + 1))
buffeffect.atk = Math.floor(55 * (summon_pet.level * 0.35 * 3 / 100 + 1))
buffeffect.round = 3;
let buff = new Buff(buffskill, buffeffect);
buff.source = summon_pet.onlyid
if (rand >= 1) {
summon_pet.addBuff(buff);
}
}
}
}
if (summon_pet.hasPassiveSkill(ESkillType.HuaWu)) {
this.huawu_flag = 1;
}
if (summon_pet.hasPassiveSkill(ESkillType.NiuZhuanQianKun)) {
this.huawu_flag = 1;
let skill = SkillUtil.getSkill(ESkillType.NiuZhuanQianKun);
let effect = skill.getEffect();
let buff = new Buff(skill, effect);
buff.source = pet_onlyid;
buff.probability = 10000;
summon_pet.addBuff(buff);
SKLogger.debug("===============================1.进入战斗扭转乾坤给自己加BUFF:" + summon_pet.name + buff.buff_id + '队伍编号' + summon_pet.team_id);
}
return pet_onlyid;
}
return 0;
}
// 召唤兽离开
onPetLeave(onlyId: number): any {
let pet = this.plist[onlyId];
if (pet && pet.isPet()) {
for (let i = 0; i < this.turnList.length; i++) {
let turn = this.turnList[i];
if (turn.onlyid == onlyId) {
this.turnList.splice(i, 1);
break;
}
}
for (let key in pet.skill_list) {
if (pet.skill_list.hasOwnProperty(key)) {
//将死
let skillId = SKDataUtil.numberBy(key);
if (skillId == ESkillType.JiangSi) {
for (let brid in this.plist) {
let brole = this.plist[brid];
if (brole.isPet() && brole.team_id == pet.team_id) {
if (brole.hasBuff(EMagicType.FORGET)) {
brole.cleanBuff(EMagicType.FORGET);
}
if (brole.hasBuff(EMagicType.SLEEP)) {
brole.cleanBuff(EMagicType.SLEEP);
}
if (brole.hasBuff(EMagicType.CHAOS)) {
brole.cleanBuff(EMagicType.CHAOS);
}
if (brole.hasBuff(EMagicType.TOXIN)) {
brole.cleanBuff(EMagicType.TOXIN);
}
if (brole.hasBuff(EMagicType.SEAL)) {
brole.cleanBuff(EMagicType.SEAL);
}
console.log(`召唤兽离场清除异常状态`);
}
}
}
//成仁取义
if (skillId == ESkillType.ChengRenQuYi) {
let owner = this.plist[pet.bindid];
if (owner.hasBuff(EMagicType.FORGET)) {
owner.cleanBuff(EMagicType.FORGET);
}
if (owner.hasBuff(EMagicType.SLEEP)) {
owner.cleanBuff(EMagicType.SLEEP);
}
if (owner.hasBuff(EMagicType.CHAOS)) {
owner.cleanBuff(EMagicType.CHAOS);
}
if (owner.hasBuff(EMagicType.TOXIN)) {
owner.cleanBuff(EMagicType.TOXIN);
}
if (owner.hasBuff(EMagicType.SEAL)) {
owner.cleanBuff(EMagicType.SEAL);
}
SKLogger.debug(`召唤兽离场成仁取义清除异常状态`);
}
}
}
pet.pos = -1;
let owner = this.plist[pet.bindid];
if (owner) {
owner.bindid = 0;
}
this.deadpetlist[onlyId] = this.plist[onlyId];
delete this.plist[onlyId];
return onlyId;
}
return 0;
}
summorBack(actid: any): any {
let bplayer = this.plist[actid];
let tpet = this.onPetLeave(bplayer.bindid);
return tpet;
}
actSummor(actid: any, summonid: any): any {
let bplayer = this.plist[actid];
let ownpos = bplayer.pos;
let tpet = this.onPetLeave(bplayer.bindid);
let bpet = this.onPetEnter(summonid, ownpos + 5);
return {
tback_pet: tpet,
battle_pet: bpet,
};
}
// 检查所有人是否在线
checkAllAct(): boolean {
for (let onlyid in this.plist) {
if (this.plist.hasOwnProperty(onlyid)) {
let brole: BattleRole = this.plist[onlyid];
if (brole.isPlayer()) {
let player = PlayerMgr.shared.getPlayerByOnlyId(brole.onlyid);
if (player && player.offline) {
brole.online_state = 0;
}
}
if (brole.isPet()) {
let owner: BattleRole = this.plist[brole.own_onlyid];
if (owner.online_state == 0) {
brole.online_state = 0;
}
}
if ((brole.isPlayer() || brole.isPet()) && brole.pos > 0 && !brole.isdead && !brole.isact && brole.online_state == 1) {
return false;
}
}
}
return true;
}
// 战斗开始
begin() {
SKLogger.debug(`战斗[${this.battle_id}]开始`);
for (let item of this.turnList) {
let brole: BattleRole = this.plist[item.onlyid];
if (brole == null) {
continue;
}
if (brole.isPet()) {
this.petEnterEffect(brole.onlyid);
}
}
this.roundBegin();
}
// findtype = 0 找同队中 非自己的 随机一个人
// findtype = 1 找敌队中 随机一个人
findRandomTeamTarget(onlyid: any, findtype: any = 0): BattleRole {
let role = this.plist[onlyid];
if (!role) {
return null;
}
let tid = role.team_id;
let team = [];
if (tid == 1) {
team = this.campA.broles;
} else if (tid == 2) {
team = this.campB.broles;
}
if (team.length - 1 <= 0) {
return null;
}
let tmpteam = [];
for (let i = 0, len = team.length; i < len; i++) {
let trole = team[i];
if (trole.pos == 0 || trole.pos == -1) {
continue;
}
if (findtype == 0 && trole.onlyid == onlyid) {
continue;
}
if (trole.hasBuff(EMagicType.HIDING)) {
continue;
}
if (trole.isdead || trole.hasBuff(EMagicType.SEAL)) {
if (role.isPet() && findtype == 0) {
let owner = this.plist[role.own_onlyid];
if (owner.hasOfudaSkill(ESkillType.ShengJi1) || owner.hasOfudaSkill(ESkillType.ShengJi2) || owner.hasOfudaSkill(ESkillType.ShengJi3)) {
tmpteam.push(trole);
}
}
continue;
}
tmpteam.push(trole);
}
if (tmpteam.length <= 0) {
return null;
}
let random = Math.floor(GameUtil.random(0, tmpteam.length - 1));
return tmpteam[random];
}
// mod == 1 敌人 2 自己人 3 全体
findRandomTarge(onlyid: number, neednum: number, list: number[], mod: number = 1, skill: SkillBase = null): any {
if (list.length == neednum) {
return list;
}
let role = this.plist[onlyid];
let tid = 0;
if (role) {
tid = role.team_id;
}
let team = [];
let enemy_team = [];
let self_team = [];
if (tid == 1) {
enemy_team = this.campB.broles;
self_team = this.campA.broles;
} else if (tid == 2) {
enemy_team = this.campA.broles;
self_team = this.campB.broles;
}
if (mod == 1) {
team = enemy_team;
} else if (mod == 2) {
team = self_team;
} else if (mod == 3) {
team = enemy_team.concat(self_team);
}
let tmplist = [];
for (let brole of team) {
if (brole.pos == 0 || brole.pos == -1) {
continue;
}
if (mod == 1 || mod == 3) {
// 不能选择自己为目标
if (brole.onlyid == onlyid) {
continue;
}
// 过滤已死的
if (brole.isdead) {
continue;
}
// 过滤 隐身的
if (brole.hasBuff(EMagicType.HIDING)) {
if (role.living_type == 1) {
let player = PlayerMgr.shared.getPlayerByOnlyId(role.onlyid);
let r = GameUtil.random(0, 10000);
if (player) {
if (player.baldric == 9225 && r <= 5000) { //珍藏 霄汉配饰
tmplist.push(brole);
} else if (player.baldric == 9226) { //无价 霄汉配饰
tmplist.push(brole);
} else {
continue;
}
}
} else {
continue;
}
}
}
if (mod == 2) {
if (skill && skill.skill_type != EMagicType.HEAL) {
if (brole.isdead && skill.skill_type != EMagicType.ZhiYu) {
continue;
}
}
}
let find = list.indexOf(brole.onlyid);
if (find == -1) {
tmplist.push(brole);
}
}
if (tmplist.length > 0) {
if (mod == 2) {
tmplist.sort((a, b) => {
return a.spd - b.spd;
});
} else {
tmplist.sort((a, b) => {
return Math.random() > .4 ? -1 : 1;
});
}
// 优先选择没有中技能BUFF的目标。
for (let index = 0; index < tmplist.length; index++) {
const tbrole = tmplist[index];
if (tbrole.hasBuff(EMagicType.SEAL)) {
continue;
}
if (skill && skill.skill_type != 0) {
// 非万毒攻心,跳过已中毒的目标
if (skill.skill_id != ESkillType.WanDuGongXin && tbrole.hasBuff(skill.skill_type)) {
continue;
}
}
if (list.length < neednum) {
list.push(tbrole.onlyid);
} else {
break;
}
}
// 补选人数
if (list.length < neednum) {
for (let index = 0; index < tmplist.length; index++) {
const tbrole = tmplist[index];
if (tbrole.hasBuff(EMagicType.SEAL)) {
continue;
}
if (list.length < neednum && list.indexOf(tbrole.onlyid) == -1) {
list.push(tbrole.onlyid);
} else {
break;
}
}
}
}
return list;
}
//利涉大川检测
lishedachuan(onlyid: any, list: any, skillId: any, params: any) {
//判断技能是否能触发利涉大川
if (skillId != ESkillType.TianMoJieTi &&
skillId != ESkillType.FenGuangHuaYing &&
skillId != ESkillType.QingMianLiaoYa &&
skillId != ESkillType.XiaoLouYeKu &&
skillId != ESkillType.HighTianMoJieTi &&
skillId != ESkillType.HighFenGuangHuaYing &&
skillId != ESkillType.HighQingMianLiaoYa &&
skillId != ESkillType.HighXiaoLouYeKu) {
return 0;
}
let num = 0;
let role = this.plist[onlyid];
//非宠物不能触发
if (!role.isPet()) {
return 0;
}
//没有利涉大川被动不能触发
let skill = role.skill_list[ESkillType.LiSheDaChuan];
if (!skill) {
return 0;
}
//判断利涉大川回蓝BUFF 不存在就添加
if (!role.hasBuff(ESkillType.LiSheDaChuan)) {
skill = SkillUtil.getSkill(ESkillType.LiSheDaChuan);
let effect = skill.getEffect(params);
let buff = new Buff(skill, effect);
role.addBuff(buff);
}
SKLogger.debug(`利涉大川被动触发`);
//倒遍历速度表 将最慢的两个地方目标加入到列表
for (let i = this.turnList.length - 1; i >= 0; i--) {
let obj = this.turnList[i];
let brole = this.plist[obj.onlyid];
//已经加入两个额外目标后直接返回
if (num >= 2) {
return num;
}
//不能选自己为目标
if (brole.onlyid == onlyid) {
continue;
}
//忽略狗带目标
if (brole.isdead) {
continue;
}
//忽略我方目标
if (brole.team_id == role.team_id) {
continue;
}
//忽略隐身目标
if (brole.hasBuff(EMagicType.HIDING)) {
continue;
}
list.push(brole.onlyid);
num++;
}
return num;
}
//穆如清风技能
muruqingfeng(onlyid: any, targetid: any) {
let brole = this.plist[onlyid];
let level = brole.level; //当前等级
let relive = brole.relive; //转生等级
let qinmi = brole.qinmi;
//概率 满亲密度最高50% 外加等级的加成
let rate = (qinmi / 2e9 + level / 1000 + relive / 10) * 100;
if (rate < SKDataUtil.random(0, 100)) {
return;
}
let target = this.plist[targetid];
if (target.hasBuff(EMagicType.CHAOS)) {
target.cleanBuff(EMagicType.CHAOS);
SKLogger.debug(`穆如清风清除混乱`);
}
if (target.hasBuff(EMagicType.SLEEP)) {
target.cleanBuff(EMagicType.SLEEP);
SKLogger.debug(`穆如清风清除昏睡`);
}
if (target.hasBuff(EMagicType.SEAL)) {
target.cleanBuff(EMagicType.SEAL);
SKLogger.debug(`穆如清风清除封印`);
}
}
// 检查队伍是否全部死亡
checkTeamAllDie(team: BattleRole[]): boolean {
let alldie = true;
for (let brole of team) {
if (brole.pos == 0 || brole.pos == -1) {
continue;
}
if (!brole.isdead) {
alldie = false;
break;
}
}
return alldie;
}
isSameTeam(onlyidA: any, onlyidB: any): boolean {
let arole = this.plist[onlyidA];
let brole = this.plist[onlyidB];
return arole.team_id == brole.team_id;
}
isPlayerWin(onlyid: any): number {
if (this.winteam.length == 0) {
return 2;
}
if (this.battle_type == BattleType.AREAN) {
//如果超过10个回合挑战失败
if (this.currentRound >= 10) {
return this.winteam.indexOf(onlyid) == -1 ? 0 : 0;
}
}
return this.winteam.indexOf(onlyid) == -1 ? 0 : 1;
}
// 团队胜
teamWin(team: any) {
let t = this.campA.broles;
if (team == 2) {
t = this.campB.broles;
}
for (const bobj of t) {
this.winteam.push(bobj.onlyid);
}
if (this.battle_type == BattleType.LingHou) {
let player = this.getAPlayer();
if (player) {
let money = this.linghouInfo.steal_money;
let type = this.linghouInfo.wintype;
if (type == 1) {
// 猴子跑了
money = 0;
if (this.currentRound == 1) {
money = GameUtil.LingHouRetMoney;
}
} else if (type == 0) {
money = money * 2;
}
if (money > 0) {
player.addMoney(GameUtil.goldKind.Money, money, '天降灵猴');
}
if (money > 500000) {
PlayerMgr.shared.broadcast('s2c_game_chat', {
scale: 3,
msg: `${player.name} 教训灵猴,获得了 ${money} 银两`,
name: '',
resid: 0,
teamid: 0,
});
}
}
}
//金蟾奖励
if (this.battle_type == BattleType.JinChan) {
if (team == 2) {
for (const bobj of this.campB.broles) {
if (bobj.isPlayer()) {
JIngChanSongFuMgr.shared.sendReward(bobj.onlyid, this.source, 1);
}
}
} else {
for (const bobj of this.campA.broles) {
if (bobj.isPlayer()) {
JIngChanSongFuMgr.shared.sendReward(bobj.onlyid, this.source, 1);
}
}
}
}
//天梯奖励
if (this.battle_type == BattleType.TianTIFight) {
if (team == 2) {
for (const bobj of this.campB.broles) {
TianTi.shared.sendReward(bobj.onlyid, 1);
}
for (const bobj of this.campA.broles) {
TianTi.shared.sendReward(bobj.onlyid, 0);
}
} else {
for (const bobj of this.campB.broles) {
TianTi.shared.sendReward(bobj.onlyid, 0);
}
for (const bobj of this.campA.broles) {
TianTi.shared.sendReward(bobj.onlyid, 1);
}
}
}
BattleMgr.shared.destroyBattle(this.battle_id);
}
// 流局
end() {
this.broadcast('s2c_btl_end', {
btlid: this.battle_id,
result: false,
});
BattleMgr.shared.destroyBattle(this.battle_id);
}
// 重新确定移速顺序
resetTurnList() {
let turnList = [];
let r = GameUtil.random(0, 10000);
for (let onlyid in this.plist) {
if (this.plist.hasOwnProperty(onlyid)) {
let brole = this.plist[onlyid];
let spd = brole.getAttr(EAttrTypeL1.SPD)
if (brole.living_type == 1) {
let player = PlayerMgr.shared.getPlayerByOnlyId(brole.onlyid);
if (player) {
if (player.baldric == 9249 && r < 3000) {// 珍藏 鲲鹏配饰
spd = 9999
}
if (player.baldric == 9250 && r < 4000) {// 无价 鲲鹏配饰
spd = 9999
}
}
}
// SKLogger.debug(`[${brole.onlyid}:${brole.name}]速度:${spd}`);
turnList.push({
spd: spd,
onlyid: brole.onlyid,
})
}
}
turnList.sort((a, b) => {
return b.spd - a.spd;
});
this.turnList = turnList;
let turnInfo = "";
let index: number = 1;
for (let turn of this.turnList) {
let brole: BattleRole = this.plist[turn.onlyid];
if (brole) {
turnInfo += `${brole.team_id == 1 ? `我方` : `敌方`}[${brole.onlyid}:${brole.name}]速度[${turn.spd}]第${index}个出手,\n`;
index++;
}
}
SKLogger.debug(`${this.currentRound}回合:出手顺序:\n${turnInfo}`);
}
// 检查是否胜利
checkWin() {
if (this.checkTeamAllDie(this.campA.broles)) {
return 2;
}
if (this.checkTeamAllDie(this.campB.broles)) {
return 1;
}
return 0;
}
// 回合开始
roundBegin() {
//清理计时
if (this.timer != 0) {
clearTimeout(this.timer);
this.timer = 0;
}
//检查是否有获胜队伍
let winTeam: number = this.checkWin();
if (winTeam != 0) {
this.teamWin(winTeam);
return;
}
//当前回合自增
this.currentRound++;
this.huhuo++;
//判定回合上限
if (this.currentRound >= 35) {
this.end();
return;
}
if (this.battle_type == BattleType.AREAN) {
if (this.currentRound >= 10) {
this.end();
return;
}
}
//玩家可操作开启
this.player_can_oper = true;
// 先处理 buff
let actionList: any = [];
for (let turn of this.turnList) {
let battleRole: BattleRole = this.plist[turn.onlyid];
if (battleRole == null) {
continue;
}
if (battleRole.isdead && !battleRole.hasBuff(EMagicType.ZhiYu)) {
continue;
}
SKLogger.debug(`dead:${battleRole.isdead} hasbuf:${battleRole.hasBuff(EMagicType.ZhiYu)}`)
let addHP = 0;
let buffList = battleRole.getBuffList();
// 处理BUFF
for (let i = 0; i < buffList.length; i++) {
let buff = buffList[i];
if (battleRole.living_type == 1) {
let r = GameUtil.random(0, 10000);
let player = PlayerMgr.shared.getPlayerByOnlyId(battleRole.onlyid);
if (player && (buff.skill_id == 1004 || buff.skill_id == 1008)) {
if (player.baldric == 9255 && r < 1000) {// 珍藏 兰心配饰
battleRole.removeBuff(buff.buff_id)
}
if (player.baldric == 9256 && r < 2000) {// 无价 兰心配饰
battleRole.removeBuff(buff.buff_id)
}
}
}
if (battleRole.hasPassiveSkill(ESkillType.HighTuoKunShu)) {
if (battleRole.tuoKun() && (buff.skill_id == 1006 || buff.skill_id == 1010)) {
battleRole.removeBuff(buff.buff_id);
}
}
// if (battleRole.isdead && buff.skill_id == ESkillType.TuMiHuaKai) {
// SKLogger.warn("----------荼蘼花开-----8888-----" + buff.skill_id);
// battleRole.removeBuff(buff.skill_id);
// //continue;
// }
addHP += buff.active(battleRole);
}
let action: any = {};
action.targetid = battleRole.onlyid;
action.acttype = addHP > 0 ? 2 : 1;
action.num = addHP; // 对应acttype 伤害量 治疗量
action.respone = 0; // 0 无响应1 防御 2闪避 3暴击
action.isdead = battleRole.isdead; // 0 未死亡 1 死亡
action.hp = battleRole.getHP(); // 剩余生命值百分比
action.mp = battleRole.getMP(); // 剩余法力值百分比
action.bufflist = battleRole.getBuffsSkillId(); // buff列表
action.param = 0;
actionList.push(action);
}
this.resetTurnList();
this.checkStageEffect();
let effect = this.getStageEffects();
this.broadcast('s2c_btl_roundbegin', {
act: actionList,
effect: effect,
});
// 被buff烫死
winTeam = this.checkWin();
if (winTeam != 0) {
SKLogger.debug(`战斗结束`);
setTimeout(() => {
this.teamWin(winTeam);
}, 5 * 1000);
return;
}
let self = this;
let waitTime = 31;
if (this.checkAllAct()) {
waitTime = 4;
}
this.timer = setTimeout(() => {
self.round();
}, waitTime * 1000);
}
// 一回合开始
round() {
if (this.timer != 0) {
clearTimeout(this.timer);
this.timer = 0;
}
this.player_can_oper = false;
let roundInfo: any = {};
/**是否触发天降流火*/
let IsTianJiangLiuHuo = false;
let IsTianJiangLiuHuo_time = 0;
let double_hit_time = 0;
let three_hit_time = 0;
roundInfo.round = this.currentRound;
roundInfo.acts = [];
let replace_list: any = {};
let target: any = {
targetid: 0, // 目标onlyid
acttype: 0, // 1伤害 2治疗 3buff
num: 0, // 对应acttype 伤害量 治疗量
respone: 0, // 0 无响应1 防御 2 闪避 3 暴击
isdead: 0, // 0 未死亡 1 死亡
hp: 0, // 剩余生命值百分比
mp: 0, // 剩余法力值百分比
bufflist: [], // buff列表
param: 0,
actaffix: '',
selfid: 0, //自己onlyid
fan: 0, //反伤
selfhp: 0,
selfdead: 0,
recover: 0,
selfmp: 0,
backmp: 0,
babyskill: ""
};
let protect_list: any = {}
// 整理保护列表
for (let turn of this.turnList) {
let battleRole: BattleRole = this.plist[turn.onlyid];
if (battleRole.act && battleRole.act.acttype == EActType.PROTECT) {
let target_id = battleRole.act.target;
if (protect_list[target_id] == null) {
protect_list[target_id] = battleRole.onlyid;
}
}
}
//重置角色信息
for (let turnIndex = 0; turnIndex < this.turnList.length; turnIndex++) {
let turn = this.turnList[turnIndex];
// 出手的角色
let battleRole: BattleRole = this.plist[turn.onlyid];
battleRole.resetRoundStatus()
//重置宝宝技能
let player = PlayerMgr.shared.getPlayerByOnlyId(battleRole.onlyid);
if (player) {
let baby = player.BabyMgr.GetBattleBaby()
baby && baby.ResetSkill()
}
}
//宝宝加速技能
for (let turnIndex = 0; turnIndex < this.turnList.length; turnIndex++) {
let turn = this.turnList[turnIndex];
// 出手的角色
let battleRole: BattleRole = this.plist[turn.onlyid];
if (battleRole.isPlayer()) {
let player = PlayerMgr.shared.getPlayerByOnlyId(battleRole.onlyid);
if (player != null) {
let baby = player.BabyMgr.GetBattleBaby()
if (baby != null && baby.IsTriggerSpeed()) {
let spd = battleRole.getAttr(EAttrTypeL1.SPD)
battleRole.setAttr(EAttrTypeL1.SPD, spd + 300)
}
}
}
}
this.resetTurnList()
let addTime = 0;
for (let turnIndex = 0; turnIndex < this.turnList.length; turnIndex++) {
let turn = this.turnList[turnIndex];
// 出手的角色
let battleRole: BattleRole = this.plist[turn.onlyid];
if (battleRole == null || battleRole.beCache) {
console.log("1294行不出手原因战斗角色为空 或者 battleRole.beCache = true")
continue;
}
// 出手目标死亡则跳过
if (battleRole.isdead && battleRole.act.acttype != EActType.SUMMON && battleRole.act.acttype != EActType.RUN_AWAY) {
battleRole.isroundact = true;
continue;
}
//宝宝技能清除异常状态
if (battleRole.isPlayer()) {
let player = PlayerMgr.shared.getPlayerByOnlyId(battleRole.onlyid);
if (player) {
let baby = player.BabyMgr.GetBattleBaby()
if (baby != null && baby.HasPlaySkill() == false) {
if (battleRole.hasBuff(EMagicType.FORGET) ||
battleRole.hasBuff(EMagicType.SLEEP) ||
battleRole.hasBuff(EMagicType.CHAOS) ||
battleRole.hasBuff(EMagicType.SEAL)) {
if (battleRole.wake_times <= 2 && baby.IsTriggerLingJi()) {
battleRole.cleanBuff(EMagicType.FORGET);
battleRole.cleanBuff(EMagicType.SLEEP);
battleRole.cleanBuff(EMagicType.CHAOS);
battleRole.cleanBuff(EMagicType.SEAL);
battleRole.wake_times++
}
}
}
}
}
// 出手目标被封印或昏睡则跳过
if (battleRole.hasBuff(EMagicType.SEAL) || battleRole.hasBuff(EMagicType.SLEEP)) {
SKLogger.info(`1306行不出手原因${battleRole.name}被封印或昏睡`)
continue;
}
if (battleRole.isPartner() && this.hasBB()) {
continue;
}
// 修正内容 行动类型没有设定强改为伤害型
if (battleRole.act.acttype == 0) {
battleRole.act.acttype = EActType.SKILL;
}
//混乱状态下 强制行动为伤害类型
if (battleRole.hasBuff(EMagicType.CHAOS)) {
battleRole.act.acttype = EActType.SKILL;
SKLogger.debug(`战斗:[${battleRole.onlyid}:${battleRole.name}]中了混乱,动作修正为技能`);
}
// if (battleRole.isMonster()) {
// let bufflist = battleRole.getBuffList();
// for (let i = 0; i < bufflist.length; i++) {
// let buff = bufflist[i];
// if (buff.skill_id == ESkillType.TuMiHuaKai) {
// buff.active(battleRole);
// // SKLogger.warn("----------荼蘼花开-----7777-----" + buff.active(battleRole))
// }
// }
// }
//判定当前战斗类型是灵猴 且角色是为怪物
if (this.battle_type == BattleType.LingHou && battleRole.isMonster()) {
//获取第一个玩家
let player = this.getAPlayer();
//判定玩家银两是否满足活动,不满足灵猴行动为逃跑
if (player && player.money < GameUtil.lingHouMinMoney) {
battleRole.act.acttype = EActType.RUN_AWAY;
}
//35%概率逃跑
let random = GameUtil.random(0, 10000);
if (random < 3500) {
battleRole.act.acttype = EActType.RUN_AWAY;
}
}
// 不是防御 都要破除隐身状态
if (battleRole.act.acttype != EActType.SKILL && battleRole.act.actionid != 0 && battleRole.act.actionid != ESkillType.NormalDefSkill) {
let yinshen = battleRole.getBuffByEffect(EMagicType.HIDING);
if (yinshen) {
battleRole.removeBuff(yinshen.buff_id);
}
}
//声明动作对象
let actionList: any = {};
//行动者连接ID
actionList.actid = turn.onlyid;
//动作类型
actionList.action = battleRole.act.acttype;
//出手前技能定义?
let actbef: any = {};
//反伤
let fan = 0;
actionList.act = [];
battleRole.isroundact = true;
let runaway = false;
// SKLogger.debug(`战斗:[${battleRole.onlyid}:${battleRole.name}]执行动作:${battleRole.act.acttype}`);
//安行疾斗判定
if (battleRole.isPet() && battleRole.hasPassiveSkill(ESkillType.AnXingJiDou)) {
let owner = this.plist[battleRole.own_onlyid];
if (owner && owner.deadNum > 0) {
if (!battleRole.hasBuff(ESkillType.AnXingJiDou)) {
let skill = SkillUtil.getSkill(ESkillType.AnXingJiDou);
let buff = new Buff(ESkillType.AnXingJiDou, skill.getEffect());
battleRole.addBuff(buff);
buff.active(battleRole);
}
}
}
if (battleRole.act.acttype == EActType.RUN_AWAY) {
// 逃跑
actionList.actionid = 0;
let r = GameUtil.random(1, 10000);
if (this.battle_type == BattleType.ShuiLu) {
r = 10001;
}
if (this.battle_type == BattleType.LingHou) {
r = 0;
this.linghouInfo.wintype = 1;
}
if (r < 8000) {
runaway = true;
actionList.actionid = 1;
let self = this;
let winteamid = battleRole.team_id == 1 ? 2 : 1;
setTimeout(() => {
self.teamWin(winteamid);
}, (roundInfo.acts.length + 1) * Battle.actionTime * 1000);
}
} else if (battleRole.act.acttype == EActType.ITEM) { //使用物品
if (battleRole.hasBuff(EMagicType.FORGET) || battleRole.hasBuff(EMagicType.CHAOS)) {
SKLogger.info(`1390行不出手原因${battleRole.name}有遗忘buff或混乱buff`)
continue;
}
let itemid = battleRole.act.actionid;
let target_id = battleRole.act.target;
let targetact = this.onBroleUseItem(battleRole.onlyid, target_id, itemid, target);
if (targetact && targetact.length > 0) {
actionList.act = actionList.act.concat(targetact);
let player = PlayerMgr.shared.getPlayerByOnlyId(battleRole.onlyid);
if (player) {
player.addBagItem(itemid, -1, false);
}
}
} else if (battleRole.act.acttype == EActType.CATCH) { //捕捉
let player = PlayerMgr.shared.getPlayerByOnlyId(battleRole.onlyid);
if (player) {
let target_id = battleRole.act.target;
let targetRole: BattleRole = this.plist[target_id];
let targetAction = SKDataUtil.clone(target);
targetAction.targetid = target_id;
targetAction.respone = EBtlRespone.NO_CATCH;
while (true) {
if (targetRole.is_bb == false) {
targetAction.respone = EBtlRespone.NO_CATCH;
break;
}
let rand = GameUtil.random(0, 10000);
if (rand > 6000) {
targetAction.respone = EBtlRespone.CATCH_FAILED;
break;
}
targetAction.respone = EBtlRespone.CATCHED;
let mondata = MonsterMgr.shared.getMonsterData(targetRole.dataid);
player.createPet({
petid: mondata.petid
});
break
}
targetAction.hp = targetRole.getHP();
targetAction.mp = targetRole.getMP();
targetAction.isdead = targetRole.isDead() ? 1 : 0;
targetAction.bufflist = targetRole.getBuffsSkillId();
actionList.act.push(targetAction);
if (targetAction.respone == EBtlRespone.CATCHED) {
this.delBattleRole(target_id);
}
}
} else if (battleRole.act.acttype == EActType.PROTECT) {
// 保护
let yinshen = battleRole.getBuffByEffect(EMagicType.HIDING);
if (yinshen) {
battleRole.removeBuff(yinshen.buff_id);
}
} else if (battleRole.act.acttype == EActType.SUMMON) { //召唤
if (battleRole.isDead()) {
// let targetAction2 = SKDataUtil.clone(target);
// targetAction2.respone = EBtlRespone.SUMMON_FAILED;
// actionList.act.push(targetAction2);
} else {
// 召唤
let petid = battleRole.act.actionid;
let summorInfo = this.actSummor(battleRole.onlyid, petid);
let targetAction = SKDataUtil.clone(target);
targetAction.targetid = summorInfo.tback_pet;
targetAction.respone = EBtlRespone.SUMMON_BACK;
actionList.act.push(targetAction);
let sumpet = this.plist[summorInfo.battle_pet];
let targetAction2 = SKDataUtil.clone(target);
if (sumpet == null) {
targetAction2.respone = EBtlRespone.SUMMON_FAILED;
actionList.act.push(targetAction2);
} else {
let own: BattleRole = this.plist[sumpet.own_onlyid]
targetAction2.respone = EBtlRespone.SUMMON;
targetAction2.targetid = sumpet.onlyid;
targetAction2.num = sumpet.pos;
targetAction2.hp = sumpet.getHP();
targetAction2.mp = sumpet.getMP();
targetAction2.isdead = sumpet.isDead() ? 1 : 0;
targetAction2.bufflist = sumpet.getBuffsSkillId();
let sumenterinfo = this.petEnterEffect(sumpet.onlyid);
if (sumenterinfo) {
let actaffix: any = {}
actaffix.petenter = sumenterinfo;
targetAction2.actaffix = SKDataUtil.toJson(actaffix, "{}");
if (sumenterinfo.act == ESkillType.JiQiBuYi) {
sumpet.act.acttype = EActType.SKILL;
sumpet.act.skill = ESkillType.NormalAtkSkill;
sumpet.act.actionid = ESkillType.NormalAtkSkill;
this.turnList.splice(turnIndex + 1, 0, { spd: sumpet.getAttr(EAttrTypeL1.SPD), onlyid: sumpet.onlyid });
}
}
if (sumpet.hasPassiveSkill(ESkillType.HighXianFengDaoGu) || sumpet.hasPassiveSkill(ESkillType.HighMiaoShouRenXin)) {
let hp = own.getAttr(EAttrTypeL1.HP_MAX);
let mp = own.getAttr(EAttrTypeL1.MP_MAX);
if (sumpet.hasPassiveSkill(ESkillType.HighXianFengDaoGu)) {
own.subHP(hp)
own.subMP(Math.floor(mp * 0.02))
targetAction2.selfid = own.onlyid;
targetAction2.selfhp = own.getHP();
targetAction2.recover = hp;
targetAction2.backmp = Math.floor(mp * 0.2);
}
if (sumpet.hasPassiveSkill(ESkillType.HighMiaoShouRenXin)) {
own.subHP(Math.floor(hp * 0.02))
own.subMP(mp)
targetAction2.selfid = own.onlyid;
targetAction2.selfhp = own.getHP();
targetAction2.recover = Math.floor(hp * 0.2);
targetAction2.backmp = mp;
}
}
actionList.act.push(targetAction2);
replace_list[summorInfo.tback_pet] = sumpet.onlyid;
}
}
} else if (battleRole.act.acttype == EActType.SUMMON_BACK) {
// 召还
let backid = this.summorBack(battleRole.onlyid);
let targetact = SKDataUtil.clone(target);
targetact.targetid = backid;
targetact.respone = EBtlRespone.SUMMON_BACK;
actionList.act.push(targetact);
} else if (battleRole.act.acttype == EActType.SKILL) {
// 确认技能
let skillId = battleRole.act.actionid;
//没有行动操作 智能获取一个行动
if (skillId == null || skillId == 0) {
skillId = battleRole.getAiSkill();
if (battleRole.isPet()) {
skillId = battleRole.last_skill
}
battleRole.act.actionid = skillId;
//判断被动技能
// let skil = SkillUtil.getSkill(skillId);
// if(skil){
// if(skil.action_type == EActionType.PASSIVE && skillId != ESkillType.YouFengLaiYi){
// skillId = battleRole.getAiSkill();
// battleRole.act.actionid = skillId;
// }
// }
}
//天降流火
let r = GameUtil.random(0, 100);
if (r >= 60) { IsTianJiangLiuHuo = true };
if (battleRole.isPet() && skillId == ESkillType.NormalAtkSkill && IsTianJiangLiuHuo) {// 天降流火
if (battleRole.hasPassiveSkill(ESkillType.TianJiangLiuHUo)) {
if (IsTianJiangLiuHuo_time <= 1) {
skillId = ESkillType.TianJiangLiuHUo;
SKLogger.debug(`${battleRole.name}触发技能为:${skillId}`)
IsTianJiangLiuHuo_time++;
turnIndex--;
} else {//施法2次次数清零
IsTianJiangLiuHuo_time = 0;
IsTianJiangLiuHuo = false;
continue;
}
}
}
//春回大地
if (skillId == ESkillType.ChunHuiDaDi) {
for (let brid in this.plist) {
let brole = this.plist[brid];
if (brole.team_id == battleRole.team_id) {
if (brole.hasBuff(EMagicType.FORGET)) {
brole.cleanBuff(EMagicType.FORGET);
}
if (brole.hasBuff(EMagicType.SLEEP)) {
brole.cleanBuff(EMagicType.SLEEP);
}
if (brole.hasBuff(EMagicType.CHAOS)) {
brole.cleanBuff(EMagicType.CHAOS);
}
if (brole.hasBuff(EMagicType.TOXIN)) {
brole.cleanBuff(EMagicType.TOXIN);
}
if (brole.hasBuff(EMagicType.SEAL)) {
brole.cleanBuff(EMagicType.SEAL);
}
SKLogger.debug(`春回大地清除异常状态`);
}
}
}
//如果是灵猴 强制偷钱
if (this.battle_type == BattleType.LingHou && battleRole.isMonster()) {
skillId = ESkillType.StealMoney;
}
// 混乱状态-攻击改为普通攻击
if (battleRole.hasBuff(EMagicType.CHAOS)) {
if(battleRole.isDead()){
skillId = ESkillType.NormalDefSkill;
SKLogger.debug(`战斗:[${battleRole.onlyid}:${battleRole.name}]混乱中,进行防御!`);
}else{
skillId = ESkillType.NormalAtkSkill;
SKLogger.debug(`战斗:[${battleRole.onlyid}:${battleRole.name}]混乱中,进行普通攻击!`);
}
}
if (skillId != ESkillType.NormalAtkSkill && skillId != ESkillType.NormalDefSkill) {
//获取自身技能信息
let skillInfo = battleRole.getSkillInfo(skillId);
//不为普攻和防御时判定
if (skillId != ESkillType.NormalAtkSkill && skillId != ESkillType.NormalDefSkill) {
//找不到技能信息强转普攻
if (skillInfo == null) {
SKLogger.debug(`战斗:[${battleRole.onlyid}:${battleRole.name}]技能[${SkillUtil.getSkillName(skillId)}]不存在,改为普攻!`);
skillId = ESkillType.NormalAtkSkill;
} else if (skillInfo.cooldown > 0) { //cd时间未到 强转普攻
SKLogger.debug(`战斗:[${battleRole.onlyid}:${battleRole.name}]技能[${SkillUtil.getSkillName(skillId)}]冷却中,改为普攻!`);
skillId = ESkillType.NormalAtkSkill;
}
}
}
//获取系统技能
let skill = SkillUtil.getSkill(skillId);
//skill.useSkill(battleRole);
// 技能不存在改普攻
if (!skill) {
SKLogger.warn(`战斗:[${battleRole.onlyid}:${battleRole.name}]找不到技能[${skillId}]改为普通攻击`);
skillId = ESkillType.NormalAtkSkill;
skill = SkillUtil.getSkill(skillId);
}
//防御跳过
if (skillId == ESkillType.NormalDefSkill && this.nilin == 0) {
continue;
}
//技能回合限制判定 未达到技能可使用回合强转普攻
if (skill.limit_round > 0 && this.currentRound < skill.limit_round) {
skillId = ESkillType.NormalAtkSkill;
skill = SkillUtil.getSkill(skillId);
battleRole.act.actionid = skillId;
SKLogger.debug(`[${battleRole.onlyid}:${battleRole.name}]技能[${skill.skill_name}]改变普攻:${skill.limit_round}:${this.currentRound}`);
}
//判定技能使用次数限制
if (skill.limit_times > 0) {
//使用次数超过限制强转普攻
let limit_times = battleRole.used_skill[skillId];
if (limit_times >= skill.limit_times) {
skillId = ESkillType.NormalAtkSkill;
skill = SkillUtil.getSkill(skillId);
battleRole.act.actionid = skillId;
SKLogger.debug(`[${battleRole.onlyid}:${battleRole.name}]技能[${skill.skill_name}]改变普攻:${limit_times}:${skill.limit_times}`);
}
if (skill.limit_times > 0) {
battleRole.addLimitSkill(skillId); //增加技能使用次数
}
}
actionList.actionid = skillId;
//判定最后使用的技能
if (battleRole.last_skill != skillId && skillId != ESkillType.NormalAtkSkill) {
if (battleRole.online_state == 1) {
//更新最后使用的技能
battleRole.last_skill = skillId;
if (battleRole.source) {
battleRole.source.default_btl_skill = skillId;
}
} else {//离线状态使用最后一次的技能
actionList.actionid = battleRole.last_skill
}
}
//如果有隐身BUFF 移除隐身
let yinshen = battleRole.getBuffByEffect(EMagicType.HIDING);
if (yinshen) {
battleRole.removeBuff(yinshen.buff_id);
}
//是否可以蓝耗
let canSubMp = true;
// 是否可以使用技能
let canUseSkill = true;
// 普通战斗不计算蓝耗
// 兵临城下等部分技能 必须计算蓝耗
if (this.battle_type == BattleType.Normal && SkillUtil.forceMpSkill.indexOf(skillId) == -1) {
canSubMp = false;
}
// 怪物或伙伴 忽略蓝耗
if (battleRole.isMonster() || battleRole.isPartner()) {
canSubMp = false;
}
//耗蓝计算
if (canSubMp) {
//获取技能使用耗蓝结果
let info = skill.useSkill(battleRole);
//如果有信息返回 则更改不可使用技能状态
if (info.length > 0 && battleRole.online_state != 0) {
SKLogger.debug(`[${battleRole.onlyid}:${battleRole.name}]技能[${SkillUtil.getSkillName(skillId)}]无法使用[${info}]`)
battleRole.send('s2c_notice', {
strRichText: info
});
canUseSkill = false;
}
}
if (battleRole.hasBuff(EMagicType.FORGET)) {//遗忘buff几率不出手
let r = GameUtil.random(0, 10000);
if (r <= 5000) {
canUseSkill = false
}
}
if (battleRole.hasBuff(EMagicType.BAN)) {
let r = GameUtil.random(0, 10000);
if (r <= 5000) {
canUseSkill = false
}
}
//不能使用技能时跳过当前角色操作
if (!canUseSkill) {
SKLogger.debug(`[${battleRole.onlyid}:${battleRole.name}]技能[${SkillUtil.getSkillName(skillId)}]不能释放!`);
SKLogger.info(`1669行不出手原因${battleRole}不能使用技能`)
continue;
}
// 落日融金 血海深仇 技能计算
let deadNum = 0;
if (skillId == ESkillType.LuoRiRongJin || skillId == ESkillType.XueHaiShenChou) {
let n = 0;
let tid = battleRole.team_id;
let team = [];
if (tid == 1) {
team = this.campA.broles;
} else if (tid == 2) {
team = this.campB.broles;
}
for (const r of team) {
if ((r.isPlayer() || r.isPartner()) && r.isdead) {
n++;
}
}
deadNum = n;
}
// 技能效果
let params: any = {
level: battleRole.level,
relive: battleRole.relive,
qinmi: battleRole.qinmi,
profic: battleRole.getSkillProfic(skillId),
atk: battleRole.getAttr(EAttrTypeL1.ATK),
spd: battleRole.getAttr(EAttrTypeL1.SPD),
spdehan: battleRole.getAttr(EAttrTypeL1.SPD_ADD_EHAN),
braek: battleRole.getAttr(EAttrTypeL1.BREAK_EHAN),
sweep: battleRole.getAttr(EAttrTypeL1.SWEEP_EHAN),
cure: battleRole.getAttr(EAttrTypeL1.CURE_EHAN),
thud: battleRole.getAttr(EAttrTypeL1.THUD_EHAN),
san: battleRole.getAttr(EAttrTypeL1.BLOODRETURN_EHAN),
po: battleRole.getAttr(EAttrTypeL1.PHY_BREAK),
polv: battleRole.getAttr(EAttrTypeL1.PHY_BREAK_PROB),
du: battleRole.getAttr(EAttrTypeL1.TOXIN_EHAN),
guihuo: battleRole.getAttr(EAttrTypeL1.WILDFIRE),
huhuo: this.huhuo,
nilin: this.nilin,
deadnum: deadNum,
maxmp: battleRole.getAttr(EAttrTypeL1.MP_MAX),
maxhp: battleRole.getAttr(EAttrTypeL1.HP_MAX),
brole: battleRole,
}
//我见犹怜 狐火
if (skillId == ESkillType.WoJianYouLian) {
this.huhuo = 0;
}
//获得技能属性加成
let skillEffect = skill.getEffect(params);
// SKLogger.info(`使用技能为:${skill.skill_name}`)
// 如果技能有冷却 更新技能使用冷却
if (skill.cooldown > 0) {
let skillInfo = battleRole.getSkillInfo(skillId);
if (skillInfo) {
skillInfo.cooldown = skill.cooldown;
}
}
//目标数量
// let target_num = 1
// if (skillEffect != null && skillEffect.cnt > 1) {
// target_num = skillEffect.cnt + 1
// }
let target_num = skillEffect == null ? 1 : skillEffect.cnt;
if (battleRole.isPlayer()) { //幻影配饰
let player = PlayerMgr.shared.getPlayerByOnlyId(battleRole.onlyid);
if (player && skillId == ESkillType.NormalAtkSkill) {
let r = GameUtil.random(0, 10000);
if (player.baldric == 9191 && r < 4000) {
target_num = 3
}
if (player.baldric == 9192 && r < 6000) {
target_num = 3
}
if (player.baldric == 9193) {
target_num = 5
}
}
}
if (battleRole.isPet()) {
if (skillId == ESkillType.NormalAtkSkill && battleRole.hasPassiveSkill(ESkillType.YiJiDangQian)) {
let r = GameUtil.random(0, 10000);
target_num = 3;
if (r > 7000) {
target_num = 5;
}
}
}
if (battleRole.isPet()) {
if (skillId == ESkillType.TuMiHuaKai) {
// let r = GameUtil.random(0, 10000);
target_num = 3;
/*if(r > 7000){
target_num = 3;
}*/
}
}
//目标列表
let targetList: any[] = [];
// 确定主目标
let main_target_id = battleRole.act.target;
//获取主目标角色
let main_role = this.plist[main_target_id];
//利涉大川检测
target_num += this.lishedachuan(battleRole.onlyid, targetList, skillId, params);
//判断宝宝技能释放增加一个目标
//判断宝宝是否增加一次攻击
if (battleRole.isPlayer()) {
let player = PlayerMgr.shared.getPlayerByOnlyId(battleRole.onlyid);
if (player) {
let baby = player.BabyMgr.GetBattleBaby()
if (baby != null && baby.HasPlaySkill() == false) {
if (baby.IsAddTarget(skillId, battleRole)) {
target_num += 1
} else {
if (BattleType.Normal == this.battle_type || this.battle_type == BattleType.LingHou) {
if (double_hit_time == 0) {
if (baby.IsHitTwice(skillId, battleRole)) {
turnIndex--;
double_hit_time++;
}
} else {
double_hit_time = 0
}
}
}
}
if (baby != null && baby.IsAddTarget(skillId, battleRole)) {
target_num += 1
}
if (baby != null) {
let type = baby.GetPlaySkillType()
if (type == 1) {
actionList.babyskill = baby.GetPlaySkillName()
}
}
}
}
//没有混乱 主目标存在未狗带且无隐身时 添加到目标列表
if (!battleRole.hasBuff(EMagicType.CHAOS)) {
if (main_role && !main_role.isdead && !main_role.hasBuff(EMagicType.HIDING)) {
targetList.push(main_target_id);
}
}
//移花接木
if (skillId == ESkillType.YiHuaJieMu) {
let livelist: any = [];
let brolelist: any = [];
if (main_role && !main_role.isdead) {
let buflist: any = [];
buflist = main_role.buff_list;
main_role.buff_list = battleRole.buff_list;
battleRole.buff_list = buflist;
}
for (let i = 0; i < this.plist.length; i++) {
let brole = this.plist[i];
if (brole.team_id == battleRole.team_id) {
brolelist.push(brole);
if (!brole.isdead) {
livelist.push(brole);
}
}
}
if ((brolelist.length / 2) > livelist.length) {
if (battleRole.hasBuff(EMagicType.SLEEP)) {
battleRole.cleanBuff(EMagicType.SLEEP);
}
if (battleRole.hasBuff(EMagicType.CHAOS)) {
battleRole.cleanBuff(EMagicType.CHAOS);
}
if (battleRole.hasBuff(EMagicType.SEAL)) {
battleRole.cleanBuff(EMagicType.SEAL);
}
}
}
//初始化分裂状态
let fenlie = false;
// 如果混乱中,攻击改为全体目标
if (battleRole.hasBuff(EMagicType.CHAOS)) {
// 判断混乱后 天罡战气 技能
if (battleRole.hasPassiveSkill(ESkillType.TianGangZhanQi)) {
targetList = this.findRandomTarge(battleRole.onlyid, target_num, targetList, 1, skill);
} else {
targetList = this.findRandomTarge(battleRole.onlyid, target_num, targetList, 3);
}
} else {
// 如果是子虚乌有 就直接放入 自己与同队随机一人
if (skillId == ESkillType.ZiXuWuYou) {
targetList.push(battleRole.onlyid);
// SKLogger.debug(`战斗:子虚乌有加入施法目标[${battleRole.onlyid}:${battleRole.name}]`);
} else {
if (SkillUtil.isSelfBuffSkill(skillId)) {
targetList = this.findRandomTarge(battleRole.onlyid, target_num, targetList, 2, skill);
} else {
if (skillId == ESkillType.NormalAtkSkill) {
fenlie = battleRole.fenLie();
let r = GameUtil.random(0, 10000);
if (fenlie) {
target_num += 1;
if (r <= 3000 && battleRole.living_type == 1) {
target_num += 1;
if (r <= 2000) {
target_num += 1;
}
}
}
}
targetList = this.findRandomTarge(battleRole.onlyid, target_num, targetList, 1, skill);
}
}
}
//荼蘼花开判定
if (battleRole.isPet() && battleRole.hasPassiveSkill(ESkillType.TuMiHuaKai)) {
for (let trindex = 0; trindex < targetList.length; trindex++) {
let troleid = targetList[trindex];
let targetRole: BattleRole = this.plist[troleid];
if (!battleRole.hasBuff(ESkillType.TuMiHuaKai)) {
let skill = SkillUtil.getSkill(ESkillType.TuMiHuaKai);
//params.atk = params.atk*0.35
let buff = new Buff(ESkillType.TuMiHuaKai, skill.getEffect(params));
SKLogger.warn("----------荼蘼花开-----555-----" + buff.buff_id)
buff.effects["hurt"] = buff.effects["hurt"] * 0.45
if (SkillUtil.isAtkSkill(skillId) && !battleRole.hasBuff(EMagicType.CHAOS) && this.isSameTeam(battleRole.onlyid, targetRole.onlyid)) {
buff.effects["hurt"] = 1
}
targetRole.addBuff(buff);
// buff.active(targetRole)
}
}
}
if (targetList.length < 1) {
SKLogger.debug(`战斗:角色[${battleRole.onlyid}:${battleRole.name}]没有攻击目标跳过!`)
SKLogger.info(`1839行不出手原因${battleRole.name}没有攻击目标`)
continue;
}
let targetInfo: string = "";
for (let onlyid of targetList) {
let target = this.plist[onlyid];
targetInfo += `[${target.onlyid}:${target.name}]`
}
if (this.debug == BattleDebug.MY) {
if (battleRole.team_id == 1) {
SKLogger.debug(`我方[${battleRole.onlyid}:${battleRole.name}]第${this.currentRound}回合:对${targetInfo}技能[${SkillUtil.getSkillName(skillId)}]攻击:`);
}
} else {
SKLogger.debug(`${battleRole.team_id == 1 ? `我方` : `敌方`}[${battleRole.onlyid}:${battleRole.name}]第${this.currentRound}回合:使用技能[${SkillUtil.getSkillName(skillId)}]攻击:${targetInfo}`);
}
// 计算悬刃 遗患 等 出手前技能
if (skillId != ESkillType.NormalAtkSkill && skillId != ESkillType.StealMoney) {
let camp = this.campA;
if (battleRole.team_id == 1) {
camp = this.campB;
}
let huawu = this.hasStageEffect(camp, ESkillType.HuaWu);
let huawu1 = this.hasHuaWu(battleRole);
// 有场景化无特效
if (huawu > 0 || huawu1 > 0) {
console.log("huawu++++++++++++")
this.setStageEffect(camp, ESkillType.HuaWu, 0);
this.huawu_flag = 0;
actbef.huawu = true;
actionList.actbef = SKDataUtil.toJson(actbef, "{}");
actionList.act = [];
roundInfo.acts.push(actionList);
SKLogger.debug(`战斗:角色[${battleRole.onlyid}:${battleRole.name}]中了化无`);
continue;
}
let xuanren_hurt = this.hasStageEffect(camp, ESkillType.XuanRen);
if (xuanren_hurt > 0) {
this.setStageEffect(camp, ESkillType.XuanRen, 0);
battleRole.subHP(-xuanren_hurt, ESubType.XUAN_REN);
actbef.xuanren = xuanren_hurt;
}
let yihuan_hurt = this.hasStageEffect(camp, ESkillType.YiHuan);
if (yihuan_hurt > 0) {
this.setStageEffect(camp, ESkillType.YiHuan, 0);
battleRole.subMP(-yihuan_hurt, ESubType.YI_HUAN);
actbef.yihuan = yihuan_hurt;
}
if (battleRole.isdead) {
actbef.hp = battleRole.getHP();
actbef.mp = battleRole.getMP();
actbef.isdead = battleRole.isDead() ? 1 : 0;
actionList.actbef = SKDataUtil.toJson(actbef, "{}");
actionList.act = [];
roundInfo.acts.push(actionList);
continue;
}
}
// 吸血池
let poolHP = [];
let tgs = [];
if (battleRole.living_type == 1) {
let brole = PlayerMgr.shared.getPlayerByOnlyId(battleRole.onlyid);
let actskill: any = {};
if (brole && brole.race == 5) {
let btlrole: BattleRole = this.plist[brole.onlyid];
actskill.targetid = this.nilin;
if (this.nilin > 0) {
let skill = SkillUtil.getSkill(this.nilin);
let effect = skill.getEffect(brole.attr1);
let buff = new Buff(skill, effect);
btlrole.addBuff(buff);
}
}
tgs.push(actskill);
}
let bmingzhong = battleRole.getAttr(EAttrTypeL1.PHY_HIT) + 80;
let actaffix: any = {} // 被攻击者后续
let fenhuatimes = 0;
for (let trindex = 0; trindex < targetList.length; trindex++) {
let troleid = targetList[trindex];
let targetRole: BattleRole = this.plist[troleid];
if (targetRole == null) {
continue;
}
let ntr = SKDataUtil.clone(target);
ntr.targetid = troleid;
tgs.push(ntr);
// 封印状态
if (targetRole.hasBuff(EMagicType.SEAL)) {
ntr.hp = targetRole.getHP();
ntr.mp = targetRole.getMP();
ntr.isdead = targetRole.isDead() ? 1 : 0;
if (skill.skill_type == EMagicType.SEAL && skillEffect.round > 1) {
targetRole.checkReplaceBuffRound(skillId, skillEffect.round);
}
ntr.bufflist = targetRole.getBuffsSkillId();
SKLogger.info(`[${targetRole.onlyid}:${targetRole.name}]被封印跳过`);
continue;
}
let hkType = GameUtil.skillTypeStrengthen[skill.skill_type] || -1;
let hkValue = hkType > 0 ? battleRole.getAttr(hkType) : 0; // 忽视
let kType = GameUtil.skillTypeKangXing[skill.skill_type];
if (kType == undefined || kType == null) {
kType = -1;
}
let kValue = kType >= 0 ? targetRole.getAttr(kType) : 0; // 抗性
//是否装备黄鹤阵, 获得冰混睡忘抗性加成
// if(skill.skill_type == EMagicType.SEAL || skill.skill_type == EMagicType.CHAOS || skill.skill_type == EMagicType.SLEEP || skill.skill_type == EMagicType.FORGET){
// if(targetRole.isPlayer()){
// let player = PlayerMgr.shared.getPlayerByOnlyId(targetRole.onlyid);
// if(player && player.StarMgr.EquipID == 7){
// let star = player.StarMgr.GetStarByID(7)
// let buf = star.Level * 0.003
// kValue = Math.floor(kValue * (1 + buf))
// SKLogger.debug(`[${targetRole.onlyid}:${targetRole.name}]获得冰混睡忘抗性加成:${kValue}`)
// }
// }
// }
let subValue = hkValue - kValue;
// SKLogger.debug(`[${battleRole.name}]忽视计算[${GameUtil.attrTypeL1Name[hkType]}]=${hkValue}`);
// SKLogger.debug(`[${targetRole.name}]抗性计算:[${GameUtil.attrTypeL1Name[kType]}]=${kValue}`);
// 判断控制技能闪避
if (SkillUtil.isControlSkill(skillId)) {
if (this.battle_type == BattleType.PK || this.battle_type == BattleType.AREAN || this.battle_type == BattleType.Sat || this.battle_type == BattleType.ShuiLu || this.battle_type == BattleType.Force) {
let rand = GameUtil.random(0, 10000);
if (subValue > 40) {
if (rand >= 5000) {
ntr.respone = EBtlRespone.DODGE;
ntr.hp = targetRole.getHP();
ntr.mp = targetRole.getMP();
ntr.isdead = targetRole.isDead() ? 1 : 0;
ntr.bufflist = targetRole.getBuffsSkillId();
// SKLogger.debug(`[${battleRole.onlyid}:${battleRole.name}]的控制技能[${SkillUtil.getSkillName(skillId)}]被目标[${targetRole.onlyid}:${targetRole.name}]闪避跳过`);
continue;
}
}
if (subValue < 40 && subValue >= 0) {
if (rand >= 3000) {
ntr.respone = EBtlRespone.DODGE;
ntr.hp = targetRole.getHP();
ntr.mp = targetRole.getMP();
ntr.isdead = targetRole.isDead() ? 1 : 0;
ntr.bufflist = targetRole.getBuffsSkillId();
// SKLogger.debug(`[${battleRole.onlyid}:${battleRole.name}]的控制技能[${SkillUtil.getSkillName(skillId)}]被目标[${targetRole.onlyid}:${targetRole.name}]闪避跳过`);
continue;
}
}
if (subValue < 0) {
if (rand >= 1000) {
ntr.respone = EBtlRespone.DODGE;
ntr.hp = targetRole.getHP();
ntr.mp = targetRole.getMP();
ntr.isdead = targetRole.isDead() ? 1 : 0;
ntr.bufflist = targetRole.getBuffsSkillId();
// SKLogger.debug(`[${battleRole.onlyid}:${battleRole.name}]的控制技能[${SkillUtil.getSkillName(skillId)}]被目标[${targetRole.onlyid}:${targetRole.name}]闪避跳过`);
continue;
}
}
} else {
let temp = (subValue + 110) * 100;
let rand = GameUtil.random(0, 10000);
if (temp <= rand) {
ntr.respone = EBtlRespone.DODGE;
ntr.hp = targetRole.getHP();
ntr.mp = targetRole.getMP();
ntr.isdead = targetRole.isDead() ? 1 : 0;
ntr.bufflist = targetRole.getBuffsSkillId();
// SKLogger.debug(`[${battleRole.onlyid}:${battleRole.name}]的控制技能[${SkillUtil.getSkillName(skillId)}]被目标[${targetRole.onlyid}:${targetRole.name}]闪避跳过`);
continue;
}
}
}
// 判断闪避命中
if (SkillUtil.isCanShanbiSkill(skillId)) {
let shanbi = targetRole.getAttr(EAttrTypeL1.PHY_DODGE);
let rand = GameUtil.random(0, 10000);
if (rand > (bmingzhong - shanbi) * 100) {
ntr.respone = EBtlRespone.DODGE;
ntr.hp = targetRole.getHP();
ntr.mp = targetRole.getMP();
ntr.isdead = targetRole.isDead() ? 1 : 0;
ntr.bufflist = targetRole.getBuffsSkillId();
// SKLogger.debug(`[${targetRole.onlyid}:${targetRole.name}]普攻闪避跳过`);
continue;
}
}
// 伤害
let respone = EBtlRespone.NOTHING;
let hurt = skillEffect == null ? 1 : skillEffect.hurt;
//是否装备金牛阵,获得普工加成
SKLogger.debug(`技能类型:${skillId} 普工ID:${ESkillType.NormalAtkSkill}`)
if (skillId == ESkillType.NormalAtkSkill) {
let player
if (battleRole.isPlayer()) {
player = PlayerMgr.shared.getPlayerByOnlyId(battleRole.onlyid);
}
if (battleRole.isPet()) {
player = PlayerMgr.shared.getPlayerByOnlyId(battleRole.own_onlyid);
}
if (player != null) {
SKLogger.debug(`技能类型:${skillId} equipid: ${player.StarMgr.EquipID}`)
if (player.StarMgr.EquipID == 4) {
let star = player.StarMgr.GetStarByID(4)
let buf = star.Level * 0.003
hurt = Math.floor(hurt * (1 + buf))
SKLogger.debug(`[${battleRole.onlyid}:${battleRole.name}]的普通攻击获得伤害加成为:${hurt}]`);
}
}
}
SKLogger.debug(`技能类型:${skill.skill_type} 震慑:${EMagicType.FRIGHTEN}`)
//主动技能风火雷电鬼火 判断是否装备苍狼阵,获得技能伤害加成
if (skill.skill_type == EMagicType.WATER || skill.skill_type == EMagicType.FIRE || skill.skill_type == EMagicType.THUNDER || skill.skill_type == EMagicType.WIND || skill.skill_type == EMagicType.GHOST_FIRE) {
let player
if (battleRole.isPlayer()) {
player = PlayerMgr.shared.getPlayerByOnlyId(battleRole.onlyid);
}
if (battleRole.isPet()) {
player = PlayerMgr.shared.getPlayerByOnlyId(battleRole.own_onlyid);
}
if (player != null) {
if (player.StarMgr.EquipID == 6) {
let star = player.StarMgr.GetStarByID(6)
let buf = star.Level * 0.003
hurt = Math.floor(hurt * (1 + buf))
SKLogger.debug(`[${battleRole.onlyid}:${battleRole.name}]的技能[${SkillUtil.getSkillName(skillId)}]获得伤害加成为:${hurt}`);
}
}
}
//反震
if (targetRole.isPlayer() || targetRole.isPet()) {
let player
if (targetRole.isPlayer()) {
player = PlayerMgr.shared.getPlayerByOnlyId(targetRole.onlyid);
}
if (targetRole.isPet()) {
player = PlayerMgr.shared.getPlayerByOnlyId(battleRole.own_onlyid);
}
if (targetRole.getAttr(EAttrTypeL1.PHY_REBOUND) > 0) {
let rebound = targetRole.getAttr(EAttrTypeL1.PHY_REBOUND)
let r = GameUtil.random(0, 10000);
let rate = targetRole.getAttr(EAttrTypeL1.PHY_REBOUND_PROB);
if (r < rate * 100) {
fan = hurt + Math.floor(hurt * rebound / 100);
battleRole.subHP(-fan);
ntr.selfid = battleRole.onlyid;
ntr.selfdead = battleRole.isDead() ? 1 : 0;
ntr.fan = -fan;
ntr.selfhp = battleRole.getHP();
}
}
}
//天策符判断
if (battleRole.living_type == 1) {
let rand = GameUtil.random(0, 10000);
//千钧符 飞花溅玉
if (skill.skill_id == ESkillType.NormalAtkSkill) {
if (battleRole.hasOfudaSkill(ESkillType.FeiHuaJianYv1) || battleRole.hasOfudaSkill(ESkillType.FeiHuaJianYv2) || battleRole.hasOfudaSkill(ESkillType.FeiHuaJianYv3)) {
if (rand >= 5500) {
respone = EBtlRespone.CRITICAL_HIT
hurt = hurt * 3
let trole2 = this.findRandomTeamTarget(targetRole.onlyid);
if (trole2 && trole2.isDead() == false && trole2.team_id != battleRole.team_id) {
trole2.subHP(-hurt);
actaffix.geshan = {
roleid: trole2.onlyid,
respone: respone,
num: -hurt,
hp: trole2.getHP(),
mp: trole2.getMP(),
isdead: trole2.isdead ? 1 : 0,
};
}
}
}
}
//千钧符 陌上开花
if (battleRole.act.acttype = EActType.SKILL && skill.skill_id != ESkillType.NormalAtkSkill && skill.skill_id != ESkillType.NormalDefSkill) {
if (battleRole.hasOfudaSkill(ESkillType.MoShangKaiHua1) || battleRole.hasOfudaSkill(ESkillType.MoShangKaiHua2) || battleRole.hasOfudaSkill(ESkillType.MoShangKaiHua3)) {
if (rand >= 4500 && double_hit_time == 0) {
battleRole.act.actionid = ESkillType.NormalAtkSkill;
turnIndex--;
double_hit_time++;
}
}
}
//千钧符 金石为开
if (battleRole.hasOfudaSkill(ESkillType.JinShiWeiKai1) || battleRole.hasOfudaSkill(ESkillType.JinShiWeiKai2) || battleRole.hasOfudaSkill(ESkillType.JinShiWeiKai3)) {
if (skill.skill_type == EMagicType.WATER || skill.skill_type == EMagicType.FIRE || skill.skill_type == EMagicType.THUNDER || skill.skill_type == EMagicType.WIND || skill.skill_type == EMagicType.TOXIN || skill.skill_type == EMagicType.GHOST_FIRE || skill.skill_type == EMagicType.THREE_CORPSE) {
if (this.jswk_count == 0) {//第一次使用该类型技能 赋值
this.jswk_type = skill.skill_type;
this.jswk_count++;
} else {
if (this.jswk_type == skill.skill_type) {//类型符合 次数+1
this.jswk_count++;
hurt = hurt * (1 + this.jswk_count / 100)
} else {//使用其他类型的技能
this.jswk_count = 0;
}
}
}
}
if (skill.skill_type == EMagicType.TOXIN) { //天策符 堆月
if (battleRole.hasOfudaSkill(ESkillType.DuiYue1)) {
hurt = Math.floor((this.currentRound * 0.07) * hurt + hurt);
}
if (battleRole.hasOfudaSkill(ESkillType.DuiYue2)) {
hurt = Math.floor((this.currentRound * 0.1) * hurt + hurt);
}
if (battleRole.hasOfudaSkill(ESkillType.DuiYue3)) {
hurt = Math.floor((this.currentRound * 0.15) * hurt + hurt);
}
}
//千钧符-安神定魄
if (skill.skill_type == EMagicType.GHOST_FIRE || skill.skill_type == EMagicType.THREE_CORPSE) {
let hp = battleRole.getAttr(EAttrTypeL1.HP_MAX);
if (battleRole.hasOfudaSkill(ESkillType.AnShenDingPo1) && targetRole.isPet()) {
battleRole.subHP(Math.floor(hp * 0.07))
ntr.selfid = battleRole.onlyid;
ntr.selfhp = battleRole.getHP();
ntr.recover = Math.floor(hp * 0.07);
}
if (battleRole.hasOfudaSkill(ESkillType.AnShenDingPo2) && targetRole.isPet()) {
battleRole.subHP(Math.floor(hp * 0.1))
ntr.selfid = battleRole.onlyid;
ntr.selfhp = battleRole.getHP();
ntr.recover = Math.floor(hp * 0.1);
}
if (battleRole.hasOfudaSkill(ESkillType.AnShenDingPo3) && targetRole.isPet()) {
battleRole.subHP(Math.floor(hp * 0.15))
ntr.selfid = battleRole.onlyid;
ntr.selfhp = battleRole.getHP();
ntr.recover = Math.floor(hp * 0.15);
}
}
if (skill.skill_type == EMagicType.CHAOS) {
let hp = battleRole.getAttr(EAttrTypeL1.HP_MAX);
if (battleRole.hasOfudaSkill(ESkillType.HunE1)) {
battleRole.subHP(Math.floor(hp * 0.07))
ntr.selfid = battleRole.onlyid;
ntr.selfhp = battleRole.getHP();
ntr.recover = Math.floor(hp * 0.07);
}
if (battleRole.hasOfudaSkill(ESkillType.HunE2)) {
battleRole.subHP(Math.floor(hp * 0.1))
ntr.selfid = battleRole.onlyid;
ntr.selfhp = battleRole.getHP();
ntr.recover = Math.floor(hp * 0.1);
}
if (battleRole.hasOfudaSkill(ESkillType.HunE3)) {
battleRole.subHP(Math.floor(hp * 0.15))
ntr.selfid = battleRole.onlyid;
ntr.selfhp = battleRole.getHP();
ntr.recover = Math.floor(hp * 0.15);
}
}
if (skill.skill_type == EMagicType.FORGET) { //天策符 忘尘
let hp = battleRole.getAttr(EAttrTypeL1.HP_MAX);
if (battleRole.hasOfudaSkill(ESkillType.WangChen1)) {
battleRole.subHP(Math.floor(hp * 0.07))
ntr.selfid = battleRole.onlyid;
ntr.selfhp = battleRole.getHP();
ntr.recover = Math.floor(hp * 0.07);
}
if (battleRole.hasOfudaSkill(ESkillType.WangChen2)) {
battleRole.subHP(Math.floor(hp * 0.1))
ntr.selfid = battleRole.onlyid;
ntr.selfhp = battleRole.getHP();
ntr.recover = Math.floor(hp * 0.1);
}
if (battleRole.hasOfudaSkill(ESkillType.WangChen3)) {
battleRole.subHP(Math.floor(hp * 0.15))
ntr.selfid = battleRole.onlyid;
ntr.selfhp = battleRole.getHP();
ntr.recover = Math.floor(hp * 0.15);
}
}
if (this.battle_type == BattleType.Normal) {
let ms1 = new Date().getMilliseconds();
let hp = battleRole.getAttr(EAttrTypeL1.HP_MAX);
if (battleRole.hasOfudaSkill(ESkillType.YinXue1)) { //天策符 饮血
battleRole.subHP(Math.floor(hp * 0.07))
ntr.selfid = battleRole.onlyid;
ntr.selfhp = battleRole.getHP();
ntr.recover = Math.floor(hp * 0.07);
}
if (battleRole.hasOfudaSkill(ESkillType.YinXue2)) {
battleRole.subHP(Math.floor(hp * 0.1))
ntr.selfid = battleRole.onlyid;
ntr.selfhp = battleRole.getHP();
ntr.recover = Math.floor(hp * 0.1);
}
if (battleRole.hasOfudaSkill(ESkillType.YinXue3)) {
battleRole.subHP(Math.floor(hp * 0.15))
ntr.selfid = battleRole.onlyid;
ntr.selfhp = battleRole.getHP();
ntr.recover = Math.floor(hp * 0.15);
}
let ms2 = new Date().getMilliseconds();
let time = ms2 - ms1;
SKLogger.info(`天策符-饮血-运行时间:${time}ms`);
}
if (this.battle_type != BattleType.Normal) { //天策符 攻心 PVP
if (skill.skill_type == EMagicType.THREE_CORPSE && (this.currentRound % 2) == 0 && skillEffect.cnt == 1) {
if (battleRole.hasOfudaSkill(ESkillType.SanShiGongXin1) || battleRole.hasOfudaSkill(ESkillType.SanShiGongXin2) || battleRole.hasOfudaSkill(ESkillType.SanShiGongXin3)) { //天策符 三尸攻心
hurt = hurt * 1.5;
}
}
if (skill.skill_type == EMagicType.GHOST_FIRE && (this.currentRound % 2) == 0 && skillEffect.cnt == 1) {
if (battleRole.hasOfudaSkill(ESkillType.GuiHuoGongXin1) || battleRole.hasOfudaSkill(ESkillType.GuiHuoGongXin2) || battleRole.hasOfudaSkill(ESkillType.GuiHuoGongXin3)) { //天策符 鬼火攻心
hurt = hurt * 1.5;
}
}
if (skill.skill_type == EMagicType.WATER && (this.currentRound % 2) == 0 && skillEffect.cnt == 1) {
if (battleRole.hasOfudaSkill(ESkillType.ShuiXiGongXin1) || battleRole.hasOfudaSkill(ESkillType.ShuiXiGongXin2) || battleRole.hasOfudaSkill(ESkillType.ShuiXiGongXin3)) { //天策符 水系攻心
hurt = hurt * 1.5;
}
}
if (skill.skill_type == EMagicType.FIRE && (this.currentRound % 2) == 0 && skillEffect.cnt == 1) {
if (battleRole.hasOfudaSkill(ESkillType.HuoXiGongXin1) || battleRole.hasOfudaSkill(ESkillType.HuoXiGongXin2) || battleRole.hasOfudaSkill(ESkillType.HuoXiGongXin3)) { //天策符 火系攻心
hurt = hurt * 1.5;
}
}
if (skill.skill_type == EMagicType.THUNDER && (this.currentRound % 2) == 0 && skillEffect.cnt == 1) {
if (battleRole.hasOfudaSkill(ESkillType.LeiXiGongXin1) || battleRole.hasOfudaSkill(ESkillType.LeiXiGongXin2) || battleRole.hasOfudaSkill(ESkillType.LeiXiGongXin3)) { //天策符 雷系攻心
hurt = hurt * 1.5;
}
}
if (battleRole.hasOfudaSkill(ESkillType.GongXin1) || battleRole.hasOfudaSkill(ESkillType.GongXin2) || battleRole.hasOfudaSkill(ESkillType.GongXin3)) { //天策符 攻心
if (this.currentRound % 5 == 0 && skill.skill_type != ESkillType.NormalAtkSkill && skillEffect.cnt == 1) {
hurt = hurt * 1.5;
}
}
} else {//天策符 攻心 PVE
if (skill.skill_type == EMagicType.THREE_CORPSE && skillEffect.cnt == 1) {
if (battleRole.hasOfudaSkill(ESkillType.SanShiGongXin1) || battleRole.hasOfudaSkill(ESkillType.SanShiGongXin2) || battleRole.hasOfudaSkill(ESkillType.SanShiGongXin3)) { //天策符 三尸攻心
hurt = hurt * 1.5;
}
}
if (skill.skill_type == EMagicType.GHOST_FIRE && skillEffect.cnt == 1) {
if (battleRole.hasOfudaSkill(ESkillType.GuiHuoGongXin1) || battleRole.hasOfudaSkill(ESkillType.GuiHuoGongXin2) || battleRole.hasOfudaSkill(ESkillType.GuiHuoGongXin3)) { //天策符 鬼火攻心
hurt = hurt * 1.5;
}
}
if (skill.skill_type == EMagicType.WATER && skillEffect.cnt == 1) {
if (battleRole.hasOfudaSkill(ESkillType.ShuiXiGongXin1) || battleRole.hasOfudaSkill(ESkillType.ShuiXiGongXin2) || battleRole.hasOfudaSkill(ESkillType.ShuiXiGongXin3)) { //天策符 水系攻心
hurt = hurt * 1.5;
}
}
if (skill.skill_type == EMagicType.FIRE && skillEffect.cnt == 1) {
if (battleRole.hasOfudaSkill(ESkillType.HuoXiGongXin1) || battleRole.hasOfudaSkill(ESkillType.HuoXiGongXin2) || battleRole.hasOfudaSkill(ESkillType.HuoXiGongXin3)) { //天策符 火系攻心
hurt = hurt * 1.5;
}
}
if (skill.skill_type == EMagicType.THUNDER && skillEffect.cnt == 1) {
if (battleRole.hasOfudaSkill(ESkillType.LeiXiGongXin1) || battleRole.hasOfudaSkill(ESkillType.LeiXiGongXin2) || battleRole.hasOfudaSkill(ESkillType.LeiXiGongXin3)) { //天策符 雷系攻心
hurt = hurt * 1.5;
}
}
if (battleRole.hasOfudaSkill(ESkillType.GongXin1) || battleRole.hasOfudaSkill(ESkillType.GongXin2) || battleRole.hasOfudaSkill(ESkillType.GongXin3)) { //天策符 攻心
if (skill.skill_type != ESkillType.NormalAtkSkill && skillEffect.cnt == 1) {
hurt = hurt * 1.5;
}
}
}
}
if (battleRole.living_type == 4) {
let rand = GameUtil.random(0, 10000);
let owner = this.plist[battleRole.own_onlyid];
if (owner) {
//高级慈乌反哺
if (battleRole.hasPassiveSkill(ESkillType.HighCiWuFanBu) && skill.skill_type == EMagicType.PHYSICS) {
if (rand <= 4000) {
owner.subHP(Math.floor(skillEffect.hurt * 0.5))
ntr.selfid = owner.onlyid;
ntr.selfhp = owner.getHP();
ntr.recover = Math.floor(skillEffect.hurt * 0.5);
}
}
//御兽符 吸血
if (owner.hasOfudaSkill(ESkillType.XiXue1)) {
if (rand >= 6500) {
battleRole.subHP(Math.floor(hurt * 0.07))
ntr.selfid = battleRole.onlyid;
ntr.selfhp = battleRole.getHP();
ntr.recover = Math.floor(hurt * 0.07);
}
}
if (owner.hasOfudaSkill(ESkillType.XiXue2)) {
if (rand >= 5500) {
battleRole.subHP(Math.floor(hurt * 0.1))
ntr.selfid = battleRole.onlyid;
ntr.selfhp = battleRole.getHP();
ntr.recover = Math.floor(hurt * 0.1);
}
}
if (owner.hasOfudaSkill(ESkillType.XiXue3)) {
if (rand >= 5000) {
battleRole.subHP(Math.floor(hurt * 0.15))
ntr.selfid = battleRole.onlyid;
ntr.selfhp = battleRole.getHP();
ntr.recover = Math.floor(hurt * 0.15);
}
}
//御兽符-潜龙在渊
if (skillId == ESkillType.TianMoJieTi || skillId == ESkillType.FenGuangHuaYing || skillId == ESkillType.QingMianLiaoYa || skillId == ESkillType.XiaoLouYeKu ||
skillId == ESkillType.HighTianMoJieTi || skillId == ESkillType.HighFenGuangHuaYing || skillId == ESkillType.HighQingMianLiaoYa || skillId == ESkillType.HighXiaoLouYeKu ||
skill.skill_type == EMagicType.FIRE || skill.skill_type == EMagicType.PHYSICS || skill.skill_type == EMagicType.WATER || skill.skill_type == EMagicType.WIND ||
skill.skill_type == EMagicType.GHOST_FIRE || skill.skill_type == EMagicType.THUNDER) {
if (owner.hasOfudaSkill(ESkillType.QianLongZaiYuan1)) {
hurt = Math.floor(hurt * (1 + this.currentRound / 100 + 0.7))
}
if (owner.hasOfudaSkill(ESkillType.QianLongZaiYuan2)) {
hurt = Math.floor(hurt * (1 + this.currentRound / 100 + 1))
}
if (owner.hasOfudaSkill(ESkillType.QianLongZaiYuan3)) {
hurt = Math.floor(hurt * (1 + this.currentRound / 100 + 2))
}
}
//狂澜
if (skill.skill_type == EMagicType.FIRE || skill.skill_type == EMagicType.WATER || skill.skill_type == EMagicType.WIND ||
skill.skill_type == EMagicType.GHOST_FIRE || skill.skill_type == EMagicType.THUNDER) {
if (owner.hasOfudaSkill(ESkillType.KuangLan1)) {
hurt = Math.floor(hurt * 1.3)
}
if (owner.hasOfudaSkill(ESkillType.KuangLan2)) {
hurt = Math.floor(hurt * 1.5)
}
if (owner.hasOfudaSkill(ESkillType.KuangLan3)) {
hurt = Math.floor(hurt * 1.7)
}
}
//御兽符-淬毒
if (skill.skill_type == EMagicType.PHYSICS) {
let buffskill = SkillUtil.getSkill(ESkillType.WanDuGongXin)
let buffeffect = buffskill.getEffect(params);
buffeffect.hurt = hurt;
buffeffect.round = 2;
let buff = new Buff(buffskill, buffeffect);
buff.source = battleRole.onlyid
if (owner.hasOfudaSkill(ESkillType.CuiDu1)) {
if (rand >= 6500) {
targetRole.addBuff(buff);
}
}
if (owner.hasOfudaSkill(ESkillType.CuiDu2)) {
if (rand >= 5500) {
targetRole.addBuff(buff);
}
}
if (owner.hasOfudaSkill(ESkillType.CuiDu3)) {
if (rand >= 5000) {
targetRole.addBuff(buff);
}
}
}
}
}
if (battleRole.isPlayer()) {
let player = PlayerMgr.shared.getPlayerByOnlyId(battleRole.onlyid);
if (player) {
//计算残梦配饰伤害加成
if (player.race == 2 || player.race == 4) {
if (player.baldric == 9204) {
if (player.attr1[EAttrTypeL2.LINGXING] > 550) {
hurt = hurt + ((player.attr1[EAttrTypeL2.LINGXING] - 550) * 20);
}
} else if (player.baldric == 9205) {
if (player.attr1[EAttrTypeL2.LINGXING] > 550) {
hurt = hurt + ((player.attr1[EAttrTypeL2.LINGXING] - 550) * 40);
}
}
}
//司命佩饰
if (player.race == 4) {
if (player.baldric == 9268) {
if (skillId == 1032 && this.currentRound > 1) {
let kbstr = battleRole.getKuangBaoStr(skill.skill_type);
hurt = Math.floor(hurt * (1.5 + kbstr / 100));
respone = EBtlRespone.CRITICAL_HIT;
// SKLogger.debug(`伤害计算:技能[${SkillUtil.getSkillName(skillId)}]狂暴伤害${hurt}`);
}
} else if (player.baldric == 9269) {
if (skillId == 1032 && this.currentRound > 1) {
let kbstr = battleRole.getKuangBaoStr(skill.skill_type);
hurt = Math.floor(hurt * (1.6 + kbstr / 100));
respone = EBtlRespone.CRITICAL_HIT;
// SKLogger.debug(`伤害计算:技能[${SkillUtil.getSkillName(skillId)}]狂暴伤害${hurt}`);
}
}
}
//计算相柳配饰伤害加成
if (player.race == 1) {
if (player.baldric == 9246) {
let add = 0;
let r = GameUtil.random(0, 10000);
if (r < 40 * 100) {
add = 10;
}
hurt += hurt * (add / 100);
} else if (player.baldric == 9247) {
let add = 0;
let r = GameUtil.random(0, 10000);
if (r < 40 * 100) {
add = 50;
}
if (player.attr1[EAttrTypeL2.GENGU] / 200 > 0) {
add += Math.floor(10 * player.attr1[EAttrTypeL2.GENGU] / 200);
}
hurt += hurt * (add / 100);
}
}
//刑天配饰
if (player.race == 3) {
if (player.baldric == 9231) {
if (skill.skill_type == EMagicType.FRIGHTEN && this.currentRound == 1) {
for (let key of targetList) {
let target = this.plist[key];
if (target) {
target.setAttr(EAttrTypeL1.K_WIND, Math.floor(target.roleattr[EAttrTypeL1.K_WIND] - target.roleattr[EAttrTypeL1.K_WIND] * 0.15));
target.setAttr(EAttrTypeL1.K_THUNDER, Math.floor(target.roleattr[EAttrTypeL1.K_THUNDER] - target.roleattr[EAttrTypeL1.K_THUNDER] * 0.15));
target.setAttr(EAttrTypeL1.K_WATER, Math.floor(target.roleattr[EAttrTypeL1.K_WATER] - target.roleattr[EAttrTypeL1.K_WATER] * 0.15));
target.setAttr(EAttrTypeL1.K_BLOODRETURN, Math.floor(target.roleattr[EAttrTypeL1.K_BLOODRETURN] - target.roleattr[EAttrTypeL1.K_BLOODRETURN] * 0.15));
target.setAttr(EAttrTypeL1.K_WILDFIRE, Math.floor(target.roleattr[EAttrTypeL1.K_WILDFIRE] - target.roleattr[EAttrTypeL1.K_WILDFIRE] * 0.15));
target.setAttr(EAttrTypeL1.K_POISON, Math.floor(target.roleattr[EAttrTypeL1.K_POISON] - target.roleattr[EAttrTypeL1.K_POISON] * 0.5));
target.setAttr(EAttrTypeL1.K_PHY_GET, Math.floor(target.roleattr[EAttrTypeL1.K_PHY_GET] - target.roleattr[EAttrTypeL1.K_PHY_GET] * 0.15));
}
}
}
} else if (player.baldric == 9232) {
let basic = 15;
basic += Math.floor(battleRole.roleattr[EAttrTypeL2.MINJIE] / 100);
if (skill.skill_type == EMagicType.FRIGHTEN && this.currentRound == 1) {
for (let key of targetList) {
let target = this.plist[key];
if (target) {
target.setAttr(EAttrTypeL1.K_WIND, Math.floor(target.roleattr[EAttrTypeL1.K_WIND] - target.roleattr[EAttrTypeL1.K_WIND] * (basic / 100)));
target.setAttr(EAttrTypeL1.K_THUNDER, Math.floor(target.roleattr[EAttrTypeL1.K_THUNDER] - target.roleattr[EAttrTypeL1.K_THUNDER] * (basic / 100)));
target.setAttr(EAttrTypeL1.K_WATER, Math.floor(target.roleattr[EAttrTypeL1.K_WATER] - target.roleattr[EAttrTypeL1.K_WATER] * (basic / 100)));
target.setAttr(EAttrTypeL1.K_BLOODRETURN, Math.floor(target.roleattr[EAttrTypeL1.K_BLOODRETURN] - target.roleattr[EAttrTypeL1.K_BLOODRETURN] * (basic / 100)));
target.setAttr(EAttrTypeL1.K_WILDFIRE, Math.floor(target.roleattr[EAttrTypeL1.K_WILDFIRE] - target.roleattr[EAttrTypeL1.K_WILDFIRE] * (basic / 100)));
target.setAttr(EAttrTypeL1.K_POISON, Math.floor(target.roleattr[EAttrTypeL1.K_POISON] - target.roleattr[EAttrTypeL1.K_POISON] * (basic / 100)));
target.setAttr(EAttrTypeL1.K_PHY_GET, Math.floor(target.roleattr[EAttrTypeL1.K_PHY_GET] - target.roleattr[EAttrTypeL1.K_PHY_GET] * (basic / 100)));
}
}
}
}
}
}
}
// SKLogger.debug(`伤害计算:技能[${SkillUtil.getSkillName(skillId)}]效果伤害${hurt}`);
if (hurt == 0) {
if (skillEffect.hurtpre != 0) {
let percent = skillEffect.hurtpre / 100;
hurt = Math.floor(targetRole.getHP() * percent);
if (skillId == ESkillType.TianMoJieTi || skillId == ESkillType.HighTianMoJieTi) {
let cur = battleRole.getAttr(EAttrTypeL1.HP) || 0;
let sub = Math.floor(cur * 0.95);
battleRole.subHP(-sub);
hurt = Math.floor(sub);
}
if (battleRole.living_type == 4) {
let owner = this.plist[battleRole.own_onlyid];
if (owner) {
//咆哮
if (skillId == ESkillType.TianMoJieTi || skillId == ESkillType.FenGuangHuaYing || skillId == ESkillType.QingMianLiaoYa || skillId == ESkillType.XiaoLouYeKu ||
skillId == ESkillType.HighTianMoJieTi || skillId == ESkillType.HighFenGuangHuaYing || skillId == ESkillType.HighQingMianLiaoYa || skillId == ESkillType.HighXiaoLouYeKu
) {
if (owner.hasOfudaSkill(ESkillType.PaoXiao1)) {
hurt = Math.floor(hurt * 1.3)
}
if (owner.hasOfudaSkill(ESkillType.PaoXiao2)) {
hurt = Math.floor(hurt * 1.5)
}
if (owner.hasOfudaSkill(ESkillType.PaoXiao3)) {
hurt = Math.floor(hurt * 1.7)
}
}
}
}
// SKLogger.debug(`伤害计算:技能[${SkillUtil.getSkillName(skillId)}]效果前置伤害${hurt}`);
}
}
// 狂暴率
let kbpre = battleRole.getKuangBaoPre(skill.skill_type);
if (hurt > 0 && kbpre > 0) {
let randkb = SKDataUtil.random(0, 10000);
if (randkb < kbpre * 100) {
let kbstr = battleRole.getKuangBaoStr(skill.skill_type);
hurt = Math.floor(hurt + (hurt * 0.3));
respone = EBtlRespone.CRITICAL_HIT;
// SKLogger.debug(`伤害计算:技能[${SkillUtil.getSkillName(skillId)}]狂暴伤害${hurt}`);
}
}
// 没有混乱的时候 攻击自己人 掉1点血 非buff技能
if (SkillUtil.isAtkSkill(skillId) && !battleRole.hasBuff(EMagicType.CHAOS) && this.isSameTeam(battleRole.onlyid, targetRole.onlyid)) {
hurt = 1;
SKLogger.debug(`伤害计算:攻击自己人伤害值为1`);
}
if (targetRole.hasBuff(EMagicType.ASYLUM)) { //如果有庇护buff受到伤害减少10%
hurt = hurt - hurt * 0.1
}
//载物符
if (targetRole.isPlayer()) {
let rand = GameUtil.random(0, 10000);
let player = PlayerMgr.shared.getPlayerByOnlyId(targetRole.onlyid);
let banglevel = 0;
if (player) {
let bang = BangMgr.shared.getBang(player.bangid);
if (bang) {
let list = bang.rolelist;
for (let key in list) {
if (player.roleid == list[key].roleid) {
banglevel = list[key].ofudalevel;
break;
}
}
}
}
//承天载物
if (targetRole.hasOfudaSkill(ESkillType.ChengTianZaiWu1) && rand >= 6500) {
hurt -= Math.floor(hurt * 0.17);
}
if (targetRole.hasOfudaSkill(ESkillType.ChengTianZaiWu2) && rand >= 5000) {
hurt -= Math.floor(hurt * 0.2);
}
if (targetRole.hasOfudaSkill(ESkillType.ChengTianZaiWu3) && rand >= 4000) {
hurt -= Math.floor(hurt * 0.25);
}
//乘鸾
if (targetRole.hasOfudaSkill(ESkillType.ChengLuan1) || targetRole.hasOfudaSkill(ESkillType.ChengLuan2) || targetRole.hasOfudaSkill(ESkillType.ChengLuan3)) {
let buffskill = SkillUtil.getSkill(ESkillType.MoShenHuTi)
let buffeffect = buffskill.getEffect(params);
buffeffect.fangyu = Math.floor(25 * (banglevel * 0.35 * 3 / 100 + 1))
buffeffect.round = 3;
let buff = new Buff(buffskill, buffeffect);
buff.source = battleRole.onlyid
if (targetRole.hasOfudaSkill(ESkillType.ChengLuan1)) {
if (rand >= 6500 && hurt > 0) {
targetRole.addBuff(buff);
}
}
if (targetRole.hasOfudaSkill(ESkillType.ChengLuan2)) {
if (rand >= 5500 && hurt > 0) {
targetRole.addBuff(buff);
}
}
if (targetRole.hasOfudaSkill(ESkillType.ChengLuan3)) {
if (rand >= 5000 && hurt > 0) {
targetRole.addBuff(buff);
}
}
}
//御风
if (targetRole.hasOfudaSkill(ESkillType.YvFeng1) || targetRole.hasOfudaSkill(ESkillType.YvFeng2) || targetRole.hasOfudaSkill(ESkillType.YvFeng3)) {
let buffskill = SkillUtil.getSkill(ESkillType.TianWaiFeiMo)
let buffeffect = buffskill.getEffect(params);
buffeffect.spd = Math.floor(25 * (banglevel * 0.15 * 2 / 100 + 1))
buffeffect.round = 3;
let buff = new Buff(buffskill, buffeffect);
buff.source = battleRole.onlyid
if (targetRole.hasOfudaSkill(ESkillType.YvFeng1)) {
if (rand >= 6500 && hurt > 0) {
targetRole.addBuff(buff);
}
}
if (targetRole.hasOfudaSkill(ESkillType.YvFeng1)) {
if (rand >= 5500 && hurt > 0) {
targetRole.addBuff(buff);
}
}
if (targetRole.hasOfudaSkill(ESkillType.YvFeng1)) {
if (rand >= 5000 && hurt > 0) {
targetRole.addBuff(buff);
}
}
}
//冲冠
if (targetRole.hasOfudaSkill(ESkillType.ChongGuan1) || targetRole.hasOfudaSkill(ESkillType.ChongGuan2) || targetRole.hasOfudaSkill(ESkillType.ChongGuan3)) {
let buffskill = SkillUtil.getSkill(ESkillType.ShouWangShenLi)
let buffeffect = buffskill.getEffect(params);
buffeffect.atk = Math.floor(50000 * (banglevel * 0.85 * 8 / 100 + 1))
buffeffect.round = 3;
let buff = new Buff(buffskill, buffeffect);
buff.source = targetRole.onlyid
if (targetRole.hasOfudaSkill(ESkillType.ChongGuan1)) {
if (rand >= 6500) {
targetRole.addBuff(buff);
}
}
if (targetRole.hasOfudaSkill(ESkillType.ChongGuan1)) {
if (rand >= 5500) {
targetRole.addBuff(buff);
}
}
if (targetRole.hasOfudaSkill(ESkillType.ChongGuan1)) {
if (rand >= 5000) {
targetRole.addBuff(buff);
}
}
}
if (player) {
let baby = player.BabyMgr.GetBattleBaby()
if (baby != null && baby.HasPlaySkill() == false) {
//宝宝技能免伤
let defence = baby.Defence(skillId, targetRole)
if (defence > 0) {
hurt = hurt - defence
if (hurt < 0) hurt = 0
ntr.babyskill = baby.GetPlaySkillName()
}
}
if (baby != null && baby.HasPlaySkill() == false) {
if (baby.IsTriggerJinGang()) {
targetRole.defense_times = 2
ntr.babyskill = baby.GetPlaySkillName()
}
}
}
if (this.battle_type == BattleType.Normal && target.defense_times > 0) {
target.defense_times--
hurt = 0 //直接免伤
}
}
if (this.battle_type == BattleType.Force || this.battle_type == BattleType.PK || this.battle_type == BattleType.AREAN || this.battle_type == BattleType.Sat || this.battle_type == BattleType.ShuiLu) {//pvp模式修正伤害
hurt = hurt - hurt * 0.5;
}
if (hurt > 0) {
// 查看保护
let protect = false;
let protect_id = protect_list[targetRole.onlyid];
while (protect_id != null && skillId == ESkillType.NormalAtkSkill) {
let protecter = this.plist[protect_id];
if (protecter == null || protecter.isdead) {
break;
}
let thurt = hurt;
// 前置破防
let pfpre = battleRole.getPoFangPre();
let randkb = GameUtil.random(0, 10000);
if (randkb < pfpre * 100) {
let pfstr = battleRole.getPoFang();
let kwl = protecter.getKangWuLi();
respone = EBtlRespone.PO_FANG;
if (pfstr > kwl) {
thurt = Math.floor(thurt * (1 + ((pfstr - kwl) * 3) / 100));
} else {
thurt = Math.floor(thurt * (1 + (pfstr * 3 - kwl * 2) / 100));
}
// SKLogger.debug(`伤害计算:前置破防伤害${thurt}`);
}
if (thurt <= 0) {
thurt = 1;
// SKLogger.debug(`伤害计算:伤害值不能小于1`);
}
if (this.battle_type != BattleType.Normal && this.currentRound <= 5 && protecter.isPet()) {
let owner = this.plist[protecter.own_onlyid];
if (owner) {
if (owner.hasOfudaSkill(ESkillType.BiYou1)) {
thurt -= Math.floor(thurt * 0.15)
}
if (owner.hasOfudaSkill(ESkillType.BiYou2)) {
thurt -= Math.floor(thurt * 0.25)
}
if (owner.hasOfudaSkill(ESkillType.BiYou3)) {
thurt -= Math.floor(thurt * 0.55)
}
}
}
SKLogger.debug(`protect` + (thurt));
protecter.subHP(-thurt);
protect = true;
actaffix.protect = {
roleid: protect_id,
hurt: -thurt,
isdead: protecter.isdead,
hp: protecter.getHP(),
mp: protecter.getMP(),
respone: respone,
};
if (thurt > 0) {
poolHP.push(thurt * 3);
}
hurt = 0;
break;
}
if (protect) {
// 被保护了
ntr.acttype = EActNumType.HURT;
ntr.respone = EBtlRespone.PROTECT;
ntr.num = hurt;
// ntr.actaffix = SKDataUtil.toJson(protect);
} else {
let thurt = hurt;
// 破防
if (skillId == ESkillType.NormalAtkSkill || skill.skill_type == EMagicType.PHYSICS) {
let pf = battleRole.getPoFang();
if (pf > 0) {
hkValue += pf;
}
let evalue = hkValue - kValue;
if (evalue < 0) {
thurt = thurt - thurt * 0.8;
} else if (evalue >= 0 && evalue <= 20) {
thurt = thurt - thurt * 0.5;
} else if (evalue > 20 && evalue <= 50) {
thurt = thurt - thurt * 0.3;
} else if (evalue < 50) {
thurt = thurt - thurt * 0.1;
}
let phy = targetRole.getAttr(EAttrTypeL1.PHY_GET)
thurt = thurt * (100 - phy) / 100
SKLogger.debug(`伤害计算:普攻破防伤害${phy}, ${thurt}`);
} else {
thurt = Math.floor(thurt * (1 + (hkValue * 3 - kValue * 2) / 100));
// 如果技能效果是震摄则破防伤害最高为目标血量的百分之50
if (skill.skill_type == EMagicType.FRIGHTEN) {
let player
if (battleRole.isPlayer()) {
player = PlayerMgr.shared.getPlayerByOnlyId(battleRole.onlyid);
}
if (battleRole.isPet()) {
player = PlayerMgr.shared.getPlayerByOnlyId(battleRole.own_onlyid);
}
if (player != null) {
if (player.StarMgr.EquipID == 6) {
let star = player.StarMgr.GetStarByID(6)
let buf = star.Level * 0.003
thurt = Math.floor(thurt * (1 + buf))
SKLogger.debug(`[${battleRole.onlyid}:${battleRole.name}]的技能[${SkillUtil.getSkillName(skillId)}]获得伤害加成为:${thurt}`);
}
}
let limit = Math.floor(targetRole.getHP() * 0.5);
if (thurt > limit) {
thurt = limit;
}
// let mp = targetRole.getMaxMp() * 0.1
// if(targetRole.isPlayer()){
// let player = PlayerMgr.shared.getPlayerByOnlyId(targetRole.onlyid);
// if(player != null){
// let baby = player.BabyMgr.GetBattleBaby()
// if(baby != null && baby.HasPlaySkill() == false){
// if(baby.IsTriggerLongShen(skillId)){
// thurt = 0
// // mp = 0
// ntr.babyskill = baby.GetPlaySkillName()
// }
// }
// }
// }
// targetRole.subMP(-mp)
}
// SKLogger.debug(`伤害计算:技能[${SkillUtil.getSkillName(skillId)}]破防伤害${thurt}`);
}
// 五行
if (battleRole.isPet()) {
if (skill.skill_type == EMagicType.PHYSICS) {//物理攻击才有伤害加成
let pet = this.plist[battleRole.onlyid].source
if (pet && pet.owner) {
if (pet.petinfo != null && pet.petinfo != undefined) {
let skillList = pet.owner.horseSkill.getList(pet.petinfo.control);
for (let skil of skillList) {
if (skil.skill_id == ESkillType.HighCuiJinJue && (targetRole.getAttr(EAttrTypeL1.GOLD) >= 50)) {
thurt = thurt + (0.35 * thurt);
} else if (skil.skill_id == ESkillType.HighGuanMuJue && (targetRole.getAttr(EAttrTypeL1.WOOD) >= 50)) {
thurt = thurt + (0.35 * thurt);
} else if (skil.skill_id == ESkillType.HighHenShuiJue && (targetRole.getAttr(EAttrTypeL1.WATER) >= 50)) {
thurt = thurt + (0.35 * thurt);
} else if (skil.skill_id == ESkillType.HighTuiHuoJue && (targetRole.getAttr(EAttrTypeL1.FIRE) >= 50)) {
thurt = thurt + (0.35 * thurt);
} else if (skil.skill_id == ESkillType.HighJueTuJue && (targetRole.getAttr(EAttrTypeL1.SOIL) >= 50)) {
thurt = thurt + (0.35 * thurt);
}
}
}
}
}
}
// 震慑不算五行
if (skill.skill_type == EMagicType.FRIGHTEN) {
} else {
let hurtWxPre = 0;
for (let wuxing in GameUtil.wuXingStrengthen) {
if (GameUtil.wuXingStrengthen.hasOwnProperty(wuxing)) {
let kwuxing = GameUtil.wuXingStrengthen[wuxing];
let bWx = battleRole.getAttr(wuxing);
let tWx = targetRole.getAttr(kwuxing);
hurtWxPre += (bWx / 100) * (tWx / 100) * 0.4;
}
}
for (let wuxing in GameUtil.WuXingKeStrengthen) {
if (GameUtil.WuXingKeStrengthen.hasOwnProperty(wuxing)) {
const kwuxing = GameUtil.WuXingKeStrengthen[wuxing];
let bWx = battleRole.getAttr(wuxing);
let tWx = targetRole.getAttr(kwuxing);
hurtWxPre += (bWx / 10) * (tWx / 100) * 0.4;
}
}
thurt = Math.floor(thurt * (1 + hurtWxPre));
// SKLogger.debug(`伤害计算:五行伤害${thurt}`);
}
// 判断防御
if (thurt > 0 && targetRole.act.acttype == EActType.SKILL &&
battleRole.act.actionid == ESkillType.NormalAtkSkill && targetRole.act.actionid == ESkillType.NormalDefSkill &&
!targetRole.hasBuff(EMagicType.CHAOS)) {
thurt = Math.floor(thurt * 0.5);
// SKLogger.debug(`伤害计算:防御伤害${thurt}`);
ntr.respone = EBtlRespone.DEFENSE;
}
if (thurt <= 0) {
thurt = 1;
}
if (thurt > 0) {
// 如果中了睡眠
if (targetRole.hasBuff(EMagicType.SLEEP)) {
// 清理睡眠
targetRole.cleanBuff(EMagicType.SLEEP);
if (targetRole.isroundact == false) {
let bindex = this.turnList.indexOf(battleRole.onlyid);
let tindex = this.turnList.indexOf(targetRole.onlyid);
if (tindex < bindex) {
this.turnList.splice(bindex + 1, 0, targetRole.onlyid);
this.turnList.splice(tindex, 1);
}
}
}
}
//吉人天相判断
if (targetRole.living_type == 4 && targetRole.hasPassiveSkill(ESkillType.JiRenTianXiang)) {
let skill = SkillUtil.getSkill(ESkillType.JiRenTianXiang);
if (thurt >= targetRole.getHP() && this.currentRound > 3 && this.passive_times < skill.limit_times) {
this.passive_times++;
thurt = targetRole.getHP() - 10;
}
}
if (targetRole.isPlayer() && thurt >= targetRole.getHP()) {
let player = PlayerMgr.shared.getPlayerByOnlyId(targetRole.onlyid);
if (player != null) {
let baby = player.BabyMgr.GetBattleBaby()
if (baby != null && baby.HasPlaySkill() == false) {
if (targetRole.relive_times <= 5 && baby.IsTriggerRelive()) {
thurt = targetRole.getHP() - 10;
targetRole.relive_times++
ntr.babyskill = baby.GetPlaySkillName()
}
}
}
}
// SKLogger.debug(`[${targetRole.onlyid}:${targetRole.name}]受到[${battleRole.onlyid}:${battleRole.name}]技能[${SkillUtil.getSkillName(skillId)}]伤害${thurt}`);
if (!Battle.isDebug) {
targetRole.subHP(-thurt, ESubType.SKILL);
}
// 普攻,兵临城下,幻影如风 处理连击,隔山效果
if (SkillUtil.hasComboSkill(skillId) && thurt > 0) {
let combo = battleRole.getCombo();
if (combo > 0 && battleRole.team_id != targetRole.team_id) {
actaffix.lianji = {
hurt: [],
};
actaffix.lianji.hurt.push(-thurt);
let lianjihurt = thurt;
for (let i = 0; i < combo; i++) {
lianjihurt = Math.ceil(lianjihurt * 0.5);
actaffix.lianji.hurt.push(-lianjihurt);
targetRole.subHP(-lianjihurt, ESubType.SKILL);
}
addTime += combo * 0.16;
// SKLogger.debug(`技能[${SkillUtil.getSkillName(skillId)}]触发连击${-hurt}`);
}
if (battleRole.isPet()) {
let geshan = battleRole.geShan();
if (geshan != 0) {
// 如果有隔山打牛
let trole2 = this.findRandomTeamTarget(targetRole.onlyid);
if (trole2 && trole2.isDead() == false && trole2.team_id != battleRole.team_id) {
let atk = battleRole.getAttr(EAttrTypeL1.ATK);
let hurt = Math.floor(atk + geshan.hurt);
trole2.subHP(-hurt);
actaffix.geshan = {
roleid: trole2.onlyid,
respone: respone,
num: -hurt,
hp: trole2.getHP(),
mp: trole2.getMP(),
isdead: trole2.isdead ? 1 : 0,
};
// SKLogger.debug(`技能[${SkillUtil.getSkillName(skillId)}]触发隔山打牛${-hurt}`);
}
}
}
}
ntr.acttype = EActNumType.HURT;
ntr.respone = respone;
if (targetRole.onlyid == battleRole.act.target) {
if (skillId == ESkillType.CangHaiHengLiu || skillId == ESkillType.FeiJvJiuTian) {
let skill = SkillUtil.getSkill(skillId);
let effect = skill.getEffect(params);
thurt += (effect.hurt * 0.4);
ntr.num = -thurt;
}
}
ntr.num = -thurt;
if (thurt > 0) {
poolHP.push(thurt * 3);
}
// 天降灵猴
if (skillId == ESkillType.StealMoney) {
let player = this.getAPlayer();
if (player) {
let stealmoney = skillEffect.money;
if (stealmoney > player.money) {
stealmoney = player.money;
}
this.linghouInfo.steal_money = stealmoney;
player.addMoney(GameUtil.goldKind.Money, -stealmoney, '天降灵猴偷走');
SKLogger.debug(`灵猴偷走${stealmoney}银两`);
}
}
hurt = thurt;
}
}
// 治疗
let hp = skillEffect == null ? 0 : skillEffect.hp;
if (hp > 0) {
targetRole.subHP(hp, ESubType.ADD);
ntr.acttype = EActNumType.HP;
ntr.num = hp;
}
let smppre = skillEffect == null ? 0 : skillEffect.smppre;
if (smppre > 0) {
let smp = -Math.ceil(targetRole.getMaxMp() * smppre / 100);
if (skillId == ESkillType.YanLuoZhuiMing || skillId == ESkillType.XiaoHunShiGu) {
if (targetRole.isPlayer()) {
let player = PlayerMgr.shared.getPlayerByOnlyId(targetRole.onlyid);
if (player != null) {
let baby = player.BabyMgr.GetBattleBaby()
if (baby != null && baby.HasPlaySkill() == false) {
if (baby.IsTriggerLongShen(skillId)) {
smp = 0
ntr.babyskill = baby.GetPlaySkillName()
}
}
}
}
}
targetRole.subMP(smp, ESubType.SUB);
}
let hpper = skillEffect == null ? 0 : skillEffect.hppre;
if (hpper > 0) {
let maxhp = targetRole.getAttr(EAttrTypeL1.HP_MAX);
let addhp = maxhp * hpper / 100;
targetRole.subHP(addhp, ESubType.PERCENT);
ntr.acttype = EActNumType.HP;
ntr.num = addhp;
}
let mpper = skillEffect == null ? 0 : skillEffect.mppre;
if (mpper > 0) {
let maxmp = targetRole.getAttr(EAttrTypeL1.MP_MAX);
let addmp = maxmp * mpper / 100;
targetRole.subMP(addmp, ESubType.PERCENT);
}
// 处理buff
let round = skillEffect == null ? 1 : skillEffect.round;
if (round > 0) {
let mingzhong = 10000;
// 抗性计算
if (SkillUtil.isAtkSkill(skillId)) {
let sattr = GameUtil.skillTypeStrengthen[skill.skill_type];
let dattr = GameUtil.skillTypeKangXing[skill.skill_type];
let sattrnum = battleRole.getAttr(sattr);
let tattrnum = targetRole.getAttr(dattr);
let attrnum = (sattrnum - tattrnum + 100) * 100;
let r = GameUtil.random(0, 10000);
if (r < attrnum) {
mingzhong = attrnum;
} else {
mingzhong = 0;
}
}
// 如果命中大于0
if (mingzhong > 0) {
let buffeffect = SKDataUtil.clone(skillEffect);
buffeffect.hurt = hurt;
let buff = new Buff(skill, buffeffect);
buff.source = battleRole.onlyid;
buff.probability = mingzhong;
targetRole.addBuff(buff);
// SKLogger.debug(`战斗:角色[${targetRole.onlyid}:${targetRole.name}]加入BUFF[${skill.skill_name}:${SkillUtil.getBuffName(buff.effecttype)}]`);
}
}
if (targetRole.isDead() == false) {
// 修正普通攻击属性 混乱 封印
let fix_atk_skill = 0;
if (skillId == ESkillType.NormalAtkSkill) {
let fixskill = null;
if (battleRole.hasPassiveSkill(ESkillType.HunLuan)) {
fixskill = SkillUtil.getSkill(ESkillType.HunLuan);
}
if (battleRole.hasPassiveSkill(ESkillType.FengYin)) {
fixskill = SkillUtil.getSkill(ESkillType.FengYin);
}
if (fixskill) {
let params = {
level: battleRole.level,
relive: battleRole.relive,
qinmi: battleRole.qinmi
}
let fixEffect = fixskill.getEffect(params);
if (fixEffect != null) {
fix_atk_skill = fixEffect;
}
}
}
if (fix_atk_skill != 0) {
let buffSkill = SkillUtil.getSkill(fix_atk_skill);
if (buffSkill) {
SKLogger.info("战斗被修正了");
let buffSkillEffect = buffSkill.getEffect(params);
buffSkillEffect.round = 1;
let buff = new Buff(buffSkill, buffSkillEffect);
buff.source = battleRole.onlyid;
buff.probability = 10000;
targetRole.addBuff(buff);
} else {
SKLogger.warn(`战斗:修正攻击技能找不到${fix_atk_skill}`);
}
}
}
//恨雨霏霏
// if(skillId == ESkillType.HenYvFeiFei){
// if((targetRole.getAttr(EAttrTypeL1.HP) - skillEffect.hurt) < (targetRole.getAttr(EAttrTypeL1.HP_MAX) * 0.3) || targetRole.isdead){
// let trole2 = this.findRandomTeamTarget(targetRole.onlyid);
// if (trole2 && trindex == targetList.length - 1 && fenhuatimes < 2) {
// targetList.push(trole2.onlyid);
// fenhuatimes++;
// }
// }
// }
let isDead = targetRole.isDead();
ntr.hp = targetRole.getHP();
ntr.mp = targetRole.getMP();
ntr.isdead = isDead ? 1 : 0;
ntr.bufflist = targetRole.getBuffsSkillId();
if (isDead) {
if (targetRole.isPlayer()) {
let pet = this.plist[targetRole.bindid];
//作鸟兽散
if (pet) {
if (pet.isPet() && pet.hasPassiveSkill(ESkillType.ZuoNiaoShouSan)) {
let flag = true;
for (let key in this.plist) {
let brole = this.plist[key];
if (brole.team_id == pet.team_id && brole.isPet() && brole.onlyid != pet.onlyid && brole.isdead == false) {
flag = false; //己方宠物(除自己外)还有在场时作鸟兽散不生效
}
}
if (flag) {
for (let key in this.plist) {
let brole = this.plist[key];
if (pet.team_id == brole.team_id) {
let hp = brole.getAttr(EAttrTypeL1.HP_MAX);
let mp = brole.getAttr(EAttrTypeL1.MP_MAX);
brole.subHP(hp * 0.5)
brole.subMP(Math.floor(mp * 0.5))
ntr.selfid = brole.onlyid;
ntr.selfhp = brole.getHP();
ntr.recover = hp * 0.5;
ntr.backmp = Math.floor(mp * 0.2);
}
}
this.onPetLeave(pet.onlyid)
}
}
}
}
if (targetRole.isPet() && targetRole.niepan_times == 0) {
if (targetRole.niepan()) {
actaffix.niepan = {
hp: targetRole.getHP(),
mp: targetRole.getMP(),
bufflist: [],
}
targetRole.niepan_times += 1;
addTime += 2;
// SKLogger.debug(`战斗:召唤兽[${targetRole.name}]死亡涅槃!`);
} else {
// 设置 死亡宠物不可被召唤
let ppos = targetRole.pos;
let own: BattleRole = this.plist[targetRole.own_onlyid];
if (own) {//御兽符-护主
let pranter = this.findRandomTeamTarget(targetRole.onlyid);
let hp = targetRole.getAttr(EAttrTypeL1.HP_MAX);
if (own.hasOfudaSkill(ESkillType.HuZhu1)) {
own.subHP(Math.floor(hp * 0.07))
ntr.selfid = own.onlyid;
ntr.selfhp = own.getHP();
ntr.recover = Math.floor(hp * 0.07);
}
if (own.hasOfudaSkill(ESkillType.HuZhu2)) {
own.subHP(Math.floor(hp * 0.1))
ntr.selfid = own.onlyid;
ntr.selfhp = own.getHP();
ntr.recover = Math.floor(hp * 0.1);
}
if (own.hasOfudaSkill(ESkillType.HuZhu3)) {
own.subHP(Math.floor(hp * 0.15))
ntr.selfid = own.onlyid;
ntr.selfhp = own.getHP();
ntr.recover = Math.floor(hp * 0.15);
}
if (pranter) {//御兽符-生机
if (own.hasOfudaSkill(ESkillType.ShengJi1)) {
pranter.subHP(Math.floor(hp * 0.07))
ntr.selfid = pranter.onlyid;
ntr.selfhp = pranter.getHP();
ntr.recover = Math.floor(hp * 0.07);
}
if (own.hasOfudaSkill(ESkillType.ShengJi2)) {
pranter.subHP(Math.floor(hp * 0.1))
ntr.selfid = pranter.onlyid;
ntr.selfhp = pranter.getHP();
ntr.recover = Math.floor(hp * 0.1);
}
if (own.hasOfudaSkill(ESkillType.ShengJi3)) {
pranter.subHP(Math.floor(hp * 0.15))
ntr.selfid = pranter.onlyid;
ntr.selfhp = pranter.getHP();
ntr.recover = Math.floor(hp * 0.15);
}
}
}
this.onPetLeave(targetRole.onlyid);
// 寻找闪现宠物
let player = PlayerMgr.shared.getPlayerByOnlyId(targetRole.own_onlyid);
if (player) {
let list = PetSupport.shared.getPetlistById(player.roleid);
for (let id in list) {
let petinfo = list[id];
let petRole = null;
for (let oid in this.petlist) {
let petRolea: BattleRole = this.petlist[oid];
if (petRolea.source.petid == petinfo.petid) {
petRole = petRolea
break;
}
}
if (petRole == undefined || petRole == null) {
continue;
}
if (petRole.isdead || petRole.onlyid == targetRole.onlyid) {
continue;
}
if (petRole.pos != -1 && petRole.own_onlyid == targetRole.own_onlyid) {
let shanxian_ret = petRole.shanXian();
// 没闪现,继续找闪现宠物
if (shanxian_ret == 1) {
continue;
}
// 有闪现没出来,跳出闪现逻辑
if (shanxian_ret == 2) {
break;
}
// 成功闪现
if (shanxian_ret == 0) {
let petid = this.onPetEnter(petRole.onlyid, ppos);
SKLogger.info(`战斗:召唤兽[${targetRole.name}]死亡,[${petRole.name}${petRole.onlyid}]闪现出来了`);
if (petid > 0) {
let petenter = this.petEnterEffect(petRole.onlyid);
actaffix.shanxian = {
petoid: petid,
hp: petRole.getHP(),
mp: petRole.getMP(),
pos: ppos,
bufflist: petRole.getBuffsSkillId(),
};
actaffix.petenter = petenter;
if (petenter && petenter.act == ESkillType.JiQiBuYi) {
let shanxianpet = this.plist[petid];
if (shanxianpet) {
shanxianpet.act.acttype = EActType.SKILL;
shanxianpet.act.skill = ESkillType.NormalAtkSkill;
shanxianpet.act.actionid = ESkillType.NormalAtkSkill;
this.turnList.splice(turnIndex + 1, 0, { spd: shanxianpet.getAttr(EAttrTypeL1.SPD), onlyid: shanxianpet.onlyid });
}
}
let turn = this.turnList[turnIndex];
// 出手的角色
if (turn) {
let battleRole: BattleRole = this.plist[turn.onlyid];
if (targetRole.getAttr(EAttrTypeL1.SPD) > battleRole.getAttr(EAttrTypeL1.SPD)) {
turnIndex--;
}
}
if (petRole.hasPassiveSkill(ESkillType.HighXianFengDaoGu) || petRole.hasPassiveSkill(ESkillType.HighMiaoShouRenXin)) {
let hp = own.getAttr(EAttrTypeL1.HP_MAX);
let mp = own.getAttr(EAttrTypeL1.MP_MAX);
if (petRole.hasPassiveSkill(ESkillType.HighXianFengDaoGu)) {
own.subHP(hp)
own.subMP(Math.floor(mp * 0.02))
ntr.selfid = own.onlyid;
ntr.selfhp = own.getHP();
ntr.recover = hp;
ntr.backmp = Math.floor(mp * 0.2);
}
if (petRole.hasPassiveSkill(ESkillType.HighMiaoShouRenXin)) {
own.subHP(Math.floor(hp * 0.02));
own.subMP(mp);
ntr.selfid = own.onlyid;
ntr.selfhp = own.getHP();
ntr.recover = Math.floor(hp * 0.2);
ntr.backmp = mp;
}
}
break;
}
}
}
}
}
}
}
if (battleRole.fenhua()) {
// 分花拂柳
let trole2 = this.findRandomTeamTarget(targetRole.onlyid);
if (trole2 && trole2.isDead() == false && trindex == targetList.length - 1 && fenhuatimes < 3) {
targetList.push(trole2.onlyid);
fenhuatimes++;
}
}
}
ntr.actaffix = SKDataUtil.toJson(actaffix, "{}");
}
// 吸血
let aiHP = skillEffect == null ? 0 : skillEffect.aihp;
let tar = battleRole.act.target;
if (aiHP > 0) {
// 智能加血,给队伍中血量最少的 几个人 加血。
let teamId = battleRole.team_id;
let team = [];
if (teamId == 1) {
team = this.campA.broles;
} else if (teamId == 2) {
team = this.campB.broles;
}
team.sort((a: any, b: any) => {
let t1 = a.getAttr(EAttrTypeL1.HP) / a.getAttr(EAttrTypeL1.HP_MAX);
let t2 = b.getAttr(EAttrTypeL1.HP) / b.getAttr(EAttrTypeL1.HP_MAX);
return t1 - t2;
});
poolHP.sort((a, b) => {
return b - a;
});
let index = 0;
for (let member of team) {
// 未出战跳过
if (member.pos < 0) {
continue;
}
// 如果是召唤兽并死亡跳过
if (member.isPet() && member.isdead) {
continue;
}
index++;
if (index > poolHP.length) {
break;
}
let addHP = poolHP[index - 1];
let addntr = SKDataUtil.clone(target);
addntr.targetid = member.onlyid;
if (member.isdead) {
member.isdead = false;
}
addntr.acttype = EActNumType.SUCK;
member.subHP(addHP);
addntr.num = addHP;
addntr.hp = member.getHP();
addntr.mp = member.getMP();
addntr.isdead = member.isDead() ? 1 : 0;
addntr.bufflist = member.getBuffsSkillId();
tgs.push(addntr);
}
}
actionList.act = tgs;
skillEffect = null;
if (skill && skill.skill_type == EMagicType.SPEED) {
this.resetTurnList();
}
}
actbef.hp = battleRole.getHP();
actbef.mp = battleRole.getMP();
actbef.isdead = battleRole.isDead() ? 1 : 0;
actionList.actbef = SKDataUtil.toJson(actbef, "{}");
actionList.bufflist = battleRole.getBuffsSkillId();
roundInfo.acts.push(actionList);
if (battleRole.isPlayer() && battleRole.act.acttype == EActType.SKILL) {// 浩气凌霄 法术连击
//判断是否装备浩气凌霄
if (battleRole.hasOfudaSkill(ESkillType.HaoQiLingXiao1) || battleRole.hasOfudaSkill(ESkillType.HaoQiLingXiao2) || battleRole.hasOfudaSkill(ESkillType.HaoQiLingXiao3)) {
let skill = SkillUtil.getSkill(battleRole.act.actionid);
if (skill.skill_type == EMagicType.WATER || skill.skill_type == EMagicType.FIRE || skill.skill_type == EMagicType.THUNDER || skill.skill_type == EMagicType.WIND || skill.skill_type == EMagicType.TOXIN || skill.skill_type == EMagicType.GHOST_FIRE || skill.skill_type == EMagicType.THREE_CORPSE) {
if (double_hit_time == 0) {
let r = GameUtil.random(0, 10000);
if (battleRole.hasOfudaSkill(ESkillType.HaoQiLingXiao1) && r >= 6000) {
double_hit_time++;
turnIndex--;
}
if (battleRole.hasOfudaSkill(ESkillType.HaoQiLingXiao2) && r >= 4000) {
double_hit_time++;
turnIndex--;
}
if (battleRole.hasOfudaSkill(ESkillType.HaoQiLingXiao3) && r >= 2000) {
double_hit_time++;
turnIndex--;
}
} else {//第一个人施法两次,次数清零
double_hit_time = 0
}
}
}
// if (BattleType.Normal == this.battle_type || this.battle_type == BattleType.LingHou) {
// if (double_hit_time == 0) {
// double_hit_time++;
// turnIndex--;
// } else {//第一个人施法两次,次数清零
// double_hit_time = 0
// }
// }
}
if (battleRole.isPet() && battleRole.act.acttype == EActType.SKILL) {// 梅花三弄 仙法连击
let skill = SkillUtil.getSkill(battleRole.act.actionid);
if (skill) {
if (skill.skill_type == EMagicType.WATER || skill.skill_type == EMagicType.FIRE || skill.skill_type == EMagicType.THUNDER || skill.skill_type == EMagicType.WIND || skill.skill_type == EMagicType.GHOST_FIRE) {
let r = GameUtil.random(0, 10000);
if (three_hit_time <= 1) {
let pet = this.plist[battleRole.onlyid].source
if (pet && pet.owner) {
if (pet.petinfo != null && pet.petinfo != undefined) {
let skillList = pet.owner.horseSkill.getList(pet.petinfo.control);
for (let skil of skillList) {
if (skil.skill_id == ESkillType.MeiHuaSanNong && r >= 6500) {
three_hit_time++;
turnIndex--;
break;
}
if (skil.skill_id == ESkillType.HighMeiHuaSanNong && r >= 5000) {
three_hit_time++;
turnIndex--;
break;
}
}
}
}
} else {//施法三次,次数清零
three_hit_time = 0
}
}
}
}
if (runaway) {
break;
}
}
let self = this;
this.timer = setTimeout(() => {
self.roundEnd();
}, (roundInfo.acts.length * Battle.actionTime + addTime + 1) * 1000);
this.broadcast('s2c_btl_round', roundInfo);
}
// 回合结束
roundEnd() {
if (this.timer != 0) {
clearTimeout(this.timer);
this.timer = 0;
}
for (const t of this.turnList) {
let brole = this.plist[t.onlyid];
if (!brole) {
continue;
}
// 技能冷却减少
for (const skillid in brole.skill_list) {
if (brole.skill_list.hasOwnProperty(skillid)) {
const skillinfo = brole.skill_list[skillid];
if (skillinfo.cooldown > 0) {
skillinfo.cooldown--;
}
}
}
let bufflist = brole.getBuffList();
for (let i = 0; i < bufflist.length; i++) {
const buff = bufflist[i];
buff.addRound(brole);
if (buff.effecttype == EMagicType.CHAOS ||
buff.effecttype == EMagicType.SLEEP ||
buff.effecttype == EMagicType.SEAL) {
if (buff.probability != 10000) {
let r = GameUtil.random(0, 10000);
if (buff.probability < r) {
brole.removeBuff(buff.buff_id);
continue;
}
}
}
if (buff.checkEnd()) {
brole.removeBuff(buff.buff_id);
}
}
brole.init();
}
this.nilin = 0;
this.roundBegin();
}
// 回到战斗
backToBattle(onlyid: any) {
let brole = this.plist[onlyid];
if (brole == null) {
return;
}
brole.online_state = 1;
let eteam = 2;
let steam = 1;
if (brole.team_id == 2) {
eteam = 1;
steam = 2;
}
let s2c_btl = {
btlid: this.battle_id,
teamS: this.getTeamData(steam),
teamE: this.getTeamData(eteam),
};
brole.send('s2c_btl', s2c_btl);
}
//设置对象离线
setObjOffline(onlyid: any) {
let brole = this.plist[onlyid];
if (brole) {
brole.online_state = 0;
for (const bonlyid in this.plist) {
const bobj = this.plist[bonlyid];
if (bobj.own_onlyid == onlyid) {
bobj.online_state = 0;
}
}
}
}
//设置对象在线
setObjOnline(onlyid: any) {
let brole = this.plist[onlyid];
if (brole) {
brole.online_state = 1;
for (const onlyid in this.plist) {
const bobj = this.plist[onlyid];
if (bobj.own_onlyid == onlyid) {
bobj.online_state = 1;
}
}
if (brole.isact == false) {
brole.isact = true;
brole.act = {
acttype: EActType.SKILL,
actionid: brole.last_skill,
target: 0,
}
}
}
}
//检查在线玩家
checkOnlinePlayer() {
for (const onlyid in this.plist) {
if (this.plist.hasOwnProperty(onlyid)) {
const brole = this.plist[onlyid];
if (brole.isPlayer() && brole.online_state == 1) {
return true;
}
}
}
return false;
}
//广播本队所有玩家
broadcastCamp(onlyid: any, event: any, obj: any) {
for (let oid in this.plist) {
if (this.plist.hasOwnProperty(oid)) {
let brole = this.plist[oid];
if (brole.isPlayer() && this.isSameTeam(brole.onlyid, onlyid)) {
brole.send(event, obj);
}
}
}
}
//广播本场战斗除目标外所有玩家
broadcast(event: any, obj: any, exclude: any = 0) {
for (let onlyid in this.plist) {
if (this.plist.hasOwnProperty(onlyid)) {
let brole = this.plist[onlyid];
if (exclude != 0 && brole.onlyid == exclude) {
continue;
}
if (brole.isPlayer() && brole.online_state == 1) {
brole.send(event, obj);
}
}
}
}
}