Alright, thanks, but I think there's something wrong with my onwall checks...
PHP Code:
function onCreated() {
this.anglex = this.angley = NULL;
this.moving = this.canhurt = false;
this.velocity = this.dist = this.momentum = NULL;
this.distgone = this.time = this.timetotal = NULL;
}
function onActionHit(damage, accuracy, effects, acc, px, py) {
temp.px = px+1.5; temp.py = py+2;
this.distgone = 0;
this.anglex = getangle(temp.px-this.x,temp.py-this.y);
if (this.anglex > degtorad(180))
this.anglex -= degtorad(180);
else this.anglex += degtorad(180);
this.angley = this.anglex;
this.velocity = ((damage*4.45)/this.weight)*.05;
temp.momentum = this.weight * this.veolocity;
if (temp.momentum > 5) this.canhurt = true;
else this.canhurt = false;
temp.friction = this.weight/damage;
if (temp.friction>=1) this.dist = 0;
else this.dist = .75 / temp.friction;
this.moving = true;
onTimeOut();
}
function onTimeOut() {
if (this.moving) {
if (this.distgone<this.dist) {
temp.dx = this.x+(this.velocity*cos(this.anglex));
temp.dy = this.y+(this.velocity*(-sin(this.angley)));
if (!onwall(temp.dx,temp.dy)) {
this.x = temp.dx; this.y = temp.dy;
this.distgone += this.velocity;
}
else {
temp.bx = onwall(temp.dx,this.y);
temp.by = onwall(this.x,temp.dy);
if (temp.bx && temp.by) {
this.anglex = pi - this.anglex;
this.angley = this.anglex;
}
else {
if (temp.bx) this.anglex = pi - this.anglex;
if (temp.by) this.angley = pi - this.angley;
}
//this.velocity = this.velocity/2;
this.dist = this.dist-this.distgone;
this.distgone = 0;
}
setTimer(0.05);
}
}
}
They're pretty off...