Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ChapterMaster.yyp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
{"$GMFolder":"","%Name":"Diplomacy","folderPath":"folders/Scripts/Diplomacy.yy","name":"Diplomacy","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"events_and_missions","folderPath":"folders/Scripts/events_and_missions.yy","name":"events_and_missions","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"fleet","folderPath":"folders/Scripts/fleet.yy","name":"fleet","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"Global Functions","folderPath":"folders/Scripts/Global Functions.yy","name":"Global Functions","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"Helpers","folderPath":"folders/Scripts/Helpers.yy","name":"Helpers","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"Draw Shapes","folderPath":"folders/Scripts/Helpers/Draw Shapes.yy","name":"Draw Shapes","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"Text","folderPath":"folders/Scripts/Helpers/Text.yy","name":"Text","resourceType":"GMFolder","resourceVersion":"2.0",},
Expand Down Expand Up @@ -715,6 +716,7 @@
{"id":{"name":"Armamentarium","path":"scripts/Armamentarium/Armamentarium.yy",},},
{"id":{"name":"ColourItem","path":"scripts/ColourItem/ColourItem.yy",},},
{"id":{"name":"ColourPicker","path":"scripts/ColourPicker/ColourPicker.yy",},},
{"id":{"name":"CombatDebugger","path":"scripts/CombatDebugger/CombatDebugger.yy",},},
{"id":{"name":"CombatLog","path":"scripts/CombatLog/CombatLog.yy",},},
{"id":{"name":"DebugView","path":"scripts/DebugView/DebugView.yy",},},
{"id":{"name":"DiploBasicNodes","path":"scripts/DiploBasicNodes/DiploBasicNodes.yy",},},
Expand Down
5 changes: 2 additions & 3 deletions objects/obj_bomb_select/Draw_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,13 @@ if ((max_ships > 0) && instance_exists(obj_star_select)) {

// Check if ship_index is still within range
if (ship_index < array_length(ship) && ship[ship_index] != "") {
// Delete the string from the 20th character onwards
var num = string_delete(ship[ship_index], 20, 999);
var ship_name = ship[ship_index];
// Calculate button position based on row and column
var buttonX = bomb_window.x1 + 24 + col * buttonSpacingX;
var buttonY = bomb_window.y1 + 172 + row * buttonSpacingY;

// Draw the unit buttons and handle selection
if (point_and_click(draw_unit_buttons([buttonX, buttonY, buttonX + 105, buttonY + 20], string_truncate(num, 200), [1, 1], ship_all[ship_index] ? #34bc75 : #bf4040, fa_center, fnt_40k_10, ship_all[ship_index] ? 1 : 0.5))) {
if (point_and_click(draw_unit_buttons([buttonX, buttonY, buttonX + 105, buttonY + 20], string_truncate(ship_name, 200), [1, 1], ship_all[ship_index] ? #34bc75 : #bf4040, fa_center, fnt_40k_10, ship_all[ship_index] ? 1 : 0.5))) {
ship_all[ship_index] = !ship_all[ship_index];
ships_selected += ship_all[ship_index] ? 1 : -1;

Expand Down
32 changes: 16 additions & 16 deletions objects/obj_en_fleet/Draw_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -48,29 +48,29 @@ if (obj_controller.zoomed == 1) {
}
}

if (obj_controller.selecting_planet > 0) {
if ((mouse_x >= camera_get_view_x(view_camera[0]) + 529) && (mouse_y >= camera_get_view_y(view_camera[0]) + 234) && (mouse_x < camera_get_view_x(view_camera[0]) + 611) && (mouse_y < camera_get_view_y(view_camera[0]) + 249)) {
if (instance_exists(obj_star_select)) {
if (obj_star_select.button1 != "") {
within = 0;
if (obj_controller.selecting_planet > 0) {
if ((mouse_x >= camera_get_view_x(view_camera[0]) + 529) && (mouse_y >= camera_get_view_y(view_camera[0]) + 234) && (mouse_x < camera_get_view_x(view_camera[0]) + 611) && (mouse_y < camera_get_view_y(view_camera[0]) + 249)) {
if (instance_exists(obj_star_select)) {
if (array_length(obj_star_select.buttons) > 0) {
within = 0;
}
}
}
}
if ((mouse_x >= camera_get_view_x(view_camera[0]) + 529) && (mouse_y >= camera_get_view_y(view_camera[0]) + 250) && (mouse_x < camera_get_view_x(view_camera[0]) + 611) && (mouse_y < camera_get_view_y(view_camera[0]) + 265)) {
if (instance_exists(obj_star_select)) {
if (obj_star_select.button2 != "") {
within = 0;
if ((mouse_x >= camera_get_view_x(view_camera[0]) + 529) && (mouse_y >= camera_get_view_y(view_camera[0]) + 250) && (mouse_x < camera_get_view_x(view_camera[0]) + 611) && (mouse_y < camera_get_view_y(view_camera[0]) + 265)) {
if (instance_exists(obj_star_select)) {
if (array_length(obj_star_select.buttons) > 1) {
within = 0;
}
}
}
}
if ((mouse_x >= camera_get_view_x(view_camera[0]) + 529) && (mouse_y >= camera_get_view_y(view_camera[0]) + 266) && (mouse_x < camera_get_view_x(view_camera[0]) + 611) && (mouse_y < camera_get_view_y(view_camera[0]) + 281)) {
if (instance_exists(obj_star_select)) {
if (obj_star_select.button3 != "") {
within = 0;
if ((mouse_x >= camera_get_view_x(view_camera[0]) + 529) && (mouse_y >= camera_get_view_y(view_camera[0]) + 266) && (mouse_x < camera_get_view_x(view_camera[0]) + 611) && (mouse_y < camera_get_view_y(view_camera[0]) + 281)) {
if (instance_exists(obj_star_select)) {
if (array_length(obj_star_select.buttons) > 2) {
within = 0;
}
}
}
}
}

if (action != "") {
draw_set_halign(fa_left);
Expand Down
37 changes: 33 additions & 4 deletions objects/obj_enunit/Alarm_0.gml
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
/// @description This alarm is responsible for the enemy target column selection

obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.SYSTEM, $"Enemy {obj_ncombat.combat_debugger.resolve_label(id)} at x={x}, flank={flank} is picking a target");

if (!instance_exists(obj_pnunit)) {
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"No valid player blocks, exiting");
exit;
}

enemy = flank ? get_leftmost() : get_rightmost();
if (enemy == noone) {
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"Couldn't find valid player blocks, exiting");
exit;
}

obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"Initial target player block: {obj_ncombat.combat_debugger.resolve_label(enemy)} at x={enemy.x}");

//In melee check
engaged = collision_point(x - 10, y, obj_pnunit, 0, 1) || collision_point(x + 10, y, obj_pnunit, 0, 1);

if (!engaged) {
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"Not engaged, firing");
// Shooting
for (var i = 0; i < array_length(wep); i++) {
if (wep[i] == "" || wep_num[i] == 0) {
Expand All @@ -23,14 +30,18 @@ if (!engaged) {
continue;
}

obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"{wep[i]}(i{i}) is firing");

if (range[i] == 0) {
LOGGER.error($"{wep[i]} has broken range! This shouldn't happen! Range: {range[i]}; Ammo: {ammo[i]}; Owner: {wep_owner[i]}");
continue;
}

if (!target_block_is_valid(enemy, obj_pnunit)) {
enemy = flank == 0 ? get_rightmost() : get_leftmost();
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"Target is invalid, flipped to {obj_ncombat.combat_debugger.resolve_label(enemy)}");
if (!target_block_is_valid(enemy, obj_pnunit)) {
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"Target is still invalid, exiting");
exit;
}
}
Expand All @@ -40,6 +51,7 @@ if (!engaged) {
if (instance_exists(obj_nfort) && !flank) {
enemy = instance_nearest(x, y, obj_nfort);
dist = 2;
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"Targeting Fort");
} else {
dist = get_block_distance(enemy);
}
Expand Down Expand Up @@ -69,6 +81,7 @@ if (!engaged) {
if (cm_present) {
enemy = cm_block;
target_unit_index = cm_index;
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"Alpha Strike: targeting Chapter Master at {obj_ncombat.combat_debugger.resolve_label(cm_block)} unit_index={cm_index}");
}
}

Expand All @@ -78,6 +91,7 @@ if (!engaged) {
var _shot = false;
if ((!instance_exists(obj_nfort)) || flank) {
if (block_has_armour(enemy) || (enemy.veh_type[1] == "Defenses")) {
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"AP -> vehicle in column {obj_ncombat.combat_debugger.resolve_label(enemy)}, apa={apa[i]}, firing");
scr_shoot(i, enemy, target_unit_index, "arp", "ranged");
continue;
} else if ((instance_number(obj_pnunit) > 1)) {
Expand All @@ -92,6 +106,7 @@ if (!engaged) {
break;
}
if (block_has_armour(enemy2)) {
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"AP -> vehicle found in next column {obj_ncombat.combat_debugger.resolve_label(enemy2)}, firing");
scr_shoot(i, enemy2, target_unit_index, "arp", "ranged");
_shot = true;
break;
Expand All @@ -100,10 +115,12 @@ if (!engaged) {
if (!_shot) {
_no_vehicles_present = true;
_target_vehicles = false;
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"AP -> no vehicles found, falling back to infantry");
}
}
} else {
enemy = instance_nearest(x, y, obj_nfort);
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"AP -> targeting wall");
scr_shoot(i, enemy, 1, "arp", "wall");
continue;
}
Expand All @@ -113,7 +130,7 @@ if (!engaged) {
if ((!_target_vehicles) && ((!instance_exists(obj_nfort)) || flank)) {
var _shot = false;
if (enemy.men > 0) {
// There are marines in the first column;
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"non-AP -> infantry in column {obj_ncombat.combat_debugger.resolve_label(enemy)}, men={enemy.men}, firing");
scr_shoot(i, enemy, target_unit_index, "att", "ranged");
continue;
} else if (instance_number(obj_pnunit) > 1) {
Expand Down Expand Up @@ -144,6 +161,7 @@ if (!engaged) {
continue;
}
}
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"non-AP -> infantry found in back column {obj_ncombat.combat_debugger.resolve_label(enemy2)}, firing");
scr_shoot(i, enemy2, target_unit_index, "att", "ranged");
_shot = true;
break;
Expand All @@ -155,6 +173,7 @@ if (!engaged) {
if (!_shot && !_no_vehicles_present) {
if ((!instance_exists(obj_nfort)) || flank) {
if (block_has_armour(enemy) || (enemy.veh_type[1] == "Defenses")) {
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"non-AP fallback -> armour in column {obj_ncombat.combat_debugger.resolve_label(enemy)}, firing");
scr_shoot(i, enemy, target_unit_index, "att", "ranged");
continue;
} else if ((instance_number(obj_pnunit) > 1)) {
Expand All @@ -169,13 +188,15 @@ if (!engaged) {
break;
}
if (block_has_armour(enemy2)) {
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"non-AP fallback -> armour in next column {obj_ncombat.combat_debugger.resolve_label(enemy2)}, firing");
scr_shoot(i, enemy2, target_unit_index, "att", "ranged");
break;
}
}
}
} else {
enemy = instance_nearest(x, y, obj_nfort);
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"non-AP -> targeting fort, firing");
scr_shoot(i, enemy, 1, "att", "wall");
continue;
}
Expand All @@ -187,6 +208,7 @@ if (!engaged) {
LOGGER.error($"{wep[i]} didn't find a valid target! This shouldn't happen!");
}
} else if ((engaged || enemy.engaged) && target_block_is_valid(enemy, obj_pnunit)) {
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"Engaged, attacking in melee");
//TODO: The melee code was not refactored;
// Melee
engaged = 1;
Expand All @@ -208,13 +230,16 @@ if (!engaged) {
}

if ((range[i] <= 2) || (floor(range[i]) != range[i])) {
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"{wep[i]}(i{i}) is striking");
// Weapon meets preliminary checks
if (apa[i] > 2) {
_armour_piercing = true;
} // Determines if it is _armour_piercing or not
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"melee AP=true");
}
if (_armour_piercing && instance_exists(obj_nfort) && (!flank)) {
// Huff and puff and blow the wall down
enemy = instance_nearest(x, y, obj_nfort);
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"melee AP -> wall");
scr_shoot(i, enemy, 1, "arp", "wall");
continue;
}
Expand All @@ -223,20 +248,24 @@ if (!engaged) {
var good = false;

if (block_has_armour(enemy)) {
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"melee AP -> vehicles in {obj_ncombat.combat_debugger.resolve_label(enemy)}");
scr_shoot(i, enemy, 1, "arp", "melee");
good = true;
}
if (!good) {
_armour_piercing = false;
} // Fuck it, shoot at infantry
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"melee AP -> no vehicles, falling back to infantry");
}
}

