1429 lines
55 KiB
TypeScript
1429 lines
55 KiB
TypeScript
import BattleObj from "./BattleObj";
|
||
import PetMgr from "../core/PetMgr";
|
||
import GoodsMgr from "../item/GoodsMgr";
|
||
import SkillUtil from "../skill/core/SkillUtil";
|
||
import SkillBase from "../skill/core/SkillBase";
|
||
import SKDataUtil from "../gear/SKDataUtil";
|
||
import ExpUtil from "../core/ExpUtil";
|
||
import GameUtil from "../core/GameUtil";
|
||
import Player from "./Player";
|
||
import SKLogger from "../gear/SKLogger";
|
||
import Horse from "../horse/Horse";
|
||
import {
|
||
ERaceType,
|
||
EActionType,
|
||
EAttrTypeL1,
|
||
EAttrTypeL2,
|
||
ELiveingType,
|
||
MsgCode,
|
||
Operate,
|
||
ESkillType, Aptitude
|
||
} from "../role/EEnum";
|
||
import PlayerMgr from "../object/PlayerMgr";
|
||
import SKCxfUtil from "../gear/SKCxfUtil";
|
||
import PetSupport from "../object/PetSupport";
|
||
|
||
export default class Pet extends BattleObj {
|
||
petid: number;
|
||
dataid: number;
|
||
owner: Player;
|
||
resid: number;
|
||
intro: string;
|
||
name: string;
|
||
relive: number;
|
||
level: number;
|
||
grade: number;
|
||
qinmi: number;
|
||
skill_list: any;
|
||
rate: number;
|
||
basehp: number;
|
||
basemp: number;
|
||
baseatk: number;
|
||
basespd: number;
|
||
ppoint: any;
|
||
dpoint: any;
|
||
wuxing: any;
|
||
exp: number;
|
||
xexp: number;
|
||
xlevel: number;
|
||
longgu: number;
|
||
state: number;
|
||
maxskillcnt: number;
|
||
wash_property: any; // 洗练的属性
|
||
color: number; // -1:未变色 0:变色未成功 >0:其他颜色
|
||
fly: number; // %10飞升次数 /10飞升增加的属性 1hp 2mp 3atk 4spd
|
||
shenskill: number;
|
||
petinfo: any;
|
||
dfengyin: any;
|
||
dhunlun: any;
|
||
dhunshui: any;
|
||
dyiwang: any;
|
||
dfeng: any;
|
||
dshui: any;
|
||
dhuo: any;
|
||
ddu: any;
|
||
dlei: any;
|
||
dguihuo: any;
|
||
dsanshi: any;
|
||
dzhenshe: number;
|
||
pxishou: any;
|
||
pmingzhong: number;
|
||
pshanbi: number;
|
||
plianji: number;
|
||
plianjilv: number;
|
||
pkuangbao: number;
|
||
ppofang: number;
|
||
ppofanglv: number;
|
||
pfanzhenlv: number;
|
||
pfanzhen: number;
|
||
// 0:资质平平 (比较垃圾),1:出类拔萃 (一般),2:妙领天机 (中等),3:万中无一 (极好的)
|
||
aptitude: number;
|
||
// 坐骑管制位 0 未管制 1 坐骑1 2 坐骑2 3 坐骑3 4 坐骑4
|
||
control: number;
|
||
|
||
constructor(petid: any) {
|
||
super();
|
||
this.petid = 0;
|
||
this.dataid = petid;
|
||
this.owner = null;
|
||
this.resid = 0; // 资源id
|
||
this.intro = ''; // 介绍
|
||
this.name = '';
|
||
this.relive = 0;
|
||
this.level = 0;
|
||
this.grade = 0;
|
||
this.qinmi = 0; // 亲密
|
||
this.skill_list = {};
|
||
this.rate = 0;
|
||
this.basehp = 0; // 初始血
|
||
this.basemp = 0;
|
||
this.baseatk = 0;
|
||
this.basespd = 0;
|
||
this.ppoint = {};
|
||
this.dpoint = {};
|
||
this.wuxing = {};
|
||
this.exp = 0;
|
||
this.xexp = 0;
|
||
this.xlevel = 0;
|
||
this.longgu = 0;
|
||
this.state = 1;
|
||
this.maxskillcnt = 4;
|
||
this.wash_property = null; // 洗练的属性
|
||
this.color = -1; // -1:未变色 0:变色未成功 >0:其他颜色
|
||
// this.yuanqi = 0;
|
||
this.fly = 0; // %10飞升次数 /10飞升增加的属性 1hp 2mp 3atk 4spd
|
||
this.shenskill = 0;
|
||
this.living_type = ELiveingType.PET;
|
||
this.control = 0;
|
||
this.aptitude = 0;
|
||
}
|
||
|
||
setOwner(player: any) {
|
||
this.maxskillcnt = PetMgr.shared.getMaxSkillCnt(this.dataid);
|
||
this.owner = player;
|
||
}
|
||
|
||
setDB(info: any) {
|
||
this.petinfo = info;
|
||
if (!this.petinfo) {
|
||
return;
|
||
}
|
||
let data = PetMgr.shared.getPetData(this.dataid);
|
||
if (!data) {
|
||
SKLogger.debug(`召唤兽找不到${this.dataid}`);
|
||
return;
|
||
}
|
||
/* TODO 修复宠物属性 */
|
||
while (info.hp && info.hp > data.hp[1]) {
|
||
info.hp -= 60;
|
||
}
|
||
while (info.mp && info.mp > data.mp[1]) {
|
||
info.mp -= 60;
|
||
}
|
||
while (info.atk && info.atk > data.atk[1]) {
|
||
info.atk -= 60;
|
||
}
|
||
while (info.spd && info.spd > data.spd[1]) {
|
||
info.spd -= 60;
|
||
}
|
||
info.petid && (this.petid = info.petid);
|
||
info.dataid && (this.dataid = info.dataid);
|
||
info.resid && (this.resid = info.resid);
|
||
info.intro && (this.intro = info.intro);
|
||
info.name && (this.name = info.name);
|
||
info.relive && (this.relive = info.relive);
|
||
info.level && (this.level = info.level);
|
||
info.grade && (this.grade = info.grade);
|
||
info.shenskill && (this.shenskill = info.shenskill);
|
||
let skillList = SKDataUtil.jsonBy(info.skill);
|
||
this.initSkill(skillList);
|
||
info.rate && (this.rate = info.rate);
|
||
info.hp && (this.basehp = info.hp);
|
||
info.mp && (this.basemp = info.mp);
|
||
info.atk && (this.baseatk = info.atk);
|
||
info.spd && (this.basespd = info.spd);
|
||
info.ppoint && (this.ppoint = SKDataUtil.jsonBy(info.ppoint));
|
||
info.dpoint && (this.dpoint = SKDataUtil.jsonBy(info.dpoint));
|
||
info.wuxing && (this.wuxing = SKDataUtil.jsonBy(info.wuxing));
|
||
info.exp && (this.exp = info.exp);
|
||
info.xexp && (this.xexp = info.xexp);
|
||
info.xlevel && (this.xlevel = info.xlevel);
|
||
info.longgu && (this.longgu = info.longgu);
|
||
info.maxskillcnt && (this.maxskillcnt = info.maxskillcnt);
|
||
if (SKDataUtil.isNumber(info.color)) {
|
||
this.color = this.petColorTransformCom(info.color);
|
||
}
|
||
// if (this.color != -1) {
|
||
// this.yuanqi = goodsMgr.getPetUseYuanqiRate(this.dataid);
|
||
// }
|
||
this.aptitude = PetMgr.shared.getAptitude(this.dataid, info);
|
||
info.aptitude = this.aptitude;
|
||
info.qinmi && (this.qinmi = info.qinmi);
|
||
if (typeof (info.fly) == 'number') {
|
||
this.fly = info.fly;
|
||
}
|
||
this.maxskillcnt = PetMgr.shared.getMaxSkillCnt(this.dataid);
|
||
if (info.control) {
|
||
this.control = SKDataUtil.clamp(info.control, ERaceType.HUMEN, ERaceType.DRAGON);
|
||
}
|
||
this.calculateAttribute();
|
||
}
|
||
|
||
initSkill(skillinfos: any) {
|
||
for (let skillId in skillinfos) {
|
||
if (skillinfos.hasOwnProperty(skillId)) {
|
||
const skillinfo = skillinfos[skillId];
|
||
if (typeof skillinfo == 'object' && skillinfo) {
|
||
this.skill_list[skillId] = skillinfo;
|
||
}
|
||
if (typeof skillinfo == 'number') {
|
||
this.skill_list[skillId] = {
|
||
idx: skillinfo,
|
||
lck: 0
|
||
};
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/*
|
||
* 宠物使用元气丹
|
||
*/
|
||
useYuanqi() {
|
||
let can_wash_rate = 1; // 能洗颜色的概率
|
||
if (this.color == -1) { // 未吃过元气丹
|
||
this.color = 0;
|
||
// this.yuanqi = goodsMgr.getPetUseYuanqiRate(this.dataid);
|
||
this.calculateAttribute();
|
||
can_wash_rate = 0.1;
|
||
}
|
||
if (Math.random() < can_wash_rate || this.getCurRate() == this.getMaxRate()) {
|
||
this.color = this.changeColor();
|
||
}
|
||
if (this.owner) {
|
||
this.owner.send('s2c_update_pet', {
|
||
info: this.toObj()
|
||
});
|
||
SKCxfUtil.getCxfRecordOperate({
|
||
roleId: this.owner.roleid,
|
||
roleName: this.owner.name,
|
||
operateType: Operate.ITEM,
|
||
operateDepict: "元气丹",
|
||
operateResSerial: this.petid,
|
||
operateResName: this.name,
|
||
operateContent: SKDataUtil.toJson(this.toObj(), "{}")
|
||
})
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
/*
|
||
* 宠物洗颜色
|
||
*/
|
||
changeColor() {
|
||
let colors = PetMgr.shared.getPetColors(this.resid);
|
||
let common_colors = colors.colorValue; // 普通颜色
|
||
let special_colors = colors.colorNice; // 特殊颜色
|
||
let random = Math.random();
|
||
let rate = 0.9; // 普通颜色的概率
|
||
let color = 0;
|
||
if (random < rate) {
|
||
color = parseInt(common_colors[Math.floor(Math.random() * common_colors.length)]);
|
||
} else {
|
||
color = parseInt(special_colors[Math.floor(Math.random() * special_colors.length)]);
|
||
}
|
||
return color;
|
||
}
|
||
|
||
calculateAttribute() {
|
||
let player = this.owner
|
||
GameUtil.clearAllAttr(this.attr1);
|
||
this.dpoint[EAttrTypeL2.GENGU] = this.dpoint[EAttrTypeL2.GENGU] || 0;
|
||
this.dpoint[EAttrTypeL2.LINGXING] = this.dpoint[EAttrTypeL2.LINGXING] || 0;
|
||
this.dpoint[EAttrTypeL2.LILIANG] = this.dpoint[EAttrTypeL2.LILIANG] || 0;
|
||
this.dpoint[EAttrTypeL2.MINJIE] = this.dpoint[EAttrTypeL2.MINJIE] || 0;
|
||
|
||
this.ppoint[EAttrTypeL2.GENGU] = this.ppoint[EAttrTypeL2.GENGU] || 0;
|
||
this.ppoint[EAttrTypeL2.LINGXING] = this.ppoint[EAttrTypeL2.LINGXING] || 0;
|
||
this.ppoint[EAttrTypeL2.LILIANG] = this.ppoint[EAttrTypeL2.LILIANG] || 0;
|
||
this.ppoint[EAttrTypeL2.MINJIE] = this.ppoint[EAttrTypeL2.MINJIE] || 0;
|
||
|
||
let cur_rate = this.getCurRate();
|
||
let calhp = Math.round(this.level * cur_rate / 10000 * (this.level + this.ppoint[EAttrTypeL2.GENGU]) + 0.7 * this.getBaseProperty('hp') * this.level * cur_rate / 10000 + this.getBaseProperty('hp'));
|
||
let calmp = Math.round(this.level * cur_rate / 10000 * (this.level + this.ppoint[EAttrTypeL2.LINGXING]) + 0.7 * this.getBaseProperty('mp') * this.level * cur_rate / 10000 + this.getBaseProperty('mp'));
|
||
let calatk = Math.round(0.2 * this.level * cur_rate / 10000 * (this.level + this.ppoint[EAttrTypeL2.LILIANG]) + 0.2 * 0.7 * this.getBaseProperty('atk') * this.level * cur_rate / 10000 + this.getBaseProperty('atk'));
|
||
let calspd = Math.round((this.getBaseProperty('spd') + (this.level + this.ppoint[EAttrTypeL2.MINJIE])) * cur_rate / 10000);
|
||
|
||
this.setAttr1(EAttrTypeL1.HP, calhp);
|
||
this.setAttr1(EAttrTypeL1.HP_MAX, calhp);
|
||
this.setAttr1(EAttrTypeL1.MP, calmp);
|
||
this.setAttr1(EAttrTypeL1.MP_MAX, calmp);
|
||
this.setAttr1(EAttrTypeL1.ATK, calatk);
|
||
this.setAttr1(EAttrTypeL1.SPD, calspd);
|
||
|
||
this.dpoint[EAttrTypeL1.K_SEAL] = this.dpoint[EAttrTypeL1.K_SEAL] || 0;
|
||
this.dpoint[EAttrTypeL1.K_CONFUSION] = this.dpoint[EAttrTypeL1.K_CONFUSION] || 0;
|
||
this.dpoint[EAttrTypeL1.K_SLEEP] = this.dpoint[EAttrTypeL1.K_SLEEP] || 0;
|
||
this.dpoint[EAttrTypeL1.K_FORGET] = this.dpoint[EAttrTypeL1.K_FORGET] || 0;
|
||
this.dpoint[EAttrTypeL1.K_DETER] = this.dpoint[EAttrTypeL1.K_DETER] || 0;
|
||
this.dfengyin = this.dpoint[EAttrTypeL1.K_SEAL] * 4 + player.checkPetOfudaUseState(this, EAttrTypeL1.K_SEAL) + this.ofudaQingLan(EAttrTypeL1.K_SEAL);
|
||
this.dhunlun = this.dpoint[EAttrTypeL1.K_CONFUSION] * 4 + player.checkPetOfudaUseState(this, EAttrTypeL1.K_CONFUSION) + this.ofudaQingLan(EAttrTypeL1.K_CONFUSION);
|
||
this.dhunshui = this.dpoint[EAttrTypeL1.K_SLEEP] * 4 + player.checkPetOfudaUseState(this, EAttrTypeL1.K_SLEEP) + this.ofudaQingLan(EAttrTypeL1.K_SLEEP);
|
||
this.dyiwang = this.dpoint[EAttrTypeL1.K_FORGET] * 4 + player.checkPetOfudaUseState(this, EAttrTypeL1.K_FORGET) + this.ofudaQingLan(EAttrTypeL1.K_FORGET);
|
||
this.dzhenshe = this.dpoint[EAttrTypeL1.K_DETER] * 4 + player.checkPetOfudaUseState(this, EAttrTypeL1.K_DETER);
|
||
|
||
this.setAttr1(EAttrTypeL1.K_SEAL, this.dfengyin);
|
||
this.setAttr1(EAttrTypeL1.K_CONFUSION, this.dhunlun);
|
||
this.setAttr1(EAttrTypeL1.K_SLEEP, this.dhunshui);
|
||
this.setAttr1(EAttrTypeL1.K_FORGET, this.dyiwang);
|
||
this.setAttr1(EAttrTypeL1.K_DETER, this.dzhenshe);
|
||
|
||
this.dpoint[EAttrTypeL1.K_WIND] = this.dpoint[EAttrTypeL1.K_WIND] || 0;
|
||
this.dpoint[EAttrTypeL1.K_WATER] = this.dpoint[EAttrTypeL1.K_WATER] || 0;
|
||
this.dpoint[EAttrTypeL1.K_FIRE] = this.dpoint[EAttrTypeL1.K_FIRE] || 0;
|
||
this.dpoint[EAttrTypeL1.K_POISON] = this.dpoint[EAttrTypeL1.K_POISON] || 0;
|
||
this.dpoint[EAttrTypeL1.K_THUNDER] = this.dpoint[EAttrTypeL1.K_THUNDER] || 0;
|
||
this.dpoint[EAttrTypeL1.K_WILDFIRE] = this.dpoint[EAttrTypeL1.K_WILDFIRE] || 0;
|
||
this.dpoint[EAttrTypeL1.K_BLOODRETURN] = this.dpoint[EAttrTypeL1.K_BLOODRETURN] || 0;
|
||
|
||
this.dfeng = this.dpoint[EAttrTypeL1.K_WIND] * 4;
|
||
this.dshui = this.dpoint[EAttrTypeL1.K_WATER] * 4;
|
||
this.dhuo = this.dpoint[EAttrTypeL1.K_FIRE] * 4;
|
||
this.ddu = this.dpoint[EAttrTypeL1.K_POISON] * 4;
|
||
this.dlei = this.dpoint[EAttrTypeL1.K_THUNDER] * 4;
|
||
this.dguihuo = this.dpoint[EAttrTypeL1.K_WILDFIRE] * 4;
|
||
this.dsanshi = this.dpoint[EAttrTypeL1.K_BLOODRETURN] * 4;
|
||
|
||
this.setAttr1(EAttrTypeL1.K_WIND, this.dfeng);
|
||
this.setAttr1(EAttrTypeL1.K_WATER, this.dshui);
|
||
this.setAttr1(EAttrTypeL1.K_FIRE, this.dhuo);
|
||
this.setAttr1(EAttrTypeL1.K_POISON, this.ddu);
|
||
this.setAttr1(EAttrTypeL1.K_THUNDER, this.dlei);
|
||
this.setAttr1(EAttrTypeL1.K_WILDFIRE, this.dguihuo);
|
||
this.setAttr1(EAttrTypeL1.K_BLOODRETURN, this.dsanshi);
|
||
|
||
this.dpoint[EAttrTypeL1.PHY_GET] = this.dpoint[EAttrTypeL1.PHY_GET] || 0;
|
||
this.dpoint[EAttrTypeL1.PHY_HIT] = this.dpoint[EAttrTypeL1.PHY_HIT] || 0;
|
||
this.dpoint[EAttrTypeL1.PHY_DODGE] = this.dpoint[EAttrTypeL1.PHY_DODGE] || 0;
|
||
this.dpoint[EAttrTypeL1.PHY_COMBO] = this.dpoint[EAttrTypeL1.PHY_COMBO] || 0;
|
||
this.dpoint[EAttrTypeL1.PHY_COMBO_PROB] = this.dpoint[EAttrTypeL1.PHY_COMBO_PROB] || 0;
|
||
this.dpoint[EAttrTypeL1.PHY_DEADLY] = this.dpoint[EAttrTypeL1.PHY_DEADLY] || 0;
|
||
this.dpoint[EAttrTypeL1.PHY_BREAK] = this.dpoint[EAttrTypeL1.PHY_BREAK] || 0;
|
||
this.dpoint[EAttrTypeL1.PHY_BREAK_PROB] = this.dpoint[EAttrTypeL1.PHY_BREAK_PROB] || 0;
|
||
this.dpoint[EAttrTypeL1.PHY_REBOUND_PROB] = this.dpoint[EAttrTypeL1.PHY_REBOUND_PROB] || 0;
|
||
this.dpoint[EAttrTypeL1.PHY_REBOUND] = this.dpoint[EAttrTypeL1.PHY_REBOUND] || 0;
|
||
|
||
this.pxishou = this.dpoint[EAttrTypeL1.PHY_GET] * 3;
|
||
this.pmingzhong = 80 + this.dpoint[EAttrTypeL1.PHY_HIT] * 1.5 + player.checkPetOfudaUseState(this, EAttrTypeL1.PHY_HIT);
|
||
this.pshanbi = this.dpoint[EAttrTypeL1.PHY_DODGE] * 1.5;
|
||
this.plianji = 3 + this.dpoint[EAttrTypeL1.PHY_COMBO] * 1;
|
||
this.plianjilv = this.dpoint[EAttrTypeL1.PHY_COMBO_PROB] * 1.5;
|
||
this.pkuangbao = this.dpoint[EAttrTypeL1.PHY_DEADLY] * 1.5;
|
||
this.ppofang = this.dpoint[EAttrTypeL1.PHY_BREAK] * 3 + player.checkPetOfudaUseState(this, EAttrTypeL1.PHY_BREAK);
|
||
this.ppofanglv = this.dpoint[EAttrTypeL1.PHY_BREAK_PROB] * 3 + player.checkPetOfudaUseState(this, EAttrTypeL1.PHY_BREAK_PROB);
|
||
this.pfanzhenlv = this.dpoint[EAttrTypeL1.PHY_REBOUND_PROB] * 4;
|
||
this.pfanzhen = this.dpoint[EAttrTypeL1.PHY_REBOUND] * 4 + player.checkPetOfudaUseState(this, EAttrTypeL1.PHY_REBOUND);
|
||
|
||
this.setAttr1(EAttrTypeL1.PHY_GET, this.pxishou);
|
||
this.setAttr1(EAttrTypeL1.PHY_HIT, this.pmingzhong);
|
||
this.setAttr1(EAttrTypeL1.PHY_DODGE, this.pshanbi);
|
||
this.setAttr1(EAttrTypeL1.PHY_COMBO, this.plianji);
|
||
this.setAttr1(EAttrTypeL1.PHY_COMBO_PROB, this.plianjilv);
|
||
this.setAttr1(EAttrTypeL1.PHY_DEADLY, this.pkuangbao);
|
||
this.setAttr1(EAttrTypeL1.PHY_BREAK, this.ppofang);
|
||
this.setAttr1(EAttrTypeL1.PHY_BREAK_PROB, this.ppofanglv);
|
||
this.setAttr1(EAttrTypeL1.PHY_REBOUND_PROB, this.pfanzhenlv);
|
||
this.setAttr1(EAttrTypeL1.PHY_REBOUND, this.pfanzhen);
|
||
|
||
this.maxhp = this.getBaseProperty('hp');
|
||
this.maxmp = this.getBaseProperty('mp');
|
||
this.maxexp = ExpUtil.getSummonUpGradeExp(this.relive, this.level);
|
||
this.calcPassiveSkillAttr();
|
||
this.calcHorseSkillAttr();
|
||
|
||
player.ZFMgr.calculateActiveZhenFaForPet(this.attr1)
|
||
}
|
||
|
||
// 计算被动技能属性
|
||
calcPassiveSkillAttr() {
|
||
let skill_list = this.getActualSkill(this.skill_list)
|
||
for (let skillId in skill_list) {
|
||
let skill = SkillUtil.getSkill(skillId);
|
||
this.checkSkill(skill, "召唤兽");
|
||
}
|
||
if (this.shenskill != 0) {
|
||
let skill = SkillUtil.getSkill(this.shenskill);
|
||
this.checkSkill(skill, "神兽");
|
||
}
|
||
}
|
||
|
||
// 获取已经学会的技能
|
||
getActualSkill(skill_list: any): any {
|
||
let skill: any = {};
|
||
for (let key in skill_list) {
|
||
if (key != skill_list[key].idx) {
|
||
skill[key] = skill_list[key];
|
||
}
|
||
}
|
||
return skill;
|
||
}
|
||
|
||
// 计算坐骑技能属性
|
||
calcHorseSkillAttr() {
|
||
if (this.control < 1) {
|
||
return;
|
||
}
|
||
if (this.owner == null) {
|
||
return;
|
||
}
|
||
let horse = this.owner.horseList.getHorse(this.control);
|
||
if (horse == null) {
|
||
return;
|
||
}
|
||
let skillList = this.owner.horseSkill.getList(this.control);
|
||
for (let skill of skillList) {
|
||
this.checkHorseSkill(skill, horse);
|
||
}
|
||
}
|
||
|
||
checkSkill(skill: SkillBase, prefix: string) {
|
||
if (skill == null) {
|
||
return;
|
||
}
|
||
if (skill.action_type != EActionType.PASSIVE) {
|
||
return;
|
||
}
|
||
let effectMap = skill.effectMap;
|
||
for (let key in effectMap) {
|
||
let type: EAttrTypeL1 = SKDataUtil.numberBy(key);
|
||
let params: any = {
|
||
type: type,
|
||
level: this.level,
|
||
relive: this.relive,
|
||
qinmi: this.qinmi
|
||
};
|
||
let ret = skill.getEffect(params);
|
||
if (ret.add) {
|
||
let old = SKDataUtil.toDecimal2(this.attr1[type]);
|
||
this.attr1[type] = SKDataUtil.toDecimal2(old + ret.add);
|
||
let current = this.attr1[type];
|
||
SKLogger.debug(`${prefix}[${this.name}]技能[${skill.skill_name}][${GameUtil.attrTypeL1Name[type]}]改变[${ret.add}]:${old}->${current}`);
|
||
let oldHP = this.attr1[EAttrTypeL1.HP];
|
||
let oldMP = this.attr1[EAttrTypeL1.MP];
|
||
let oldATK = this.attr1[EAttrTypeL1.ATK];
|
||
let oldSPD = this.attr1[EAttrTypeL1.SPD];
|
||
if (type == EAttrTypeL1.HP_MAX) {
|
||
this.attr1[EAttrTypeL1.HP] = this.attr1[EAttrTypeL1.HP_MAX];
|
||
SKLogger.debug(`${prefix}[${this.name}]技能[${skill.skill_name}]气血最大值改变:${oldHP}->${this.attr1[EAttrTypeL1.HP]}`);
|
||
} else if (type == EAttrTypeL1.MP_MAX) {
|
||
this.attr1[EAttrTypeL1.MP] = this.attr1[EAttrTypeL1.MP_MAX];
|
||
SKLogger.debug(`${prefix}[${this.name}]技能[${skill.skill_name}]法力最大值改变:${oldMP}->${this.attr1[EAttrTypeL1.MP]}`);
|
||
} else if (type == EAttrTypeL1.HP_PERC) {
|
||
this.attr1[EAttrTypeL1.HP] = Math.floor(this.attr1[EAttrTypeL1.HP_MAX] * (1 + ret.add / 100));
|
||
SKLogger.debug(`${prefix}[${this.name}]技能[${skill.skill_name}]气血百分比改变:${oldHP}->${this.attr1[EAttrTypeL1.HP]}`);
|
||
} else if (type == EAttrTypeL1.MP_PERC) {
|
||
this.attr1[EAttrTypeL1.MP] = Math.floor(this.attr1[EAttrTypeL1.MP_MAX] * (1 + ret.add / 100));
|
||
SKLogger.debug(`${prefix}[${this.name}]技能[${skill.skill_name}]法力百分比改变:${oldMP}->${this.attr1[EAttrTypeL1.MP]}`);
|
||
} else if (type == EAttrTypeL1.ATK_PERC) {
|
||
this.attr1[EAttrTypeL1.ATK] = Math.floor(this.attr1[EAttrTypeL1.ATK] * (1 + ret.add / 100));
|
||
SKLogger.debug(`${prefix}[${this.name}]技能[${skill.skill_name}]攻击百分比改变:${oldATK}->${this.attr1[EAttrTypeL1.ATK]}`);
|
||
} else if (type == EAttrTypeL1.SPD_PERC) {
|
||
this.attr1[EAttrTypeL1.SPD] = Math.floor(this.attr1[EAttrTypeL1.SPD] * (1 + ret.add / 100));
|
||
SKLogger.debug(`${prefix}[${this.name}]技能[${skill.skill_name}]速度百分比改变:${oldSPD}->${this.attr1[EAttrTypeL1.SPD]}`);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// 检查坐骑技能
|
||
checkHorseSkill(skill: SkillBase, horse: Horse) {
|
||
if (skill == null) {
|
||
return;
|
||
}
|
||
if (skill.action_type != EActionType.PASSIVE) {
|
||
return;
|
||
}
|
||
let effectMap = skill.effectMap;
|
||
for (let key in effectMap) {
|
||
let type: EAttrTypeL1 = SKDataUtil.numberBy(key);
|
||
let ret = skill.getHorseEffect(type, horse.level, skill.exp);
|
||
if (ret.add) {
|
||
let old = SKDataUtil.toDecimal2(this.attr1[type]);
|
||
this.attr1[type] = SKDataUtil.toDecimal2(old + ret.add);
|
||
let current: number = this.attr1[type];
|
||
SKLogger.debug(`召唤兽[${this.name}]坐骑[${horse.name}]技能[${skill.skill_name}][${GameUtil.attrTypeL1Name[type]}]改变[${ret.add}]:${old}->${current}`);
|
||
let oldHP = this.attr1[EAttrTypeL1.HP];
|
||
let oldMP = this.attr1[EAttrTypeL1.MP];
|
||
let oldATK = this.attr1[EAttrTypeL1.ATK];
|
||
let oldSPD = this.attr1[EAttrTypeL1.SPD];
|
||
if (type == EAttrTypeL1.HP_MAX) {
|
||
this.attr1[EAttrTypeL1.HP] = this.attr1[EAttrTypeL1.HP_MAX];
|
||
SKLogger.debug(`召唤兽[${this.name}]坐骑[${horse.name}]技能[${skill.skill_name}]气血最大值改变:${oldHP}->${this.attr1[EAttrTypeL1.HP]}`);
|
||
} else if (type == EAttrTypeL1.MP_MAX) {
|
||
this.attr1[EAttrTypeL1.MP] = this.attr1[EAttrTypeL1.MP_MAX];
|
||
SKLogger.debug(`召唤兽[${this.name}]坐骑[${horse.name}]技能[${skill.skill_name}]法力最大值改变:${oldMP}->${this.attr1[EAttrTypeL1.MP]}`);
|
||
} else if (type == EAttrTypeL1.HP_PERC) {
|
||
this.attr1[EAttrTypeL1.HP] = Math.floor(this.attr1[EAttrTypeL1.HP_MAX] * (1 + ret.add / 100));
|
||
SKLogger.debug(`召唤兽[${this.name}]坐骑[${horse.name}]技能[${skill.skill_name}]气血百分比改变:${oldHP}->${this.attr1[EAttrTypeL1.HP]}`);
|
||
} else if (type == EAttrTypeL1.MP_PERC) {
|
||
this.attr1[EAttrTypeL1.MP] = Math.floor(this.attr1[EAttrTypeL1.MP_MAX] * (1 + ret.add / 100));
|
||
SKLogger.debug(`召唤兽[${this.name}]坐骑[${horse.name}]技能[${skill.skill_name}]法力百分比改变:${oldMP}->${this.attr1[EAttrTypeL1.MP]}`);
|
||
} else if (type == EAttrTypeL1.ATK_PERC) {
|
||
this.attr1[EAttrTypeL1.ATK] = Math.floor(this.attr1[EAttrTypeL1.ATK] * (1 + ret.add / 100));
|
||
SKLogger.debug(`召唤兽[${this.name}]坐骑[${horse.name}]技能[${skill.skill_name}]攻击百分比改变:${oldATK}->${this.attr1[EAttrTypeL1.ATK]}`);
|
||
} else if (type == EAttrTypeL1.SPD_PERC) {
|
||
this.attr1[EAttrTypeL1.SPD] = Math.floor(this.attr1[EAttrTypeL1.SPD] * (1 + ret.add / 100));
|
||
SKLogger.debug(`召唤兽[${this.name}]坐骑[${horse.name}]技能[${skill.skill_name}]速度百分比改变:${oldSPD}->${this.attr1[EAttrTypeL1.SPD]}`);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//天演策技能
|
||
checkOfudaSkill(skill: SkillBase,addition: number, addi: number){
|
||
if (skill == null) {
|
||
return 0;
|
||
}
|
||
if (skill.action_type != EActionType.PASSIVE) {
|
||
return 0;
|
||
}
|
||
let liliang = this.ppoint[EAttrTypeL2.LILIANG];
|
||
let lingxing = this.ppoint[EAttrTypeL2.LINGXING];
|
||
let gengu = this.ppoint[EAttrTypeL2.GENGU];
|
||
if(skill.skill_id == ESkillType.MengGong1){
|
||
let num = Math.floor(((liliang / 100 * 0.03) * addition) * (addi * 0.1));
|
||
return num;
|
||
}
|
||
if(skill.skill_id == ESkillType.MengGong2){
|
||
let num = Math.floor(((liliang / 100 * 0.05) * addition) * (addi * 0.1));
|
||
return num;
|
||
}
|
||
if(skill.skill_id == ESkillType.MengGong3){
|
||
let num = Math.floor(((liliang / 100 * 0.08) * addition) * (addi * 0.1));
|
||
return num;
|
||
}
|
||
if(skill.skill_id == ESkillType.KanPo1){
|
||
let num = Math.floor(((liliang / 100 * 0.02) * addition) * (addi * 0.1));
|
||
return num;
|
||
}
|
||
if(skill.skill_id == ESkillType.KanPo2){
|
||
let num = Math.floor(((liliang / 100 * 0.05) * addition) * (addi * 0.1));
|
||
return num;
|
||
}
|
||
if(skill.skill_id == ESkillType.KanPo3){
|
||
let num = Math.floor(((liliang / 100 * 0.08) * addition) * (addi * 0.1));
|
||
return num;
|
||
}
|
||
if(skill.skill_id == ESkillType.JingZhun1){
|
||
let num = Math.floor(((liliang / 100 * 0.02) * addition) * (addi * 0.1));
|
||
return num;
|
||
}
|
||
if(skill.skill_id == ESkillType.JingZhun2){
|
||
let num = Math.floor(((liliang / 100 * 0.05) * addition) * (addi * 0.1));
|
||
return num;
|
||
}
|
||
if(skill.skill_id == ESkillType.JingZhun3){
|
||
let num = Math.floor(((liliang / 100 * 0.08) * addition) * (addi * 0.1));
|
||
return num;
|
||
}
|
||
if(skill.skill_id == ESkillType.HuWei1){
|
||
let num = SKDataUtil.toDecimal2((1 + (addition * 0.1)) * (addi * 0.1))
|
||
return num;
|
||
}
|
||
if(skill.skill_id == ESkillType.HuWei2){
|
||
let num = SKDataUtil.toDecimal2((1 + (addition * 0.1)) * (addi * 0.1))
|
||
return num;
|
||
}
|
||
if(skill.skill_id == ESkillType.HuWei3){
|
||
let num = SKDataUtil.toDecimal2((1 + (addition * 0.1)) * (addi * 0.1))
|
||
return num;
|
||
}
|
||
if(skill.skill_id == ESkillType.LianXi1){
|
||
let num = SKDataUtil.toDecimal2((1 + (addition * 0.1)) * (addi * 0.1))
|
||
return num;
|
||
}
|
||
if(skill.skill_id == ESkillType.LianXi2){
|
||
let num = SKDataUtil.toDecimal2((1 + (addition * 0.1)) * (addi * 0.1))
|
||
return num;
|
||
}
|
||
if(skill.skill_id == ESkillType.LianXi3){
|
||
let num = SKDataUtil.toDecimal2((1 + (addition * 0.1)) * (addi * 0.1))
|
||
return num;
|
||
}
|
||
if(skill.skill_id == ESkillType.HuiGen1){
|
||
let num = Math.floor(((lingxing / 100 * 0.02) * addition) * (addi * 0.1)) + Math.floor(((gengu / 100 * 0.08) * addition) * (addi * 0.1));
|
||
return num;
|
||
}
|
||
if(skill.skill_id == ESkillType.HuiGen2){
|
||
let num = Math.floor(((lingxing / 100 * 0.05) * addition) * (addi * 0.1)) + Math.floor(((gengu / 100 * 0.08) * addition) * (addi * 0.1));
|
||
return num;
|
||
}
|
||
if(skill.skill_id == ESkillType.HuiGen3){
|
||
let num = Math.floor(((lingxing / 100 * 0.08) * addition) * (addi * 0.1)) + Math.floor(((gengu / 100 * 0.08) * addition) * (addi * 0.1));
|
||
return num;
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
toObj() {
|
||
let obj: any = {};
|
||
if (this.grade == 4 && this.shenskill == 0) {
|
||
this.shenskill = 3005;
|
||
}
|
||
obj.petid = this.petid;
|
||
obj.dataid = this.dataid;
|
||
obj.onlyid = this.onlyid;
|
||
obj.ownid = this.owner.roleid;
|
||
obj.name = this.name;
|
||
obj.relive = this.relive;
|
||
obj.level = this.level;
|
||
obj.resid = this.resid;
|
||
obj.grade = this.grade;
|
||
obj.skill = SKDataUtil.toJson(this.skill_list, "{}");
|
||
obj.ppoint = SKDataUtil.toJson(this.ppoint, "{}");
|
||
obj.dpoint = SKDataUtil.toJson(this.dpoint, "{}");
|
||
obj.wuxing = SKDataUtil.toJson(this.wuxing, "{}");
|
||
obj.exp = this.exp;
|
||
obj.rate = this.getCurRate();
|
||
obj.maxrate = this.getMaxRate();
|
||
obj.hp = this.getBaseProperty('hp');
|
||
obj.mp = this.getBaseProperty('mp');
|
||
obj.atk = this.getBaseProperty('atk');
|
||
obj.spd = this.getBaseProperty('spd');
|
||
obj.intro = this.intro;
|
||
obj.xexp = this.xexp;
|
||
obj.xlevel = this.xlevel;
|
||
obj.longgu = this.longgu;
|
||
obj.maxskillcnt = this.maxskillcnt;
|
||
obj.attr1 = SKDataUtil.toJson(this.attr1, "{}");
|
||
obj.shenskill = this.shenskill;
|
||
obj.color = this.color;
|
||
obj.qinmi = this.qinmi;
|
||
obj.fly = this.fly;
|
||
obj.control = this.control;
|
||
obj.aptitude = this.aptitude;
|
||
return obj;
|
||
}
|
||
|
||
//宝宝转生
|
||
petRelive() {
|
||
if (!this.owner) {
|
||
return;
|
||
}
|
||
let nextlive = this.relive + 1;
|
||
if (nextlive > 4) { //最大转生4
|
||
this.owner.send('s2c_notice', {
|
||
//更高转生等级暂未开放
|
||
strRichText: MsgCode.RELIVE_LEVEL_TOO_HIGH + ''
|
||
});
|
||
return;
|
||
}
|
||
if (nextlive > this.owner.relive) {
|
||
this.owner.send('s2c_notice', {
|
||
strRichText: `角色转生等级不足!`
|
||
});
|
||
return;
|
||
}
|
||
if (this.level < ExpUtil.getSummonMaxGrade(this.relive)) { //等级不够
|
||
this.owner.send('s2c_notice', {
|
||
strRichText: MsgCode.RELIVE_LEVEL_NOT_ENOUGH + ''
|
||
});
|
||
return;
|
||
}
|
||
let maxrate = this.getMaxRate();
|
||
if (this.rate > maxrate) {
|
||
this.rate = maxrate;
|
||
}
|
||
this.relive = nextlive;
|
||
this.level = ExpUtil.getSummonGradeStart(this.relive);
|
||
for (const key in this.ppoint) {
|
||
this.ppoint[key] = 0;
|
||
}
|
||
this.addExp(0);
|
||
this.calculateAttribute();
|
||
let info = `您的召唤兽[${this.name}]${this.relive < 4 ? `${this.relive}转` : "飞升"}成功!`
|
||
this.owner.send('s2c_notice', {
|
||
strRichText: info
|
||
});
|
||
}
|
||
|
||
/*
|
||
* 洗练属性
|
||
*/
|
||
washProperty() {
|
||
if (!this.owner) {
|
||
return;
|
||
}
|
||
let data = PetMgr.shared.getBaseAttr(this.dataid);
|
||
let petData = PetMgr.shared.getPetData(this.dataid);
|
||
this.wash_property = SKDataUtil.clone(data); // 保存的属性不能+60
|
||
switch (parseInt("" + this.fly / 10)) { // 神兽飞升
|
||
case 1:
|
||
data.hp += 60;
|
||
if(data.hp > petData.hp[1]){
|
||
data.hp = petData.hp[1];
|
||
}
|
||
break;
|
||
case 2:
|
||
data.mp += 60;
|
||
if(data.mp > petData.mp[1]){
|
||
data.mp = petData.mp[1];
|
||
}
|
||
break;
|
||
case 3:
|
||
data.atk += 60;
|
||
if(data.atk > petData.atk[1]){
|
||
data.atk = petData.atk[1];
|
||
}
|
||
break;
|
||
case 4:
|
||
data.spd += 60;
|
||
if(data.spd > petData.spd[1]){
|
||
data.spd = petData.spd[1];
|
||
}
|
||
break;
|
||
}
|
||
data.rate += this.getRateAdd();
|
||
data.maxrate = this.getMaxRate(); // 元气丹可以影响最大成长率
|
||
if (data.rate > data.maxrate) {
|
||
data.rate = data.maxrate;
|
||
}
|
||
if (data.aptitude == Aptitude.EXCELLENT){
|
||
data.rate = data.maxrate;
|
||
}
|
||
this.owner.send('s2c_wash_petproperty', data);
|
||
}
|
||
highWashProperty() {
|
||
if (!this.owner) {
|
||
return;
|
||
}
|
||
let list = [];
|
||
let petData = PetMgr.shared.getPetData(this.dataid);
|
||
for(let i = 0; i < 6; i++){
|
||
let data = PetMgr.shared.getBaseAttr(this.dataid);
|
||
this.wash_property = SKDataUtil.clone(data); // 保存的属性不能+60
|
||
switch (parseInt("" + this.fly / 10)) { // 神兽飞升
|
||
case 1:
|
||
data.hp += 60;
|
||
if(data.hp > petData.hp[1]){
|
||
data.hp = petData.hp[1];
|
||
}
|
||
break;
|
||
case 2:
|
||
data.mp += 60;
|
||
if(data.mp > petData.mp[1]){
|
||
data.mp = petData.mp[1];
|
||
}
|
||
break;
|
||
case 3:
|
||
data.atk += 60;
|
||
if(data.atk > petData.atk[1]){
|
||
data.atk = petData.atk[1];
|
||
}
|
||
break;
|
||
case 4:
|
||
data.spd += 60;
|
||
if(data.spd > petData.spd[1]){
|
||
data.spd = petData.spd[1];
|
||
}
|
||
break;
|
||
}
|
||
data.rate += this.getRateAdd();
|
||
data.maxrate = this.getMaxRate(); // 元气丹可以影响最大成长率
|
||
if (data.rate > data.maxrate) {
|
||
data.rate = data.maxrate;
|
||
}
|
||
if (data.aptitude == Aptitude.EXCELLENT){
|
||
data.rate = data.maxrate;
|
||
}
|
||
list.push(data);
|
||
}
|
||
this.owner.send('s2c_highwash_petproperty', {data: SKDataUtil.toJson(list,"{}")});
|
||
}
|
||
|
||
playerChangePetName(name: any) {
|
||
this.name = name;
|
||
this.owner.send('s2c_update_pet', {
|
||
info: this.toObj()
|
||
});
|
||
}
|
||
|
||
/*
|
||
* 保存洗练属性
|
||
*/
|
||
saveProperty(data: any) {
|
||
if (!this.owner) {
|
||
return;
|
||
}
|
||
if(data.info){
|
||
this.wash_property = SKDataUtil.jsonBy(data.info);
|
||
}
|
||
let petdata = PetMgr.shared.getPetData(this.dataid);
|
||
if (this.wash_property) {
|
||
this.rate = this.wash_property.rate;
|
||
this.basehp = this.wash_property.hp;
|
||
this.basemp = this.wash_property.mp;
|
||
this.basespd = this.wash_property.spd;
|
||
this.baseatk = this.wash_property.atk;
|
||
this.aptitude = this.wash_property.aptitude;
|
||
this.calculateAttribute();
|
||
this.owner.send('s2c_update_pet', {
|
||
info: this.toObj()
|
||
});
|
||
let ret_data = {
|
||
errcode: MsgCode.SUCCESS,
|
||
petid: this.petid,
|
||
rate: this.getCurRate(),
|
||
maxrate: this.getMaxRate(),
|
||
hp: this.getBaseProperty('hp'),
|
||
mp: this.getBaseProperty('mp'),
|
||
spd: this.getBaseProperty('spd'),
|
||
atk: this.getBaseProperty('atk'),
|
||
aptitude: this.wash_property.aptitude,
|
||
};
|
||
if(ret_data.rate > ret_data.maxrate){
|
||
ret_data.rate = ret_data.maxrate;
|
||
}
|
||
if(ret_data.hp > petdata.hp[1]){
|
||
ret_data.hp = petdata.hp[1];
|
||
}
|
||
if(ret_data.mp > petdata.mp[1]){
|
||
ret_data.mp = petdata.mp[1];
|
||
}
|
||
if(ret_data.atk > petdata.atk[1]){
|
||
ret_data.atk = petdata.atk[1];
|
||
}
|
||
if(ret_data.spd > petdata.spd[1]){
|
||
ret_data.spd = petdata.spd[1];
|
||
}
|
||
this.owner.send('s2c_save_petproperty', ret_data);
|
||
this.wash_property = null;
|
||
}
|
||
return;
|
||
}
|
||
|
||
useLongGu() {
|
||
if (this.longgu < PetMgr.shared.getMaxLongGu(this.relive)) {
|
||
this.longgu += 1;
|
||
this.calculateAttribute();
|
||
if (this.owner) {
|
||
this.owner.send('s2c_update_pet', {
|
||
info: this.toObj()
|
||
});
|
||
}
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
toSaveObj(): any {
|
||
let result: any = {};
|
||
if (this.grade == 4 && this.shenskill == 0) {
|
||
this.shenskill = 3005;
|
||
}
|
||
result.petid = this.petid;
|
||
result.name = this.name;
|
||
result.dataid = this.dataid;
|
||
result.relive = this.relive;
|
||
result.level = this.level;
|
||
result.resid = this.resid;
|
||
result.color = this.petColorTransformDB(this.color);
|
||
result.grade = this.grade;
|
||
result.roleid = this.owner.roleid;
|
||
result.fly = this.fly;
|
||
result.qinmi = this.qinmi;
|
||
result.shenskill = this.shenskill;
|
||
result.skill = SKDataUtil.toJson(this.skill_list, "{}");
|
||
result.ppoint = SKDataUtil.toJson(this.ppoint, "{}");
|
||
result.dpoint = SKDataUtil.toJson(this.dpoint, "{}");
|
||
result.rate = this.rate;
|
||
result.hp = this.basehp;
|
||
result.mp = this.basemp;
|
||
result.atk = this.baseatk;
|
||
result.spd = this.basespd;
|
||
result.wuxing = SKDataUtil.toJson(this.wuxing, "{}");
|
||
result.exp = this.exp;
|
||
result.xexp = this.xexp;
|
||
result.xlevel = this.xlevel;
|
||
result.longgu = this.longgu;
|
||
result.control = this.control;
|
||
return result;
|
||
}
|
||
|
||
addExp(exp: any): boolean {
|
||
if (exp == 0) {
|
||
return false;
|
||
}
|
||
|
||
//检查星阵是否装备赤马阵, 经验获得加成
|
||
if (exp > 0 && this.owner && this.owner.StarMgr.EquipID == 5){
|
||
let star = this.owner.StarMgr.GetStarByID(5)
|
||
let buf = star.Level * 0.003
|
||
exp = Math.floor(exp * (1 + buf))
|
||
}
|
||
|
||
let maxlevel = ExpUtil.getSummonMaxGrade(this.relive);
|
||
let plevel = this.owner == null ? 0 : this.owner.level;
|
||
let prelive = this.owner == null ? 0 : this.owner.relive;
|
||
if (this.relive >= prelive) {
|
||
maxlevel = Math.min(maxlevel, plevel + 10);
|
||
}
|
||
let upexp = ExpUtil.getSummonUpGradeExp(this.relive, this.level);
|
||
if (this.level >= maxlevel && this.exp >= upexp) { //超过本次转生的最大等级
|
||
return false;
|
||
}
|
||
this.exp += exp;
|
||
let isleavelup = false;
|
||
while (this.exp >= upexp) {
|
||
this.exp -= upexp;
|
||
this.level++;
|
||
if (this.level > maxlevel) {
|
||
this.level = maxlevel;
|
||
this.exp = ExpUtil.getSummonUpGradeExp(this.relive, this.level);
|
||
break;
|
||
}
|
||
isleavelup = true;
|
||
upexp = ExpUtil.getSummonUpGradeExp(this.relive, this.level);
|
||
}
|
||
if (isleavelup) {
|
||
this.owner.send('s2c_notice', {
|
||
strRichText: `您的召唤兽[color=#00FF00]${this.name}[/color]等级升到了[color=#00FF00]${this.level}[/color]级!`
|
||
});
|
||
}
|
||
this.calculateAttribute();
|
||
if (this.owner) {
|
||
this.owner.send('s2c_update_pet', {
|
||
info: this.toObj()
|
||
});
|
||
}
|
||
this.owner.send('s2c_notice', {
|
||
strRichText: `你的召唤[color=#00FF00]${this.name}[/color]获得了[img]ui://main_ui/ui_common_icon_exppet[/img][color=#00FF00]${exp}[/color]`
|
||
});
|
||
this.owner.refresh_team_data();
|
||
return true;
|
||
}
|
||
|
||
getSkillNum() {
|
||
return Object.keys(this.skill_list).length;
|
||
}
|
||
|
||
// 开启宠物技能格子
|
||
openSkillGrid(index: any) {
|
||
let skillnum = this.getSkillNum();
|
||
if (skillnum >= this.maxskillcnt) {
|
||
this.send('s2c_notice', {
|
||
strRichText: `宠物技能栏已全部开启`
|
||
});
|
||
return;
|
||
} else {
|
||
this.skill_list[index] = {
|
||
idx: index,
|
||
lck: 0
|
||
};
|
||
this.owner.send("s2c_pet_skill_grid", {
|
||
petInfo: SKDataUtil.toJson(this.toObj(), "{}"),
|
||
type: 1
|
||
})
|
||
return;
|
||
}
|
||
}
|
||
|
||
// 宠物学习技能书
|
||
learnSkill(skillid: any) {
|
||
let skilldata: SkillBase = SkillUtil.getSkill(skillid);
|
||
if (skilldata == null) {
|
||
return false;
|
||
}
|
||
if (this.skill_list[skillid] != null) {
|
||
this.owner.send_notice(`[color=#0fffff]${this.name}[/color]已学会 ${skilldata.skill_name}了`);
|
||
return false;
|
||
}
|
||
let skillnum = this.getSkillNum();
|
||
let data = PetMgr.shared.getPetData(this.dataid);
|
||
let num = this.getAllSkill(data.skill);
|
||
if (num <= 0) {
|
||
this.owner.send_notice('请先开启宠物格子');
|
||
return false;
|
||
}
|
||
|
||
if (skilldata.kind != 0) {
|
||
for (const sid in this.skill_list) {
|
||
if (Number(sid) != 0) {
|
||
// 判断当前是否是开启的格子
|
||
if (this.skill_list[sid].idx != sid) {
|
||
// 不是格子获取技能
|
||
let info = SkillUtil.getSkill(sid);
|
||
if (info.kind == skilldata.kind) {
|
||
if (info.quality > skilldata.quality) {
|
||
return false;
|
||
}
|
||
delete this.skill_list[sid];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
// 遗忘上一个技能
|
||
let forget_str = '';
|
||
let lastskillinfo = null;
|
||
let tmp = this.getLearnSkill() - 1;
|
||
for (const skillid in this.skill_list) {
|
||
const skillinfo = this.skill_list[skillid];
|
||
if (skillinfo.idx > tmp && skillinfo.lck == 0) {
|
||
lastskillinfo = skillinfo;
|
||
lastskillinfo.skillid = skillid;
|
||
}
|
||
}
|
||
// 遗忘的技能
|
||
let forget: any;
|
||
if (lastskillinfo && lastskillinfo.lck == 0) {
|
||
if (skillnum > 1 || skilldata.skill_id == 0 || lastskillinfo.skillid != skilldata.skill_id) {
|
||
let onerand = 10000 / (this.maxskillcnt - 1);
|
||
let rand = GameUtil.random(0, 10000);
|
||
if (rand < onerand * tmp || this.getVacantGrid() == 0) {
|
||
forget = this.skill_list[lastskillinfo.skillid];
|
||
delete this.skill_list[lastskillinfo.skillid];
|
||
skillnum--;
|
||
let lastskilldata = SkillUtil.getSkill(lastskillinfo.skillid);
|
||
if (lastskilldata) {
|
||
if (lastskilldata.skill_id == 2110 || lastskilldata.skill_id == 2010) {//遗忘了闪现技能
|
||
PetSupport.shared.deletePet(this.owner.roleid, this.petid);
|
||
}
|
||
forget_str = `,遗忘了 ${lastskilldata.skill_name} 技能`;
|
||
} else {
|
||
forget_str = `,遗忘了技能`;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
// 替换技能
|
||
if (forget) {
|
||
this.skill_list[skillid] = {
|
||
idx: forget.idx,
|
||
lck: 0
|
||
};
|
||
if (skilldata.skill_id == 2110 || skilldata.skill_id == 2010) {//如果是闪现技能加入支援列表
|
||
PetSupport.shared.pushPet(this.owner.roleid, this.petid, this.name, this.resid);
|
||
}
|
||
}
|
||
// 学习新技能
|
||
else {
|
||
let index = this.getVacantGridIndex();
|
||
if (index != undefined) {
|
||
delete this.skill_list[index];
|
||
this.skill_list[skillid] = {
|
||
idx: index,
|
||
lck: 0
|
||
};
|
||
if (skillid == 2110 || skillid == 2010) {//如果是闪现技能加入支援列表
|
||
PetSupport.shared.pushPet(this.owner.roleid, this.petid, this.name, this.resid);
|
||
}
|
||
} else {
|
||
this.owner.send_notice('请先开启宠物格子');
|
||
return false;
|
||
}
|
||
|
||
}
|
||
|
||
// 通知前端
|
||
this.calculateAttribute();
|
||
this.owner.send_notice(`${this.name}习得 ${skilldata.skill_name}` + forget_str);
|
||
this.send('s2c_update_pet', {
|
||
info: this.toObj()
|
||
});
|
||
if (this.owner) {
|
||
SKLogger.debug(`玩家[${this.owner.roleid}:${this.owner.name}]的召唤兽[${this.petid}:${this.name}]习得${skilldata.skill_name}` + forget_str);
|
||
}
|
||
return true;
|
||
}
|
||
|
||
// 除了天生技能外数量
|
||
getAllSkill(skillid: any): number {
|
||
let num = 0;
|
||
for (let key in this.skill_list) {
|
||
if (key != skillid) {
|
||
num++;
|
||
}
|
||
}
|
||
return num;
|
||
}
|
||
|
||
// 已经学会的技能数量
|
||
getLearnSkill() {
|
||
let num = 0;
|
||
for (let key in this.skill_list) {
|
||
if (key != this.skill_list[key].idx) {
|
||
num++;
|
||
}
|
||
}
|
||
return num;
|
||
}
|
||
|
||
// 已经解锁格子数量
|
||
getVacantGrid() {
|
||
let num = 0;
|
||
for (let key in this.skill_list) {
|
||
if (key == this.skill_list[key].idx) {
|
||
num++;
|
||
}
|
||
}
|
||
return num;
|
||
}
|
||
|
||
// 随机获取个已经开启格子的下标
|
||
getVacantGridIndex() {
|
||
let list: any = [];
|
||
for (const sid in this.skill_list) {
|
||
if (Number(sid) != 0) {
|
||
// 判断当前是否是开启的格子
|
||
if (this.skill_list[sid].idx == sid) {
|
||
list.push(sid);
|
||
}
|
||
}
|
||
}
|
||
return list[Math.floor((Math.random() * list.length))];
|
||
}
|
||
|
||
getLockedSkillNum() {
|
||
let n = 0;
|
||
for (const skillid in this.skill_list) {
|
||
if (this.skill_list.hasOwnProperty(skillid)) {
|
||
const skillinfo = this.skill_list[skillid];
|
||
if (skillinfo.lck == 1) {
|
||
n++;
|
||
}
|
||
}
|
||
}
|
||
return n;
|
||
}
|
||
|
||
forgetSkill(skillid: any) {
|
||
let data = PetMgr.shared.getPetData(this.dataid);
|
||
//判断是否为天生技能
|
||
if (data.skill == skillid) {
|
||
let skilldata: SkillBase = SkillUtil.getSkill(skillid);
|
||
this.owner.send_notice(`天生技能[color=#0fffff]${skilldata.skill_name}[/color]不可以遗忘哦!`);
|
||
return;
|
||
}
|
||
// 获取技能
|
||
let skill = this.skill_list[skillid];
|
||
// 删除技能
|
||
delete this.skill_list[skillid];
|
||
// 重新赋值
|
||
if (skill != null){
|
||
this.skill_list[skill.idx] = {
|
||
idx: skill.idx,
|
||
lck: 0
|
||
};
|
||
}else {
|
||
SKLogger.info(`找不到召唤兽[${this.name} = [${skillid}]技能信息`)
|
||
}
|
||
|
||
let skillinfo = SkillUtil.getSkill(skillid);
|
||
this.calculateAttribute();
|
||
let str = `玩家[${this.owner.name}(${this.owner.roleid})]的召唤兽[${this.name}(${this.petid})]遗忘了`;
|
||
if (skillinfo) {
|
||
if (skillinfo.skill_id == 2110 || skillinfo.skill_id == 2010) {//遗忘了闪现技能
|
||
PetSupport.shared.deletePet(this.owner.roleid, this.petid);
|
||
}
|
||
str += `${skillinfo.skill_name}`;
|
||
this.owner.send_notice(`你的召唤兽[${this.name}]遗忘了[${skillinfo.skill_name}]`);
|
||
}
|
||
str += `(${skillid})`;
|
||
SKLogger.debug(str);
|
||
this.send('s2c_update_pet', {
|
||
info: this.toObj()
|
||
});
|
||
}
|
||
|
||
lockSkill(skillid: any) {
|
||
let skillinfo = this.skill_list[skillid];
|
||
if (skillinfo && skillinfo.lck == 0) {
|
||
skillinfo.lck = 1;
|
||
this.send('s2c_update_pet', {
|
||
info: this.toObj()
|
||
});
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
changeShenShouSkill(skillid: any) {
|
||
this.shenskill = skillid;
|
||
this.calculateAttribute();
|
||
}
|
||
|
||
send(event: any, data: any) {
|
||
if (this.owner) {
|
||
this.owner.send(event, data);
|
||
}
|
||
}
|
||
|
||
/*
|
||
* 宠物颜色储存转换
|
||
*/
|
||
petColorTransformDB(color: any) {
|
||
if (!SKDataUtil.isNumber(color)) {
|
||
SKLogger.warn(`玩家[${this.owner.roleid}:${this.owner.name}]召唤兽[${this.name}]颜色异常:${color}`)
|
||
return -1;
|
||
}
|
||
if (isNaN(color)) {
|
||
SKLogger.warn(`玩家[${this.owner.roleid}:${this.owner.name}]召唤兽[${this.name}]颜色异常:${color}`)
|
||
return -1;
|
||
}
|
||
if (color > 700) {
|
||
return color;
|
||
}
|
||
return color + 2000;
|
||
}
|
||
|
||
/*
|
||
* 正常使用的颜色
|
||
*/
|
||
petColorTransformCom(color: any) {
|
||
if (!SKDataUtil.isNumber(color)) {
|
||
color = -1;
|
||
} else if (isNaN(color)) {
|
||
color = -1;
|
||
}
|
||
if (color > 700) {
|
||
return color - 2000;
|
||
}
|
||
return color;
|
||
}
|
||
|
||
/*
|
||
* 宠物增加亲密值
|
||
* @param qinmi 增加的亲密值
|
||
*/
|
||
addqinmi(qinmi: number) {
|
||
if (this.qinmi < 10000000) {
|
||
SKLogger.debug(`召唤兽[${this.name}]亲密度${this.qinmi}+${qinmi}`);
|
||
this.qinmi += qinmi;
|
||
this.calculateAttribute();
|
||
this.owner.send('s2c_update_pet', {
|
||
info: this.toObj()
|
||
});
|
||
let player = PlayerMgr.shared.getPlayerByRoleId(this.owner.roleid);
|
||
if (player) {
|
||
let pet = player.getPetByID(this.petid);
|
||
SKCxfUtil.getCxfRecordOperate({
|
||
roleId: player.roleid,
|
||
roleName: player.name,
|
||
operateType: Operate.PET,
|
||
operateDepict: "亲密丹",
|
||
operateResSerial: this.petid,
|
||
operateResName: this.name,
|
||
operateContent: SKDataUtil.toJson(pet.toObj(), "{}")
|
||
})
|
||
}
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
getMaxRate() {
|
||
let maxrate = PetMgr.shared.getMaxRate(this.dataid) + this.getRateAdd(); // 元气丹可以影响最大成长率
|
||
return maxrate;
|
||
}
|
||
|
||
// 成长增量 0.612 + 0.01 * 12 + 0.1 * 3 + 1 =
|
||
getRateAdd(): number {
|
||
let yqrate = GoodsMgr.shared.getPetUseYuanqiRate(this.dataid);
|
||
yqrate = this.color == -1 ? 0 : yqrate;
|
||
let addrate = this.relive * 1000 + this.longgu * 100 + yqrate * 1000;
|
||
addrate += (this.fly % 10 >= 1) ? 1000 : 0;
|
||
addrate += (this.fly % 10 >= 2) ? 500 : 0;
|
||
return addrate;
|
||
}
|
||
|
||
getCurRate(): number {
|
||
let rate = this.rate + this.getRateAdd() + this.ofudaLonghyt(); // 成长率,服务器计算
|
||
let maxrate = this.getMaxRate()
|
||
if(rate > maxrate + this.ofudaLonghyt()){
|
||
rate = maxrate + this.ofudaLonghyt();
|
||
}
|
||
return rate;
|
||
}
|
||
|
||
/*
|
||
* 飞升增加属性
|
||
*/
|
||
flyingUp(type: any) {
|
||
if (this.grade < 3 || !this.owner) {
|
||
return;
|
||
}
|
||
if (this.level >= 50 && this.relive >= 0 && this.fly % 10 == 0) { // 第一次飞升
|
||
++this.fly;
|
||
type = 0;
|
||
this.owner.send('s2c_notice', {strRichText: '第一次飞升成功!'});
|
||
} else if (this.level >= 100 && this.relive >= 1 && this.fly % 10 == 1) { // 第二次飞升
|
||
++this.fly;
|
||
type = 0;
|
||
this.owner.send('s2c_notice', {strRichText: '第二次飞升成功!'});
|
||
} else if (this.level >= 120 && this.relive >= 2 && this.fly % 10 == 2) { // 第三次飞升
|
||
if (this.owner.money < 5000000) {
|
||
this.owner.send('s2c_notice', {strRichText: '银两不足'});
|
||
return;
|
||
}
|
||
this.owner.send('s2c_notice', {strRichText: '第三次飞升成功!'});
|
||
++this.fly;
|
||
} else if (this.level >= 120 && this.relive >= 2 && this.fly % 10 == 3) { // 不是修改属性
|
||
if (this.owner.money < 5000000) {
|
||
this.owner.send('s2c_notice', {strRichText: '银两不足'});
|
||
return;
|
||
}
|
||
this.owner.send('s2c_notice', {strRichText: '修改属性成功!'});
|
||
} else {
|
||
return;
|
||
}
|
||
if (this.fly % 10 == 3 && type != 0 && type != parseInt("" + this.fly / 10)) {
|
||
this.owner.addMoney(0, -5000000, '宠物进行飞升');
|
||
}
|
||
this.fly = type * 10 + this.fly % 10;
|
||
this.calculateAttribute();
|
||
let player = PlayerMgr.shared.getPlayerByRoleId(this.owner.roleid);
|
||
if (player) {
|
||
let pet = player.getPetByID(this.petid);
|
||
SKCxfUtil.getCxfRecordOperate({
|
||
roleId: player.roleid,
|
||
roleName: player.name,
|
||
operateType: Operate.PET,
|
||
operateDepict: "宠物飞升",
|
||
operateResSerial: this.petid,
|
||
operateResName: this.name,
|
||
operateContent: SKDataUtil.toJson(pet.toObj(), "{}")
|
||
})
|
||
}
|
||
this.owner.send('s2c_update_pet', {
|
||
info: this.toObj()
|
||
});
|
||
}
|
||
|
||
/*
|
||
* 获取基础属性
|
||
*/
|
||
getBaseProperty(type: any) {
|
||
let fly_property = parseInt("" + this.fly / 10);
|
||
let petData = PetMgr.shared.getPetData(this.dataid);
|
||
let ret = 0;
|
||
if (type == 1 || type == 'hp') {
|
||
ret = this.basehp + ((fly_property == 1) ? 60 : 0);
|
||
if(ret > petData.hp[1]){
|
||
ret = petData.hp[1]
|
||
}
|
||
} else if (type == 2 || type == 'mp') {
|
||
ret = this.basemp + ((fly_property == 2) ? 60 : 0);
|
||
if(ret > petData.mp[1]){
|
||
ret = petData.mp[1]
|
||
}
|
||
} else if (type == 3 || type == 'atk') {
|
||
ret = this.baseatk + ((fly_property == 3) ? 60 : 0);
|
||
if(ret > petData.atk[1]){
|
||
ret = petData.atk[1]
|
||
}
|
||
} else if (type == 4 || type == 'spd') {
|
||
ret = this.basespd + ((fly_property == 4) ? 60 : 0);
|
||
if(ret > petData.spd[1]){
|
||
ret = petData.spd[1]
|
||
}
|
||
} else if (type == 5 || type == 'aptitude') {
|
||
ret = this.aptitude + ((fly_property == 5) ? 60 : 0);
|
||
}
|
||
return ret;
|
||
}
|
||
|
||
ofudaQingLan(attr: any){
|
||
//青岚
|
||
if(this.relive == 3 && this.level >= 120 && this.level<= 180){
|
||
let add = Math.floor((this.level - 120) / 10);
|
||
if(this.owner && add > 1){
|
||
if(this.owner.checkOfudaBySkillId(ESkillType.QingLan1)){
|
||
if(attr == EAttrTypeL1.K_SEAL){
|
||
return add * 3
|
||
}
|
||
if(attr == EAttrTypeL1.K_CONFUSION){
|
||
return add * 3
|
||
}
|
||
if(attr == EAttrTypeL1.K_SLEEP){
|
||
return add * 3
|
||
}
|
||
if(attr == EAttrTypeL1.K_FORGET){
|
||
return add * 3
|
||
}
|
||
}
|
||
if(this.owner.checkOfudaBySkillId(ESkillType.QingLan2)){
|
||
if(attr == EAttrTypeL1.K_SEAL){
|
||
return add * 4
|
||
}
|
||
if(attr == EAttrTypeL1.K_CONFUSION){
|
||
return add * 4
|
||
}
|
||
if(attr == EAttrTypeL1.K_SLEEP){
|
||
return add * 4
|
||
}
|
||
if(attr == EAttrTypeL1.K_FORGET){
|
||
return add * 4
|
||
}
|
||
}
|
||
if(this.owner.checkOfudaBySkillId(ESkillType.QingLan3)){
|
||
if(attr == EAttrTypeL1.K_SEAL){
|
||
return add * 5
|
||
}
|
||
if(attr == EAttrTypeL1.K_CONFUSION){
|
||
return add * 5
|
||
}
|
||
if(attr == EAttrTypeL1.K_SLEEP){
|
||
return add * 5
|
||
}
|
||
if(attr == EAttrTypeL1.K_FORGET){
|
||
return add * 5
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
ofudaLonghyt(){
|
||
//龙魂萦体
|
||
if(this.relive == 3 && this.level<= 180){
|
||
let add = Math.floor((this.level - 120) / 10);
|
||
if(this.owner && add > 1){
|
||
if(this.owner.checkOfudaBySkillId(ESkillType.LongHunYingTi1)){
|
||
return add * 15
|
||
}
|
||
if(this.owner.checkOfudaBySkillId(ESkillType.LongHunYingTi2)){
|
||
return add * 20
|
||
}
|
||
if(this.owner.checkOfudaBySkillId(ESkillType.LongHunYingTi3)){
|
||
return add * 40
|
||
}
|
||
}
|
||
}
|
||
return 0;
|
||
}
|
||
}
|