But shouldn't the first onwall (onwall(temp.dx, temp.dy)) still work when it's first hit, then? Because in that case this.anglex and this.angley are exactly the same.
In any case, I just plain ****ed it up...
PHP Code:
function onActionHit(damage, accuracy, effects, acc, px, py) {
this.distgone = 0;
this.angle = getangle(px-this.x,py-this.y);
if (this.angle > degtorad(180))
this.angle -= degtorad(180);
else this.angle += degtorad(180);
this.velocity = ((damage*4.45)/this.weight)*.05;
temp.friction = this.weight/damage;
if (temp.friction>=1) this.dist = 0;
else this.dist = .75 / temp.friction;
onTimeOut();
}
function onTimeOut() {
if (this.distgone < this.dist) {
temp.x = this.x+1; temp.y = this.y+1;
temp.dx = temp.x+(this.velocity*cos(this.angle));
temp.dy = temp.y+(this.velocity*(-sin(this.angle)));
if (!onwall(temp.dx, temp.dy)) {
this.x = temp.dx; this.y = temp.dy;
this.distgone += this.velocity;
this.velocity = (this.velocity/5)*4;
}
else {
temp.bx = onwall(temp.bx,temp.y);
temp.by = onwall(temp.y,temp.by);
if (temp.bx && temp.by) {
if (this.angle > degtorad(180))
this.angle -= degtorad(180);
else this.angle += degtorad(180);
}
else {
if (temp.bx) this.angle = pi - this.angle;
if (temp.by) this.angle = -this.angle;
}
this.velocity = (this.velocity/5)*3;
temp.dx = temp.x+(this.velocity*cos(this.angle));
temp.dy = temp.y+(this.velocity*(-sin(this.angle)));
if (!onwall(temp.dx, temp.dy)) {
this.x = temp.dx; this.y = temp.dy;
this.distgone += this.velocity;
}
}
if (this.velocity <= .005) this.dist = this.distgone = 0;
else setTimer(0.05);
}
}