/
domahes
/
Arcade
Обзор
Документация
Войти
/
domahes
/
Arcade
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
js/data/DBuff.js
230 строк
6 KB
domahes
Update game scripts and data configurations
01 июн 2026, 10:11
01 июн 2026, 10:11
83cd2f8
Код
Авторство
О чём код?
/** * Created by Yitian Chen on 2019/4/29. * BUFF execution data structure / BUFF data logic * @param cof Configuration data of buff * @param self buff recipient */ function DBuff(cof , self){ //==================================== private attributes =================================== var _sf = this; //LActor object var actor = self.getActor(); //coordinate var x = actor.getCharacter().x; var y = actor.getCharacter().y; //End mark var isEnd = false; var tempEnd = false; //Configuration data of animation var animcof = RV.NowRes.findResAnim(cof.animID); //current animation var anim = null; //buff interval var intervalNow = 0; var intervalMax = cof.cTimes; //change hp&mp var minAddHp = self.getMaxHP() * cof.cHP / 100; var minAddMp = self.getMaxMp() * cof.cMP / 100; //change attck and move speed var changeSpeed = 1 + cof.cSpeed / 100; //==================================== public attributes =================================== //end type this.endType = 0; //end time this.endTime = 0; //end HP this.endHP = 0; //end step this.endMove = 0; //end callback this.endDo = null; //==================================== initialize logic =================================== if(animcof != null){ var haveView = true; var point = animcof.point; if(point.type == 0){//Relative coordinates if(point.dir == 5){//scene haveView = false; } }else{//absolute coordinate haveView = false; } if(animcof instanceof DResAnimFrame){ anim = new LAnim(animcof,haveView ? RV.NowMap.getView() : null,false,actor); }else if(animcof instanceof DResAnimParticle){ anim = new LParticle(animcof,haveView ? RV.NowMap.getView() : null,false,actor); } } if(cof.RelieveOutOfCombat){ this.endType = 0; }else if(cof.RelieveTime){ this.endType = 1; this.endTime = cof.RTime * 60; }else if(cof.RelieveHP){ this.endType = 2; this.endHP = self.sumHp + (self.getMaxHP() * cof.RHP / 100); }else if(cof.RelieveMove){ this.endType = 3; if(self instanceof GActor){ this.endMove = RV.GameData.step + cof.RMove; }else{ this.endMove = actor.moveNum + cof.RMove; } } //==================================== Public function =================================== /** * Main update */ this.update = function(){ if(isEnd)return; if(tempEnd) { _sf.overBuff(); return; } //manage end if(_sf.endType == 0 && actor.combatTime <= 0){ tempEnd = true; return; } if(_sf.endType == 1 && _sf.endTime <= 0){ tempEnd = true; return; } if(_sf.endType == 2 && self.sumHp > this.endHP){ tempEnd = true; return; }if(_sf.endType == 3){ if(self instanceof GActor && RV.GameData.step > _sf.endMove){ tempEnd = true; return; }else if(self.moveNum > _sf.endMove){ tempEnd = true; return; } } actor = self.getActor(); if(_sf.endType == 1) _sf.endTime -= 1; if(anim != null) anim.update(); if(intervalNow <= 0){ x = actor.getCharacter().x; y = actor.getCharacter().y; intervalNow = intervalMax; //change HP if(cof.cHpBool){ if(self instanceof LEnemy){ actor.injure(0 , minAddHp * -1); }else{ RV.NowMap.getActor().injure(0 , minAddHp * -1); new LNum(0 , minAddHp * -1 , RV.NowMap.getView() , x , y); } } if(cof.cMpBool){ self.mp += minAddMp; new LNum(2 , minAddMp , RV.NowMap.getView() , x , y); } //change speed if(cof.cSpeedBool){ actor.speedEfficiency = changeSpeed; } } intervalNow -= 1; //invincible and SuperArmor if(cof.invincible){ actor.invincible(60); } if(cof.superArmor){ actor.superArmor = true; } if(cof.limit.cantAtk){ self.LAtk = true; } if(cof.limit.cantSkill){ self.LSkill = true; } if(cof.limit.cantItem){ self.LItem = true; } if(cof.limit.cantMove){ self.LMove = true; } if(cof.limit.cantSquat){ self.LSquat = true; } if(cof.limit.cantJump){ self.LJump = true; } if(cof.limit.cantOutOfCombat){ self.LOutOfCombat = true; } }; /** * buff end */ this.overBuff = function(){ isEnd = true; _sf.dispose(); if(cof.invincible){ //actor.endIncible(); } if(cof.superArmor){ actor.superArmor = false; } if(cof.limit.cantAtk){ self.LAtk = false; } if(cof.limit.cantSkill){ self.LSkill = false; } if(cof.limit.cantItem){ self.LItem = false; } if(cof.limit.cantMove){ self.LMove = false; } if(cof.limit.cantSquat){ self.LSquat = false; } if(cof.limit.cantJump){ self.LJump = false; } if(cof.limit.cantOutOfCombat){ self.LOutOfCombat = false; } if(cof.cSpeedBool){ actor.speedEfficiency = 1; } if(_sf.endDo != null) _sf.endDo(); }; /** * get buff data * @returns {DSetState} */ this.getData = function(){ return cof; }; /** * get icon file of buff * @returns {string} */ this.getIcon = function(){ if(cof != null){ return cof.pic; } return null; }; /** * dispose buff */ this.dispose = function(){ if(anim != null) anim.dispose(); } }