604 lines
16 KiB
ActionScript
604 lines
16 KiB
ActionScript
package net.pixvi.myr
|
|
{
|
|
import net.pixvi.myr.center.Table;
|
|
import net.pixvi.myr.element.mon.MonsterVo;
|
|
import net.pixvi.myr.view.attack.type.AttackType;
|
|
import net.pixvi.myrloader.center.MyrCenter;
|
|
import net.pixvi.pfw.utils.Counter;
|
|
import net.pixvi.pfw.utils.Random;
|
|
|
|
public class GameMath
|
|
{
|
|
|
|
public static const ModeEvent:Boolean = false;
|
|
|
|
public static var ModeTrace:Boolean = false;
|
|
|
|
public static var ModeTraceOpened:Boolean = false;
|
|
|
|
public static var ModeTraceServer:Boolean = false;
|
|
|
|
public static var ModeCrypto:Boolean = true;
|
|
|
|
public static var ModeNetCrypto:Boolean = true;
|
|
|
|
public static var ModePayCrypto:Boolean = true;
|
|
|
|
private static var modereal:Object = null;
|
|
|
|
public static var quickLogin:Boolean = false;
|
|
|
|
public static const waveSpaceTime:int = 700;
|
|
|
|
public static const numScale:Number = 4;
|
|
|
|
public function GameMath()
|
|
{
|
|
super();
|
|
}
|
|
|
|
public static function get ModeRealName() : Boolean
|
|
{
|
|
if(modereal != null)
|
|
{
|
|
return modereal;
|
|
}
|
|
if(Table.setting.safeModePlatform != null && Table.setting.safeModePlatform.indexOf(MyrCenter.platform) == -1)
|
|
{
|
|
return false;
|
|
}
|
|
if(MyrCenter.closeRealName == true)
|
|
{
|
|
return false;
|
|
}
|
|
if(MyrCenter.channel == "DYD")
|
|
{
|
|
modereal = true;
|
|
return true;
|
|
}
|
|
modereal = false;
|
|
return false;
|
|
}
|
|
|
|
public static function get OpenPay() : Boolean
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public static function get critAdd() : Number
|
|
{
|
|
return Table.game_setting.critAdd;
|
|
}
|
|
|
|
public static function get counterAdd() : Number
|
|
{
|
|
return Table.game_setting.counterAdd;
|
|
}
|
|
|
|
public static function get apCD() : int
|
|
{
|
|
return Table.game_setting.apCD;
|
|
}
|
|
|
|
public static function get tiCD() : int
|
|
{
|
|
return Table.game_setting.tiCD;
|
|
}
|
|
|
|
public static function get apCostByStar() : Array
|
|
{
|
|
return Table.game_setting.apCostByStar;
|
|
}
|
|
|
|
public static function get maxFeel() : int
|
|
{
|
|
return Table.game_setting.maxFeel;
|
|
}
|
|
|
|
public static function get monGiftTime() : int
|
|
{
|
|
return Table.game_setting.monGiftTime;
|
|
}
|
|
|
|
public static function get monGiftMax() : int
|
|
{
|
|
return Table.game_setting.monGiftMax;
|
|
}
|
|
|
|
public static function get masterMaxLevel() : int
|
|
{
|
|
return Table.game_setting.masterMaxLevel;
|
|
}
|
|
|
|
public static function get loopTaskMaxNum() : int
|
|
{
|
|
return Table.game_setting.loopTaskMaxNum;
|
|
}
|
|
|
|
public static function get farmEventTime() : int
|
|
{
|
|
return Table.game_setting.farmEventTime;
|
|
}
|
|
|
|
public static function get normalBattleTime() : int
|
|
{
|
|
return Table.game_setting.normalBattleTime;
|
|
}
|
|
|
|
public static function get countDamagePerAtk() : Number
|
|
{
|
|
return Table.game_setting.countDamagePerAtk;
|
|
}
|
|
|
|
public static function get countGuardPerDef() : Number
|
|
{
|
|
return Table.game_setting.countGuardPerDef;
|
|
}
|
|
|
|
public static function get tpExp() : Object
|
|
{
|
|
return Table.game_setting.tpExp;
|
|
}
|
|
|
|
public static function get maxTpLevel() : int
|
|
{
|
|
return 4;
|
|
}
|
|
|
|
public static function get alchemyFormulaLevel() : Array
|
|
{
|
|
return Table.game_setting.alchemyFormulaLevel;
|
|
}
|
|
|
|
public static function get alchemyFormulaCost() : Object
|
|
{
|
|
return Table.game_setting.alchemyFormulaCost;
|
|
}
|
|
|
|
public static function get feedExpScale() : Number
|
|
{
|
|
return Table.game_setting.monExpScale;
|
|
}
|
|
|
|
public static function get equipNumFloat() : Number
|
|
{
|
|
return Table.game_setting.equipNumFloat;
|
|
}
|
|
|
|
public static function get speedItemId() : int
|
|
{
|
|
return Table.game_setting.monSpeedItemId;
|
|
}
|
|
|
|
public static function get alchemySpeedItemId() : int
|
|
{
|
|
return Table.game_setting.alchemySpeedItemId;
|
|
}
|
|
|
|
public static function get equipNum() : int
|
|
{
|
|
return Table.game_setting.equipNum;
|
|
}
|
|
|
|
public static function get monSpeedItemTime() : int
|
|
{
|
|
return Table.game_setting.monSpeedItemTime;
|
|
}
|
|
|
|
public static function get monExpScale() : int
|
|
{
|
|
return Table.game_setting.monExpScale;
|
|
}
|
|
|
|
public static function apByLevel(lv:int) : int
|
|
{
|
|
return Table.game_setting.startAp + (lv - 1) * Table.game_setting.addApByLevel;
|
|
}
|
|
|
|
public static function tiMaxByLevel(lv:int) : int
|
|
{
|
|
var timax:int = Table.game_setting.tiFirst + (lv - 1) * Table.game_setting.tiLevelAdd;
|
|
if(timax > Table.game_setting.tiTotalMax)
|
|
{
|
|
return Table.game_setting.tiTotalMax;
|
|
}
|
|
return timax;
|
|
}
|
|
|
|
public static function get_apCost(star:int) : int
|
|
{
|
|
return Table.game_setting.apCostByStar[star - 1];
|
|
}
|
|
|
|
public static function damage(atkA:int, dexA:int, dexB:int, defB:int, defDamaB:Number = 0) : int
|
|
{
|
|
var dexp:int = dexA - dexB;
|
|
var dam:int = 0;
|
|
var minp:Number = 0.8;
|
|
var maxp:Number = 1.2;
|
|
var maxa:int = 80;
|
|
if(dexp > 0)
|
|
{
|
|
if(dexp > maxa)
|
|
{
|
|
dexp = maxa;
|
|
}
|
|
minp += 0.3 * dexp / maxa;
|
|
}
|
|
else
|
|
{
|
|
if(dexp < -maxa)
|
|
{
|
|
dexp = -maxa;
|
|
}
|
|
maxp += 0.3 * dexp / maxa;
|
|
}
|
|
dam = Math.round(atkA * countDamagePerAtk * Random.number(minp,maxp) - defB * (countGuardPerDef * 0.75 + Random.number(0,countGuardPerDef * 0.25)));
|
|
dam *= 1 - defDamaB;
|
|
if(dam < 1)
|
|
{
|
|
dam = 1;
|
|
}
|
|
return dam;
|
|
}
|
|
|
|
public static function fix_spd_atk(atk_spd:int) : int
|
|
{
|
|
return atk_spd;
|
|
}
|
|
|
|
public static function cost_speedGrow(s:int) : int
|
|
{
|
|
return Math.ceil(s / 120);
|
|
}
|
|
|
|
public static function cost_speedAlchemy(s:int) : int
|
|
{
|
|
return Math.ceil(s / 120);
|
|
}
|
|
|
|
public static function addSecondByCost(cost:int) : int
|
|
{
|
|
return cost * 120;
|
|
}
|
|
|
|
public static function critByDex(crit:Number, dexA:int, dexB:int) : Number
|
|
{
|
|
var dexp:int = (dexA - dexB) / 4;
|
|
if(dexp < 0)
|
|
{
|
|
return 0.02 + crit / 100;
|
|
}
|
|
return 0.02 + crit / 100 + dexp / (dexp + 120);
|
|
}
|
|
|
|
public static function addAtkSpdByDex(dex:int) : int
|
|
{
|
|
return -(dex * 3) / 4;
|
|
}
|
|
|
|
public static function addMovSpdByDex(dex:int) : Number
|
|
{
|
|
return Number((dex / (50 * 4)).toFixed(2));
|
|
}
|
|
|
|
public static function addPowByAtk(atk:int) : Number
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
public static function addPowDefByHp(hp:int) : Number
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
public static function pveThornDmg(countDamage:int, thorn:int) : int
|
|
{
|
|
var a:int = 2;
|
|
var b:int = 400;
|
|
if(Table.game_setting.pveThornDmg_a != null)
|
|
{
|
|
a = int(Table.game_setting.pveThornDmg_a);
|
|
}
|
|
if(Table.game_setting.pveThornDmg_b != null)
|
|
{
|
|
b = int(Table.game_setting.pveThornDmg_b);
|
|
}
|
|
var dmg:int = countDamage * (thorn / (a * thorn + b));
|
|
if(dmg < 1)
|
|
{
|
|
dmg = 1;
|
|
}
|
|
return dmg;
|
|
}
|
|
|
|
public static function getFeedExpByMonsterVo(vo:MonsterVo) : int
|
|
{
|
|
return vo.sell_exp + int(vo.exp * GameMath.feedExpScale);
|
|
}
|
|
|
|
public static function zl_atk(atk:Number, atk_spd:int = 1600) : int
|
|
{
|
|
if(1600 / atk_spd > 1)
|
|
{
|
|
return atk * 10 * (1 + (1600 / atk_spd - 1) * 0.7);
|
|
}
|
|
return atk * 10 * (1 - (1 - 1600 / atk_spd) * 0.8);
|
|
}
|
|
|
|
public static function zl_def(def:Number) : int
|
|
{
|
|
return def * 5;
|
|
}
|
|
|
|
public static function zl_hp(hp:Number) : int
|
|
{
|
|
return hp;
|
|
}
|
|
|
|
public static function zl_dex(dex:Number) : int
|
|
{
|
|
return dex * 10;
|
|
}
|
|
|
|
public static function zl_atkSpd(atkspd:Number) : int
|
|
{
|
|
return atkspd * 20;
|
|
}
|
|
|
|
public static function zl_atkVim(atkvim:Number) : int
|
|
{
|
|
return atkvim * 50;
|
|
}
|
|
|
|
public static function zl_selfCure(selfCure:Number) : int
|
|
{
|
|
return selfCure * 6;
|
|
}
|
|
|
|
public static function zl_deadBoom(deadBoom:Number) : int
|
|
{
|
|
return int(deadBoom * 1.5);
|
|
}
|
|
|
|
public static function zl_atkStun(atkStunChance:Number) : int
|
|
{
|
|
return atkStunChance * 20;
|
|
}
|
|
|
|
public static function zl_defStun(defStunChance:Number) : int
|
|
{
|
|
return defStunChance * 30;
|
|
}
|
|
|
|
public static function zl_atkPoi(atkPoiChance:Number, atkPoiDamage:*) : int
|
|
{
|
|
return atkPoiChance * 10 + atkPoiDamage * 2;
|
|
}
|
|
|
|
public static function zl_apCostSave(apCostSave:int) : int
|
|
{
|
|
return apCostSave * 150;
|
|
}
|
|
|
|
public static function zl_sunFire(sunFire:int) : int
|
|
{
|
|
return sunFire * 4;
|
|
}
|
|
|
|
public static function zl_moonHeal(moonHeal:int) : int
|
|
{
|
|
return moonHeal * 10;
|
|
}
|
|
|
|
public static function zl_crit(crit:Number) : int
|
|
{
|
|
return crit * 30;
|
|
}
|
|
|
|
public static function zl_skillCooldown(skillCooldown:Number) : int
|
|
{
|
|
return skillCooldown * 20;
|
|
}
|
|
|
|
public static function zl_thorns(thorns:int) : int
|
|
{
|
|
return thorns * 2;
|
|
}
|
|
|
|
public static function zl_editMon(mon:Object, abilityScale:Number = 1, hpScale:Number = 1) : int
|
|
{
|
|
var m:Object = null;
|
|
var zl:int = 0;
|
|
var moveImmune:Boolean = Boolean(mon.moveImmune);
|
|
var mode:int = int(mon.mode);
|
|
var teampos:int = int(mon.teamPos);
|
|
if(mon.autoValue)
|
|
{
|
|
m = new MonsterVo();
|
|
m.editorInit(mon.type);
|
|
m.buildByArea();
|
|
m.level = mon.level;
|
|
mon = m;
|
|
}
|
|
zl = hpScale * zl_hp(mon.hp) + abilityScale * (zl_def(mon.def) + zl_dex(mon.dex) + zl_atk(mon.atk,mon.spd_atk));
|
|
if(moveImmune)
|
|
{
|
|
if(!AttackType.isShooter(mon.type,mode))
|
|
{
|
|
return int(zl * 0.25);
|
|
}
|
|
zl *= 0.8;
|
|
}
|
|
if(teampos >= 6)
|
|
{
|
|
zl *= 0.8;
|
|
}
|
|
return zl;
|
|
}
|
|
|
|
public static function zl_battleMonVo(mon:Object) : int
|
|
{
|
|
return int(zl_hp(mon.hp) + zl_def(mon.def) + zl_dex(mon.dex) + zl_atk(mon.atk,mon.spd_atk));
|
|
}
|
|
|
|
public static function zl_monVo(monvo:MonsterVo) : int
|
|
{
|
|
var zl:int = zl_hp(monvo.hp) + zl_def(monvo.def) + zl_dex(monvo.dex) + zl_atk(monvo.atk);
|
|
zl += zl_atkSpd(monvo.allAdd("atkSpd"));
|
|
zl += zl_crit(monvo.allAdd("crit"));
|
|
zl += zl_selfCure(monvo.allAdd("selfCure"));
|
|
zl += zl_atkVim(monvo.allAdd("atkVim"));
|
|
zl += zl_atkStun(monvo.allAdd("atkStun"));
|
|
zl += zl_defStun(monvo.allAdd("defStun"));
|
|
zl += zl_atkPoi(monvo.allAdd("atkPoi"),monvo.allAdd("atkPoiDmg"));
|
|
zl += zl_skillCooldown(monvo.allAdd("skillCooldown"));
|
|
zl += zl_sunFire(monvo.allAdd("sunFire"));
|
|
zl += zl_moonHeal(monvo.allAdd("moonHeal"));
|
|
zl += zl_deadBoom(monvo.allAdd("deadBoom"));
|
|
return int(zl + zl_thorns(monvo.allAdd("thorns")));
|
|
}
|
|
|
|
public static function zl_battle(battle:Object) : int
|
|
{
|
|
var zl:int = 0;
|
|
var arr:Array = null;
|
|
try
|
|
{
|
|
zl = 0;
|
|
arr = battle.teams[0].mons;
|
|
for each(var mo:Object in arr)
|
|
{
|
|
if(!(mo is int) && mo.team == 2 && mo != null)
|
|
{
|
|
if(battle.scaleAbility == null)
|
|
{
|
|
battle.scaleAbility = 1;
|
|
}
|
|
if(battle.scaleHp == null)
|
|
{
|
|
battle.scaleHp = 1;
|
|
}
|
|
zl += zl_editMon(mo,battle.scaleAbility,battle.scaleHp);
|
|
}
|
|
}
|
|
}
|
|
catch(error:Error)
|
|
{
|
|
return 0;
|
|
}
|
|
return zl;
|
|
}
|
|
|
|
public static function zl_battle_onstage(battle:Object) : int
|
|
{
|
|
var zl:int = 0;
|
|
var arr:Array = battle.teams[0].mons;
|
|
for each(var mo:Object in arr)
|
|
{
|
|
if(!(mo is int) && mo.team == 2 && mo != null && mo.teamPos < 6)
|
|
{
|
|
if(battle.scaleAbility == null)
|
|
{
|
|
battle.scaleAbility = 1;
|
|
}
|
|
if(battle.scaleHp == null)
|
|
{
|
|
battle.scaleHp = 1;
|
|
}
|
|
zl += zl_editMon(mo,battle.scaleAbility,battle.scaleHp);
|
|
}
|
|
}
|
|
return zl;
|
|
}
|
|
|
|
public static function feelAdd(feel:int) : Number
|
|
{
|
|
return Counter.getAreaByArea(0,0.1,0,200,feel,true);
|
|
}
|
|
|
|
public static function isVipGood(goodId:String) : Boolean
|
|
{
|
|
if(goodId == "301")
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static function getSwitchMoney(star:int) : int
|
|
{
|
|
return Table.game_setting.monSwitchCost[star - 1];
|
|
}
|
|
|
|
public static function getGrowUpFarmExp(montype:int) : int
|
|
{
|
|
var exp:int = (int(Table.monster_info[montype].time_1) + int(Table.monster_info[montype].time_2)) / 1200;
|
|
if(exp < 1)
|
|
{
|
|
exp = 1;
|
|
}
|
|
return exp;
|
|
}
|
|
|
|
public static function getMonMaxLevel(potentialLevel:int) : int
|
|
{
|
|
return potentialLevel * Table.potential_info.potentialLevelMaxAdd;
|
|
}
|
|
|
|
public static function getStageNumByLevel(level:int) : int
|
|
{
|
|
var stageNum:int = 2;
|
|
if(level >= Table.team_info.battleTeam[2].level)
|
|
{
|
|
stageNum++;
|
|
}
|
|
if(level >= Table.team_info.battleTeam[3].level)
|
|
{
|
|
stageNum++;
|
|
}
|
|
return stageNum;
|
|
}
|
|
|
|
public static function getLevelByStageNum(stageNum:*) : int
|
|
{
|
|
if(stageNum <= 2)
|
|
{
|
|
return 0;
|
|
}
|
|
if(stageNum <= 3)
|
|
{
|
|
return 6;
|
|
}
|
|
if(stageNum <= 4)
|
|
{
|
|
return 12;
|
|
}
|
|
return 12;
|
|
}
|
|
|
|
public static function getEquipZdl(equip:Object) : int
|
|
{
|
|
var zdl:int = 0;
|
|
zdl += zl_atk(equip.atk);
|
|
zdl += zl_def(equip.def);
|
|
zdl += zl_hp(equip.hp);
|
|
zdl += zl_dex(equip.dex);
|
|
zdl += zl_crit(equip.crit);
|
|
zdl += zl_atkSpd(equip.atkSpd);
|
|
zdl += zl_atkVim(equip.atkVim);
|
|
zdl += zl_selfCure(equip.selfCure);
|
|
zdl += zl_deadBoom(equip.deadBoom);
|
|
zdl += zl_atkStun(equip.atkStun);
|
|
zdl += zl_defStun(equip.defStun);
|
|
zdl += zl_atkPoi(equip.atkPoi,equip.atkPoiDmg);
|
|
zdl += zl_apCostSave(equip.apCostSave);
|
|
zdl += zl_skillCooldown(equip.skillCooldown);
|
|
zdl += zl_sunFire(equip.sunFire);
|
|
zdl += zl_moonHeal(equip.moonHeal);
|
|
return int(zdl + zl_thorns(equip.thorns));
|
|
}
|
|
}
|
|
}
|
|
|