if ((!_armour_piercing) && target_block_is_valid(enemy, obj_pnunit)) {
// Check for men
if (enemy.men) {
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"melee -> infantry in {obj_ncombat.combat_debugger.resolve_label(enemy)}");
scr_shoot(i, enemy, 1, "att", "melee");
} else if (block_has_armour(enemy)) {
scr_shoot(i, enemy, 1, "arp", "melee"); // Swing anyways, maybe they'll get lucky
obj_ncombat.combat_debugger.add(eCOMBAT_CATEGORY.TARGETING, $"melee -> armour fallback in {obj_ncombat.combat_debugger.resolve_label(enemy)}");
scr_shoot(i, enemy, 1, "arp", "melee");
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions objects/obj_ncombat/Alarm_7.gml
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,16 @@ try {
obj_cursor.image_index = 0;
}

if (combat_debugger.active) {
Comment thread
EttyKitty marked this conversation as resolved.
combat_debugger.flush({
enemy_name: enem,
defeat: defeat,
turns: turn_count,
player_start: player_max,
player_end: player_forces,
});
}

instance_destroy();
} catch (_exception) {
ERROR_HANDLER.handle_exception(_exception);
Expand Down
1 change: 1 addition & 0 deletions objects/obj_ncombat/CleanUp_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
combat_debugger.cleanup();
3 changes: 3 additions & 0 deletions objects/obj_ncombat/Create_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ dead_jims = 0;

combat_log = new CombatLog(id);
combat_log.log_font = fnt_aldrich_12;

combat_debugger = new CombatDebugger(false);

ctally_target = undefined;
ctally_bounce = [];
ctally_injure = [];
Expand Down
2 changes: 2 additions & 0 deletions objects/obj_ncombat/KeyPress_13.gml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ if (!instance_exists(obj_popup)) {
}

if ((timer_stage == 1) || (timer_stage == 5)) {
combat_debugger.add(eCOMBAT_CATEGORY.SYSTEM, $"=== Player Turn start (turn {turn_count}) ===");
if (global_perils > 0) {
global_perils -= 1;
}
Expand Down Expand Up @@ -105,6 +106,7 @@ if (!instance_exists(obj_popup)) {
reset_combat_message_arrays();
timer_stage = 2;
} else if (timer_stage == 3) {
combat_debugger.add(eCOMBAT_CATEGORY.SYSTEM, $"=== Enemy Turn start (turn {turn_count}) ===");
if (battle_over != 1) {
alarm[8] = 15;
}
Expand Down
1 change: 1 addition & 0 deletions objects/obj_ncombat/obj_ncombat.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 4 additions & 19 deletions objects/obj_p_fleet/Draw_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -66,29 +66,14 @@ if (!keyboard_check(vk_shift)) {
}
}

if (obj_controller.selecting_planet > 0) {
if ((mouse_x >= camera_get_view_x(view_camera[0]) + 529) && (mouse_y >= camera_get_view_y(view_camera[0]) + 234) && (mouse_x < camera_get_view_x(view_camera[0]) + 611) && (mouse_y < camera_get_view_y(view_camera[0]) + 249)) {
if (instance_exists(obj_star_select)) {
if (obj_star_select.button1 != "") {
if (obj_controller.selecting_planet > 0 && instance_exists(obj_star_select)) {
var _btn_count = array_length(obj_star_select.buttons);
for (var i = 0; i < _btn_count; i++) {
if ((mouse_x >= camera_get_view_x(view_camera[0]) + 529) && (mouse_y >= camera_get_view_y(view_camera[0]) + 234 + (16 * i)) && (mouse_x < camera_get_view_x(view_camera[0]) + 611) && (mouse_y < camera_get_view_y(view_camera[0]) + 249 + (16 * i))) {
within = 0;
}
}
}
if ((mouse_x >= camera_get_view_x(view_camera[0]) + 529) && (mouse_y >= camera_get_view_y(view_camera[0]) + 234 + 16) && (mouse_x < camera_get_view_x(view_camera[0]) + 611) && (mouse_y < camera_get_view_y(view_camera[0]) + 249 + 16)) {
if (instance_exists(obj_star_select)) {
if (obj_star_select.button2 != "") {
within = 0;
}
}
}
if ((mouse_x >= camera_get_view_x(view_camera[0]) + 529) && (mouse_y >= camera_get_view_y(view_camera[0]) + 234 + 32) && (mouse_x < camera_get_view_x(view_camera[0]) + 611) && (mouse_y < camera_get_view_y(view_camera[0]) + 249 + 32)) {
if (instance_exists(obj_star_select)) {
if (obj_star_select.button3 != "") {
within = 0;
}
}
}
}

var line_width = sqr(scale);
var text_size = sqr(scale);
Expand Down
Loading
Loading