|
|
|
@ -39,7 +39,8 @@ function st_moving() {
|
|
|
|
|
var dude = c_gettile(x+hspd+abs(sprite_width)/4, y+vspd, true);
|
|
|
|
|
if dude != noone {
|
|
|
|
|
var dist = c_tiledist(dude.x, dude.y, returnpos.x, returnpos.y);
|
|
|
|
|
if dist.x + dist.y <= data.mov.val && dude.passable {
|
|
|
|
|
var friend = c_containsunit(dude.x, dude.y);
|
|
|
|
|
if dist.x + dist.y <= data.mov.val && dude.passable && (friend == noone || friend == id) {
|
|
|
|
|
pos.x = dude.x;
|
|
|
|
|
pos.y = dude.y;
|
|
|
|
|
if !stop {
|
|
|
|
@ -66,24 +67,53 @@ function st_moving() {
|
|
|
|
|
//log("selecting");
|
|
|
|
|
//var rng = [1];
|
|
|
|
|
var guy = c_gettile(x, y, true);
|
|
|
|
|
var hitting = noone;
|
|
|
|
|
if guy != noone {
|
|
|
|
|
if stop {
|
|
|
|
|
//var dist = c_tiledist();
|
|
|
|
|
//hitpos.y = clamp(hitpos.y+downp-upp, -data.rng.val, data.rng.val);
|
|
|
|
|
//hitpos.x = clamp(hitpos.x+rightp-leftp, -(data.rng.val-abs(hitpos.y)), (data.rng.val-abs(hitpos.y)));
|
|
|
|
|
//hitpos.y = clamp(hitpos.y, -(data.rng.val-abs(hitpos.x)), (data.rng.val-abs(hitpos.x)));
|
|
|
|
|
var shits = c_tiledist(0, 0, hitpos.x+rightp-leftp, hitpos.y+downp-upp);
|
|
|
|
|
var dist = shits.x + shits.y;
|
|
|
|
|
if dist <= data.rng.val && !(data.rng.val && hitpos.x == 0 && hitpos.y == 0) {
|
|
|
|
|
hitpos.x += rightp-leftp;
|
|
|
|
|
hitpos.y += downp-upp;
|
|
|
|
|
} else {
|
|
|
|
|
switch dir {
|
|
|
|
|
case DIR.LEFT:
|
|
|
|
|
hitpos.x = -1;
|
|
|
|
|
hitpos.y = 0;
|
|
|
|
|
break;
|
|
|
|
|
case DIR.DOWN:
|
|
|
|
|
hitpos.x = 0;
|
|
|
|
|
hitpos.y = 1;
|
|
|
|
|
break;
|
|
|
|
|
case DIR.UP:
|
|
|
|
|
hitpos.x = 0;
|
|
|
|
|
hitpos.y = -1;
|
|
|
|
|
break;
|
|
|
|
|
case DIR.RIGHT:
|
|
|
|
|
hitpos.x = 1;
|
|
|
|
|
hitpos.y = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var hitting = noone;
|
|
|
|
|
if guy != noone {
|
|
|
|
|
hitting = c_gettile(guy.x+hitpos.x, guy.y+hitpos.y);
|
|
|
|
|
switch dir {
|
|
|
|
|
case DIR.LEFT:
|
|
|
|
|
hitting = c_gettile(guy.x-1, guy.y);
|
|
|
|
|
sprite_index = data.down;
|
|
|
|
|
image_xscale = -1;
|
|
|
|
|
break;
|
|
|
|
|
case DIR.DOWN:
|
|
|
|
|
hitting = c_gettile(guy.x, guy.y+1);
|
|
|
|
|
sprite_index = data.down;
|
|
|
|
|
break;
|
|
|
|
|
case DIR.UP:
|
|
|
|
|
hitting = c_gettile(guy.x, guy.y-1);
|
|
|
|
|
sprite_index = data.up;
|
|
|
|
|
break;
|
|
|
|
|
case DIR.RIGHT:
|
|
|
|
|
hitting = c_gettile(guy.x+1, guy.y);
|
|
|
|
|
sprite_index = data.down;
|
|
|
|
|
image_xscale = 1;
|
|
|
|
|
break;
|
|
|
|
@ -104,13 +134,15 @@ function st_moving() {
|
|
|
|
|
if hitting.contents[i].object_index = o_unit {
|
|
|
|
|
log("is unit");
|
|
|
|
|
log("found two");
|
|
|
|
|
c_moveunit(id, c_gettile(x, y, true));
|
|
|
|
|
if hitting.contents[i].alignment != alignment ^^ !data.str.val {
|
|
|
|
|
c_moveunit(id, c_gettile(pos.x, pos.y));
|
|
|
|
|
c_generatecombatstack([id, hitting.contents[i]]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if back {
|
|
|
|
|
c_moveunit(id, c_gettile(returnpos.x, returnpos.y));
|
|
|
|
|
c_deselectunit(id);
|
|
|
|
|