fr range selection
This commit is contained in:
parent
c6a380fe0a
commit
37f598b561
|
@ -13,6 +13,7 @@ c_addweapon(id, wp.nothing);
|
|||
equippedweapon = noone;
|
||||
waiting = false;
|
||||
targeting = new vec2(0, 0);
|
||||
hitpos = new vec2(0, 0);
|
||||
marked = false;
|
||||
|
||||
continuecombat = function(me, them) {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
state();
|
||||
if data.hp.val <= 0 {
|
||||
c_deselectunit(id);
|
||||
c_deleteunit(pos.x, pos.y, id);
|
||||
}
|
||||
}
|
||||
//depth = x;
|
|
@ -23,5 +23,5 @@ function c_containsunit(x, y) {
|
|||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return noone;
|
||||
}
|
|
@ -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);
|
||||
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,8 +134,10 @@ 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));
|
||||
c_generatecombatstack([id, hitting.contents[i]]);
|
||||
if hitting.contents[i].alignment != alignment ^^ !data.str.val {
|
||||
c_moveunit(id, c_gettile(pos.x, pos.y));
|
||||
c_generatecombatstack([id, hitting.contents[i]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue