diff --git a/eastern flames/objects/o_unit/Create_0.gml b/eastern flames/objects/o_unit/Create_0.gml index ba31097..3dc2e4c 100644 --- a/eastern flames/objects/o_unit/Create_0.gml +++ b/eastern flames/objects/o_unit/Create_0.gml @@ -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) { diff --git a/eastern flames/objects/o_unit/Step_0.gml b/eastern flames/objects/o_unit/Step_0.gml index 750097b..2d5164e 100644 --- a/eastern flames/objects/o_unit/Step_0.gml +++ b/eastern flames/objects/o_unit/Step_0.gml @@ -1,4 +1,6 @@ state(); if data.hp.val <= 0 { + c_deselectunit(id); c_deleteunit(pos.x, pos.y, id); -} \ No newline at end of file +} +//depth = x; \ No newline at end of file diff --git a/eastern flames/scripts/c_passableeval/c_passableeval.gml b/eastern flames/scripts/c_passableeval/c_passableeval.gml index 502bc38..c90ad05 100644 --- a/eastern flames/scripts/c_passableeval/c_passableeval.gml +++ b/eastern flames/scripts/c_passableeval/c_passableeval.gml @@ -23,5 +23,5 @@ function c_containsunit(x, y) { } } } - return false; + return noone; } \ No newline at end of file diff --git a/eastern flames/scripts/st_moving/st_moving.gml b/eastern flames/scripts/st_moving/st_moving.gml index a793c86..e675678 100644 --- a/eastern flames/scripts/st_moving/st_moving.gml +++ b/eastern flames/scripts/st_moving/st_moving.gml @@ -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]]); + } } } }