xy-server/game/skill/core/SkillBase.ts

233 lines
8.9 KiB
TypeScript
Raw Normal View History

2025-04-23 09:34:08 +08:00
import SKDataUtil from "../../gear/SKDataUtil";
import {
EActionOn,
EActionType,
EAttrTypeL1,
EBuffType,
EMagicType,
ESkillQuality,
EHorsePASV,
ESkillType,
BattleType,
ELiveingType
} from "../../role/EEnum";
import BattleMgr from "../../battle/BattleMgr";
import SkillUtil from "../../skill/core/SkillUtil";
export default class SkillBase {
//BUFF名称
static magicName: any;
static skillEffect: any = {
cnt: 1, // 人数
round: 0, // 回合
hurt: 0, //伤害
hurtpre: 0, //伤害百分比
hppre: 0, // 加血百分比
mppre: 0, // 加蓝百分比
smppre: 0, // 法力减少-
hit: 0, // 命中增加+
spd: 0, // 速度增加+
atk: 0, // 攻击增加+
kongzhi: 0, // 控制抗性+
fashang: 0, // 法伤抗性+
fangyu: 0, // 防御+
hp: 0, // 增加血量
aihp: 0, // 智能回血(用于吸血类技能)
skongzhi: 0, // 减少控制抗性
yinshen: 0, // 隐身
attrtype: 0, //五行
attrnum: 0, //五行数值
}
skill_id: number;
skill_name: string;
skill_type: number;
action_type: number;
skill_data: any;
buff_type: number;
effectDesc: string;
effectMap: { [key: number]: object } = {};
kind: number;
quality: number;
cooldown: number;
limit_round: number;
limit_times: number;
act_on: number;
exp: number = 0; // 经验值
expMax: number = 20000; // 最大经验值
constructor() {
this.skill_id = 0;
this.skill_name = '未知技能';
this.skill_type = EMagicType.NONE;
this.action_type = EActionType.INITIATIVE;
this.skill_data = null;
this.buff_type = EBuffType.NONE;
this.effectMap = {};
this.kind = 0; // 技能类型
this.quality = 0; //技能 品质
this.cooldown = 0; // 技能冷却时间
this.limit_round = 0; // 技能回合限制 前几回合不能用
this.limit_times = 0;// 技能限制使用次数
this.act_on = EActionOn.ENEMY;// 技能作用于 0 all 1 敌人 2 自己人
}
setSkillData(data: any) {
this.skill_data = data;
}
// 使用技能
useSkill(brole: any): any {
let flag = false;
let name = "";
// 宠物或者玩家进行消耗计算
if (ELiveingType.PLAYER == brole.living_type) {
flag = true;
} else if (ELiveingType.PET == brole.living_type) {
flag = true;
name = brole.name;
}
if (flag) {
// 获取技能熟练度
let profic = brole.getSkillProfic(this.skill_id);
let consume = 0;
if (this.quality == ESkillQuality.LOW) {
consume = Math.ceil(profic * 0.1);
} else if (this.quality == ESkillQuality.HIGH) {
consume = Math.ceil(profic * 0.3);
}
if(brole.living_type == ELiveingType.PET){
if(this.skill_id==ESkillType.ChangQuZhiRu||this.skill_id==ESkillType.ShiRuPoZhu){
consume = 15400;
}
}
//千钧符 冥想 减少耗蓝
if(brole.living_type == 1){
if(brole.hasOfudaSkill(ESkillType.MingXiang1)){
consume = consume * 0.9;
}
if(brole.hasOfudaSkill(ESkillType.MingXiang2)){
consume = consume * 0.7;
}
if(brole.hasOfudaSkill(ESkillType.MingXiang3)){
consume = consume * 0.5;
}
}
// 获取当前剩余蓝
let curMP = brole.getAttr(EAttrTypeL1.MP) || 0;
if (curMP < consume) {
return `${name}当前法力不足无法使用技能[color=#0fffff]${SkillUtil.getSkillName(this.skill_id)}[/color]`;
} else {
brole.subMP(-consume);
}
//双管齐下
let battle = BattleMgr.shared.getBattle(brole.battle_id);
for (let key in battle.plist) {
let battleRole = battle.plist[key];
if (battleRole.isPet() && battleRole.hasPassiveSkill(ESkillType.ShuangGuanQiXia)) {
let curhp = brole.getAttr(EAttrTypeL1.HP) || 0;
if (curhp - consume < 0) {
return `[${this.skill_name}]气血不足,无法释放`;
}
brole.subHP(-consume);
return "";
break;
}
if (battleRole.isPet() && battleRole.hasPassiveSkill(ESkillType.BuLvWeiJian)) {//步履维艰
let curmp = brole.getAttr(EAttrTypeL1.MP) || 0;
if (curmp - consume < 0) {
return `[${this.skill_name}]蓝量不足,无法释放`;
}
brole.subMP(-consume);
return "";
break;
}
}
}
return "";
}
// 获得技能属性加成
getEffect(params: any = null): any {
let result = SKDataUtil.clone(SkillBase.skillEffect);
return result;
}
// 获得坐骑技能属性加成
getBaldricEffect(type: EAttrTypeL1): any {
let ret: any = {};
let item: any = this.effectMap[type];
if (item) {
if (item.add) {
ret.add = SKDataUtil.toDecimal2(item.add);
if (item.grade == null) {
ret.add = SKDataUtil.toDecimal2(ret.add);
}
}
}
return ret;
}
// 获得坐骑技能属性加成
getHorseEffect(type: EAttrTypeL1, level: number, exp: number): any {
let prop: number = Math.max(level * 0.1 + exp * 0.00025, 1);
let ret: any = {};
let item: any = this.effectMap[type];
if (item) {
if (item.rsa != undefined){
item.grade = exp;
item.add = this.rsa(item,level,0.755 * 1000);
}
if (item.add) {
ret.add = SKDataUtil.toDecimal2(item.add);
if (item.grade == null) {
ret.add = SKDataUtil.toDecimal2(ret.add * prop);
}
}
}
return ret;
}
// 坐骑技能算法
rsa(item: any,level: number,growthRate: number){
let grade = 0;
let value = 0;
if (item.grade != null){
grade = item.grade;
}
if (item.rsa == "HuMaChiZhou" || item.rsa == "FengJiDianFei" || item.rsa == "ChengBenYvFeng") {
if (item.pasv == EHorsePASV.Percenta){
value = Math.round((1.0E-4 * (growthRate / 1000 / (1.175 + 0.0013 * grade) * (0.6 * grade + 0.4 * level / 1000)) ^ 2 + 0.05 * (growthRate / 1000 / (1.175 + 0.0013 * grade) * (0.6 * grade + 0.4 * level / 1000))) * 0.6 + 0.05)
}else if (item.pasv == EHorsePASV.Percentb){
value = Math.round(2 *(growthRate / 1000 / 6.325 * (0.12 * (0.0013 * grade ^ 2 + 2.06 * grade) / 130 + (0.0067 * level ^ 2 / 1000 + 2.06 * level) / 325000 + 0.1)) * 0.6 + 0.1);
}else if (item.pasv == EHorsePASV.Percentc){
value = Math.round((2.0E-4 * (growthRate / 1000 / (1.175 + 0.0013 * grade) * (0.6 * grade + 0.4 * level / 1000)) ^ 2 + 0.1 * (growthRate / 1000 / (1.175 + 0.0013 * grade) * (0.6 * grade + 0.4 * level / 1000))) * 0.6 + 0.05);
}else if (item.pasv == EHorsePASV.Percentd){
value = Math.floor(2 + grade / 100 / 80);
}
return value <= 0 ? item.add : value;
}
if(item.rsa == "HighChengBenYvFeng" || item.rsa == "HighFengJiDianFei" || item.rsa == "HighHuMaChiZhou"){
if (item.pasv == EHorsePASV.Percenta){
value = Math.round((1.0E-4 * (growthRate / 1000 / (1.175 + 0.0013 * grade) * (0.6 * grade + 0.4 * level / 1000)) ^ 2 + 0.05 * (growthRate / 1000 / (1.175 + 0.0013 * grade) * (0.6 * grade + 0.4 * level / 1000))) * 0.6 + 0.05+1)
}else if (item.pasv == EHorsePASV.Percentb){
value = Math.round(2 * (growthRate / 1000 / 6.325 * (0.12 * (0.0013 * grade ^ 2 + 2.06 * grade) / 130 + (0.0067 * level ^ 2 / 1000 + 2.06 * level) / 325000 + 0.1)) * 0.6 + 0.1+1);
}else if (item.pasv == EHorsePASV.Percentc){
value = Math.round((2.0E-4 * (growthRate / 1000 / (1.175 + 0.0013 * grade) * (0.6 * grade + 0.4 * level / 1000)) ^ 2 + 0.1 * (growthRate / 1000 / (1.175 + 0.0013 * grade) * (0.6 * grade + 0.4 * level / 1000))) * 0.6 + 0.05 + 1);
}else if (item.pasv == EHorsePASV.Percentd){
value = Math.floor(2 + grade / 100 / 80 + 1);
}
return value <= 0 ? item.add : value;
}
return 0;
}
toObj(): any {
let result = {
skill_id: this.skill_id,
exp: this.exp
}
return result;
}
}