2022-08-19 17:19:08 +00:00
|
|
|
function st_control() {
|
|
|
|
c_input();
|
|
|
|
var mouse = c_2dto3d(mouse_x,mouse_y);
|
2022-08-19 22:06:21 +00:00
|
|
|
if select {
|
2022-08-19 17:19:08 +00:00
|
|
|
var mousex = floor(mouse.x/global.tilesize.x);
|
|
|
|
var mousey = floor(mouse.y/global.tilesize.y);
|
|
|
|
log(mousex, mousey);
|
|
|
|
if mousex < array_length(global.map) && mousex >= 0 {
|
|
|
|
if mousey < array_length(global.map[mousex]) && mousey >= 0 {
|
|
|
|
var i;
|
|
|
|
for (i=0; i<array_length(global.map[mousex][mousey].contents); i++) {
|
|
|
|
if global.map[mousex][mousey].contents[i].object_index == o_unit {
|
|
|
|
var dude = global.map[mousex][mousey].contents[i];
|
2022-08-23 13:06:02 +00:00
|
|
|
log(global.map[mousex][mousey].contents);
|
2022-08-19 17:19:08 +00:00
|
|
|
if dude.alignment == global.turn {
|
2022-08-23 10:09:17 +00:00
|
|
|
if selectedunit == noone {
|
|
|
|
c_selectunit(dude);
|
|
|
|
se_play(se_select);
|
|
|
|
}
|
2022-08-19 17:19:08 +00:00
|
|
|
} else {
|
|
|
|
c_markunit(dude);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if select {
|
|
|
|
if mouse.x > global.gw-100 {
|
|
|
|
var guyhits = floor(abs(mouse.y-global.gh-10)/32);
|
|
|
|
log(guyhits, array_length(selectedunit.inventory));
|
|
|
|
if guyhits < array_length(selectedunit.inventory) {
|
|
|
|
//log("doing");
|
|
|
|
selectedunit.equippedweapon = guyhits+1;
|
|
|
|
c_equipweapon(selectedunit, selectedunit.inventory[selectedunit.equippedweapon]);
|
|
|
|
}
|
|
|
|
//draw_text(global.gw-10, global.gh-10-i*20;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if selectedunit == noone {
|
|
|
|
hspd = lerp(hspd, (right-left)*((.1+stop*.1)*(ts.x)), .4);
|
|
|
|
vspd = lerp(vspd, (down-up)*((.1+stop*.1)*(ts.y)), .4);
|
|
|
|
x += hspd;
|
|
|
|
y += vspd;
|
|
|
|
} else {
|
|
|
|
hspd = 0;
|
|
|
|
vspd = 0;
|
|
|
|
x = lerp(x, selectedunit.x, .4);
|
|
|
|
y = lerp(y, selectedunit.y, .4);
|
2022-08-19 22:06:21 +00:00
|
|
|
//cursor.x = selectedunit.x;
|
|
|
|
//cursor.y = selectedunit.y;
|
2022-08-19 17:19:08 +00:00
|
|
|
}
|
2022-08-19 22:06:21 +00:00
|
|
|
cursor.x = mouse_x;
|
|
|
|
cursor.y = mouse_y;
|
2022-08-19 17:19:08 +00:00
|
|
|
global.camerax = x;
|
|
|
|
global.cameray = y;
|
|
|
|
var mousex = floor(mouse.x/global.tilesize.x);
|
|
|
|
var mousey = floor(mouse.y/global.tilesize.y);
|
|
|
|
//log(mousex, mousey);
|
|
|
|
hoveredunit = selectedunit;
|
|
|
|
if mousex < array_length(global.map) && mousex >= 0 {
|
|
|
|
if mousey < array_length(global.map[mousex]) && mousey >= 0 {
|
|
|
|
var i;
|
|
|
|
for (i=0; i<array_length(global.map[mousex][mousey].contents); i++) {
|
|
|
|
if global.map[mousex][mousey].contents[i].object_index == o_unit {
|
|
|
|
hoveredunit = (global.map[mousex][mousey].contents[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-08-19 22:06:21 +00:00
|
|
|
if hoveredunit != noone {
|
|
|
|
//cursor.x = lerp(mouse_x, hoveredunit.x, .4);
|
|
|
|
//cursor.y = lerp(mouse_y, hoveredunit.y, .4);
|
|
|
|
}
|
2022-08-19 17:19:08 +00:00
|
|
|
var i;
|
|
|
|
for (i=0; i<array_length(global.units[global.turn]); i++) {
|
|
|
|
if global.units[global.turn][i].waiting = false exit;
|
|
|
|
}
|
|
|
|
c_dewait(global.turn);
|
2022-08-23 01:28:48 +00:00
|
|
|
//global.turn = (global.turn+1)%2;
|
2022-08-23 09:25:43 +00:00
|
|
|
hoveredunit = noone;
|
|
|
|
c_deselectunit(selectedunit);
|
|
|
|
waiting = 60;
|
2022-08-23 08:34:45 +00:00
|
|
|
k = 0;
|
2022-08-23 01:28:48 +00:00
|
|
|
global.turn = ARMY.THEM;
|
2022-08-19 17:19:08 +00:00
|
|
|
log("TURN " + string(global.turn));
|
|
|
|
state = st_enemyturn;
|
|
|
|
}
|