234 lines
6.1 KiB
Plaintext
234 lines
6.1 KiB
Plaintext
function st_moving() {
|
|
var mov = data.mov.val;
|
|
c_input();
|
|
hspd = lerp(hspd, (right-left)*.07, .4);
|
|
vspd = lerp(vspd, (down-up)*.07, .4);
|
|
if !stop dir = DIR.NONE;
|
|
if left dir = DIR.LEFT;
|
|
if down dir = DIR.DOWN;
|
|
if up dir = DIR.UP;
|
|
if right dir = DIR.RIGHT;
|
|
if leftp dir = DIR.LEFT;
|
|
if downp dir = DIR.DOWN;
|
|
if upp dir = DIR.UP;
|
|
if rightp dir = DIR.RIGHT;
|
|
/*var remainingmov = mov+1 - (
|
|
abs(x+hspd-16-returnpos.x*ts.x)/ts.x +
|
|
abs(y+vspd-16-returnpos.y*ts.y)/ts.y
|
|
);*/
|
|
var dist = c_tiledist(pos.x, pos.y, returnpos.y, returnpos.y);
|
|
//var remainingmov = dist.x + dist.y;
|
|
//var shitmode = point_distance(x, y, returnpos.x*ts.x, returnpos.y*ts.y);
|
|
//if shitmode > mov*ts.x {
|
|
|
|
//while !remainingmov {
|
|
/*hspd = 0;
|
|
vspd = 0;
|
|
x = linear_approach(x, returnpos.x*ts.x, 1);
|
|
y = linear_approach(y, returnpos.y*ts.y, 1);
|
|
log(x, returnpos.x*ts.x);
|
|
log(y, returnpos.y*ts.y);
|
|
var remainingmov = mov+1 - (
|
|
abs(x+hspd-16-returnpos.x*ts.x)/ts.x +
|
|
abs(y+vspd-16-returnpos.y*ts.y)/ts.y
|
|
);*/
|
|
//log("oob, " + string(remainingmov));
|
|
/*} else {
|
|
log("not oob!");*/
|
|
//}
|
|
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);
|
|
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 {
|
|
x += hspd*ts.x;
|
|
y += vspd*ts.y;
|
|
}
|
|
} else {
|
|
x -= hspd*ts.x;
|
|
y -= vspd*ts.y;
|
|
x = linear_approach(x, returnpos.x*ts.x+abs(sprite_width)/4, 1);
|
|
y = linear_approach(y, returnpos.y*ts.y, 1);
|
|
}
|
|
} else {
|
|
x -= hspd*ts.x;
|
|
y -= vspd*ts.y;
|
|
x = linear_approach(x, returnpos.x*ts.x+abs(sprite_width)/4, 1);
|
|
y = linear_approach(y, returnpos.y*ts.y, 1);
|
|
}
|
|
//prevremainingmov = remainingmov;
|
|
c_decolor_all(c_red);
|
|
c_decolor_all(c_green);
|
|
var guy = c_gettile(pos.x, pos.y);
|
|
c_colortile(guy.x, guy.y, c_green);
|
|
//log("selecting");
|
|
//var rng = [1];
|
|
var guy = c_gettile(x, y, true);
|
|
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;
|
|
|
|
}
|
|
}
|
|
}
|
|
hitting = noone;
|
|
if guy != noone {
|
|
hitting = c_gettile(guy.x+hitpos.x, guy.y+hitpos.y);
|
|
switch dir {
|
|
case DIR.LEFT:
|
|
sprite_index = data.down;
|
|
image_xscale = -1;
|
|
break;
|
|
case DIR.DOWN:
|
|
sprite_index = data.down;
|
|
break;
|
|
case DIR.UP:
|
|
sprite_index = data.up;
|
|
break;
|
|
case DIR.RIGHT:
|
|
sprite_index = data.down;
|
|
image_xscale = 1;
|
|
break;
|
|
default:
|
|
sprite_index = data.idle;
|
|
//image_xscale = -1;
|
|
break;
|
|
|
|
}
|
|
if hitting != noone && stop c_colortile(hitting.x, hitting.y, c_red);
|
|
if hitting != noone && select && stop {
|
|
//log("found one");
|
|
//log(hitting.contents, hitting.x, hitting.y);
|
|
var i;
|
|
for (i=0; i<array_length(hitting.contents); i++) {
|
|
if instance_exists(hitting.contents[i]) {
|
|
//log("is instance");
|
|
if hitting.contents[i].object_index = o_unit {
|
|
//log("is unit");
|
|
//log("found two");
|
|
if hitting.contents[i].alignment != alignment ^^ !data.str.val {
|
|
c_moveunit(id, c_gettile(pos.x, pos.y));
|
|
c_generatecombatstack([id, hitting.contents[i]]);
|
|
waiting = true;
|
|
c_deselectunit(id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if back {
|
|
c_moveunit(id, c_gettile(returnpos.x, returnpos.y));
|
|
c_deselectunit(id);
|
|
}
|
|
if dir == DIR.NONE && select && stop {
|
|
se_play(se_move);
|
|
c_moveunit(id, c_gettile(x, y, true));
|
|
waiting = true;
|
|
c_deselectunit(id);
|
|
}
|
|
/*if x < (returnpos.x-mov)*ts.x {
|
|
x = (returnpos.x-mov)*ts.x;
|
|
} else if x > (returnpos.x+mov+1)*ts.x {
|
|
x = (returnpos.x+mov+1)*ts.x;
|
|
} else {
|
|
x += hspd*ts.x;
|
|
}
|
|
if y < (returnpos.y-mov)*ts.y {
|
|
y = (returnpos.y-mov)*ts.y;
|
|
} else if y > (returnpos.y+mov+1)*ts.y {
|
|
y = (returnpos.y+mov+1)*ts.y;
|
|
} else {
|
|
y += vspd*ts.y;
|
|
}*/
|
|
|
|
}
|
|
|
|
function st_movingdraw() {
|
|
/*var mov = 2;
|
|
draw_set_color(c_cyan);
|
|
draw_set_alpha(.4);
|
|
var i, j;
|
|
for (i=-mov; i<=mov; i++) {
|
|
for (j=-mov; j<=mov; j++) {
|
|
if abs(i)+abs(j) <= mov {
|
|
draw_rectangle(
|
|
(returnpos.x+i)*ts.x,
|
|
(returnpos.y+j)*ts.y,
|
|
(returnpos.x+i+1)*ts.x,
|
|
(returnpos.y+j+1)*ts.y, false
|
|
);
|
|
}
|
|
}
|
|
}
|
|
draw_set_alpha(1);*/
|
|
|
|
if hitting != noone && stop {
|
|
var i;
|
|
for (i=0; i<array_length(hitting.contents); i++) {
|
|
if instance_exists(hitting.contents[i]) {
|
|
if hitting.contents[i].object_index = o_unit {
|
|
if hitting.contents[i].alignment != alignment ^^ !data.str.val {
|
|
var them = hitting.contents[i];
|
|
draw_sprite_ext(s_box, 0, 320-120, 360, 8, -4, 0, c_white, 1);
|
|
draw_set_color(c_white);
|
|
draw_set_halign(fa_center);
|
|
//draw_set_valign(fa_middle);
|
|
draw_text(320-60, 245, data.name);
|
|
draw_text(320, 245, "VS");
|
|
draw_text_ext(320+60, 245, them.data.name, 14, 80);
|
|
|
|
draw_text(320-60, 280, string(data.str.val - them.data.def.val) + (data.spd.val > them.data.spd.val+5 ? " x 2" : ""));
|
|
draw_text(320, 280, "POW");
|
|
draw_text(320+60, 280, string(them.data.str.val - data.def.val) + (them.data.spd.val > data.spd.val+5 ? " x 2" : ""));
|
|
|
|
draw_text(320-60, 315, data.hit.val);
|
|
draw_text(320, 315, "HIT");
|
|
draw_text(320+60, 315, them.data.hit.val);
|
|
|
|
|
|
draw_set_halign(fa_left);
|
|
draw_set_valign(fa_top);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#macro ts global.tilesize
|
|
|
|
enum DIR {
|
|
NONE,
|
|
LEFT,
|
|
DOWN,
|
|
UP,
|
|
RIGHT,
|
|
} |