61 lines
1.5 KiB
Plaintext
Raw Normal View History

2022-08-14 21:06:41 -07:00
function c_selectunit(unitobject) {
2022-08-16 15:28:01 -07:00
if unitobject.waiting return false
2022-08-14 21:06:41 -07:00
unitobject.state = st_moving;
unitobject.drawstate = st_movingdraw;
unitobject.returnpos = new vec2(unitobject.pos.x, unitobject.pos.y);
2022-08-16 15:28:01 -07:00
var mov = unitobject.data.mov.val;
2022-08-14 21:06:41 -07: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-15 18:01:09 -07:00
ARTICULATOR.selectedunit = unitobject;
2022-08-16 15:39:22 -07:00
c_fulleval(unitobject);
2022-08-16 15:28:01 -07:00
return unitobject;
2022-08-15 18:01:09 -07:00
}
function c_deselectunit(unitobject) {
if ARTICULATOR.selectedunit != unitobject return false
2022-08-15 19:04:23 -07:00
unitobject.sprite_index = unitobject.data.idle;
2022-08-15 18:01:09 -07: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 15:39:22 -07:00
c_fulleval(unitobject);
2022-08-15 18:01:09 -07:00
return true;
2022-08-14 21:06:41 -07:00
}
function c_colortile(x, y, color) {
2022-08-14 21:36:37 -07:00
if !c_tileexists(x, y) return false;
2022-08-14 21:06:41 -07:00
if !array_contains(global.map[x][y], color) {
array_push(global.map[x][y].overlays, color);
}
2022-08-14 21:36:37 -07:00
return true;
2022-08-18 13:47:07 -07:00
}
function c_markunit(unitobject) {
2022-08-18 18:47:44 -07: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-18 19:26:10 -07:00
var mov = unitobject.data.mov.val+unitobject.data.rng.val;
2022-08-18 18:47:44 -07: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 13:47:07 -07:00
}
}
}
2022-08-14 21:06:41 -07:00
}