Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function getBattleResult(attacker:WorldObject, defender:WorldObject) : Object
- {
- var _magic_:* = 4.5;
- var _attk_:Number = attacker.attack * (attacker.health / attacker.maxHealth);
- var _deff_:Number = defender.defence * (defender.health / defender.maxHealth);
- var _sum_:Number = _attk_ + _deff_;
- var _attack_:Number = Math.round(_attk_ / _sum_ * attacker.attack * _magic_);
- var _defence_:* = -1;
- if(defender.tile.getAttackRange(defender.owner).indexOf(attacker.tile) > -1)
- {
- _defence_ = Number(Math.round(_deff_ / defender.defenceBonus / _sum_ * defender.defence * _magic_));
- }
- var _proceed_:Boolean = false;
- if(attacker is Unit && defender.health <= _attack_ && attacker.range == 1 && Boolean(defender.tile.moveOk(attacker as Unit)))
- {
- _proceed_ = true;
- }
- return {
- "attack":_attack_,
- "defence":_defence_,
- "proceed":_proceed_
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement