diff --git a/objects/obj_al_ship/Create_0.gml b/objects/obj_al_ship/Create_0.gml index 0b21ad38bb..efd840fd60 100644 --- a/objects/obj_al_ship/Create_0.gml +++ b/objects/obj_al_ship/Create_0.gml @@ -24,6 +24,7 @@ class = ""; hp = 0; maxhp = 0; conditions = ""; +owner = eFACTION.IMPERIUM; shields = 1; maxshields = 1; armour_front = 0; diff --git a/objects/obj_al_ship/Step_0.gml b/objects/obj_al_ship/Step_0.gml index 1155fe63a5..bdefc1181f 100644 --- a/objects/obj_al_ship/Step_0.gml +++ b/objects/obj_al_ship/Step_0.gml @@ -1,40 +1,46 @@ // Manages space combat, checks if ships are destroyed and does the targeting and pointing of the ship +image_angle = direction; -var bull, ok, targe = 0, rdir = 0, dist = 9999, xx = x, yy = y; -var front = 0, right = 0, left = 0, rear = 0; -var f = 0, facing = "", ammo = 0, range = 0, wep = "", dam = 0; -var o_dist = 0, spid = 0; -var gud = 0; +if (obj_fleet.start != 5) { + exit; +} +// Need to every couple of seconds check this +// with obj_en_ship if not big then disable, check nearest, and activate once more +if (instance_exists(obj_en_ship)) { + target = instance_nearest(x, y, obj_en_ship); +} +if (!instance_exists(target)) { + exit; +} -if (owner != 6) { - image_angle = direction; +if ((shields > 0) && (shields < maxshields)) { + shields += (owner == eFACTION.ELDAR) ? 0.03 : 0.02; +} - if (obj_fleet.start != 5) { - exit; - } +var bull = noone; +var ok = 0; +var targe = noone; +var dist = 9999; +var front = 0; +var right = 0; +var left = 0; +var rear = 0; +var facing = ""; +var ammo = 0; +var range = 0; +var wep = ""; +var dam = 0; +var o_dist = 0; +var spid = 0; +var gud = 0; +if (owner != eFACTION.ELDAR) { if ((class == "Daemon") && (image_alpha < 1)) { image_alpha += 0.006; } - o_dist = 0; - spid = 0; - - if ((shields > 0) && (shields < maxshields)) { - shields += 0.02; - } - - // Need to every couple of seconds check this - // with obj_en_ship if not big then disable, check nearest, and activate once more - if (instance_exists(obj_en_ship)) { - target = instance_nearest(x, y, obj_en_ship); - } - if (!instance_exists(target)) { - exit; - } // Check if ship is destroyed if (hp <= 0) { - gud = 0; for (var wh = 1; wh <= 5; wh++) { if (obj_fleet.enemy[wh] == owner) { gud = wh; @@ -161,10 +167,10 @@ if (owner != 6) { dist = point_distance(x, y, target.x, target.y) - max(sprite_get_width(sprite_index), sprite_get_height(sprite_index)); // For example here we could improve the options and how ships beheave... - if ((target != 0) && (action == "attack")) { + if ((target != noone) && (action == "attack")) { direction = turn_towards_point(direction, x, y, target.x, target.y, 0.1); } - if ((target != 0) && (action == "broadside") && (dist > o_dist)) { + if ((target != noone) && (action == "broadside") && (dist > o_dist)) { if (y >= target.y) { dist = point_distance(x, y, target.x + lengthdir_x(64, target.direction - 180), target.y + lengthdir_y(128, target.direction - 90)) - max(sprite_get_width(sprite_index), sprite_get_height(sprite_index)); } @@ -223,11 +229,7 @@ if (owner != 6) { turret_cool -= 1; } - targe = 0; - rdir = 0; dist = 9999; - xx = x; - yy = y; // Turret targetting if ((turrets > 0) && instance_exists(obj_en_in) && (turret_cool == 0)) { targe = instance_nearest(x, y, obj_en_in); @@ -248,10 +250,7 @@ if (owner != 6) { bull.direction += choose(random(10), 1 * -random(10)); } } - targe = 0; dist = 9999; - xx = lengthdir_x(64, direction + 90); - yy = lengthdir_y(64, direction + 90); // TODO we could implement facing with stronger shields or other stuff front = 0; @@ -259,8 +258,6 @@ if (owner != 6) { left = 0; rear = 0; - targe = instance_nearest(xx, yy, obj_en_ship); - rdir = point_direction(x, y, target.x, target.y); target_l = instance_nearest(x + lengthdir_x(64, direction + 90), y + lengthdir_y(64, direction + 90), obj_en_ship); target_r = instance_nearest(x + lengthdir_x(64, direction + 270), y + lengthdir_y(64, direction + 270), obj_en_ship); @@ -268,21 +265,14 @@ if (owner != 6) { front = 1; } - f = 0; - facing = ""; - ammo = 0; - range = 0; - wep = ""; - dam = 0; - for (var gg = 1; gg <= weapons; gg++) { // Resets ok = 0; - f += 1; facing = ""; ammo = 0; range = 0; wep = ""; + dam = 0; if ((cooldown[gg] <= 0) && (weapon[gg] != "") && (weapon_ammo[gg] > 0)) { ok = 1; @@ -293,7 +283,6 @@ if (owner != 6) { range = weapon_range[gg]; } - targe = target; if ((facing == "front") && (front == 1)) { ok = 2; } @@ -303,10 +292,7 @@ if (owner != 6) { if (facing == "special") { ok = 2; } - if (!instance_exists(targe)) { - exit; - } - dist = point_distance(x, y, targe.x, targe.y); + dist = point_distance(x, y, target.x, target.y); if ((facing == "right") && (point_direction(x, y, target_r.x, target_r.y) < 337) && (point_direction(x, y, target_r.x, target_r.y) > 203)) { ok = 2; } @@ -330,9 +316,6 @@ if (owner != 6) { bull = instance_create(x + lengthdir_x(32, direction), y + lengthdir_y(32, direction), obj_al_round); bull.speed = 20; bull.dam = dam; - if (targe == target) { - bull.direction = point_direction(x + lengthdir_x(32, direction), y + lengthdir_y(32, direction), target.x, target.y); - } if (facing != "front") { bull.direction = point_direction(x + lengthdir_x(32, direction), y + lengthdir_y(32, direction), target.x, target.y); } @@ -432,27 +415,8 @@ if (owner != 6) { } } // Checks if the enemy fleet is Eldar -if (owner == 6) { - image_angle = direction; - - if (obj_fleet.start != 5) { - exit; - } - - o_dist = 0; - spid = 0; - - if ((shields > 0) && (shields < maxshields)) { - shields += 0.03; - } - // Need to every couple of seconds check this - // with obj_en_ship if not big then disable, check nearest, and activate once more - if (instance_exists(obj_en_ship)) { - target = instance_nearest(x, y, obj_en_ship); - } - +if (owner == eFACTION.ELDAR) { if (hp <= 0) { - gud = 0; for (var wh = 1; wh <= 5; wh++) { if (obj_fleet.enemy[wh] == owner) { gud = wh; @@ -544,10 +508,7 @@ if (owner == 6) { turret_cool -= 1; } - targe = 0; dist = 9999; - xx = x; - yy = y; if ((turrets > 0) && instance_exists(obj_en_in) && (turret_cool == 0)) { targe = instance_nearest(x, y, obj_en_in); @@ -572,20 +533,13 @@ if (owner == 6) { bull.direction += choose(random(10), 1 * -random(10)); } } - targe = 0; - rdir = 0; dist = 9999; - xx = lengthdir_x(64, direction + 90); - yy = lengthdir_y(64, direction + 90); - front = 0; right = 0; left = 0; rear = 0; - targe = instance_nearest(xx, yy, obj_en_ship); - rdir = point_direction(x, y, target.x, target.y); target_l = instance_nearest(x + lengthdir_x(64, direction + 90), y + lengthdir_y(64, direction + 90), obj_en_ship); target_r = instance_nearest(x + lengthdir_x(64, direction + 270), y + lengthdir_y(64, direction + 270), obj_en_ship); @@ -593,20 +547,13 @@ if (owner == 6) { front = 1; } - f = 0; - facing = ""; - ammo = 0; - range = 0; - wep = ""; - dam = 0; - for (var gg = 1; gg <= weapons; gg++) { ok = 0; - f += 1; facing = ""; ammo = 0; range = 0; wep = ""; + dam = 0; if ((cooldown[gg] <= 0) && (weapon[gg] != "") && (weapon_ammo[gg] > 0)) { ok = 1; @@ -617,7 +564,6 @@ if (owner == 6) { range = weapon_range[gg]; } - targe = target; if ((facing == "front") && (front == 1)) { ok = 2; } @@ -627,10 +573,7 @@ if (owner == 6) { if (facing == "special") { ok = 2; } - if (!instance_exists(targe)) { - exit; - } - dist = point_distance(x, y, targe.x, targe.y); + dist = point_distance(x, y, target.x, target.y); if ((facing == "right") && (point_direction(x, y, target_r.x, target_r.y) < 337) && (point_direction(x, y, target_r.x, target_r.y) > 203)) { ok = 2; @@ -655,9 +598,6 @@ if (owner == 6) { bull = instance_create(x + lengthdir_x(32, direction), y + lengthdir_y(32, direction), obj_al_round); bull.speed = 20; bull.dam = dam; - if (targe == target) { - bull.direction = point_direction(x + lengthdir_x(32, direction), y + lengthdir_y(32, direction), target.x, target.y); - } if (facing != "front") { bull.direction = point_direction(x + lengthdir_x(32, direction), y + lengthdir_y(32, direction), target.x, target.y); } diff --git a/objects/obj_enunit/Alarm_0.gml b/objects/obj_enunit/Alarm_0.gml index 2ca388bb62..8c0b3809f7 100644 --- a/objects/obj_enunit/Alarm_0.gml +++ b/objects/obj_enunit/Alarm_0.gml @@ -56,7 +56,7 @@ if (!engaged) { var cm_present = false; var cm_index = -1; - var cm_block = false; + var cm_block = noone; with (obj_pnunit) { for (var u = 0; u < array_length(unit_struct); u++) { if (marine_type[u] == obj_ini.role[100][eROLE.CHAPTERMASTER]) { diff --git a/objects/obj_enunit/Create_0.gml b/objects/obj_enunit/Create_0.gml index c5d7de3fcf..8746fb2f92 100644 --- a/objects/obj_enunit/Create_0.gml +++ b/objects/obj_enunit/Create_0.gml @@ -1,4 +1,4 @@ -unit = ""; +unit = undefined; men = 0; veh = 0; dreads = 0; diff --git a/objects/obj_pnunit/Alarm_0.gml b/objects/obj_pnunit/Alarm_0.gml index 1c43c0829e..a104570622 100644 --- a/objects/obj_pnunit/Alarm_0.gml +++ b/objects/obj_pnunit/Alarm_0.gml @@ -81,6 +81,10 @@ try { instance_destroy(); } enemy = instance_nearest(0, y, obj_enunit); + if (!instance_exists(enemy)) { + engaged = false; + break; + } } if ((range[i] >= dist) && (ammo[i] != 0 || range[i] == 1)) { @@ -109,41 +113,41 @@ try { ap = 1; } - if (instance_exists(enemy)) { - if ((obj_enunit.veh > 0) && (obj_enunit.men == 0) && (apa[i] > 10)) { - ap = 1; - } - - if ((ap == 1) && (once_only == 0)) { - // Check for vehicles - var g = 0; + if ((obj_enunit.veh > 0) && (obj_enunit.men == 0) && (apa[i] > 10)) { + ap = 1; + } - if (enemy.veh > 0) { - good = scr_target(enemy, "veh"); // First target has vehicles, blow it to hell - scr_shoot(i, enemy, good, "arp", "ranged"); - } - if ((good == 0) && (instance_number(obj_enunit) > 1)) { - // First target does not have vehicles, cycle through objects to find one that has vehicles - var x2 = enemy.x; - repeat (instance_number(obj_enunit) - 1) { - if (good == 0) { - x2 += 10; - var enemy2 = instance_nearest(x2, y, obj_enunit); - if ((enemy2.veh > 0) && (good == 0)) { - good = scr_target(enemy2, "veh"); // This target has vehicles, blow it to hell - scr_shoot(i, enemy2, good, "arp", "ranged"); - once_only = 1; - } + if ((ap == 1) && (once_only == 0)) { + // Check for vehicles + if (enemy.veh > 0) { + good = scr_target(enemy, "veh"); // First target has vehicles, blow it to hell + scr_shoot(i, enemy, good, "arp", "ranged"); + } + if ((good == 0) && (instance_number(obj_enunit) > 1)) { + // First target does not have vehicles, cycle through objects to find one that has vehicles + var x2 = enemy.x; + repeat (instance_number(obj_enunit) - 1) { + if (good == 0) { + x2 += 10; + var enemy2 = instance_nearest(x2, y, obj_enunit); + if ((enemy2.veh > 0) && (good == 0)) { + good = scr_target(enemy2, "veh"); // This target has vehicles, blow it to hell + scr_shoot(i, enemy2, good, "arp", "ranged"); + once_only = 1; } } } - if (good == 0) { - ap = 0; - } // Fuck it, shoot at infantry + } + if (good == 0) { + ap = 0; + } // Fuck it, shoot at infantry + if (!instance_exists(enemy)) { + engaged = false; + continue; } } - if (instance_exists(enemy) && (once_only == 0)) { + if (once_only == 0) { if ((enemy.medi > 0) && (enemy.veh == 0)) { good = scr_target(enemy, "medi"); // First target has vehicles, blow it to hell scr_shoot(i, enemy, good, "medi", "ranged"); @@ -168,34 +172,39 @@ try { } // Next up is infantry // Was previously ap=1; } + if (!instance_exists(enemy)) { + engaged = false; + continue; + } } - if (instance_exists(enemy)) { - if ((ap == 0) && (once_only == 0)) { - // Check for men - var g = 0; - good = 0; + if ((ap == 0) && (once_only == 0)) { + // Check for men + good = 0; - if (enemy.men + enemy.medi > 0) { - good = scr_target(enemy, "men"); // First target has vehicles, blow it to hell - scr_shoot(i, enemy, good, "att", "ranged"); - } - if ((good == 0) && (instance_number(obj_enunit) > 1)) { - // First target does not have vehicles, cycle through objects to find one that has vehicles - var x2 = enemy.x; - repeat (instance_number(obj_enunit) - 1) { - if (good == 0) { - x2 += 10; - var enemy2 = instance_nearest(x2, y, obj_enunit); - if ((enemy2.men > 0) && (good == 0)) { - good = scr_target(enemy2, "men"); // This target has vehicles, blow it to hell - scr_shoot(i, enemy2, good, "att", "ranged"); - once_only = 1; - } + if (enemy.men + enemy.medi > 0) { + good = scr_target(enemy, "men"); // First target has vehicles, blow it to hell + scr_shoot(i, enemy, good, "att", "ranged"); + } + if ((good == 0) && (instance_number(obj_enunit) > 1)) { + // First target does not have vehicles, cycle through objects to find one that has vehicles + var x2 = enemy.x; + repeat (instance_number(obj_enunit) - 1) { + if (good == 0) { + x2 += 10; + var enemy2 = instance_nearest(x2, y, obj_enunit); + if ((enemy2.men > 0) && (good == 0)) { + good = scr_target(enemy2, "men"); // This target has vehicles, blow it to hell + scr_shoot(i, enemy2, good, "att", "ranged"); + once_only = 1; } } } } + if (!instance_exists(enemy)) { + engaged = false; + continue; + } } } else if ((range_shoot == "melee") && ((range[i] == 1) || (range[i] != floor(range[i])))) { // Weapon meets preliminary checks @@ -225,6 +234,10 @@ try { if ((good == 0) && (att[i] > 0)) { ap = 0; } // Fuck it, shoot at infantry + if (!instance_exists(enemy)) { + engaged = false; + continue; + } } if ((enemy.veh == 0) && (enemy.medi > 0) && (once_only == 0)) { @@ -243,11 +256,15 @@ try { if ((good == 0) && (att[i] > 0)) { ap = 0; } // Fuck it, shoot at infantry + if (!instance_exists(enemy)) { + engaged = false; + continue; + } } if ((ap == 0) && (once_only == 0)) { // Check for men - var g = 0, good = 0; + var good = 0; if ((enemy.men > 0) && (once_only == 0)) { good = scr_target(enemy, "men"); @@ -258,6 +275,10 @@ try { if (good != 0) { once_only = 1; } + if (!instance_exists(enemy)) { + engaged = false; + continue; + } } } } diff --git a/objects/obj_pnunit/Alarm_6.gml b/objects/obj_pnunit/Alarm_6.gml index a9a58d7f4f..62ac8b4e7f 100644 --- a/objects/obj_pnunit/Alarm_6.gml +++ b/objects/obj_pnunit/Alarm_6.gml @@ -1,6 +1,4 @@ -// -// Handles marines dying on battle -// +/// @description Handles marines dying on battle // Remove from ships // Remove from the controller @@ -23,7 +21,6 @@ for (var i = 0; i < array_length(unit_struct); i++) { if (unit.ship_location > -1) { obj_ini.ship_carrying[unit.ship_location] -= man_size; } - // scr_kill_unit(unit.company, unit.marine_number); } } diff --git a/objects/obj_pnunit/Create_0.gml b/objects/obj_pnunit/Create_0.gml index f484862cf1..aa333d8c0a 100644 --- a/objects/obj_pnunit/Create_0.gml +++ b/objects/obj_pnunit/Create_0.gml @@ -1,4 +1,4 @@ -unit = ""; +unit = undefined; men = 0; veh = 0; charge = 0; diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index 85cc1d2c8b..10aa52538b 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -131,23 +131,6 @@ ai_c = -1; ai_d = -1; ai_e = -1; -global.star_name_colors = [ - c_gray, - c_white, //player - c_gray, //imperium - c_red, // toaster fuckers - CM_GREEN_COLOR, //nothing for inquisition - c_white, //ecclesiarchy - #FF8000, //Hi, I'm Elfo - #009500, // waagh - #FECB01, // the greater good - #AD5272, // bug boys - c_dkgray, // chaos - CM_GREEN_COLOR, //nothing for heretics either - #AD5272, //why 12 is skipped in general, we will never know - #80FF00 // Sleepy robots -]; - #region save/load serialization /// Called from save function to take all object variables and convert them to a json savable format and return it diff --git a/scripts/__init/__init.gml b/scripts/__init/__init.gml index ba0c460a8f..3c87509a80 100644 --- a/scripts/__init/__init.gml +++ b/scripts/__init/__init.gml @@ -173,4 +173,31 @@ function __init() { global.name_generator = new NameGenerator(); global.star_sprites = ds_map_create(); global.base_component_surface = -1; + + global.force_strength_descriptions = [ + "None", + "Minimal", + "Sparse", + "Moderate", + "Numerous", + "Very Numerous", + "Overwhelming", + ]; + + global.star_name_colors = [ + c_gray, + c_white, // Player + c_gray, // Imperium + c_red, // Mechanicus + CM_GREEN_COLOR, // Inquisition (Default) + c_white, // Ecclesiarchy + #FF8000, // Eldar + #009500, // Orks + #FECB01, // Tau + #AD5272, // Tyranids + c_dkgray, // Chaos + CM_GREEN_COLOR, // Heretics (Default) + #AD5272, // why 12 is skipped in general, we will never know + #80FF00 // Necrons + ]; } diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index 053569d7b4..d711546c6d 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -1,13 +1,3 @@ -global.force_strength_descriptions = [ - "none", - "Minimal", - "Sparse", - "Moderate", - "Numerous", - "Very Numerous", - "Overwhelming", -]; - /// @param {Real} _planet /// @param {Id.Instance.obj_star} _system function PlanetData(_planet, _system) constructor { diff --git a/scripts/scr_culture_visuals/scr_culture_visuals.gml b/scripts/scr_culture_visuals/scr_culture_visuals.gml index 465c41a459..5eeb441fa3 100644 --- a/scripts/scr_culture_visuals/scr_culture_visuals.gml +++ b/scripts/scr_culture_visuals/scr_culture_visuals.gml @@ -1553,12 +1553,6 @@ global.modular_drawing_items = [ sprite: spr_cata_shoulder_hanging_leather_right, body_types: [2], armours: ["Cataphractii"], - subcomponents: [ - [ - spr_blank, - spr_cata_shoulder_hanging_leather_right_tips - ] - ], overides: { "left_pauldron_embeleshments": spr_cata_shoulder_hanging_leather_left, "tabbard": spr_cata_tabbard_leather,