diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index bdd1e3318e..79fe03c2e5 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -522,6 +522,10 @@ {"$GMIncludedFile":"","%Name":"purge8.png","CopyToMask":-1,"filePath":"datafiles/images/ui","name":"purge8.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"raid1.png","CopyToMask":-1,"filePath":"datafiles/images/ui","name":"raid1.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"resources.png","CopyToMask":-1,"filePath":"datafiles/images/ui","name":"resources.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, + {"$GMIncludedFile":"","%Name":"guardsman.png","CopyToMask":-1,"filePath":"datafiles/images/units","name":"guardsman.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, + {"$GMIncludedFile":"","%Name":"Guardsman.png","CopyToMask":-1,"filePath":"datafiles/images/units","name":"Guardsman.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, + {"$GMIncludedFile":"","%Name":"sarge.png","CopyToMask":-1,"filePath":"datafiles/images/units","name":"sarge.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, + {"$GMIncludedFile":"","%Name":"Sarge.png","CopyToMask":-1,"filePath":"datafiles/images/units","name":"Sarge.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"chapter_advantages.json","CopyToMask":-1,"filePath":"datafiles/main","name":"chapter_advantages.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"chapter_disadvantages.json","CopyToMask":-1,"filePath":"datafiles/main","name":"chapter_disadvantages.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"pauldron.png","CopyToMask":-1,"filePath":"datafiles/main/chapter_symbols/darkangels","name":"pauldron.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, @@ -604,7 +608,7 @@ "isEcma":false, "LibraryEmitters":[], "MetaData":{ - "IDEVersion":"2024.1400.5.1065", + "IDEVersion":"2026.0.0.16", }, "name":"ChapterMaster", "resources":[ diff --git a/datafiles/data/armour.json b/datafiles/data/armour.json index b591e3cbd4..0504ce9e46 100644 --- a/datafiles/data/armour.json +++ b/datafiles/data/armour.json @@ -172,6 +172,37 @@ }, "description": "This armour is used by T'au fire warriors." }, + "Flak Armour": { + "abbreviation": "FlkArm", + "armour_value": { + "artifact": 12, + "master_crafted": 11, + "standard": 10 + }, + "damage_resistance_mod": { + "artifact": 0, + "master_crafted": 0, + "standard": 0 + }, + "description": "A simple flak jacket of ablative plates and ballistic weave, the standard protection of the Astra Militarum rank and file. It turns aside shrapnel and glancing hits but offers little against a determined blow.", + "hp_mod": { + "artifact": 0, + "master_crafted": 0, + "standard": 0 + }, + "melee_mod": { + "artifact": 0, + "master_crafted": 0, + "standard": 0 + }, + "ranged_mod": { + "artifact": 10, + "master_crafted": 8, + "standard": 5 + }, + "renegade_buy": true, + "value": 2 + }, "Light Power Armour": { "abbreviation": "LPwrArm", "armour_value": { diff --git a/datafiles/data/gear.json b/datafiles/data/gear.json index cc769254d8..ee0c3bfdeb 100644 --- a/datafiles/data/gear.json +++ b/datafiles/data/gear.json @@ -41,6 +41,7 @@ "Gene Pod Incubator": { "abbreviation": "GenePod", "description": "Required to house gene slaves in order to generate new gene seed for the chapter.", + "tags":["no_equip"], "value": 20 }, "Iron Halo": { diff --git a/datafiles/data/unit_stats.json b/datafiles/data/unit_stats.json index a8ad115cf7..b7d3d04977 100644 --- a/datafiles/data/unit_stats.json +++ b/datafiles/data/unit_stats.json @@ -581,6 +581,222 @@ 1 ] }, + "guard_squad": { + "ballistic_skill": [ + 25, + 1 + ], + "base_group": "human", + "charisma": [ + 15, + 1 + ], + "constitution": [ + 28, + 1, + "max" + ], + "dexterity": [ + 20, + 1 + ], + "intelligence": [ + 15, + 1 + ], + "luck": 5, + "piety": [ + 25, + 1 + ], + "religion": "imperial_cult", + "start_gear": { + "armour": "Flak Armour", + "gear": "", + "mobi": "", + "wep1": "Lasgun", + "wep2": "Bayonet" + }, + "strength": [ + 20, + 1 + ], + "technology": [ + 10, + 1 + ], + "title": "Guard Squad", + "weapon_skill": [ + 15, + 1 + ], + "wisdom": [ + 15, + 1 + ] + }, + "guardsman": { + "ballistic_skill": [ + 25, + 6 + ], + "base_group": "human", + "charisma": [ + 15, + 1 + ], + "constitution": [ + 28, + 1, + "max" + ], + "dexterity": [ + 20, + 1 + ], + "intelligence": [ + 15, + 1 + ], + "luck": 5, + "piety": [ + 25, + 1 + ], + "religion": "imperial_cult", + "start_gear": { + "armour": "Flak Armour", + "gear": "", + "mobi": "", + "wep1": "Lasgun", + "wep2": "Bayonet" + }, + "strength": [ + 20, + 1 + ], + "technology": [ + 10, + 1 + ], + "title": "Guardsman", + "weapon_skill": [ + 15, + 1 + ], + "wisdom": [ + 15, + 1 + ] + }, + "heavy_weapons_team": { + "ballistic_skill": [ + 28, + 4 + ], + "base_group": "human", + "charisma": [ + 15, + 1 + ], + "constitution": [ + 28, + 1, + "max" + ], + "dexterity": [ + 20, + 1 + ], + "intelligence": [ + 15, + 1 + ], + "luck": 5, + "piety": [ + 25, + 1 + ], + "religion": "imperial_cult", + "start_gear": { + "armour": "Flak Armour", + "gear": "", + "mobi": "", + "wep1": "Heavy Bolter", + "wep2": "" + }, + "strength": [ + 22, + 1 + ], + "technology": [ + 10, + 1 + ], + "title": "Heavy Weapons Team", + "weapon_skill": [ + 15, + 1 + ], + "wisdom": [ + 15, + 1 + ] + }, + "guard_sergeant": { + "ballistic_skill": [ + 20, + 6 + ], + "base_group": "human", + "charisma": [ + 18, + 1 + ], + "constitution": [ + 34, + 1, + "max" + ], + "dexterity": [ + 24, + 1 + ], + "intelligence": [ + 18, + 1 + ], + "luck": 6, + "piety": [ + 30, + 1 + ], + "religion": "imperial_cult", + "start_gear": { + "armour": "Flak Armour", + "gear": "", + "mobi": "", + "wep1": "Guard Chainsword", + "wep2": "Laspistol" + }, + "strength": [ + 24, + 1 + ], + "technology": [ + 12, + 1 + ], + "title": "Guard Sergeant", + "weapon_skill": [ + 18, + 1 + ], + "wisdom": [ + 18, + 1 + ] + }, "skitarii": { "ballistic_skill": [ 20, diff --git a/datafiles/data/weapons.json b/datafiles/data/weapons.json index a570b6efeb..f4a3054d91 100644 --- a/datafiles/data/weapons.json +++ b/datafiles/data/weapons.json @@ -121,6 +121,50 @@ ], "value": 30 }, + "Earthshaker Cannon": { + "abbreviation": "Erthshk", + "ammo": 8, + "arp": 3, + "attack": { + "artifact": 1050, + "master_crafted": 850, + "standard": 700 + }, + "description": "The Earthshaker is the thunderous main gun of the Basilisk self-propelled artillery. It lobs enormous high-explosive shells in a high arc onto distant formations, shattering massed infantry and light armour from well beyond the firing line.", + "melee_hands": 0, + "range": 24, + "ranged_hands": 0, + "spli": 12, + "tags": [ + "vehicle", + "heavy_ranged", + "explosive", + "turret" + ], + "value": 45 + }, + "Battle Cannon": { + "abbreviation": "BtlCnn", + "ammo": 12, + "arp": 4, + "attack": { + "artifact": 1000, + "master_crafted": 800, + "standard": 650 + }, + "description": "The main armament of the Leman Russ battle tank. A high-calibre cannon firing massive shells that crack armour and scatter massed infantry alike, the versatile mainstay of Astra Militarum armoured companies.", + "melee_hands": 0, + "range": 18, + "ranged_hands": 0, + "spli": 8, + "tags": [ + "vehicle", + "heavy_ranged", + "explosive", + "turret" + ], + "value": 40 + }, "Boarding Shield": { "abbreviation": "BrdShld", "armour_value": { @@ -314,6 +358,28 @@ ], "value": 4 }, + "Guard Chainsword": { + "abbreviation": "GdChSw", + "ammo": 0, + "arp": 1, + "attack": { + "artifact": 190, + "master_crafted": 150, + "standard": 120 + }, + "description": "A mass-produced chainsword issued to Astra Militarum officers and sergeants. Cruder and less potent than an Astartes blade, but a brutal close-quarters weapon in a guardsman's hands.", + "melee_hands": 1, + "range": 1, + "ranged_hands": 0, + "spli": 4, + "tags": [ + "chain", + "sword", + "savage", + "boarding 1" + ], + "value": 3 + }, "Choppa": { "abbreviation": "Chop", "attack": { @@ -352,6 +418,25 @@ ], "value": 45 }, + "Bayonet": { + "abbreviation": "Bynt", + "ammo": 0, + "arp": 1, + "attack": { + "artifact": 22, + "master_crafted": 20, + "standard": 18 + }, + "description": "A short blade clamped to the muzzle of a lasgun. It gives a Guardsman something to thrust with when the foe closes, but against anything tougher than a grot it is little more than a desperate inconvenience.", + "melee_hands": 0, + "range": 1, + "ranged_hands": 0, + "spli": 0, + "tags": [ + "knife" + ], + "value": 1 + }, "Combat Knife": { "abbreviation": "CbKnf", "ammo": 0, @@ -1259,7 +1344,8 @@ "ranged_hands": 1, "spli": 3, "tags": [ - "las" + "las", + "veteran_guard_only" ] }, "Hellrifle": { @@ -1610,6 +1696,25 @@ ], "value": 15 }, + "Lasgun": { + "abbreviation": "Lasgun", + "ammo": 40, + "arp": 1, + "attack": { + "artifact": 130, + "master_crafted": 110, + "standard": 60 + }, + "description": "The standard-issue weapon of the Astra Militarum. A rugged two-handed las weapon firing coherent energy beams, prized for its reliability and the ease of recharging its power packs in the field. Common, dependable, and unremarkable on its own.", + "melee_hands": 0, + "range": 12, + "ranged_hands": 1, + "spli": 1, + "tags": [ + "las" + ], + "value": 2 + }, "Laspistol": { "abbreviation": "Lpstl", "ammo": 30, @@ -1814,6 +1919,28 @@ ], "value": 70 }, + "Multi-Laser": { + "abbreviation": "MultiLas", + "ammo": 30, + "arp": 2, + "attack": { + "artifact": 220, + "master_crafted": 180, + "standard": 150 + }, + "description": "A rapid-firing laser array mounted on light Imperial vehicles such as the Chimera. Pours volley after volley of coherent energy into massed infantry and light targets.", + "melee_hands": 0, + "range": 10, + "ranged_hands": 0, + "spli": 6, + "tags": [ + "vehicle", + "heavy_ranged", + "las", + "turret" + ], + "value": 20 + }, "Multi-Melta": { "abbreviation": "MltMelt", "ammo": 8, @@ -3295,4 +3422,4 @@ "xenos" ] } -} \ No newline at end of file +} diff --git a/datafiles/images/units/Sarge.png b/datafiles/images/units/Sarge.png new file mode 100644 index 0000000000..20ffb0db55 Binary files /dev/null and b/datafiles/images/units/Sarge.png differ diff --git a/datafiles/images/units/guardsman.png b/datafiles/images/units/guardsman.png new file mode 100644 index 0000000000..59ac96dbf5 Binary files /dev/null and b/datafiles/images/units/guardsman.png differ diff --git a/datafiles/main/chapters/36.json b/datafiles/main/chapters/36.json index 8ab38f9e81..234df44b14 100644 --- a/datafiles/main/chapters/36.json +++ b/datafiles/main/chapters/36.json @@ -119,11 +119,11 @@ "ossmodula": 0, "membrane": 0, "zygote": 0, - "betchers": 0, + "betchers": 1, "catalepsean": 0, "secretions": 0, "occulobe": 0, - "mucranoid": 1 + "mucranoid": 0 }, "disposition": [ 0, // nothing diff --git a/objects/obj_al_ship/Alarm_0.gml b/objects/obj_al_ship/Alarm_0.gml index e280bbb35b..78c3323c3a 100644 --- a/objects/obj_al_ship/Alarm_0.gml +++ b/objects/obj_al_ship/Alarm_0.gml @@ -876,8 +876,4 @@ if (owner != eFACTION.ELDAR) { shields = shields / 2; maxshields = shields; } -// if (obj_fleet.enemy=2){hp=hp*0.75;maxhp=hp;shields=shields*0.75;maxshields=shields;} -// hp=1;shields=1; -// if (obj_fleet.enemy="orks") then name=global.name_generator.GenerateFromSet("ork_ship"); name = "sdagdsagdasg"; -// show_message(string(class)); diff --git a/objects/obj_al_ship/Create_0.gml b/objects/obj_al_ship/Create_0.gml index 3b3ccd9bad..0b21ad38bb 100644 --- a/objects/obj_al_ship/Create_0.gml +++ b/objects/obj_al_ship/Create_0.gml @@ -3,8 +3,8 @@ ship_id = 0; action = ""; direction = 0; -/// @type {Asset.GMObject.obj_en_ship} -target = -50; +/// @type {Id.Instance.obj_en_ship} +target = noone; if (instance_exists(obj_en_ship)) { target = instance_nearest(x, y, obj_en_ship); } @@ -34,6 +34,11 @@ fighters = 0; bombers = 0; thunderhawks = 0; +capacity = 0; +carrying = 0; +leadership = 0; +ship_size = 0; + weapon = array_create(SHIP_WEAPON_SLOTS, ""); weapon_facing = array_create(SHIP_WEAPON_SLOTS, ""); weapon_cooldown = array_create(SHIP_WEAPON_SLOTS, 0); diff --git a/objects/obj_al_ship/Step_0.gml b/objects/obj_al_ship/Step_0.gml index d175fa43de..1155fe63a5 100644 --- a/objects/obj_al_ship/Step_0.gml +++ b/objects/obj_al_ship/Step_0.gml @@ -5,8 +5,6 @@ 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; -var husk; -var explo; if (owner != 6) { image_angle = direction; @@ -60,14 +58,14 @@ if (owner != 6) { image_alpha = 0.5; if (owner != eFACTION.TYRANIDS) { - husk = instance_create(x, y, obj_en_husk); + var husk = instance_create(x, y, obj_en_husk); husk.sprite_index = sprite_index; husk.direction = direction; husk.image_angle = image_angle; husk.depth = depth; husk.image_speed = 0; for (var i = 0; i < choose(4, 5, 6); i++) { - explo = instance_create(x, y, obj_explosion); + var explo = instance_create(x, y, obj_explosion); explo.image_xscale = 0.5; explo.image_yscale = 0.5; explo.x += random_range(sprite_width * 0.25, sprite_width * -0.25); @@ -185,29 +183,6 @@ if (owner != 6) { } } } - /*if (target!=0) and (action="broadside") and (o_dist>=dist){ - direction=turn_towards_point(direction,x+lengthdir_x(128,target.direction-90),y,target.x,target.y+lengthdir_y(128,target.direction-90),.2) - }*/ - /*if (target!=0) and (action="broadside") and (o_dist>=dist){ - var re_deh;re_deh=relative_direction(direction,target.direction); - // if (re_deh<45) or (re_deh>315) or ((re_deh>135) and (re_deh<225)) then direction=turn_towards_point(direction,x+lengthdir_x(128,target.direction-90),y,target.x,target.y+lengthdir_y(128,target.direction-90),.2) - var wok; - wok=0; - if (!instance_exists(target_l)) then wok=2; - if (!instance_exists(target_r)) then wok=1; - if (instance_exists(target_l)) and (instance_exists(target_r)){ - if (point_distance(x,y,target_l.x,target_l.y))<(point_distance(x,y,target_r.x,target_r.y)) then wok=1; - else{wok=2;} - - } - if (wok=1){ - direction=turn_towards_point(direction,x,y,x+lengthdir_x(256,90),y+lengthdir_y(256,90),.2) - } - if (wok=2){ - direction=turn_towards_point(direction,x,y,x+lengthdir_x(256,270),y+lengthdir_y(256,270),.2) - } - // direction=turn_towards_point(direction,x+lengthdir_x(128,target.direction-90),y,target.x,target.y+lengthdir_y(128,target.direction-90),.2) - }*/ // Controls speed based on action if (action == "attack") { if ((dist > o_dist) && (speed < (spid / 10))) { @@ -286,8 +261,6 @@ if (owner != 6) { targe = instance_nearest(xx, yy, obj_en_ship); rdir = point_direction(x, y, target.x, target.y); - // if (rdir>45) and (rdir<=135) and (targe!=target){target_r=targe;right=1;} - // if (rdir>225) and (rdir<=315) and (targe!=target) and (targe!=target_r){target_l=targe;left=1;} 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); @@ -327,13 +300,6 @@ if (owner != 6) { if (facing == "most") { ok = 2; } - /* - if (facing="right") then targe=target_r; - if (facing="left") then targe=target_l; - if ((facing="front") or (facing="most")) and (front=1) then ok=2; - if (facing="right") or (facing="most") and (right=1) then ok=2; - if (facing="left") or (facing="most") and (left=1) then ok=2; - */ if (facing == "special") { ok = 2; } @@ -347,9 +313,6 @@ if (owner != 6) { if ((facing == "left") && (point_direction(x, y, target_r.x, target_r.y) > 22) && (point_direction(x, y, target_r.x, target_r.y) < 157)) { ok = 2; } - /*var re_deh;re_deh=relative_direction(direction,target.direction); - if (re_deh<45) or (re_deh>315) or ((re_deh>135) and (re_deh<225)) then direction=turn_towards_point(direction,x+lengthdir_x(128,target.direction-90),y,target.x,target.y+lengthdir_y(128,target.direction-90),.2) - */ if ((ok == 2) && (dist < (range + max(sprite_get_width(sprite_index), sprite_get_height(sprite_index))))) { if ((ammo > 0) && (ammo < 900)) { ammo -= 1; @@ -358,7 +321,6 @@ if (owner != 6) { cooldown[gg] = weapon_cooldown[gg]; wep = weapon[gg]; dam = weapon_dam[gg]; - // if (f=3) and (ship_id=2) then show_message("ammo: "+string(ammo)+" | range: "+string(range)); if (ammo < 0) { ok = 0; } @@ -509,7 +471,7 @@ if (owner == 6) { image_alpha = 0.5; - husk = instance_create(x, y, obj_en_husk); + var husk = instance_create(x, y, obj_en_husk); husk.sprite_index = sprite_index; husk.direction = direction; husk.image_angle = image_angle; @@ -517,7 +479,7 @@ if (owner == 6) { husk.image_speed = 0; for (var i = 0; i < choose(4, 5, 6); i++) { - explo = instance_create(x, y, obj_explosion); + var explo = instance_create(x, y, obj_explosion); explo.image_xscale = 0.5; explo.image_yscale = 0.5; explo.x += random_range(sprite_width * 0.25, sprite_width * -0.25); @@ -624,8 +586,6 @@ if (owner == 6) { targe = instance_nearest(xx, yy, obj_en_ship); rdir = point_direction(x, y, target.x, target.y); - // if (rdir>45) and (rdir<=135) and (targe!=target){target_r=targe;right=1;} - // if (rdir>225) and (rdir<=315) and (targe!=target) and (targe!=target_r){target_l=targe;left=1;} 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); @@ -639,7 +599,6 @@ if (owner == 6) { range = 0; wep = ""; dam = 0; - gg = 0; for (var gg = 1; gg <= weapons; gg++) { ok = 0; @@ -665,13 +624,6 @@ if (owner == 6) { if (facing == "most") { ok = 2; } - /* - if (facing="right") then targe=target_r; - if (facing="left") then targe=target_l; - if ((facing="front") or (facing="most")) and (front=1) then ok=2; - if (facing="right") or (facing="most") and (right=1) then ok=2; - if (facing="left") or (facing="most") and (left=1) then ok=2; - */ if (facing == "special") { ok = 2; } @@ -686,10 +638,6 @@ if (owner == 6) { if ((facing == "left") && (point_direction(x, y, target_r.x, target_r.y) > 22) && (point_direction(x, y, target_r.x, target_r.y) < 157)) { ok = 2; } - /* - var re_deh;re_deh=relative_direction(direction,target.direction); - if (re_deh<45) or (re_deh>315) or ((re_deh>135) and (re_deh<225)) then direction=turn_towards_point(direction,x+lengthdir_x(128,target.direction-90),y,target.x,target.y+lengthdir_y(128,target.direction-90),.2) - */ if ((ok == 2) && (dist < (range + max(sprite_get_width(sprite_index), sprite_get_height(sprite_index))))) { if ((ammo > 0) && (ammo < 900)) { ammo -= 1; @@ -698,7 +646,6 @@ if (owner == 6) { cooldown[gg] = weapon_cooldown[gg]; wep = weapon[gg]; dam = weapon_dam[gg]; - // if (f=3) and (ship_id=2) then show_message("ammo: "+string(ammo)+" | range: "+string(range)); if (ammo < 0) { ok = 0; } diff --git a/objects/obj_bomb_select/Draw_0.gml b/objects/obj_bomb_select/Draw_0.gml index 0850d58e03..5ff3d97ced 100644 --- a/objects/obj_bomb_select/Draw_0.gml +++ b/objects/obj_bomb_select/Draw_0.gml @@ -37,13 +37,12 @@ if ((max_ships > 0) && instance_exists(obj_star_select)) { draw_text_transformed(bomb_window.x1 + 18, bomb_window.y1 + 30, "Initializing Bombardment...", 0.8, 0.8, 0); // Target info - var _total_hers, _influ; draw_set_font(fnt_info); draw_text_bold(bomb_window.x1 + 20, bomb_window.y1 + 70, $"Target planet: {p_data.name()}"); - _total_hers = p_data.corruption + p_data.secret_corruption; - - _influ = p_data.population_influences; + var _total_hers = p_data.corruption + p_data.secret_corruption; + var str = 0; + var _influ = p_data.population_influences; var population_string = $"Population: {p_data.display_population()} people"; draw_text_bold(bomb_window.x1 + 20, bomb_window.y1 + 90, population_string); @@ -91,7 +90,7 @@ if ((max_ships > 0) && instance_exists(obj_star_select)) { break; } - var str = 0, str_string = ""; + var str_string = ""; // TODO a centralised point to be able to fetch display names from factions identifying number str = floor(p_data.planet_forces[target]); if (target == 2.5) { @@ -150,8 +149,7 @@ if ((max_ships > 0) && instance_exists(obj_star_select)) { // Total selection number draw_set_halign(fa_left); draw_set_font(fnt_info); - var sel = ""; - sel = ships_selected; + var sel = ships_selected; var curr_sel_string = $"Current Selection: {sel} ships"; draw_text_bold(bomb_window.x1 + 20, bomb_window.y2 - 28, curr_sel_string); diff --git a/objects/obj_controller/Alarm_1.gml b/objects/obj_controller/Alarm_1.gml index 0c5b7673d7..ec35ac28aa 100644 --- a/objects/obj_controller/Alarm_1.gml +++ b/objects/obj_controller/Alarm_1.gml @@ -8,9 +8,7 @@ instance_activate_all(); // Lots of damn tyranids // Some damn orks and a few genestealer cults -var field = ""; - -field = "both"; //("orks","tyranids","both"); +var field = "both"; // "orks", "tyranids", "both" if (global.chapter_name == "Lamenters") { field = "both"; } @@ -20,7 +18,7 @@ if (is_test_map == true) { good_log = 1; -var xx, yy, ok = 0, did = 0, _current_system = 0, px = 0, py = 0, rando = 0; +var xx, yy, did = 0, _current_system = 0, px = 0, py = 0; // Set player set _current_system = find_player_spawn_star(); @@ -102,16 +100,6 @@ if (did) { _current_system.image_index = 4; _current_system.p_type[1] = "Forge"; _current_system.p_type[2] = "Ice"; - /* - _current_system.p_owner[1]=3; - _current_system.p_owner[2]=3; - _current_system.p_owner[3]=3; - _current_system.p_owner[4]=3; - _current_system.p_first[1]=3; - _current_system.p_first[2]=3; - _current_system.p_first[3]=3; - _current_system.p_first[4]=3; - */ _current_system.owner = eFACTION.MECHANICUS; _current_system.p_owner = array_create(5, _current_system.owner); _current_system.p_first = array_create(5, _current_system.owner); @@ -121,7 +109,6 @@ if (did) { } with (_current_system) { - // with _current_system var a = 99, b = 99, c = 99, d = 99, e = "", f = 0; for (var i = 0; i < 10; i++) { e = p_type[1]; @@ -280,8 +267,6 @@ if (did) { } } // end with _current_system - // _current_system.explored=1; - repeat (6) { instance_deactivate_object(instance_nearest(xx, yy, obj_star)); } @@ -326,7 +311,6 @@ if (did) { var tau_start_size = irandom(4) + 5; for (var i = 0; i <= tau_start_size; i++) { - rando = 1; _current_system = instance_nearest(xx, yy, obj_star); with (_current_system) { if ((planets > 0) && (_current_system.p_type[1] != "Dead") && (_current_system.owner == eFACTION.IMPERIUM)) { @@ -368,7 +352,7 @@ if (did) { ]; with (obj_star) { if (array_contains(hell_holes, name)) { - rando = choose(1, 1); // make 1's 0's if you want less chaos + var rando = choose(1, 1); // make 1's 0's if you want less chaos if (rando == 1) { owner = eFACTION.CHAOS; p_owner = array_create(5, owner); @@ -411,7 +395,6 @@ if (did) { if (field == "both") { orkz += 15; } - /*if (obj_ini.fleet_type==ePLAYER_BASE.PENITENT) then orkz+=2;*/ if (is_test_map == true) { orkz = 4; } @@ -514,7 +497,7 @@ for (var i = 0; i < 100; i++) { if (point_distance(room_width / 2, room_height / 2, xx, yy) >= 50) { go = 1; } - me = instance_nearest(xx, yy, obj_star); + var me = instance_nearest(xx, yy, obj_star); if ((go == 1) && (point_distance(me.x, me.y, xx, yy) >= 150)) { go = 2; } @@ -582,41 +565,6 @@ with (obj_creation) { create_complex_star_routes(_player_star.id); -/* //135 testing crusade object -instance_create(x,y,obj_crusade); -obj_crusade.placing=1;scr_zoom();*/ - -// 135 ; testing artifacts with combat -// argument0 : type -// argument1 : tags -// argument2 : identified -// argument3: location -// argument4: sid - -// scr_add_artifact("Weapon","",4,obj_ini.home_name,1); - -/*scr_add_artifact("good","daemonic",0,obj_ini.ship[0],501); -scr_add_artifact("good","daemonic",0,obj_ini.ship[0],501); -scr_add_artifact("good","daemonic",0,obj_ini.ship[0],501); -scr_add_artifact("good","daemonic",0,obj_ini.ship[0],501); -scr_add_artifact("good","daemonic",0,obj_ini.ship[0],501); -scr_add_artifact("good","daemonic",0,obj_ini.ship[0],501); -scr_add_artifact("good","daemonic",0,obj_ini.ship[0],501);*/ - -// scr_add_item("Cyclonic Torpedo",5); -// scr_add_item("Exterminatus",5); - -if (is_test_map == true) { - // scr_add_item("Exterminatus",5); - /*scr_add_artifact("good","",0,obj_ini.ship[0],501); - scr_add_artifact("good","",0,obj_ini.ship[0],501); - scr_add_artifact("good","",0,obj_ini.ship[0],501); - scr_add_artifact("good","",0,obj_ini.ship[0],501); - scr_add_artifact("good","",0,obj_ini.ship[0],501); - scr_add_artifact("good","",0,obj_ini.ship[0],501); - scr_add_artifact("good","",0,obj_ini.ship[0],501);*/ -} - with (obj_temp7) { instance_destroy(); } @@ -635,10 +583,6 @@ if (instance_exists(obj_temp7)) { } } -/*with(obj_star){ - scr_star_ownership(false); -}*/ - // Save immediately after world gen if (global.load == -1 && global.settings.autosave == true) { alarm[2] = 5; diff --git a/objects/obj_controller/Alarm_5.gml b/objects/obj_controller/Alarm_5.gml index e68d7e6c36..7444a45fc7 100644 --- a/objects/obj_controller/Alarm_5.gml +++ b/objects/obj_controller/Alarm_5.gml @@ -340,7 +340,7 @@ try { } with (_stars[i]) { if (owner == eFACTION.IMPERIUM && planets) { - if (scr_orbiting_fleet(eFACTION.IMPERIUM) != "none") { + if (scr_orbiting_fleet(eFACTION.IMPERIUM) != noone) { _star_found = true; _choice_star = self.id; break; diff --git a/objects/obj_controller/Alarm_8.gml b/objects/obj_controller/Alarm_8.gml index 53a8aa9f8c..446741deec 100644 --- a/objects/obj_controller/Alarm_8.gml +++ b/objects/obj_controller/Alarm_8.gml @@ -20,22 +20,12 @@ with (obj_star) { heh.show = false; heh.placing = false; heh.alarm[1] = -1; - if (p_owner[1] == 1) { - p_pdf[1] += p_guardsmen[1]; - p_guardsmen[1] = 0; - } - if (p_owner[2] == 1) { - p_pdf[2] += p_guardsmen[2]; - p_guardsmen[2] = 0; - } - if (p_owner[3] == 1) { - p_pdf[3] += p_guardsmen[3]; - p_guardsmen[3] = 0; - } - if (p_owner[4] == 1) { - p_pdf[4] += p_guardsmen[4]; - p_guardsmen[4] = 0; - } + // The Guard-into-PDF fold was removed here. It used to run, every turn, for + // each player world: p_pdf += p_guardsmen; p_guardsmen = 0. That quietly ate the + // Imperial Guard you raise and deploy, folding them back into the abstract PDF and + // zeroing the deployable pool. Recruited Guard now persist as their own pool until + // you embark them, and recruitment pulls bodies the other way (PDF into Guard), so + // folding them back would undo it. } } diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index f1b8d3ccf4..42e9be7f2d 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -101,6 +101,7 @@ unit_manage_constants = {}; unit_manage_constants.current_data = ""; management_buttons = false; +diplo_buttons = {}; diplomacy_pathway = ""; option_selections = []; ready = false; @@ -804,9 +805,6 @@ trade_attempt = false; // ** Sets income ** income = 0; income_last = 0; -/*income-=obj_ini.battle_barges; -income-=obj_ini.strike_cruisers/2; -income-=(obj_ini.gladius+obj_ini.hunters)/10;*/ income_base = 0; income_home = 0; income_forge = 0; diff --git a/objects/obj_controller/Draw_0.gml b/objects/obj_controller/Draw_0.gml index 014492f1d9..d1f05f535d 100644 --- a/objects/obj_controller/Draw_0.gml +++ b/objects/obj_controller/Draw_0.gml @@ -4,9 +4,6 @@ try { scr_ui_advisors(); scr_ui_tooltip(); if (menu == eMENU.DIPLOMACY) { - /*if (audience > 0 && instance_exists(obj_turn_end)){ - menu = 20; - }*/ scr_ui_diplomacy(); } if (menu == eMENU.SECRET_LAIR) { diff --git a/objects/obj_controller/Draw_64.gml b/objects/obj_controller/Draw_64.gml index 96f77dc779..83f1318404 100644 --- a/objects/obj_controller/Draw_64.gml +++ b/objects/obj_controller/Draw_64.gml @@ -40,7 +40,6 @@ try { menu = eMENU.DEFAULT; } -// if (instance_exists(obj_turn_end)) then exit; draw_set_alpha(1); draw_set_valign(fa_top); draw_set_halign(fa_left); diff --git a/objects/obj_controller/KeyPress_13.gml b/objects/obj_controller/KeyPress_13.gml index f308c78a21..e69de29bb2 100644 --- a/objects/obj_controller/KeyPress_13.gml +++ b/objects/obj_controller/KeyPress_13.gml @@ -1,9 +0,0 @@ -/*var onceh;onceh=0; -if (new_buttons_hide=0) and (onceh=0){onceh=1;new_buttons_hide=1;} -if (new_buttons_hide=1) and (onceh=0){onceh=1;new_buttons_hide=0;} -*/ - -// scr_gov_disp("Ariana Prime",1,choose(1,2,3,4,5)); - -/* */ -/* */ diff --git a/objects/obj_controller/KeyPress_73.gml b/objects/obj_controller/KeyPress_73.gml index 876a6afc51..e69de29bb2 100644 --- a/objects/obj_controller/KeyPress_73.gml +++ b/objects/obj_controller/KeyPress_73.gml @@ -1,35 +0,0 @@ -/*var onceh;onceh=0; -if (audio_is_playing(snd_royal)=true) then scr_music("blood",2000); -if (audio_is_playing(snd_blood)=true) then scr_music("royal",2000); -*/ - -/*menu=20;diplomacy=10.1; -scr_dialogue("lol"); -*/ - -// alarm[7]=1; - -/*with(obj_star){ - var balh;balh=0; - if (string_count("WL10",p_feature[1])>0) then balh=1; - if (string_count("WL10",p_feature[2])>0) then balh=2; - if (string_count("WL10",p_feature[3])>0) then balh=3; - if (string_count("WL10",p_feature[4])>0) then balh=4; - if (balh>0) then show_message(string(name)+" "+scr_roman(balh)); -}*/ - -// loyalty=0;loyalty_hidden=0; - -// show_message(string(obj_ini.ship[0])+" location: "+string(obj_ini.ship_location[0])); - -// alarm[8]=1; - -// menu=20; -// diplomacy=-5.3; - -// show_message(cooldown); - -// instance_activate_object(obj_enunit); - -/* */ -/* */ diff --git a/objects/obj_controller/Mouse_50.gml b/objects/obj_controller/Mouse_50.gml index 532aac4372..d555496424 100644 --- a/objects/obj_controller/Mouse_50.gml +++ b/objects/obj_controller/Mouse_50.gml @@ -142,33 +142,6 @@ if ((menu == 12) && (cooldown <= 0) && (penitorium > 0)) { } } } -// ** Fleet count ** -// Moved to scr_fleet_advisor(); -/* if (menu==16) and (cooldown<=0){ - var i=ship_current; - for(var j=0; j<34; j++){ - i+=1; - if (obj_ini.ship[i]!="") and (mouse_x>=xx+953) and (mouse_x>=yy+84+(i*20)) and (mouse_x 0) || ((diplomacy < -5) && (diplomacy > -6)) && (cooldown <= 0) && (diplomacy < 10)) { diff --git a/objects/obj_creation/Create_0.gml b/objects/obj_creation/Create_0.gml index fa45f5d93f..0ecaca9b9d 100644 --- a/objects/obj_creation/Create_0.gml +++ b/objects/obj_creation/Create_0.gml @@ -7,27 +7,27 @@ keyboard_string = ""; #region Icon Grid settings for chapter selection icon_width = 48; icon_height = 48; -/// distance between 2 rows of icons in the grid +// distance between 2 rows of icons in the grid icon_row_gap = 60; -/// distance between section heading and icon grid row +// distance between section heading and icon grid row icon_gap_y = 34; -/// distance between columns in icon grid +// distance between columns in icon grid icon_gap_x = 53; -/// x coord of left edge of the icon grid +// x coord of left edge of the icon grid icon_grid_left_edge = 441; -/// Max number of columns of icons until a new row is made +// Max number of columns of icons until a new row is made max_cols = 10; -/// x coord of the right edge of the icon grid +// x coord of the right edge of the icon grid icon_grid_right_edge = function() { return icon_grid_left_edge + (icon_gap_x * max_cols - 1); }; // icon_gap_x * max number of desired columns - 1 -/// y coord of Founding section heading +// y coord of Founding section heading founding_y = 133; -/// y coord of Successor section heading +// y coord of Successor section heading successor_y = 250; -/// y coord of Custom section heading +// y coord of Custom section heading custom_y = 463; -/// y coord of Other section heading +// y coord of Other section heading other_y = 593; var view = new DebugView("Obj Creation Grid", self); @@ -60,6 +60,7 @@ company_liveries = ""; complex_livery = false; complex_selection = "sgt"; complex_depth_selection = 0; +allow_colour_click = false; //TODO probably make this array based at some point ot match other unit data complex_livery_data = complex_livery_default(); left_data_slate = new DataSlate(); @@ -131,8 +132,8 @@ temp = 0; target_gear = 0; tab = 0; role_names_all = ""; +custom_roles = {}; -// chapter_name = "Unnamed"; chapter_string = "Unnamed"; chapter_year = 0; @@ -303,37 +304,37 @@ function ChapterDataLite(_id, _origin, _progenitor, _name, _tooltip, _icon_name // For new additions, as long as the order in the array is the same as the enum order, //you will be able to index the array by using syntax like so: `var dark_angels = all_chapters[CHAPTERS.DARK_ANGELS]` all_chapters = [ - new ChapterDataLite(eCHAPTERS.UNKNOWN, eCHAPTER_ORIGINS.NONE, 0, "Unknown", "Error: The tooltip is missing", "unknown"), - new ChapterDataLite(eCHAPTERS.DARK_ANGELS, eCHAPTER_ORIGINS.FOUNDING, 0, "Dark Angels", "The Dark Angels claim complete allegiance and service to the Emperor of Mankind, though their actions and secret goals seem to run counter to this- above all other things they strive to atone for an ancient crime of betrayal.", "dark_angels"), - new ChapterDataLite(eCHAPTERS.WHITE_SCARS, eCHAPTER_ORIGINS.FOUNDING, 0, "White Scars", "Known and feared for their highly mobile way of war, the White Scars are the masters of lightning strikes and hit-and-run tactics. They are particularly adept in the use of Attack Bikes and field large numbers of them.", "white_scars"), - new ChapterDataLite(eCHAPTERS.SPACE_WOLVES, eCHAPTER_ORIGINS.FOUNDING, 0, "Space Wolves", "Brave sky warriors hailing from the icy deathworld of Fenris, the Space Wolves are a non-Codex compliant chapter, and deadly in close combat. They fight on their own terms and damn any who wish otherwise.", "space_wolves"), - new ChapterDataLite(eCHAPTERS.IMPERIAL_FISTS, eCHAPTER_ORIGINS.FOUNDING, 0, "Imperial Fists", "Siege-masters of utmost excellence, the Imperial Fists stoicism has lead them to great victories and horrifying defeats. To them, the idea of a tactical retreat is utterly inconsiderable. They hold ground on Inwit vigilantly, refusing to back down from any fight.", "imperial_fists"), - new ChapterDataLite(eCHAPTERS.BLOOD_ANGELS, eCHAPTER_ORIGINS.FOUNDING, 0, "Blood Angels", "One of the most noble and renowned chapters, their combat record belies a dark flaw in their gene-seed caused by the death of their primarch. Their primarch had wings and a propensity for close combat, and this shows in their extensive use of jump packs and close quarters weapons.", "blood_angels"), - new ChapterDataLite(eCHAPTERS.IRON_HANDS, eCHAPTER_ORIGINS.FOUNDING, 0, "Iron Hands", "The flesh is weak, and the weak shall perish. Such is the creed of these mercilessly efficient cyborg warriors. A chapter with strong ties to the Mechanicum, they crush the foes of the Emperor and Machine God alike with a plethora of exotic technology and ancient weaponry.", "iron_hands"), - new ChapterDataLite(eCHAPTERS.ULTRAMARINES, eCHAPTER_ORIGINS.FOUNDING, 0, "Ultramarines", "An honourable and venerated chapter, the Ultramarines are considered to be amongst the best of the best. Their Primarch was the author of the great tome of the “Codex Astartes”, and they are considered exemplars of what a perfect Space Marine Chapter should be like.", "ultramarines"), - new ChapterDataLite(eCHAPTERS.SALAMANDERS, eCHAPTER_ORIGINS.FOUNDING, 0, "Salamanders", "Followers of the Promethean Cult, the jet-black skinned Salamanders are forgemasters of legend. They are armed with the best wargear available and prefer flame based weaponry. Their only drawback is their low numbers and slow recruiting.", "salamanders"), - new ChapterDataLite(eCHAPTERS.RAVEN_GUARD, eCHAPTER_ORIGINS.FOUNDING, 0, "Raven Guard", "Clinging to the shadows and riding the edge of lightning the Raven Guard strike out at the hated enemy with stealth and speed. Using lightning strikes, hit and run tactics, and guerrilla warfare, they are known for being there one second and gone the next.", "raven_guard"), + new ChapterDataLite(eCHAPTERS.UNKNOWN, eCHAPTER_ORIGINS.NONE, eCHAPTERS.UNKNOWN, "Unknown", "Error: The tooltip is missing", "unknown"), + new ChapterDataLite(eCHAPTERS.DARK_ANGELS, eCHAPTER_ORIGINS.FOUNDING, eCHAPTERS.UNKNOWN, "Dark Angels", "The Dark Angels claim complete allegiance and service to the Emperor of Mankind, though their actions and secret goals seem to run counter to this- above all other things they strive to atone for an ancient crime of betrayal.", "dark_angels"), + new ChapterDataLite(eCHAPTERS.WHITE_SCARS, eCHAPTER_ORIGINS.FOUNDING, eCHAPTERS.UNKNOWN, "White Scars", "Known and feared for their highly mobile way of war, the White Scars are the masters of lightning strikes and hit-and-run tactics. They are particularly adept in the use of Attack Bikes and field large numbers of them.", "white_scars"), + new ChapterDataLite(eCHAPTERS.SPACE_WOLVES, eCHAPTER_ORIGINS.FOUNDING, eCHAPTERS.UNKNOWN, "Space Wolves", "Brave sky warriors hailing from the icy deathworld of Fenris, the Space Wolves are a non-Codex compliant chapter, and deadly in close combat. They fight on their own terms and damn any who wish otherwise.", "space_wolves"), + new ChapterDataLite(eCHAPTERS.IMPERIAL_FISTS, eCHAPTER_ORIGINS.FOUNDING, eCHAPTERS.UNKNOWN, "Imperial Fists", "Siege-masters of utmost excellence, the Imperial Fists stoicism has lead them to great victories and horrifying defeats. To them, the idea of a tactical retreat is utterly inconsiderable. They hold ground on Inwit vigilantly, refusing to back down from any fight.", "imperial_fists"), + new ChapterDataLite(eCHAPTERS.BLOOD_ANGELS, eCHAPTER_ORIGINS.FOUNDING, eCHAPTERS.UNKNOWN, "Blood Angels", "One of the most noble and renowned chapters, their combat record belies a dark flaw in their gene-seed caused by the death of their primarch. Their primarch had wings and a propensity for close combat, and this shows in their extensive use of jump packs and close quarters weapons.", "blood_angels"), + new ChapterDataLite(eCHAPTERS.IRON_HANDS, eCHAPTER_ORIGINS.FOUNDING, eCHAPTERS.UNKNOWN, "Iron Hands", "The flesh is weak, and the weak shall perish. Such is the creed of these mercilessly efficient cyborg warriors. A chapter with strong ties to the Mechanicum, they crush the foes of the Emperor and Machine God alike with a plethora of exotic technology and ancient weaponry.", "iron_hands"), + new ChapterDataLite(eCHAPTERS.ULTRAMARINES, eCHAPTER_ORIGINS.FOUNDING, eCHAPTERS.UNKNOWN, "Ultramarines", "An honourable and venerated chapter, the Ultramarines are considered to be amongst the best of the best. Their Primarch was the author of the great tome of the “Codex Astartes”, and they are considered exemplars of what a perfect Space Marine Chapter should be like.", "ultramarines"), + new ChapterDataLite(eCHAPTERS.SALAMANDERS, eCHAPTER_ORIGINS.FOUNDING, eCHAPTERS.UNKNOWN, "Salamanders", "Followers of the Promethean Cult, the jet-black skinned Salamanders are forgemasters of legend. They are armed with the best wargear available and prefer flame based weaponry. Their only drawback is their low numbers and slow recruiting.", "salamanders"), + new ChapterDataLite(eCHAPTERS.RAVEN_GUARD, eCHAPTER_ORIGINS.FOUNDING, eCHAPTERS.UNKNOWN, "Raven Guard", "Clinging to the shadows and riding the edge of lightning the Raven Guard strike out at the hated enemy with stealth and speed. Using lightning strikes, hit and run tactics, and guerrilla warfare, they are known for being there one second and gone the next.", "raven_guard"), new ChapterDataLite(eCHAPTERS.BLACK_TEMPLARS, eCHAPTER_ORIGINS.SUCCESSOR, eCHAPTERS.IMPERIAL_FISTS, "Black Templars", "Not adhering to the Codex Astartes, Black Templars are a Chapter on an Eternal Crusade with unique organization and high numbers. Masters of assault, they charge at the enemy with zeal unmatched. They hate psykers, and as such, have no Librarians.", "black_templars"), new ChapterDataLite(eCHAPTERS.MINOTAURS, eCHAPTER_ORIGINS.SUCCESSOR, eCHAPTERS.IMPERIAL_FISTS, "Minotaurs", "Bronze-clad Astartes of unknown Founding, the Minotaurs prefer to channel their righteous fury in a massive storm of fire, with tanks and artillery. They could be considered the Inquisition’s attack dog, since they often attack fellow chapters suspected of heresy.", "minotaurs"), - new ChapterDataLite(eCHAPTERS.BLOOD_RAVENS, eCHAPTER_ORIGINS.SUCCESSOR, 0, "Blood Ravens", "Of unknown origins and Founding, the origins of the Blood Ravens are shrouded in mystery and are believed to be tied to a dark truth. This elusive Chapter is drawn to the pursuit of knowledge and ancient lore and produces an unusually high number of Librarians.", "blood_ravens"), + new ChapterDataLite(eCHAPTERS.BLOOD_RAVENS, eCHAPTER_ORIGINS.SUCCESSOR, eCHAPTERS.UNKNOWN, "Blood Ravens", "Of unknown origins and Founding, the origins of the Blood Ravens are shrouded in mystery and are believed to be tied to a dark truth. This elusive Chapter is drawn to the pursuit of knowledge and ancient lore and produces an unusually high number of Librarians.", "blood_ravens"), new ChapterDataLite(eCHAPTERS.CRIMSON_FISTS, eCHAPTER_ORIGINS.SUCCESSOR, eCHAPTERS.IMPERIAL_FISTS, "Crimson Fists", "An Imperial Fists descendant, the Crimson Fists are more level-minded than their Progenitor and brother chapters. They suffer the same lacking zygotes as their ancestors, and more resemble the Ultramarines in their balanced approach to combat. After surviving a devastating Ork WAAAGH! the chapter clings dearly to its future.", "crimson_fists"), new ChapterDataLite(eCHAPTERS.LAMENTERS, eCHAPTER_ORIGINS.SUCCESSOR, eCHAPTERS.BLOOD_ANGELS, "Lamenters", "The Lamenter's accursed and haunted legacy seems to taint much of what they have achieved; their victories often become bitter ashes in their hands. Nearly extinct, they fight their last days on behalf of the common folk in a crusade of endless penitence.", "lamenters"), new ChapterDataLite(eCHAPTERS.CARCHARODONS, eCHAPTER_ORIGINS.SUCCESSOR, eCHAPTERS.RAVEN_GUARD, "Carcharodons", "Rumored to be Successors of the Raven Guard, these Astartes are known for their sudden attacks and shock assaults. Travelling through the Imperium via self-sufficient Nomad-Predation based fleets, no enemy is safe from the fury of these bloodthirsty Space Marines.", "carcharodons"), new ChapterDataLite(eCHAPTERS.SOUL_DRINKERS, eCHAPTER_ORIGINS.SUCCESSOR, eCHAPTERS.IMPERIAL_FISTS, "Soul Drinkers", "Sharing ancestry of the Black Templars or Crimson fists. As proud sons of Dorn they share the strong void combat traditions, fielding a large amount of Battle Barges. As well as being fearsome in close combat. Whispers of the Ruinous Powers are however quite enticing.", "soul_drinkers"), - new ChapterDataLite(eCHAPTERS.ANGRY_MARINES, eCHAPTER_ORIGINS.NON_CANON, 0, "Angry Marines", "Frothing with pathological rage since the day their Primarch emerged from his pod with naught but a dented copy of battletoads. Every last Angry Marine is a homicidal, suicidal berserker with a voice that projects, and are always angry, all the time. A /tg/ classic.", "angry_marines"), - new ChapterDataLite(eCHAPTERS.EMPERORS_NIGHTMARE, eCHAPTER_ORIGINS.NON_CANON, 0, "Emperor’s Nightmare", "The Emperor's Nightmare bear the curse of a bizarre mutation within their gene-seed. The Catalepsean Node is in a state of decay and thus do not sleep for months at a time until falling asleep suddenly. They prefer shock and awe tactics with stealth.", "emperors_nightmare"), - new ChapterDataLite(eCHAPTERS.STAR_KRAKENS, eCHAPTER_ORIGINS.NON_CANON, 0, "Star Krakens", "In darkness, they dwell in The Deep. The Star Krakens stand divided in individual companies but united in the form of the Ten-Flag Council. They utilize boarding tactics and are the sole guardians of the ancient sensor array called “The Lighthouse”.", "star_krakens"), - new ChapterDataLite(eCHAPTERS.CONSERVATORS, eCHAPTER_ORIGINS.NON_CANON, 0, "Conservators", "Hailing from the Asharn Marches and having established their homeworld on the planet Dekara, these proud sons of Dorn suffer from an extreme lack of supplies, Ork raids, and more. Though under strength and lacking equipment, they managed to forge an interstellar kingdom loyal to both Emperor and Imperium.", "conservators"), - new ChapterDataLite(eCHAPTERS.CUSTOM_1, eCHAPTER_ORIGINS.CUSTOM, 0, "Custom", "Your Chapter"), - new ChapterDataLite(eCHAPTERS.CUSTOM_2, eCHAPTER_ORIGINS.CUSTOM, 0, "Custom", "Your Chapter"), - new ChapterDataLite(eCHAPTERS.CUSTOM_3, eCHAPTER_ORIGINS.CUSTOM, 0, "Custom", "Your Chapter"), - new ChapterDataLite(eCHAPTERS.CUSTOM_4, eCHAPTER_ORIGINS.CUSTOM, 0, "Custom", "Your Chapter"), - new ChapterDataLite(eCHAPTERS.CUSTOM_5, eCHAPTER_ORIGINS.CUSTOM, 0, "Custom", "Your Chapter"), - new ChapterDataLite(eCHAPTERS.CUSTOM_6, eCHAPTER_ORIGINS.CUSTOM, 0, "Custom", "Your Chapter"), - new ChapterDataLite(eCHAPTERS.CUSTOM_7, eCHAPTER_ORIGINS.CUSTOM, 0, "Custom", "Your Chapter"), - new ChapterDataLite(eCHAPTERS.CUSTOM_8, eCHAPTER_ORIGINS.CUSTOM, 0, "Custom", "Your Chapter"), - new ChapterDataLite(eCHAPTERS.CUSTOM_9, eCHAPTER_ORIGINS.CUSTOM, 0, "Custom", "Your Chapter"), - new ChapterDataLite(eCHAPTERS.CUSTOM_10, eCHAPTER_ORIGINS.CUSTOM, 0, "Custom", "Your Chapter") + new ChapterDataLite(eCHAPTERS.ANGRY_MARINES, eCHAPTER_ORIGINS.NON_CANON, eCHAPTERS.UNKNOWN, "Angry Marines", "Frothing with pathological rage since the day their Primarch emerged from his pod with naught but a dented copy of battletoads. Every last Angry Marine is a homicidal, suicidal berserker with a voice that projects, and are always angry, all the time. A /tg/ classic.", "angry_marines"), + new ChapterDataLite(eCHAPTERS.EMPERORS_NIGHTMARE, eCHAPTER_ORIGINS.NON_CANON, eCHAPTERS.UNKNOWN, "Emperor’s Nightmare", "The Emperor's Nightmare bear the curse of a bizarre mutation within their gene-seed. The Catalepsean Node is in a state of decay and thus do not sleep for months at a time until falling asleep suddenly. They prefer shock and awe tactics with stealth.", "emperors_nightmare"), + new ChapterDataLite(eCHAPTERS.STAR_KRAKENS, eCHAPTER_ORIGINS.NON_CANON, eCHAPTERS.UNKNOWN, "Star Krakens", "In darkness, they dwell in The Deep. The Star Krakens stand divided in individual companies but united in the form of the Ten-Flag Council. They utilize boarding tactics and are the sole guardians of the ancient sensor array called “The Lighthouse”.", "star_krakens"), + new ChapterDataLite(eCHAPTERS.CONSERVATORS, eCHAPTER_ORIGINS.NON_CANON, eCHAPTERS.UNKNOWN, "Conservators", "Hailing from the Asharn Marches and having established their homeworld on the planet Dekara, these proud sons of Dorn suffer from an extreme lack of supplies, Ork raids, and more. Though under strength and lacking equipment, they managed to forge an interstellar kingdom loyal to both Emperor and Imperium.", "conservators"), + new ChapterDataLite(eCHAPTERS.CUSTOM_1, eCHAPTER_ORIGINS.CUSTOM, eCHAPTERS.UNKNOWN, "Custom", "Your Chapter"), + new ChapterDataLite(eCHAPTERS.CUSTOM_2, eCHAPTER_ORIGINS.CUSTOM, eCHAPTERS.UNKNOWN, "Custom", "Your Chapter"), + new ChapterDataLite(eCHAPTERS.CUSTOM_3, eCHAPTER_ORIGINS.CUSTOM, eCHAPTERS.UNKNOWN, "Custom", "Your Chapter"), + new ChapterDataLite(eCHAPTERS.CUSTOM_4, eCHAPTER_ORIGINS.CUSTOM, eCHAPTERS.UNKNOWN, "Custom", "Your Chapter"), + new ChapterDataLite(eCHAPTERS.CUSTOM_5, eCHAPTER_ORIGINS.CUSTOM, eCHAPTERS.UNKNOWN, "Custom", "Your Chapter"), + new ChapterDataLite(eCHAPTERS.CUSTOM_6, eCHAPTER_ORIGINS.CUSTOM, eCHAPTERS.UNKNOWN, "Custom", "Your Chapter"), + new ChapterDataLite(eCHAPTERS.CUSTOM_7, eCHAPTER_ORIGINS.CUSTOM, eCHAPTERS.UNKNOWN, "Custom", "Your Chapter"), + new ChapterDataLite(eCHAPTERS.CUSTOM_8, eCHAPTER_ORIGINS.CUSTOM, eCHAPTERS.UNKNOWN, "Custom", "Your Chapter"), + new ChapterDataLite(eCHAPTERS.CUSTOM_9, eCHAPTER_ORIGINS.CUSTOM, eCHAPTERS.UNKNOWN, "Custom", "Your Chapter"), + new ChapterDataLite(eCHAPTERS.CUSTOM_10, eCHAPTER_ORIGINS.CUSTOM, eCHAPTERS.UNKNOWN, "Custom", "Your Chapter") ]; var missing_splash = 99; @@ -401,11 +402,6 @@ custom_chapters = array_filter(all_chapters, function(item) { other_chapters = array_filter(all_chapters, function(item) { return item.origin == eCHAPTER_ORIGINS.NON_CANON; }); -// LOGGER.debug($"founding: {founding_chapters}"); -// LOGGER.debug($"successor: {successor_chapters}"); -// LOGGER.debug($"custom: {custom_chapters}"); -// LOGGER.debug($"other: {other_chapters}"); - // TODO refactor into struct constructors stored in which are struct arrays // meta provides a universal way to control not having contradictory advatages and disadvantages @@ -417,10 +413,6 @@ chapter_trait_meta = []; setup_chapter_traits(); -// disadvantage[i]="Embargo";dis_tooltip[i]="NOT IMPLEMENTED YET.";i+=1;// Greatly increases the cost of common wargear and disallows advanced items. -// disadvantage[i]="First In, Last Out";dis_tooltip[i]="NOT IMPLEMENTED YET.";i+=1; -// disadvantage[i]="Rival Brotherhood";dis_tooltip[i]="NOT IMPLEMENTED YET.";i+=1; - race = []; role = []; wep1 = []; @@ -444,6 +436,14 @@ for (var slot = 99; slot <= 103; slot++) { defaults_slot = 100; +/// @description +/// @param {Real} _role_id +/// @param {String} _role_name +/// @param {String} _wep1 +/// @param {String} _wep2 +/// @param {String} _armour +/// @param {String} _mobi +/// @param {String} _gear load_default_gear = function(_role_id, _role_name, _wep1, _wep2, _armour, _mobi, _gear) { role[defaults_slot][_role_id] = _role_name; wep1[defaults_slot][_role_id] = _wep1; @@ -485,11 +485,9 @@ if (global.restart > 0) { slide_show = 2; reset_creation_variables(); - //with(obj_restart_vars){instance_destroy();} global.restart = 0; } -/* */ col = []; col_r = []; col_g = []; @@ -592,6 +590,5 @@ weapon_colour_replace = [ col_g[weapon_color] / 255, col_b[weapon_color] / 255 ]; -/* */ + alarm_set(1, 30); -/* */ diff --git a/objects/obj_creation/Draw_0.gml b/objects/obj_creation/Draw_0.gml index a8ecc0d4e8..f866158d21 100644 --- a/objects/obj_creation/Draw_0.gml +++ b/objects/obj_creation/Draw_0.gml @@ -2,18 +2,16 @@ add_draw_return_values(); draw_set_valign(fa_top); try { //read - // 850,860 var xx = 375; var yy = 10; + allow_colour_click = (custom == eCHAPTER_TYPE.CUSTOM) && (!instance_exists(obj_creation_popup)); tooltip = ""; tooltip2 = ""; draw_set_alpha(1); - // draw_sprite(spr_creation_slate,0,xx,yy); scr_image("creation/slate", 1, xx, yy, 850, 860); draw_set_alpha(1 - (slate1 / 30)); - // draw_sprite(spr_creation_slate,1,xx,yy); scr_image("creation/slate", 2, xx, yy, 850, 860); draw_set_color(#5B872E); @@ -36,8 +34,6 @@ try { draw_line(xx + 30, yy + 70 + (slate3 * 36), xx + 790, yy + 70 + (slate3 * 36)); } - allow_colour_click = (custom == eCHAPTER_TYPE.CUSTOM) && (!instance_exists(obj_creation_popup)); - draw_set_alpha(slate4 / 30); if (slate4 > 0) { /* Chapter Selection grid */ @@ -181,6 +177,7 @@ try { t_tip2: "Your Astartes lack the detoxifying gland called the Preomnor- they are more susceptible to poisons and toxins.", data: preomnor, mutation_points: 1, + disposition: [], }, { t_tip: "Disturbing Voice", @@ -215,42 +212,49 @@ try { t_tip2: "Lacking a working Lyman's ear, all deep-striked Astartes receive moderate penalties to both attack and defense.", data: lyman, mutation_points: 1, + disposition: [], }, { t_tip: "Hyper-Stimulated Omophagea", t_tip2: "After every battle the Astartes have a chance to feast upon their fallen enemies, or seldom, their allies.", data: omophagea, mutation_points: 1, + disposition: [], }, { t_tip: "Hyperactive Ossmodula", t_tip2: "Instead of wound tissue bone is generated; Apothecaries must spend twice the normal time healing your Astartes.", data: ossmodula, mutation_points: 1, + disposition: [], }, { t_tip: "Lost Zygote", t_tip2: "One of the Zygotes is faulty or missing. The Astartes only have one each and generate half the normal Gene-Seed.", data: zygote, mutation_points: 2, + disposition: [], }, { t_tip: "Inactive Sus-an Membrane", t_tip2: "Your Astartes do not have a Sus-an Membrane; they cannot enter suspended animation and receive more casualties as a result.", data: membrane, mutation_points: 1, + disposition: [], }, { t_tip: "Missing Betchers Gland", t_tip2: "Your Astartes cannot spit acid, and as a result, have slightly less attack in melee combat.", data: betchers, mutation_points: 1, + disposition: [], }, { t_tip: "Mutated Catalepsean Node", t_tip2: "Your Astartes have reduced awareness when tired. Slightly less attack in ranged and melee combat.", data: catalepsean, mutation_points: 1, + disposition: [], }, { t_tip: "Oolitic Secretions", @@ -312,7 +316,7 @@ try { x1 = 450; y1 = 260; for (var i = 0; i < array_length(mutations_defects); i++) { - mutation_data = mutations_defects[i]; + var mutation_data = mutations_defects[i]; draw_sprite(spr_creation_check, mutation_data.data, x1, y1); if (point_and_click([x1, y1, x1 + 32, y1 + 32]) && allow_colour_click) { var onceh = 0; @@ -438,7 +442,7 @@ try { var str_width, hei; str_width = max(350, string_width(string_hash_to_newline(chapter_master_name))); hei = string_height(string_hash_to_newline(chapter_master_name)); - if (scr_hit(580 - 2, 144 - 2, 582 + str_width, 146 + hei)) { + if (scr_hit(578, 142, 582 + str_width, 146 + hei)) { obj_cursor.image_index = 2; if (mouse_button_clicked() && !instance_exists(obj_creation_popup)) { text_selected = "cm"; @@ -448,7 +452,7 @@ try { if (text_selected == "cm") { chapter_master_name = keyboard_string; } - draw_rectangle(580 - 2, 144 - 2, 582 + 350, 146 + hei, 1); + draw_rectangle(578, 142, 932, 146 + hei, 1); var _refresh_cm_name_btn = [ 943, diff --git a/objects/obj_creation_popup/Create_0.gml b/objects/obj_creation_popup/Create_0.gml index d7a7963bf5..94a744c9b5 100644 --- a/objects/obj_creation_popup/Create_0.gml +++ b/objects/obj_creation_popup/Create_0.gml @@ -8,9 +8,13 @@ rows = 0; picker = new ColourPicker(20, 550, 350); picker.disable_textures = true; start_colour = -1; +col_shift = false; +bulk_buttons = []; tooltip = ""; tooltip2 = ""; +item_name = []; +role_names_all = ""; type_names = { "1": "Primary Color", diff --git a/objects/obj_creation_popup/Step_0.gml b/objects/obj_creation_popup/Step_0.gml index b8c9de7e38..957631718e 100644 --- a/objects/obj_creation_popup/Step_0.gml +++ b/objects/obj_creation_popup/Step_0.gml @@ -1,59 +1,50 @@ role_names_all = ""; -var derpaderp, z, idd; -derpaderp = 0; -idd = 0; if (!is_string(type)) { - if (type >= 100) { - z = type - 100; - } - if (type < 100) { - z = type; - } + var z = (type >= 100) ? type - 100 : type; if (type >= 100) { - repeat (13) { - derpaderp += 1; - if (derpaderp == 1) { + for (var i = 1 ; i <= 13; i++) { + var idd = 0; + if (i == 1) { idd = 15; } - if (derpaderp == 2) { + if (i == 2) { idd = 14; } - if (derpaderp == 3) { + if (i == 3) { idd = 17; } - if (derpaderp == 4) { + if (i == 4) { idd = 16; } - if (derpaderp == 5) { + if (i == 5) { idd = 5; } - if (derpaderp == 6) { + if (i == 6) { idd = 2; } - if (derpaderp == 7) { + if (i == 7) { idd = 4; } - if (derpaderp == 8) { + if (i == 8) { idd = 3; } - if (derpaderp == 9) { + if (i == 9) { idd = 6; } - if (derpaderp == 10) { + if (i == 10) { idd = 8; } - if (derpaderp == 11) { + if (i == 11) { idd = 9; } - if (derpaderp == 12) { + if (i == 12) { idd = 10; } - if (derpaderp == 13) { + if (i == 13) { idd = 12; } - role_names_all += string(obj_creation.role[100][idd]) + "|"; } @@ -61,8 +52,6 @@ if (!is_string(type)) { role_names_all += "Master of Sanctity|"; role_names_all += "Master of the Apothecarion|"; role_names_all += "Forge Master|"; - // role_names_all+="Crusader|"; - // role_names_all+="Ranger|"; if (obj_creation.role[100][z] != "") { if (string_count(obj_creation.role[100][z], role_names_all) > 1) { diff --git a/objects/obj_credits/Draw_0.gml b/objects/obj_credits/Draw_0.gml index bdbab00d62..0d5cc1ddf2 100644 --- a/objects/obj_credits/Draw_0.gml +++ b/objects/obj_credits/Draw_0.gml @@ -31,14 +31,8 @@ draw_text_transformed(802 - 200, 472, string_hash_to_newline("ASSISTANT ARTISTS" draw_text(802 - 200, 498, string_hash_to_newline("sinndogg#efngn#Toni ''TrashMan'' Stanicic")); draw_text_transformed(802, 373, string_hash_to_newline("SUPPORTERS AND LEGACY CODERS"), 0.85, 0.85, 0); -// draw_text_transformed(802,472,"FORMER SUPPORTERS",0.85,0.85,0); draw_text(802, 397, string_hash_to_newline("Duke#Paul-Ross#MANDOZERTHEGREAT#Alex Norry#Carli")); -// draw_text(802,496,""); - -draw_set_font(fnt_cul_18); -draw_set_halign(fa_center); -draw_text_ext(room_width / 2, 706 - 25, string_hash_to_newline(obj_main_menu.legal_text), -1, 1406); draw_set_font(fnt_cul_14); draw_set_halign(fa_left); @@ -48,30 +42,8 @@ draw_text_ext(991, 92 + 15, string_hash_to_newline(@" Late 2011 /tg/ came up wi -Duke"), -1, 570); -// 253,96 - -var bhih; -bhih = 0; -if ((scr_hit(319, 307, 393, 324) == false) && (obj_main_menu.browser == 1)) { - obj_main_menu.browser = 0; -} -if (scr_hit(319, 307, 393, 324) == true) { - bhih = 1; - if ((obj_main_menu.browser == 0) && mouse_button_clicked()) { - /*switch(show_question("Open your browser?")) { - case 1:*/ - // url_open_ext( 'http://planetofthebrandons.com/donate.html', '_blank');browser=1; - if (obj_main_menu.blog_url != "Error") { - url_open_ext(obj_main_menu.blog_url, "_blank"); - } - obj_main_menu.browser = 1; - // break; - // } - } -} draw_text(257, 96, string_hash_to_newline("DukeFluffy")); draw_text_ext_transformed(257, 96, string_hash_to_newline("#A hobbyist game producer with insomnia and way too much time on his hands. Duke has created several pen and paper RPG's, namely ChromeStrike and the Morrowind RPG. He has aspirations of one day working on robots."), -1, 208 * 1.1, 0.9, 0.9, 0); -draw_sprite(spr_blog, bhih, 319, 307); if (fade_in > 0) { draw_set_color(0); @@ -88,5 +60,3 @@ if (instance_exists(obj_main_menu_buttons)) { } draw_set_alpha(1); } -/* */ -/* */ diff --git a/objects/obj_drop_select/Alarm_2.gml b/objects/obj_drop_select/Alarm_2.gml index fefcbb61e4..486ef6d44e 100644 --- a/objects/obj_drop_select/Alarm_2.gml +++ b/objects/obj_drop_select/Alarm_2.gml @@ -1,16 +1,11 @@ -var i; -i = -1; -repeat (31) { - i += 1; - ship[i] = ""; - ship_all[i] = 0; - ship_use[i] = 0; - ship_max[i] = 0; - ship_ide[i] = -1; -} +ship = array_create(31, ""); +ship_all = array_create(31, 0); +ship_use = array_create(31, 0); +ship_max = array_create(31, 0); +ship_ide = array_create(31, -1); max_ships = 0; -if (sh_target != -50) { +if (sh_target != noone) { max_ships = sh_target.capital_number + sh_target.frigate_number + sh_target.escort_number; } @@ -24,36 +19,35 @@ if (l_size > 0) { l_size = l_size * -1; } -if (sh_target != -50) { - var tump = 0; +if (sh_target != noone) { var i = 0; - for (var q = 0; q < sh_target.capital_number; q++) { - if ((sh_target.capital[q] != "") && (obj_ini.ship_carrying[sh_target.capital_num[q]] > 0)) { - ship[i] = sh_target.capital[i]; + for (var s = 0; s < sh_target.capital_number; s++) { + if ((sh_target.capital[s] != "") && (obj_ini.ship_carrying[sh_target.capital_num[s]] > 0)) { + ship[i] = sh_target.capital[s]; ship_use[i] = 0; - tump = sh_target.capital_num[i]; + var tump = sh_target.capital_num[s]; ship_max[i] = obj_ini.ship_carrying[tump]; ship_ide[i] = tump; ship_size[i] = 3; i += 1; } } - for (var q = 0; q < sh_target.frigate_number; q++) { - if ((sh_target.frigate[q] != "") && (obj_ini.ship_carrying[sh_target.frigate_num[q]] > 0)) { - ship[i] = sh_target.frigate[q]; + for (var s = 0; s < sh_target.frigate_number; s++) { + if ((sh_target.frigate[s] != "") && (obj_ini.ship_carrying[sh_target.frigate_num[s]] > 0)) { + ship[i] = sh_target.frigate[s]; ship_use[i] = 0; - tump = sh_target.frigate_num[q]; + var tump = sh_target.frigate_num[s]; ship_max[i] = obj_ini.ship_carrying[tump]; ship_ide[i] = tump; ship_size[i] = 2; i += 1; } } - for (var q = 0; q < sh_target.escort_number; q++) { - if ((sh_target.escort[q] != "") && (obj_ini.ship_carrying[sh_target.escort_num[q]] > 0)) { - ship[i] = sh_target.escort[q]; + for (var s = 0; s < sh_target.escort_number; s++) { + if ((sh_target.escort[s] != "") && (obj_ini.ship_carrying[sh_target.escort_num[s]] > 0)) { + ship[i] = sh_target.escort[s]; ship_use[i] = 0; - tump = sh_target.escort_num[q]; + var tump = sh_target.escort_num[s]; ship_max[i] = obj_ini.ship_carrying[tump]; ship_ide[i] = tump; ship_size[i] = 1; diff --git a/objects/obj_drop_select/Alarm_3.gml b/objects/obj_drop_select/Alarm_3.gml index 95134e0c6f..0b91fa8255 100644 --- a/objects/obj_drop_select/Alarm_3.gml +++ b/objects/obj_drop_select/Alarm_3.gml @@ -1,34 +1,22 @@ -var i; -i = -1; -repeat (61) { - i += 1; - ship[i] = ""; - ship_all[i] = 0; - ship_use[i] = 0; - ship_max[i] = 0; - ship_ide[i] = -1; -} +ship = array_create(61, ""); +ship_all = array_create(61, 0); +ship_use = array_create(61, 0); +ship_max = array_create(61, 0); +ship_ide = array_create(61, -1); max_ships = 0; -if (sh_target != -50) { +if (sh_target != noone) { max_ships = sh_target.capital_number + sh_target.frigate_number + sh_target.escort_number; - var tump; - tump = 0; - - var i, q, b; - i = 0; - q = 0; - b = 0; - repeat (sh_target.capital_number) { - b += 1; - if (sh_target.capital[b] != "") { + var i = 0; + for (var s = 1; s <= sh_target.capital_number; s++) { + if (sh_target.capital[s] != "") { i += 1; - ship[i] = sh_target.capital[i]; + ship[i] = sh_target.capital[s]; ship_use[i] = 0; - tump = sh_target.capital_num[i]; + var tump = sh_target.capital_num[s]; ship_max[i] = obj_ini.ship_carrying[tump]; ship_ide[i] = tump; ship_size[i] = 3; @@ -38,15 +26,13 @@ if (sh_target != -50) { purge_c += ship_max[i]; } } - q = 0; - repeat (sh_target.frigate_number) { - q += 1; - if (sh_target.frigate[q] != "") { + for (var s = 1; s <= sh_target.frigate_number; s++) { + if (sh_target.frigate[s] != "") { i += 1; - ship[i] = sh_target.frigate[q]; + ship[i] = sh_target.frigate[s]; ship_use[i] = 0; - tump = sh_target.frigate_num[q]; + var tump = sh_target.frigate_num[s]; ship_max[i] = obj_ini.ship_carrying[tump]; ship_ide[i] = tump; ship_size[i] = 2; @@ -56,15 +42,13 @@ if (sh_target != -50) { purge_c += ship_max[i]; } } - q = 0; - repeat (sh_target.escort_number) { - q += 1; - if ((sh_target.escort[q] != "") && (obj_ini.ship_carrying[sh_target.escort_num[q]] > 0)) { + for (var s = 1; s <= sh_target.escort_number; s++) { + if ((sh_target.escort[s] != "") && (obj_ini.ship_carrying[sh_target.escort_num[s]] > 0)) { i += 1; - ship[i] = sh_target.escort[q]; + ship[i] = sh_target.escort[s]; ship_use[i] = 0; - tump = sh_target.escort_num[q]; + var tump = sh_target.escort_num[s]; ship_max[i] = obj_ini.ship_carrying[tump]; ship_ide[i] = tump; ship_size[i] = 1; diff --git a/objects/obj_drop_select/Alarm_4.gml b/objects/obj_drop_select/Alarm_4.gml index da2daf698f..f8f2febae1 100644 --- a/objects/obj_drop_select/Alarm_4.gml +++ b/objects/obj_drop_select/Alarm_4.gml @@ -1,36 +1,23 @@ // This confirms the number of ships available for bombarding - -var i; -i = -1; -repeat (61) { - i += 1; - ship[i] = ""; - ship_all[i] = 0; - ship_use[i] = 0; - ship_max[i] = 0; - ship_ide[i] = -1; -} +ship = array_create(61, ""); +ship_all = array_create(61, 0); +ship_use = array_create(61, 0); +ship_max = array_create(61, 0); +ship_ide = array_create(61, -1); max_ships = 0; -if (sh_target != -50) { +if (sh_target != noone) { max_ships = sh_target.capital_number + sh_target.frigate_number + sh_target.escort_number; - var tump; - tump = 0; - - var i, q, b; - i = 0; - q = 0; - b = 0; - repeat (sh_target.capital_number) { - b += 1; - if (sh_target.capital[b] != "") { + var i = 0; + for (var s = 1; s <= sh_target.capital_number; s++) { + if (sh_target.capital[s] != "") { i += 1; - ship[i] = sh_target.capital[i]; + ship[i] = sh_target.capital[s]; ship_use[i] = 0; - tump = sh_target.capital_num[i]; + var tump = sh_target.capital_num[s]; ship_max[i] = obj_ini.ship_carrying[tump]; ship_ide[i] = tump; ship_size[i] = 3; @@ -40,15 +27,13 @@ if (sh_target != -50) { purge_c += ship_max[i]; } } - q = 0; - repeat (sh_target.frigate_number) { - q += 1; - if (sh_target.frigate[q] != "") { + for (var s = 1; s <= sh_target.frigate_number; s++) { + if (sh_target.frigate[s] != "") { i += 1; - ship[i] = sh_target.frigate[q]; + ship[i] = sh_target.frigate[s]; ship_use[i] = 0; - tump = sh_target.frigate_num[q]; + var tump = sh_target.frigate_num[s]; ship_max[i] = obj_ini.ship_carrying[tump]; ship_ide[i] = tump; ship_size[i] = 2; diff --git a/objects/obj_drop_select/Create_0.gml b/objects/obj_drop_select/Create_0.gml index f583a58a9d..9d5ba32067 100644 --- a/objects/obj_drop_select/Create_0.gml +++ b/objects/obj_drop_select/Create_0.gml @@ -1,9 +1,12 @@ -if (!variable_instance_exists(self, "attack")) { - attack = 0; -} set_zoom_to_default(); //bandaid the purge screen flying off screen if zoomed out once_only = 0; +var _vars = ["purge", "planet_number", "attack"]; +for (var i = 0; i < array_length(_vars); i++) { + if (!variable_instance_exists(self, _vars[i])) { + variable_instance_set(self, _vars[i], 0); + } +} raid_tact = 1; raid_vet = 1; @@ -16,14 +19,11 @@ raid_wounded = obj_controller.select_wounded; refresh_raid = 0; remove_local = 1; -// - main_slate = new DataSlate(); draw = drop_select_draw; main_slate.inside_method = draw; roster_slate = new DataSlate(); local_content_slate = new DataSlate(); -var i = -1; formation_current = -1; via = array_create(100, 0); formation_possible = []; @@ -59,7 +59,6 @@ if (!instance_exists(obj_saveload)) { tooltip2 = ""; all_sel = 0; - var i = -1; var _ship_index = array_length(obj_ini.ship); ship = array_create(_ship_index, ""); ship_size = array_create(_ship_index, 0); @@ -68,13 +67,12 @@ if (!instance_exists(obj_saveload)) { ship_max = array_create(_ship_index, 0); ship_ide = array_create(_ship_index, -1); - i = 500; - ship[i] = "Local"; - ship_size[i] = 0; - ship_all[i] = 0; - ship_use[i] = 0; - ship_max[i] = 0; - ship_ide[i] = -42; + ship[500] = "Local"; + ship_size[500] = 0; + ship_all[500] = 0; + ship_use[500] = 0; + ship_max[500] = 0; + ship_ide[500] = -42; menu = 0; @@ -101,7 +99,7 @@ if (!instance_exists(obj_saveload)) { demons = 0; // Formation check - var i = 0, is = 0, arright = false; + var is = 0; var _formations = obj_controller.bat_formation; var _formation_types = obj_controller.bat_formation_type; @@ -134,6 +132,15 @@ if (!instance_exists(obj_saveload)) { if (formation_current == -1) { formation_current = 0; } + // Hardening: a stored last_raid_form / last_attack_form that is not among the formations + // valid for this drop type, or a value left over across a save/load, would otherwise leave + // formation_current as an out-of-range raw value. Clamp it so the selector can never index + // past the array, and pin it to 0 when there are no formations to choose from. + if (array_length(formation_possible) > 0) { + formation_current = clamp(formation_current, 0, array_length(formation_possible) - 1); + } else { + formation_current = 0; + } fighting = array_create(11, array_create(501)); veh_fighting = array_create(11, array_create(501)); @@ -227,9 +234,7 @@ if (purge == 0) { attacking = 9; } - var forces, t_attack; - forces = 0; - t_attack = 0; + var forces = 0; if (sisters > 0) { forces += 1; force_present[forces] = 5; diff --git a/objects/obj_drop_select/Draw_64.gml b/objects/obj_drop_select/Draw_64.gml index 7809223906..7a61185ff0 100644 --- a/objects/obj_drop_select/Draw_64.gml +++ b/objects/obj_drop_select/Draw_64.gml @@ -39,13 +39,7 @@ try { instance_destroy(); } } - var _xx = local_content_slate.XX; - /*if (instance_exists(p_target)) { - if (p_target.p_type[planet_number] = "Shrine") then nup = true; - } - */ - // 89,31 draw_set_halign(fa_left); for (var i = 0; i < array_length(purge_options); i++) { var _purge_button = purge_options[i]; @@ -83,7 +77,7 @@ try { } else if (purge > eDROP_TYPE.PURGESELECT) { draw_text_ext(_xx, _yy, "Purge Insight", -1, roster_slate.width - 40); _yy += 30; - var hers, influ, poppy; + var poppy = "0"; var hers = p_target.p_heresy[planet_number] + p_target.p_heresy_secret[planet_number]; var influ = p_target.p_influence[planet_number]; if (p_target.p_large[planet_number] == 1) { @@ -108,7 +102,7 @@ try { var _draw_y = _y_center; if (purge > eDROP_TYPE.PURGESELECT) { if (roster_slate.XX < _x_center + 660) { - var _draw_x = min(roster_slate.XX + 15, _x_center + 660); + _draw_x = min(roster_slate.XX + 15, _x_center + 660); } else { _draw_x = roster_slate.XX; } diff --git a/objects/obj_dropdown_sel/Create_0.gml b/objects/obj_dropdown_sel/Create_0.gml index 7c611022e6..de586a0c67 100644 --- a/objects/obj_dropdown_sel/Create_0.gml +++ b/objects/obj_dropdown_sel/Create_0.gml @@ -7,23 +7,13 @@ opened = 0; my_menu = 12.1; determined_planets = 0; -var ii; -ii = -1; -repeat (51) { - ii += 1; - option[ii] = ""; - option_id[ii] = 0; - option_star[ii] = 0; -} +option = array_create(51, ""); +option_id = array_create(51, 0); +option_star = array_create(51, 0); -var ii; -ii = -1; -repeat (101) { - ii += 1; - star[ii] = ""; - star_planet[ii] = 0; - star_mahreens[ii] = 0; -} +star = array_create(101, ""); +star_planet = array_create(101, 0); +star_mahreens = array_create(101, 0); width = 124; height = 24; diff --git a/objects/obj_dropdown_sel/Draw_0.gml b/objects/obj_dropdown_sel/Draw_0.gml index ff85508442..fcf2af60b1 100644 --- a/objects/obj_dropdown_sel/Draw_0.gml +++ b/objects/obj_dropdown_sel/Draw_0.gml @@ -41,15 +41,12 @@ if ((scr_hit(x, y, x + width, y + height) == true) && (obj_controller.dropdown_o } if (opened == 1) { - var ii, y5, yyy, hi; - ii = 0; - yyy = 24; - y5 = y; - hi = 24; - - repeat (options) { - ii += 1; - if ((ii != option_selected) && (ii <= options)) { + var yyy = 24; + var y5 = y; + var hi = 24; + + for (var i = 1; i <= options; i++) { + if ((i != option_selected) && (i <= options)) { y5 += hi; yyy += hi; @@ -59,7 +56,7 @@ if (opened == 1) { draw_set_font(fnt_40k_14); draw_set_color(c_black); draw_set_halign(fa_center); - draw_text(x + (width / 2), y5 + 2, string_hash_to_newline(string(option[ii]))); + draw_text(x + (width / 2), y5 + 2, string_hash_to_newline(string(option[i]))); draw_rectangle(x, y5, x + width, y5 + hi, 1); if (scr_hit(x, y5, x + width, y5 + hi) == true) { @@ -67,12 +64,12 @@ if (opened == 1) { draw_set_color(c_white); draw_rectangle(x, y5, x + width, y5 + hi, 0); - tooltip = option[ii]; - if ((target == "event_display") && (option[ii] != "None")) { - tooltip = option[ii]; - tooltip2 = fetch_artifact(option_id[ii]).description(); + tooltip = option[i]; + if ((target == "event_display") && (option[i] != "None")) { + tooltip = option[i]; + tooltip2 = fetch_artifact(option_id[i]).description(); } - if ((target == "event_display") && (option[ii] == "None")) { + if ((target == "event_display") && (option[i] == "None")) { tooltip = "Display"; tooltip2 = "There is no Artifact set to be displayed at the event."; } @@ -81,17 +78,16 @@ if (opened == 1) { obj_controller.dropdown_open = 0; opened = 0; - var no; - no = false; - if ((target == "event_type") && (option[ii] != "Great Feast")) { + var no = false; + if ((target == "event_type") && (option[i] != "Great Feast")) { no = true; } if (no == false) { - option_selected = ii; + option_selected = i; } - if ((target == "event_type") && (option[ii] == "Great Feast")) { - obj_controller.fest_type = option[ii]; + if ((target == "event_type") && (option[i] == "Great Feast")) { + obj_controller.fest_type = option[i]; with (obj_dropdown_sel) { if (target == "event_public") { option[1] = ""; @@ -138,34 +134,34 @@ if (opened == 1) { obj_controller.fest_display = option_id[option_selected]; } if (target == "event_public") { - obj_controller.fest_locals = ii - 1; + obj_controller.fest_locals = i - 1; } if (target == "event_loc") { if (obj_controller.fest_planet == 0) { - obj_controller.fest_sid = option_id[ii]; + obj_controller.fest_sid = option_id[i]; obj_controller.fest_wid = 0; - if (option_id[ii] > 0) { - if ((obj_controller.fest_warp == 0) && (obj_ini.ship_location[option_id[ii]] == "Warp")) { + if (option_id[i] > 0) { + if ((obj_controller.fest_warp == 0) && (obj_ini.ship_location[option_id[i]] == "Warp")) { obj_controller.fest_warp = 1; } - if ((obj_controller.fest_warp == 1) && (obj_ini.ship_location[option_id[ii]] != "Warp")) { + if ((obj_controller.fest_warp == 1) && (obj_ini.ship_location[option_id[i]] != "Warp")) { obj_controller.fest_warp = 0; } - obj_controller.fest_attend = scr_event_dudes(0, 0, "", option_id[ii]); + obj_controller.fest_attend = scr_event_dudes(0, 0, "", option_id[i]); } - if (option[ii] == "None Selected") { + if (option[i] == "None Selected") { obj_controller.fest_sid = 0; obj_controller.fest_attend = ""; } } if (obj_controller.fest_planet == 1) { - obj_controller.fest_wid = option_id[ii]; + obj_controller.fest_wid = option_id[i]; obj_controller.fest_sid = 0; - obj_controller.fest_star = option_star[ii]; - if (option[ii] != "None Selected") { - obj_controller.fest_attend = scr_event_dudes(0, 1, option_star[ii], option_id[ii]); + obj_controller.fest_star = option_star[i]; + if (option[i] != "None Selected") { + obj_controller.fest_attend = scr_event_dudes(0, 1, option_star[i], option_id[i]); } - if (option[ii] == "None Selected") { + if (option[i] == "None Selected") { obj_controller.fest_wid = 0; obj_controller.fest_star = ""; obj_controller.fest_attend = ""; @@ -173,13 +169,13 @@ if (opened == 1) { } } if (target == "event_lavish") { - obj_controller.fest_lav = ii; + obj_controller.fest_lav = i; } if (target == "event_repeat") { - if (ii <= 4) { - obj_controller.fest_repeats = ii; + if (i <= 4) { + obj_controller.fest_repeats = i; } - if (ii == 5) { + if (i == 5) { obj_controller.fest_repeats = 12; } } @@ -202,20 +198,11 @@ if ((tooltip != "Great Feast") && (target == "event_type")) { tooltip2 = "(NOT COMPLETED YET)"; } -/* -if (tooltip="Tournament") then tooltip2="Hosts a non-lethal tournament for friendly competition."; -if (tooltip="Deathmatch") then tooltip2="Pits all those present to fight until one remains standing. HQ are unable to participate."; -if (tooltip="Imperial Mass") then tooltip2="Hosts Imperial Cult Mass for your astartes, in praise of the Emperor."; -if (tooltip="Chapter Sermon") then tooltip2="Hosts a Chapter Cult sermon for your astartes, praising the "+string(global.chapter_name)+"."; -if (tooltip="Chapter Relic") then tooltip2="Instructs your "+string(obj_ini.role[100][16])+"s and "+string(obj_ini.role[100][14])+"s to construct a Chapter artifact."; -if (tooltip="Triumphal March") then tooltip2="Present Astartes will participate in a massive march to present a show of arms and power."; -*/ - if ((tooltip != "") && (tooltip2 != "")) { draw_set_alpha(1); draw_set_font(fnt_40k_14); draw_set_halign(fa_left); - draw_set_color(0); + draw_set_color(c_black); draw_rectangle(mouse_x + 18, mouse_y + 20, mouse_x + string_width_ext(string_hash_to_newline(tooltip2), -1, 500) + 24, mouse_y + 44 + string_height_ext(string_hash_to_newline(tooltip2), -1, 500), 0); draw_set_color(c_gray); draw_rectangle(mouse_x + 18, mouse_y + 20, mouse_x + string_width_ext(string_hash_to_newline(tooltip2), -1, 500) + 24, mouse_y + 44 + string_height_ext(string_hash_to_newline(tooltip2), -1, 500), 1); @@ -224,6 +211,3 @@ if ((tooltip != "") && (tooltip2 != "")) { draw_set_font(fnt_40k_14); draw_text_ext(mouse_x + 22, mouse_y + 42, string_hash_to_newline(string(tooltip2)), -1, 500); } - -/* */ -/* */ diff --git a/objects/obj_dropdown_sel/Step_0.gml b/objects/obj_dropdown_sel/Step_0.gml index 91b94bbab1..70868f4554 100644 --- a/objects/obj_dropdown_sel/Step_0.gml +++ b/objects/obj_dropdown_sel/Step_0.gml @@ -5,35 +5,10 @@ if (obj_controller.menu != my_menu) { instance_destroy(); } -/* - - - - -option[1]="Great Feast"; -option[2]="Tournament"; -option[3]="Deathmatch"; -option[4]="Commision Relic"; -option[5]="Imperial Mass"; -option[6]="Cult Sermon"; -dro=instance_create(xx+1064,yy+126,obj_dropdown_sel);dro.target="event_type"; - dro=instance_create(xx+1100,yy+184,obj_dropdown_sel);dro.target="event_loc"; - dro=instance_create(xx+1088,yy+271,obj_dropdown_sel);dro.target="event_lavish"; - dro=instance_create(xx+1041,yy+385,obj_dropdown_sel);dro.target="event_display"; - dro=instance_create(xx+1041,yy+443,obj_dropdown_sel);dro.target="event_repeat"; - - -*/ - if (target == "event_type") { with (obj_controller) { fest_cost = 0; - /* - option[2]="Tournament"; - option[3]="Deathmatch"; - */ - if (fest_type == "Great Feast") { fest_cost = fest_lav * 20; if (fest_lav == 0) { @@ -42,8 +17,7 @@ if (target == "event_type") { if (fest_locals > 0) { fest_cost += 20 * fest_locals; } - var tt; - tt = fest_cost; + var tt = fest_cost; if (fest_feature1 == 0) { fest_cost = 0; } @@ -62,8 +36,7 @@ if (target == "event_type") { if (fest_locals > 0) { fest_cost += 20 * fest_locals; } - var tt; - tt = fest_cost; + var tt = fest_cost; if (fest_feature2 > 0) { fest_cost += 30; @@ -71,10 +44,6 @@ if (target == "event_type") { if ((fest_type == "Tournament") && (fest_feature3 > 0)) { fest_cost += 100; } - - /*if (fest_feature1=0) then fest_cost=0; - if (fest_feature2>0) then fest_cost+=round(tt/2); - if (fest_feature3>0) then fest_cost+=tt;*/ } if (fest_type == "Chapter Relic") { if (fest_feature1 == 1) { @@ -99,8 +68,7 @@ if (target == "event_type") { if (fest_locals > 0) { fest_cost += 40 * fest_locals; } - var tt; - tt = fest_cost; + var tt = fest_cost; if (fest_feature2 > 0) { fest_cost += 100; } @@ -116,8 +84,7 @@ if (target == "event_type") { if (fest_locals > 0) { fest_cost += 20 * fest_locals; } - var tt; - tt = fest_cost; + var tt = fest_cost; if (fest_feature2 > 0) { fest_cost += round(tt / 2); } @@ -133,8 +100,7 @@ if (target == "event_type") { if (fest_locals > 0) { fest_cost += 10 * fest_locals; } - var tt; - tt = fest_cost; + var tt = fest_cost; if (fest_feature1 > 0) { fest_cost += tt; } @@ -157,40 +123,27 @@ if (target == "event_honor") { if ((target == "event_loc") && (determined_planets == 0)) { // Fill out the options for planets - var coo, ide, q; - coo = -1; - ide = 0; - q = 0; - - repeat (11) { - coo += 1; - ide = 0; - - repeat (300) { - ide += 1; + for (var coo = 0; coo <= 10; coo++) { + for (var ide = 1; ide <= 300; ide++) { var _unit = fetch_unit([coo, ide]); if ((_unit.role() != obj_ini.role[100][6]) && (_unit.role() != "Venerable " + string(obj_ini.role[100][6])) && (_unit.planet_location > 0)) { - var stahp, first_open; - stahp = 0; - q = 0; - first_open = 0; + var stahp = 0; + var first_open = 0; - repeat (100) { - if (stahp == 0) { - q += 1; - if ((star[q] == "") && (first_open == 0)) { - first_open = q; - } - if (star[q] == _unit.location_string && star_planet[q] == _unit.planet_location) { - stahp = 1; - star_mahreens[q] += 1; - } + for (var q = 1; q <= 100; q++) { + if ((star[q] == "") && (first_open == 0)) { + first_open = q; + } + if (star[q] == _unit.location_string && star_planet[q] == _unit.planet_location) { + stahp = 1; + star_mahreens[q] += 1; + break; } } if (stahp == 0) { star[first_open] = _unit.location_string; star_planet[first_open] = _unit.planet_location; - star_marheens[first_open] = 1; + star_mahreens[first_open] = 1; } } } @@ -233,13 +186,8 @@ if (target == "event_public") { } if (option[1] == "") { - var ii; - ii = 0; - repeat (50) { - ii += 1; - option[ii] = ""; - option_id[ii] = 0; - } + option = array_create(50, ""); + option_id = array_create(50, 0); if (target == "event_type") { option[1] = "Great Feast"; @@ -253,10 +201,8 @@ if (option[1] == "") { option_selected = 1; } if (target == "event_loc") { - var q, works, thatone; - q = 0; - works = 1; - thatone = false; + var works = 1; + var thatone = false; option[1] = "None Selected"; option_id[1] = -50; options = 1; @@ -264,13 +210,12 @@ if (option[1] == "") { // Present ship options if (obj_controller.fest_planet == 0) { - repeat (70) { - q += 1; + for (var i = 1; i <= 70; i++) { thatone = false; - if ((obj_ini.ship[q] != "") && (obj_ini.ship_carrying[q] > 0)) { + if ((obj_ini.ship[i] != "") && (obj_ini.ship_carrying[i] > 0)) { works += 1; - option[works] = obj_ini.ship[q]; - option_id[works] = q; + option[works] = obj_ini.ship[i]; + option_id[works] = i; options += 1; thatone = false; } @@ -279,13 +224,12 @@ if (option[1] == "") { // Present planet options if (obj_controller.fest_planet == 1) { - repeat (80) { - q += 1; - if ((star[q] != "") && (star_mahreens[q] > 0)) { + for (var i = 1; i <= 80; i++) { + if ((star[i] != "") && (star_mahreens[i] > 0)) { options += 1; - option_star[options] = string(star[q]); - option[options] = string(star[q]) + " " + scr_roman(star_planet[q]); - option_id[options] = star_planet[q]; + option_star[options] = string(star[i]); + option[options] = string(star[i]) + " " + scr_roman(star_planet[i]); + option_id[options] = star_planet[i]; } } } @@ -300,39 +244,36 @@ if (option[1] == "") { options = 5; } if (target == "event_display") { - var q, arti_work, thatone; - q = 0; - arti_work = 1; - thatone = false; + var arti_work = 1; + var thatone = false; option[1] = "None"; option_id[1] = -50; options = 1; option_selected = 1; - repeat (obj_controller.artifacts) { - q += 1; + for (var i = 1; i <= obj_controller.artifacts; i++) { thatone = false; - if (obj_ini.artifact[q] == "Casket") { + if (obj_ini.artifact[i] == "Casket") { thatone = true; } - if (obj_ini.artifact[q] == "Chalice") { + if (obj_ini.artifact[i] == "Chalice") { thatone = true; } - if (obj_ini.artifact[q] == "Statue") { + if (obj_ini.artifact[i] == "Statue") { thatone = true; } - if (obj_ini.artifact[q] == "Tome") { + if (obj_ini.artifact[i] == "Tome") { thatone = true; } - if (obj_ini.artifact[q] == "Robot") { + if (obj_ini.artifact[i] == "Robot") { thatone = true; } if (thatone == true) { arti_work += 1; - option[arti_work] = obj_ini.artifact[q]; - option_id[arti_work] = q; + option[arti_work] = obj_ini.artifact[i]; + option_id[arti_work] = i; options += 1; thatone = false; } @@ -391,6 +332,3 @@ if (option[1] == "") { options = 4; } } - -/* */ -/* */ diff --git a/objects/obj_en_fleet/Alarm_1.gml b/objects/obj_en_fleet/Alarm_1.gml index b29e6b9c6a..19e9aa7202 100644 --- a/objects/obj_en_fleet/Alarm_1.gml +++ b/objects/obj_en_fleet/Alarm_1.gml @@ -2,19 +2,18 @@ try { var orb = orbiting; if ((round(owner) != eFACTION.IMPERIUM) && (navy == 1)) { - owner = noone; + owner = 0; } //TODO centralise orbiting logic var _is_orbiting = is_orbiting(); - if (orbiting != 0 && action == "" && owner != noone) { - var orbiting_found = _is_orbiting; - if (orbiting_found) { - orbiting_found = variable_instance_exists(orbiting, "present_fleet"); + if (action == "" && owner != 0) { + if (_is_orbiting) { + var orbiting_found = variable_instance_exists(orbiting, "present_fleet"); if (orbiting_found) { orbiting.present_fleet[owner] += 1; } - } else if (!orbiting_found) { + } else if (!_is_orbiting) { orbiting = instance_nearest(x, y, obj_star); orbiting.present_fleet[owner]++; } @@ -65,13 +64,8 @@ try { } } - // 1355; - if (instance_exists(obj_crusade) && (owner == eFACTION.ORK) && (orbiting.owner == eFACTION.ORK)) { // Ork crusade AI - var max_dis; - max_dis = 400; - var fleet_owner = owner; with (obj_crusade) { if (owner != fleet_owner) { @@ -127,45 +121,6 @@ try { instance_activate_object(obj_crusade); instance_activate_object(obj_en_fleet); - /*if (action="") and (owner = eFACTION.IMPERIUM){// Defend nearby systems and return when done - - with(obj_star){ - // 137 ; might want for it to defend under other circumstances - if (present_fleet[8]>0) and (owner<=5) and (x>2) and (y>2) then instance_create(x,y,obj_temp3); - } - if (instance_number(obj_temp3)=0) then ret=1; - if (instance_number(obj_temp3)>0){ - var you,dis,mem; - you=instance_nearest(x,y,obj_temp3); - dis=point_distance(x,y,you.x,you.y); - - if (dis<300) and (image_index>=3){ - action_x=you.x;action_y=you.y; - home_x=instance_nearest(x,y,obj_star).x; - home_y=instance_nearest(x,y,obj_star).y; - set_fleet_movement();with(obj_temp3){instance_destroy();} - exit; - } - if (dis>=300) then ret=1; - } - - if (instance_exists(obj_crusade)){ - var cru;cru=instance_nearest(x,y,obj_crusade); - if (cru.owner=self.owner) and (point_distance(x,y,cru.x,cru.y)0){ - action_x=home_x; - action_y=home_y; - set_fleet_movement(); - } - } - - with(obj_temp3){instance_destroy();} - }*/ - if (owner == eFACTION.INQUISITION) { var valid = true; if (instance_exists(target)) { @@ -188,28 +143,28 @@ try { scr_loyalty("Heretic Homeworld", "+"); } - var whom = -1; - whom = inquisitor; + var whom = inquisitor; var inquisitors = obj_controller.inquisitor; var inquis_string = $"Inquisitor {whom > -1 ? inquisitors[whom] : inquisitors[0]}"; // INVESTIGATE DEAD HERE 137 ; INVESTIGATE DEAD HERE 137 ; INVESTIGATE DEAD HERE 137 ; INVESTIGATE DEAD HERE 137 ; - var cur_star, t, type, cha, dem, tem1, tem1_base, perc, popup; - t = 0; - type = 0; - cha = 0; - dem = 0; - tem1 = 0; - popup = 0; - perc = 0; - tem1_base = 0; - - cur_star = instance_nearest(x, y, obj_star); + var t = 0; + var type = 0; + var cha = 0; + var dem = 0; + var tem1 = 0; + var popup = 0; + var perc = 0; + var tem1_base = 0; + + var cur_star = instance_nearest(x, y, obj_star); if (string_count("investigate", trade_goods) > 0) { // Check for xenos or demon-equip items on those planets //TODO update this to check weapon or artifact tags - var e = 0, ia = -1, ca = 0; + var e = 0; + var ia = -1; + var ca = 0; var _unit; repeat (4400) { if ((ca <= 10) && (ca >= 0)) { @@ -259,9 +214,7 @@ try { orbiting = instance_nearest(x, y, obj_star); - // 135; if (obj_controller.loyalty_hidden <= 0) { - // obj_controller.alarm[7]=1;global.defeat=2; var moo = false; if ((obj_controller.penitent == 1) && (moo == false)) { obj_controller.alarm[8] = 1; @@ -289,23 +242,6 @@ try { obj_controller.known[eFACTION.TAU] = 1; } } - - /*if (image_index>=4){ - with(obj_star){ - if (owner = eFACTION.TAU) and (present_fleets>0) and (tau_fleets=0){ - instance_create(x,y,obj_temp5); - } - } - if (instance_exists(obj_temp5)){ - var wop;wop=instance_nearest(x,y,obj_temp5); - if (wop!=0) and (point_distance(x,y,wop.x,wop.y)<300) and (wop.x>5) and (wop.y>5){ - target_x=wop.x;target_y=wop.y; - home_x=x;home_y=y; - set_fleet_movement(); - } - } - with(obj_temp5){instance_destroy();} - }*/ } if (owner == eFACTION.TYRANIDS) { @@ -344,12 +280,11 @@ try { } if (n) { - var xx, yy, good, plin, plin2; - xx = 0; - yy = 0; - good = 0; - plin = 0; - plin2 = 0; + var xx = 0; + var yy = 0; + var good = 0; + var plin = 0; + var plin2 = 0; if (capital_number > 5) { n = 5; @@ -394,11 +329,6 @@ try { new_fleet.sprite_index = spr_fleet_tyranid; new_fleet.image_index = 1; - /*with(new_fleet){ - var ii;ii=0;ii+=capital_number;ii+=round((frigate_number/2));ii+=round((escort_number/4)); - if (ii<=1) then ii=1;image_index=ii; - }*/ - new_fleet.action_x = plin2.x; new_fleet.action_y = plin2.y; with (new_fleet) { @@ -444,7 +374,7 @@ try { var dos = 0; dos = point_distance(x, y, action_x, action_y); - orbiting = dos / action_eta; + orbiting = dos / max(1, action_eta); dir = point_direction(x, y, action_x, action_y); x = x + lengthdir_x(orbiting, dir); @@ -452,17 +382,13 @@ try { action_eta -= 1; - /*if (owner>5){ - - }*/ - if ((action_eta == 2) && (owner == eFACTION.INQUISITION) && (inquisitor > -1)) { inquisitor_ship_approaches(); } else if (action_eta == 0) { action = ""; if (array_length(complex_route) > 0) { var target_loc = find_star_by_name(complex_route[0]); - if (target_loc != "none") { + if (target_loc != noone) { array_delete(complex_route, 0, 1); action_x = target_loc.x; action_y = target_loc.y; diff --git a/objects/obj_en_fleet/Alarm_3.gml b/objects/obj_en_fleet/Alarm_3.gml index f26bcbe2ab..82e7e5d05c 100644 --- a/objects/obj_en_fleet/Alarm_3.gml +++ b/objects/obj_en_fleet/Alarm_3.gml @@ -8,9 +8,7 @@ obj_controller.fleet_minimized = 0; obj_controller.selected = instance_nearest(x, y, obj_en_fleet); -// obj_controller.selected=self; obj_controller.sel_owner = self.owner; -// show_message(obj_controller.selected); obj_controller.cooldown = 8; if (obj_controller.zoomed == 1) { @@ -21,8 +19,6 @@ if (obj_controller.zoomed == 1) { obj_cursor.image_yscale = 1; } -// Pass variables to obj_controller.temp[t]=""; here -// Pass variables to obj_controller.temp[t]=""; here with (obj_fleet_select) { instance_destroy(); } diff --git a/objects/obj_en_fleet/Alarm_4.gml b/objects/obj_en_fleet/Alarm_4.gml index cfe41c63f2..e1ed832c5a 100644 --- a/objects/obj_en_fleet/Alarm_4.gml +++ b/objects/obj_en_fleet/Alarm_4.gml @@ -1,30 +1,12 @@ try { if (action != "") { - var sys, sys_dist, mine, connected, cont; - sys_dist = 9999; - connected = 0; - cont = 0; - - sys = instance_nearest(action_x, action_y, obj_star); - sys_dist = point_distance(action_x, action_y, sys.x, sys.y); + var sys = instance_nearest(action_x, action_y, obj_star); act_dist = point_distance(x, y, sys.x, sys.y); - mine = instance_nearest(x, y, obj_star); - if ((mine.x == sys.x2) && (mine.y == sys.y2)) { - connected = 1; - } - - var eta; - eta = 0; - eta = floor(point_distance(x, y, action_x, action_y) / action_spd) + 1; - if (connected == 0) { - eta = eta * 2; - } + var mine = instance_nearest(x, y, obj_star); if ((owner == eFACTION.INQUISITION) && (action_eta < 2)) { action_eta = 2; } - // action_x=sys.x; - // action_y=sys.y; action = "move"; if ((owner != eFACTION.ELDAR) && (mine.storm > 0)) { @@ -36,84 +18,65 @@ try { } if (action == "") { - var sys, sys_dist, mine, connected, cont, target_dist; - sys_dist = 9999; - connected = 0; - cont = 0; - target_dist = 0; - - sys = instance_nearest(action_x, action_y, obj_star); - sys_dist = point_distance(action_x, action_y, sys.x, sys.y); + var sys = instance_nearest(action_x, action_y, obj_star); + var sys_dist = point_distance(action_x, action_y, sys.x, sys.y); + var target_dist = 0; if (scr_valid_fleet_target(target)) { target_dist = point_distance(x, y, target.action_x, target.action_y); } else { - target = 0; + target = noone; } act_dist = point_distance(x, y, sys.x, sys.y); - mine = instance_nearest(x, y, obj_star); + var mine = instance_nearest(x, y, obj_star); - // if (owner = eFACTION.TAU) then mine.tau_fleets-=1; - // if (owner = eFACTION.TAU) and (image_index!=1) then mine.tau_fleets-=1; - // mine.present_fleets-=1; + var connected = determine_warp_join(mine, sys); - connected = determine_warp_join(mine, sys); - cont = 1; + // Move the entire fleet, don't worry about the other crap + turns_static = 0; - if (cont == 1) { - cont = 20; - } - - if (cont == 20) { - // Move the entire fleet, don't worry about the other crap - turns_static = 0; - var eta = 0; - - if ((trade_goods != "") && (owner != eFACTION.TYRANIDS) && (owner != eFACTION.CHAOS) && (string_count("Inqis", trade_goods) == 0) && (string_count("merge", trade_goods) == 0) && (string_count("_her", trade_goods) == 0) && (trade_goods != "cancel_inspection") && (trade_goods != "return")) { - if (scr_valid_fleet_target(target)) { - if (target.action != "") { - if (target_dist > sys_dist) { - action_x = target.action_x; - action_y = target.action_y; - sys = instance_nearest(action_x, action_y, obj_star); - } + if ((trade_goods != "") && (owner != eFACTION.TYRANIDS) && (owner != eFACTION.CHAOS) && (string_count("Inqis", trade_goods) == 0) && (string_count("merge", trade_goods) == 0) && (string_count("_her", trade_goods) == 0) && (trade_goods != "cancel_inspection") && (trade_goods != "return")) { + if (scr_valid_fleet_target(target)) { + if (target.action != "") { + if (target_dist > sys_dist) { + action_x = target.action_x; + action_y = target.action_y; + sys = instance_nearest(action_x, action_y, obj_star); } - } else { - target = 0; } + } else { + target = noone; } + } - eta = floor(point_distance(x, y, action_x, action_y) / action_spd) + 1; - if (connected == 0) { - eta = eta * 2; - } - - if ((action_eta <= 0) || (owner != eFACTION.INQUISITION)) { - action_eta = eta; - if ((owner == eFACTION.INQUISITION) && (action_eta < 2) && (string_count("_her", trade_goods) == 0)) { - action_eta = 2; - } - } + var eta = floor(point_distance(x, y, action_x, action_y) / action_spd) + 1; + if (connected == 0) { + eta = eta * 2; + } - if ((owner != eFACTION.ELDAR) && (mine.storm > 0)) { - action_eta += 10000; + if ((action_eta <= 0) || (owner != eFACTION.INQUISITION)) { + action_eta = eta; + if ((owner == eFACTION.INQUISITION) && (action_eta < 2) && (string_count("_her", trade_goods) == 0)) { + action_eta = 2; } + } - // action_x=sys.x; - // action_y=sys.y; - action = "move"; + if ((owner != eFACTION.ELDAR) && (mine.storm > 0)) { + action_eta += 10000; + } - if ((minimum_eta > action_eta) && (minimum_eta > 0)) { - action_eta = minimum_eta; - } - minimum_eta = 0; - if ((etah > action_eta) && (etah != 0)) { - action_eta = etah; - } + action = "move"; - x = x + lengthdir_x(24, point_direction(x, y, sys.x, sys.y)); - y = y + lengthdir_y(24, point_direction(x, y, sys.x, sys.y)); + if ((minimum_eta > action_eta) && (minimum_eta > 0)) { + action_eta = minimum_eta; + } + minimum_eta = 0; + if ((etah > action_eta) && (etah != 0)) { + action_eta = etah; } + + x = x + lengthdir_x(24, point_direction(x, y, sys.x, sys.y)); + y = y + lengthdir_y(24, point_direction(x, y, sys.x, sys.y)); } etah = 0; diff --git a/objects/obj_en_fleet/Alarm_5.gml b/objects/obj_en_fleet/Alarm_5.gml index 5f31ff9eb2..24533f6691 100644 --- a/objects/obj_en_fleet/Alarm_5.gml +++ b/objects/obj_en_fleet/Alarm_5.gml @@ -11,9 +11,6 @@ if (rep > 0) { } if (rep == 0) { - // if (id mod 2 == 0) then action_eta=obj_controller.temp[90]; - // else{action_eta=obj_controller.temp[90]-1;} - action_eta = obj_controller.temp[90] - choose(0, 1); rep = 3; diff --git a/objects/obj_en_fleet/Alarm_8.gml b/objects/obj_en_fleet/Alarm_8.gml index c2b74fb6d2..f575c966b7 100644 --- a/objects/obj_en_fleet/Alarm_8.gml +++ b/objects/obj_en_fleet/Alarm_8.gml @@ -1,5 +1,4 @@ -var wop; -wop = instance_nearest(x, y, obj_star); +var wop = instance_nearest(x, y, obj_star); if (instance_exists(wop)) { if (point_distance(x, y, wop.x, wop.y) <= 40) { wop.present_fleet[owner] += 1; diff --git a/objects/obj_en_fleet/Collision_obj_pnunit.gml b/objects/obj_en_fleet/Collision_obj_pnunit.gml index 0a10a77ae4..e69de29bb2 100644 --- a/objects/obj_en_fleet/Collision_obj_pnunit.gml +++ b/objects/obj_en_fleet/Collision_obj_pnunit.gml @@ -1,14 +0,0 @@ -/* -if (other.sprite_index != self.sprite_index) { - if (other.action="") and (action="") and (other.owner=owner) and (string_count("her",trade_goods)=0) and (string_count("her",string(other.trade_goods))=0){ - if (obj_controller.faction_status[eFACTION.IMPERIUM]="War") and (instance_nearest(x,y,obj_star).owner = eFACTION.PLAYER) and (owner = eFACTION.IMPERIUM) and (other.owner = eFACTION.IMPERIUM){ - if (id>other.id){ - guardsmen+=other.guardsmen; - capital_number+=other.capital_number; - frigate_number+=other.frigate_number; - escort_number+=other.escort_number; - with(other){instance_destroy();} - } - } - } -} */ // No colonists and fleets bashing together \ No newline at end of file diff --git a/objects/obj_en_fleet/Create_0.gml b/objects/obj_en_fleet/Create_0.gml index 5228a687f7..4ff5ba0b55 100644 --- a/objects/obj_en_fleet/Create_0.gml +++ b/objects/obj_en_fleet/Create_0.gml @@ -8,8 +8,8 @@ home_y = 0; selected = 0; ret = 0; hurt = 0; -/// @type {Asset.GMObject.obj_star} -orbiting = 0; +/// @type {Id.Instance.obj_star} +orbiting = noone; rep = 3; minimum_eta = 2; turns_static = 0; @@ -116,15 +116,14 @@ deserialize = function(save_data) { continue; } var loaded_value = struct_get(save_data, var_name); - // LOGGER.debug($"en_fleet {en_fleet_instance.id} - var: {var_name} - val: {loaded_value}"); try { - variable_struct_set(self, var_name, loaded_value); + variable_instance_set(self, var_name, loaded_value); } catch (e) { LOGGER.exception("Deserialization failed", e); } } if (struct_exists(save_data, "cargo_data")) { - variable_struct_set(self, "cargo_data", save_data.cargo_data); + variable_instance_set(self, "cargo_data", save_data.cargo_data); if (fleet_has_cargo("ork_warboss")) { var _boss = new NewPlanetFeature(eP_FEATURES.ORKWARBOSS); _boss.load_json_data(cargo_data.ork_warboss); @@ -132,10 +131,8 @@ deserialize = function(save_data) { } } - if (save_data.orbiting != 0 && action == "") { - var nearest_star = instance_nearest(x, y, obj_star); - orbiting = nearest_star; - // LOGGER.debug($"p_fleet id {id} deserialized: {self}"); + if (save_data.orbiting != noone && action == "") { + orbiting = instance_nearest(x, y, obj_star); } }; diff --git a/objects/obj_en_fleet/Destroy_0.gml b/objects/obj_en_fleet/Destroy_0.gml index 205e6cddac..e8dfacde7d 100644 --- a/objects/obj_en_fleet/Destroy_0.gml +++ b/objects/obj_en_fleet/Destroy_0.gml @@ -1,12 +1,8 @@ -/*if (owner = eFACTION.CHAOS){ - show_message("Trade Goods: "+string(trade_goods)+"#Alarms: "+string(alarm[0])+"|"+string(alarm[1])+"|"+string(alarm[2])+"|"+string(alarm[4])); -}*/ - -if ((action == "") && (orbiting != 0)) { +if ((action == "") && (orbiting != noone)) { if (orbiting == instance_nearest(x, y, obj_star)) { orbiting.present_fleet[owner] -= 1; } - orbiting = 0; + orbiting = noone; } if (instance_exists(obj_controller)) { @@ -21,6 +17,3 @@ if (instance_exists(obj_controller)) { } } } - -/* */ -/* */ diff --git a/objects/obj_en_fleet/Draw_0.gml b/objects/obj_en_fleet/Draw_0.gml index 050ea8b33f..5eaf44cc36 100644 --- a/objects/obj_en_fleet/Draw_0.gml +++ b/objects/obj_en_fleet/Draw_0.gml @@ -20,7 +20,7 @@ var coords = [ ]; var near_star = instance_nearest(x, y, obj_star); if (x == near_star.x && y == near_star.y) { - var coords = fleet_star_draw_offsets(); + coords = fleet_star_draw_offsets(); } if (image_index > 9) { @@ -48,8 +48,6 @@ if (obj_controller.zoomed == 1) { } } -// if (obj_controller.selected!=0) and (selected=1) then within=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)) { @@ -79,7 +77,6 @@ if (action != "") { draw_set_alpha(1); draw_set_color(c_white); draw_line_width(x, y, action_x, action_y, 1); - // draw_set_font(fnt_40k_14b); if (obj_controller.zoomed == 0) { draw_text_transformed(x + 12, y, string_hash_to_newline("ETA " + string(action_eta)), 1, 1, 0); @@ -88,9 +85,9 @@ if (action != "") { draw_text_transformed(x + 24, y, string_hash_to_newline("ETA " + string(action_eta)), 2, 2, 0); } // was 1.4 } +var _has_warboss = false; switch (owner) { case eFACTION.ORK: - var _has_warboss = false; if (fleet_has_cargo("ork_warboss")) { draw_icon = true; _has_warboss = true; @@ -103,7 +100,6 @@ if ((within == 1) || (selected > 0)) { draw_set_font(fnt_40k_14b); draw_set_halign(fa_center); - var fleet_descript = ""; if (owner == eFACTION.PLAYER) { fleet_descript = "Renegade Fleet"; } @@ -123,7 +119,6 @@ if ((within == 1) || (selected > 0)) { } } } - // if (navy=1) then fleet_descript=string(trade_goods)+" ("+string(guardsmen_unloaded)+"/"+string(guardsmen_ratio)+")"; switch (owner) { case eFACTION.MECHANICUS: fleet_descript = "Mechanicus Fleet"; @@ -161,15 +156,10 @@ if ((within == 1) || (selected > 0)) { break; } - // if (owner = eFACTION.IMPERIUM) and (navy=1){fleet_descript=string(capital_max_imp[1]+frigate_max_imp[1]+escort_max_imp[1]);} - if (global.cheat_debug == true) { fleet_descript += "C" + string(capital_number) + "|F" + string(frigate_number) + "|E" + string(escort_number); } - // fleet_descript=string(capital_number)+"|"+string(frigate_number)+"|"+string(escort_number); - // fleet_descript+="|"+string(trade_goods); - draw_set_halign(fa_left); } @@ -194,19 +184,9 @@ if (draw_icon) { } draw_sprite_ext(sprite_index, image_index, x + (coords[0] * scale), y + (coords[1] * scale), 1 * scale, 1 * scale, 0, c_white, 1); -/*if (owner = eFACTION.ORK){ - draw_set_font(fnt_small); - draw_set_halign(fa_center); - draw_set_color(c_white); - draw_text(x,y+32,string(escort_number)+"/"+string(frigate_number)+"/"+string(capital_number)); -}*/ - if (instance_exists(target)) { draw_set_color(c_red); draw_set_alpha(0.5); draw_line(x, y, target.x, target.y); draw_set_alpha(1); } - -/* */ -/* */ diff --git a/objects/obj_en_fleet/KeyPress_73.gml b/objects/obj_en_fleet/KeyPress_73.gml index 871f147a6a..e69de29bb2 100644 --- a/objects/obj_en_fleet/KeyPress_73.gml +++ b/objects/obj_en_fleet/KeyPress_73.gml @@ -1,12 +0,0 @@ -/*if (navy=1){ - var fid,tot,i;i=-1; - fid=self.id;tot=0; - - repeat(21){i+=1;tot+=capital_imp[i];} - i=-1;repeat(31){i+=1;tot+=frigate_imp[i]} - - show_message("Fleet: "+string(fid)+"#Action: "+string(trade_goods)+"#E"+string(escort_number)+"|F"+string(frigate_number)+"|C:"+string(capital_number)+"#Total Guardsmen: "+string(scr_display_number(tot))); -}*/ - -/* */ -/* */ diff --git a/objects/obj_en_fleet/Step_0.gml b/objects/obj_en_fleet/Step_0.gml index f6ef070d0f..baabf203df 100644 --- a/objects/obj_en_fleet/Step_0.gml +++ b/objects/obj_en_fleet/Step_0.gml @@ -2,16 +2,16 @@ if ((global.load >= 0) || instance_exists(obj_saveload)) { exit; } -if ((action != "") && (orbiting != 0)) { +if ((action != "") && (orbiting != noone)) { if (instance_exists(orbiting)) { if (variable_instance_exists(orbiting, "present_fleet")) { orbiting.present_fleet[owner] -= 1; - orbiting = 0; + orbiting = noone; } else { orbiting = instance_nearest(x, y, obj_star); var cur_owner_fleet = orbiting.present_fleet[owner]; orbiting.present_fleet[owner] = cur_owner_fleet > 0 ? cur_owner_fleet - 1 : cur_owner_fleet == 0; - orbiting = 0; + orbiting = noone; } } } @@ -45,8 +45,7 @@ if (ii_check == 0) { ii_check = 10; if ((owner != eFACTION.ELDAR) && (owner != eFACTION.INQUISITION)) { - var ii = 0; - ii += capital_number; + var ii = capital_number; ii += round((frigate_number / 2)); ii += round((escort_number / 4)); if (ii <= 1) { @@ -56,9 +55,7 @@ if (ii_check == 0) { image_index = min(image_index, 9); } if (owner == eFACTION.ELDAR) { - var ii; - ii = 0; - ii += capital_number; + var ii = capital_number; ii += round((frigate_number / 2)); ii += round((escort_number / 4)); if (ii <= 1) { @@ -75,8 +72,7 @@ if (ii_check == 0) { if (owner == eFACTION.TYRANIDS) { image_alpha = 0; if (instance_exists(obj_p_fleet)) { - var bundy; - bundy = instance_nearest(x, y, obj_p_fleet); + var bundy = instance_nearest(x, y, obj_p_fleet); if ((bundy.action == "") && (self.action == "") && (point_distance(bundy.x, bundy.y, x, y) < 90) && (bundy.x > x) && (bundy.y < y)) { image_alpha = 1; } @@ -89,7 +85,6 @@ if (owner == eFACTION.TYRANIDS) { if ((owner == eFACTION.TAU) && (action_spd != 32)) { action_spd = 32; } -// if (owner = eFACTION.TAU) and (image_index>1) if (owner == eFACTION.MECHANICUS) { if (action != "") { direction = point_direction(x, y, action_x, action_y); @@ -103,13 +98,12 @@ if ((owner == eFACTION.ELDAR) && (trade_goods != "") && (action == "move")) { if ((owner == eFACTION.TAU) && (action == "") && (obj_controller.tau_messenger >= 30) && (frigate_number > 0) && (escort_number + capital_number > 0)) { obj_controller.tau_messenger = 0; - var fleet, good, stir, xx, yy; - stir = 0; - xx = 0; - yy = 0; - good = 0; + var stir = 0; + var xx = 0; + var yy = 0; + var good = 0; - fleet = instance_nearest(x, y, obj_star); + var fleet = instance_nearest(x, y, obj_star); fleet.tau_fleets += 1; fleet.present_fleets += 1; instance_deactivate_object(fleet); diff --git a/objects/obj_en_ship/Alarm_0.gml b/objects/obj_en_ship/Alarm_0.gml index 5f40906f56..b4e28c2640 100644 --- a/objects/obj_en_ship/Alarm_0.gml +++ b/objects/obj_en_ship/Alarm_0.gml @@ -1246,22 +1246,6 @@ if ((owner != eFACTION.ELDAR) && (owner != eFACTION.NECRONS)) { bridge = maxhp; -/* -if (obj_fleet.enemy == 2) { - hp = hp * 0.75; - maxhp = hp; - shields = shields * 0.75; - maxshields = shields; -} - */ -// hp=1; -shields = 1; - -// if (obj_fleet.enemy="orks") then name=global.name_generator.GenerateFromSet("ork_ship"); +// shields = 1; name = "sdagdsagdasg"; - -// show_message(string(class)); - -/* */ -/* */ diff --git a/objects/obj_en_ship/Create_0.gml b/objects/obj_en_ship/Create_0.gml index 959fba43ae..6955f5ce31 100644 --- a/objects/obj_en_ship/Create_0.gml +++ b/objects/obj_en_ship/Create_0.gml @@ -3,7 +3,6 @@ owner = 0; action = ""; direction = 180; -// if (instance_exists(obj_p_ship)){target=instance_nearest(x,y,obj_p_ship);} /// @type {Asset.GMObject.obj_p_ship} target_l = 0; diff --git a/objects/obj_en_ship/Draw_0.gml b/objects/obj_en_ship/Draw_0.gml index ff36fa9843..738f09e7d5 100644 --- a/objects/obj_en_ship/Draw_0.gml +++ b/objects/obj_en_ship/Draw_0.gml @@ -1,13 +1,6 @@ if (name != "") { draw_set_font(fnt_info); draw_set_halign(fa_center); - - // 135; - /*if (action="broadside"){ - draw_set_color(c_blue);if (instance_exists(target_l)) then draw_line(x,y,target_l.x,target_l.y); - draw_set_color(c_red);if (instance_exists(target_r)) then draw_line(x,y,target_r.x,target_r.y); - }draw_set_color(CM_GREEN_COLOR);*/ - draw_set_alpha(1); if ((lightning > 1) && instance_exists(target)) { diff --git a/objects/obj_en_ship/Step_0.gml b/objects/obj_en_ship/Step_0.gml index b5987450da..04c45c9327 100644 --- a/objects/obj_en_ship/Step_0.gml +++ b/objects/obj_en_ship/Step_0.gml @@ -1,4 +1,4 @@ -if (owner != 6) { +if (owner != eFACTION.ELDAR) { image_angle = direction; if (obj_fleet.start != 5) { @@ -9,8 +9,6 @@ if (owner != 6) { image_alpha += 0.006; } - var o_dist, dist, ch_rang, ex, spid; - spid = 0; if ((shields > 0) && (shields < maxshields)) { shields += 0.02; @@ -26,9 +24,8 @@ if (owner != 6) { target = instance_nearest(x, y, obj_al_ship); } if (instance_exists(obj_p_ship) && instance_exists(obj_al_ship)) { - var tp1, tp2; - tp1 = instance_nearest(x, y, obj_p_ship); - tp2 = instance_nearest(x, y, obj_al_ship); + var tp1 = instance_nearest(x, y, obj_p_ship); + var tp2 = instance_nearest(x, y, obj_al_ship); if (point_distance(x, y, tp1.x, tp1.y) <= point_distance(x, y, tp2.x, tp2.y)) { target = tp1; } @@ -41,13 +38,10 @@ if (owner != 6) { } if (hp <= 0) { - var wh, gud; - wh = 0; - gud = 0; - repeat (5) { - wh += 1; - if (obj_fleet.enemy[wh] == owner) { - gud = wh; + var gud = 0; + for (var i = 1; i <= 5; i++) { + if (obj_fleet.enemy[i] == owner) { + gud = i; } } @@ -64,18 +58,14 @@ if (owner != 6) { image_alpha = 0.5; if (owner != eFACTION.TYRANIDS) { - // ex=instance_create(x,y,obj_explosion); - // ex.image_xscale=2;ex.image_yscale=2;ex.image_speed=0.75; - var husk; - husk = instance_create(x, y, obj_en_husk); + var husk = instance_create(x, y, obj_en_husk); husk.sprite_index = sprite_index; husk.direction = direction; husk.image_angle = image_angle; husk.depth = depth; husk.image_speed = 0; repeat (choose(4, 5, 6)) { - var explo; - explo = instance_create(x, y, obj_explosion); + var explo = instance_create(x, y, obj_explosion); explo.image_xscale = 0.5; explo.image_yscale = 0.5; explo.x += random_range(sprite_width * 0.25, sprite_width * -0.25); @@ -89,6 +79,8 @@ if (owner != 6) { } if ((hp > 0) && instance_exists(obj_p_ship)) { + var spid = 0; + var o_dist = 0; if (class == "Apocalypse Class Battleship") { o_dist = 500; action = "attack"; @@ -191,11 +183,9 @@ if (owner != 6) { spid = 45; } - // if (class!="big") then flank!!!! + spid *= speed_bonus; - spid = spid * speed_bonus; - - dist = point_distance(x, y, target.x, target.y) - max(sprite_get_width(sprite_index), sprite_get_height(sprite_index)); + var dist = point_distance(x, y, target.x, target.y) - max(sprite_get_width(sprite_index), sprite_get_height(sprite_index)); if ((target != 0) && (action == "attack")) { direction = turn_towards_point(direction, x, y, target.x, target.y, 0.1); @@ -220,42 +210,6 @@ if (owner != 6) { } } - /*if (target!=0) and (action="broadside") and (o_dist>=dist){ - direction=turn_towards_point(direction,x+lengthdir_x(128,target.direction-90),y,target.x,target.y+lengthdir_y(128,target.direction-90),.2) - }*/ - - /*if (target!=0) and (action="broadside") and (o_dist>=dist){ - var re_deh;re_deh=relative_direction(direction,target.direction); - - // if (re_deh<45) or (re_deh>315) or ((re_deh>135) and (re_deh<225)) then direction=turn_towards_point(direction,x+lengthdir_x(128,target.direction-90),y,target.x,target.y+lengthdir_y(128,target.direction-90),.2) - - var wok; - wok=0; - - if (!instance_exists(target_l)) then wok=2; - if (!instance_exists(target_r)) then wok=1; - - if (instance_exists(target_l)) and (instance_exists(target_r)){ - if (point_distance(x,y,target_l.x,target_l.y))<(point_distance(x,y,target_r.x,target_r.y)) then wok=1; - else{wok=2;} - - } - - - if (wok=1){ - direction=turn_towards_point(direction,x,y,x+lengthdir_x(256,90),y+lengthdir_y(256,90),.2) - } - - if (wok=2){ - direction=turn_towards_point(direction,x,y,x+lengthdir_x(256,270),y+lengthdir_y(256,270),.2) - } - - // direction=turn_towards_point(direction,x+lengthdir_x(128,target.direction-90),y,target.x,target.y+lengthdir_y(128,target.direction-90),.2) - - - - }*/ - if (action == "attack") { if ((dist > o_dist) && (speed < (spid / 10))) { speed += 0.005; @@ -296,58 +250,35 @@ if (owner != 6) { turret_cool -= 1; } - var bull, targe, rdir, dirr, dist, xx, yy, ok; - targe = 0; - rdir = 0; - dirr = ""; - dist = 9999; - xx = x; - yy = y; - if ((turrets > 0) && instance_exists(obj_p_small) && (turret_cool == 0)) { - /// @type {Asset.GMObject.obj_p_small} - targe = instance_nearest(x, y, obj_p_small); + var targe = instance_nearest(x, y, obj_p_small); if (instance_exists(targe)) { dist = point_distance(x, y, targe.x, targe.y); - } - - if ((dist > 64) && (dist < 300)) { - /// @type {Asset.GMObject.obj_en_round} - bull = instance_create(x, y, obj_en_round); - bull.direction = point_direction(x, y, targe.x, targe.y); - if (owner == eFACTION.TYRANIDS) { - bull.sprite_index = spr_glob; - } - bull.speed = 20; - bull.dam = 3; - bull.image_xscale = 0.5; - bull.image_yscale = 0.5; - turret_cool = floor(60 / turrets); - if (owner == eFACTION.NECRONS) { - bull.sprite_index = spr_green_las; - bull.image_yscale = 1; + if ((dist > 64) && (dist < 300)) { + var bull = instance_create(x, y, obj_en_round); + bull.direction = point_direction(x, y, targe.x, targe.y); + if (owner == eFACTION.TYRANIDS) { + bull.sprite_index = spr_glob; + } + bull.speed = 20; + bull.dam = 3; + bull.image_xscale = 0.5; + bull.image_yscale = 0.5; + turret_cool = floor(60 / turrets); + if (owner == eFACTION.NECRONS) { + bull.sprite_index = spr_green_las; + bull.image_yscale = 1; + } + bull.direction += choose(random(10), 1 * -random(10)); } - bull.direction += choose(random(10), 1 * -random(10)); } } - targe = 0; - rdir = 0; - dirr = ""; - dist = 9999; - - xx = lengthdir_x(64, direction + 90); - yy = lengthdir_y(64, direction + 90); - var front, right, left, rear; - front = 0; - right = 0; - left = 0; - rear = 0; + var front = 0; + var right = 0; + var left = 0; + var rear = 0; - targe = instance_nearest(xx, yy, obj_p_ship); - rdir = point_direction(x, y, target.x, target.y); - // if (rdir>45) and (rdir<=135) and (targe!=target){target_r=targe;right=1;} - // if (rdir>225) and (rdir<=315) and (targe!=target) and (targe!=target_r){target_l=targe;left=1;} target_l = instance_nearest(x + lengthdir_x(64, direction + 90), y + lengthdir_y(64, direction + 90), obj_p_ship); target_r = instance_nearest(x + lengthdir_x(64, direction + 270), y + lengthdir_y(64, direction + 270), obj_p_ship); @@ -355,39 +286,26 @@ if (owner != 6) { front = 1; } - var f, facing, ammo, range, wep, dam, gg; - f = 0; - facing = ""; - ammo = 0; - range = 0; - wep = ""; - dam = 0; - gg = 0; - lightning = 0; - repeat (weapons) { - gg += 1; + for (var i = 1; i <= weapons; i++) { + var ok = 0; + var facing = ""; + var ammo = 0; + var range = 0; + var wep = ""; + var bull = noone; - ok = 0; - f += 1; - facing = ""; - ammo = 0; - range = 0; - wep = ""; - - //weapon[gg]=0;weapon_ammo[gg]=0;weapon_range[gg]=0; - - if ((cooldown[gg] <= 0) && (weapon[gg] != "") && (weapon_ammo[gg] > 0)) { + if ((cooldown[i] <= 0) && (weapon[i] != "") && (weapon_ammo[i] > 0)) { ok = 1; } if (ok == 1) { - facing = weapon_facing[gg]; - ammo = weapon_ammo[gg]; - range = weapon_range[gg]; + facing = weapon_facing[i]; + ammo = weapon_ammo[i]; + range = weapon_range[i]; } - targe = target; + var targe = target; if ((facing == "front") && (front == 1)) { ok = 2; } @@ -395,13 +313,6 @@ if (owner != 6) { ok = 2; } - /* - if (facing="right") then targe=target_r; - if (facing="left") then targe=target_l; - if ((facing="front") or (facing="most")) and (front=1) then ok=2; - if (facing="right") or (facing="most") and (right=1) then ok=2; - if (facing="left") or (facing="most") and (left=1) then ok=2; - */ if (facing == "special") { ok = 2; } @@ -417,25 +328,19 @@ if (owner != 6) { ok = 2; } - /*var re_deh;re_deh=relative_direction(direction,target.direction); - if (re_deh<45) or (re_deh>315) or ((re_deh>135) and (re_deh<225)) then direction=turn_towards_point(direction,x+lengthdir_x(128,target.direction-90),y,target.x,target.y+lengthdir_y(128,target.direction-90),.2) - */ - if ((ok == 2) && (dist < (range + max(sprite_get_width(sprite_index), sprite_get_height(sprite_index))))) { if ((ammo > 0) && (ammo < 900)) { ammo -= 1; } - weapon_ammo[gg] = ammo; - cooldown[gg] = weapon_cooldown[gg]; - wep = weapon[gg]; - dam = weapon_dam[gg]; - - // if (f=3) and (ship_id=2) then show_message("ammo: "+string(ammo)+" | range: "+string(range)); + weapon_ammo[i] = ammo; + cooldown[i] = weapon_cooldown[i]; + wep = weapon[i]; + var dam = weapon_dam[i]; + ok = 3; if (ammo < 0) { ok = 0; } - ok = 3; if ((string_count("orpedo", wep) == 0) && (string_count("Interceptor", wep) == 0) && (string_count("ommerz", wep) == 0) && (string_count("Claws", wep) == 0) && (string_count("endrils", wep) == 0) && (ok == 3) && (owner != eFACTION.NECRONS)) { bull = instance_create(x + lengthdir_x(32, direction), y + lengthdir_y(32, direction), obj_en_round); @@ -552,7 +457,6 @@ if (owner != 6) { } } if ((wep == "Star Pulse Generator") && (ok == 3) && instance_exists(target)) { - /// @type {Asset.GMObject.obj_en_pulse} bull = instance_create(x + lengthdir_x(32, direction), y + lengthdir_y(32, direction), obj_en_pulse); bull.speed = 20; if (targe == target) { @@ -574,7 +478,6 @@ if (owner != 6) { } } if (((string_count("Interceptor", wep) == 1) || (string_count("ommerz", wep) == 1) || (string_count("Manta", wep) == 1) || (string_count("Glands", wep) == 1) || (string_count("Eldar Launch", wep) == 1)) && (ok == 3)) { - /// @type {Asset.GMObject.obj_en_in} bull = instance_create(x, y + lengthdir_y(-30, direction + 90), obj_en_in); bull.direction = self.direction; bull.owner = self.owner; @@ -582,8 +485,6 @@ if (owner != 6) { } } } - - /* */ } if (owner == 6) { image_angle = direction; @@ -592,9 +493,6 @@ if (owner == 6) { exit; } - var o_dist, dist, ch_rang, ex, spid; - spid = 0; - if ((shields > 0) && (shields < maxshields)) { shields += 0.03; } @@ -606,13 +504,10 @@ if (owner == 6) { } if (hp <= 0) { - var wh, gud; - wh = 0; - gud = 0; - repeat (5) { - wh += 1; - if (obj_fleet.enemy[wh] == owner) { - gud = wh; + var gud = 0; + for (var i = 1; i <= 5; i++) { + if (obj_fleet.enemy[i] == owner) { + gud = i; } } @@ -628,18 +523,14 @@ if (owner == 6) { image_alpha = 0.5; - // ex=instance_create(x,y,obj_explosion); - // ex.image_xscale=2;ex.image_yscale=2;ex.image_speed=0.75; - var husk; - husk = instance_create(x, y, obj_en_husk); + var husk = instance_create(x, y, obj_en_husk); husk.sprite_index = sprite_index; husk.direction = direction; husk.image_angle = image_angle; husk.depth = depth; husk.image_speed = 0; repeat (choose(4, 5, 6)) { - var explo; - explo = instance_create(x, y, obj_explosion); + var explo = instance_create(x, y, obj_explosion); explo.image_xscale = 0.5; explo.image_yscale = 0.5; explo.x += random_range(sprite_width * 0.25, sprite_width * -0.25); @@ -650,6 +541,8 @@ if (owner == 6) { } if ((hp > 0) && instance_exists(obj_p_ship)) { + var spid = 0; + var o_dist = 0; if (class == "Void Stalker") { o_dist = 300; action = "swoop"; @@ -666,16 +559,13 @@ if (owner == 6) { spid = 100; } - dist = point_distance(x, y, target.x, target.y) - max(sprite_get_width(target.sprite_index), sprite_get_height(sprite_index)); - if (target != 0) { if (speed < (spid / 10)) { speed += 0.02; } - var dist, range; if (instance_exists(target)) { - dist = point_distance(x, y, target.x, target.y); + var dist = point_distance(x, y, target.x, target.y); if (action == "swoop") { direction = turn_towards_point(direction, x, y, target.x, target.y, 5 - ship_size); @@ -718,56 +608,37 @@ if (owner == 6) { turret_cool -= 1; } - var bull, targe, rdir, dirr, dist, xx, yy, ok; - targe = 0; - rdir = 0; - dirr = ""; - dist = 9999; - xx = x; - yy = y; if ((turrets > 0) && instance_exists(obj_p_small) && (turret_cool == 0)) { - targe = instance_nearest(x, y, obj_p_small); + var targe = instance_nearest(x, y, obj_p_small); if (instance_exists(targe)) { - dist = point_distance(x, y, targe.x, targe.y); + var dist = point_distance(x, y, targe.x, targe.y); + if ((dist > 64) && (dist < 300)) { + var bull = instance_create(x, y, obj_en_round); + bull.direction = point_direction(x, y, targe.x, targe.y); + if (owner == eFACTION.TYRANIDS) { + bull.sprite_index = spr_glob; + } + if ((owner == eFACTION.TAU) || (owner == eFACTION.ELDAR)) { + bull.sprite_index = spr_pulse; + } + bull.speed = 20; + bull.dam = 3; + bull.image_xscale = 0.5; + bull.image_yscale = 0.5; + turret_cool = floor(60 / turrets); + bull.direction += choose(random(10), 1 * -random(10)); + } } - if ((dist > 64) && (dist < 300)) { - /// @type {Asset.GMObject.obj_en_round} - bull = instance_create(x, y, obj_en_round); - bull.direction = point_direction(x, y, targe.x, targe.y); - if (owner == eFACTION.TYRANIDS) { - bull.sprite_index = spr_glob; - } - if ((owner == eFACTION.TAU) || (owner == eFACTION.ELDAR)) { - bull.sprite_index = spr_pulse; - } - bull.speed = 20; - bull.dam = 3; - bull.image_xscale = 0.5; - bull.image_yscale = 0.5; - turret_cool = floor(60 / turrets); - bull.direction += choose(random(10), 1 * -random(10)); - } - } - targe = 0; - rdir = 0; - dirr = ""; - dist = 9999; - - xx = lengthdir_x(64, direction + 90); - yy = lengthdir_y(64, direction + 90); - - var front, right, left, rear; - front = 0; - right = 0; - left = 0; - rear = 0; - - targe = instance_nearest(xx, yy, obj_p_ship); - rdir = point_direction(x, y, target.x, target.y); - // if (rdir>45) and (rdir<=135) and (targe!=target){target_r=targe;right=1;} - // if (rdir>225) and (rdir<=315) and (targe!=target) and (targe!=target_r){target_l=targe;left=1;} + + } + + var front = 0; + var right = 0; + var left = 0; + var rear = 0; + target_l = instance_nearest(x + lengthdir_x(64, direction + 90), y + lengthdir_y(64, direction + 90), obj_p_ship); target_r = instance_nearest(x + lengthdir_x(64, direction + 270), y + lengthdir_y(64, direction + 270), obj_p_ship); @@ -775,37 +646,24 @@ if (owner == 6) { front = 1; } - var f, facing, ammo, range, wep, dam, gg; - f = 0; - facing = ""; - ammo = 0; - range = 0; - wep = ""; - dam = 0; - gg = 0; - - repeat (weapons) { - gg += 1; + for (var i = 1; i <= weapons; i++) { + var ok = 0; + var facing = ""; + var ammo = 0; + var range = 0; + var wep = ""; + var bull = noone; - ok = 0; - f += 1; - facing = ""; - ammo = 0; - range = 0; - wep = ""; - - //weapon[gg]=0;weapon_ammo[gg]=0;weapon_range[gg]=0; - - if ((cooldown[gg] <= 0) && (weapon[gg] != "") && (weapon_ammo[gg] > 0)) { + if ((cooldown[i] <= 0) && (weapon[i] != "") && (weapon_ammo[i] > 0)) { ok = 1; } if (ok == 1) { - facing = weapon_facing[gg]; - ammo = weapon_ammo[gg]; - range = weapon_range[gg]; + facing = weapon_facing[i]; + ammo = weapon_ammo[i]; + range = weapon_range[i]; } - targe = target; + var targe = target; if ((facing == "front") && (front == 1)) { ok = 2; } @@ -813,20 +671,13 @@ if (owner == 6) { ok = 2; } - /* - if (facing="right") then targe=target_r; - if (facing="left") then targe=target_l; - if ((facing="front") or (facing="most")) and (front=1) then ok=2; - if (facing="right") or (facing="most") and (right=1) then ok=2; - if (facing="left") or (facing="most") and (left=1) then ok=2; - */ if (facing == "special") { ok = 2; } if (!instance_exists(targe)) { exit; } - dist = point_distance(x, y, targe.x, targe.y); + var dist = point_distance(x, y, targe.x, targe.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; @@ -835,25 +686,19 @@ if (owner == 6) { ok = 2; } - /*var re_deh;re_deh=relative_direction(direction,target.direction); - if (re_deh<45) or (re_deh>315) or ((re_deh>135) and (re_deh<225)) then direction=turn_towards_point(direction,x+lengthdir_x(128,target.direction-90),y,target.x,target.y+lengthdir_y(128,target.direction-90),.2) - */ - if ((ok == 2) && (dist < (range + max(sprite_get_width(sprite_index), sprite_get_height(sprite_index))))) { if ((ammo > 0) && (ammo < 900)) { ammo -= 1; } - weapon_ammo[gg] = ammo; - cooldown[gg] = weapon_cooldown[gg]; - wep = weapon[gg]; - dam = weapon_dam[gg]; - - // if (f=3) and (ship_id=2) then show_message("ammo: "+string(ammo)+" | range: "+string(range)); + weapon_ammo[i] = ammo; + cooldown[i] = weapon_cooldown[i]; + wep = weapon[i]; + var dam = weapon_dam[i]; + ok = 3; if (ammo < 0) { ok = 0; } - ok = 3; if ((string_count("orpedo", wep) == 0) && (string_count("Interceptor", wep) == 0) && (string_count("ommerz", wep) == 0) && (string_count("Claws", wep) == 0) && (string_count("endrils", wep) == 0) && (ok == 3)) { bull = instance_create(x + lengthdir_x(32, direction), y + lengthdir_y(32, direction), obj_en_round); @@ -951,7 +796,6 @@ if (owner == 6) { } } if (((string_count("Interceptor", wep) == 1) || (string_count("ommerz", wep) == 1) || (string_count("Manta", wep) == 1) || (string_count("Glands", wep) == 1) || (string_count("Eldar Launch", wep) == 1)) && (ok == 3)) { - /// @type {Asset.GMObject.obj_en_in} bull = instance_create(x, y + lengthdir_y(-30, direction + 90), obj_en_in); bull.direction = self.direction; bull.owner = self.owner; @@ -959,7 +803,4 @@ if (owner == 6) { } } } - - /* */ } -/* */ diff --git a/objects/obj_enunit/Alarm_0.gml b/objects/obj_enunit/Alarm_0.gml index 1a34d045f4..438018f8c4 100644 --- a/objects/obj_enunit/Alarm_0.gml +++ b/objects/obj_enunit/Alarm_0.gml @@ -48,7 +48,16 @@ if (!engaged) { if (range[i] >= dist) { // The weapon is in range; - var _target_vehicles = apa[i] > 0 ? true : false; // AP weapons target vehicles + // A weapon's armour pierce doubles as its role. Dedicated anti-tank guns + // (apa >= GUARD_ENEMY_ANTITANK_AP, the rokkit / lascannon / melta class) hunt + // vehicles. Everything lighter (general-purpose and pure anti-infantry) goes + // for the men first. This is preference by weapon role, not per-shot penetration + // knowledge: the enemy never checks whether a given shot would crack a specific + // target, it just sends tank-hunters at tanks and lighter guns at infantry. + // Either type still crosses over as a fallback through the paths below: an + // anti-tank gun with no vehicle in reach drops to the men path, and a lighter + // gun with no men in reach drops to the vehicle fallback inside the men path. + var _target_vehicles = apa[i] >= GUARD_ENEMY_ANTITANK_AP; // role-based target preference // Weird alpha strike mechanic, that changes target unit index to CM; if (((wep[i] == "Power Fist") || (wep[i] == "Bolter")) && (obj_ncombat.alpha_strike > 0) && (wep_num[i] > 5)) { @@ -80,21 +89,48 @@ if (!engaged) { if (block_has_armour(enemy) || (enemy.veh_type[1] == "Defenses")) { scr_shoot(i, enemy, target_unit_index, "arp", "ranged"); continue; - } else if ((instance_number(obj_pnunit) > 1) && (obj_ncombat.enemy != 7)) { - var x2 = enemy.x; - repeat (instance_number(obj_pnunit) - 1) { - x2 += flank == 0 ? -10 : 10; - var enemy2 = instance_nearest(x2, y, obj_pnunit); - if (!target_block_is_valid(enemy2, obj_pnunit)) { - continue; - } - if (range[i] < get_block_distance(enemy2)) { - break; - } - if (block_has_armour(enemy2)) { - scr_shoot(i, enemy2, target_unit_index, "arp", "ranged"); - _shot = true; - break; + } else { + // Front block has no armour. If there are other blocks behind, + // look for a vehicle to hit. If none is found anywhere (including + // a single men-only block, such as a lone Guard rank), fall back + // to shooting the men instead of idling. The original code gated + // this whole fallback behind a multi-block check, so a lone + // men-only block left every AP weapon firing zero shots. + if ((instance_number(obj_pnunit) > 1) && (obj_ncombat.enemy != 7)) { + var _column_size_value = enemy.column_size; + var x2 = enemy.x; + repeat (instance_number(obj_pnunit) - 1) { + x2 += flank == 0 ? -10 : 10; + var enemy2 = instance_nearest(x2, y, obj_pnunit); + if (!target_block_is_valid(enemy2, obj_pnunit)) { + continue; + } + if (range[i] < get_block_distance(enemy2)) { + break; + } + if (block_has_armour(enemy2)) { + // Screening: a large front block (such as a wall of + // Guardsmen) shields the vehicles behind it from AP + // fire, the same way the men-targeting path below + // shields the men behind it. Without this every apa>0 + // weapon looks straight past the men-only Guard rank + // to the Marines' vehicles, so the Guard screen + // nothing. When the back block is shielded the shot + // is not taken here; _shot stays false and the weapon + // falls back to firing on the front Guard block. + var _back_column_size_value = enemy2.column_size; + if (_back_column_size_value < _column_size_value) { + continue; + } else { + var _pass_chance = ((_back_column_size_value / _column_size_value) - 1) * 100; + if (irandom_range(1, 100) < min(_pass_chance, 80)) { + continue; + } + } + scr_shoot(i, enemy2, target_unit_index, "arp", "ranged"); + _shot = true; + break; + } } } if (!_shot) { diff --git a/objects/obj_enunit/Create_0.gml b/objects/obj_enunit/Create_0.gml index 51a9373e1c..c5d7de3fcf 100644 --- a/objects/obj_enunit/Create_0.gml +++ b/objects/obj_enunit/Create_0.gml @@ -29,8 +29,8 @@ if (obj_ncombat.enemy < array_length(global.star_name_colors) && obj_ncombat.ene column_draw_colour = c_dkgrey; } -enemy = 0; -enemy2 = 0; +enemy = noone; +enemy2 = noone; avg_attack = 1; avg_ranged = 1; @@ -76,10 +76,6 @@ dudes_gear = array_create(_array_size, ""); dudges_mobi = array_create(_array_size, ""); alarm[1] = 5; -alarm[5] = 6; -if (obj_ncombat.enemy == 1) { - alarm[6] = 10; -} hit = function() { return scr_hit(x1, y1, x2, y2) && obj_ncombat.fadein <= 0; diff --git a/objects/obj_event_log/Create_0.gml b/objects/obj_event_log/Create_0.gml index d9c01930f4..6848ad602b 100644 --- a/objects/obj_event_log/Create_0.gml +++ b/objects/obj_event_log/Create_0.gml @@ -1,34 +1,20 @@ top = 1; entries = 0; scroll_cool = 0; -var t = -1; -event = []; // Get upon load? -t = 0; event = []; -// help = 0; help_topics = 0; topic = ""; info = ""; strategy = ""; main_info = ""; -topics[0] = ""; -related[0] = ""; -related[1] = ""; -related[2] = ""; -related[3] = ""; -var e = -1; -repeat (101) { - e += 1; - topics[e] = ""; -} +topics = array_create(101, ""); +related = array_create(4, ""); + if (file_exists(PATH_HELP_INI)) { ini_open(PATH_HELP_INI); - var ch; - ch = 0; - repeat (100) { - ch += 1; + for (var ch = 1; ch <= 100; ch++) { if (ini_section_exists(string(ch))) { help_topics += 1; topics[help_topics] = ini_read_string(string(ch), "topic", "Error"); diff --git a/objects/obj_event_log/Draw_0.gml b/objects/obj_event_log/Draw_0.gml index e3acdc8111..56f94fd0c6 100644 --- a/objects/obj_event_log/Draw_0.gml +++ b/objects/obj_event_log/Draw_0.gml @@ -1,15 +1,9 @@ if (help == 0) { - var bad = 1; - if (instance_exists(obj_controller)) { - if (obj_controller.menu == eMENU.EVENT_LOG) { - bad = 0; - } - } - if (bad == 0) { + if (instance_exists(obj_controller) && (obj_controller.menu == eMENU.EVENT_LOG)) { var xx = camera_get_view_x(view_camera[0]); var yy = camera_get_view_y(view_camera[0]); draw_set_alpha(1); - draw_set_color(0); + draw_set_color(c_black); draw_rectangle(xx, yy, xx + 1600, yy + 900, 0); draw_set_alpha(0.5); draw_sprite(spr_rock_bg, 0, xx, yy); @@ -19,26 +13,25 @@ if (help == 0) { draw_set_halign(fa_center); draw_text(xx + 800, yy + 74, string(global.chapter_name) + " Event Log"); draw_set_halign(fa_left); - var t = 0, p = -1, cur_event; var ent = array_length(event); draw_set_color(CM_GREEN_COLOR); if (ent == 0) { draw_text(xx + 25, yy + 120, "No entries logged."); } else { - p = -1; + var p = -1; draw_set_font(fnt_40k_14); draw_set_alpha(0.8); for (var t = top - 1; t < ent; t++) { p++; - cur_event = event[t]; + var cur_event = event[t]; if (cur_event.text != "") { // 1554 set_alert_draw_colour(cur_event.colour); draw_text_ext(xx + 25, yy + 120 + (p * 26), $"{cur_event.date} (Turn {cur_event.turn}) - {cur_event.text}", -1, 1554); - if (cur_event.event_target != "none") { + if (cur_event.event_target != noone) { if (point_and_click(draw_unit_buttons([xx + 1400, yy + 120 + (p * 26)], "View", [1, 1], c_green,, fnt_40k_14b, 1, true))) { var view_star = find_star_by_name(cur_event.event_target); - if (view_star != "none") { + if (view_star != noone) { main_map_defaults(); obj_controller.x = view_star.x; obj_controller.y = view_star.y; @@ -48,26 +41,25 @@ if (help == 0) { } } } - var x1, y1, x2, y2, scrolly, chunk_size, my, y5; - x1 = xx + 1557; - y1 = yy + 117; - x2 = xx + 1583; - y2 = yy + 823; + var x1 = xx + 1557; + var y1 = yy + 117; + var x2 = xx + 1583; + var y2 = yy + 823; draw_rectangle(x1, y1, x2, y2, 1); cubey = 30; - scrolly = (y2 - y1) + 12; // The maximum amount of moving around that the cube does - my = max(1, ent - 24); // The maximum number of scroll chunks - chunk_size = scrolly / my; - y5 = (top - 1) * chunk_size; + var scrolly = (y2 - y1) + 12; // The maximum amount of moving around that the cube does + var my = max(1, ent - 24); // The maximum number of scroll chunks + var chunk_size = scrolly / my; + var y5 = (top - 1) * chunk_size; draw_rectangle(x1, y1 + y5, x2, y1 + y5 + cubey, 0); + draw_set_alpha(1); } - draw_set_alpha(1); } if (help == 1) { var xx = camera_get_view_x(view_camera[0]); var yy = camera_get_view_y(view_camera[0]); - draw_set_color(0); + draw_set_color(c_black); draw_set_alpha(0.75); draw_rectangle(0, 0, room_width, room_height, 0); draw_set_alpha(1); @@ -87,10 +79,6 @@ if (help == 1) { help = 0; } } - var t, x1, y1; - x1 = 0; - y1 = 0; - t = 0; draw_set_color(c_black); draw_rectangle(xx + 466, yy + 136, xx + 644, yy + 166, 0); draw_set_color(c_gray); @@ -99,10 +87,9 @@ if (help == 1) { draw_set_font(fnt_40k_14b); draw_set_halign(fa_left); draw_text(xx + 466 + 4, yy + 136 + 6, string_hash_to_newline("Topics")); - x1 = xx + 466; - y1 = yy + 166; - repeat (20) { - t += 1; + var x1 = xx + 466; + var y1 = yy + 166; + for (var t = 1; t <= 20; t++) { if (topics[t] != "") { draw_set_color(c_gray); draw_set_alpha(0.75); @@ -132,7 +119,6 @@ if (help == 1) { draw_set_alpha(1); draw_set_color(c_gray); draw_set_halign(fa_center); - // draw_rectangle(xx+664,yy+148,xx+805,yy+316,0); if (topic != "") { draw_set_font(fnt_40k_14b); draw_text_transformed(xx + 897, yy + 131, string_hash_to_newline(string(topic)), 1.25, 1.25, 0); @@ -141,9 +127,8 @@ if (help == 1) { draw_text(xx + 663, yy + 177, string_hash_to_newline("Game Info:")); } draw_set_font(fnt_40k_14); - var p1, y2; - y2 = 0; - p1 = string(info); + var y2 = 0; + var p1 = string(info); if (info != "") { draw_text_ext(xx + 663, yy + 197, string_hash_to_newline(string(p1)), -1, 469); } diff --git a/objects/obj_event_log/Mouse_60.gml b/objects/obj_event_log/Mouse_60.gml index 70202f1328..979c58bbd2 100644 --- a/objects/obj_event_log/Mouse_60.gml +++ b/objects/obj_event_log/Mouse_60.gml @@ -1,9 +1,3 @@ -// if (scroll_cool<=0){ -// scroll_cool=1; if (top > 1) { top -= 1; } -if (top > 1) { - top -= 1; -} -// } diff --git a/objects/obj_event_log/Mouse_61.gml b/objects/obj_event_log/Mouse_61.gml index fb48e44b58..932eaeb14d 100644 --- a/objects/obj_event_log/Mouse_61.gml +++ b/objects/obj_event_log/Mouse_61.gml @@ -1,15 +1,4 @@ -// if (scroll_cool<=0){ -// scroll_cool=1; - -var t, p; -ent = 0; -p = top - 1; -t = 0; ent = array_length(event); if (ent - 24 > top) { top += 1; } -if (ent - 24 > top) { - top += 1; -} -// } diff --git a/objects/obj_fleet/Alarm_1.gml b/objects/obj_fleet/Alarm_1.gml index ad405efc5b..d14b29edde 100644 --- a/objects/obj_fleet/Alarm_1.gml +++ b/objects/obj_fleet/Alarm_1.gml @@ -1,5 +1,3 @@ -// if (csm_exp!=0) then show_message(string(csm_exp)); - if (control == 1) { instance_activate_object(obj_cursor); } @@ -17,9 +15,7 @@ if (enemy == 2) { en_size[3] = 2; } - var i; - i = 0; - i = en_capital; + var i = en_capital; if (i > 0) { en_column[2] = "Apocalypse Class Battleship"; en_num[2] = floor(random(i)) + 1; @@ -76,32 +72,30 @@ if (enemy == 7) { en_num[2] = irandom_range(1, i); i -= en_num[2]; en_size[2] = 3; - } // en_num[2]+=en_num[1]+1; + } if (i > 0) { en_column[3] = "Kroolboy"; en_num[3] = i; i -= en_num[3]; en_size[3] = 3; - } // en_num[3]+=en_num[2]+1; + } if (en_frigate > 0) { en_column[4] = "Battlekroozer"; en_num[4] = en_frigate; en_size[4] = 2; - } // en_num[4]+=en_num[3]+1; + } if (en_escort > 0) { en_column[5] = "Ravager"; en_num[5] = en_escort; en_size[5] = 1; - } // en_num[5]+=en_num[4]+1; + } } if (enemy == 8) { - var i; - i = 0; - i = en_frigate; + var i = en_frigate; if (en_capital > 0) { en_column[1] = "Custodian"; @@ -121,7 +115,7 @@ if (enemy == 8) { en_num[3] = i; i -= en_num[3]; en_size[3] = 2; - } // en_num[3]+=en_num[2]+1; + } if (en_escort > 0) { en_column[4] = "Castellan"; @@ -137,9 +131,7 @@ if (enemy == 8) { } if (enemy == 9) { - var i; - i = 0; - i = en_escort; + var i = en_escort; if (en_capital > 0) { en_column[1] = "Leviathan"; @@ -158,19 +150,17 @@ if (enemy == 9) { en_column[3] = "Razorfiend"; en_num[3] = en_frigate; en_size[3] = 2; - } // en_num[2]+=en_num[1]+1; + } if (i > 0) { en_column[4] = "Prowler"; en_num[4] = i; en_size[4] = 1; - } // en_num[5]+=en_num[4]+1; + } } if (enemy == 10) { - var i; - i = 0; - i = en_frigate; + var i = en_frigate; if (en_capital > 0) { en_column[1] = "Desecrator"; @@ -190,83 +180,28 @@ if (enemy == 10) { en_num[3] = floor(random(i)) + 1; i -= en_num[3]; en_size[3] = 2; - } // en_num[2]+=en_num[1]+1; + } if (i > 0) { en_column[4] = "Daemon"; en_num[4] = i; i -= en_num[4]; en_size[4] = 2; - } // en_num[3]+=en_num[2]+1; + } if (en_escort > 0) { en_column[5] = "Iconoclast"; en_num[5] = en_escort; en_size[5] = 1; - } // en_num[5]+=en_num[4]+1; + } } -// show_message("Dethdeala "+string(en_num[1])+" | Gorbag "+string(en_num[2])+" | Kroolboy "+string(en_num[3])+" | Frigate "+string(en_num[4])+" | Escort "+string(en_num[5])); - en_capital = 0; en_frigate = 0; en_escort = 0; en_ships_max = 0; -/* -if (enemy="orks"){ - if (threat=1){ - en_column[1]="Ravager";en_num[1]=floor(random_range(1,3));en_size[1]=1; - } - if (threat=2){ - en_column[1]=choose("Deathdeala","Gorbag's Revenge","Battlekroozer");en_num[1]=choose(0,1);en_size[1]=3; - en_column[2]="Ravager";en_num[2]=floor(random_range(1,5));en_size[2]=1; - } - if (threat=3){ - en_column[1]="Dethdeala";en_num[1]=choose(1,1);en_size[1]=3; - en_column[2]="Gorbag's Revenge";en_num[2]=choose(0,1);en_size[2]=3; - en_column[3]="Battlekroozer";en_num[3]=floor(random_range(0,1));en_size[3]=3; - en_column[4]="Ravager";en_num[4]=floor(random_range(3,8));en_size[4]=1; - } - if (threat=4){ - en_column[1]="Dethdeala";en_num[1]=choose(1,2);en_size[1]=3; - en_column[2]="Gorbag's Revenge";en_num[2]=choose(0,1,1);en_size[2]=3; - en_column[3]="Battlekroozer";en_num[3]=floor(random_range(1,1));en_size[3]=3; - en_column[4]="Ravager";en_num[4]=floor(random_range(4,10));en_size[4]=1; - } - if (threat=5){ - en_column[1]="Dethdeala";en_num[1]=choose(1,2,3);en_size[1]=3; - en_column[2]="Gorbag's Revenge";en_num[2]=choose(0,1,2);en_size[2]=3; - en_column[3]="Kroolboy";en_num[3]=choose(0,1,2);en_size[3]=3; - en_column[4]="Battlekroozer";en_num[4]=floor(random_range(0,5));en_size[4]=3; - en_column[5]="Ravager";en_num[5]=floor(random_range(6,15));en_size[5]=1; - } -} - -*/ - -/*if (en_num[2]=0) then en_num[2]=en_num[1]+1; -if (en_num[3]=0) then en_num[3]=en_num[2]+1; -if (en_num[4]=0) then en_num[4]=en_num[3]+1; -if (en_num[5]=0) then en_num[5]=en_num[4]+1; - -if (en_num[2]!=0) then en_num[2]+=en_num[1]; -if (en_num[3]!=0) then en_num[3]+=en_num[3]; -if (en_num[4]!=0) then en_num[4]+=en_num[4]; -if (en_num[5]!=0) then en_num[5]+=en_num[5];*/ - -/*var i;i=0; -repeat(5){i+=1; - if (en_column[4]="") and (en_column[5]!="") and (en_num[5]>0){en_column[4]=en_column[5];en_num[4]=en_num[5];en_column[5]="";en_num[5]=0;} - if (en_column[3]="") and (en_column[4]!="") and (en_num[4]>0){en_column[3]=en_column[4];en_num[3]=en_num[4];en_column[4]="";en_num[4]=0;} - if (en_column[2]="") and (en_column[3]!="") and (en_num[3]>0){en_column[2]=en_column[3];en_num[2]=en_num[3];en_column[3]="";en_num[3]=0;} - if (en_column[1]="") and (en_column[2]!="") and (en_num[2]>0){en_column[1]=en_column[2];en_num[1]=en_num[2];en_column[2]="";en_num[2]=0;} -}*/ - -var i; -i = 0; -repeat (5) { - i += 1; +for (var i = 1; i <= 5; i++) { if (en_column[i] == "Avenger Class Grand Cruiser") { en_width[i] = 196; en_height[i] = 96; @@ -386,24 +321,14 @@ repeat (5) { } } -/* */ - attack_mode = "offensive"; -// if (ambushers=1) or (enemy=8) then attack_mode="offensive"; -// if (enemy=9) then attack_mode="defensive"; - if ((ambushers == 1) && (ambushers == 999)) { global_attack = global_attack * 1.1; } // Need to finish this if (bolter_drilling == 1) { global_bolter = global_bolter * 1.1; } -// if (enemy_eldar=1) and (enemy=6){global_attack=global_attack*1.1;global_defense=global_defense*1.1;} -// if (enemy_fallen=1) and (enemy=10){global_attack=global_attack*1.1;global_defense=global_defense*1.1;} -// if (enemy_orks=1) and (enemy=7){global_attack=global_attack*1.1;global_defense=global_defense*1.1;} -// if (enemy_tau=1) and (enemy=8){global_attack=global_attack*1.1;global_defense=global_defense*1.1;} -// if (enemy_tyranids=1) and (enemy=10){global_attack=global_attack*1.1;global_defense=global_defense*1.1;} if ((siege == 1) && (siege == 555)) { global_attack = global_attack * 1.2; } // Need to finish this @@ -414,11 +339,9 @@ if (slow == 1) { if (melee == 1) { global_melee = global_melee * 1.15; } -// if (shitty_luck == 1) { global_defense = global_defense * 0.9; } -// if (lyman=1) and (dropping=1) then ||| handle within each object if (ossmodula == 1) { global_attack = global_attack * 0.95; global_defense = global_defense * 0.95; @@ -429,17 +352,5 @@ if (betchers == 1) { if (catalepsean == 1) { global_attack = global_attack * 0.95; } -// if (occulobe=1){if (time=5) or (time=6) then global_attack=global_attack*0.7;global_defense=global_defense*0.9;} - -/* -global.chapter_name=5; -obj_ini.main_color=obj_creation.main_color; -obj_ini.secondary_color=obj_creation.secondary_color; -obj_ini.lens_color=obj_creation.lens_color; -obj_ini.weapon_color=obj_creation.weapon_color; -*/ alarm[2] = 1; - -/* */ -/* */ diff --git a/objects/obj_fleet/Alarm_2.gml b/objects/obj_fleet/Alarm_2.gml index 6aa95b0ba4..ec9f7fc85d 100644 --- a/objects/obj_fleet/Alarm_2.gml +++ b/objects/obj_fleet/Alarm_2.gml @@ -2,30 +2,16 @@ capital_max = capital; frigate_max = frigate; escort_max = escort; -var i, k, temp1, temp2, x2, hei, man, sizz; -i = 0; -k = 0; -temp1 = 0; -temp2 = 0; -x2 = 224; -hei = 0; -man = 0; -sizz = 0; +var x2 = 1200; +var man = noone; +var yy = 0; sort_ships_into_columns(self); player_fleet_ship_spawner(); -if (enemy == 2) { - // This is an orderly Tau ship formation - var xx, yy, i, temp1, x2, man; - xx = 0; - yy = 0; - i = 0; - temp1 = 0; - x2 = 1200; - man = 0; - +if (enemy == eFACTION.IMPERIUM) { + // This is an orderly Imperium ship formation if (en_num[4] > 0) { yy = (room_height / 2) - ((en_height[4] * en_num[4]) / 2); yy += en_height[4] / 2; @@ -67,23 +53,8 @@ if (enemy == 2) { } } -/* -if (en_escort>0){en_column[4]="Aconite";en_num[4]=max(1,floor(en_escort/2));en_size[4]=1;} -if (en_escort>1){en_column[3]="Hellebore";en_num[3]=max(1,floor(en_escort/2));en_size[3]=1;} -if (en_frigate>0){en_column[2]="Shadow Class";en_num[2]=en_frigate;en_size[2]=2;} -if (en_capital>0){en_column[1]="Void Stalker";en_num[1]=en_capital;en_size[1]=3;} -*/ - -if (enemy == 6) { - // This is an orderly Tau ship formation - var xx, yy, i, temp1, x2, man; - xx = 0; - yy = 0; - i = 0; - temp1 = 0; - x2 = 1200; - man = 0; - +if (enemy == eFACTION.ELDAR) { + // This is an orderly Eldar ship formation if (en_num[4] > 0) { yy = 128; repeat (en_num[4]) { @@ -123,22 +94,9 @@ if (enemy == 6) { } } -if ((enemy == 7) || (enemy == 10)) { +if ((enemy == eFACTION.ORK) || (enemy == eFACTION.CHAOS)) { // This is spew out random ships without regard for formations - var xx, yy, dist, targ, numb, man; - xx = 0; - yy = 0; - dist = 0; - target = 0; - numb = 0; - man = 0; - - var i; - i = 0; - - repeat (5) { - i += 1; - + for (var i = 1; i <= 5; i++) { if (en_column[i] != "") { for (s = 0; s < en_num[i]; s += 1) { if (en_size[i] > 1) { @@ -153,16 +111,8 @@ if ((enemy == 7) || (enemy == 10)) { } } -if (enemy == 8) { +if (enemy == eFACTION.TAU) { // This is an orderly Tau ship formation - var xx, yy, i, temp1, x2, man; - xx = 0; - yy = 0; - i = 0; - temp1 = 0; - x2 = 1200; - man = 0; - yy = (room_height / 2) - ((en_height[5] * en_num[5]) / 2); yy += en_height[5] / 2; repeat (en_num[5]) { @@ -205,16 +155,8 @@ if (enemy == 8) { } } -if (enemy == 9) { +if (enemy == eFACTION.TYRANIDS) { // This is an orderly Tyranid ship formation - var xx, yy, i, temp1, x2, man; - xx = 0; - yy = 0; - i = 0; - temp1 = 0; - x2 = 1200; - man = 0; - yy = (room_height / 2) - ((en_height[4] * en_num[4]) / 2); yy += en_height[4] / 2; repeat (en_num[4]) { @@ -251,5 +193,4 @@ if (enemy == 9) { } } -/* */ alarm_set(3, 2); diff --git a/objects/obj_fleet/Alarm_4.gml b/objects/obj_fleet/Alarm_4.gml index 020d812e45..ff3ec16f70 100644 --- a/objects/obj_fleet/Alarm_4.gml +++ b/objects/obj_fleet/Alarm_4.gml @@ -38,8 +38,6 @@ with (obj_en_husk) { instance_activate_all(); obj_controller.combat = 0; instance_activate_object(obj_turn_end); -// instance_activate_object(obj_star_select); -// show_message(obj_turn_end.current_battle); if (player_started == 0) { with (obj_turn_end) { @@ -48,10 +46,7 @@ if (player_started == 0) { } } if (player_started == 1) { - var taxt; - taxt = ""; - - taxt = string(global.chapter_name) + " engage and destroy a"; + var taxt = string(global.chapter_name) + " engage and destroy a"; if ((enemy[1] == 2) || (enemy[1] == 4) || (enemy[1] == 5) || (enemy[1] == 6)) { taxt += "n"; } @@ -88,7 +83,6 @@ if (view_x + view_y > 0) { obj_controller.y = view_y; } -// show_message(obj_turn_end.current_battle); with (obj_controller) { instance_activate_all(); } diff --git a/objects/obj_fleet/Alarm_6.gml b/objects/obj_fleet/Alarm_6.gml index 8355b668ff..694f857f81 100644 --- a/objects/obj_fleet/Alarm_6.gml +++ b/objects/obj_fleet/Alarm_6.gml @@ -1,53 +1,30 @@ -/* -enemy[2]=6;enemy_status[2]=1; -en_capital[2]=2;en_frigate[2]=3;en_escort[2]=5; -en_capital_max[2]=2;en_frigate_max[2]=3;en_escort_max[2]=5; -en_ships_max[2]=10; +var total_enemies = 0; +var total_allies = 1; -enemy[3]=2;enemy_status[3]=1; -en_capital[3]=1;en_frigate[3]=2;en_escort[3]=3; -en_capital_max[3]=1;en_frigate_max[3]=2;en_escort_max[3]=3; -en_ships_max[3]=6; -*/ - -var total_enemies, total_allies, t, tt, y1, y2, fug, spawner; -total_enemies = 0; -total_allies = 1; -spawner = 0; -t = 0; -y1 = 0; -y2 = 0; -tt = 0; -fug = 0; - -repeat (6) { - t += 1; - if (enemy[t] != 0) { - if (enemy_status[t] < 0) { +for (var i = 1; i <= 6; i++) { + if (enemy[i] != 0) { + if (enemy_status[i] < 0) { total_enemies += 1; } - if (enemy_status[t] > 0) { + if (enemy_status[i] > 0) { total_allies += 1; } - - // show_message("Computer "+string(t)+":"+string(enemy[t])+", status:"+string(enemy_status[t])); } } if (total_enemies > 0) { - t = 1; - y2 = room_height / total_enemies / 2; - tt = 0; - repeat (5) { - fug += 1; - if (enemy_status[fug] < 0) { + var t = 1; + var y2 = room_height / total_enemies / 2; + var tt = 0; + for (var i = 1; i <= 5; i++) { + if (enemy_status[i] < 0) { tt += 1; - y1 = t * y2; + var y1 = t * y2; - spawner = instance_create(room_width + 200, y1, obj_fleet_spawner); - spawner.owner = enemy[fug]; + var spawner = instance_create(room_width + 200, y1, obj_fleet_spawner); + spawner.owner = enemy[i]; spawner.height = y2; - spawner.number = fug; + spawner.number = i; t += 2; } @@ -55,41 +32,33 @@ if (total_enemies > 0) { } if (total_allies > 0) { - y1 = 0; - fug = 0; - t = 1; - y2 = room_height / total_allies / 2; - tt = 0; - repeat (5) { - fug += 1; - if (enemy_status[fug] > 0) { + var t = 1; + var y2 = room_height / total_allies / 2; + var tt = 0; + for (var i = 1; i <= 5; i++) { + if (enemy_status[i] > 0) { tt += 1; - y1 = t * y2; + var y1 = t * y2; - spawner = instance_create(200, y1, obj_fleet_spawner); + var spawner = instance_create(200, y1, obj_fleet_spawner); - if (fug == 1) { + if (i == 1) { spawner.owner = eFACTION.PLAYER; } - if (fug > 1) { - spawner.owner = enemy[fug]; + if (i > 1) { + spawner.owner = enemy[i]; } // Get the ENEMY after the actual enemies spawner.height = y2; - spawner.number = fug; + spawner.number = i; t += 2; } } } -// show_message("Total Enemies: "+string(total_enemies)); -// show_message("Total Allies: "+string(total_allies)); - // Buffs here -// if (ambushers=1) or (enemy=8) then attack_mode = "offensive"; -// if (enemy=9) then attack_mode="defensive"; if ((ambushers == 1) && (ambushers == 999)) { global_attack = global_attack * 1.1; @@ -97,11 +66,6 @@ if ((ambushers == 1) && (ambushers == 999)) { if (bolter_drilling == 1) { global_bolter = global_bolter * 1.1; } -// if (enemy_eldar=1) and (enemy=6){global_attack=global_attack*1.1;global_defense=global_defense*1.1;} -// if (enemy_fallen=1) and (enemy=10){global_attack=global_attack*1.1;global_defense=global_defense*1.1;} -// if (enemy_orks=1) and (enemy=7){global_attack=global_attack*1.1;global_defense=global_defense*1.1;} -// if (enemy_tau=1) and (enemy=8){global_attack=global_attack*1.1;global_defense=global_defense*1.1;} -// if (enemy_tyranids=1) and (enemy=10){global_attack=global_attack*1.1;global_defense=global_defense*1.1;} if ((siege == 1) && (siege == 555)) { global_attack = global_attack * 1.2; } // Need to finish this @@ -112,11 +76,9 @@ if (slow == 1) { if (melee == 1) { global_melee = global_melee * 1.15; } -// if (shitty_luck == 1) { global_defense = global_defense * 0.9; } -// if (lyman=1) and (dropping=1) then ||| handle within each object if (ossmodula == 1) { global_attack = global_attack * 0.95; global_defense = global_defense * 0.95; @@ -127,20 +89,10 @@ if (betchers == 1) { if (catalepsean == 1) { global_attack = global_attack * 0.95; } -// if (occulobe=1){if (time=5) or (time=6) then global_attack=global_attack*0.7;global_defense=global_defense*0.9;} - // More prep for player -var i = 0, k = 0, onceh = 0; - -// instance_activate_object(obj_combat_info); - capital_max = capital; frigate_max = frigate; escort_max = escort; obj_fleet_spawner.alarm[0] = 1; - -// alarm[1]=2; -/* */ -/* */ diff --git a/objects/obj_fleet/Alarm_7.gml b/objects/obj_fleet/Alarm_7.gml index 7597b88ea2..105ef32455 100644 --- a/objects/obj_fleet/Alarm_7.gml +++ b/objects/obj_fleet/Alarm_7.gml @@ -1,12 +1,10 @@ try { - var _player_battle_fleet, yeehaw2, tstar; - _player_battle_fleet = 0; - yeehaw2 = 0; - tstar = 0; + var _player_battle_fleet = noone; + var killer = false; + var killer_tg = 0; if (player_started == 1) { _player_battle_fleet = pla_fleet; - yeehaw2 = ene_fleet; } if ((player_started == 0) && instance_exists(obj_turn_end)) { @@ -32,12 +30,6 @@ try { } } - var op, ii, killer, killer_tg; - op = 0; - killer = 0; - killer_tg = 0; - ii = -50; - if ((player_started == 0) && instance_exists(obj_turn_end)) { with (obj_star) { if (name != obj_turn_end.battle_location[obj_turn_end.current_battle]) { @@ -54,8 +46,8 @@ try { } } } - ii = instance_nearest(room_width, room_height, obj_star); - obj_controller.temp[1070] = ii.id; + var _random_star = instance_nearest(room_width, room_height, obj_star); + obj_controller.temp[1070] = _random_star.id; with (obj_star) { if ((x < -5000) && (y < -5000)) { x += 10000; @@ -63,17 +55,10 @@ try { } } - op = 0; - var ofleet; - ofleet = 0; - repeat (5) { - op += 1; + for (var op = 1; op <= 5; op++) { if ((enemy[op] != 0) && (enemy[op] != 4)) { - ofleet = 0; obj_controller.temp[1071] = enemy[op]; - // show_message("Hiding all but the fleet owned by "+string(obj_controller.temp[1071])); - with (obj_en_fleet) { if ((owner != obj_controller.temp[1071]) || (orbiting != obj_controller.temp[1070])) { x -= 10000; @@ -81,30 +66,23 @@ try { } } - ofleet = instance_nearest(room_width / 2, room_height / 2, obj_en_fleet); - // show_message("Fleet: "+string(ofleet.capital_number)+"/"+string(ofleet.frigate_number)+"/"+string(ofleet.escort_number)+", lost "+string(en_capital_lost[op])+"/"+string(en_frigate_lost[op])+"/"+string(en_escort_lost[op])); - repeat (50) { - if (!instance_exists(ofleet)) { - ofleet = instance_nearest(room_width / 2, room_height / 2, obj_en_fleet); - } - if (instance_exists(ofleet)) { + /// @type {Id.Instance.obj_en_fleet} + var ofleet = instance_nearest(room_width / 2, room_height / 2, obj_en_fleet); + if (ofleet != noone) { if (ofleet.trade_goods == "player_hold") { ofleet.trade_goods = ""; } - // show_message("ofleet x:"+string(ofleet.x)+", ofleet y:"+string(ofleet.y)+", ofleet owner: "+string(ofleet.owner)+" wants "+string(enemy[op])); if ((ofleet.x > -7000) && (ofleet.y > -7000) && (ofleet.owner == enemy[op])) { if (en_capital_lost[op] + en_frigate_lost[op] + en_escort_lost[op] >= ofleet.capital_number + ofleet.frigate_number + ofleet.escort_number) { en_capital_lost[op] -= ofleet.capital_number; en_frigate_lost[op] -= ofleet.frigate_number; en_escort_lost[op] -= ofleet.escort_number; - // show_message("Fleet baleeted"); with (ofleet) { instance_destroy(); } } if ((en_capital_lost[op] + en_frigate_lost[op] + en_escort_lost[op] > 0) && instance_exists(ofleet)) { - // show_message("Fleet: "+string(ofleet.capital_number)+"/"+string(ofleet.frigate_number)+"/"+string(ofleet.escort_number)+", lost "+string(en_capital_lost[op])+"/"+string(en_frigate_lost[op])+"/"+string(en_escort_lost[op])); if ((en_capital_lost[op] > 0) && (ofleet.capital_number > 0)) { en_capital_lost[op] -= 1; ofleet.capital_number -= 1; @@ -133,13 +111,8 @@ try { y += 10000; } } - - // if (instance_exists(ofleet)){show_message("Fleet: "+string(ofleet.capital_number)+"/"+string(ofleet.frigate_number)+"/"+string(ofleet.escort_number));} - // if (!instance_exists(ofleet)){show_message("FlEET WAS DELETED");} } - // show_message("End ship removing"); - if ((enemy[op] == 4) && (enemy_status[op] < 0)) { obj_controller.temp[1071] = enemy[op]; with (obj_en_fleet) { @@ -148,8 +121,8 @@ try { y -= 10000; } } - ofleet = instance_nearest(room_width / 2, room_height / 2, obj_en_fleet); - killer = 1; + var ofleet = instance_nearest(room_width / 2, room_height / 2, obj_en_fleet); + killer = true; obj_controller.temp[1071] = enemy[op]; killer_tg = ofleet.inquisitor; with (ofleet) { @@ -164,7 +137,7 @@ try { obj_controller.cooldown = 20; - if (killer > 0) { + if (killer) { scr_loyalty("Inquisitor Killer", "+"); if (obj_controller.loyalty >= 85) { obj_controller.last_inquisitor_inspection -= 44; @@ -179,11 +152,11 @@ try { scr_loyalty("Inquisitor Killer", "+"); } - var msg = "", msg2 = "", i = 0; + var msg = ""; + var inquis_name = ""; if (killer_tg > 0) { - var inquis_name = obj_controller.inquisitor[killer_tg]; - msg += $"Inquisitor {inquis_name} has been killed!"; - msg2 = $"Inquisitor {inquis_name}"; + inquis_name = $"Inquisitor {obj_controller.inquisitor[killer_tg]}"; + msg += $"{inquis_name} has been killed!"; } if (obj_controller.inquisitor_type[killer_tg] == "Ordo Hereticus") { scr_loyalty("Inquisitor Killer", "+"); @@ -205,11 +178,10 @@ try { instance_activate_object(obj_turn_end); if (instance_exists(obj_turn_end)) { - scr_alert("red", "inqis", string(msg), ii.x + 16, ii.y - 24); + scr_alert("red", "inqis", string(msg), _random_star.x + 16, _random_star.y - 24); } if ((!instance_exists(obj_turn_end)) && (obj_controller.faction_status[eFACTION.INQUISITION] != "War")) { - var pip; - pip = instance_create(0, 0, obj_popup); + var pip = instance_create(0, 0, obj_popup); pip.title = "Inquisitor Killed"; pip.text = msg; pip.image = "inquisition"; @@ -217,13 +189,10 @@ try { if (obj_controller.known[eFACTION.INQUISITION] < 3) { pip.title = "EXCOMMUNICATUS TRAITORUS"; - pip.text = $"The Inquisition has noticed your uncalled murder of {msg2} and declared your chapter Excommunicatus Traitorus."; + pip.text = $"The Inquisition has noticed your uncalled murder of {inquis_name} and declared your chapter Excommunicatus Traitorus."; obj_controller.alarm[8] = 1; } } - - // if (obj_controller.known[eFACTION.INQUISITION]<3) then with(obj_popup){instance_destroy();} - // excommunicatus traitorus } diff --git a/objects/obj_fleet/Create_0.gml b/objects/obj_fleet/Create_0.gml index 724718dacf..9004826a78 100644 --- a/objects/obj_fleet/Create_0.gml +++ b/objects/obj_fleet/Create_0.gml @@ -13,7 +13,6 @@ battle_special = ""; csm_exp = 0; star_name = ""; -// woohoo=0; left_down = 0; view_x = obj_controller.x; @@ -41,8 +40,8 @@ player_started = 0; player_lasers = 0; player_lasers_cd = 70; player_lasers_target = 0; -pla_fleet = 0; -ene_fleet = 0; +pla_fleet = instance_nearest(x, y, obj_p_fleet); +ene_fleet = instance_nearest(x, y, obj_en_fleet); victory = false; instance_deactivate_all(true); @@ -103,7 +102,6 @@ en_mutation[0] = ""; en_mutation[1] = ""; en_mutation[2] = ""; -// ambushers = scr_has_adv("Ambushers"); bolter_drilling = scr_has_adv("Bolter Drilling"); enemy_eldar = scr_has_adv("Enemy: Eldar"); @@ -114,7 +112,7 @@ enemy_tyranids = scr_has_adv("Enemy: Tyranids"); siege = scr_has_adv("Siege Masters"); slow = scr_has_adv("Devastator Doctrine"); melee = scr_has_adv("Assault Doctrine"); -// + black_rage = scr_has_disadv("Black Rage"); shitty_luck = scr_has_disadv("Shitty Luck"); favoured_by_the_warp = scr_has_adv("Favoured By The Warp"); @@ -126,7 +124,7 @@ betchers = obj_ini.betchers; // slight melee penalty catalepsean = obj_ini.catalepsean; // minor global attack decrease occulobe = obj_ini.occulobe; // penalty if morning and susceptible to flash grenades mucranoid = obj_ini.mucranoid; // chance to short-circuit -// + global_melee = 1; global_bolter = 1; global_attack = 1; @@ -150,7 +148,6 @@ if (scr_has_adv("Kings of Space")) { global_attack += 0.1; } -// master = 0; time = 0; @@ -186,7 +183,6 @@ ship_lost = []; // screwing around below here alarm[6] = 2; -// // waiting at this point- show loading screen // in this time the obj_controller passes over which units will be fighting, similar to the below code @@ -203,6 +199,3 @@ column[5] = "escort"; column_width[5] = 76; color_index = 0; - -/* */ -/* */ diff --git a/objects/obj_fleet/Draw_64.gml b/objects/obj_fleet/Draw_64.gml index 436410a156..0381e7b108 100644 --- a/objects/obj_fleet/Draw_64.gml +++ b/objects/obj_fleet/Draw_64.gml @@ -50,7 +50,7 @@ if (start == 0) { } // fast forward icon -if (gamespeed_fps != 90 && start == 5) { +if (game_get_speed(gamespeed_fps) != 90 && start == 5) { draw_set_alpha(1); var _ff_h = sprite_get_height(spr_fast_forward); draw_sprite(spr_fast_forward, 0, 12, (_surface_h / 2) - (_ff_h / 2)); diff --git a/objects/obj_fleet/KeyPress_67.gml b/objects/obj_fleet/KeyPress_67.gml index 632facf1c3..e69de29bb2 100644 --- a/objects/obj_fleet/KeyPress_67.gml +++ b/objects/obj_fleet/KeyPress_67.gml @@ -1,11 +0,0 @@ -/*obj_p_capital.hp=0; -obj_en_ship.hp=0; -obj_en_ship.shields=0; -with(obj_en_ship){instance_destroy();} -*/ - -/*obj_p_ship.hp=0; -player_lasers=48;*/ - -/* */ -/* */ diff --git a/objects/obj_fleet/Mouse_56.gml b/objects/obj_fleet/Mouse_56.gml index 0765ef3893..2c62e6353a 100644 --- a/objects/obj_fleet/Mouse_56.gml +++ b/objects/obj_fleet/Mouse_56.gml @@ -1,5 +1,3 @@ -var pressy; -pressy = 0; sel_x1 = 0; sel_y1 = 0; @@ -42,12 +40,12 @@ if (instance_exists(obj_p_ship) && (control == 1)) { //Why is this here? if ((start == 5) && (obj_controller.zoomed == 0)) { - if ((mouse_x >= camera_get_view_x(view_camera[0]) + 12) && (mouse_y >= camera_get_view_y(view_camera[0]) + 436) && (mouse_x < camera_get_view_x(view_camera[0]) + 48) && (mouse_y < camera_get_view_y(view_camera[0]) + 480) && (gamespeed_fps < 90)) { + if ((mouse_x >= camera_get_view_x(view_camera[0]) + 12) && (mouse_y >= camera_get_view_y(view_camera[0]) + 436) && (mouse_x < camera_get_view_x(view_camera[0]) + 48) && (mouse_y < camera_get_view_y(view_camera[0]) + 480) && (game_get_speed(gamespeed_fps) < 90)) { game_set_speed(game_get_speed(gamespeed_fps) + 30, gamespeed_fps); } } if ((start == 5) && (obj_controller.zoomed == 1)) { - if ((mouse_x > 24) && (mouse_y > 872) && (mouse_x < 90) && (mouse_y < 960) && (gamespeed_fps < 90)) { + if ((mouse_x > 24) && (mouse_y > 872) && (mouse_x < 90) && (mouse_y < 960) && (game_get_speed(gamespeed_fps) < 90)) { game_set_speed(game_get_speed(gamespeed_fps) + 30, gamespeed_fps); } } diff --git a/objects/obj_fleet/Step_0.gml b/objects/obj_fleet/Step_0.gml index c31d146b9d..65390ce41b 100644 --- a/objects/obj_fleet/Step_0.gml +++ b/objects/obj_fleet/Step_0.gml @@ -1,6 +1,4 @@ -// if (woohoo<60) then woohoo+=1; - -if (beg != 0) /* and (instance_exists(obj_fleet_controller))*/ { +if (beg != 0) { if ((combat_end > -1) && (!instance_exists(obj_en_ship))) { combat_end -= 1; victory = true; @@ -59,6 +57,3 @@ if (start == 5) { } } } - -/* */ -/* */ diff --git a/objects/obj_fleet_select/Create_0.gml b/objects/obj_fleet_select/Create_0.gml index 33aee50fe0..73a672ea75 100644 --- a/objects/obj_fleet_select/Create_0.gml +++ b/objects/obj_fleet_select/Create_0.gml @@ -29,15 +29,12 @@ selection_window.inside_method = function() { var width = selection_window.width; var height = selection_window.height; - // draw_text(view_xview[0]+46,view_yview[0]+117,"Title"); - // draw_text(view_xview[0]+46,view_yview[0]+142,"1#2#3#4#5#6#7#8#9#10#11#1#13#14#15#16#17#18#19#20#21#22#23#24#25"); + var lines = 0, posi = -1, colu = 1, x3 = 48, y3 = 60, ty = 0, name = "", selection_box, scale = 1, void_h = 122, shew, ship_health = 0; + var escorts = escort; + var frigates = frigate; + var capitals = capital; - var type = "capital", lines = 0, posi = -1, colu = 1, x3 = 48, y3 = 60, escorts, frigates, capitals, ty = 0, current_ship = 0, current_fleet = 0, name = "", sal = 0, selection_box, scale = 1, void_h = 122, shew, ship_health = 0; - escorts = escort; - frigates = frigate; - capitals = capital; - - current_fleet = instance_nearest(x, y, obj_p_fleet); + var current_fleet = instance_nearest(x, y, obj_p_fleet); if (escorts > 0) { ty++; @@ -159,14 +156,6 @@ selection_window.inside_method = function() { ship_select = fleet_all; } - /*if (y3>670) and (posi<=escorts+frigates+capitals){ - lines=1; - y3=30; - x3+=223; - posi++; - colu++; - }*/ - if ((posi <= escorts + frigates + capitals) && is_array(ship_type) && current_ship < array_length(ship_type)) { name = ship_type[current_ship]; if (string_width(name) * scale > 179) { diff --git a/objects/obj_fleet_select/Draw_0.gml b/objects/obj_fleet_select/Draw_0.gml index d28e51c2c4..a7c91ad80b 100644 --- a/objects/obj_fleet_select/Draw_0.gml +++ b/objects/obj_fleet_select/Draw_0.gml @@ -142,10 +142,9 @@ if (!instance_exists(obj_drop_select) && !instance_exists(obj_bomb_select)) { } else { move_fleet = split_selected_into_new_fleet(player_fleet); } + var final_course = star_travel.final_array_path(); if (keyboard_check(vk_shift)) { final_course = [sys.name]; - } else { - var final_course = star_travel.final_array_path(); } with (move_fleet) { set_new_player_fleet_course(final_course); diff --git a/objects/obj_ingame_menu/Step_0.gml b/objects/obj_ingame_menu/Step_0.gml index 990916a4c8..75b1473934 100644 --- a/objects/obj_ingame_menu/Step_0.gml +++ b/objects/obj_ingame_menu/Step_0.gml @@ -22,11 +22,11 @@ switch (effect) { var _sav = instance_create_depth(0, 0, -20005, obj_saveload); _sav.menu = (effect == eIN_GAME_MENU_EFFECT.SAVE) ? 1 : 2; - var _b = instance_create_depth(707, 830, -20010, obj_new_button); - _b.button_text = "Back"; - _b.target = eIN_GAME_MENU_EFFECT.BACK_FROM_SAVELOAD; - _b.scaling = 1.5; - _b.button_id = 1; + var _load_button = instance_create_depth(707, 830, -20010, obj_new_button); + _load_button.button_text = "Back"; + _load_button.target = eIN_GAME_MENU_EFFECT.BACK_FROM_SAVELOAD; + _load_button.scaling = 1.5; + _load_button.button_id = 1; break; case eIN_GAME_MENU_EFFECT.OPTIONS: @@ -34,12 +34,12 @@ switch (effect) { x -= 2000; y -= 2000; } - var _b = instance_create_depth(653, 664, -20010, obj_new_button); - _b.sprite_index = spr_ui_but_1; - _b.button_text = "Back"; - _b.target = eIN_GAME_MENU_EFFECT.BACK_FROM_SETTINGS; - _b.scaling = 1.5; - _b.button_id = 1; + var _options_button = instance_create_depth(653, 664, -20010, obj_new_button); + _options_button.sprite_index = spr_ui_but_1; + _options_button.button_text = "Back"; + _options_button.target = eIN_GAME_MENU_EFFECT.BACK_FROM_SETTINGS; + _options_button.scaling = 1.5; + _options_button.button_id = 1; settings = 1; cooldown = 8; diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index 1478436c5f..f66a3ef83e 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -94,6 +94,8 @@ ship_capacity = []; ship_carrying = []; ship_contents = []; ship_turrets = []; +ship_guardsmen = []; // Imperial Guard auxilia currently embarked on this ship +ship_guardsmen_max = []; // Max Guard auxilia this ship hull can carry ship_lost = []; // Vehicle Init @@ -196,13 +198,16 @@ serialize = function() { var _marines = array_create(0); for (var _coy = 0; _coy <= 10; _coy++) { - for (var _mar = 0; _mar <= 500; _mar++) { - var _marine_json; + // Iterate the company's full restored length, not a fixed 0..500, so guardsmen in overflow + // slots past 500 (HQ grows uncapped once it fills) are serialized too. The old early-break + // on consecutive empty slots is dropped because guardsmen can leave gaps, and the break + // would skip every unit after the first gap, which is what desynced TTRPG from name[] on + // reload. + var _coy_len = array_length(obj_ini.name[_coy]); + for (var _mar = 0; _mar < _coy_len; _mar++) { if (obj_ini.name[_coy][_mar] != "") { - _marine_json = jsonify_marine_struct(_coy, _mar, false); + var _marine_json = jsonify_marine_struct(_coy, _mar, false); array_push(_marines, _marine_json); - } else if (_mar > 0 && _mar <= 499 && obj_ini.name[_coy][_mar + 1] == "") { - break; } } } @@ -324,9 +329,16 @@ deserialize = function(save_data) { obj_ini.TTRPG[company][marine].load_json_data(struct); } - obj_ini.TTRPG = array_create(11, array_create(501, [])); + // Size each company's struct array to its restored roster length (minimum 501) so TTRPG can + // never be shorter than the flat name[] array. HQ can exceed 501 slots once guardsmen overflow + // it, and a fixed 501 here desynced from name[] after a load, sending fetch_unit out of range + // (Chapter Management crash). Building each company array separately also avoids the shared + // inner-array aliasing of the old array_create(11, array_create(501, [])) form. + obj_ini.TTRPG = array_create(11); for (var _coy = 0; _coy < 11; _coy++) { - for (var _mar = 0; _mar <= 500; _mar++) { + var _coy_len = max(501, array_length(obj_ini.name[_coy])); + obj_ini.TTRPG[_coy] = array_create(_coy_len); + for (var _mar = 0; _mar < _coy_len; _mar++) { obj_ini.TTRPG[_coy][_mar] = new TTRPG_stats("chapter", _coy, _mar, "blank"); } } diff --git a/objects/obj_managment_panel/Create_0.gml b/objects/obj_managment_panel/Create_0.gml index 63e0a70013..262e78cc80 100644 --- a/objects/obj_managment_panel/Create_0.gml +++ b/objects/obj_managment_panel/Create_0.gml @@ -45,6 +45,7 @@ draw_lines = function(_x, _y, increment, truncate_line) { draw_set_font(fnt_40k_12); var _draw_func = draw_text; + var _line = truncate_line ? string_truncate(line[l], 134) : line[l]; var _is_struct = is_struct(line[l]); if (_is_struct) { var _struc = line[l]; @@ -54,9 +55,7 @@ draw_lines = function(_x, _y, increment, truncate_line) { if (_struc.bold) { _draw_func = draw_text_bold; } - var _line = truncate_line ? string_truncate(_struc.str1, 134) : _struc.str1; - } else { - var _line = truncate_line ? string_truncate(line[l], 134) : line[l]; + _line = truncate_line ? string_truncate(_struc.str1, 134) : _struc.str1; } _draw_func(_x, _y + _y_depth - scroll_offset, _line); diff --git a/objects/obj_managment_panel/Draw_64.gml b/objects/obj_managment_panel/Draw_64.gml index f49d172dc3..d2b9490c6e 100644 --- a/objects/obj_managment_panel/Draw_64.gml +++ b/objects/obj_managment_panel/Draw_64.gml @@ -60,7 +60,7 @@ slate_panel.inside_method = function() { } else if (title == "LIBRARIUM") { draw_sprite_ext(spr_lib_area_pad, 0, x + (panel_width / 2) - ((0.3 * 180) / 2), y - 30, 0.3, 0.3, 0, c_white, 1); } else { - sprx = x + (wid / 2) - 16; + sprx = x + (panel_width / 2) - 16; spry = y - 16; sprw = 141 * 0.23; sprh = 141 * 0.23; diff --git a/objects/obj_ncombat/Alarm_0.gml b/objects/obj_ncombat/Alarm_0.gml index 7657a4bc4f..8ff85db560 100644 --- a/objects/obj_ncombat/Alarm_0.gml +++ b/objects/obj_ncombat/Alarm_0.gml @@ -7,9 +7,6 @@ try { instance_activate_object(obj_enunit); - // show_message("Leader?: "+string(leader)); - - // if (enemy=1) then show_message("exiting obj_ncombat_Alarm 0_2 due to enemy=1"); if (enemy == 1) { instance_activate_object(obj_enunit); exit; @@ -30,8 +27,7 @@ try { fortified = 0; } - var i = 0, u; - i = xxx / 10; + var u; if ((fortified > 1) && (enemy + threat != 17)) { u = instance_create(0, 0, obj_nfort); @@ -63,10 +59,11 @@ try { u.maxhp[1] = u.hp[1]; } + var _num = xxx / 10; for (var j = 0; j < 10; j++) { - i -= 1; - u = instance_create(i * 10, 240, obj_enunit); - u.column = i - ((xxx / 10) - 10); + _num -= 1; + u = instance_create(_num * 10, 240, obj_enunit); + u.column = _num - ((xxx / 10) - 10); } // *** Enemy Forces Special Event *** // * Malcadon Spyrer * @@ -287,8 +284,8 @@ try { } // ** Space Hulk Forces ** if (battle_special == "space_hulk") { - var make, modi; - // show_message("space hulk battle, player forces: "+string(player_forces)); + var make; + var modi; with (obj_enunit) { instance_destroy(); } @@ -347,7 +344,6 @@ try { } // * CSM Space Hulk * if (enemy == 10) { - var make, modi; modi = random_range(0.80, 1.20) + 1; make = round(max(3, player_starting_dudes * modi)); @@ -374,7 +370,6 @@ try { hulk_forces = make; } - // show_message(string(instance_number(obj_enunit))+"x enemy blocks"); instance_activate_object(obj_enunit); exit; } @@ -397,11 +392,9 @@ try { u.dudes[5] = "Venerable Chaos Chosen"; u.dudes_num[5] = 50; - // u.dudes[4]="Chaos Basilisk";u.dudes_num[4]=18; instance_deactivate_object(u); u = instance_nearest(xxx + 10, 240, obj_enunit); - // u.dudes[1]="Chaos Leman Russ";u.dudes_num[1]=40; u.dudes[1] = "Chaos Sorcerer"; u.dudes_num[1] = 4; u.dudes[2] = "Chaos Space Marine"; @@ -412,7 +405,6 @@ try { u.dudes_num[4] = 20; u.dudes[5] = "Bloodletter"; u.dudes_num[5] = 30; - // u.dudes[3]="Vindicator";u.dudes_num[3]=10; instance_deactivate_object(u); u = instance_nearest(xxx + 20, 240, obj_enunit); @@ -427,16 +419,11 @@ try { u = instance_nearest(xxx + 30, 240, obj_enunit); u.dudes[1] = "Cultist Elite"; u.dudes_num[1] = 1500; - // u.dudes[2]="Cultist Elite";u.dudes_num[2]=1500; u.dudes[2] = "Helbrute"; u.dudes_num[2] = 3; - // u.dudes[3]="Predator";u.dudes_num[3]=6; - // u.dudes[4]="Vindicator";u.dudes_num[4]=3; - // u.dudes[5]="Land Raider";u.dudes_num[5]=2; instance_deactivate_object(u); u = instance_nearest(xxx + 40, 240, obj_enunit); - // u.dudes[1]="Mutant";u.dudes_num[1]=8000; u.dudes[1] = "Cultist"; u.dudes_num[1] = 1500; u.dudes[2] = "Helbrute"; @@ -458,11 +445,9 @@ try { u.dudes_num[4] = 20; u.dudes[5] = "Venerable Chaos Chosen"; u.dudes_num[5] = 50; - // u.dudes[4]="Chaos Basilisk";u.dudes_num[4]=18; instance_deactivate_object(u); u = instance_nearest(xxx + 10, 240, obj_enunit); - // u.dudes[1]="Chaos Leman Russ";u.dudes_num[1]=40; u.dudes[1] = "Chaos Sorcerer"; u.dudes_num[1] = 2; u.dudes[1] = "Cultist"; @@ -476,15 +461,6 @@ try { guard_total = threat; guard_score = 6; - /*if (guard_total>=15000000) then guard_score=6; - if (guard_total<15000000) and (guard_total>=6000000) then guard_score=5; - if (guard_total<6000000) and (guard_total>=1000000) then guard_score=4; - if (guard_total<1000000) and (guard_total>=50000) then guard_score=3; - if (guard_total<50000) and (guard_total>=500) then guard_score=2; - if (guard_total<500) then guard_score=1;*/ - - // guard_effective=floor(guard_total)/8; - var f = 0, guar = threat / 10; // Guardsmen @@ -569,16 +545,6 @@ try { u.flank = 1; u.flyer = 1; } - - /*u=instance_nearest(xxx,240,obj_enunit);enemy_dudes=threat; - u.dudes[1]="Imperial Guardsman";u.dudes_num[1]=floor(guard_effective*0.6);enemies[1]=u.dudes[1]; - u.dudes[2]="Heavy Weapons Team";u.dudes_num[2]=min(1000,floor(guard_effective*0.1));enemies[2]=u.dudes[2]; - if (threat>1){u.dudes[3]="Leman Russ Battle Tank";u.dudes_num[3]=min(1000,floor(guard_effective*0.1));enemies[3]=u.dudes[3];} - - u=instance_nearest(xxx,240+10,obj_enunit);enemy_dudes=threat; - u.dudes[1]="Imperial Guardsman";u.dudes_num[1]=floor(guard_effective*0.6);enemies[1]=u.dudes[1]; - u.dudes[2]="Heavy Weapons Team";u.dudes_num[2]=min(1000,floor(guard_effective*0.1));enemies[2]=u.dudes[2]; - if (threat>1){u.dudes[3]="Leman Russ Battle Tank";u.dudes_num[3]=min(1000,floor(guard_effective*0.1));enemies[3]=u.dudes[3];}*/ } // ** Aeldar Force ** @@ -3154,6 +3120,15 @@ try { u.sprite_index = spr_weapon_blank; } + // ** Imperial Guard auxilia ** + // The old p_guardsmen bolt-on block was retired here. Guardsmen are now fielded + // through the standard roster: station them on a world (ship_location -1) and the + // Local Forces toggle deploys them into the Hirelings block like any other unit, + // so the engine handles placement, targeting and casualties. player_guard is kept + // at 0 so the dormant firepower-injection path in scr_player_combat_weapon_stacks + // stays inert. + player_guard = 0; + instance_activate_object(obj_enunit); } catch (_exception) { ERROR_HANDLER.handle_exception(_exception); diff --git a/objects/obj_ncombat/Alarm_1.gml b/objects/obj_ncombat/Alarm_1.gml index 62d194cebb..1afad2cd9d 100644 --- a/objects/obj_ncombat/Alarm_1.gml +++ b/objects/obj_ncombat/Alarm_1.gml @@ -1,5 +1,4 @@ -var a1; -a1 = ""; +var a1 = ""; if ((ally > 0) && (ally_forces > 0)) { if (ally == 3) { @@ -39,8 +38,7 @@ temp += techmarines + honors + dreadnoughts + terminators + captains; temp += standard_bearers + champions + important_dudes + chaplains + apothecaries; temp += sgts + vet_sgts; -var color_descr; -color_descr = ""; +var color_descr = ""; if (obj_ini.main_color != obj_ini.secondary_color) { color_descr = string(obj_controller.col[obj_ini.main_color]) + " and " + string(obj_controller.col[obj_ini.secondary_color]); @@ -49,15 +47,8 @@ if (obj_ini.main_color == obj_ini.secondary_color) { color_descr = string(obj_controller.col[obj_ini.main_color]); } -/*show_message(scouts+tacticals+veterans+devastators+assaults+librarians); -show_message(techmarines+honors+dreadnoughts+terminators+captains); -show_message(standard_bearers+important_dudes+chaplains+apothecaries); -show_message(temp);*/ - // Random variations; dark out, rain pooling down, dawn shining off of the armour, etc. -var variation; -variation = ""; -variation = choose("", "dawn", "rain"); +var variation = choose("", "dawn", "rain"); if (battle_special == "ship_demon") { p1 = "As the Artifact is smashed and melted down some foul smoke begins to erupt from it, spilling outward and upward. After a sparse handful of seconds it takes form into a "; @@ -102,12 +93,6 @@ if (battle_special == "") { if (temp - dreadnoughts > 0) { // lyman p1 = "The air rumbles and quakes as " + string(temp) + " " + string(global.chapter_name) + " descend in drop-pods. "; - - /*if (variation=""){ - if (lyman=0) then p1="The air rumbles and quakes as "+string(temp)+" "+string(global.chapter_name)+" descend in drop-pods. Before the enemy can bring their full ranged power to bear the pods smash down. With practiced speed your marines pour on free. Their ranks are made up of "; - if (lyman=1) then p1="The air rumbles and quakes as "+string(temp)+" "+string(global.chapter_name)+" descend in drop-pods. Before the enemy can bring their full ranged power to bear the pods smash down. Your marines exit the vehicles, shaking off their vertigo and nausea with varying degrees of success. Your ranks are made up of "; - } - */ } } } @@ -308,17 +293,14 @@ if (temp6 > 0) { p2 += string(temp6) + " other various Astartes, "; } -var woo; -woo = string_length(p2); +var woo = string_length(p2); p2 = string_delete(p2, woo - 1, 2); if (string_count(", ", p2) > 1) { - var woo; woo = string_rpos(", ", p2); p2 = string_insert(" and", p2, woo + 1); } if (string_count(", ", p2) == 1) { - var woo; woo = string_rpos(", ", p2); p2 = string_delete(p2, woo - 1, 2); p2 = string_insert(" and", p2, woo + 1); @@ -375,17 +357,14 @@ if (dreadnoughts + predators + land_raiders > 3) { // Other vehicles here? - var woo; woo = string_length(p6); p6 = string_delete(p6, woo - 1, 2); if (string_count(", ", p6) > 1) { - var woo; woo = string_rpos(", ", p6); p6 = string_insert(" and", p6, woo + 1); } if (string_count(", ", p6) == 1) { - var woo; woo = string_rpos(", ", p6); p6 = string_delete(p6, woo - 1, 2); p6 = string_insert(" and", p6, woo + 1); @@ -459,14 +438,6 @@ temp3 = 0; temp4 = 0; temp5 = 0; -/*if (terrain=""){rand=choose(1,2,3);// Variations for terrain - if (rand<4) then - // if (rand=2) then p1="Encroaching upon your forces are "; - // if (rand=3) then p1="Advancing upon your forces are "; -} - -// p1+=string(enemy_dudes);// The number descriptor*/ - if (enemy == 2) { p1 = "Opposing your forces are a total of " + scr_display_number(floor(guard_effective)) + " Guardsmen, including Heavy Weapons and Armour."; p2 = ""; @@ -493,11 +464,10 @@ if ((enemy == 5) && (dropping == 0)) { } if ((enemy == 6) && (dropping == 0)) { - // p1+=" Eldar";// Need a few random descriptors here + // Need a few random descriptors here rand = choose(1, 2, 3); } if ((enemy == 7) && (dropping == 0)) { - // p1+=" Orks"; rand = choose(1, 2, 3); if (rand < 4) { p1 = "Howls and grunts ring from the surrounding terrain as the Orks announce their presence. "; @@ -513,11 +483,9 @@ if ((enemy == 7) && (dropping == 1)) { } if ((enemy == 8) && (dropping == 0)) { - // p1+=" Tau"; rand = choose(1, 2, 3); } if ((enemy == 9) && (dropping == 0)) { - // p1+=" Tyranids"; rand = choose(1, 2, 3); } if ((enemy == 9) && (dropping == 1)) { @@ -525,7 +493,6 @@ if ((enemy == 9) && (dropping == 1)) { } if ((enemy == 10) && (dropping == 0)) { - // p1+=" heretics"; rand = choose(1, 2, 3); } @@ -542,7 +509,6 @@ if ((enemy == 10) && (threat == 7)) { } if ((enemy == 11) && (dropping == 0)) { - // p1+=" Chaos Space Marines"; rand = choose(1, 2, 3); } @@ -632,7 +598,6 @@ if ((fortified > 1) && (dropping == 0) && (enemy + threat != 17)) { } // Check for battlecry here -// if (temp>=100) and (threat>1) and (big_mofo!=10) and (dropping=0){ if ((temp >= 100) && (threat > 1) && (big_mofo > 0) && (big_mofo < 10) && (dropping == 0)) { p1 = ""; p2 = ""; @@ -659,11 +624,9 @@ if ((temp >= 100) && (threat > 1) && (big_mofo > 0) && (big_mofo < 10) && (dropp p1 = "A Chaplain "; } - var standard_cry; - standard_cry = 0; + var standard_cry = 0; if (global.chapter_name == "Salamanders") { standard_cry = 1; - var rand; rand = choose(1, 2, 3, 4, 5); if ((rand == 1) && (big_mofo != 1)) { p2 = "breaks the silence, begining the Chapter Battlecry-"; @@ -720,7 +683,6 @@ if ((temp >= 100) && (threat > 1) && (big_mofo > 0) && (big_mofo < 10) && (dropp } if (obj_ini.battle_cry == "...") { standard_cry = 1; - var rand; rand = choose(1, 2, 3); if ((rand == 1) && (big_mofo != 1)) { p2 = "remains silent as the Chapter forms for battle-"; @@ -764,11 +726,8 @@ if ((temp >= 100) && (threat > 1) && (big_mofo > 0) && (big_mofo < 10) && (dropp scr_newtext(); } - // show_message(string(global.chapter_name)+"|"+string(global.custom)+"|"+string(standard_cry)); - if ((global.chapter_name == "Iron Warriors") && (global.custom == eCHAPTER_TYPE.PREMADE)) { standard_cry = 1; - var rand; rand = choose(1, 2, 3, 4, 5); if ((rand == 1) && (big_mofo != 1)) { p2 = "breaks the silence, begining the Chapter Battlecry-"; @@ -826,7 +785,6 @@ if ((temp >= 100) && (threat > 1) && (big_mofo > 0) && (big_mofo < 10) && (dropp if (standard_cry == 0) { standard_cry = 1; - var rand; rand = choose(1, 2, 3, 4); if (rand == 1) { if (big_mofo != 1) { @@ -894,6 +852,3 @@ newline = line_break; scr_newtext(); newline = line_break; scr_newtext(); - -/* */ -/* */ diff --git a/objects/obj_ncombat/Alarm_2.gml b/objects/obj_ncombat/Alarm_2.gml index c1201cff51..7d76826361 100644 --- a/objects/obj_ncombat/Alarm_2.gml +++ b/objects/obj_ncombat/Alarm_2.gml @@ -7,17 +7,15 @@ if (dropping) { squeeze_map_forces(); } +//TODO refactor so that unit structs are created for ally forces +/* if ((ally > 0) && (ally_forces > 0)) { if (ally == 3) { if (ally_forces >= 1) { - var thata, ii, good; - thata = instance_nearest(0, 240, obj_pnunit); - ii = 0; - good = 0; + var thata = instance_nearest(0, 240, obj_pnunit); + var ii = 0; + var good = 0; - //TODO refactor so that unit structs are created for ally forces - - /* if (instance_exists(thata)){ ii=array_length(marine_type); @@ -57,9 +55,9 @@ if ((ally > 0) && (ally_forces > 0)) { repeat(50){if (good=0){ii+=1;if (thata.dudes[ii]="") and (thata.dudes_num[ii]=0) then good=ii;}} if (good>0){thata.dudes[ii]="Skitarii";thata.dudes_num[ii]=20;thata.dudes_vehicle[ii]=0;} thata.alarm[1]=1; - }*/ + } } } -} +}*/ instance_activate_object(obj_enunit); diff --git a/objects/obj_ncombat/Alarm_3.gml b/objects/obj_ncombat/Alarm_3.gml index e50d0f7ac1..f0249ee4ad 100644 --- a/objects/obj_ncombat/Alarm_3.gml +++ b/objects/obj_ncombat/Alarm_3.gml @@ -27,7 +27,7 @@ repeat (100) { changed = 0; i = 0; - repeat (55) { + repeat (COMBAT_LOG_CAPACITY) { i += 1; // Collide the messages if needed @@ -42,37 +42,8 @@ repeat (100) { changed = 1; } - // Move larger messages up - if ((message[i] != "") && (message[i + 1] != "") && (message_sz[i] < message_sz[i + 1]) && ((message_priority[i] < message_priority[i + 1]) || (message_priority[i] == 0))) { - message[100] = message[i]; - message_sz[100] = message_sz[i]; - message_priority[100] = message_priority[i]; - - message[i] = message[i + 1]; - message_sz[i] = message_sz[i + 1]; - message_priority[i] = message_priority[i + 1]; - - message[i + 1] = message[100]; - message_sz[i + 1] = message_sz[100]; - message_priority[i + 1] = message_priority[100]; - changed = 1; - } - - // Move messages with higher priority up - if ((message[i] != "") && (message[i + 1] != "") && (message_priority[i] < message_priority[i + 1])) { - message[100] = message[i]; - message_sz[100] = message_sz[i]; - message_priority[100] = message_priority[i]; - - message[i] = message[i + 1]; - message_sz[i] = message_sz[i + 1]; - message_priority[i] = message_priority[i + 1]; - - message[i + 1] = message[100]; - message_sz[i + 1] = message_sz[100]; - message_priority[i + 1] = message_priority[100]; - changed = 1; - } + // Messages are shown in the order they happened, so we only compact gaps upward + // (above) and no longer reorder by size/priority. if (changed == 0) { good = 1; @@ -81,20 +52,20 @@ repeat (100) { } } -if (((messages > 0) && (messages_shown < 24)) && (messages_shown <= 100)) { - var that_sz, that; // show_message("Largest Message"); - that_sz = 0; - that = 0; +if (messages > 0) { + // Show messages in the order they happened (chronological), with no per-turn cap, so the + // whole exchange is visible right down to the closing "held fire" line. + var that = 0; i = 0; - repeat (60) { + repeat (COMBAT_LOG_CAPACITY) { i += 1; - if ((message[i] != "") && (message_sz[i] > that_sz)) { - that_sz = message_sz[i]; + if (message[i] != "") { that = i; + break; } } - if ((that != 0) && (that_sz > 0)) { + if (that != 0) { newline = message[that]; if (message_priority[that] > 0) { newline_color = "bright"; @@ -116,6 +87,12 @@ if (((messages > 0) && (messages_shown < 24)) && (messages_shown <= 100)) { if (message_priority[that] == 137) { newline_color = "red"; } + if (message_priority[that] == MSG_COLOR_WHITE) { + newline_color = "white"; + } + if (message_priority[that] == MSG_COLOR_LIGHTGREEN) { + newline_color = "lightgreen"; + } scr_newtext(); messages_shown += 1; @@ -129,10 +106,6 @@ if (((messages > 0) && (messages_shown < 24)) && (messages_shown <= 100)) { alarm[3] = 2; } -if ((messages == 0) || (messages_shown >= 24)) { - messages_shown = 999; -} - if (messages == 0) { messages_shown = 999; } @@ -155,23 +128,7 @@ if (!instance_exists(obj_pnunit)) { if (((messages_shown == 999) || (messages == 0)) && (timer_stage == 2)) { newline_color = "yellow"; if (obj_ncombat.enemy != 6) { - if ((enemy_forces > 0) && (obj_ncombat.enemy != 30)) { - newline = "Enemy Forces at " + string(max(1, round((enemy_forces / enemy_max) * 100))) + "%"; - } - if ((obj_ncombat.enemy == 30) && instance_exists(obj_enunit)) { - newline = "Enemy has "; - var yoo; - yoo = instance_nearest(0, 0, obj_enunit); - newline += string(round(yoo.dudes_hp[1])) + "HP remaining"; - } - if ((enemy_forces <= 0) || (!instance_exists(obj_enunit)) && (defeat_message == 0)) { - defeat_message = 1; - newline = "Enemy Forces Defeated"; - timer_maxspeed = 0; - timer_speed = 0; - started = 2; - instance_activate_object(obj_pnunit); - } + combat_emit_enemy_status(); } newline_color = "yellow"; if (obj_ncombat.enemy == 6) { diff --git a/objects/obj_ncombat/Alarm_4.gml b/objects/obj_ncombat/Alarm_4.gml index cb52e8a14b..52ebeeff05 100644 --- a/objects/obj_ncombat/Alarm_4.gml +++ b/objects/obj_ncombat/Alarm_4.gml @@ -1,8 +1,4 @@ -var jims; -jims = 0; -repeat (20) { - jims += 1; - +for (var jims = 1; jims <= 20; jims++) { if (dead_jim[jims] != "") { newline = dead_jim[jims]; newline_color = "red"; diff --git a/objects/obj_ncombat/Alarm_5.gml b/objects/obj_ncombat/Alarm_5.gml index 8e164ccf10..4c445c459b 100644 --- a/objects/obj_ncombat/Alarm_5.gml +++ b/objects/obj_ncombat/Alarm_5.gml @@ -354,8 +354,21 @@ if ((!defeat) && (battle_special == "space_hulk")) { var enemy_power = 0, loot = 0, dicey = roll_dice_chapter(1, 100, "low"); ex = 0; - if (enemy == eFACTION.ORK || enemy == eFACTION.TYRANIDS || enemy == eFACTION.HERETICS) { - enemy_power = p_data.add_forces(enemy, -1); + // Reduce the hulk garrison by one and read the strength left behind. A Chaos hulk keeps its + // strength in the traitor (p_traitors) slot, which edit_forces reaches through the HERETICS + // case, so it is reduced as HERETICS. This also lets Chaos hulks lose forces, clear, and roll + // loot at all, which they previously never could. + var _hulk_faction = enemy; + if (enemy == eFACTION.CHAOS) { + _hulk_faction = eFACTION.HERETICS; + } + if (enemy == eFACTION.ORK || enemy == eFACTION.TYRANIDS || enemy == eFACTION.HERETICS || enemy == eFACTION.CHAOS) { + enemy_power = p_data.add_forces(_hulk_faction, -1); + // Garrison wiped out: the hulk is cleared. The salvage choice is offered post-battle in + // space_hulk_explore_battle_aftermath (scr_post_battle_events). + if (enemy_power <= 0) { + hulk_cleared = 1; + } } part10 = "Space Hulk Exploration at "; @@ -494,7 +507,7 @@ if (defeat == 0 && _reduce_power) { who_cleansed = "Gene Stealer Cult"; make_alert = true; delete_features(p_feature[battle_planet], eP_FEATURES.GENE_STEALER_CULT); - adjust_influence(eFACTION.TYRANIDS, -25, battle_planet); + adjust_influence(eFACTION.TYRANIDS, -25, battle_planet, self); } if (make_alert) { if (p_first[battle_planet] == 1) { @@ -559,7 +572,20 @@ if (defeat == 0 && _reduce_power) { } if (enemy >= 5) { - p_data.edit_forces(enemy, new_power); + // Combat numbers the Chaos/Heretic pair opposite to eFACTION. enemy 10 (eFACTION.CHAOS) + // is fought as the Heretic/traitor force and its strength is read from p_traitors above; + // enemy 11 (eFACTION.HERETICS) is fought as the Chaos Space Marine force read from p_chaos. + // edit_forces maps by eFACTION (CHAOS -> p_chaos, HERETICS -> p_traitors), so passing the + // raw combat enemy wrote the reduced strength into the OTHER slot, leaving the force that + // was actually fought untouched and often inflating the other one. Swap the pair so the + // reduction lands on the same force the battle was drawn from. Mirrors the space_hulk fix. + var _reduce_faction = enemy; + if (enemy == eFACTION.CHAOS) { + _reduce_faction = eFACTION.HERETICS; + } else if (enemy == eFACTION.HERETICS) { + _reduce_faction = eFACTION.CHAOS; + } + p_data.edit_forces(_reduce_faction, new_power); } if ((enemy != 2) && (string_count("cs_meeting_battle", battle_special) == 0)) { @@ -684,9 +710,8 @@ if ((leader || ((battle_special == "ChaosWarband") && (!obj_controller.faction_d } } -var endline, inq_eated; -endline = 1; -inq_eated = false; +var endline = 1; +var inq_eated = false; if (obj_ini.omophagea) { var eatme = roll_dice_chapter(1, 100, "high"); @@ -757,7 +782,6 @@ if (obj_ini.omophagea) { // check for inquisitor eatme = roll_dice_chapter(1, 100, "high"); if ((eatme <= 40) && (present_inquisitor == 1)) { - var thatta = 0, remove = 0, i = 0; obj_controller.disposition[4] -= 10; inq_eated = true; instance_activate_object(obj_en_fleet); @@ -779,7 +803,8 @@ if (obj_ini.omophagea) { scr_loyalty("Inquisitor Killer", "+"); } - var msg = "", msg2 = "", i = 0, remove = 0; + var msg = ""; + var remove = 0; // if (string_count("Inqis",inquisitor_ship.trade_goods)>0) then show_message("B"); if (inquisitor_ship.inquisitor > 0) { var inquis_name = obj_controller.inquisitor[inquisitor_ship.inquisitor]; @@ -794,7 +819,7 @@ if (obj_ini.omophagea) { scr_loyalty("Inquisitor Killer", "+"); } - i = remove; + var i = remove; repeat (10 - remove) { if (i < 10) { obj_controller.inquisitor_gender[i] = obj_controller.inquisitor_gender[i + 1]; diff --git a/objects/obj_ncombat/Alarm_7.gml b/objects/obj_ncombat/Alarm_7.gml index bef6f9528e..9e380eb233 100644 --- a/objects/obj_ncombat/Alarm_7.gml +++ b/objects/obj_ncombat/Alarm_7.gml @@ -1,5 +1,4 @@ try { - // LOGGER.debug("alarm 7 start"); audio_stop_sound(snd_battle); audio_play_sound(snd_royal, 0, true); audio_sound_gain(snd_royal, 1, 5000); @@ -14,20 +13,15 @@ try { // If battling own dudes, then remove the loyalists after the fact if (enemy == 1) { - var j = -1; var cleann = array_create(11, false); with (obj_enunit) { - var q = 0; - repeat (700) { - q += 1; + for (var q = 1; q <= 700; q++) { if (dude_id[q] > 0) { var commandy = false; var nco = dude_co[q]; var nid = dude_id[q]; cleann[nco] = true; - // show_message("dude ID:"+string(q)+" ("+string(obj_ini.name[nco,nid])+") is being removed from the array"); - commandy = is_specialist(obj_ini.role[nco][nid]); if (commandy == true) { obj_controller.command -= 1; @@ -44,7 +38,7 @@ try { } } - for (j = 0; j <= 10; j++) { + for (var j = 0; j <= 10; j++) { if (cleann[j]) { with (obj_ini) { scr_company_order(j); @@ -60,16 +54,14 @@ try { with (obj_star) { if (name == obj_ncombat.battle_loc) { instance_create(x, y, obj_temp_meeting); - var i = 0, ii = 0, otm, good = 0, master_present = 0; - var run = 0, s = 0, chaos_meeting = 0; + var master_present = 0; var master_index = array_get_index(obj_ini.role[0], obj_ini.role[100][eROLE.CHAPTERMASTER]); - chaos_meeting = fetch_unit([0, master_index]).planet_location; + var chaos_meeting = fetch_unit([0, master_index]).planet_location; - // show_message("meeting planet:"+string(chaos_meeting)); for (var co = 0; co <= 10; co++) { for (var i = 0; i < array_length(obj_ini.TTRPG[co]); i++) { - good = 0; + var good = 0; _unit = fetch_unit([co, i]); if (_unit.role() == "" || _unit.location_string != name) { continue; @@ -84,11 +76,9 @@ try { good += 1; } - // if (good>=3) then show_message(string(obj_ini.role[co][i])+": "+string(co)+"."+string(i)); - if (good >= 3) { obj_temp_meeting.dudes += 1; - otm = obj_temp_meeting.dudes; + var otm = obj_temp_meeting.dudes; obj_temp_meeting.present[otm] = 1; obj_temp_meeting.co[otm] = co; obj_temp_meeting.ide[otm] = i; @@ -98,7 +88,6 @@ try { } } } - // show_message("obj_temp_meeting.dudes:"+string(obj_temp_meeting.dudes)); } } } @@ -114,7 +103,6 @@ try { obj_ground_mission.defeat = defeat; obj_ground_mission.explore_feature.ruins_combat_end(); } else if ((battle_special == "WL10_reveal") || (battle_special == "WL10_later")) { - var moar, ox, oy; with (obj_temp8) { instance_destroy(); } @@ -127,28 +115,24 @@ try { if (battle_special == "WL10_reveal") { instance_create(battle_object.x, battle_object.y, obj_temp8); - ox = battle_object.x; - oy = battle_object.y; // battle_object.owner = eFACTION.CHAOS; + var ox = battle_object.x; + var oy = battle_object.y; battle_object.p_traitors[battle_id] = 6; battle_object.p_chaos[battle_id] = 4; battle_object.p_pdf[battle_id] = 0; battle_object.p_owner[battle_id] = 10; - var corro; - corro = 0; + var corro = 0; repeat (100) { - var ii; - ii = 0; if (corro <= 5) { - moar = instance_nearest(ox, oy, obj_star); + var moar = instance_nearest(ox, oy, obj_star); if (moar.owner <= 3) { corro += 1; - repeat (4) { - ii += 1; - if (moar.p_owner[ii] <= 3) { - moar.p_heresy[ii] = min(100, moar.p_heresy[ii] + floor(random_range(30, 50))); + for (var i = 1; i <= 4; i++) { + if (moar.p_owner[i] <= 3) { + moar.p_heresy[i] = min(100, moar.p_heresy[i] + floor(random_range(30, 50))); } } } @@ -213,8 +197,6 @@ try { if ((battle_special == "study2a") || (battle_special == "study2b")) { if (defeat == 1) { - var ii = 0, good = 0; - if (remove_planet_problem(battle_id, "mech_tomb", battle_object)) { obj_controller.disposition[3] -= 10; @@ -247,11 +229,6 @@ try { if ((string_count("mech", battle_special) > 0) && (defeat == 0)) { with (obj_ground_mission) { - var comp, plan, i; - i = 0; - comp = 0; - plan = 0; - plan = instance_nearest(x, y, obj_star); scr_return_ship(obj_ground_mission.loc, obj_ground_mission, obj_ground_mission.num); with (obj_ground_mission) { instance_destroy(); @@ -315,7 +292,7 @@ try { if ((string_count("ruins", battle_special) > 0) && (defeat == 1)) { //TODO this logic is wrong assumes all player units died in ruins var _combat_star = find_star_by_name(obj_ncombat.battle_loc); - if (_combat_star != "none") { + if (_combat_star != noone) { _combat_star.p_player[obj_ncombat.battle_id] -= obj_ncombat.world_size; } } @@ -324,10 +301,8 @@ try { necron_tomb_raid_post_battle_sequence(); } - if ((string_count("spyrer", battle_special) > 0) /* and (string_count("demon",battle_special)>0))*/ && (defeat == 0)) { + if ((string_count("spyrer", battle_special) > 0) && (defeat == 0)) { instance_activate_object(obj_star); - // show_message(obj_turn_end.current_battle); - // show_message(obj_turn_end.battle_world[obj_turn_end.current_battle]); // title / text / image / speshul var cur_star = obj_turn_end.battle_object[obj_turn_end.current_battle]; var planet = obj_turn_end.battle_world[obj_turn_end.current_battle]; @@ -356,13 +331,13 @@ try { hunt_fallen_battle_aftermath(); } else if ((defeat == 0) && (enemy == 9) && (battle_special == "tyranid_org")) { if (captured_gaunt > 1) { - _pop = instance_create(0, 0, obj_popup); + var _pop = instance_create(0, 0, obj_popup); _pop.image = "inquisition"; _pop.title = "Inquisition Mission Completed"; _pop.text = "You have captured several Gaunt organisms. The Inquisitor is pleased with your work, though she notes that only one is needed- the rest are to be purged. It will be stored until it may be retrieved. The mission is a success."; } if (captured_gaunt == 1) { - _pop = instance_create(0, 0, obj_popup); + var _pop = instance_create(0, 0, obj_popup); _pop.image = "inquisition"; _pop.title = "Inquisition Mission Completed"; _pop.text = "You have captured a Gaunt organism- the Inquisitor is pleased with your work. The Tyranid will be stored until it may be retrieved. The mission is a success."; @@ -371,7 +346,7 @@ try { var diceh = roll_dice_chapter(1, 100, "high"); if (diceh <= 15) { - var ship, ship_hp, i = -1; + var ship, ship_hp; for (var i = 0; i < array_length(obj_ini.ship); i++) { ship[i] = obj_ini.ship[i]; ship_hp[i] = obj_ini.ship_hp[i]; @@ -418,7 +393,7 @@ try { instance_destroy(); } if (instance_exists(obj_turn_end)) { - obj_turn_end.combating = 0; // obj_turn_end.alarm[1]=1; + obj_turn_end.combating = 0; } var pip; pip = instance_create(0, 0, obj_popup); @@ -442,7 +417,7 @@ try { instance_destroy(); } if (instance_exists(obj_turn_end)) { - obj_turn_end.combating = 0; // obj_turn_end.alarm[1]=1; + obj_turn_end.combating = 0; } var pip = instance_create(0, 0, obj_popup); pip.title = "Survived"; @@ -489,7 +464,7 @@ try { instance_destroy(); } if (instance_exists(obj_turn_end)) { - obj_turn_end.combating = 0; // obj_turn_end.alarm[1]=1; + obj_turn_end.combating = 0; } var pip = instance_create(0, 0, obj_popup); pip.title = "Chaos Lord Killed"; @@ -544,7 +519,7 @@ try { } } if (battle_special == "ChaosWarband") { - obj_controller.faction_defeated[10] = 1; // show_message("WL10 defeated"); + obj_controller.faction_defeated[10] = 1; if (instance_exists(obj_turn_end)) { scr_event_log("", "Enemy Leader Assassinated: Chaos Lord"); scr_alert("", "ass", "Chaos Lord " + string(obj_controller.faction_leader[eFACTION.CHAOS]) + " has been killed.", 0, 0); @@ -581,9 +556,6 @@ try { } instance_destroy(); - - /* */ - /* */ } catch (_exception) { ERROR_HANDLER.handle_exception(_exception); } diff --git a/objects/obj_ncombat/Create_0.gml b/objects/obj_ncombat/Create_0.gml index 5f685215a1..d48fdc7e4b 100644 --- a/objects/obj_ncombat/Create_0.gml +++ b/objects/obj_ncombat/Create_0.gml @@ -3,10 +3,6 @@ if (instance_number(obj_ncombat) > 1) { } set_zoom_to_default(); -var co, i; -co = -1; -co = 0; -i = 0; hue = 0; turn_count = 0; @@ -50,10 +46,9 @@ instance_activate_object(obj_cursor); instance_activate_object(obj_ini); instance_activate_object(obj_img); -var i, u; -i = 11; -repeat (10) { - i -= 1; // This creates the objects to then be filled in +var u = noone; +for (var i = 10; i > 0; i--) { + // This creates the objects to then be filled in u = instance_create(i * 10, 240, obj_pnunit); } @@ -79,6 +74,7 @@ done = 0; captured_gaunt = 0; ethereal = 0; hulk_treasure = 0; +hulk_cleared = 0; four_show = 0; chaos_angry = 0; @@ -86,6 +82,7 @@ leader = 0; thirsty = 0; really_thirsty = 0; allies = 0; +player_attack_guard = 0; // embarked Guard committed to an assault from the attacking fleet present_inquisitor = 0; sorcery_seen = 0; inquisitor_ship = 0; @@ -129,12 +126,12 @@ player_forces = 0; player_max = 0; player_defenses = 0; player_silos = 0; +player_guard = 0; enemy_forces = 0; enemy_max = 0; hulk_forces = 0; -i = -1; messages = 0; messages_to_show = 24; messages_shown = 0; @@ -146,22 +143,25 @@ dead_enemies = 0; units_lost_counts = {}; vehicles_lost_counts = {}; -repeat (70) { - i += 1; - lines[i] = ""; - lines_color[i] = ""; - message[i] = ""; - message_sz[i] = 0; - message_priority[i] = 0; - dead_jim[i] = ""; - dead_ene[i] = ""; - dead_ene_n[i] = 0; - - crunch[i] = 0; - - if (i <= 10) { - mucra[i] = 0; - } +lines = array_create(70, ""); +lines_color = array_create(70, ""); +message = array_create(70, ""); +message_sz = array_create(70, 0); +message_priority = array_create(70, 0); +dead_jim = array_create(70, ""); +dead_ene = array_create(70, ""); +dead_ene_n = array_create(70, 0); +crunch = array_create(70, 0); +mucra = array_create(11, 0); + +// The combat-log queue must hold at least COMBAT_LOG_CAPACITY entries so a long turn fully drains. +// The status line ("Enemy Forces at X%" / "Defeated") only renders once `messages` reaches 0, and +// Alarm_3 drains the queue through a COMBAT_LOG_CAPACITY-wide window - anything past it strands the +// tail, leaving messages > 0 forever so the status never shows. The +20 is headroom for compaction. +for (var _m = 1; _m <= COMBAT_LOG_CAPACITY + 20; _m++) { + message[_m] = ""; + message_sz[_m] = 0; + message_priority[_m] = 0; } post_equipment_lost = new EquipmentTracker(); @@ -191,6 +191,16 @@ dead_jims = 0; newline = ""; newline_color = ""; liness = 0; + +// Combat-log scrollback. lines[] is only a rolling 45-row live window (older rows are discarded by +// scr_lines_increase), so keep a separate capped history the player can scroll back through. +// log_scroll counts rows above the live bottom: 0 = pinned to the newest line (live). +log_history = []; +log_history_max = 300; +log_scroll = 0; +log_view_lines = 45; +log_dragging = false; + world_size = 0; timer = 0; @@ -200,8 +210,6 @@ timer_maxspeed = 1; timer_pause = -1; turns = 1; -// - scouts = 0; tacticals = 0; veterans = 0; @@ -250,8 +258,6 @@ en_apothecaries = 0; en_big_mofo = 10; en_important_dudes = 0; -// - defending = true; // 1 is defensive dropping = 0; // 0 is was on ground attacking = 0; // 1 means attacked from space/local @@ -330,12 +336,12 @@ betchers = obj_ini.betchers; // slight melee penalty catalepsean = obj_ini.catalepsean; // minor global attack decrease occulobe = obj_ini.occulobe; // penalty if morning and susceptible to flash grenades mucranoid = obj_ini.mucranoid; // chance to short-circuit -// + global_melee = 1; global_bolter = 1; global_attack = 1; global_defense = 1; -// + if ((ambushers == 1) && (ambushers == 999)) { global_attack = global_attack * 1.1; } @@ -382,7 +388,6 @@ if (lightning == 1) { if (melee == 1) { global_melee = global_melee * 1.15; } -// if (shitty_luck == 1) { global_defense = global_defense * 0.9; } diff --git a/objects/obj_ncombat/Draw_0.gml b/objects/obj_ncombat/Draw_0.gml index a406fb7925..545c40124b 100644 --- a/objects/obj_ncombat/Draw_0.gml +++ b/objects/obj_ncombat/Draw_0.gml @@ -51,31 +51,75 @@ if ((display_p2 > 0) && (enemy_forces > 0)) { draw_set_halign(fa_left); +// When pinned to the bottom (log_scroll == 0) the live 45-row window is drawn exactly as before; +// when scrolled up, page back through the retained log_history instead. +var _log_total = array_length(log_history); +var _log_start = (log_scroll <= 0) ? -1 : max(0, _log_total - log_view_lines - log_scroll); + repeat (45) { l += 1; - // draw_text(x+6,y-10+(l*14),"."+string(lines[31-l])); + + var _row_txt, _row_col; + if (_log_start < 0) { + _row_txt = lines[l]; + _row_col = lines_color[l]; + } else { + var _hi = _log_start + (l - 1); + if ((_hi >= 0) && (_hi < _log_total)) { + _row_txt = log_history[_hi].text; + _row_col = log_history[_hi].color; + } else { + _row_txt = ""; + _row_col = ""; + } + } + draw_set_color(CM_GREEN_COLOR); - if (lines_color[l] == "red") { + if (_row_col == "red") { draw_set_color(c_red); } - if (lines_color[l] == "yellow") { + if (_row_col == "yellow") { draw_set_color(3055825); } - if (lines_color[l] == "purple") { + if (_row_col == "purple") { draw_set_color(16646566); } - if (lines_color[l] == "bright") { + if (_row_col == "bright") { draw_set_color(65280); } - if (lines_color[l] == "white") { + if (_row_col == "white") { draw_set_color(c_silver); } - if (lines_color[l] == "blue") { + if (_row_col == "blue") { draw_set_color(c_aqua); } - draw_text(x + 6, y - 10 + (l * 18), string_hash_to_newline(string(lines[l]))); + if (_row_col == "lightgreen") { + draw_set_color(make_color_rgb(150, 255, 150)); + } + draw_text(x + 6, y - 10 + (l * 18), string_hash_to_newline(string(_row_txt))); } +// Combat-log scrollbar: a thin draggable thumb in the gutter between the frame and the text column. +// Only shown when there's more history than the visible window. Thumb height tracks visible/total; +// it sits at the bottom when live (log_scroll == 0) and rises as the player pages back. +if (_log_total > log_view_lines) { + var _sb_x1 = x + 2; + var _sb_x2 = x + 4; + var _sb_y1 = y + 8; + var _sb_h = log_view_lines * 18; + var _sb_max_scroll = _log_total - log_view_lines; + var _sb_thumb_h = max(20, _sb_h * (log_view_lines / _log_total)); + var _sb_frac = log_scroll / _sb_max_scroll; // 0 = live bottom, 1 = oldest + var _sb_thumb_y1 = _sb_y1 + (1 - _sb_frac) * (_sb_h - _sb_thumb_h); + + draw_set_color(CM_GREEN_COLOR); + draw_set_alpha(0.3); + draw_rectangle(_sb_x1, _sb_y1, _sb_x2, _sb_y1 + _sb_h, false); + draw_set_alpha(1); + draw_rectangle(_sb_x1, _sb_thumb_y1, _sb_x2, _sb_thumb_y1 + _sb_thumb_h, false); +} +draw_set_alpha(1); + draw_set_color(CM_GREEN_COLOR); if (click_stall_timer <= 0) { if ((fadein < 0) && (fadein > -100) && (started == 0)) { diff --git a/objects/obj_ncombat/KeyPress_13.gml b/objects/obj_ncombat/KeyPress_13.gml index 2a7c097145..858bf01ac6 100644 --- a/objects/obj_ncombat/KeyPress_13.gml +++ b/objects/obj_ncombat/KeyPress_13.gml @@ -1,11 +1,6 @@ if (!instance_exists(obj_popup)) { if (cd < 1) { if (click_stall_timer < 1) { - // with(ob_ennt){shomesge(string(dudes[1])+"|"+string(dudes_num[1])+"|"+string(men+medi)+"|"+string(dudes_hp[1]));} - - // 135; - // instance_activate_object(obj_cursor); - if (enemy_forces <= 0) { // Combat for whatever reason sometimes bugs out when there are no enemies, so if enter is pressed 6 times at this state it will set started to 2 enter_pressed++; @@ -29,17 +24,13 @@ if (!instance_exists(obj_popup)) { click_stall_timer = 15; } - // if (done>=1) then exit; - if (turn_count >= 50 || enter_pressed > 5) { started = 2; } if ((started == 2) || (started == 4)) { instance_activate_object(obj_pnunit); instance_activate_object(obj_enunit); - // started=3;alarm[5]=3;obj_pnunit.alarm[4]=1;obj_pnunit.alarm[5]=2;obj_enunit.alarm[1]=3; started = 3; - // obj_pnunit.alarm[4]=2;obj_pnunit.alarm[5]=3;obj_enunit.alarm[1]=1; var _quad_factor = 10; total_battle_exp_gain = _quad_factor * sqr(threat); if (instance_exists(obj_enunit)) { @@ -94,14 +85,12 @@ if (!instance_exists(obj_popup)) { four_show = 0; click_stall_timer = 15; - // if (battle_over!=1) then alarm[8]=15; if (enemy != 6) { if (instance_exists(obj_enunit)) { obj_enunit.alarm[1] = 1; } set_up_player_blocks_turn(); - // alarm[9]=5; } else if (enemy == 6) { if (instance_exists(obj_enunit)) { obj_enunit.alarm[1] = 2; @@ -143,7 +132,6 @@ if (!instance_exists(obj_popup)) { if (instance_exists(obj_enunit)) { obj_enunit.alarm[1] = 1; } - // alarm[9]=5; reset_combat_message_arrays(); } } diff --git a/objects/obj_ncombat/Step_0.gml b/objects/obj_ncombat/Step_0.gml index ecbd3e136a..5a71266b52 100644 --- a/objects/obj_ncombat/Step_0.gml +++ b/objects/obj_ncombat/Step_0.gml @@ -1,3 +1,38 @@ +// --- Combat-log scroll input ------------------------------------------------- +// Mouse wheel over the left log panel pages through retained history; the thin scrollbar in the +// gutter can also be grabbed and dragged. log_scroll counts rows above the live bottom (0 = live). +var _log_total = array_length(log_history); +var _log_max_scroll = max(0, _log_total - log_view_lines); + +if ((mouse_x >= x) && (mouse_x <= x + 800) && (mouse_y >= y) && (mouse_y <= y + 900)) { + if (mouse_wheel_up()) { + log_scroll += 3; + } + if (mouse_wheel_down()) { + log_scroll -= 3; + } +} + +var _sb_y1 = y + 8; +var _sb_h = log_view_lines * 18; +if (mouse_check_button_pressed(mb_left) && (_log_max_scroll > 0) + && (mouse_x >= x + 1) && (mouse_x <= x + 5) + && (mouse_y >= _sb_y1) && (mouse_y <= _sb_y1 + _sb_h)) { + log_dragging = true; +} +if (!mouse_check_button(mb_left)) { + log_dragging = false; +} +if (log_dragging && (_log_max_scroll > 0)) { + var _sb_thumb_h = max(20, _sb_h * (log_view_lines / _log_total)); + var _sb_usable = max(1, _sb_h - _sb_thumb_h); + var _sb_rel = clamp((mouse_y - _sb_y1 - _sb_thumb_h * 0.5) / _sb_usable, 0, 1); + log_scroll = round((1 - _sb_rel) * _log_max_scroll); +} + +log_scroll = clamp(log_scroll, 0, _log_max_scroll); +// ----------------------------------------------------------------------------- + if (fadein > -30) { fadein -= 1; } @@ -43,14 +78,7 @@ if (((fugg >= 60) || (fugg2 >= 60)) && (messages_shown == 0) && (messages_to_sho if (((messages_shown == 999) || (messages == 0)) && (timer_stage == 2)) { newline_color = "yellow"; if (obj_ncombat.enemy != 6) { - if ((enemy_forces <= 0) || (!instance_exists(obj_enunit)) && (defeat_message == 0)) { - defeat_message = 1; - newline = "Enemy Forces Defeated"; - timer_maxspeed = 0; - timer_speed = 0; - started = 2; - instance_activate_object(obj_pnunit); - } + combat_emit_enemy_status(); } newline_color = "yellow"; if (obj_ncombat.enemy == 6) { @@ -109,8 +137,11 @@ if (((fugg >= 60) || (fugg2 >= 60)) && (messages_shown == 0) && (messages_to_sho if (timer_stage == 2) { fugg += 1; } -if ((timer_stage == 2) && (fugg > 60)) { - timer_stage = 3; // if (!instance_exists(obj_pnunit)) or (!instance_exists(obj_enunit)){alarm[5]=1;started=4;defeat_message=1;} +// Don't time out of stage 2 until the combat log has finished displaying - otherwise on a long turn +// the stage advances before `messages` drains and the "Enemy Forces at X%" status line is skipped. +// The large hard cap is anti-hang insurance in case the queue ever fails to drain. +if ((timer_stage == 2) && (((fugg > 60) && (messages == 0)) || (fugg > COMBAT_STAGE_TIMEOUT_FRAMES))) { + timer_stage = 3; } if (timer_stage != 2) { @@ -119,8 +150,8 @@ if (timer_stage != 2) { if (timer_stage == 4) { fugg2 += 1; } -if ((timer_stage == 4) && (fugg2 > 60)) { - timer_stage = 5; // if (!instance_exists(obj_pnunit)) or (!instance_exists(obj_enunit)){alarm[5]=1;started=4;defeat_message=1;} +if ((timer_stage == 4) && (((fugg2 > 60) && (messages == 0)) || (fugg2 > COMBAT_STAGE_TIMEOUT_FRAMES))) { + timer_stage = 5; } if (timer_stage != 4) { diff --git a/objects/obj_p_assra/Step_0.gml b/objects/obj_p_assra/Step_0.gml index c469ce1083..519cf2d065 100644 --- a/objects/obj_p_assra/Step_0.gml +++ b/objects/obj_p_assra/Step_0.gml @@ -93,8 +93,7 @@ if ((boarding == true) && (board_cooldown >= 0) && instance_exists(target) && in if (board_cooldown == 0) { board_cooldown = 60; - var o, challenge, boarding_odds, boarding_advantage, boarding_disadvantage, gear_bonus, marine_bonus, outcome_roll, damage_roll, attack, arp, wep, ac, dr, co, i, hits, hurt, damaged_ship, bridge_damage; - o = firstest - 1; + var challenge, boarding_odds, boarding_advantage, boarding_disadvantage, gear_bonus, marine_bonus, outcome_roll, damage_roll, attack, arp, wep, ac, dr, co, i, hits, hurt, damaged_ship, bridge_damage; boarding_odds = 0; challenge = 0; outcome_roll = 0; @@ -116,9 +115,6 @@ if ((boarding == true) && (board_cooldown >= 0) && instance_exists(target) && in exit; } - // show_message(origin); - // show_message(string(origin.board_co[1])); - co = origin.board_co[o]; i = origin.board_id[o]; ac = 0; @@ -141,8 +137,8 @@ if ((boarding == true) && (board_cooldown >= 0) && instance_exists(target) && in if (!is_struct(_weapons[0]) && !is_struct(_weapons[1])) { gear_bonus -= 10; } else { - for (var i = 0; i <= 1; i++) { - var _weapon = _weapons[i]; + for (var j = 0; j <= 1; j++) { + var _weapon = _weapons[j]; if (!is_struct(_weapon)) { continue; } @@ -566,16 +562,11 @@ if ((boarding == true) && (board_cooldown >= 0) && instance_exists(target) && in apothecary_had -= 1; } } - - // show_message(string(obj_ini.role[co][i])+" "+string(obj_ini.role[co][i])+" hit by "+string(hits)+"x "+string(wep)+", "+string(obj_ini.hp[co][i])+" HP remaining"); } } - - // board_co[i]=0;board_id[i]=0;board_location[i]=0;board_raft[i]=0; } if (experience > 0) { - var o = 0, co = 0, i = 0; var new_exp, unit_exp, exp_roll; for (var o = 0; o < array_length(origin.board_co); o++) { co = origin.board_co[o]; diff --git a/objects/obj_p_fleet/Alarm_1.gml b/objects/obj_p_fleet/Alarm_1.gml index 46203a0399..f53c6325b7 100644 --- a/objects/obj_p_fleet/Alarm_1.gml +++ b/objects/obj_p_fleet/Alarm_1.gml @@ -1,23 +1,18 @@ try { - var spid, dir; - spid = 0; - dir = 0; - acted = 0; if (action == "Lost") { set_fleet_location("Lost"); exit; } else if (action == "") { - spid = instance_nearest(x, y, obj_star); - // spid.present_fleets+=1; + var spid = instance_nearest(x, y, obj_star); spid.present_fleet[1] += 1; if (spid.vision == 0) { spid.vision = 1; } orbiting = spid; - if ((orbiting != 0) && instance_exists(orbiting)) { + if ((orbiting != noone) && instance_exists(orbiting)) { if (orbiting.visited == 0) { for (var planet_num = 1; planet_num <= orbiting.planets; planet_num += 1) { if (array_length(orbiting.p_feature[planet_num]) != 0) { @@ -32,16 +27,15 @@ try { meet_system_governors(orbiting); } } else if (array_contains(global.fleet_move_options, action)) { - var i; set_fleet_location("Warp"); if (instance_nearest(action_x, action_y, obj_star).storm > 0) { exit; } - spid = point_distance(x, y, action_x, action_y); - spid = spid / action_eta; - dir = point_direction(x, y, action_x, action_y); + var spid = point_distance(x, y, action_x, action_y); + spid = spid / max(1, action_eta); + var dir = point_direction(x, y, action_x, action_y); x = x + lengthdir_x(spid, dir); y = y + lengthdir_y(spid, dir); @@ -63,7 +57,7 @@ try { } var enemies = false; for (var i = 6; i < 13; i++) { - if (scr_orbiting_fleet(i) != "none") { + if (scr_orbiting_fleet(i) != noone) { enemies = true; break; } @@ -95,7 +89,6 @@ try { } steh.present_fleet[1] += 1; orbiting = steh; - // show_message("Present Fleets at alarm[1]: "+string(steh.present_fleets)); meet_system_governors(steh); @@ -144,8 +137,7 @@ try { } } - var steh; - steh = instance_nearest(x, y, obj_star); + var steh = instance_nearest(x, y, obj_star); if (instance_exists(steh) && (steh != 0)) { if (steh.p_type[1] == "Craftworld") { var dist, rando; @@ -153,8 +145,6 @@ try { rando = floor(random(100)) + 1; dist = point_distance(x, y, steh.old_x, steh.old_y); - // show_message("Dist: "+string(dist)+", Rando: "+string(rando)); - if ((rando >= 95) && (dist <= 300)) { obj_controller.known[eFACTION.ELDAR] = 1; scr_alert("green", "elfs", "Eldar Craftworld discovered.", steh.old_x, steh.old_y); diff --git a/objects/obj_p_fleet/Alarm_11.gml b/objects/obj_p_fleet/Alarm_11.gml index 718c564b5a..f146c8727b 100644 --- a/objects/obj_p_fleet/Alarm_11.gml +++ b/objects/obj_p_fleet/Alarm_11.gml @@ -1,4 +1,4 @@ -if ((action == "") && (orbiting != 0)) { +if ((action == "") && (orbiting != noone)) { orbiting = instance_nearest(x, y, obj_star); orbiting.present_fleet[1] += 1; } diff --git a/objects/obj_p_fleet/Alarm_3.gml b/objects/obj_p_fleet/Alarm_3.gml index faff553a20..2a23b39138 100644 --- a/objects/obj_p_fleet/Alarm_3.gml +++ b/objects/obj_p_fleet/Alarm_3.gml @@ -1,4 +1,4 @@ -if (obj_controller.zoomed == 1) { +if (obj_controller.zoomed == 1 && !is_nan(self.x) && !is_nan(self.y)) { obj_controller.x = self.x; obj_controller.y = self.y; } @@ -6,24 +6,19 @@ obj_controller.popup = 1; // 1: fleet, 2: other fleet, 3: other selected = 1; obj_controller.fleet_minimized = 0; -var xx = x, yy = y; - obj_controller.selected = id; if (instance_exists(obj_fleet_select)) { if (obj_controller.selected == obj_fleet_select.id) { exit; } } -// obj_controller.selected=self; obj_controller.sel_owner = self.owner; -// show_message(obj_controller.selected); obj_controller.cooldown = 8; if (obj_controller.zoomed) { scr_zoom(); } -// Pass variables to obj_controller.temp[t]=""; here with (obj_fleet_select) { instance_destroy(); } @@ -34,9 +29,7 @@ obj_fleet_select.escort = escort_number; obj_fleet_select.frigate = frigate_number; obj_fleet_select.capital = capital_number; -var i = -1; -repeat (91) { - i += 1; +for (var i = 0; i <= 90; i++) { if (i <= 20) { capital_sel[i] = 1; } @@ -57,9 +50,3 @@ repeat (91) { } } } - -/*var ii;ii=0;ii+=capital_number;ii+=round((frigate_number/2));ii+=round((escort_number/4)); -if (ii<=1) then ii=1;image_index=ii;*/ - -/* */ -/* */ diff --git a/objects/obj_p_fleet/Alarm_4.gml b/objects/obj_p_fleet/Alarm_4.gml index 98ad26b469..73eca50db5 100644 --- a/objects/obj_p_fleet/Alarm_4.gml +++ b/objects/obj_p_fleet/Alarm_4.gml @@ -1,15 +1,5 @@ -var sys_dist, mine, connected, fleet, cont; -sys_dist = 9999; -connected = 0; -cont = 0; - var eta = calculate_fleet_eta(x, y, action_x, action_y, action_spd, false, false, warp_able); -// if (connected=0) then eta=eta*2; -// if (connected=1) then connected=1; -// if (web=1) then eta=1; -action_eta = eta; -// if (action="crusade2") then action="crusade3"; -// if (action="crusade1") then action="crusade2"; +action_eta = eta; set_fleet_location("Warp"); diff --git a/objects/obj_p_fleet/Alarm_5.gml b/objects/obj_p_fleet/Alarm_5.gml index 9012a59566..c39419c485 100644 --- a/objects/obj_p_fleet/Alarm_5.gml +++ b/objects/obj_p_fleet/Alarm_5.gml @@ -1,9 +1,6 @@ -var i, minhp, maxhp; - if (capital_number > 0) { - i = 0; - minhp = 0; - maxhp = 0; + var minhp = 0; + var maxhp = 0; for (var i = 0; i < array_length(capital); i++) { if ((capital[i] != "") && (capital_num[i] > -1)) { minhp += obj_ini.ship_hp[i]; @@ -18,9 +15,8 @@ if (capital_number > 0) { } if (frigate_number > 0) { - i = 0; - minhp = 0; - maxhp = 0; + var minhp = 0; + var maxhp = 0; for (var i = 0; i < array_length(frigate); i++) { if (frigate[i] != "" && frigate_num[i] > -1 && frigate_num[i] < array_length(obj_ini.ship_hp)) { minhp += obj_ini.ship_hp[i]; @@ -35,9 +31,8 @@ if (frigate_number > 0) { } if (escort_number > 0) { - i = 0; - minhp = 0; - maxhp = 0; + var minhp = 0; + var maxhp = 0; for (var i = 0; i < array_length(escort); i++) { if ((escort[i] != "") && (escort_num[i] > -1)) { minhp += obj_ini.ship_hp[i]; diff --git a/objects/obj_p_fleet/Alarm_6.gml b/objects/obj_p_fleet/Alarm_6.gml index 0e1de6d0be..9f215138d3 100644 --- a/objects/obj_p_fleet/Alarm_6.gml +++ b/objects/obj_p_fleet/Alarm_6.gml @@ -5,6 +5,3 @@ with (obj_ini) { if (player_fleet_ship_count() == 0) { instance_destroy(); } - -/* */ -/* */ diff --git a/objects/obj_p_fleet/Alarm_7.gml b/objects/obj_p_fleet/Alarm_7.gml index 7f1765c106..2a300c2cd2 100644 --- a/objects/obj_p_fleet/Alarm_7.gml +++ b/objects/obj_p_fleet/Alarm_7.gml @@ -3,7 +3,8 @@ if (capital_number == 0) { exit; } -var c = 0, good = 0; +var c = 0; +var good = 0; var capital_id; var capital_list = fleet_full_ship_array(,, true, true); for (var i = 0; i < array_length(capital_list); i++) { diff --git a/objects/obj_p_fleet/Create_0.gml b/objects/obj_p_fleet/Create_0.gml index 290aef21a0..53cf95ae69 100644 --- a/objects/obj_p_fleet/Create_0.gml +++ b/objects/obj_p_fleet/Create_0.gml @@ -3,7 +3,7 @@ capital_number = 0; frigate_number = 0; escort_number = 0; selected = 0; -orbiting = 0; +orbiting = noone; warp_able = true; ii_check = choose(8, 9, 10, 11, 12); @@ -19,7 +19,6 @@ point_breakdown = single_loc_point_data(); image_xscale = 1.25; image_yscale = 1.25; -var i = -1; capital = []; capital_num = []; capital_sel = []; @@ -95,7 +94,7 @@ deserialize = function(save_data) { } } - if (save_data.orbiting != 0) { + if (save_data.orbiting != noone) { var nearest_star = instance_nearest(x, y, obj_star); set_player_fleet_image(); orbiting = nearest_star; diff --git a/objects/obj_p_fleet/Destroy_0.gml b/objects/obj_p_fleet/Destroy_0.gml index 0d9ab96c6c..28facfa8b8 100644 --- a/objects/obj_p_fleet/Destroy_0.gml +++ b/objects/obj_p_fleet/Destroy_0.gml @@ -1,6 +1,6 @@ -if ((action == "") && (orbiting != 0)) { +if ((action == "") && (orbiting != noone)) { if (instance_exists(orbiting)) { orbiting.present_fleet[1] -= 1; } - orbiting = 0; + orbiting = noone; } diff --git a/objects/obj_p_fleet/Draw_0.gml b/objects/obj_p_fleet/Draw_0.gml index 916758ec3a..9b352f166e 100644 --- a/objects/obj_p_fleet/Draw_0.gml +++ b/objects/obj_p_fleet/Draw_0.gml @@ -22,7 +22,7 @@ var coords = [ var near_star = instance_nearest(x, y, obj_star); if (x == near_star.x && y == near_star.y) { - var coords = [ + coords = [ 24, -24 ]; @@ -65,7 +65,6 @@ if (!keyboard_check(vk_shift)) { } } } -// if (obj_controller.selected!=0) and (selected=1) then within=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)) { @@ -91,7 +90,6 @@ if (obj_controller.selecting_planet > 0) { } } -var line_width = obj_controller.zoomed ? 6 : 1; var line_width = sqr(scale); var text_size = sqr(scale); @@ -100,7 +98,6 @@ if (action != "") { draw_set_alpha(1); draw_set_color(c_white); draw_line_width(x, y, action_x, action_y, line_width); - // draw_set_font(fnt_40k_14b); draw_text_transformed(x + 12, y, string_hash_to_newline("ETA " + string(action_eta)), text_size, text_size, 0); @@ -130,8 +127,6 @@ if ((within == 1) || (selected > 0)) { if ((capital_number == 0) && (frigate_number == 0) && (escort_number == 1)) { ppp = escort[0]; } - // ppp=acted; - // draw_set_color(CM_GREEN_COLOR); draw_set_font(fnt_40k_14b); draw_set_halign(fa_center); @@ -148,12 +143,4 @@ if ((within == 1) || (selected > 0)) { draw_set_alpha(1); } -// if (is_orbiting()){ -// orbiting = instance_nearest(x,y ,obj_star); -// var draw_x = x - orbiting.x; -// var draw_y = y - orbiting.y; -// } - draw_sprite_ext(sprite_index, image_index, x + (coords[0] * scale), y + (coords[1] * scale), 1 * scale, 1 * scale, 0, c_white, 1); - -// draw_sprite_ext(sprite_index,image_index,(draw_x*scale),(draw_y*scale),1*scale,1*scale,0,c_white,1) diff --git a/objects/obj_p_fleet/Step_0.gml b/objects/obj_p_fleet/Step_0.gml index 1c712b0f0a..13cafe81f7 100644 --- a/objects/obj_p_fleet/Step_0.gml +++ b/objects/obj_p_fleet/Step_0.gml @@ -2,10 +2,10 @@ ii_check -= 1; if (action == "Lost") { exit; } -if ((action != "") && (orbiting != 0)) { +if ((action != "") && (orbiting != noone)) { orbiting = instance_nearest(x, y, obj_star); orbiting.present_fleet[1] -= 1; - orbiting = 0; + orbiting = noone; } action_spd = calculate_action_speed(); diff --git a/objects/obj_p_ship/Alarm_0.gml b/objects/obj_p_ship/Alarm_0.gml index 14382cbf0f..2c72938d10 100644 --- a/objects/obj_p_ship/Alarm_0.gml +++ b/objects/obj_p_ship/Alarm_0.gml @@ -1,12 +1,6 @@ action = ""; direction = 0; -cooldown1 = 0; -cooldown2 = 0; -cooldown3 = 0; -cooldown4 = 0; -cooldown5 = 0; - name = obj_ini.ship[ship_id]; class = obj_ini.ship_class[ship_id]; hp = obj_ini.ship_hp[ship_id] * 1; @@ -18,7 +12,6 @@ armour_front = obj_ini.ship_front_armour[ship_id]; armour_other = obj_ini.ship_other_armour[ship_id]; weapons = obj_ini.ship_weapons[ship_id]; turrets = 0; -ship_colour = obj_controller.body_colour_replace; weapon = obj_ini.ship_wep[ship_id]; weapon_facing[1] = ""; @@ -191,14 +184,12 @@ if (obj_controller.stc_bonus[6] == 2) { armour_other = round(armour_other * 1.1); } -var i = 0, unit, b = 0; - for (var co = 0; co <= obj_ini.companies; co++) { - for (i = 0; i < array_length(obj_ini.name[co]); i++) { + for (var i = 0; i < array_length(obj_ini.name[co]); i++) { if (obj_ini.name[co][i] == "") { continue; } - unit = fetch_unit([co, i]); + var unit = fetch_unit([co, i]); if (unit.ship_location == ship_id) { if (unit.is_boarder && unit.hp() > (unit.max_health() / 10)) { array_push(board_co, co); diff --git a/objects/obj_p_ship/Create_0.gml b/objects/obj_p_ship/Create_0.gml index 0c53712f9a..3cf0c6a883 100644 --- a/objects/obj_p_ship/Create_0.gml +++ b/objects/obj_p_ship/Create_0.gml @@ -16,7 +16,7 @@ action_dis = 0; action_dir = 0; action_fac = 0; direction = 0; -target = -50; +target = noone; if (instance_exists(obj_en_ship)) { target = instance_nearest(x, y, obj_en_ship); } diff --git a/objects/obj_p_ship/Step_0.gml b/objects/obj_p_ship/Step_0.gml index a08c002be8..16c69ac2a9 100644 --- a/objects/obj_p_ship/Step_0.gml +++ b/objects/obj_p_ship/Step_0.gml @@ -18,10 +18,10 @@ if (board_cooldown >= 0) { if (instance_exists(target)) { if (((target.x < 3) && (target.y < 3)) || (target.hp < 0)) { - target = -50; + target = noone; } } -if ((!instance_exists(target)) || (target == -50)) { +if ((!instance_exists(target)) || (target == noone)) { with (obj_en_ship) { if (((x < 3) && (y < 3)) || (hp <= 0)) { instance_deactivate_object(id); @@ -156,9 +156,8 @@ if ((hp > 0) && instance_exists(target)) { } // STC Bonuses - var speed_up, speed_down; - speed_up = 0.005; - speed_down = 0.025; + var speed_up = 0.005; + var speed_down = 0.025; if (obj_controller.stc_bonus[6] == 3) { speed_up = 0.008; speed_down = 0.037; @@ -216,7 +215,6 @@ if ((hp > 0) && instance_exists(target)) { } if ((paction == "move") || (paction == "attack_move")) { direction = turn_towards_point(direction, x, y, target_x, target_y, ts / 2); - var dist; dist = point_distance(x, y, target_x, target_y); if (y > target_y) { direction = turn_towards_point(direction, x, y, target_x, target_y, ts); @@ -252,22 +250,15 @@ if ((hp > 0) && instance_exists(target)) { turret_cool -= 1; } - var bull, targe, rdir, dirr, dist, xx, yy, ok; - targe = 0; - rdir = 0; - dirr = ""; - 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); + dist = 9999; + var targe = instance_nearest(x, y, obj_en_in); if (instance_exists(targe)) { dist = point_distance(x, y, targe.x, targe.y); } if ((dist > 64) && (dist < 300)) { - bull = instance_create(x, y, obj_p_round); + var bull = instance_create(x, y, obj_p_round); bull.direction = point_direction(x, y, targe.x, targe.y); bull.speed = 20; bull.dam = 3; @@ -277,21 +268,18 @@ if ((hp > 0) && instance_exists(target)) { bull.direction += choose(random(3), 1 * -random(3)); } } - targe = 0; - rdir = 0; - dirr = ""; - dist = 9999; + var rdir = 0; - xx = lengthdir_x(64, direction + 90); - yy = lengthdir_y(64, direction + 90); + var xx = lengthdir_x(64, direction + 90); + var yy = lengthdir_y(64, direction + 90); - var front, right, left, rear; - front = 0; - right = 0; - left = 0; - rear = 0; + var front = 0; + var right = 0; + var left = 0; + var rear = 0; - targe = instance_nearest(xx, yy, obj_en_ship); + var bull = noone; + var targe = instance_nearest(xx, yy, obj_en_ship); if (instance_exists(targe)) { rdir = point_direction(x, y, target.x, target.y); if ((rdir > 45) && (rdir <= 135) && (targe != target)) { @@ -309,9 +297,7 @@ if ((hp > 0) && instance_exists(target)) { var f = 0, facing = "", ammo = 0, range = 0, wep = "", dam = 0; for (var gg = 1; gg < array_length(weapon); gg++) { - // if (cooldown[gg]>0) then cooldown[gg]-=1; - - ok = 0; + var ok = 0; f += 1; facing = ""; ammo = 0; @@ -351,14 +337,11 @@ if ((hp > 0) && instance_exists(target)) { dist = point_distance(x, y, targe.x, targe.y); if ((ok == 2) && (dist < (range + max(sprite_get_width(sprite_index), sprite_get_height(sprite_index))))) { - //if (ammo>0) and (ammo<500) then ammo-=1; weapon_ammo[gg] = ammo; cooldown[gg] = weapon_cooldown[gg]; wep = weapon[gg]; dam = weapon_dam[gg]; - // if (f=3) and (ship_id=2) then show_message("ammo: "+string(ammo)+" | range: "+string(range)); - if (ammo < 0) { ok = 0; } @@ -427,14 +410,11 @@ if ((hp > 0) && instance_exists(target)) { } } -/* */ //Deploy boarding craft logic if (instance_exists(obj_en_ship) && (boarders > 0) && (board_cooldown <= 0) && ((board_capital == true) || (board_frigate == true))) { - var eh = 0, te = 0; - repeat (2) { - eh += 1; - te = 0; + for (var eh = 1; eh <= 2; eh++) { + var te = 0; if ((eh == 1) && (board_capital == true)) { if (instance_exists(obj_en_capital)) { te = instance_nearest(x, y, obj_en_capital); @@ -452,6 +432,3 @@ if (instance_exists(obj_en_ship) && (boarders > 0) && (board_cooldown <= 0) && ( } } } - -/* */ -/* */ diff --git a/objects/obj_pnunit/Alarm_0.gml b/objects/obj_pnunit/Alarm_0.gml index 822996c62f..a0319f75d5 100644 --- a/objects/obj_pnunit/Alarm_0.gml +++ b/objects/obj_pnunit/Alarm_0.gml @@ -1,8 +1,4 @@ try { - // with(obj_enunit){show_message(string(dudes[1])+"|"+string(dudes_num[1])+"|"+string(men+medi)+"|"+string(dudes_hp[1]));} - - var rightest, charge = 0, enemy2 = 0; // psy=false; - if (instance_number(obj_enunit) != 1) { obj_ncombat.flank_x = self.x; with (obj_enunit) { @@ -12,9 +8,7 @@ try { } } - rightest = get_rightmost(); // Right most pnunit enemy = instance_nearest(0, y, obj_enunit); // Left most enemy - enemy2 = enemy; if (obj_ncombat.dropping || (!obj_ncombat.defending && obj_ncombat.formation_set != 2)) { move_unit_block("east"); @@ -57,25 +51,55 @@ try { } if (instance_exists(obj_enunit)) { + global.ctally_target = undefined; + global.ctally_bounce = []; + global.ctally_injure = []; + global.ktally_target = undefined; + global.ktally_weapons = {}; + global.ktally_order = []; + global.ktally_leaders = []; for (var i = 0; i < array_length(wep); i++) { + // Enemies wiped before every weapon got to fire (e.g. spill-over cleared the line). + // Report who held fire and stop, rather than swinging at empty air. + if (!instance_exists(obj_enunit)) { + var _held_fire = []; + for (var hf = i; hf < array_length(wep); hf++) { + // Only ranged weapons "hold fire"; melee (range 1) never shoots, so skip it. + if (wep[hf] != "" && wep_num[hf] > 0 && range[hf] > 1) { + array_push(_held_fire, wep[hf]); + } + } + report_held_fire(_held_fire); + break; + } if (wep[i] == "") { continue; } weapon_data = gear_weapon_data("weapon", wep[i]); once_only = 0; enemy = instance_nearest(0, y, obj_enunit); - enemy2 = enemy; if (enemy.men + enemy.veh + enemy.medi <= 0) { var x5 = enemy.x; with (enemy) { instance_destroy(); } enemy = instance_nearest(0, y, obj_enunit); - enemy2 = enemy; + } + + // Speed Force sweeps the whole field - bypass normal targeting/range. + if (wep[i] == "Speed Force" || wep[i] == "Speed Force (Ranged)") { + scr_shoot_spread(i); + continue; } if ((range[i] >= dist) && (ammo[i] != 0 || range[i] == 1)) { - if ((range[i] != 1) && (engaged == 0)) { + // Guard blocks (guard > 0) keep firing their ranged weapons even when + // engaged: Guardsmen empty lasguns and heavy bolters into the enemy at + // point-blank, and the tank line keeps its main guns firing once a unit + // reaches it instead of standing mute. Marines keep the vanilla rule of + // ranged only while not engaged. The bayonet (range 1) still resolves on + // the melee line below, so engaged Guard both shoot and stab. + if ((range[i] != 1) && ((engaged == 0) || (guard > 0))) { range_shoot = "ranged"; } if ((range[i] != floor(range[i]) || floor(range[i]) == 1) && engaged == 1) { @@ -86,6 +110,7 @@ try { if ((range_shoot == "ranged") && (range[i] >= dist)) { // Weapon meets preliminary checks var ap = 0; + var good = 0; if (apa[i] > att[i]) { ap = 1; } // Determines if it is AP or not @@ -106,7 +131,7 @@ try { if ((ap == 1) && (once_only == 0)) { // Check for vehicles - var enemy2, g = 0, good = 0; + var g = 0; if (enemy.veh > 0) { good = scr_target(enemy, "veh"); // First target has vehicles, blow it to hell @@ -118,7 +143,7 @@ try { repeat (instance_number(obj_enunit) - 1) { if (good == 0) { x2 += 10; - enemy2 = instance_nearest(x2, y, obj_enunit); + 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"); @@ -144,7 +169,7 @@ try { repeat (instance_number(obj_enunit) - 1) { if (good == 0) { x2 += 10; - enemy2 = instance_nearest(x2, y, obj_enunit); + var enemy2 = instance_nearest(x2, y, obj_enunit); if ((enemy2.veh > 0) && (good == 0)) { good = scr_target(enemy2, "medi"); // This target has vehicles, blow it to hell scr_shoot(i, enemy2, good, "medi", "ranged"); @@ -163,8 +188,7 @@ try { if (instance_exists(enemy)) { if ((ap == 0) && (once_only == 0)) { // Check for men - var g, good, enemy2; - g = 0; + var g = 0; good = 0; if (enemy.men + enemy.medi > 0) { @@ -173,12 +197,11 @@ try { } 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; - x2 = enemy.x; + var x2 = enemy.x; repeat (instance_number(obj_enunit) - 1) { if (good == 0) { x2 += 10; - enemy2 = instance_nearest(x2, y, obj_enunit); + 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"); @@ -203,7 +226,7 @@ try { if ((apa[i] == 1) && (once_only == 0)) { // Check for vehicles - var enemy2, g = 0, good = 0; + var g = 0, good = 0; if (enemy.veh > 0) { good = scr_target(enemy, "veh"); // First target has vehicles, blow it to hell @@ -221,7 +244,7 @@ try { if ((enemy.veh == 0) && (enemy.medi > 0) && (once_only == 0)) { // Check for vehicles - var enemy2, g = 0, good = 0; + var g = 0, good = 0; if (enemy.medi > 0) { good = scr_target(enemy, "medi"); // First target has vehicles, blow it to hell @@ -239,10 +262,9 @@ try { if ((ap == 0) && (once_only == 0)) { // Check for men - var g = 0, good = 0, enemy2; + var g = 0, good = 0; if ((enemy.men > 0) && (once_only == 0)) { - // show_message(string(wep[i])+" attacking"); good = scr_target(enemy, "men"); if (range[i] == 1) { scr_shoot(i, enemy, good, "att", "melee"); @@ -254,25 +276,50 @@ try { } } } + } else { + // The field was already clear when this block's turn came up - its whole arsenal holds fire. + var _skipped_fire = []; + for (var s = 0; s < array_length(wep); s++) { + // Only ranged weapons "hold fire"; melee (range 1) never shoots, so skip it. + if (wep[s] != "" && wep_num[s] > 0 && range[s] > 1) { + array_push(_skipped_fire, wep[s]); + } + } + report_held_fire(_skipped_fire); } + combat_tally_flush(); + combat_kill_tally_flush(); + instance_activate_object(obj_enunit); + // Safety net: drop empty/zombie formations the firing loop never reached, so a lingering corpse + // can't keep the battle alive. + with (obj_enunit) { + var _alive = 0; + for (var _rr = 1; _rr <= 30; _rr++) { + if (dudes_num[_rr] > 0 && dudes_hp[_rr] > 0) { + _alive += dudes_num[_rr]; + } + } + if ((_alive == 0) && (owner != 1)) { + instance_destroy(); + } + } + if (instance_exists(obj_enunit)) { + // Accumulate this formation's attack casts, then emit one summary line per power instead + // of one line per Librarian (see flush_psychic_summary in scr_powers). + var _psy_log = {}; for (var i = 0; i < array_length(unit_struct); i++) { if (marine_dead[i] == 0 && marine_casting[i] == true) { var caster_id = i; - scr_powers(caster_id); + scr_powers(caster_id, _psy_log); } } + flush_psychic_summary(_psy_log); } } -// LOGGER.debug($"known_powers: {known_powers}"); -// LOGGER.debug($"buff_powers: {buff_powers}"); -// LOGGER.debug($"buff_cast: {buff_cast}"); -// LOGGER.debug($"power_index: {power_index}"); -// LOGGER.debug($"known_attack_powers: {known_attack_powers}"); catch (_exception) { - // LOGGER.debug($"known_buff_powers: {known_buff_powers}"); ERROR_HANDLER.handle_exception(_exception); } diff --git a/objects/obj_pnunit/Alarm_1.gml b/objects/obj_pnunit/Alarm_1.gml index 9327b39df8..a776c983aa 100644 --- a/objects/obj_pnunit/Alarm_1.gml +++ b/objects/obj_pnunit/Alarm_1.gml @@ -1,5 +1 @@ -/* */ -/* */ scr_player_combat_weapon_stacks(); - -//LOGGER.debug("{0},/n{1},/n{2},/n{3},/n{4},/n{5}",wep_num,range,wep,att,wep_solo,wep_title); diff --git a/objects/obj_pnunit/Alarm_3.gml b/objects/obj_pnunit/Alarm_3.gml index 488913264b..a1f7f38b1b 100644 --- a/objects/obj_pnunit/Alarm_3.gml +++ b/objects/obj_pnunit/Alarm_3.gml @@ -5,8 +5,10 @@ try { instance_destroy(); } // if (veh+dreads>0) then instance_destroy(); - obj_ncombat.player_forces += self.men + self.veh + self.dreads; - obj_ncombat.player_max += self.men + self.veh + self.dreads; + if (guard == 0) { + obj_ncombat.player_forces += self.men + self.veh + self.dreads; + obj_ncombat.player_max += self.men + self.veh + self.dreads; + } //TODO centralise a method for moving units between columns /*if (men<=4) and (veh=0) and (dreads=0){// Squish leftt @@ -119,7 +121,15 @@ try { } } - if (norun == 0) { + // Guard blocks never retreat. The vanilla rule backs a block away from a + // pure-vehicle enemy it cannot hurt, but for the Guard that walks the + // whole rank out of the line and off to the rear, where the enemy ignores + // it (the Marines are now the front block) and turns on the Marines it was + // meant to screen. This is why the Guard only behaved when they were the + // last force left: alone there is nothing to fall back behind and no + // Marine front for the enemy to switch to. The Guard are meant to hold and + // die in place, so only non-guard blocks fall back here. + if (norun == 0 && guard == 0) { x -= 10; engaged = 0; } diff --git a/objects/obj_pnunit/Alarm_6.gml b/objects/obj_pnunit/Alarm_6.gml index a318f8dafa..a9a58d7f4f 100644 --- a/objects/obj_pnunit/Alarm_6.gml +++ b/objects/obj_pnunit/Alarm_6.gml @@ -6,19 +6,16 @@ // Remove from the controller // Remove from any planetary bodies -// show_message("pnunit alarm 6"); - -var i = -1, unit; for (var i = 0; i < array_length(unit_struct); i++) { if ((marine_dead[i] > 0) && (marine_type[i] != "") && (ally[i] == false)) { - unit = unit_struct[i]; + var unit = unit_struct[i]; if (!is_struct(unit)) { continue; } if (unit.name() == "") { continue; } - man_size = unit.get_unit_size(); + var man_size = unit.get_unit_size(); if (unit.planet_location > 0) { obj_ncombat.world_size += man_size; @@ -32,19 +29,9 @@ for (var i = 0; i < array_length(unit_struct); i++) { } for (var i = 0; i < array_length(veh_type); i++) { - // if (veh_type[i]="Predator") or (veh_type[i]="Land Raider") then show_message(string(veh_type[i])+" ("+string(veh_co[i])+"."+string(veh_id[i])+")#HP: "+string(veh_hp[i])+"#Dead: "+string(veh_dead[i])+""); - if ((veh_dead[i] > 0) && (veh_type[i] != "") && (veh_ally[i] == false)) { var man_size = scr_unit_size("", veh_type[i], true); - /* - if (veh_type[i]="Rhino") then man_size+=10; - if (veh_type[i]="Predator") then man_size+=10; - if (veh_type[i]="Land Raider") then man_size+=20; - if (veh_type[i]="Bike") then man_size+=2; - if (veh_type[i]="Land Speeder") then man_size+=6; - if (veh_type[i]="Whirlwind") then man_size+=10;*/ - if (obj_ini.veh_wid[veh_co[i]][veh_id[i]] > -1) { obj_ncombat.world_size += man_size; } @@ -52,15 +39,9 @@ for (var i = 0; i < array_length(veh_type); i++) { obj_ini.ship_carrying[obj_ini.veh_lid[veh_co[i]][veh_id[i]]] -= man_size; } - // show_message(string(veh_type[i])+" ("+string(veh_co[i])+"."+string(veh_id[i])+") dead"); - - // destroy_vehicle(veh_co[i], veh_id[i]); } if ((veh_dead[i] == 0) && (veh_type[i] != "") && (veh_ally[i] == false)) { obj_ini.veh_hp[veh_co[i]][veh_id[i]] = veh_hp[i] / veh_hp_multiplier[i]; } } - -/* */ -/* */ diff --git a/objects/obj_pnunit/Create_0.gml b/objects/obj_pnunit/Create_0.gml index af2c9fb260..35b3bb9ace 100644 --- a/objects/obj_pnunit/Create_0.gml +++ b/objects/obj_pnunit/Create_0.gml @@ -9,6 +9,7 @@ attacked_dudes = 0; dreads = 0; jetpack_destroy = 0; defenses = 0; +guard = 0; // OBSOLETE (iteration 1): flag for the dead planetary Guard men-block. Never set to 1 anywhere, so the guard==1 branches in scr_clean and scr_player_combat_weapon_stacks are dead. Live guardsmen are role "Guardsman" unit_struct units. unit_count = 0; unit_count_old = 0; diff --git a/objects/obj_pnunit/KeyPress_73.gml b/objects/obj_pnunit/KeyPress_73.gml index 78b64c7e29..e69de29bb2 100644 --- a/objects/obj_pnunit/KeyPress_73.gml +++ b/objects/obj_pnunit/KeyPress_73.gml @@ -1,34 +0,0 @@ -/*show_message("X: "+string(x)+", Y: "+string(y)+" -"+string(dudes_num[1])+"x "+string(dudes[1])+" "+string(dudes_vehicle[1])+" -"+string(dudes_num[2])+"x "+string(dudes[2])+" "+string(dudes_vehicle[2])+" -"+string(dudes_num[3])+"x "+string(dudes[3])+" "+string(dudes_vehicle[3])+" -"+string(dudes_num[4])+"x "+string(dudes[4])+" "+string(dudes_vehicle[4])+" -"+string(dudes_num[5])+"x "+string(dudes[5])+" "+string(dudes_vehicle[5])+" -"+string(dudes_num[6])+"x "+string(dudes[6])+" "+string(dudes_vehicle[6])+" -"+string(dudes_num[7])+"x "+string(dudes[7])+" "+string(dudes_vehicle[7])+" -"+string(dudes_num[8])+"x "+string(dudes[8])+" "+string(dudes_vehicle[8])+" -"+string(dudes_num[9])+"x "+string(dudes[9])+" "+string(dudes_vehicle[9])+" -"+string(dudes_num[10])+"x "+string(dudes[10])+" "+string(dudes_vehicle[10]));*/ - -/* - -show_message("Engaged "+string(engaged)+" -"+string(wep_num[1])+"x "+string(wep[1])+": ATT"+string(att[1])+" ARP"+string(apa[1])+" splash:"+string(splash[1])+" -"+string(wep_num[2])+"x "+string(wep[2])+": ATT"+string(att[2])+" ARP"+string(apa[2])+" splash:"+string(splash[2])+" -"+string(wep_num[3])+"x "+string(wep[3])+": ATT"+string(att[3])+" ARP"+string(apa[3])+" splash:"+string(splash[3])+" -"+string(wep_num[4])+"x "+string(wep[4])+": ATT"+string(att[4])+" ARP"+string(apa[4])+" splash:"+string(splash[4])+" -"+string(wep_num[5])+"x "+string(wep[5])+": ATT"+string(att[5])+" ARP"+string(apa[5])+" splash:"+string(splash[5])+" -"+string(wep_num[6])+"x "+string(wep[6])+": ATT"+string(att[6])+" ARP"+string(apa[6])+" splash:"+string(splash[6])+" -"+string(wep_num[7])+"x "+string(wep[7])+": ATT"+string(att[7])+" ARP"+string(apa[7])+" splash:"+string(splash[7])+" -"+string(wep_num[8])+"x "+string(wep[8])+": ATT"+string(att[8])+" ARP"+string(apa[8])+" splash:"+string(splash[8])+" -"+string(wep_num[9])+"x "+string(wep[9])+": ATT"+string(att[9])+" ARP"+string(apa[9])+" splash:"+string(splash[9])+" -"+string(wep_num[10])+"x "+string(wep[10])+": ATT"+string(att[10])+" ARP"+string(apa[10])+" splash:"+string(splash[10])+" -"+string(wep_num[11])+"x "+string(wep[11])+": ATT"+string(att[11])+" ARP"+string(apa[11])+" splash:"+string(splash[11])+" -"+string(wep_num[12])+"x "+string(wep[12])+": ATT"+string(att[12])+" ARP"+string(apa[12])+" splash:"+string(splash[12])+" -"+string(wep_num[13])+"x "+string(wep[13])+": ATT"+string(att[13])+" ARP"+string(apa[13])+" splash:"+string(splash[13])+" -"+string(wep_num[14])+"x "+string(wep[14])+": ATT"+string(att[14])+" ARP"+string(apa[14])+" splash:"+string(splash[14])+" -"+string(wep_num[15])+"x "+string(wep[15])+": ATT"+string(att[15])+" ARP"+string(apa[15])+" splash:"+string(splash[15])); -*/ - -/* */ -/* */ diff --git a/objects/obj_pnunit/KeyPress_84.gml b/objects/obj_pnunit/KeyPress_84.gml index a4b90bee18..e69de29bb2 100644 --- a/objects/obj_pnunit/KeyPress_84.gml +++ b/objects/obj_pnunit/KeyPress_84.gml @@ -1,22 +0,0 @@ -/*instance_activate_object(obj_pnunit); - -show_message("Engaged "+string(engaged)+" -"+string(dudes_num[1])+"x "+string(dudes[1])+" "+string(dudes_vehicle[1])+" -"+string(dudes_num[2])+"x "+string(dudes[2])+" "+string(dudes_vehicle[2])+" -"+string(dudes_num[3])+"x "+string(dudes[3])+" "+string(dudes_vehicle[3])+" -"+string(dudes_num[4])+"x "+string(dudes[4])+" "+string(dudes_vehicle[4])+" -"+string(dudes_num[5])+"x "+string(dudes[5])+" "+string(dudes_vehicle[5])+" -"+string(dudes_num[6])+"x "+string(dudes[6])+" "+string(dudes_vehicle[6])+" -"+string(dudes_num[7])+"x "+string(dudes[7])+" "+string(dudes_vehicle[7])+" -"+string(dudes_num[8])+"x "+string(dudes[8])+" "+string(dudes_vehicle[8])+" -"+string(dudes_num[9])+"x "+string(dudes[9])+" "+string(dudes_vehicle[9])+" -"+string(dudes_num[10])+"x "+string(dudes[10])+" "+string(dudes_vehicle[10])+" -"+string(dudes_num[11])+"x "+string(dudes[11])+" "+string(dudes_vehicle[11])+" -"+string(dudes_num[12])+"x "+string(dudes[12])+" "+string(dudes_vehicle[12])+" -"+string(dudes_num[13])+"x "+string(dudes[13])+" "+string(dudes_vehicle[13])+" -"+string(dudes_num[14])+"x "+string(dudes[14])+" "+string(dudes_vehicle[14])+" -"+string(dudes_num[15])+"x "+string(dudes[15])+" "+string(dudes_vehicle[15])+" -"+string(dudes_num[16])+"x "+string(dudes[16])+" "+string(dudes_vehicle[16]));*/ - -/* */ -/* */ diff --git a/objects/obj_pnunit/Mouse_0.gml b/objects/obj_pnunit/Mouse_0.gml index f02d0756f4..590cdab285 100644 --- a/objects/obj_pnunit/Mouse_0.gml +++ b/objects/obj_pnunit/Mouse_0.gml @@ -46,10 +46,13 @@ show_message(blarg);*/ "+string(dudes_num[15])+"x "+string(dudes[15])+" "+string(dudes_num[16])+"x "+string(dudes[16]));*/ -var i = 0; -repeat (50) { - i += 1; - if (marine_type[i] != "") { - show_message(string(i) + ", " + string(marine_type[i]) + ", HP: " + string(marine_hp[i])); +// Debug-only roster dump. Guarded behind cheat_debug so a stray left-click during combat (e.g. on +// the log scrollbar, which overlaps the leftmost unit's sprite box) can't fire it in normal play, +// and bounded by the real array length so it can't index past marine_type. +if (global.cheat_debug == 1) { + for (var i = 0; i < array_length(marine_type); i++) { + if (marine_type[i] != "") { + show_message(string(i) + ", " + string(marine_type[i]) + ", HP: " + string(marine_hp[i])); + } } } diff --git a/objects/obj_pnunit/obj_pnunit.yy b/objects/obj_pnunit/obj_pnunit.yy index 89cc44022f..1296b63952 100644 --- a/objects/obj_pnunit/obj_pnunit.yy +++ b/objects/obj_pnunit/obj_pnunit.yy @@ -35,8 +35,8 @@ "physicsSensor":false, "physicsShape":0, "physicsShapePoints":[ - {"x":0,"y":0,}, - {"x":5,"y":5,}, + {"x":0.0,"y":0.0,}, + {"x":5.0,"y":5.0,}, ], "physicsStartAwake":true, "properties":[], diff --git a/objects/obj_popup/Create_0.gml b/objects/obj_popup/Create_0.gml index ce80f45a21..f93e1217f3 100644 --- a/objects/obj_popup/Create_0.gml +++ b/objects/obj_popup/Create_0.gml @@ -120,20 +120,15 @@ company_promote_data = [ } //10th company ]; -for (var i = 0; i <= 10; i++) { - i += 1; - role_name[i] = ""; - role_exp[i] = 0; -} +role_name = array_create(11, ""); +role_exp = array_create(11, 0); // TODO: connect this logic with the other_manage_data() to reduce verboseness; get_unit_promotion_options = function() { var spec = 0; - for (var i = 0; i <= 11; i++) { - role_name[i] = ""; - role_exp[i] = 0; - } - i = 0; + role_name = array_create(11, ""); + role_exp = array_create(11, 0); + var i = 0; // this area does the required exp for roles per company if (unit_role == obj_ini.role[100][16]) { //techmarine diff --git a/objects/obj_popup/Destroy_0.gml b/objects/obj_popup/Destroy_0.gml index dd8b57bbe0..5f061ba49b 100644 --- a/objects/obj_popup/Destroy_0.gml +++ b/objects/obj_popup/Destroy_0.gml @@ -40,7 +40,7 @@ if (instance_exists(obj_controller)) { instance_create(0, 0, obj_ncombat); obj_ncombat.battle_special = "cs_meeting_battle10"; - var meeting_star = "none"; + var meeting_star = noone; var meeting_planet; with (obj_star) { var meeting = has_problem_star("meeting"); @@ -54,7 +54,7 @@ if (instance_exists(obj_controller)) { } } } - if (meeting_star == "none") { + if (meeting_star == noone) { instance_activate_object(obj_star); with (obj_star) { if (string_count(name, scr_master_loc()) > 0) { @@ -63,7 +63,7 @@ if (instance_exists(obj_controller)) { } } } - if (meeting_star != "none") { + if (meeting_star != noone) { obj_ncombat.battle_object = meeting_star; obj_ncombat.battle_loc = meeting_star.name; obj_ncombat.battle_id = meeting_planet; diff --git a/objects/obj_popup/Keyboard_13.gml b/objects/obj_popup/Keyboard_13.gml index 0f7c77addc..3b4ce730e4 100644 --- a/objects/obj_popup/Keyboard_13.gml +++ b/objects/obj_popup/Keyboard_13.gml @@ -15,7 +15,7 @@ if (cooldown > 0) { exit; } - if (array_length(options == 0) && type < 5) { + if (array_length(options) == 0 && type < 5) { obj_controller.cooldown = 10; if ((number != 0) && (obj_controller.complex_event == false)) { if (instance_exists(obj_turn_end)) { diff --git a/objects/obj_popup/Step_0.gml b/objects/obj_popup/Step_0.gml index ec49edb825..e125134993 100644 --- a/objects/obj_popup/Step_0.gml +++ b/objects/obj_popup/Step_0.gml @@ -65,7 +65,7 @@ try { obj_controller.disposition[10] -= 10; text = "The heretic is killed in a most violent fashion. With a lack of go-between the meeting cannot proceed."; reset_popup_options(); - mission = ""; // image=""; + mission = ""; if (obj_controller.blood_debt == 1) { obj_controller.penitent_current += 1; obj_controller.penitent_turn = 0; @@ -199,8 +199,6 @@ try { if ((press == 0) && array_length(options) || ((demand == 1) && (mission != "") && (string_count("Inquisition", title) > 0)) || ((demand == 1) && (title == "Inquisition Recon"))) { if (title == "Inquisition Recon") { - var mission_star, onceh; - onceh = 0; obj_controller.temp[200] = string(loc); var mission_star = find_star_by_name(obj_controller.temp[200]); if (add_new_problem(planet, "recon", estimate, mission_star)) { @@ -215,12 +213,10 @@ try { if ((mission != "") && (title == "Inquisition Mission")) { obj_controller.temp[200] = string(loc); - var mission_star, onceh; - mission_star = 0; - onceh = 0; + var onceh = 0; var mission_star = find_star_by_name(obj_controller.temp[200]); var mission_is_go = false; - if (mission_star != "none" && planet > 0) { + if (mission_star != noone && planet > 0) { var _estimate = estimate; var _planet = planet; var _mission = mission; diff --git a/objects/obj_saveload/Alarm_0.gml b/objects/obj_saveload/Alarm_0.gml index 8a8a51ece7..ed0352779e 100644 --- a/objects/obj_saveload/Alarm_0.gml +++ b/objects/obj_saveload/Alarm_0.gml @@ -63,7 +63,6 @@ if (load_part == 6) { txt = "Praise be to the Emperor"; } with (obj_controller) { - // LOGGER.debug($"load section 5"); scr_load(5, global.load); } trickle = 2; @@ -76,7 +75,6 @@ if (load_part == 5) { } with (obj_controller) { - // LOGGER.debug($"load section 4"); scr_load(4, global.load); } trickle = 2; @@ -89,7 +87,6 @@ if (load_part == 4) { txt = "Donning Power Armour"; } with (obj_controller) { - // LOGGER.debug($"load section 3"); scr_load(3, global.load); } trickle = 2; @@ -102,7 +99,6 @@ if (load_part == 3) { txt = "Rousing the Machine Spirit"; } with (obj_controller) { - // LOGGER.debug($"load section 2"); scr_load(2, global.load); } trickle = 2; @@ -115,7 +111,6 @@ if (load_part == 2) { txt = "Turtle Waxing Scalp"; } with (obj_controller) { - // LOGGER.debug($"load section 1"); scr_load(1, global.load); } trickle = 2; diff --git a/objects/obj_saveload/Create_0.gml b/objects/obj_saveload/Create_0.gml index ec94f28527..436d719df9 100644 --- a/objects/obj_saveload/Create_0.gml +++ b/objects/obj_saveload/Create_0.gml @@ -53,9 +53,7 @@ save_icon = array_create(201, -1); saves = 0; -var i = 0; - -repeat (100) { +for (var i = 0; i < 100; i++) { if (file_exists(string(PATH_SAVE_FILES, i))) { save[saves] = i; saves += 1; @@ -66,7 +64,6 @@ repeat (100) { if (file_exists(string(PATH_SAVE_FILES, i + 1)) && (max_ini > 0)) { max_ini = 0; } - i += 1; } first_open = saves; diff --git a/objects/obj_saveload/Draw_64.gml b/objects/obj_saveload/Draw_64.gml index 12ab3aee61..2d86e926db 100644 --- a/objects/obj_saveload/Draw_64.gml +++ b/objects/obj_saveload/Draw_64.gml @@ -6,10 +6,7 @@ if (!hide) { if (save_part + load_part > 0) { draw_set_color(0); - // - // draw_sprite(spr_load_splash,splash,0+0,0+0); scr_image("loading", splash, 0, 0, 1600, 900); - // draw_sprite(spr_loadbar_empty, 0, 1047, 875); draw_sprite(spr_loadbar, 0, 1047, 875); @@ -85,13 +82,12 @@ if (!hide) { var _chapter_icon = scr_load_chapter_icon(save_icon[save[slot_index]]); var _icon_size = 94; draw_sprite_stretched(_chapter_icon, 0, slot_left + 147 - (_icon_size / 2), slot_top + 28, _icon_size, _icon_size); - var ohboy, result, tsec, tmin, thour, tday; - ohboy = save_time[save[slot_index]]; - result = ""; - tsec = 0; - tmin = 0; - thour = 0; - tday = 0; + var ohboy = save_time[save[slot_index]]; + var result = ""; + var tsec = 0; + var tmin = 0; + var thour = 0; + var tday = 0; if (ohboy > 0) { tday = floor(ohboy / 86400); if (tday >= 1) { @@ -164,8 +160,7 @@ if (!hide) { draw_set_alpha(1); if (mouse_button_clicked(,, true) && !instance_exists(obj_popup)) { // Clear - var com; - com = instance_create_depth(0, 0, -200010, obj_popup); + var com = instance_create_depth(0, 0, -200010, obj_popup); com.image = "fuklaw"; com.title = "Delete Save Game?"; com.text = "Are you sure you wish to delete Save " + string(save[slot_index]) + "- " + string(save_chapter[save[slot_index]]) + "?"; @@ -222,8 +217,6 @@ if (!hide) { obj_cursor.image_alpha = 0; splash = choose(0, 1, 2, 3, 4); - // show_message("loading 'save"+string(save[slot_index])+".json'"); - if (instance_exists(obj_main_menu)) { with (obj_main_menu) { instance_destroy(); @@ -316,7 +309,5 @@ if (!hide) { slot_index += 1; slot_top += 158; } - - // 32,166 } } diff --git a/objects/obj_star/Alarm_1.gml b/objects/obj_star/Alarm_1.gml index 0e57d05e7f..abfec6e0b7 100644 --- a/objects/obj_star/Alarm_1.gml +++ b/objects/obj_star/Alarm_1.gml @@ -346,7 +346,7 @@ for (var i = 1; i <= planets; i++) { p_owner[i] = 5; p_first[i] = 5; p_sisters[i] = 4; - adjust_influence(eFACTION.ECCLESIARCHY, (p_sisters[i] * 10) - irandom(5), i); + adjust_influence(eFACTION.ECCLESIARCHY, (p_sisters[i] * 10) - irandom(5), i, self); } // if (p_owner[i]=3) or (p_owner[i]=5){p_feature[i]="Artifact|";}Testing ; 137 } @@ -362,10 +362,9 @@ if ((name == "Kim Jong") && (owner == eFACTION.CHAOS)) { obj_controller.alarm[3] = 1; -var i = choose(0, 1); -if ((i == 1) && (planets > 0)) { +if ((choose(0, 1) == 1) && (planets > 0)) { var nostart = false, aa = 0; - i = floor(random(planets)) + 1; + var _ran_num = floor(random(planets)) + 1; if (instance_exists(obj_p_fleet)) { aa = instance_nearest(x, y, obj_p_fleet); @@ -377,10 +376,8 @@ if ((i == 1) && (planets > 0)) { nostart = true; } - if ((array_length(p_feature[i]) == 0) && (p_owner[i] != 1) && nostart) { + if ((array_length(p_feature[_ran_num]) == 0) && (p_owner[_ran_num] != 1) && nostart) { var ranb = 0; - // if (ranb=1) and (p_owner[i]!=1) and (p_owner[i]!=2) and (p_owner[i]!=3) then ranb=floor(random(4))+2; - // var goo = 0; if (goo == 0) { for (var j = 0; j < 10; j++) { @@ -402,46 +399,46 @@ if ((i == 1) && (planets > 0)) { if (goo == 0) { switch (ranb) { case 1: - array_push(p_feature[i], new NewPlanetFeature(eP_FEATURES.SORORITAS_CATHEDRAL)); - if (p_heresy[i] > 10) { - p_heresy[i] -= 10; + array_push(p_feature[_ran_num], new NewPlanetFeature(eP_FEATURES.SORORITAS_CATHEDRAL)); + if (p_heresy[_ran_num] > 10) { + p_heresy[_ran_num] -= 10; } - p_sisters[i] = choose(2, 2, 3); - adjust_influence(eFACTION.ECCLESIARCHY, (p_sisters[i] * 10) - irandom(3), i); + p_sisters[_ran_num] = choose(2, 2, 3); + adjust_influence(eFACTION.ECCLESIARCHY, (p_sisters[_ran_num] * 10) - irandom(3), _ran_num, self); goo = 1; break; case 2: - if ((p_type[i] != "Hive") && (p_type[i] != "Lava") && (goo == 0)) { - array_push(p_feature[i], new NewPlanetFeature(eP_FEATURES.NECRON_TOMB)); + if ((p_type[_ran_num] != "Hive") && (p_type[_ran_num] != "Lava") && (goo == 0)) { + array_push(p_feature[_ran_num], new NewPlanetFeature(eP_FEATURES.NECRON_TOMB)); goo = 1; } break; case 3: - array_push(p_feature[i], new NewPlanetFeature(eP_FEATURES.ARTIFACT)); + array_push(p_feature[_ran_num], new NewPlanetFeature(eP_FEATURES.ARTIFACT)); goo = 1; break; case 4: - array_push(p_feature[i], new NewPlanetFeature(eP_FEATURES.STC_FRAGMENT)); + array_push(p_feature[_ran_num], new NewPlanetFeature(eP_FEATURES.STC_FRAGMENT)); goo = 1; break; case 5: - if ((p_type[i] != "Ice") && (p_type[i] != "Dead") && (p_type[i] != "Feudal")) { + if ((p_type[_ran_num] != "Ice") && (p_type[_ran_num] != "Dead") && (p_type[_ran_num] != "Feudal")) { goo = 1; - array_push(p_feature[i], new NewPlanetFeature(eP_FEATURES.ANCIENT_RUINS)); + array_push(p_feature[_ran_num], new NewPlanetFeature(eP_FEATURES.ANCIENT_RUINS)); } break; //alternative spawn for necron tomb probably needs merging with other method case 6: - if ((p_type[i] == "Ice") || (p_type[i] == "Dead")) { - array_push(p_feature[i], new NewPlanetFeature(eP_FEATURES.NECRON_TOMB)); + if ((p_type[_ran_num] == "Ice") || (p_type[_ran_num] == "Dead")) { + array_push(p_feature[_ran_num], new NewPlanetFeature(eP_FEATURES.NECRON_TOMB)); goo = 1; } break; case 7: - if ((p_type[i] == "Dead") || (p_type[i] == "Desert")) { + if ((p_type[_ran_num] == "Dead") || (p_type[_ran_num] == "Desert")) { var randum = floor(random(100)) + 1; if (randum <= 25) { - array_push(p_feature[i], new NewPlanetFeature(eP_FEATURES.CAVE_NETWORK)); + array_push(p_feature[_ran_num], new NewPlanetFeature(eP_FEATURES.CAVE_NETWORK)); goo = 1; } } @@ -454,76 +451,25 @@ if ((i == 1) && (planets > 0)) { } } -var hyu = 0; +var hyu = false; for (var i = 1; i <= 4; i++) { if (p_tyranids[i] >= 5) { p_guardsmen[i] = 0; p_pdf[i] = 0; p_population[i] = 0; - hyu += 1; + hyu = true; p_owner[i] = 9; } if ((p_first[i] <= 5) && (dispo[i] > -5000)) { dispo[i] = -20; } } -if ((hyu == 0) && (owner == eFACTION.TYRANIDS)) { +if ((!hyu) && (owner == eFACTION.TYRANIDS)) { owner = eFACTION.IMPERIUM; } scr_star_ownership(false); -if (obj_controller.is_test_map == true) { - /*if (p_owner[1]=3) then p_feature[1]="STC Fragment|"; - if (p_owner[2]=3) then p_feature[2]="STC Fragment|"; - if (p_owner[3]=3) then p_feature[3]="STC Fragment|"; - - - // Testing new guardsmen - p_guardsmen[1]=5000000; - p_tyranids[1]=4; - - p_guardsmen[2]=500000; - p_tyranids[2]=3; - - p_guardsmen[3]=100000; - p_tyranids[3]=2; - - p_orks[1]=0;p_orks[2]=0;p_orks[3]=0;*/ -} - -// if (obj_controller.is_test_map=true) and (p_owner[2]=1){ - -if (p_owner[2] == 1) { - /* - p_guardsmen[2]=10000000; - p_pdf[2]=0; - obj_controller.faction_status[eFACTION.IMPERIUM]="War"; - */ - - // p_type[1]="Dead"; - // p_feature[2]=""; - - // p_orks[2]=3; - // p_feature[2]="Starship!0!|"; - - /*repeat(4){ - var fleet;fleet=instance_create(x+(floor(random_range(100,200))*choose(1,-1)),y+(floor(random_range(100,200))*choose(1,-1)),obj_en_fleet); - fleet.owner = eFACTION.CHAOS;fleet.sprite_index=spr_fleet_chaos;fleet.orbiting=0; - fleet.action_x=x;fleet.action_y=y;fleet.alarm[4]=1; - - fleet.capital_number=0; - fleet.frigate_number=1; - fleet.escort_number=2; - - // Create ships here - fleet.image_speed=0; - var ii;ii=0;ii+=capital-1;ii+=round((frigate/2));ii+=round((escort/4)); - if (ii<=1) and (capital+frigate+escort>0) then ii=1; - fleet.image_index=ii; - }*/ -} - if ((obj_controller.is_test_map != true) && (p_owner[2] != 1)) { for (var i = 1; i <= 4; i++) { p_guardsmen[i] = 0; diff --git a/objects/obj_star/Alarm_3.gml b/objects/obj_star/Alarm_3.gml index b9e503f956..5ab629e7d6 100644 --- a/objects/obj_star/Alarm_3.gml +++ b/objects/obj_star/Alarm_3.gml @@ -39,9 +39,9 @@ try { if (!struct_exists(_data, "system")) { _data.system = id; } - if (_data.system != "none") { + if (_data.system != noone) { if (struct_exists(_data, "feature")) { - if (_data.feature != " none") { + if (_data.feature != "none") { if (is_struct(_data.feature)) { if (struct_exists(_data.feature, "f_type")) { if (_data.feature.f_type != "none") { diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index ceebdee134..73f19bbdef 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -1,5 +1,5 @@ // Creates all variables, sets up default variables for different planets and if there is a fleet orbiting a system/planet -craftworld = 0; // orbit_angle=0;orbit_radius=0; +craftworld = 0; space_hulk = 0; old_x = 0; old_y = 0; @@ -10,9 +10,8 @@ if ((((x >= (room_width - 150)) && (y <= 450)) || (y < 100)) && (global.load == } scale = 1; -var run = 0; name = ""; -star = ""; +star = noone; planets = 0; owner = eFACTION.IMPERIUM; image_speed = 0; @@ -84,7 +83,16 @@ get_garrison = function(planet){ _gar.star = self; _gar.planet = planet; } else { - _gar.update(); + try { + _gar.update(); + } catch (_garrison_reload_error) { + // A garrison restored from a save keeps its data but loses its struct + // methods, so rebuild it from the planet's operatives, which persist. + system_garrison[planet] = new GarrisonForce(self, planet); + _gar = system_garrison[planet]; + _gar.star = self; + _gar.planet = planet; + } } return _gar; } @@ -97,7 +105,14 @@ get_sabatours = function(planet){ _gar.star = self; _gar.planet = planet; } else { - _gar.update(); + try { + _gar.update(); + } catch (_sabotage_reload_error) { + system_sabatours[planet] = new GarrisonForce(self, planet, "sabotage"); + _gar = system_sabatours[planet]; + _gar.star = self; + _gar.planet = planet; + } } return _gar; } @@ -108,7 +123,12 @@ get_planet_data = function(planet){ system_datas[planet] = new PlanetData(planet, self); _gar = system_datas[planet]; } else { - _gar.refresh_data(); + try { + _gar.refresh_data(); + } catch (_planetdata_reload_error) { + system_datas[planet] = new PlanetData(planet, self); + _gar = system_datas[planet]; + } } return _gar; } @@ -124,8 +144,6 @@ var _array_size = 23; present_fleet = array_create(_array_size, 0); vision = 1; -// present_fleets=0; -// tau_fleets=0; ai_a = -1; ai_b = -1; @@ -211,8 +229,7 @@ function deserialize(save_data) { // Automatic var setting var all_names = struct_get_names(save_data); - var _len = array_length(all_names); - for (var i = 0; i < _len; i++) { + for (var i = 0; i < array_length(all_names); i++) { var var_name = all_names[i]; if (array_contains(exclusions, var_name)) { continue; @@ -229,8 +246,7 @@ function deserialize(save_data) { var _temp_features = false; if (struct_exists(save_data, "planet_data")) { var planet_arr = save_data.planet_data; - var _len = array_length(planet_arr); - for (var p = 1; p < _len; p++) { + for (var p = 1; p < array_length(planet_arr); p++) { var planet = planet_arr[p]; var var_names = struct_get_names(planet); for (var v = 0; v < array_length(var_names); v++) { @@ -253,12 +269,7 @@ function deserialize(save_data) { continue; } var val = planet[$ var_name]; - // var_name = "p_type" - // planet = {"p_type":"hive"}; - // val = planet[$var_name] = "hive" - self[$ var_name][p] = val; - // variable_struct_set(self, var_name, planet[$var_name]); } } } diff --git a/objects/obj_star_select/Alarm_0.gml b/objects/obj_star_select/Alarm_0.gml index 9799664c59..f334b62e23 100644 --- a/objects/obj_star_select/Alarm_0.gml +++ b/objects/obj_star_select/Alarm_0.gml @@ -1,43 +1,15 @@ -/*if (instance_exists(target)){ - if (target.craftworld=1) or (target.space_hulk=1){ - // 135 ; - obj_controller.selecting_planet=1; - - if (instance_exists(obj_p_fleet)){ - var targ_targ;targ_targ=instance_nearest(target.x+24,target.y-24,obj_p_fleet); - - if (instance_exists(targ_targ)){ - if (targ_targ.action="") and (point_distance(target.x+24,target.y-24,targ_targ.x,targ_targ.y)<=40){ - - // if (target.p_owner[obj_controller.selecting_planet]>5){ - if (button1!=""){button1="Raid";if (targ_targ.capital_number>0) or (targ_targ.frigate_number>0) then button2="Bombard";} - if (button1=""){button2="Raid";if (targ_targ.capital_number>0) or (targ_targ.frigate_number>0) then button3="Bombard";} - // } - } - } - } - } -}*/ - if (loading == 0) { exit; } // check for the right star - -var xb, yb, good, tiber; -xb = 0; -yb = 0; -good = 0; -tiber = 0; - with (obj_star) { if (name == obj_star_select.loading_name) { instance_create(x, y, obj_temp2); } } if (instance_exists(obj_temp2)) { - tiber = instance_nearest(obj_temp2.x, obj_temp2.y, obj_star); + var tiber = instance_nearest(obj_temp2.x, obj_temp2.y, obj_star); target = tiber; } with (obj_temp2) { @@ -45,6 +17,3 @@ with (obj_temp2) { } instance_activate_object(obj_star); - -/* */ -/* */ diff --git a/objects/obj_star_select/Alarm_1.gml b/objects/obj_star_select/Alarm_1.gml index 9c1fc9fafe..7609ee3d93 100644 --- a/objects/obj_star_select/Alarm_1.gml +++ b/objects/obj_star_select/Alarm_1.gml @@ -8,18 +8,10 @@ tau_fleet = target.present_fleet[8]; tyranid_fleet = target.present_fleet[9]; heretic_fleet = target.present_fleet[10]; -en_fleet[0] = 0; -var i; -i = -1; -repeat (15) { - i += 1; - en_fleet[i] = 0; -} +en_fleet = array_create(15, 0); if ((player_fleet > 0) && (imperial_fleet + mechanicus_fleet + inquisitor_fleet + eldar_fleet + ork_fleet + tau_fleet + heretic_fleet > 0)) { - var open; - open = 1; - i = -1; + var open = 1; if (imperial_fleet > 0) { en_fleet[open] = 2; diff --git a/objects/obj_star_select/Create_0.gml b/objects/obj_star_select/Create_0.gml index 7464f52338..45f412b0b4 100644 --- a/objects/obj_star_select/Create_0.gml +++ b/objects/obj_star_select/Create_0.gml @@ -16,13 +16,11 @@ has_player_forces = array_sum(target.p_player) > 0; manage_units_button = new UnitButtonObject({x1: 115, y1: 200, style: "pixel", label: "Manage Units"}); -//if (global.cheat_debug){ debug_button = new UnitButtonObject({x1: 36, y1: 185, style: "pixel", label: "Debug"}); debug_options = new RadioSet([{str1: "Edit Forces"}, {str1: "Add Problem"}, {str1: "Add Feature"}], "Debug options", {x1: 36, y1: 129, max_width: 300}); debug_slate = new DataSlate({style: "plain", XX: 36, YY: 100, set_width: true, width: 310, height: 900}); -//} torpedo = scr_item_count("Cyclonic Torpedo"); @@ -44,6 +42,26 @@ colonist_button.bind_method = function() { new_colony_fleet(doner[0], doner[1], target.id, obj_controller.selecting_planet, "bolster_population"); }; +// Recruit Guard: levy Imperial Guard from a world's Planetary Defense Force. Player +// worlds only (you can only mobilise your own PDF), drawn in fixed elements of 1000 and +// bounded by the PDF on hand so it cannot be spammed. Costs 50 requisition per 1000. +// Each PDF trooper raised joins the chapter as an individual Guardsman unit mustering at +// the home planet, the same singular Guardsmen the Sector Governor supplies. Guardsmen +// only: no Sergeants, Heavy Weapons Teams or vehicles. +guard_recruit_button = new PurchaseButton(100); +guard_recruit_button.update({tooltip: "Levy 1000 Imperial Guard from this world's PDF. Each joins your chapter as an individual Guardsman, mustering at your home planet. Drawn in fixed elements of 1000. /n Costs 50 requisition, requires personal control of the planet and at least 1000 PDF", label: "Recruit Guard", target: target}); +guard_recruit_button.bind_method = function() { + var _p = obj_controller.selecting_planet; + if (target.p_owner[_p] == eFACTION.PLAYER && target.p_pdf[_p] >= 1000) { + target.p_pdf[_p] -= 1000; + with (obj_controller) { + repeat (1000) { + scr_add_man("Guardsman", 0, "", "", 0, true, "home_planet", {skip_company_order: true}); + } + } + } +}; + recruiting_button = new PurchaseButton(0); recruiting_button.update({tooltip: "Enable recruiting", label: "Recruiting", target: target}); recruiting_button.bind_method = function() { @@ -108,13 +126,7 @@ tau_fleet = 0; tyranid_fleet = 0; heretic_fleet = 0; -en_fleet[0] = 0; -var i; -i = -1; -repeat (15) { - i += 1; - en_fleet[i] = 0; -} +en_fleet = array_create(15, 0); if (obj_controller.menu == 0) { alarm[1] = 1; diff --git a/objects/obj_star_select/Draw_64.gml b/objects/obj_star_select/Draw_64.gml index 249581ed7a..0abf773016 100644 --- a/objects/obj_star_select/Draw_64.gml +++ b/objects/obj_star_select/Draw_64.gml @@ -19,16 +19,7 @@ draw_set_valign(fa_top); draw_set_color(0); try { - var temp1 = 0; - var xx = 0; - var yy = 0; if (loading == 1) { - xx = xx; - yy = yy; - } else if (loading == 1) { - var temp1, dist; - dist = 999; - obj_controller.selecting_planet = 0; button1 = ""; button2 = ""; @@ -48,11 +39,10 @@ try { var click_accepted = (!obj_controller.menu) && (!obj_controller.zoomed) && (!instance_exists(obj_bomb_select)) && (!instance_exists(obj_drop_select)); if (click_accepted && (!debug || !debug_slate.entered())) { if (mouse_button_clicked(, 0)) { - var closes = 0, sta1 = 0, sta2 = 0; var mouse_consts = return_mouse_consts(); - sta1 = instance_nearest(mouse_consts[0], mouse_consts[1], obj_star); - sta2 = point_distance(mouse_consts[0], mouse_consts[1], sta1.x, sta1.y); - closes = true; + var sta1 = instance_nearest(mouse_consts[0], mouse_consts[1], obj_star); + var sta2 = point_distance(mouse_consts[0], mouse_consts[1], sta1.x, sta1.y); + var closes = true; if (sta2 > 15) { if (scr_hit(27, 165, 300, 165 + 294)) { closes = false; @@ -70,7 +60,6 @@ try { } } } - var shutter_button; var shutters = [ shutter_1, shutter_2, @@ -78,7 +67,7 @@ try { shutter_4 ]; for (var i = 0; i < 4; i++) { - shutter_button = shutters[i]; + var shutter_button = shutters[i]; if (shutter_button.hit()) { closes = false; break; @@ -164,14 +153,13 @@ try { } // Buttons that are available if (!buttons_selected) { + var is_enemy = false; if ((obj_controller.faction_status[eFACTION.IMPERIUM] != "War" && p_data.current_owner > 5) || (obj_controller.faction_status[eFACTION.IMPERIUM] == "War" && p_data.at_war(0, 1, 1) && p_data.player_disposition <= 50)) { - var is_enemy = true; - } else { - var is_enemy = false; + is_enemy = true; } if (p_data.planet > 0) { - if (target.present_fleet[1] == 0) /* and (target.p_type[obj_controller.selecting_planet]!="Dead")*/ { + if (target.present_fleet[1] == 0) { if (p_data.player_forces > 0) { if (is_enemy) { button1 = "Attack"; @@ -181,7 +169,7 @@ try { } } } - if (target.present_fleet[1] > 0) /* and (target.p_type[obj_controller.selecting_planet]!="Dead")*/ { + if (target.present_fleet[1] > 0) { if (is_enemy) { button1 = "Attack"; button2 = "Raid"; @@ -305,6 +293,10 @@ try { if (obj_controller.selecting_planet > 0) { main_data_slate.draw(344, 160, slate_draw_scale, slate_draw_scale + 0.1); } + // Deploy Guard auxilia: offer the 4th slot when guard-carrying ships orbit this world. + if ((button4 == "") && (obj_controller.selecting_planet > 0) && (player_guardsmen_at(target.name) > 0)) { + button4 = "Deploy Guard"; + } var current_button = ""; var shutter_x = main_data_slate.XX - 165; var shutter_y = 296 + 165; @@ -340,28 +332,31 @@ try { instance_destroy(); } } else if (current_button == "Raid" && instance_nearest(x, y, obj_p_fleet).acted <= 1) { + // feather ignore once GM2064 instance_create_layer(x, y, layer_get_all()[0], obj_drop_select, {p_target: target, planet_number: obj_controller.selecting_planet, sh_target: instance_nearest(x, y, obj_p_fleet), purge: 0}); } else if (current_button == "Attack") { var _allow_attack = true; - var _targ = !target.present_fleet[1] ? -50 : instance_nearest(x, y, obj_p_fleet); + var _targ = !target.present_fleet[1] ? noone : instance_nearest(x, y, obj_p_fleet); if (instance_exists(_targ)) { if (_targ.acted >= 2) { _allow_attack = false; } } if (_allow_attack) { + // feather ignore once GM2064 instance_create_layer(x, y, layer_get_all()[0], obj_drop_select, {p_target: target, planet_number: obj_controller.selecting_planet, attack: true, sh_target: _targ, purge: 0}); } } else if (current_button == "Purge") { var _allow_attack = true; - var _targ = !target.present_fleet[1] ? -50 : instance_nearest(x, y, obj_p_fleet); + var _targ = !target.present_fleet[1] ? noone : instance_nearest(x, y, obj_p_fleet); if (instance_exists(_targ)) { if (_targ.acted >= 2) { _allow_attack = false; } } if (_allow_attack) { - instance_create_layer(x, y, layer_get_all()[0], obj_drop_select, {p_target: target, purge: 1, planet_number: obj_controller.selecting_planet, sh_target: _targ}); + // feather ignore once GM2064 + instance_create_layer(x, y, layer_get_all()[0], obj_drop_select, {p_target: target, planet_number: obj_controller.selecting_planet, sh_target: _targ, purge: 1}); } } else if (current_button == "Bombard") { instance_create(x, y, obj_bomb_select); @@ -375,6 +370,9 @@ try { } } } + } else if (current_button == "Deploy Guard") { + var _n = deploy_guardsmen(target.name, obj_controller.selecting_planet); + scr_popup("Imperial Guard", "Deployed " + string(_n) + " Guard onto " + planet_numeral_name(obj_controller.selecting_planet, target) + ".", ""); } else if (current_button == "+Recruiting") { if (obj_controller.recruiting_worlds_bought > 0 && p_data.current_owner <= 5 && !p_data.at_war()) { if (!p_data.has_feature(eP_FEATURES.RECRUITING_WORLD)) { @@ -400,7 +398,7 @@ try { button4 = ""; } } - // 135 ; popup? + // popup? } } } else if (current_button == "Cyclonic Torpedo") { @@ -416,8 +414,6 @@ try { draw_rectangle(37, 413, 270, 452, 0); draw_set_alpha(1); - /*draw_set_color(CM_GREEN_COLOR);draw_rectangle(40,247,253,273,1);*/ - draw_set_halign(fa_left); draw_set_color(0); @@ -428,12 +424,10 @@ try { draw_set_font(fnt_40k_14b); draw_text(37.5, 413.5, "Select Fleet Combat"); - // x3=46;y3=252; var x3 = 49, y3 = 441; for (var i = 1; i <= 7; i++) { if (en_fleet[i] > 0) { - // draw_sprite_ext(spr_force_icon,en_fleet[i],x3,y3,0.5,0.5,0,c_white,1); scr_image("ui/force", en_fleet[i], x3 - 16, y3 - 16, 32, 32); x3 += 64; } @@ -446,7 +440,3 @@ try { ERROR_HANDLER.handle_exception(_exception); instance_destroy(); } - -/* */ - -/* */ diff --git a/objects/obj_star_select/Mouse_50.gml b/objects/obj_star_select/Mouse_50.gml index 0733d86c25..cd1cffb440 100644 --- a/objects/obj_star_select/Mouse_50.gml +++ b/objects/obj_star_select/Mouse_50.gml @@ -62,16 +62,13 @@ if (!instance_exists(obj_saveload) && !instance_exists(obj_drop_select)) { purge = 0; if ((player_fleet > 0) && (imperial_fleet + mechanicus_fleet + inquisitor_fleet + eldar_fleet + ork_fleet + tau_fleet + heretic_fleet > 0) && (obj_controller.cooldown <= 0)) { - var i, x3, y3; - i = 0; - // x3=xx+46;y3=yy+252; + var x3, y3; x3 = xx + 49; y3 = yy + 441; var combating = 0; - repeat (7) { - i += 1; + for (var i = 1; i <= 7; i++) { if ((en_fleet[i] > 0) && (mouse_x >= x3 - 24) && (mouse_y >= y3 - 24) && (mouse_x < x3 + 48) && (mouse_y < y3 + 48) && (obj_controller.cooldown <= 0)) { obj_controller.cooldown = 8; combating = en_fleet[i]; @@ -82,7 +79,7 @@ if (!instance_exists(obj_saveload) && !instance_exists(obj_drop_select)) { if (combating > 0) { obj_controller.combat = combating; - var xx = false, yy = false, good = false, e1 = false, e2 = false, e3 = false; + var e1 = false, e2 = false, e3 = false; var enemy_fleet = array_create(20, 0); var allied_fleet = array_create(20, 0); @@ -93,18 +90,18 @@ if (!instance_exists(obj_saveload) && !instance_exists(obj_drop_select)) { var afri = array_create(20, 0); var aesc = array_create(20, 0); - good = 1; + var good = true; var p_fleet = get_nearest_player_fleet(x, y, true); obj_controller.temp[1099] = target.name; - good = p_fleet != "none" && instance_exists(target); + good = p_fleet != noone && instance_exists(target); if (good == 1) { // trying to find the star instance_activate_object(obj_star); obj_controller.x = target.x; - obj_controller.y = target.y; // show=current_battle; + obj_controller.y = target.y; strin[1] = string(p_fleet.capital_number); strin[2] = string(p_fleet.frigate_number); @@ -181,13 +178,11 @@ if (!instance_exists(obj_saveload) && !instance_exists(obj_drop_select)) { instance_deactivate_all(true); instance_activate_object(obj_controller); instance_activate_object(obj_ini); - // instance_activate_object(battle_object[current_battle]); instance_activate_object(p_fleet); instance_activate_object(obj_star); instance_create(0, 0, obj_fleet); obj_fleet.star_name = target.name; - // obj_fleet.enemy[1] = enemy_fleet[1]; obj_fleet.enemy_status[1] = -1; @@ -214,7 +209,6 @@ if (!instance_exists(obj_saveload) && !instance_exists(obj_drop_select)) { add_fleet_ships_to_combat(p_fleet, obj_fleet); - // instance_deactivate_object(battle_object[current_battle]); instance_deactivate_object(p_fleet); obj_controller.combat = 1; diff --git a/objects/obj_star_select/Step_0.gml b/objects/obj_star_select/Step_0.gml index 6d02e8eb8c..5f0b8b453f 100644 --- a/objects/obj_star_select/Step_0.gml +++ b/objects/obj_star_select/Step_0.gml @@ -7,6 +7,3 @@ if ((obj_controller.popup < 3) && (loading == 0)) { instance_destroy(); } } - -/* */ -/* */ diff --git a/objects/obj_temp_build/Create_0.gml b/objects/obj_temp_build/Create_0.gml index 2b0c1461d1..23d429f387 100644 --- a/objects/obj_temp_build/Create_0.gml +++ b/objects/obj_temp_build/Create_0.gml @@ -1,5 +1,5 @@ target = noone; -planet = noone; +planet = (variable_instance_exists(id, "planet") && planet > 0) ? planet : 0; lair = false; arsenal = false; diff --git a/objects/obj_turn_end/Alarm_0.gml b/objects/obj_turn_end/Alarm_0.gml index f62d5f1296..805c4fcc84 100644 --- a/objects/obj_turn_end/Alarm_0.gml +++ b/objects/obj_turn_end/Alarm_0.gml @@ -2,28 +2,21 @@ try { instance_activate_object(obj_star); combating = 0; - var i; - - i = 50; - repeat (50) { - i -= 1; - + for (var i = 49; i >= 0; i--) { if ((battles <= i) && (i >= 2)) { - if ((battle[i] != 0) && (battle[i - 1] != 0) && (battle_world[i] == -50) && (battle_world[i - 1] > 0)) { - var tem1, tem2, tem3, tem4, tem5, tem6, tem7; - tem1 = battle[i - 1]; - tem2 = battle_location[i - 1]; - tem3 = battle_world[i - 1]; - tem4 = battle_opponent[i - 1]; - tem5 = battle_object[i - 1]; - tem6 = battle_pobject[i - 1]; - tem7 = battle_special[i - 1]; + if ((battle[i] != 0) && (battle[i - 1] != 0) && (battle_world[i] == noone) && (battle_world[i - 1] > 0)) { + var tem1 = battle[i - 1]; + var tem2 = battle_location[i - 1]; + var tem3 = battle_world[i - 1]; + var tem4 = battle_opponent[i - 1]; + var tem5 = battle_object[i - 1]; + var tem6 = battle_pobject[i - 1]; + var tem7 = battle_special[i - 1]; battle[i - 1] = battle[i]; battle_location[i - 1] = battle_location[i]; battle_world[i - 1] = battle_world[i]; battle_opponent[i - 1] = battle_opponent[i]; - // battle_object[i-1]=battle_object[i]; battle_pobject[i - 1] = battle_pobject[i]; battle_special[i - 1] = battle_special[i]; @@ -43,19 +36,15 @@ try { // Ground battles after if ((battles > 0) && (current_battle <= battles)) { - var ii, xx, yy, good; - ii = 0; - good = 0; - var battle_star = find_star_by_name(battle_location[current_battle]); - if (battle_star != "none") { + if (battle_star != noone) { // trying to find the star obj_controller.x = battle_star.x; obj_controller.y = battle_star.y; show = current_battle; - if (battle_world[current_battle] == -50) { + if (battle_world[current_battle] == noone) { strin[1] = string(round(battle_pobject[current_battle].capital_number)); strin[2] = string(round(battle_pobject[current_battle].frigate_number)); strin[3] = string(round(battle_pobject[current_battle].escort_number)); @@ -66,9 +55,7 @@ try { // pull enemy ships here - var e = 1; - repeat (10) { - e += 1; + for (var e = 2; e <= 11; e++) { if (e == 11) { e = 13; } @@ -87,9 +74,8 @@ try { } } - var l1, l2; - l1 = 0; - l2 = 0; + var l1 = 0; + var l2 = 0; if (obj_controller.faction_status[e] != "War") { repeat (10) { l1 += 1; @@ -135,8 +121,7 @@ try { strin[3] = ""; - var tempy = 0; - tempy = battle_object[current_battle].p_owner[battle_world[current_battle]]; + var tempy = battle_object[current_battle].p_owner[battle_world[current_battle]]; if ((tempy == 1) || (tempy == 2) || (tempy == 3)) { var array_string = [ @@ -187,8 +172,6 @@ try { if (tempy == 6) { strin[4] = "Overwhelming"; } - - // if (battle_opponent[current_battle]=2) then obj_controller.alarm[7]=1; obj_controller.cooldown = 9999; } @@ -211,9 +194,6 @@ try { } alarm[1] = 1; } - - /* */ - /* */ } catch (_exception) { ERROR_HANDLER.handle_exception(_exception); } diff --git a/objects/obj_turn_end/Alarm_1.gml b/objects/obj_turn_end/Alarm_1.gml index 33cc7d7554..ffda7b59e3 100644 --- a/objects/obj_turn_end/Alarm_1.gml +++ b/objects/obj_turn_end/Alarm_1.gml @@ -1,6 +1,7 @@ var _is_audience = false; +var current_audience = noone; if (array_length(audience_stack) > 0) { - var current_audience = audience_stack[0]; + current_audience = audience_stack[0]; _is_audience = true; } @@ -41,14 +42,11 @@ if (_is_audience) { exit; } -// if (current_audience<=audiences) then alarm[1]=5; - if (!_is_audience) { current_popup += 1; if (popup[current_popup] != 0) { - var pip; - pip = instance_create(0, 0, obj_popup); + var pip = instance_create(0, 0, obj_popup); pip.title = popup_type[current_popup]; pip.text = popup_text[current_popup]; pip.image = popup_image[current_popup]; @@ -77,7 +75,6 @@ if (!_is_audience) { explode_script(popup_special[current_popup], "|"); pip.mission = string(explode[0]); pip.loc = string(explode[1]); - // "mech_raider!0!|"+string(you2.name)); "mech_bionics!0!|"+string(you2.name)); } if (string_count("meeting_", popup_special[current_popup]) > 0) { pip.mission = popup_special[current_popup]; @@ -98,25 +95,10 @@ if (!_is_audience) { if (popups_end == 0) { popups_end = 1; } - // obj_controller.x=first_x; - // obj_controller.y=first_y; - // instance_destroy(); } - - // obj_controller.x=first_x; - // obj_controller.y=first_y; - // instance_destroy(); } -// if (current_popup>popups) or (popup[1]=0) then popups_end=1; - if (popups_end == 1) { - /*if (popups=0){ - obj_controller.x=first_x; - obj_controller.y=first_y; - instance_destroy(); - }*/ - obj_controller.x = first_x; obj_controller.y = first_y; @@ -134,9 +116,5 @@ if (popups_end == 1) { millenium += 1; year -= 1000; } - // menu=0; } } - -/* */ -/* */ diff --git a/objects/obj_turn_end/Alarm_4.gml b/objects/obj_turn_end/Alarm_4.gml index 725d0b442a..dc62948b5d 100644 --- a/objects/obj_turn_end/Alarm_4.gml +++ b/objects/obj_turn_end/Alarm_4.gml @@ -1,21 +1,18 @@ -var battle_o; -battle_o = 0; current_battle += 1; combating = 0; instance_activate_object(obj_star); if ((battles > 0) && (current_battle <= battles)) { - var ii = 0, good = 0; var battle_star = find_star_by_name(battle_location[current_battle]); obj_controller.temp[1060] = battle_location[current_battle]; - if (battle_star != "none") { + if (battle_star != noone) { obj_controller.x = battle_star.x; obj_controller.y = battle_star.y; show = current_battle; - if (battle_world[current_battle] == -50) { + if (battle_world[current_battle] == noone) { strin[1] = string(battle_pobject[current_battle].capital_number); strin[2] = string(battle_pobject[current_battle].frigate_number); strin[3] = string(battle_pobject[current_battle].escort_number); @@ -51,9 +48,7 @@ if ((battles > 0) && (current_battle <= battles)) { strin[3] = ""; - var tempy; - tempy = 0; - tempy = battle_object[current_battle].p_owner[battle_world[current_battle]]; + var tempy = battle_object[current_battle].p_owner[battle_world[current_battle]]; if ((tempy == 1) || (tempy == 2) || (tempy == 3)) { if (battle_object[current_battle].p_fortified[battle_world[current_battle]] == 1) { diff --git a/objects/obj_turn_end/Create_0.gml b/objects/obj_turn_end/Create_0.gml index 2dad46637a..06f4ee3521 100644 --- a/objects/obj_turn_end/Create_0.gml +++ b/objects/obj_turn_end/Create_0.gml @@ -2,8 +2,6 @@ instance_deactivate_object(obj_star_select); instance_deactivate_object(obj_drop_select); instance_deactivate_object(obj_bomb_select); -var i; -i = -1; keywords = ""; last_open = 1; @@ -72,16 +70,13 @@ audience_stack = []; alert_alpha[1] = 0.2; alert_char[1] = 1; -i = -1; handle_discovered_governor_assasinations(); if (audiences > 0) { // This is a one-off change all messages to declare war - var i = 0; var war; - repeat (15) { - i += 1; + for (var i = 1; i <= 15; i++) { war[i] = 0; } for (var i = 0; i < array_length(audience_stack); i++) { @@ -98,6 +93,3 @@ if (audiences > 0) { alerts = 0; fast = 0; show = 0; - -/* */ -/* */ diff --git a/objects/obj_turn_end/Draw_0.gml b/objects/obj_turn_end/Draw_0.gml index f35608d78f..bdeb948003 100644 --- a/objects/obj_turn_end/Draw_0.gml +++ b/objects/obj_turn_end/Draw_0.gml @@ -26,7 +26,7 @@ if ((show > 0) && (current_battle <= battles)) { var i = current_battle; draw_sprite(spr_purge_panel, 0, xxx, yyy); - if (battle_world[i] == -50) { + if (battle_world[i] == noone) { scr_image("attacked", 1, xxx + 12, yyy + 54, 254, 174); } if (battle_world[i] > 0) { @@ -44,12 +44,11 @@ if ((show > 0) && (current_battle <= battles)) { if (battle_world[i] > 0) { draw_text_transformed(xxx + 265, yyy + 11, string_hash_to_newline("Forces Attacked! (" + string(battle_location[i]) + " " + scr_roman(battle_world[i]) + ")"), 0.7, 0.7, 0); } - if (battle_world[i] == -50) { + if (battle_world[i] == noone) { draw_text_transformed(xxx + 265, yyy + 11, string_hash_to_newline("Fleet Attacked! (" + string(battle_location[i]) + " System)"), 0.7, 0.7, 0); } scr_image("ui/force", 1, xxx + 378 - 32, yyy + 86 - 32, 64, 64); - // draw_sprite(spr_force_icon,1,xxx+378,yyy+86); draw_set_font(fnt_40k_14); draw_set_halign(fa_left); @@ -83,7 +82,6 @@ if ((show > 0) && (current_battle <= battles)) { draw_set_halign(fa_center); if (enemy_fleet[1] != 0) { - // draw_sprite(spr_force_icon,enemy_fleet[1],xxx+44,yyy+269); scr_image("ui/force", enemy_fleet[1], xxx + 44 - 32, yyy + 269 - 32, 64, 64); var shw; shw = ""; @@ -111,7 +109,6 @@ if ((show > 0) && (current_battle <= battles)) { draw_set_font(fnt_40k_14b); } if (enemy_fleet[2] != 0) { - // draw_sprite(spr_force_icon,enemy_fleet[2],xxx+154,yyy+269); scr_image("ui/force", enemy_fleet[2], xxx + 154 - 32, yyy + 269 - 32, 64, 64); var shw; shw = ""; @@ -139,7 +136,6 @@ if ((show > 0) && (current_battle <= battles)) { draw_set_font(fnt_40k_14b); } if (enemy_fleet[3] != 0) { - // draw_sprite(spr_force_icon,enemy_fleet[3],xxx+264,yyy+269); scr_image("ui/force", enemy_fleet[3], xxx + 264 - 32, yyy + 269 - 32, 64, 64); var shw; shw = ""; @@ -168,7 +164,6 @@ if ((show > 0) && (current_battle <= battles)) { } if (allied_fleet[1] != 0) { - // draw_sprite(spr_force_icon,allied_fleet[1],xxx+374,yyy+269); scr_image("ui/force", allied_fleet[1], xxx + 374 - 32, yyy + 269 - 32, 64, 64); var shw; shw = ""; @@ -196,7 +191,6 @@ if ((show > 0) && (current_battle <= battles)) { draw_set_font(fnt_40k_14b); } if (allied_fleet[2] != 0) { - // draw_sprite(spr_force_icon,allied_fleet[1],xxx+484,yyy+269); scr_image("ui/force", allied_fleet[1], xxx + 484 - 32, yyy + 269 - 32, 64, 64); var shw; shw = ""; @@ -261,7 +255,6 @@ if ((show > 0) && (current_battle <= battles)) { draw_text(xxx + 332, yyy + 237, string_hash_to_newline("Allies:")); draw_set_halign(fa_center); - // draw_sprite(spr_force_icon,battle_opponent[i],xxx+44,yyy+289); scr_image("ui/force", battle_opponent[i], xxx + 44 - 32, yyy + 289 - 32, 64, 64); draw_text_transformed(xxx + 44, yyy + 316, string_hash_to_newline(string(strin[4])), 0.75, 1, 0); draw_set_halign(fa_center); @@ -288,99 +281,3 @@ if ((show > 0) && (current_battle <= battles)) { } } } - -/* - -if (show>0) and (current_battle<=battles){ - var xxx,yyy,i; - xxx=view_xview[0]; - yyy=view_yview[0]; - i=current_battle; - - if (battle_world[i]>0) then draw_sprite(spr_attacked,0,xxx+90,yyy+101); - if (battle_world[i]=-50) then draw_sprite(spr_attacked,1,xxx+90,yyy+101); - - draw_set_font(fnt_info);draw_set_halign(fa_left);draw_set_color(CM_GREEN_COLOR); - draw_text(xxx+103,yyy+115,string(i)+"/"+string(battles)); - - draw_set_halign(fa_center); - draw_set_font(fnt_fancy); - - if (battle_world[i]>0) then draw_text_transformed(xxx+313,yyy+111,"Forces Attacked!",1.5,1.5,0); - if (battle_world[i]=-50) then draw_text_transformed(xxx+313,yyy+111,"Fleet Attacked!",1.5,1.5,0); - - if (battle_world[i]>0) then draw_text_transformed(xxx+313,yyy+144,"Planet "+string(battle_location[i])+" "+string(battle_world[i]),1,1,0); - if (battle_world[i]=-50) then draw_text_transformed(xxx+313,yyy+144,string(battle_location[i])+" System",1,1,0); - - draw_sprite(spr_force_icon,1,xxx+340,yyy+191); - if (battle_world[i]>0) then draw_sprite(spr_force_icon,battle_opponent[i],xxx+340,yyy+285); - draw_set_font(fnt_40k_14);draw_set_halign(fa_left); - - - - - if (battle_world[i]=-50){ - if (strin[1]!="0"){ - if (string(strin[1])="1") then draw_text(xxx+367,yyy+210,string(strin[1])+" Battleship ("+string(strin[4])+"% HP)"); - if (string(strin[1])!="1") then draw_text(xxx+367,yyy+210,string(strin[1])+" Battleships ("+string(strin[4])+"% HP)");} - - if (strin[2]!="0"){ - if (string(strin[2])="1") then draw_text(xxx+367,yyy+222,string(strin[2])+" Cruiser ("+string(strin[5])+"% HP)"); - if (string(strin[2])!="1") then draw_text(xxx+367,yyy+222,string(strin[2])+" Cruisers ("+string(strin[5])+"% HP)");} - - if (strin[3]!="0"){ - if (string(strin[3])="1") then draw_text(xxx+367,yyy+234,string(strin[3])+" Escort ("+string(strin[6])+"% HP)"); - if (string(strin[3])!="1") then draw_text(xxx+367,yyy+234,string(strin[3])+" Escorts ("+string(strin[6])+"% HP)");} - - - if (strin[7]!="0"){ - if (string(strin[7])="1") draw_text(xxx+367,yyy+302,string(strin[7])+" Battleship ("+string(strin[10])+"% HP)"); - if (string(strin[7])!="1") draw_text(xxx+367,yyy+302,string(strin[7])+" Battleships ("+string(strin[10])+"% HP)");} - - if (strin[8]!="0"){ - if (string(strin[8])="1") draw_text(xxx+367,yyy+314,string(strin[8])+" Cruiser ("+string(strin[11])+"% HP)"); - if (string(strin[8])!="1") draw_text(xxx+367,yyy+314,string(strin[8])+" Cruisers ("+string(strin[11])+"% HP)");} - - if (strin[9]!="0"){ - if (string(strin[9])="1") draw_text(xxx+367,yyy+326,string(strin[9])+" Escort ("+string(strin[12])+"% HP)"); - if (string(strin[9])!="1") draw_text(xxx+367,yyy+326,string(strin[9])+" Escorts ("+string(strin[12])+"% HP)");} - - draw_rectangle(xxx+188,yyy+350,xxx+297,yyy+372,1);draw_rectangle(xxx+328,yyy+350,xxx+437,yyy+372,1); - draw_set_alpha(0.5); - draw_rectangle(xxx+189,yyy+351,xxx+296,yyy+371,1);draw_rectangle(xxx+329,yyy+351,xxx+436,yyy+371,1); - draw_set_alpha(1); - - draw_set_halign(fa_center); - draw_text(xxx+241,yyy+353,"Fight");draw_text(xxx+383,yyy+353,"Retreat"); - draw_set_halign(fa_left); - } - - - if (battle_world[i]>=1){ - if (battle_opponent[i]<=20){ - draw_text(xxx+367,yyy+210,string(strin[1])+" Marines"); - draw_text(xxx+367,yyy+222,string(strin[2])+" Vehicles"); - if (strin[3]!="") then draw_text(xxx+367,yyy+234,string(strin[3])+" Fortified");// Not / Barely / Lightly / Moderately / Highly / Maximally - } - - draw_set_halign(fa_center); - draw_text(xxx+440,yyy+302,string(strin[4])); - - draw_rectangle(xxx+188,yyy+350,xxx+297,yyy+372,1);draw_rectangle(xxx+328,yyy+350,xxx+437,yyy+372,1); - draw_set_alpha(0.5); - draw_rectangle(xxx+189,yyy+351,xxx+296,yyy+371,1);draw_rectangle(xxx+329,yyy+351,xxx+436,yyy+371,1); - draw_set_alpha(1); - - draw_text(xxx+241,yyy+353,"Offensive");draw_text(xxx+383,yyy+353,"Defensive"); - draw_set_halign(fa_left); - } - - - - -}*/ - -/* */ - -/* */ -/* */ diff --git a/objects/obj_turn_end/Draw_64.gml b/objects/obj_turn_end/Draw_64.gml index 1dbe9b418b..6705411cc2 100644 --- a/objects/obj_turn_end/Draw_64.gml +++ b/objects/obj_turn_end/Draw_64.gml @@ -1,30 +1,21 @@ /// @description Insert description here // You can write your code in this editor -var i = 0; - draw_set_font(fnt_40k_14b); draw_set_halign(fa_left); draw_set_color(CM_GREEN_COLOR); if ((alerts > 0) && (popups_end == 1)) { - repeat (alerts) { - i += 1; + for (var i = 1; i <= alerts; i++) { set_alert_draw_colour(alert_color[i]); draw_set_alpha(min(1, alert_alpha[i])); if (obj_controller.zoomed == 0) { draw_text(32, +46 + (i * 20), string_hash_to_newline(string(alert_txt[i]))); - // draw_text(view_xview[0]+16.5,view_yview[0]+40.5+(i*12),string(alert_txt[i])); } - /*if (obj_controller.zoomed=1){ - draw_text_transformed(80,80+(i*24),string(alert_txt[i]),2,2,0); - draw_text_transformed(81,81+(i*24),string(alert_txt[i]),2,2,0); - }*/ if (obj_controller.zoomed == 1) { draw_text_transformed(32, 92 + (i * 40), string_hash_to_newline(string(alert_txt[i])), 2, 2, 0); - // draw_text_transformed(122,122+(i*36),string(alert_txt[i]),3,3,0); } } } diff --git a/objects/obj_turn_end/Mouse_56.gml b/objects/obj_turn_end/Mouse_56.gml index dcd58601e9..9a267f3e77 100644 --- a/objects/obj_turn_end/Mouse_56.gml +++ b/objects/obj_turn_end/Mouse_56.gml @@ -7,7 +7,7 @@ if (!instance_exists(obj_saveload) && !instance_exists(obj_popup) && !instance_e var xxx = camera_get_view_x(view_camera[0]) + 535; var yyy = camera_get_view_y(view_camera[0]) + 200; - if ((cooldown <= 0) && (battle_world[current_battle] == -50) && (combating == 0)) { + if ((cooldown <= 0) && (battle_world[current_battle] == noone) && (combating == 0)) { if ((mouse_x >= xxx + 132) && (mouse_y >= yyy + 354) && (mouse_x < xxx + 259) && (mouse_y < yyy + 389)) { // Run like hell, space with (obj_fleet_select) { @@ -31,7 +31,6 @@ if (!instance_exists(obj_saveload) && !instance_exists(obj_popup) && !instance_e combating = 1; instance_create(0, 0, obj_fleet); - // obj_fleet.enemy[1] = enemy_fleet[1]; obj_fleet.enemy_status[1] = -1; @@ -42,10 +41,8 @@ if (!instance_exists(obj_saveload) && !instance_exists(obj_popup) && !instance_e // Plug in all of the enemies first // And then plug in the allies after then with their status set to positive - var g = 1; ee = 1; - repeat (5) { - g += 1; + for (var g = 2; g <= 6; g++) { if (enemy_fleet[g] != 0) { ee += 1; obj_fleet.enemy[ee] = enemy_fleet[g]; @@ -56,9 +53,7 @@ if (!instance_exists(obj_saveload) && !instance_exists(obj_popup) && !instance_e obj_fleet.en_escort[ee] = eesc[g]; } } - var g = 0; - repeat (6) { - g += 1; + for (var g = 1; g <= 6; g++) { if (allied_fleet[g] != 0) { ee += 1; obj_fleet.enemy[ee] = allied_fleet[g]; @@ -92,13 +87,11 @@ if (!instance_exists(obj_saveload) && !instance_exists(obj_popup) && !instance_e instance_activate_object(obj_ini); instance_activate_object(obj_fleet); instance_activate_object(obj_cursor); - // instance_deactivate_object(battle_pobject[current_battle]); } } if ((cooldown <= 0) && (battle_world[current_battle] > 0) && (combating == 0)) { - var tip; - tip = ""; + var tip = ""; if ((mouse_x >= xxx + 132) && (mouse_y >= yyy + 354) && (mouse_x < xxx + 259) && (mouse_y < yyy + 389)) { tip = "offensive"; @@ -163,14 +156,6 @@ if (!instance_exists(obj_saveload) && !instance_exists(obj_popup) && !instance_e obj_ncombat.battle_special = battle_special[current_battle]; obj_ncombat.battle_climate = _planet_data.planet_type; - // show_message(string(battle_object[current_battle].p_feature[battle_world[current_battle]])); - /*if (scr_planetary_feature.plant_feature_bool(battle_object[current_battle].p_feature[battle_world[current_battle]], eP_FEATURES.MONASTERY)==1){ - // show_message(string(battle_object[current_battle].p_defenses[battle_world[current_battle]])); - // show_message(string(battle_object[current_battle].p_silo[battle_world[current_battle]])); - obj_ncombat.player_defenses+=battle_object[current_battle].p_defenses[battle_world[current_battle]]; - obj_ncombat.player_silos+=battle_object[current_battle].p_silo[battle_world[current_battle]]; - }*/ - if (_enemy == eFACTION.IMPERIUM) { obj_ncombat.threat = min(1000000, _planet_data.guardsmen); } else if (obj_ncombat.enemy < 14 && _enemy > 5) { @@ -179,7 +164,6 @@ if (!instance_exists(obj_saveload) && !instance_exists(obj_popup) && !instance_e obj_ncombat.threat = 1; } - // _roster = new Roster(); with (_roster) { roster_location = _loc; diff --git a/objects/obj_turn_end/Step_0.gml b/objects/obj_turn_end/Step_0.gml index c187d532ff..a3c79d9d2c 100644 --- a/objects/obj_turn_end/Step_0.gml +++ b/objects/obj_turn_end/Step_0.gml @@ -1,14 +1,9 @@ -var i; -i = 0; - if (cooldown >= 0) { cooldown -= 1; } if ((alerts > 0) && (popups_end == 1) && (fadeout == 0)) { - repeat (alerts) { - i += 1; - + for (var i = 1; i <= alerts; i++) { if ((fast >= i) && (string_length(alert_txt[i]) < string_length(alert_text[i]))) { alert_char[i] += 1; alert_txt[i] = string_copy(alert_text[i], 0, alert_char[i]); @@ -20,9 +15,7 @@ if ((alerts > 0) && (popups_end == 1) && (fadeout == 0)) { } if (fadeout == 1) { - i = 0; - repeat (alerts) { - i += 1; + for (var i = 1; i <= alerts; i++) { alert_alpha[i] -= 0.05; if ((i == 1) && (alert_alpha[1] <= 0)) { instance_destroy(); diff --git a/scripts/Armamentarium/Armamentarium.gml b/scripts/Armamentarium/Armamentarium.gml index 671e5e9f66..72215cedeb 100644 --- a/scripts/Armamentarium/Armamentarium.gml +++ b/scripts/Armamentarium/Armamentarium.gml @@ -161,11 +161,10 @@ function ShopItem(_name) constructor { } /// @desc Handles the display and interaction for STC fragment research and bonuses. -/// @param {Id.Instance} _controller_ref Reference to the object holding STC data (usually obj_controller). +/// @param {Id.Instance.obj_controller} _controller_ref Reference to the object holding STC data (usually obj_controller). /// @param {Function} _on_change_callback Callback after identification. /// @return {Struct.STCResearchPanel} function STCResearchPanel(_controller_ref, _on_change_callback) constructor { - /// @type {Asset.GMObject.obj_controller} controller = _controller_ref; on_change = _on_change_callback; @@ -416,7 +415,7 @@ function STCResearchPanel(_controller_ref, _on_change_callback) constructor { } /// @desc Primary controller for the Chapter's armory and technologies. -/// @param {Asset.GMObject.obj_controller} _controller +/// @param {Id.Instance.obj_controller} _controller /// @returns {Struct.Armamentarium} function Armamentarium(_controller) constructor { controller = _controller; @@ -785,7 +784,13 @@ function Armamentarium(_controller) constructor { } break; case "ships": - discount_stc = controller.stc_ships * 5; + // Tiered discount matching the STC panel descriptions and the real + // per-level feature unlocks. 8% at L1, 16% at L3, 25% at L5, held + // across the feature levels (L2 Hull, L4 Armour, L6 Warp). The old + // stc_ships * 5 gave 5/10/15/20/25/30, which mismatched every label + // and overshot the 25% cap at L6. + var _ship_tiers = [0, 8, 8, 16, 16, 25, 25]; + discount_stc = _ship_tiers[clamp(controller.stc_ships, 0, STC_MAX_LEVEL)]; if (discount_stc > 0) { global_cost_tooltip += $"Ship STC: -{discount_stc}%\n"; } diff --git a/scripts/ColourItem/ColourItem.gml b/scripts/ColourItem/ColourItem.gml index 7b12235588..911032194e 100644 --- a/scripts/ColourItem/ColourItem.gml +++ b/scripts/ColourItem/ColourItem.gml @@ -443,13 +443,13 @@ function ColourItem(_xx, _yy) constructor { }; colour_pick = false; - dummy_marine = false; - dummy_image = false; + dummy_marine = undefined; + dummy_image = undefined; static reset_image = function() { if (is_struct(dummy_image)) { delete dummy_image; - dummy_image = false; + dummy_image = undefined; } }; @@ -524,7 +524,7 @@ function ColourItem(_xx, _yy) constructor { break; } delete dummy_image; - dummy_image = false; + dummy_image = undefined; } } } @@ -554,8 +554,7 @@ function ColourItem(_xx, _yy) constructor { } image_location_maps.company_marks = move_location_relative(draw_unit_buttons([xx - 30, yy - 40], "Company Marks"), -xx, -yy); - //draw_sprite(sprite_index, 0, x, y); - if (dummy_marine == false) { + if (dummy_marine ?? true) { dummy_marine = new DummyMarine(); } if (!is_struct(dummy_image)) { diff --git a/scripts/DebugView/DebugView.gml b/scripts/DebugView/DebugView.gml index eb65eee8c5..7e98b9fd86 100644 --- a/scripts/DebugView/DebugView.gml +++ b/scripts/DebugView/DebugView.gml @@ -29,19 +29,19 @@ function DebugView(view_name, obj) constructor { return self; }; - static add_slider_int = function(_name, min, max, label = _name, step = 1) { + static add_slider_int = function(_name, _min, _max, label = _name, step = 1) { if (update) { return self; } - dbg_slider_int(ref_create(self.obj_ref, _name), min, max, label, step); + dbg_slider_int(ref_create(self.obj_ref, _name), _min, _max, label, step); return self; }; - static add_slider = function(_name, min, max, label = _name, step = 0.01) { + static add_slider = function(_name, _min, _max, label = _name, step = 0.01) { if (update) { return self; } - dbg_slider(ref_create(self.obj_ref, _name), min, max, label == name, step); + dbg_slider(ref_create(self.obj_ref, _name), _min, _max, label, step); return self; }; diff --git a/scripts/NameGenerator/NameGenerator.gml b/scripts/NameGenerator/NameGenerator.gml index 07ce8bf667..3f2c56ced8 100644 --- a/scripts/NameGenerator/NameGenerator.gml +++ b/scripts/NameGenerator/NameGenerator.gml @@ -6,15 +6,15 @@ function NameTracker(set_name) constructor { composite_names = []; - composite_components = {}; + composite_components = { + prefixes : [], + suffixes : [], + special : [] + }; generic_counter = 0; static LoadSimpleNames = function(file_name, fallback_value, json_names_property_name = "names") { - if (json_names_property_name == noone) { - json_names_property_name = "names"; - } - var file_loader = new JsonFileListLoader(); var load_result = file_loader.load_list_from_json_file($"main/names/{file_name}.json", [json_names_property_name]); @@ -36,21 +36,17 @@ function NameTracker(set_name) constructor { "special" ] ) { - if (json_names_property_names == noone) { - json_names_property_names = [ - "prefixes", - "suffixes", - "special" - ]; - } - composite_names = json_names_property_names; var file_loader = new JsonFileListLoader(); var load_result = file_loader.load_list_from_json_file($"main/names/{file_name}.json", json_names_property_names); - var result = {}; + var result = { + prefixes : [], + suffixes : [], + special : [] + }; for (var i = 0; i < array_length(json_names_property_names); i++) { var _property_name = json_names_property_names[i]; diff --git a/scripts/instance_create/instance_create.gml b/scripts/instance_create/instance_create.gml index 9ff3d86578..89d7c8b462 100644 --- a/scripts/instance_create/instance_create.gml +++ b/scripts/instance_create/instance_create.gml @@ -1,9 +1,9 @@ /// @function instance_create /// @description Creates an instance of a given object at a given position. -/// @param {real} _x The x position the object will be created at. -/// @param {real} _y The y position the object will be created at. +/// @param {Real} _x The x position the object will be created at. +/// @param {Real} _y The y position the object will be created at. /// @param {Asset.GMObject} _obj The object to create an instance of. -/// @returns {Asset.GMObject} +/// @returns {Id.Instance} function instance_create(_x, _y, _obj) { var myDepth = object_get_depth(_obj); return instance_create_depth(_x, _y, myDepth, _obj); @@ -11,8 +11,8 @@ function instance_create(_x, _y, _obj) { /// @function instances_exist_any /// @description Checks if any of the provided instances exist -/// @param {array} instance_set Array of instances to check for existence -/// @returns {bool} +/// @param {Array} instance_set Array of instances to check for existence +/// @returns {Bool} function instances_exist_any(instance_set = []) { var _exists = false; for (var i = 0; i < array_length(instance_set); i++) { diff --git a/scripts/is_specialist/is_specialist.gml b/scripts/is_specialist/is_specialist.gml index 1907ca498b..0581a0c37b 100644 --- a/scripts/is_specialist/is_specialist.gml +++ b/scripts/is_specialist/is_specialist.gml @@ -15,17 +15,17 @@ #macro SPECIALISTS_HEADS "heads" /// @description Retrieves the active roles from the game, either from the obj_creation or obj_ini object. -/// @returns {array} +/// @returns {Array} function active_roles() { var _roles = instance_exists(obj_creation) ? obj_creation.role[100] : obj_ini.role[100]; return _roles; } /// @description Returns a list of roles based on the specified group, with optional inclusion of trainees and heads. -/// @param {integer} group The group of roles to retrieve (e.g., SPECIALISTS_STANDARD, SPECIALISTS_LIBRARIANS). -/// @param {bool} include_trainee Whether to include trainee roles (default is false). -/// @param {bool} include_heads Whether to include head roles (default is true). -/// @returns {array} +/// @param {Real} group The group of roles to retrieve (e.g., SPECIALISTS_STANDARD, SPECIALISTS_LIBRARIANS). +/// @param {Bool} include_trainee Whether to include trainee roles (default is false). +/// @param {Bool} include_heads Whether to include head roles (default is true). +/// @returns {Array} function role_groups(group, include_trainee = false, include_heads = true) { var _role_list = []; var _roles = active_roles(); @@ -217,11 +217,11 @@ function role_groups(group, include_trainee = false, include_heads = true) { } /// @description Checks if a given unit's role is a specialist within a specific role group. -/// @param {string} unit_role The role of the unit to check. -/// @param {integer} type The type of specialist group to check (default is SPECIALISTS_STANDARD). -/// @param {bool} include_trainee Whether to include trainee roles (default is false). -/// @param {bool} include_heads Whether to include head roles (default is true). -/// @returns {bool} +/// @param {String} unit_role The role of the unit to check. +/// @param {String} type The type of specialist group to check (default is SPECIALISTS_STANDARD). +/// @param {Bool} include_trainee Whether to include trainee roles (default is false). +/// @param {Bool} include_heads Whether to include head roles (default is true). +/// @returns {Bool} function is_specialist(unit_role, type = SPECIALISTS_STANDARD, include_trainee = false, include_heads = true) { var _specialists = role_groups(type, include_trainee, include_heads); diff --git a/scripts/macros/macros.gml b/scripts/macros/macros.gml index 7c16cd0d58..4d9be9d137 100644 --- a/scripts/macros/macros.gml +++ b/scripts/macros/macros.gml @@ -1,3 +1,58 @@ +// Imperial Guard squad: how many guardsmen one Guard Squad unit represents. +// RESERVED (iteration 2): the Guard Squad system (this macro, the guard_squad template, +// scr_add_man, scr_marine_struct max_health(), scr_cheatcode, scr_roster, and the combat +// hook in scr_player_combat_weapon_stacks) is not used in normal play. Kept for planned +// reuse as heavy weapons teams. Do not delete. +#macro GUARD_SQUAD_SIZE 10 + +// Imperial Guard heavy weapons team: how many guardsmen one Heavy Weapons Team unit represents. +// The team is a single pooled-HP entity (role "Heavy Weapons Team") crewing one heavy weapon, with +// the health of this many guardsmen (see scr_marine_struct max_health()). 3 = a 3-man weapons team. +#macro GUARD_HEAVY_WEAPONS_TEAM_SIZE 3 + +// Imperial Guard cover save: fraction of would-be ground-combat casualties treated as +// missed, standing in for spacing, terrain use and a low profile that the combat model +// does not simulate. Applied after armour, so it also blunts armour-piercing weapons +// (choppaz, power klawz) that ignore Flak entirely. 0 = no save, 0.4 = 40% fewer losses. +#macro GUARD_COVER_SAVE 0.4 + +// Imperial Guard auxilia screen: the front-most battle columns guardsmen are dealt across. +// Ten obj_pnunit columns exist (1 back to 10 front, higher column = nearer the enemy); the +// Marine and vehicle roles only use columns 1-7, so 8-10 are free front-most positions. +// Guardsmen are spread across these as separate positional blocks so the screen sits ahead of +// the Marines and engages the enemy in waves, instead of merging the whole regiment into one +// lasgun volley in the hire column. FIRST is the rear-most screen column, COUNT how many +// front columns the screen occupies (FIRST + COUNT - 1 must stay within the 10 columns). +#macro GUARD_SCREEN_COLUMN_FIRST 8 +#macro GUARD_SCREEN_COLUMN_COUNT 3 + +// Enemy target preference: the minimum weapon armour pierce (apa, scale 0-4) that counts as +// "anti-tank" and so hunts vehicles in obj_enunit\Alarm_0. Weapons below this prefer infantry +// and only turn to vehicles as a fallback. 3 splits dedicated anti-tank (rokkit / lascannon / +// melta tier) from general-purpose and anti-infantry guns. Raise toward 4 to make only the +// heaviest guns chase tanks; drop toward 1 for the old behaviour where almost everything did. +#macro GUARD_ENEMY_ANTITANK_AP 3 + +// Guard volley size: how many rank-and-file guardsmen share one firing stack in combat. The +// regiment splits into capped stacks of this size instead of merging into one giant lasgun +// volley, so each chunk fires and targets independently like an enemy obj_enunit block (those +// run ~32-40 strong). They still deploy as one movable hireling line; this only affects firing. +// Lower for more, smaller volleys; raise toward one big stack. Keep it from making too many +// stacks: a block has 71 stack slots shared with every other weapon. +#macro GUARD_VOLLEY_SIZE 100 + + +// Imperial Guard accuracy ("doom"): mirrors the enemy's per-faction doom in scr_shoot (the +// owner == eFACTION.IMPERIUM branch, e.g. Orks 0.2, Tyranids 0.4). Massed lasgun fire from raw +// conscripts connects far less than disciplined Astartes fire, so the guard's ranged lasgun +// volleys have their effective shots scaled by this fraction before damage. The player branch +// divides damage_per_weapon by wep_num rather than the scaled count, so per-shot damage is +// untouched and the cut is linear: the volley still fires in full but only this share lands. +// 1 = no reduction (marine-grade, also what Elite Cultists fire at), 0.35 = roughly a third of +// the lasguns connect. Kills scale about linearly with this value, so 0.7 is roughly double the +// effectiveness of 0.35 with no change to damage or penetration. +#macro GUARD_DOOM 0.7 + #macro MAX_STC_PER_SUBCATEGORY 6 #macro DEFAULT_TOOLTIP_VIEW_OFFSET 32 #macro DEFAULT_LINE_GAP -1 @@ -15,6 +70,14 @@ #macro MANAGE_MAN_MAX array_length(obj_controller.display_unit) + 7 #macro LARGE_PLANET_MOD 1000000000 // Population threshold for large planet classification +// Ground combat message log: lines the display fully drains per turn (so the end-of-turn status +// line shows even on long battles), and the per-stage frame timeout before force-advancing. +#macro COMBAT_LOG_CAPACITY 500 +#macro COMBAT_STAGE_TIMEOUT_FRAMES 1200 +// Battle-log message_priority colour codes (extends the existing 134/135/137 set). +#macro MSG_COLOR_WHITE 140 +#macro MSG_COLOR_LIGHTGREEN 141 + #macro STR_ANY_POWER_ARMOUR "Any Power Armour" #macro STR_ANY_TERMINATOR_ARMOUR "Any Terminator Armour" @@ -70,12 +133,14 @@ enum eROLE { ASSAULT = 10, ANCIENT = 11, SCOUT = 12, + BIKER = 13, CHAPLAIN = 14, APOTHECARY = 15, TECHMARINE = 16, LIBRARIAN = 17, SERGEANT = 18, VETERANSERGEANT = 19, + ATTACK_BIKER = 20, LANDRAIDER = 50, RHINO = 51, PREDATOR = 52, @@ -115,7 +180,8 @@ enum eINQUISITION_MISSION { TOMB_WORLD, TYRANID_ORGANISM, ETHEREAL, - DEMON_WORLD + DEMON_WORLD, + RANDOM = 100, } enum eEVENT { diff --git a/scripts/scr_ChapterTraits/scr_ChapterTraits.gml b/scripts/scr_ChapterTraits/scr_ChapterTraits.gml index ef930d94aa..7fc5c23783 100644 --- a/scripts/scr_ChapterTraits/scr_ChapterTraits.gml +++ b/scripts/scr_ChapterTraits/scr_ChapterTraits.gml @@ -469,10 +469,11 @@ function ChapterGameData(data = {}) constructor { function draw_chapter_trait_list(type) { add_draw_return_values(); + var _list = []; if (type) { - var _list = obj_creation.all_advantages; + _list = obj_creation.all_advantages; } else { - var _list = obj_creation.all_disadvantages; + _list = obj_creation.all_disadvantages; } var _title = type ? "Advantages" : "Disadvantage"; @@ -553,12 +554,14 @@ function draw_selected_chapter_traits(type) { add_draw_return_values(); + var _title_x = 0; + var _advarray = []; if (bool(type)) { - var _title_x = 436; - var _advarray = obj_creation.all_advantages; + _title_x = 436; + _advarray = obj_creation.all_advantages; } else { - var _title_x = 810; - var _advarray = obj_creation.all_disadvantages; + _title_x = 810; + _advarray = obj_creation.all_disadvantages; } var _adv_txt = { @@ -580,9 +583,10 @@ function draw_selected_chapter_traits(type) { var _advantages = 0; for (var i = 0; i < array_length(_advarray); i++) { var _adv = _advarray[i]; + var _array = []; if (_adv.activated) { if (_advantages < _max_advantage_count) { - var _array = draw_unit_buttons([_adv_txt.x1, _adv_txt.y1 + (_advantages * _adv_txt.h)], $"[-] {_adv.name}", [0.75, 0.75], CM_GREEN_COLOR); + _array = draw_unit_buttons([_adv_txt.x1, _adv_txt.y1 + (_advantages * _adv_txt.h)], $"[-] {_adv.name}", [0.75, 0.75], CM_GREEN_COLOR); _advantages++; } else { _adv.remove(); diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index d1bda6d055..7db5d3be33 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -1,6 +1,3 @@ -// Script assets have changed for v2.3.0 see -// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information - global.force_strength_descriptions = [ "none", "Minimal", @@ -8,21 +5,20 @@ global.force_strength_descriptions = [ "Moderate", "Numerous", "Very Numerous", - "Overwhelming" + "Overwhelming", ]; -/// @param {real} planet -/// @param {Asset.GMObject.obj_star} system +/// @param {Real} planet +/// @param {Id.Instance.obj_star} system function PlanetData(planet, system) constructor { //safeguards // TODO LOW DEBUG_LOGGING // Log when tripped somewhere //disposition - // static large_pop_conversion = 1000000000; self.planet = planet; self.system = system; - static refresh_data = function(){ + static refresh_data = function() { features = system.p_feature[planet]; current_owner = system.p_owner[planet]; origional_owner = system.p_first[planet]; @@ -34,10 +30,11 @@ function PlanetData(planet, system) constructor { is_hulk = system.space_hulk; x = system.x; y = system.y; + player_disposition = system.dispo[planet]; planet_type = system.p_type[planet]; operatives = system.p_operatives[planet]; pdf = system.p_pdf[planet]; - fortification_level = system.p_fortified[planet]; + fortification_level = system.p_fortified[planet]; star_station = system.p_station[planet]; pdf_loss_reduction = 0; @@ -53,34 +50,38 @@ function PlanetData(planet, system) constructor { guardsmen = system.p_guardsmen[planet]; pdf = system.p_pdf[planet]; - try{ + try { planet_forces[eFACTION.PLAYER] = player_forces; - planet_forces[eFACTION.IMPERIUM] = guardsmen; + planet_forces[eFACTION.IMPERIUM] = guardsmen; - planet_forces[eFACTION.ECCLESIARCHY] = system.p_sisters[planet]; - planet_forces[eFACTION.ELDAR] = system.p_eldar[planet]; - planet_forces[eFACTION.ORK] = system.p_orks[planet]; - planet_forces[eFACTION.TAU] = system.p_tau[planet]; - planet_forces[eFACTION.TYRANIDS] = system.p_tyranids[planet]; - planet_forces[eFACTION.CHAOS] = system.p_chaos[planet]+ system.p_demons[planet]; - planet_forces[eFACTION.HERETICS] = system.p_traitors[planet]; + planet_forces[eFACTION.ECCLESIARCHY] = system.p_sisters[planet]; + planet_forces[eFACTION.ELDAR] = system.p_eldar[planet]; + planet_forces[eFACTION.ORK] = system.p_orks[planet]; + planet_forces[eFACTION.TAU] = system.p_tau[planet]; + planet_forces[eFACTION.TYRANIDS] = system.p_tyranids[planet]; + planet_forces[eFACTION.CHAOS] = system.p_chaos[planet] + system.p_demons[planet]; + planet_forces[eFACTION.HERETICS] = system.p_traitors[planet]; planet_forces[eFACTION.NECRONS] = system.p_necrons[planet]; - }catch(_exception){ - handle_exception(_exception); + } catch (_exception) { + ERROR_HANDLER.handle_exception(_exception); } - - fortification_level = system.p_fortified[planet]; + + fortification_level = system.p_fortified[planet]; is_heretic = system.p_hurssy[planet]; heretic_timer = system.p_hurssy_time[planet]; + secret_corruption = system.p_heresy_secret[planet]; + + corruption = system.p_heresy[planet]; + population_influences = system.p_influence[planet]; raided_this_turn = system.p_raided[planet]; - // + governor = system.p_governor[planet]; problems = system.p_problem[planet]; @@ -92,22 +93,22 @@ function PlanetData(planet, system) constructor { requests_help = system.p_halp[planet]; - //safeguards // TODO LOW DEBUG_LOGGING // Log when tripped somewhere + //safeguards // TODO LOW DEBUG_LOGGING // Log when tripped somewhere //disposition - if (system.dispo[planet] < -100 && system.dispo[planet] > -1000 && system.p_owner[planet] != eFACTION.PLAYER ) { // Personal Rule code be doing some interesting things + if (system.dispo[planet] < -100 && system.dispo[planet] > -1000 && system.p_owner[planet] != eFACTION.PLAYER) { + // Personal Rule code be doing some interesting things system.dispo[planet] = -100; // TODO LOW DISPOSITION_REVAMP // Consider revamping the disposition system } else if (system.dispo[planet] > 100) { system.dispo[planet] = 100; } - player_disposition = system.dispo[planet]; garrisons = system.system_garrison[planet]; - if (garrisons == 0){ - garrisons = system.get_garrison(planet) + if (garrisons == 0) { + garrisons = system.get_garrison(planet); } sabatours = system.system_sabatours[planet]; - if (sabatours == 0){ - sabatours = system.get_sabatours(planet) + if (sabatours == 0) { + sabatours = system.get_sabatours(planet); } system.system_datas[planet] = self; @@ -123,14 +124,13 @@ function PlanetData(planet, system) constructor { secret_corruption = system.p_heresy_secret[planet]; corruption = system.p_heresy[planet]; - } + }; refresh_data(); - - static total_corruption = function(){ + static total_corruption = function() { return secret_corruption + corruption; - } + }; function add_operatives(new_ops) { array_push(system.p_operatives[planet], new_ops); @@ -171,28 +171,28 @@ function PlanetData(planet, system) constructor { return pop_value; }; - static population_as_small = function(){ + static population_as_small = function() { if (large_population) { return population * large_pop_conversion; } else { return population; } - } + }; - static end_turn_population_growth = function(){ + static end_turn_population_growth = function() { if ((population < max_population) && (planet_type != "Dead") && (planet_type != "Craftworld") && (current_owner <= 5) && (planet_forces[eFACTION.HERETICS] == 0) && (planet_forces[eFACTION.TAU] == 0) && (planet_forces[eFACTION.ORK] == 0) && (planet_forces[eFACTION.NECRONS] == 0) && (planet_forces[eFACTION.TYRANIDS] == 0)) { if (!large_population) { set_population(round(population * 1.0008)); } else if (large_population == 1) { edit_population(choose(0, 0.01)); } - } - } + } + }; - static alter_influence = function(faction,value){ + static alter_influence = function(faction, value) { adjust_influence(faction, value, planet, system); population_influences = system.p_influence[planet]; - } + }; static send_colony_ship = function(target, targ_planet, type) { new_colony_fleet(system, planet, target, targ_planet, type); @@ -259,11 +259,11 @@ function PlanetData(planet, system) constructor { guardsmen = system.p_guardsmen[planet]; }; - static edit_pdf = function(edit_val){ + static edit_pdf = function(edit_val) { system.p_pdf[planet] = max(0, system.p_pdf[planet] + edit_val); - pdf = system.p_pdf[planet] - } - + pdf = system.p_pdf[planet]; + }; + pdf = system.p_pdf[planet]; fortification_level = system.p_fortified[planet]; @@ -278,7 +278,7 @@ function PlanetData(planet, system) constructor { if (large_population) { new_pdf *= large_pop_conversion; } - edit_pdf(new_pdf) + edit_pdf(new_pdf); return new_pdf; }; @@ -293,9 +293,9 @@ function PlanetData(planet, system) constructor { player_forces = system.p_player[planet]; }; - static collect_planet_group = function(group="all",opposite=false,search_conditions = {companies:"all"} , return_as_UnitGroup = true){ - return collect_role_group(group,[system.name,planet],opposite,search_conditions, return_as_UnitGroup); - } + static collect_planet_group = function(group = "all", opposite = false, search_conditions = {companies: "all"}, return_as_UnitGroup = true) { + return collect_role_group(group, [system.name, planet], opposite, search_conditions, return_as_UnitGroup); + }; defence_lasers = system.p_lasers[planet]; defence_silos = system.p_silo[planet]; @@ -363,57 +363,50 @@ function PlanetData(planet, system) constructor { static assasinate_governor = function(assaination_type, discovery_modifier) { var randa = roll_dice_chapter(1, 100, "high"); var randa2 = roll_dice(1, 100); + var _text = $"All of the successors for {name()} are removed or otherwise made indisposed. Paperwork is slightly altered. Rather than any sort of offical one of your Chapter Serfs is installed as the Planetary Governor. The planet is effectively under your control."; + var _discovery_rate = 25; //type 1 is install a sympathectic else it's a straight serf installation if (assaination_type == 1) { - var _discovery_rate = 10; + _discovery_rate = 10; set_player_disposition(70 + floor(random_range(5, 15)) + 1); - var _text = $"Many of the successors for {name()} are removed or otherwise made indisposed. Your chapter ensures that the new Planetary Governor is sympathetic to your plight and more than willing to heed your advice. A powerful new ally may be in the making."; + _text = $"Many of the successors for {name()} are removed or otherwise made indisposed. Your chapter ensures that the new Planetary Governor is sympathetic to your plight and more than willing to heed your advice. A powerful new ally may be in the making."; scr_event_log("", $"Planetary Governor of {name()} assassinated. A more suitable Governor is installed."); } else { - var _discovery_rate = 25; if (origional_owner != 3) { set_new_owner(eFACTION.PLAYER); } set_player_disposition(101); scr_event_log("", $"Planetary Governor of {name()} assassinated. One of your Chapter Serfs take their position."); - var _text = $"All of the successors for {name()} are removed or otherwise made indisposed. Paperwork is slightly altered. Rather than any sort of offical one of your Chapter Serfs is installed as the Planetary Governor. The planet is effectively under your control."; } if (randa2 <= (_discovery_rate * discovery_modifier)) { + var _duration = (choose(1, 2) * 6) + choose(-3, -2, -1, 0, 1, 2, 3); if (assaination_type == 1) { - var _duration = ((choose(1, 2, 3, 4, 5, 6) + choose(1, 2, 3, 4, 5, 6)) * 6) + choose(-3, -2, -1, 0, 1, 2, 3); - } else { - var _duration = (choose(1, 2) * 6) + choose(-3, -2, -1, 0, 1, 2, 3); + _duration = ((choose(1, 2, 3, 4, 5, 6) + choose(1, 2, 3, 4, 5, 6)) * 6) + choose(-3, -2, -1, 0, 1, 2, 3); } - add_event({ - duration: _duration, e_id: - "governor_assassination", - variant: assaination_type, - system: system.name, - planet - }); + add_event({duration: _duration, e_id: "governor_assassination", variant: assaination_type, system: system.name, planet}); } return _text; }; + static purge = scr_purge_world; - static assasinate_governor_setup = function(action_score){ - var aroll=roll_dice_chapter(1, 100, "high"); + static assasinate_governor_setup = function(action_score) { + var aroll = roll_dice_chapter(1, 100, "high"); var chance = 100; - // var siz_penalty=0; - var o=0; - var yep=0; - + var o = 0; + var yep = 0; + // Disposition aroll += floor(player_disposition / 10); // Advantages - if (scr_has_adv("Ambushers")){ - aroll+=10; + if (scr_has_adv("Ambushers")) { + aroll += 10; } - if (scr_has_adv("Lightning Warriors")){ - aroll+=5; + if (scr_has_adv("Lightning Warriors")) { + aroll += 5; } // Size - unused @@ -423,102 +416,127 @@ function PlanetData(planet, system) constructor { // if ((action_score > 50) && (action_score <= 100)) { siz_penalty = 50; } // if ((action_score > 100) && (action_score <= 200)) { siz_penalty = 75; } // if (action_score > 200) { siz_penalty = 125; } - - var spec1=0,spec2=0,txt=""; // TODO consider making it a battle with Planetary governor's guards - txt=$"Your Astartes descend upon the surface of {name()} and plot the movements and schedule of the governor. "; - txt+="Once the time is right their target is ambushed " - txt+=choose("in their home","in the streets","while driving","taking a piss")+" and tranquilized. "; - - if (scr_has_disadv("Never Forgive")){ - spec1=1; - } - if (global.chapter_name="Space Wolves" || obj_ini.progenitor == ePROGENITOR.SPACE_WOLVES) { - spec1=3; + + var spec1 = 0, spec2 = 0, txt = ""; // TODO consider making it a battle with Planetary governor's guards + txt = $"Your Astartes descend upon the surface of {name()} and plot the movements and schedule of the governor. "; + txt += "Once the time is right their target is ambushed "; + txt += choose("in their home", "in the streets", "while driving", "taking a piss") + " and tranquilized. "; + + if (scr_has_disadv("Never Forgive")) { + spec1 = 1; } - else if (scr_has_adv("Tech-Brothers")) { - spec1=6; + if (global.chapter_name == "Space Wolves" || obj_ini.progenitor == ePROGENITOR.SPACE_WOLVES) { + spec1 = 3; + } else if (scr_has_adv("Tech-Brothers")) { + spec1 = 6; } - if (obj_ini.omophagea=1){ - spec1=choose(spec1,20); + if (obj_ini.omophagea == 1) { + spec1 = choose(spec1, 20); } var _gov_gender = set_gender(); var _gender_third = string_gender_third_person(_gov_gender); var _gender_pronouns = string_gender_pronouns(_gov_gender); - - if (spec1=1) then txt+=$"They are brought to the already-prepared facilities for Fallen, tortured to make {_gender_pronouns} appear a heretic, and then incinerated. "; - if (spec1=3) then txt+=$"{_gender_third} is tossed to the Fenrisian Wolves and viciously mauled, torn apart, and eaten. The beasts leave nothing but bloody scraps. "; - if (spec1=6) then txt+=$"{_gender_third} is stuck in with the other criminals, and scum, to be turned into a servitor. Soon nothing remains that could be likened to the former Governor. "; - if (spec1=20){ - if (action_score>1) then txt+=$"Things get out of hand, and the Governor is torn limb from limb and consumed. {_gender_pronouns}flesh is torn off and eaten, bone pulverized, and marrow sucked free. "; - if (action_score=1) then txt+=$"Your battle brother chops apart the Governor and eats a sizeable portion of {_gender_pronouns} flesh, focusing upon the eyes, teeth, and fingers. Once full the rest is disposed of. "; - } - - if (spec1=0){ - spec2=choose(1,2,3,4,5,5,5); - if (spec2=1) then txt+=$"Their still-living body is disintegrated by acid. "; - if (spec2=2) then txt+=$"The Governor is jettisoned into the local star at the first opportunity. "; - if (spec2=3) then txt+=$"{_gender_third} is burned as fuel for one of your vessels. "; - if (spec2=4) then txt+=$"A few grenades is all it takes to blow {_gender_pronouns} body to smithereens. "; - if (spec2=5) then txt+=$"{_gender_third} is executed in a mundane fashion and buried. "; - } - - txt+="What is thy will?"; - - var pip = instance_create(0,0,obj_popup); + + if (spec1 == 1) { + txt += $"They are brought to the already-prepared facilities for Fallen, tortured to make {_gender_pronouns} appear a heretic, and then incinerated. "; + } + if (spec1 == 3) { + txt += $"{_gender_third} is tossed to the Fenrisian Wolves and viciously mauled, torn apart, and eaten. The beasts leave nothing but bloody scraps. "; + } + if (spec1 == 6) { + txt += $"{_gender_third} is stuck in with the other criminals, and scum, to be turned into a servitor. Soon nothing remains that could be likened to the former Governor. "; + } + if (spec1 == 20) { + if (action_score > 1) { + txt += $"Things get out of hand, and the Governor is torn limb from limb and consumed. {_gender_pronouns}flesh is torn off and eaten, bone pulverized, and marrow sucked free. "; + } + if (action_score == 1) { + txt += $"Your battle brother chops apart the Governor and eats a sizeable portion of {_gender_pronouns} flesh, focusing upon the eyes, teeth, and fingers. Once full the rest is disposed of. "; + } + } + + if (spec1 == 0) { + spec2 = choose(1, 2, 3, 4, 5, 5, 5); + if (spec2 == 1) { + txt += $"Their still-living body is disintegrated by acid. "; + } + if (spec2 == 2) { + txt += $"The Governor is jettisoned into the local star at the first opportunity. "; + } + if (spec2 == 3) { + txt += $"{_gender_third} is burned as fuel for one of your vessels. "; + } + if (spec2 == 4) { + txt += $"A few grenades is all it takes to blow {_gender_pronouns} body to smithereens. "; + } + if (spec2 == 5) { + txt += $"{_gender_third} is executed in a mundane fashion and buried. "; + } + } + + txt += "What is thy will?"; + + var pip = instance_create(0, 0, obj_popup); pip.title = "Planetary Governor Assassinated"; - pip._text = txt; + pip.text = txt; pip.planet = planet; pip.p_data = self; var options = [ { - str1 : "Allow the official successor to become Planetary Governor.", - choice_func : allow_governor_successor, - }, + str1: "Allow the official successor to become Planetary Governor.", + choice_func: allow_governor_successor, + }, { - str1 : "Ensure that a sympathetic successor will be the one to rule.", - choice_func : install_sympathetic_successor, + str1: "Ensure that a sympathetic successor will be the one to rule.", + choice_func: install_sympathetic_successor, }, { - str1 : "Remove all successors and install a loyal Chapter Serf.", - choice_func : install_chapter_surf, + str1: "Remove all successors and install a loyal Chapter Serf.", + choice_func: install_chapter_surf, }, - ] - pip.add_option(options); - pip.cooldown=20; - + ]; + pip.add_option(options); + pip.cooldown = 20; + // Result- this is the multiplier for the chance of discovery with the inquisition, can also be used to determine // the new Governor disposition if they are the official successor - if (aroll < chance){// Discovered - pip.estimate=2; - } else if (aroll >= chance){// Success - pip.estimate=1; + if (aroll < chance) { + // Discovered + pip.estimate = 2; + } else if (aroll >= chance) { + // Success + pip.estimate = 1; } // If there are enemy non-chaos forces then they may be used as a cover // Does not work with chaos because if the governor dies, with chaos present, the new governor would possibly be investigated - if (planet_forces[eFACTION.ORK]>=4) or (planet_forces[eFACTION.NECRONS]>=3) or (planet_forces[eFACTION.TYRANIDS]>=5){ - pip.estimate = pip.estimate*0.5; + if ((planet_forces[eFACTION.ORK] >= 4) || (planet_forces[eFACTION.NECRONS] >= 3) || (planet_forces[eFACTION.TYRANIDS] >= 5)) { + pip.estimate = pip.estimate * 0.5; } - } - static grow_ork_forces = function(){ + }; + + static grow_ork_forces = function() { var contin = 0; - var _rando = roll_dice(1,100);// This part handles the spreading - // if (_rando<30){ + var _rando = roll_dice(1, 100); // This part handles the spreading var _non_deads = planets_without_type("dead", system); var _has_warboss = has_feature(eP_FEATURES.ORKWARBOSS); var _has_stronghold = has_feature(eP_FEATURES.ORKSTRONGHOLD); var _build_ships = false; - if (_has_stronghold){ - var _stronghold = get_features(eP_FEATURES.ORKSTRONGHOLD)[0]; + var _stronghold = []; + var _warboss = []; + var _orks = planet_forces[eFACTION.ORK]; + + if (_has_stronghold) { + _stronghold = get_features(eP_FEATURES.ORKSTRONGHOLD)[0]; } - if (_has_warboss){ - var _warboss = get_features(eP_FEATURES.ORKWARBOSS)[0]; + if (_has_warboss) { + _warboss = get_features(eP_FEATURES.ORKWARBOSS)[0]; _warboss.turns_static++; } var _roll_num = 100; - if (_has_stronghold){ + if (_has_stronghold) { _roll_num -= (_has_stronghold + 1) * 3; } var _ork_growth = roll_dice_chapter(1, 100, "high"); @@ -526,13 +544,12 @@ function PlanetData(planet, system) constructor { var _ork_growth_threshold = 13; - if (_has_warboss){ + if (_has_warboss) { _ork_growth_threshold *= 2; } - var _orks = planet_forces[eFACTION.ORK]; if ((current_owner == eFACTION.ORK) && (_orks < 5) && (planet_forces[eFACTION.HERETICS] == 0) && (player_forces <= 0 || !is_garrison_force)) { - if ((_orks> 0) && (_ork_growth <= _ork_growth_threshold)) { + if ((_orks > 0) && (_ork_growth <= _ork_growth_threshold)) { var _grow_orks = true; if (sabatours.garrison_force) { if (irandom(3) < 2) { @@ -540,197 +557,200 @@ function PlanetData(planet, system) constructor { _grow_orks = false; } } - if (_grow_orks){ - add_forces(eFACTION.ORK,1); + if (_grow_orks) { + add_forces(eFACTION.ORK, 1); } } } - if (array_length(_non_deads)>0 && _rando>40){ + if (array_length(_non_deads) > 0 && _rando > 40) { var _ork_spread_planet = array_random_element(_non_deads); - var _orks = planet_forces[eFACTION.ORK] var _ork_target = system.p_orks[_ork_spread_planet]; - var _spread_orks = (current_owner==eFACTION.ORK && ((pdf + guardsmen + planet_forces[8] + planet_forces[10]+planet_forces[1]) == 0 )); - if (_spread_orks){ + var _spread_orks = current_owner == eFACTION.ORK && ((pdf + guardsmen + planet_forces[8] + planet_forces[10] + planet_forces[1]) == 0); + if (_spread_orks) { // determine maximum Ork presence on the source planet var _ork_max = planet_forces[eFACTION.ORK]; - if (_ork_max<5 && _ork_target<2) then system.p_orks[_ork_spread_planet]++; - if (_orks>4 && _ork_target<3){ + if (_ork_max < 5 && _ork_target < 2) { + system.p_orks[_ork_spread_planet]++; + } + if (_orks > 4 && _ork_target < 3) { system.p_orks[_ork_spread_planet]++; - if (_ork_target<3){ + if (_ork_target < 3) { system.p_orks[_ork_spread_planet]++; add_forces(eFACTION.ORK, -1); } } - } } - contin=0; - _rando=roll_dice(1,100);// This part handles the ship building - if (population>0 && pdf==0 && guardsmen==0 && planet_forces[10]==0) and (planet_forces[eFACTION.TAU]==0){ - if (!large_population){ - set_population(population*0.97); - }else { + contin = 0; + _rando = roll_dice(1, 100); // This part handles the ship building + if ((population > 0 && pdf == 0 && guardsmen == 0 && planet_forces[10] == 0) && (planet_forces[eFACTION.TAU] == 0)) { + if (!large_population) { + set_population(population * 0.97); + } else { edit_population(-0.01); } - - }; - - var enemies_present=false; - with (system){ - for (var n=0;n=1) and ((p_pdf[plan]>0) or (p_guardsmen[plan]>0) or (p_traitors[plan]>0) or (p_tau[plan]>0)){ - enemies_present=true; + if ((planets >= 1) && ((p_pdf[plan] > 0) || (p_guardsmen[plan] > 0) || (p_traitors[plan] > 0) || (p_tau[plan] > 0))) { + enemies_present = true; } } } - if (_has_warboss && !_has_stronghold){ - _rando=roll_dice_chapter(1,100, "low"); - if (_rando<30){ + if (_has_warboss && !_has_stronghold) { + _rando = roll_dice_chapter(1, 100, "low"); + if (_rando < 30) { add_feature(eP_FEATURES.ORKSTRONGHOLD); } } else { - if (_has_stronghold){ + if (_has_stronghold) { growth = 0.01; - if (_has_warboss){ + if (_has_warboss) { growth *= 2; } - if (_stronghold.tier0) then _rando-=10;// Empire bonus, was 15 before - + if (obj_controller.known[eFACTION.ORK] > 0) { + _rando -= 10; + } // Empire bonus, was 15 before + // Check for industrial facilities - var fleet_buildable = ((planet_type!="Dead" && planet_type!="Lava") || _has_warboss || _has_stronghold); - if (fleet_buildable && planet_forces[eFACTION.ORK]>=4){// Used to not have Ice either + var fleet_buildable = (planet_type != "Dead" && planet_type != "Lava") || _has_warboss || _has_stronghold; + if (fleet_buildable && planet_forces[eFACTION.ORK] >= 4) { + // Used to not have Ice either - if (instance_exists(obj_p_fleet)){ - var ppp=instance_nearest(x,y,obj_p_fleet); - if (point_distance(x,y,ppp.x,ppp.y)<50) and (ppp.action=""){ + if (instance_exists(obj_p_fleet)) { + var ppp = instance_nearest(x, y, obj_p_fleet); + if ((point_distance(x, y, ppp.x, ppp.y) < 50) && (ppp.action == "")) { exit; - }; + } } - if (planet_type == "Forge"){ - _rando-=80; - } else if (planet_type == "Hive" || planet_type == "Temperate"){ - _rando-=30; - }else if (planet_type == "Agri"){ - _rando-=10; + if (planet_type == "Forge") { + _rando -= 80; + } else if (planet_type == "Hive" || planet_type == "Temperate") { + _rando -= 30; + } else if (planet_type == "Agri") { + _rando -= 10; } - var _ork_fleet = scr_orbiting_fleet(eFACTION.ORK, system); - if (_ork_fleet=="none"){ - if (_rando<=20){ - new_ork_fleet(x,y); + _ork_fleet = scr_orbiting_fleet(eFACTION.ORK, system); + if (_ork_fleet == noone) { + if (_rando <= 20) { + new_ork_fleet(x, y); } } else { - _build_ships = true; - - } - } + } + } } - if (_build_ships){ + if (_build_ships) { var _pdata = self; - with (_ork_fleet){ - // Increase ship number for this object? - var _rando=irandom(101); - if (obj_controller.known[eFACTION.ORK]>0) then _rando-=10; + with (_ork_fleet) { + // Increase ship number for this object? + _rando = irandom(101); + if (obj_controller.known[eFACTION.ORK] > 0) { + _rando -= 10; + } var _planet_type = _pdata.planet_type; - if (_planet_type=="Forge"){ - _rando-=20; - } else if (_planet_type=="Hive"){ - _rando-=10; - }else if (_planet_type=="Shrine" || _planet_type=="Temperate"){ - _rando-=5; + if (_planet_type == "Forge") { + _rando -= 20; + } else if (_planet_type == "Hive") { + _rando -= 10; + } else if (_planet_type == "Shrine" || _planet_type == "Temperate") { + _rando -= 5; } - if (_rando<=15){// was 25 - _rando=choose(1,1,1,1,1,1,1,2,2,2); - var _big_stronghold = false - if (_has_stronghold){ - if (_stronghold.tier>=2){ + if (_rando <= 15) { + // was 25 + _rando = choose(1, 1, 1, 1, 1, 1, 1, 2, 2, 2); + var _big_stronghold = false; + if (_has_stronghold) { + if (_stronghold.tier >= 2) { _big_stronghold = true; } } - if (_planet_type=="Forge" || _big_stronghold || _has_warboss){ - if (!irandom(10)){ + if (_planet_type == "Forge" || _big_stronghold || _has_warboss) { + if (!irandom(10)) { _rando = 3; } - }else if (_has_stronghold || _planet_type=="Hive"){ - if (!irandom(30)){ + } else if (_has_stronghold || _planet_type == "Hive") { + if (!irandom(30)) { _rando = 3; } } - if (capital_number<=0){ + if (capital_number <= 0) { _rando = 3; } - switch(_rando){ + switch (_rando) { case 3: - capital_number+=1; + capital_number += 1; break; case 2: - frigate_number+=1; + frigate_number += 1; break; case 1: - escort_number+=1; + escort_number += 1; break; - } } - var ii=round(standard_fleet_strength_calc()); - if (ii<=1) then ii=1; - image_index=ii; + var ii = round(standard_fleet_strength_calc()); + if (ii <= 1) { + ii = 1; + } + image_index = ii; //if big enough flee bugger off to new star - if (image_index>=5){ + if (image_index >= 5) { instance_deactivate_object(_pdata.system); - with(obj_star){ - if (is_dead_star()){ + with (obj_star) { + if (is_dead_star()) { instance_deactivate_object(id); } else { - if (owner == eFACTION.ORK || array_contains(p_owner, eFACTION.ORK)){ + if (owner == eFACTION.ORK || array_contains(p_owner, eFACTION.ORK)) { instance_deactivate_object(id); - } + } } } - var new_wagh_star = instance_nearest(x,y,obj_star); - if (instance_exists(new_wagh_star)){ - action_x=new_wagh_star.x; - action_y=new_wagh_star.y; + var new_wagh_star = instance_nearest(x, y, obj_star); + if (instance_exists(new_wagh_star)) { + action_x = new_wagh_star.x; + action_y = new_wagh_star.y; action = ""; set_fleet_movement(); } - } instance_activate_object(obj_star); } } - if (_has_warboss){ - _rando=roll_dice(1,100)+10; - var _ork_fleet = scr_orbiting_fleet(eFACTION.ORK, system); - if (_ork_fleet!="none" && _rando < _warboss.turns_static){ + if (_has_warboss) { + _rando = roll_dice(1, 100) + 10; + _ork_fleet = scr_orbiting_fleet(eFACTION.ORK, system); + if (_ork_fleet != noone && _rando < _warboss.turns_static) { _warboss.turns_static = 0; _ork_fleet.cargo_data.ork_warboss = _warboss; delete_feature(eP_FEATURES.ORKWARBOSS); - if (!_warboss.player_hidden || !irandom(5)){ - scr_alert("red","ork",$"{_warboss.name} departs {name()} as his waaagh gains momentum",0,0); + if (!_warboss.player_hidden || !irandom(5)) { + scr_alert("red", "ork", $"{_warboss.name} departs {name()} as his waaagh gains momentum", 0, 0); } } } - }; deamons = system.p_demons[planet]; @@ -745,7 +765,7 @@ function PlanetData(planet, system) constructor { corruption = system.p_heresy[planet]; }; - static set_corruption = function(value){ + static set_corruption = function(value) { system.p_heresy[planet] = value; corruption = system.p_heresy[planet]; }; @@ -759,7 +779,7 @@ function PlanetData(planet, system) constructor { population_influences = system.p_influence[planet]; raided_this_turn = system.p_raided[planet]; - // + governor = system.p_governor[planet]; problems = system.p_problem[planet]; @@ -884,7 +904,6 @@ function PlanetData(planet, system) constructor { scr_alert("green", "owner", $"{_requisition_spend} Requision spent on Ancient Ship repairs in materials and outfitting (outfitting {(_starship.funds_spent / _target_spend) * 100}%)", system.x, system.y); } if (_starship.funds_spent >= _target_spend && _starship.engineer_score >= 2000) { - // u2=tar; //TODO refactor into general new ship logic delete_feature(eP_FEATURES.STARSHIP); @@ -1284,7 +1303,7 @@ function PlanetData(planet, system) constructor { "Moderate", "Heavy", "Major", - "Extreme" + "Extreme", ]; var planet_forti = $"Defenses: {forti_string[fortification_level]}"; @@ -1337,7 +1356,7 @@ function PlanetData(planet, system) constructor { "Chaos", "Traitors", "Daemons", - "Necrons" + "Necrons", ]; var faction_ids = [ "p_sisters", @@ -1347,7 +1366,7 @@ function PlanetData(planet, system) constructor { "p_traitors", "p_chaos", "p_demons", - "p_necrons" + "p_necrons", ]; var blurbs = [ "Minima", @@ -1355,7 +1374,7 @@ function PlanetData(planet, system) constructor { "Moderatus", "Significus", "Enormicus", - "Extremis" + "Extremis", ]; for (var t = 0; t < array_length(faction_names); t++) { @@ -1383,21 +1402,19 @@ function PlanetData(planet, system) constructor { draw_text(xx + 349, yy + 346, string_hash_to_newline(string(presence_text))); var to_show = 0, temp9 = ""; - t = -1; var fit = array_create(11, ""); - var planet_displays = [], i; - var feat_count, _cur_feature; + var planet_displays = []; var feat_count = array_length(features); var upgrade_count = array_length(upgrades); var size = [ "", "Small", "", - "Large" + "Large", ]; if (feat_count > 0) { - for (i = 0; i < feat_count; i++) { + for (var i = 0; i < feat_count; i++) { var cur_feature = features[i]; try { if (cur_feature.planet_display != 0) { @@ -1425,7 +1442,7 @@ function PlanetData(planet, system) constructor { } } if (upgrade_count > 0) { - for (i = 0; i < upgrade_count; i++) { + for (var i = 0; i < upgrade_count; i++) { var _upgrade = upgrades[i]; if (_upgrade.f_type == eP_FEATURES.SECRET_BASE) { if (_upgrade.forge > 0) { @@ -1437,7 +1454,7 @@ function PlanetData(planet, system) constructor { } } - for (i = 0; i < array_length(problems); i++) { + for (var i = 0; i < array_length(problems); i++) { if (problems[i] == "") { continue; } @@ -1454,9 +1471,8 @@ function PlanetData(planet, system) constructor { } } - t = 0; var button_size, y_move = 0, button_colour; - for (i = 0; i < array_length(planet_displays); i++) { + for (var i = 0; i < array_length(planet_displays); i++) { button_colour = c_green; if (planet_displays[i][0] == "????") { button_colour = c_red; @@ -1472,30 +1488,9 @@ function PlanetData(planet, system) constructor { } } if (planet > 0) { - var current_planet = planet; + current_planet = planet; draw_set_color(c_black); draw_set_halign(fa_center); - - /*if (obj_controller.recruiting_worlds_bought>0) and (system.p_owner[planet]<=5) and (obj_controller.faction_status[system.p_owner[planet]]!="War"){ - if (string_count("Recr",system.p_feature[planet])=0){ - button4="+Recruiting"; - } - }*/ - - /*if (origional_owner=1){ - if (mouse_x>=xx+363) and (mouse_y>=yy+194) and (mouse_x0){ - var wid,hei,tex;draw_set_halign(fa_left); - tex=string(system.p_lasers[current_planet])+" Defense Laser, "+string(system.p_defenses[current_planet])+" Weapon Emplacements, "+string(system.p_silo[current_planet])+" Missile Silo"; - hei=string_height_ext(tex,-1,200)+4;wid=string_width_ext(tex,-1,200)+4; - draw_set_color(c_black); - draw_rectangle(xx+363,yy+210,xx+363+wid,yy+210+hei,0); - draw_set_color(CM_GREEN_COLOR); - draw_rectangle(xx+363,yy+210,xx+363+wid,yy+210+hei,1); - draw_text_ext(xx+365,yy+212,tex,-1,200); - } - } - }*/ } }; @@ -1591,17 +1586,17 @@ function PlanetData(planet, system) constructor { instance_destroy(obj_star_select); }; - static set_star_select_planet = function(){ + static set_star_select_planet = function() { obj_star_select.garrison = garrisons; system.garrison = garrisons.garrison_force; obj_star_select.feature = ""; buttons_selected = false; garrisons.update(); - if (garrisons.garrison_force){ + if (garrisons.garrison_force) { garrisons.find_leader(); - garrisons.garrison_disposition_change(true); - } - } + garrisons.garrison_disposition_change(true); + } + }; static planet_selection_logic = function() { var planet_is_allies = scr_is_planet_owned_by_allies(system, planet); @@ -1684,6 +1679,17 @@ function PlanetData(planet, system) constructor { _col_button.draw(array_length(obj_star_select.potential_donors)); + // Recruit Guard sits directly below Request Colonists (same column, one + // row down). Player worlds only, since you can only mobilise your own PDF. + // Clicking is gated on the PDF holding at least 1000 (here) and on having + // the 50 requisition (the PurchaseButton's own check), so a click can never + // spend the 50 without actually raising the 1000. + if (current_owner == eFACTION.PLAYER) { + var _guard_button = obj_star_select.guard_recruit_button; + _guard_button.update({x1: xx + 35, y1: _half_way + spacing_y, allow_click: true}); + _guard_button.draw(pdf >= 1000); + } + var _recruit_button = obj_star_select.recruiting_button; _recruit_button.update({x1: xx + (spacing_x * 2) + 15, y1: _half_way, allow_click: true}); @@ -1723,8 +1729,7 @@ function PlanetData(planet, system) constructor { } }; - static end_of_turn_population_influence_and_enemy_growth = function(){ - + static end_of_turn_population_influence_and_enemy_growth = function() { sabotage_force = sabatours.garrison_force; total_garrison = garrisons.total_garrison; is_garrison_force = garrisons.garrison_force; @@ -1735,8 +1740,7 @@ function PlanetData(planet, system) constructor { // increasing necrons if (array_length(features) != 0) { - var has_awake_tomb = false, - nfleet = 0; + var has_awake_tomb = false, nfleet = 0; if (awake_tomb_world(features) == 1) { has_awake_tomb = true; } @@ -1755,7 +1759,7 @@ function PlanetData(planet, system) constructor { if (has_awake_tomb) { // Necron fleets, woooo //necrons kill populatin - if ((population > 0) && (player_forces + pdf + guardsmen + planet_forces[eFACTION.TYRANIDS] == 0)) { + if ((population > 0) && (player_forces + pdf + guardsmen + planet_forces[eFACTION.TYRANIDS] == 0)) { set_population(population * 0.75); if ((large_population == 0) && (population <= 5000)) { set_population(0); @@ -1788,7 +1792,7 @@ function PlanetData(planet, system) constructor { system.present_fleet[eFACTION.NECRONS] += 1; } var enemy_fleets = 0; - with(necron_fleet) { + with (necron_fleet) { if (owner == eFACTION.NECRONS) { var ii = 0; ii += capital_number; @@ -1796,7 +1800,7 @@ function PlanetData(planet, system) constructor { ii += round((escort_number / 4)); if (ii <= 1) { ii = 1; - } // image_index=max(8,round(ii)); + } if ((ii >= 7) && (capital_number > 1)) { for (var fleet_n = 1; fleet_n <= 10; fleet_n++) { @@ -1808,11 +1812,9 @@ function PlanetData(planet, system) constructor { } } if (enemy_fleets > 0) { - var necron_fleet2; - necron_fleet2 = instance_create(x, y, obj_en_fleet); + var necron_fleet2 = instance_create(x, y, obj_en_fleet); necron_fleet2.owner = eFACTION.NECRONS; necron_fleet2.sprite_index = spr_fleet_necron; - // necron_fleet2.image_index=0; necron_fleet.image_speed = 0; necron_fleet2.capital_number = 1; necron_fleet2.frigate_number = round(necron_fleet.frigate_number / 2); @@ -1826,8 +1828,8 @@ function PlanetData(planet, system) constructor { var _found_near_planet = false; var _distance = 0; var _start_star = system.id; - with(obj_star) { - if (id == _start_star){ + with (obj_star) { + if (id == _start_star) { continue; } if (present_fleet[eFACTION.NECRONS] > 0) { @@ -1845,13 +1847,13 @@ function PlanetData(planet, system) constructor { } } - if (!_valid_owners){ + if (!_valid_owners) { continue; } var _point_dist = object_distance(_start_star, self); - if (_distance == 0 || _point_dist < _distance){ + if (_distance == 0 || _point_dist < _distance) { _nearest_planet = self.id; _found_near_planet = true; _distance = _point_dist; @@ -1863,7 +1865,7 @@ function PlanetData(planet, system) constructor { necron_fleet2.action_x = _nearest_planet.x; necron_fleet2.action_y = _nearest_planet.y; - with (necron_fleet2){ + with (necron_fleet2) { set_fleet_movement(); } } @@ -1876,37 +1878,32 @@ function PlanetData(planet, system) constructor { end_turn_genestealer_cults(); - // Spread influence on controlled sector if ((planet_type != "Space Hulk") && (planet_type != "Dead")) { - if ((corruption < 70 && current_owner == 10)) { - if (current_owner == 10){ + if (corruption < 70 && current_owner == 10) { + if (current_owner == 10) { alter_corruption(2); } - } - if (current_owner == eFACTION.TAU && population_influences[eFACTION.TYRANIDS]<70){ - var _influ_chance = roll_dice(1,100); - if (_influ_chance <= 5 && population_influences[eFACTION.TYRANIDS]>=20){ + if (current_owner == eFACTION.TAU && population_influences[eFACTION.TYRANIDS] < 70) { + var _influ_chance = roll_dice(1, 100); + if (_influ_chance <= 5 && population_influences[eFACTION.TYRANIDS] >= 20) { alter_influence(eFACTION.TAU, 1); } } - if (planet_type == "Daemon"){ - if (pdf > 0) { - pdf = 0; + if (planet_type == "Daemon") { + if (pdf > 0) { + pdf = 0; } if (guardsmen > 0) { guardsmen = 0; } } - } - - } - + }; - static end_turn_genestealer_cults = function(){ + static end_turn_genestealer_cults = function() { // Genestealer cults grow in number if (has_feature(eP_FEATURES.GENE_STEALER_CULT)) { var cult = get_features(eP_FEATURES.GENE_STEALER_CULT)[0]; @@ -1919,7 +1916,7 @@ function PlanetData(planet, system) constructor { var find_cult_chance = irandom(50); var alert_text = $"A hidden Genestealer Cult on {name()} Has suddenly burst forth from hiding!"; if (planet_garrison.garrison_force) { - var alert_text = $"A hidden Genestealer Cult on {name()} Has been discovered by marine garrisons!"; + alert_text = $"A hidden Genestealer Cult on {name()} Has been discovered by marine garrisons!"; find_cult_chance -= 25; } if (find_cult_chance < 1) { @@ -1927,7 +1924,7 @@ function PlanetData(planet, system) constructor { scr_popup("System Lost", alert_text, "Genestealer Cult", ""); set_new_owner(eFACTION.TYRANIDS); scr_event_log("red", $"A hidden Genestealer Cult on {name()} has Started a revolt.", system.name); - edit_forces(eFACTION.TYRANIDS,1); + edit_forces(eFACTION.TYRANIDS, 1); } } } @@ -1960,15 +1957,13 @@ function PlanetData(planet, system) constructor { add_feature(eP_FEATURES.GENE_STEALER_CULT); } } - } + }; - static end_turn_heretics_and_corruption_growth = function(){ + static end_turn_heretics_and_corruption_growth = function() { // traitors cults - var notixt; - var is_ork; - notixt = false; + var notixt = false; - var _rando = roll_dice(1,100); + var _rando = roll_dice(1, 100); if ((current_owner == eFACTION.CHAOS) && (corruption < 80)) { alter_corruption(1); @@ -1976,22 +1971,16 @@ function PlanetData(planet, system) constructor { if ((current_owner != eFACTION.CHAOS) && (current_owner != eFACTION.HERETICS) && (current_owner != eFACTION.ELDAR) && (planet_type != "Dead") && (planet_type != "Craftworld")) { success = false; - is_ork = current_owner == eFACTION.ORK; - if (!is_ork) { + if (!current_owner == eFACTION.ORK) { //made a linear function for this while here...now the minimum for the roll is a bit higher, but var score_to_beat = (3 / 4) * (corruption + secret_corruption) - 27.5; - - //if (corruption+secret_corruption>=25) and (_rando<=3) then success=true; - //if (corruption+secret_corruption>=50) and (_rando<=10) then success=true; - //if (corruption+secret_corruption>=70) and (_rando<=25) then success=true; - //if (corruption+secret_corruption>=90) and (_rando<=40) then success=true; if (_rando < score_to_beat) { success = true; } } - if (success && (pdf == 0) && (guardsmen == 0) && (planet_forces[eFACTION.TAU] == 0) && (planet_forces[eFACTION.ORK] == 0)) { + if (success && (pdf == 0) && (guardsmen == 0) && (planet_forces[eFACTION.TAU] == 0) && (planet_forces[eFACTION.ORK] == 0)) { set_new_owner(eFACTION.HERETICS); scr_alert("red", "owner", $"{name()} has fallen to heretics!", x, y); @@ -1999,7 +1988,7 @@ function PlanetData(planet, system) constructor { //visited variable check whether the star has been visited or not 1 for true 0 for false if (planet_type == "Forge") { add_disposition(-10); - // 10 disposition decreases for the respective planet + // 10 disposition decreases for the respective planet obj_controller.disposition[3] -= 3; // 10 disposition decrease for the toaster Fetishest since they aren't that numerous } else if (has_feature(eP_FEATURES.SORORITAS_CATHEDRAL) || (planet_type == "Shrine")) { add_disposition(-4); // similarly 10 disposition decrease, note those nurses are a bit pissy and @@ -2012,8 +2001,7 @@ function PlanetData(planet, system) constructor { } if (success && (planet_type != "Space Hulk")) { - _rando = roll_dice(1,100); - // // // obj_controller.x=self.x;obj_controller.y=self.y; + _rando = roll_dice(1, 100); if (is_garrison_force) { _rando -= total_garrison; } @@ -2032,19 +2020,19 @@ function PlanetData(planet, system) constructor { } if (garrison_mod > 0) { - var lost = floor(pdf * garrison_mod); + var lost = floor(pdf * garrison_mod); - if (pdf <= 500) { - lost = pdf ; + if (pdf <= 500) { + lost = pdf; edit_forces(eFACTION.HERETICS, 1); } edit_pdf(-lost); if (planet_forces[eFACTION.HERETICS] == 0) { - if (pdf > 0) { + if (pdf > 0) { tixt = $"{scr_display_number(lost)} PDF killed in a rebellion on {name()}."; - } else if (pdf == 0) { + } else if (pdf == 0) { tixt = $"Heretic cults have appeared in {name()}."; } @@ -2074,17 +2062,17 @@ function PlanetData(planet, system) constructor { } else { traitor_mod = 3; } - edit_forces(eFACTION.HERETICS,traitor_mod); + edit_forces(eFACTION.HERETICS, traitor_mod); tixt = $"Heretic cults have spread around {name()}."; } // Major uprising // major and huge uprisings are impossible as long as a garrisons of at least 10 marines is present if ((_rando >= 91) && (_rando < 100) && (planet_forces[eFACTION.HERETICS] < 4)) { notixt = true; - edit_forces(eFACTION.HERETICS,4); + edit_forces(eFACTION.HERETICS, 4); if ((obj_controller.faction_defeated[10] == 0) && (obj_controller.faction_gender[10] == 1)) { - edit_forces(eFACTION.HERETICS,5); + edit_forces(eFACTION.HERETICS, 5); } var n_name = name(); @@ -2094,11 +2082,11 @@ function PlanetData(planet, system) constructor { } // Huge uprising if ((_rando >= 100) && (planet_forces[eFACTION.HERETICS] < 5)) { - edit_forces(eFACTION.HERETICS,6); - set_new_owner(eFACTION.HERETICS) + edit_forces(eFACTION.HERETICS, 6); + set_new_owner(eFACTION.HERETICS); add_feature(eP_FEATURES.DAEMONIC_INCURSION); - set_corruption(corruption < 80 ? 80 : 95) + set_corruption(corruption < 80 ? 80 : 95); tixt = $"Daemonic incursion on {name()}!"; } // Oh god what @@ -2107,17 +2095,15 @@ function PlanetData(planet, system) constructor { scr_alert("red", "owner", tixt, x, y); scr_event_log("purple", tixt, system.name); } - // if (planet_forces[eFACTION.HERETICS]>2){obj_controller.x=self.x;obj_controller.y=self.y;} } // End traitors cult } + }; - } - - static create_alert = function(){ + static create_alert = function() { return instance_create(system.x + 16, system.y - 24, obj_star_event); - } + }; - static init_war_of_succession = function(){ + static init_war_of_succession = function() { add_feature(eP_FEATURES.SUCCESSION_WAR); add_problem("succession", irandom(6) + 4); set_player_disposition(-5000); @@ -2127,12 +2113,10 @@ function PlanetData(planet, system) constructor { _star_alert.image_alpha = 1; _star_alert.image_speed = 1; _star_alert.col = "red"; - scr_event_log("red", $"War of Succession on {name()}"); - } - - - static init_fallen_marines = function(){ + scr_event_log("red", $"War of Succession on {name()}"); + }; + static init_fallen_marines = function() { var _eta = scr_mission_eta(system.x, system.y, 1); LOGGER.info($"Fallen: found star {name()} as candidate"); @@ -2151,7 +2135,6 @@ function PlanetData(planet, system) constructor { var star_alert = create_alert(); star_alert.image_alpha = 1; star_alert.image_speed = 1; - star_alert.col = "purple"; - } - -} \ No newline at end of file + star_alert.col = "purple"; + }; +} diff --git a/scripts/scr_Table/scr_Table.gml b/scripts/scr_Table/scr_Table.gml index f300597cff..e3d91a7817 100644 --- a/scripts/scr_Table/scr_Table.gml +++ b/scripts/scr_Table/scr_Table.gml @@ -34,7 +34,7 @@ function Table(data) constructor { headings[i] = new ReactiveString(_heading, 0, 0, {scale_text: true}); } - var _heading = headings[i]; + _heading = headings[i]; if (i < array_length(set_column_widths) && set_column_widths[i] > 0) { array_push(column_widths, set_column_widths[i]); @@ -65,7 +65,6 @@ function Table(data) constructor { } if (struct_exists(_row, "hover")) { - //LOGGER.debug($"click : {struct_exists(_row,"click_left")}"); _row.hover(); } diff --git a/scripts/scr_UnitGroup/scr_UnitGroup.gml b/scripts/scr_UnitGroup/scr_UnitGroup.gml index 08a51d7cd2..35e8259574 100644 --- a/scripts/scr_UnitGroup/scr_UnitGroup.gml +++ b/scripts/scr_UnitGroup/scr_UnitGroup.gml @@ -279,13 +279,14 @@ function UnitGroup(units) constructor { /*and ((squad_fulfilment[$ obj_ini.role[100][8]] > 4)or (squad_fulfilment[$ obj_ini.role[100][10]] > 4) or (squad_fulfilment[$ obj_ini.role[100][9]] > 4)or (squad_fulfilment[$ obj_ini.role[100][3]] > 4) )*/ var _members = squad.get_members(true); + var _exp_unit = 0; if (!bool(_members.number())) { return [false, squad.uid]; } for (var s = 0; s < 2; s++) { var _sgt_type = sgt_types[s]; if (struct_exists(squad_fulfilment, _sgt_type) && (!sergeant_found)) { - var _exp_unit = _members.highest_exp(); + _exp_unit = _members.highest_exp(); squad_fulfilment[$ _sgt_type]++; } diff --git a/scripts/scr_add_artifact/scr_add_artifact.gml b/scripts/scr_add_artifact/scr_add_artifact.gml index 9cf59a26a5..563f1486b7 100644 --- a/scripts/scr_add_artifact/scr_add_artifact.gml +++ b/scripts/scr_add_artifact/scr_add_artifact.gml @@ -1,5 +1,5 @@ function find_open_artifact_slot() { - var i = 0, last_artifact = -1; + var last_artifact = -1; for (var i = 0; i < array_length(obj_ini.artifact); i++) { if (last_artifact == -1) { if (obj_ini.artifact[i] == "") { @@ -215,7 +215,6 @@ function scr_add_artifact(artifact_type = "random", artifact_tags = "", is_ident } var big = choose(1, 2); - // if (big=1 || artifact_tags="minor") then t5=""; if (artifact_tags == "minor") { t4 = ""; t5 = ""; @@ -241,7 +240,6 @@ function scr_add_artifact(artifact_type = "random", artifact_tags = "", is_ident array_push(tags, "daemonic"); array_push(tags, "chaos_gift"); } - // show_message(string(t3)); if (artifact_location == "") { if (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD) { @@ -255,8 +253,6 @@ function scr_add_artifact(artifact_type = "random", artifact_tags = "", is_ident obj_ini.artifact[last_artifact] = base_type_detail; obj_ini.artifact_tags[last_artifact] = tags; - // show_message(string(obj_ini.artifact_tags[last_artifact])); - obj_ini.artifact_identified[last_artifact] = is_identified; obj_ini.artifact_condition[last_artifact] = 100; obj_ini.artifact_loc[last_artifact] = artifact_location; @@ -539,11 +535,10 @@ function ArtifactStruct(Index) constructor { var _b_type = determine_base_type(); var _bearer = false; var _bearer_found = false; - var _unit; if (_b_type == "weapon") { for (var co = 0; co < obj_ini.companies; co++) { for (var i = 0; i < array_length(obj_ini.role[co]); i++) { - _unit = fetch_unit([co, i]); + var _unit = fetch_unit([co, i]); if (_unit.weapon_one(true) == index) { _unit.update_weapon_one("", false, true); _bearer_found = true; @@ -561,14 +556,15 @@ function ArtifactStruct(Index) constructor { } } else { var _find_function = ""; + var _update_function = ""; if (_b_type == "gear") { - var _update_function = "update_gear"; + _update_function = "update_gear"; _find_function = "gear"; } else if (_b_type == "armour") { - var _update_function = "update_armour"; + _update_function = "update_armour"; _find_function = "armour"; } else if (_b_type == "mobility") { - var _update_function = "update_mobility_item"; + _update_function = "update_mobility_item"; _find_function = "mobility_item"; } if (_find_function != "") { @@ -868,12 +864,6 @@ function delete_artifact(index) { artifact_equipped[index] = false; artifact_struct[index] = new ArtifactStruct(index); } - /*for (var i=index;i 0) { array_push(ships, capital_num[i]); @@ -32,7 +26,7 @@ function scr_add_corruption(is_fleet, modifier_type) { if (obj_ini.name[co][i] == "") { continue; } - unit = fetch_unit([co, i]); + var unit = fetch_unit([co, i]); if (array_contains(ships, unit.ship_location)) { if (modifier_type == "1d3") { unit.edit_corruption(choose(1, 2, 3)); diff --git a/scripts/scr_add_man/scr_add_man.gml b/scripts/scr_add_man/scr_add_man.gml index d8281e1c6f..a5e241b893 100644 --- a/scripts/scr_add_man/scr_add_man.gml +++ b/scripts/scr_add_man/scr_add_man.gml @@ -10,7 +10,11 @@ function scr_add_man(man_role, target_company, spawn_exp, spawn_name, corruption "Sister Hospitaler", "Ranger", "Ork Sniper", - "Flash Git" + "Flash Git", + "Guardsman", + "Guard Squad", + "Guard Sergeant", + "Heavy Weapons Team" ]; var _gear = {}; var _company_slot = 0; @@ -26,6 +30,26 @@ function scr_add_man(man_role, target_company, spawn_exp, spawn_name, corruption // TODO: Implement logic for Auxiliary Soldier (Race 2.5, Renegade stats) switch (man_role) { + case "Guardsman": + spawn_exp = 10; + obj_ini.race[target_company][_company_slot] = eFACTION.IMPERIUM; + _unit = new TTRPG_stats("imperial_guard", target_company, _company_slot, "guardsman"); + break; + case "Guard Squad": + spawn_exp = 10; + obj_ini.race[target_company][_company_slot] = eFACTION.IMPERIUM; + _unit = new TTRPG_stats("imperial_guard", target_company, _company_slot, "guard_squad"); + break; + case "Guard Sergeant": + spawn_exp = 10; + obj_ini.race[target_company][_company_slot] = eFACTION.IMPERIUM; + _unit = new TTRPG_stats("imperial_guard", target_company, _company_slot, "guard_sergeant"); + break; + case "Heavy Weapons Team": + spawn_exp = 10; + obj_ini.race[target_company][_company_slot] = eFACTION.IMPERIUM; + _unit = new TTRPG_stats("imperial_guard", target_company, _company_slot, "heavy_weapons_team"); + break; case "Skitarii": spawn_exp = 10; obj_ini.race[target_company][_company_slot] = 3; @@ -101,6 +125,22 @@ function scr_add_man(man_role, target_company, spawn_exp, spawn_name, corruption case "Sister Hospitaler": obj_ini.name[target_company][_company_slot] = global.name_generator.GenerateFromSet("imperial_female"); break; + + case "Guardsman": + obj_ini.name[target_company][_company_slot] = global.name_generator.GenerateFromSet("imperial_male"); + break; + + case "Guard Squad": + obj_ini.name[target_company][_company_slot] = global.name_generator.GenerateFromSet("imperial_male"); + break; + + case "Guard Sergeant": + obj_ini.name[target_company][_company_slot] = global.name_generator.GenerateFromSet("imperial_male"); + break; + + case "Heavy Weapons Team": + obj_ini.name[target_company][_company_slot] = global.name_generator.GenerateFromSet("imperial_male"); + break; } if (!array_contains(non_marine_roles, man_role)) { @@ -125,8 +165,14 @@ function scr_add_man(man_role, target_company, spawn_exp, spawn_name, corruption _unit.add_exp(spawn_exp); _unit.allocate_unit_to_fresh_spawn(home_spot); _unit.update_role(man_role); - with (obj_ini) { - scr_company_order(target_company); + // Re-sorting the whole company after every spawn is O(n) per call, which makes a + // bulk spawn O(n^2) and freezes at high counts. Callers doing a batch can pass + // other_data.skip_company_order and run scr_company_order once when finished. + var _skip_order = is_struct(other_data) && variable_struct_exists(other_data, "skip_company_order") && other_data.skip_company_order; + if (!_skip_order) { + with (obj_ini) { + scr_company_order(target_company); + } } _unit.update_health(_unit.max_health()); return _unit; diff --git a/scripts/scr_add_vehicle/scr_add_vehicle.gml b/scripts/scr_add_vehicle/scr_add_vehicle.gml index f0cd942878..77cc7b5e71 100644 --- a/scripts/scr_add_vehicle/scr_add_vehicle.gml +++ b/scripts/scr_add_vehicle/scr_add_vehicle.gml @@ -1,8 +1,17 @@ +/// @function scr_add_vehicle(vehicle_type, target_company, otherdata, weapon1, weapon2, weapon3, upgrade, accessory) +/// @description +/// @param {String} vehicle_type +/// @param {Real} target_company +/// @param {Struct} otherdata +/// @param {String} weapon1 +/// @param {String} weapon2 +/// @param {String} weapon3 +/// @param {String} upgrade +/// @param {String} accessory function scr_add_vehicle(vehicle_type, target_company, otherdata = {}, weapon1 = "standard", weapon2 = "standard", weapon3 = "standard", upgrade = "standard", accessory = "standard") { try { // That should be sufficient to add stuff in a highly modifiable fashion - var i = 0; var e = 0; var good = 0; var wep1 = ""; @@ -32,7 +41,8 @@ function scr_add_vehicle(vehicle_type, target_company, otherdata = {}, weapon1 = if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD) { // Need a more elaborate ship_carrying += here for the different types of units - var first = -1, backup = -1, i = 0; + var first = -1; + var backup = -1; for (var i = 0; i < array_length(obj_ini.ship_class); i++) { if ((obj_ini.ship_class[i] == "Battle Barge") && (first == -1) && (obj_ini.ship_capacity[i] > obj_ini.ship_carrying[i])) { first = i; @@ -123,6 +133,22 @@ function scr_add_vehicle(vehicle_type, target_company, otherdata = {}, weapon1 = obj_ini.veh_wep2[target_company][good] = ""; obj_ini.veh_upgrade[target_company][good] = ""; } + if (vehicle_type == "Chimera") { + obj_ini.veh_wep1[target_company][good] = "Multi-Laser"; + obj_ini.veh_wep2[target_company][good] = "Heavy Bolter"; + } + if (vehicle_type == "Leman Russ") { + // Battle Cannon turret (anti-armour and anti-infantry blast) with a hull + // Heavy Bolter, the standard Astra Militarum main battle tank loadout. + obj_ini.veh_wep1[target_company][good] = "Battle Cannon"; + obj_ini.veh_wep2[target_company][good] = "Heavy Bolter"; + } + if (vehicle_type == "Basilisk") { + // Earthshaker Cannon (long-range artillery blast) with a Storm Bolter for + // close defence, mirroring the enemy Basilisk loadout. + obj_ini.veh_wep1[target_company][good] = "Earthshaker Cannon"; + obj_ini.veh_wep2[target_company][good] = "Storm Bolter"; + } } obj_ini.veh_hp[target_company][good] = 100; @@ -135,6 +161,10 @@ function scr_add_vehicle(vehicle_type, target_company, otherdata = {}, weapon1 = } } +/// @function destroy_vehicle(co, num) +/// @description +/// @param {Real} co +/// @param {Real} num function destroy_vehicle(co, num) { try { obj_ini.veh_race[co][num] = 0; diff --git a/scripts/scr_after_combat/scr_after_combat.gml b/scripts/scr_after_combat/scr_after_combat.gml index b4668a3b90..cf4b78b28b 100644 --- a/scripts/scr_after_combat/scr_after_combat.gml +++ b/scripts/scr_after_combat/scr_after_combat.gml @@ -70,6 +70,8 @@ function add_vehicles_to_recovery() { "Whirlwind": 4, "Rhino": 3, "Land Speeder": 3, + "Leman Russ": 3, + "Chimera": 2, "Bike": 1, }; @@ -240,7 +242,7 @@ function after_battle_part1() { marine_dead[i] = 1; marine_hp[i] = -50; } - if ((veh_type[i] != "") && (obj_ncombat.defeat == 1)) { + if ((i < array_length(veh_type)) && (veh_type[i] != "") && (obj_ncombat.defeat == 1)) { veh_dead[i] = 1; veh_hp[i] = -200; } diff --git a/scripts/scr_apothecary_ground/scr_apothecary_ground.gml b/scripts/scr_apothecary_ground/scr_apothecary_ground.gml index 2792949cc0..2bb1db36e4 100644 --- a/scripts/scr_apothecary_ground/scr_apothecary_ground.gml +++ b/scripts/scr_apothecary_ground/scr_apothecary_ground.gml @@ -24,8 +24,8 @@ function calculate_full_chapter_spread() { var _apoth_spread = {}; var _unit_spread = {}; for (var company = 0; company < 11; company++) { - var _marine_len = array_length(obj_ini.name[company]); - var _veh_len = array_length(obj_ini.veh_hp[company]); + var _marine_len = array_length(obj_ini.name[company]) - 1; + var _veh_len = array_length(obj_ini.veh_hp[company]) - 1; var _company_length = max(_marine_len, _veh_len); for (var v = 0; v < _company_length; v++) { @@ -174,7 +174,7 @@ function system_point_data_spawn() { /// @self Struct.SpecialistPointHandler function process_specialist_points() { - var _spreads = chapter_spread(); + var _spreads = calculate_full_chapter_spread(); var _tech_spread = _spreads[0]; var _apoth_spread = _spreads[1]; var _unit_spread = _spreads[2]; @@ -201,75 +201,6 @@ function process_specialist_points() { array_push(_unit_spread[$ name], self); } - // --- Step 2: Process Locations --- - for (var i = 0; i < _loc_count; i++) { - var _cur_loc = _locations[i]; - var _loc_slots = _unit_spread[$ _cur_loc]; - var _star_inst = (array_length(_loc_slots) > STAR_INSTANCE_INDEX) ? _loc_slots[STAR_INSTANCE_INDEX] : pointer_null; - - if (_star_inst != pointer_null) { - point_breakdown.systems[$ _star_inst.name] = system_point_data_spawn(); - } - - for (var _p = 0; _p < PLANET_SLOT_COUNT; _p++) { - var _cur_units = _loc_slots[_p]; - var _unit_count = array_length(_cur_units); - if (_unit_count == 0) { - continue; - } - - var _cur_apoths = _apoth_spread[$ _cur_loc][_p]; - var _cur_techs = _tech_spread[$ _cur_loc][_p]; - - var _pool = { - heal: 0, - forge: 0, - }; - - // Calculate Generation - for (var a = 0, _al = array_length(_cur_apoths); a < _al; a++) { - _pool.heal += _cur_apoths[a].apothecary_point_generation(turn_end)[0]; - } - for (var t = 0, _tl = array_length(_cur_techs); t < _tl; t++) { - _pool.forge += _cur_techs[t].forge_point_generation(turn_end)[0]; - } - - var _initial_heal = _pool.heal; - var _initial_forge = _pool.forge; - - // Process Maintenance and Repairs/Heal - for (var u = 0; u < _unit_count; u++) { - var _unit = _cur_units[u]; - if (is_array(_unit)) { - _process_vehicle_maintenance(_unit, _pool); - } else if (is_struct(_unit)) { - _process_marine_maintenance(_unit, _pool); - } - } - - // Record Stats - var _stats = { - heal_points: _initial_heal, - forge_points: _initial_forge, - heal_points_use: _initial_heal - _pool.heal, - forge_points_use: _initial_forge - _pool.forge, - }; - - if (_star_inst != pointer_null) { - point_breakdown.systems[$ _star_inst.name][_p] = _stats; - - // Planet specific logic (Orbit is 0, Planets are 1-4) - if (turn_end && _p > 0 && array_length(_star_inst.p_feature[_p]) > 0) { - var _planet_data = _star_inst.get_planet_data(_p); - _planet_data.recover_starship(_cur_techs); - _planet_data.planet_training(_pool.heal); - } - } else if (_p == 0 && string_pos("ref instance", _cur_loc) > 0) { - _handle_instance_point_recording(_cur_loc, _stats); - } - } - } - /// @param {Array} _unit /// @param {Struct} _pool static _process_vehicle_maintenance = function(_unit, _pool) { @@ -355,4 +286,73 @@ function process_specialist_points() { LOGGER.error($"Failed to parse instance ID from location string: {_loc_str} | Error: {_ex.message}"); } }; + + // --- Step 2: Process Locations --- + for (var i = 0; i < _loc_count; i++) { + var _cur_loc = _locations[i]; + var _loc_slots = _unit_spread[$ _cur_loc]; + var _star_inst = (array_length(_loc_slots) > STAR_INSTANCE_INDEX) ? _loc_slots[STAR_INSTANCE_INDEX] : pointer_null; + + if (_star_inst != pointer_null) { + point_breakdown.systems[$ _star_inst.name] = system_point_data_spawn(); + } + + for (var _p = 0; _p < PLANET_SLOT_COUNT; _p++) { + var _cur_units = _loc_slots[_p]; + var _unit_count = array_length(_cur_units); + if (_unit_count == 0) { + continue; + } + + var _cur_apoths = _apoth_spread[$ _cur_loc][_p]; + var _cur_techs = _tech_spread[$ _cur_loc][_p]; + + var _pool = { + heal: 0, + forge: 0, + }; + + // Calculate Generation + for (var a = 0, _al = array_length(_cur_apoths); a < _al; a++) { + _pool.heal += _cur_apoths[a].apothecary_point_generation(turn_end)[0]; + } + for (var t = 0, _tl = array_length(_cur_techs); t < _tl; t++) { + _pool.forge += _cur_techs[t].forge_point_generation(turn_end)[0]; + } + + var _initial_heal = _pool.heal; + var _initial_forge = _pool.forge; + + // Process Maintenance and Repairs/Heal + for (var u = 0; u < _unit_count; u++) { + var _unit = _cur_units[u]; + if (is_array(_unit)) { + _process_vehicle_maintenance(_unit, _pool); + } else if (is_struct(_unit)) { + _process_marine_maintenance(_unit, _pool); + } + } + + // Record Stats + var _stats = { + heal_points: _initial_heal, + forge_points: _initial_forge, + heal_points_use: _initial_heal - _pool.heal, + forge_points_use: _initial_forge - _pool.forge, + }; + + if (_star_inst != pointer_null) { + point_breakdown.systems[$ _star_inst.name][_p] = _stats; + + // Planet specific logic (Orbit is 0, Planets are 1-4) + if (turn_end && _p > 0 && array_length(_star_inst.p_feature[_p]) > 0) { + var _planet_data = _star_inst.get_planet_data(_p); + _planet_data.recover_starship(_cur_techs); + _planet_data.planet_training(_pool.heal); + } + } else if (_p == 0 && string_pos("ref instance", _cur_loc) > 0) { + _handle_instance_point_recording(_cur_loc, _stats); + } + } + } } diff --git a/scripts/scr_array_functions/scr_array_functions.gml b/scripts/scr_array_functions/scr_array_functions.gml index 193c4877fe..806d25e087 100644 --- a/scripts/scr_array_functions/scr_array_functions.gml +++ b/scripts/scr_array_functions/scr_array_functions.gml @@ -128,13 +128,13 @@ function array_delete_random_index(choice_array) { /// @function array_to_string_list /// @description Converts an array into a string, with each element on a newline. -/// @param {array} stacktrace stacktrace. +/// @param {array} _array stacktrace. /// @return {string} function array_to_string_list(_array, _pop_last = false) { var _string_list = ""; if (!is_array(_array)) { - return; + return _string_list; } if (_pop_last) { diff --git a/scripts/scr_battle_sort/scr_battle_sort.gml b/scripts/scr_battle_sort/scr_battle_sort.gml index ec0dab8d8f..2df63bad59 100644 --- a/scripts/scr_battle_sort/scr_battle_sort.gml +++ b/scripts/scr_battle_sort/scr_battle_sort.gml @@ -9,7 +9,7 @@ function scr_battle_sort() { i -= 1; if ((battles <= i) && (i >= 2) && (battles > 0)) { - if ((battle[i] != 0) && (battle[i - 1] != 0) && (battle_world[i] == -50) && (battle_world[i - 1] > 0)) { + if ((battle[i] != 0) && (battle[i - 1] != 0) && (battle_world[i] == noone) && (battle_world[i - 1] > 0)) { var tem1, tem2, tem3, tem4, tem5, tem6, tem7; tem1 = battle[i - 1]; tem2 = battle_location[i - 1]; diff --git a/scripts/scr_boarding_actions/scr_boarding_actions.gml b/scripts/scr_boarding_actions/scr_boarding_actions.gml index 1fb3a37b37..64934848ee 100644 --- a/scripts/scr_boarding_actions/scr_boarding_actions.gml +++ b/scripts/scr_boarding_actions/scr_boarding_actions.gml @@ -1,9 +1,10 @@ function create_boarding_craft(target_ship) { - var first = 0, o = 1; + var first = 0; for (var o = 0; o < array_length(board_id); o++) { - if ((first == 0) && (board_id[o] != 0) && (board_location[o] == 0)) { + if ((board_id[o] != 0) && (board_location[o] == 0)) { first = o; + break; } } @@ -11,7 +12,6 @@ function create_boarding_craft(target_ship) { var bear = instance_create(x, y, obj_p_assra); bear.apothecary = 0; - o = first; for (var o = 0; o < array_length(board_id); o++) { if ((board_id[o] != 0) && (board_location[o] == 0)) { diff --git a/scripts/scr_buttons/scr_buttons.gml b/scripts/scr_buttons/scr_buttons.gml index a5839b12ce..e3721885e8 100644 --- a/scripts/scr_buttons/scr_buttons.gml +++ b/scripts/scr_buttons/scr_buttons.gml @@ -51,16 +51,16 @@ function standard_loc_data() { /// @function draw_unit_buttons(position, text, size_mod, colour, halign, font, alpha_mult, bg, bg_color) /// @category Draw Helpers /// @description Draws a styled button with text, optional background and hover effects. -/// @param {array} position Either [x, y] or [x1, y1, x2, y2]. -/// @param {string} text Text to display. -/// @param {array} size_mod Text scaling. -/// @param {color} colour Text color. -/// @param {real} _halign Text horizontal alignment. -/// @param {font} font Font resource. -/// @param {real} alpha_mult Alpha multiplier. -/// @param {bool} bg Draw background rectangle. -/// @param {color} bg_color Background color. -/// @returns {array} [x1, y1, x2, y2] bounding box. +/// @param {Array} position Either [x, y] or [x1, y1, x2, y2]. +/// @param {String} text Text to display. +/// @param {Array} size_mod Text scaling. +/// @param {Constant.Color} colour Text color. +/// @param {Constant.HAlign} _halign Text horizontal alignment. +/// @param {Asset.GMFont} font Font resource. +/// @param {Real} alpha_mult Alpha multiplier. +/// @param {Bool} bg Draw background rectangle. +/// @param {Constant.Color} bg_color Background color. +/// @returns {Array} [x1, y1, x2, y2] bounding box. function draw_unit_buttons(position, text, size_mod = [1.5, 1.5], colour = c_gray, _halign = fa_center, font = fnt_40k_14b, alpha_mult = 1, bg = false, bg_color = c_black) { // TODO: fix halign usage add_draw_return_values(); @@ -415,8 +415,7 @@ function LabeledIcon(icon_param, text_param, x1_param = 0, y1_param = 0, data = /// @constructor /// @category UI /// @desc A clickable sprite-based button component that manages its own state and hover logic. -/// @param {Asset.GMSprite} _sprite The default sprite to display. -/// @param {Asset.GMSprite} _hover_sprite Optional sprite to show when hovered. +/// @param {Struct} data Property overrides (sprite, hover_sprite, scale_x/y, alpha_*, etc.). /// @returns {Struct.SpriteButton} function SpriteButton(data) constructor { standard_loc_data(); @@ -449,8 +448,6 @@ function SpriteButton(data) constructor { update(data); /// @desc Updates interaction state and draws the button. - /// @param {real} _x The X position to draw at. - /// @param {real} _y The Y position to draw at. /// @param {bool} _enabled If false, interaction is disabled and the button appears faded. static draw = function(_enabled = true) { diff --git a/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml b/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml index 92d9f8caf7..9952151679 100644 --- a/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml +++ b/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml @@ -1,9 +1,8 @@ /// @self Asset.GMObject.obj_popup function tech_uprising_event_aftermath() { - var tech, t, i, check_tech, location_techs, location_heretics, delete_positions; - techs = collect_role_group(SPECIALISTS_TECHS); + var techs = collect_role_group(SPECIALISTS_TECHS); var tech_count = array_length(techs); - for (i = 0; i < tech_count; i++) { + for (var i = 0; i < tech_count; i++) { var heretic_data = [ 0, 0, @@ -14,11 +13,11 @@ function tech_uprising_event_aftermath() { 0, 0 ]; - delete_positions = []; - location_techs = []; - location_heretics = []; + var delete_positions = []; + var location_techs = []; + var location_heretics = []; /// @type {Struct.TTRPG_stats} - tech = techs[i]; + var tech = techs[i]; if (tech.has_trait("tech_heretic")) { array_push(location_heretics, tech); heretic_data[0] += tech.weapon_skill; @@ -31,8 +30,8 @@ function tech_uprising_event_aftermath() { loyal_data[2] += tech.ballistic_skill; } //loop techs to fins out which techs are in the same location - for (t = i + 1; t < tech_count; t++) { - check_tech = techs[t].marine_location(); + for (var t = i + 1; t < tech_count; t++) { + var check_tech = techs[t].marine_location(); if (locations_are_equal(tech.marine_location(), check_tech)) { if (techs[t].has_trait("tech_heretic")) { array_push(location_heretics, techs[t]); @@ -49,12 +48,11 @@ function tech_uprising_event_aftermath() { } } if (array_length(location_heretics) > 0 && array_length(location_techs) > 0) { - var purge_target = "none"; + var purge_target = noone; if (press == 0) { - var tal; var heretic_tally = 0; var loyal_tally = 0; - for (tal = 0; tal < 3; tal++) { + for (var tal = 0; tal < 3; tal++) { if (heretic_data[tal] > loyal_data[0]) { heretic_tally++; } else if (heretic_data[tal] < loyal_data[0]) { @@ -66,7 +64,7 @@ function tech_uprising_event_aftermath() { } else if (heretic_tally < loyal_tally) { purge_target = location_heretics; } - if (purge_target == "none") { + if (purge_target == noone) { purge_target = choose(location_heretics, location_techs); } } else if (press == 1) { @@ -74,14 +72,14 @@ function tech_uprising_event_aftermath() { } else if (press == 2) { purge_target = location_heretics; } - if (purge_target != "none") { - for (tal = 0; tal < array_length(purge_target); tal++) { + if (purge_target != noone) { + for (var tal = 0; tal < array_length(purge_target); tal++) { kill_and_recover(purge_target[tal].company, purge_target[tal].marine_number); } } } if (array_length(delete_positions) > 0) { - for (t = array_length(delete_positions) - 1; t >= 0; t--) { + for (var t = array_length(delete_positions) - 1; t >= 0; t--) { array_delete(techs, delete_positions[t], 1); tech_count--; } @@ -140,7 +138,7 @@ function setup_new_forge_master_popup(techs) { } } - for (i = 1; i < array_length(techs); i++) { + for (var i = 1; i < array_length(techs); i++) { if (_pop_data.charisma_pick.charisma < techs[i].charisma) { _pop_data.charisma_pick = techs[i]; } @@ -230,10 +228,10 @@ function new_forge_master_chosen(pick) { } } - if (pick != "none") { + if (pick != noone) { pick.update_role("Forge Master"); - var likability; + var likability = ""; if (dislike <= 5) { likability = "He is generally well liked"; } @@ -276,10 +274,10 @@ function new_forge_master_chosen(pick) { if (pick.company > 0) { for (var i = 1; i < 500; i++) { if (obj_ini.name[0][i] == "") { + scr_move_unit_info(pick.company, 0, pick.marine_number, i); break; } } - scr_move_unit_info(pick.company, 0, pick.marine_number, i); } } } diff --git a/scripts/scr_chapter_new/scr_chapter_new.gml b/scripts/scr_chapter_new/scr_chapter_new.gml index 320f32742d..8b5c7af2af 100644 --- a/scripts/scr_chapter_new/scr_chapter_new.gml +++ b/scripts/scr_chapter_new/scr_chapter_new.gml @@ -6,7 +6,7 @@ function ChapterData() constructor { points = 0; flavor = ""; origin = eCHAPTER_ORIGINS.NONE; - founding = ePROGENITOR.NONE; + founding = eCHAPTERS.UNKNOWN; successors = 0; splash = 0; icon_name = "unknown"; @@ -159,7 +159,6 @@ function ChapterData() constructor { load_result = file_loader.load_struct_from_json_file($"main/chapters/{chapter_id}.json", "chapter", false); } if (!load_result.is_success) { - // LOGGER.error($"No chapter json exits for chapter_id {chapter_id}"); return false; } var json_chapter = load_result.value.chapter; @@ -203,7 +202,6 @@ function scr_chapter_new(chapter_identifier) { //9th captain = relic_master_name //10th captain = recruiter_name - var i = 0; world = array_create(20, ""); world_type = array_create(20, ""); world_feature = array_create(20, ""); diff --git a/scripts/scr_cheatcode/scr_cheatcode.gml b/scripts/scr_cheatcode/scr_cheatcode.gml index ed52ae4e20..8cdeb77b9e 100644 --- a/scripts/scr_cheatcode/scr_cheatcode.gml +++ b/scripts/scr_cheatcode/scr_cheatcode.gml @@ -103,6 +103,22 @@ function scr_cheatcode(argument0) { scr_add_man("Flash Git", 0, "", "", 0, true, "default"); } break; + case "guardsman": + repeat (real(cheat_arguments[0])) { + scr_add_man("Guardsman", 0, "", "", 0, true, "home_planet", {skip_company_order: true}); + } + with (obj_ini) { + scr_company_order(0); + } + break; + case "guardsquad": + repeat (real(cheat_arguments[0])) { + scr_add_man("Guard Squad", 0, "", "", 0, true, "home_planet", {skip_company_order: true}); + } + with (obj_ini) { + scr_company_order(0); + } + break; case "chaosfleetspawn": spawn_chaos_warlord(); break; @@ -406,16 +422,12 @@ function draw_planet_debug_options() { if (debug) { debug_slate.inside_method = function() { debug_options.draw(); - switch(debug_options.current_selection){ - case 0: - draw_planet_debug_forces(); - break; - case 1: - draw_planet_debug_problems(); - break; - case 2: - draw_planet_debug_features(); - break; + if (debug_options.current_selection == 0) { + draw_planet_debug_forces(); + } else if (debug_options.current_selection == 1) { + draw_planet_debug_problems(); + } else if (debug_options.current_selection == 2) { + draw_planet_debug_features(); } }; debug_slate.draw(); @@ -496,7 +508,6 @@ function draw_planet_debug_problems() { if (scr_hit(38, _y, 337, _y + 20)) { tooltip_draw(mission_name_key(_keys[i])); if (mouse_button_clicked()) { - var _p_data = obj_star_select.p_data; switch (_keys[i]) { case "inquisitor": mission_inquistion_hunt_inquisitor(target.id); @@ -513,12 +524,7 @@ function draw_planet_debug_problems() { case "mech_bionics": spawn_mechanicus_mission("mech_bionics"); break; - case "succession": - _p_data.init_war_of_succession(); - break; - case "fallen": - _p_data.init_fallen_marines(); - break + default: scr_popup("error", "no specific debug action created please consider helping to make one", ""); break; diff --git a/scripts/scr_clean/scr_clean.gml b/scripts/scr_clean/scr_clean.gml index e1b6a2e10a..832fb30008 100644 --- a/scripts/scr_clean/scr_clean.gml +++ b/scripts/scr_clean/scr_clean.gml @@ -75,9 +75,19 @@ function compress_enemy_array(_target_column) { /// @description Destroys the column if it's empty /// @param {id.Instance} _target_column - The column instance to clean up function destroy_empty_column(_target_column) { - // Destroy empty non-player columns to conserve memory and processing + // Destroy empty non-player columns to conserve memory and processing. with (_target_column) { - if ((men + veh + medi == 0) && (owner != 1)) { + // Count living models straight from dudes_num. men/veh/medi are only refreshed on the enemy's + // own alarm, so during the player's firing phase they're stale and would leave a wiped-out + // formation standing - which then keeps getting fired at and blocks "held fire" reporting. + var _alive = 0; + for (var r = 1; r < array_length(dudes_num); r++) { + // A rank chipped to 0 HP but still showing dudes_num is a dead "zombie" - don't count it. + if (dudes_num[r] > 0 && dudes_hp[r] > 0) { + _alive += dudes_num[r]; + } + } + if ((_alive == 0) && (owner != 1)) { instance_destroy(); } } @@ -118,8 +128,8 @@ function check_dead_marines(unit_struct, unit_index) { return unit_lost; } -/// @self Asset.GMObject.obj_pnunit -/// @param {Asset.GMObject.obj_pnunit} target_object +/// @self Id.Instance.obj_pnunit +/// @param {Id.Instance.obj_pnunit} target_object function scr_clean(target_object, target_is_infantry, hostile_shots, hostile_damage, hostile_weapon, hostile_range, hostile_splash, weapon_index_position) { // Converts enemy scr_shoot damage into player marine or vehicle casualties. // @@ -142,8 +152,21 @@ function scr_clean(target_object, target_is_infantry, hostile_shots, hostile_dam "units_lost": 0, "unit_type": "", "hits": 0, + "severity": 0, + "is_vehicle": false, }; + // Scope the casualty breakdown to THIS attack. lost[]/lost_num[] are the column's + // per-attack scratch tally that scr_flavor2 reads to build its "X Foo lost" text. + // scr_flavor2 clears them at its end, but fork-added early-exits (suppressed empty or + // zero-shot attacks, a destroyed wall) can return before that reset, leaving a previous + // attack's casualties in place. A later attack that inflicts nothing of its own (e.g. + // autoguns pinging off a Predator's AC40 armour for zero damage) would then read and + // mis-report those stale kills as "8 Autoguns strike at Predator. 4 Predators lost." + // Clearing here guarantees the breakdown reflects only what this attack actually kills. + lost = []; + lost_num = []; + // ### Vehicle Damage Processing ### if (!target_is_infantry && veh > 0) { damage_vehicles(damage_data, hostile_shots, hostile_damage, weapon_index_position); @@ -151,7 +174,7 @@ function scr_clean(target_object, target_is_infantry, hostile_shots, hostile_dam // ### Marine + Dreadnought Processing ### if (target_is_infantry && (men + dreads > 0)) { - damage_infantry(damage_data, hostile_shots, hostile_damage, weapon_index_position); + damage_infantry(damage_data, hostile_shots, hostile_damage, weapon_index_position, hostile_splash); } if (damage_data.hits < hostile_shots) { @@ -162,11 +185,11 @@ function scr_clean(target_object, target_is_infantry, hostile_shots, hostile_dam // ### Marine + Dreadnought Processing ### if (!target_is_infantry && (men + dreads > 0)) { - damage_infantry(damage_data, hostile_shots, hostile_damage, weapon_index_position); + damage_infantry(damage_data, hostile_shots, hostile_damage, weapon_index_position, hostile_splash); } } - scr_flavor2(damage_data.units_lost, damage_data.unit_type, hostile_range, hostile_weapon, damage_data.hits, hostile_splash); + scr_flavor2(damage_data.units_lost, damage_data.unit_type, hostile_range, hostile_weapon, damage_data.hits, hostile_splash, damage_data.severity, damage_data.is_vehicle); // ### Cleanup ### // If the target_object got wiped out, move it off-screen @@ -181,7 +204,7 @@ function scr_clean(target_object, target_is_infantry, hostile_shots, hostile_dam } /// @self Asset.GMObject.obj_pnunit -function damage_infantry(_damage_data, _shots, _damage, _weapon_index) { +function damage_infantry(_damage_data, _shots, _damage, _weapon_index, _splash) { var _armour_pierce = apa[_weapon_index]; var _armour_mod = 0; switch (_armour_pierce) { @@ -211,6 +234,76 @@ function damage_infantry(_damage_data, _shots, _damage, _weapon_index) { } } + // Bulk man-block with no individual model structs (Guard auxilia): take losses + // straight off the men count, the way the enemy's ranks do, since there are no + // marine structs for the normal path to kill. Scoped to guard blocks only. + // ===== OBSOLETE: planetary Guard (iteration 1) ===== + // Casualty math for the dead first-iteration men-block. The `guard` flag is never set + // to 1, so this never runs, and the cover-save inside it never applies. Live guardsmen + // take casualties through the normal marine path below. Left for reference only. + if (guard == 1 && array_length(valid_marines) == 0 && men > 0) { + // Identical to the enemy Guardsman casualty math in scr_shoot. Reduce each + // shot by armour, pool the survivable damage across all shots, convert it to + // dead men at dudes_hp each, and cap the kills at the shot count. With + // dudes_ac 40 the rank shrugs off low-AP fire (basic Choppaz, Shootas) the + // same way the enemy Guardsmen you fight do, and only armour-piercing weapons + // cut them down in numbers. Armour is what gives them their staying power, so + // there is no separate cohesion cap here. + var _g_ac = (array_length(dudes_ac) > 1) ? dudes_ac[1] : 40; + var _g_hp = (array_length(dudes_hp) > 1) ? dudes_hp[1] : 5; + if (_g_hp <= 0) { + _g_hp = 5; + } + var _g_after = _damage - (_g_ac * _armour_mod); + if (_g_after < 0) { + _g_after = 0; + } + var _g_pool = _shots * _g_after; + var _g_total = min(floor(_g_pool / _g_hp), _shots); + _g_total = min(_g_total, men); + if (_g_total < 0) { + _g_total = 0; + } + // Cover / dispersion save (see GUARD_COVER_SAVE in macros.gml). A flat fraction + // of would-be casualties are treated as missed, standing in for spacing, terrain + // and a small profile. Applied after armour so it also blunts armour-piercing + // weapons (choppaz, power klawz) that ignore Flak entirely. + if (_g_total > 0 && GUARD_COVER_SAVE > 0) { + _g_total = floor(_g_total * (1 - GUARD_COVER_SAVE)); + } + _damage_data.hits += _shots; + // Always name the block, even on a zero-casualty hit, or the enemy attack + // flavor prints "fire at ." with a blank target whenever armour soaks the shot. + _damage_data.unit_type = "Imperial Guardsman"; + if (_g_total > 0) { + men -= _g_total; + if (array_length(dudes_num) > 1) { + dudes_num[1] = max(0, dudes_num[1] - _g_total); + } + // Report through the same lost/lost_num summary the marines use. + _damage_data.units_lost += _g_total; + _damage_data.unit_type = "Imperial Guardsman"; + var _g_idx = -1; + for (var gk = 0, gl = array_length(lost); gk < gl; gk++) { + if (lost[gk] == "Imperial Guardsman") { + _g_idx = gk; + break; + } + } + if (_g_idx >= 0) { + lost_num[_g_idx] += _g_total; + } else { + array_push(lost, "Imperial Guardsman"); + array_push(lost_num, _g_total); + } + } + return; + } + + // Per-role tally of kills this volley, used to relabel the attack after the loop. + var _killed_roles = []; + var _killed_counts = []; + // Apply damage for each shot for (var shot = 0; shot < _shots; shot++) { if (array_length(valid_marines) == 0) { @@ -270,16 +363,92 @@ function damage_infantry(_damage_data, _shots, _damage, _weapon_index) { var chunk = max(10, 62 - (marine_ac[marine_index] * 2)); _modified_damage = (webr <= chunk) ? 5000 : 0; } */ + var _hp_before = marine.hp(); marine.add_or_sub_health(-_modified_damage); + if ((_hp_before > 0) && (_modified_damage > 0)) { + _damage_data.severity = max(_damage_data.severity, clamp(_modified_damage / _hp_before, 0, 1)); + } // Check if marine is dead if (check_dead_marines(marine, marine_index)) { // Remove dead infantry from further hits valid_marines = array_delete_value(valid_marines, marine_index); _damage_data.units_lost++; + + // Record the fallen role so the headline can name who actually died. + var _arole = marine.role(); + var _aidx = -1; + for (var _ai = 0; _ai < array_length(_killed_roles); _ai++) { + if (_killed_roles[_ai] == _arole) { _aidx = _ai; break; } + } + if (_aidx == -1) { + array_push(_killed_roles, _arole); + array_push(_killed_counts, 1); + } else { + _killed_counts[_aidx] += 1; + } + + // ===== Splash carry-over ===== + // Port of the enemy men-block math in scr_shoot onto the player's individual + // units. A blast weapon's lethal overkill spills onto adjacent units, capped at + // the weapon's splash, and every further kill is gated by that unit's own armour + // and HP. Low-HP ranks (guardsmen) get torn apart by a Kannon or Rokkit; Marines + // and bosses soak the leftover through armour and HP, so it cannot wipe them, and + // ordinary attrition does not rise because only overkill carries. + if (_splash > 1) { + var _carry = _modified_damage - _hp_before; // damage left after this kill + var _spread_left = _splash - 1; + while (_spread_left > 0 && _carry > 0 && array_length(valid_marines) > 0) { + var _next_index = array_random_element(valid_marines); + var _next = unit_struct[_next_index]; + var _next_net = _carry - (marine_ac[_next_index] * _armour_mod); + if (_next_net > 0) { + _next_net = round(_next_net * (1 - (_next.damage_resistance() / 100))); + } + if (_next_net <= 0) { + break; // armour soaked the leftover; the blast is spent + } + var _next_hp_before = _next.hp(); + _next.add_or_sub_health(-_next_net); + if (check_dead_marines(_next, _next_index)) { + valid_marines = array_delete_value(valid_marines, _next_index); + _damage_data.units_lost++; + // Record the fallen role (splash victims count too). + var _brole = _next.role(); + var _bidx = -1; + for (var _bi = 0; _bi < array_length(_killed_roles); _bi++) { + if (_killed_roles[_bi] == _brole) { _bidx = _bi; break; } + } + if (_bidx == -1) { + array_push(_killed_roles, _brole); + array_push(_killed_counts, 1); + } else { + _killed_counts[_bidx] += 1; + } + _carry = _next_net - _next_hp_before; // remaining overkill rolls on + } else { + break; // wounded but alive; the blast is spent on this body + } + _spread_left--; + } + } } } + // The loop overwrote unit_type with a random *surviving* unit every shot, so a dying + // screen in front of a tanky unit (Dreadnought) let the survivor win the "strike at X" + // headline while the casualty list named the dead. If anything fell, relabel the attack + // with the role that took the most casualties so the headline and the losses agree. + if (array_length(_killed_roles) > 0) { + var _top = 0; + for (var _ti = 1; _ti < array_length(_killed_counts); _ti++) { + if (_killed_counts[_ti] > _killed_counts[_top]) { + _top = _ti; + } + } + _damage_data.unit_type = _killed_roles[_top]; + } + return; } @@ -334,8 +503,13 @@ function damage_vehicles(_damage_data, _shots, _damage, _weapon_index) { if (enemy == 13 && _modified_damage < 1) { _modified_damage = 1; } + var _veh_hp_before = veh_hp[veh_index]; veh_hp[veh_index] -= _modified_damage; _damage_data.unit_type = veh_type[veh_index]; + _damage_data.is_vehicle = true; + if (_veh_hp_before > 0) { + _damage_data.severity = max(_damage_data.severity, clamp(_modified_damage / _veh_hp_before, 0, 1)); + } // Check if the vehicle is destroyed if (veh_hp[veh_index] <= 0 && veh_dead[veh_index] == 0) { diff --git a/scripts/scr_company_order/scr_company_order.gml b/scripts/scr_company_order/scr_company_order.gml index f0855871cb..b7996fc3cc 100644 --- a/scripts/scr_company_order/scr_company_order.gml +++ b/scripts/scr_company_order/scr_company_order.gml @@ -22,10 +22,7 @@ function scr_company_order(company) { // This sorts and crunches the marine variables for the company var co = company; - var i = -1; - var _empty_squads = []; - var _squadless = {}; var _roles = active_roles(); @@ -36,9 +33,9 @@ function scr_company_order(company) { // find units not in a _squad //at this point check that all squads have the right types and numbers of units in them - var _squad, wanted_roles; + var wanted_roles; var _squad_ids = get_squad_ids(); - for (i = 0; i < array_length(_squad_ids); i++) { + for (var i = 0; i < array_length(_squad_ids); i++) { var _squad = fetch_squad(_squad_ids[i]); if (_squad.base_company != co) { if (!bool(array_length(_squad.members))) { @@ -69,7 +66,7 @@ function scr_company_order(company) { } } - var _squadless = _squadless_index.turn_to_UnitGroup(); + _squadless = _squadless_index.turn_to_UnitGroup(); if (_squadless.number() > 3) { var _squad_index = _company_marines.index_squads(); @@ -109,25 +106,17 @@ function scr_company_order(company) { var _squads = _company_marines.count_squads("all", true); for (var i = 0; i < array_length(_squads); i++) { - _squad = fetch_squad(_squads[i]); + var _squad = fetch_squad(_squads[i]); _squad.members = []; } var _temps = []; - for (i = 0; i < array_length(_company_marines.units); i++) { + for (var i = 0; i < array_length(_company_marines.units); i++) { var _unit = _company_marines.units[i]; array_push(_temps, {unit: _unit, race: _unit.race(), name: _unit.name(), role: _unit.role(), wep1: _unit.weapon_one(true), wep2: _unit.weapon_two(true), armour: _unit.armour(true), gear: _unit.gear(true), mobi: _unit.mobility_item(true), age: _unit.age(), spe: _unit.specials(), god: _unit.god_status()}); } - //position 2 in role order - /*if (global.chapter_name!="Space Wolves") and (global.chapter_name!="Iron Hands"){ - i=0;repeat(300){i+=1; - if (role[co][i]=_roles[Roles.CHAPLAIN]){v+=1; - temp_marine_variables(co, i ,v); - } - }*/ - - for (i = 0; i < array_length(_temps); i++) { + for (var i = 0; i < array_length(_temps); i++) { var _unit = _temps[i]; var _struc = _unit.unit; TTRPG[co][i] = _struc; @@ -156,21 +145,6 @@ function scr_company_order(company) { } _struc.movement_after_math(co, i, false); } - /* i=0;repeat(300){i+=1; - if (role[co][i]="Death Company"){ - if (string_count("Dreadnought",armour[co][i])>0){v+=1; - temp_marine_variables(co, i ,v); - } - } - } - - i=0;repeat(300){i+=1; - if (role[co][i]="Death Company"){ - if (string_count("Dreadnought",armour[co][i])=0) and (string_count("Terminator",armour[co][i])=0) and (armour[co][i]!="Tartaros"){v+=1; - temp_marine_variables(co, i ,v); - } - } - }*/ } catch (_exception) { ERROR_HANDLER.handle_exception(_exception); } diff --git a/scripts/scr_company_struct/scr_company_struct.gml b/scripts/scr_company_struct/scr_company_struct.gml index 9fcea8a5af..51efe0f984 100644 --- a/scripts/scr_company_struct/scr_company_struct.gml +++ b/scripts/scr_company_struct/scr_company_struct.gml @@ -181,7 +181,7 @@ function CompanyStruct(comp) constructor { _reset_surface = true; } for (var i = 0; i < array_length(_cur_squad.members); i++) { - var _member = _cur_squad.fetch_member(i); + _member = _cur_squad.fetch_member(i); if (_reset_surface) { array_push(squad_draw_surfaces, [_member.uid, _member.draw_unit_image()]); @@ -224,7 +224,7 @@ function CompanyStruct(comp) constructor { } if (is_struct(sprite_draw_delay)) { - var _member = sprite_draw_delay.unit; + _member = sprite_draw_delay.unit; unit_sprite_coords = sprite_draw_delay.draw_coords; var _surface = sprite_draw_delay.unit_surface; _surface.draw_part(unit_sprite_coords.x1, unit_sprite_coords.y1, 0, 0, 166, 231, true); @@ -311,7 +311,7 @@ function CompanyStruct(comp) constructor { if (point_and_click(garrison_but)) { var garrrison_star = find_star_by_name(cur_assignment.location); obj_controller.view_squad = false; - if (garrrison_star != "none") { + if (garrrison_star != noone) { scr_toggle_manage(); obj_controller.x = garrrison_star.x; obj_controller.y = garrrison_star.y; diff --git a/scripts/scr_company_view/scr_company_view.gml b/scripts/scr_company_view/scr_company_view.gml index 0addd44874..61a6e41bda 100644 --- a/scripts/scr_company_view/scr_company_view.gml +++ b/scripts/scr_company_view/scr_company_view.gml @@ -49,6 +49,25 @@ function find_company_open_slot(target_company) { break; } } + if (good == -1) { + // No free slot left: grow the company by one fully-initialised blank slot so + // companies are effectively uncapped (HQ included). Only runs on overflow, so + // normal recruiting is unchanged. All parallel arrays are extended together to + // stay in sync, mirroring _init_marine_row for a single index. + good = array_length(obj_ini.name[target_company]); + obj_ini.race[target_company][good] = 1; + obj_ini.name[target_company][good] = ""; + obj_ini.role[target_company][good] = ""; + obj_ini.wep1[target_company][good] = ""; + obj_ini.spe[target_company][good] = ""; + obj_ini.wep2[target_company][good] = ""; + obj_ini.armour[target_company][good] = ""; + obj_ini.gear[target_company][good] = ""; + obj_ini.mobi[target_company][good] = ""; + obj_ini.age[target_company][good] = 0; + obj_ini.god[target_company][good] = 0; + obj_ini.TTRPG[target_company][good] = new TTRPG_stats("chapter", target_company, good, "blank"); + } return good; } @@ -505,13 +524,13 @@ function company_manage_actions() { } // Previous company if (point_and_click([xx + 424, yy + 80, xx + 496, yy + 128]) || (keyboard_check_pressed(ord(string("N"))) && allow_shortcuts)) { - var new_view = managing == 1 ? 15 : managing - 1; + var new_view = managing == 1 ? 16 : managing - 1; switch_view_company(new_view); } // Next company if (point_and_click([xx + 1105, yy + 80, xx + 1178, yy + 128]) || (keyboard_check_pressed(ord(string("M"))) && allow_shortcuts)) { - var new_view = managing == 15 ? 1 : managing + 1; + var new_view = managing == 16 ? 1 : managing + 1; switch_view_company(new_view); } } @@ -535,6 +554,8 @@ function ui_manage_hotkeys() { switch_view_company(14); } else if (press_exclusive(ord("Y"))) { switch_view_company(15); + } else if (press_exclusive(ord("U"))) { + switch_view_company(16); } } } diff --git a/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml b/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml index ce09a6bee1..63be9f3f6d 100644 --- a/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml +++ b/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml @@ -42,10 +42,10 @@ function setup_complex_livery_shader(setup_role, unit = "none") { shader_set(full_livery_shader); var _in_creation = instance_exists(obj_creation); - + var data_set = {}; var _is_unit = unit != "none"; if (_in_creation) { - var data_set = variable_clone(obj_creation.livery_picker.map_colour); + data_set = variable_clone(obj_creation.livery_picker.map_colour); if (obj_creation.livery_selection_options.current_selection == 2) { var _base = obj_creation.full_liveries[0]; var _component_names = struct_get_names(_base); @@ -62,7 +62,7 @@ function setup_complex_livery_shader(setup_role, unit = "none") { } else { var _full_liveries = obj_ini.full_liveries; var _roles = obj_ini.role[100]; - var data_set = obj_ini.full_liveries[0]; + data_set = obj_ini.full_liveries[0]; if (is_specialist(setup_role, SPECIALISTS_LIBRARIANS)) { data_set = _full_liveries[eROLE.LIBRARIAN]; } else if (is_specialist(setup_role, SPECIALISTS_HEADS)) { @@ -325,7 +325,7 @@ function setup_complex_livery_shader(setup_role, unit = "none") { } main_key = get_marine_icon_set(_data.type); if (sub_key != "" && is_struct(main_key)) { - var _tex_set = variable_clone(main_key[$ sub_key]); + _tex_set = variable_clone(main_key[$ sub_key]); } if (is_struct(_tex_set)) { if (struct_exists(_tex_set, _data.icon)) { @@ -351,20 +351,19 @@ function setup_complex_livery_shader(setup_role, unit = "none") { function get_shader_colour_from_arrays(colour) { var colours_instance = instance_exists(obj_creation) ? obj_creation : obj_controller; + var colour_set = [ + 0, + 0, + 0 + ]; try { - var colour_set = [ + colour_set = [ colours_instance.col_r[colour] / 255, colours_instance.col_g[colour] / 255, colours_instance.col_b[colour] / 255 ]; - } - catch (_exception) { - //ERROR_HANDLER.handle_exception(_exception); - var colour_set = [ - 0, - 0, - 0 - ]; + } catch (_exception) { + ERROR_HANDLER.assert_popup(_exception); } return colour_set; diff --git a/scripts/scr_controller_helpers/scr_controller_helpers.gml b/scripts/scr_controller_helpers/scr_controller_helpers.gml index d68a3a44aa..d0e21fe3be 100644 --- a/scripts/scr_controller_helpers/scr_controller_helpers.gml +++ b/scripts/scr_controller_helpers/scr_controller_helpers.gml @@ -47,7 +47,7 @@ function scr_menu_clear_up(specific_area_function) { } // 136 ; if (instance_exists(obj_temp_build)) { - if (obj_temp_build.isnew) { + if (variable_instance_exists(obj_temp_build, "isnew") && obj_temp_build.isnew) { exit; } } diff --git a/scripts/scr_creation_home_planet_create/scr_creation_home_planet_create.gml b/scripts/scr_creation_home_planet_create/scr_creation_home_planet_create.gml index dbd7932a36..5c9bf0693a 100644 --- a/scripts/scr_creation_home_planet_create/scr_creation_home_planet_create.gml +++ b/scripts/scr_creation_home_planet_create/scr_creation_home_planet_create.gml @@ -29,11 +29,9 @@ function player_recruit_planet_selection() { recruiting = list_traveler(planet_types, recruiting, [1265, 285, 1265 + 32, 285 + 32], [1455, 285, 1455 + 32, 285 + 32]); } - // draw_sprite(spr_planet_splash,_cur_planet_index2,580+333,244); scr_image("ui/planet", _cur_planet_index2, 980 + 333, 244, 128, 128); draw_text_transformed(1044 + 333, 378, recruiting, 0.5, 0.5, 0); - // draw_text_transformed(644+333,398,string(recruiting_name),0.5,0.5,0); if (_recruit_world_type < 2) { recruiting_name = homeworld_name; @@ -42,6 +40,7 @@ function player_recruit_planet_selection() { recruiting_name = global.name_generator.GenerateFromSet("star", false); } } + var name_bad = 0; if ((fleet_type == 1 && _recruit_world_type < 2) && (homeworld_name == recruiting_name)) { name_bad = 1; } @@ -83,7 +82,6 @@ function player_recruit_planet_selection() { draw_unit_buttons(_refresh_rec_name_btn, "?", [1, 1], CM_GREEN_COLOR,, fnt_40k_14b); if (point_and_click(_refresh_rec_name_btn)) { var _new_rec_name = global.name_generator.GenerateFromSet("star", false); - //LOGGER.debug($"regen name of recruiting_name from {recruiting_name} to {_new_rec_name}"); recruiting_name = _new_rec_name; } } @@ -97,8 +95,6 @@ function scr_creation_home_planet_create() { var fleet_type_text = fleet_type == ePLAYER_BASE.HOME_WORLD ? "Homeworld" : "Flagship"; draw_text_transformed(644, 218, fleet_type_text, 0.6, 0.6, 0); - var _cur_planet_index = 0, _cur_planet_index2 = 0, name_bad = 0; - var _cur_planet_index = scr_planet_image_numbers(homeworld); if (fleet_type != 1) { _cur_planet_index = 16; @@ -106,10 +102,8 @@ function scr_creation_home_planet_create() { if (fleet_type == ePLAYER_BASE.HOME_WORLD) { scr_image("ui/planet", _cur_planet_index, 580, 244, 128, 128); - // draw_sprite(spr_planet_splash,_cur_planet_index,580,244); draw_text_transformed(644, 378, homeworld, 0.5, 0.5, 0); - // draw_text_transformed(644,398,string(homeworld_name),0.5,0.5,0); if ((text_selected != "home_name") || (custom != eCHAPTER_TYPE.CUSTOM)) { draw_text_transformed(644, 398, homeworld_name, 0.5, 0.5, 0); } @@ -141,7 +135,6 @@ function scr_creation_home_planet_create() { draw_unit_buttons(_refresh_hw_name_btn, "?", [1, 1], CM_GREEN_COLOR,, fnt_40k_14b); if (point_and_click(_refresh_hw_name_btn)) { var _new_hw_name = global.name_generator.GenerateFromSet("star", false); - //LOGGER.debug($"regen name of homeworld from {homeworld_name} to {_new_hw_name}"); homeworld_name = _new_hw_name; } } @@ -158,11 +151,9 @@ function scr_creation_home_planet_create() { draw_set_font(fnt_40k_30b); } if (fleet_type != ePLAYER_BASE.HOME_WORLD) { - // draw_sprite(spr_planet_splash,_cur_planet_index,580,244); scr_image("ui/planet", _cur_planet_index, 580, 244, 128, 128); draw_text_transformed(644, 378, "Battle Barge", 0.5, 0.5, 0); - // draw_text_transformed(644,398,string(homeworld_name),0.5,0.5,0); if ((text_selected != "flagship_name") || (custom == eCHAPTER_TYPE.PREMADE)) { draw_text_transformed(644, 398, flagship_name, 0.5, 0.5, 0); } @@ -212,7 +203,6 @@ function scr_creation_home_planet_create() { right_data_slate.draw(1210, 5, 0.45, 1); if (recruiting_exists == 0 && homeworld_exists == 1) { - // draw_sprite(spr_planet_splash,_cur_planet_index,580+333,244); scr_image("ui/planet", _cur_planet_index, 580 + 333, 244, 128, 128); draw_set_alpha(0.5); @@ -239,9 +229,6 @@ function scr_creation_home_planet_create() { draw_line(445, 456, 1125, 456); draw_line(445, 457, 1125, 457); - // homeworld_rule=0; - // aspirant_trial=eTRIALS.BLOODDUEL; - draw_set_halign(fa_left); //TODO move to OOP checkboxes diff --git a/scripts/scr_crusade/scr_crusade.gml b/scripts/scr_crusade/scr_crusade.gml index ed9e4ca50a..dc27c3b8f5 100644 --- a/scripts/scr_crusade/scr_crusade.gml +++ b/scripts/scr_crusade/scr_crusade.gml @@ -1,3 +1,4 @@ +/// @self Id.Instance.obj_fleet function scr_crusade() { // Executed to kill the fuck out of the player's marines // Think it is ran in the obj_p_fleet object when arriving back from crusade @@ -89,12 +90,12 @@ function scr_crusade() { death_determination -= 10; } - var dead = false; + var _dead = false; if (death_determination > death_data[0] || death_determination_2 > death_data[1]) { - dead = true; + _dead = true; if (unit.role() == obj_ini.role[100][5]) { if (irandom(20) < unit.luck) { - dead = false; + _dead = false; } else { if (irandom(100) < unit.weapon_skill) { var heroic_deed = choose("holding a breach in imperial defenses allowing allied forces to regroup,", "slaying the enemy leader in glorious combat, while victorious he ultimately succumbed to his wounds,", "leading an imortant boarding mission,",); @@ -107,10 +108,10 @@ function scr_crusade() { } } } else if (unit.role() == obj_ini.role[100][11] || unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) { - dead = false; + _dead = false; } } - if (dead) { + if (_dead) { var man_size = 0; obj_ini.ship_carrying[unit.ship_location] -= unit.get_unit_size(); if (unit.IsSpecialist(SPECIALISTS_STANDARD, true)) { @@ -149,15 +150,11 @@ function scr_crusade() { obj_controller.gene_seed += seed; } - // i=-1; - // repeat(11){ - // i+=1; with (obj_ini) { for (i = 0; i <= 10; i++) { scr_company_order(i); } } - // } if (roll3 <= 10) { artifacts += 1; @@ -220,13 +217,13 @@ function scr_crusade() { //TODO never place the star out of reach of a player fleet, eiter increase allowed response time or find nearer planet function launch_crusade() { var star_id = scr_random_find(2, true, "", ""); - if (star_id == undefined) { + if (star_id == noone) { LOGGER.error("RE: Crusade, couldn't find a star for the crusade"); return false; } else { //TODO decide the target/purpose of the crusade to create more variety and to help with post crusade rewards var _nearest_player_fleet = get_nearest_player_fleet(star_id.x, star_id.y); - if (_nearest_player_fleet == "none") { + if (_nearest_player_fleet == noone) { return false; } var travel_leeway = 10; diff --git a/scripts/scr_culture_visuals/scr_culture_visuals.gml b/scripts/scr_culture_visuals/scr_culture_visuals.gml index d151b148dd..465c41a459 100644 --- a/scripts/scr_culture_visuals/scr_culture_visuals.gml +++ b/scripts/scr_culture_visuals/scr_culture_visuals.gml @@ -107,10 +107,11 @@ function load_vis_set_to_global(directory, data) { if (directory_exists(directory + $"/{_sprite_item.name}")) { var _sprite_direct = directory + $"/{_sprite_item.name}"; + var _new_sprite = undefined; // --- MAIN SPRITE LOADING --- if (file_exists($"{_sprite_direct}/1.png")) { - var _new_sprite = sprite_add(_sprite_direct + "/1.png", 1, 0, 0, 0, 0); + _new_sprite = sprite_add(_sprite_direct + "/1.png", 1, 0, 0, 0, 0); var s = 2; while (file_exists(_sprite_direct + $"/{s}.png")) { var _merge_sprite = sprite_add(_sprite_direct + $"/{s}.png", 1, 0, 0, 0, 0); @@ -1945,9 +1946,10 @@ function DummyMarine() constructor { static armour = function() { var armours = global.list_basic_power_armour; var _last_armour = last_armour; + var _armour = ""; with (obj_creation) { if (!livery_picker.freeze_armour) { - var _armour = armour[100][livery_picker.role_set > 0 ? livery_picker.role_set : eROLE.TACTICAL]; + _armour = armour[100][livery_picker.role_set > 0 ? livery_picker.role_set : eROLE.TACTICAL]; if (array_contains(armours, _armour) || _armour == STR_ANY_POWER_ARMOUR) { _armour = array_random_element(armours); } else if (array_contains(global.list_terminator_armour, _armour) || _armour == STR_ANY_POWER_ARMOUR) { @@ -2188,8 +2190,9 @@ function add_purity_seal_markers() { } function format_weapon_visuals(weapon_name) { + var _weapon_visual_data = {}; if (struct_exists(global.weapon_visual_data, weapon_name)) { - var _weapon_visual_data = global.weapon_visual_data[$ weapon_name]; + _weapon_visual_data = global.weapon_visual_data[$ weapon_name]; } else { return []; } diff --git a/scripts/scr_destroy_planet/scr_destroy_planet.gml b/scripts/scr_destroy_planet/scr_destroy_planet.gml index ab4a9adbc3..3560c67ae3 100644 --- a/scripts/scr_destroy_planet/scr_destroy_planet.gml +++ b/scripts/scr_destroy_planet/scr_destroy_planet.gml @@ -3,17 +3,17 @@ function scr_destroy_planet(destruction_method) { var baid = 0; enemy9 = 0; + var you = noone; + var pip = instance_create(0, 0, obj_popup); if (destruction_method == 2) { - var pip; - pip = instance_create(0, 0, obj_popup); with (pip) { title = "Exterminatus"; image = "exterminatus"; text = "You give the order to fire the Cyclonic Torpedo. After a short descent it lands upon the surface and detonates- the air itself igniting across "; } - var you = obj_star_select.target; + you = obj_star_select.target; pip.text += you.name; pip.text += " " + scr_roman(obj_controller.selecting_planet); baid = obj_controller.selecting_planet; @@ -21,7 +21,6 @@ function scr_destroy_planet(destruction_method) { obj_star_select.torpedo -= 1; enemy9 = you.p_owner[obj_controller.selecting_planet]; } else if (destruction_method == 1) { - var pip = instance_create(0, 0, obj_popup); with (pip) { title = "Exterminatus"; image = "exterminatus"; @@ -31,7 +30,7 @@ function scr_destroy_planet(destruction_method) { } instance_activate_object(obj_star); - var you = battle_object; + you = battle_object; pip.text += planet_numeral_name(obj_ncombat.battle_id, battle_object); baid = obj_ncombat.battle_id; @@ -41,10 +40,9 @@ function scr_destroy_planet(destruction_method) { } // No survivors! - var unit; for (var cah = 0; cah <= obj_ini.companies; cah++) { for (var ed = 0; ed < array_length(obj_ini.role[cah]); ed++) { - unit = fetch_unit([cah, ed]); + var unit = fetch_unit([cah, ed]); if ((unit.location_string == you.name) && (unit.planet_location == baid)) { if (unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) { obj_controller.alarm[7] = 15; @@ -56,7 +54,6 @@ function scr_destroy_planet(destruction_method) { if (obj_ini.race[cah][ed] == 1) { var comm = unit.IsSpecialist(, true); - // if (obj_ini.race[cah,ed]=1) then obj_controller.marines-=1; if (comm == false) { obj_controller.marines -= 1; } diff --git a/scripts/scr_dialogue/scr_dialogue.gml b/scripts/scr_dialogue/scr_dialogue.gml index fb971c6088..80610ceb82 100644 --- a/scripts/scr_dialogue/scr_dialogue.gml +++ b/scripts/scr_dialogue/scr_dialogue.gml @@ -26,7 +26,7 @@ function interpret_diag_string(string_data, data) { // Relationship-based dialogue if (struct_exists(string_data, "relationship")) { - var _string = string_data.relationship[$ data.relationship]; + _string = string_data.relationship[$ data.relationship]; if (is_string(_string)) { return string_interpolate_from_struct(_string, data); } else { @@ -178,8 +178,8 @@ function scr_dialogue(diplo_keyphrase, data = {}) { // Option4 here if all the right conditions are met var born = false; - for (var ii = 1; i <= 200; i++) { - if ((obj_ini.role[0][ii] == obj_ini.role[100][eROLE.CHAPTERMASTER]) && (string_count("$", obj_ini.spe[0][ii]) > 0)) { + for (var i = 1; i <= 200; i++) { + if ((obj_ini.role[0][i] == obj_ini.role[100][eROLE.CHAPTERMASTER]) && (string_count("$", obj_ini.spe[0][i]) > 0)) { born = true; } } @@ -221,10 +221,10 @@ function scr_dialogue(diplo_keyphrase, data = {}) { var _string = $"Stand with me my brothers! Fight for the future of your Chapter, and slay {_master_of_sanct.name()}! [Battle loyalist {global.chapter_name}"; add_diplomacy_option({option_text: _string, goto: "cs_meeting_battle1", goto: "cs_meeting_battle1"}); - var _string = $"{global.chapter_name}, I order you to hold your fire! {_master_of_sanct.name()}, if you doubt my leadership then let it be decided by single combat! [Duel your Master of Sanctity]"; + _string = $"{global.chapter_name}, I order you to hold your fire! {_master_of_sanct.name()}, if you doubt my leadership then let it be decided by single combat! [Duel your Master of Sanctity]"; add_diplomacy_option({option_text: _string, goto: "cs_meeting_battle2"}); - var _string = $"I deny you {obj_controller.faction_leader[eFACTION.CHAOS]}. And now I shall destroy you. For the Emperor! [Attack Chaos forces]"; + _string = $"I deny you {obj_controller.faction_leader[eFACTION.CHAOS]}. And now I shall destroy you. For the Emperor! [Attack Chaos forces]"; add_diplomacy_option({option_text: _string, goto: "cs_meeting_battle5"}); } @@ -331,7 +331,6 @@ function scr_dialogue(diplo_keyphrase, data = {}) { if (diplo_keyphrase == "cs_meeting137") { diplo_text = $"When enough of your warriors have embraced Chaos, assemble them together in one place and then speak with me, and I will show you the beginning of the Eightfold Path. Now, begone.\n[[As you leave he calls out to you one more time.]]\nAnd {obj_ini.master_name}, I expect action within a few years. My patience, unlike Chaos, is not infinite."; complex_event = true; - current_eventing = ""; force_goodbye = 1; faction_status[eFACTION.CHAOS] = "Antagonism"; @@ -368,7 +367,8 @@ function scr_dialogue(diplo_keyphrase, data = {}) { instance_destroy(); } var _found = false; - var _star, _planet; + var _star = noone; + var _planet = noone; with (obj_star) { if (has_problem_star("meeting") > 0 && has_problem_star("meeting") > 0) { _found = true; @@ -381,14 +381,13 @@ function scr_dialogue(diplo_keyphrase, data = {}) { var _master = fetch_unit([0, 0]); if (_master.planet_location > 0) { var _master_star = find_star_by_name(_master.location_string); - if (_master_star != "none") { + if (_master_star != noone) { _found = true; _planet = _master.planet_location; _star = _master_star; } } } - // show_message(string(instance_number(obj_ground_mission))); if (_found) { instance_create(0, 0, obj_ncombat); @@ -2988,7 +2987,7 @@ function scr_dialogue(diplo_keyphrase, data = {}) { instance_destroy(); } with (obj_star) { - for (var i = 1; i <= 4; i++) { + for (var j = 1; j <= 4; j++) { if (planet_feature_bool(p_feature[1], eP_FEATURES.WARLORD10) == 1) { instance_create(x, y, obj_temp5); } @@ -2998,9 +2997,9 @@ function scr_dialogue(diplo_keyphrase, data = {}) { var you, nuum, plan = 0; you = instance_nearest(obj_temp5.x, obj_temp5.y, obj_star); nuum = you.name; - for (var i = 1; i <= you.planets; i++) { + for (var j = 1; j <= you.planets; j++) { if (planet_feature_bool(you.p_feature[1], eP_FEATURES.WARLORD10) == 1) { - plan = i; + plan = j; } } found = 1; @@ -3023,7 +3022,7 @@ function scr_dialogue(diplo_keyphrase, data = {}) { instance_destroy(); } with (obj_star) { - for (var i = 1; i <= 4; i++) { + for (var j = 1; j <= 4; j++) { if (planet_feature_bool(p_feature[1], eP_FEATURES.ORKWARBOSS) == 1) { instance_create(x, y, obj_temp5); } @@ -3033,9 +3032,9 @@ function scr_dialogue(diplo_keyphrase, data = {}) { var you, nuum, plan = 0; you = instance_nearest(obj_temp5.x, obj_temp5.y, obj_star); nuum = you.name; - for (var i = 1; i <= you.planets; i++) { + for (var j = 1; j <= you.planets; j++) { if (planet_feature_bool(you.p_feature[1], eP_FEATURES.ORKWARBOSS) == 1) { - plan = i; + plan = j; } } if (you.p_orks[plan] < 6) { @@ -3101,7 +3100,7 @@ function scr_dialogue(diplo_keyphrase, data = {}) { } var that, good = 0; that = instance_nearest(random(room_width), random(room_height), obj_star); - for (var i = 0; i < 5; i++) { + for (var index = 0; index < 5; index++) { if (good == 0) { with (that) { var j = 0, onceh = 0; @@ -3167,9 +3166,9 @@ function scr_dialogue(diplo_keyphrase, data = {}) { with (that) { var onceh = 0; for (var k = 0; k < 10; k++) { - var i = floor(random(planets)) + 1; - if ((array_length(p_feature[i]) == 0) && (onceh == 0)) { - onceh = i; + var l = floor(random(planets)) + 1; + if ((array_length(p_feature[l]) == 0) && (onceh == 0)) { + onceh = l; } } if (onceh != 0) { diff --git a/scripts/scr_diplomacy_helpers/scr_diplomacy_helpers.gml b/scripts/scr_diplomacy_helpers/scr_diplomacy_helpers.gml index 01ba720870..914a8d87d4 100644 --- a/scripts/scr_diplomacy_helpers/scr_diplomacy_helpers.gml +++ b/scripts/scr_diplomacy_helpers/scr_diplomacy_helpers.gml @@ -238,7 +238,7 @@ function evaluate_chosen_diplomacy_option(diplo_pressed) { } } -function scr_diplomacy_hit(selection, new_path = undefined, complex_path = "none") { +function scr_diplomacy_hit(selection, new_path = undefined, complex_path = undefined) { if (array_length(option_selections) > selection) { if (point_and_click(option_selections[selection])) { if (!is_method(complex_path)) { @@ -277,7 +277,7 @@ function scr_emmisary_diplomacy_routes() { //grab a random librarian var lib = scr_random_marine(SPECIALISTS_LIBRARIANS, 0); if (lib != "none") { - var chapter_master = obj_ini.TTRPG[0][1]; + chapter_master = obj_ini.TTRPG[0][1]; var dead_lib = obj_ini.TTRPG[lib[0]][lib[1]]; pop_up = instance_create(0, 0, obj_popup); pop_up.title = "Skull for the Skull Throne"; @@ -308,9 +308,6 @@ function scr_emmisary_diplomacy_routes() { pop_up.text = $"You summon {dead_champ.name_role()} to your personal chambers. Darting from the shadows towards {dead_champ.name()} who is a cunning warrior and reacts with precision to your attack, however eventually you prevail and strike him down. With the flesh removed from his skull you place it upon a hastily erected shrine."; pop_up.type = 98; pop_up.image = "chaos"; - // obj_duel = instance_create(0,0,obj_duel); - // obj_duel.title = "Ambush Champion"; - // pop.type="duel"; kill_and_recover(champ[0], champ[1]); } else { diplomacy_pathway = "daemon_scorn"; diff --git a/scripts/scr_draw_management_unit/scr_draw_management_unit.gml b/scripts/scr_draw_management_unit/scr_draw_management_unit.gml index ddbf2f4d5a..9b93b7bfe6 100644 --- a/scripts/scr_draw_management_unit/scr_draw_management_unit.gml +++ b/scripts/scr_draw_management_unit/scr_draw_management_unit.gml @@ -1,13 +1,15 @@ /// @self Asset.GMObject.obj_controller function scr_draw_management_unit(selected, yy = 0, xx = 0, draw = true, click_lock = false) { var assignment = "none"; - var _unit; + var _unit = noone; var string_role = ""; var health_string = ""; var eventing = false; var jailed = false; var impossible = !is_struct(display_unit[selected]) && !is_array(display_unit[selected]); var is_man = false; + var unit_location_string = ""; + var unit_specialist = false; if (man[selected] == "man" && is_struct(display_unit[selected])) { is_man = true; _unit = display_unit[selected]; @@ -32,8 +34,7 @@ function scr_draw_management_unit(selected, yy = 0, xx = 0, draw = true, click_l return "continue"; } } - var unit_specialist = is_specialist(_unit.role()); - var unit_location_string = ""; + unit_specialist = is_specialist(_unit.role()); if (_unit.in_jail()) { jailed = true; unit_location_string = "=Penitorium="; @@ -68,8 +69,6 @@ function scr_draw_management_unit(selected, yy = 0, xx = 0, draw = true, click_l if (draw) { health_string = ma_health_string[selected]; - var exp_string = $"{round(ma_exp[selected])} EXP"; - ma_ar = ""; ma_we1 = ""; ma_we2 = ""; @@ -105,7 +104,6 @@ function scr_draw_management_unit(selected, yy = 0, xx = 0, draw = true, click_l } } } else if (man[selected] == "vehicle" && is_array(display_unit[selected]) && draw) { - // string_role="v "+string(managing)+"."+string(ide[selected]); string_role = string(ma_role[selected]); unit_location_string = string(ma_loc[selected]); @@ -116,7 +114,6 @@ function scr_draw_management_unit(selected, yy = 0, xx = 0, draw = true, click_l unit_location_string = obj_ini.ship[ma_lid[selected]]; } health_string = string(round(ma_health[selected])) + "% HP"; - exp_string = ""; // Need abbreviations here ma_ar = ""; @@ -150,7 +147,6 @@ function scr_draw_management_unit(selected, yy = 0, xx = 0, draw = true, click_l if (ma_wep2[selected] != "") { ma_we2 = gear_weapon_data("weapon", ma_wep2[selected], "abbreviation"); ma_we2 = is_string(ma_we2) ? ma_we2 : ""; - // temp5=string(ma_wep1[selected])+", "+string(ma_wep2[selected])+" + "+string(ma_gear[selected]); } } @@ -174,13 +170,13 @@ function scr_draw_management_unit(selected, yy = 0, xx = 0, draw = true, click_l draw_set_alpha(1); draw_rectangle(xx + 25, yy + 64, xx + 974, yy + 85, 1); if (man[selected] == "man" && is_struct(display_unit[selected])) { - var _unit = display_unit[selected]; + _unit = display_unit[selected]; var _is_rank_file = is_specialist(_unit.role(), SPECIALISTS_RANK_AND_FILE); if (_is_rank_file) { var _role = _unit.role(); var _experience = _unit.experience; - var _data, valid = false; + var _data; var _circle_coords = [ xx + 321, yy + 77 @@ -298,8 +294,6 @@ function scr_draw_management_unit(selected, yy = 0, xx = 0, draw = true, click_l } draw_line(xx + 25 + 8, yy + 64, xx + 25 + 8, yy + 85); - // was 885 - // 974 if ((man[selected] == "man") && (ma_ar == "")) { draw_set_alpha(0.5); @@ -312,6 +306,7 @@ function scr_draw_management_unit(selected, yy = 0, xx = 0, draw = true, click_l } } + var exp_string = $"{round(ma_exp[selected])} EXP"; var hpText = [ xx + 240 + 8, yy + 66, @@ -360,8 +355,7 @@ function scr_draw_management_unit(selected, yy = 0, xx = 0, draw = true, click_l draw_sprite(spr_loc_icon, 2, xx + 427 + 8, yy + 66); } else { if (man[selected] == "man") { - c = managing <= 10 ? managing : 0; - var _unit = display_unit[selected]; + _unit = display_unit[selected]; if ((ma_lid[selected] > -1) && (ma_wid[selected] == 0)) { draw_sprite(spr_loc_icon, _unit.is_boarder ? 2 : 1, xx + 427 + 8, yy + 66); diff --git a/scripts/scr_draw_unit_image/scr_draw_unit_image.gml b/scripts/scr_draw_unit_image/scr_draw_unit_image.gml index 3f5062e37b..f51b01da91 100644 --- a/scripts/scr_draw_unit_image/scr_draw_unit_image.gml +++ b/scripts/scr_draw_unit_image/scr_draw_unit_image.gml @@ -524,6 +524,32 @@ function scr_draw_unit_image(_background = false) { draw_sprite(spr_skitarii, 0, x_surface_offset, y_surface_offset); } } + + // ===== Guardsman portrait (mod) ===== + // Guardsmen are base_group "human", so the Marine body-part composition above is + // skipped and the surface is left empty. Draw the static guardsman portrait here, the + // same way Skitarii and Sisters draw theirs, loaded once from a runtime PNG because the + // mod cannot add compiled sprite assets. The image ships at images\units\guardsman.png. + // If alignment needs nudging, offset the draw from x_surface_offset / y_surface_offset. + if (role() == "Guardsman" || role() == "Veteran Guard" || role() == "Heavy Weapons Team") { + if (!variable_global_exists("guardsman_portrait")) { + global.guardsman_portrait = sprite_add(working_directory + "/images/units/guardsman.png", 1, false, false, 0, 0); + } + if (sprite_exists(global.guardsman_portrait)) { + draw_sprite(global.guardsman_portrait, 0, x_surface_offset, y_surface_offset); + } + } + + // ===== Guard Sergeant portrait (mod) ===== + // Same runtime-PNG approach as the guardsman above. The image ships at images\units\sarge.png. + if (role() == "Guard Sergeant") { + if (!variable_global_exists("sarge_portrait")) { + global.sarge_portrait = sprite_add(working_directory + "/images/units/sarge.png", 1, false, false, 0, 0); + } + if (sprite_exists(global.sarge_portrait)) { + draw_sprite(global.sarge_portrait, 0, x_surface_offset, y_surface_offset); + } + } surface_reset_target(); shader_reset(); diff --git a/scripts/scr_draw_unit_stat_data/scr_draw_unit_stat_data.gml b/scripts/scr_draw_unit_stat_data/scr_draw_unit_stat_data.gml index 8f279cde8c..efb3eccebb 100644 --- a/scripts/scr_draw_unit_stat_data/scr_draw_unit_stat_data.gml +++ b/scripts/scr_draw_unit_stat_data/scr_draw_unit_stat_data.gml @@ -1,18 +1,15 @@ -// Script assets have changed for v2.3.0 see -// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information function scr_draw_unit_stat_data(manage = false, data_block = {x1: 1008, y1: 520, w: 569, h: 303}, squeezed = false) { var _cur_font = draw_get_font(); draw_set_font(fnt_40k_14); + var xx = camera_get_view_x(view_camera[0]); + var yy = camera_get_view_y(view_camera[0]); if (event_number == ev_gui) { xx = 0; yy = 0; - } else { - var xx = camera_get_view_x(view_camera[0]); - var yy = camera_get_view_y(view_camera[0]); } - var stat_tool_tips = []; - var trait_tool_tips = []; - var unit_name = name(); + var _stat_tool_tips = []; + var _trait_tool_tips = []; + var _unit_name = self.name(); if (psionic < 0) { var _psy_levels = global.arr_negative_psy_levels; var _psionic_assignment = _psy_levels[psionic * -1]; @@ -27,7 +24,7 @@ function scr_draw_unit_stat_data(manage = false, data_block = {x1: 1008, y1: 520 data_block.x_mid = (data_block.x1 + data_block.x2) / 2; data_block.y_mid = (data_block.y1 + data_block.y2) / 2; - var attribute_box = { + var _attribute_box = { x1: data_block.x1 + (squeezed ? 42 : 84), y1: data_block.y1 + 8, w: 32, @@ -39,10 +36,10 @@ function scr_draw_unit_stat_data(manage = false, data_block = {x1: 1008, y1: 520 draw_rectangle(x1, y1, x2, y2, outline); }, }; - attribute_box.x2 = attribute_box.x1 + attribute_box.w; - attribute_box.y2 = attribute_box.y1 + attribute_box.h; - attribute_box.x_mid = (attribute_box.x1 + attribute_box.x2) / 2; - attribute_box.y_mid = (attribute_box.y1 + attribute_box.y2) / 2; + _attribute_box.x2 = _attribute_box.x1 + _attribute_box.w; + _attribute_box.y2 = _attribute_box.y1 + _attribute_box.h; + _attribute_box.x_mid = (_attribute_box.x1 + _attribute_box.x2) / 2; + _attribute_box.y_mid = (_attribute_box.y1 + _attribute_box.y2) / 2; stat_display_list = [ [ @@ -90,221 +87,153 @@ function scr_draw_unit_stat_data(manage = false, data_block = {x1: 1008, y1: 520 "charisma" ] ]; - // draw_set_color(c_gray); - // draw_rectangle(stat_block.x1,stat_block.y1, stat_block.x1 + (36*array_length(stat_display_list)), stat_block.y1+48+8, 0) - // draw_set_color(c_black); - // draw_rectangle(stat_block.x1,stat_block.y1, stat_block.x1 + (4*array_length(stat_display_list)), stat_block.y1+48+4, 1) - var viewing_stat, icon_colour; for (var i = 0; i < array_length(stat_display_list); i++) { - var stat_data = stat_display_list[i]; - var stat_key = stat_data[1]; - var stat_abbreviation = global.stat_shorts[$ stat_key]; - var _stat_name = global.stat_display_strings[$ stat_key]; - var _icon = global.stat_icons[$ stat_key]; - var _stat_description = stat_data[0]; - var _stat_col = global.stat_display_colour[$ stat_key]; - - if (attribute_box.enter()) { - icon_colour = c_white; + var _stat_data = stat_display_list[i]; + var _stat_key = _stat_data[1]; + var _stat_abbreviation = global.stat_shorts[$ _stat_key]; + var _stat_name = global.stat_display_strings[$ _stat_key]; + var _icon = global.stat_icons[$ _stat_key]; + var _stat_description = _stat_data[0]; + var _stat_col = global.stat_display_colour[$ _stat_key]; + var _icon_colour = c_gray; + + if (_attribute_box.enter()) { + _icon_colour = c_white; draw_set_color(_stat_col); - attribute_box.draw(false); - } else { - icon_colour = c_gray; + _attribute_box.draw(false); } - //draw_rectangle(stat_square.x1-1,stat_square.y1-1,stat_square.x1+33,stat_square.y1+49, 1); draw_set_color(c_gray); - attribute_box.draw(true); - draw_sprite_ext(_icon, 0, attribute_box.x1, attribute_box.y1, 0.5, 0.5, 0, icon_colour, 1); + _attribute_box.draw(true); + draw_sprite_ext(_icon, 0, _attribute_box.x1, _attribute_box.y1, 0.5, 0.5, 0, _icon_colour, 1); draw_set_color(#50a076); draw_set_halign(fa_center); - draw_text((attribute_box.x1 + attribute_box.x2) / 2, attribute_box.y1 + 32, $"{self[$ stat_key]}"); + draw_text((_attribute_box.x1 + _attribute_box.x2) / 2, _attribute_box.y1 + 32, $"{self[$ _stat_key]}"); draw_set_halign(fa_left); if (manage) { - if (point_and_click([attribute_box.x1, attribute_box.y1, attribute_box.x2, attribute_box.y1 + 45])) { - filter_and_sort_company("stat", stat_key); + if (point_and_click([_attribute_box.x1, _attribute_box.y1, _attribute_box.x2, _attribute_box.y1 + 45])) { + filter_and_sort_company("stat", _stat_key); obj_controller.unit_bio = false; } } var stat_percentage = 0; if (is_struct(obj_controller.temp[122])) { - if (struct_exists(obj_controller.temp[122], stat_key)) { - stat_percentage = obj_controller.temp[122][$ stat_key]; + if (struct_exists(obj_controller.temp[122], _stat_key)) { + stat_percentage = obj_controller.temp[122][$ _stat_key]; } } var _final_string = $"{_stat_description} #Click to order by highest {_stat_name}#{stat_percentage}% chance of growth"; - array_push(stat_tool_tips, [attribute_box.x1, attribute_box.y1, attribute_box.x2, attribute_box.y2, _final_string, $"{_stat_name} ({stat_abbreviation})"]); - attribute_box.x1 += 36; - attribute_box.x2 += 36; + array_push(_stat_tool_tips, [_attribute_box.x1, _attribute_box.y1, _attribute_box.x2, _attribute_box.y2, _final_string, $"{_stat_name} ({_stat_abbreviation})"]); + _attribute_box.x1 += 36; + _attribute_box.x2 += 36; } - // var data_block.x_mid = stats_block.x1+((attribute_box.x1 - stats_block.x1)/2); - // var data_block.y_mid = attribute_box.y2+4; - - // draw_set_color(c_gray); - // draw_rectangle(data_block.x_mid-70,data_block.y_mid, data_block.x_mid+67, data_block.y_mid+70, 0); - // draw_set_color(c_black); - // draw_rectangle(data_block.x_mid-66,data_block.y_mid+1, data_block.x_mid-1, data_block.y_mid+65, 1); - // draw_rectangle(data_block.x_mid-66,data_block.y_mid,data_block.x_mid-1,data_block.y_mid+64, 0); - - // var psy_box = { - // x1: attribute_box.x2-36, - // y1: attribute_box.y1, - // w: attribute_box.w, - // h: attribute_box.h, - // } - // psy_box.x2 = psy_box.x1 + psy_box.w; - // psy_box.y2 = psy_box.y1 + psy_box.h; - // psy_box.x_mid = (psy_box.x1 + psy_box.x2) / 2; - // psy_box.y_mid = (psy_box.y1 + psy_box.y2) / 2; - // draw_set_color(c_gray); - // draw_rectangle(psy_box.x1,psy_box.y1,psy_box.x2,psy_box.y2, 1); - // draw_set_color(c_white); - // draw_sprite_stretched(spr_warp_level_icon, 2, psy_box.x1, psy_box.y1, psy_box.w, psy_box.h); - // draw_set_halign(fa_center); - // draw_set_valign(fa_middle); - // draw_text(psy_box.x_mid, psy_box.y_mid+3, $"{psionic}") - // var assignment_description = "The Imperium measures and records the psionic activity and power level of psychic individuals through a rating system called The Assignment. Comprised of a twenty-four point scale, The Assignment simplifies the comparison of psykers to aid Imperial authorities in recognizing possible threats."; - // array_push(stat_tool_tips, [psy_box.x1, psy_box.y1, psy_box.x2, psy_box.y2, assignment_description, "The Assignment"]); - - // var forge_box = { - // x1: attribute_box.x2, - // y1: attribute_box.y1, - // w: attribute_box.w, - // h: attribute_box.h, - // } - // forge_box.x2 = forge_box.x1 + forge_box.w; - // forge_box.y2 = forge_box.y1 + forge_box.h; - // forge_box.x_mid = (forge_box.x1 + forge_box.x2) / 2; - // forge_box.y_mid = (forge_box.y1 + forge_box.y2) / 2; - // //draw_rectangle(data_block.x_mid+1,data_block.y_mid+2,data_block.x_mid+1,data_block.y_mid+34, 0); - // var is_forge = IsSpecialist(SPECIALISTS_TECHS); - // if (is_forge){ - // draw_set_color(c_gray); - // draw_rectangle(forge_box.x1,forge_box.y1,forge_box.x2,forge_box.y2, 1); - // draw_set_color(c_white); - // draw_sprite_stretched(spr_forge_points_icon, 1, forge_box.x1-6, forge_box.y1-4, forge_box.w+12, forge_box.h+8); - // draw_set_halign(fa_center); - // draw_set_valign(fa_middle); - // draw_text(forge_box.x_mid, forge_box.y_mid, $"{forge_point_generation()[0]}"); - // var forge_description = ""; - // array_push(stat_tool_tips, [forge_box.x1,forge_box.y1,forge_box.x2,forge_box.y2, $"{forge_point_generation()}", "Craftsmanship"]); - // } - - //var warp_box_size = tooltip_draw(stat_square.x1,stat_square.y1+56,$"Warp Level:{psionic}"); - //draw_set_color(c_red); - //if (IsSpecialist(SPECIALISTS_TECHS)){ - // tooltip_draw(stat_square.x1,stat_square.y1+45+warp_box_size[1],$"Forge Points:{forge_point_generation()}"); - //} - // draw_line(stat_block.x1, yy+519, stat_block.x1, yy+957); - // draw_line(stat_square.x1, yy+519, stat_square.x1, yy+957); - draw_set_halign(fa_left); draw_set_valign(fa_top); draw_set_color(#50a076); if (!obj_controller.view_squad && obj_controller.unit_bio) { - var unit_data_string = unit_profile_text(); - tooltip_draw(unit_data_string, 925, [xx + 23, yy + 141],,,,, true); + var _unit_data_string = unit_profile_text(); + tooltip_draw(_unit_data_string, 925, [xx + 23, yy + 141],,,,, true); } - var data_lines = []; - var data_entry = {}; - data_entry.text = $"Loyalty: {loyalty}\n"; - data_entry.tooltip = "Loyalty represents the unwavering devotion to one's Chapter, their Primarch, and the Emperor himself. It is a measure of their ability to resist the temptations of Chaos, the influence of xenos artifacts, and the machinations of the Warp."; - array_push(data_lines, data_entry); - - data_entry = {}; - data_entry.text = $"Corruption: {corruption}\n"; - data_entry.tooltip = "Corruption reflects exposure to the malevolent forces of the Warp. High Corruption may indicate that the person is teetering on the brink of damnation, while a low score suggests relative purity."; - array_push(data_lines, data_entry); - - data_entry = {}; - data_entry.text = $"Assignment: {_psionic_assignment} ({psionic})\n"; - data_entry.tooltip = "The Imperium measures and records the psionic activity and power level of psychic individuals through a rating system called The Assignment. Comprised of a twenty-four point scale, The Assignment simplifies the comparison of psykers to aid Imperial authorities in recognizing possible threats."; - array_push(data_lines, data_entry); - - var forge_gen = forge_point_generation(); - - data_entry = {}; - data_entry.tooltip = ""; - var gen_reasons = forge_gen[1]; - data_entry.text = $"Forge Production: {forge_gen[0]}\n"; - if (struct_exists(gen_reasons, "trained")) { - data_entry.tooltip += $"Trained On Mars (TEC/10): {gen_reasons.trained}\n"; - if (struct_exists(gen_reasons, "at_forge")) { - data_entry.tooltip += $"{gen_reasons.at_forge}(at Forge)\n"; + var _data_lines = []; + var _data_entry = {}; + _data_entry.text = $"Loyalty: {loyalty}\n"; + _data_entry.tooltip = "Loyalty represents the unwavering devotion to one's Chapter, their Primarch, and the Emperor himself. It is a measure of their ability to resist the temptations of Chaos, the influence of xenos artifacts, and the machinations of the Warp."; + array_push(_data_lines, _data_entry); + + _data_entry = {}; + _data_entry.text = $"Corruption: {corruption}\n"; + _data_entry.tooltip = "Corruption reflects exposure to the malevolent forces of the Warp. High Corruption may indicate that the person is teetering on the brink of damnation, while a low score suggests relative purity."; + array_push(_data_lines, _data_entry); + + _data_entry = {}; + _data_entry.text = $"Assignment: {_psionic_assignment} ({psionic})\n"; + _data_entry.tooltip = "The Imperium measures and records the psionic activity and power level of psychic individuals through a rating system called The Assignment. Comprised of a twenty-four point scale, The Assignment simplifies the comparison of psykers to aid Imperial authorities in recognizing possible threats."; + array_push(_data_lines, _data_entry); + + var _forge_gen = forge_point_generation(); + + _data_entry = {}; + _data_entry.tooltip = ""; + var _gen_reasons = _forge_gen[1]; + _data_entry.text = $"Forge Production: {_forge_gen[0]}\n"; + if (struct_exists(_gen_reasons, "trained")) { + _data_entry.tooltip += $"Trained On Mars (TEC/10): {_gen_reasons.trained}\n"; + if (struct_exists(_gen_reasons, "at_forge")) { + _data_entry.tooltip += $"{_gen_reasons.at_forge}(at Forge)\n"; } } - if (struct_exists(gen_reasons, "master")) { - data_entry.tooltip += $"Forge Master: +{gen_reasons.master}\n"; + if (struct_exists(_gen_reasons, "master")) { + _data_entry.tooltip += $"Forge Master: +{_gen_reasons.master}\n"; } - if (struct_exists(gen_reasons, "crafter")) { - data_entry.tooltip += $"Crafter: +{gen_reasons.crafter}\n"; + if (struct_exists(_gen_reasons, "crafter")) { + _data_entry.tooltip += $"Crafter: +{_gen_reasons.crafter}\n"; } - if (struct_exists(gen_reasons, "maintenance")) { - data_entry.tooltip += $"Maintenance: {gen_reasons.maintenance}"; + if (struct_exists(_gen_reasons, "maintenance")) { + _data_entry.tooltip += $"Maintenance: {_gen_reasons.maintenance}"; } - array_push(data_lines, data_entry); + array_push(_data_lines, _data_entry); - for (var i = 0; i < array_length(data_lines); i++) { - draw_text(data_block.x1 + 16, attribute_box.y2 + 16 + (i * 24), data_lines[i].text); // Adjust the y-coordinate for the new line - array_push(stat_tool_tips, [data_block.x1 + 16, attribute_box.y2 + 16 + (i * 24), data_block.x1 + 16 + string_width(data_lines[i].text), attribute_box.y2 + 16 + (i * 24) + string_height(data_lines[i].text), data_lines[i].tooltip, ""]); + for (var i = 0; i < array_length(_data_lines); i++) { + draw_text(data_block.x1 + 16, _attribute_box.y2 + 16 + (i * 24), _data_lines[i].text); // Adjust the y-coordinate for the new line + array_push(_stat_tool_tips, [data_block.x1 + 16, _attribute_box.y2 + 16 + (i * 24), data_block.x1 + 16 + string_width(_data_lines[i].text), _attribute_box.y2 + 16 + (i * 24) + string_height(_data_lines[i].text), _data_lines[i].tooltip, ""]); } var x1 = squeezed ? data_block.x1 + ((data_block.x2 - data_block.x1) / 2) + 32 : data_block.x2 - 16; if (array_length(traits) != 0) { for (var i = 0; i < array_length(traits); i++) { - var trait = global.trait_list[$ traits[i]]; - var trait_name = trait.display_name; - var trait_description = string(trait.flavour_text, unit_name); - var trait_effect = ""; - if (struct_exists(trait, "effect")) { - trait_effect = string(trait.effect + "." + "\n\n"); + var _trait = global.trait_list[$ traits[i]]; + var _trait_name = _trait.display_name; + var _trait_description = string(_trait.flavour_text, _unit_name); + var _trait_effect = ""; + if (struct_exists(_trait, "effect")) { + _trait_effect = string(_trait.effect + "." + "\n\n"); } - var y1 = attribute_box.y2 + 16 + (i * 24); + var y1 = _attribute_box.y2 + 16 + (i * 24); draw_set_halign(fa_right); - draw_text(x1, y1, trait_name); + draw_text(x1, y1, _trait_name); draw_set_halign(fa_left); - var x2 = x1 - string_width(trait_name); - var y2 = y1 + string_height(trait_name); + var x2 = x1 - string_width(_trait_name); + var y2 = y1 + string_height(_trait_name); var _trait_growth_effect = ""; var _stat_list = global.stat_list; for (var j = 0; j < array_length(_stat_list); j++) { var _stat = _stat_list[j]; var _stat_name = global.stat_display_strings[$ _stat]; - if (struct_exists(trait, _stat)) { - var _stat_val = eval_trait_stat_data(trait[$ _stat]); - var descriptive_string = ""; + if (struct_exists(_trait, _stat)) { + var _stat_val = eval_trait_stat_data(_trait[$ _stat]); + var _descriptive_string = ""; if (_stat_val > 0) { repeat (max(floor(_stat_val / 2), 1)) { - descriptive_string += "+"; + _descriptive_string += "+"; } } else { repeat (max(floor((_stat_val * -1) / 2), 1)) { - descriptive_string += "-"; + _descriptive_string += "-"; } } - _trait_growth_effect += $"{_stat_name} : {descriptive_string}\n"; + _trait_growth_effect += $"{_stat_name} : {_descriptive_string}\n"; } } - array_push(trait_tool_tips, [x1, y1, x2, y2, $"{trait_description}\n{trait_effect}\n{_trait_growth_effect}" + trait_effect]); + array_push(_trait_tool_tips, [x1, y1, x2, y2, $"{_trait_description}\n{_trait_effect}\n{_trait_growth_effect}" + _trait_effect]); } } else { draw_set_halign(fa_right); - draw_text(data_block.x2 - 16, attribute_box.y2 + 16, "No Traits"); + draw_text(data_block.x2 - 16, _attribute_box.y2 + 16, "No Traits"); draw_set_halign(fa_left); } - for (var i = 0; i < array_length(stat_tool_tips); i++) { - if (scr_hit(stat_tool_tips[i])) { - tooltip_draw(stat_tool_tips[i][4], 300, [stat_tool_tips[i][0], stat_tool_tips[i][3]],,, stat_tool_tips[i][5]); + for (var i = 0; i < array_length(_stat_tool_tips); i++) { + if (scr_hit(_stat_tool_tips[i])) { + tooltip_draw(_stat_tool_tips[i][4], 300, [_stat_tool_tips[i][0], _stat_tool_tips[i][3]],,, _stat_tool_tips[i][5]); } } - for (var i = 0; i < array_length(trait_tool_tips); i++) { - if (point_in_rectangle(mouse_x, mouse_y, trait_tool_tips[i][2], trait_tool_tips[i][1], trait_tool_tips[i][0], trait_tool_tips[i][3])) { - tooltip_draw(trait_tool_tips[i][4], 300); + for (var i = 0; i < array_length(_trait_tool_tips); i++) { + if (point_in_rectangle(mouse_x, mouse_y, _trait_tool_tips[i][2], _trait_tool_tips[i][1], _trait_tool_tips[i][0], _trait_tool_tips[i][3])) { + tooltip_draw(_trait_tool_tips[i][4], 300); } } diff --git a/scripts/scr_drop_select_function/scr_drop_select_function.gml b/scripts/scr_drop_select_function/scr_drop_select_function.gml index 55814adb37..f7d54123b1 100644 --- a/scripts/scr_drop_select_function/scr_drop_select_function.gml +++ b/scripts/scr_drop_select_function/scr_drop_select_function.gml @@ -22,9 +22,6 @@ function drop_select_unit_selection() { if (purge == eDROP_TYPE.RAIDATTACK) { draw_set_font(fnt_40k_30b); - - // var xx,yy; - // xx=view_xview[0]+545;yy=view_yview[0]+212; draw_set_halign(fa_left); draw_set_color(c_gray); var attack_type = attack ? "Attacking" : "Raiding"; @@ -49,15 +46,24 @@ function drop_select_unit_selection() { // draw_rectangle(xx+1084,yy+215,xx+1142,yy+273,0); // Formation - var _formation_str = $"Formation: {obj_controller.bat_formation[formation_possible[formation_current]]}"; + // Hardening: never index formation_possible without checking it is non-empty and the + // index is in range. A drifted or stale formation_current (e.g. across a load) would + // otherwise crash the whole drop screen on draw. + var _formation_str = "Formation: -"; + if (array_length(formation_possible) > 0) { + formation_current = clamp(formation_current, 0, array_length(formation_possible) - 1); + _formation_str = $"Formation: {obj_controller.bat_formation[formation_possible[formation_current]]}"; + } formation.x1 = x2 - 40 - (string_width(_formation_str) + 4); formation.y1 = y1 + 80; formation.update({str1: _formation_str}); formation.draw(); if (formation.clicked()) { - formation_current++; - if (formation_current >= array_length(formation_possible)) { - formation_current = 0; + if (array_length(formation_possible) > 0) { + formation_current++; + if (formation_current >= array_length(formation_possible)) { + formation_current = 0; + } } } @@ -138,12 +144,11 @@ function drop_select_unit_selection() { _x_offset += _button.width + 10; } - // draw_text(x2 + 14, y2 + 352, string_hash_to_newline("Selection: " + string(smin) + "/" + string(smax))); - // Target var race_quantity = 0; if (purge == eDROP_TYPE.RAIDATTACK) { - var target_race = "", target_threat = "", race_quantity = 0; + var target_race = ""; + var target_threat = ""; if (attacking >= 5 && attacking <= 13) { race_quantity = race_quantities[attacking - 4]; @@ -205,11 +210,19 @@ function drop_select_unit_selection() { if (purge == 0) { combating = 1; // Start battle here + // Hardening: resolve the chosen formation through a single bounds-checked read so a + // bad formation_current cannot crash the drop launch. Falls back to formation 0 when + // no formations are available. + var _chosen_form = 0; + if (array_length(formation_possible) > 0) { + _chosen_form = formation_possible[clamp(formation_current, 0, array_length(formation_possible) - 1)]; + } + if (attack == 1) { - obj_controller.last_attack_form = formation_possible[formation_current]; + obj_controller.last_attack_form = _chosen_form; } if (attack == 0) { - obj_controller.last_raid_form = formation_possible[formation_current]; + obj_controller.last_raid_form = _chosen_form; } instance_deactivate_all(true); @@ -218,7 +231,7 @@ function drop_select_unit_selection() { instance_activate_object(obj_drop_select); // 135 ; temporary balancing - if (sh_target != -50) { + if (sh_target != noone) { sh_target.acted += 1; } @@ -234,10 +247,15 @@ function drop_select_unit_selection() { obj_ncombat.dropping = 1 - attack; obj_ncombat.attacking = attack; obj_ncombat.enemy = attacking; - obj_ncombat.formation_set = formation_possible[formation_current]; + obj_ncombat.formation_set = _chosen_form; obj_ncombat.defending = false; obj_ncombat.local_forces = roster.local_button.active; + // (Imperial Guard assault bring-along disabled for now: the player-side + // battlefield unit needs real per-model data, so this is being rebuilt. + // Until then we do not touch the embarked Guard, so attacks cost nothing.) + obj_ncombat.player_attack_guard = 0; + var _planet = obj_ncombat.battle_object.p_feature[obj_ncombat.battle_id]; if (obj_ncombat.battle_object.space_hulk == 1) { obj_ncombat.battle_special = "space_hulk"; @@ -413,7 +431,7 @@ function drop_select_draw() { draw_text_transformed(x2 + 14, y2 + 12, string(_purge_strings[purge - 2], _planet_string), 0.6, 0.6, 0); // Disposition here - var succession = 0, pp = planet_number; + var pp = planet_number; var succession = has_problem_planet(pp, "succession", p_target); @@ -479,7 +497,7 @@ function collect_local_units() { purge_d = ship_max[500]; if (purge == 1) { - if (sh_target != -50) { + if (sh_target != noone) { max_ships = sh_target.capital_number + sh_target.frigate_number + sh_target.escort_number; if (sh_target.acted >= 1) { diff --git a/scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml b/scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml index 74039d9832..88fc4e9775 100644 --- a/scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml +++ b/scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml @@ -1,8 +1,8 @@ /// @self Asset.GMObject.obj_star function scr_enemy_ai_a() { + var _garrison = noone; for (var i = 1; i <= planets; i++) { - var _ops = p_operatives[i]; - var _garrison = get_garrison(i); + _garrison = get_garrison(i); _garrison.increase_time_on_planet(); get_sabatours(i); get_planet_data(i); @@ -458,10 +458,9 @@ function scr_enemy_ai_a() { } if (guard_attack == "pdf") { + var pdf_mod = irandom(5) + 1; if (pdf_with_player) { pdf_mod = irandom_range(1, 6 + _garrison.total_garrison * 0.1); - } else { - pdf_mod = irandom(5) + 1; } rand1 = (choose(3, 4, 5, 6) * guard_score) * choose(1, 1.25, 1.25); rand2 = (pdf_mod * pdf_score) * choose(1, 1.25); @@ -489,7 +488,7 @@ function scr_enemy_ai_a() { if (_planet_data.population_influences[eFACTION.TYRANIDS] > 50 && _planet_data.has_feature(eP_FEATURES.GENE_STEALER_CULT)) { var _cur_influ = p_influence[_run][eFACTION.TYRANIDS]; var _influence_reduction = _cur_influ * (p_pdf[_run] / _pdf_before); - adjust_influence(eFACTION.TYRANIDS, -min(_influence_reduction, _cur_influ - 3), _run); + adjust_influence(eFACTION.TYRANIDS, -min(_influence_reduction, _cur_influ - 3), _run, self); if (p_influence[_run][eFACTION.TYRANIDS] < 20) { _planet_data.delete_feature(eP_FEATURES.GENE_STEALER_CULT); } @@ -1190,7 +1189,7 @@ function scr_enemy_ai_a() { if (p_tyranids[_run] != after_combat_tyranids) { p_tyranids[_run] = after_combat_tyranids; if (_planet_data.has_feature(eP_FEATURES.GENE_STEALER_CULT)) { - adjust_influence(eFACTION.TYRANIDS, -min(p_influence[_run][eFACTION.TYRANIDS] - 4, 5), _run); + adjust_influence(eFACTION.TYRANIDS, -min(p_influence[_run][eFACTION.TYRANIDS] - 4, 5), _run, self); var _cult = _planet_data.get_features(eP_FEATURES.GENE_STEALER_CULT)[0]; if (p_influence[_run][eFACTION.TYRANIDS] < 5) { _cult.hiding = true; @@ -1228,7 +1227,7 @@ function scr_enemy_ai_a() { who_cleansed = "Gene Stealer Cult"; make_alert = true; delete_features(p_feature[_run], eP_FEATURES.GENE_STEALER_CULT); - adjust_influence(eFACTION.TYRANIDS, -25, _run); + adjust_influence(eFACTION.TYRANIDS, -25, _run, self); } if (make_alert) { if (p_first[_run] == 1) { diff --git a/scripts/scr_enemy_ai_b/scr_enemy_ai_b.gml b/scripts/scr_enemy_ai_b/scr_enemy_ai_b.gml index 0d67059886..abc912ea51 100644 --- a/scripts/scr_enemy_ai_b/scr_enemy_ai_b.gml +++ b/scripts/scr_enemy_ai_b/scr_enemy_ai_b.gml @@ -3,39 +3,35 @@ function scr_enemy_ai_b() { // Imperial Repleneshes numbers // If no enemies and guard < pop /470 then increase guardsman // If no enemies and population < max_pop then increase by like 1% - var rando = 0, success = false, i = 0, is_garrison_force = false, total_garrison = 0, sabotage_force = false; - - i = 0; - for (i = 1; i <= planets; i++) { - system_datas[i].refresh_data(); - system_datas[i].end_of_turn_population_influence_and_enemy_growth(); - // if (p_heresy[i]>0) and (owner != eFACTION.CHAOS) then p_heresy[i]-=2; + for (var i = 1; i <= planets; i++) { + system_datas[i].refresh_data(); + system_datas[i].end_of_turn_population_influence_and_enemy_growth(); } // Tau rebellions if ((present_fleet[8] >= 1) && (owner != eFACTION.TAU)) { - var flit, ran1, ran2, tau_chance; - flit = scr_orbiting_fleet(eFACTION.TAU); - ran1 = 0; - ran2 = floor(random(planets)) + 1; + var tau_chance; + var flit = scr_orbiting_fleet(eFACTION.TAU); + var ran1 = 0; + var ran2 = floor(random(planets)) + 1; - if (flit != "none") { + if (flit != noone) { ran1 = floor(random(100)) + 1; var tau_influence = p_influence[ran2][eFACTION.TAU]; if (tau_influence < 90 && (p_type[ran2] != "Dead")) { if ((flit.image_index == 1) && (ran1 <= 90)) { - adjust_influence(eFACTION.TAU, choose(2, 3), ran2); + adjust_influence(eFACTION.TAU, choose(2, 3), ran2, self); if ((p_type[ran2] == "Forge") && (tau_influence >= 3)) { - adjust_influence(eFACTION.TAU, -3, ran2); + adjust_influence(eFACTION.TAU, -3, ran2, self); } } else if ((flit.image_index > 1) && (flit.image_index < 4) && (ran1 <= 90)) { - adjust_influence(eFACTION.TAU, choose(7, 9, 11, 13), ran2); + adjust_influence(eFACTION.TAU, choose(7, 9, 11, 13), ran2, self); if ((p_type[ran2] == "Forge") && (tau_influence >= 10)) { - adjust_influence(eFACTION.TAU, -10, ran2); + adjust_influence(eFACTION.TAU, -10, ran2, self); } } else if (flit.image_index >= 4) { - adjust_influence(eFACTION.TAU, choose(9, 11, 13, 15, 17), ran2); + adjust_influence(eFACTION.TAU, choose(9, 11, 13, 15, 17), ran2, self); if ((p_type[ran2] == "Forge") && (tau_influence >= 13)) { - adjust_influence(eFACTION.TAU, -13, ran2); + adjust_influence(eFACTION.TAU, -13, ran2, self); } } } @@ -44,7 +40,7 @@ function scr_enemy_ai_b() { } } - for (i = 1; i <= planets; i++) { + for (var i = 1; i <= planets; i++) { var tau_influence = p_influence[i][eFACTION.TAU]; tau_chance = floor(random(100)) + 1; @@ -55,14 +51,10 @@ function scr_enemy_ai_b() { } } - if (flit != "none" && flit.owner == eFACTION.TAU) { + if (flit != noone && flit.owner == eFACTION.TAU) { tau_chance += (flit.image_index * 5) - 5; } - if (tau_chance >= 95) { - /*obj_controller.x=self.x;obj_controller.y=self.y;show_message(string(tau_chance)+" |"+string(p_orks[i])+"|"+string(p_traitors[i]));*/ - } - if ((tau_chance >= 95) && (p_orks[i] == 0) && (p_traitors[i] == 0) && (p_necrons[i] == 0) && (p_demons[i] == 0) && (p_chaos[i] == 0)) { p_owner[i] = 8; if (p_guardsmen[i] > 0) { @@ -70,9 +62,10 @@ function scr_enemy_ai_b() { p_guardsmen[i] = 0; } - var targ = 0, have = 0, badd = 1; + var have = 0; + var badd = 1; - targ = planets; + var targ = planets; for (var s = 1; s <= planets; s++) { if (p_type[s] == "Dead") { targ -= 1; diff --git a/scripts/scr_enemy_ai_c/scr_enemy_ai_c.gml b/scripts/scr_enemy_ai_c/scr_enemy_ai_c.gml index 4f2801929c..a2c2b11d7a 100644 --- a/scripts/scr_enemy_ai_c/scr_enemy_ai_c.gml +++ b/scripts/scr_enemy_ai_c/scr_enemy_ai_c.gml @@ -1,9 +1,7 @@ /// @self Asset.GMObject.obj_star function scr_enemy_ai_c() { - var rando, contin, i; - rando = 0; - contin = 0; - i = 0; + var rando = 0; + var contin = 0; with (obj_star) { if ((craftworld == 1) || (space_hulk == 1)) { @@ -16,10 +14,9 @@ function scr_enemy_ai_c() { orks_end_turn_growth(); // traitors below here - i = 0; if (array_sum(p_traitors)) { var traitor_system = true; - for (i = 1; i <= planets; i++) { + for (var i = 1; i <= planets; i++) { if (p_owner[i] != 10) { traitor_system = false; } else if ((p_pdf[i] > 0) || (p_guardsmen[i] > 0) || (p_orks[i] > 0) || (p_tau[i] > 0)) { @@ -29,10 +26,9 @@ function scr_enemy_ai_c() { break; } } - for (i = 1; i <= planets; i++) { + for (var i = 1; i <= planets; i++) { contin = 0; rando = irandom(100) + 1; // This part handles the spreading - // if (rando<30){ contin = floor(random(planets)) + 1; repeat (30) { if ((p_type[contin] == "Dead") || (contin == i)) { @@ -44,15 +40,12 @@ function scr_enemy_ai_c() { contin = 500; } - // if (contin<100) then show_message(string(name)+"."+string(i)+" to "+string(contin)); - if (contin < 100) { if ((p_traitors[i] >= 3) && (p_traitors[contin] < ceil(p_traitors[i] / 2)) && (p_type[contin] != "Dead")) { p_traitors[contin] += 1; contin = 500; } } - // } contin = 0; rando = floor(random(100)) + 1; // This part handles the ship building @@ -63,8 +56,7 @@ function scr_enemy_ai_c() { if ((p_type[i] != "Dead") && (p_type[i] != "Lava")) { if ((p_traitors[i] >= 2) && (p_heresy[i] >= 80)) { // Have the proppa facilities and size - var fleet; - fleet = 0; + var fleet = noone; contin = 2; if (!instance_exists(obj_en_fleet)) { contin = 3; @@ -74,8 +66,7 @@ function scr_enemy_ai_c() { } if (instance_exists(obj_p_fleet)) { - var ppp; - ppp = instance_nearest(x, y, obj_p_fleet); + var ppp = instance_nearest(x, y, obj_p_fleet); if ((point_distance(x, y, ppp.x, ppp.y) < 50) && (ppp.action == "")) { contin = 0; } @@ -83,7 +74,7 @@ function scr_enemy_ai_c() { if (contin == 2) { fleet = scr_orbiting_fleet(eFACTION.CHAOS); - if (fleet == "none") { + if (fleet == noone) { contin = 3; } else if ((fleet.action == "") && (contin != 3)) { // Increase ship number for this object? @@ -103,11 +94,9 @@ function scr_enemy_ai_c() { if (fleet.image_index >= 5) { // eh heh heh - var stue, stue2; - stue = 0; - stue2 = 0; - var goood; - goood = 0; + var stue = 0; + var stue2 = 0; + var goood = 0; with (obj_star) { if ((planets == 1) && (p_type[1] == "Dead")) { @@ -159,12 +148,6 @@ function scr_enemy_ai_c() { present_fleet[10] += 1; obj_controller.chaos_fleets += 1; } - /*if (fleet!=0){ - if (instance_exists(fleet)) then with(fleet){ - var ii;ii=0;ii+=capital_number;ii+=round((frigate_number/2));ii+=round((escort_number/4)); - if (ii<=1) then ii=1;image_index=ii; - } - }*/ } } } @@ -172,18 +155,15 @@ function scr_enemy_ai_c() { } // This is the traitors corruption code - var boat, kay, temp5, temp6, temp7; - boat = 0; - kay = 0; - temp5 = 0; - temp6 = 0; - temp7 = 0; + var kay = 0; + var temp5 = 0; + var temp6 = 0; + var temp7 = 0; - boat = scr_orbiting_fleet(eFACTION.CHAOS); + var boat = scr_orbiting_fleet(eFACTION.CHAOS); - if ((present_fleet[10] > 0) && (present_fleet[1] + present_fleet[2] == 0) && (boat != "none") && (owner != eFACTION.CHAOS) && (planets > 0)) { - var i = 0; - repeat (5) { + if ((present_fleet[10] > 0) && (present_fleet[1] + present_fleet[2] == 0) && (boat != noone) && (owner != eFACTION.CHAOS) && (planets > 0)) { + for (var i = 0; i < 5; i++) { if ((p_type[1] != "Dead") && (p_owner[1] != 10)) { kay = 1; } @@ -242,8 +222,7 @@ function scr_enemy_ai_c() { if ((kay > 0) && (kay != 50)) { // Ere we go! - var cor; - cor = floor(image_index) + 1; + var cor = floor(image_index) + 1; if (p_type[kay] == "Shrine") { cor = round(cor / 3); @@ -255,22 +234,14 @@ function scr_enemy_ai_c() { } } } - i += 1; - } // End repeat + } } // End corruption code // This is the CSM landing code - var boat, kay, temp5, temp6, temp7; - boat = 0; - kay = 0; - temp5 = 0; - temp6 = 0; - temp7 = 0; - boat = scr_orbiting_fleet(eFACTION.CHAOS); var aler = 0; - if ((present_fleet[10] > 0) && (present_fleet[1] + present_fleet[2] == 0) && (boat != "none") && (planets > 0)) { + if ((present_fleet[10] > 0) && (present_fleet[1] + present_fleet[2] == 0) && (boat != noone) && (planets > 0)) { var ii = 0, gud = 0; repeat (planets) { ii += 1; @@ -300,12 +271,8 @@ function scr_enemy_ai_c() { } // End landing portion of code // Tau Here - i = 0; - if (array_sum(p_tau) > 0) { - repeat (4) { - i += 1; - + for (var i = 1; i <= 4; i++) { contin = 0; rando = floor(random(100)) + 1; // This part handles the spreading // if (rando<30){ @@ -320,8 +287,6 @@ function scr_enemy_ai_c() { contin = 500; } - // if (contin<100) then show_message(string(name)+"."+string(i)+" to "+string(contin)); - if (contin < 100) { if ((p_tau[i] == 3) && (p_tau[contin] < 2) && (p_type[contin] != "Dead") && (p_population[contin] > 0)) { p_tau[contin] += 1; @@ -346,7 +311,6 @@ function scr_enemy_ai_c() { contin = 500; } } - // } contin = 0; rando = floor(random(100)) + 1; // This part handles the ship building @@ -405,10 +369,10 @@ function scr_enemy_ai_c() { if (contin == 2) { fleet = scr_orbiting_fleet(eFACTION.TAU); - if (fleet == "none") { + if (fleet == noone) { contin = 3; } - if ((fleet != "none") && (contin != 3)) { + if ((fleet != noone) && (contin != 3)) { // Increase ship number for this object? if ((rando <= 10) && (fleet.image_index < 5)) { rando = choose(1, 2, 2, 3, 3, 3, 3); @@ -424,16 +388,13 @@ function scr_enemy_ai_c() { } if (fleet.image_index >= 5) { - var kawaii, think, xx, yy; - kawaii = 0; - think = 0; - xx = 0; - yy = 0; + var kawaii = 0; + var think = 0; repeat (50) { if ((think == 0) && (kawaii == 0)) { - xx = x + floor(choose(random(300), random(300) * -1)); - yy = y + floor(choose(random(300), random(300) * -1)); + var xx = x + floor(choose(random(300), random(300) * -1)); + var yy = y + floor(choose(random(300), random(300) * -1)); think = instance_nearest(xx, yy, obj_star); if ((think.owner != eFACTION.TAU) && (think.owner != eFACTION.ELDAR) && (think.present_fleet[8] + think.present_fleet[1] + think.present_fleet[2] == 0) && (think.planets > 0)) { kawaii = 1; @@ -456,10 +417,9 @@ function scr_enemy_ai_c() { if ((kawaii == 1) && instance_exists(obj_crusade)) { // NOPE, stay home and defend - var him, own, dis; - him = instance_nearest(x, y, obj_crusade); - own = him.owner; - dis = him.radius; + var him = instance_nearest(x, y, obj_crusade); + var own = him.owner; + var dis = him.radius; if (point_distance(x, y, him.x, him.y) <= dis) { kawaii = 0; } @@ -485,12 +445,6 @@ function scr_enemy_ai_c() { present_fleet[8] += 1; obj_controller.tau_fleets += 1; } - /*if (fleet!=0){ - if (instance_exists(fleet)) then with(fleet){ - var ii;ii=0;ii+=capital_number;ii+=round((frigate_number/2));ii+=round((escort_number/4)); - if (ii<=1) then ii=1;image_index=ii; - } - }*/ } } } @@ -498,12 +452,10 @@ function scr_enemy_ai_c() { } // Tyranids here - var i = 0; - repeat (planets) { - i += 1; + for (var i = 1; i <= planets; i++) { if ((p_tyranids[i] >= 5) && (planets >= i) && (p_player[i] + p_orks[i] + p_guardsmen[i] + p_pdf[i] + p_chaos[i] == 0)) { var ship = scr_orbiting_fleet(eFACTION.TYRANIDS); - if ((ship != "none") && (p_type[i] != "Dead") && (array_length(p_feature[i]) != 0)) { + if ((ship != noone) && (p_type[i] != "Dead") && (array_length(p_feature[i]) != 0)) { if (ship.capital_number > 0) { if (planet_feature_bool(p_feature[i], eP_FEATURES.RECLAMATION_POOLS) == 1) { p_tyranids[i] = 0; @@ -514,7 +466,7 @@ function scr_enemy_ai_c() { ship.escort_number += 3; ship.image_index = floor(ship.capital_number + (ship.frigate_number / 2) + (ship.escort_number / 4)); p_type[i] = "Dead"; - delete_features(p_feature[i], eP_FEATURES.RECLAMATION_POOLS); // show_message("D"); + delete_features(p_feature[i], eP_FEATURES.RECLAMATION_POOLS); if ((planets == 1) && (p_type[1] == "Dead")) { image_alpha = 0.33; } @@ -536,10 +488,10 @@ function scr_enemy_ai_c() { if ((planet_feature_bool(p_feature[i], eP_FEATURES.CAPILLARY_TOWERS) == 1) && (p_type[i] != "Dead")) { p_feature[i] = []; array_push(p_feature[i], new NewPlanetFeature(eP_FEATURES.CAPILLARY_TOWERS), new NewPlanetFeature(eP_FEATURES.RECLAMATION_POOLS)); - p_population[i] = 0; // show_message("C"); + p_population[i] = 0; } if ((planet_feature_bool(p_feature[i], eP_FEATURES.CAPILLARY_TOWERS) == 0) && (planet_feature_bool(p_feature[i], eP_FEATURES.RECLAMATION_POOLS) == 0) && (p_type[i] != "Dead")) { - array_push(p_feature[i], new NewPlanetFeature(eP_FEATURES.CAPILLARY_TOWERS)); // show_message("B"); + array_push(p_feature[i], new NewPlanetFeature(eP_FEATURES.CAPILLARY_TOWERS)); } } } diff --git a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml index 50984068c6..1d976d438c 100644 --- a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml +++ b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml @@ -104,13 +104,7 @@ function scr_enemy_ai_e() { instance_activate_object(obj_en_fleet); if ((battle2 > 0) && (battle == 0)) { // AI only battle - var i, f, shiyp; - i = 0; - f = 1; - shiyp = 0; - - repeat (10) { - f += 1; + for (var f = 2; f <= 11; f++) { if (f == 11) { f = 13; } @@ -141,8 +135,6 @@ function scr_enemy_ai_e() { strength[13] = strength[13] * 2; } - // if (f=10) or (f=2) then show_message("["+string(f)+"] Fleet strength: "+string(strength[f])); - with (obj_en_ship) { if ((x < -7000) && (y < -7000)) { x += 10000; @@ -161,14 +153,12 @@ function scr_enemy_ai_e() { y += 10000; } } - // show_message(string(name)+"] Owner: "+string(f)+", strength: "+string(strength[f])); } } // This grabs the "strength" from all present fleets and adds it to the temporary variable for this AI battle // Determine who will attack who - var still_battling, rond; - still_battling = true; - rond = 0; + var still_battling = true; + var rond = 0; repeat (5) { rond += 1; @@ -195,14 +185,9 @@ function scr_enemy_ai_e() { still_battling = true; } - // show_message(string(name)+" Round "+string(rond)+": "+string(still_battling)); - if (still_battling == true) { - var who; - who = 0; - // Imperial Fleet Attacks - who = 2; + var who = 2; if (strength[who] > 0) { if ((strength[9] > 0) && (attack[who] == 0)) { attack[who] = 9; @@ -223,21 +208,16 @@ function scr_enemy_ai_e() { attack[who] = 6; } damage[attack[who]] += strength[who] / 2; - - // if (attack[who]=10) then show_message("Imperial Fleet damage: "+string(damage[10])+", Strength: "+string(strength[2])); - // show_message(string(who)+" attacking "+string(attack[who])+" for "+string(strength[who]/2)); } // Eldar Fleet Attacks who = 6; if (strength[who] > 0) { - i = 11; if ((strength[13] > 0) && (13 != who)) { attack[who] = 13; } if (attack[who] != 13) { - repeat (9) { - i -= 1; + for (var i = 10; i >= 2; i--) { if ((strength[i] > 0) && (i != who)) { attack[who] = i; } @@ -268,7 +248,6 @@ function scr_enemy_ai_e() { attack[who] = 6; } damage[attack[who]] += strength[who] / 2; - // show_message(string(who)+" attacking "+string(attack[who])+" for "+string(strength[who]/2)); } // Tau Fleet Attacks @@ -295,13 +274,11 @@ function scr_enemy_ai_e() { // Tyranid Fleet Attacks who = 9; if (strength[who] > 0) { - i = 1; if ((strength[13] > 0) && (13 != who)) { attack[who] = 13; } if (attack[who] != 13) { - repeat (9) { - i += 1; + for (var i = 2; i <= 10; i++) { if ((strength[i] > 0) && (i != who)) { attack[who] = i; } @@ -332,7 +309,6 @@ function scr_enemy_ai_e() { attack[who] = 8; } damage[attack[who]] += strength[who] / 2; - // if (attack[who]=2) then show_message("Chaos Fleet damage: "+string(damage[2])+", Strength: "+string(strength[10])); } // Necron Fleet Attacks @@ -360,15 +336,10 @@ function scr_enemy_ai_e() { } // Attacking has been determined, work out damage - var i; - i = 1; - repeat (9) { - i += 1; + for (var i = 2; i <= 10; i++) { strength[i] -= damage[i]; damage[i] = 0; - // if (strength[i]>0) and (present_fleet[i]>0) then show_message(string(name)+"] Fleet:"+string(i)+" surviving at "+string(strength[i])+" in round "+string(rond)); if ((strength[i] <= 0) && (present_fleet[i] > 0)) { - // show_message(string(name)+"] Fleet:"+string(i)+" beat to shit in round "+string(rond)); obj_controller.temp[1049] = i; obj_controller.temp[1050] = self.id; with (obj_en_fleet) { @@ -381,9 +352,7 @@ function scr_enemy_ai_e() { strength[13] -= damage[13]; damage[13] = 0; - // if (strength[i]>0) and (present_fleet[i]>0) then show_message(string(name)+"] Fleet:"+string(i)+" surviving at "+string(strength[i])+" in round "+string(rond)); if ((strength[13] <= 0) && (present_fleet[13] > 0)) { - // show_message(string(name)+"] Fleet:"+string(i)+" beat to shit in round "+string(rond)); obj_controller.temp[1049] = 13; obj_controller.temp[1050] = self.id; with (obj_en_fleet) { @@ -398,10 +367,7 @@ function scr_enemy_ai_e() { // Those 5 battle intervals have finished // Clean up the surviving fleet(s) - var i; - i = 1; - repeat (10) { - i += 1; + for (var i = 2; i <= 11; i++) { if (i == 11) { i = 13; } @@ -424,10 +390,6 @@ function scr_enemy_ai_e() { } } - // show_message("Fleet "+string(owner)+" has "+string(obj_controller.temp[1048])+" strength remaining after the battle"); - - // if (i=10) and (strength[i]>0) then show_message("STR "+string(strength[10])+" < "+string(obj_controller.temp[1048])+" ?"); - if (strength[i] < obj_controller.temp[1048]) { // Need to remove ships if != repeat (40) { @@ -437,7 +399,6 @@ function scr_enemy_ai_e() { if ((escort_number > 0) && (escort_number + frigate_number + capital_number != 1)) { escort_number -= 1; obj_controller.temp[1047] -= 1; - // show_message("removed an escort, escorts left: "+string(escort_number)); if (escort_number + frigate_number + capital_number <= 0) { instance_destroy(); } @@ -455,7 +416,6 @@ function scr_enemy_ai_e() { if ((frigate_number > 0) && (escort_number + frigate_number + capital_number != 1)) { frigate_number -= 1; obj_controller.temp[1047] -= 4; - // show_message("removed a frigate, frigates left: "+string(frigate_number)); if (escort_number + frigate_number + capital_number <= 0) { instance_destroy(); } @@ -471,7 +431,6 @@ function scr_enemy_ai_e() { if ((capital_number > 0) && (escort_number + frigate_number + capital_number != 1)) { capital_number -= 1; obj_controller.temp[1047] -= 8; - // show_message("removed a capital ship, capitals left: "+string(capital_number)); if (escort_number + frigate_number + capital_number <= 0) { instance_destroy(); } @@ -483,7 +442,6 @@ function scr_enemy_ai_e() { } strength[i] = obj_controller.temp[1047]; - // show_message("Surviving fleet ("+string(i)+") strength: "+string(strength[i])); // I'd hope that removes enough ships from the survivor } with (obj_en_fleet) { @@ -512,10 +470,9 @@ function scr_enemy_ai_e() { // Quene battle obj_turn_end.battles += 1; obj_turn_end.battle[obj_turn_end.battles] = 1; - obj_turn_end.battle_world[obj_turn_end.battles] = -50; + obj_turn_end.battle_world[obj_turn_end.battles] = noone; obj_turn_end.battle_opponent[obj_turn_end.battles] = i; // Who triggered it first obj_turn_end.battle_location[obj_turn_end.battles] = name; - // obj_turn_end.battle_object[obj_turn_end.battles]=instance_nearest(x,y,obj_en_fleet); obj_turn_end.battle_pobject[obj_turn_end.battles] = instance_nearest(x, y, obj_p_fleet); if (i == 10) { @@ -587,8 +544,7 @@ function scr_enemy_ai_e() { } if (has_problem_planet(run, "spyrer")) { if (p_player[run] > 20) { - var tixt; - tixt = "The Spyrer on " + planet_numeral_name(run); + var tixt = "The Spyrer on " + planet_numeral_name(run); tixt += " seems to have vanished, presumably gone into hiding."; scr_popup("Spyrer Rampage", tixt, "spyrer", ""); } else if (p_player[run] <= 20) { @@ -620,7 +576,7 @@ function scr_enemy_ai_e() { } } else if (chan >= 3) { if (remove_planet_problem(run, "fallen")) { - tixt = "Your marines have scoured " + planet_numeral_name(run); + var tixt = "Your marines have scoured " + planet_numeral_name(run); tixt += " in search of the Fallen. Despite their best efforts, and meticulous searching, none have been found. It appears as though the information was faulty or out of date."; scr_popup("Hunt the Fallen", tixt, "fallen", ""); scr_event_log("", $"Mission Successful: No Fallen located upon {planet_numeral_name(run)}"); @@ -634,6 +590,7 @@ function scr_enemy_ai_e() { if ((p_player[run] > 0) && (force_count > 0)) { for (force = 2; force < 14; force++) { battle_opponent = 0; + var pause = false; switch (force) { case 3: // mechanicus aren't quite in yet @@ -674,14 +631,14 @@ function scr_enemy_ai_e() { } break; case 10: - var pause = has_problem_planet(run, "meeting") || has_problem_planet(run, "meeting_trap"); - if (p_guardsmen[run] + p_pdf[run] == 0 && p_player[run] > 0 && p_traitors[run] > 0 && pause == 0 && obj_controller.faction_status[10] == "War") { + pause = has_problem_planet(run, "meeting") || has_problem_planet(run, "meeting_trap"); + if (p_guardsmen[run] + p_pdf[run] == 0 && p_player[run] > 0 && p_traitors[run] > 0 && !pause && obj_controller.faction_status[10] == "War") { battle_opponent = 10; } break; case 11: - var pause = has_problem_planet(run, "meeting") || has_problem_planet(run, "meeting_trap"); - if (p_guardsmen[run] + p_pdf[run] == 0 && p_player[run] > 0 && p_chaos[run] > 0 && pause == 0 && obj_controller.faction_status[10] == "War") { + pause = has_problem_planet(run, "meeting") || has_problem_planet(run, "meeting_trap"); + if (p_guardsmen[run] + p_pdf[run] == 0 && p_player[run] > 0 && p_chaos[run] > 0 && !pause && obj_controller.faction_status[10] == "War") { battle_opponent = 11; } break; @@ -694,7 +651,6 @@ function scr_enemy_ai_e() { // other battle crap here if (battle_opponent > 0) { - // obj_controller.x=self.x;obj_controller.y=self.y; obj_turn_end.battles += 1; obj_turn_end.battle[obj_turn_end.battles] = 1; obj_turn_end.battle_world[obj_turn_end.battles] = run; diff --git a/scripts/scr_equipment_struct/scr_equipment_struct.gml b/scripts/scr_equipment_struct/scr_equipment_struct.gml index de6b92c9b6..02abe764f7 100644 --- a/scripts/scr_equipment_struct/scr_equipment_struct.gml +++ b/scripts/scr_equipment_struct/scr_equipment_struct.gml @@ -68,7 +68,6 @@ function EquipmentStruct(item_data, core_type, quality_request = "none", arti_st self[$ _struct_key] = self[$ _struct_key][$ quality]; } } - // _struct_key = ""; } } @@ -266,7 +265,6 @@ function EquipmentStruct(item_data, core_type, quality_request = "none", arti_st array_push(special_properties_array, second_profiles[h]); } } - //item_desc_tooltip += $"#Properties:#{special_properties_string}#" } if (is_struct(specials)) { diff --git a/scripts/scr_event_code/scr_event_code.gml b/scripts/scr_event_code/scr_event_code.gml index 6b6562b288..019af1f22a 100644 --- a/scripts/scr_event_code/scr_event_code.gml +++ b/scripts/scr_event_code/scr_event_code.gml @@ -52,7 +52,7 @@ function event_end_turn_action() { var _star_name = _event.system; var _event_star = find_star_by_name(_event.system); var _planet = _event.planet; - if (_event_star != "none") { + if (_event_star != noone) { _event_star.dispo[_planet] = -10; // Resets var twix = $"Inquisition executes Chapter Serf in control of {planet_numeral_name(_planet, _event_star)} and installs a new Planetary Governor."; if (_event_star.p_owner[_planet] == eFACTION.PLAYER) { @@ -89,7 +89,7 @@ function event_end_turn_action() { if (_event.e_id == "chaos_invasion") { var xx = 0, yy = 0, flee = 0, dirr = 0; var star_id = scr_random_find(1, true, "", ""); - if (star_id != undefined) { + if (star_id != noone) { scr_event_log("purple", $"Chaos Fleets exit the warp near the {star_id.name} system.", star_id.name); for (var j = 0; j < 4; j++) { dirr += irandom_range(50, 100); @@ -163,6 +163,7 @@ function event_end_turn_action() { var marine_num = _event.marine; var _unit = fetch_unit([comp, marine_num]); var item = _event.crafted; + var _pop_data = {}; LOGGER.warning($"comp: {comp}, marine_num: {marine_num}"); @@ -235,14 +236,12 @@ function event_end_turn_action() { choice_func: popup_default_close, } ]; - var _pop_data = { + _pop_data = { options: options, marine_number: marine_num, company: comp, marine_name: marine_name, }; - } else { - _pop_data = ""; } scr_popup("He Built It", tixt, "tech_build", _pop_data); @@ -358,7 +357,7 @@ function strange_build_event() { if (marine_is_planetside && heritical_item) { var _system = find_star_by_name(_unit.location_string); var _planet = _unit.planet_location; - if (_system != "none") { + if (_system != noone) { with (_system) { p_hurssy[_planet] += 6; p_hurssy_time[_planet] = 2; @@ -366,7 +365,7 @@ function strange_build_event() { } } else if (!marine_is_planetside && heritical_item) { var _fleet = find_ships_fleet(_unit.ship_location); - if (_fleet != "none") { + if (_fleet != noone) { //the intended code for here was to add some sort of chaos event on the ship stashed up ready to fire in a few turns } } diff --git a/scripts/scr_event_log/scr_event_log.gml b/scripts/scr_event_log/scr_event_log.gml index e71b2224ce..8a3fad3aa8 100644 --- a/scripts/scr_event_log/scr_event_log.gml +++ b/scripts/scr_event_log/scr_event_log.gml @@ -1,4 +1,4 @@ -function scr_event_log(event_colour, event_text, target = "none") { +function scr_event_log(event_colour, event_text, target = noone) { LOGGER.info($"Adding event to log: {event_text}"); if (instance_exists(obj_event_log)) { var yf; diff --git a/scripts/scr_event_newlines/scr_event_newlines.gml b/scripts/scr_event_newlines/scr_event_newlines.gml index 5fbd9ae77d..d584d3404e 100644 --- a/scripts/scr_event_newlines/scr_event_newlines.gml +++ b/scripts/scr_event_newlines/scr_event_newlines.gml @@ -1,27 +1,15 @@ function scr_event_newlines(argument0) { // argument0: string being added to the event display - need to verify string height - // show_message(string(argument0)); - if (argument0 != "") { - var nl, nls, lo, q, onceh; draw_set_font(fnt_40k_14); - onceh = 0; - lo = 0; - - nls = string_height_ext(string_hash_to_newline(argument0), -1, 916) / 21; - // show_message(string(nls)); + var nls = string_height_ext(string_hash_to_newline(argument0), -1, 916) / 21; if (lines + nls > 17) { // Going to need to move some lines around - nl = (lines + nls) - 17; - - repeat (nl) { - var q; - q = 0; - repeat (17) { - q += 1; - line[q] = line[q + 1]; + repeat ((lines + nls) - 17) { + for (var i = 1; i <= 17; i++) { + line[i] = line[i + 1]; } line[17] = ""; lines -= 1; @@ -31,12 +19,10 @@ function scr_event_newlines(argument0) { if (lines + nls <= 17) { // Slap in text without worrying about lines // get first open - q = 0; - lo = 0; - repeat (17) { - q += 1; - if ((line[q] == "") && (lo == 0)) { - lo = q; + var lo = 0; + for (var i = 1; i <= 17; i++) { + if ((line[i] == "") && (lo == 0)) { + lo = i; } } @@ -46,14 +32,12 @@ function scr_event_newlines(argument0) { // If it is composed of several lines than make those lines beneath it blank as needed if (nls > 1) { - q = nls - 1; - repeat (q) { + repeat (nls - 1) { lo += 1; line[lo] = "---"; lines += 1; } } - onceh = 1; } } } diff --git a/scripts/scr_flavor/scr_flavor.gml b/scripts/scr_flavor/scr_flavor.gml index b26bd358e5..e41abd8ec7 100644 --- a/scripts/scr_flavor/scr_flavor.gml +++ b/scripts/scr_flavor/scr_flavor.gml @@ -22,8 +22,59 @@ function display_battle_log_message() { obj_ncombat.alarm[3] = 5; } -function scr_flavor(id_of_attacking_weapons, target, target_type, number_of_shots, casulties) { +/// @desc Plural form of a weapon name. Names that are already plural (end in "s", e.g. +/// "Twin Linked Bolters") are left as-is so we don't print "Bolterss". +/// @param {string} _name The weapon name. +/// @returns {string} +function weapon_name_plural(_name) { + return _name + ((string_char_at(_name, string_length(_name)) == "s") ? "" : "s"); +} + +/// @desc Logs one "held fire" line for weapons that had no live target left to shoot at, e.g. +/// when an earlier volley wiped the enemy before the rest of the squad fired. +/// @param {Array} _weapon_names Raw weapon names (duplicates allowed) that never fired. +function report_held_fire(_weapon_names) { + // Dedupe and pluralise. + var _unique = []; + for (var i = 0; i < array_length(_weapon_names); i++) { + var _p = weapon_name_plural(_weapon_names[i]); + if (array_get_index(_unique, _p) == -1) { + array_push(_unique, _p); + } + } + + var _count = array_length(_unique); + if (_count == 0) { + return; + } + + // Build "A, B, and C" (or "A and B", or "A"). + var _list = _unique[0]; + for (var i = 1; i < _count; i++) { + if (i == _count - 1) { + _list += (_count > 2 ? ", and " : " and ") + _unique[i]; + } else { + _list += ", " + _unique[i]; + } + } + + add_battle_log_message($"{_list} held fire lacking live targets.", 0, 135); + display_battle_log_message(); +} + +function scr_flavor(id_of_attacking_weapons, target, target_type, number_of_shots, casulties, shots_bounced = false, _defer = false) { // Generates flavor based on the damage and casualties from scr_shoot, only for the player + // shots_bounced: true when armour stopped the shots outright (AP too low) and nothing died, + // so the log can explain *why* instead of a flat "no casualties". + // _defer: when true, build the message but DON'T post it; return it so the caller can append a + // spill-over kill list and post a single consolidated line (see emit_volley_flavour). + + // Clamp away any negative casualty count so it can never render as "-1". Every volley now earns + // a line: a kill, a wound (injured, no kill), or an armour-bounce. The latter two are consolidated + // per target by emit_volley_flavour / combat_tally_*. + if (casulties < 0) { + casulties = 0; + } var attack_message, kill_message, leader_message, targeh; targeh = target_type; @@ -31,10 +82,19 @@ function scr_flavor(id_of_attacking_weapons, target, target_type, number_of_shot attack_message = $""; kill_message = ""; + // Guard/diagnostic: a non-killing volley against a rank with no living models means we fired at a + // dead target. Shouldn't happen now that emptied formations are destroyed - log it if it does and + // bail, so it can never feed the consolidated non-pen / wound feed. (Spill-over kills, if any, are + // still reported by emit_volley_flavour's undefined-primary path.) + if (casulties <= 0 && (!instance_exists(target) || target.dudes_num[targeh] <= 0)) { + LOGGER.warning($"scr_flavor: shot at a dead target (weapon stack {id_of_attacking_weapons}, rank {targeh})"); + exit; + } + var weapon_name = wep[id_of_attacking_weapons]; if (id_of_attacking_weapons == -51) { - weapon_name = "Heavy Bolter Emplacemelse ent"; + weapon_name = "Heavy Bolter Emplacement"; } if (id_of_attacking_weapons == -52) { weapon_name = "Missile Launcher Emplacement"; @@ -43,6 +103,9 @@ function scr_flavor(id_of_attacking_weapons, target, target_type, number_of_shot weapon_name = "Missile Silo"; } + // Plural form for "{n} {weapon}s ..." lines (see weapon_name_plural). + var weapon_plural = weapon_name_plural(weapon_name); + var weapon_data = gear_weapon_data("weapon", weapon_name, "all"); if (!is_struct(weapon_data)) { weapon_data = new EquipmentStruct({}, ""); @@ -65,7 +128,7 @@ function scr_flavor(id_of_attacking_weapons, target, target_type, number_of_shot if (array_length(full_names) == 1) { unit_name = wep_title[id_of_attacking_weapons] + " " + wep_solo[id_of_attacking_weapons][0]; } else { - unit_name = wep_title[id_of_attacking_weapons] + "'s"; + unit_name = wep_title[id_of_attacking_weapons]; } } if (wep_solo[id_of_attacking_weapons][0] == obj_ini.master_name) { @@ -93,6 +156,26 @@ function scr_flavor(id_of_attacking_weapons, target, target_type, number_of_shot target_name = "flanking " + target_name; } + // Firing subject for consolidated lines: " " for a titled character, "The " + // for a lone shot, or " " for a volley (also used when a unit has no title, e.g. Dreadnoughts). + var firing_subject; + if (character_shot && unit_name != "") { + if (number_of_shots > 1) { + // Grouped titled units (e.g. several Dreadnoughts share one "Dreadnought" title) — show the count. + firing_subject = $"{number_of_shots} {string(unit_name)} {weapon_plural}"; + } else { + firing_subject = $"{string(unit_name)} {weapon_name}"; + } + } else if (number_of_shots == 1) { + firing_subject = $"The {weapon_name}"; + } else { + firing_subject = $"{number_of_shots} {weapon_plural}"; + } + + // A plain volley line (" ", no character title) can be summed with other volleys + // of the same weapon on the same target into one consolidated kill line (see emit_volley_flavour). + var _volley_line = (!(character_shot && unit_name != "")) && (number_of_shots > 1); + var flavoured = false; if (weapon_data.has_tag("bolt")) { @@ -104,29 +187,29 @@ function scr_flavor(id_of_attacking_weapons, target, target_type, number_of_shot if (number_of_shots < 200) { if (target.dudes_num[targeh] == 1) { if (casulties == 0) { - attack_message += $"{number_of_shots} {weapon_name}s fire. The {target_name} is hit but survives."; + attack_message += $"{number_of_shots} {weapon_plural} fire. The {target_name} is hit but survives."; } else { - attack_message += $"{number_of_shots} {weapon_name}s fire. The {target_name} is struck down."; + attack_message += $"{number_of_shots} {weapon_plural} fire. The {target_name} is struck down."; } } else { if (casulties == 0) { - attack_message += $"{number_of_shots} {weapon_name}s fire hits {target_name} ranks without causing casualties."; + attack_message += $"{number_of_shots} {weapon_plural} fire at {target_name} ranks without causing casualties."; } else { - attack_message += $"{number_of_shots} {weapon_name}s strike {target_name} ranks, taking down {casulties}."; + attack_message += $"{number_of_shots} {weapon_plural} strike {target_name} ranks, taking down {casulties}."; } } } else { if (target.dudes_num[targeh] == 1) { if (casulties == 0) { - attack_message += $"{number_of_shots} {weapon_name}s fire. Explosions rock the {target_name}'s armour but don't kill it."; + attack_message += $"{number_of_shots} {weapon_plural} fire. Explosions rock the {target_name}'s armour but don't kill it."; } else { - attack_message += $"{number_of_shots} {weapon_name}s fire. Explosions take down the {target_name}."; + attack_message += $"{number_of_shots} {weapon_plural} fire. Explosions take down the {target_name}."; } } else { if (casulties == 0) { - attack_message += $"{number_of_shots} {weapon_name}s hit {target_name} ranks, but no casualties are confirmed."; + attack_message += $"{number_of_shots} {weapon_plural} hit {target_name} ranks, but no casualties are confirmed."; } else { - attack_message += $"{number_of_shots} {weapon_name}s tear through {target_name} ranks, instantly killing {casulties}."; + attack_message += $"{number_of_shots} {weapon_plural} tear through {target_name} ranks, instantly killing {casulties}."; } } } @@ -181,7 +264,87 @@ function scr_flavor(id_of_attacking_weapons, target, target_type, number_of_shot if (casulties == 0) { attack_message += $"but all survive the impact."; } else { - attack_message += $"killing {casulties} perish in the attack."; + attack_message += $"and {casulties} are crushed in the impact."; + } + } + } + } else if (weapon_name == "Speed Force" || weapon_name == "Speed Force(M)") { + flavoured = true; + if (!character_shot) { + if (number_of_shots < 20) { + attack_message += $"{number_of_shots} Astartes on Bikes speed ahead, their Bikes roaring like beasts of old- "; + } else if (number_of_shots >= 20 && number_of_shots < 100) { + attack_message += $"Squads of {number_of_shots} Astartes thunder ahead on their Bikes. They descend upon the enemy- "; + } else { + attack_message += $"A massive wave of {number_of_shots} Astartes rolls ahead on top of their mighty Bikes. They crash into enemy lines, smashing their foe- "; + } + if (target.dudes_num[targeh] == 1) { + if (casulties == 0) { + attack_message += $"but the {target_name} endures the onslaught."; + } else { + attack_message += $"the {target_name} falls to the charge."; + } + } else { + if (casulties == 0) { + attack_message += $"{target_name} ranks are hit, but no casualties are confirmed."; + } else { + attack_message += $"{target_name} ranks are hit, killing {casulties} in an instant."; + } + } + } else { + if (target.dudes_num[targeh] == 1) { + attack_message += string(unit_name) + $" speeds on his bike, roaring and crashing into the {target_name}- "; + if (casulties == 0) { + attack_message += $"but it endures the onslaught."; + } else { + attack_message += $"and it falls to the charge."; + } + } else { + attack_message += string(unit_name) + $" speeds on his bike, slamming into {target_name} ranks- "; + if (casulties == 0) { + attack_message += $"but all survive the impact."; + } else { + attack_message += $"crushing {casulties} beneath his wheels."; + } + } + } + } else if (weapon_name == "Speed Force (Ranged)") { + flavoured = true; + if (!character_shot) { + if (number_of_shots < 20) { + attack_message += $"{number_of_shots} Attack Bikes race across the field, sidecar gunners hosing down the enemy on the move- "; + } else if (number_of_shots >= 20 && number_of_shots < 100) { + attack_message += $"A column of {number_of_shots} Attack Bikes sweeps past, heavy weapons hammering away in a thunderous strafing run- "; + } else { + attack_message += $"A roaring tide of {number_of_shots} Attack Bikes tears along the line, sidecar guns blazing without pause- "; + } + if (target.dudes_num[targeh] == 1) { + if (casulties == 0) { + attack_message += $"but the {target_name} weathers the fusillade."; + } else { + attack_message += $"and the {target_name} is gunned down where it stands."; + } + } else { + if (casulties == 0) { + attack_message += $"{target_name} ranks are raked with fire, but none fall."; + } else { + attack_message += $"cutting down {casulties} {target_name} in the pass."; + } + } + } else { + if (target.dudes_num[targeh] == 1) { + attack_message += string(unit_name) + $" guns his Attack Bike past the {target_name}, sidecar weapon roaring- "; + if (casulties == 0) { + attack_message += $"but it endures the barrage."; + } else { + attack_message += $"and it is torn apart."; + } + } else { + attack_message += string(unit_name) + $" sweeps his Attack Bike along {target_name} ranks, raking them with fire- "; + if (casulties == 0) { + attack_message += $"but all survive the onslaught."; + } else { + attack_message += $"cutting down {casulties} in the pass."; } } } @@ -190,15 +353,15 @@ function scr_flavor(id_of_attacking_weapons, target, target_type, number_of_shot if (!character_shot) { if (target.dudes_num[targeh] == 1) { if (casulties == 0) { - attack_message += $"{number_of_shots} {weapon_name}s roar, explosions clap across the armour of the {target_name} but it remains standing."; + attack_message += $"{number_of_shots} {weapon_plural} roar, explosions clap across the armour of the {target_name} but it remains standing."; } else { - attack_message += $"{number_of_shots} {weapon_name}s fire at the {target_name} and rip it apart."; + attack_message += $"{number_of_shots} {weapon_plural} fire at the {target_name} and rip it apart."; } } else { if (casulties == 0) { - attack_message += $"{number_of_shots} {weapon_name}s thunder, {target_name} are rocked but unharmed."; + attack_message += $"{number_of_shots} {weapon_plural} thunder, {target_name} are rocked but unharmed."; } else { - attack_message += $"{number_of_shots} {weapon_name}s mow down {casulties} {target_name}."; + attack_message += $"{number_of_shots} {weapon_plural} mow down {casulties} {target_name}."; } } } else { @@ -221,15 +384,15 @@ function scr_flavor(id_of_attacking_weapons, target, target_type, number_of_shot if (!character_shot) { if (target.dudes_num[targeh] == 1) { if (casulties == 0) { - attack_message = $"{number_of_shots} {weapon_name}s fire upon the {target_name} but it remains standing."; + attack_message = $"{number_of_shots} {weapon_plural} fire upon the {target_name} but it remains standing."; } else { - attack_message = $"{number_of_shots} {weapon_name}s blast the {target_name} to oblivion."; + attack_message = $"{number_of_shots} {weapon_plural} blast the {target_name} to oblivion."; } } else { if (casulties == 0) { - attack_message = $"{number_of_shots} {weapon_name}s hit {target_name} ranks but they hold firm."; + attack_message = $"{number_of_shots} {weapon_plural} hit {target_name} ranks but they hold firm."; } else { - attack_message = $"{number_of_shots} {weapon_name}s pulverize {casulties} {target_name}."; + attack_message = $"{number_of_shots} {weapon_plural} pulverize {casulties} {target_name}."; } } } else { @@ -391,10 +554,10 @@ function scr_flavor(id_of_attacking_weapons, target, target_type, number_of_shot attack_message = $"A {target_name} is struck down by a Battle Sister's {weapon_name}."; } if ((number_of_shots > 1) && (casulties == 0)) { - attack_message = $"Battle Sisters " + choose("howl out", "roar") + $" and hack at {target_name} ranks with their {weapon_name}s, but they survive."; + attack_message = $"Battle Sisters " + choose("howl out", "roar") + $" and hack at {target_name} ranks with their {weapon_plural}, but they survive."; } if ((number_of_shots > 1) && (casulties > 0)) { - attack_message = $"{number_of_shots} Battle Sisters " + choose("howl out", "roar") + $" as they hack away at the {target_name} ranks, killing {casulties} with their {weapon_name}s."; + attack_message = $"{number_of_shots} Battle Sisters " + choose("howl out", "roar") + $" as they hack away at the {target_name} ranks, killing {casulties} with their {weapon_plural}."; } } else if (weapon_name == "Eviscerator") { flavoured = true; @@ -435,18 +598,18 @@ function scr_flavor(id_of_attacking_weapons, target, target_type, number_of_shot } if ((number_of_shots > 1) && (casulties == 0)) { - attack_message = $"A {target_name} is struck by {number_of_shots} {weapon_name}s but survives."; + attack_message = $"A {target_name} is struck by {number_of_shots} {weapon_plural} but survives."; } if ((number_of_shots > 1) && (casulties == 1)) { - attack_message = $"A {target_name} is struck down by {number_of_shots} {weapon_name}s."; + attack_message = $"A {target_name} is struck down by {number_of_shots} {weapon_plural}."; } } if (target.dudes_num[targeh] > 1) { if ((number_of_shots > 1) && (casulties == 0)) { - attack_message = $"{number_of_shots} {weapon_name}s crackle and spark, striking at the {target_name} ranks, inflicting no damage."; + attack_message = $"{number_of_shots} {weapon_plural} crackle and spark, striking at the {target_name} ranks, inflicting no damage."; } if ((number_of_shots > 1) && (casulties > 0)) { - attack_message = $"{number_of_shots} {weapon_name}s crackle and spark, hewing through the {target_name} ranks, {casulties} are cut down."; + attack_message = $"{number_of_shots} {weapon_plural} crackle and spark, hewing through the {target_name} ranks, {casulties} are cut down."; } } } @@ -461,9 +624,9 @@ function scr_flavor(id_of_attacking_weapons, target, target_type, number_of_shot } else if (number_of_shots == 1 && casulties == 1) { attack_message = $"A {target_name} is struck down by {weapon_name}."; } else if (number_of_shots > 1 && casulties == 0) { - attack_message = $"A {target_name} is struck by {number_of_shots} {weapon_name}s but survives."; + attack_message = $"A {target_name} is struck by {number_of_shots} {weapon_plural} but survives."; } else if (number_of_shots > 1 && casulties == 1) { - attack_message = $"A {target_name} is struck down by {number_of_shots} {weapon_name}s."; + attack_message = $"A {target_name} is struck down by {number_of_shots} {weapon_plural}."; } } else { if (number_of_shots == 1 && casulties == 0) { @@ -471,28 +634,47 @@ function scr_flavor(id_of_attacking_weapons, target, target_type, number_of_shot } else if (number_of_shots == 1 && casulties > 0) { attack_message = $"{weapon_name} strikes at {target_name} and kills {casulties}"; } else if (number_of_shots > 1 && casulties == 0) { - attack_message = $"{number_of_shots} {weapon_name}s strike at the {target_name} ranks, but fail to inflict damage."; + attack_message = $"{number_of_shots} {weapon_plural} strike at the {target_name} ranks, but fail to inflict damage."; } else if (number_of_shots > 1 && casulties > 0) { - attack_message = $"{number_of_shots} {weapon_name}s strike at the {target_name} ranks, killing {casulties}."; + attack_message = $"{number_of_shots} {weapon_plural} strike at the {target_name} ranks, killing {casulties}."; } } } else { if (target.dudes_num[targeh] == 1) { if (casulties == 0) { - attack_message = $"{string(unit_name)} {weapon_name} strikes at a {target_name} but fails to kill it."; + attack_message = $"{firing_subject} strikes at a {target_name} but fails to kill it."; } else { - attack_message = $"{string(unit_name)} {weapon_name} strikes at a {target_name}, killing it."; + attack_message = $"{firing_subject} strikes at a {target_name}, killing it."; } } else { if (casulties == 0) { - attack_message = $"{string(unit_name)} {weapon_name} strikes at the {target_name} ranks, failing to kill any."; + attack_message = $"{firing_subject} strikes at the {target_name} ranks, failing to kill any."; } else { - attack_message = $"{string(unit_name)} {weapon_name} strikes at the {target_name} ranks and kills {casulties}."; + attack_message = $"{firing_subject} strikes at the {target_name} ranks and kills {casulties}."; } } } } + // Reason-aware override: armour stopped the shots cold (AP too low). Replaces whatever + // generic "no casualties" text the branches produced with something that explains why. + if (shots_bounced && casulties == 0) { + flavoured = true; + if (character_shot) { + attack_message = $"{string(unit_name)} {weapon_name} strikes the {target_name} but fails to penetrate its armour."; + } else if (number_of_shots == 1) { + attack_message = $"The {weapon_name} strikes the {target_name} but fails to penetrate its armour."; + } else if (weapon_data.has_tag("bolt")) { + attack_message = $"{number_of_shots} {weapon_plural} hammer the {target_name} but spark harmlessly off its armour."; + } else if (weapon_data.has_tag("flame")) { + attack_message = $"{number_of_shots} {weapon_plural} wash over the {target_name} but its armour endures the flames."; + } else if (weapon_data.has_tag("power")) { + attack_message = $"{number_of_shots} {weapon_plural} strike the {target_name} but glance off its armour."; + } else { + attack_message = $"{number_of_shots} {weapon_plural} strike the {target_name} but fail to penetrate its armour."; + } + } + // if (string_length(attack_message+kill_message+p3)<8) then show_message(weapon_name+" is not displaying anything"); // I don't understand what this was supposed to do either. @@ -545,26 +727,283 @@ function scr_flavor(id_of_attacking_weapons, target, target_type, number_of_shot } } + // Message size drives which lines survive the per-turn display cap (largest win). var message_size = 0; if (defenses == 1) { message_size = 999; } else if (casulties == 0) { - message_size = number_of_shots / 10; + // "Couldn't penetrate" lines must never outrank an actual kill (that's why a lone + // Warboss death used to get culled under its own bounce spam), so keep them tiny. + message_size = 0; } else { + // Weight kills by count *and* toughness so a single hard target (Warboss, Meganob) isn't + // buried under big trash-mob kills. Armour is the stable proxy: a lone survivor's HP gets + // chipped down before death, but its armour rating doesn't change. + message_size = casulties * (1 + target.dudes_ac[targeh]); if (target.dudes_vehicle[targeh] == 1) { - message_size = casulties * 10; + message_size *= 10; + } + } + + // When deferred, hand the parts back to the caller instead of posting them, so the spill-over + // kill list can be appended and the whole volley posted as one line. + if (!_defer) { + if (attack_message != "") { + add_battle_log_message(attack_message, message_size, message_priority); + display_battle_log_message(); + } + + if (leader_message != "") { + add_battle_log_message(leader_message, message_size, message_priority); + display_battle_log_message(); + } + } + + return { + attack: attack_message, + leader: leader_message, + size: message_size, + priority: message_priority, + bounced: (shots_bounced && casulties == 0), + injured: (!shots_bounced && casulties == 0), + target: target_name, + subject: firing_subject, + weapon: weapon_plural, + shots: number_of_shots, + kills: casulties, + volley: _volley_line, + }; +} + +/// @desc Formats a list of kills into "the X" / "N X", joined as "A, B, and C". +/// @param {Array} _kills Array of { name, count } structs. +/// @returns {string} +function format_kill_list(_kills) { + // Merge entries that share a name so multiple ranks of one unit read as a single tally + // (e.g. "29 Slugga Boy and 223 Slugga Boy" -> "252 Slugga Boy"). + var _merged = []; + for (var m = 0; m < array_length(_kills); m++) { + var _hit = false; + for (var n = 0; n < array_length(_merged); n++) { + if (_merged[n].name == _kills[m].name) { + _merged[n].count += _kills[m].count; + _hit = true; + break; + } + } + if (!_hit) { + array_push(_merged, { name: _kills[m].name, count: _kills[m].count }); + } + } + _kills = _merged; + var _n = array_length(_kills); + if (_n == 0) { + return ""; + } + var _parts = []; + for (var i = 0; i < _n; i++) { + var _k = _kills[i]; + array_push(_parts, (_k.count == 1) ? ("the " + _k.name) : (string(_k.count) + " " + _k.name)); + } + var _list = _parts[0]; + for (var i = 1; i < _n; i++) { + if (i == _n - 1) { + _list += (_n > 2 ? ", and " : " and ") + _parts[i]; } else { - message_size = casulties; + _list += ", " + _parts[i]; } } + return _list; +} + +/// @desc Posts a single consolidated volley line: the deferred rich flavour for the first target, +/// plus a trailing list of everything the volley's overflow killed afterwards. +/// @param {Struct} _primary Result returned by scr_flavor(..., _defer=true) for the first target (or undefined). +/// @param {Array} _spill_kills Array of { name, count } for targets killed after the first. +function emit_volley_flavour(_primary, _spill_kills) { + var _list = format_kill_list(_spill_kills); + + // Non-killing volley (armour-bounce or a wound that dropped no-one, and nothing spilled): + // consolidate into one chronological line per target instead of one line per weapon. + if (is_struct(_primary) && (_primary.bounced || _primary.injured) && _list == "") { + combat_kill_tally_flush(); + combat_tally_add(_primary.target, _primary.subject, _primary.injured); + return; + } + + // Simple killing volley with no spill-over: buffer it so consecutive volleys of the same weapon + // on the same target (e.g. a split lasgun volley firing in sub-stacks) collapse into one summed + // line. A single unmerged volley keeps its original rich flavour on flush. Flush the wound/bounce + // tally first so the log stays chronological. + if (is_struct(_primary) && _list == "" && _primary.volley && _primary.kills > 0) { + combat_tally_flush(); + combat_kill_tally_add(_primary.target, _primary.weapon, _primary.shots, _primary.kills, _primary.attack, _primary.size, _primary.priority, _primary.leader); + return; + } + + // A killing volley with spill-over, or a titled/lone shot, posts immediately; flush both pending + // tallies first so the log stays in chronological order. + combat_tally_flush(); + combat_kill_tally_flush(); + + if (!is_struct(_primary)) { + // No primary line (scr_flavor bailed on a dead target - shouldn't happen now that emptied + // formations are destroyed). Spill-over only happens after a wipe, so this is just defensive. + if (_list != "") { + add_battle_log_message("Overflowing fire cuts down " + _list + ".", 0, 0); + display_battle_log_message(); + } + return; + } + + var _message = _primary.attack; + if (_list != "") { + _message += " In the torrent of fire that reaches beyond those they slaughter: " + _list + "."; + } - if (attack_message != "") { - add_battle_log_message(attack_message, message_size, message_priority); + if (_message != "") { + add_battle_log_message(_message, _primary.size, _primary.priority); display_battle_log_message(); } + if (_primary.leader != "") { + add_battle_log_message(_primary.leader, _primary.size, _primary.priority); + display_battle_log_message(); + } +} + +/// @desc Buffers a non-killing volley (wound or armour-bounce) against a target. Consecutive volleys +/// on the same target merge; switching target flushes the previous one, keeping the log +/// chronological. _injured true = penetrated but no kill; false = bounced off armour. +function combat_tally_add(_target, _subject, _injured) { + if (!variable_global_exists("ctally_target")) { + global.ctally_target = undefined; + global.ctally_bounce = []; + global.ctally_injure = []; + } + if (global.ctally_target != _target) { + combat_tally_flush(); + global.ctally_target = _target; + } + if (_injured) { + array_push(global.ctally_injure, _subject); + } else { + array_push(global.ctally_bounce, _subject); + } +} + +/// @desc Posts the buffered wound/bounce lines for the current target (one each), then clears them. +function combat_tally_flush() { + if (!variable_global_exists("ctally_target") || global.ctally_target == undefined) { + return; + } + var _t = global.ctally_target; + if (array_length(global.ctally_injure) > 0) { + add_battle_log_message($"Fire from {combat_subject_join(global.ctally_injure)} wounds the {_t} but cannot bring it down.", 0, MSG_COLOR_LIGHTGREEN); + display_battle_log_message(); + } + if (array_length(global.ctally_bounce) > 0) { + add_battle_log_message($"Fire from {combat_subject_join(global.ctally_bounce)} cannot penetrate the {_t}'s armour.", 0, MSG_COLOR_WHITE); + display_battle_log_message(); + } + global.ctally_target = undefined; + global.ctally_bounce = []; + global.ctally_injure = []; +} + +/// @desc Buffers killing volleys that share a weapon and target, summing shots and kills so a split +/// volley (many sub-stacks firing at one target) collapses into one line. The first volley's +/// rich flavour is kept and used verbatim if no second volley merges with it. Switching target +/// flushes the previous target first, keeping the log chronological. +function combat_kill_tally_add(_target, _weapon, _shots, _kills, _attack, _size, _priority, _leader) { + if (!variable_global_exists("ktally_target")) { + global.ktally_target = undefined; + global.ktally_weapons = {}; + global.ktally_order = []; + global.ktally_leaders = []; + } + if (global.ktally_target != _target) { + combat_kill_tally_flush(); + global.ktally_target = _target; + global.ktally_weapons = {}; + global.ktally_order = []; + global.ktally_leaders = []; + } + if (!variable_struct_exists(global.ktally_weapons, _weapon)) { + global.ktally_weapons[$ _weapon] = { shots: 0, kills: 0, count: 0, attack: _attack, size: _size, priority: _priority }; + array_push(global.ktally_order, _weapon); + } + var _acc = global.ktally_weapons[$ _weapon]; + _acc.shots += _shots; + _acc.kills += _kills; + _acc.count += 1; + if (_leader != "") { + array_push(global.ktally_leaders, _leader); + } +} - if (leader_message != "") { - add_battle_log_message(leader_message, message_size, message_priority); +/// @desc Posts the buffered kills for the current target: one line per weapon (the original rich +/// line when only a single volley landed, otherwise a summed " strike at the +/// ranks, killing "), then any deferred leader lines, and clears. +function combat_kill_tally_flush() { + if (!variable_global_exists("ktally_target") || global.ktally_target == undefined) { + return; + } + var _t = global.ktally_target; + for (var _i = 0; _i < array_length(global.ktally_order); _i++) { + var _acc = global.ktally_weapons[$ global.ktally_order[_i]]; + if (_acc.count == 1) { + add_battle_log_message(_acc.attack, _acc.size, _acc.priority); + } else { + add_battle_log_message($"{_acc.shots} {global.ktally_order[_i]} strike at the {_t} ranks, killing {_acc.kills}.", _acc.size, _acc.priority); + } + display_battle_log_message(); + } + for (var _i = 0; _i < array_length(global.ktally_leaders); _i++) { + add_battle_log_message(global.ktally_leaders[_i], 0, 0); display_battle_log_message(); } + global.ktally_target = undefined; + global.ktally_weapons = {}; + global.ktally_order = []; + global.ktally_leaders = []; +} + +/// @desc Joins firing subjects into "A", "A and B", or "A, B, and C". +function combat_subject_join(_subjects) { + var _n = array_length(_subjects); + if (_n == 0) { + return ""; + } + var _list = _subjects[0]; + for (var i = 1; i < _n; i++) { + if (i == _n - 1) { + _list += (_n > 2 ? ", and " : " and ") + _subjects[i]; + } else { + _list += ", " + _subjects[i]; + } + } + return _list; +} + +/// @self Asset.GMObject.obj_ncombat +/// @desc Sets `newline` to the enemy strength readout (live %, boss HP, or "Defeated") and fires the +/// enemy-defeated side-effects. Shared by obj_ncombat's Alarm_3 and Step_0 so the line can't +/// drift between the two copies (that drift is what hid the % for so long). +function combat_emit_enemy_status() { + if ((enemy_forces > 0) && (enemy != 30)) { + newline = "Enemy Forces at " + string(max(1, round((enemy_forces / enemy_max) * 100))) + "%"; + } + if ((enemy == 30) && instance_exists(obj_enunit)) { + newline = "Enemy has "; + var yoo = instance_nearest(0, 0, obj_enunit); + newline += string(round(yoo.dudes_hp[1])) + "HP remaining"; + } + if ((enemy_forces <= 0) || (!instance_exists(obj_enunit)) && (defeat_message == 0)) { + defeat_message = 1; + newline = "Enemy Forces Defeated"; + timer_maxspeed = 0; + timer_speed = 0; + started = 2; + instance_activate_object(obj_pnunit); + } } diff --git a/scripts/scr_flavor2/scr_flavor2.gml b/scripts/scr_flavor2/scr_flavor2.gml index 5a84f0d153..098bc1b875 100644 --- a/scripts/scr_flavor2/scr_flavor2.gml +++ b/scripts/scr_flavor2/scr_flavor2.gml @@ -1,4 +1,28 @@ -function scr_flavor2(lost_units_count, target_type, hostile_range, hostile_weapon, hostile_shots, hostile_splash) { +/// @function incoming_damage_flavor +/// @description Combat-log sentence for an enemy hit that did NOT kill, scaled by how close it came +/// to a kill (_severity = damage over the target's health before the hit, 0..1). Vehicles get +/// armour/hull language, infantry get wound language. Appended after the attack verb, e.g. +/// "24 Big Shootaz roar and blast away at Rhino. Piercing the armour." Edit the wording freely; +/// only the tier thresholds matter to the rest of the code. +/// @param {real} _severity 0..1 +/// @param {bool} _is_vehicle target is a vehicle +/// @returns {string} +function incoming_damage_flavor(_severity, _is_vehicle) { + if (_is_vehicle) { + if (_severity < 0.10) return choose("Only peeling the paint.", "Just chipping the paint.", "Pinging off the armour.", "Bouncing off the hull.", "Only scratching the armour."); + if (_severity < 0.35) return choose("Barely putting a dent in the armour.", "Leaving a few dents in the hull.", "Only scuffing the armour."); + if (_severity < 0.65) return choose("Piercing the armour.", "Punching through the plating.", "Cracking the armour open."); + if (_severity < 0.90) return choose("Punching a huge hole in the armour.", "Tearing a gash through the hull.", "Blowing a hole in the plating."); + return choose("Almost destroying it.", "Leaving it a smoking wreck.", "Nearly tearing it apart."); + } + if (_severity < 0.10) return choose("But the armour holds.", "But it is shrugged off."); + if (_severity < 0.35) return choose("Drawing blood.", "Causing light wounds.", "Leaving a few grazes."); + if (_severity < 0.65) return choose("Wounding several.", "Bloodying the ranks.", "Leaving wounded behind."); + if (_severity < 0.90) return choose("Leaving deep wounds.", "Savaging the ranks.", "Leaving many badly wounded."); + return choose("Leaving the survivors maimed and reeling.", "All but breaking them.", "Leaving them maimed and scattered."); +} + +function scr_flavor2(lost_units_count, target_type, hostile_range, hostile_weapon, hostile_shots, hostile_splash, damage_severity = 0, target_is_vehicle = false) { // Generates flavor based on the damage and casualties from scr_shoot, only for the opponent if (obj_ncombat.wall_destroyed == 1) { @@ -35,6 +59,13 @@ function scr_flavor2(lost_units_count, target_type, hostile_range, hostile_weapo _hostile_shots = max(1, round(_hostile_shots / 3)); } + // Suppress empty attacks: no hits landed or no resolved target means there is nothing worth + // reporting. This is what produced lines like "0 rokkitz shoot at ." and "blasting into ." + // Walls are exempt; their own branch handles display. + if ((target_type != "wall") && ((hostile_shots <= 0) || (string(target_type) == ""))) { + exit; + } + // show_message(string(hostile_weapon)+"|"+string(_hostile_weapon)+"#"+string(los)+"#"+string(los_num)); var flavor = 0; @@ -382,17 +413,9 @@ function scr_flavor2(lost_units_count, target_type, hostile_range, hostile_weapo if (flavor == 0) { flavor = true; if (_hostile_shots == 1) { - if (lost_units_count == 0) { - m1 += $"{_hostile_weapon} strikes at {target_type}, no casualties."; - } else { - m1 += $"{_hostile_weapon} strikes at {target_type}. "; - } + m1 += $"{_hostile_weapon} strikes at {target_type}. "; } else { - if (lost_units_count == 0) { - m1 += $"{_hostile_shots} {_hostile_weapon}s strike at {target_type}, no casualties."; - } else { - m1 += $"{_hostile_shots} {_hostile_weapon}s strike at {target_type}. "; - } + m1 += $"{_hostile_shots} {_hostile_weapon}s strike at {target_type}. "; } } @@ -439,8 +462,11 @@ function scr_flavor2(lost_units_count, target_type, hostile_range, hostile_weapo special = is_specialist(unit_role, SPECIALISTS_HEADS) || unit_role == obj_ini.role[100][eROLE.CHAPTERMASTER] || unit_role == "Venerable " + string(obj_ini.role[100][eROLE.DREADNOUGHT]) || unit_role == obj_ini.role[100][eROLE.CAPTAIN] || obj_ncombat.player_max <= 6; if (!special) { - plural = units_lost > 1 ? "s" : ""; - m2 += $"{units_lost} {unit_role}{plural}, "; + var _plural_name = unit_role; + if (units_lost > 1) { + _plural_name = (unit_role == "Guardsman") ? "Guardsmen" : (unit_role + "s"); + } + m2 += $"{units_lost} {_plural_name}, "; } else { him = -1; // Find which unit this is for (var marine = 0; marine < marine_length; marine++) { @@ -517,14 +543,27 @@ function scr_flavor2(lost_units_count, target_type, hostile_range, hostile_weapo } } + // No kills but the attack connected: report the damage instead of a bare attack verb, scaled by + // how close it came to a kill. Severity is 0 for targets that do not track it (e.g. guardsmen), + // which lands on the lowest tier. + if ((m2 == "") && (lost_units_count == 0) && (hostile_shots > 0) && (target_type != "wall")) { + m2 = incoming_damage_flavor(damage_severity, target_is_vehicle); + } + mes = m1 + m2 + m3; // show_message(mes); if (string_length(mes) > 3) { + // Yellow when the enemy hurt your forces but destroyed nothing (damage, no kill). Kills carry + // the word "lost" and are coloured red elsewhere, so they are left at priority 0 here. + var _enemy_priority = 0; + if ((lost_units_count == 0) && (hostile_shots > 0) && (damage_severity >= 0.10)) { + _enemy_priority = 136; + } obj_ncombat.messages += 1; obj_ncombat.message[obj_ncombat.messages] = mes; obj_ncombat.message_sz[obj_ncombat.messages] = lost_units_count + (0.5 - (obj_ncombat.messages / 100)); - obj_ncombat.message_priority[obj_ncombat.messages] = 0; + obj_ncombat.message_priority[obj_ncombat.messages] = _enemy_priority; obj_ncombat.alarm[3] = 2; } } diff --git a/scripts/scr_fleet_advisor/scr_fleet_advisor.gml b/scripts/scr_fleet_advisor/scr_fleet_advisor.gml index ead8f667f8..0696818b72 100644 --- a/scripts/scr_fleet_advisor/scr_fleet_advisor.gml +++ b/scripts/scr_fleet_advisor/scr_fleet_advisor.gml @@ -183,6 +183,9 @@ function scr_fleet_advisor() { location.contents = obj_ini.ship_location[i]; hp.contents = $"{round(obj_ini.ship_hp[i] / obj_ini.ship_maxhp[i] * 100)}%"; carrying.contents = $"{obj_ini.ship_carrying[i]}/{obj_ini.ship_capacity[i]}"; + if (obj_ini.ship_guardsmen[i] > 0) { + carrying.contents += $" +{scr_display_number(obj_ini.ship_guardsmen[i])} IG"; + } } for (var g = 0; g < array_length(_columns_array); g++) { @@ -234,7 +237,8 @@ function scr_fleet_advisor() { cn.temp[119] = scr_ship_occupants(i); } } - tooltip_draw($"Carrying ({cn.temp[118]}): {cn.temp[119]}"); + var _ig_line = (obj_ini.ship_guardsmen[i] > 0) ? $" | Imperial Guard embarked: {scr_display_number(obj_ini.ship_guardsmen[i])}" : ""; + tooltip_draw($"Carrying ({cn.temp[118]}): {cn.temp[119]}{_ig_line}"); if (_goto_button.click()) { with (obj_p_fleet) { var _fleet_ships = fleet_full_ship_array(); diff --git a/scripts/scr_fleet_functions/scr_fleet_functions.gml b/scripts/scr_fleet_functions/scr_fleet_functions.gml index 9937992eeb..c540b26ba9 100644 --- a/scripts/scr_fleet_functions/scr_fleet_functions.gml +++ b/scripts/scr_fleet_functions/scr_fleet_functions.gml @@ -1,3 +1,5 @@ +/// @param {Real} strength +/// @param {Id.Instance.obj_en_fleet|Id.Instance.obj_p_fleet} fleet function distribute_strength_to_fleet(strength, fleet) { while (strength > 0) { var ship_type = choose(1, 1, 1, 1, 2, 2, 3); @@ -12,26 +14,34 @@ function distribute_strength_to_fleet(strength, fleet) { } } -function standard_fleet_strength_calc(fleet = undefined){ - if (is_undefined(fleet)){ +/// @self Id.Instance.obj_en_fleet|Id.Instance.obj_p_fleet +/// @param {Id.Instance.obj_en_fleet|Id.Instance.obj_p_fleet} fleet +function standard_fleet_strength_calc(fleet = noone){ + if (fleet == noone) { fleet = self; } return fleet.capital_number + (fleet.frigate_number/2) + (fleet.escort_number/4); } -/// @self Asset.GMObject.obj_en_fleet function random_sector_exit_point() { action_x = choose(room_width * -1, room_width * 2); action_y = choose(room_height * -1, room_height * 2); } -/// @self Asset.GMObject.obj_en_fleet|Asset.GMObject.obj_p_fleet -function in_room(object = undefined) { - object ??= self; +/// @self Id.Instance.obj_en_fleet|Id.Instance.obj_p_fleet +/// @param {Id.Instance.obj_en_fleet|Id.Instance.obj_p_fleet} object +/// @return {Bool} +function in_room(object = noone) { + if (object == noone) { + object = self; + } return !(object.x < 0 || object.x > room_width || object.y < 0 || object.y > room_height); } -/// @self Asset.GMObject.obj_en_fleet|Asset.GMObject.obj_p_fleet +/// @self Id.Instance.obj_en_fleet|Id.Instance.obj_p_fleet +/// @param {Real} targ_x +/// @param {Real} targ_y +/// @param {Id.Instance.obj_fleet} final_target function set_fleet_target(targ_x, targ_y, final_target) { action_x = targ_x; action_y = targ_y; @@ -39,7 +49,7 @@ function set_fleet_target(targ_x, targ_y, final_target) { action_eta = floor(point_distance(x, y, targ_x, targ_y) / 128) + 1; } -/// @param {Asset.GMObject.obj_en_fleet|Asset.GMObject.obj_p_fleet} target +/// @param {Id.Instance} target function scr_valid_fleet_target(target) { if (target == noone) { return false; @@ -56,22 +66,22 @@ function scr_valid_fleet_target(target) { } function get_fleet_uid(search_uid) { - var _fleet = undefined; + var _fleet = noone; with (obj_en_fleet) { if (uid == search_uid) { - _fleet = id; + _fleet = self; break; } } return _fleet; } - /// @self Asset.GMObject.obj_en_fleet|Asset.GMObject.obj_p_fleet -/// @param {Asset.GMObject.obj_en_fleet|Asset.GMObject.obj_p_fleet} fleet -function fleets_next_location(fleet = "none", visited = []) { - var targ_location = "none"; +/// @param {Id.Instance.obj_en_fleet|Id.Instance.obj_p_fleet} fleet +/// @param {Array} visited +function fleets_next_location(fleet = noone, visited = []) { + var targ_location = noone; - if (fleet == "none") { + if (fleet == noone) { fleet = self; } @@ -99,15 +109,17 @@ function fleets_next_location(fleet = "none", visited = []) { } } // If targ_location was not set to anything else, default to the nearest star - if (targ_location == "none") { + if (targ_location == noone) { targ_location = instance_nearest(fleet.x, fleet.y, obj_star); } return targ_location; } +/// @self Asset.GMObject.obj_en_fleet|Asset.GMObject.obj_p_fleet +/// @param {Id.Instance.obj_en_fleet|Id.Instance.obj_p_fleet} target function chase_fleet_target_set(target) { var targ_location = fleets_next_location(target); - if (targ_location != "none") { + if (targ_location != noone) { action_x = targ_location.x; action_y = targ_location.y; action = ""; @@ -126,11 +138,11 @@ function fleet_intercept_time_calculate(target_intercept) { } function get_largest_player_fleet() { - var chosen_fleet = "none"; + var chosen_fleet = noone; if (instance_exists(obj_p_fleet)) { with (obj_p_fleet) { if (point_in_rectangle(x, y, 0, 0, room_width, room_height) && point_in_rectangle(action_x, action_y, 0, 0, room_width, room_height)) { - if (chosen_fleet == "none") { + if (chosen_fleet == noone) { chosen_fleet = self; continue; } @@ -154,8 +166,8 @@ function get_largest_player_fleet() { } /// @self Asset.GMObject.obj_en_fleet|Asset.GMObject.obj_p_fleet -function is_orbiting(fleet = "none") { - if (fleet == "none") { +function is_orbiting(fleet = noone) { + if (fleet == noone) { if (action != "") { return false; } @@ -165,7 +177,7 @@ function is_orbiting(fleet = "none") { orbiting = nearest.id; return true; } - orbiting = false; + orbiting = noone; } catch (_exception) { return false; } @@ -191,7 +203,7 @@ function set_fleet_movement(fastest_route = true, new_action = "move", minimum_e var path = star_travel.final_array_path(); if (array_length(path) > 1) { var targ = find_star_by_name(path[1]); - if (targ != "none") { + if (targ != noone) { array_delete(path, 0, 2); complex_route = path; action_x = targ.x; @@ -226,15 +238,15 @@ function set_fleet_movement(fastest_route = true, new_action = "move", minimum_e } } - // action_x=sys.x; - // action_y=sys.y; - orbiting = false; + orbiting = noone; action = new_action; action_eta = clamp(action_eta, minimum_eta, maximum_eta); } } } +/// @param {Id.Instance.obj_en_fleet|Id.Instance.obj_p_fleet} fleet +/// @param {Struct} unit function load_unit_to_fleet(fleet, unit) { var loaded = false; var all_ships = fleet_full_ship_array(fleet); @@ -253,47 +265,45 @@ function load_unit_to_fleet(fleet, unit) { return loaded; } -function calculate_fleet_eta(xx, yy, xxx, yyy, fleet_speed, star1 = true, star2 = true, warp_able = false) { - var warp_lane = false; - var eta = 0; - //Some duke unfinished webway stuff copied here for reference - /*for (var w = 1;w<5;w++){ - if (planet_feature_bool(mine.p_feature[w], eP_FEATURES.WEBWAY)==1) then web1=1; - if (planet_feature_bool(sys.p_feature[w], eP_FEATURES.WEBWAY)==1) then web2=1; - }*/ - if (star1 && star2) { - star1 = instance_nearest(xx, yy, obj_star); - star2 = instance_nearest(xxx, yyy, obj_star); - warp_lane = determine_warp_join(star1.id, star2.id); - } else if (star1) { - star1 = instance_nearest(xx, yy, obj_star); - } - eta = floor(point_distance(xx, yy, xxx, yyy) / fleet_speed) + 1; +/// @param {Real} xx +/// @param {Real} yy +/// @param {Real} xxx +/// @param {Real} yyy +/// @param {Real} fleet_speed +/// @param {Id.Instance.obj_star} star1 +/// @param {Id.Instance.obj_star} star2 +/// @param {Bool} warp_able +function calculate_fleet_eta(xx, yy, xxx, yyy, fleet_speed, star1 = noone, star2 = noone, warp_able = false) { + // Always resolve both endpoints to real star instances from the coordinates. + // Every real-travel caller historically passes booleans (from_star, is_orbiting(), + // true/false) in the star1/star2 slots, which left warp_lane at 0 and made actual + // jumps ignore lanes entirely (doubling the time and skipping the storm check), while + // the map preview, which omits these args, computed lanes correctly. Resolving from + // coords here ignores those bad args and keeps the preview and the real transit in sync. + star1 = instance_nearest(xx, yy, obj_star); + star2 = instance_nearest(xxx, yyy, obj_star); + var warp_lane = determine_warp_join(star1.id, star2.id); + var eta = floor(point_distance(xx, yy, xxx, yyy) / fleet_speed) + 1; if (!warp_lane) { eta *= 2; } if (warp_lane && warp_able) { eta = ceil(eta / warp_lane); } - if (!star2) { - return eta; - } //check end location for warp storm - if (instance_exists(star2)) { - if (star2.object_index == obj_star) { - if (star2.storm) { - eta += 10000; - } - } + if (instance_exists(star2) && (star2.object_index == obj_star) && star2.storm) { + eta += 10000; } return eta; } /// @self Asset.GMObject.obj_en_fleet|Asset.GMObject.obj_p_fleet -function calculate_action_speed(fleet = "none", selected = false) { +/// @param {Id.Instance.obj_en_fleet|Id.Instance.obj_p_fleet} fleet +/// @param {Bool} selected +function calculate_action_speed(fleet = noone, selected = false) { try { - if (fleet == "none") { + if (fleet == noone) { var capitals = 0, frigates = 0, escorts = 0, i; var _is_player_fleet = object_index == obj_p_fleet; if (_is_player_fleet) { @@ -387,7 +397,7 @@ function scr_efleet_arrive_at_trade_loc() { //if no fleet find a valid planet with player forces if (action == "") { var _player_star = nearest_star_with_ownership(x, y, 1); - if (_player_star != "none") { + if (_player_star != noone) { action_x = _player_star.x; action_y = _player_star.y; set_fleet_movement(); @@ -406,7 +416,7 @@ function scr_efleet_arrive_at_trade_loc() { //if no other viable options drop off at random imperial planet if (action == "") { var _imp = nearest_star_with_ownership(x, y, 2); - if (_imp != "none") { + if (_imp != noone) { if (x == _imp.x && y == _imp.y) { _valid_planet = true; } else { @@ -442,7 +452,7 @@ function scr_efleet_arrive_at_trade_loc() { if (owner == eFACTION.ELDAR) { cur_star = nearest_star_with_ownership(xx, yy, eFACTION.ELDAR); - if (cur_star != "none") { + if (cur_star != noone) { cur_star = targ.x; cur_star = targ.y; } @@ -462,17 +472,17 @@ function scr_efleet_arrive_at_trade_loc() { /// @function scr_orbiting_fleet(faction, system) /// @description Returns the ID of a fleet orbiting the given system/star that matches the specified faction. -/// @param {any|array} faction +/// @param {Real|Array} faction /// The faction identifier to check against. Can be a single faction ID or an array of multiple factions. -/// @param {any} [system="none"] -/// The system instance or star to check. If `"none"`, the function uses the calling instance's position. -/// @returns {real|string} The ID of the matching fleet instance, or `"none"` if no valid fleet is found. +/// @param {Id.Instance.obj_star} system +/// The system instance or star to check. If `noone`, the function uses the calling instance's position. +/// @returns {Id.Instance.obj_en_fleet|Id.Instance.obj_p_fleet} The ID of the matching fleet instance, or `noone` if no valid fleet is found. /// /// @example /// ```gml /// // Find a fleet orbiting this star that belongs to faction 3 /// var fleet_id = scr_orbiting_fleet(3); -/// if (fleet_id != "none") { +/// if (fleet_id != noone) { /// LOGGER.debug("Faction fleet found: " + string(fleet_id)); /// } /// @@ -480,13 +490,11 @@ function scr_efleet_arrive_at_trade_loc() { /// var factions = [1, 2, 5]; /// var fleet_id = scr_orbiting_fleet(factions, some_system); /// ``` -/// - -function scr_orbiting_fleet(faction, system = "none") { - var _found_fleet = "none"; +function scr_orbiting_fleet(faction, system = noone) { + var _found_fleet = noone; var _faction_list = is_array(faction); - var xx = system == "none" ? x : system.x; - var yy = system == "none" ? y : system.y; + var xx = system == noone ? x : system.x; + var yy = system == noone ? y : system.y; with (obj_en_fleet) { if (x == xx && y == yy) { var _valid = false; @@ -508,9 +516,9 @@ function scr_orbiting_fleet(faction, system = "none") { /// @function object_distance(obj_1, obj_2) /// @description Returns the distance in pixels between two instances or objects based on their `x` and `y` coordinates. -/// @param {instance} obj_1 The first object or instance. -/// @param {instance} obj_2 The second object or instance. -/// @returns {real} The distance in pixels between `obj_1` and `obj_2`. +/// @param {Id.Instance} obj_1 The first object or instance. +/// @param {Id.Instance} obj_2 The second object or instance. +/// @returns {Real} The distance in pixels between `obj_1` and `obj_2`. /// /// @example /// ```gml @@ -519,17 +527,15 @@ function scr_orbiting_fleet(faction, system = "none") { /// LOGGER.debug("Enemy is within range!"); /// } /// ``` -/// - function object_distance(obj_1, obj_2) { return point_distance(obj_1.x, obj_1.y, obj_2.x, obj_2.y); } /// @function scr_orbiting_player_fleet(system) /// @description Returns the ID of the nearest player fleet orbiting the given system or star. -/// @param {any} [system="none"] -/// The system instance or identifier to check. If `"none"`, the function checks the calling star instance. -/// @returns {real} The instance ID of the orbiting player fleet, or -1 if none is found. +/// @param {Id.Instance.obj_star} system +/// The system instance or identifier to check. If `noone`, the function checks the calling star instance. +/// @returns {Id.Instance.obj_p_fleet} The instance ID of the orbiting player fleet, or -1 if none is found. /// /// @example /// ```gml @@ -538,16 +544,15 @@ function object_distance(obj_1, obj_2) { /// LOGGER.debug("Fleet orbiting star: " + string(fleet_id)); /// } /// ``` -/// -function scr_orbiting_player_fleet(system = "none") { - if (system == "none" && !is_struct(self) && object_index == obj_star) { +function scr_orbiting_player_fleet(system = noone) { + if (system == noone && !is_struct(self) && object_index == obj_star) { var _fleet = instance_nearest(x, y, obj_p_fleet); if (object_distance(self, _fleet) > 0) { return -1; } else { return _fleet.id; } - } else if (system != "none") { + } else if (system != noone) { try { with (system) { return scr_orbiting_player_fleet(); @@ -560,11 +565,11 @@ function scr_orbiting_player_fleet(system = "none") { return -1; } -function get_orbiting_fleets(faction, system = "none") { +function get_orbiting_fleets(faction, system = noone) { var _fleets = []; var _faction_list = is_array(faction); - var xx = system == "none" ? x : system.x; - var yy = system == "none" ? y : system.y; + var xx = system == noone ? x : system.x; + var yy = system == noone ? y : system.y; with (obj_en_fleet) { if (x == xx && y == yy) { var _valid = false; @@ -686,8 +691,6 @@ function fleet_arrival_logic() { sta = instance_nearest(action_x, action_y, obj_star); is_orbiting(); - // cur_star.present_fleets+=1;if (owner = eFACTION.TAU) then cur_star.tau_fleets+=1; - if (owner == eFACTION.MECHANICUS) { if (trade_goods == "mars_spelunk1") { trade_goods = "mars_spelunk2"; @@ -709,7 +712,6 @@ function fleet_arrival_logic() { } if (trade_goods == "return") { - // with(instance_nearest(x,y,obj_star)){present_fleets-=1;} instance_destroy(); } @@ -881,7 +883,7 @@ function fleet_arrival_logic() { action_x = 0; action_y = 0; - // 135 ; fleet chase + // fleet chase if ((string_count("Inqis", trade_goods) > 0) && (string_count("fleet", trade_goods) > 0) && (!string_count("_her", trade_goods))) { inquisition_fleet_inspection_chase(); } @@ -916,24 +918,18 @@ function fleet_arrival_logic() { mergus = 0; } - if ((owner == eFACTION.TAU) && (image_index == 1)) { - // show_message("Tau||| Other Owner: "+string(cur_star.owner)+" ret: "+string(ret)+" mergus: "+string(mergus)); - } - if ((owner == eFACTION.CHAOS) && fleet_has_cargo("csm") || fleet_has_cargo("warband")) { mergus = 0; } - // if (cur_star.owner!=owner) then mergus=0; if ((cur_star.x == old_x) && (cur_star.y == old_y) && (cur_star.owner == self.owner) && (cur_star.action == "") && (mergus == 1999)) { // Merge the fleets cur_star.escort_number += self.escort_number; - cur_star.frigate_number += self.frigate_number; // show_message("Tau fleet merging"); + cur_star.frigate_number += self.frigate_number; cur_star.capital_number += self.capital_number; cur_star.guardsmen += self.guardsmen; cur_star = instance_nearest(old_x, old_y, obj_star); - // if (cur_star.present_fleets>=1) then cur_star.present_fleets-=1; if (owner == eFACTION.TAU) { obj_controller.tau_fleets -= 1; cur_star.tau_fleets -= 1; @@ -947,9 +943,8 @@ function fleet_arrival_logic() { if ((owner == eFACTION.TAU) && (mergus == 15)) { // Get the fuck out - var new_star, stue; - new_star = 0; - stue = 0; + var new_star = 0; + var stue = 0; ret = 1; instance_activate_object(obj_star); // new_star @@ -969,14 +964,14 @@ function fleet_arrival_logic() { if ((tau_influence_chance <= 70) && (tau_influence < 70)) { adjust_influence[tau_influence_planet](eFACTION.TAU, 10, tau_influence_planet); if (p_type[tau_influence_planet] == "Forge") { - adjust_influence(eFACTION.TAU, -5, tau_influence_planet); + adjust_influence(eFACTION.TAU, -5, tau_influence_planet, self); } } if ((tau_influence_chance <= 3) && (tau_influence < 70)) { - adjust_influence(eFACTION.TAU, 30, tau_influence_planet); + adjust_influence(eFACTION.TAU, 30, tau_influence_planet, self); if (p_type[tau_influence_planet] == "Forge") { - adjust_influence(eFACTION.TAU, -25, tau_influence_planet); + adjust_influence(eFACTION.TAU, -25, tau_influence_planet, self); } } } @@ -987,18 +982,16 @@ function fleet_arrival_logic() { with (obj_star) { if (owner != eFACTION.TAU) { - instance_deactivate_object(instance_id); + instance_deactivate_object(self); } } - var good; - good = 0; + var good = 0; repeat (100) { - var xx, yy; if (good == 0) { - xx = x + choose(random(300), random(300) * -1); - yy = y + choose(random(300), random(300) * -1); + var xx = x + choose(random(300), random(300) * -1); + var yy = y + choose(random(300), random(300) * -1); new_star = instance_nearest(xx, yy, obj_star); if (new_star.owner != eFACTION.TAU) { with (new_star) { @@ -1011,10 +1004,7 @@ function fleet_arrival_logic() { } } - // show_message("Get the fuck out working?: "+string(good)); - if (new_star.owner == eFACTION.TAU) { - // show_message("Tau fleet actually fleeing"); action_x = new_star.x; action_y = new_star.y; set_fleet_movement(); @@ -1031,9 +1021,7 @@ function fleet_arrival_logic() { if ((cur_star.x == old_x) && (cur_star.y == old_y) && (cur_star.owner == self.owner) && (cur_star.action == "") && ((owner == eFACTION.TAU) || (owner == eFACTION.CHAOS)) && (mergus == 10) && (!_csm)) { // Move somewhere new - var stue, stue2; - stue = 0; - stue2 = 0; + var stue2 = noone; var goood = 0; with (obj_star) { @@ -1041,7 +1029,7 @@ function fleet_arrival_logic() { instance_deactivate_object(id); } } - stue = instance_nearest(x, y, obj_star); + var stue = instance_nearest(x, y, obj_star); instance_deactivate_object(stue); repeat (10) { if (goood == 0) { @@ -1065,7 +1053,7 @@ function fleet_arrival_logic() { } action_x = stue2.x; action_y = stue2.y; - set_fleet_movement(); // stue.present_fleets-=1; + set_fleet_movement(); instance_activate_object(obj_star); } @@ -1084,7 +1072,7 @@ function fleet_arrival_logic() { var kay = 0, temp5 = 0, temp6 = 0, temp7 = 0; - var cur_star = instance_nearest(x, y, obj_star); + cur_star = instance_nearest(x, y, obj_star); // This is the new check to go along code; if doesn't add up to all planets = 7 then they exit if (!is_dead_star(cur_star)) { @@ -1102,7 +1090,7 @@ function fleet_arrival_logic() { if (owner == eFACTION.ORK) { with (obj_star) { if (owner == eFACTION.ORK) { - instance_deactivate_object(instance_id); + instance_deactivate_object(self); } } } @@ -1130,7 +1118,6 @@ function fleet_arrival_logic() { action_y = temp7.y; set_fleet_movement(); - // cur_star.present_fleets-=1; } instance_activate_object(obj_star); @@ -1141,7 +1128,7 @@ function fleet_arrival_logic() { instance_activate_object(obj_star); } - exit; // end of eta=0 + exit; } /// @self Asset.GMObject.obj_en_fleet|Asset.GMObject.obj_p_fleet @@ -1170,8 +1157,8 @@ function choose_fleet_sprite_image() { image_speed = 0; } -/// @param {Asset.GMObject.obj_en_fleet|Asset.GMObject.obj_p_fleet} main_fleet -/// @param {Asset.GMObject.obj_en_fleet|Asset.GMObject.obj_p_fleet} merge_fleet +/// @param {Id.Instance.obj_en_fleet|Id.Instance.obj_p_fleet} main_fleet +/// @param {Id.Instance.obj_en_fleet|Id.Instance.obj_p_fleet} merge_fleet function merge_fleets(main_fleet, merge_fleet) { main_fleet.capital_number += merge_fleet.capital_number; main_fleet.frigate_number += merge_fleet.frigate_number; @@ -1216,7 +1203,6 @@ function fleet_respond_crusade() { } var enemu; - //var cs with (obj_star) { var cs = instance_nearest(x, y, obj_crusade); diff --git a/scripts/scr_forge_world_functions/scr_forge_world_functions.gml b/scripts/scr_forge_world_functions/scr_forge_world_functions.gml index 3826cea3f2..3733008d02 100644 --- a/scripts/scr_forge_world_functions/scr_forge_world_functions.gml +++ b/scripts/scr_forge_world_functions/scr_forge_world_functions.gml @@ -186,12 +186,12 @@ function build_planet_defence_fleets() { var forge = array_random_element(_mechanicus_worlds); var _current_imperial_fleet = scr_orbiting_fleet(eFACTION.IMPERIUM, forge); var _defence_fleet = false; - if (_current_imperial_fleet != "none") { + if (_current_imperial_fleet != noone) { if (!_current_imperial_fleet.navy) { _defence_fleet = true; } } else { - var _current_imperial_fleet = instance_create(forge.x, forge.y, obj_en_fleet); + _current_imperial_fleet = instance_create(forge.x, forge.y, obj_en_fleet); _defence_fleet = true; with (_current_imperial_fleet) { navy = false; diff --git a/scripts/scr_garrison/scr_garrison.gml b/scripts/scr_garrison/scr_garrison.gml index 9439e40c4e..746a20eac7 100644 --- a/scripts/scr_garrison/scr_garrison.gml +++ b/scripts/scr_garrison/scr_garrison.gml @@ -280,7 +280,6 @@ function GarrisonForce(system, planet, type = "garrison") constructor { static determine_battle = function(attack_defend, win, margin, enemy, location, planet = 0, ship = 0) { var _sim = global.character_tester; if (win) {} else { - //var squad_positions; var _leader; var m; var _unit; @@ -342,12 +341,12 @@ function GarrisonForce(system, planet, type = "garrison") constructor { }; } -function determine_pdf_defence(pdf, garrison = "none", planet_forti = 0, enemy = 0) { +function determine_pdf_defence(pdf, garrison = noone, planet_forti = 0, enemy = 0) { var explanations = ""; var defence_mult = planet_forti * 0.1; var pdf_score = 0; explanations += $"Planet Defences:X{defence_mult + 1}#"; - if (garrison != "none") { + if (garrison != noone) { //if player supports give garrison bonus var garrison_mult = garrison.viable_garrison * (0.008 + (0.001 * planet_forti)); var siege_masters = scr_has_adv("Siege Masters"); diff --git a/scripts/scr_get_item_names/scr_get_item_names.gml b/scripts/scr_get_item_names/scr_get_item_names.gml index 9f91a71d50..ee9430e912 100644 --- a/scripts/scr_get_item_names/scr_get_item_names.gml +++ b/scripts/scr_get_item_names/scr_get_item_names.gml @@ -762,7 +762,7 @@ function scr_get_item_names(_item_names, _role, _slot, _engagement, _include_com undefined, // no range filter false, // not master crafted undefined, // no required tags - ["vehicle"], // exclude vehicle gear + ["vehicle", "no_equip"], // exclude vehicle gear + unequippable items _with_none_if_not_skip, true // with_any ); diff --git a/scripts/scr_gift_items/scr_gift_items.gml b/scripts/scr_gift_items/scr_gift_items.gml index 2d9d809857..b1b22bd940 100644 --- a/scripts/scr_gift_items/scr_gift_items.gml +++ b/scripts/scr_gift_items/scr_gift_items.gml @@ -55,8 +55,6 @@ function gift_artifact(give_to, known = true) { var artifact_struct = obj_ini.artifact_struct[arti_index]; var cur_tags = obj_ini.artifact_tags[arti_index]; - // obj_controller.artifacts-=1; // this is done by delete_artifact() that is run later; - obj_controller.cooldown = 10; if (obj_controller.menu_artifact > obj_controller.artifacts) { obj_controller.menu_artifact = obj_controller.artifacts; @@ -214,16 +212,13 @@ function setup_gift_popup() { fac_buttons = []; + var _y1 = 131; for (var i = 2; i <= 8; i++) { if (i == 7) { continue; } - var _y1 = 131; - if (i > 2) { - var _y1 = _last_y; - } var _fac_but = new UnitButtonObject({x1: 660, w: 147, set_width: true, y1: _y1, style: "pixel", label: obj_controller.faction[i], faction: i, tooltip: $"Disposition : {obj_controller.disposition[i]}"}); - var _last_y = _fac_but.y2; + _y1 = _fac_but.y2; array_push(fac_buttons, _fac_but); } } @@ -243,10 +238,9 @@ function setup_gift_stc_popup() { } function gift_stc_fragment() { - var r1, r2, cn; - r2 = 0; - cn = obj_controller; - r1 = floor(random(cn.stc_wargear_un + cn.stc_vehicles_un + cn.stc_ships_un)) + 1; + var r2 = 0; + var cn = obj_controller; + var r1 = floor(random(cn.stc_wargear_un + cn.stc_vehicles_un + cn.stc_ships_un)) + 1; if ((r1 < cn.stc_wargear_un) && (cn.stc_wargear_un > 0)) { r2 = 1; @@ -301,8 +295,7 @@ function gift_stc_fragment() { scr_toggle_diplomacy(); obj_controller.diplomacy = giveto; obj_controller.force_goodbye = -1; - var the; - the = ""; + var the = ""; if ((giveto != eFACTION.ORK) && (giveto != eFACTION.CHAOS)) { the = "the "; } diff --git a/scripts/scr_ground_ai_helpers/scr_ground_ai_helpers.gml b/scripts/scr_ground_ai_helpers/scr_ground_ai_helpers.gml index fb6bd8f317..c86f369f98 100644 --- a/scripts/scr_ground_ai_helpers/scr_ground_ai_helpers.gml +++ b/scripts/scr_ground_ai_helpers/scr_ground_ai_helpers.gml @@ -1,5 +1,3 @@ -// Script assets have changed for v2.3.0 see -// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information function system_guard_total() { var total = 0; for (var i = 1; i <= planets; i++) { @@ -8,8 +6,8 @@ function system_guard_total() { return total; } -function planet_imperial_base_enemies(planet, star = "none") { - if (star == "none") { +function planet_imperial_base_enemies(planet, star = noone) { + if (star == noone) { return p_orks[planet] + p_tau[planet] + p_chaos[planet] + p_traitors[planet] + p_tyranids[planet] + p_necrons[planet]; } else { with (star) { diff --git a/scripts/scr_has_adv/scr_has_adv.gml b/scripts/scr_has_adv/scr_has_adv.gml index e67a46ad2b..b5428d6407 100644 --- a/scripts/scr_has_adv/scr_has_adv.gml +++ b/scripts/scr_has_adv/scr_has_adv.gml @@ -3,8 +3,8 @@ * @return {Bool} */ function scr_has_adv(advantage) { + var result = false; try { - var result; if (instance_exists(obj_creation)) { result = selected_chapter_trait(advantage); } else { @@ -12,15 +12,6 @@ function scr_has_adv(advantage) { } } catch (_exception) { ERROR_HANDLER.handle_exception(_exception); - result = false; } return result; - - // var adv_count = array_length(obj_ini.adv); - // for(var i = 0; i < adv_count; i++){ - // if(obj_ini.adv[i] == advantage){ - // return true; - // } - // } - // return false; } diff --git a/scripts/scr_has_disadv/scr_has_disadv.gml b/scripts/scr_has_disadv/scr_has_disadv.gml index 41b3f787f1..4907eb46b7 100644 --- a/scripts/scr_has_disadv/scr_has_disadv.gml +++ b/scripts/scr_has_disadv/scr_has_disadv.gml @@ -3,8 +3,8 @@ * @return {Bool} */ function scr_has_disadv(disadvantage) { + var result = false; try { - var result; if (instance_exists(obj_creation)) { result = selected_chapter_trait(disadvantage); } else { @@ -12,14 +12,6 @@ function scr_has_disadv(disadvantage) { } } catch (_exception) { ERROR_HANDLER.handle_exception(_exception); - result = false; } return result; - // var disadv_count = array_length(obj_ini.dis); - // for(var i = 0; i < disadv_count; i++){ - // if(obj_ini.dis[i] == disadvantage){ - // return true; - // } - // } - // return false; } diff --git a/scripts/scr_hit/scr_hit.gml b/scripts/scr_hit/scr_hit.gml index eac8d57182..f41d4a714f 100644 --- a/scripts/scr_hit/scr_hit.gml +++ b/scripts/scr_hit/scr_hit.gml @@ -1,7 +1,12 @@ /// @function scr_hit /// @description Returns true if mouse is hovering on the specified rectangle area. -/// @returns {bool} -function scr_hit(x1 = 0, y1 = 0, x2 = 0, y2 = 0, force_gui = false) { +/// @param {Real|Array} x1 +/// @param {Real} y1 +/// @param {Real} x2 +/// @param {Real} y2 +/// @param {Bool} force_gui +/// @returns {Bool} +function scr_hit(x1, y1 = 0, x2 = 0, y2 = 0, force_gui = false) { var _mouse_consts = force_gui ? [device_mouse_x_to_gui(0), device_mouse_y_to_gui(0)] : return_mouse_consts(); if (is_array(x1)) { return point_in_rectangle(_mouse_consts[0], _mouse_consts[1], x1[0], x1[1], x1[2], x1[3]); @@ -12,28 +17,52 @@ function scr_hit(x1 = 0, y1 = 0, x2 = 0, y2 = 0, force_gui = false) { /// @function sr_hit_struct /// @description Returns true if mouse is hovering on the specified rectangle area runs withi any valid strucct with x1, y1, x2, y2. -/// @returns {bool} +/// @param {Bool} force_gui +/// @returns {Bool} /// @mixin function sr_hit_struct(force_gui = false){ var _mouse_consts = force_gui ? [device_mouse_x_to_gui(0), device_mouse_y_to_gui(0)] : return_mouse_consts(); return point_in_rectangle(_mouse_consts[0], _mouse_consts[1], x1, y1, x2, y2); } +/// @function scr_hit_object +/// @description +/// @param {Bool} force_gui +/// @returns {Bool} function scr_hit_object(force_gui = false){ var _mouse_consts = force_gui ? [device_mouse_x_to_gui(0), device_mouse_y_to_gui(0)] : return_mouse_consts(); return point_in_rectangle(_mouse_consts[0], _mouse_consts[1], x, y, x + width, y + height); } +/// @function scr_hit_relative +/// @description +/// @param {Array} x1 +/// @param {Array} relative +/// @returns {Bool} function scr_hit_relative(x1, relative = [0, 0]) { var _mouse_consts = return_mouse_consts(); return point_in_rectangle(_mouse_consts[0], _mouse_consts[1], relative[0] + x1[0], relative[1] + x1[1], relative[0] + x1[2], relative[1] + x1[3]); } +/// @function scr_hit_dimensions +/// @description +/// @param {Real} x1 +/// @param {Real} y1 +/// @param {Real} w +/// @param {Real} h +/// @returns {Bool} function scr_hit_dimensions(x1 = 0, y1 = 0, w = 0, h = 0) { var _mouse_consts = return_mouse_consts(); return point_in_rectangle(_mouse_consts[0], _mouse_consts[1], x1, y1, x1 + w, y1 + h); } +/// @function _point_and_click_logic +/// @description +/// @param {Array} _rect +/// @param {Real} _cooldown +/// @param {Bool} _lock_bypass +/// @param {Bool} _inverted +/// @returns {Bool} function _point_and_click_logic(_rect, _cooldown = 60, _lock_bypass = false, _inverted = false) { if (!_lock_bypass && global.ui_click_lock) { return false; @@ -105,12 +134,26 @@ function point_outside_and_click(_rect, _cooldown = 60, _lock_bypass = false) { return _point_and_click_logic(_rect, _cooldown, _lock_bypass, true); } +/// @function point_and_click_sprite +/// @description +/// @param {Real} x1 +/// @param {Real} y1 +/// @param {Asset.GMSprite} sprite +/// @param {Real} x_scale +/// @param {Real} y_scale +/// @returns {Bool} function point_and_click_sprite(x1, y1, sprite, x_scale = 1, y_scale = 1) { var _width = sprite_get_width(sprite) * x_scale; var _height = sprite_get_height(sprite) * y_scale; return point_and_click([x1, y1, x1 + _width, y1 + _height]); } +/// @function mouse_button_clicked +/// @description +/// @param {Constant} button +/// @param {Real} cooldown +/// @param {Bool} lock_bypass +/// @returns {Bool} function mouse_button_clicked(button = mb_left, cooldown = 60, lock_bypass = false) { if (lock_bypass == false && global.ui_click_lock == true) { return false; @@ -165,6 +208,10 @@ function mouse_button_clicked(button = mb_left, cooldown = 60, lock_bypass = fal return mouse_clicked; } +/// @function mouse_button_held +/// @description +/// @param {Constant} _button +/// @returns {Bool} function mouse_button_held(_button = mb_left) { var mouse_held = event_number == ev_gui ? device_mouse_check_button(0, _button) : mouse_check_button(_button); if (!mouse_held) { @@ -200,19 +247,21 @@ function mouse_button_held(_button = mb_left) { return mouse_held; } +/// @function return_mouse_consts +/// @description +/// @returns {Array} function return_mouse_consts() { - var mouse_const_x; - var mouse_const_y; - if (event_number == ev_gui) { - mouse_const_x = device_mouse_x_to_gui(0); - mouse_const_y = device_mouse_y_to_gui(0); - } else { - mouse_const_x = mouse_x; - mouse_const_y = mouse_y; - } + var mouse_const_x = (event_number == ev_gui) ? device_mouse_x_to_gui(0) : mouse_x; + var mouse_const_y = (event_number == ev_gui) ? device_mouse_y_to_gui(0) : mouse_y; return [mouse_const_x, mouse_const_y]; } +/// @function mouse_distance_less +/// @description +/// @param {Real} xx +/// @param {Real} yy +/// @param {Real} distance +/// @returns {Bool} function mouse_distance_less(xx, yy, distance) { var _mouse_consts = return_mouse_consts(); return point_distance(xx, yy, _mouse_consts[0], _mouse_consts[1]) <= distance; diff --git a/scripts/scr_image/scr_image.gml b/scripts/scr_image/scr_image.gml index 80842ab002..31d92be2bd 100644 --- a/scripts/scr_image/scr_image.gml +++ b/scripts/scr_image/scr_image.gml @@ -282,11 +282,8 @@ function scr_image(path, image_id, x1, y1, width, height) { with (obj_img) { // Initialize these images - var i, single_image; - i = -1; - single_image = false; - repeat (80) { - i += 1; + var single_image = false; + for (var i = 0; i < 80; i++) { if ((path == "creation") && (creation_exists[i] > 0) && sprite_exists(creation[i])) { sprite_delete(creation[i]); @@ -507,12 +504,9 @@ function scr_image(path, image_id, x1, y1, width, height) { } if (single_image == false) { - var i, w; - i = 0; - w = 0; + var w = 0; - repeat (40) { - i += 1; + for (var i = 1; i <= 40; i++) { if (path == "main_splash") { if (file_exists(working_directory + "/images/creation/main" + string(i) + ".png")) { main[i - 1] = sprite_add(working_directory + "/images/creation/main" + string(i) + ".png", 1, false, false, 0, 0); @@ -738,16 +732,15 @@ function scr_image(path, image_id, x1, y1, width, height) { if ((path != "") && (image_id >= 0) && (image_id != 666)) { with (obj_img) { // Draw the image - var drawing_sprite, drawing_exists, old_alpha, old_color, x13, y13, x14, y14; - drawing_sprite = 0; - drawing_exists = false; - x13 = 0; - y13 = 0; - x14 = 0; - y14 = 0; + var drawing_sprite = undefined; + var drawing_exists = false; + var x13 = 0; + var y13 = 0; + var x14 = 0; + var y14 = 0; - old_alpha = draw_get_alpha(); - old_color = draw_get_colour(); + var old_alpha = draw_get_alpha(); + var old_color = draw_get_colour(); if (path == "creation") { if ((creation_exists[1] > 0) && sprite_exists(creation[1])) { @@ -930,7 +923,7 @@ function scr_image(path, image_id, x1, y1, width, height) { /// @param {Bool} use_app_data determines whether reading from `datafiles` or `%LocalAppData%\ChapterMaster` folder function scr_image_cache(path, image_id, use_app_data = false) { try { - var drawing_sprite; + var drawing_sprite = undefined; var cache_arr_exists = struct_exists(obj_img.image_cache, path); if (!cache_arr_exists) { variable_struct_set(obj_img.image_cache, path, array_create(100, -1)); @@ -979,6 +972,7 @@ function scr_image_cache(path, image_id, use_app_data = false) { /// @description Simplified handling of chapter icon stuff for both Creation and player chapter icon /// attempting to keep things consistent and easy through save/load and etc +/// @param {String} _name /// @param {Bool} update_global_var set to true when wanting to update the player's icon, false if you just want to return the sprite for further use function scr_load_chapter_icon(_name, update_global_var = false) { if (!ds_map_exists(global.chapter_icons_map, _name)) { diff --git a/scripts/scr_imperial_manage_fleet_functions/scr_imperial_manage_fleet_functions.gml b/scripts/scr_imperial_manage_fleet_functions/scr_imperial_manage_fleet_functions.gml index 44a93f9fa9..474c49b8a8 100644 --- a/scripts/scr_imperial_manage_fleet_functions/scr_imperial_manage_fleet_functions.gml +++ b/scripts/scr_imperial_manage_fleet_functions/scr_imperial_manage_fleet_functions.gml @@ -41,8 +41,8 @@ function new_colony_fleet(doner_star, doner_planet, target, target_planet, missi scr_event_log("green", $"New colony fleet departs from {doner_star.name}. for the {target.name} system", doner_star.name); } -function fleet_has_cargo(desired_cargo, fleet = "none") { - if (fleet == "none") { +function fleet_has_cargo(desired_cargo, fleet = noone) { + if (fleet == noone) { return struct_exists(cargo_data, desired_cargo); } else { var has_cargo = false; @@ -53,8 +53,8 @@ function fleet_has_cargo(desired_cargo, fleet = "none") { } } -function fleet_add_cargo(new_cargo, data, overwrite = false, fleet = "none") { - if (fleet == "none") { +function fleet_add_cargo(new_cargo, data, overwrite = false, fleet = noone) { + if (fleet == noone) { var _add = true; if (fleet_has_cargo(new_cargo) && !overwrite) { _add = false; diff --git a/scripts/scr_imperial_navy_functions/scr_imperial_navy_functions.gml b/scripts/scr_imperial_navy_functions/scr_imperial_navy_functions.gml index 9006474a97..4365e7ec68 100644 --- a/scripts/scr_imperial_navy_functions/scr_imperial_navy_functions.gml +++ b/scripts/scr_imperial_navy_functions/scr_imperial_navy_functions.gml @@ -86,11 +86,9 @@ function navy_orbiting_planet_end_turn_action() { /// @self Asset.GMObject.obj_en_fleet function check_navy_guard_still_live() { - var o = 0; if (guardsmen_unloaded) { - var o = 0, guardsmen_dead = true; - repeat (orbiting.planets) { - o += 1; + var guardsmen_dead = true; + for (var o = 1; o <= orbiting.planets; o++) { if (orbiting.p_guardsmen[o] > 0) { guardsmen_dead = false; break; @@ -141,9 +139,9 @@ function build_new_navy_fleet(construction_forge) { /// @self Asset.GMObject.obj_en_fleet function new_navy_ships_forge() { if (trade_goods == "building_ships") { - var onceh = 0, advance = false, p = 0; + var onceh = 0; + var advance = false; - p = 0; is_orbiting(); for (var p = 1; p <= orbiting.planets; p++) { if (orbiting.p_type[p] == "Forge") { @@ -198,7 +196,6 @@ function new_navy_ships_forge() { trade_goods = ""; } - //if (trade_goods="building_ships" || !advance) then exit; end_sequence_finished = true; } } @@ -306,7 +303,7 @@ function navy_hunt_player_assets() { if (hold) { // Chase player fleets var chase_fleet = get_nearest_player_fleet(x, y, false, true); - if (chase_fleet != "none") { + if (chase_fleet != noone) { var thatp, my_dis; etah = chase_fleet.eta; @@ -420,22 +417,6 @@ function navy_hunt_player_assets() { with (obj_temp8) { instance_destroy(); } - - /*var homeworld_distance,homeworld_nearby,fleet_nearby,fleet_distance; - homeworld_distance=9999;fleet_distance=9999;fleet_nearby=0;homeworld_nearby=0; - - with(obj_p_fleet){if (action!="") then y-=20000;}// Disable non-stationary player fleets - if (instance_exists(obj_p_fleet)){fleet_nearby=instance_nearest(x,y,obj_p_fleet);fleet_distance=point_distance(x,y,fleet_nearby.x,fleet_nearby.y);}// Get closest player fleet - with(obj_star){if (owner = eFACTION.PLAYER) then instance_create(x,y,obj_temp7);}// Create temp7 at player stars - if (instance_exists(obj_temp7)){homeworld_nearby=instance_nearest(x,y,obj_temp7);homeworld_distance=point_distance(x,y,homeworld_nearby.x,homeworld_nearby.y);}// Get closest star - with(obj_p_fleet){if (y<-10000) then y+=20000;}// Enable non-stationary player fleets - - if (homeworld_distance<=fleet_distance && homeworld_distance<7000 && instance_exists(homeworld_nearby)){// Go towards planet - action_x=homeworld_nearby.x;action_y=homeworld_nearby.y;set_fleet_movement();;exit; - } - - - */ } } @@ -471,33 +452,26 @@ function navy_attack_player_world() { if (obj_controller.faction_status[eFACTION.IMPERIUM] == "War" && trade_goods == "invade_player" && guardsmen_unloaded == 0) { if (instance_exists(orbiting)) { var tar = 0; - var i = 0; - for (i = 1; i <= orbiting.planets; i++) { + for (var i = 1; i <= orbiting.planets; i++) { if ((orbiting.p_owner[i] == eFACTION.PLAYER) && (planet_feature_bool(orbiting.p_feature[i], eP_FEATURES.MONASTERY) == 0) && (orbiting.p_guardsmen[i] == 0)) { tar = i; } } if (tar) { guardsmen_unloaded = 1; - i = 0; - repeat (20) { - i += 1; + for (var i = 1; i <= 20; i++) { if (capital_imp[i] > 0) { orbiting.p_guardsmen[tar] += capital_imp[i]; capital_imp[i] = 0; } } - i = 0; - repeat (30) { - i += 1; + for (var i = 1; i <= 30; i++) { if (frigate_imp[i] > 0) { orbiting.p_guardsmen[tar] += frigate_imp[i]; frigate_imp[i] = 0; } } - i = 0; - repeat (30) { - i += 1; + for (var i = 1; i <= 30; i++) { if (escort_imp[i] > 0) { orbiting.p_guardsmen[tar] += escort_imp[i]; escort_imp[i] = 0; @@ -529,7 +503,7 @@ function navy_bombard_player_world() { hostile_fleet_count += present_fleet[eFACTION.PLAYER] + present_fleet[eFACTION.ELDAR] + present_fleet[eFACTION.ORK] + present_fleet[eFACTION.TAU] + present_fleet[eFACTION.TYRANIDS] + present_fleet[eFACTION.CHAOS] + present_fleet[eFACTION.NECRONS]; } if (hostile_fleet_count == 0) { - var bombard = 0, deaths = 0, hurss = 0, onceh = 0, wob = 0, kill = 0; + var deaths = 0, hurss = 0, onceh = 0, wob = 0, kill = 0; for (var o = 1; o <= orbiting.planets; o++) { if (orbiting.p_owner[o] == eFACTION.PLAYER) { @@ -890,7 +864,7 @@ function scr_navy_has_unloaded_guardsmen_turn_end() { /// @self Asset.GMObject.obj_en_fleet function scr_navy_recruit_new_guard() { - var o = 0, that = 0, te = 0, te_large = 0; + var that = 0, te = 0, te_large = 0; for (var o = 1; o <= orbiting.planets; o++) { if (orbiting.p_owner[o] <= 5) { var _imp_enemies = has_imperial_enemies(o, orbiting); @@ -914,7 +888,6 @@ function scr_navy_recruit_new_guard() { var recruit_planet = orbiting.get_planet_data(that); - // if (orbiting.p_population[that] guard_wanted || recruit_planet.large_population) { if (recruit_planet.large_population) { guard_wanted = recruit_planet.population_large_conversion(1000000000); diff --git a/scripts/scr_ini_ship_cleanup/scr_ini_ship_cleanup.gml b/scripts/scr_ini_ship_cleanup/scr_ini_ship_cleanup.gml index b11957a0a6..ae90424800 100644 --- a/scripts/scr_ini_ship_cleanup/scr_ini_ship_cleanup.gml +++ b/scripts/scr_ini_ship_cleanup/scr_ini_ship_cleanup.gml @@ -31,10 +31,11 @@ function scr_kill_ship(index) { var in_warp = ship_location[index] == "Warp"; var _available_ships = []; var _ship_fleet = find_ships_fleet(index); + var _nearest_star = noone; if (!in_warp) { - var _nearest_star = find_star_by_name(ship_location[index]); + _nearest_star = find_star_by_name(ship_location[index]); } - if (_ship_fleet != "none") { + if (_ship_fleet != noone) { delete_ship_from_fleet(index, _ship_fleet); _available_ships = fleet_full_ship_array(_ship_fleet); } @@ -99,9 +100,11 @@ function scr_kill_ship(index) { array_delete(ship_carrying, index, 1); array_delete(ship_contents, index, 1); array_delete(ship_turrets, index, 1); + array_delete(ship_guardsmen, index, 1); + array_delete(ship_guardsmen_max, index, 1); if (!in_warp) { - if (_nearest_star != "none") { + if (_nearest_star != noone) { while (array_length(_units_on_ship) > 0) { _unit = array_pop(_units_on_ship); if (irandom(100) > 100 - _unit.luck) { diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index 34acd5719a..7bee2adb51 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -719,8 +719,6 @@ function trial_map(trial_name) { /// @self Asset.GMObject.obj_ini function scr_initialize_custom() { - // LOGGER.debug("Executing scr_initialize_custom"); - progenitor = obj_creation.founding; successors = obj_creation.successors; homeworld_rule = obj_creation.homeworld_rule; @@ -731,38 +729,14 @@ function scr_initialize_custom() { recruit_relative_loc = obj_creation.buttons.recruit_home_relationship.current_selection; culture_styles = obj_creation.buttons.culture_styles.selections(); - if (struct_exists(obj_creation, "custom_advisors")) { + if (variable_instance_exists(obj_creation, "custom_advisors")) { obj_ini.custom_advisors = obj_creation.custom_advisors; } - // Initializes all of the marine/vehicle/ship variables for the chapter. - - techmarines = 8; - apothecary = 8; - epistolary = 2; - codiciery = 2; - lexicanum = 4; - terminator = 40; - veteran = 70; - second = 100; - third = 100; - fourth = 100; - fifth = 100; - sixth = 100; - seventh = 100; - eighth = 100; - ninth = 100; - tenth = 100; - assault = 20; - devastator = 20; - siege = 0; - recruit_trial = obj_creation.aspirant_trial; purity = obj_creation.purity; stability = obj_creation.stability; - // show_message(instance_number(obj_controller)); - global.chapter_name = obj_creation.chapter_name; global.founding = obj_creation.founding; global.founding_secret = ""; @@ -786,7 +760,7 @@ function scr_initialize_custom() { "", "" ]; - if (struct_exists(obj_creation, "company_title")) { + if (variable_instance_exists(obj_creation, "company_title")) { for (var ct = 0; ct < array_length(obj_creation.company_title); ct++) { company_title[ct] = obj_creation.company_title[ct]; } @@ -832,7 +806,6 @@ function scr_initialize_custom() { for (var i = 0; i < array_length(obj_creation.all_advantages); i++) { var _adv = obj_creation.all_advantages[i]; if (_adv.activated) { - // LOGGER.info($"{_adv}"); array_push(adv, _adv.name); chapter_data.add_trait_data(_adv); } @@ -841,7 +814,6 @@ function scr_initialize_custom() { for (var i = 0; i < array_length(obj_creation.all_disadvantages); i++) { var _disadv = obj_creation.all_disadvantages[i]; if (_disadv.activated) { - // LOGGER.info($"{_disadv}"); array_push(dis, _disadv.name); chapter_data.add_trait_data(_disadv); } @@ -912,7 +884,7 @@ function scr_initialize_custom() { if (scr_has_adv("Boarders")) { strike_cruisers += 2; } - if (struct_exists(obj_creation, "extra_ships")) { + if (variable_instance_exists(obj_creation, "extra_ships")) { battle_barges = battle_barges + obj_creation.extra_ships.battle_barges; strike_cruisers = strike_cruisers + obj_creation.extra_ships.strike_cruisers; gladius = gladius + obj_creation.extra_ships.gladius; @@ -920,13 +892,11 @@ function scr_initialize_custom() { } var ship_summary_str = $"Ships: bb: {battle_barges} sc: {strike_cruisers} g: {gladius} h: {hunters}"; - // LOGGER.info(ship_summary_str); - // LOGGER.debug(ship_summary_str); if (battle_barges >= 1) { - for (v = 0; v < battle_barges; v++) { + for (var i = 0; i < battle_barges; i++) { var new_ship = new_player_ship("Battle Barge", "home"); - if ((flagship_name != "") && (v == 0)) { + if ((flagship_name != "") && (i == 0)) { ship[new_ship] = flagship_name; } } @@ -991,15 +961,42 @@ function scr_initialize_custom() { millenium = 41; #region Determine Total Number of Marines per Company and Role - var company = 0; - var second = 100, third = 100, fourth = 100, fifth = 100, sixth = 100, seventh = 100, eighth = 100, ninth = 100, tenth = 100; - var siege = 0, temp1 = 0, intolerant = 0; - var k, v; - k = 0; - v = 0; + var intolerant = 0; /* Default Specialists */ - var chaplains = 8, chaplains_per_company = 1, techmarines = 8, techmarines_per_company = 1, apothecary = 8, apothecary_per_company = 1, epistolary = 2, epistolary_per_company = 1, codiciery = 2, lexicanum = 4, terminator = 20, veteran = 85, assault = 20, devastator = 20, dreadnought = 1, rhino = 8, whirlwind = 4, landspeeder = 2, predator = 2, landraider = 6; + var chaplains_per_company = 1; + var techmarines_per_company = 1; + var apothecary_per_company = 1; + var epistolary_per_company = 1; + + var rhino = 8; + var whirlwind = 4; + var landspeeder = 2; + var predator = 2; + var landraider = 6; + + var chaplains = 8; + var techmarines = 8; + var apothecary = 8; + var epistolary = 2; + var codiciery = 2; + var lexicanum = 4; + var terminator = 20; + var dreadnought = 1; + var veteran = 85; + var assault = 20; + var devastator = 20; + var siege = 0; + + var second = 100; + var third = 100; + var fourth = 100; + var fifth = 100; + var sixth = 100; + var seventh = 100; + var eighth = 100; + var ninth = 100; + var tenth = 100; /* Used for summing total count */ specials = 0; @@ -1014,11 +1011,6 @@ function scr_initialize_custom() { ninths = 0; tenths = 0; - /*techs=20;epistolary=5;apothecary=6;codiciery=6;lexicanum=10;terminator=30;veteran=30; - second=9;third=9;fourth=9;fifth=9;sixth=9;seventh=9;ei; - ninth=9;tenth=10; - assault=2;siege=0;devastator=2;*/ - var chapter_option, o; if (scr_has_adv("Lightning Warriors")) { rhino -= 2; @@ -1202,9 +1194,9 @@ function scr_initialize_custom() { if (scr_has_disadv("Obliterated")) { bonus_marines = (obj_creation.strength - 1) * 10; } - var i = 0; + var _bm = 0; while (bonus_marines >= 5) { - switch (i % 10) { + switch (_bm % 10) { case 0: if (veteran > 0) { bonus_marines -= 5; @@ -1266,16 +1258,15 @@ function scr_initialize_custom() { } break; } - i++; + _bm++; } - if (struct_exists(obj_creation, "extra_specialists")) { + if (variable_instance_exists(obj_creation, "extra_specialists")) { var c_specialists = obj_creation.extra_specialists; var c_specialist_names = struct_get_names(c_specialists); for (var s = 0; s < array_length(c_specialist_names); s++) { var s_name = c_specialist_names[s]; var s_val = struct_get(c_specialists, s_name); - // LOGGER.debug($"updating specialist {s_name} with {s_val})"); switch (s_name) { case "chaplains": chaplains = chaplains + real(s_val); @@ -1327,7 +1318,7 @@ function scr_initialize_custom() { } } - if (struct_exists(obj_creation, "extra_marines")) { + if (variable_instance_exists(obj_creation, "extra_marines")) { var c_marines = obj_creation.extra_marines; var c_marines_names = struct_get_names(c_marines); for (var s = 0; s < array_length(c_marines_names); s++) { @@ -1426,11 +1417,6 @@ function scr_initialize_custom() { } } - /*main_color=obj_creation.main_color; - secondary_color=obj_creation.secondary_color; - lens_color=obj_creation.lens_color; - weapon_color=obj_creation.weapon_color;*/ - master_name = obj_creation.chapter_master_name; chief_librarian_name = obj_creation.clibrarian; high_chaplain_name = obj_creation.hchaplain; @@ -1506,7 +1492,7 @@ function scr_initialize_custom() { if (scr_has_disadv("Psyker Intolerant")) { race[defaults_slot][eROLE.LIBRARIAN] = 0; } - if (struct_exists(obj_creation, "custom_roles")) { + if (variable_instance_exists(obj_creation, "custom_roles")) { var c_roles = obj_creation.custom_roles; var possible_custom_roles = [ [ @@ -1603,9 +1589,6 @@ function scr_initialize_custom() { var attribute = possible_custom_attributes[a]; if (struct_exists(c_roles[$ c_rolename], attribute)) { var value = c_roles[$ c_rolename][$ attribute]; - // var dbg_m = $"role {c_roleid} {c_rolename} updated {attribute} to {typeof(value)} {value}"; - // LOGGER.info(dbg_m); - // LOGGER.debug(dbg_m); switch (attribute) { case "name": role[defaults_slot][c_roleid] = value; @@ -1626,8 +1609,6 @@ function scr_initialize_custom() { mobi[defaults_slot][c_roleid] = value; break; } - // array_set_value(obj_ini[attribute][100][c_roleid], value); - // [$attribute][100][c_roleid] = value; } } } @@ -1654,7 +1635,6 @@ function scr_initialize_custom() { sergeant: role[defaults_slot][eROLE.SERGEANT], veteran_sergeant: role[defaults_slot][eROLE.VETERANSERGEANT], }; - // LOGGER.info($"roles: {json_stringify(roles, true)}") #endregion @@ -1687,7 +1667,7 @@ function scr_initialize_custom() { _squad_name = "Clave"; } } - if (struct_exists(obj_creation, "squad_name")) { + if (variable_instance_exists(obj_creation, "squad_name")) { _squad_name = obj_creation.squad_name; } @@ -1769,8 +1749,7 @@ function scr_initialize_custom() { ]; var _roles_player = obj_ini.role[100]; var _default_player = obj_ini.role[101]; - var i; - for (i = 1; i < 20; i++) { + for (var i = 1; i < 20; i++) { if (_roles_player[i] == "") { continue; } @@ -1784,25 +1763,21 @@ function scr_initialize_custom() { array_push(_swaps, _set); } - for (i = 1; i < 20; i++) { + for (var i = 1; i < 20; i++) { var _set = {}; var _key = $"wep1[{i}]"; var _val = obj_ini.wep1[100][i]; variable_struct_set(_set, _key, _val); array_push(_swaps, _set); - var _set = {}; + _set = {}; _key = $"wep2[{i}]"; _val = obj_ini.wep2[100][i]; variable_struct_set(_set, _key, _val); - array_push(_swaps, _set); } - // LOGGER.debug($"squads object for chapter {chapter_name}"); - // LOGGER.debug($"{custom_squads}"); - - if (struct_exists(obj_creation, "squad_builder")) { + if (variable_instance_exists(obj_creation, "squad_builder")) { for (var s = 0; s < array_length(obj_creation.squad_builder); s++) { var _custom_build = obj_creation.squad_builder[s]; for (var i = 0; i < array_length(obj_ini.chapter_squad_arrangement.companies); i++) { @@ -1814,7 +1789,7 @@ function scr_initialize_custom() { } } - if (struct_exists(obj_creation, "custom_squads")) { + if (variable_instance_exists(obj_creation, "custom_squads")) { var _customs = obj_creation.custom_squads; with (squad_types) { move_data_to_current_scope(_customs); @@ -1822,8 +1797,6 @@ function scr_initialize_custom() { } json_inject_swaps(squad_types, _swaps); - // LOGGER.debug($"roles object for chapter {chapter_name} after setting from obj"); - // LOGGER.debug($"{custom_squads}"); if (global.chapter_name == "Salamanders") { squad_types.assault_squad.loadout = { @@ -1974,8 +1947,6 @@ function scr_initialize_custom() { array_push(_class_data, "scout"); } */ - // LOGGER.debug("Squad types"); - // LOGGER.debug(squad_types); #endregion for (var i = 0; i <= 20; i++) { @@ -1995,12 +1966,15 @@ function scr_initialize_custom() { } initialized = 500; // How many array variables have been prepared - v = 0; - company = 0; + + var _marine_i = 0; + var _vehicle_i = 0; + var _company_i = 0; // TODO: When modding support is implemented, uncomment this init. Otherwise traits are initialized at compile. //loads up marine traits potential modding potential; // initialize_marine_traits(); + #region Chapter HQ for (var c = 0; c < 11; c++) { for (var i = 0; i < 501; i++) { @@ -2022,15 +1996,15 @@ function scr_initialize_custom() { // Chapter Master // This needs work - name[company][0] = obj_creation.chapter_master_name; + name[_company_i][_marine_i] = obj_creation.chapter_master_name; var cm_equip = load_chapter_master_equipment(); - var chapter_master = add_unit_to_company("chapter_master", 0, 0, roles.chapter_master, eROLE.CHAPTERMASTER, cm_equip.wep1, cm_equip.wep2, cm_equip.gear, cm_equip.mobi, cm_equip.armour); + var chapter_master = add_unit_to_company("chapter_master", _company_i, _marine_i, roles.chapter_master, eROLE.CHAPTERMASTER, cm_equip.wep1, cm_equip.wep2, cm_equip.gear, cm_equip.mobi, cm_equip.armour); repeat (cm_equip.bionics) { chapter_master.add_bionics("none", "standard", false); } - spe[company][0] = ""; + spe[_company_i][_marine_i] = ""; chapter_master.add_trait("lead_example"); //builds in which of the three chapter master types your CM is @@ -2038,11 +2012,11 @@ function scr_initialize_custom() { switch (obj_creation.chapter_master_specialty) { case 1: chapter_master.add_exp(550); - spe[company][0] += "$"; + spe[_company_i][_marine_i] += "$"; break; case 2: chapter_master.add_exp(650); - spe[company][0] += "@"; + spe[_company_i][_marine_i] += "@"; chapter_master.add_trait("champion"); break; case 3: @@ -2063,13 +2037,12 @@ function scr_initialize_custom() { if (scr_has_disadv("Poor Equipment")) { _hq_armour = "MK6 Corvus"; } - - k += 1; + _marine_i += 1; commands = 1; // Forge Master - name[company][1] = obj_creation.fmaster; - var _forge_master = add_unit_to_company("marine", company, 1, "Forge Master", eROLE.TECHMARINE, "Infernus Pistol", "Omnissian Axe", "default", "Servo-harness", _hq_armour); + name[_company_i][_marine_i] = obj_creation.fmaster; + var _forge_master = add_unit_to_company("marine", _company_i, _marine_i, "Forge Master", eROLE.TECHMARINE, "Infernus Pistol", "Omnissian Axe", "default", "Servo-harness", _hq_armour); if (_forge_master.technology < 40) { _forge_master.technology = 40; } @@ -2085,87 +2058,87 @@ function scr_initialize_custom() { _forge_master.add_bionics("none", "standard", false); } } - k += 1; + _marine_i += 1; commands += 1; // Master of Sanctity (Chaplain) if (chaplains > 0) { - name[company][2] = high_chaplain_name; - var _hchap = add_unit_to_company("marine", company, 2, "Master of Sanctity", eROLE.CHAPLAIN, "default", "Plasma Pistol", "default", "default", _hq_armour); + name[_company_i][_marine_i] = high_chaplain_name; + var _hchap = add_unit_to_company("marine", _company_i, _marine_i, "Master of Sanctity", eROLE.CHAPLAIN, "default", "Plasma Pistol", "default", "default", _hq_armour); _hchap.edit_corruption(-100); if (_hchap.piety < 45) { _hchap.piety = 45; } _hchap.add_trait("zealous_faith"); - k += 1; + _marine_i += 1; commands += 1; } // Maser of the Apothecarion (Apothecary) - name[company][3] = obj_creation.hapothecary; - var _hapoth = add_unit_to_company("marine", company, 3, "Master of the Apothecarion", eROLE.APOTHECARY, "default", "Plasma Pistol", "default", "default", _hq_armour); + name[_company_i][_marine_i] = obj_creation.hapothecary; + var _hapoth = add_unit_to_company("marine", _company_i, _marine_i, "Master of the Apothecarion", eROLE.APOTHECARY, "default", "Plasma Pistol", "default", "default", _hq_armour); _hapoth.edit_corruption(0); - k += 1; + _marine_i += 1; commands += 1; // Chief Librarian if (!scr_has_disadv("Psyker Intolerant")) { - name[company][4] = obj_creation.clibrarian; - var _clibrarian = add_unit_to_company("marine", company, 4, string("Chief {0}", roles.librarian), eROLE.LIBRARIAN, "default", "Plasma Pistol", "default", "default", _hq_armour); + name[_company_i][_marine_i] = obj_creation.clibrarian; + var _clibrarian = add_unit_to_company("marine", _company_i, _marine_i, string("Chief {0}", roles.librarian), eROLE.LIBRARIAN, "default", "Plasma Pistol", "default", "default", _hq_armour); _clibrarian.edit_corruption(0); _clibrarian.psionic = choose(11, 12); _clibrarian.update_powers(); _clibrarian.add_trait("favoured_by_the_warp"); - k += 1; + _marine_i += 1; commands += 1; } - man_size = k; + man_size = _marine_i; // Techmarines in the armoury repeat (techmarines) { - k += 1; + _marine_i += 1; commands += 1; man_size += 1; - add_unit_to_company("marine", company, k, roles.techmarine, eROLE.TECHMARINE, "default", choose_weighted(global.weapon_list_weighted_ranged_pistols)); + add_unit_to_company("marine", _company_i, _marine_i, roles.techmarine, eROLE.TECHMARINE, "default", choose_weighted(global.weapon_list_weighted_ranged_pistols)); } // Librarians in the librarium repeat (epistolary) { - k += 1; + _marine_i += 1; commands += 1; man_size += 1; - var _epi = add_unit_to_company("marine", company, k, roles.librarian, eROLE.LIBRARIAN, "default", choose_weighted(global.weapon_list_weighted_ranged_pistols)); + var _epi = add_unit_to_company("marine", _company_i, _marine_i, roles.librarian, eROLE.LIBRARIAN, "default", choose_weighted(global.weapon_list_weighted_ranged_pistols)); } // Codiciery repeat (codiciery) { - k += 1; + _marine_i += 1; commands += 1; man_size += 1; - var _codi = add_unit_to_company("marine", company, k, "Codiciery", eROLE.LIBRARIAN, "default", choose_weighted(global.weapon_list_weighted_ranged_pistols)); + var _codi = add_unit_to_company("marine", _company_i, _marine_i, "Codiciery", eROLE.LIBRARIAN, "default", choose_weighted(global.weapon_list_weighted_ranged_pistols)); } // Lexicanum repeat (lexicanum) { - k += 1; + _marine_i += 1; commands += 1; man_size += 1; - var _lexi = add_unit_to_company("marine", company, k, "Lexicanum", eROLE.LIBRARIAN, "default", choose_weighted(global.weapon_list_weighted_ranged_pistols)); + var _lexi = add_unit_to_company("marine", _company_i, _marine_i, "Lexicanum", eROLE.LIBRARIAN, "default", choose_weighted(global.weapon_list_weighted_ranged_pistols)); } // Apothecaries in Apothecarion repeat (apothecary) { - k += 1; + _marine_i += 1; commands += 1; man_size += 1; - add_unit_to_company("marine", company, k, roles.apothecary, eROLE.APOTHECARY, "Chainsword", choose_weighted(global.weapon_list_weighted_ranged_pistols)); + add_unit_to_company("marine", _company_i, _marine_i, roles.apothecary, eROLE.APOTHECARY, "Chainsword", choose_weighted(global.weapon_list_weighted_ranged_pistols)); } // Chaplains in Reclusium repeat (chaplains) { - k += 1; + _marine_i += 1; commands += 1; man_size += 1; - add_unit_to_company("marine", company, k, roles.chaplain, eROLE.CHAPLAIN, "default", choose_weighted(global.weapon_list_weighted_ranged_pistols)); + add_unit_to_company("marine", _company_i, _marine_i, roles.chaplain, eROLE.CHAPLAIN, "default", choose_weighted(global.weapon_list_weighted_ranged_pistols)); } // Honour Guard @@ -2180,13 +2153,13 @@ function scr_initialize_custom() { _honour_guard_count = 3; } for (var i = 0; i < min(_honour_guard_count, 10); i++) { - k += 1; + _marine_i += 1; commands += 1; man_size += 1; - add_unit_to_company("marine", company, k, roles.honour_guard, eROLE.HONOURGUARD); + add_unit_to_company("marine", _company_i, _marine_i, roles.honour_guard, eROLE.HONOURGUARD); } - specials = k; + specials = _marine_i; #endregion #region New Totals Per Company Adjusted @@ -2282,7 +2255,6 @@ function scr_initialize_custom() { }, }; - // LOGGER.info($"Pre balancing company totals: {json_stringify(companies, true)}"); // Extra vehicles loaded from json files all get dumped into the 10th company for the player to sort out var vehicle_keys = [ @@ -2292,9 +2264,9 @@ function scr_initialize_custom() { "land_raider", "land_speeder" ]; - if (struct_exists(obj_creation, "extra_vehicles")) { - for (var v = 0; v < array_length(vehicle_keys); v++) { - var key = vehicle_keys[v]; + if (variable_instance_exists(obj_creation, "extra_vehicles")) { + for (var i = 0; i < array_length(vehicle_keys); i++) { + var key = vehicle_keys[i]; if (struct_exists(obj_creation.extra_vehicles, key) && real(obj_creation.extra_vehicles[$ key]) > 0) { var coy_key = ""; switch (key) { @@ -2321,8 +2293,8 @@ function scr_initialize_custom() { var squad_distribution = obj_creation.squad_distribution; var scout_company_behaviour = 0; - if (struct_exists(obj_creation, "scout_company_behaviour")) { - var scout_company_behaviour = obj_creation.scout_company_behaviour; + if (variable_instance_exists(obj_creation, "scout_company_behaviour")) { + scout_company_behaviour = obj_creation.scout_company_behaviour; } if (scout_company_behaviour == 1) { load_default_gear(eROLE.SCOUT, "Neophyte", "Bolter", "", "Scout Armour", "", ""); @@ -2348,10 +2320,10 @@ function scr_initialize_custom() { } for (var _c = 0, _clen = array_length(_coys); _c < _clen; _c++) { - var k = 0, v = 0; //k = marine slot, v = vehicle slot - var _name = _coys[_c]; var _coy = companies[$ _name]; + _marine_i = 0; + _vehicle_i = 0; if (_coy.total <= 0) { continue; } @@ -2388,9 +2360,6 @@ function scr_initialize_custom() { /// comp 9: dev 100 /// comp 10: tac 40: scout 50; if (squad_distribution == 1 || squad_distribution == 3) { - // LOGGER.info("balancing for equal specialists") - // LOGGER.info($"equal_scouts? {equal_scouts}") - if (_coy.coy >= 2 && _coy.coy <= 9) { if (equal_scouts) { if (companies.tenth.scouts > 10) { @@ -2414,7 +2383,6 @@ function scr_initialize_custom() { _coy.tacticals = _moved_scouts; } } else { - // LOGGER.info("balancing for non-equal specialists") /// Default specialist behaviour, battle companies 2-7 have 90 tacticals each /// and the assaults go into the 8th and devastators into the 9th if (_coy.coy >= 2 && _coy.coy <= 5) { @@ -2468,21 +2436,17 @@ function scr_initialize_custom() { } } - // LOGGER.info($"New Company Totals: eq specialists: {equal_specialists}: scout coy {scout_company_behaviour} equal_scouts: {equal_scouts}"); - // LOGGER.info($"Company {_coy.coy}: {json_stringify(_coy, true)}"); - var _set_company_makeup = function(old_values, new_values) { var _override_keys = struct_get_names(new_values); var _override_keys_count = array_length(_override_keys); for (var j = 0; j < _override_keys_count; j++) { var _okey_hash = _override_keys[j]; var _okey_ins = new_values[$ _okey_hash]; - // LOGGER.info($"{_okey_hash}<{_okey_ins}<{old_values}"); old_values[$ _okey_hash] = _okey_ins; } return old_values; }; - if (struct_exists(obj_creation, "companies")) { + if (variable_instance_exists(obj_creation, "companies")) { var _company_keys = [ "first", "second", @@ -2505,7 +2469,6 @@ function scr_initialize_custom() { } } } - // LOGGER.info($"attrs {attrs}"); var attrs = struct_get_names(_coy); @@ -2529,7 +2492,6 @@ function scr_initialize_custom() { continue; } - // LOGGER.info($"processing: coy {_coy.coy} role {_role} count {_count}"); switch (_role) { // MAINLINE case "tacticals": @@ -2590,34 +2552,34 @@ function scr_initialize_custom() { case "captains": switch (_coy.coy) { case 1: - name[_coy.coy][k] = honor_captain_name != "" ? honor_captain_name : global.name_generator.ChapterMemberNameGeneration(); + name[_coy.coy][_marine_i] = honor_captain_name != "" ? honor_captain_name : global.name_generator.ChapterMemberNameGeneration(); break; case 2: - name[_coy.coy][k] = watch_master_name != "" ? watch_master_name : global.name_generator.ChapterMemberNameGeneration(); + name[_coy.coy][_marine_i] = watch_master_name != "" ? watch_master_name : global.name_generator.ChapterMemberNameGeneration(); break; case 3: - name[_coy.coy][k] = arsenal_master_name != "" ? arsenal_master_name : global.name_generator.ChapterMemberNameGeneration(); + name[_coy.coy][_marine_i] = arsenal_master_name != "" ? arsenal_master_name : global.name_generator.ChapterMemberNameGeneration(); break; case 4: - name[_coy.coy][k] = lord_admiral_name != "" ? lord_admiral_name : global.name_generator.ChapterMemberNameGeneration(); + name[_coy.coy][_marine_i] = lord_admiral_name != "" ? lord_admiral_name : global.name_generator.ChapterMemberNameGeneration(); break; case 5: - name[_coy.coy][k] = march_master_name != "" ? march_master_name : global.name_generator.ChapterMemberNameGeneration(); + name[_coy.coy][_marine_i] = march_master_name != "" ? march_master_name : global.name_generator.ChapterMemberNameGeneration(); break; case 6: - name[_coy.coy][k] = rites_master_name != "" ? rites_master_name : global.name_generator.ChapterMemberNameGeneration(); + name[_coy.coy][_marine_i] = rites_master_name != "" ? rites_master_name : global.name_generator.ChapterMemberNameGeneration(); break; case 7: - name[_coy.coy][k] = chief_victualler_name != "" ? chief_victualler_name : global.name_generator.ChapterMemberNameGeneration(); + name[_coy.coy][_marine_i] = chief_victualler_name != "" ? chief_victualler_name : global.name_generator.ChapterMemberNameGeneration(); break; case 8: - name[_coy.coy][k] = lord_executioner_name != "" ? lord_executioner_name : global.name_generator.ChapterMemberNameGeneration(); + name[_coy.coy][_marine_i] = lord_executioner_name != "" ? lord_executioner_name : global.name_generator.ChapterMemberNameGeneration(); break; case 9: - name[_coy.coy][k] = relic_master_name != "" ? relic_master_name : global.name_generator.ChapterMemberNameGeneration(); + name[_coy.coy][_marine_i] = relic_master_name != "" ? relic_master_name : global.name_generator.ChapterMemberNameGeneration(); break; case 10: - name[_coy.coy][k] = recruiter_name != "" ? recruiter_name : global.name_generator.ChapterMemberNameGeneration(); + name[_coy.coy][_marine_i] = recruiter_name != "" ? recruiter_name : global.name_generator.ChapterMemberNameGeneration(); break; } commands++; @@ -2768,7 +2730,6 @@ function scr_initialize_custom() { _is_vehicle = true; _rolename = "Predator"; _erole = eROLE.PREDATOR; - var variant = choose(1, 1, 2, 3); // 1st company relic predators if (_coy.coy == 1) { _upgrade = "Artificer Hull"; @@ -2819,48 +2780,52 @@ function scr_initialize_custom() { } repeat (_count) { if (_is_vehicle) { - add_veh_to_company(_rolename, _coy.coy, v, _wep1, _wep2, _wep3, _upgrade, _accessory); - v++; - man_size += 10; + if (_vehicle_i < 205) { + add_veh_to_company(_rolename, _coy.coy, _vehicle_i, _wep1, _wep2, _wep3, _upgrade, _accessory); + man_size += 10; + _vehicle_i++; + } } else { - add_unit_to_company(_unit_type, _coy.coy, k, _rolename, _erole, _wep1, _wep2, _gear, _mobi, _armour); - k++; - man_size++; - if (_is_terminator(_armour)) { + if (_marine_i < 500) { + add_unit_to_company(_unit_type, _coy.coy, _marine_i, _rolename, _erole, _wep1, _wep2, _gear, _mobi, _armour); + _marine_i++; man_size++; + if (_is_terminator(_armour)) { + man_size++; + } } } } switch (_coy.coy) { case 1: - firsts = k; + firsts = _marine_i; break; case 2: - seconds = k; + seconds = _marine_i; break; case 3: - thirds = k; + thirds = _marine_i; break; case 4: - fourths = k; + fourths = _marine_i; break; case 5: - fifths = k; + fifths = _marine_i; break; case 6: - sixths = k; + sixths = _marine_i; break; case 7: - sevenths = k; + sevenths = _marine_i; break; case 8: - eighths = k; + eighths = _marine_i; break; case 9: - ninths = k; + ninths = _marine_i; break; case 10: - tenths = k; + tenths = _marine_i; break; } } @@ -2868,20 +2833,16 @@ function scr_initialize_custom() { #endregion - var c; - c = 0; - k = 0; - company = 0; - repeat (200) { - c += 1; - if (k == 0) { - if ((role[0][c] != "") && (role[0][c + 1] == "")) { - k = c; - } - } - } - - // obj_controller.marines-=commands; + //? Seems to be dead code; prove me wrong + // _marine_i = 0; + // company = 0; + // for (var c = 0; c <= 200; c++) { + // if (_marine_i == 0) { + // if ((role[0][c] != "") && (role[0][c + 1] == "")) { + // _marine_i = c; + // } + // } + // } scr_add_item("Bolter", 20); scr_add_item("Chainsword", 20); @@ -2901,7 +2862,7 @@ function scr_initialize_custom() { scr_add_item("Bike", 40); - if (struct_exists(obj_creation, "extra_equipment")) { + if (variable_instance_exists(obj_creation, "extra_equipment")) { for (var e = 0; e < array_length(obj_creation.extra_equipment); e++) { var e_name = obj_creation.extra_equipment[e][0]; var e_qty = obj_creation.extra_equipment[e][1]; @@ -2945,8 +2906,6 @@ function scr_initialize_custom() { scr_add_item("Close Combat Weapon", 4); } - // man_size+=80;// bikes - if (scr_has_adv("Crafters") && scr_has_adv("Melee Enthusiasts")) { scr_add_item("MK3 Iron Armour", irandom_range(2, 12)); } @@ -2958,8 +2917,7 @@ function scr_initialize_custom() { //Fixed Loot tagble if (scr_has_adv("Ancient Armoury")) { //armour - var armm5 = ""; - armm5 = choose("Tartaros", "Cataphractii"); + var armm5 = choose("Tartaros", "Cataphractii"); scr_add_item("MK3 Iron Armour", irandom_range(2, 5)); scr_add_item("MK4 Maximus", irandom_range(5, 10)); scr_add_item("MK5 Heresy", irandom_range(5, 10)); @@ -2994,9 +2952,7 @@ function scr_initialize_custom() { gene_slaves = []; - var bloo = 0, o = 0; if (scr_has_disadv("Blood Debt")) { - bloo = 1; if (instance_exists(obj_controller)) { obj_controller.blood_debt = 1; penitent = 1; @@ -3014,7 +2970,6 @@ function scr_initialize_custom() { if (obj_creation.chapter_name == "Lamenters") { penitent_max = 600; penitent_end = 600; - // obj_controller.loyalty=50;obj_controller.loyalty_hidden=50; } } } @@ -3024,10 +2979,16 @@ function scr_initialize_custom() { game_start_squads(); } -/// @description helper function to streamline code inside of scr_initialize_custom, should only be used as part of -/// game setup and not during normal gameplay +/// @description helper function to streamline code inside of scr_initialize_custom, should only be used as part of game setup and not during normal gameplay +/// @param {String} name +/// @param {Real} company +/// @param {Real} slot +/// @param {String} wep1 +/// @param {String} wep2 +/// @param {String} wep3 +/// @param {String} upgrade +/// @param {String} accessory function add_veh_to_company(name, company, slot, wep1, wep2, wep3, upgrade, accessory) { - // LOGGER.info($"adding vehicle name {name} company {company} slot {slot} ") obj_ini.veh_race[company][slot] = 1; obj_ini.veh_loc[company][slot] = obj_ini.home_name; obj_ini.veh_role[company][slot] = name; @@ -3048,7 +3009,6 @@ function add_veh_to_company(name, company, slot, wep1, wep2, wep3, upgrade, acce /// Use "" if you want to set weapons and gear via squad layouts. /// "default" will set it to the value in the default slot for the given role, see `load_default_gear` function add_unit_to_company(ttrpg_name, company, slot, role_name, role_id, wep1 = "default", wep2 = "default", gear = "default", mobi = "default", armour = "default") { - // LOGGER.info($"adding unit to company ttrpg_name {ttrpg_name}, company {company}, slot {slot}, role_name {role_name}, role_id {role_id}") obj_ini.TTRPG[company][slot] = new TTRPG_stats("chapter", company, slot, ttrpg_name); var spawn_unit = fetch_unit([company, slot]); obj_ini.race[company][slot] = 1; @@ -3079,8 +3039,6 @@ function add_unit_to_company(ttrpg_name, company, slot, role_name, role_id, wep1 } else { spawn_unit.update_armour(armour, false, false); } - - // LOGGER.debug($"updating coy {company}:{slot} {role_name} armour to {armour}: {_msg} : {spawn_unit.armour()} : {obj_ini.armour[company][slot]}"); } if (gear != "") { if (gear == "default") { @@ -3153,7 +3111,6 @@ function load_chapter_master_equipment() { break; case 3: chapter_master_equip.wep1 = "Relic Blade"; - //wep1[0,1]="Relic Blade&MNR|"; break; case 4: chapter_master_equip.wep1 = "Thunder Hammer"; @@ -3208,7 +3165,7 @@ function load_chapter_master_equipment() { var arti; // From json - if (struct_exists(obj_creation, "artifact")) { + if (variable_instance_exists(obj_creation, "artifact")) { if (is_struct(obj_creation.artifact) && struct_exists(obj_creation.artifact, "name")) { arti = obj_ini.artifact_struct[last_artifact]; arti.name = obj_creation.artifact.name; @@ -3253,7 +3210,7 @@ function load_chapter_master_equipment() { } } - if (struct_exists(obj_creation, "chapter_master")) { + if (variable_instance_exists(obj_creation, "chapter_master")) { if (struct_exists(obj_creation.chapter_master, "gear") && obj_creation.chapter_master.gear != "") { chapter_master_equip.gear = obj_creation.chapter_master.gear; } diff --git a/scripts/scr_inquisition_fleet_functions/scr_inquisition_fleet_functions.gml b/scripts/scr_inquisition_fleet_functions/scr_inquisition_fleet_functions.gml index a64980367f..bb65ba7f97 100644 --- a/scripts/scr_inquisition_fleet_functions/scr_inquisition_fleet_functions.gml +++ b/scripts/scr_inquisition_fleet_functions/scr_inquisition_fleet_functions.gml @@ -21,7 +21,7 @@ function radical_inquisitor_mission_ship_arrival() { //TODO make a centralised player_fleet present method var _p_fleet = instance_nearest(x, y, obj_p_fleet); var _intercept_fleet = -1; - if (point_distance(x, y, _p_fleet.x, _p_fleet.y) < 10 && is_orbiting(obj_p_fleet)) { + if (point_distance(x, y, _p_fleet.x, _p_fleet.y) < 10 && is_orbiting(_p_fleet)) { _intercept_fleet = _p_fleet; } @@ -53,7 +53,6 @@ function radical_inquisitor_mission_ship_arrival() { _radical_inquisitor.inquisitor_ship = self.id; scr_popup("Inquisitor Located", _tixt, "inquisition", _radical_inquisitor); } - //instance_destroy(); exit; } @@ -66,7 +65,7 @@ function inquisition_fleet_inspection_chase() { if (reset) { // Reaquire target var target_player_fleet = get_largest_player_fleet(); - if (target_player_fleet != "none") { + if (target_player_fleet != noone) { if (target_player_fleet.action == "") { set_fleet_target(target_player_fleet.x, target_player_fleet.y, target_player_fleet); } else { @@ -86,8 +85,6 @@ function inquisition_fleet_inspection_chase() { scr_loyalty("Avoiding Inspections", "+"); } - // if (string_count("!",trade_goods)>=3) then demand stop fleet - //Inquisitor is pissed as hell if (string_count("!", trade_goods) == 5) { obj_controller.alarm[8] = 10; @@ -140,10 +137,9 @@ function inquisition_fleet_inspection_chase() { // Sets up an inquisitor ship to do an inspection on the HomeWorld function new_inquisitor_inspection() { - var target_system = "none"; - var new_inquis_fleet; + var target_system = noone; if (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD) { - var monestary_system = "none"; + var monestary_system = noone; // If player does not own their homeworld than do a fleet inspection instead var player_stars = []; with (obj_star) { @@ -154,21 +150,20 @@ function new_inquisitor_inspection() { monestary_system = self; } } - if (monestary_system != "none") { + if (monestary_system != noone) { target_system = monestary_system; } else if (array_length(player_stars) > 0) { target_system = player_stars[0]; } - if (target_system != "none") { + if (target_system != noone) { var target_star = target_system; - var tar, new_inquis_fleet; var xx = target_star.x; var yy = target_star.y; //get the second or third closest planet to launch inquisitor from var from_star = distance_removed_star(target_star.x, target_star.y); - new_inquis_fleet = instance_create(from_star.x, from_star.y, obj_en_fleet); + var new_inquis_fleet = instance_create(from_star.x, from_star.y, obj_en_fleet); with (new_inquis_fleet) { base_inquis_fleet(); @@ -187,11 +182,11 @@ function new_inquisitor_inspection() { // otherwise, do a fleet inspection. var target_player_fleet = get_largest_player_fleet(); - if (target_player_fleet != "none") { + if (target_player_fleet != noone) { //get the second or third closest planet to launch inquisitor from var from_star = distance_removed_star(target_player_fleet.x, target_player_fleet.y); - new_inquis_fleet = instance_create(from_star.x, from_star.y, obj_en_fleet); + var new_inquis_fleet = instance_create(from_star.x, from_star.y, obj_en_fleet); var obj; with (new_inquis_fleet) { base_inquis_fleet(); @@ -222,7 +217,7 @@ function inquisitor_ship_approaches() { var do_alert = false; if (string_count("fleet", trade_goods) > 0 && scr_valid_fleet_target(target)) { var player_fleet_location = fleets_next_location(target); - if (player_fleet_location != "none") { + if (player_fleet_location != noone) { if (approach_system.name == player_fleet_location.name) { inquis_string = $"Our navigators report that an inquisitor's ship is currently warping towards our flagship. It is likely that the inquisitor on board (provided he/she makes it) will attempt to perform an inspection of our flagship."; do_alert = true; @@ -240,7 +235,7 @@ function inquisitor_ship_approaches() { } } if (do_alert) { - var approach_system = instance_nearest(action_x, action_y, obj_star).name; + approach_system = instance_nearest(action_x, action_y, obj_star).name; if (inquisitor == 0) { scr_alert("green", "duhuhuhu", $"Inquisitor Ship approaches {approach_system}.", x, y); } else { @@ -260,8 +255,6 @@ function inquisitor_inspect_base() { chapter_asset_discovery = roll_dice_chapter(2, 100, "high"); } - // 137 ; chapter_asset_discovery=floor(random(20))+1; - var cur_planet = 0; if (chapter_asset_discovery <= 5) { repeat (planets) { @@ -297,7 +290,7 @@ function inquisitor_inspect_base() { var _current_planet_name = name; var launch_planet, launch_point_found = false; launch_planet = nearest_star_with_ownership(x, y, [eFACTION.IMPERIUM, eFACTION.MECHANICUS], self.id); - if (launch_planet != "none") { + if (launch_planet != noone) { if (instance_exists(launch_planet)) { flee = instance_create(launch_planet.x, launch_planet.y, obj_en_fleet); with (flee) { diff --git a/scripts/scr_inquisition_inspection/scr_inquisition_inspection.gml b/scripts/scr_inquisition_inspection/scr_inquisition_inspection.gml index 47348cbc1b..06f69c5baa 100644 --- a/scripts/scr_inquisition_inspection/scr_inquisition_inspection.gml +++ b/scripts/scr_inquisition_inspection/scr_inquisition_inspection.gml @@ -21,11 +21,12 @@ function check_for_next_inquisitor_inspection() { } if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD) { + var _player_fleet = instance_nearest(x, y, obj_p_fleet); var _player_fleets = instance_number(obj_p_fleet); if (_player_fleets == 1) { //can't inspect if fleet not in room //can't innspect if on other non negotiable action e.g crusading - _inspec = in_room(obj_p_fleet) && !fleet_engaged(obj_p_fleet); + _inspec = in_room(_player_fleet) && !fleet_engaged(_player_fleet); } else if (_player_fleets == 0) { _inspec = false; } diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index a890181ed0..29c0737d4a 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -17,7 +17,7 @@ /// @param {Enum.eEVENT} event /// @param {Enum.eINQUISITION_MISSION} forced_mission optional -function scr_inquisition_mission(event, forced_mission = -1) { +function scr_inquisition_mission(event, forced_mission = eINQUISITION_MISSION.RANDOM) { LOGGER.info($"RE: Inquisition Mission, event {event}, forced_mission {forced_mission}"); if ((obj_controller.known[eFACTION.INQUISITION] == 0 || obj_controller.faction_status[eFACTION.INQUISITION] == "War") && !global.cheat_debug) { LOGGER.info("Player is either hasn't met or is at war with Inquisition, not proceeding with inquisition mission"); @@ -52,7 +52,7 @@ function scr_inquisition_mission(event, forced_mission = -1) { found_sleeping_necrons = true; } - if (star_has_planet_with_forces(_star, "Demons", 1)) { + if (star_has_planet_with_forces(_star, eFACTION.HERETICS, 1)) { // array_push(demon_worlds, _star); // turning this off til i have a way to finish the mission } @@ -81,26 +81,9 @@ function scr_inquisition_mission(event, forced_mission = -1) { LOGGER.info($"Couldn't find any planets with demons for inquisition mission"); } - //if (string_count("Tau",obj_controller.useful_info)=0){ - // var found_tau = false; - // with(obj_star){ - // if (found_tau){ - // break; - // } - // for(var i = 1; i <= planets; i++) - // { - // if (p_tau[i]>4) { - // array_push(inquisition_missions, eINQUISITION_MISSION.ETHEREAL); - // found_tau = true - // break; - // } - // } - // } - //} - - var chosen_mission = choose_array(inquisition_missions); - if (forced_mission != -1) { - chosen_mission = forced_mission; + var chosen_mission = forced_mission; + if (chosen_mission == eINQUISITION_MISSION.RANDOM) { + chosen_mission = choose_array(inquisition_missions); } switch (chosen_mission) { case eINQUISITION_MISSION.PURGE: @@ -188,7 +171,7 @@ function mission_inquisition_tyranid_organism(worlds) { } var eta = scr_mission_eta(_star.x, _star.y, 1); - var eta = min(max(eta, 6), 50); + eta = min(max(eta, 6), 50); var text = $"An Inquisitor is trusting you with a special mission. The planet {string(_star.name)} {scr_roman(planet)}"; text += " is ripe with Tyranid organisms. They require that you capture one of the Gaunt species for research purposes. Can your chapter handle this mission?"; @@ -197,8 +180,9 @@ function mission_inquisition_tyranid_organism(worlds) { function mission_inquisition_tomb_world(tomb_worlds) { LOGGER.info("RE: Necron Tomb Bombing"); + var _star = noone; if (is_array(tomb_worlds)) { - var _star = array_random_element(tomb_worlds); + _star = array_random_element(tomb_worlds); } else { _star = tomb_worlds; } @@ -242,7 +226,7 @@ function mission_inquisition_tomb_world(tomb_worlds) { /// @self Asset.GMObject.obj_popup function init_mission_inquisition_tomb_world() { mission_star = find_star_by_name(pop_data.system); - if (mission_star == "none") { + if (mission_star == noone) { popup_default_close(); exit; } @@ -274,23 +258,13 @@ function mission_inquisition_artifact() { scr_popup("Inquisition Mission", text, "inquisition", $"artifact|bop|0|{string(irandom_range(6, 26))}|"); } -function mission_inquistion_hunt_inquisitor(star_id = -1) { +function mission_inquistion_hunt_inquisitor(star_id = noone) { LOGGER.info("RE: Inquisitor Hunt"); var stars = scr_get_stars(); - /*var _valid_stars = array_filter_ext(stars, - function(_star,index){ - var _p_fleet = instance_nearest(_star.x,_star.y,obj_p_fleet); - if (instance_exists(_p_fleet)){ - var _distance = point_distance(_star.x,_star.y,_p_fleet.x,_p_fleet.y); - if (100 <= _distance & _distance <= 300){ - return true; - } - } - return false; - });*/ + var _star = noone; - if (star_id == -1) { + if (star_id == noone) { var _valid_stars = stars; if (array_length(_valid_stars) == 0) { @@ -298,7 +272,7 @@ function mission_inquistion_hunt_inquisitor(star_id = -1) { exit; } - var _star = array_random_element(_valid_stars); + _star = array_random_element(_valid_stars); } else { _star = star_id; } @@ -351,7 +325,7 @@ function add_new_inquis_mission() { /// @self Asset.GMObject.obj_popup function init_mission_hunt_inquisitor() { mission_star = find_star_by_name(pop_data.system); - if (mission_star == "none") { + if (mission_star == noone) { popup_default_close(); exit; } diff --git a/scripts/scr_json_functions/scr_json_functions.gml b/scripts/scr_json_functions/scr_json_functions.gml index 071c386187..0bb663d798 100644 --- a/scripts/scr_json_functions/scr_json_functions.gml +++ b/scripts/scr_json_functions/scr_json_functions.gml @@ -6,9 +6,6 @@ function json_to_gamemaker(_json_path, _func) { var file_buffer = undefined; try { if (file_exists(_json_path)) { - var _json_string = ""; - var _parsed_json = {}; - file_buffer = buffer_load(_json_path); if (file_buffer == -1) { diff --git a/scripts/scr_khornate_fleet_functions/scr_khornate_fleet_functions.gml b/scripts/scr_khornate_fleet_functions/scr_khornate_fleet_functions.gml index de1c39b8d9..127d2b3c07 100644 --- a/scripts/scr_khornate_fleet_functions/scr_khornate_fleet_functions.gml +++ b/scripts/scr_khornate_fleet_functions/scr_khornate_fleet_functions.gml @@ -1,5 +1,3 @@ -// Script assets have changed for v2.3.0 see -// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information function khorne_fleet_cargo() { //This handles khorne fleets killing planet popultions moving planet and then choosing a new target ot chase warband = cargo_data.warband; @@ -7,39 +5,37 @@ function khorne_fleet_cargo() { if (_is_orbiting && (action == "")) { _orb = orbiting; if (_orb.present_fleet[1] + _orb.present_fleet[2] + _orb.present_fleet[3] + _orb.present_fleet[6] + _orb.present_fleet[7] + _orb.present_fleet[9] + _orb.present_fleet[13] == 0) { - var ii = 0, good = 0, part = 0, find_new_planet = false; + var good = 0; + var find_new_planet = false; // No forces already landed var _fleet = self; with (_orb) { - repeat (planets) { - ii += 1; - if (planet_feature_bool(p_feature[ii], eP_FEATURES.CHAOSWARBAND) == 1) { + for (var i = 1; i <= planets; i++) { + if (planet_feature_bool(p_feature[i], eP_FEATURES.CHAOSWARBAND) == 1) { good -= 1; - if (planet_imperium_ground_total(ii) <= 0) { - if (p_population[ii] > p_max_population[ii] / 20) { - p_population[ii] = round(p_population[ii] / 2); - if (p_population[ii] <= p_max_population[ii] / 20) { + if (planet_imperium_ground_total(i) <= 0) { + if (p_population[i] > p_max_population[i] / 20) { + p_population[i] = round(p_population[i] / 2); + if (p_population[i] <= p_max_population[i] / 20) { find_new_planet = true; } } - } else if (p_population[ii] <= p_max_population[ii] / 20) { + } else if (p_population[i] <= p_max_population[i] / 20) { find_new_planet = true; } } } // Next planet; rembark the chaos forces if (find_new_planet == true) { - ii = 0; find_new_planet = false; - repeat (planets) { - ii += 1; - if (planet_feature_bool(p_feature[ii], eP_FEATURES.CHAOSWARBAND) == 1) { - p_chaos[ii] = 0; - p_traitors[ii] = max(4, p_traitors[ii] + 1); - delete_features(p_feature[ii], eP_FEATURES.CHAOSWARBAND); + for (var i = 1; i <= planets; i++) { + if (planet_feature_bool(p_feature[i], eP_FEATURES.CHAOSWARBAND) == 1) { + p_chaos[i] = 0; + p_traitors[i] = max(4, p_traitors[i] + 1); + delete_features(p_feature[i], eP_FEATURES.CHAOSWARBAND); find_new_planet = true; } } @@ -48,24 +44,22 @@ function khorne_fleet_cargo() { // No forces landed if ((good == 0) || (find_new_planet == true)) { - ii = 0; var landing_planet = 0; with (_orb) { - repeat (planets) { - ii += 1; + for (var i = 1; i <= planets; i++) { if (landing_planet == 0) { - if ((planet_imperium_ground_total(ii) > 0) && (p_population[ii] > p_max_population[ii] / 20)) { - array_push(p_feature[ii], new NewPlanetFeature(eP_FEATURES.CHAOSWARBAND)); - landing_planet = ii; - p_chaos[ii] = 6; + if ((planet_imperium_ground_total(i) > 0) && (p_population[i] > p_max_population[i] / 20)) { + array_push(p_feature[i], new NewPlanetFeature(eP_FEATURES.CHAOSWARBAND)); + landing_planet = i; + p_chaos[i] = 6; break; } // Forces landed } if (landing_planet == 0) { - if ((p_player[ii] > 0) && (p_population[ii] > p_max_population[ii] / 20)) { - landing_planet = ii; - p_chaos[ii] = 6; - array_push(p_feature[ii], new NewPlanetFeature(eP_FEATURES.CHAOSWARBAND)); + if ((p_player[i] > 0) && (p_population[i] > p_max_population[i] / 20)) { + landing_planet = i; + p_chaos[i] = 6; + array_push(p_feature[i], new NewPlanetFeature(eP_FEATURES.CHAOSWARBAND)); break; } // Forces landed } @@ -74,7 +68,6 @@ function khorne_fleet_cargo() { if ((landing_planet == 0) && (trade_goods != "khorne_warband_landing_force")) { // Nothing to see here, continue to next star*/ - ii = 0; with (_orb) { instance_deactivate_object(id); @@ -109,21 +102,18 @@ function khorne_fleet_cargo() { } } - var nx, ny, n2, yy2, ndir, next_star; - next_star = 0; - ndir = point_direction(x, y, home_x, home_y); - nx = x + lengthdir_x(250, ndir); - ny = y + lengthdir_y(250, ndir); - n2 = x + lengthdir_x(450, ndir); - yy2 = y + lengthdir_y(450, ndir); + var ndir = point_direction(x, y, home_x, home_y); + var nx = x + lengthdir_x(250, ndir); + var ny = y + lengthdir_y(250, ndir); + var n2 = x + lengthdir_x(450, ndir); + var yy2 = y + lengthdir_y(450, ndir); if (!point_in_rectangle(n2, yy2, 50, 50, room_width, room_height)) { trade_goods = "khorne_warband_landing_force"; - // show_message("khorne_warband_landing_force"); } if (trade_goods != "khorne_warband_landing_force") { - next_star = instance_nearest(nx, ny, obj_star); + var next_star = instance_nearest(nx, ny, obj_star); action_x = next_star.x; action_y = next_star.y; action = ""; @@ -151,7 +141,7 @@ function khorne_fleet_cargo() { if (player_stars > 0) { var pee1 = instance_nearest(x, y, obj_star); instance_activate_object(obj_star); - next_star = distance_removed_star(pee1.x, pee1.y, choose(1, 1, 2)); + var next_star = distance_removed_star(pee1.x, pee1.y, choose(1, 1, 2)); action_x = next_star.x; action_y = next_star.y; action = ""; @@ -167,7 +157,7 @@ function khorne_fleet_cargo() { } var chase_fleet = get_nearest_player_fleet(nearest_x, nearest_y); - if ((chase_fleet != "none") && (action == "")) { + if ((chase_fleet != noone) && (action == "")) { var intercept_time = fleet_intercept_time_calculate(chase_fleet); if (chase_fleet.action != "") { if (intercept_time <= chase_fleet.eta) { @@ -195,7 +185,7 @@ function khorne_fleet_cargo() { if (player_stars > 0) { var nearest_star = instance_nearest(x, y, obj_star); instance_activate_object(obj_star); - if (chase_fleet == "none") { + if (chase_fleet == noone) { action_x = nearest_star.x; action_y = nearest_star.y; set_fleet_movement(); @@ -238,12 +228,12 @@ function spawn_chaos_warlord() { scr_audience(eFACTION.CHAOS, "intro", 0, "", 0, 2); fdir = terra_direction + choose(-90, 90); fdir += floor(random_range(-35, 35)); - var len, width, height, t, c, s; - width = room_width; - height = room_height; - t = degtorad(fdir); - c = abs(cos(t)); - s = abs(sin(t)); + var len = 0; + var width = room_width; + var height = room_height; + var t = degtorad(fdir); + var c = abs(cos(t)); + var s = abs(sin(t)); if (c * height > s * width) { len = (width / 2) / c; } else { @@ -264,13 +254,11 @@ function spawn_chaos_warlord() { frigate_number = 20; escort_number = 40; } - var rep, filtered_array, candidate_systems; - candidate_systems = []; + var candidate_systems = []; with (obj_star) { - rep = 0; ya = false; //should probably get turned into its own helper if used multiple times - filtered_array = array_filter(p_owner, function(val, idx) { + var filtered_array = array_filter(p_owner, function(val, idx) { return scr_is_planet_owned_by_allies(self, idx); }); if (array_length(filtered_array)) { diff --git a/scripts/scr_livery_setup/scr_livery_setup.gml b/scripts/scr_livery_setup/scr_livery_setup.gml index a9e650855d..fdc1b33c5b 100644 --- a/scripts/scr_livery_setup/scr_livery_setup.gml +++ b/scripts/scr_livery_setup/scr_livery_setup.gml @@ -198,11 +198,6 @@ function scr_livery_setup() { _cultures.x1 = right_data_slate.XX + 30; _cultures.y1 = right_data_slate.YY + 80; _cultures.max_width = right_data_slate.width - 120; - _cultures.on_change = function() { - var _picker = obj_creation.livery_picker; - _picker.shuffle_dummy(); - _picker.reset_image(); - }; _cultures.draw(); }; diff --git a/scripts/scr_load/scr_load.gml b/scripts/scr_load/scr_load.gml index 3e629e0566..06b5d12aa4 100644 --- a/scripts/scr_load/scr_load.gml +++ b/scripts/scr_load/scr_load.gml @@ -1,6 +1,7 @@ function scr_load(save_part, save_id) { var t1 = get_timer(); var filename = string(PATH_SAVE_FILES, save_id); + var json_game_save = {}; if (save_id == 0) { filename = string(PATH_AUTOSAVE_FILE); LOGGER.info("Loading from Autosave"); @@ -9,7 +10,7 @@ function scr_load(save_part, save_id) { var _gamesave_buffer = buffer_load(filename); var _gamesave_string = buffer_read(_gamesave_buffer, buffer_string); buffer_delete(_gamesave_buffer); - var json_game_save = json_parse(_gamesave_string); + json_game_save = json_parse(_gamesave_string); } if (!struct_exists(obj_saveload.GameSave, "Save")) { @@ -63,7 +64,7 @@ function scr_load(save_part, save_id) { "point_breakdown", "apothecary_points", "forge_points", - "chapter_master_data" + "chapter_master_data", ]; // skip automatic setting of certain vars, handle explicitly later // Automatic var setting @@ -75,9 +76,8 @@ function scr_load(save_part, save_id) { continue; } var loaded_value = struct_get(save_data, var_name); - // LOGGER.debug($"obj_controller var: {var_name} - val: {loaded_value}"); try { - variable_struct_set(obj_controller, var_name, loaded_value); + variable_instance_set(obj_controller, var_name, loaded_value); } catch (e) { LOGGER.debug(e); } @@ -144,12 +144,36 @@ function scr_load(save_part, save_id) { obj_event_log.event = obj_saveload.GameSave.EventLog; LOGGER.info("EVENT LOG Loaded"); + // Sanitize NaN coordinates baked into older saves. A fleet whose x/y went NaN + // (from the pre-fix action_eta divide-by-zero) keeps re-baking that NaN into + // obj_controller through the fleet-focus copy, which then crashes the collision + // grid when obj_cursor is recreated on a room change. Snap any broken instance + // back to a valid star so the bad value can never reach the controller again. + var _anchor = instance_nearest(0, 0, obj_star); + var _ax = instance_exists(_anchor) ? _anchor.x : 0; + var _ay = instance_exists(_anchor) ? _anchor.y : 0; + with (obj_p_fleet) { + if (is_nan(x) || is_nan(y)) { + x = _ax; + y = _ay; + } + } + with (obj_en_fleet) { + if (is_nan(x) || is_nan(y)) { + x = _ax; + y = _ay; + } + } + if (is_nan(obj_controller.x) || is_nan(obj_controller.y)) { + obj_controller.x = _ax; + obj_controller.y = _ay; + } + obj_saveload.alarm[1] = 5; obj_controller.invis = false; global.load = -1; scr_image("force", -50, 0, 0, 0, 0); LOGGER.info("Loading completed"); - // room_goto(rm_game); } var t2 = get_timer(); diff --git a/scripts/scr_load_all/scr_load_all.gml b/scripts/scr_load_all/scr_load_all.gml index 85f0fed57d..124c41efb9 100644 --- a/scripts/scr_load_all/scr_load_all.gml +++ b/scripts/scr_load_all/scr_load_all.gml @@ -4,6 +4,21 @@ function scr_load_all(select_units) { // Load / Select All if (select_units) { man_size = 0; + // If no location is anchored yet, anchor it to the first selectable unit so a + // straight Select All works even when nothing was individually clicked first + // (e.g. a body of guardsmen mustered on a planet). The vehicle branch below + // already self-anchors; this gives the man branch the same behaviour. + if (selecting_location == "") { + for (var j = 0; j < array_length(display_unit); j++) { + var anchor_unit = display_unit[j]; + if (is_struct(anchor_unit) && (man[j] == "man") && (ma_god[j] < 10) && (anchor_unit.assignment() == "none")) { + selecting_location = ma_loc[j]; + selecting_planet = ma_wid[j]; + selecting_ship = ma_lid[j]; + break; + } + } + } // This sets the maximum size of marines in a company to 200 size for (var i = 0; i < array_length(display_unit); i++) { unit = display_unit[i]; diff --git a/scripts/scr_manage_tags/scr_manage_tags.gml b/scripts/scr_manage_tags/scr_manage_tags.gml index 1bf7b7082b..f177064a2f 100644 --- a/scripts/scr_manage_tags/scr_manage_tags.gml +++ b/scripts/scr_manage_tags/scr_manage_tags.gml @@ -93,7 +93,7 @@ function draw_tag_manager() { } tag_selects = new MultiSelect(_selecs, "Tags", {max_width: 500, x1: 1040, y1: 210}); } - var _tool = "Remove Tags from current Marine selection"; + _tool = "Remove Tags from current Marine selection"; remove_tag_button.disabled = false; if (!_addable) { _tool = "Make some tags to Remove them from marines"; @@ -127,7 +127,6 @@ function draw_tag_manager() { } } tag_selects = new MultiSelect(_selecs, "Tags", {max_width: 500, x1: 1040, y1: 210}); - //new_tag = ""; } } diff --git a/scripts/scr_management/scr_management.gml b/scripts/scr_management/scr_management.gml index 816210c85b..d416d61509 100644 --- a/scripts/scr_management/scr_management.gml +++ b/scripts/scr_management/scr_management.gml @@ -3,11 +3,7 @@ function scr_management(argument0) { // Creates the company blocks in the main management screen and assigns text to them // Variable creation - var num = 0, nam = "", company = 50, q = 0; - var romanNumerals = scr_roman_numerals(); var chapter_name = global.chapter_name; - var role_names = obj_ini.role[100]; - var unit; if (argument0 == 1) { with (obj_managment_panel) { @@ -25,7 +21,7 @@ function scr_management(argument0) { var _reclusium_units = _command_company.get_from({group: [SPECIALISTS_CHAPLAINS, true, true]}, true, true); - var _reclusium_units = _reclusium_units.index_roles(); + _reclusium_units = _reclusium_units.index_roles(); pane.line = array_join(pane.line, _reclusium_units.create_plural_strings_array()); @@ -37,7 +33,7 @@ function scr_management(argument0) { var _apothecary_units = _command_company.get_from({group: [SPECIALISTS_APOTHECARIES, true, true]}, true, true); - var _apothecary_units = _apothecary_units.index_roles(); + _apothecary_units = _apothecary_units.index_roles(); pane.line = array_join(pane.line, _apothecary_units.create_plural_strings_array()); @@ -48,7 +44,7 @@ function scr_management(argument0) { pane.title = "ARMOURY"; var _armoury_units = _command_company.get_from({group: [SPECIALISTS_TECHS, true, true]}, true, true); - var _armoury_units = _armoury_units.index_roles(); + _armoury_units = _armoury_units.index_roles(); pane.line = array_join(pane.line, _armoury_units.create_plural_strings_array()); @@ -61,10 +57,22 @@ function scr_management(argument0) { var _lib_units = _command_company.get_from({group: [SPECIALISTS_LIBRARIANS, true, true]}, true, true); - var _lib_units = _lib_units.index_roles(); + _lib_units = _lib_units.index_roles(); pane.line = array_join(pane.line, _lib_units.create_plural_strings_array()); + pane = instance_create(1325, 180 - 48, obj_managment_panel); + pane.company = 0; + pane.manage = 16; + pane.header = 2; + pane.title = "AUXILIA"; + + var _auxilia_units = collect_role_group("all", "", false, {roles: auxilia_roles()}, true); + + var _auxilia_units = _auxilia_units.index_roles(); + + pane.line = array_join(pane.line, _auxilia_units.create_plural_strings_array()); + pane = instance_create(700, 180 - 48, obj_managment_panel); pane.company = 0; pane.manage = 11; @@ -76,13 +84,14 @@ function scr_management(argument0) { pane.line = array_join(pane.line, _command_units.create_plural_strings_array()); // Coordinates declaration and text initiation - var xx = 25, yy = 400 - 48, t; + var xx = 25; + var yy = 352; // Creates the first 10 companies using roman numerals for (var company = 1; company <= 10; company++) { - t = string_upper(scr_convert_company_to_string(company)); + var t = string_upper(scr_convert_company_to_string(company)); - var pane = instance_create(xx, yy, obj_managment_panel); + pane = instance_create(xx, yy, obj_managment_panel); pane.company = company; pane.manage = company; pane.header = 1; @@ -113,7 +122,6 @@ function scr_management(argument0) { if (num[d] > 0) { if (d == 1) { array_push(pane.line, {str1: nam[d], bold: true, italic: false}); - // obj_managment_panel.italic[q] = 1; } else { array_push(pane.line, nam[d], string_plural_count(nam[d], num[d], false)); } diff --git a/scripts/scr_map_and_warp_functions/scr_map_and_warp_functions.gml b/scripts/scr_map_and_warp_functions/scr_map_and_warp_functions.gml index d4a663ce78..0e74b9c8b5 100644 --- a/scripts/scr_map_and_warp_functions/scr_map_and_warp_functions.gml +++ b/scripts/scr_map_and_warp_functions/scr_map_and_warp_functions.gml @@ -1,10 +1,3 @@ -// Script assets have changed for v2.3.0 see -// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information -// function set_warp_point_data(){ -// warp_point_hover = true; -// } -// Main menu movement - function in_camera_view(rect) { var x1 = camera_get_view_x(view_camera[0]); var y1 = camera_get_view_y(view_camera[0]); @@ -66,25 +59,21 @@ function draw_warp_lanes() { routes = []; var star_degrade_list = []; var total_stars = instance_number(obj_star); - var cur_star, this_star, connection, i, check_star; - for (i = 0; i < total_stars; i++) { + for (var i = 0; i < total_stars; i++) { array_push(star_degrade_list, i); } - for (i = 0; i < total_stars; i++) { - cur_star = instance_find(obj_star, star_degrade_list[i]); + for (var i = 0; i < total_stars; i++) { + var cur_star = instance_find(obj_star, star_degrade_list[i]); var this_star = cur_star.id; var in_view = true; - //var in_view = in_camera_view(star_box_shape(this_star)); - //if (!in_view) then in_view = zoomed; if (array_length(cur_star.warp_lanes) > 0) { for (var s = 0; s < total_stars; s++) { if (s == i) { continue; } - check_star = instance_find(obj_star, star_degrade_list[s]); - //if (!in_view && !in_camera_view(star_box_shape(check_star))) then continue; - connection = determine_warp_join(check_star.id, this_star); + var check_star = instance_find(obj_star, star_degrade_list[s]); + var connection = determine_warp_join(check_star.id, this_star); if (connection) { array_push(routes, [[check_star.x, check_star.y, this_star.x, this_star.y], connection]); } @@ -101,8 +90,6 @@ function draw_warp_lanes() { if (warp_image == 58) { warp_image = 0; } - // if (!warp_point_hover) then hover_time=0; - // warp_point_hover = false; for (var i = 0; i < array_length(routes); i++) { draw_set_color(c_gray); route = routes[i]; @@ -114,20 +101,15 @@ function draw_warp_lanes() { } else if (route[1] == 4) { draw_set_color(c_yellow); //TODO abstract code as a ratio distance function - //static debug_c = 0; var direction_x = route_coords[2] - route_coords[0]; var direction_y = route_coords[3] - route_coords[1]; var forward = direction_x >= 0 ? 1 : -1; var downward = direction_y >= 0 ? 1 : -1; - //var grade = direction_x/direction_y; var total_dist = 80; var pythag_dist = sqr(total_dist); var sum = (direction_x * forward) + (direction_y * downward); var x_ratio = direction_x * forward / sum; var y_ratio = direction_y * downward / sum; - /*if (debug_c<100){ - LOGGER.debug($"{x_ratio},{forward},{y_ratio},{downward}"); - }*/ var dist_x = sqrt(pythag_dist * x_ratio) * forward; var dist_y = sqrt(pythag_dist * y_ratio) * downward; @@ -167,20 +149,12 @@ function draw_warp_lanes() { if (!star_overlap) { var to = instance_nearest(route_coords[2], route_coords[3], obj_star); - // warp_point_hover = true; if (_allow_tooltips) { tooltip_draw(string(warp_route_tooltip, to.name)); } - /* if (array_equals(hover_loc,[route_coords[0] ,route_coords[1]])){ - hover_time++; - } else { - hover_loc = [route_coords[0] ,route_coords[1]]; - hover_time = 0; - }*/ - - if (mouse_check_button_pressed(mb_left) && keyboard_check(vk_shift) /* || (instance_exists(obj_fleet_select) && hover_time>=30) */) { + if (mouse_check_button_pressed(mb_left) && keyboard_check(vk_shift)) { set_map_pan_to_loc(to); } } @@ -207,25 +181,16 @@ function draw_warp_lanes() { } if (!star_overlap) { var to = instance_nearest(route_coords[0], route_coords[1], obj_star); - // warp_point_hover = true; if (_allow_tooltips) { tooltip_draw(string(warp_route_tooltip, to.name)); } - // if (array_equals(hover_loc,[route_coords[2] ,route_coords[3]])){ - // hover_time++; - // } else { - // hover_loc = [route_coords[2] ,route_coords[3]]; - // hover_time = 0; - // } - - if (mouse_check_button_pressed(mb_left) && keyboard_check(vk_shift) /* || (instance_exists(obj_fleet_select) && hover_time>=30) */) { + if (mouse_check_button_pressed(mb_left) && keyboard_check(vk_shift)) { set_map_pan_to_loc(to); } } } - //debug_c++; } } } @@ -302,9 +267,9 @@ function create_complex_star_routes(player_star) { continue; } if (player_hub_overide) { - for (var i = 0; i < array_length(set); i++) { - if (set[i] == player_star) { - WarpHub = set[i]; + for (var j = 0; j < array_length(set); j++) { + if (set[j] == player_star) { + WarpHub = set[j]; break; } } @@ -321,10 +286,6 @@ function create_complex_star_routes(player_star) { if (s == i || set_count == 0) { continue; } - /*//if (irandom(1)) then continue; - for (var i=0;i 0) { sz += 5; } else if (array_contains(global.list_terminator_armour, arm)) { sz += 1; } - //var mobi = mobility_item(); - /*if (mobi == "Jump Pack"){ - sz++; - }*/ if (unit_role == obj_ini.role[100][eROLE.CHAPTERMASTER]) { sz++; } @@ -396,6 +379,12 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} max_h += gear_weapon_data("weapon", weapon_one(), "hp_mod"); max_h += gear_weapon_data("weapon", weapon_two(), "hp_mod"); } + if (role() == "Guard Squad") { + max_h *= GUARD_SQUAD_SIZE; // a squad shares one pooled health bar and dies as a whole + } + if (role() == "Heavy Weapons Team") { + max_h *= GUARD_HEAVY_WEAPONS_TEAM_SIZE; // a 3-man weapons team shares one pooled health bar + } return max_h; }; @@ -452,12 +441,14 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} //adds a trait to a marines trait list static add_trait = function(trait, return_stat_diff = false, return_description = false) { + var _start_stats = {}; + var _return_string = ""; if (return_stat_diff) { - var _start_stats = get_stat_line(); + _start_stats = get_stat_line(); } if (struct_exists(global.trait_list, trait)) { if (!array_contains(traits, trait)) { - var _return_string = ""; + var _stat_diff = {}; var selec_trait = global.trait_list[$ trait]; stat_boosts(selec_trait); array_push(traits, trait); @@ -465,7 +456,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} if (return_stat_diff) { var _end_stats = get_stat_line(); - var _stat_diff = compare_stats(_end_stats, _start_stats); + _stat_diff = compare_stats(_end_stats, _start_stats); } if (return_description) { @@ -475,12 +466,10 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} if (return_stat_diff) { _return_string += $", {print_stat_diffs(_stat_diff)}"; } - - return _return_string; } } - return ""; + return _return_string; }; static has_trait = marine_has_trait; @@ -529,7 +518,6 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} if (array_contains(variable_struct_get_names(global.base_stats), class)) { load_json_data(global.base_stats[$ class]); } - var edit_stat, stat_mod; var stats = [ "constitution", "strength", @@ -546,8 +534,8 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} for (var stat_iter = 0; stat_iter < array_length(stats); stat_iter++) { if (struct_exists(self, stats[stat_iter])) { if (is_array(variable_struct_get(self, stats[stat_iter]))) { - edit_stat = variable_struct_get(self, stats[stat_iter]); - stat_mod = floor(gauss(edit_stat[0], edit_stat[1])); + var edit_stat = variable_struct_get(self, stats[stat_iter]); + var stat_mod = floor(gauss(edit_stat[0], edit_stat[1])); if (array_length(edit_stat) > 2) { if (edit_stat[2] == "max") { variable_struct_set(self, stats[stat_iter], max(stat_mod, edit_stat[0])); @@ -636,21 +624,6 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} so as an example salamanders could have the chapter values as */ loyalty = 0; - static alter_loyalty = function(alt_val) { - if (alt_val < 0) { - if (has_trait("honorable")) { - alt_val /= 2; - } - if (has_trait("jaded")) { - alt_val *= 2; - } - } - if (has_trait("old_guard")) { - alt_val /= 2; - } - loyalty = clamp(loyalty + alt_val, 0, 100); - }; - switch (base_group) { case "astartes": //basic marine class //adds specific mechanics not releveant to most units loyalty = 100; @@ -681,13 +654,6 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} allegiance = global.chapter_name; } - assign_inherent_mutations(); - assign_random_mutations(); - - if (gene_seed_mutations[$ "voice"] == 1) { - charisma -= 2; - } - static assign_inherent_mutations = function() { gene_seed_mutations = { "preomnor": obj_ini.preomnor, @@ -737,9 +703,12 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} } }; - //array index 0 == trait to add - // array index 1 == probability e.g 99,98 == if (irandom(99)>98){add_trait} - // array index 3 == probability modifiers + assign_inherent_mutations(); + assign_random_mutations(); + + if (gene_seed_mutations[$ "voice"] == 1) { + charisma -= 2; + } if ((global.chapter_name == "Space Wolves") || (obj_ini.progenitor == ePROGENITOR.SPACE_WOLVES)) { religion_sub_cult = "The Allfather"; @@ -798,6 +767,21 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} return obj_ini.race[company][marine_number]; }; + static alter_loyalty = function(alt_val) { + if (alt_val < 0) { + if (has_trait("honorable")) { + alt_val /= 2; + } + if (has_trait("jaded")) { + alt_val *= 2; + } + } + if (has_trait("old_guard")) { + alt_val /= 2; + } + loyalty = clamp(loyalty + alt_val, 0, 100); + }; + static update_loyalty = function(change_value) { loyalty = clamp(loyalty + change_value, 0, 100); }; @@ -819,9 +803,9 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} return false; }; - /// @param {string} area - /// @param {string} bionic_quality - /// @param {bool} from_armoury + /// @param {string} _area + /// @param {string} _quality + /// @param {bool} _from_armoury static add_bionics = function(_area = "none", _quality = "any", _from_armoury = true) { if (bionics >= 10) { return false; @@ -954,7 +938,6 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} is_boarder = false; gear_quality = "standard"; - static update_gear = scr_update_unit_gear; if (base_group != "none") { update_health(max_health()); //set marine unit_health to max @@ -1781,6 +1764,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} //quick way of getting name and role combined in string static name_role = function(include_epithet = true, include_role = true) { var _name = name(); + var _epithet = ""; if (include_role) { var _temp_role = squad_role(); @@ -1788,7 +1772,6 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} } if (include_epithet) { - var _epithet = ""; if (array_length(epithets)) { _epithet += $"{epithets[0].title}"; } @@ -1813,7 +1796,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} return $"{scr_roman_numerals()[company - 1]}"; }; - static load_marine = function(ship, star = "none") { + static load_marine = function(ship, star = noone) { get_unit_size(); // make sure marines size given it's current equipment is correct var current_location = marine_location(); var system = current_location[2]; @@ -1837,10 +1820,10 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} ship_location = ship; //id of ship marine is now loaded on obj_ini.ship_carrying[ship] += size; //update ship capacity - if (star == "none") { + if (star == noone) { star = find_star_by_name(system); } - if (star != "none") { + if (star != noone) { if (star.p_player[current_location[1]] > 0) { star.p_player[current_location[1]] -= size; } @@ -1893,17 +1876,33 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} }; static allocate_unit_to_fresh_spawn = function(type = "default") { - var homestar = "none"; + var homestar = noone; var spawn_location_chosen = false; - if (((type == "home") || (type == "default")) && (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD)) { + if (type == "home_planet") { + // Place on the chapter's actual owned planet in the home system and keep the unit + // off-ship, so bulk spawns are not scattered across the fleet's ships. Scan for a + // player-owned planet rather than trusting obj_ini.home_planet, which can be a + // stale index pointing at a planet that does not exist in this system. + ship_location = -1; + location_string = obj_ini.home_name; + planet_location = obj_ini.home_planet; var homestar = find_star_by_name(obj_ini.home_name); + if (homestar != "none") { + for (var i = 1; i <= homestar.planets; i++) { + if (homestar.p_owner[i] == eFACTION.PLAYER) { + planet_location = i; + break; + } + } + } + return; + } + if (((type == "home") || (type == "default")) && (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD)) { + homestar = find_star_by_name(obj_ini.home_name); } else if (type != "ship") { - var homestar = find_star_by_name(type); + homestar = find_star_by_name(type); } - /* if (!spawn_location_chosen){ - - }*/ - if (homestar != "none") { + if (homestar != noone) { for (var i = 1; i <= homestar.planets; i++) { if (homestar.p_owner[i] == eFACTION.PLAYER || (obj_controller.faction_status[eFACTION.IMPERIUM] != "War" && array_contains(obj_controller.imperial_factions, homestar.p_owner[i]))) { planet_location = i; @@ -1914,14 +1913,14 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} } if (!spawn_location_chosen) { var player_fleet = get_largest_player_fleet(); - if (player_fleet != "none") { + if (player_fleet != noone) { get_unit_size(); load_unit_to_fleet(player_fleet, self); spawn_location_chosen = true; } //TODO add more work arounds in case of no valid spawn point if (!spawn_location_chosen) { - if (player_fleet != "none") {} + if (player_fleet != noone) {} } } }; @@ -1977,11 +1976,10 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} static roll_age = scr_marine_spawn_age; static roll_experience = function() { - var _exp = 0; var _age_bonus = age(); var _gauss_sd_mod = 14; - _exp = _age_bonus; + var _exp = _age_bonus; _exp = max(0, floor(gauss(_exp, _exp / _gauss_sd_mod))); add_exp(_exp); }; @@ -2298,7 +2296,11 @@ function jsonify_marine_struct(company, marine, stringify = true) { /// @param {Array} unit where unit[0] is company and unit[1] is the position /// @returns {Struct.TTRPG_stats} unit function fetch_unit(unit) { - return obj_ini.TTRPG[unit[0]][unit[1]]; + try { + return obj_ini.TTRPG[unit[0]][unit[1]]; + } catch (_exception) { + ERROR_HANDLER.assert_popup(_exception); + } } function fetch_unit_uid(uuid) { diff --git a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml index 951c15494a..2e2056b4f1 100644 --- a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml +++ b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml @@ -104,7 +104,7 @@ function mechanicus_missions_end_turn(planet) { var _marines = collect_role_group("all", [name, planet, -1]); if (array_length(_marines) >= 20) { remove_planet_problem(planet, "mech_tomb1"); - add_new_problem(planet, "mech_tomb2", 999, star == "none", other_data == {turns: 0}); + add_new_problem(planet, "mech_tomb2", 999, noone, {turns: 0}); scr_popup("Mechanicus Research", "The Mechanicus Research team on planet " + string(name) + " " + scr_roman(planet) + " has taken note of your Astartes and are now prepared to begin their research. Your marines are to stay on the planet until further notice.", "necron_cave", ""); } else {} } @@ -182,13 +182,13 @@ function spawn_mechanicus_mission(chosen_mission = "random") { } var star = array_random_element(_forge_stars); - + var text = ""; var _mission_data = { star: star.id, }; var _name = star.name; if (chosen_mission == "mech_raider") { - var text = $"The Adeptus Mechanicus are trusting you with a special mission. They wish for you to bring a Land Raider and six {obj_ini.role[100][16]} to a Forge World in {_name} for testing and training, for a duration of 24 months. You have four years to complete this. Can your chapter handle this mission?"; + text = $"The Adeptus Mechanicus are trusting you with a special mission. They wish for you to bring a Land Raider and six {obj_ini.role[100][16]} to a Forge World in {_name} for testing and training, for a duration of 24 months. You have four years to complete this. Can your chapter handle this mission?"; _mission_data.options = [ { str1: "Accept", @@ -201,7 +201,7 @@ function spawn_mechanicus_mission(chosen_mission = "random") { ]; _evented = true; } else if (chosen_mission == "mech_bionics") { - var text = $"The Adeptus Mechanicus are trusting you with a special mission. They desire a squad of Astartes with bionics to stay upon a Forge World in {_name} for testing, for a duration of 24 months. You have four years to complete this. Can your chapter handle this mission?"; + text = $"The Adeptus Mechanicus are trusting you with a special mission. They desire a squad of Astartes with bionics to stay upon a Forge World in {_name} for testing, for a duration of 24 months. You have four years to complete this. Can your chapter handle this mission?"; _mission_data.options = [ { str1: "Accept", @@ -214,7 +214,7 @@ function spawn_mechanicus_mission(chosen_mission = "random") { ]; _evented = true; } else { - var text = $"The local Adeptus Mechanicus are preparing to embark on a voyage to Mars, to delve into the catacombs in search of lost technology. Due to your close relations they have made the offer to take some of your {obj_ini.role[100][16]}s with them for both their unique abilities to function as both scientific helpers and as helpers (high Weapon Skill and Technology is reccomended). Can your chapter handle this mission?"; + text = $"The local Adeptus Mechanicus are preparing to embark on a voyage to Mars, to delve into the catacombs in search of lost technology. Due to your close relations they have made the offer to take some of your {obj_ini.role[100][16]}s with them for both their unique abilities to function as both scientific helpers and as helpers (high Weapon Skill and Technology is reccomended). Can your chapter handle this mission?"; _mission_data.options = [ { str1: "Accept", @@ -249,7 +249,7 @@ function spawn_mechanicus_mission(chosen_mission = "random") { exit; } var star = array_random_element(valid_stars); - _mission_data = { + var _mission_data = { star: star.id, pathway_id: chosen_mission, }; diff --git a/scripts/scr_mission_eta/scr_mission_eta.gml b/scripts/scr_mission_eta/scr_mission_eta.gml index 41fe6c7f3b..3ea001f119 100644 --- a/scripts/scr_mission_eta/scr_mission_eta.gml +++ b/scripts/scr_mission_eta/scr_mission_eta.gml @@ -15,7 +15,7 @@ function scr_mission_eta(star_x, star_y, type = 1, leeway = 10) { if (instance_exists(obj_p_fleet)) { if (type == 1) { var nearest_fleet = get_nearest_player_fleet(star_x, star_y); - if (nearest_fleet != "none") { + if (nearest_fleet != noone) { eta1 = get_viable_travel_time(leeway, nearest_fleet.x, nearest_fleet.y, star_x, star_y, nearest_fleet, false); } // n1=instance_nearest(x,y,obj_p_fleet); diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index 84a494ae52..1f98b0e5ca 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -568,10 +568,10 @@ function complete_garrison_mission(problem_index) { if (_result == "none") { //TODO make a dedicated plus minus string function if there isn't one already } else if (_result < 0) { - var _effect = _result * irandom_range(1, 5); + _effect = _result * irandom_range(1, 5); _mission_string += $"A number of diplomatic incidents occured over the period which had considerable negative effects on our disposition with the planetary governor (disposition -{_effect})"; } else { - var _effect = _result * irandom_range(1, 5); + _effect = _result * irandom_range(1, 5); _mission_string += $"As a diplomatic mission the duration of the stay was a success with our political position with the planet being enhanced greatly (disposition +{_effect})"; } @@ -777,8 +777,8 @@ function complete_beast_hunt_mission(targ_planet, problem_index) { //TODO allow most of these functions to be condensed and allow arrays of problems or planets and maybe increase filtering options //filtering options could be done via universal methods that all the filters to be passed to many other game systems /// @self Asset.GMObject.obj_star -function has_any_problem_planet(planet, star = "none") { - if (star == "none") { +function has_any_problem_planet(planet, star = noone) { + if (star == noone) { for (var i = 0; i < array_length(p_problem[planet]); i++) { if (p_problem[planet][i] != "") { return true; @@ -793,9 +793,9 @@ function has_any_problem_planet(planet, star = "none") { } /// @self Asset.GMObject.obj_star -function planet_problemless(planet, star = "none") { +function planet_problemless(planet, star = noone) { var _problemless = true; - if (star == "none") { + if (star == noone) { for (var i = 0; i < array_length(p_problem[planet]); i++) { if (p_problem[planet][i] != "") { _problemless = false; @@ -818,9 +818,9 @@ function star_problemless(){ // returns a bool for if any planet on a given star has the given problem /// @self Asset.GMObject.obj_star -function has_problem_star(problem, star = "none") { +function has_problem_star(problem, star = noone) { var has_problem = false; - if (star == "none") { + if (star == noone) { for (var i = 1; i <= planets; i++) { has_problem = has_problem_planet(i, problem); if (has_problem) { @@ -838,8 +838,8 @@ function has_problem_star(problem, star = "none") { //returns a bool for if a planet has a given problem /// @self Asset.GMObject.obj_star -function has_problem_planet(planet, problem, star = "none") { - if (star == "none") { +function has_problem_planet(planet, problem, star = noone) { + if (star == noone) { return array_contains(p_problem[planet], problem); } else { with (star) { @@ -850,9 +850,9 @@ function has_problem_planet(planet, problem, star = "none") { //returns the array position of a given problem on a given planet if the specfied time is given /// @self Asset.GMObject.obj_star -function has_problem_planet_and_time(planet, problem, time, star = "none") { +function has_problem_planet_and_time(planet, problem, time, star = noone) { var _had_problem = -1; - if (star == "none") { + if (star == noone) { for (var i = 0; i < array_length(p_problem[planet]); i++) { if (p_problem[planet][i] == problem) { if (p_timer[planet][i] == time) { @@ -870,9 +870,9 @@ function has_problem_planet_and_time(planet, problem, time, star = "none") { //returns the array position of a given problem on a given planet if the specfied time is above 0 /// @self Asset.GMObject.obj_star -function has_problem_planet_with_time(planet, problem, star = "none") { +function has_problem_planet_with_time(planet, problem, star = noone) { var _had_problem = -1; - if (star == "none") { + if (star == noone) { for (var i = 0; i < array_length(p_problem[planet]); i++) { if (p_problem[planet][i] == problem) { if (p_timer[planet][i] > 0) { @@ -890,8 +890,8 @@ function has_problem_planet_with_time(planet, problem, star = "none") { //returns the array position of a gien problem on a given planet /// @self Asset.GMObject.obj_star -function find_problem_planet(planet, problem, star = "none") { - if (star == "none") { +function find_problem_planet(planet, problem, star = noone) { + if (star == noone) { for (var i = 0; i < array_length(p_problem[planet]); i++) { if (p_problem[planet][i] == problem) { return i; @@ -907,9 +907,9 @@ function find_problem_planet(planet, problem, star = "none") { ///removie all of a given problem from a planet /// @self Asset.GMObject.obj_star -function remove_planet_problem(planet, problem, star = "none") { +function remove_planet_problem(planet, problem, star = noone) { var _had_problem = -1; - if (star == "none") { + if (star == noone) { for (var i = 0; i < array_length(p_problem[planet]); i++) { if (p_problem[planet][i] == problem) { p_problem[planet][i] = ""; @@ -928,8 +928,8 @@ function remove_planet_problem(planet, problem, star = "none") { //find an open problem slot on a given planet /// @self Asset.GMObject.obj_star -function open_problem_slot(planet, star = "none") { - if (star == "none") { +function open_problem_slot(planet, star = noone) { + if (star == noone) { for (var i = 0; i < array_length(p_problem[planet]); i++) { if (p_problem[planet][i] == "") { return i; @@ -945,8 +945,8 @@ function open_problem_slot(planet, star = "none") { //remove all of a given problem types from a star /// @self Asset.GMObject.obj_star -function remove_star_problem(problem, star = "none") { - if (star == "none") { +function remove_star_problem(problem, star = noone) { + if (star == noone) { for (var i = 1; i <= planets; i++) { remove_planet_problem(i, problem); } @@ -973,9 +973,9 @@ function problem_count_down(planet, count_change = 1) { //add a new problem /// @self Asset.GMObject.obj_star -function add_new_problem(planet, problem, timer, star = "none", other_data = {}) { +function add_new_problem(planet, problem, timer, star = noone, other_data = {}) { var problem_added = false; - if (star == "none") { + if (star == noone) { for (var i = 0; i < array_length(p_problem[planet]); i++) { if (p_problem[planet][i] == "") { p_problem[planet][i] = problem; @@ -987,7 +987,7 @@ function add_new_problem(planet, problem, timer, star = "none", other_data = {}) } } else { with (star) { - problem_added = add_new_problem(planet, problem, timer, "none", other_data); + problem_added = add_new_problem(planet, problem, timer, noone, other_data); } } return problem_added; @@ -1009,9 +1009,9 @@ function increment_mission_completion(mission_data) { //search problem data for a given and key and iff applicable value on that key //TODO increase filtering and search options /// @self Asset.GMObject.obj_star -function problem_has_key_and_value(planet, problem, key, value = "", star = "none") { +function problem_has_key_and_value(planet, problem, key, value = "", star = noone) { var has_data = false; - if (star == "none") { + if (star == noone) { var problem_data = p_problem_other_data[planet][problem]; if (struct_exists(problem_data, key)) { if (value == "") { diff --git a/scripts/scr_mission_reward/scr_mission_reward.gml b/scripts/scr_mission_reward/scr_mission_reward.gml index 88db7585bf..be982d132e 100644 --- a/scripts/scr_mission_reward/scr_mission_reward.gml +++ b/scripts/scr_mission_reward/scr_mission_reward.gml @@ -6,13 +6,7 @@ function scr_mission_reward(mission, star, planet) { // "mech_bionics",id,i // "mech_raider",id,i - var cleanup, i; - cleanup = 0; - i = -1; - repeat (11) { - i += 1; - cleanup[i] = 0; - } + var cleanup = array_create(11, 0); if (mission == "mars_spelunk") { var roll1 = roll_dice_chapter(1, 100, "high"); // For the first STC @@ -100,20 +94,14 @@ function scr_mission_reward(mission, star, planet) { if (_tech_point_gain) { tixt += $"\n{_tech_point_gain} {string_plural("Tech Point", _tech_point_gain)} gained"; } - // scr_alert("green","mission",tixt,star.x,star.y,); scr_event_log("green", tixt); - /*if (found_artifact=1) then scr_event_log("","Artifact recovered from Mars Catacombs."); - if (found_artifact>1) then scr_event_log("",string(found_artifact)+" Artifacts recovered from Mars Catacombs."); - if (found_stc=1) then scr_event_log("","STC Fragment recovered from Mars Catacombs."); - if (found_stc>1) then scr_event_log("",string(found_artifact)+" STC Fragments recovered from Mars Catacombs.");*/ sort_all_companies_to_map(cleanup); } if (mission == "mech_raider") { - var roll1, result; - roll1 = roll_dice_chapter(1, 100, "low"); - result = ""; + var roll1 = roll_dice_chapter(1, 100, "low"); + var result = ""; if (roll1 <= 33) { result = "New"; @@ -129,16 +117,10 @@ function scr_mission_reward(mission, star, planet) { scr_popup("Mechanicus Mission Completed", $"Your {obj_ini.role[100][16]} have worked with the Adeptus Mechanicus in a satisfactory manor. The testing and training went well, but your Land Raider was ultimately lost. 300 Requisition has been given to your Chapter and relations are better than before.", "mechanicus", ""); obj_controller.requisition += 300; obj_controller.disposition[3] += 2; - var com, i, onceh; - onceh = 0; - com = -1; - i = 0; - repeat (11) { + var onceh = 0; + for (var com = 0; com <= 10; com++) { if (onceh == 0) { - com += 1; - i = 0; - repeat (100) { - i += 1; + for (var i = 1; i <= 100; i++) { if ((obj_ini.veh_role[com][i] == "Land Raider") && (obj_ini.veh_loc[com][i] == star.name) && (obj_ini.veh_wid[com][i] == planet)) { onceh = 1; obj_ini.veh_race[com][i] = 0; @@ -158,27 +140,25 @@ function scr_mission_reward(mission, star, planet) { star.p_player[planet] -= 20; } } + } else { + break; } } } if (result == "Land Raider") { scr_popup("Mechanicus Mission Completed", "Your " + string(obj_ini.role[100][16]) + " have worked with the Adeptus Mechanicus in a satisfactory manor. The testing and training went well, but your Land Raider was ultimately lost. A new Land Raider has been provided in return.", "mechanicus", ""); - var com, i, onceh; - onceh = 0; - com = -1; - i = 0; + var onceh = 0; obj_controller.disposition[3] += 1; - repeat (11) { + for (var com = 0; com <= 10; com++) { if (onceh == 0) { - com += 1; - i = 0; - repeat (100) { - i += 1; + for (var i = 1; i <= 100; i++) { if ((obj_ini.veh_role[com][i] == "Land Raider") && (obj_ini.veh_loc[com][i] == star.name) && (obj_ini.veh_wid[com][i] == planet)) { onceh = 1; obj_ini.veh_hp[com][i] = 100; } } + } else { + break; } } } @@ -188,9 +168,7 @@ function scr_mission_reward(mission, star, planet) { obj_controller.disposition[3] += 1; } - i = -1; - repeat (11) { - i += 1; + for (var i = 0; i <= 10; i++) { if (cleanup[i] == 1) { obj_controller.temp[3000] = real(i); with (obj_ini) { @@ -200,16 +178,11 @@ function scr_mission_reward(mission, star, planet) { } } - i = -1; - repeat (11) { - i += 1; - cleanup[i] = 0; - } + cleanup = array_create(11, 0); if (mission == "mech_bionics") { - var roll1, result; - roll1 = roll_dice_chapter(1, 100, "low"); - result = ""; + var roll1 = roll_dice_chapter(1, 100, "low"); + var result = ""; if (roll1 <= 33) { result = "Requisition"; @@ -229,7 +202,6 @@ function scr_mission_reward(mission, star, planet) { obj_controller.requisition += 150 * _marines.number(); _marines.kill_percent(100); } else if (result == "Bionics" || result == "Requisition") { - var _new_bionics = irandom_range(40, 100); obj_controller.disposition[3] += 1; mech_disp_change = 1; diff --git a/scripts/scr_move_unit_info/scr_move_unit_info.gml b/scripts/scr_move_unit_info/scr_move_unit_info.gml index 95870c4c52..ee8a427ea5 100644 --- a/scripts/scr_move_unit_info/scr_move_unit_info.gml +++ b/scripts/scr_move_unit_info/scr_move_unit_info.gml @@ -26,7 +26,7 @@ function scr_move_unit_info(start_company, end_company, start_slot, end_slot, ev _temp_struct.company = start_company; _temp_struct.marine_number = start_slot; - var _temp_struct = fetch_unit([end_company, end_slot]); + _temp_struct = fetch_unit([end_company, end_slot]); if (is_struct(_temp_struct)) { _temp_struct.company = end_company; _temp_struct.marine_number = end_slot; diff --git a/scripts/scr_newtext/scr_newtext.gml b/scripts/scr_newtext/scr_newtext.gml index 67f7317824..065a56ec63 100644 --- a/scripts/scr_newtext/scr_newtext.gml +++ b/scripts/scr_newtext/scr_newtext.gml @@ -21,6 +21,21 @@ function scr_newtext() { } liness += string_count("@", newline); + // Mirror the freshly appended rows into the scrollback history (capped) so the log stays + // scrollable after lines[] rolls them off its 45-row live window. If the player is currently + // reading scrolled-up history, push their view down by the same amount to hold its position. + if (variable_instance_exists(id, "log_history")) { + for (var _h = first_open; _h <= first_open + breaks - 1; _h++) { + array_push(log_history, { text: lines[_h], color: newline_color }); + } + while (array_length(log_history) > log_history_max) { + array_delete(log_history, 0, 1); + } + if (log_scroll > 0) { + log_scroll = min(log_scroll + breaks, max(0, array_length(log_history) - log_view_lines)); + } + } + repeat (100) { // if (liness>30){scr_lines_increase(1);liness-=1;} if (liness > 45) { diff --git a/scripts/scr_ork_fleet_functions/scr_ork_fleet_functions.gml b/scripts/scr_ork_fleet_functions/scr_ork_fleet_functions.gml index 3a73a7c08b..777250e6fe 100644 --- a/scripts/scr_ork_fleet_functions/scr_ork_fleet_functions.gml +++ b/scripts/scr_ork_fleet_functions/scr_ork_fleet_functions.gml @@ -41,7 +41,7 @@ function ork_fleet_move() { } with (obj_star) { - if (is_dead_star() || owner == eFACTION.ORK || scr_orbiting_fleet(eFACTION.ORK) != "none") { + if (is_dead_star() || owner == eFACTION.ORK || scr_orbiting_fleet(eFACTION.ORK) != noone) { instance_deactivate_object(id); } } @@ -58,13 +58,13 @@ function ork_fleet_move() { function ork_fleet_arrive_target() { instance_activate_object(obj_en_fleet); var _ork_fleet = scr_orbiting_fleet(eFACTION.ORK); - if (_ork_fleet == "none") { + if (_ork_fleet == noone) { return; } var aler = 0; var _imperial_ship = scr_orbiting_fleet([eFACTION.IMPERIUM, eFACTION.MECHANICUS]); - if (_imperial_ship == "none" && planets > 0 && !has_orbiting_player_fleet()) { + if (_imperial_ship == noone && planets > 0 && !has_orbiting_player_fleet()) { var _allow_landing = true, ork_attack_planet = 0, l = 0; var _planets = shuffled_planet_array(); for (var i = 0; i < array_length(_planets); i++) { @@ -83,9 +83,9 @@ function ork_fleet_arrive_target() { if (p_tyranids[ork_attack_planet] <= 0) { if (planet_feature_bool(p_feature[ork_attack_planet], eP_FEATURES.GENE_STEALER_CULT)) { _pdata.delete_feature(eP_FEATURES.GENE_STEALER_CULT); - adjust_influence(eFACTION.TYRANIDS, -25, ork_attack_planet); + adjust_influence(eFACTION.TYRANIDS, -25, ork_attack_planet, self); var nearest_imperial = nearest_star_with_ownership(x, y, eFACTION.IMPERIUM, self.id); - if (nearest_imperial != "none") { + if (nearest_imperial != noone) { var targ_planet = scr_get_planet_with_owner(nearest_imperial, eFACTION.IMPERIUM); if (targ_planet == -1) { targ_planet = irandom_range(1, nearest_imperial.planets); @@ -97,6 +97,7 @@ function ork_fleet_arrive_target() { } _allow_landing = !is_dead_star(); + var _fleet_persists = false; if (_allow_landing) { for (var i = 0; i < planets; i++) { var _planet = _planets[i]; @@ -104,8 +105,6 @@ function ork_fleet_arrive_target() { if ((p_type[_planet] != "Dead") && (p_orks[_planet] < 4) && (i <= planets)) { p_orks[_planet] += max(2, floor(_ork_fleet.image_index * 0.8)); - var _fleet_persists = false; - if (fleet_has_cargo("ork_warboss", _ork_fleet)) { array_push(p_feature[_planet], _ork_fleet.cargo_data.ork_warboss); p_orks[_planet] = 6; @@ -207,17 +206,19 @@ function init_ork_waagh(override = false) { } } + var _waaagh_star = noone; var _waaagh_star_found = false; if (array_length(ork_waagh_activity)) { - var _waaagh_star = array_random_element(ork_waagh_activity); + _waaagh_star = array_random_element(ork_waagh_activity); _waaagh_star_found = true; } else if (array_length(_any_ork_star) > 0) { - var _waaagh_star = array_random_element(_any_ork_star); + _waaagh_star = array_random_element(_any_ork_star); _waaagh_star_found = true; } + var _pdata = noone; if (_waaagh_star_found) { - var _pdata = _waaagh_star[0].get_planet_data(_waaagh_star[1]); + _pdata = _waaagh_star[0].get_planet_data(_waaagh_star[1]); var _boss = _pdata.add_feature(eP_FEATURES.ORKWARBOSS); if (override) { diff --git a/scripts/scr_ork_planet_functions/scr_ork_planet_functions.gml b/scripts/scr_ork_planet_functions/scr_ork_planet_functions.gml index fc914789a9..974d0a0483 100644 --- a/scripts/scr_ork_planet_functions/scr_ork_planet_functions.gml +++ b/scripts/scr_ork_planet_functions/scr_ork_planet_functions.gml @@ -25,10 +25,10 @@ function ork_ship_production(planet) { } if (contin == 2) { fleet = scr_orbiting_fleet(eFACTION.ORK); - if (fleet == "none") { + if (fleet == noone) { contin = 3; } - if ((fleet != "none") && (contin != 3)) { + if ((fleet != noone) && (contin != 3)) { rando = choose(1, 1, 1, 1, 1, 2, 2, 2, 2); switch (rando) { case 1: diff --git a/scripts/scr_perils_table/scr_perils_table.gml b/scripts/scr_perils_table/scr_perils_table.gml index 73a9152519..4f3a3a1b79 100644 --- a/scripts/scr_perils_table/scr_perils_table.gml +++ b/scripts/scr_perils_table/scr_perils_table.gml @@ -5,17 +5,15 @@ function scr_perils_table(perils_strength, unit, psy_discipline, power_name, uni 1, function(perils_strength, unit, psy_discipline, power_name, unit_id) { unit.corruption += roll_dice_chapter(1, 6, "low"); - var flavour_text2 = "He begins to gibber as psychic backlash overtakes him."; - return flavour_text2; - } + return "He begins to gibber as psychic backlash overtakes him."; + }, ], [ 5, function(perils_strength, unit, psy_discipline, power_name, unit_id) { marine_casting_cooldown[unit_id] += roll_dice_chapter(1, 6, "low"); - var flavour_text2 = "His mind is burned fiercely by the warp."; - return flavour_text2; - } + return "His mind is burned fiercely by the warp."; + }, ], [ 15, @@ -31,44 +29,39 @@ function scr_perils_table(perils_strength, unit, psy_discipline, power_name, uni } } } - var flavour_text2 = $"Psychic energy outlash knocks him out for {_cooldown} hours, and stuns nearby marines for {_cooldown2}."; - return flavour_text2; - } + return $"Psychic energy outlash knocks him out for {_cooldown} hours, and stuns nearby marines for {_cooldown2}."; + }, ], [ 20, function(perils_strength, unit, psy_discipline, power_name, unit_id) { unit.add_or_sub_health(roll_dice_chapter(1, 50, "low") * -1); + var flavour_text2 = "The psychic blast he had prepared runs loose, striking himself!"; switch (psy_discipline) { case "biomancy": - var flavour_text2 = "The psychic blast he had prepared runs loose, boiling his own blood!"; + flavour_text2 = "The psychic blast he had prepared runs loose, boiling his own blood!"; break; case "pyromancy": - var flavour_text2 = "He lights on fire from the inside out, burning in agony!"; + flavour_text2 = "He lights on fire from the inside out, burning in agony!"; break; case "telekinesis": - var flavour_text2 = "The blast he had prepared runs loose, smashing himself into the ground!"; - break; - default: - var flavour_text2 = "The psychic blast he had prepared runs loose, striking himself!"; + flavour_text2 = "The blast he had prepared runs loose, smashing himself into the ground!"; break; } return flavour_text2; - } + }, ], [ 30, function(perils_strength, unit, psy_discipline, power_name, unit_id) { marine_casting_cooldown[unit_id] += 20; unit.corruption += roll_dice_chapter(1, 6, "low"); - var flavour_text2 = $"His mind is seared by the warp, now unable to cast more powers for {marine_casting_cooldown[unit_id]} hours."; - return flavour_text2; - } + return $"His mind is seared by the warp, now unable to cast more powers for {marine_casting_cooldown[unit_id]} hours."; + }, ], [ 40, function(perils_strength, unit, psy_discipline, power_name, unit_id) { - var flavour_text2 = "Capricious voices eminate from the surrounding area, whispering poisonous lies and horrible truths."; unit.corruption += roll_dice_chapter(1, 10, "low"); if (men > 0) { repeat (6) { @@ -79,16 +72,14 @@ function scr_perils_table(perils_strength, unit, psy_discipline, power_name, uni } } } - return flavour_text2; - } + return "Capricious voices eminate from the surrounding area, whispering poisonous lies and horrible truths."; + }, ], [ 50, function(perils_strength, unit, psy_discipline, power_name, unit_id) { - var flavour_text2 = "Dark, shifting lights form into several "; var d1 = 0, d2 = 0, d3 = 0; var dem = choose("Pink Horror", "Daemonette", "Bloodletter", "Plaguebearer"); - flavour_text2 += string(dem) + "s."; d1 = instance_nearest(x, y, obj_enunit); var exist; exist = 0; @@ -131,13 +122,12 @@ function scr_perils_table(perils_strength, unit, psy_discipline, power_name, uni obj_ncombat.enemy_forces += d2; obj_ncombat.enemy_max += d2; } - return flavour_text2; - } + return "Dark, shifting lights form into several " + string(dem) + "s."; + }, ], [ 60, function(perils_strength, unit, psy_discipline, power_name, unit_id) { - var flavour_text2 = "There is a massive explosion of warp energy which injures him and several other marines!"; unit.add_or_sub_health(roll_dice_chapter(1, 50, "low") * -1); if (men > 0) { repeat (6) { @@ -147,16 +137,15 @@ function scr_perils_table(perils_strength, unit, psy_discipline, power_name, uni } } } - return flavour_text2; - } + return "There is a massive explosion of warp energy which injures him and several other marines!"; + }, ], [ 70, function(perils_strength, unit, psy_discipline, power_name, unit_id) { obj_ncombat.global_perils += 10; - var flavour_text2 = "Wind shrieks and blood pours from the sky! The warp feels unstable."; - return flavour_text2; - } + return "Wind shrieks and blood pours from the sky! The warp feels unstable."; + }, ], [ 80, @@ -171,33 +160,19 @@ function scr_perils_table(perils_strength, unit, psy_discipline, power_name, uni } } unit.add_equipment_repairs(eEQUIPMENT_SLOT.ALL); - var flavour_text2 = "A massive shockwave eminates from the marine, who is knocked out cold! All of his equipment is damaged!"; - return flavour_text2; - } + return "A massive shockwave eminates from the marine, who is knocked out cold! All of his equipment is damaged!"; + }, ], [ 90, function(perils_strength, unit, psy_discipline, power_name, unit_id) { - var flavour_text2; marine_casting_cooldown[unit_id] += 999; unit.corruption += roll_dice_chapter(5, 10, "low"); - flavour_text2 = "The marine's flesh begins to twist and rip, seemingly turning inside out. His form looms up, and up, and up. Within seconds a Greater Daemon of "; var dem = choose("Slaanesh", "Nurgle", "Tzeentch"); - /* if (using_tome != "") { - if (string_count("daemonic", marine_gear[unit_id]) > 0) { - if (string_count("SLAANESH", marine_gear[unit_id]) > 0) { - dem = "Slaanesh"; - } - if (string_count("NURGLE", marine_gear[unit_id]) > 0) { - dem = "Nurgle"; - } - if (string_count("TZEENTCH", marine_gear[unit_id]) > 0) { - dem = "Tzeentch"; - } - } - } */ - var d1 = 0, d2 = 0, d3 = 0, d1 = instance_nearest(x, y, obj_enunit); + var d1 = instance_nearest(x, y, obj_enunit); + var d2 = 0; + var d3 = 0; repeat (30) { if (d3 == 0) { d2 += 1; @@ -220,28 +195,26 @@ function scr_perils_table(perils_strength, unit, psy_discipline, power_name, uni d1.neww = 1; d1.alarm[1] = 1; - flavour_text2 += string(dem) + " has taken form."; - return flavour_text2; - } + return "The marine's flesh begins to twist and rip, seemingly turning inside out. His form looms up, and up, and up. Within seconds a Greater Daemon of " + string(dem) + " has taken form."; + }, ], [ 100, function(perils_strength, unit, psy_discipline, power_name, unit_id) { - var flavour_text2 = ""; + var flavour_text2 = choose("There is a snap, and pop, and he disappears entirely.", "He explodes into a cloud of gore, splattering guts and ceramite across the battlefield."); if (unit.role() == obj_ini.role[100][eROLE.CHAPTERMASTER]) { - var flavour_text2 = "There is a snap, and pop, and he disappears entirely. Reappearing minutes later, barely alive and stunned."; + flavour_text2 = "There is a snap, and pop, and he disappears entirely. Reappearing minutes later, barely alive and stunned."; unit.update_health(10); marine_casting_cooldown[unit_id] = 999; } else { - flavour_text2 = choose("There is a snap, and pop, and he disappears entirely.", "He explodes into a cloud of gore, splattering guts and ceramite across the battlefield."); unit.update_health(0); marine_dead[unit_id] = 2; } return flavour_text2; - } - ] + }, + ], ]; for (var i = array_length(combat_perils) - 1; i >= 0; i--) { diff --git a/scripts/scr_planetary_feature/scr_planetary_feature.gml b/scripts/scr_planetary_feature/scr_planetary_feature.gml index d5b33a64c6..58300f6705 100644 --- a/scripts/scr_planetary_feature/scr_planetary_feature.gml +++ b/scripts/scr_planetary_feature/scr_planetary_feature.gml @@ -291,33 +291,25 @@ function awake_tomb_world(planet) { //selas a tomb world and switche off awake so will no longer spawn necrons or necron fleets function seal_tomb_world(planet) { - var awake_tomb = 0; var tombs = search_planet_features(planet, eP_FEATURES.NECRON_TOMB); if (array_length(tombs) > 0) { for (var tomb = 0; tomb < array_length(tombs); tomb++) { - awake_tomb = 1; planet[tombs[tomb]].awake = 0; planet[tombs[tomb]].sealed = 1; planet[tombs[tomb]].planet_display = "Sealed Necron Tomb"; - if (awake_tomb == 1) { - break; - } + break; } } } //awakens a tomb world so necrons and necron fleets will spawn function awaken_tomb_world(planet) { - var awake_tomb = 0; var tombs = search_planet_features(planet, eP_FEATURES.NECRON_TOMB); if (array_length(tombs) > 0) { for (var tomb = 0; tomb < array_length(tombs); tomb++) { if (planet[tombs[tomb]].awake == 0) { - awake_tomb = 1; planet[tombs[tomb]].awake = 1; planet[tombs[tomb]].planet_display = "Active Necron Tomb"; - } - if (awake_tomb == 1) { break; } } @@ -333,12 +325,13 @@ function scr_planetary_feature(planet_num) { if (feat.player_hidden == 1) { feat.player_hidden = 0; var numeral_n = planet_numeral_name(planet_num); + var lop = ""; switch (feat.f_type) { case eP_FEATURES.SORORITAS_CATHEDRAL: if (obj_controller.known[eFACTION.ECCLESIARCHY] == 0) { obj_controller.known[eFACTION.ECCLESIARCHY] = 1; } - var lop = $"Sororitas Cathedral discovered on {numeral_n}."; + lop = $"Sororitas Cathedral discovered on {numeral_n}."; scr_alert("green", "feature", lop, x, y); scr_event_log("", lop); if (p_heresy[planet_num] > 10) { @@ -348,32 +341,32 @@ function scr_planetary_feature(planet_num) { goo = 1; break; case eP_FEATURES.NECRON_TOMB: - var lop = $"Necron Tomb discovered on {numeral_n}."; + lop = $"Necron Tomb discovered on {numeral_n}."; scr_alert("red", "feature", lop, x, y); scr_event_log("red", lop); break; case eP_FEATURES.ARTIFACT: - var lop = $"Artifact discovered on {numeral_n}."; + lop = $"Artifact discovered on {numeral_n}."; scr_alert("green", "feature", lop, x, y); scr_event_log("", lop); break; case eP_FEATURES.STC_FRAGMENT: - var lop = $"STC Fragment located on {numeral_n}."; + lop = $"STC Fragment located on {numeral_n}."; scr_alert("green", "feature", lop, x, y); scr_event_log("", lop); break; case eP_FEATURES.ANCIENT_RUINS: - var lop = $"A {feat.ruins_size} Ancient Ruins discovered on {string(name)} {scr_roman(planet_num)}."; + lop = $"A {feat.ruins_size} Ancient Ruins discovered on {string(name)} {scr_roman(planet_num)}."; scr_alert("green", "feature", lop, x, y); scr_event_log("", lop); break; case eP_FEATURES.CAVE_NETWORK: - var lop = $"Extensive Cave Network discovered on {numeral_n}."; + lop = $"Extensive Cave Network discovered on {numeral_n}."; scr_alert("green", "feature", lop, x, y); scr_event_log("", lop); break; case eP_FEATURES.ORKWARBOSS: - var lop = $"Ork Warboss discovered on {numeral_n}."; + lop = $"Ork Warboss discovered on {numeral_n}."; scr_alert("red", "feature", lop, x, y); scr_event_log("red", lop); break; @@ -384,7 +377,7 @@ function scr_planetary_feature(planet_num) { function create_starship_event() { var star = scr_random_find(2, true, "", ""); - if (star == undefined) { + if (star == noone) { LOGGER.error("RE: couldn't find starship target"); return false; } else { @@ -408,10 +401,6 @@ function ground_mission_leave_it_function() { /// @self Struct.PlanetData function discover_artifact_popup(feature) { obj_controller.menu = eMENU.DEFAULT; - /*if ((planet_type == "Dead" || current_owner == eFACTION.PLAYER)) { - alarm[4] = 1; - exit; - }*/ var pop = instance_create(0, 0, obj_popup); pop.image = "artifact"; @@ -628,17 +617,10 @@ function ground_forces_collect_artifact() { with (obj_ground_mission) { scr_return_ship(pdata.system.name, self, pdata.planet); - var man_size, ship_id, comp, i; - i = 0; - ship_id = 0; - man_size = 0; - comp = 0; - ship_id = get_valid_player_ship("", loc); + var ship_id = get_valid_player_ship("", loc); var last_artifact = scr_add_artifact("random", "random", 4, loc, ship_id + 500); - var i = 0; - var mission = "bad"; var mission_roll = irandom(100) + 1; if (scr_has_adv("Ambushers")) { @@ -646,14 +628,12 @@ function ground_forces_collect_artifact() { } if (mission_roll <= 60) { mission = "good"; - } // 135 + } if (pdata.planet_type == "Dead") { mission = "good"; } - // mission="bad"; - var pop; - pop = instance_create(0, 0, obj_popup); + var pop = instance_create(0, 0, obj_popup); pop.image = "artifact_recovered"; pop.title = "Artifact Recovered!"; @@ -668,7 +648,7 @@ function ground_forces_collect_artifact() { } if (pdata.current_owner == eFACTION.MECHANICUS) { obj_controller.disposition[3] -= 10; - } // max(obj_controller.disposition/4,10) + } if (pdata.current_owner == 4) { obj_controller.disposition[4] -= max(obj_controller.disposition[4] / 4, 10); } @@ -710,7 +690,12 @@ function ground_forces_collect_artifact() { } if (scr_has_adv("Tech-Scavengers")) { - var ex1 = "", ex1_num = 0, ex2 = "", ex2_num = 0, ex3 = "", ex3_num = 0; + var ex1 = ""; + var ex1_num = 0; + var ex2 = ""; + var ex2_num = 0; + var ex3 = ""; + var ex3_num = 0; var stah = instance_nearest(x, y, obj_star); @@ -821,14 +806,6 @@ function governor_negotiate_artifact() { function remove_stc_from_planet() { with (obj_ground_mission) { - var comp, plan, i; - i = 0; - comp = 0; - plan = 0; - plan = instance_nearest(x, y, obj_star); - - var mission, mission_roll; - var mission = "bad"; var mission_roll = floor(random(100)) + 1; @@ -840,14 +817,12 @@ function remove_stc_from_planet() { } if (mission_roll <= 60) { mission = "good"; - } // 135 + } if (pdata.planet_type == "Dead") { mission = "good"; } - // mission="bad"; - var pop; - pop = instance_create(0, 0, obj_popup); + var pop = instance_create(0, 0, obj_popup); pop.image = "artifact_recovered"; pop.title = "STC Recovered!"; @@ -860,34 +835,16 @@ function remove_stc_from_planet() { if (mission == "good" && pdata.origional_owner == 3 && pdata.planet_type == "Forge") { pop.text = "Your forces descend into the vaults of the Mechanicus Forge, bypassing sentries, automated defenses, and blast doors on the way.##"; pop.text += "The STC Fragment has been safely recovered and stowed away. It is ready to be decrypted or gifted at your convenience."; - - /*if (pdata.planet_type!="Dead"){ - if (pdata.current_owner=2) then obj_controller.disposition[2]-=1; - if (pdata.current_owner=eFACTION.MECHANICUS) then obj_controller.disposition[3]-=10;// max(obj_controller.disposition/4,10) - if (pdata.current_owner=4) then obj_controller.disposition[4]-=max(obj_controller.disposition[4]/4,10); - if (pdata.current_owner=5) then obj_controller.disposition[5]-=3; - if (pdata.current_owner=8) then obj_controller.disposition[8]-=3; - }*/ scr_return_ship(pdata.system.name, self, pdata.planet); } if (mission == "bad" && pdata.origional_owner == eFACTION.MECHANICUS && pdata.planet_type == "Forge") { - /*pop.text="Your marines converge upon the STC Fragment; resistance is light and easily dealt with. After a brief firefight it is retrieved.##"; - pop.text+="The fragment been safely stowed away, and is ready to be decrypted or gifted at your convenience."; - - */ - pop.image = "thallax"; pop.text = "Your forces descend into the vaults of the Mechanicus Forge. Sentries, automated defenses, and blast doors stand in their way.##"; pop.text += "Half-way through the mission a small army of Praetorian Servitors and Skitarii bear down upon your men. The Mechanicus guards seem to be upset."; - /*if (pdata.current_owner=2) then obj_controller.disposition[2]-=2;*/ if (pdata.current_owner == eFACTION.MECHANICUS) { obj_controller.disposition[3] -= 40; } - /*if (pdata.current_owner=4) then obj_controller.disposition[4]-=max(obj_controller.disposition[4]/3,20); - if (pdata.current_owner=5) then obj_controller.disposition[5]-=max(obj_controller.disposition[3]/4,15); - if (pdata.current_owner=6) then obj_controller.disposition[6]-=15; - if (pdata.current_owner=8) then obj_controller.disposition[8]-=8;*/ if (pdata.current_owner > 3 && pdata.current_owner <= 6) { scr_audience(pdata.current_owner, "artifact_angry",); @@ -909,16 +866,14 @@ function remove_stc_from_planet() { } if (scr_has_adv("Tech-Scavengers")) { - var ex1, ex1_num, ex2, ex2_num, ex3, ex3_num; - ex1 = ""; - ex1_num = 0; - ex2 = ""; - ex2_num = 0; - ex3 = ""; - ex3_num = 0; + var ex1 = ""; + var ex1_num = 0; + var ex2 = ""; + var ex2_num = 0; + var ex3 = ""; + var ex3_num = 0; - var stah; - stah = instance_nearest(x, y, obj_star); + var stah = instance_nearest(x, y, obj_star); if (pdata.origional_owner == 2) { ex1 = "Meltagun"; @@ -976,9 +931,6 @@ function remove_stc_from_planet() { clear_diplo_choices(); obj_controller.menu = 0; instance_destroy(); - - /* */ - /* */ } instance_destroy(); } @@ -986,13 +938,8 @@ function remove_stc_from_planet() { function recieve_artifact_in_discussion() { scr_return_ship(loc, self, num); - var man_size, comp, plan, i; - i = 0; - man_size = 0; - comp = 0; - plan = 0; var ship_id = get_valid_player_ship("", loc); - plan = instance_nearest(x, y, obj_star); + var plan = instance_nearest(x, y, obj_star); var last_artifact = scr_add_artifact("random", "random", 4, loc, ship_id + 500); var pop = instance_create(0, 0, obj_popup); @@ -1017,8 +964,7 @@ function recieve_artifact_in_discussion() { function send_stc_to_adeptus_mech() { with (obj_ground_mission) { - var _target_planet; - _target_planet = instance_nearest(x, y, obj_star); + var _target_planet = instance_nearest(x, y, obj_star); pdata.delete_feature(eP_FEATURES.STC_FRAGMENT); scr_return_ship(pdata.system.name, self, pdata.planet); @@ -1085,8 +1031,7 @@ function send_stc_to_adeptus_mech() { } } - var _enemy_fleet; - var _target = -1; + var _target = noone; if (instance_exists(obj_temp2)) { _target = nearest_star_with_ownership(obj_temp2.x, obj_temp2.y, obj_controller.diplomacy); @@ -1095,7 +1040,7 @@ function send_stc_to_adeptus_mech() { } else if ((!instance_exists(obj_temp2)) && (!instance_exists(obj_temp7)) && instance_exists(obj_p_fleet) && (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD)) { // If player fleet is flying about then get their target for new target with (obj_p_fleet) { - var pop; + var pop = noone; if ((capital_number > 0) && (action != "")) { pop = instance_create(action_x, action_y, obj_temp2); pop.action_eta = action_eta; @@ -1108,7 +1053,7 @@ function send_stc_to_adeptus_mech() { } if (is_struct(_target)) { - _enemy_fleet = instance_create(_target.x, _target.y, obj_en_fleet); + var _enemy_fleet = instance_create(_target.x, _target.y, obj_en_fleet); _enemy_fleet.owner = obj_controller.diplomacy; _enemy_fleet.home_x = _target.x; diff --git a/scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml b/scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml index 2c8e1cd5da..2dcad296f9 100644 --- a/scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml +++ b/scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml @@ -60,6 +60,36 @@ function add_data_to_stack(stack_index, weapon, unit_damage = false, head_role = } } +/// @self Asset.GMObject.obj_pnunit +/// Adds a single named weapon to the stacks, firing "count" times. Used for Guard +/// Squads, where one unit struct stands for a whole squad: the default weapon (wep1) +/// fires once per man and the special weapon (wep2) fires once for the squad. Mirrors +/// the enemy horde firepower in scr_en_weapon (attack times the number firing) rather +/// than the normal single-primary-weapon path, which would only fire the higher-attack gun. +function add_squad_weapon(weapon_name, count, head_role = false, unit = "none") { + if (weapon_name == "") { + return; + } + var _w = gear_weapon_data("weapon", weapon_name, "all", false, "standard"); + if (!is_struct(_w) || _w.name == "") { + return; + } + var _idx = find_stack_index(_w.name, head_role, unit); + if (_idx < 0) { + return; + } + att[_idx] += _w.attack * count; + apa[_idx] = _w.arp; + range[_idx] = _w.range; + wep_num[_idx] += count; + splash[_idx] = _w.spli; + wep[_idx] = _w.name; + if (obj_ncombat.started == 0) { + ammo[_idx] = _w.ammo; + } + wep_owner[_idx] = "assorted"; +} + /// @self Asset.GMObject.obj_pnunit function find_stack_index(weapon_name, head_role = false, unit = "none") { final_index = -1; @@ -81,6 +111,35 @@ function find_stack_index(weapon_name, head_role = false, unit = "none") { return final_index; } +/// @self Asset.GMObject.obj_pnunit +/// Like find_stack_index, but caps how many shooters share a stack so a large body of +/// identically-armed troops (a guard regiment of lasguns) splits into several smaller stacks +/// instead of one regiment-wide one. Each capped stack fires and targets independently in +/// combat, the way the enemy's obj_enunit blocks already do. Fills a partial chunk first, +/// opens a fresh stack when the current one is full, and only as a last resort (all 71 stack +/// slots used) merges over the cap so fire is never silently dropped. +function find_capped_stack_index(weapon_name, cap) { + // 1. a matching, un-led chunk that still has room + for (var si = 1; si < array_length(wep); si++) { + if (wep[si] == weapon_name && wep_title[si] == "" && wep_num[si] < cap) { + return si; + } + } + // 2. no room left in any existing chunk: start a fresh one + for (var si = 1; si < array_length(wep); si++) { + if (wep[si] == "" && wep_title[si] == "") { + return si; + } + } + // 3. stack slots exhausted: merge over the cap rather than drop the shots + for (var si = 1; si < array_length(wep); si++) { + if (wep[si] == weapon_name && wep_title[si] == "") { + return si; + } + } + return -1; +} + /// @self Asset.GMObject.obj_pnunit function player_head_role_stack(stack_index, unit) { wep_title[stack_index] = unit.role(); @@ -130,6 +189,82 @@ function scr_player_combat_weapon_stacks() { exit; } + // ===== OBSOLETE: planetary Guard (iteration 1) ===== + // First-iteration "planetary Guard" men-block (PDF / Imperial Navy). The obj_pnunit + // `guard` flag is never set to 1 anywhere in the project, so this branch is dead and + // never runs. Left for reference only. The live guardsmen are individual unit_struct + // units with role "Guardsman" and fire through the normal weapon path below, not here. + if (guard == 1) { + var _gi = 0; + var _pg = men; // current Guardsmen in this block + + // Massed lasguns: one per man, attack 60, armour pierce 1, range 6, 30 rounds. + _gi += 1; + wep[_gi] = "Lasgun"; + wep_num[_gi] = max(1, _pg); + range[_gi] = 6; + att[_gi] = 60 * wep_num[_gi]; + apa[_gi] = 1; + ammo[_gi] = 30; + splash[_gi] = 0; + + // Bayonets (melee, range 1). Required or the block locks up in melee: once an + // enemy is adjacent the fire logic disables every ranged weapon, and with no + // melee weapon the Guard can neither shoot nor swing. Guardsmen are poor in + // melee, so this is a weak profile. + _gi += 1; + wep[_gi] = "Bayonet"; + wep_num[_gi] = max(1, _pg); + range[_gi] = 1; + att[_gi] = 12 * wep_num[_gi]; + apa[_gi] = 0; + ammo[_gi] = -1; + splash[_gi] = 0; + + // Heavy bolters: attack 120, range 16. Anti-infantry support only. The Guard + // carry no anti-tank weapon by design, so a pure-infantry force cannot crack + // armour; they bleed against vehicles unless a Leman Russ tank line is present. + _gi += 1; + wep[_gi] = "Heavy Bolter"; + wep_num[_gi] = max(1, round(_pg / 200)); + range[_gi] = 16; + att[_gi] = 120 * wep_num[_gi]; + apa[_gi] = 0; + ammo[_gi] = -1; + splash[_gi] = 0; + + exit; + } + + if (guard == 2) { + // Leman Russ tank line, fielded as its own block separate from the infantry, + // the way the enemy Imperial Guard keep tanks out of their soldier lines. + // Battle Cannon 300 and Lascannon 200, both armour-piercing, scaled to the + // tanks still alive. This is the Guard's only anti-armour. + var _gi = 0; + var _tk = veh; + + _gi += 1; + wep[_gi] = "Battle Cannon"; + wep_num[_gi] = max(1, _tk); + range[_gi] = 12; + att[_gi] = 300 * wep_num[_gi]; + apa[_gi] = round(att[_gi] * 0.6); + ammo[_gi] = -1; + splash[_gi] = 0; + + _gi += 1; + wep[_gi] = "Lascannon"; + wep_num[_gi] = max(1, _tk); + range[_gi] = 20; + att[_gi] = 200 * wep_num[_gi]; + apa[_gi] = round(att[_gi] * 0.8); + ammo[_gi] = -1; + splash[_gi] = 0; + + exit; + } + var i, g = 0; veh = 0; men = 0; @@ -189,6 +324,16 @@ function scr_player_combat_weapon_stacks() { } } } + if (is_struct(mobi_item) && mobi_item.has_tag("bike")) { + var _speed_force = unit.speed_force(mobi_item.has_tag("sf_ranged")); + var stack_index = find_stack_index(_speed_force.name, head_role, unit); + if (stack_index > -1) { + add_data_to_stack(stack_index, _speed_force, false, head_role, unit); + if (head_role) { + player_head_role_stack(stack_index, unit); + } + } + } if (is_struct(mobi_item)) { add_second_profiles_to_stack(mobi_item); @@ -241,12 +386,35 @@ function scr_player_combat_weapon_stacks() { } if (marine_casting[g] == false) { var weapon_stack_index = 0; - var primary_ranged = unit.ranged_damage_data[3]; //collect unit ranged data - var weapon_stack_index = find_stack_index(primary_ranged.name, head_role, unit); - if (weapon_stack_index > -1) { - add_data_to_stack(weapon_stack_index, primary_ranged, unit.ranged_damage_data[0], head_role, unit); - if (head_role) { - player_head_role_stack(weapon_stack_index, unit); + // ===== RESERVED: Guard Squad (iteration 2) ===== + // Single pooled-HP squad entity (role "Guard Squad"). Not deployed in + // normal play; the live guardsmen are individuals. Kept deliberately for + // planned reuse as heavy weapons teams. Do not delete. + if (unit.role() == "Guard Squad") { + // The squad thins as it takes losses: its surviving strength scales with + // remaining health, so a half-health squad fires half its lasguns and a + // squad on its last legs fires one. It fires wep1 once per surviving man + // and its special weapon (wep2) once while the squad still lives. + var _sq_max = unit.max_health(); + var _sq_men = (_sq_max > 0) ? max(1, ceil(GUARD_SQUAD_SIZE * unit.hp() / _sq_max)) : 1; + add_squad_weapon(unit.weapon_one(), _sq_men, head_role, unit); + add_squad_weapon(unit.weapon_two(), 1, head_role, unit); + } else { + var primary_ranged = unit.ranged_damage_data[3]; //collect unit ranged data + // Rank-and-file guardsmen split into enemy-block-sized volleys (capped + // stacks) instead of merging the whole regiment into one lasgun stack, so + // each volley fires and picks its target on its own. Everyone else (Marines, + // sergeants, specialists) stacks normally. + if (unit.role() == "Guardsman") { + weapon_stack_index = find_capped_stack_index(primary_ranged.name, GUARD_VOLLEY_SIZE); + } else { + weapon_stack_index = find_stack_index(primary_ranged.name, head_role, unit); + } + if (weapon_stack_index > -1) { + add_data_to_stack(weapon_stack_index, primary_ranged, unit.ranged_damage_data[0], head_role, unit); + if (head_role) { + player_head_role_stack(weapon_stack_index, unit); + } } } diff --git a/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml b/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml index ee42ff8c85..cd7e0efa79 100644 --- a/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml +++ b/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml @@ -1,6 +1,5 @@ -// Script assets have changed for v2.3.0 see -// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information -/// @param {Asset.GMObject.obj_fleet} combat +/// @param {Id.Instance.obj_p_fleet} fleet +/// @param {Id.Instance.obj_fleet} combat function add_fleet_ships_to_combat(fleet, combat) { var capital_count = array_length(fleet.capital); var _ship_id; @@ -53,7 +52,7 @@ function add_fleet_ships_to_combat(fleet, combat) { } } -/// @param {Asset.GMObject.obj_fleet} combat +/// @param {Id.Instance.obj_fleet} combat function sort_ships_into_columns(combat) { var col = 5; with (combat) { @@ -129,7 +128,6 @@ function player_fleet_ship_spawner() { hei = 160; sizz = 3; } - // if (column[col]="Slaughtersong"){hei=200;sizz=3;} if (column[col] == "Strike Cruiser" || column[col] == "frigate") { hei = 96; sizz = 2; @@ -150,7 +148,6 @@ function player_fleet_ship_spawner() { temp2 += 20; } - // show_message(string(column_num[col])+" "+string(column[col])+" X:"+string(x2)); for (var k = 0; k < array_length(ship_id); k++) { if (ship_class[k] == column[col] || (player_ships_class(ship_id[k]) == column[col])) { man = -1; diff --git a/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml b/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml index 44d5157973..2064f118ed 100644 --- a/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml +++ b/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml @@ -1,12 +1,9 @@ -// Script assets have changed for v2.3.0 see -// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more informationype -function fleet_has_roles(fleet = "none", roles) { +function fleet_has_roles(fleet, roles = []) { var all_ships = fleet_full_ship_array(fleet); - var unit; for (var i = 0; i <= 10; i++) { for (var s = 0; s < array_length(obj_ini.TTRPG[i]); s++) { - unit = fetch_unit([i, s]); + var unit = fetch_unit([i, s]); if (unit.planet_location < 1) { if (array_contains(all_ships, unit.ship_location)) { if (array_contains(roles, unit.role())) { @@ -18,9 +15,8 @@ function fleet_has_roles(fleet = "none", roles) { } } -function fleet_engaged(fleet = undefined) { +function fleet_engaged(fleet) { var _engaged = false; - fleet ??= self; var _fleet_action = fleet.action; if (_fleet_action != "" && _fleet_action != "move") { //don't inspect if engaged in non negotiable actions @@ -32,15 +28,14 @@ function fleet_engaged(fleet = undefined) { return _engaged; } -function split_selected_into_new_fleet(start_fleet = "none") { - var new_fleet; - if (start_fleet == "none") { - new_fleet = instance_create(x, y, obj_p_fleet); - new_fleet.owner = eFACTION.PLAYER; +function split_selected_into_new_fleet(start_fleet) { + var new_fleet = instance_create(x, y, obj_p_fleet); + new_fleet.owner = eFACTION.PLAYER; + with (start_fleet) { // Pass over ships to the new fleet, if they are selected var cap_number = array_length(capital); - for (i = 0; i < cap_number; i++) { + for (var i = 0; i < cap_number; i++) { if ((capital[i] != "") && capital_sel[i]) { move_ship_between_player_fleets(self, new_fleet, "capital", i); i--; @@ -48,7 +43,7 @@ function split_selected_into_new_fleet(start_fleet = "none") { } } var frig_number = array_length(frigate); - for (i = 0; i < frig_number; i++) { + for (var i = 0; i < frig_number; i++) { if ((frigate[i] != "") && frigate_sel[i]) { move_ship_between_player_fleets(self, new_fleet, "frigate", i); i--; @@ -56,7 +51,7 @@ function split_selected_into_new_fleet(start_fleet = "none") { } } var esc_number = array_length(escort); - for (i = 0; i < esc_number; i++) { + for (var i = 0; i < esc_number; i++) { if ((escort[i] != "") && escort_sel[i]) { move_ship_between_player_fleets(self, new_fleet, "escort", i); i--; @@ -64,10 +59,6 @@ function split_selected_into_new_fleet(start_fleet = "none") { } } set_player_fleet_image(); - } else { - with (start_fleet) { - new_fleet = split_selected_into_new_fleet(); - } } return new_fleet; } @@ -88,7 +79,7 @@ function set_new_player_fleet_course(target_array) { var target_planet = find_star_by_name(target_array[0]); var nearest_planet = instance_nearest(x, y, obj_star); var from_star = point_distance(nearest_planet.x, nearest_planet.y, x, y) < 75; - var valid = target_planet != "none"; + var valid = target_planet != noone; if (valid) { valid = !(target_planet.id == nearest_planet.id && from_star); } @@ -110,7 +101,7 @@ function set_new_player_fleet_course(target_array) { action_y = target_planet.y; action = "move"; just_left = true; - orbiting = 0; + orbiting = noone; x = x + lengthdir_x(48, point_direction(x, y, action_x, action_y)); y = y + lengthdir_y(48, point_direction(x, y, action_x, action_y)); set_fleet_location("Warp"); @@ -235,7 +226,7 @@ function set_player_fleet_image() { } function find_ships_fleet(index) { - var _chosen_fleet = "none"; + var _chosen_fleet = noone; with (obj_p_fleet) { if (array_contains(capital_num, index) || array_contains(frigate_num, index) || array_contains(escort_num, index)) { _chosen_fleet = self; @@ -244,7 +235,7 @@ function find_ships_fleet(index) { return _chosen_fleet; } -function add_ship_to_fleet(index, fleet = "none") { +function add_ship_to_fleet(index, fleet = noone) { var _escorts = [ "Escort", "Hunter", @@ -256,7 +247,7 @@ function add_ship_to_fleet(index, fleet = "none") { ]; var _frigates = ["Strike Cruiser"]; - if (fleet == "none") { + if (fleet == noone) { if (array_contains(_capitals, obj_ini.ship_class[index])) { array_push(capital, obj_ini.ship[index]); array_push(capital_num, index); @@ -285,16 +276,14 @@ function add_ship_to_fleet(index, fleet = "none") { function player_retreat_from_fleet_combat() { try { - var p_strength, ratio, diceh, _roll_100; var mfleet = obj_turn_end.battle_pobject[obj_turn_end.current_battle]; - var _fleet_ships = fleet_full_ship_array(mfleet); var en_strength = 0; var p_strength = mfleet.escort_number; p_strength += mfleet.frigate_number * 3; p_strength += mfleet.capital_number * 8; - _roll_100 = roll_dice_chapter(1, 100, "low"); + var _roll_100 = roll_dice_chapter(1, 100, "low"); var _loc_star = find_star_by_name(obj_turn_end.battle_location[obj_turn_end.current_battle]); @@ -315,14 +304,13 @@ function player_retreat_from_fleet_combat() { en_strength += frig_total * 2; en_strength += escort_total; - ratio = 9999; + var ratio = 9999; if ((p_strength > 0) && (en_strength > 0)) { ratio = (en_strength / p_strength) * 100; } var esc_lost = 0, frig_lost = 0, cap_lost = 0, which = 0, sayd = 0; - i = -1; // var ship_lost,i; var ship_lost = []; if (scr_has_adv("Kings of Space")) { @@ -334,7 +322,7 @@ function player_retreat_from_fleet_combat() { if (_roll_100 != -5) { repeat (50) { - diceh = roll_dice_chapter(1, 100, "high"); + var diceh = roll_dice_chapter(1, 100, "high"); if (diceh <= ratio) { ratio -= 100; var onceh = 0; @@ -373,7 +361,6 @@ function player_retreat_from_fleet_combat() { if (!(mfleet.capital_number + mfleet.frigate_number + mfleet.escort_number)) { break; } - // show_message("Ship lost"); } } } @@ -409,6 +396,7 @@ function player_retreat_from_fleet_combat() { instance_destroy(); } + var text = "Your fleet is given the command to fall back. The vessels turn and prepare to enter the Warp, constantly under a hail of enemy fire. "; if ((esc_lost + frig_lost + cap_lost > 0) && (mfleet.escort_number + mfleet.frigate_number + mfleet.capital_number > 0)) { text = "Your fleet is given the command to fall back. The vesels turn and prepare to enter the Warp, constantly under a hail of enemy fire. Some of your ships remain behind to draw off the attack and give the rest of your fleet a chance to escape. "; @@ -432,7 +420,6 @@ function player_retreat_from_fleet_combat() { text += string(esc_lost) + " Escorts were destroyed. "; } } - var text = "Your fleet is given the command to fall back. The vessels turn and prepare to enter the Warp, constantly under a hail of enemy fire. "; if (esc_lost + frig_lost + cap_lost == 0) { text += "The entire fleet manages to escape with minimal damage."; } @@ -458,27 +445,26 @@ function player_retreat_from_fleet_combat() { } } -function fleet_full_ship_array(fleet = "none", exclude_capitals = false, exclude_frigates = false, exclude_escorts = false) { +function fleet_full_ship_array(fleet = noone, exclude_capitals = false, exclude_frigates = false, exclude_escorts = false) { var all_ships = []; - var i; var _ship_count = array_length(obj_ini.ship); - if (fleet == "none") { + if (fleet == noone) { if (!exclude_capitals) { - for (i = 0; i < array_length(capital_num); i++) { + for (var i = 0; i < array_length(capital_num); i++) { if (capital_num[i] < _ship_count) { array_push(all_ships, capital_num[i]); } } } if (!exclude_frigates) { - for (i = 0; i < array_length(frigate_num); i++) { + for (var i = 0; i < array_length(frigate_num); i++) { if (frigate_num[i] < _ship_count) { array_push(all_ships, frigate_num[i]); } } } if (!exclude_escorts) { - for (i = 0; i < array_length(escort_num); i++) { + for (var i = 0; i < array_length(escort_num); i++) { if (escort_num[i] < _ship_count) { array_push(all_ships, escort_num[i]); } @@ -494,17 +480,15 @@ function fleet_full_ship_array(fleet = "none", exclude_capitals = false, exclude function set_fleet_location(location) { var fleet_ships = fleet_full_ship_array(); - var temp; for (var i = 0; i < array_length(fleet_ships); i++) { - temp = fleet_ships[i]; + var temp = fleet_ships[i]; if (temp >= 0 && temp < array_length(obj_ini.ship_location)) { obj_ini.ship_location[temp] = location; } } - var unit; for (var co = 0; co <= obj_ini.companies; co++) { - for (i = 0; i < array_length(obj_ini.name[co]); i++) { - unit = fetch_unit([co, i]); + for (var i = 0; i < array_length(obj_ini.name[co]); i++) { + var unit = fetch_unit([co, i]); if (array_contains(fleet_ships, unit.ship_location)) { unit.location_string = location; } @@ -513,20 +497,22 @@ function set_fleet_location(location) { } function selected_ship_types() { - var capitals = 0, frigates = 0, escorts = 0, i; - for (i = 0; i < array_length(capital); i++) { + var capitals = false; + var frigates = false; + var escorts = false; + for (var i = 0; i < array_length(capital); i++) { if (capital[i] != "" && capital_sel[i]) { capitals = true; break; } } - for (i = 0; i < array_length(frigate); i++) { + for (var i = 0; i < array_length(frigate); i++) { if (frigate[i] != "" && frigate_sel[i]) { frigates = true; break; } } - for (i = 0; i < array_length(escort); i++) { + for (var i = 0; i < array_length(escort); i++) { if (escort[i] != "" && escort_sel[i]) { escorts = true; break; @@ -535,26 +521,26 @@ function selected_ship_types() { return [capitals, frigates, escorts]; } -function player_fleet_ship_count(fleet = "none") { +function player_fleet_ship_count(fleet = noone) { var ship_count = 0; - if (fleet == "none") { + if (fleet == noone) { capital_number = 0; frigate_number = 0; escort_number = 0; - for (i = 0; i < array_length(capital); i++) { + for (var i = 0; i < array_length(capital); i++) { if (capital[i] != "") { ship_count++; capital_number++; } } - for (i = 0; i < array_length(frigate); i++) { + for (var i = 0; i < array_length(frigate); i++) { if (frigate[i] != "") { ship_count++; frigate_number++; } } - for (i = 0; i < array_length(escort); i++) { + for (var i = 0; i < array_length(escort); i++) { if (escort[i] != "") { ship_count++; escort_number++; @@ -568,20 +554,20 @@ function player_fleet_ship_count(fleet = "none") { return ship_count; } -function player_fleet_selected_count(fleet = "none") { +function player_fleet_selected_count(fleet = noone) { var ship_count = 0; - if (fleet == "none") { - for (i = 0; i < array_length(capital); i++) { + if (fleet == noone) { + for (var i = 0; i < array_length(capital); i++) { if (capital[i] != "" && capital_sel[i]) { ship_count++; } } - for (i = 0; i < array_length(frigate); i++) { + for (var i = 0; i < array_length(frigate); i++) { if (frigate[i] != "" && frigate_sel[i]) { ship_count++; } } - for (i = 0; i < array_length(escort); i++) { + for (var i = 0; i < array_length(escort); i++) { if (escort[i] != "" && escort_sel[i]) { ship_count++; } @@ -595,7 +581,7 @@ function player_fleet_selected_count(fleet = "none") { } function get_nearest_player_fleet(nearest_x, nearest_y, is_static = false, is_moving = false, stop_complex_actions = true) { - var chosen_fleet = "none"; + var chosen_fleet = noone; if (instance_exists(obj_p_fleet)) { with (obj_p_fleet) { var viable = !(is_static && action != ""); @@ -613,7 +599,7 @@ function get_nearest_player_fleet(nearest_x, nearest_y, is_static = false, is_mo continue; } if (point_in_rectangle(x, y, 0, 0, room_width, room_height)) { - if (chosen_fleet == "none") { + if (chosen_fleet == noone) { chosen_fleet = self; } if (point_distance(nearest_x, nearest_y, x, y) < point_distance(nearest_x, nearest_y, chosen_fleet.x, chosen_fleet.y)) { diff --git a/scripts/scr_player_ship_functions/scr_player_ship_functions.gml b/scripts/scr_player_ship_functions/scr_player_ship_functions.gml index 7e34b63ed8..599c6576ac 100644 --- a/scripts/scr_player_ship_functions/scr_player_ship_functions.gml +++ b/scripts/scr_player_ship_functions/scr_player_ship_functions.gml @@ -9,7 +9,7 @@ function return_lost_ships_chance() { function return_lost_ship() { var _return_id = get_valid_player_ship("Lost"); if (_return_id != -1) { - var _lost_fleet = "none"; + var _lost_fleet = noone; with (obj_p_fleet) { if (action == "Lost") { _lost_fleet = id; @@ -19,7 +19,7 @@ function return_lost_ship() { var _star = instance_find(obj_star, irandom(instance_number(obj_star) - 1)); _new_fleet = instance_create(_star.x, _star.y, obj_p_fleet); _new_fleet.owner = eFACTION.PLAYER; - if (_lost_fleet != "none") { + if (_lost_fleet != noone) { find_and_move_ship_between_fleets(_lost_fleet, _new_fleet, _return_id); if (player_fleet_ship_count(_lost_fleet) == 0) { with (_lost_fleet) { @@ -92,7 +92,7 @@ function return_lost_ship() { //More scenarios needed but this is a good start } scr_popup("Ship Returns", _text, "lost_warp", ""); - if (_lost_fleet != "none") { + if (_lost_fleet != noone) { if (!player_fleet_ship_count(_lost_fleet)) { with (_lost_fleet) { instance_destroy(); @@ -143,6 +143,8 @@ function new_player_ship_defaults() { array_push(ship_carrying, 0); array_push(ship_contents, ""); array_push(ship_turrets, 0); + array_push(ship_guardsmen, 0); + array_push(ship_guardsmen_max, 0); } return array_length(obj_ini.ship) - 1; } @@ -188,14 +190,14 @@ function loose_ship_to_warp_event() { text += $" {marine_count} Battle Brothers were onboard."; } scr_event_log("red", text); - var _lost_ship_fleet = "none"; + var _lost_ship_fleet = noone; with (obj_p_fleet) { if (action == "Lost") { _lost_ship_fleet = id; } } - if (_lost_ship_fleet == "none") { - var _lost_ship_fleet = instance_create(-500, -500, obj_p_fleet); + if (_lost_ship_fleet == noone) { + _lost_ship_fleet = instance_create(-500, -500, obj_p_fleet); _lost_ship_fleet.owner = eFACTION.PLAYER; } @@ -236,7 +238,6 @@ function loose_ship_to_warp_event() { //TODO make method for setting ship weaponry function new_player_ship(type, start_loc = "home", new_name = "") { - var ship_names = "", index = 0; var index = new_player_ship_defaults(); for (var k = 0; k <= 200; k++) { @@ -286,6 +287,8 @@ function new_player_ship(type, start_loc = "home", new_name = "") { obj_ini.ship_wep_facing[index][5] = "most"; obj_ini.ship_wep_condition[index][5] = ""; obj_ini.ship_capacity[index] = 600; + obj_ini.ship_guardsmen_max[index] = 500000; // Battle Barge: Guard auxilia capacity + obj_ini.ship_guardsmen[index] = 0; obj_ini.ship_carrying[index] = 0; obj_ini.ship_contents[index] = ""; obj_ini.ship_turrets[index] = 3; @@ -315,6 +318,8 @@ function new_player_ship(type, start_loc = "home", new_name = "") { obj_ini.ship_wep_facing[index][4] = "most"; obj_ini.ship_wep_condition[index][4] = ""; obj_ini.ship_capacity[index] = 250; + obj_ini.ship_guardsmen_max[index] = 150000; // Strike Cruiser: Guard auxilia capacity + obj_ini.ship_guardsmen[index] = 0; obj_ini.ship_carrying[index] = 0; obj_ini.ship_contents[index] = ""; obj_ini.ship_turrets[index] = 1; @@ -334,6 +339,8 @@ function new_player_ship(type, start_loc = "home", new_name = "") { obj_ini.ship_wep_facing[index][1] = "most"; obj_ini.ship_wep_condition[index][1] = ""; obj_ini.ship_capacity[index] = 30; + obj_ini.ship_guardsmen_max[index] = 0; // Gladius escort: no Guard capacity + obj_ini.ship_guardsmen[index] = 0; obj_ini.ship_carrying[index] = 0; obj_ini.ship_contents[index] = ""; obj_ini.ship_turrets[index] = 1; @@ -356,6 +363,8 @@ function new_player_ship(type, start_loc = "home", new_name = "") { obj_ini.ship_wep_facing[index][2] = "most"; obj_ini.ship_wep_condition[index][2] = ""; obj_ini.ship_capacity[index] = 25; + obj_ini.ship_guardsmen_max[index] = 0; // Hunter escort: no Guard capacity + obj_ini.ship_guardsmen[index] = 0; obj_ini.ship_carrying[index] = 0; obj_ini.ship_contents[index] = ""; obj_ini.ship_turrets[index] = 1; @@ -391,6 +400,8 @@ function new_player_ship(type, start_loc = "home", new_name = "") { obj_ini.ship_wep_facing[index][5] = "most"; obj_ini.ship_wep_condition[index][5] = ""; obj_ini.ship_capacity[index] = 800; + obj_ini.ship_guardsmen_max[index] = 1000000; // Gloriana: Guard auxilia capacity + obj_ini.ship_guardsmen[index] = 0; obj_ini.ship_carrying[index] = 0; obj_ini.ship_contents[index] = ""; obj_ini.ship_turrets[index] = 8; @@ -455,3 +466,156 @@ function ship_bombard_score(ship_id) { return _bomb_score; } + +// ===================================================================== +// Imperial Guard Auxilia - player embark / deploy / raise +// Added by mod. Uses the same p_guardsmen planetary force the Imperial +// Navy uses, so deployed Guard plug straight into the ground-war AI. +// ===================================================================== + +/// @description Pad the parallel Guard arrays out to ship[] length so that indexing +/// ship_guardsmen[i] by a ship index is always safe. ship_guardsmen starts +/// empty and only grows as ships are added during play, so a loaded save +/// (especially one predating these arrays) can restore ship[] while leaving +/// ship_guardsmen shorter or empty. Without this, reading ship_guardsmen[i] +/// for a real ship throws "index out of range". +function ensure_ship_guardsmen_arrays() { + with (obj_ini) { + var _n = array_length(ship); + while (array_length(ship_guardsmen) < _n) { + array_push(ship_guardsmen, 0); + } + while (array_length(ship_guardsmen_max) < _n) { + array_push(ship_guardsmen_max, 0); + } + } +} + +/// @description Total Imperial Guard auxilia currently embarked across all player ships. +/// @returns {real} +function player_guardsmen_embarked() { + var _total = 0; + with (obj_ini) { + for (var i = 0; i < array_length(ship_guardsmen); i++) { + _total += ship_guardsmen[i]; + } + } + return _total; +} + +/// @description Embark Guard from a world you own onto your ships in that system. +/// Pulls from the planet garrison (p_guardsmen) and fills each ship up +/// to its ship_guardsmen_max. Returns the number actually loaded. +/// @param {string} system_name Star system name (e.g. obj_ini.home_name) +/// @param {real} planet Planet index in that system (e.g. obj_ini.home_planet) +/// @returns {real} +function embark_guardsmen(system_name, planet) { + var _star = find_star_by_name(system_name); + if (_star == "none") { + return 0; + } + if (_star.p_owner[planet] != eFACTION.PLAYER) { + return 0; // only from worlds you control + } + + var _pdata = new PlanetData(planet, _star); + var _available = _pdata.guardsmen; + if (_available <= 0) { + return 0; // nothing garrisoned to pick up + } + + var _loaded = 0; + ensure_ship_guardsmen_arrays(); + with (obj_ini) { + for (var i = 0; i < array_length(ship); i++) { + if (ship[i] == "") continue; // empty roster slot + if (ship_location[i] != system_name) continue; // ship must be here + var _space = ship_guardsmen_max[i] - ship_guardsmen[i]; + if (_space <= 0) continue; // no hull room (escorts = 0) + var _take = min(_space, _available - _loaded); + if (_take <= 0) break; + ship_guardsmen[i] += _take; + _loaded += _take; + if (_loaded >= _available) break; + } + } + + _pdata.edit_guardsmen(-_loaded); // remove what we embarked from the planet + return _loaded; +} + +/// @description Deploy all embarked Guard from your ships in a system onto a planet. +/// Adds them to p_guardsmen so the ground-war AI fields them. +/// @param {string} system_name Star system the fleet is in +/// @param {real} planet Planet index to garrison +/// @returns {real} +function deploy_guardsmen(system_name, planet) { + var _star = find_star_by_name(system_name); + if (_star == "none") { + return 0; + } + + var _unloaded = 0; + ensure_ship_guardsmen_arrays(); + with (obj_ini) { + for (var i = 0; i < array_length(ship); i++) { + if (ship[i] == "") continue; + if (ship_location[i] != system_name) continue; + if (ship_guardsmen[i] <= 0) continue; + _unloaded += ship_guardsmen[i]; + ship_guardsmen[i] = 0; + } + } + if (_unloaded <= 0) { + return 0; + } + + var _pdata = new PlanetData(planet, _star); + _pdata.edit_guardsmen(_unloaded); + return _unloaded; +} + +/// @description OPTIONAL: raise fresh Guard from a controlled world's population, +/// adding them to that world's garrison so you can then embark them. +/// Mirrors the Imperial Navy recruit idiom, so it is safe on both +/// "small" and "large" population worlds. +/// @param {string} system_name +/// @param {real} planet +/// @param {real} amount headcount of Guard to raise +/// @returns {real} +function tithe_guardsmen(system_name, planet, amount) { + var _star = find_star_by_name(system_name); + if (_star == "none") { + return 0; + } + if (_star.p_owner[planet] != eFACTION.PLAYER) { + return 0; + } + + var _pdata = new PlanetData(planet, _star); + var _headcount = _pdata.population_as_small(); + if (_headcount <= 0) { + return 0; + } + + amount = min(amount, _headcount); + _pdata.edit_population(-_pdata.population_large_conversion(amount)); + _pdata.edit_guardsmen(amount); + return amount; +} + +/// @description Total embarked Guard on player ships currently at a given system. +/// @param {string} system_name +/// @returns {real} +function player_guardsmen_at(system_name) { + ensure_ship_guardsmen_arrays(); + var _total = 0; + with (obj_ini) { + for (var i = 0; i < array_length(ship); i++) { + if (ship[i] == "") continue; + if (ship_location[i] != system_name) continue; + _total += ship_guardsmen[i]; + } + } + return _total; +} diff --git a/scripts/scr_population_influence/scr_population_influence.gml b/scripts/scr_population_influence/scr_population_influence.gml index 0d92015a40..8df7598b6e 100644 --- a/scripts/scr_population_influence/scr_population_influence.gml +++ b/scripts/scr_population_influence/scr_population_influence.gml @@ -1,7 +1,5 @@ -// Script assets have changed for v2.3.0 see -// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information -function adjust_influence(faction, value, planet, star = "none") { - if (star == "none") { +function adjust_influence(faction, value, planet, star) { + with (star) { p_influence[planet][faction] += value; var total_influence = array_sum(p_influence[planet]); var loop = 0; @@ -27,10 +25,6 @@ function adjust_influence(faction, value, planet, star = "none") { } } } - } else { - with (star) { - adjust_influence(faction, value, planet); - } } } @@ -39,6 +33,6 @@ function merge_influences(doner_influence, planet) { if (i == 2) { continue; } - adjust_influence(i, (p_influence[planet][i] + doner_influence[i] / 2), planet); + adjust_influence(i, (p_influence[planet][i] + doner_influence[i] / 2), planet, self); } } diff --git a/scripts/scr_popup_functions/scr_popup_functions.gml b/scripts/scr_popup_functions/scr_popup_functions.gml index 1251954c72..6fa2266ffc 100644 --- a/scripts/scr_popup_functions/scr_popup_functions.gml +++ b/scripts/scr_popup_functions/scr_popup_functions.gml @@ -152,10 +152,9 @@ function replace_options(option, if_empty = false, use_default_option = true) { function evaluate_popup_option(opt) { var _allow = true; + var _requirements = {}; if (struct_exists(opt, "requires")) { - var _requirements = opt.requires; - } else { - return true; + _requirements = opt.requires; } if (struct_exists(_requirements, "req")) { @@ -202,7 +201,7 @@ function draw_popup_options() { _opt_string = _opt.str1; } - var _opt_string = $"{i + 1}. {_opt_string}"; + _opt_string = $"{i + 1}. {_opt_string}"; var _string_x = x1 + 25.5; var _string_y = y1 + 20 + sz; @@ -258,7 +257,7 @@ function draw_popup_options() { /// @self Asset.GMObject.obj_popup function calculate_equipment_needs() { - var i = 0, rall = "", all_good = 0; + var all_good = 0; req_armour = ""; req_armour_num = 0; @@ -276,11 +275,8 @@ function calculate_equipment_needs() { req_wep2_num = 0; have_wep2_num = 0; - rall = role_name[target_role]; + var rall = role_name[target_role]; - /*if (rall=obj_ini.role[100][14]) and (global.chapter_name!="Space Wolves") and (global.chapter_name!="Iron Hands"){ - req_armour="";req_armour_num=0;req_wep1="";req_wep1_num=0;req_wep2="";req_wep2_num=0;req_mobi="";req_mobi_num=0; - }*/ if (rall == "Codiciery") { req_armour = ""; req_armour_num = 0; @@ -380,19 +376,17 @@ function calculate_equipment_needs() { } } } - - // if (n_wep1=n_wep2) and ((o_wep1!=n_wep1) or (o_wep2!=n_wep2)){have_wep1_num-=1;have_wep2_num-=1;} } // End Repeat // This checks to see if there is any more in the armoury if (req_armour == STR_ANY_POWER_ARMOUR) { var _armour_list = global.list_basic_power_armour; - for (i = 0; i < array_length(_armour_list); i++) { + for (var i = 0; i < array_length(_armour_list); i++) { have_armour_num += scr_item_count(_armour_list[i]); } } else if (req_armour == STR_ANY_TERMINATOR_ARMOUR) { var _armour_list = global.list_terminator_armour; - for (i = 0; i < array_length(_armour_list); i++) { + for (var i = 0; i < array_length(_armour_list); i++) { have_armour_num += scr_item_count(_armour_list[i]); } } else if (req_armour == "Dreadnought") { @@ -584,7 +578,7 @@ function allow_governor_successor() { _text_last = "Regrettably he has a dim view of your chapter"; } if (randa >= 95) { - _newdisp = max(p_data.player_disposition, 60 + choose(1, 2, 3, 4, 5, 6) * 3); + var _newdisp = max(p_data.player_disposition, 60 + choose(1, 2, 3, 4, 5, 6) * 3); p_data.set_player_disposition(_newdisp); _text_last = "Fortunately you already have good relations with the new governor"; } diff --git a/scripts/scr_post_battle_events/scr_post_battle_events.gml b/scripts/scr_post_battle_events/scr_post_battle_events.gml index 323d35bb89..0ca3342f3d 100644 --- a/scripts/scr_post_battle_events/scr_post_battle_events.gml +++ b/scripts/scr_post_battle_events/scr_post_battle_events.gml @@ -30,7 +30,7 @@ function necron_tomb_raid_post_battle_sequence() { } var _star_obj = find_star_by_name(battle_loc); - if (_star_obj != "none") { + if (_star_obj != noone) { with (_star_obj) { var planet = obj_ncombat.battle_id; if (remove_planet_problem(planet, "necron")) { @@ -150,4 +150,120 @@ function space_hulk_explore_battle_aftermath() { pop.text = "The fallen heretics wore several suits of Terminator Armour- a handful of them were found to be cleansible and worthy of use. " + string(termi) + " Terminator Armour has been added to the Armamentarium."; } } + + // Hulk fully cleared this battle: offer the salvage choice. The hulk is removed from the map + // by whichever option the player picks (space_hulk_strip / space_hulk_surrender). + if (!defeat && hulk_cleared) { + var _shi = 0, _loc = ""; + var _shiyp = instance_nearest(battle_object.x, battle_object.y, obj_p_fleet); + if (_shiyp.x == battle_object.x && _shiyp.y == battle_object.y) { + _shi = fleet_full_ship_array(_shiyp)[0]; + _loc = obj_ini.ship[_shi]; + } + + var pop = instance_create(0, 0, obj_popup); + pop.image = "space_hulk_done"; + pop.title = "Space Hulk Cleared"; + pop.text = "The last of the hulk's defenders are purged and the drifting wreck falls silent. It is yours to dispose of. Strip it for the Chapter, or tow it to the nearest Forge World for the Adeptus Mechanicus?"; + pop.hulk_star = battle_object; + pop.hulk_loot_ship = _shi; + pop.hulk_loot_loc = _loc; + with (pop) { + replace_options([ + { str1: "Strip it for the Chapter", choice_func: space_hulk_strip }, + { str1: "Tow it to the nearest Forge World", choice_func: space_hulk_surrender } + ]); + } + } +} + +/// @description Salvage choice: strip a cleared space hulk for the Chapter. Runs in obj_popup scope. +/// Raises Inquisitorial suspicion and angers the Mechanicus, but yields requisition and a relic +/// that carries the normal chance of chaos/daemonic taint. Removes the hulk from the map. +function space_hulk_strip() { + // --- Penalties (tunable) --- + // Inquisition takes note; the Mechanicus consider the claim theft from the Omnissiah. + obj_ini.chapter_data.chapter_suspicion = clamp(obj_ini.chapter_data.chapter_suspicion + 1, -5, 5); + obj_controller.disposition[eFACTION.MECHANICUS] = clamp(obj_controller.disposition[eFACTION.MECHANICUS] - 12, 0, 100); + // The uncancellable cost of hoarding forbidden discoveries: Chapter standing drops a tier + // (100 -> 75 leaves the >=85 "Loyal" band). Both visible and hidden loyalty fall, the same + // idiom the existing crime penalties use, so it persists through Inquisition inspections. + // Gifting any recovered STC to the Mechanicus can repair their disposition, never this. + var _loyalty_hit = 25; + obj_controller.loyalty = clamp(obj_controller.loyalty - _loyalty_hit, 0, 100); + obj_controller.loyalty_hidden = clamp(obj_controller.loyalty_hidden - _loyalty_hit, 0, 100); + + // --- Rewards (tunable) --- + var _reqi = irandom_range(80, 120) * 10; // ~1000 Requisition + obj_controller.requisition += _reqi; + + // 1-3 relics, most carrying chaos/daemonic taint. ~65% are forced daemonic; the rest still + // roll the normal ~30% taint chance, so the overall haul is dangerous more often than not. + var _arts = irandom_range(1, 3); + for (var _a = 0; _a < _arts; _a++) { + var _art_tags = (random(1) < 0.65) ? "daemonic" : "random"; + scr_add_artifact("random", _art_tags, 4, hulk_loot_loc, hulk_loot_ship + 500); + } + + // Rare STC fragment in the haul. Kept low on purpose: a guaranteed STC would let the player + // gift it back to the Mechanicus and buy back the disposition they just lost (the loyalty + // hit above is what they can never undo). + var _found_stc = (random(1) < 0.20); + if (_found_stc) { + scr_add_stc_fragment(); + } + + if (instance_exists(hulk_star)) { + with (hulk_star) { + instance_destroy(); + } + } + if (instance_exists(obj_star_select)) { + with (obj_star_select) { + instance_destroy(); + } + } + obj_controller.sel_system_x = 0; + obj_controller.sel_system_y = 0; + + image = "space_hulk_done"; + title = "Space Hulk Stripped"; + var _stc_line = _found_stc ? " An intact STC fragment is prised from the wreck and spirited away." : ""; + text = $"Your Chapter strips the hulk for itself. {_arts} relic(s) and {_reqi} Requisition worth of archeotech are hauled aboard.{_stc_line} The unsanctioned claim will not go unnoticed: the Adeptus Mechanicus consider it theft from the Omnissiah, the Inquisition's gaze lingers, and the Chapter's standing suffers for hoarding forbidden discoveries."; + reset_popup_options(); + cooldown = 20; +} + +/// @description Salvage choice: tow a cleared space hulk to the nearest Forge World. Runs in +/// obj_popup scope. The sanctioned, expected course: the Mechanicus are grateful and send a +/// token of thanks. Removes the hulk from the map. +function space_hulk_surrender() { + // --- Rewards (tunable): the payoff here is Mechanicus favour, not loot. --- + obj_controller.disposition[eFACTION.MECHANICUS] = clamp(obj_controller.disposition[eFACTION.MECHANICUS] + 12, 0, 100); + + var _reqi = irandom_range(8, 12) * 10; // ~100 Requisition, a token of thanks + obj_controller.requisition += _reqi; + + // A single minor, untainted relic of the sort the Mechanicus part with in trade. No major + // relic wargear here: the Mechanicus are stingy and keep their best for themselves. + scr_add_artifact("random_nodemon", "minor", 4, hulk_loot_loc, hulk_loot_ship + 500); + + if (instance_exists(hulk_star)) { + with (hulk_star) { + instance_destroy(); + } + } + if (instance_exists(obj_star_select)) { + with (obj_star_select) { + instance_destroy(); + } + } + obj_controller.sel_system_x = 0; + obj_controller.sel_system_y = 0; + + image = "space_hulk_done"; + title = "Space Hulk Surrendered"; + text = $"The hulk is towed to the nearest Forge World for the Adeptus Mechanicus to pick apart at their leisure. They receive it gratefully, their disposition toward your Chapter warms, and they send a token of thanks worth {_reqi} Requisition along with a minor relic from their archives."; + reset_popup_options(); + cooldown = 20; } diff --git a/scripts/scr_powers/scr_powers.gml b/scripts/scr_powers/scr_powers.gml index 3185b2f11b..65268acada 100644 --- a/scripts/scr_powers/scr_powers.gml +++ b/scripts/scr_powers/scr_powers.gml @@ -5,7 +5,7 @@ global.psy_disciplines_starting = [ "biomancy", "pyromancy", "telekinesis", - "rune_magic" + "rune_magic", ]; #macro PSY_PERILS_CHANCE_MIN 1 @@ -58,8 +58,11 @@ function generate_marine_powers_description_string(unit) { /// @desc Psychic powers execution mess. Called in the scope of obj_pnunit. /// @param {real} caster_id - ID of the caster in the player column from obj_pnunit. +/// @param {Struct} [_psy_log] - Per-formation accumulator for attack casts. When provided, ordinary +/// attack casts fold into a per-power summary (see flush_psychic_summary) instead of logging +/// one line each. Leader kills, failed casts and Perils still log individually. /// @self Asset.GMObject.obj_pnunit -function scr_powers(caster_id) { +function scr_powers(caster_id, _psy_log = undefined) { // Gather unit data /// @type {Struct.TTRPG_stats} var _unit = unit_struct[caster_id]; @@ -297,18 +300,19 @@ function scr_powers(caster_id) { compress_enemy_array(_target_data.column); destroy_empty_column(_target_data.column); - // Log battle message to combat feed - _battle_log_message = _cast_flavour_text + _power_flavour_text + _casualties_flavour_text; - if (_casualties == 0) { - _battle_log_priority = _final_damage / 50; // Just to have some priority here, as they don't have the usual "shots fired" + // Battle log: the enemy leader dying always earns its own callout; every other + // attack cast folds into a per-power summary emitted at the end of the casting + // phase (flush_psychic_summary), so a wall of Librarians becomes one line. + // (We're always inside the _casualties > 0 branch here.) + _battle_log_priority = _target_is_vehicle ? (_casualties * 12) : (_casualties * 3); + var _is_leader = (obj_ncombat.enemy <= 10) && (_target_unit_name == obj_controller.faction_leader[obj_ncombat.enemy]); + + if (is_struct(_psy_log) && !_is_leader) { + accumulate_psychic_cast(_psy_log, _power_name, _power_flavour_text, _target_unit_name, _destruction_verb, _target_is_vehicle, _casualties); } else { - if (_target_is_vehicle) { - _battle_log_priority = _casualties * 12; // Vehicles are more juicy - } else { - _battle_log_priority = _casualties * 3; // More casualties = higher priority messages - } + _battle_log_message = _cast_flavour_text + _power_flavour_text + _casualties_flavour_text; + add_battle_log_message(_battle_log_message, _battle_log_priority, 134); } - add_battle_log_message(_battle_log_message, _battle_log_priority, 134); } } } @@ -332,19 +336,61 @@ function scr_powers(caster_id) { display_battle_log_message(); } +/// @desc Folds one attack-power cast into the per-formation psychic summary, keyed by power + target, +/// so many identical Librarian casts collapse into a single battle-log line. +/// @param {Struct} _psy_log The accumulator struct (one per formation casting phase). +function accumulate_psychic_cast(_psy_log, _power_name, _power_flavour, _target_name, _verb, _is_vehicle, _kills) { + var _key = _power_name + "|" + _target_name; + if (!variable_struct_exists(_psy_log, _key)) { + _psy_log[$ _key] = { + power: _power_name, + flavour: _power_flavour, + target: _target_name, + verb: _verb, + vehicle: _is_vehicle, + casts: 0, + kills: 0, + }; + } + var _entry = _psy_log[$ _key]; + _entry.casts += 1; + _entry.kills += _kills; +} + +/// @desc Emits one battle-log line per power+target accumulated during a formation's casting phase. +/// Mirrors scr_powers' own concatenation so spacing matches the individual-cast lines. +/// @param {Struct} _psy_log The accumulator filled by accumulate_psychic_cast. +function flush_psychic_summary(_psy_log) { + if (!is_struct(_psy_log)) { + return; + } + var _keys = variable_struct_get_names(_psy_log); + for (var i = 0; i < array_length(_keys); i++) { + var _e = _psy_log[$ _keys[i]]; + var _cast_word = (_e.casts == 1) ? "casting" : "castings"; + var _message = $"{_e.casts} {_cast_word} of '{_e.power}'{_e.flavour} {_e.kills} {_e.target} are {_e.verb}."; + var _size = _e.vehicle ? (_e.kills * 12) : (_e.kills * 3); + add_battle_log_message(_message, _size, 134); + } + if (array_length(_keys) > 0) { + display_battle_log_message(); + } +} + /// @desc Function to get requested data from the disciplines_data structure. Returns The requested data, or undefined if not found. /// @param _discipline_name - The name of the discipline /// @param _data_name - The specific data attribute you want function get_discipline_data(_discipline_name, _data_name) { // Check if the power exists in the global.disciplines_data if (struct_exists(global.disciplines_data, _discipline_name)) { + var _data_content = {}; var _discipline_object = global.disciplines_data[$ _discipline_name]; // Check if the data exists for that power if (struct_exists(_discipline_object, _data_name)) { - var _data_content = _discipline_object[$ _data_name]; + _data_content = _discipline_object[$ _data_name]; } else { _discipline_object = global.disciplines_data[$ "example"]; - var _data_content = _discipline_object[$ _data_name]; + _data_content = _discipline_object[$ _data_name]; } return _data_content; } else { @@ -360,16 +406,17 @@ function get_discipline_data(_discipline_name, _data_name) { function get_power_data(_power_id, _data_name = "") { // Check if the power exists in the global.powers_data if (struct_exists(global.powers_data, _power_id)) { + var _data_content = {}; var _power_object = global.powers_data[$ _power_id]; // Check if the data exists for that power if (_data_name == "") { return _power_object; } else if (struct_exists(_power_object, _data_name)) { - var _data_content = _power_object[$ _data_name]; + _data_content = _power_object[$ _data_name]; } else { _power_object = global.powers_data[$ "example"]; - var _data_content = _power_object[$ _data_name]; + _data_content = _power_object[$ _data_name]; } if (_data_name == "flavour_text") { diff --git a/scripts/scr_promote/scr_promote.gml b/scripts/scr_promote/scr_promote.gml index 7f1282b74c..90906d38e4 100644 --- a/scripts/scr_promote/scr_promote.gml +++ b/scripts/scr_promote/scr_promote.gml @@ -25,13 +25,13 @@ function setup_promotion_popup() { units = nuuum; promote_button = new UnitButtonObject({x1: 1450, y1: 491, style: "pixel", label: "Promote"}); promote_button.bind_method = function() { - var mahreens = 0, i = -1; + var mahreens = 0; if (target_comp > 10) { target_comp = 0; } - for (i = 0; i < 498; i++) { + for (var i = 0; i < 498; i++) { if (obj_ini.name[target_comp][i] == "" && obj_ini.name[target_comp][i + 1] == "") { mahreens = i; break; @@ -47,7 +47,7 @@ function setup_promotion_popup() { variable_struct_set(role_squad_equivilances, obj_ini.role[100][3], "veteran_squad"); variable_struct_set(role_squad_equivilances, obj_ini.role[100][4], "terminator_squad"); - for (i = 0; i < array_length(obj_controller.display_unit) && mahreens < 500; i++) { + for (var i = 0; i < array_length(obj_controller.display_unit) && mahreens < 500; i++) { if ((obj_controller.man[i] == "man") && (obj_controller.man_sel[i] == 1) && (obj_controller.ma_exp[i] >= min_exp)) { moveable = true; unit = obj_controller.display_unit[i]; @@ -78,8 +78,8 @@ function setup_promotion_popup() { } //move squad if (moveable) { - var mem_unit; - for (var mem = 0; mem < array_length(move_members); mem++) { + var mem; + for (mem = 0; mem < array_length(move_members); mem++) { var mem_unit = fetch_unit(move_members[mem]); if (mem_unit.company != target_comp) { scr_move_unit_info(mem_unit.company, target_comp, mem_unit.marine_number, mahreens, false); @@ -210,13 +210,12 @@ function draw_popup_promotion() { target_role = 0; get_unit_promotion_options(); } - // } draw_set_halign(fa_left); draw_text(1020, 290, "Target Role:"); //choose new role var role_x = 0; role_y = 0; if (target_comp != -1) { - for (var r = 1; r <= 11; r++) { + for (var r = 1; r < array_length(role_name); r++) { if (role_name[r] != "") { draw_set_alpha(1); check = " "; diff --git a/scripts/scr_purge_world/scr_purge_world.gml b/scripts/scr_purge_world/scr_purge_world.gml index 12ee94c3d8..3278143439 100644 --- a/scripts/scr_purge_world/scr_purge_world.gml +++ b/scripts/scr_purge_world/scr_purge_world.gml @@ -1,259 +1,242 @@ +function PlayerPurge(action_type, action_score, planet_data) constructor { + pop_before = 0; + max_kill = 0; + pop_after = 0; + overkill = 0; + self.planet_data = planet_data; + self.action_type = action_type; + self.action_score = action_score; + population_reduction_percentage = 0; + + heres_after = 0; + heres_before = 0; + + static calculate_max_kills = function() { + switch (action_type) { + case eDROP_TYPE.PURGEBOMBARD: + max_kill = 15000000 * action_score; + if (pop_before > 0) { + overkill = max(pop_before * 0.1, ((heres_before / 200) * pop_before)); + } + break; + case eDROP_TYPE.PURGEFIRE: + max_kill = 12000 * action_score; + if (pop_before > 0) { + overkill = max(pop_before * 0.1, ((heres_before / 200) * pop_before)); + } + break; + case eDROP_TYPE.PURGESELECTIVE: + max_kill = action_score * 30; + break; + } + kill = min(max_kill, pop_before); + + if (overkill > 0) { + kill = min(kill, overkill); + } + }; + + calculate_influence_reduction = function() { + switch (action_type) { + case eDROP_TYPE.PURGEBOMBARD: + if (population_reduction_percentage > 0) { + influence_reduction = min((population_reduction_percentage * 2), action_score * 2); // How much hurresy to get rid of + } + break; + case eDROP_TYPE.PURGEFIRE: + influence_reduction = min((population_reduction_percentage * 2), round(action_score / 25)); + break; + case eDROP_TYPE.PURGESELECTIVE: + influence_reduction = round(action_score / 50); + break; + } + influence_reduction = min(influence_reduction, heres_before); + }; + + static calculate_deaths = function() { + calculate_max_kills(); + + pop_after = pop_before - kill; + + population_reduction_percentage = (pop_after / pop_before) * 100; // Relative % of people murderized -function PlayerPurge(action_type, action_score, planet_data) constructor{ - pop_before = 0; - max_kill = 0; - pop_after = 0; - overkill = 0; - self.planet_data = planet_data; - self.action_type = action_type; - self.action_score = action_score; - population_reduction_percentage = 0; - - heres_after = 0; - heres_before = 0; - - - static calculate_max_kills = function(){ - switch (action_type){ - case eDROP_TYPE.PURGEBOMBARD: - max_kill = 15000000 * action_score; - if (pop_before > 0){ - overkill = max(pop_before * 0.1, ((heres_before / 200) * pop_before)); - } - break; - case eDROP_TYPE.PURGEFIRE: - max_kill = 12000 * action_score; - if (pop_before > 0){ - overkill = max(pop_before * 0.1, ((heres_before / 200) * pop_before)); - } - break; - case eDROP_TYPE.PURGESELECTIVE: - max_kill=action_score * 30; - break; - } - kill=min(max_kill, pop_before); - - if (overkill > 0){ - kill=min(kill, overkill); - } - } - - calculate_influence_reduction = function(){ - switch (action_type){ - case eDROP_TYPE.PURGEBOMBARD: - if (population_reduction_percentage>0){ - influence_reduction=min((population_reduction_percentage*2), action_score*2);// How much hurresy to get rid of - } - break; - case eDROP_TYPE.PURGEFIRE: - influence_reduction = min((population_reduction_percentage * 2), round(action_score / 25)); - break; - case eDROP_TYPE.PURGESELECTIVE: - influence_reduction = round(action_score / 50); - break; - } - influence_reduction = min(influence_reduction, heres_before); - } - - static calculate_deaths = function(){ - - - calculate_max_kills(); - - pop_after = (pop_before - kill); - - population_reduction_percentage = (pop_after/pop_before)*100;// Relative % of people murderized - - - calculate_influence_reduction(); - - heres_after = max(heres_before - influence_reduction, 0); - } - - static population_death_string = function(){ - var _death_string = "\n\nThe planet had a population of " - if (!planet_data.large_population){ - _death_string += $"{scr_display_number(floor(pop_before))} and {scr_display_number(floor(kill))}"; + calculate_influence_reduction(); + + heres_after = max(heres_before - influence_reduction, 0); + }; + + static population_death_string = function() { + var _death_string = "\n\nThe planet had a population of "; + if (!planet_data.large_population) { + _death_string += $"{scr_display_number(floor(pop_before))} and {scr_display_number(floor(kill))}"; } else { - _death_string += $"{pop_before / LARGE_PLANET_MOD} billion and {scr_display_number(kill)}"; + _death_string += $"{pop_before / LARGE_PLANET_MOD} billion and {scr_display_number(kill)}"; } - switch (action_type){ - case eDROP_TYPE.PURGEBOMBARD: - _death_string += "were purged over the duration of the bombardment."; - break; - case eDROP_TYPE.PURGEFIRE: - _death_string += " over the duration of the cleansing." - break; - case eDROP_TYPE.PURGESELECTIVE: - _death_string += " over the duration of the search."; - break; - } + switch (action_type) { + case eDROP_TYPE.PURGEBOMBARD: + _death_string += "were purged over the duration of the bombardment."; + break; + case eDROP_TYPE.PURGEFIRE: + _death_string += " over the duration of the cleansing."; + break; + case eDROP_TYPE.PURGESELECTIVE: + _death_string += " over the duration of the search."; + break; + } _death_string += " were purged"; - switch(heres_target){ - case "corruption": - _death_string += $"\n\nHeresy has fallen to {heres_after}%."; - break; - case "tau": - _death_string += $"\n\Tau influence is now effecting {heres_after}% of the population."; - break; - case "genestealers": - _death_string += $"\n\Genestealer influence is now effecting {heres_after}% of the population."; - break; - } + switch (heres_target) { + case "corruption": + _death_string += $"\n\nHeresy has fallen to {heres_after}%."; + break; + case "tau": + _death_string += $"\n\Tau influence is now effecting {heres_after}% of the population."; + break; + case "genestealers": + _death_string += $"\n\Genestealer influence is now effecting {heres_after}% of the population."; + break; + } return _death_string; - } - - static bombard_repercussions = function(){ - var _type = planet_data.planet_type; - - if (pop_after <=0 ){ - if (planet_data.current_owner == eFACTION.IMPERIUM && planet_data.owner_status() != "War"){ - if (_type == "Temperate" || _type == "Hive" || _type == "Desert"){ - var _disp_hit = -10; - if (_type = "Temperate"){ - _disp_hit = -5; - } - if (_type="Desert"){ - _disp_hit = -3; - } - scr_audience(eFACTION.IMPERIUM, "bombard_angry", _disp_hit, "", 0, 0); - } - } - } - if (planet_data.current_owner == eFACTION.MECHANICUS && planet_data.owner_status() != "War"){ - - if (_type="Forge"){ - _disp_hit =-15; - } - if (_type="Ice"){ - _disp_hit =-7; - } - scr_audience(eFACTION.INQUISITION, "bombard_angry", _disp_hit, "", 0, 0); - - } - } + }; + + static bombard_repercussions = function() { + var _type = planet_data.planet_type; + + if (pop_after <= 0) { + if (planet_data.current_owner == eFACTION.IMPERIUM && planet_data.owner_status() != "War") { + if (_type == "Temperate" || _type == "Hive" || _type == "Desert") { + var _disp_hit = -10; + if (_type == "Temperate") { + _disp_hit = -5; + } + if (_type == "Desert") { + _disp_hit = -3; + } + scr_audience(eFACTION.IMPERIUM, "bombard_angry", _disp_hit, "", 0, 0); + } + } + } + if (planet_data.current_owner == eFACTION.MECHANICUS && planet_data.owner_status() != "War") { + var _disp_hit = 0; + if (_type == "Forge") { + _disp_hit = -15; + } + if (_type == "Ice") { + _disp_hit = -7; + } + scr_audience(eFACTION.INQUISITION, "bombard_angry", _disp_hit, "", 0, 0); + } + }; } function scr_purge_world(action_type, action_score) { + var _purge = new PlayerPurge(action_type, action_score, self); - var _purge = new PlayerPurge(action_type, action_score, self); - - var _isquest=0,_thequest="",_questnum=0; - - - _purge.pop_before = population_as_small(); - - _purge.heres_before = max(total_corruption(), population_influences[eFACTION.TAU],population_influences[eFACTION.TYRANIDS]);// Starting heresy - - - if (action_type != eDROP_TYPE.PURGEASSASSINATE){ - _purge.calculate_deaths(); - } - var _heres_target = "corruption"; - - if (max(population_influences[eFACTION.TAU],population_influences[eFACTION.TYRANIDS]) > total_corruption()){ - if (population_influences[eFACTION.TAU] > population_influences[eFACTION.TYRANIDS]){ - _heres_target = "tau"; - } else{ - _heres_target = "genestealers"; - } - - } - - _purge.heres_target = _heres_target; - - - var _no_chaos = (planet_forces[eFACTION.HERETICS] + planet_forces[eFACTION.CHAOS]) == 0; - if ((action_type==eDROP_TYPE.PURGEFIRE || action_type==eDROP_TYPE.PURGESELECTIVE) && _no_chaos && obj_controller.turn>=obj_controller.chaos_turn){ - if (has_feature(eP_FEATURES.WARLORD10) && obj_controller.known[10]=0 && obj_controller.faction_gender[10]=1){ - with(obj_drop_select){ - var pop=instance_create(0,0,obj_popup); - pop.image="chaos_symbol"; - pop.title="Concealed Heresy"; - pop.text=$"Your astartes set out and begin to cleanse {name()} of possible heresy. The general populace appears to be devout in their faith, but a disturbing trend appears- the odd citizen cursing your forces, frothing at the mouth, and screaming out heresy most foul. One week into the cleansing a large hostile force is detected approaching and encircling your forces."; - exit; - } - } - if (has_feature(eP_FEATURES.WARLORD10) && obj_controller.known[10]>=2 && obj_controller.faction_gender[10]=1){ - with(obj_drop_select){ - - attacking=10; - obj_controller.cooldown=30; - combating=1;// Start battle here - - instance_deactivate_all(true); - instance_activate_object(obj_controller); - instance_activate_object(obj_ini); - instance_activate_object(obj_drop_select); - - instance_create(0,0,obj_ncombat); - obj_ncombat.battle_object=p_target; - obj_ncombat.battle_loc=p_target.name; - obj_ncombat.battle_id=obj_controller.selecting_planet; - obj_ncombat.dropping=0; - obj_ncombat.attacking=10; - obj_ncombat.enemy=10; - obj_ncombat.formation_set=1; - - obj_ncombat.leader=1; - obj_ncombat.threat=5; - obj_ncombat.battle_special="WL10_later"; - scr_battle_allies(); - setup_battle_formations(); - roster.add_to_battle(); - } - } - } - - - // TODO - while I don't expect Surface to Orbit weapons retaliating against player's purge bombardment, it might still be worthwhile to consider possible situations - - if (action_type=eDROP_TYPE.PURGEBOMBARD){// Bombardment - var _ship = string_plural("ship", obj_drop_select.ships_selected); - _popup_text=choose($"Your cruiser and larger {_ship}", $"The heavens rumble and thunder as your {_ship}"); - _popup_text+=choose(" position themselves over the target in close orbit, and unleash", " unload"); - var _adjective = choose("tearing ground", "hammering", "battering", "thundering"); - _popup_text+= $" annihilation upon {name()}. Even from space the explosions can be seen, {_adjective} across the planet's surface."; - - _purge.bombard_repercussions(); - } - - - if (action_type=eDROP_TYPE.PURGEFIRE){// Burn baby burn - var i=0; - if (has_problem("cleanse")){ - _isquest = true; - _thequest="cleanse"; - _questnum=i; - } - - if (_isquest){ - if (_thequest="cleanse" && action_score>=20){ - remove_problem(_thequest); - - alter_disposition(eFACTION.INQUISITION,obj_controller.demanding ? choose(0,0,1) :1); - - _popup_text="Your marines scour the underhive of {name()}, spraying mutants down with promethium as they go. It takes several days but a sizeable dent is put in their numbers."; - scr_event_log("","Inquisition Mission Completed: The mutants of {name()} have been cleansed by promethium."); - add_disposition(choose(1,2,3)); - } - }else { // TODO add more variation, with planets, features, marine equipment perhaps? - _popup_text=choose( - $"Timing their visits right, Your forces scour {name()} burning down whatever the local heretic communities call their homes. Their screams were quickly extinguished by fire, turning whatever it was before, into ash.", - $"Your forces scour {name()}, burning homes and towns that reek of heresy. The screams and wails of the damned carry through the air." - ); - - - var nid_influence = population_influences[eFACTION.TYRANIDS]; + var _isquest = 0, _thequest = "", _questnum = 0; + + _purge.pop_before = population_as_small(); + + _purge.heres_before = max(total_corruption(), population_influences[eFACTION.TAU], population_influences[eFACTION.TYRANIDS]); // Starting heresy + + if (action_type != eDROP_TYPE.PURGEASSASSINATE) { + _purge.calculate_deaths(); + } + var _heres_target = "corruption"; + + if (max(population_influences[eFACTION.TAU], population_influences[eFACTION.TYRANIDS]) > total_corruption()) { + if (population_influences[eFACTION.TAU] > population_influences[eFACTION.TYRANIDS]) { + _heres_target = "tau"; + } else { + _heres_target = "genestealers"; + } + } + + _purge.heres_target = _heres_target; + + var _no_chaos = (planet_forces[eFACTION.HERETICS] + planet_forces[eFACTION.CHAOS]) == 0; + if ((action_type == eDROP_TYPE.PURGEFIRE || action_type == eDROP_TYPE.PURGESELECTIVE) && _no_chaos && obj_controller.turn >= obj_controller.chaos_turn) { + if (has_feature(eP_FEATURES.WARLORD10) && obj_controller.known[10] == 0 && obj_controller.faction_gender[10] == 1) { + with (obj_drop_select) { + var pop = instance_create(0, 0, obj_popup); + pop.image = "chaos_symbol"; + pop.title = "Concealed Heresy"; + pop.text = $"Your astartes set out and begin to cleanse {name()} of possible heresy. The general populace appears to be devout in their faith, but a disturbing trend appears- the odd citizen cursing your forces, frothing at the mouth, and screaming out heresy most foul. One week into the cleansing a large hostile force is detected approaching and encircling your forces."; + exit; + } + } + if (has_feature(eP_FEATURES.WARLORD10) && obj_controller.known[10] >= 2 && obj_controller.faction_gender[10] == 1) { + with (obj_drop_select) { + attacking = 10; + obj_controller.cooldown = 30; + combating = 1; // Start battle here + + instance_deactivate_all(true); + instance_activate_object(obj_controller); + instance_activate_object(obj_ini); + instance_activate_object(obj_drop_select); + + instance_create(0, 0, obj_ncombat); + obj_ncombat.battle_object = p_target; + obj_ncombat.battle_loc = p_target.name; + obj_ncombat.battle_id = obj_controller.selecting_planet; + obj_ncombat.dropping = 0; + obj_ncombat.attacking = 10; + obj_ncombat.enemy = 10; + obj_ncombat.formation_set = 1; + + obj_ncombat.leader = 1; + obj_ncombat.threat = 5; + obj_ncombat.battle_special = "WL10_later"; + scr_battle_allies(); + setup_battle_formations(); + roster.add_to_battle(); + } + } + } + + // TODO - while I don't expect Surface to Orbit weapons retaliating against player's purge bombardment, it might still be worthwhile to consider possible situations + + if (action_type == eDROP_TYPE.PURGEBOMBARD) { + // Bombardment + var _ship = string_plural("ship", obj_drop_select.ships_selected); + _popup_text = choose($"Your cruiser and larger {_ship}", $"The heavens rumble and thunder as your {_ship}"); + _popup_text += choose(" position themselves over the target in close orbit, and unleash", " unload"); + var _adjective = choose("tearing ground", "hammering", "battering", "thundering"); + _popup_text += $" annihilation upon {name()}. Even from space the explosions can be seen, {_adjective} across the planet's surface."; + + _purge.bombard_repercussions(); + } + + if (action_type == eDROP_TYPE.PURGEFIRE) { + // Burn baby burn + var i = 0; + if (has_problem("cleanse")) { + _isquest = true; + _thequest = "cleanse"; + _questnum = i; + } + + if (_isquest) { + if (_thequest == "cleanse" && action_score >= 20) { + remove_problem(_thequest); + + alter_disposition(eFACTION.INQUISITION, obj_controller.demanding ? choose(0, 0, 1) : 1); + + _popup_text = "Your marines scour the underhive of {name()}, spraying mutants down with promethium as they go. It takes several days but a sizeable dent is put in their numbers."; + scr_event_log("", "Inquisition Mission Completed: The mutants of {name()} have been cleansed by promethium."); + add_disposition(choose(1, 2, 3)); + } + } else { + // TODO add more variation, with planets, features, marine equipment perhaps? + _popup_text = choose($"Timing their visits right, Your forces scour {name()} burning down whatever the local heretic communities call their homes. Their screams were quickly extinguished by fire, turning whatever it was before, into ash.", $"Your forces scour {name()}, burning homes and towns that reek of heresy. The screams and wails of the damned carry through the air."); + + var nid_influence = population_influences[eFACTION.TYRANIDS]; if (has_feature(eP_FEATURES.GENE_STEALER_CULT)) { var cult = get_features(eP_FEATURES.GENE_STEALER_CULT)[0]; - if (cult.hiding) { - - } + if (cult.hiding) {} } else { if (nid_influence > 25) { _popup_text += " Scores of mutant offspring from a genestealer infestation are burnt, while we have damaged their influence over this world, the mutants appear to lack the organisation of a true cult"; @@ -263,86 +246,75 @@ function scr_purge_world(action_type, action_score) { } } - _popup_text += _purge.population_death_string(); - - } - } - - - if (action_type=eDROP_TYPE.PURGESELECTIVE){// Blam! - var i=0; - if (has_problem("purge")){ - _isquest=1; - _thequest="purge"; - _questnum=i; - } - - if (_isquest=1){ - if (_thequest="purge" && action_score>=10){ - remove_problem("purge"); - - alter_disposition(eFACTION.INQUISITION,obj_controller.demanding ? choose(0,0,1) :1); - - _popup_text="Your marines drop fast and hard, blowing through guards and mercenaries with minimal resistance. Before ten minutes have passed all your targets are executed."; - scr_event_log("","Inquisition Mission Completed: The unruly Nobles of {name()} have been purged."); - add_disposition(choose(1,2,3)); - } - } - else if (_isquest=0){ // TODO add more variation, with planets, features, possibly marine equipment - _popup_text = $"Your marines move across {name()}," - _popup_text += choose( - $"searching for high profile targets. Once found, they are dragged outside from their lairs. Their execution would soon follow.", - $"rooting out sources of corruption. Heretics are dragged from their lairs and executed in the streets." - ); - - _popup_text += _purge.population_death_string(); - } - } - - - - if (action_type == eDROP_TYPE.PURGEASSASSINATE){ - assasinate_governor_setup(action_score); - } - - else if (action_type!=eDROP_TYPE.PURGEASSASSINATE){ - if (_isquest=0){// DO EET - var _txt2=_popup_text; - switch(_purge.heres_target){ - case "corruption": - alter_corruption(-_purge.influence_reduction); - break; - case "tau": - alter_influence(eFACTION.TAU , -_purge.influence_reduction); - break; - case "genestealers": - alter_influence(eFACTION.TYRANIDS , -_purge.influence_reduction); - break; - } - - set_population(population_large_conversion(_purge.pop_after)); - - var pip=instance_create(0,0,obj_popup); - pip.title="Purge Results"; - pip.text=_txt2; - } - if (_isquest){// DO EET - var pip=instance_create(0,0,obj_popup); - scr_popup("Inquisition Mission Completed", _popup_text, "inquisition") - // scr_event_log("","Inquisition Mission Completed: The unruly nobles of {name()} have been silenced."); - } - } - - - if instance_exists(obj_drop_select){ - with(obj_drop_select){ - if (instance_exists(sh_target)){ - sh_target.acted=5; - } - instance_destroy(); - } - } + _popup_text += _purge.population_death_string(); + } + } + + if (action_type == eDROP_TYPE.PURGESELECTIVE) { + // Blam! + var i = 0; + if (has_problem("purge")) { + _isquest = 1; + _thequest = "purge"; + _questnum = i; + } + if (_isquest == 1) { + if (_thequest == "purge" && action_score >= 10) { + remove_problem("purge"); -} + alter_disposition(eFACTION.INQUISITION, obj_controller.demanding ? choose(0, 0, 1) : 1); + + _popup_text = "Your marines drop fast and hard, blowing through guards and mercenaries with minimal resistance. Before ten minutes have passed all your targets are executed."; + scr_event_log("", "Inquisition Mission Completed: The unruly Nobles of {name()} have been purged."); + add_disposition(choose(1, 2, 3)); + } + } else if (_isquest == 0) { + // TODO add more variation, with planets, features, possibly marine equipment + _popup_text = $"Your marines move across {name()},"; + _popup_text += choose($"searching for high profile targets. Once found, they are dragged outside from their lairs. Their execution would soon follow.", $"rooting out sources of corruption. Heretics are dragged from their lairs and executed in the streets."); + + _popup_text += _purge.population_death_string(); + } + } + + if (action_type == eDROP_TYPE.PURGEASSASSINATE) { + assasinate_governor_setup(action_score); + } else if (action_type != eDROP_TYPE.PURGEASSASSINATE) { + if (_isquest == 0) { + // DO EET + var _txt2 = _popup_text; + switch (_purge.heres_target) { + case "corruption": + alter_corruption(-_purge.influence_reduction); + break; + case "tau": + alter_influence(eFACTION.TAU, -_purge.influence_reduction); + break; + case "genestealers": + alter_influence(eFACTION.TYRANIDS, -_purge.influence_reduction); + break; + } + + set_population(population_large_conversion(_purge.pop_after)); + var pip = instance_create(0, 0, obj_popup); + pip.title = "Purge Results"; + pip.text = _txt2; + } + if (_isquest) { + // DO EET + var pip = instance_create(0, 0, obj_popup); + scr_popup("Inquisition Mission Completed", _popup_text, "inquisition"); + } + } + + if (instance_exists(obj_drop_select)) { + with (obj_drop_select) { + if (instance_exists(sh_target)) { + sh_target.acted = 5; + } + instance_destroy(); + } + } +} diff --git a/scripts/scr_quest/scr_quest.gml b/scripts/scr_quest/scr_quest.gml index 4bcb4480da..bf61508cec 100644 --- a/scripts/scr_quest/scr_quest.gml +++ b/scripts/scr_quest/scr_quest.gml @@ -1,121 +1,109 @@ -function scr_quest(quest_satus = 0, quest_name, quest_fac, quest_end) { +function scr_quest(quest_satus, quest_name, quest_fac, quest_end) { // quest_satus: 0/1/2/3/4 create/fail/accomplish/clear/check // quest_name: quest name // quest_fac: faction // quest_end: duration before end - var quick_trade; - quick_trade = 0; + var quick_trade = 0; + var max_quests = 30; if (quest_satus == 0) { // Create - var first_quest, i; - first_quest = 0; - i = 0; - - repeat (30) { - if (first_quest == 0) { - i += 1; - if (obj_controller.quest[i] == "") { - first_quest = i; - } + var _first_empty_quest_slot = -1; + + for (var i = 1; i <= max_quests; i++) { + if (obj_controller.quest[i] == "") { + _first_empty_quest_slot = i; + break; } } - obj_controller.quest[i] = quest_name; - obj_controller.quest_faction[i] = quest_fac; - obj_controller.quest_end[i] = obj_controller.turn + quest_end; + if (_first_empty_quest_slot != -1) { + obj_controller.quest[_first_empty_quest_slot] = quest_name; + obj_controller.quest_faction[_first_empty_quest_slot] = quest_fac; + obj_controller.quest_end[_first_empty_quest_slot] = obj_controller.turn + quest_end; + } else { + LOGGER.error($"Warning: Quest log is full. Could not add: {quest_name}"); + } + } else if (quest_satus > 0) { - // 1 = Fail, 2 = Accomplish, 3 = Clear - var que = 0; + // 1 = Fail, 2 = Accomplish, 3 = Clear, 4 = Check + var que = -1; - for (var i = 1; i <= 10; i += 1) { - if (que == 0 && obj_controller.quest[i] == quest_name) { + for (var i = 1; i <= max_quests; i++) { + if (obj_controller.quest[i] == quest_name) { que = i; break; } } - if ((quest_name == "fund_elder") && (quest_satus == 1)) { + if (que != -1 || quest_satus == 4) { + if ((quest_name == "fund_elder") && (quest_satus == 1)) { // obj_controller.disposition[6]-=2;// Player going 'maybe' and then waiting out the quest duration - scr_audience(6, "mission1_failed", -2, "", 0, 0); - scr_event_log("red", "Eldar Mission Failed: Several years have passed since offering to assist the Eldar with resources."); - } else if ((quest_name == "artifact_return") && (quest_satus == 1)) { + scr_audience(6, "mission1_failed", -2, "", 0, 0); + scr_event_log("red", "Eldar Mission Failed: Several years have passed since offering to assist the Eldar with resources."); + } else if ((quest_name == "artifact_return") && (quest_satus == 1)) { // Inq are now pissed - obj_controller.alarm[8] = 1; - } else if ((quest_name == "artifact_loan") && (quest_satus == 1)) { + obj_controller.alarm[8] = 1; + } else if ((quest_name == "artifact_loan") && (quest_satus == 1)) { // Inq want the artifact back - var wanted_arti = -1; - for (var i = 0; i < array_length(obj_ini.artifact); i++) { - if (obj_ini.artifact[i] != "") { - if (obj_ini.artifact_struct[i].has_tag("inq")) { - wanted_arti = i; - break; + var wanted_arti = -1; + for (var i = 0; i < array_length(obj_ini.artifact); i++) { + if (obj_ini.artifact[i] != "") { + if (obj_ini.artifact_struct[i].has_tag("inq")) { + wanted_arti = i; + break; + } } } - } - var failed = false; - if (wanted_arti < 0) { - failed = true; - } else { - var arti = obj_ini.artifact_struct[wanted_arti]; - if (arti.equipped() && is_array(arti.bearer)) { + var failed = false; + if (wanted_arti < 0) { failed = true; + } else { + var arti = obj_ini.artifact_struct[wanted_arti]; + if (arti.equipped() && is_array(arti.bearer)) { + failed = true; + } } - } - if (failed) { - scr_popup("Inquisition Artifact", "The Inquisition has asked for the return of the Artifact left in your care. Despite your Marine's best efforts they were unable to waylay the Inquisition, who are now furious. They demand the Artifact's immediate return.", "inquisition", ""); - scr_event_log("red", "Inquisition Mission: The Inquisition Artifact entrusted to your Chapter is not retrievable."); - disposition[4] -= 10; - obj_controller.qsfx = 1; - } else { - var _result_text = ""; - delete_artifact(wanted_arti); - i = wanted_arti; - if (obj_controller.demanding == 0) { - obj_controller.disposition[4] += 1; - obj_controller.inspection_passes++; - _result_text = "(Disposition : 1\nInspection Passes : +1(yieldable in diplommacy))"; - } - if (obj_controller.demanding == 1) { - obj_controller.disposition[4] += choose(0, 0, 1); + if (failed) { + scr_popup("Inquisition Artifact", "The Inquisition has asked for the return of the Artifact left in your care. Despite your Marine's best efforts they were unable to waylay the Inquisition, who are now furious. They demand the Artifact's immediate return.", "inquisition", ""); + scr_event_log("red", "Inquisition Mission: The Inquisition Artifact entrusted to your Chapter is not retrievable."); + obj_controller.disposition[4] -= 10; // Explicitly use obj_controller scope + obj_controller.qsfx = 1; + } else { + var _result_text = ""; + delete_artifact(wanted_arti); + if (obj_controller.demanding == 0) { + obj_controller.disposition[4] += 1; + obj_controller.inspection_passes++; + _result_text = "(Disposition : +1\nInspection Passes : +1(yieldable in diplomacy))"; + } + if (obj_controller.demanding == 1) { + obj_controller.disposition[4] += choose(0, 0, 1); + } + scr_popup("Inquisition Mission Completed", "The Inquisition has asked for the return of the Artifact, and your Chapter was able to hand it over without complications. The mission has been accomplished." + _result_text, "inquisition", ""); + scr_event_log("", "Inquisition Mission Completed: The entrusted Artifact has been returned to the Inquisition."); } - scr_popup("Inquisition Mission Completed", "The Inquisition has asked for the return of the Artifact, and your Chapter was able to hand it over without complications. The mission has been accomplished." + _result_text, "inquisition", ""); - scr_event_log("", "Inquisition Mission Completed: The entrusted Artifact has been returned to the Inquisition."); } - } - if ((quest_name == "fund_elder") && (quest_satus == 2)) { - if (trading == 0) { - quick_trade = 6; + if ((quest_name == "fund_elder") && (quest_satus == 2)) { + if (obj_controller.trading == 0) { + quick_trade = 6; + } + obj_controller.known[eFACTION.ELDAR] += 1; + obj_controller.disposition[6] += 10; } - obj_controller.known[eFACTION.ELDAR] += 1; - obj_controller.disposition[6] += 10; - } - if (quest_satus == 4) { - var first_quest, i; - first_quest = 0; - i = 0; - - repeat (30) { - if (first_quest == 0) { - i += 1; - if (obj_controller.quest[i] == quest_name) { - first_quest = i; - } - } + if (quest_satus == 4) { + return que; } - if (first_quest != 0) { - return first_quest; + if (que != -1) { + obj_controller.quest[que] = ""; + obj_controller.quest_faction[que] = 0; + obj_controller.quest_end[que] = 0; } - exit; } - - obj_controller.quest[que] = ""; - obj_controller.quest_faction[que] = 0; - obj_controller.quest_end[que] = 0; } if (quick_trade != 0) { @@ -145,9 +133,7 @@ function scr_quest(quest_satus = 0, quest_name, quest_fac, quest_end) { } } - var targ, flit, goods, i, chasing; - goods = ""; - chasing = 0; // Set target + var targ = noone; if (instance_exists(obj_temp2)) { targ = instance_nearest(obj_temp2.x, obj_temp2.y, obj_temp3); } @@ -157,7 +143,6 @@ function scr_quest(quest_satus = 0, quest_name, quest_fac, quest_end) { // If player fleet is flying about then get their target for new target if ((!instance_exists(obj_temp2)) && (!instance_exists(obj_ground_mission)) && instance_exists(obj_p_fleet)) { - chasing = 1; with (obj_p_fleet) { var pop; if ((capital_number > 0) && (action != "")) { @@ -177,7 +162,7 @@ function scr_quest(quest_satus = 0, quest_name, quest_fac, quest_end) { targ = instance_nearest(obj_ground_mission.x, obj_ground_mission.y, obj_temp3); } - flit = instance_create(targ.x, targ.y, obj_en_fleet); + var flit = instance_create(targ.x, targ.y, obj_en_fleet); flit.owner = quick_trade; if (quick_trade == 2) { diff --git a/scripts/scr_random_event/scr_random_event.gml b/scripts/scr_random_event/scr_random_event.gml index 2abdde5f2e..608d7f7a5b 100644 --- a/scripts/scr_random_event/scr_random_event.gml +++ b/scripts/scr_random_event/scr_random_event.gml @@ -157,27 +157,27 @@ function scr_random_event(execute_now) { } break; case eEVENT.FLEET_DELAY: - var has_moving_fleet = false; + var _delayed_fleet_moving = false; with (obj_p_fleet) { if (action == "move") { - has_moving_fleet = true; + _delayed_fleet_moving = true; break; } } - if (!has_moving_fleet) { + if (!_delayed_fleet_moving) { events_share[i] -= 1; events_total -= 1; } break; case eEVENT.SHIP_LOST: - var has_moving_fleet = false; + var _lost_fleet_moving = false; with (obj_p_fleet) { if (action == "move") { - has_moving_fleet = true; + _lost_fleet_moving = true; break; } } - if (!has_moving_fleet) { + if (!_lost_fleet_moving) { events_share[i] -= 1; events_total -= 1; } @@ -220,17 +220,17 @@ function scr_random_event(execute_now) { var own = choose(1, 1, 2); var star_id = scr_random_find(own, true, "", ""); - if (star_id == undefined && own == 1) { + if (star_id == noone && own == 1) { // find the nearest star to a player fleet and user that one, dukecode did that // we could also try to find to find another star but this one is owned by the imperium and not the player, this code is doing that own = 2; star_id = scr_random_find(own, true, "", ""); } - if (star_id == undefined && own == 2) { + if (star_id == noone && own == 2) { star_id = scr_random_find(0, true, "", ""); // try for litteraly any star } - if (star_id == undefined) { + if (star_id == noone) { LOGGER.error("RE: Space Hulk, couldn't find a star for the spacehulk"); exit; } else { @@ -300,12 +300,12 @@ function scr_random_event(execute_now) { own = choose(1, 2); var star_id = scr_random_find(own, true, "", ""); - if (star_id == undefined && own == 1) { + if (star_id == noone && own == 1) { own = 2; star_id = scr_random_find(own, true, "", ""); } - if (star_id == undefined) { + if (star_id == noone) { LOGGER.error("RE: Sororitas Company, couldn't find a star for the company"); exit; } else { @@ -555,16 +555,16 @@ function scr_random_event(execute_now) { } var star_id = scr_random_find(own, true, "", ""); - if (star_id == undefined && own == 1) { + if (star_id == noone && own == 1) { own = 2; star_id = scr_random_find(own, true, "", ""); } - if (star_id == undefined && own == 2) { + if (star_id == noone && own == 2) { own = 0; star_id = scr_random_find(own, true, "", ""); } - if (star_id == undefined) { + if (star_id == noone) { LOGGER.error("RE: Warp Storm, couldn't pick a star for the warp storm"); exit; } else { @@ -586,16 +586,16 @@ function scr_random_event(execute_now) { } var star_id = scr_random_find(own, true, "", ""); - if (star_id == undefined && own == 1) { + if (star_id == noone && own == 1) { own = 2; star_id = scr_random_find(own, true, "", ""); } - if (star_id == undefined && own == 2) { + if (star_id == noone && own == 2) { own = 3; star_id = scr_random_find(own, true, "", ""); } - if (star_id == undefined) { + if (star_id == noone) { LOGGER.error("RE: Enemy Forces, couldn't find a star for the enemy"); exit; } else { diff --git a/scripts/scr_random_find/scr_random_find.gml b/scripts/scr_random_find/scr_random_find.gml index a458e7ab49..404bac6827 100644 --- a/scripts/scr_random_find/scr_random_find.gml +++ b/scripts/scr_random_find/scr_random_find.gml @@ -17,7 +17,7 @@ function scr_random_find(owner, is_planet, ship_action, feature) { var star = stars[star_index]; return star; // use that to get the obj } else { - return undefined; + return noone; } } else if (!is_planet && instance_exists(obj_all_fleet)) { var ships = []; @@ -35,9 +35,9 @@ function scr_random_find(owner, is_planet, ship_action, feature) { var ship = ships[ship_index]; return ship; } else { - return undefined; + return noone; } } else { - return undefined; //?? I think it would return that regardless + return noone; //?? I think it would return that regardless } } diff --git a/scripts/scr_random_marine/scr_random_marine.gml b/scripts/scr_random_marine/scr_random_marine.gml index 6e38a9f3f0..520610d15c 100644 --- a/scripts/scr_random_marine/scr_random_marine.gml +++ b/scripts/scr_random_marine/scr_random_marine.gml @@ -1,11 +1,7 @@ -function scr_random_marine(role, exp_req, search_params = "none") { - // role : role - // exp_req: exp - //search params : a struct giving extra search information defaults to "none" - - var company, i, comp_size, unit, match, r, unit_role, marine_list; - company = 0; - i = 0; +/// @param {string|Array} role +/// @param {Real} exp_req +/// @param {Struct} search_params a struct giving extra search information +function scr_random_marine(role, exp_req, search_params = {}) { var company_list = [ 0, 1, @@ -19,13 +15,13 @@ function scr_random_marine(role, exp_req, search_params = "none") { 9, 10 ]; - if (role == SPECIALISTS_LIBRARIANS) { + if (!is_array(role) && role == SPECIALISTS_LIBRARIANS) { role = role_groups(SPECIALISTS_LIBRARIANS); } for (var comp_shuffle = 0; comp_shuffle < 11; comp_shuffle++) { // this ensures that companies are searched randomly var new_comp = irandom(array_length(company_list) - 1); - company = company_list[new_comp]; + var company = company_list[new_comp]; array_delete(company_list, new_comp, 1); if (!is_array(role)) { if (string_count("Aspirant", role) > 0) { @@ -34,18 +30,18 @@ function scr_random_marine(role, exp_req, search_params = "none") { } } if (company <= 10) { - comp_size = array_length(obj_ini.name[company]); + var comp_size = array_length(obj_ini.name[company]); //This makes sure that cmopanies are searched randomly by creating an array of array positions to be randomly accessed - marine_list = []; - for (i = 0; i < comp_size; i++) { + var marine_list = []; + for (var i = 0; i < comp_size; i++) { marine_list[i] = i; } while (comp_size > 0) { var list_place = irandom(comp_size - 1); - i = marine_list[list_place]; - match = true; - unit = obj_ini.TTRPG[company][i]; + var _dude_index = marine_list[list_place]; + var match = true; + var unit = obj_ini.TTRPG[company][_dude_index]; //exit if not real name if ((unit.name() == "") || (unit.name() == 0)) { @@ -55,7 +51,7 @@ function scr_random_marine(role, exp_req, search_params = "none") { } //check correct search param roles - unit_role = unit.role(); + var unit_role = unit.role(); if (unit_role == obj_ini.role[100][eROLE.CHAPTERMASTER]) { array_delete(marine_list, list_place, 1); comp_size--; @@ -64,7 +60,7 @@ function scr_random_marine(role, exp_req, search_params = "none") { //if list of matchable roles given if (is_array(role)) { match = false; - for (r = 0; r < array_length(role); r++) { + for (var r = 0; r < array_length(role); r++) { if (unit_role == role[r]) { match = true; break; @@ -184,7 +180,7 @@ function scr_random_marine(role, exp_req, search_params = "none") { } //if match made exit loop and return unit if (match) { - return [company, i]; + return [company, _dude_index]; } } } diff --git a/scripts/scr_recent/scr_recent.gml b/scripts/scr_recent/scr_recent.gml index 5c9f4c0bdb..b40a25fec6 100644 --- a/scripts/scr_recent/scr_recent.gml +++ b/scripts/scr_recent/scr_recent.gml @@ -5,7 +5,6 @@ function scr_recent(recent_type = "", keyword = "", numerical_data = 0) { // Add an entry to the end of the argument2array if ((string(recent_type) != "") && (string(keyword) != "")) { - i = obj_controller.recent_happenings; array_push(obj_controller.recent_type, recent_type); array_push(obj_controller.recent_keyword, keyword); array_push(obj_controller.recent_turn, obj_controller.turn); @@ -21,9 +20,8 @@ function scr_recent(recent_type = "", keyword = "", numerical_data = 0) { array_push(delete_positions, i); } } - var del_pos; for (var i = 0; i < array_length(delete_positions); i++) { - del_pos = delete_positions[i]; + var del_pos = delete_positions[i]; array_delete(obj_controller.recent_type, del_pos, 1); array_delete(obj_controller.recent_keyword, del_pos, 1); array_delete(obj_controller.recent_turn, del_pos, 1); diff --git a/scripts/scr_recruit_data/scr_recruit_data.gml b/scripts/scr_recruit_data/scr_recruit_data.gml index 4d550cebe3..fcbfa2aec0 100644 --- a/scripts/scr_recruit_data/scr_recruit_data.gml +++ b/scripts/scr_recruit_data/scr_recruit_data.gml @@ -107,14 +107,14 @@ function find_recruit_success_chance(local_apothecary_points, system, planet, ui } else if (p_data.at_war(0, 0, 0) && p_data.player_disposition < 0) { recruit_chance = 2000; } else if (p_data.player_disposition < -1000 && p_data.current_owner == eFACTION.PLAYER) { - var recruit_chance = 1500 - _recruit_cost * 100; + recruit_chance = 1500 - _recruit_cost * 100; } else { var _frictious = p_data.at_war(0, 1, 1) && p_data.player_disposition <= 50; var _disp_mod = -((_frictious ? 30 : 10) * p_data.player_disposition); var _faction_disp_mod = !_frictious ? 2000 : 3000; var _recruit_cost_mod = -_recruit_cost * 100; - var recruit_chance = _disp_mod + _recruit_cost_mod + _faction_disp_mod; + recruit_chance = _disp_mod + _recruit_cost_mod + _faction_disp_mod; } if (_recruit_world.recruit_type == 1) { @@ -123,10 +123,9 @@ function find_recruit_success_chance(local_apothecary_points, system, planet, ui recruit_chance = 300; } if (ui == 0) { + var droll = irandom(100); if (scr_has_adv("Ambushers")) { - var droll = irandom(400); - } else { - var droll = irandom(100); + droll = irandom(400); } if (droll == 0) { @@ -158,10 +157,9 @@ function find_recruit_success_chance(local_apothecary_points, system, planet, ui } } } + var _success_chance = 0; if (recruit_chance != 0) { - var _success_chance = recruit_chance_total / recruit_chance; - } else { - var _success_chance = 0; + _success_chance = recruit_chance_total / recruit_chance; } return _success_chance; } @@ -345,7 +343,6 @@ function planet_training_sequence(local_apothecary_points) { // xp gain for the recruit is here // as well as planet type buffs or nerfs if (aspirant) { - var i = 0; var new_recruit = 0; // gets the next empty recruit space on the array diff --git a/scripts/scr_reequip_units/scr_reequip_units.gml b/scripts/scr_reequip_units/scr_reequip_units.gml index 6607e7d131..45bbe63069 100644 --- a/scripts/scr_reequip_units/scr_reequip_units.gml +++ b/scripts/scr_reequip_units/scr_reequip_units.gml @@ -1,7 +1,7 @@ /// @self Asset.GMObject.obj_controller function set_up_equip_popup() { if (!instance_exists(obj_popup)) { - var f = 0, god = 0, nuuum = 0; + var nuuum = 0; var o_wep1 = "", o_wep2 = "", o_armour = "", o_gear = "", o_mobi = ""; var b_wep1 = 0, b_wep2 = 0, b_armour = 0, b_gear = 0, b_mobi = 0; var vih = 0, _unit; @@ -461,11 +461,9 @@ function draw_popup_equip() { //TODO wrap this up in a function if (weapon_one_data.req_exp > 0) { - var g = -1, exp_check = 0; for (var g = 0; g < array_length(obj_controller.display_unit); g++) { if (obj_controller.man_sel[g] == 1 && is_struct(obj_controller.display_unit[g])) { if (obj_controller.display_unit[g].experience < weapon_one_data.req_exp) { - exp_check = 1; n_good1 = 0; warning = $"A unit must have {weapon_one_data.req_exp}+ EXP to use a {weapon_one_data.name}."; break; @@ -488,9 +486,7 @@ function draw_popup_equip() { // Check numbers req_wep2_num = units; have_wep2_num = 0; - var i = -1; - repeat (array_length(obj_controller.display_unit)) { - i += 1; + for (var i = 0; i < array_length(obj_controller.display_unit); i++) { if ((vehicle_equipment != -1) && (obj_controller.ma_wep2[i] == n_wep2)) { have_wep2_num += 1; } @@ -508,13 +504,9 @@ function draw_popup_equip() { } //TODO standardise exp check if (weapon_two_data.req_exp > 0) { - var g, exp_check; - g = -1; - exp_check = 0; for (var g = 0; g < array_length(obj_controller.display_unit); g++) { if (obj_controller.man_sel[g] == 1 && is_struct(obj_controller.display_unit[g])) { if (obj_controller.display_unit[g].experience < weapon_two_data.req_exp) { - exp_check = 1; n_good2 = 0; warning = $"A unit must have {weapon_two_data.req_exp}+ EXP to use a {weapon_two_data.name}."; break; @@ -543,10 +535,7 @@ function draw_popup_equip() { // Check numbers req_armour_num = units; have_armour_num = 0; - var i; - i = -1; - repeat (array_length(obj_controller.display_unit)) { - i += 1; + for (var i = 0; i < array_length(obj_controller.display_unit); i++) { if ((vehicle_equipment != -1) && (obj_controller.man_sel[i] == 1) && (obj_controller.ma_armour[i] == n_armour)) { have_armour_num += 1; } @@ -561,16 +550,11 @@ function draw_popup_equip() { warning = $"Not enough {n_armour} : {req_armour_num - have_armour_num} more are required."; } - var g = -1, exp_check = 0; if (armour_data.has_tag("terminator")) { if (armour_data.req_exp > 0) { - var g, exp_check; - g = -1; - exp_check = 0; for (var g = 0; g < array_length(obj_controller.display_unit); g++) { if (obj_controller.man_sel[g] == 1 && is_struct(obj_controller.display_unit[g])) { if (obj_controller.display_unit[g].experience < armour_data.req_exp) { - exp_check = 1; n_good3 = 0; warning = $"A unit must have {armour_data.req_exp}+ EXP to use a {armour_data.name}."; break; @@ -608,13 +592,13 @@ function draw_popup_equip() { } if (is_struct(armour_data) && is_struct(gear_data)) { - if (armour_data.has_tag("terminator") && !gear_data.has_tag("terminator") && !gear_data.has_tag("terminator_only")) { + /*if (armour_data.has_tag("terminator") && !gear_data.has_tag("terminator") && !gear_data.has_tag("terminator_only")) { n_good4 = 0; warning = "Cannot use this with Terminator Armour."; } else if (!armour_data.has_tag("terminator") && gear_data.has_tag("terminator_only")) { n_good4 = 0; warning = "Cannot use this without Terminator Armour."; - } else if (armour_data.has_tag("dreadnought") && !gear_data.has_tag("dreadnought") && !gear_data.has_tag("dreadnought_only")) { + } else*/ if (armour_data.has_tag("dreadnought") && !gear_data.has_tag("dreadnought") && !gear_data.has_tag("dreadnought_only")) { n_good4 = 0; warning = "Cannot use this with Dreadnought Armour."; } else if (!armour_data.has_tag("dreadnought") && gear_data.has_tag("dreadnought_only")) { @@ -627,10 +611,7 @@ function draw_popup_equip() { // Check numbers req_mobi_num = units; have_mobi_num = 0; - var i; - i = -1; - repeat (array_length(obj_controller.display_unit)) { - i += 1; + for (var i = 0; i < array_length(obj_controller.display_unit); i++) { if ((vehicle_equipment != -1) && (obj_controller.man_sel[i] == 1) && (obj_controller.ma_mobi[i] == n_mobi)) { have_mobi_num += 1; } diff --git a/scripts/scr_return_ship/scr_return_ship.gml b/scripts/scr_return_ship/scr_return_ship.gml index c04bf731cc..946a7d7af6 100644 --- a/scripts/scr_return_ship/scr_return_ship.gml +++ b/scripts/scr_return_ship/scr_return_ship.gml @@ -2,24 +2,12 @@ function scr_return_ship(ship_name, object, planet_number) { // ship_name: name of ship // object: object with man_selecting // planet_number: planet number - var man_size, i; - i = 0; - man_size = 0; - /*repeat(30){ - i+=1;if (obj_ini.ship[i]=ship_name) then ship_id=i; - }*/ - i = 0; - - // Increase ship storage ship_carrying[i] - - var unit; var return_planet = obj_controller.return_object; with (object) { - var man_size; for (var i = 0; i < array_length(display_unit); i++) { if (object.man_sel[i] > 0) { - unit = display_unit[i]; + var unit = display_unit[i]; if (is_struct(unit)) { if (return_place[i] > 0) { unit.load_marine(return_place[i], return_planet); diff --git a/scripts/scr_role_count/scr_role_count.gml b/scripts/scr_role_count/scr_role_count.gml index 09847c2dfb..3b64024bb7 100644 --- a/scripts/scr_role_count/scr_role_count.gml +++ b/scripts/scr_role_count/scr_role_count.gml @@ -1,11 +1,8 @@ function scr_role_count(target_role, search_location = "", return_type = "count") { // Take a guess - - var com, count, coom, units = [], unit, match; - - count = 0; - com = 0; - coom = -999; + var units = []; + var count = 0; + var coom = -999; if (is_string(search_location)) { if (search_location == "0") { @@ -36,27 +33,25 @@ function scr_role_count(target_role, search_location = "", return_type = "count" } if (coom >= 0) { - com = coom; - for (var i = 0; i < array_length(obj_ini.TTRPG[com]); i++) { - unit = obj_ini.TTRPG[com][i]; + for (var i = 0; i < array_length(obj_ini.TTRPG[coom]); i++) { + var unit = obj_ini.TTRPG[coom][i]; if (unit.name() == "") { continue; } - if ((unit.role() == target_role) && (obj_ini.god[com][i] < 10)) { + if ((unit.role() == target_role) && (obj_ini.god[coom][i] < 10)) { count += 1; if (return_type == "units") { - array_push(units, obj_ini.TTRPG[com][i]); + array_push(units, obj_ini.TTRPG[coom][i]); } } } - com += 1; } if (coom < 0) { for (var com = 0; com <= obj_ini.companies; com++) { for (var i = 0; i < array_length(obj_ini.TTRPG[com]); i++) { - match = false; - unit = fetch_unit([com, i]); + var match = false; + var unit = fetch_unit([com, i]); if (unit.name() == "") { continue; } diff --git a/scripts/scr_roster/scr_roster.gml b/scripts/scr_roster/scr_roster.gml index 5caf8a0f44..c47893aa0f 100644 --- a/scripts/scr_roster/scr_roster.gml +++ b/scripts/scr_roster/scr_roster.gml @@ -103,7 +103,7 @@ function Roster() constructor { continue; } if (_unit.squad_type() != "none") { - var _valid_type = array_contains(_valid_squad_types, _unit.squad_type()); + _valid_type = array_contains(_valid_squad_types, _unit.squad_type()); } else { var _armour_data = _unit.get_armour_data(); if (is_struct(_armour_data)) { @@ -111,6 +111,11 @@ function Roster() constructor { _valid_type = _allow_dreadnoughts; } } + // Guardsmen answer to their own filter button rather than always passing + var _grd_role = _unit.role(); + if (_grd_role == "Guardsman" || _grd_role == "Guard Squad" || _grd_role == "Guard Sergeant" || _grd_role == "Veteran Guard" || _grd_role == "Heavy Weapons Team") { + _valid_type = array_contains(_valid_squad_types, "guardsman"); + } } if (_unit.ship_location > -1) { @@ -158,7 +163,7 @@ function Roster() constructor { static new_squad_button = function(display, squad_id) { var _button = new ToggleButton(); display = string_replace(display, " Squad", ""); - if (display != "Command") { + if (display != "Command" && display != "Guardsmen") { display = string_plural(display); } _button.str1 = display; @@ -225,7 +230,7 @@ function Roster() constructor { roster_local_string += "\n"; roster_local_string += "Remaining\n"; - var _roster_types = struct_get_names(possible_local_roster); + _roster_types = struct_get_names(possible_local_roster); for (var i = 0; i < array_length(_roster_types); i++) { var _roster_type_name = _roster_types[i]; var _roster_type_count = possible_local_roster[$ _roster_type_name]; @@ -290,6 +295,13 @@ function Roster() constructor { new_squad_button("Dreadnought", "dreadnought"); } } + // Guardsmen and Guard Squads have no squad type, so give them their + // own filter button (added once) so they can be selected on their own. + var _grd_role = _unit.role(); + if ((_grd_role == "Guardsman" || _grd_role == "Guard Squad" || _grd_role == "Guard Sergeant" || _grd_role == "Veteran Guard" || _grd_role == "Heavy Weapons Team") && !array_contains(_squads, "guardsman")) { + array_push(_squads, "guardsman"); + new_squad_button("Guardsmen", "guardsman"); + } } } } @@ -369,13 +381,11 @@ function Roster() constructor { var size_count = 0; var _limit = obj_ncombat.man_size_limit; var _has_limit = _limit > 0; - var _add; - var _unit, _size; for (var i = 0; i < array_length(selected_units); i++) { if (_has_limit && _limit == size_count) { break; } - _add = true; + var _add = true; if (is_struct(selected_units[i])) { var _unit = selected_units[i]; @@ -505,9 +515,8 @@ function add_unit_to_battle(unit, meeting, is_local) { //Same as co/company and v, but with extra comprovations in case of a meeting (meeting?) var _role = obj_ini.role[100]; - var cooh, va; - cooh = 0; - va = 0; + var cooh = 0; + var va = 0; var v = unit.marine_number; var company = unit.company; if (!meeting) { @@ -633,12 +642,6 @@ function add_unit_to_battle(unit, meeting, is_local) { if (_unit_role == _role[7]) { new_combat.champions++; } - - //if (company = 1) { - // col = obj_controller.bat_veteran_column; - // if (obj_ini.armour[cooh][va] = "Terminator Armour") then col = obj_controller.bat_terminator_column; - // if (obj_ini.armour[cooh][va] = "Tartaros Armour") then col = obj_controller.bat_terminator_column; - //} if (company >= 2) { col = obj_controller.bat_tactical_column; } @@ -711,6 +714,21 @@ function add_unit_to_battle(unit, meeting, is_local) { col = max(obj_controller.bat_assault_column, obj_controller.bat_command_column, obj_controller.bat_honor_column, obj_controller.bat_dreadnought_column, obj_controller.bat_veteran_column); } + // ===== Guardsmen: "Hirelings" formation ===== + // Guardsmen go into the movable Hirelings block (bat_hire_column), so the player can position + // them anywhere from the formation screen as a single line. This restores the behaviour from + // before the positional-screen experiment: every guardsman shares this one column instead of + // being pinned to fixed front columns. bat_hire_column was resolved for this formation at the + // top of this function and is driven by the Hirelings bar (bat_hire_for, unit_id 12). + if (_unit_role == "Heavy Weapons Team") { + // Heavy weapons teams fight from the Devastator formation, the chapter's own heavy-weapon + // line, instead of the Hirelings block, so the auxilia's heavy guns stand with the Marines'. + col = obj_controller.bat_devastator_column; + new_combat.devastators++; + } else if (_unit_role == "Guardsman" || _unit_role == "Guard Sergeant" || _unit_role == "Veteran Guard") { + col = obj_controller.bat_hire_column; + } + targ = instance_nearest(col * 10, 240, obj_pnunit); with (targ) { @@ -729,10 +747,21 @@ function add_vehicle_to_battle(company, veh_index, is_local) { col = obj_controller.bat_rhino_column; new_combat.rhinos++; break; + // Chimera (guard transport) screens like a Rhino. This first drop parks it in the Rhino + // column; the dedicated Imperial Armor column arrives with the formation drop. + case "Chimera": + col = obj_controller.bat_rhino_column; + new_combat.rhinos++; + break; case "Predator": col = obj_controller.bat_predator_column; new_combat.predators++; break; + // Leman Russ (guard battle tank) anchors the armour line alongside the Predators. + case "Leman Russ": + col = obj_controller.bat_predator_column; + new_combat.predators++; + break; case "Land Raider": col = obj_controller.bat_landraider_column; new_combat.land_raiders++; @@ -776,6 +805,24 @@ function add_vehicle_to_battle(company, veh_index, is_local) { targ.veh_hp[targ.veh] = obj_ini.veh_hp[company][v] * 4; targ.veh_hp_multiplier[targ.veh] = 4; targ.veh_ac[targ.veh] = 40; + } else if (obj_ini.veh_role[company][v] == "Chimera") { + // Mirrors the enemy Chimera: HP 200 (base 100 x2), armour 30. + targ.veh_hp[targ.veh] = obj_ini.veh_hp[company][v] * 2; + targ.veh_hp_multiplier[targ.veh] = 2; + targ.veh_ac[targ.veh] = 30; + } else if (obj_ini.veh_role[company][v] == "Leman Russ") { + // Mirrors the enemy Leman Russ Battle Tank: heavy armour 40, HP 300 (base 100 x3), + // so it shrugs off small arms and trades blows with other tanks like a Predator. + targ.veh_hp[targ.veh] = obj_ini.veh_hp[company][v] * 3; + targ.veh_hp_multiplier[targ.veh] = 3; + targ.veh_ac[targ.veh] = 40; + } else if (obj_ini.veh_role[company][v] == "Basilisk") { + // Mirrors the enemy Basilisk: armour 30, HP 150 (base 100 x1.5). A self-propelled + // artillery piece, tougher than a Chimera but lighter than a Leman Russ, built to + // shell from the rear of the line rather than trade blows at the front. + targ.veh_hp[targ.veh] = obj_ini.veh_hp[company][v] * 1.5; + targ.veh_hp_multiplier[targ.veh] = 1.5; + targ.veh_ac[targ.veh] = 30; } // STC Bonuses @@ -801,3 +848,42 @@ function add_vehicle_to_battle(company, veh_index, is_local) { } } } + +/// @function auxilia_roles +/// @description Single source of truth for which unit roles belong to the Auxilia company +/// screen (managing 16). These are non-Astartes auxiliary mercenaries mustered into company 0 +/// alongside the Headquarters, but managed on their own screen. Add future merc roles here +/// (Ogryn, heavy weapons team, etc.) and they will automatically appear under Auxilia and be +/// excluded from the Headquarters detail view. +/// @returns {array} +function auxilia_roles() { + return ["Guardsman", "Guard Squad", "Guard Sergeant", "Veteran Guard", "Heavy Weapons Team"]; +} + +/// @description Promote every basic Guardsman to Veteran Guard, applying the veteran stat +/// buff. Veterans keep all Guard behaviour (Auxilia screen, hireling line, volley fire, +/// tenth-slot berth, guardsman portrait) through the role closure. They receive no free +/// weapon; Hellguns are forged separately and equip-gated to this role. Intended to be wired +/// to the Auxilia "Promote All" button. Pass a company index to limit promotion to one +/// company, or leave it undefined to promote every auxilia Guardsman. The stat_boosts numbers +/// are tunable. Additions are flat; stat_boosts rebalances constitution into current health. +/// @param {real} [_company] optional company index to limit promotion to +/// @returns {real} number of troopers promoted +function promote_auxilia_to_veteran(_company = undefined) { + var _troops = collect_role_group("all", "", false, { roles: ["Guardsman"] }); + var _count = 0; + for (var _i = 0; _i < array_length(_troops); _i++) { + var _unit = _troops[_i]; + if (_company != undefined && _unit.company != _company) { + continue; + } + _unit.update_role("Veteran Guard"); + _unit.stat_boosts({ + ballistic_skill: 8, + constitution: 6, + dexterity: 4 + }); + _count++; + } + return _count; +} diff --git a/scripts/scr_ruins_reward/scr_ruins_reward.gml b/scripts/scr_ruins_reward/scr_ruins_reward.gml index e0e8dd5461..6a7f1122be 100644 --- a/scripts/scr_ruins_reward/scr_ruins_reward.gml +++ b/scripts/scr_ruins_reward/scr_ruins_reward.gml @@ -35,7 +35,7 @@ function LootPool(_data) constructor { } /// @desc Processes rewards for exploring ancient ruins. -/// @param {Asset.GMObject.obj_star} _star_system The star system object. +/// @param {Id.Instance.obj_star} _star_system The star system object. /// @param {Real} _pid_idx Planet index within the system. /// @param {Struct.NewPlanetFeature} _ruins The ruins feature struct. function scr_ruins_reward(_star_system, _pid_idx, _ruins) { @@ -47,7 +47,7 @@ function scr_ruins_reward(_star_system, _pid_idx, _ruins) { /// @desc Internal logic for handling Gear distribution via JSON data. /// @param {Real} _race The ID of the ruins race. - /// @param {Asset.GMObject.obj_popup} _popup The popup instance to populate. + /// @param {Id.Instance.obj_popup} _popup The popup instance to populate. static _process_gear_reward = function(_race, _popup) { static _loot_registry = undefined; @@ -104,7 +104,9 @@ function scr_ruins_reward(_star_system, _pid_idx, _ruins) { }; /// @desc Internal logic for handling Artifact retrieval. - /// @param {Asset.GMObject.obj_popup} _popup + /// @param {Id.Instance.obj_star} _star + /// @param {String} _pidx + /// @param {Id.Instance.obj_popup} _popup static _process_artifact_reward = function(_star, _pidx, _popup) { var _chosen_ship = -1; var _fleet = scr_orbiting_player_fleet(_star); @@ -218,7 +220,7 @@ function scr_ruins_reward(_star_system, _pid_idx, _ruins) { _ruins.ruins_explored(); } -/// @param {Asset.GMObject.obj_popup} _popup The popup instance to populate. +/// @param {Id.Instance.obj_popup} _popup The popup instance to populate. function ancient_gene_lab_ruins_loot(_popup) { _popup.image = "geneseed_lab"; _popup.title = "Ancient Ruins: Gene-seed"; @@ -266,10 +268,10 @@ function ancient_gene_lab_ruins_loot(_popup) { }; } -/// @param {Asset.GMObject.obj_star} _star +/// @param {Id.Instance.obj_star} _star /// @param {Real} _planet /// @param {Struct} _ruins -/// @param {Asset.GMObject.obj_popup} _popup +/// @param {Id.Instance.obj_popup} _popup function ancient_fortress_ruins_loot(_star, _planet, _ruins, _popup) { _popup.image = "ruins_fort"; _popup.title = "Ancient Ruins: Fortress"; diff --git a/scripts/scr_serialization_functions/scr_serialization_functions.gml b/scripts/scr_serialization_functions/scr_serialization_functions.gml index 3ab0e0dcf9..f4ce04a7c5 100644 --- a/scripts/scr_serialization_functions/scr_serialization_functions.gml +++ b/scripts/scr_serialization_functions/scr_serialization_functions.gml @@ -1,8 +1,8 @@ /// @desc Copies simple (serializable) variables from one struct to another, excluding specified names and prefixes. Useful for building save-data structs. -/// @param {struct} _source - The struct to copy variables from. -/// @param {struct} _destination - The struct to copy variables into. -/// @param {array} _exclude - List of variable names to exclude. -/// @param {array} _exclude_start - List of string prefixes; variables starting with any of these will be excluded. +/// @param {Id.Instance|Struct} _source - The struct to copy variables from. +/// @param {Id.Instance|Struct} _destination - The struct to copy variables into. +/// @param {Array} _exclude - List of variable names to exclude. +/// @param {Array} _exclude_start - List of string prefixes; variables starting with any of these will be excluded. function copy_serializable_fields(_source, _destination, _exclude = [], _exclude_start = []) { /// Check all object variable values types and save the simple ones dynamically. /// simple types are numbers, strings, bools. arrays of only simple types are also considered simple. diff --git a/scripts/scr_ship_count/scr_ship_count.gml b/scripts/scr_ship_count/scr_ship_count.gml index 000dfb14ee..00bd30e0e0 100644 --- a/scripts/scr_ship_count/scr_ship_count.gml +++ b/scripts/scr_ship_count/scr_ship_count.gml @@ -1,7 +1,7 @@ function scr_ship_count(wanted_ship_class) { // Mi color favorito es bicicleta. - var count = 0, i = 0; + var count = 0; for (var i = 0; i < array_length(obj_ini.ship_class); i++) { if (obj_ini.ship_class[i] == wanted_ship_class) { @@ -10,8 +10,4 @@ function scr_ship_count(wanted_ship_class) { } return count; - - // temp[36]=scr_role_count("Chaplain","field"); - // temp[37]=scr_role_count("Chaplain","home"); - // temp[37]=scr_role_count("Chaplain",""); } diff --git a/scripts/scr_shoot/scr_shoot.gml b/scripts/scr_shoot/scr_shoot.gml index ad46100221..267c0f784e 100644 --- a/scripts/scr_shoot/scr_shoot.gml +++ b/scripts/scr_shoot/scr_shoot.gml @@ -7,12 +7,6 @@ function scr_shoot(weapon_index_position, target_object, target_type, damage_dat // melee_or_ranged: melee or ranged // This massive clusterfuck of a script uses the newly determined weapon and target data to attack and assign damage - for (var j = 1; j <= 100; j++) { - obj_ncombat.dead_ene[j] = ""; - obj_ncombat.dead_ene_n[j] = 0; - } - obj_ncombat.dead_enemies = 0; - var hostile_type; var hostile_damage; var hostile_weapon; @@ -203,6 +197,15 @@ function scr_shoot(weapon_index_position, target_object, target_type, damage_dat exit; } + // Guardsman accuracy: mirror the enemy's doom (the owner == eFACTION.IMPERIUM branch + // above) on the player side. Ranged, multi-shot lasgun stacks only, matching the enemy + // gating (shots_fired != 1 && not melee). Scaling shots_fired flows through total damage + // (c = shots_fired * final_hit_damage_value), the casualty cap, and the announced count, + // while damage_per_weapon stays divided by wep_num, so the cut is a clean linear share. + if ((weapon_index_position >= 0) && (shots_fired > 1) && (melee_or_ranged != "melee") && (wep[weapon_index_position] == "Lasgun")) { + shots_fired = max(1, floor(shots_fired * GUARD_DOOM)); + } + /*if (weapon_index_position<-40){ if (weapon_index_position=-53){ if (player_silos>30) then shots_fired=30; @@ -252,8 +255,6 @@ function scr_shoot(weapon_index_position, target_object, target_type, damage_dat if ((weapon_index_position >= 0) || (weapon_index_position < -40)) { // Normal shooting - var overkill = 0, damage_remaining = 0, shots_remaining = 0; - var that_works = false; if (weapon_index_position >= 0) { @@ -266,280 +267,314 @@ function scr_shoot(weapon_index_position, target_object, target_type, damage_dat } if (that_works == true) { - var damage_per_weapon = 0, c = 0, target_armour_value = 0, ap = 0, wii = ""; + var damage_per_weapon = 0; attack_count_mod = 0; if (weapon_index_position >= 0) { damage_per_weapon = aggregate_damage / wep_num[weapon_index_position]; - ap = armour_pierce; } // Average damage if (weapon_index_position < -40) { - wii = ""; attack_count_mod = 3; if (weapon_index_position == -51) { - wii = "Heavy Bolter Emplacement"; at = 160; armour_pierce = 0; } if (weapon_index_position == -52) { - wii = "Missile Launcher Emplacement"; at = 200; armour_pierce = -1; } if (weapon_index_position == -53) { - wii = "Missile Silo"; at = 250; armour_pierce = 0; } } - target_armour_value = target_object.dudes_ac[target_type]; + attack_count_mod = max(1, splash[weapon_index_position]); - // Calculate final armor value based on armor piercing (AP) rating against target type - if (target_object.dudes_vehicle[target_type]) { - if (armour_pierce == 4) { - target_armour_value = 0; + // Armour multiplier indexed by AP rating (1..4); any AP outside that range + // leaves armour untouched. Infantry and vehicles scale differently. + var _inf_ap = [1, 3, 2, 1.5, 0]; + var _veh_ap = [1, 6, 4, 2, 0]; + var _ap_valid = (armour_pierce >= 1) && (armour_pierce <= 4); + + // Never open fire on a dead rank/formation. Stale men/veh/medi (only refreshed on + // the enemy's own alarm) and scr_target's rank-1 fallback can aim us at corpses; + // snap to a living rank instead, or clean up the empty formation and bail. + if (!instance_exists(target_object)) { + exit; + } + if (target_object.dudes_num[target_type] <= 0) { + var _alive_rank = find_next_alive_rank(target_object, -1); + if (_alive_rank == -1) { + destroy_empty_column(target_object); + exit; } - if (armour_pierce == 3) { - target_armour_value = target_armour_value * 2; + target_type = _alive_rank; + } + + // Damage spills across ranks and, once a formation is spent, into the + // formation behind it. Every target actually fired upon gets its own flavour + // line with its own casualty count. The loop always terminates: shots_left + // strictly shrinks on every iteration that continues. + var spill_block = target_object; + var spill_rank = target_type; + var shots_left = shots_fired; + var touched_blocks = []; // Spill-over formations only; target_object is cleaned below. + + // The whole volley posts ONE battle-log line: the first target gets the rich + // weapon flavour (deferred), and every later target the overflow kills is + // gathered into a kill list appended to it (see emit_volley_flavour). + var _first_target = true; + var _primary_flavour = undefined; + var _spill_kills = []; // [{ name, count }] for targets killed after the first. + + while (shots_left > 0) { + // This target's armour against our AP rating. + var _armour = spill_block.dudes_ac[spill_rank]; + if (_ap_valid) { + var _ap_table = spill_block.dudes_vehicle[spill_rank] ? _veh_ap : _inf_ap; + _armour *= _ap_table[armour_pierce]; } - if (armour_pierce == 2) { - target_armour_value = target_armour_value * 4; + var final_hit = max(0, (damage_per_weapon - (_armour * attack_count_mod)) * spill_block.dudes_dr[spill_rank]); + + var rank_num = spill_block.dudes_num[spill_rank]; + var rank_hp = spill_block.dudes_hp[spill_rank]; + var total_damage = shots_left * final_hit; + var raw_kills = floor(total_damage / rank_hp); + var casualties = min(raw_kills, rank_num, shots_left * attack_count_mod); + + // Surplus damage only spills once this rank is actually wiped out. + var next_shots = 0; + if ((casualties >= rank_num) && (rank_num > 0) && (raw_kills > rank_num)) { + next_shots = max(0, shots_left - ceil((rank_num * rank_hp) / final_hit)); } - if (armour_pierce == 1) { - target_armour_value = target_armour_value * 6; + + // Gather flavour. The first target carries the rich phrasing (deferred, with + // the full weapon count); later targets just contribute to the kill list. + // final_hit <= 0 means armour stopped the shots cold (AP too low). + if (_first_target) { + _primary_flavour = scr_flavor(weapon_index_position, spill_block, spill_rank, shots_fired, casualties, final_hit <= 0, true); + _first_target = false; + } else if (casualties > 0) { + array_push(_spill_kills, { name: spill_block.dudes[spill_rank], count: casualties }); } - } else { - if (armour_pierce == 4) { - target_armour_value = 0; + + if ((rank_num == 1) && (casualties == 0) && (total_damage > 0)) { + spill_block.dudes_hp[spill_rank] -= total_damage; // Chip a lone survivor + if (spill_block.dudes_hp[spill_rank] <= 0) { + // Chipped to death: remove it now and drop the force count. Otherwise + // dudes_num stays 1 at dudes_hp <= 0 - a "zombie" that find_next_alive_rank + // skips, so it's never finished off and keeps inflating enemy_forces. + spill_block.dudes_num[spill_rank] = 0; + obj_ncombat.enemy_forces -= 1; + } } - if (armour_pierce == 3) { - target_armour_value = target_armour_value * 1.5; + if (casualties >= 1) { + spill_block.dudes_num[spill_rank] -= casualties; + obj_ncombat.enemy_forces -= casualties; } - if (armour_pierce == 2) { - target_armour_value = target_armour_value * 2; + + shots_left = next_shots; + if (shots_left <= 0) { + break; } - if (armour_pierce == 1) { - target_armour_value = target_armour_value * 3; + + // Next target: a living rank in this formation, else the formation behind. + var next_rank = find_next_alive_rank(spill_block, spill_block.dudes_vehicle[spill_rank]); + if (next_rank == -1) { + spill_block = get_next_enemy_formation(spill_block); + if (spill_block == noone) { + break; + } + array_push(touched_blocks, spill_block); + next_rank = find_next_alive_rank(spill_block, -1); + if (next_rank == -1) { + break; + } } + spill_rank = next_rank; } - attack_count_mod = max(1, splash[weapon_index_position]); - - final_hit_damage_value = damage_per_weapon - (target_armour_value * attack_count_mod); //damage armour reduction - - final_hit_damage_value *= target_object.dudes_dr[target_type]; //damage_resistance mod + // Post the single consolidated line for the whole volley. + emit_volley_flavour(_primary_flavour, _spill_kills); - if (final_hit_damage_value <= 0) { - final_hit_damage_value = 0; - } // Average after armour + // Clean up the spill-over formations (target_object is handled below). + for (var _tb = 0; _tb < array_length(touched_blocks); _tb++) { + if (instance_exists(touched_blocks[_tb])) { + compress_enemy_array(touched_blocks[_tb]); + destroy_empty_column(touched_blocks[_tb]); + } + } + } + } - c = shots_fired * final_hit_damage_value; // New damage + if (stop == 0) { + compress_enemy_array(target_object); + destroy_empty_column(target_object); + } + } + } catch (_exception) { + ERROR_HANDLER.handle_exception(_exception); + } +} - var casualties, onceh = 0, ponies = 0; +/// @function find_next_alive_rank +/// @description Returns the index of the next living rank (dudes_num > 0 and dudes_hp > 0) in a +/// formation, preferring ranks that match the requested vehicle flag. Returns -1 if +/// none. The dudes_hp > 0 check keeps callers safe from dividing by a rank's HP. +/// @param {Id.Instance} _block The obj_enunit formation to search. +/// @param {Real} _prefer_vehicle 0/1 to prefer that category, or -1 for any living rank. +/// @returns {Real} +function find_next_alive_rank(_block, _prefer_vehicle) { + if (!instance_exists(_block)) { + return -1; + } + var _fallback = -1; + for (var f = 1; f <= 30; f++) { + if (_block.dudes_num[f] <= 0 || _block.dudes_hp[f] <= 0) { + continue; + } + if (_prefer_vehicle == -1 || _block.dudes_vehicle[f] == _prefer_vehicle) { + return f; + } + if (_fallback == -1) { + _fallback = f; + } + } + return _fallback; +} - casualties = min(floor(c / target_object.dudes_hp[target_type]), shots_fired * attack_count_mod); +/// @function get_next_enemy_formation +/// @description Returns the nearest enemy formation (obj_enunit) sitting behind the given one +/// that still contains at least one living rank, or noone if there isn't one. +/// @param {Id.Instance} _block The formation we are spilling out of. +/// @returns {Id.Instance} +function get_next_enemy_formation(_block) { + if (!instance_exists(_block)) { + return noone; + } + var _bx = _block.x; + var _bid = _block.id; + var _best = noone; + var _best_x = 0; + with (obj_enunit) { + if (id == _bid) { + continue; + } + if (x <= _bx) { + continue; + } + if (find_next_alive_rank(id, -1) == -1) { + continue; + } + if (_best == noone || x < _best_x) { + _best = id; + _best_x = x; + } + } + return _best; +} - ponies = target_object.dudes_num[target_type]; - if ((target_object.dudes_num[target_type] == 1) && ((target_object.dudes_hp[target_type] - c) <= 0)) { - casualties = 1; - } +/// @self Asset.GMObject.obj_pnunit +/// @description Speed Force: sweep the whole enemy force, dividing damage proportionally to rank +/// size, and report it as ONE consolidated volley line (see emit_volley_flavour). +/// @param {Real} weapon_index_position The Speed Force weapon stack index. +function scr_shoot_spread(weapon_index_position) { + try { + if (wep_num[weapon_index_position] <= 0 || ammo[weapon_index_position] == 0) { + exit; + } - if (target_object.dudes_num[target_type] - casualties < 0) { - overkill = casualties - target_object.dudes_num[target_type]; - damage_remaining = c - (overkill * target_object.dudes_hp[target_type]); + var _shots = wep_num[weapon_index_position]; + var _ap = apa[weapon_index_position]; + var _dpw = att[weapon_index_position] / _shots; // per-bike damage + var _mod = max(1, splash[weapon_index_position]); + if (ammo[weapon_index_position] > 0) { + ammo[weapon_index_position] -= 1; + } - shots_remaining = round(damage_remaining / damage_per_weapon); - } + // Armour multiplier indexed by AP rating (1..4), matching scr_shoot's normal path. + var _inf_ap = [1, 3, 2, 1.5, 0]; + var _veh_ap = [1, 6, 4, 2, 0]; + var _ap_valid = (_ap >= 1) && (_ap <= 4); + + // Total living models across every formation on the field. + var _formations = []; + var _total = 0; + with (obj_enunit) { + array_push(_formations, id); + for (var r = 1; r <= 30; r++) { + if (dudes[r] != "" && dudes_num[r] > 0) { + _total += dudes_num[r]; + } + } + } + if (_total <= 0) { + exit; + } - if (target_object.dudes_num[target_type] - casualties < 0) { - casualties = ponies; - } - if (casualties < 0) { - casualties = 0; - } + // Apply damage proportionally to each rank's share of the field; record every rank that lost models. + var _hits = []; // [{ name, kills, bounced }] + for (var fi = 0; fi < array_length(_formations); fi++) { + var _f = _formations[fi]; + if (!instance_exists(_f)) { + continue; + } + for (var r = 1; r <= 30; r++) { + if (_f.dudes[r] == "" || _f.dudes_num[r] <= 0) { + continue; + } - if (casualties >= 1) { - var iii = 0, found = 0, openz = 0; - for (iii = 0; iii <= 40; iii++) { - iii += 1; - if (found == 0) { - if ((obj_ncombat.dead_ene[iii] == "") && (openz == 0)) { - openz = iii; - } - if ((obj_ncombat.dead_ene[iii] == target_object.dudes[target_type]) && (found == 0)) { - found = iii; - obj_ncombat.dead_ene_n[obj_ncombat.dead_enemies] += casualties; - } - } - } - if (found == 0) { - obj_ncombat.dead_enemies += 1; - obj_ncombat.dead_ene[openz] = string(target_object.dudes[target_type]); - obj_ncombat.dead_ene_n[openz] = casualties; - } - } + var _armour = _f.dudes_ac[r]; + if (_ap_valid) { + var _ap_table = _f.dudes_vehicle[r] ? _veh_ap : _inf_ap; + _armour *= _ap_table[_ap]; + } - var k = 0; - if ((damage_remaining > 0) && (shots_remaining > 0)) { - repeat (10) { - if ((damage_remaining > 0) && (shots_remaining > 0)) { - var godd; - godd = 0; - k = target_type; - - // Find similar target in this same group - repeat (10) { - k += 1; - if (godd == 0) { - if ((target_object.dudes_num[k] > 0) && (target_object.dudes_vehicle[k] == target_object.dudes_vehicle[target_type])) { - godd = k; - } - } - } - k = target_type; - if (godd == 0) { - repeat (10) { - k -= 1; - if ((godd == 0) && (k >= 1)) { - if ((target_object.dudes_num[k] > 0) && (target_object.dudes_vehicle[k] == target_object.dudes_vehicle[target_type])) { - godd = k; - } - } - } - } - - // Found damage_per_weapon similar target to get the damage - if ((godd > 0) && (damage_remaining > 0) && (shots_remaining > 0)) { - var a2, b2, c2, target_armour_value2, ap2; - ap2 = damage_remaining; - a2 = damage_per_weapon; // Average damage - - target_armour_value2 = target_object.dudes_ac[godd]; - if (target_object.dudes_vehicle[godd] == 0) { - if (ap2 == 1) { - target_armour_value2 = target_armour_value2 * 3; - } - if (ap2 == 2) { - target_armour_value2 = target_armour_value2 * 2; - } - if (ap2 == 3) { - target_armour_value2 = target_armour_value2 * 1.5; - } - if (ap2 == 4) { - target_armour_value2 = 0; - } - } - if (target_object.dudes_vehicle[godd] == 1) { - if (ap2 == 1) { - target_armour_value2 = target_armour_value2 * 6; - } - if (ap2 == 2) { - target_armour_value2 = target_armour_value2 * 4; - } - if (ap2 == 3) { - target_armour_value2 = target_armour_value2 * 2; - } - } - b2 = a2 - target_armour_value2; - if (b2 <= 0) { - b2 = 0; - } // Average after armour - - c2 = b2 * shots_remaining; // New damage - - var casualties2, ponies2, onceh2; - onceh2 = 0; - ponies2 = 0; - if (attack_count_mod <= 1) { - casualties2 = min(floor(c2 / target_object.dudes_hp[godd]), shots_remaining); - } - - if (attack_count_mod > 1) { - casualties2 = floor(c2 / target_object.dudes_hp[godd]); - } - ponies2 = target_object.dudes_num[godd]; - if ((target_object.dudes_num[godd] == 1) && ((target_object.dudes_hp[godd] - c2) <= 0)) { - casualties2 = 1; - } - if (target_object.dudes_num[godd] < casualties2) { - casualties2 = target_object.dudes_num[godd]; - } - if (casualties2 < 1) { - casualties2 = 0; - damage_remaining = 0; - overkill = 0; - shots_remaining = 0; - } - - if ((casualties2 >= 1) && (shots_fired > 0)) { - var iii, found, openz; - iii = 0; - found = 0; - openz = 0; - repeat (40) { - iii += 1; - if (found == 0) { - if ((obj_ncombat.dead_ene[iii] == "") && (openz == 0)) { - openz = iii; - } - if ((obj_ncombat.dead_ene[iii] == target_object.dudes[godd]) && (found == 0)) { - found = iii; - obj_ncombat.dead_ene_n[obj_ncombat.dead_enemies] += casualties; - } - } - } - if (found == 0) { - obj_ncombat.dead_enemies += 1; - obj_ncombat.dead_ene[openz] = string(target_object.dudes[godd]); - obj_ncombat.dead_ene_n[openz] = casualties; - } - - /*obj_ncombat.dead_enemies+=1; - if (casualties2=1) then obj_ncombat.dead_ene[obj_ncombat.dead_enemies]="1 "+string(target_object.dudes[godd]); - if (casualties2>1) then obj_ncombat.dead_ene[obj_ncombat.dead_enemies]=string(casualties2)+" "+string(target_object.dudes[godd]); - obj_ncombat.dead_enemies+=1; - obj_ncombat.dead_ene[obj_ncombat.dead_enemies]=string(target_object.dudes[godd]); - obj_ncombat.dead_ene_n[obj_ncombat.dead_enemies]=casualties;*/ - - target_object.dudes_num[godd] -= casualties2; - obj_ncombat.enemy_forces -= casualties2; - } - - if (casualties2 >= 1) { - if (target_object.dudes_num[godd] <= 0) { - overkill = casualties2 - target_object.dudes_num[godd]; - damage_remaining -= casualties2 * target_object.dudes_hp[godd]; - - var proportional_shots; - proportional_shots = round(damage_remaining / a2); - shots_remaining = proportional_shots; - - // show_message("killed "+string(casualties2)+"x "+string(target_object.dudes[godd])); - // show_message("did "+string(c)+" damage with "+string(proportional_shots)+" shots fired, have "+string(damage_remaining)+" damage remaining"); - } - } - } - } - } - } // End repeat 10 - scr_flavor(weapon_index_position, target_object, target_type, shots_fired - wep_rnum[weapon_index_position], casualties); + var _rank_shots = _shots * (_f.dudes_num[r] / _total); + var _final_hit = max(0, (_dpw - (_armour * _mod)) * _f.dudes_dr[r]); + var _kills = min(floor((_rank_shots * _final_hit) / _f.dudes_hp[r]), _f.dudes_num[r]); + if (_kills < 0) { + _kills = 0; + } - if ((target_object.dudes_num[target_type] == 1) && (c > 0)) { - target_object.dudes_hp[target_type] -= c; - } // Need special flavor here for just damaging + if (_kills > 0) { + _f.dudes_num[r] -= _kills; + obj_ncombat.enemy_forces -= _kills; + array_push(_hits, { name: _f.dudes[r], kills: _kills, bounced: (_final_hit <= 0), block: _f, rank: r }); + } + } + } - if (casualties >= 1) { - target_object.dudes_num[target_type] -= casualties; - obj_ncombat.enemy_forces -= casualties; - } + // Primary = the rank with the most kills (rich deferred flavour); the rest form the kill list. + var _primary = undefined; + var _spill = []; + if (array_length(_hits) > 0) { + var _best = 0; + for (var i = 1; i < array_length(_hits); i++) { + if (_hits[i].kills > _hits[_best].kills) { + _best = i; + } + } + for (var i = 0; i < array_length(_hits); i++) { + if (i == _best) { + continue; } + array_push(_spill, { name: _hits[i].name, count: _hits[i].kills }); } + var _p = _hits[_best]; + if (instance_exists(_p.block)) { + _primary = scr_flavor(weapon_index_position, _p.block, _p.rank, _shots, _p.kills, _p.bounced, true); + } + } + emit_volley_flavour(_primary, _spill); - if (stop == 0) { - compress_enemy_array(target_object); - destroy_empty_column(target_object); + // Clean up spent ranks/formations (mirrors scr_shoot). + for (var fi = 0; fi < array_length(_formations); fi++) { + if (instance_exists(_formations[fi])) { + compress_enemy_array(_formations[fi]); + destroy_empty_column(_formations[fi]); } } } catch (_exception) { diff --git a/scripts/scr_special_view/scr_special_view.gml b/scripts/scr_special_view/scr_special_view.gml index e597e6387b..08ff2b466e 100644 --- a/scripts/scr_special_view/scr_special_view.gml +++ b/scripts/scr_special_view/scr_special_view.gml @@ -72,6 +72,18 @@ function scr_special_view(command_group) { } } + if ((command_group == 16) || (command_group == 0)) { + // Auxilia (Guardsmen and other auxiliary mercs). Gathered by role, not specialist + // group, since they are mustered into company 0 with race IMPERIUM but are not Astartes + // specialists. auxilia_roles() is the single source of truth shared with the HQ exclusion. + var auxilia = collect_role_group("all", "", false, {roles: auxilia_roles()}); + for (var i = 0; i < array_length(auxilia); i++) { + unit = auxilia[i]; + array_push(_already_used, unit.marine_number); + add_man_to_manage_arrays(auxilia[i]); + } + } + if ((command_group == 11) || (command_group == 0)) { //HQ units for (var v = 0; v < array_length(obj_ini.TTRPG[0]); v++) { @@ -88,6 +100,8 @@ function scr_special_view(command_group) { } yep = !(_unit.IsSpecialist(SPECIALISTS_TECHS) || _unit.IsSpecialist(SPECIALISTS_CHAPLAINS) || _unit.IsSpecialist(SPECIALISTS_LIBRARIANS) || _unit.IsSpecialist(SPECIALISTS_APOTHECARIES)); + // Auxilia mercs live in company 0 but belong to the Auxilia screen, not Headquarters. + yep = yep && !array_contains(auxilia_roles(), _unit.role()); if (yep) { add_man_to_manage_arrays(_unit); } diff --git a/scripts/scr_specialist_point_handler/scr_specialist_point_handler.gml b/scripts/scr_specialist_point_handler/scr_specialist_point_handler.gml index 97aa509017..c719e838a8 100644 --- a/scripts/scr_specialist_point_handler/scr_specialist_point_handler.gml +++ b/scripts/scr_specialist_point_handler/scr_specialist_point_handler.gml @@ -1,5 +1,4 @@ function SpecialistPointHandler() constructor { - static chapter_spread = calculate_full_chapter_spread; forge_queue = []; techs = []; apoths = []; @@ -239,7 +238,7 @@ function SpecialistPointHandler() constructor { var _new_pursuasion; for (var i = 0; i < array_length(techs) && heretics_persuade_chances > 0; i++) { _same_location = false; - var _new_pursuasion = array_random_index(techs); + _new_pursuasion = array_random_index(techs); //if tech is also heretic skip if (array_contains(heretics, _new_pursuasion)) { continue; @@ -291,7 +290,6 @@ function SpecialistPointHandler() constructor { _noticed_heresy = true; scr_event_log("purple", $"{techs[forge_master].name_role()} Has noticed signs of tech heresy amoung the Armentarium ranks"); scr_alert("purple", "Tech Heresy", $"{techs[forge_master].name_role()} Has noticed signs of tech heresy amoung the Armentarium ranks"); - //pip=instance_create(0,0,obj_popup); } } } @@ -302,18 +300,10 @@ function SpecialistPointHandler() constructor { } } //add check to see if tech heretic is anywhere near mechanicus forge if so maybe do stuff?? - /*if (_heretic_location==eLOCATION_TYPES.PLANET){ - if - }*/ } if (array_length(techs) > array_length(heretics) && !_heritecs) { if (array_length(heretics) / array_length(techs) >= 0.35) { if (!irandom(9)) { - /*var text_string = "You Recive an Urgent Transmision from"; - if (forge_master>-1){ - - }*/ - tech_uprising_event(); } } @@ -517,7 +507,4 @@ function SpecialistPointHandler() constructor { ERROR_HANDLER.handle_exception(_exception); } }; - /*static apothecary_points_calc(){ - - }*/ } diff --git a/scripts/scr_specialist_points/scr_specialist_points.gml b/scripts/scr_specialist_points/scr_specialist_points.gml index 1789dc2aa9..b46792f589 100644 --- a/scripts/scr_specialist_points/scr_specialist_points.gml +++ b/scripts/scr_specialist_points/scr_specialist_points.gml @@ -3,7 +3,7 @@ function unit_apothecary_points_gen(turn_end = false) { var reasons = {}; var points = 0; if (_trained_person) { - var points = ((technology / 2) + (wisdom / 2) + intelligence) / 8; + points = ((technology / 2) + (wisdom / 2) + intelligence) / 8; reasons.points = points; } return [points, reasons]; @@ -15,7 +15,7 @@ function unit_forge_point_generation(turn_end = false) { var reasons = {}; var points = 0; if (_trained_person) { - var points = technology / 5; + points = technology / 5; reasons.trained = points; } if (job != "none") { diff --git a/scripts/scr_specialist_training/scr_specialist_training.gml b/scripts/scr_specialist_training/scr_specialist_training.gml index cdc28f5404..93cdf547e6 100644 --- a/scripts/scr_specialist_training/scr_specialist_training.gml +++ b/scripts/scr_specialist_training/scr_specialist_training.gml @@ -1,4 +1,6 @@ /// @self Struct.TTRPG_stats +/// @param {String} specialist +/// @param {Real} req_exp function specialistfunct(specialist, req_exp) { var spec_tips = [ string("{0} Potential", obj_ini.role[100][16]), @@ -92,6 +94,7 @@ function specialistfunct(specialist, req_exp) { // Parameters: // specialist - Integer index (0: Techmarine, 1: Librarian, 2: Chaplain, 3: Apothecary) // Returns: Array containing company and position of selected marine, or "none" if no suitable marine found +/// @param {Real} specialist function spec_data_set(specialist) { var _data = obj_controller.spec_train_data[specialist]; var _search = { @@ -127,11 +130,7 @@ function apothecary_training() { if (apothecary_recruit_points >= 48) { if (recruit_count > 0) { var random_marine = scr_random_marine(novice_type, 0); - // show_message(marine_position); - // show_message(obj_ini.role[0,marine_position]); if (random_marine != "none") { - marine_position = random_marine[1]; - marine_company = random_marine[0]; apothecary_recruit_points -= 48; /// @type {Struct.TTRPG_stats} var unit = fetch_unit(random_marine); @@ -211,7 +210,6 @@ function chaplain_training() { if (recruit_count > 0) { var random_marine = scr_random_marine(novice_type, 0); if (random_marine != "none") { - marine_position = random_marine[1]; var unit = fetch_unit(random_marine); scr_alert("green", "recruitment", unit.name_role() + " has finished training.", 0, 0); chaplain_points -= 48; @@ -288,7 +286,6 @@ function librarian_training() { recruit_count = scr_role_count(novice_type, ""); if (psyker_points >= goal) { if (recruit_count > 0) { - marine_position = 0; var random_marine = scr_random_marine(novice_type, 0, {"stat": [["psionic", 2, "more"]]}); if (random_marine != "none") { var unit = fetch_unit(random_marine); @@ -357,11 +354,10 @@ function techmarine_training() { var novice_type = string("{0} Aspirant", obj_ini.role[100][16]); if (training_techmarine > 0) { recruit_count = scr_role_count(novice_type, ""); + var _threshold = 252; if (obj_controller.faction_status[eFACTION.MECHANICUS] != "War") { - var _threshold = 360; - } else { - var _threshold = 252; + _threshold = 360; } if (tech_points >= _threshold) { diff --git a/scripts/scr_sprite_helpers/scr_sprite_helpers.gml b/scripts/scr_sprite_helpers/scr_sprite_helpers.gml index 4d512b072b..86dd088349 100644 --- a/scripts/scr_sprite_helpers/scr_sprite_helpers.gml +++ b/scripts/scr_sprite_helpers/scr_sprite_helpers.gml @@ -7,18 +7,16 @@ function draw_sprite_flipped(_sprite, _subimg, _x, _y) { } /// @function return_sprite_mirrored(sprite) -/// @param sprite The sprite index to mirror -/// @returns A new sprite index that is the mirrored version -/// @function return_sprite_mirrored(sprite) -/// @param sprite The sprite index to mirror -/// @returns A new sprite index that is the mirrored version +/// @param {Asset.GMSprite} _spr The sprite index to mirror +/// @param {Bool} delete_sprite +/// @returns {Asset.GMSprite} A new sprite index that is the mirrored version function return_sprite_mirrored(_spr, delete_sprite = true) { var _w = sprite_get_width(_spr); var _h = sprite_get_height(_spr); var _frames = sprite_get_number(_spr); // New mirrored sprite we’ll build - var _new_sprite = -1; + var _new_sprite = undefined; for (var _i = 0; _i < _frames; _i++) { // Create surface for this frame diff --git a/scripts/scr_squads/scr_squads.gml b/scripts/scr_squads/scr_squads.gml index eaafb6a7ca..7cabad2454 100644 --- a/scripts/scr_squads/scr_squads.gml +++ b/scripts/scr_squads/scr_squads.gml @@ -242,10 +242,6 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { uid = scr_uuid_generate(); allow_bulk_swap = true; - if (squad_type != undefined) { - change_type(squad_type); - } - //TODO introduce loyalty hits from long periods of exile from hierarchy nodes // nodes will be captains chapter masters and other senior staff time_from_parent_node = 0; @@ -286,6 +282,10 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { add_type_data(obj_ini.squad_types[$ type].type_data); }; + if (squad_type != undefined) { + change_type(squad_type); + } + static find_squad_unit_types = function() { //find out what type of units squad consists of var fill_squad = obj_ini.squad_types[$ type]; @@ -586,14 +586,13 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { //this means the highest ranking dude in a squad will always be the squad leader //failing that the highest experience dude static determine_leader = function() { - var _unit; var member_length = array_length(members); var hierarchy = role_hierarchy(); var leader_hier_pos = array_length(hierarchy); - var leader = "none", _unit; + var leader = "none"; var highest_exp = 0; for (var i = 0; i < member_length; i++) { - _unit = fetch_unit(members[i]); + var _unit = fetch_unit(members[i]); if (_unit.name() == "") { array_delete(members, i, 1); member_length--; @@ -656,24 +655,23 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { static set_location = function(loc, lid, wid) { var member_length = array_length(members); var member_location; - var system = "none"; + var system = noone; with (obj_star) { if (name == loc) { system = self; break; } } - if (system == "none") { + if (system == noone) { return "invalid system"; } member_loop(set_member_loc, {loc: loc, lid: lid, wid: wid, system: system}); }; static member_loop = function(member_func, data_pack) { - var _unit; member_length = array_length(members); for (var i = 0; i < member_length; i++) { - _unit = fetch_unit(members[i]); + var _unit = fetch_unit(members[i]); if (_unit.name() == "") { array_delete(members, i, 1); member_length--; diff --git a/scripts/scr_start_load/scr_start_load.gml b/scripts/scr_start_load/scr_start_load.gml index f35b38b27d..700fcc16b8 100644 --- a/scripts/scr_start_load/scr_start_load.gml +++ b/scripts/scr_start_load/scr_start_load.gml @@ -55,7 +55,7 @@ function scr_start_load(fleet, load_from_star, load_options) { } } // i feel like there definatly is or should be a generic function for this???? - var _vehicles = ["Rhino", "Predator", "Land Speeder", "Land Raider", "Whirlwind"]; + var _vehicles = ["Rhino", "Predator", "Land Speeder", "Land Raider", "Whirlwind", "Chimera", "Leman Russ", "Basilisk"]; function load_vehicles(_companies, _equip, _ship, size) { obj_ini.veh_wid[_companies][_equip] = 0; obj_ini.veh_lid[_companies][_equip] = _ship; diff --git a/scripts/scr_system_search_helpers/scr_system_search_helpers.gml b/scripts/scr_system_search_helpers/scr_system_search_helpers.gml index 796720a22f..7ef17e63bc 100644 --- a/scripts/scr_system_search_helpers/scr_system_search_helpers.gml +++ b/scripts/scr_system_search_helpers/scr_system_search_helpers.gml @@ -74,8 +74,8 @@ function scr_star_has_planet_with_feature(star, feature) { return scr_get_planet_with_feature(star, feature) != -1; } -function scr_planet_owned_by_group(planet_id, group, star = "none") { - if (star == "none") { +function scr_planet_owned_by_group(planet_id, group, star = noone) { + if (star == noone) { return array_contains(group, p_owner[planet_id]); } else { var is_in_group = false; @@ -133,9 +133,9 @@ function stars_with_faction_fleets(search_faction) { return _stars_with_fleets; } -function planets_without_type(type, star = "none") { +function planets_without_type(type, star = noone) { var return_planets = []; - if (star == "none") { + if (star == noone) { for (var i = 1; i <= planets; i++) { if (p_type[i] != type) { array_push(return_planets, i); @@ -172,10 +172,8 @@ function scr_get_stars(shuffled = false, ownership = [], types = []) { var _owner_sort = array_length(ownership); var _types_sort = array_length(types); with (obj_star) { - if (!_owner_sort && !_types_sort) { - var _add = true; - } else { - var _add = true; + var _add = true; + if (_owner_sort || _types_sort) { if (_owner_sort && !array_contains(ownership, owner)) { _add = false; } @@ -208,11 +206,11 @@ function planet_imperium_ground_total(planet_check) { /// @function find_star_by_name(search_name) /// @description Searches all `obj_star` instances and returns the one with a matching name. /// @param {String} search_name The name of the star to find. -/// @returns {Id.Instance.obj_star | String} Returns the `obj_star` instance that matches `search_name`, or the string `"none"` if no matching star is found. +/// @returns {Id.Instance.obj_star | noone} Returns the `obj_star` instance that matches `search_name`, or the 'noone' object reference if no matching star is found. function find_star_by_name(search_name) { if (!instance_exists(obj_star)) { ERROR_HANDLER.assert_popup("Not a single instance of obj_star exists!"); - return "none"; + return noone; } with (obj_star) { @@ -221,7 +219,7 @@ function find_star_by_name(search_name) { } } - return "none"; + return noone; } //use this to quickly make a loop through a stars planets in an unordered way @@ -308,7 +306,7 @@ function distance_removed_star(origional_x, origional_y, star_offset = choose(2, } function nearest_star_proper(xx, yy) { - var cur_star; + var cur_star = noone; for (var i = 0; i < 100; i++) { cur_star = instance_nearest(xx, yy, obj_star); if (!cur_star.craftworld && !cur_star.space_hulk) { @@ -317,24 +315,24 @@ function nearest_star_proper(xx, yy) { } instance_deactivate_object(cur_star.id); } - return "none"; + return noone; } -function nearest_star_with_ownership(xx, yy, ownership, start_star = "none", ignore_dead = true) { - var nearest = "none"; +function nearest_star_with_ownership(xx, yy, ownership, start_star = noone, ignore_dead = true) { + var nearest = noone; var _deactivated = []; var total_stars = instance_number(obj_star); var i = 0; if (!is_array(ownership)) { ownership = [ownership]; } - while (nearest == "none" && i < total_stars) { + while (nearest == noone && i < total_stars) { i++; var cur_star = instance_nearest(xx, yy, obj_star); if (!instance_exists(cur_star)) { break; } - if (start_star != "none") { + if (start_star != noone) { if (start_star.id == cur_star.id || (ignore_dead && is_dead_star(cur_star))) { array_push(_deactivated, cur_star.id); instance_deactivate_object(cur_star.id); @@ -369,13 +367,11 @@ function find_population_doners(doner_to = 0) { return pop_doner_options; } -function planet_numeral_name(planet, star = "none") { - if (star == "none") { - //LOGGER.debug($"{planet}, numeral name") +function planet_numeral_name(planet, star = noone) { + if (star == noone) { return $"{name} {int_to_roman(planet)}"; } else { with (star) { - //LOGGER.debug($"{planet}, numeral name") return $"{name} {int_to_roman(planet)}"; } } @@ -400,9 +396,9 @@ function nearest_from_array(xx, yy, list) { return _nearest; } -function is_dead_star(star = "none") { +function is_dead_star(star = noone) { var dead_star = true; - if (star == "none") { + if (star == noone) { for (var i = 1; i <= planets; i++) { if (string_lower(p_type[i]) != "dead") { dead_star = false; @@ -489,15 +485,6 @@ function scr_planet_image_numbers(p_type) { return 0; } -//function scr_get_player_fleets() { -// var player_fleets = []; -// with(obj_p_fleet){ -// array_push(player_fleets,id); -// } -// return player_fleets; - -//} - /// @param {Id.Instance.obj_star} star /// @param {Enum.eFACTION} faction /// @param {Real} minimum_strength diff --git a/scripts/scr_system_spawn_functions/scr_system_spawn_functions.gml b/scripts/scr_system_spawn_functions/scr_system_spawn_functions.gml index b3e7f09945..046faa0f6f 100644 --- a/scripts/scr_system_spawn_functions/scr_system_spawn_functions.gml +++ b/scripts/scr_system_spawn_functions/scr_system_spawn_functions.gml @@ -25,6 +25,7 @@ enum ePLAYER_BASE { function find_player_spawn_star() { instance_activate_object(obj_star); var _spawn_star; + var _chosen_star = noone; var _allowable = false; var _allowables = [ "Temperate", @@ -36,7 +37,8 @@ function find_player_spawn_star() { "Lava" ]; for (var i = 0; i < 100; i++) { - var y_loc, x_loc; + var x_loc = irandom_range(0 + (room_width / 2), room_width - (room_width / 2)); + var y_loc = irandom_range(0 + (room_height / 2), room_height - (room_height / 2)); if (obj_ini.homeworld_relative_loc == 0) { if (irandom(1)) { y_loc = choose(0, room_height); @@ -45,11 +47,8 @@ function find_player_spawn_star() { x_loc = choose(0, room_width); y_loc = irandom(room_height); } - } else { - x_loc = irandom_range(0 + (room_width / 2), room_width - (room_width / 2)); - y_loc = irandom_range(0 + (room_height / 2), room_height - (room_height / 2)); } - var _chosen_star = instance_nearest(x_loc, y_loc, obj_star); + _chosen_star = instance_nearest(x_loc, y_loc, obj_star); if (instance_exists(_chosen_star)) { for (var p = 0; p < array_length(_chosen_star.p_type); p++) { if (array_contains(_allowables, _chosen_star.p_type[p])) { @@ -66,6 +65,7 @@ function find_player_spawn_star() { return _chosen_star.id; } +/// @self Id.Instance.obj_star function player_home_star(home_planet) { var _star_names = global.name_generator.name_sets.star; p_type[home_planet] = obj_ini.home_type; @@ -75,7 +75,7 @@ function player_home_star(home_planet) { if (obj_ini.home_name != "random") { _star_names.AddUsedName(obj_ini.home_name); var _old_name_star = find_star_by_name(obj_ini.home_name); - if (_old_name_star != "none") { + if (_old_name_star != noone) { _old_name_star.name = global.name_generator.GenerateFromSet("star", false); } name = obj_ini.home_name; @@ -114,10 +114,9 @@ function player_home_star(home_planet) { p_player[home_planet] = obj_ini.man_size; - var unit; for (var co = 0; co <= obj_ini.companies; co++) { - for (i = 0; i < array_length(obj_ini.name[co]); i++) { - unit = fetch_unit([co, i]); + for (var i = 0; i < array_length(obj_ini.name[co]); i++) { + var unit = fetch_unit([co, i]); if (unit.location_string == name) { unit.planet_location = home_planet; } @@ -133,7 +132,7 @@ function set_player_recruit_planet(recruit_planet) { var recruit_name = obj_ini.recruiting_name; if (recruit_name != "random") { _star_names.AddUsedName(recruit_name); - if (find_star_by_name(recruit_name) != "none") { + if (find_star_by_name(recruit_name) != noone) { find_star_by_name(recruit_name).name = global.name_generator.GenerateFromSet("star", false); } name = recruit_name; @@ -141,7 +140,7 @@ function set_player_recruit_planet(recruit_planet) { } else { if (obj_ini.home_name != "random") { _star_names.AddUsedName(obj_ini.home_name); - if (find_star_by_name(obj_ini.home_name) != "none") { + if (find_star_by_name(obj_ini.home_name) != noone) { find_star_by_name(obj_ini.home_name).name = global.name_generator.GenerateFromSet("star", false); } name = obj_ini.home_name; diff --git a/scripts/scr_trade/scr_trade.gml b/scripts/scr_trade/scr_trade.gml index 76753d5db6..9dffdfdfa2 100644 --- a/scripts/scr_trade/scr_trade.gml +++ b/scripts/scr_trade/scr_trade.gml @@ -17,6 +17,8 @@ function TradeAttempt(diplomacy) constructor { "Inferno Bolts": 5, "Sister of Battle": 40, "Sister Hospitaler": 75, + "Guardsman": 0.1, + "Leman Russ": 800, "Eldar Power Sword": 50, "Archeotech Laspistol": 150, "Ranger": 100, @@ -83,13 +85,86 @@ function TradeAttempt(diplomacy) constructor { } else if (_opt.trade_type == "req") { obj_controller.requisition += _opt.number; } else if (_opt.trade_type == "merc") { - if (!struct_exists(trading_object, "mercenaries")) { - trading_object.mercenaries = {}; + if (_type == "Guardsman") { + // The Sector Governor raises the regiment straight from his homeworld + // PDF, so they muster at the chapter's home planet at once with no + // convoy. An earlier patch dropped this and routed them onto the + // convoy stash instead, so they never arrived; this restores it. + repeat (_opt.number) { + scr_add_man("Guardsman", 0, "", "", 0, true, "home_planet", {skip_company_order: true}); + } + // One Guard Sergeant musters with every full squad of GUARD_SQUAD_SIZE + // guardsmen, raised from the same homeworld levy and attached to his men. He + // rides the same path as a guardsman, just a tougher melee-focused profile. + repeat (floor(_opt.number / GUARD_SQUAD_SIZE)) { + scr_add_man("Guard Sergeant", 0, "", "", 0, true, "home_planet", {skip_company_order: true}); + } + // One Chimera transport is assigned per 200 guardsmen to carry and screen the + // levy. They muster into the Auxilia company (company 0) alongside the guardsmen, + // not the transient new_vehicles staging company, so they stay grouped with the + // levy and persist after the battle instead of being reorganised out of the + // build-staging slot. + repeat (floor(_opt.number / 200)) { + scr_add_vehicle("Chimera", 0); + } + // One Heavy Weapons Team musters per 100 guardsmen, a Heavy Bolter crew + // drawn from the same homeworld levy to give the auxilia organic anti-heavy + // fire. This mirrors how the enemy Guard field Heavy Weapons Teams, scaled to + // the player at 1 per 100. They muster into the Auxilia company (company 0) + // alongside the guardsmen. The /100 ratio is tunable. + repeat (floor(_opt.number / 100)) { + scr_add_man("Heavy Weapons Team", 0, "", "", 0, true, "home_planet", {skip_company_order: true}); + } + with (obj_ini) { + scr_company_order(0); + } + // Space Marines commandeering Imperial Guard is frowned upon since the + // Heresy and the reign of Goge Vandire, so the Sector Governor's regard dips + // with the size of the levy: about 1 per 200 raised (so a full 2000 costs 10), + // floored at 1 so even a token request costs a little standing. + alter_disposition(diplomacy_faction, -max(1, round(_opt.number / 200))); + } else if (_type == "Leman Russ") { + // The Adeptus Mechanicus forge and part with their tanks reluctantly. Each + // Leman Russ musters into the Auxilia company (company 0) alongside the guard + // levy so the force can field its own armour line, then the company is reordered + // so the tanks settle into their slots. + repeat (_opt.number) { + scr_add_vehicle("Leman Russ", 0); + } + with (obj_ini) { + scr_company_order(0); + } + // Handing over sacred war materiel costs the forge world some regard, one point + // per tank with a floor of one, so a larger order stings their disposition more. + alter_disposition(diplomacy_faction, -max(1, _opt.number)); + } else if (_type == "Basilisk") { + // The Adeptus Mechanicus part with a Basilisk only grudgingly. Each musters + // into the Auxilia company (company 0) alongside the guard armour line so the + // force can field its own artillery. The Basilisk serves the Imperial Guard + // auxilia, not the Chapter, so it is tagged eFACTION.IMPERIUM to match the + // guardsmen it supports rather than the player's own colours. + repeat (_opt.number) { + scr_add_vehicle("Basilisk", 0); + } + for (var _bv = 1; _bv < array_length(obj_ini.veh_role[0]); _bv++) { + if (obj_ini.veh_role[0][_bv] == "Basilisk") { + obj_ini.veh_race[0][_bv] = eFACTION.IMPERIUM; + } + } + with (obj_ini) { + scr_company_order(0); + } + alter_disposition(diplomacy_faction, -max(1, _opt.number)); + } else { + // Every other mercenary type arrives by trade convoy. + if (!struct_exists(trading_object, "mercenaries")) { + trading_object.mercenaries = {}; + } + trading_object.mercenaries[$ _type] = { + quality: "standard", + number: _opt.number, + }; } - trading_object.mercenaries[$ _type] = { - quality: "standard", - number: _opt.number, - }; } else if (_opt.trade_type == "arti") { scr_add_artifact("random", "minor", true); } else if (_opt.trade_type == "vehic") { @@ -359,7 +434,6 @@ function TradeAttempt(diplomacy) constructor { _option.disabled = true; _option.tooltip = $"{trade_disp} disposition required"; } - //_option.bind_scope = _option; array_push(demand_options, _option); }; @@ -373,6 +447,7 @@ function TradeAttempt(diplomacy) constructor { switch (diplomacy_faction) { case 2: new_demand_buttons(0, "Requisition", "req"); + new_demand_buttons(35, "Guardsman", "merc", 2000); new_demand_buttons(0, "Recruiting Planet", "license", 1); new_demand_buttons(0, "License: Repair", "license", 1); new_demand_buttons(0, "License: Crusade", "license", 1); @@ -381,6 +456,8 @@ function TradeAttempt(diplomacy) constructor { new_demand_buttons(40, "Minor Artifact", "arti", 1); new_demand_buttons(25, "Skitarii", "merc", 200); new_demand_buttons(55, "Techpriest", "merc", 3); + new_demand_buttons(40, "Leman Russ", "merc", 10); + new_demand_buttons(50, "Basilisk", "merc", 5); break; case 4: new_demand_buttons(25, "Crusader", "merc", 5); @@ -388,7 +465,6 @@ function TradeAttempt(diplomacy) constructor { new_demand_buttons(60, "Cyclonic Torpedo", "equip", 1); break; case 5: - //new_demand_buttons(30, "Inferno Bolts", "equip"); new_demand_buttons(40, "Sister of Battle", "merc", 5); new_demand_buttons(45, "Sister Hospitaler", "merc", 3); break; @@ -468,7 +544,6 @@ function TradeAttempt(diplomacy) constructor { draw_set_font(fnt_40k_14); draw_set_color(CM_GREEN_COLOR); var _requested_count = 0; - //if (obj_controller.trading_artifact = 0){ for (var i = 0; i < array_length(demand_options); i++) { var _opt = demand_options[i]; if (_opt.number != _opt.number_last) { @@ -496,9 +571,8 @@ function TradeAttempt(diplomacy) constructor { _requested_count++; } } - //} - var _requested_count = 0; + _requested_count = 0; draw_text(507, 529, $"{global.chapter_name}:"); for (var i = 0; i < array_length(offer_options); i++) { var _opt = offer_options[i]; @@ -675,6 +749,33 @@ function TradeAttempt(diplomacy) constructor { deal_chance = (100 - penalty) - (their_worth - (my_worth * dif_penalty)); //LOGGER.debug($"{their_worth},{my_worth},{deal_chance}"); + + // Guardsmen are abundant Imperial line troops the Sector Governor hands over by the + // thousand, not a haggled rarity, so the base trade overhead does not apply to a + // pure Guard levy. They cost a flat 0.1 requisition each (100 per 1000). If the + // offered requisition covers the guardsmen demanded the Governor obliges outright, + // otherwise he declines. Only triggers when guardsmen are the sole demand, so it + // cannot be used to slip other goods through cheaply. + var _guard_num = 0; + var _other_demand = false; + for (var gi = 0; gi < array_length(demand_options); gi++) { + if (demand_options[gi].number > 0) { + if (demand_options[gi].label == "Guardsman") { + _guard_num += demand_options[gi].number; + } else { + _other_demand = true; + } + } + } + if ((_guard_num > 0) && !_other_demand) { + var _req_offered = 0; + for (var ri = 0; ri < array_length(offer_options); ri++) { + if (offer_options[ri].label == "Requisition") { + _req_offered += offer_options[ri].number; + } + } + deal_chance = _req_offered >= ceil(_guard_num * 0.1) ? 100 : 0; + } var _chance = clamp(floor((deal_chance / 20)), 0, 6); trade_likely = chance_chart[_chance]; diff --git a/scripts/scr_trade_dep/scr_trade_dep.gml b/scripts/scr_trade_dep/scr_trade_dep.gml index bd5bf465f5..6506d37f27 100644 --- a/scripts/scr_trade_dep/scr_trade_dep.gml +++ b/scripts/scr_trade_dep/scr_trade_dep.gml @@ -1,13 +1,23 @@ +/// @self Id.Instance.obj_en_fleet function scr_trade_dep() { var _goods = cargo_data.player_goods; //LOGGER.debug($"trade goods : {_goods}"); if (struct_exists(_goods, "mercenaries")) { var _mercs = struct_get_names(_goods.mercenaries); + var _spawned_any = false; for (var m = 0; m < array_length(_mercs); m++) { var _merc_type = _mercs[m]; repeat (_goods.mercenaries[$ _merc_type].number) { - scr_add_man(_merc_type, 0, "", "", 0, true, "default"); + // Skip the per-spawn company re-sort; one sort after the batch keeps a + // large levy (a thousand guardsmen) fast instead of O(n squared). + scr_add_man(_merc_type, 0, "", "", 0, true, "default", {skip_company_order: true}); + _spawned_any = true; + } + } + if (_spawned_any) { + with (obj_ini) { + scr_company_order(0); } } } diff --git a/scripts/scr_transfer_marines/scr_transfer_marines.gml b/scripts/scr_transfer_marines/scr_transfer_marines.gml index 83fcf7875b..a964c2b6e7 100644 --- a/scripts/scr_transfer_marines/scr_transfer_marines.gml +++ b/scripts/scr_transfer_marines/scr_transfer_marines.gml @@ -20,31 +20,29 @@ function draw_popup_transfer() { } function transfer_marines() { - var mahreens = 0, w = 0, god = 0, vehi = 0, god2 = 0; + var vehi = 0; - mahreens = find_company_open_slot(target_comp); + var mahreens = find_company_open_slot(target_comp); - for (w = 1; w < 101; w++) { + for (var w = 1; w < 101; w++) { // Gets the number of vehicles in the target company - if (god2 == 0 && obj_ini.veh_role[target_comp][w] == "") { - god2 = 1; + if (obj_ini.veh_role[target_comp][w] == "") { vehi = w; break; } } // The MAHREENS and TARGET/FROM seems to check out - var unit, move_squad, move_members, moveable, squad; - for (w = 0; w < array_length(obj_controller.display_unit); w++) { + for (var w = 0; w < array_length(obj_controller.display_unit); w++) { if (obj_controller.man_sel[w] == 1) { if (obj_controller.man[w] == "man" && is_struct(obj_controller.display_unit[w])) { - moveable = true; - unit = obj_controller.display_unit[w]; + var moveable = true; + var unit = obj_controller.display_unit[w]; if (unit.squad != "none") { // this evaluates if you are tryin to move a whole squad and if so moves teh squad to a new company var move_squad = unit.squad; - squad = fetch_squad(move_squad); - move_members = squad.members; + var squad = fetch_squad(move_squad); + var move_members = squad.members; for (var mem = 0; mem < array_length(move_members); mem++) { //check all members have been selected and are in the same company if (w + mem < array_length(obj_controller.display_unit)) { diff --git a/scripts/scr_turn_first/scr_turn_first.gml b/scripts/scr_turn_first/scr_turn_first.gml index 2c415f592d..a32796250a 100644 --- a/scripts/scr_turn_first/scr_turn_first.gml +++ b/scripts/scr_turn_first/scr_turn_first.gml @@ -21,7 +21,7 @@ function scr_turn_first() { if (instance_exists(obj_p_fleet) && (!_identifiable)) { var _arti_fleet = find_ships_fleet(_cur_arti.ship_id()); - if (_arti_fleet != "none") { + if (_arti_fleet != noone) { if (array_length(_arti_fleet.capital_num)) { _identifiable = true; _cur_arti.set_ship_id(_arti_fleet.capital_num[0]); diff --git a/scripts/scr_ui_diplomacy/scr_ui_diplomacy.gml b/scripts/scr_ui_diplomacy/scr_ui_diplomacy.gml index 008ce5b5e1..7dd59ebd35 100644 --- a/scripts/scr_ui_diplomacy/scr_ui_diplomacy.gml +++ b/scripts/scr_ui_diplomacy/scr_ui_diplomacy.gml @@ -317,11 +317,11 @@ function set_up_diplomacy_persons() { management_buttons = { audience: new UnitButtonObject({ style: "pixel", - label: "Request Audience", //tooltip: "." + label: "Request Audience", }), ignore: new UnitButtonObject({ style: "pixel", - label: "Ignore", //tooltip: "." + label: "Ignore", }), unignore: new UnitButtonObject({style: "pixel", label: "Unignore", tooltip: "Click here or press B to Toggle Unit Biography."}), screen_slate: new DataSlate(), @@ -371,11 +371,6 @@ function set_up_diplomacy_persons() { _ignore_status.update({x1: _audience.x2 + 1, y1: yy + 85}); _ignore_status.draw(); - - /*var fis;fis="[Request Audience]"; - if (turns_ignored[2]>0) then fis=" "; - if (ignore[eFACTION.IMPERIUM]<1) then draw_text_transformed(xx+189,yy+354,string(fis)+" [Ignore]",0.7,0.7,0); - if (ignore[eFACTION.IMPERIUM]>=1) then draw_text_transformed(xx+189,yy+354,string(fis)+"[Unignore]",0.7,0.7,0);*/ } }; } @@ -417,17 +412,6 @@ function scr_ui_diplomacy() { if (diplomacy == 0) { // Main diplomacy screen - /*draw_set_color(CM_GREEN_COLOR); - draw_rectangle(xx+31,yy+281,xx+438,yy+416,0); - draw_rectangle(xx+31,yy+417,xx+438,yy+552,0); - draw_rectangle(xx+31,yy+553,xx+438,yy+688,0); - draw_rectangle(xx+31,yy+689,xx+438,yy+824,0); - // - draw_rectangle(xx+451,yy+281,xx+858,yy+125,0); - draw_rectangle(xx+451,yy+417,xx+858,yy+125+91,0); - draw_rectangle(xx+451,yy+553,xx+858,yy+125+182,0); - draw_rectangle(xx+451,yy+689,xx+858,yy+125+273,0);*/ - draw_set_color(CM_GREEN_COLOR); draw_set_font(fnt_40k_30b); draw_set_halign(fa_center); @@ -456,28 +440,9 @@ function scr_ui_diplomacy() { scr_image("symbol", 1, xx + 525, yy + 174, 109, 54); scr_image("symbol", 2, xx + 1147, yy + 174, 217, 107); - //draws chapter diplomacy - /*draw_rectangle(xx+451,yy+281,xx+675,yy+416,1); - draw_line(xx+604,yy+281,xx+604,yy+416); - draw_rectangle(xx+451,yy+417,xx+675,yy+552,1); - draw_line(xx+604,yy+417,xx+604,yy+553); - draw_rectangle(xx+451,yy+553,xx+675,yy+688,1); - draw_line(xx+604,yy+553,xx+604,yy+689); - draw_rectangle(xx+451,yy+689,xx+675,yy+824,1); - draw_line(xx+604,yy+689,xx+604,yy+824); - */ - draw_set_font(fnt_40k_14b); draw_set_halign(fa_left); - //draw faction names, etc - /* - draw_text(xx+609,yy+285,"Chapter 1"); - draw_text(xx+609,yy+421,"Chapter 2"); - draw_text(xx+609,yy+557,"Chapter 3"); - draw_text(xx+609,yy+693,"Chapter 4"); - */ - //render status, i.e. whether at war, that stuff draw_set_font(fnt_40k_14); draw_set_halign(fa_right); @@ -522,8 +487,6 @@ function scr_ui_diplomacy() { if (!is_struct(character_diplomacy)) { LOGGER.debug("no valid diplomacy target"); diplomacy = 0; - } else { - // draw_sprite(spr_diplo_splash,diplomacy,xx+916,yy+33); } } @@ -534,9 +497,7 @@ function scr_ui_diplomacy() { if ((diplomacy > 10) && (diplomacy < 11)) { daemon = true; } - // draw_sprite(spr_diplo_splash,diplomacy,xx+916,yy+33); if (diplomacy == 10.1) { - // if (diplomacy=10.1) then draw_sprite(spr_diplomacy_dae,0,xx+16,yy+43); daemon = true; scr_image("diplomacy_daemon", 0, xx + 16, yy + 43, 310, 828); show_stuff = false; @@ -586,7 +547,6 @@ function scr_ui_diplomacy() { draw_set_font(fnt_40k_14); if (daemon == false) { _disposition_rating = $"Disposition: {faction_disposition_rating_string(diplomacy)} ({disposition[diplomacy]})"; - // draw_set_halign(fa_center); draw_text(xx + 622, yy + 144, _disposition_rating); scr_draw_rainbow(xx + 366, yy + 165, xx + 871, yy + 175, (disposition[diplomacy] / 200) + 0.5); } @@ -612,7 +572,5 @@ function scr_ui_diplomacy() { draw_rectangle(mouse_x - 2, mouse_y + 20, mouse_x + 2 + string_width_ext(warn, -1, 600), mouse_y + 24 + string_height_ext(warn, -1, 600), 1); draw_text_ext(mouse_x, mouse_y + 22, warn, -1, 600); } - - //scr_dialogue(diplomacy_pathway); basic_diplomacy_screen(); } diff --git a/scripts/scr_ui_formation_bars/scr_ui_formation_bars.gml b/scripts/scr_ui_formation_bars/scr_ui_formation_bars.gml index a77072a730..c902f4b290 100644 --- a/scripts/scr_ui_formation_bars/scr_ui_formation_bars.gml +++ b/scripts/scr_ui_formation_bars/scr_ui_formation_bars.gml @@ -1,7 +1,7 @@ /// @self Asset.GMObject.obj_controller function scr_ui_formation_bars() { var ui_formations_data = { - nbar: 0, + nbar: noone, abar: 0, te: 4700, x9: 49, diff --git a/scripts/scr_ui_manage/scr_ui_manage.gml b/scripts/scr_ui_manage/scr_ui_manage.gml index 0502eb063a..e73e68a429 100644 --- a/scripts/scr_ui_manage/scr_ui_manage.gml +++ b/scripts/scr_ui_manage/scr_ui_manage.gml @@ -49,11 +49,12 @@ function load_marines_into_ship(system, ship, units, reload = false) { } } + var _unit_size = 0; if (_is_marine) { - var _unit_size = man_size; + _unit_size = man_size; } else { var _vehic_size = scr_unit_size("", ma_role[q], true); - var _unit_size = _vehic_size; + _unit_size = _vehic_size; } if (_unit_ship_id == -1) { @@ -155,7 +156,7 @@ function reset_manage_unit_constants(unit) { // Gear - var _data = { + _data = { tooltip: $"==Gear==\n{is_struct(_equip_data.gear_data) ? _equip_data.gear_data.item_tooltip_desc_gen() : ""}", colour: quality_color(unit.gear_quality), max_width: 187, @@ -164,7 +165,7 @@ function reset_manage_unit_constants(unit) { unit_manage_constants.gear_string = new ReactiveString(unit.equipments_qual_string("gear", true), 0, 0, _data); //mobility - var _data = { + _data = { tooltip: $"==Back/Mobilitiy==\n{is_struct(_equip_data.mobility_data) ? _equip_data.mobility_data.item_tooltip_desc_gen() : ""}", colour: quality_color(unit.mobility_item_quality), max_width: 187, @@ -172,7 +173,7 @@ function reset_manage_unit_constants(unit) { unit_manage_constants.mobi_string = new ReactiveString(unit.equipments_qual_string("mobi", true), 0, 0, _data); - var _data = { + _data = { tooltip: $"==First Weapon==\n{is_struct(_equip_data.weapon_one_data) ? _equip_data.weapon_one_data.item_tooltip_desc_gen() : ""}", colour: quality_color(unit.weapon_one_quality), max_width: 187, @@ -181,7 +182,7 @@ function reset_manage_unit_constants(unit) { unit_manage_constants.wep1_string = new ReactiveString(unit.equipments_qual_string("wep1", true), 0, 0, _data); //mobility - var _data = { + _data = { tooltip: $"==Second Weapon==\n{is_struct(_equip_data.weapon_two_data) ? _equip_data.weapon_two_data.item_tooltip_desc_gen() : ""}", colour: quality_color(unit.weapon_two_quality), max_width: 187, @@ -342,7 +343,7 @@ function reset_manage_unit_constants(unit) { var _range = unit.ranged_attack(); unit_manage_constants.ranged_attack = new LabeledIcon(spr_icon_ballistic_skill, $"{round(_range[0])}", 0, 0, {icon_width: 24, icon_height: 24, tooltip: $"==Ranged Attack==\n{_range[1]}", colour: unit.encumbered_ranged ? #bf4040 : CM_GREEN_COLOR}); - var _carry = _range[2]; + _carry = _range[2]; unit_manage_constants.ranged_burden = new LabeledIcon(spr_icon_weight, $"{_carry[0]}/{_carry[1]}", 0, 0, {icon_width: 24, icon_height: 24, tooltip: $"==Ranged Burden==\n{_carry[2]}", colour: unit.encumbered_ranged ? #bf4040 : CM_GREEN_COLOR}); // ------------------------- @@ -488,6 +489,9 @@ function company_specific_management() { case 15: _company_name = "Armamentarium"; break; + case 16: + _company_name = "Auxilia"; + break; } } // Draw the company followed by chapters name @@ -808,7 +812,17 @@ function scr_ui_manage() { squad_sel = -1; squad_sel_action = -1; } - if (man_size < 1) { + // Only clear the selection when nothing is actually picked. The old check reset + // on any total below 1.0, which wiped fractional-size selections (guardsmen at + // 0.1) before they could reach a full marine's worth of space. + var _has_selection = false; + for (var _ms = 0; _ms < array_length(man_sel); _ms++) { + if (man_sel[_ms] == 1) { + _has_selection = true; + break; + } + } + if (man_size < 1 && !_has_selection) { reset_manage_selections(); } var unit; @@ -1090,8 +1104,6 @@ function scr_ui_manage() { sel_all = ""; draw_set_color(c_black); - xx = camera_get_view_x(view_camera[0]); - yy = camera_get_view_y(view_camera[0]); draw_rectangle(xx + 974, yy + 165, xx + 1005, yy + 822, 0); draw_set_color(c_gray); draw_rectangle(xx + 974, yy + 165, xx + 1005, yy + 822, 1); @@ -1109,17 +1121,6 @@ function scr_ui_manage() { draw_sprite_stretched(spr_arrow, 2, xx + 974, yy + 141, 31, 30); draw_sprite_stretched(spr_arrow, 3, xx + 974, yy + 791, 31, 30); - /* - draw_set_color(c_black);draw_rectangle(xx+25,yy+400,xx+600,yy+417,0); - draw_set_color(CM_GREEN_COLOR);draw_rectangle(xx+25,yy+400,xx+600,yy+417,1); - draw_line(xx+160,yy+400,xx+160,yy+417); - draw_line(xx+304,yy+400,xx+304,yy+417); - draw_line(xx+448,yy+400,xx+448,yy+417); - - draw_set_font(fnt_menu); - draw_set_halign(fa_center); - */ - yy += 8; var _draw_selec_buttons = !obj_controller.unit_profile && !stats_displayed; if (_draw_selec_buttons && instance_exists(obj_popup)) { @@ -1136,8 +1137,6 @@ function scr_ui_manage() { var selected_unit = obj_controller.unit_focus; if ((selected_unit.name() != "") && (selected_unit.race() != 0)) { draw_set_alpha(1); - var xx = camera_get_view_x(view_camera[0]); - var yy = camera_get_view_y(view_camera[0]); if (obj_controller.unit_profile && !instance_exists(obj_popup)) { stats_displayed = true; selected_unit.stat_display(true); @@ -1211,6 +1210,9 @@ function scr_ui_manage() { case 15: fx = "Armamentarium"; break; + case 16: + fx = "Auxilia"; + break; default: fx = "Unknown"; break; diff --git a/scripts/scr_ui_tooltip/scr_ui_tooltip.gml b/scripts/scr_ui_tooltip/scr_ui_tooltip.gml index 28f531bfb3..760977ba0e 100644 --- a/scripts/scr_ui_tooltip/scr_ui_tooltip.gml +++ b/scripts/scr_ui_tooltip/scr_ui_tooltip.gml @@ -2,8 +2,8 @@ /// @category UI /// @description Handles tooltip logics around the main play screen function scr_ui_tooltip() { - if ((selected != 0) && (!instance_exists(selected))) { - selected = 0; + if ((selected != noone) && (!instance_exists(selected))) { + selected = noone; } if (zoomed != 0) { exit; diff --git a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml index 46a1685743..70df34808c 100644 --- a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml +++ b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml @@ -108,11 +108,12 @@ function scr_update_unit_armour(new_armour, from_armoury = true, to_armoury = tr } else { armour_quality = quality; } - var new_arm_data = get_armour_data(); if (is_struct(new_arm_data)) { if (new_arm_data.has_tag("terminator")) { - update_mobility_item(""); + var _cur_mobility_data = gear_weapon_data("mobility", mobility_item()); + if (is_struct(_cur_mobility_data) && !_cur_mobility_data.has_tag("terminator") && !_cur_mobility_data.has_tag("terminator_only")) + update_mobility_item(""); } if (new_arm_data.has_tag("dreadnought")) { @@ -176,6 +177,17 @@ function scr_update_unit_weapon_one(new_weapon, from_armoury = true, to_armoury } } + // Veteran-only weapon gate: some weapons are role-restricted (the Hellgun is Veteran + // Guard only). Reject and log before any armoury or slot mutation if the unit lacks the + // role. Skips unequip and artifacts. Mirrors the mobility tag-gate, keyed on role. + if (!unequipping && !is_artifact) { + var _wep_restrict_data = gear_weapon_data("weapon", new_weapon); + if (is_struct(_wep_restrict_data) && _wep_restrict_data.has_tag("veteran_guard_only") && role() != "Veteran Guard") { + LOGGER.error($"Failed to equip {new_weapon} for {name()} - restricted to Veteran Guard."); + return "restricted"; + } + } + if (from_armoury && !unequipping && !is_artifact) { var viability = weapon_viable(new_weapon, quality); if (viability[0]) { @@ -380,10 +392,6 @@ function scr_update_unit_mobility_item(new_mobility_item, from_armoury = true, t return false; } } else { - if (new_mobility_item == "Jump Pack") { - LOGGER.error($"Failed to equip {new_mobility_item} for {name()} - requires armour!"); - return false; - } if (_mobility_data.has_tag("terminator") || _mobility_data.has_tag("terminator_only")) { LOGGER.error($"Failed to equip {new_mobility_item} for {name()} - requires terminator armour!"); return false; diff --git a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml index b52049e53a..1ae836dbb0 100644 --- a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml +++ b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml @@ -16,7 +16,7 @@ function UnitQuickFindPanel() constructor { static detail_slate = new DataSlateMKTwo(); view_area = "fleets"; - hover_item = "none"; + hover_item = noone; travel_target = []; travel_time = 0; travel_increments = []; @@ -43,7 +43,7 @@ function UnitQuickFindPanel() constructor { var _stars = []; for (var i = 0; i < array_length(_names); i++) { var _star = find_star_by_name(_names[i]); - if (_star != "none") { + if (_star != noone) { array_push(_stars, _star); } } @@ -250,11 +250,10 @@ function UnitQuickFindPanel() constructor { update_mission_log = function() { mission_log = []; var temp_log = []; - var p, i, problems; with (obj_star) { - for (i = 1; i <= planets; i++) { - problems = p_problem[i]; - for (p = 0; p < array_length(problems); p++) { + for (var i = 1; i <= planets; i++) { + var problems = p_problem[i]; + for (var p = 0; p < array_length(problems); p++) { if (problems[p] == "") { continue; } @@ -371,7 +370,7 @@ function UnitQuickFindPanel() constructor { var system_names = struct_get_names(garrison_log); var hover_entered = false; var any_hover = false; - if (hover_item != "none") { + if (hover_item != noone) { var loc = hover_item.location; hover_entered = scr_hit(loc[0], loc[1], loc[2], loc[3]); } @@ -431,7 +430,7 @@ function UnitQuickFindPanel() constructor { if (!hover_entered) { if (point_and_click([xx + 10, yy + 90 + (20 * i) - 2, xx + main_panel.width, yy + 90 + (20 * i) + 18])) { var star = find_star_by_name(system_names[i]); - if (star != "none") { + if (star != noone) { travel_target = [ star.x, star.y @@ -459,8 +458,8 @@ function UnitQuickFindPanel() constructor { if (!any_hover && !hover_entered) { current_hover = -1; hover_count = 0; - hover_item = "none"; - } else if (hover_item != "none") { + hover_item = noone; + } else if (hover_item != noone) { if (point_and_click(hover_item.draw(xx + 10, yy + 90 + (20 * hover_item.root_item), "Manage"))) { group_selection(garrison_log[$ system_names[hover_item.root_item]].units, {purpose: $"{system_names[hover_item.root_item]} Management", purpose_code: "manage", number: 0, system: find_star_by_name(system_names[hover_item.root_item]).id, feature: "none", planet: 0, selections: []}); } @@ -541,7 +540,7 @@ function UnitQuickFindPanel() constructor { } function HoverBox() constructor { - root_item = "none"; + root_item = noone; relative_x = 0; relative_y = 0; location = [ @@ -574,7 +573,7 @@ function update_garrison_manage() { var _planets = 0; if (struct_exists(selection_data, "system") && instance_exists(selection_data.system)) { if (struct_exists(location_viewer.garrison_log, selection_data.system.name)) { - var sys_name = selection_data.system.name; + sys_name = selection_data.system.name; } } @@ -684,9 +683,37 @@ function jail_selection() { alarm[6] = 7; } +/// @self Asset.GMObject.obj_controller +// Returns true if at least one unit is actually selected. Used so loading works for +// fractional-size units (guardsmen at 0.1) whose summed total can read as 0 even +// though units are picked. The real per-unit loader checks each unit's own size. +function selection_has_units() { + if (man_size > 0) { + return true; + } + for (var i = 0; i < array_length(man_sel); i++) { + if (man_sel[i] == 1) { + return true; + } + } + return false; +} + /// @self Asset.GMObject.obj_controller function load_selection() { - if (man_size > 0 && !location_out_of_player_control(selecting_location)) { + // Recover the location anchor from the actual selection if it was lost. This keeps + // Load working for fractional-size units whose summed total can read 0. + if (selecting_location == "") { + for (var i = 0; i < array_length(man_sel); i++) { + if (man_sel[i] == 1) { + selecting_location = ma_loc[i]; + selecting_planet = ma_wid[i]; + selecting_ship = ma_lid[i]; + break; + } + } + } + if (selection_has_units() && !location_out_of_player_control(selecting_location)) { scr_company_load(selecting_location); menu = 30; top = 1; @@ -695,11 +722,11 @@ function load_selection() { /// @self Asset.GMObject.obj_controller function unload_selection() { - if (man_size > 0 && obj_controller.selecting_ship >= 0 && !instance_exists(obj_star_select) && !location_out_of_player_control(selecting_location) && selecting_location != "Warp") { + if (selection_has_units() && obj_controller.selecting_ship >= 0 && !instance_exists(obj_star_select) && !location_out_of_player_control(selecting_location) && selecting_location != "Warp") { cooldown = 8000; var boba = 0; var unload_star = find_star_by_name(selecting_location); - if (unload_star != "none") { + if (unload_star != noone) { if (unload_star.space_hulk != 1) { for (var t = 0; t < array_length(display_unit); t++) { if (man_sel[t] == 1) { @@ -725,12 +752,11 @@ function unload_selection() { /// @self Asset.GMObject.obj_controller function reset_selection_equipment() { - var _unit; for (var f = 0; f < array_length(display_unit); f++) { // If come across a man, set vih to 1 if ((man[f] == "man") && (man_sel[f] == 1)) { if (is_struct(display_unit[f])) { - _unit = display_unit[f]; + var _unit = display_unit[f]; _unit.set_default_equipment(); } } @@ -739,12 +765,11 @@ function reset_selection_equipment() { /// @self Asset.GMObject.obj_controller function add_tag_to_selection(new_tag) { - var _unit; for (var f = 0; f < array_length(display_unit); f++) { // If come across a man, set vih to 1 if ((man[f] == "man") && (man_sel[f] == 1)) { if (is_struct(display_unit[f])) { - _unit = display_unit[f]; + var _unit = display_unit[f]; _unit[$ new_tag] = !_unit[$ new_tag]; } } diff --git a/scripts/scr_unit_size/scr_unit_size.gml b/scripts/scr_unit_size/scr_unit_size.gml index 4386d9a6c5..8685d0600a 100644 --- a/scripts/scr_unit_size/scr_unit_size.gml +++ b/scripts/scr_unit_size/scr_unit_size.gml @@ -6,6 +6,8 @@ function get_vehicle_size_map() { "Land Raider": 20, "Land Speeder": 5, "Whirlwind": 10, + "Chimera": 10, + "Leman Russ": 10, "Harlequin Troupe": 5, }; diff --git a/scripts/scr_unit_spawn_functions/scr_unit_spawn_functions.gml b/scripts/scr_unit_spawn_functions/scr_unit_spawn_functions.gml index e20371c459..717a5f27ba 100644 --- a/scripts/scr_unit_spawn_functions/scr_unit_spawn_functions.gml +++ b/scripts/scr_unit_spawn_functions/scr_unit_spawn_functions.gml @@ -419,20 +419,20 @@ function scr_marine_game_spawn_constructions() { } else { bionic_count = choose(1, 1, 1, 2, 3); } + var tech_heresy = irandom(49); if ((_chap_name == "Iron Hands") || (obj_ini.progenitor == ePROGENITOR.IRON_HANDS) || scr_has_disadv("Tech-Heresy")) { add_bionics("right_arm", "standard", false); bionic_count = choose(6, 6, 7, 7, 7, 8, 9); add_trait("flesh_is_weak"); - var tech_heresy = irandom(19); + tech_heresy = irandom(19); } else { bionic_count = irandom(5) + 1; if (irandom(2) == 0) { add_trait("flesh_is_weak"); } - var tech_heresy = irandom(49); } if (scr_has_disadv("Tech-Heresy")) { - var tech_heresy = irandom(10); + tech_heresy = irandom(10); technology += 4; } if (tech_heresy == 0) { diff --git a/scripts/scr_vehicle_helpers/scr_vehicle_helpers.gml b/scripts/scr_vehicle_helpers/scr_vehicle_helpers.gml index ffae74c964..d1ed904bd7 100644 --- a/scripts/scr_vehicle_helpers/scr_vehicle_helpers.gml +++ b/scripts/scr_vehicle_helpers/scr_vehicle_helpers.gml @@ -1,16 +1,15 @@ // Records or nullifies the association between a vehicle and its last ship function set_vehicle_last_ship(vehic_array, empty = false) { + var _last_ship_data = { + uid: "", + name: "", + }; if (!empty) { var vehic_ini = obj_ini.veh_lid[vehic_array[0]][vehic_array[1]]; - var _last_ship_data = { + _last_ship_data = { uid: obj_ini.ship_uid[vehic_ini], name: obj_ini.ship[vehic_ini], }; - } else { - var _last_ship_data = { - uid: "", - name: "", - }; } obj_ini.last_ship[vehic_array[0]][vehic_array[1]] = _last_ship_data; } diff --git a/scripts/scr_vehicle_order/scr_vehicle_order.gml b/scripts/scr_vehicle_order/scr_vehicle_order.gml index 8fa5e8c5e0..d46fe1c45e 100644 --- a/scripts/scr_vehicle_order/scr_vehicle_order.gml +++ b/scripts/scr_vehicle_order/scr_vehicle_order.gml @@ -48,7 +48,10 @@ function scr_vehicle_order(company_number) { || veh_role[company_number][i] == "Predator" || veh_role[company_number][i] == "Whirlwind" || veh_role[company_number][i] == "Land Speeder" - || veh_role[company_number][i] == "Land Raider"; + || veh_role[company_number][i] == "Land Raider" + || veh_role[company_number][i] == "Chimera" + || veh_role[company_number][i] == "Leman Russ" + || veh_role[company_number][i] == "Basilisk"; if (_is_vehicle_role) { temp_race[company_number][vehicle_count] = veh_race[company_number][i];