冲锋/反击逻辑处理

This commit is contained in:
y.x 2020-12-22 03:51:23 +08:00
parent aa22797838
commit 9c0d9f7cce
7 changed files with 117 additions and 23 deletions

Binary file not shown.

View File

@ -226,10 +226,12 @@ export class BattleHandler {
} }
break; break;
case GameCampType.FRIEND: case GameCampType.FRIEND:
{
let obj = this.getFriend(src); let obj = this.getFriend(src);
if(obj && obj.isAlive()){ if(obj && obj.isAlive()){
lst.push(obj); lst.push(obj);
} }
}
break; break;
case GameCampType.MYTEAM: case GameCampType.MYTEAM:
if(src){ if(src){
@ -295,6 +297,13 @@ export class BattleHandler {
} }
} }
break; break;
case GameCampType.ALL_EXSELF:
for(let [key, obj] of this._players){
if(obj && obj.isAlive() && obj != src){
lst.push(obj);
}
}
break;
default: default:
break; break;
} }

View File

@ -260,11 +260,17 @@ export class PetHandler {
}; };
public beHurt(value: number): number{ public beHurt(value: number): number{
let res = value - value * this._exredhurt; let rv = value - value * this._exredhurt;
if(res < 0){ if(rv < 0){
return 0; return 0;
} }
return this.subAP(res); let res = this.subAP(rv);
if(res != 0){
this._owner.onBeHurt(this, res);
}
return res;
}; };
public addHP(value: number){ public addHP(value: number){
@ -316,17 +322,18 @@ export class PetHandler {
this._owner.onPetDied(this); this._owner.onPetDied(this);
}; };
public attack(apet: PetHandler, param: SkillParam){ public attack(apet: PetHandler, param: SkillParam, ev: number = 0, isAtkBack: boolean = false){
//todo: !isAtkBack && this._owner.onAttackBefore(this, param);
return 0;
};
beforeAttack(){ let myap = this.totalAP();
//todo: myap += myap*ev;
}; // let otherap = apet.totalAP();
afterAttack(){ let n = apet.beHurt(myap);
//todo:
!isAtkBack && this._owner.onBeAttack(apet, param);
return n;
}; };
public reborn(){ public reborn(){

View File

@ -267,8 +267,8 @@ export class PlayerHandler {
return this._self.addEM(value); return this._self.addEM(value);
}; };
public getEM(): number{ public getEMRatio(): number{
return this._totalem; return this._totalem/100;
}; };
public onEMChanged(value: number){ public onEMChanged(value: number){
@ -299,7 +299,7 @@ export class PlayerHandler {
}; };
public attack(apet: PetHandler, param: SkillParam, ev: number){ public attack(apet: PetHandler, param: SkillParam, ev: number){
return this._self.attack(apet, param); return this._self.attack(apet, param, ev);
}; };
public beSilent(count: number){ public beSilent(count: number){
@ -403,6 +403,18 @@ export class PlayerHandler {
this._owner.onUpdatePetsNotify(lst); this._owner.onUpdatePetsNotify(lst);
}; };
onAttackBefore(apet: PetHandler, sp?: SkillParam){
this.singleCheckSkills(apet, TriggerType.BEFORE_ATTACK, null, sp);
};
onBeAttack(apet: PetHandler, sp?: SkillParam){
this.singleCheckSkills(apet, TriggerType.BE_ATTACK, null, sp);
};
onBeHurt(apet: PetHandler, value: number){
this.singleCheckSkills(apet, TriggerType.BE_HURT, value);
};
public isMyPet(apet: PetHandler){ public isMyPet(apet: PetHandler){
if(apet == this._self){ if(apet == this._self){
return true; return true;
@ -542,6 +554,24 @@ export class PlayerHandler {
this._owner.onSkillResultNotify(reslst); this._owner.onSkillResultNotify(reslst);
}; };
singleCheckSkills(apet: PetHandler, tgttype: TriggerType, tgtvalue?: any, tgtsp?: SkillParam){
let sp = tgtsp;
if(!sp){
sp = new SkillParam(0, 0, 0, this, apet, null, null);
}
let reslst: SkillTarget[] = [];
apet.checkSkills(tgttype, tgtvalue, sp, (skill: Skill, ap: SkillParam, res: SkillTarget[])=>{
if(res){
reslst = reslst.concat(res);
}else{
let st = new SkillTarget(skill);
st.LoadParam(sp);
reslst.push(st);
}
});
this._owner.onSkillResultNotify(reslst);
};
simpleCheckSkills(skills: Skill[], apet?: PetHandler, param?: SkillParam): SkillTarget[]{ simpleCheckSkills(skills: Skill[], apet?: PetHandler, param?: SkillParam): SkillTarget[]{
let ps = param? param: new SkillParam(0, 0, 0, this, apet, this, apet); let ps = param? param: new SkillParam(0, 0, 0, this, apet, this, apet);
let reslst: SkillTarget[] = []; let reslst: SkillTarget[] = [];

View File

@ -216,7 +216,21 @@ export class Skill {
_triggerSubSkill(param: SkillParam, cb?: any){ _triggerSubSkill(param: SkillParam, cb?: any){
if(this._data.quoteskillid && !this._subskill){ if(this._data.quoteskillid && !this._subskill){
this._subskill = this._owner.newSkill(this._data.quoteskillid); this._subskill = this._owner.newSkill(this._data.quoteskillid);
}
if(this._subskill){
let subparam = this._data.skill_users? param.clone(): param;
if(this._data.skill_users){
subparam.srcplayer = subparam.dstplayer;
subparam.srcpet = subparam.dstpet;
}
let ncount = this.getFinalValue(this._data.quotecard_times,
this._data.quotecard_timesmax, param.edd_cnt, param.cardpoint);
if(ncount == 0){
ncount = 1;
}
for(let i=0; i<ncount;i++){
this._subskill._trigger(subparam, cb);
}
} }
}; };
@ -344,8 +358,9 @@ export class Skill {
break; break;
case SkillEffectType.HURT_POWER: case SkillEffectType.HURT_POWER:
case SkillEffectType.HURT_ALL: case SkillEffectType.HURT_ALL:
let effv = this.EMV(effvalue);
if(tgt.dsttype != GameUnitType.NONE && tgt.dsttype != GameUnitType.PLAYER){ if(tgt.dsttype != GameUnitType.NONE && tgt.dsttype != GameUnitType.PLAYER){
let n = (tgt.dst as PetHandler).beHurt(effvalue); let n = (tgt.dst as PetHandler).beHurt(effv);
tgt.success(efftype, n); tgt.success(efftype, n);
}else{ }else{
tgt.fail(efftype, -1); tgt.fail(efftype, -1);
@ -359,7 +374,8 @@ export class Skill {
handleHP(effvalue: number, tgt: SkillTarget){ handleHP(effvalue: number, tgt: SkillTarget){
let efftype = SkillEffectType.HURT_HP; let efftype = SkillEffectType.HURT_HP;
if(tgt.dsttype == GameUnitType.PLAYER || tgt.dsttype == GameUnitType.HERO){ if(tgt.dsttype == GameUnitType.PLAYER || tgt.dsttype == GameUnitType.HERO){
let n = tgt.dst.addHP(effvalue); let effv = this.EMV(effvalue);
let n = tgt.dst.addHP(effv);
tgt.success(efftype, n); tgt.success(efftype, n);
}else{ }else{
tgt.fail(efftype, -1); tgt.fail(efftype, -1);
@ -407,8 +423,13 @@ export class Skill {
if(ncount == 0){ if(ncount == 0){
ncount = 1; ncount = 1;
} }
let obj = tgt.srcpet? tgt.srcpet: tgt.srcplayer; let obj;
let n = obj.addSkill(this._data.getskillid, ncount); if(this._data.skill_owners){
obj = tgt.dst;
}else{
obj = tgt.srcpet? tgt.srcpet: tgt.srcplayer;
}
let n = obj? obj.addSkill(this._data.getskillid, ncount): 0;
if(n){ if(n){
tgt.success(efftype, this._data.getskillid); tgt.success(efftype, this._data.getskillid);
}else{ }else{
@ -460,6 +481,12 @@ export class Skill {
} }
}; };
EMV(effvalue: number){
let ev = effvalue;
ev *= this._owner.getEMRatio();
return effvalue + ev;
};
reborn(tgt: SkillTarget){ reborn(tgt: SkillTarget){
let efftype = SkillEffectType.REBORN; let efftype = SkillEffectType.REBORN;
if(tgt.dsttype != GameUnitType.NONE){ if(tgt.dsttype != GameUnitType.NONE){
@ -496,6 +523,18 @@ export class Skill {
let res = obj.attack((tgt.dst as PetHandler), param, v); let res = obj.attack((tgt.dst as PetHandler), param, v);
if(res){ if(res){
tgt.success(efftype, res); tgt.success(efftype, res);
if(this._data.quoteskillid == 40112){
let dp = this._data.skill_users? param.clone(): param;
if(this._data.skill_users){
dp.srcpet = param.dstpet;
dp.srcplayer = param.dstplayer;
}
let pet = tgt.srcpet;
if(!pet && tgt.srcplayer){
pet = tgt.srcplayer._self;
}
(tgt.dst as PetHandler).attack(pet, dp);
}
}else{ }else{
tgt.fail(efftype, -1); tgt.fail(efftype, -1);
} }

View File

@ -72,6 +72,8 @@ export const enum TriggerType
BE_HURT = 11, BE_HURT = 11,
BEFORE_ATTACK = 12, BEFORE_ATTACK = 12,
BE_ATTACK = 13,
}; };
// 技能大类 // 技能大类
@ -248,6 +250,7 @@ export const enum GameUnitType {
* 7. * 7.
* 8. * 8.
* 9. * 9.
* 10.+
*/ */
export const enum GameCampType { export const enum GameCampType {
NONE = 0, NONE = 0,
@ -260,6 +263,7 @@ export const enum GameCampType {
RANDOM_US = 7, RANDOM_US = 7,
RANDOM_ENEMY = 8, RANDOM_ENEMY = 8,
FACE_ENEMY = 9, FACE_ENEMY = 9,
ALL_EXSELF = 10,
}; };
// 战力参数数值 // 战力参数数值

View File

@ -24,6 +24,11 @@ export class SkillParam{
this.dstplayer = dstplayer; this.dstplayer = dstplayer;
this.dstpet = dstpet; this.dstpet = dstpet;
}; };
clone(){
return new SkillParam(this.cardid, this.cardpoint, this.edd_cnt,
this.srcplayer, this.srcpet, this.dstplayer, this.dstpet);
};
}; };
export class SkillResult{ export class SkillResult{