Browse Source

Merge branch '115-charge-through-obstacle' into 'staging'

Fixes #115

See merge request !94
tags/v0.1.3^2
Big Bad Waffle 7 years ago
parent
commit
b63bb5a206
1 changed files with 14 additions and 4 deletions
  1. +14
    -4
      src/server/config/spells/spellCharge.js

+ 14
- 4
src/server/config/spells/spellCharge.js View File

@@ -20,8 +20,11 @@ define([
var obj = this.obj;
var target = action.target;

var dx = target.x - obj.x;
var dy = target.y - obj.y;
var x = obj.x;
var y = obj.y;

var dx = target.x - x;
var dy = target.y - y;

//We need to stop just short of the target
var offsetX = 0;
@@ -39,8 +42,8 @@ define([

var physics = obj.instance.physics;
//Check where we should land
if (physics.isTileBlocking(targetPos.x - offsetX, targetPos.y - offsetY)) {
if (physics.isTileBlocking(targetPos.x - offsetX, targetPos.y)) {
if (!this.isTileValid(physics, x, y, targetPos.x - offsetX, targetPos.y - offsetY)) {
if (!this.isTileValid(physics, x, y, targetPos.x - offsetX, targetPos.y)) {
targetPos.y -= offsetY;
} else {
targetPos.x -= offsetX;
@@ -113,6 +116,13 @@ define([

var damage = this.getDamage(target);
target.stats.takeDamage(damage, this.threatMult, obj);
},

isTileValid: function(physics, fromX, fromY, toX, toY) {
if (physics.isTileBlocking(toX, toY))
return false;
else
return physics.hasLos(fromX, fromY, toX, toY);
}
};
});

Loading…
Cancel
Save