eastern-flames/eastern flames/scripts/c_selectunit/c_selectunit.gml

62 lines
1.6 KiB
Plaintext
Raw Normal View History

2022-08-15 04:06:41 +00:00
function c_selectunit(unitobject) {
2022-08-16 22:28:01 +00:00
if unitobject.waiting return false
2022-08-15 04:06:41 +00:00
unitobject.state = st_moving;
unitobject.drawstate = st_movingdraw;
unitobject.returnpos = new vec2(unitobject.pos.x, unitobject.pos.y);
2022-08-16 22:28:01 +00:00
var mov = unitobject.data.mov.val;
2022-08-15 04:06:41 +00:00
var i, j;
for (i=-mov; i<=mov; i++) {
for (j=-mov; j<=mov; j++) {
if abs(i)+abs(j) <= mov {
c_colortile(unitobject.pos.x+i, unitobject.pos.y+j, c_cyan);
}
}
}
2022-08-16 01:01:09 +00:00
ARTICULATOR.selectedunit = unitobject;
2022-08-16 22:39:22 +00:00
c_fulleval(unitobject);
2022-08-16 22:28:01 +00:00
return unitobject;
2022-08-16 01:01:09 +00:00
}
function c_deselectunit(unitobject) {
2022-08-23 09:25:43 +00:00
if ARTICULATOR.selectedunit != unitobject return false;
if unitobject == noone return false;
2022-08-16 02:04:23 +00:00
unitobject.sprite_index = unitobject.data.idle;
2022-08-16 01:01:09 +00:00
state = st_standing;
drawstate = c_null;
c_decolor_all(c_cyan);
c_decolor_all(c_red);
c_decolor_all(c_green);
ARTICULATOR.selectedunit = noone;
2022-08-16 22:39:22 +00:00
c_fulleval(unitobject);
2022-08-16 01:01:09 +00:00
return true;
2022-08-15 04:06:41 +00:00
}
function c_colortile(x, y, color) {
2022-08-15 04:36:37 +00:00
if !c_tileexists(x, y) return false;
2022-08-15 04:06:41 +00:00
if !array_contains(global.map[x][y], color) {
array_push(global.map[x][y].overlays, color);
}
2022-08-15 04:36:37 +00:00
return true;
2022-08-18 20:47:07 +00:00
}
function c_markunit(unitobject) {
2022-08-19 01:47:44 +00:00
unitobject.marked = !unitobject.marked;
c_loadmarkings();
}
function c_loadmarkings() {
c_decolor_all(c_maroon);
var k;
for (k=0; k<array_length(global.units[ARMY.THEM]); k++) {
var unitobject = global.units[ARMY.THEM][k];
var i, j;
2022-08-19 02:26:10 +00:00
var mov = unitobject.data.mov.val+unitobject.data.rng.val;
2022-08-19 01:47:44 +00:00
for (i=-mov; i<=mov; i++) {
for (j=-mov; j<=mov; j++) {
if abs(i)+abs(j) <= mov {
if unitobject.marked c_colortile(unitobject.pos.x+i, unitobject.pos.y+j, c_maroon);
}
2022-08-18 20:47:07 +00:00
}
}
}
2022-08-15 04:06:41 +00:00
}