diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index 3c2ffa5f05..79f878760b 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -49,6 +49,7 @@ {"$GMFolder":"","%Name":"Diplomacy","folderPath":"folders/Scripts/User Interface/Diplomacy.yy","name":"Diplomacy","resourceType":"GMFolder","resourceVersion":"2.0",}, {"$GMFolder":"","%Name":"Common","folderPath":"folders/Scripts/User Interface/Diplomacy/Common.yy","name":"Common","resourceType":"GMFolder","resourceVersion":"2.0",}, {"$GMFolder":"","%Name":"Render Components","folderPath":"folders/Scripts/User Interface/Render Components.yy","name":"Render Components","resourceType":"GMFolder","resourceVersion":"2.0",}, + {"$GMFolder":"","%Name":"UUID Suite","folderPath":"folders/Scripts/UUID Suite.yy","name":"UUID Suite","resourceType":"GMFolder","resourceVersion":"2.0",}, {"$GMFolder":"","%Name":"Sequences","folderPath":"folders/Sequences.yy","name":"Sequences","resourceType":"GMFolder","resourceVersion":"2.0",}, {"$GMFolder":"","%Name":"Shaders","folderPath":"folders/Shaders.yy","name":"Shaders","resourceType":"GMFolder","resourceVersion":"2.0",}, {"$GMFolder":"","%Name":"Sounds","folderPath":"folders/Sounds.yy","name":"Sounds","resourceType":"GMFolder","resourceVersion":"2.0",}, @@ -866,6 +867,7 @@ {"id":{"name":"scr_unit_spawn_functions","path":"scripts/scr_unit_spawn_functions/scr_unit_spawn_functions.yy",},}, {"id":{"name":"scr_unit_traits","path":"scripts/scr_unit_traits/scr_unit_traits.yy",},}, {"id":{"name":"scr_uuid_generate","path":"scripts/scr_uuid_generate/scr_uuid_generate.yy",},}, + {"id":{"name":"scr_uuid_management","path":"scripts/scr_uuid_management/scr_uuid_management.yy",},}, {"id":{"name":"scr_vehicle_count","path":"scripts/scr_vehicle_count/scr_vehicle_count.yy",},}, {"id":{"name":"scr_vehicle_helpers","path":"scripts/scr_vehicle_helpers/scr_vehicle_helpers.yy",},}, {"id":{"name":"scr_vehicle_order","path":"scripts/scr_vehicle_order/scr_vehicle_order.yy",},}, @@ -1720,4 +1722,4 @@ "TextureGroups":[ {"$GMTextureGroup":"","%Name":"Default","autocrop":true,"border":2,"compressFormat":"bz2","customOptions":"","directory":"","groupParent":null,"isScaled":false,"loadType":"default","mipsToGenerate":0,"name":"Default","resourceType":"GMTextureGroup","resourceVersion":"2.0","targets":-1,}, ], -} \ No newline at end of file +} diff --git a/objects/obj_controller/Alarm_5.gml b/objects/obj_controller/Alarm_5.gml index 42056cfbb4..b5a7b66d18 100644 --- a/objects/obj_controller/Alarm_5.gml +++ b/objects/obj_controller/Alarm_5.gml @@ -270,13 +270,18 @@ for (var c = 0; c < 11; c++){ } } // STC Bonuses -if (obj_controller.stc_ships>=6){ +if (obj_controller.stc_ships >= 6) { //self healing ships logic - for (var v=0; v 0) { cooldown = 8; - var b = selecting_ship; + var _ship_struct; + if (selecting_ship != "") { + _ship_struct = fetch_ship(selecting_ship); + } var unit, company, unit_id; + if (_ship_struct == undefined) { + for (var q = 0; q < array_length(display_unit); q++) { + if (ma_lid[q] != "") { + _ship_struct = fetch_ship(ma_lid[q]); + break; + } + } + } + for (var q = 0; q < array_length(display_unit); q++) { if ((man[q] == "man") && (ma_loc[q] == selecting_location) && (ma_wid[q] < 1) && (man_sel[q] != 0)) { - if (b == -1) { - b = ma_lid[q]; - } unit = display_unit[q]; if (!is_struct(unit)) { continue; @@ -798,27 +811,22 @@ try { } unit_id = unit.marine_number; company = unit.company; - obj_ini.loc[company][unit_id] = obj_ini.ship_location[b]; - unit.ship_location = -1; + obj_ini.loc[company][unit_id] = _ship_struct.location; + unit.ship_location = ""; unit.planet_location = unload; - obj_ini.uid[company][unit_id] = 0; - ma_loc[q] = obj_ini.ship_location[b]; - ma_lid[q] = -1; + ma_loc[q] = _ship_struct.location; + ma_lid[q] = ""; ma_wid[q] = unload; } else if ((man[q] == "vehicle") && (ma_loc[q] == selecting_location) && (ma_wid[q] < 1) && (man_sel[q] != 0)) { - if (b == -1) { - b = ma_lid[q]; - } var unit_id = display_unit[q][1]; var company = display_unit[q][0]; - obj_ini.veh_loc[company][unit_id] = obj_ini.ship_location[b]; - obj_ini.veh_lid[company][unit_id] = -1; + obj_ini.veh_loc[company][unit_id] = _ship_struct.location; + obj_ini.veh_lid[company][unit_id] = ""; obj_ini.veh_wid[company][unit_id] = unload; - obj_ini.veh_uid[company][unit_id] = 0; - ma_loc[q] = obj_ini.ship_location[b]; - ma_lid[q] = -1; + ma_loc[q] = _ship_struct.location; + ma_lid[q] = ""; ma_wid[q] = unload; } } @@ -826,9 +834,7 @@ try { for (var i = 0; i < array_length(display_unit); i++) { man_sel[i] = 0; } - if (b > -1 && b < array_length(obj_ini.ship_carrying)) { - obj_ini.ship_carrying[b] -= man_size; - } + _ship_struct.cargo.carrying -= man_size; reset_ship_manage_arrays(); cooldown = 10; sel_loading = -1; @@ -839,11 +845,11 @@ try { } } // Resets selections - if ((managing > 0) && (man_size == 0) && ((selecting_location != "") || (selecting_types != "") || (selecting_planet != 0) || (selecting_ship != -1))) { + if ((managing > 0) && (man_size == 0) && ((selecting_location != "") || (selecting_types != "") || (selecting_planet != 0) || (selecting_ship != ""))) { selecting_location = ""; selecting_types = ""; selecting_planet = 0; - selecting_ship = -1; + selecting_ship = ""; } if ((marines <= 0) && (alarm[7] == -1) && (!instance_exists(obj_fleet_controller)) && (!instance_exists(obj_ncombat))) { diff --git a/objects/obj_ground_mission/Alarm_2.gml b/objects/obj_ground_mission/Alarm_2.gml index 05dd140bec..849956fa8a 100644 --- a/objects/obj_ground_mission/Alarm_2.gml +++ b/objects/obj_ground_mission/Alarm_2.gml @@ -1,11 +1,11 @@ scr_return_ship(loc,self,num); -var man_size,ship_id,comp,plan,i; -i=0;ship_id=0;man_size=0;comp=0;plan=0; -ship_id = get_valid_player_ship("", loc); +var man_size,_ship_UUID,comp,plan,i; +i=0;_ship_UUID="";man_size=0;comp=0;plan=0; +_ship_UUID = get_valid_player_ship(loc); plan=instance_nearest(x,y,obj_star); -last_artifact = scr_add_artifact("random","random",4,loc,ship_id+500); +last_artifact = scr_add_artifact("random", "random", 4, fetch_ship(_ship_UUID).name, _ship_UUID); var pop=instance_create(0,0,obj_popup); pop.image="artifact_recovered"; diff --git a/objects/obj_ground_mission/Alarm_3.gml b/objects/obj_ground_mission/Alarm_3.gml index 8894266c93..c8b822bd40 100644 --- a/objects/obj_ground_mission/Alarm_3.gml +++ b/objects/obj_ground_mission/Alarm_3.gml @@ -1,18 +1,18 @@ scr_return_ship(loc,self,num); -var man_size,ship_id,comp,plan,i; +var man_size,_ship_UUID,comp,plan,i; i=0; -ship_id=0; +_ship_UUID = ""; man_size=0; comp=0; plan=0; -ship_id = get_valid_player_ship("", loc); +_ship_UUID = get_valid_player_ship(loc); i=0; plan=instance_nearest(x,y,obj_star); -last_artifact = scr_add_artifact("random","random",4,loc,ship_id+500); +last_artifact = scr_add_artifact("random", "random", 4, fetch_ship(_ship_UUID).name, _ship_UUID); var pop; diff --git a/objects/obj_ground_mission/Alarm_4.gml b/objects/obj_ground_mission/Alarm_4.gml index 8dd5679466..8fadda2e85 100644 --- a/objects/obj_ground_mission/Alarm_4.gml +++ b/objects/obj_ground_mission/Alarm_4.gml @@ -1,11 +1,11 @@ scr_return_ship(loc,self,num); -var man_size,ship_id,comp,planet,i; -i=0;ship_id=0;man_size=0;comp=0;planet=0; -ship_id = get_valid_player_ship("", loc); +var man_size,_ship_UUID,comp,planet,i; +i=0;_ship_UUID="";man_size=0;comp=0;planet=0; +_ship_UUID = get_valid_player_ship(loc); planet=instance_nearest(x,y,obj_star); -var last_artifact = scr_add_artifact("random","random",4,loc,ship_id+500); +var last_artifact = scr_add_artifact("random", "random", 4, fetch_ship(_ship_UUID).name, _ship_UUID); var i=0; diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index 51d3d43fe9..9e6c8e7442 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -43,14 +43,12 @@ repeat(200){i+=1; artifact_condition[i]=100; artifact_quality[i]="artifact"; artifact_loc[i]=""; - artifact_sid[i]=0;// Over 500 : ship + artifact_sid[i] = {};// Over 500 : ship // Weapon Unidentified artifact_struct[i] = new ArtifactStruct(i); } var i=-1; -init_player_fleet_arrays(); -ship_id = []; var v; var company=-1; @@ -76,6 +74,10 @@ repeat(11){ } } +UUID_marine = {}; +UUID_vehicle = {}; +UUID_ship = {}; + /*if (obj_creation.fleet_type=3){ obj_controller.penitent=1; obj_controller.penitent_max=(obj_creation.maximum_size*1000)+300; diff --git a/objects/obj_ncombat/Alarm_7.gml b/objects/obj_ncombat/Alarm_7.gml index 907dc09f0e..be846d40b4 100644 --- a/objects/obj_ncombat/Alarm_7.gml +++ b/objects/obj_ncombat/Alarm_7.gml @@ -599,12 +599,12 @@ try { } if (battle_special="space_hulk") and (defeat=0) and (hulk_treasure>0){ - var shi=0,loc=""; + var shi="",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]; + loc = fetch_ship(shi).name; } if (hulk_treasure=1){// Requisition @@ -617,7 +617,7 @@ try { pop.text="Your battle brothers have located several luxury goods and coginators within the Space Hulk. They are salvaged and returned to the ship, granting "+string(reqi)+" Requisition."; }else if (hulk_treasure=2){// Artifact //TODO this will eeroniously put artifacts in the wrong place but will resolve crashes - var last_artifact = scr_add_artifact("random","random",4,loc,shi+500); + var last_artifact = scr_add_artifact("random", "random", 4, loc, shi); var i=0; var pop=instance_create(0,0,obj_popup); @@ -692,4 +692,4 @@ try { } catch(_exception) { handle_exception(_exception); -} \ No newline at end of file +} diff --git a/objects/obj_p_fleet/Alarm_7.gml b/objects/obj_p_fleet/Alarm_7.gml index 63b1549765..e63b1696c0 100644 --- a/objects/obj_p_fleet/Alarm_7.gml +++ b/objects/obj_p_fleet/Alarm_7.gml @@ -3,27 +3,25 @@ // right here check for artifacts to be moved -if (capital_number=0) then exit; -var c=0,good=0; -var capital_id; -var capital_list = fleet_full_ship_array(, ,true,true); -for(var i=0;igood){ - c=capital_id; - good=obj_ini.ship_hp[capital_id]; +if (capital_number == 0) { exit; } +var c = "", good = 0; +var _capital; +var capital_list = fleet_full_ship_array(, , true, true); +for (var i = 0; i < array_length(capital_list); i++) { // Find the healthiest capital ship + var _capital_struct = fetch_ship(capital_list[i]); + if (capital.health.hp > good) { + _capital = _capital_struct.UUID; + good = capital.health.hp; } } -if (good>0){ +if (good > 0) { var ships_list = fleet_full_ship_array(, true); - for (var a=0;a0) and (x>0){ - if (point_distance(x,y,wop.x,wop.y)<=40){ - orbiting=wop; - wop.present_fleet[1]+=1; +owner = eFACTION.Player; +capital_number = 0; +frigate_number = 0; +escort_number = 0; +selected = 0; +orbiting = 0; +warp_able = true; +ii_check = choose(8, 9, 10, 11, 12); + +var wop = instance_nearest(x, y, obj_star); +if (instance_exists(wop)) && (y > 0) && (x > 0) { + if (point_distance(x, y, wop.x, wop.y) <= 40) { + orbiting = wop; + wop.present_fleet[1] += 1; } } point_breakdown = single_loc_point_data(); -image_xscale=1.25; -image_yscale=1.25; - -var i=-1; -capital = []; -capital_num = []; -capital_sel = []; -capital_uid = []; +image_xscale = 1.25; +image_yscale = 1.25; -frigate = []; -frigate_num = []; -frigate_sel = []; -frigate_uid = []; +capital = {}; -escort = []; -escort_num = []; -escort_sel = []; -escort_uid = []; +frigate = {}; +escort = {}; -image_speed=0; +image_speed = 0; -fix=2; +fix = 2; -capital_health=100; -frigate_health=100; -escort_health=100; +capital_health = 100; +frigate_health = 100; +escort_health = 100; complex_route = []; -just_left=false; +just_left = false; action=""; @@ -104,4 +92,4 @@ deserialize = function(save_data){ } -#endregion \ No newline at end of file +#endregion diff --git a/objects/obj_popup/Mouse_50.gml b/objects/obj_popup/Mouse_50.gml index 745d3c1c37..26c0cebf59 100644 --- a/objects/obj_popup/Mouse_50.gml +++ b/objects/obj_popup/Mouse_50.gml @@ -213,7 +213,7 @@ if (mouse_x>=xx+1465) and (mouse_y>=yy+499) and (mouse_x0){ reset_manage_arrays(); @@ -416,7 +416,7 @@ if (scr_hit(xx+1465, yy+499,xx+1576,yy+518)){// Promoting right here // man_current=0; var man_size=0;selecting_location=""; selecting_types=""; - selecting_ship=-1; + selecting_ship = ""; reset_manage_arrays(); alll=0; update_general_manage_view(); diff --git a/objects/obj_popup/Step_0.gml b/objects/obj_popup/Step_0.gml index 7668dc7446..4e4748a7c4 100644 --- a/objects/obj_popup/Step_0.gml +++ b/objects/obj_popup/Step_0.gml @@ -1456,11 +1456,10 @@ try { if (obj_ini.icon_name == "dorf3") { image = "fortress_dorf"; } - last_artifact = scr_add_artifact("good", "inquisition", 0, obj_ini.home_name, 2); } else if (obj_ini.fleet_type != ePlayerBase.home_world) { image = "artifact_given"; - last_artifact = scr_add_artifact("good", "inquisition", 0, obj_ini.ship[0], 501); } + last_artifact = scr_add_artifact("good", "inquisition", 0); title = "New Artifact"; fancy_title = 0; @@ -1557,12 +1556,7 @@ try { instance_destroy(); } } - if (obj_ini.fleet_type != ePlayerBase.home_world) { - var last_artifact = scr_add_artifact("random", "", 4, obj_ini.ship[0], 501); - } - if (obj_ini.fleet_type == ePlayerBase.home_world) { - var last_artifact = scr_add_artifact("random", "", 4, obj_ini.home_name, 2); - } + var last_artifact = scr_add_artifact("random", "", 4); option1 = ""; option2 = ""; option3 = ""; @@ -1734,12 +1728,7 @@ try { action = ""; } } - if (obj_ini.fleet_type != ePlayerBase.home_world) { - var last_artifact = scr_add_artifact("random", "", 4, obj_ini.ship[0], 501); - } - if (obj_ini.fleet_type == ePlayerBase.home_world) { - var last_artifact = scr_add_artifact("random", "", 4, obj_ini.home_name, 2); - } + var last_artifact = scr_add_artifact("random", "", 4); option1 = ""; option2 = ""; option3 = ""; diff --git a/scripts/is_specialist/is_specialist.gml b/scripts/is_specialist/is_specialist.gml index 45aaaf51ed..d4bc44297c 100644 --- a/scripts/is_specialist/is_specialist.gml +++ b/scripts/is_specialist/is_specialist.gml @@ -373,7 +373,7 @@ function group_selection(group, selection_data) { man_size = 0; selecting_location = ""; selecting_types = ""; - selecting_ship = -1; + selecting_ship = ""; selecting_planet = 0; sel_uid = 0; reset_manage_arrays(); diff --git a/scripts/scr_add_artifact/scr_add_artifact.gml b/scripts/scr_add_artifact/scr_add_artifact.gml index 56b1a5c189..c3fbfdeb92 100644 --- a/scripts/scr_add_artifact/scr_add_artifact.gml +++ b/scripts/scr_add_artifact/scr_add_artifact.gml @@ -12,7 +12,7 @@ function find_open_artifact_slot() { return last_artifact; } -function scr_add_artifact(artifact_type, artifact_tags, is_identified, artifact_location, ship_id) { +function scr_add_artifact(artifact_type, artifact_tags, is_identified, artifact_location = "", fship_UUID = "") { last_artifact = find_open_artifact_slot(); if (last_artifact == -1) { exit; @@ -251,13 +251,16 @@ function scr_add_artifact(artifact_type, artifact_tags, is_identified, artifact_ } // show_message(string(t3)); + var planet_num = 0; if (artifact_location == "") { if (obj_ini.fleet_type == ePlayerBase.home_world) { artifact_location = obj_ini.home_name; - ship_id = 2; + planet_num = 2; + fship_UUID = ""; } else { - artifact_location = obj_ini.ship[0]; - ship_id = 501; + var _ship_struct = fetch_ship(obj_controller.flagship_UUID); + artifact_location = _ship_struct.name; + fship_UUID = _ship_struct.UUID; } } obj_ini.artifact[last_artifact] = base_type_detail; @@ -268,7 +271,10 @@ function scr_add_artifact(artifact_type, artifact_tags, is_identified, artifact_ obj_ini.artifact_identified[last_artifact] = is_identified; obj_ini.artifact_condition[last_artifact] = 100; obj_ini.artifact_loc[last_artifact] = artifact_location; - obj_ini.artifact_sid[last_artifact] = ship_id; + obj_ini.artifact_sid[last_artifact] = { + ship : fship_UUID, + planet : planet_num + }; obj_ini.artifact_quality[last_artifact] = "artifact"; obj_ini.artifact_equipped[last_artifact] = false; obj_ini.artifact_struct[last_artifact] = new ArtifactStruct(last_artifact); @@ -300,11 +306,6 @@ function ArtifactStruct(Index) constructor { return obj_ini.artifact_loc[index]; }; - //combination of what is normally lid and wid - static sid = function() { - return obj_ini.artifact_sid[index]; - }; - static can_equip = function() { _can_equip = true; var none_equips = ["Statue", "Casket", "Chalice", "Robot"]; @@ -315,31 +316,45 @@ function ArtifactStruct(Index) constructor { }; static ship_id = function() { - return obj_ini.artifact_sid[index] - 500; + return obj_ini.artifact_sid[index].ship; + }; + + static planet_id = function() { + return obj_ini.artifact_sid[index].planet; + } + + static set_ship_id = function(fship_UUID) { + obj_ini.artifact_loc[index] = fetch_ship(fship_UUID).name; + obj_ini.artifact_sid[index] = { + ship : fship_UUID, + planet : 0 + }; }; - static set_ship_id = function(ship_id) { - obj_ini.artifact_sid[index] = ship_id + 500; + static set_planet_id = function(name, id) { + obj_ini.artifact_loc[index] = name; + obj_ini.artifact_sid[index] = { + ship : "", + planet : id + }; }; static location_string = function() { - if (sid() >= 500) { - return obj_ini.ship[ship_id()]; + var _UUID = ship_id(); + if (_UUID != "") { + return fetch_ship(_UUID).name; } else { - return $"{loc()} {sid()}"; + return $"{loc()} {planet_id()}"; } }; static is_identifiable = function() { var identifiable = false; + var _UUID = ship_id(); if (loc() == obj_ini.home_name) { identifiable = 1; - } - if (sid() >= 500) { - if (obj_ini.ship_location[ship_id()] == obj_ini.home_name) { - identifiable = 1; - } - if (obj_ini.ship_class[ship_id()] == "Battle Barge") { + } else if (_UUID != "") { + if (fetch_ship(_UUID).class == "Battle Barge") { identifiable = 1; } } @@ -420,11 +435,12 @@ function ArtifactStruct(Index) constructor { static destroy_arti = function() { if (has_tag("daemonic")) { - var _ship_id = ship_id(); - if (_ship_id > 0) { + var _ship_id = ship_id(); + if (_ship_id != "") { + var _ship_struct = fetch_ship(_ship_id); var demonSummonChance = roll_dice(1, 100, "high"); - if ((demonSummonChance <= 60) && (obj_ini.ship_carrying[_ship_id] > 0)) { + if ((demonSummonChance <= 60) && (_ship_struct.cargo.carrying > 0)) { instance_create(0, 0, obj_ncombat); obj_ncombat.battle_special = "ship_demon"; obj_ncombat.formation_set = 1; @@ -587,7 +603,7 @@ function delete_artifact(index) { artifact_identified[index] = 0; artifact_condition[index] = 0; artifact_loc[index] = ""; - artifact_sid[index] = 0; + artifact_sid[index] = {}; artifact_equipped[index] = false; artifact_struct[index] = new ArtifactStruct(index); } diff --git a/scripts/scr_add_man/scr_add_man.gml b/scripts/scr_add_man/scr_add_man.gml index 42aa6ddb43..5cb284c2b2 100644 --- a/scripts/scr_add_man/scr_add_man.gml +++ b/scripts/scr_add_man/scr_add_man.gml @@ -250,7 +250,8 @@ function scr_add_man(man_role, target_company, spawn_exp, spawn_name, corruption } } } - obj_ini.TTRPG[target_company][good] = unit; + set_unit(unit.UUID, unit); + obj_ini.TTRPG[target_company][good] = unit; unit.add_exp(spawn_exp); unit.allocate_unit_to_fresh_spawn(home_spot); unit.update_role(man_role); @@ -259,4 +260,4 @@ function scr_add_man(man_role, target_company, spawn_exp, spawn_name, corruption } } -} \ No newline at end of file +} diff --git a/scripts/scr_add_vehicle/scr_add_vehicle.gml b/scripts/scr_add_vehicle/scr_add_vehicle.gml index 0affcd9b9b..c220ee45eb 100644 --- a/scripts/scr_add_vehicle/scr_add_vehicle.gml +++ b/scripts/scr_add_vehicle/scr_add_vehicle.gml @@ -2,7 +2,6 @@ function scr_add_vehicle(vehicle_type, target_company, weapon1, weapon2, weapon3 try { // That should be sufficient to add stuff in a highly modifiable fashion - var i = 0; e = 0; good = 0; wep1 = ""; @@ -23,40 +22,44 @@ function scr_add_vehicle(vehicle_type, target_company, weapon1, weapon2, weapon3 if (good != 0) { obj_ini.veh_race[target_company][good] = 1; - if (obj_ini.fleet_type == ePlayerBase.home_world) { - obj_ini.veh_loc[target_company][good] = obj_ini.home_name; - obj_ini.veh_wid[target_company][good] = 2; - obj_ini.veh_lid[target_company][good] = -1; - } + if (obj_ini.fleet_type == ePlayerBase.home_world) { + obj_ini.veh_loc[target_company][good] = obj_ini.home_name; + obj_ini.veh_wid[target_company][good] = 2; + obj_ini.veh_lid[target_company][good] = ""; + } - if (obj_ini.fleet_type != ePlayerBase.home_world) { - // Need a more elaborate ship_carrying += here for the different types of units - var first = 0, backup = 0, i = 0; - for (var i = 0; i < array_length(obj_ini.ship_class); i++) { - if ((obj_ini.ship_class[i] == "Battle Barge") && (first == 0) && (obj_ini.ship_capacity[i] > obj_ini.ship_carrying[i])) { - first = i; - } - if ((obj_ini.ship_class[i] == "Strike Cruiser") && (backup == 0) && (obj_ini.ship_capacity[i] > obj_ini.ship_carrying[i])) { - backup = i; - } - } - if (first != 0) { - obj_ini.veh_lid[target_company][good] = first; - obj_ini.veh_loc[target_company][good] = obj_ini.ship_location[first]; - obj_ini.veh_wid[target_company][good] = 0; - obj_ini.ship_carrying[first] += 1; - } else if ((first == 0) && (backup != 0)) { - obj_ini.veh_lid[target_company][good] = backup; - obj_ini.veh_loc[target_company][good] = obj_ini.ship_location[backup]; - obj_ini.veh_wid[target_company][good] = 0; - obj_ini.ship_carrying[backup] += 1; - } else if ((first == 0) && (backup == 0)) { - obj_ini.veh_lid[target_company][good] = -1; - obj_ini.veh_loc[target_company][good] = ""; - obj_ini.veh_wid[target_company][good] = 0; - exit; - } - } + if (obj_ini.fleet_type != ePlayerBase.home_world) { + // Need a more elaborate ship_carrying += here for the different types of units + var _first = 0, _first_struct = {}, _backup = 0, _backup_struct = {}; + var _ship_UUIDs = struct_get_names(INI_USHIPROOT); + for (var i = 0; i < array_length(_ship_UUIDs); i++) { + var _ship_struct = fetch_ship(_ship_UUIDs[i]); + if ((_ship_struct.class == "Battle Barge") && (first == 0) && (_ship_struct.cargo.capacity > _ship_struct.cargo.carrying)) { + _first = _ship_UUIDs[i]; + _first_struct = _ship_struct; + } + if ((_ship_struct.class == "Strike Cruiser") && (backup == 0) && (_ship_struct.cargo.capacity > _ship_struct.cargo.carrying)) { + _backup = _ship_UUIDs[i]; + _backup_struct = _ship_struct; + } + } + if (first != 0) { + obj_ini.veh_lid[target_company][good] = _first; + obj_ini.veh_loc[target_company][good] = _first_struct.location; + obj_ini.veh_wid[target_company][good] = 0; + _first_struct.cargo.carrying += 1; + } else if ((first == 0) && (backup != 0)) { + obj_ini.veh_lid[target_company][good] = _backup; + obj_ini.veh_loc[target_company][good] = _backup_struct.location; + obj_ini.veh_wid[target_company][good] = 0; + _backup_struct.cargo.carrying += 1; + } else if ((first == 0) && (backup == 0)) { + obj_ini.veh_lid[target_company][good] = ""; + obj_ini.veh_loc[target_company][good] = ""; + obj_ini.veh_wid[target_company][good] = 0; + exit; + } + } obj_ini.veh_role[target_company][good] = vehicle_type; diff --git a/scripts/scr_cheatcode/scr_cheatcode.gml b/scripts/scr_cheatcode/scr_cheatcode.gml index f802f062c5..95d8809e29 100644 --- a/scripts/scr_cheatcode/scr_cheatcode.gml +++ b/scripts/scr_cheatcode/scr_cheatcode.gml @@ -65,10 +65,10 @@ function scr_cheatcode(argument0) { break; case "artifact": if (cheat_arguments[0] == "1") { - scr_add_artifact("random", "", 6, obj_ini.ship[0], 501); + scr_add_artifact("random", "", 6); } else { repeat(real(cheat_arguments[1])){ - scr_add_artifact(cheat_arguments[0], "", 6, obj_ini.ship[0], 501); + scr_add_artifact(cheat_arguments[0], "", 6); } } break; @@ -113,7 +113,7 @@ function scr_cheatcode(argument0) { break; case "inquisarti": scr_quest(0, "artifact_loan", 4, 10); - var last_artifact = scr_add_artifact("good", "inquisition", 0, obj_ini.ship[0], 501); + scr_add_artifact("good", "inquisition", 0); break; case "govmission": var problem = ""; @@ -302,4 +302,4 @@ function scr_cheatcode(argument0) { } catch(_exception) { show_debug_message(_exception.longMessage); } -} \ No newline at end of file +} diff --git a/scripts/scr_company_load/scr_company_load.gml b/scripts/scr_company_load/scr_company_load.gml index 2e077f65c2..a4243b8f29 100644 --- a/scripts/scr_company_load/scr_company_load.gml +++ b/scripts/scr_company_load/scr_company_load.gml @@ -1,25 +1,25 @@ function scr_company_load(ship_loc) { // load all ships at a particular location. - with (obj_controller){ + with (obj_controller) { reset_ship_manage_arrays(); - var ships = array_length(obj_ini.ship); - for (var i = 0; i < ships; i++) { - if (obj_ini.ship[i] != "" && obj_ini.ship_location[i] == ship_loc){ - array_push(sh_ide, i); - array_push(sh_name, obj_ini.ship[i]); - array_push(sh_class, obj_ini.ship_class[i]); - array_push(sh_loc, obj_ini.ship_location[i]); - array_push(sh_uid, obj_ini.ship_uid[i]); - array_push(sh_hp, $"{round(obj_ini.ship_hp[i] / obj_ini.ship_maxhp[i]) * 100}% HP") - array_push(sh_cargo, obj_ini.ship_carrying[i]); - array_push(sh_cargo_max, obj_ini.ship_capacity[i]); + var _ship_UUIDs = struct_get_names(INI_USHIPROOT); + var _ship_count = array_length(obj_ini.ship); + for (var i = 0; i < _ship_count; i++) { + var _ship_struct = fetch_ship(_ship_UUIDs[i]); + if (_ship_struct.location == ship_loc) { + array_push(sh_uuid, _ship_UUIDs[i]); + array_push(sh_name, _ship_struct.name); + array_push(sh_class, _ship_struct.class); + array_push(sh_loc, _ship_struct.location); + array_push(sh_hp, $"{round(_ship_struct.health.hp / _ship_struct.health.maxhp) * 100}% HP") + array_push(sh_cargo, _ship_struct.cargo.carrying); + array_push(sh_cargo_max, _ship_struct.cargo.capacity); } } ship_current = 0; - ship_max = array_length(sh_ide); + ship_max = array_length(sh_uuid); ship_see = 30; } - } diff --git a/scripts/scr_company_order/scr_company_order.gml b/scripts/scr_company_order/scr_company_order.gml index 71d534e733..d457d17711 100644 --- a/scripts/scr_company_order/scr_company_order.gml +++ b/scripts/scr_company_order/scr_company_order.gml @@ -36,7 +36,7 @@ function temp_marine_variables(co, unit_num){ array_push(temp_mobi,mobi[co][unit_num]); array_push(temp_spe,spe[co][unit_num]); array_push(temp_god,god[co][unit_num]); - array_push(temp_struct,jsonify_marine_struct(co,unit_num)); + array_push(temp_struct, TTRPG[co][unit_num]); scr_wipe_unit(co,unit_num); } function sort_all_companies(){ @@ -74,7 +74,7 @@ function scr_company_order(company) { temp_age=[]; temp_spe=[]; temp_god=[]; - temp_struct=[]; + temp_struct=[]; /*takes a template of a role, required role number and if there are enough @@ -328,6 +328,9 @@ function scr_company_order(company) { // Return here for (i=0;ideath_data[0] || death_determination_2>death_data[1]){ dead=true; if (unit.role()==obj_ini.role[100][5]){ @@ -79,7 +78,9 @@ function scr_crusade() { } if (dead){ var man_size=0; - obj_ini.ship_carrying[unit.ship_location]-=unit.get_unit_size(); + var _ship_struct = fetch_ship(unit.ship_location); + _ship_struct.cargo.carrying -= unit.get_unit_size(); + array_delete(_ship_struct.cargo.unit_list, array_get_index(_ship_struct.cargo.unit_list, unit.ship_location), 1); if (unit.IsSpecialist(SPECIALISTS_STANDARD,true)){ obj_controller.command--; } else { @@ -125,8 +126,7 @@ function scr_crusade() { if (roll3<=10) then artifacts+=1; if (artifacts>0) then repeat(artifacts){ - if (obj_ini.fleet_type=ePlayerBase.home_world) then scr_add_artifact("random","",4,obj_ini.home_name,2); - if (obj_ini.fleet_type != ePlayerBase.home_world) then scr_add_artifact("random","",4,obj_ini.ship[0],501); + scr_add_artifact("random", "", 4); } diff --git a/scripts/scr_dialogue/scr_dialogue.gml b/scripts/scr_dialogue/scr_dialogue.gml index 0976887efb..92d0604b55 100644 --- a/scripts/scr_dialogue/scr_dialogue.gml +++ b/scripts/scr_dialogue/scr_dialogue.gml @@ -314,8 +314,7 @@ function scr_dialogue(diplo_keyphrase) { obj_controller.chaos_rating+=1; // Casket, Chalice, Tome - if (obj_ini.fleet_type=ePlayerBase.home_world) then scr_add_artifact("chaos_gift","",0,obj_ini.home_name,2); - if (obj_ini.fleet_type != ePlayerBase.home_world) then scr_add_artifact("chaos_gift","",0,obj_ini.ship[0],501); + scr_add_artifact("chaos_gift", "", 0); } if (string_count("cs_meeting_battle",diplo_keyphrase)>0){ current_eventing=diplo_keyphrase;combating=1; 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 efbd668c1c..bc3d7a71e6 100644 --- a/scripts/scr_draw_management_unit/scr_draw_management_unit.gml +++ b/scripts/scr_draw_management_unit/scr_draw_management_unit.gml @@ -29,7 +29,7 @@ function scr_draw_management_unit(selected, yy = 0, xx = 0, draw = true) { //get roman numeral for system planet unit_location_string += scr_roman(unit_location[1]); } else if (unit_location[0] == location_types.ship) { - unit_location_string = obj_ini.ship[unit_location[1]]; + unit_location_string = fetch_ship(unit_location[1]).name; } assignment = unit.assignment(); if (assignment != "none") { @@ -89,8 +89,8 @@ function scr_draw_management_unit(selected, yy = 0, xx = 0, draw = true) { if (ma_wid[selected] != 0) { //numeral for vehicle planet unit_location_string += scr_roman(ma_wid[selected]); - } else if (ma_lid[selected] > -1) { - unit_location_string = obj_ini.ship[ma_lid[selected]]; + } else if (ma_lid[selected] != "") { + unit_location_string = fetch_ship(ma_lid[selected]).name; } health_string = string(round(ma_health[selected])) + "% HP"; exp_string = ""; @@ -413,11 +413,12 @@ function scr_draw_management_unit(selected, yy = 0, xx = 0, draw = true) { var no_location = selecting_location == ""; var wrong_location = false; if (!no_location) { - if (selecting_ship > -1) { - if (ma_lid[selected] == -1) { + if (selecting_ship != "") { + if (ma_lid[selected] == "") { wrong_location = true; } else { - wrong_location = obj_ini.ship_location[ma_lid[selected]] != selecting_location; + var _ship_struct = fetch_ship(ma_lid[selected]); + wrong_location = _ship_struct.location != selecting_location; } } else { wrong_location = ma_loc[selected] != selecting_location; diff --git a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml index 5f8eb31d2d..c11e7907f3 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -216,8 +216,7 @@ function scr_enemy_ai_d() { scr_event_log("","Mechanicus Mission Completed: The Mechanicus research team on "+string(name)+" "+scr_roman(i)+" have completed their work."); } if (reward=2){ - if (obj_ini.fleet_type=ePlayerBase.home_world) then scr_add_artifact("random","",0,obj_ini.home_name,2); - if (obj_ini.fleet_type != ePlayerBase.home_world) then scr_add_artifact("random","",0,obj_ini.ship[0],501); + scr_add_artifact("random", "", 0); text="The Mechanicus Research team on planet "+string(name)+" "+scr_roman(i)+" have completed their work without any major setbacks. Pleased with your astartes' work, they have granted your Chapter an artifact, to be used as you see fit."; scr_event_log("","Mechanicus Mission Completed: The Mechanicus research team on "+string(name)+" "+scr_roman(i)+" have completed their work."); scr_event_log("","Artifact gifted from Mechanicus."); @@ -254,12 +253,13 @@ function scr_enemy_ai_d() { unit.ship_location=-1; techs_taken+=1; } - if (unit.ship_location>-1){ - ship_planet=obj_ini.ship_location[unit.ship_location]; - if (ship_planet=name){ - obj_ini.ship_carrying[unit.ship_location]-=scr_unit_size(obj_ini.armour[com][ide],obj_ini.role[com][ide],true); - obj_ini.loc[com][ide]="Mechanicus Vessel";unit.planet_location=0;unit.ship_location=0; - techs_taken+=1; + if (unit.ship_location != "") { + var _ship_struct = fetch_ship(unit.ship_location); + ship_planet = _ship_struct.location; + if (ship_planet = name) { + _ship_struct.cargo.carrying -= scr_unit_size(obj_ini.armour[com][ide], obj_ini.role[com][ide], true); + obj_ini.loc[com][ide]="Mechanicus Vessel"; unit.planet_location = 0; unit.ship_location = ""; + techs_taken += 1; } } } diff --git a/scripts/scr_fleet_advisor/scr_fleet_advisor.gml b/scripts/scr_fleet_advisor/scr_fleet_advisor.gml index 38bcdea95b..08c92415a1 100644 --- a/scripts/scr_fleet_advisor/scr_fleet_advisor.gml +++ b/scripts/scr_fleet_advisor/scr_fleet_advisor.gml @@ -139,96 +139,99 @@ function scr_fleet_advisor(){ var _row_height = 20; var _row_gap = 2; - for (var i = ship_current; i < ship_current + 34; i++) { - if (i>= array_length(obj_ini.ship)) then continue; - if (obj_ini.ship[i] != "") { - var _row_y = _columns[$ "name"].y1 + _row_height + (i * (_row_height + _row_gap)); - draw_rectangle(xx + 950, _row_y, xx + 1546, _row_y + _row_height, 1); - - var _goto_button = { - x1: _columns.location.x1 - 20, - y1: _row_y + 4, - sprite: spr_view_small, - click: function() { - return point_and_click([x1, y1, x2, y2]); - } - }; - with(_goto_button) { - w = sprite_get_width(sprite); - h = sprite_get_height(sprite); - x2 = x1 + w; - y2 = y1 + h; - draw_sprite(sprite, 0, x1, y1); + var _ship_UUIDs = struct_get_names(INI_USHIPROOT); + var _ship_count = array_length(_ship_UUIDs); + var _scroll_max = ship_current + 34; + var _loop = _ship_count > _scroll_max ? _scroll_max : ship_current + abs(_scroll_max - _ship_count); + for (var i = ship_current; i < _loop; i++) { + var _ship_struct = fetch_ship(_ship_UUIDs[i]); + var _row_y = _columns[$ "name"].y1 + _row_height + (i * (_row_height + _row_gap)); + draw_rectangle(xx + 950, _row_y, xx + 1546, _row_y + _row_height, 1); + + var _goto_button = { + x1: _columns.location.x1 - 20, + y1: _row_y + 4, + sprite: spr_view_small, + click: function() { + return point_and_click([x1, y1, x2, y2]); } + }; + with(_goto_button) { + w = sprite_get_width(sprite); + h = sprite_get_height(sprite); + x2 = x1 + w; + y2 = y1 + h; + draw_sprite(sprite, 0, x1, y1); + } - with(_columns) { - name.contents = string_truncate(obj_ini.ship[i], _columns.name.w - 6); - class.contents = obj_ini.ship_class[i]; - 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]}"; - } + with(_columns) { + name.contents = string_truncate(ship_struct.name, _columns.name.w - 6); + class.contents = obj_ini.ship_class[i]; + location.contents = obj_ini.ship_location[i]; + hp.contents = $"{round(_ship_struct.health.hp / _ship_struct.health.maxhp * 100)}%"; + carrying.contents = $"{_ship_struct.cargo.carrying} / {_ship_struct.cargo.capacity}"; + } - for (var g = 0; g < array_length(_columns_array); g++) { - with(_columns[$ _columns_array[g]]) { - draw_set_halign(h_align); - switch (h_align) { - case fa_right: - draw_text(x2, _row_y, contents); - break; - case fa_center: - draw_text((x1 + x2) / 2, _row_y, contents); - break; - case fa_left: - default: - draw_text(x1, _row_y, contents); - break; - } + for (var g = 0; g < array_length(_columns_array); g++) { + with(_columns[$ _columns_array[g]]) { + draw_set_halign(h_align); + switch (h_align) { + case fa_right: + draw_text(x2, _row_y, contents); + break; + case fa_center: + draw_text((x1 + x2) / 2, _row_y, contents); + break; + case fa_left: + default: + draw_text(x1, _row_y, contents); + break; + } } } - if scr_hit(xx + 950, _row_y, xx + 1546, _row_y + _row_height) { - if (cn.temp[101] != obj_ini.ship[i]) { - cn.temp[101] = obj_ini.ship[i]; - cn.temp[102] = obj_ini.ship_class[i]; - - cn.temp[103] = string(obj_ini.ship_hp[i]); - cn.temp[104] = string(obj_ini.ship_maxhp[i]); - cn.temp[105] = string(obj_ini.ship_shields[i] * 100); + if scr_hit(xx + 950, _row_y, xx + 1546, _row_y + _row_height) { + if (cn.temp[100] != _ship_struct.UUID) { + cn.temp[100] = _ship_struct.UUID; + cn.temp[101] = _ship_struct.name; + cn.temp[102] = _ship_struct.class; - cn.temp[106] = string(obj_ini.ship_speed[i]); + cn.temp[103] = string(_ship_struct.health.hp); + cn.temp[104] = string(_ship_struct.health.maxhp); + cn.temp[105] = string(_ship_struct.health.shields * 100); - cn.temp[107] = string(obj_ini.ship_front_armour[i]); - cn.temp[108] = string(obj_ini.ship_other_armour[i]); + cn.temp[106] = string(_ship_struct.speed); - cn.temp[109] = string(obj_ini.ship_turrets[i]); + cn.temp[107] = string(_ship_struct.armor.front); + cn.temp[108] = string(_ship_struct.armor.other); - var facing_length = array_length(obj_ini.ship_wep_facing[i]); - var wep_length = array_length(obj_ini.ship_wep[i]); - var max_weapons = min(facing_length, wep_length, 5); + cn.temp[109] = string(_ship_struct.weapons.turrets); - for (var s = 1; s < max_weapons; s++) { - cn.temp[110+((s-1)*2)] = obj_ini.ship_wep[i][s]; - cn.temp[110+((s-1)*2)+1] = obj_ini.ship_wep_facing[i][s]; - } + var wep_length = array_length(_ship_struct.weapons.name); + var max_weapons = min(_ship_struct.weapons.count, 5); - cn.temp[118] = $"{obj_ini.ship_carrying[i]}/{obj_ini.ship_capacity[i]}"; - cn.temp[119] = ""; - if (obj_ini.ship_carrying[i] > 0) then cn.temp[119] = scr_ship_occupants(i); + for (var s = 1; s <= max_weapons; s++) { + cn.temp[110+((s-1)*2)] = _ship_struct.weapons.name[s]; + cn.temp[110+((s-1)*2)+1] = _ship_struct.weapons.facing[s]; } - tooltip_draw($"Carrying ({cn.temp[118]}): {cn.temp[119]}"); - if (_goto_button.click()) { - with(obj_p_fleet) { - var _fleet_ships = fleet_full_ship_array(); - if (array_contains(_fleet_ships, i)){ - obj_controller.x = x; - obj_controller.y = y; - obj_controller.menu = 0; - with(obj_fleet_show) { - instance_destroy(); - } - instance_create(x, y, obj_fleet_show); + + var _ship_carrying = _ship_struct.cargo.carrying; + cn.temp[118] = $"{_ship_carrying} / {_ship_struct.cargo.capacity}"; + cn.temp[119] = ""; + if (_ship_carrying > 0) { cn.temp[119] = scr_ship_occupants(i); } + } + tooltip_draw($"Carrying ({cn.temp[118]}): {cn.temp[119]}"); + if (_goto_button.click()) { + with(obj_p_fleet) { + var _fleet_ships = fleet_full_ship_array(); + if (array_contains(_fleet_ships, i)){ + obj_controller.x = x; + obj_controller.y = y; + obj_controller.menu = 0; + with(obj_fleet_show) { + instance_destroy(); } + instance_create(x, y, obj_fleet_show); } } } @@ -285,4 +288,4 @@ function scr_fleet_advisor(){ } // 31 wide scr_scrollbar(1550, 100, 1577, 818, 34, ship_max, ship_current); -} \ No newline at end of file +} diff --git a/scripts/scr_fleet_functions/scr_fleet_functions.gml b/scripts/scr_fleet_functions/scr_fleet_functions.gml index 377d79ed39..aad3dfdad0 100644 --- a/scripts/scr_fleet_functions/scr_fleet_functions.gml +++ b/scripts/scr_fleet_functions/scr_fleet_functions.gml @@ -195,25 +195,27 @@ function set_fleet_movement(fastest_route = true, new_action="move"){ } } - //TODO build into unit struct function load_unit_to_fleet(fleet, unit){ - var loaded = false; - var all_ships = fleet_full_ship_array(fleet); - - for (var i=0;iobj_ini.ship_carrying[ship_ident]){ - obj_ini.ship_carrying[ship_ident]+=unit.size; - unit.planet_location=0; - obj_ini.loc[unit.company][unit.marine_number]=obj_ini.ship_location[ship_ident]; - unit.ship_location=ship_ident; - loaded=true; - break - } - } - return loaded; + var loaded = false; + var all_ships = fleet_full_ship_array(fleet); + + for (var i = 0; i < array_length(all_ships); i++) { + var _ship = all_ships[i]; + var _ship_struct = fetch_ship(_ship); + if (_ship_struct.cargo.capacity > _ship_struct.cargo.carrying) { + _ship_struct.cargo.carrying += unit.size; + unit.planet_location = 0; + obj_ini.loc[unit.company][unit.marine_number] = _ship_struct.location; + unit.ship_location = _ship; + array_push(_ship_struct.cargo.unit_list, unit.UUID); + loaded = true; + break; + } + } + return loaded; } + function calculate_fleet_eta(xx,yy,xxx,yyy, fleet_speed,star1=true, star2=true,warp_able=false){ var warp_lane = false; eta = 0; 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 63c5c47135..8142a37946 100644 --- a/scripts/scr_ini_ship_cleanup/scr_ini_ship_cleanup.gml +++ b/scripts/scr_ini_ship_cleanup/scr_ini_ship_cleanup.gml @@ -1,116 +1,86 @@ +function scr_kill_ship(fUUID) { + try { + with(obj_ini) { + var _ship_struct = fetch_ship(fUUID); + var _units_on_ship = _ship_struct.cargo.unit_list; + for (var i = 0; i < array_length(_units_on_ship); i++) { + var _unit = fetch_unit(_units_on_ship[i]); + if (!(irandom(_unit.luck) - 3)) { + scr_kill_unit(_units_on_ship[i], undefined); + array_remove(_units_on_ship, i, 1); + i--; + } + } + for (var co = 0; co <= companies; co++) { + for (var i = 0; i < array_length(veh_role[co]); i++) { + if (veh_lid[co][i] == fUUID) { + reset_vehicle_variable_arrays(co, i); + } + } + } + var _ship_loc = _ship_struct.location; + var in_warp = _ship_struct.location == "Warp"; + var _available_ships = []; + var _ship_fleet = find_ships_fleet(UUID); + var _nearest_star = "none"; + if (!in_warp) { + _nearest_star = star_by_name(_ship_loc); + } -function scr_kill_ship(index){ - try { - with(obj_ini){ - var _units_on_ship = []; - var _unit; - for (var co=0;co<=companies;co++){ - for (var i=0;i-1){ - if (_unit.ship_location == index){ - if (!(irandom(_unit.luck)-3)){ - scr_kill_unit(_unit.company, _unit.marine_number); - } else { - array_push(_units_on_ship, _unit); - } - } else { - if (_unit.ship_location>index){ - _unit.ship_location--; - } - } - } - } - for (var i=0;iindex){ - veh_lid[co][i]--; - } - } - } - var in_warp = ship_location[index] == "Warp"; - var _available_ships = []; - var _ship_fleet = find_ships_fleet(index); - if (!in_warp){ - var _nearest_star = star_by_name(ship_location[index]); - } - if (_ship_fleet!="none"){ - delete_ship_from_fleet(index,_ship_fleet); - _available_ships = fleet_full_ship_array(_ship_fleet); - } - _units_on_ship = array_shuffle(_units_on_ship); - for (var i=0;i0){ - f++; - if (_units_on_ship[0].get_unit_size()+ship_carrying[_cur_ship]<=ship_capacity[_cur_ship]){ - _units_on_ship[0].load_marine(_cur_ship); - array_delete(_units_on_ship, 0, 1); - } - } - } - array_delete(ship,index,1); - array_delete(ship_uid,index,1); - array_delete(ship_owner,index,1); - array_delete(ship_class,index,1); - array_delete(ship_size,index,1); - array_delete(ship_leadership,index,1); - array_delete(ship_hp,index,1); - array_delete(ship_maxhp,index,1); + if (_ship_fleet != "none") { + delete_ship_from_fleet(UUID, _ship_fleet); + _available_ships = fleet_full_ship_array(_ship_fleet); + } - array_delete(ship_location,index,1); - array_delete(ship_shields,index,1); - array_delete(ship_conditions,index,1); - array_delete(ship_speed,index,1); - array_delete(ship_turning,index,1); + for (var i = 0; i < array_length(_available_ships); i++) { + var _cur_ship = fetch_ship(_available_ships[i]); + var _max_space = _cur_ship.cargo.capacity; + for (var f = 0; f < array_length(_units_on_ship); f++) { + if (_cur_ship.cargo.carrying < _max_space) { + var _index = _units_on_ship[f]; + var _unit = fetch_unit(_index); + if (_unit.get_unit_size() + _cur_ship.cargo.carrying <= _max_space) { + _unit.load_marine(_cur_ship); + array_delete(_units_on_ship, _index, 1); + f--; + } + } else { + break; + } + } + } - array_delete(ship_front_armour,index,1); - array_delete(ship_other_armour,index,1); - array_delete(ship_weapons,index,1); + if (!in_warp && _nearest_star != "none") { + for (var i = 0; i < array_length(_units_on_ship); i++) { + var _unit = fetch_unit(_units_on_ship[i]); + if (irandom(100) > 100 - _unit.luck) { + _unit.unload(irandom_range(1, _nearest_star.planets), _nearest_star); + } + } + } - array_delete(ship_wep ,index,1); - array_delete(ship_wep_condition,index,1); - array_delete(ship_wep_facing,index,1); - - array_delete(ship_capacity,index,1); - array_delete(ship_carrying,index,1); - array_delete(ship_contents,index,1); - array_delete(ship_turrets,index,1); - - if (!in_warp){ - if (_nearest_star!="none"){ - while(array_length(_units_on_ship)>0){ - _unit = array_pop(_units_on_ship); - if (irandom(100)>100-_unit.luck){ - _unit.unload(irandom_range(1, _nearest_star.planets), _nearest_star); - } - } - } - } - for (var i=0;i=0;i--){ - if (ship[i]!="") and (ship_hp[i]<=0){ - scr_kill_ship(i); - } - } - } - sort_all_companies(); - } - + // If the ship is dead then make it fucking dead man + with(obj_ini) { + var _ship_UUIDs = struct_get_names(USHIPROOT); + var _ship_count = array_length(_ship_UUIDs); + if (_ship_count) { + for (var i = 0; i < _ship_count; i++) { + if (UUID_ship[$ _ship_UUIDs[i]].health.hp <= 0) { + scr_kill_ship(_ship_UUIDs[i]); + } + } + } + sort_all_companies(); + } } diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index 3b69fa350a..e3fc767dc6 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -827,12 +827,16 @@ function scr_initialize_custom() { // log_message(ship_summary_str); // show_debug_message(ship_summary_str); - if (battle_barges>=1){ - for (v=0;v= 6 && real(_coy.coy) <= 7){ if(equal_scouts){ if(companies.tenth.scouts > 10){ @@ -3252,8 +3256,11 @@ 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"){ - // log_message($"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 = new TTRPG_stats("chapter", company, slot, ttrpg_name); + set_unit(spawn_unit.UUID, spawn_unit); + + // log_message($"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] = spawn_unit; obj_ini.race[company][slot] = 1; obj_ini.loc[company][slot] = obj_ini.home_name; obj_ini.role[company][slot] = role_name; @@ -3261,7 +3268,6 @@ function add_unit_to_company(ttrpg_name, company, slot, role_name, role_id, wep1 if(obj_ini.name[company][slot] == ""){ obj_ini.name[company][slot] = global.name_generator.generate_space_marine_name(); } - var spawn_unit = fetch_unit([company,slot]); if(wep1 != ""){ if(wep1 == "default"){ @@ -3459,4 +3465,4 @@ function load_chapter_master_equipment(){ } return chapter_master_equip; -} \ No newline at end of file +} 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 3910912628..b89e0c2cb4 100644 --- a/scripts/scr_inquisition_fleet_functions/scr_inquisition_fleet_functions.gml +++ b/scripts/scr_inquisition_fleet_functions/scr_inquisition_fleet_functions.gml @@ -1,91 +1,89 @@ -function base_inquis_fleet (){ - owner=eFACTION.Inquisition; - frigate_number=1; - sprite_index=spr_fleet_inquisition; - image_index=0; - warp_able=true; - var roll=irandom(100)+1; +function base_inquis_fleet () { + owner = eFACTION.Inquisition; + frigate_number = 1; + sprite_index = spr_fleet_inquisition; + image_index = 0; + warp_able = true; + var roll = roll_dice(1, 100); inquisitor = 0; - trade_goods="Inqis"; - if (roll>60){ - var inquis_choice = choose(2,3,4,5); - inquisitor = inquis_choice + trade_goods = "Inqis"; + if (roll > 60){ + var inquis_choice = choose(2, 3, 4, 5); + inquisitor = inquis_choice; } } - -function inquisition_fleet_inspection_chase(){ - var good=0,acty=""; - var reset = !instance_exists(target); - if (!reset){ +function inquisition_fleet_inspection_chase() { + var good = 0, acty = ""; + var reset = !instance_exists(target); + if (!reset) { reset = target.object_index != obj_p_fleet; } - if (reset){// Reaquire target + if (reset) { // Reacquire target var target_player_fleet = get_largest_player_fleet(); - if (target_player_fleet != "none"){ - if (target_player_fleet.action == ""){ - set_fleet_target(target_player_fleet.x,target_player_fleet.y, target_player_fleet); + if (target_player_fleet != "none") { + if (target_player_fleet.action == "") { + set_fleet_target(target_player_fleet.x, target_player_fleet.y, target_player_fleet); } else { - set_fleet_target(target_player_fleet.action_x,target_player_fleet.action_y, target_player_fleet); + set_fleet_target(target_player_fleet.action_x, target_player_fleet.action_y, target_player_fleet); } } - }else { - - var at_star=instance_nearest(target.x,target.y,obj_star).id; - var target_at_star=instance_nearest(x,y,obj_star).id; - if (target.action!="") then at_star=555; + } else { + var at_star = instance_nearest(target.x, target.y, obj_star).id; + var target_at_star = instance_nearest(x, y, obj_star).id; + if (target.action != "") { at_star = 555; } - if (at_star!=target_at_star){ - trade_goods+="!"; - acty="chase"; - scr_loyalty("Avoiding Inspections","+"); + if (at_star != target_at_star){ + trade_goods += "!"; + acty = "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; + if (string_count("!", trade_goods) == 5) { + obj_controller.alarm[8] = 10; instance_destroy(); exit; } - if (acty="chase"){ + if (acty == "chase") { instance_activate_object(obj_star); - var goal_x,goal_y,target_meet=0; + var goal_x, goal_y, target_meet = 0; chase_fleet_target_set(); - target_meet=instance_nearest(action_x,action_y,obj_star); - if (string_count("!",trade_goods)=4) and (instance_exists(obj_turn_end)){ + target_meet = instance_nearest(action_x, action_y, obj_star); + if (string_count("!", trade_goods) == 4 && instance_exists(obj_turn_end)) { // color / type / text /x/y scr_alert("blank","blank","blank",target_meet.x,target_meet.y); - var massa,iq;iq=0; - massa="Inquisitor "; - if (inquisitor>0){ - iq=inquisitor + var massa, iq = 0; + massa = "Inquisitor "; + if (inquisitor > 0) { + iq = inquisitor } - massa+=string(obj_controller.inquisitor[iq]); + massa += string(obj_controller.inquisitor[iq]); - if (target.action="") then massa+=$" DEMANDS that you keep your fleet at {target_meet.name} until "; - if (target.action!="") then massa+=$" DEMANDS that you station your fleet at {target_meet.name} until "; + if (target.action == "") { massa+=$" DEMANDS that you keep your fleet at {target_meet.name} until "; } + if (target.action != "") { massa+=$" DEMANDS that you station your fleet at {target_meet.name} until "; } - scr_event_log("red",string(massa)+" they may inspect it."); - var gender = obj_controller.inquisitor_gender[iq]==1?"he":"she" - if (obj_controller.inquisitor_gender[iq]=1) then massa+=$"{gender} is able to complete the inspection. Further avoidance will be met with harsh action."; + scr_event_log("red", $"{massa} they may inspect it."); + var gender = obj_controller.inquisitor_gender[iq] == 1 ? "he" : "she"; + if (obj_controller.inquisitor_gender[iq] == 1) { massa+=$"{gender} is able to complete the inspection. Further avoidance will be met with harsh action."; } - scr_popup("Fleet Inspection",massa,"inquisition",""); + scr_popup("Fleet Inspection", massa, "inquisition", ""); // scr_poup(" } exit; - } + } } } // TODO maybe have the inquisitor or his team as an actual entity that goes around and can die, which gives the player time to fix stuff @@ -93,10 +91,10 @@ 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 = "none"; + var new_inquis_fleet; if (obj_ini.fleet_type == ePlayerBase.home_world) { - var monestary_system = "none"; + var monestary_system = "none"; // If player does not own their homeworld than do a fleet inspection instead var player_stars = []; with(obj_star) { @@ -104,18 +102,18 @@ function new_inquisitor_inspection(){ array_push(player_stars, id); } if (system_feature_bool(p_feature, P_features.Monastery)) { - monestary_system = self; + monestary_system = self; } } if (monestary_system != "none"){ - target_system = monestary_system; + target_system = monestary_system; } else if (array_length(player_stars) > 0) { - target_system = player_stars[0]; + target_system = player_stars[0]; } if (target_system != "none") { var target_star = target_system; - var tar, new_inquis_fleet; + var tar; var xx = target_star.x; var yy = target_star.y; @@ -131,7 +129,7 @@ function new_inquisitor_inspection(){ set_fleet_movement(); } var mess = $"Inquisitor {obj_controller.inquisitor[new_inquis_fleet.inquisitor]}"; - mess += " wishes to inspect your chapter base at " + string(target_star.name); + mess += $" wishes to inspect your chapter base at {target_star.name}"; scr_alert("green", "inspect", mess, target_star.x, target_star.y); obj_controller.last_world_inspection = obj_controller.turn; // we sent an inspection, we are done @@ -158,7 +156,7 @@ function new_inquisitor_inspection(){ var mess = $"Inquisitor {obj_controller.inquisitor[new_inquis_fleet.inquisitor]}"; - mess += " wishes to inspect your fleet at " + string(obj.name); + mess += $" wishes to inspect your fleet at {obj.name}"; scr_alert("green", "inspect", mess, obj.x, obj.y); obj_controller.last_fleet_inspection = obj_controller.turn; @@ -168,84 +166,97 @@ function new_inquisitor_inspection(){ } function inquisition_inspection_logic(){ - var inspec_alert_string = ""; - var cur_star=instance_nearest(x,y,obj_star); - inquisitor = inquisitor<0 ? 0 : inquisitor; - var inquis_string = $"Inquisitor {obj_controller.inquisitor[inquisitor]}"; - if (string_count("fleet",trade_goods)==0){ + var inspec_alert_string = ""; + var cur_star=instance_nearest(x,y,obj_star); + inquisitor = inquisitor < 0 ? 0 : inquisitor; + var inquis_string = $"Inquisitor {obj_controller.inquisitor[inquisitor]}"; + if (string_count("fleet",trade_goods) == 0) { inspec_alert_string = $"{inquis_string} finishes inspection of {cur_star.name}"; - inquisition_inspection_loyalty("inspect_world");// This updates the loyalties - } - else if (string_count("fleet",trade_goods)>0){ - inspec_alert_string = $"{inquis_string} finishes inspection of your fleet"; - inquisition_inspection_loyalty("inspect_fleet");// This updates the loyalties - target=noone; + inquisition_inspection_loyalty("inspect_world"); // This updates the loyalties + } else if (string_count("fleet", trade_goods) > 0){ + inspec_alert_string = $"{inquis_string} finishes inspection of your fleet"; + inquisition_inspection_loyalty("inspect_fleet"); // This updates the loyalties + target = noone; } - if (inspec_alert_string!=""){ + if (inspec_alert_string != ""){ scr_event_log("", inspec_alert_string, cur_star.name); - scr_alert("green","duhuhuhu",inspec_alert_string, x,y); + scr_alert("green", "duhuhuhu", inspec_alert_string, x, y); } - + // Test-Slave Incubator Crap - if (obj_controller.und_gene_vaults==0){ - var hur = inquisitor_approval_gene_banks() - if (hur>0){ - - if (hur=1) then obj_controller.disposition[4]-=max(6,round(obj_controller.disposition[4]*0.2)); - if (hur=2) then obj_controller.disposition[4]-=max(3,round(obj_controller.disposition[4]*0.1)); - - - obj_controller.inqis_flag_gene+=1; - if (obj_controller.inqis_flag_gene=1){ - if (hur=1) then inquis_string+=" has noted your abundant Gene-Seed stores and Test-Slave Incubators. Your Chapter has plenty enough Gene-Seed to restore itself to full strength and the Incubators on top of that are excessive. Both have been reported, and you are ordered to remove the Test-Slave Incubators. Relations with the Inquisition are also more strained than before."; - if (hur=2) then inquis_string+=" has noted your abundant Gene-Seed stores and Test-Slave Incubators. Your Chapter is already at full strength and the Incubators on top of that are excessive. The Incubators have been reported, and you are ordered to remove them immediately. Relations with the Inquisition are also slightly more strained than before."; - } - if (obj_controller.inqis_flag_gene=2){ - if (hur=1) then inquis_string+=" has noted your abundant Gene-Seed stores and Test-Slave Incubators. Both the stores and incubators have been reported, and you are AGAIN ordered to remove the Test-Slave Incubators. The Inquisitor says this is your final warning."; - if (hur=2) then inquis_string+=" has noted your abundant Gene-Seed stores and Test-Slave Incubators. Your Chapter is already at full strength and the Incubators are unneeded. The Incubators have been reported, AGAIN, and you are to remove them. The Inquisitor says this is your final warning."; + if (obj_controller.und_gene_vaults == 0){ + var hur = inquisitor_approval_gene_banks(); + if (hur > 0) { + if (hur == 1) { + obj_controller.disposition[eFACTION.Inquisition] -= max(6, round(obj_controller.disposition[eFACTION.Inquisition] * 0.2)); + } else { + obj_controller.disposition[eFACTION.Inquisition] -= max(3, round(obj_controller.disposition[eFACTION.Inquisition] * 0.1)); } - if (obj_controller.inqis_flag_gene=3){ - if (obj_controller.faction_status[eFACTION.Inquisition]!="War") then obj_controller.alarm[8]=1; + + obj_controller.inqis_flag_gene += 1; + if (obj_controller.inqis_flag_gene == 1) { + if (hur == 1) { + inquis_string += " has noted your abundant Gene-Seed stores and Test-Slave Incubators. Your Chapter has plenty enough Gene-Seed to restore itself to full strength and the Incubators on top of that are excessive. Both have been reported, and you are ordered to remove the Test-Slave Incubators. Relations with the Inquisition are also more strained than before."; + } else { + inquis_string += " has noted your abundant Gene-Seed stores and Test-Slave Incubators. Your Chapter is already at full strength and the Incubators on top of that are excessive. The Incubators have been reported, and you are ordered to remove them immediately. Relations with the Inquisition are also slightly more strained than before."; + } + } else if (obj_controller.inqis_flag_gene == 2) { + if (hur == 1) { + inquis_string += " has noted your abundant Gene-Seed stores and Test-Slave Incubators. Both the stores and incubators have been reported, and you are AGAIN ordered to remove the Test-Slave Incubators. The Inquisitor says this is your final warning."; + } else { + inquis_string += " has noted your abundant Gene-Seed stores and Test-Slave Incubators. Your Chapter is already at full strength and the Incubators are unneeded. The Incubators have been reported, AGAIN, and you are to remove them. The Inquisitor says this is your final warning."; + } + } else if (obj_controller.inqis_flag_gene == 3) { + if (obj_controller.faction_status[eFACTION.Inquisition] != "War") { obj_controller.alarm[8] = 1; } } - scr_popup("Inquisition Inspection", inquis_string, "inquisition"); - + scr_popup("Inquisition Inspection", inquis_string, "inquisition"); } } } -function inquisitor_approval_gene_banks(){ +function inquisitor_approval_gene_banks() { var gene_slave_count = 0; - var hur=0 - for (var e=0;e=100) and (obj_controller.gene_seed>=1100) then hur=1; - if (obj_controller.marines<=500) and (obj_controller.marines>200) and (gene_slave_count>=75) and (obj_controller.gene_seed>=900) then hur=1; - if (obj_controller.marines<=700) and (obj_controller.marines>500) and (gene_slave_count>=50) and (obj_controller.gene_seed>=750) then hur=1; - if (obj_controller.marines>700) and (gene_slave_count>=50) and (obj_controller.gene_seed>=500) then hur=1; - if (obj_controller.marines>990) and (gene_slave_count>=50) then hur=2; + + if (obj_controller.marines <= 200) && (gene_slave_count >= 100 && obj_controller.gene_seed >= 1100) { + hur = 1; + } else if (obj_controller.marines <= 500 && obj_controller.marines > 200) && (gene_slave_count >= 75 && obj_controller.gene_seed >= 900) { + hur = 1; + } else if (gene_slave_count >= 50) { + if (obj_controller.marines <= 700 && obj_controller.marines > 500 && obj_controller.gene_seed >= 750) { + hur = 1; + } else if (obj_controller.marines > 700 && obj_controller.gene_seed >= 500) { + hur = 1; + } else if (obj_controller.marines > 990) { + hur = 2; + } + } + return hur; } function inquisitor_ship_approaches(){ //TODO figure out the meaning of this line - if ((string_count("eet",trade_goods)!=0) and (string_count("_her",trade_goods)!=0)) then exit; - var approach_system = instance_nearest(action_x,action_y,obj_star); + if ((string_count("eet", trade_goods) != 0) && (string_count("_her", trade_goods) != 0)) { exit; } + var approach_system = instance_nearest(action_x, action_y, obj_star); var inquis_string; 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 (approach_system.name==player_fleet_location.name){ + 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; - if (fleet_has_roles(target, ["Ork Sniper","Flash Git","Ranger"])){ - inquis_string+=$"Currently, there are non-imperial hirelings within the fleet. It would be wise to at least unload them on a planet below, if we wish to remain in good graces with inquisition, and possibly imperium at large."; + if (fleet_has_roles(target, ["Ork Sniper", "Flash Git", "Ranger"])) { + inquis_string += $"Currently, there are non-imperial hirelings within the fleet. It would be wise to at least unload them on a planet below, if we wish to remain in good graces with inquisition, and possibly imperium at large."; } } } - } else if (approach_system.owner == eFACTION.Player || system_feature_bool(approach_system.p_feature, P_features.Monastery)){ + } else if (approach_system.owner == eFACTION.Player || system_feature_bool(approach_system.p_feature, P_features.Monastery)) { do_alert = true; if (system_feature_bool(approach_system.p_feature, P_features.Monastery)){ inquis_string = $"Our astropaths report that an inquisitor's ship is currently warping towards our Fortress Monastery. It is likely that theInquisitor {obj_controller.inquisitor[inquisitor]} will attempt to perform inspection on our Fortress Monastery."; @@ -253,58 +264,69 @@ function inquisitor_ship_approaches(){ inquis_string = $"Our astropaths report that an inquisitor's ship is currently warping towards our systems under chapter control. It is likely that Inquisitor {obj_controller.inquisitor[inquisitor]} will want to make inspections of any chapter assets and fleets in the system."; } } - if (do_alert){ - var approach_system = instance_nearest(action_x,action_y,obj_star).name; + if (do_alert) { + 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); + scr_alert("green", "duhuhuhu", $"Inquisitor Ship approaches {approach_system}.", x, y); } else { - scr_alert("green","duhuhuhu",$"Inquisitor {obj_controller.inquisitor[inquisitor]} approaches {approach_system}.",x,y); + scr_alert("green", "duhuhuhu", $"Inquisitor {obj_controller.inquisitor[inquisitor]} approaches {approach_system}.", x, y); } scr_popup("Inquisition Inspection", inquis_string, ""); } } -function inquisition_inspection_loyalty(inspection_type){ -if (inspection_type="inspect_world") or (inspection_type="inspect_fleet"){ - var i,diceh,ca,ia,that,wid,hurr; - i=0;diceh=0;ca=0;ia=0;that=0;wid=0;hurr=0; +function inquisition_inspection_loyalty(inspection_type) { +if (inspection_type="inspect_world") || (inspection_type="inspect_fleet") { + var diceh, that, wid, hurr; + diceh = 0; that = 0; wid = 0; hurr = 0; - var sniper,finder,git,demonic; - sniper=0;finder=0;git=0;demonic=0; + var sniper, finder, git, demonic; + sniper=0; finder = 0; git = 0; demonic = 0; - if (inspection_type="inspect_world"){ + if (inspection_type="inspect_world") { - that=instance_nearest(x,y,obj_star); + that = instance_nearest(x, y, obj_star); // show_message(that); instance_activate_object(obj_en_fleet); - for (var i =1;i<=that.planets;i++){ - if (that.p_hurssy[i]>0) then hurr+=that.p_hurssy[i]; + for (var i = 1; i <= that.planets; i++){ + if (that.p_hurssy[i] > 0) { hurr += that.p_hurssy[i]; } } var unit; - for (var g=1;g0) then hurr+=player_inspection_fleet.hurssy; + if (player_inspection_fleet.hurssy > 0) { hurr += player_inspection_fleet.hurssy; } var ca, ia; - for (ca=0;ca<11;ca++){ - for (ia=0;ia0){ - var hurrr=floor(random(12))+1; - if (hurrr<=hurr){ - obj_controller.alarm[8]=1; - if (demonic>0) then scr_alert("red","inspect","Inquisitor discovers Daemonic item(s) in your posession.",0,0); - if (sniper>0) then scr_alert("red","inspect","Inquisitor discovers Ork Sniper(s) hired by your chapter.",0,0); - if (git>0) then scr_alert("red","inspect","Inquisitor discovers Flash Git(z) hired by your chapter.",0,0); - if (finder>0) then scr_alert("red","inspect","Inquisitor discovers Eldar Ranger(s) hired by your chapter.",0,0); - if (demonic+sniper+git+finder=0) then scr_alert("red","inspect","Inquisitor discovers heretical material in your posession.",0,0); + if (hurr > 0) { + var hurrr = floor(random(12))+1; + if (hurrr <= hurr) { + obj_controller.alarm[8] = 1; + if (demonic > 0) { scr_alert("red", "inspect", "Inquisitor discovers Daemonic item(s) in your posession.", 0, 0); } + if (sniper > 0) { scr_alert("red", "inspect", "Inquisitor discovers Ork Sniper(s) hired by your chapter.", 0, 0); } + if (git > 0) { scr_alert("red", "inspect", "Inquisitor discovers Flash Git(z) hired by your chapter.", 0, 0); } + if (finder > 0) { scr_alert("red", "inspect", "Inquisitor discovers Eldar Ranger(s) hired by your chapter.", 0, 0); } + if (demonic + sniper + git + finder == 0) { scr_alert("red", "inspect", "Inquisitor discovers heretical material in your posession.", 0, 0); } } } - i=0; - - repeat(22){ - i+=1;diceh=0; + + var i = 0; + repeat(22) { + i += 1; diceh = 0; - if (obj_controller.loyal_num[i]<1) and (obj_controller.loyal_num[i]>0) and (obj_controller.loyal[i]!="Avoiding Inspections"){ - diceh=random(floor(100))+1; + if (obj_controller.loyal_num[i] < 1 && obj_controller.loyal_num[i] > 0 && obj_controller.loyal[i] != "Avoiding Inspections") { + diceh = roll_dice(1, 100, "low"); - if (diceh<=(obj_controller.loyal_num[i]*1000)){ - if (obj_controller.loyal[i]="Heretic Contact"){ - obj_controller.loyal_num[i]=80; - obj_controller.loyal_time[i]=9999; - scr_alert("red","inspect","Inquisitor discovers evidence of Chaos Lord correspondence.",0,0); - - var one;one=0; - if (obj_controller.disposition[4]>=80) and (one=0){obj_controller.disposition[4]=30;one=1;} - if (obj_controller.disposition[4]<80) and (obj_controller.disposition[4]>10) and (one=0){obj_controller.disposition[4]=5;one=2;} - if (obj_controller.disposition[4]<=10) and (one=0){obj_controller.disposition[4]=0;one=3;} + if (diceh <= (obj_controller.loyal_num[i] * 1000)) { + if (obj_controller.loyal[i] == "Heretic Contact") { + obj_controller.loyal_num[i] = 80; + obj_controller.loyal_time[i] = 9999; + scr_alert("red", "inspect", "Inquisitor discovers evidence of Chaos Lord correspondence.", 0, 0); + + var one = 0; + if (one == 0) { + if (obj_controller.disposition[eFACTION.Inquisition] >= 80) { + obj_controller.disposition[eFACTION.Inquisition] = 30; + one = 1; + } else if (obj_controller.disposition[eFACTION.Inquisition] < 80) && (obj_controller.disposition[eFACTION.Inquisition] > 10) { + obj_controller.disposition[eFACTION.Inquisition] = 5; + one = 2; + } else if (obj_controller.disposition[eFACTION.Inquisition] <= 10) { + obj_controller.disposition[eFACTION.Inquisition] = 0; + one = 3; + } + } - if ((obj_controller.loyalty-80)<=0) and (one<3) then one=3; - if (one=1) then with(obj_controller){scr_audience(4,"chaos_audience1",0,"",0,0);} - if (one=2) then with(obj_controller){scr_audience(4,"chaos_audience2",0,"",0,0);} - if (one=3) then obj_controller.alarm[8]=1; + if ((obj_controller.loyalty - 80) <= 0 && one < 3) { one = 3; } + if (one == 1) { + with(obj_controller) { scr_audience(4, "chaos_audience1", 0, "", 0, 0); } + } else if (one == 2) { + with(obj_controller) { scr_audience(4, "chaos_audience2", 0, "", 0, 0); } + } else if (one == 3) { + obj_controller.alarm[8] = 1; + } + } + + switch (obj_controller.loyal[i]) { + case "Heretical Homeworld": + case "Undevout": + obj_controller.loyal_num[i] = 20; + obj_controller.loyal_time[i] = 3; + break; + case "Mutant Gene-Seed": + case "Traitorous Marines": + obj_controller.loyal_num[i] = 30; + obj_controller.loyal_time[i] = 9999; + break; + case "Non-Codex Arming": + case "Non-Codex Size": + obj_controller.loyal_num[i] = 12; + obj_controller.loyal_time[i] = 3; + break; + case "Lack Of Apothecary": + case "Upset Machine Spirits": + obj_controller.loyal_num[i] = 8; + obj_controller.loyal_time[i] = 1; + break; + case "Irreverance for His Servants": + obj_controller.loyal_num[i] = 12; + obj_controller.loyal_time[i] = 5; + break; + case "Unvigilant": + obj_controller.loyal_num[i] = 12; + obj_controller.loyal_time[i] = 9999; + break; + case "Conduct Unbecoming": + obj_controller.loyal_num[i] = 8; + obj_controller.loyal_time[i] = 9999; + break; + case "Refusing to Crusade": + obj_controller.loyal_num[i] = 20; + obj_controller.loyal_time[i] = 9999; + break; + case "Eldar Contact": + case "Ork Contact": + case "Tau Contact": + obj_controller.loyal_num[i] = 4; + obj_controller.loyal_time[i] = 9999; + break; + case "Xeno Trade": + case "Xeno Associate": + obj_controller.loyal_num[i] = 20; + obj_controller.loyal_time[i] = 9999; + break; + case "Inquisitor Killer": + obj_controller.loyal_num[i] = 100; + obj_controller.loyal_time[i] = 9999; + break; +// case "Avoiding Inspections": +// obj_controller.loyal_num[i] = 20; +// obj_controller.loyal_time[i] = 120; +// break; +// case "Lost Standard": +// obj_controller.loyal_num[i] = 10; +// obj_controller.loyal_time[i] = 9999; +// break; } - if (obj_controller.loyal[i]="Heretical Homeworld"){obj_controller.loyal_num[i]=20;obj_controller.loyal_time[i]=3;} - if (obj_controller.loyal[i]="Traitorous Marines"){obj_controller.loyal_num[i]=30;obj_controller.loyal_time[i]=9999;} - // if (obj_controller.loyal[i]="Use of Sorcery"){obj_controller.loyal_num[i]=30;obj_controller.loyal_time[i]=9999;} - if (obj_controller.loyal[i]="Mutant Gene-Seed"){obj_controller.loyal_num[i]=30;obj_controller.loyal_time[i]=9999;} - - if (obj_controller.loyal[i]="Non-Codex Arming"){obj_controller.loyal_num[i]=12;obj_controller.loyal_time[i]=3;} - if (obj_controller.loyal[i]="Non-Codex Size"){obj_controller.loyal_num[i]=12;obj_controller.loyal_time[i]=3;} - if (obj_controller.loyal[i]="Lack of Apothecary"){obj_controller.loyal_num[i]=8;obj_controller.loyal_time[i]=1;} - if (obj_controller.loyal[i]="Upset Machine Spirits"){obj_controller.loyal_num[i]=8;obj_controller.loyal_time[i]=1;} - if (obj_controller.loyal[i]="Undevout"){obj_controller.loyal_num[i]=20;obj_controller.loyal_time[i]=3;} - if (obj_controller.loyal[i]="Irreverance for His Servants"){obj_controller.loyal_num[i]=12;obj_controller.loyal_time[i]=5;} - if (obj_controller.loyal[i]="Unvigilant"){obj_controller.loyal_num[i]=12;obj_controller.loyal_time[i]=9999;} - if (obj_controller.loyal[i]="Conduct Unbecoming"){obj_controller.loyal_num[i]=8;obj_controller.loyal_time[i]=9999;} - if (obj_controller.loyal[i]="Refusing to Crusade"){obj_controller.loyal_num[i]=20;obj_controller.loyal_time[i]=9999;} - - if (obj_controller.loyal[i]="Eldar Contact"){obj_controller.loyal_num[i]=4;obj_controller.loyal_time[i]=9999;} - if (obj_controller.loyal[i]="Ork Contact"){obj_controller.loyal_num[i]=4;obj_controller.loyal_time[i]=9999;} - if (obj_controller.loyal[i]="Tau Contact"){obj_controller.loyal_num[i]=4;obj_controller.loyal_time[i]=9999;} - if (obj_controller.loyal[i]="Xeno Trade"){obj_controller.loyal_num[i]=20;obj_controller.loyal_time[i]=9999;} - if (obj_controller.loyal[i]="Xeno Associate"){obj_controller.loyal_num[i]=20;obj_controller.loyal_time[i]=9999;} - - if (obj_controller.loyal[i]="Inquisitor Killer"){obj_controller.loyal_num[i]=100;obj_controller.loyal_time[i]=9999;} - // if (obj_controller.loyal[i]="Avoiding Inspections"){obj_controller.loyal_num[i]=20;obj_controller.loyal_time[i]=120;} - // if (obj_controller.loyal[i]="Lost Standard"){obj_controller.loyal_num[i]=10;obj_controller.loyal_time[i]=9999;} - - obj_controller.loyalty_hidden-=obj_controller.loyal_num[i]; + + obj_controller.loyalty_hidden -= obj_controller.loyal_num[i]; } } }// End repeat - - obj_controller.loyalty=obj_controller.loyalty_hidden; + obj_controller.loyalty = obj_controller.loyalty_hidden; } } - - - diff --git a/scripts/scr_kill_unit/scr_kill_unit.gml b/scripts/scr_kill_unit/scr_kill_unit.gml index 0dc560d3ec..3f729b6f2a 100644 --- a/scripts/scr_kill_unit/scr_kill_unit.gml +++ b/scripts/scr_kill_unit/scr_kill_unit.gml @@ -1,62 +1,80 @@ // Script assets have changed for v2.3.0 see // https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information -function scr_kill_unit(company, unit_slot){ - if (obj_ini.role[company][unit_slot]=="Forge Master"){ - array_push(obj_ini.previous_forge_masters, obj_ini.name[company][unit_slot]); - } +function scr_kill_unit(company, unit_slot) { + var _unit; + if (is_string(company)) { + _unit = fetch_unit(company); + company = _unit.company; + unit_slot = _unit.marine_number; + } else { + _unit = fetch_unit([company, unit_slot]); + } + + if (obj_ini.role[company][unit_slot]=="Forge Master") { + array_push(obj_ini.previous_forge_masters, obj_ini.name[company][unit_slot]); + } - if (obj_ini.role[company][unit_slot]==obj_ini.role[100][eROLE.ChapterMaster]){ - tek="c"; - alarm[7]=5; - global.defeat=1; + if (obj_ini.role[company][unit_slot] == obj_ini.role[100][eROLE.ChapterMaster]) { + tek = "c"; + alarm[7] = 5; + global.defeat = 1; } - _unit = fetch_unit([company, unit_slot]); - if (_unit.weapon_one()=="Company Standard" || _unit.weapon_two()=="Company Standard"){ - scr_loyalty("Lost Standard","+"); + if (_unit.weapon_one() == "Company Standard" || _unit.weapon_two() == "Company Standard") { + scr_loyalty("Lost Standard", "+"); } _unit.remove_from_squad(); - scr_wipe_unit(company, unit_slot) + scr_uuid_delete_unit(_unit.UUID); + scr_wipe_unit(company, unit_slot); } -function scr_wipe_unit(company, unit_slot){ - obj_ini.spe[company][unit_slot]=""; - obj_ini.race[company][unit_slot]=0; - obj_ini.loc[company][unit_slot]=""; - obj_ini.name[company][unit_slot]=""; - obj_ini.wep1[company][unit_slot]=""; - obj_ini.role[company][unit_slot]=""; - obj_ini.wep2[company][unit_slot]=""; - obj_ini.armour[company][unit_slot]=""; - obj_ini.gear[company][unit_slot]=""; - obj_ini.god[company][unit_slot]=0; - obj_ini.age[company][unit_slot]=0; - obj_ini.mobi[company][unit_slot]=""; - obj_ini.bio[company][unit_slot]=""; - obj_ini.TTRPG[company][unit_slot].base_group="none"; +function scr_wipe_unit(company, unit_slot) { + obj_ini.spe[company][unit_slot] = ""; + obj_ini.race[company][unit_slot] = 0; + obj_ini.loc[company][unit_slot] = ""; + obj_ini.name[company][unit_slot] = ""; + obj_ini.wep1[company][unit_slot] = ""; + obj_ini.role[company][unit_slot] = ""; + obj_ini.wep2[company][unit_slot] = ""; + obj_ini.armour[company][unit_slot] = ""; + obj_ini.gear[company][unit_slot] = ""; + obj_ini.god[company][unit_slot] = 0; + obj_ini.age[company][unit_slot] = 0; + obj_ini.mobi[company][unit_slot] = ""; + obj_ini.bio[company][unit_slot] = ""; + obj_ini.TTRPG[company][unit_slot] = new TTRPG_stats("chapter", company, unit_slot, "blank"); // create new empty unit structure } function kill_and_recover(company, unit_slot, equipment=true, gene_seed_collect=true){ - var unit = obj_ini.TTRPG[company][unit_slot]; - if (equipment){ - var strip = { - "wep1":"", - "wep2":"", - "mobi":"", - "armour":"", - "gear":"", - }; - unit.alter_equipment(strip,false, true); - } - if (gene_seed_collect && unit.base_group=="astartes"){ - if (unit.age() > 30 && !obj_ini.zygote && !obj_ini.doomed) then obj_controller.gene_seed+=1; - if (unit.age() > 50 && !obj_ini.doomed) then obj_controller.gene_seed+=1; - } - if (obj_ini.race[company][unit_slot]==1){ - if(is_specialist(obj_ini.role[company][unit_slot])){ - obj_controller.command-=1; - } else{ - obj_controller.marines-=1; + var _unit; + if (is_string(company)) { + _unit = fetch_unit(company); + company = _unit.company; + unit_slot = _unit.marine_number; + } else { + _unit = fetch_unit([company, unit_slot]); + } + + if (equipment) { + var strip = { + "wep1" : "", + "wep2" : "", + "mobi" : "", + "armour" : "", + "gear" : "" + }; + + _unit.alter_equipment(strip, false, true); + } + if (gene_seed_collect && _unit.base_group == "astartes") { + if (_unit.age() > 30 && !obj_ini.zygote && !obj_ini.doomed) { obj_controller.gene_seed += 1; } + if (_unit.age() > 50 && !obj_ini.doomed) { obj_controller.gene_seed += 1; } + } + if (obj_ini.race[company][unit_slot] == 1) { + if(is_specialist(obj_ini.role[company][unit_slot])) { + obj_controller.command -= 1; + } else { + obj_controller.marines -= 1; } - } - scr_kill_unit(company, unit_slot); -} \ No newline at end of file + } + scr_kill_unit(company, unit_slot); +} diff --git a/scripts/scr_librarium/scr_librarium.gml b/scripts/scr_librarium/scr_librarium.gml index 6d24550393..78fbdaab4b 100644 --- a/scripts/scr_librarium/scr_librarium.gml +++ b/scripts/scr_librarium/scr_librarium.gml @@ -341,24 +341,19 @@ function scr_librarium(){ draw_set_color(881503); draw_set_halign(fa_center); - if (instance_exists(obj_p_fleet)) { + if (obj_controller.artifacts > 0 && instance_exists(obj_p_fleet)) { with(obj_p_fleet) { - var good = 0; - if (obj_controller.artifacts>0){ - for (var i = 1; i <= 20; i++) { - if (i <= 9 && i 0) { + var _ship_hash = variable_get_hash(obj_ini.artifact_sid[obj_controller.menu_artifact].ship); + var _ships = [capital, frigate, escort]; + var _ships_count = array_length(_ships); + for (var i = 0; i < _ships_count; i++) { + if (struct_exists(_ships[i], _ship_hash)) { + obj_controller.identifiable = 1; + break; } } } - if (good = 1) and(capital_number > 0) then good = 2; - if (good = 2) then obj_controller.identifiable = 1; } } -} \ No newline at end of file +} diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index 31f11bf02e..ed126cfde2 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -404,6 +404,10 @@ global.base_stats = { }; function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {}) constructor { + UUID = ""; + if (class != "blank") { + UUID = $"U{scr_uuid_generate()}"; + } constitution = 0; strength = 0; luck = 0; @@ -422,10 +426,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} planet_location = obj_ini.home_planet; } ship_location = -1; - last_ship = { - uid: "", - name: "" - }; + last_ship = ""; religion = "none"; master_loyalty = 0; job = "none"; @@ -1005,10 +1006,6 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} break; } - static race = function() { - return obj_ini.race[company][marine_number]; - }; //get race - static update_loyalty = function(change_value) { loyalty = clamp(loyalty + change_value, 0, 100); }; @@ -1125,7 +1122,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 @@ -1332,7 +1328,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} static race = function() { return obj_ini.race[company][marine_number]; - }; + }; //get race //get equipment data methods by deafult they garb all equipment data and return an equipment struct e.g new EquipmentStruct(item_data, core_type,quality="none") static get_armour_data = function(type = "all") { @@ -1867,7 +1863,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} var location_type = planet_location; if (location_type > 0) { //if marine is on planet - location_id = location_type; //planet_number marine is on + location_id = string(location_type); //planet_number marine is on location_type = location_types.planet; //state marine is on planet if (obj_ini.loc[company][marine_number] == "home") { obj_ini.loc[company][marine_number] = obj_ini.home_name; @@ -1875,12 +1871,8 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} location_name = obj_ini.loc[company][marine_number]; //system marine is in } else { location_type = location_types.ship; //marine is on ship - location_id = ship_location; //ship array position - if (location_id < array_length(obj_ini.ship_location)) { - location_name = obj_ini.ship_location[location_id]; //location of ship - } else { - location_name = location_name == obj_ini.loc[company][marine_number]; - } + location_id = ship_location; //ship UUID + location_name = fetch_ship(ship_location).location; //location of ship } return [location_type, location_id, location_name]; }; @@ -1907,11 +1899,12 @@ 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(fUUID, star = "none") { get_unit_size(); // make sure marines size given it's current equipment is correct var current_location = marine_location(); var system = current_location[2]; - var target_ship_location = obj_ini.ship_location[ship]; + var _ship_struct = fetch_ship(fUUID); + var target_ship_location = _ship_struct.location; set_last_ship(); if (assignment() != "none") { return "on assignment"; @@ -1926,10 +1919,10 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} system = obj_ini.home_name; } //check if ship is in the same location as marine and has enough space; - if ((target_ship_location == system) && ((obj_ini.ship_carrying[ship] + size) <= obj_ini.ship_capacity[ship])) { + if ((target_ship_location == system) && ((_ship_struct.cargo.carrying + size) <= _ship_struct.cargo.capacity)) { planet_location = 0; //mark marine as no longer on planet - ship_location = ship; //id of ship marine is now loaded on - obj_ini.ship_carrying[ship] += size; //update ship capacity + ship_location = fUUID; //id of ship marine is now loaded on + _ship_struct.cargo.carrying += size; //update ship capacity if (star == "none") { star = star_by_name(system); @@ -1943,37 +1936,35 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} } else if (current_location[0] == location_types.ship) { //with this addition marines can now be moved between ships freely as long as they are in the same system var off_loading_ship = current_location[1]; - if ((obj_ini.ship_location[ship] == obj_ini.ship_location[off_loading_ship]) && ((obj_ini.ship_carrying[ship] + size) <= obj_ini.ship_capacity[ship])) { - obj_ini.ship_carrying[off_loading_ship] -= size; // remove from previous ship capacity + var _off_ship_struct = fetch_ship(off_loading_ship); + if ((target_ship_location == _off_ship_struct.location) && ((_ship_struct.cargo.carrying + size) <= _ship_struct.cargo.capacity)) { + _off_ship_struct.cargo.carrying -= size; // remove from previous ship capacity ship_location = ship; // change marine location to new ship - obj_ini.ship_carrying[ship] += size; //add marine capacity to new ship + _ship_struct.cargo.carrying += size; //add marine capacity to new ship } } }; static set_last_ship = function() { if (ship_location > -1) { - last_ship.uid = obj_ini.ship_uid[ship_location]; - last_ship.name = obj_ini.ship[ship_location]; + last_ship = ship_location; } else { - last_ship = { - uid: "", - name: "" - }; + last_ship = ""; } }; static unload = function(planet_number, system) { var current_location = marine_location(); - set_last_ship(); if (current_location[0] == location_types.ship) { if (!array_contains(["Warp", "Terra", "Mechanicus Vessel", "Lost"], current_location[2]) && current_location[2] == system.name) { - obj_ini.loc[company][marine_number] = obj_ini.ship_location[current_location[1]]; + set_last_ship(); + var _ship_struct = fetch_ship(current_location[1]); + obj_ini.loc[company][marine_number] = _ship_struct.location; planet_location = planet_number; ship_location = -1; get_unit_size(); system.p_player[planet_number] += size; - obj_ini.ship_carrying[current_location[1]] -= size; + _ship_struct.cargo.carrying -= size; } } else { ship_location = -1; @@ -2295,8 +2286,36 @@ function jsonify_marine_struct(company, marine, stringify=true) { } } -/// @param {Array} unit where unit[0] is company and unit[1] is the position +#macro INI_UUNITROOT obj_ini.UUNITROOT +#macro UUNITROOT UUID_marine +/// DEPRECATED : @param {Array} unit where unit[0] is company and unit[1] is the position +/// @param {} funit where unit is a UUID /// @returns {Struct.TTRPG_stats} unit -function fetch_unit(unit) { - return obj_ini.TTRPG[unit[0]][unit[1]]; +function fetch_unit(funit) { + gml_pragma("forceinline"); + if (!is_string(funit)) { + return obj_ini.TTRPG[funit[0]][funit[1]]; + } else { + return struct_get(INI_UUNITROOT, funit); + } +} + +/// @param {} funit where unit is a hash of a UUID +/// @returns {Struct.TTRPG_stats} unit +function fetch_unit_from_hash(funit) { + gml_pragma("forceinline"); + return struct_get_from_hash(INI_UUNITROOT, funit); +} + +/// @param {} funit where unit is a UUID +function set_unit(funit, fdata) { + gml_pragma("forceinline"); + struct_set(INI_UUNITROOT, funit, fdata); +} + +/// @param {} funit where unit is a hash of a UUID +/// @param {} fdata data for variable +function set_unit_from_hash(funit, fdata) { + gml_pragma("forceinline"); + struct_set_from_hash(INI_UUNITROOT, funit, fdata); } diff --git a/scripts/scr_mission_eta/scr_mission_eta.gml b/scripts/scr_mission_eta/scr_mission_eta.gml index 2befc0ea8a..7c93281200 100644 --- a/scripts/scr_mission_eta/scr_mission_eta.gml +++ b/scripts/scr_mission_eta/scr_mission_eta.gml @@ -1,54 +1,52 @@ function scr_mission_eta(argument0, argument1, argument2) { - // argument0: x - // argument1: y - // argument2: type 1: fly to 2: marines 3: requires a couple of turns + marines + // argument0: x + // argument1: y + // argument2: type 1: fly to 2: marines 3: requires a couple of turns + marines - // round(point_distance(flit.x,flit.y,you2.x,you2.y)/48)+2 + // round(point_distance(flit.x,flit.y,you2.x,you2.y)/48)+2 - var eta1,n1,n2; - eta1=99;n1=0;n2=0; + var eta1, n1, n2; + eta1 = 99; n1 = 0; n2 = 0; - if (instance_exists(obj_p_fleet)){ - if (argument2=1){ - n1=instance_nearest(x,y,obj_p_fleet); - with(n1){y-=3000;} - n2=instance_nearest(x,y,obj_p_fleet); - with(n1){y+=3000;} + if (instance_exists(obj_p_fleet)) { + if (argument2 = 1) { + n1 = instance_nearest(x, y, obj_p_fleet); + with(n1) { y -= 3000; } + n2 = instance_nearest(x, y, obj_p_fleet); + with(n1) { y += 3000; } - eta1=((point_distance(argument0,argument1,n1.x,n1.y)+point_distance(argument0,argument1,n2.x,n2.y))/2)/48; - eta1+=2+choose(-1,0,0,0,1,2); - } - if (argument2>1){ - with(obj_p_fleet){ - var good,i;good=0;i=0; - - repeat(50){ - i+=1; - if (i<=20){if (capital[i]!="") and (obj_ini.ship_carrying[capital_num[i]]>0) then good=1;} - if (frigate[i]!="") and (obj_ini.ship_carrying[frigate_num[i]]>0) then good=1; - if (escort[i]!="") and (obj_ini.ship_carrying[escort_num[i]]>0) then good=1; - } - if (good>0) then instance_create(x,y,obj_temp_inq); - } + eta1 = ((point_distance(argument0, argument1, n1.x, n1.y) + point_distance(argument0, argument1, n2.x, n2.y)) / 2) / 48; + eta1 += 2 + choose(-1, 0, 0, 0, 1, 2); + } + if (argument2 > 1) { + with(obj_p_fleet) { + var _fleet_array = fleet_full_ship_array(); + var _fleet_array_length = array_length(_fleet_array); + + for (var i = 0; i < _fleet_array_length; i++) { + if (fetch_ship(_fleet_array[i]).cargo.carrying > 0) { + instance_create(x, y, obj_temp_inq); + break; + } + } + } - if (instance_exists(obj_temp_inq)){ - n1=instance_nearest(x,y,obj_temp_inq); - with(n1){y-=3000;} - n2=instance_nearest(x,y,obj_temp_inq); - with(n1){y+=3000;} + if (instance_exists(obj_temp_inq)) { + n1 = instance_nearest(x, y, obj_temp_inq); + with(n1) { y -= 3000; } + n2 = instance_nearest(x, y, obj_temp_inq); + with(n1) { y += 3000; } - eta1=((point_distance(argument0,argument1,n1.x,n1.y)+point_distance(argument0,argument1,n2.x,n2.y))/2)/48; - eta1+=2+choose(-1,0,0,0,1,2); - if (argument2=3) then eta1+=choose(1,2,3); - with(obj_temp_inq){instance_destroy();} - } - if (!instance_exists(obj_temp_inq)) then eta1=floor(random_range(12,26))+1; - } - } - if (!instance_exists(obj_p_fleet)) then eta1=floor(random_range(12,26))+1; - - return(eta1); - + eta1 = ((point_distance(argument0, argument1, n1.x, n1.y) + point_distance(argument0, argument1, n2.x, n2.y)) / 2) / 48; + eta1 += 2 + choose(-1, 0, 0, 0, 1, 2); + if (argument2 = 3) { eta1 += choose(1, 2, 3); } + with(obj_temp_inq) { instance_destroy(); } + } + if (!instance_exists(obj_temp_inq)) { eta1 = floor(random_range(12, 26)) + 1; } + } + } + if (!instance_exists(obj_p_fleet)) { eta1 = floor(random_range(12, 26)) + 1; } + return(eta1); } diff --git a/scripts/scr_mission_reward/scr_mission_reward.gml b/scripts/scr_mission_reward/scr_mission_reward.gml index 7cab49a924..b6b57e62e2 100644 --- a/scripts/scr_mission_reward/scr_mission_reward.gml +++ b/scripts/scr_mission_reward/scr_mission_reward.gml @@ -41,8 +41,7 @@ function scr_mission_reward(argument0, argument1, argument2) { } if (roll2>=80) and (roll2<88) then found_requisition+=100; if (roll2>=88) and (roll2<96){ - if (obj_ini.fleet_type=ePlayerBase.home_world) then scr_add_artifact("random","",4,obj_ini.home_name,2); - if (obj_ini.fleet_type != ePlayerBase.home_world) then scr_add_artifact("random","",4,obj_ini.ship[0],501); + scr_add_artifact("random", "", 4); found_artifact+=1; } if (roll2>=96){ 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 8345d15216..3fc0b1ec4e 100644 --- a/scripts/scr_move_unit_info/scr_move_unit_info.gml +++ b/scripts/scr_move_unit_info/scr_move_unit_info.gml @@ -1,34 +1,27 @@ - function scr_move_unit_info(start_company,end_company, start_slot, end_slot, eval_squad=true){ - //eval_squad : determine whether movement of units between companies should decide to check their squad coherency or not, defaults to true - - //this makes sure coherency of the unit's squad and the squads logging of the unit location are kept up to date - var unit = obj_ini.TTRPG[start_company, start_slot]; - if (eval_squad){ - unit.movement_after_math(end_company,end_slot); - } - obj_ini.spe[end_company][end_slot]=obj_ini.spe[start_company][start_slot]; - obj_ini.race[end_company][end_slot]=obj_ini.race[start_company][start_slot]; - obj_ini.loc[end_company][end_slot]=obj_ini.loc[start_company][start_slot]; - obj_ini.name[end_company][end_slot]=obj_ini.name[start_company][start_slot]; - obj_ini.wep1[end_company][end_slot]=obj_ini.wep1[start_company][start_slot]; - obj_ini.role[end_company][end_slot]=obj_ini.role[start_company][start_slot]; - obj_ini.wep2[end_company][end_slot]=obj_ini.wep2[start_company][start_slot]; - obj_ini.gear[end_company][end_slot]=obj_ini.gear[start_company][start_slot]; - obj_ini.armour[end_company][end_slot]=obj_ini.armour[start_company][start_slot]; - obj_ini.god[end_company][end_slot]=obj_ini.god[start_company][start_slot]; - obj_ini.age[end_company][end_slot]=obj_ini.age[start_company][start_slot]; - obj_ini.mobi[end_company][end_slot]=obj_ini.mobi[start_company][start_slot]; - var temp_struct = jsonify_marine_struct(start_company,start_slot); //jsonified for stransfer of struct (makes a deep copy) - obj_ini.TTRPG[end_company][end_slot] = new TTRPG_stats("chapter", end_company,end_slot ,"blank"); // create new empty unit structure - if (is_string(temp_struct)){ - obj_ini.TTRPG[end_company][end_slot].load_json_data(json_parse(temp_struct)); //load in originoal marine data - obj_ini.TTRPG[end_company][end_slot].company = end_company; - obj_ini.TTRPG[end_company][end_slot].marine_number = end_slot; - } else { - obj_ini.TTRPG[end_company][end_slot] = new TTRPG_stats("chapter", end_company,end_slot ,"blank"); - } + //eval_squad : determine whether movement of units between companies should decide to check their squad coherency or not, defaults to true + + //this makes sure coherency of the unit's squad and the squads logging of the unit location are kept up to date + var unit = obj_ini.TTRPG[start_company, start_slot]; + if (eval_squad){ + unit.movement_after_math(end_company,end_slot); + } + obj_ini.spe[end_company][end_slot]=obj_ini.spe[start_company][start_slot]; + obj_ini.race[end_company][end_slot]=obj_ini.race[start_company][start_slot]; + obj_ini.loc[end_company][end_slot]=obj_ini.loc[start_company][start_slot]; + obj_ini.name[end_company][end_slot]=obj_ini.name[start_company][start_slot]; + obj_ini.wep1[end_company][end_slot]=obj_ini.wep1[start_company][start_slot]; + obj_ini.role[end_company][end_slot]=obj_ini.role[start_company][start_slot]; + obj_ini.wep2[end_company][end_slot]=obj_ini.wep2[start_company][start_slot]; + obj_ini.gear[end_company][end_slot]=obj_ini.gear[start_company][start_slot]; + obj_ini.armour[end_company][end_slot]=obj_ini.armour[start_company][start_slot]; + obj_ini.god[end_company][end_slot]=obj_ini.god[start_company][start_slot]; + obj_ini.age[end_company][end_slot]=obj_ini.age[start_company][start_slot]; + obj_ini.mobi[end_company][end_slot]=obj_ini.mobi[start_company][start_slot]; + obj_ini.TTRPG[end_company][end_slot] = unit; //load in originoal marine data + obj_ini.TTRPG[end_company][end_slot].company = end_company; + obj_ini.TTRPG[end_company][end_slot].marine_number = end_slot; - scr_wipe_unit(start_company,start_slot); -} \ No newline at end of file + scr_wipe_unit(start_company,start_slot); +} 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 568bff61ab..e0c58568d4 100644 --- a/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml +++ b/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml @@ -1,96 +1,60 @@ // Script assets have changed for v2.3.0 see // https://help.yoyogames.com/hc/en-us/articles/360005277377 for more informationype -function init_player_fleet_arrays(){ - ship=[]; - ship_uid=[]; - ship_owner=[]; - ship_class=[]; - ship_size=[]; - ship_leadership=[]; - ship_hp=[]; - ship_maxhp=[]; - - ship_location=[]; - ship_shields=[]; - ship_conditions=[]; - ship_speed=[]; - ship_turning=[]; - - ship_front_armour=[]; - ship_other_armour=[]; - ship_weapons=[]; - - ship_wep = array_create(6, ""); - ship_wep_facing=array_create(6, ""); - ship_wep_condition=array_create(6, ""); - - ship_capacity=[]; - ship_carrying=[]; - ship_contents=[]; - ship_turrets=[]; - ship_lost = []; -} -function fleet_has_roles(fleet="none", roles){ - var all_ships = fleet_full_ship_array(fleet); - var unit; - for (var i=0;i<=10;i++){ - for (var s=0;s0){ - var target_planet = 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"; - if (valid){ - valid = !(target_planet.id == nearest_planet.id && from_star); - } - if (!valid){ - if (array_length(target_array)>1){ - target_planet = star_by_name(target_array[1]); - array_delete(target_array, 0, 2); - } else { - return "complex_route_finish"; - } - } else { - array_delete(target_array, 0, 1); - } - complex_route = target_array; - var from_x = from_star ? nearest_planet.x : x; - var from_y = from_star ? nearest_planet.y : y; - action_eta=calculate_fleet_eta(from_x,from_y,target_planet.x,target_planet.y, action_spd, from_star, ,warp_able); - action_x = target_planet.x; - action_y = target_planet.y; - action="move"; - just_left=true; - orbiting=0; - 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)); +function set_new_player_fleet_course(target_array) { + if (array_length(target_array)>0) { + var target_planet = 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"; + if (valid) { + valid = !(target_planet.id == nearest_planet.id && from_star); + } + if (!valid) { + if (array_length(target_array) > 1) { + target_planet = star_by_name(target_array[1]); + array_delete(target_array, 0, 2); + } else { + return "complex_route_finish"; + } + } else { + array_delete(target_array, 0, 1); + } + complex_route = target_array; + var from_x = from_star ? nearest_planet.x : x; + var from_y = from_star ? nearest_planet.y : y; + action_eta = calculate_fleet_eta(from_x, from_y, target_planet.x, target_planet.y, action_spd, from_star, , warp_able); + action_x = target_planet.x; + action_y = target_planet.y; + action = "move"; + just_left = true; + orbiting = 0; + 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"); - } - + } } -function find_and_move_ship_between_fleets(out_fleet, in_fleet, index){ - var _class = player_ships_class(index); - var relative_index = -1; - switch (_class){ - case "capital": - relative_index = array_get_index(out_fleet.capital_num, index); - break; - case "frigate": - relative_index = array_get_index(out_fleet.frigate_num, index); - break; - case "escort": - relative_index = array_get_index(out_fleet.escort_num, index); - break; - } - if (relative_index!=-1){ - move_ship_between_player_fleets(out_fleet, in_fleet, _class, relative_index); - } +function find_and_move_ship_between_fleets(out_fleet, in_fleet, fUUID) { + move_ship_between_player_fleets(out_fleet, in_fleet, fUUID); } -function merge_player_fleets(main_fleet, merge_fleet){ - var _merge_ships = fleet_full_ship_array(merge_fleet); - for (var i=0;i0) and (en_strength>0){ - ratio=(en_strength/p_strength)*100; + 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; + var esc_lost = 0, frig_lost = 0, cap_lost = 0; - i=-1;// var ship_lost,i; var ship_lost = []; - if (scr_has_adv("Kings of Space")) then _roll_100-=10; - if (_roll_100<=80) and (p_strength<=2) then _roll_100=-5; + if (scr_has_adv("Kings of Space")) { _roll_100 -= 10; } + if (_roll_100 <= 80) && (p_strength <= 2) { _roll_100 = -5; } - if (_roll_100!=-5){ - repeat(50){ - diceh=roll_dice(1, 100, "high"); - if (diceh<=ratio){ - ratio-=100; - var onceh=0; + if (_roll_100 != -5) { + repeat(50) { + diceh = roll_dice(1, 100, "high"); + if (diceh <= ratio) { + ratio -= 100; + var onceh = 0; - if (mfleet.escort_number>0) { - which=array_random_index(mfleet.escort_num); - sayd=mfleet.escort_num[which]; - if (!array_contains(ship_lost, sayd)){ - esc_lost+=1; - obj_ini.ship_hp[sayd]=0; - ship_lost[sayd]=1; - mfleet.escort_number-=1; - array_push(ship_lost, sayd); + if (mfleet.escort_number > 0) { + var _ship_UUIDs = struct_get_names(mfleet.escort); + var _ship = array_random_index(_ship_UUIDs); + if (!array_contains(ship_lost, _ship)) { + var _ship_struct = fetch_ship(_ship); + esc_lost += 1; + _ship_struct.health.hp = 0; + _ship_struct.lost = 1; + mfleet.escort_number -= 1; + array_push(ship_lost, _ship); } - } - else if (mfleet.frigate_number>0) { - which=array_random_index(mfleet.frigate_num); - sayd=mfleet.frigate_num[which]; - if (!array_contains(ship_lost, sayd)){ - frig_lost+=1; - obj_ini.ship_hp[sayd]=0; - ship_lost[sayd]=1; - mfleet.frigate_number-=1; - array_push(ship_lost, sayd); + } else if (mfleet.frigate_number > 0) { + var _ship_UUIDs = struct_get_names(mfleet.frigate); + var _ship = array_random_index(_ship_UUIDs); + if (!array_contains(ship_lost, _ship)) { + var _ship_struct = fetch_ship(_ship); + frig_lost += 1; + _ship_struct.health.hp = 0; + _ship_struct.lost = 1; + mfleet.frigate_number -= 1; + array_push(ship_lost, _ship); } - } - else if (mfleet.capital_number>0) { - which=array_random_index(mfleet.capital_num); - sayd=mfleet.capital_num[which]; - if (!array_contains(ship_lost, sayd)){ - cap_lost+=1; - obj_ini.ship_hp[sayd]=0; - ship_lost[sayd]=1; - mfleet.capital_number-=1; - array_push(ship_lost, sayd); + } else if (mfleet.capital_number > 0) { + var _ship_UUIDs = struct_get_names(mfleet.capital); + var _ship = array_random_index(_ship_UUIDs); + if (!array_contains(ship_lost, _ship)) { + var _ship_struct = fetch_ship(_ship); + cap_lost += 1; + _ship_struct.health.hp = 0; + _ship_struct.lost = 1; + mfleet.capital_number -= 1; + array_push(ship_lost, _ship); } } - if (!(mfleet.capital_number+mfleet.frigate_number+mfleet.escort_number)){ + if (!(mfleet.capital_number + mfleet.frigate_number + mfleet.escort_number)) { break; } // show_message("Ship lost"); } - } } - obj_p_fleet.selected=0; + obj_p_fleet.selected = 0; - with(obj_fleet_select){ + with(obj_fleet_select) { instance_destroy(); } - obj_controller.popup=0; - if (obj_controller.zoomed=1){ - with(obj_controller){ + obj_controller.popup = 0; + if (obj_controller.zoomed = 1) { + with(obj_controller) { scr_zoom(); } } - type=98; - title="Fleet Retreating"; - cooldown=15; - obj_controller.menu=0; + type = 98; + title = "Fleet Retreating"; + cooldown = 15; + obj_controller.menu = 0; // 139; - with(obj_temp_inq){instance_destroy();} - instance_create(obj_turn_end.battle_pobject[obj_turn_end.current_battle].x,obj_turn_end.battle_pobject[obj_turn_end.current_battle].y,obj_temp_inq); - with(obj_en_fleet){ - if (navy=1) and (point_distance(x,y,obj_temp_inq.x,obj_temp_inq.y)<40) and (trade_goods="player_hold") then trade_goods=""; + with(obj_temp_inq) { instance_destroy(); } + instance_create(obj_turn_end.battle_pobject[obj_turn_end.current_battle].x, obj_turn_end.battle_pobject[obj_turn_end.current_battle].y, obj_temp_inq); + with(obj_en_fleet) { + if (navy == 1) && (point_distance(x, y, obj_temp_inq.x, obj_temp_inq.y) < 40) && (trade_goods == "player_hold") { trade_goods = ""; } } - with(obj_temp_inq){instance_destroy();} + with(obj_temp_inq) { instance_destroy(); } - if (esc_lost+frig_lost+cap_lost>0) and (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. "; + 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. "; - if (cap_lost=1) then text+=string(cap_lost)+" Battle Barge is destroyed. "; - if (frig_lost=1) then text+=string(frig_lost)+" Strike Cruiser is destroyed. "; - if (esc_lost=1) then text+=string(esc_lost)+" Escort is destroyed. "; + if (cap_lost = 1) { text += $"{cap_lost} Battle Barge is destroyed. "; } + if (frig_lost = 1) { text += $"{frig_lost} Strike Cruiser is destroyed. "; } + if (esc_lost = 1) { text += $"{esc_lost} Escort is destroyed. "; } - if (cap_lost>1) then text+=string(cap_lost)+" Battle Barges were destroyed. "; - if (frig_lost>1) then text+=string(frig_lost)+" Strike Cruisers were destroyed. "; - if (esc_lost>1) then text+=string(esc_lost)+" Escorts were destroyed. "; + if (cap_lost > 1) { text += $"{cap_lost} Battle Barges were destroyed. "; } + if (frig_lost > 1) { text += $"{frig_lost} Strike Cruisers were destroyed. "; } + if (esc_lost > 1) { text += $"{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."; + if (esc_lost + frig_lost + cap_lost = 0) { + text += "The entire fleet manages to escape with minimal damage."; } - if (mfleet.escort_number+mfleet.frigate_number+mfleet.capital_number=0){ - text+="All of your ships are destroyed attempting to flee."; + if (mfleet.escort_number + mfleet.frigate_number + mfleet.capital_number = 0) { + text += "All of your ships are destroyed attempting to flee."; } - with (obj_p_fleet){ + with (obj_p_fleet) { scr_ini_ship_cleanup(); if (player_fleet_ship_count() == 0){ @@ -440,198 +371,187 @@ function player_retreat_from_fleet_combat(){ } else { complex_route=[]; } - } - with(obj_fleet_select){instance_destroy();} + } + with(obj_fleet_select) { instance_destroy(); } /* with(obj_ini){scr_dead_marines(1);} with(obj_ini){scr_ini_ship_cleanup();} */ - } catch(_exception){ - handle_exception(_exception) - } + } catch(_exception) { + handle_exception(_exception) + } } -function fleet_full_ship_array(fleet="none", 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 (!exclude_capitals){ - for (i=0; i=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;i97){ @@ -113,66 +125,71 @@ function return_lost_ship(){ } } -function get_player_ships(location="", name=""){ - var _ships = []; - for (var i = 0;i0){ - obj_ini.ship_class[index]="Battle Barge"; - obj_ini.ship_size[index]=3; - obj_ini.ship_hp[index]=1200; - obj_ini.ship_maxhp[index]=1200; - obj_ini.ship_conditions[index]=""; - obj_ini.ship_speed[index]=20; - obj_ini.ship_turning[index]=45; - obj_ini.ship_front_armour[index]=6; - obj_ini.ship_other_armour[index]=6; - obj_ini.ship_weapons[index]=5; - obj_ini.ship_shields[index]=12; - obj_ini.ship_wep[index,1]="Weapons Battery"; - obj_ini.ship_wep_facing[index,1]="left"; - obj_ini.ship_wep_condition[index,1]=""; - obj_ini.ship_wep[index,2]="Weapons Battery"; - obj_ini.ship_wep_facing[index,2]="right"; - obj_ini.ship_wep_condition[index,2]=""; - obj_ini.ship_wep[index,3]="Thunderhawk Launch Bays"; - obj_ini.ship_wep_facing[index,3]="special"; - obj_ini.ship_wep_condition[index,3]=""; - obj_ini.ship_wep[index,4]="Torpedo Tubes"; - obj_ini.ship_wep_facing[index,4]="front"; - obj_ini.ship_wep_condition[index,4]=""; - obj_ini.ship_wep[index,5]="Macro Bombardment Cannons"; - obj_ini.ship_wep_facing[index,5]="most"; - obj_ini.ship_wep_condition[index,5]=""; - obj_ini.ship_capacity[index]=600; - obj_ini.ship_carrying[index]=0; - obj_ini.ship_contents[index]=""; - obj_ini.ship_turrets[index]=3; + + if (new_name != "") { + for (var k = 0; k <= 200; k++) { + new_name = global.name_generator.generate_imperial_ship_name(); + if (!array_contains(_ship_names, new_name)) { break }; + } } - if (string_count("Strike Cruiser",type)>0){ - obj_ini.ship_class[index]="Strike Cruiser"; - obj_ini.ship_size[index]=2; - obj_ini.ship_hp[index]=600; - obj_ini.ship_maxhp[index]=600; - obj_ini.ship_conditions[index]=""; - obj_ini.ship_speed[index]=25; - obj_ini.ship_turning[index]=90; - obj_ini.ship_front_armour[index]=6; - obj_ini.ship_other_armour[index]=6; - obj_ini.ship_weapons[index]=4; - obj_ini.ship_shields[index]=6; - obj_ini.ship_wep[index,1]="Weapons Battery"; - obj_ini.ship_wep_facing[index,1]="left"; - obj_ini.ship_wep_condition[index,1]=""; - obj_ini.ship_wep[index,2]="Weapons Battery"; - obj_ini.ship_wep_facing[index,2]="right"; - obj_ini.ship_wep_condition[index,2]=""; - obj_ini.ship_wep[index,3]="Thunderhawk Launch Bays"; - obj_ini.ship_wep_facing[index,3]="special"; - obj_ini.ship_wep_condition[index,3]=""; - obj_ini.ship_wep[index,4]="Bombardment Cannons"; - obj_ini.ship_wep_facing[index,4]="most"; - obj_ini.ship_wep_condition[index,4]=""; - obj_ini.ship_capacity[index]=250; - obj_ini.ship_carrying[index]=0; - obj_ini.ship_contents[index]=""; - obj_ini.ship_turrets[index]=1; + + if (start_loc == "home") { start_loc = obj_ini.home_name; } + _ship.name = new_name; + _ship.location = start_loc; + if (string_count("Battle Barge", type) > 0){ + _ship.class = "Battle Barge"; + _ship.size = 3; + _ship.health.maxhp = 1200; + _ship.health.hp = _ship.health.maxhp; + _ship.health.shields = 12; + _ship.speed = 20; + _ship.turning = 45; + _ship.armor.front = 6; + _ship.armor.other = 6; + + _ship.weapons.count = 5; + _ship.weapons.name = [ + "", + "Weapons Battery", + "Weapons Battery", + "Thunderhawk Launch Bays", + "Torpedo Tubes", + "Macro Bombardment Cannons" + ]; + + _ship.weapons.facing = [ + "", + "left", + "right", + "special", + "front", + "most" + ]; + _ship.weapons.turrets = 3; + + _ship.cargo.capacity = 600; + } + + if (string_count("Strike Cruiser", type) > 0) { + _ship.class = "Strike Cruiser"; + _ship.size = 2; + _ship.health.maxhp = 600; + _ship.health.shields = 6; + _ship.speed = 25; + _ship.turning = 90; + _ship.armor.front = 6; + _ship.armor.other = 6; + + _ship.weapons.count = 4; + _ship.weapons.name = [ + "", + "Weapons Battery", + "Weapons Battery", + "Thunderhawk Launch Bays", + "Bombardment Cannons", + "" + ]; + + _ship.weapons.facing = [ + "", + "left", + "right", + "special", + "most", + "" + ]; + _ship.weapons.turrets = 1; + + _ship.cargo.capacity = 250; } - if (string_count("Gladius",type)>0){ - obj_ini.ship_class[index]="Gladius"; - obj_ini.ship_hp[index]=200; - obj_ini.ship_maxhp[index]=200; - obj_ini.ship_conditions[index]=""; - obj_ini.ship_speed[index]=30; - obj_ini.ship_turning[index]=90; - obj_ini.ship_front_armour[index]=5; - obj_ini.ship_other_armour[index]=5; - obj_ini.ship_weapons[index]=1; - obj_ini.ship_shields[index]=1; - obj_ini.ship_wep[index,1]="Weapons Battery"; - obj_ini.ship_wep_facing[index,1]="most"; - obj_ini.ship_wep_condition[index,1]=""; - obj_ini.ship_capacity[index]=30; - obj_ini.ship_carrying[index]=0; - obj_ini.ship_contents[index]=""; - obj_ini.ship_turrets[index]=1; + + if (string_count("Gladius", type) > 0) { + _ship.class = "Gladius"; + _ship.health.maxhp = 200; + _ship.health.shields = 1; + _ship.speed = 30; + _ship.turning = 90; + _ship.armor.front = 5; + _ship.armor.other = 5; + + _ship.weapons.count = 1; + _ship.weapons.name[1] = "Weapons Battery"; + _ship.weapons.facing[1] = "most"; + _ship.weapons.turrets = 1; + + _ship.cargo.capacity = 30; } - if (string_count("Hunter",type)>0){ - obj_ini.ship_class[index]="Hunter"; - obj_ini.ship_hp[index]=200; - obj_ini.ship_maxhp[index]=200; - obj_ini.ship_conditions[index]=""; - obj_ini.ship_speed[index]=30; - obj_ini.ship_turning[index]=90; - obj_ini.ship_front_armour[index]=5; - obj_ini.ship_other_armour[index]=5; - obj_ini.ship_weapons[index]=2; - obj_ini.ship_shields[index]=1; - obj_ini.ship_wep[index,1]="Torpedoes"; - obj_ini.ship_wep_facing[index,1]="front"; - obj_ini.ship_wep_condition[index,1]=""; - obj_ini.ship_wep[index,2]="Weapons Battery"; - obj_ini.ship_wep_facing[index,2]="most"; - obj_ini.ship_wep_condition[index,2]=""; - obj_ini.ship_capacity[index]=25; - obj_ini.ship_carrying[index]=0; - obj_ini.ship_contents[index]=""; - obj_ini.ship_turrets[index]=1; + + if (string_count("Hunter", type) > 0) { + _ship.class = "Hunter"; + _ship.health.maxhp = 200; + _ship.health.shields = 1; + _ship.speed = 30; + _ship.turning = 90; + _ship.armor.front = 5; + _ship.armor.other = 5; + + _ship.weapons.count = 2; + _ship.weapons.name[1] = "Torpedoes"; + _ship.weapons.facing[1] = "front"; + _ship.weapons.name[2] = "Weapons Battery"; + _ship.weapons.facing[2] = "most"; + _ship.weapons.turrets = 1; + + _ship.cargo.capacity = 25; } - if (string_count("Gloriana",type)>0){ - obj_ini.ship[index]=new_name; - obj_ini.ship_size[index]=3; - - obj_ini.ship_class[index]="Gloriana"; - - obj_ini.ship_hp[index]=2400; - obj_ini.ship_maxhp[index]=2400; - obj_ini.ship_conditions[index]=""; - obj_ini.ship_speed[index]=25; - obj_ini.ship_turning[index]=60; - obj_ini.ship_front_armour[index]=8; - obj_ini.ship_other_armour[index]=8; - obj_ini.ship_weapons[index]=4; - obj_ini.ship_shields[index]=24; - obj_ini.ship_wep[index,1]="Lance Battery"; - obj_ini.ship_wep_facing[index,1]="most"; - obj_ini.ship_wep_condition[index,1]=""; - obj_ini.ship_wep[index,2]="Lance Battery"; - obj_ini.ship_wep_facing[index,2]="most"; - obj_ini.ship_wep_condition[index,2]=""; - obj_ini.ship_wep[index,3]="Lance Battery"; - obj_ini.ship_wep_facing[index,3]="most"; - obj_ini.ship_wep_condition[index,3]=""; - obj_ini.ship_wep[index,4]="Plasma Cannon"; - obj_ini.ship_wep_facing[index,4]="front"; - obj_ini.ship_wep_condition[index,4]=""; - obj_ini.ship_wep[index,5]="Macro Bombardment Cannons"; - obj_ini.ship_wep_facing[index,5]="most"; - obj_ini.ship_wep_condition[index,5]=""; - obj_ini.ship_capacity[index]=800; - obj_ini.ship_carrying[index]=0; - obj_ini.ship_contents[index]=""; - obj_ini.ship_turrets[index]=8; + + if (string_count("Gloriana", type) > 0) { + _ship.class = "Gloriana"; + _ship.size = 3; + _ship.health.maxhp = 2400; + _ship.health.shields = 24; + _ship.speed = 25; + _ship.turning = 60; + _ship.armor.front = 8; + _ship.armor.other = 8; + + _ship.weapons.count = 5; + _ship.weapons.name = [ + "", + "Lance Battery", + "Lance Battery", + "Lance Battery", + "Plasma Cannon", + "Macro Bombardment Cannons", + ]; + + _ship.weapons.facing = [ + "", + "most", + "most", + "most", + "front", + "most" + ]; + _ship.weapons.turrets = 8; + + _ship.cargo.capacity = 800; } - return index; + _ship.health.hp = _ship.health.maxhp; + + struct_set(USHIPROOT, _ship.UUID, _ship); + + return _ship; } -function ship_class_name(index){ - var _ship_name = obj_ini.ship[index]; - var _ship_class = obj_ini.ship_class[index]; - return $"{_ship_class} '{_ship_name}'"; +function ship_class_name(UUID) { + var _ship_struct = fetch_ship(UUID); + + var _ship_name = _ship_struct.name; + var _ship_class = _ship_struct.class; + return $"{_ship_class} '{_ship_name}'"; } -function player_ships_class(index){ - var _escorts = ["Escort", "Hunter", "Gladius"]; - var _capitals = ["Gloriana", "Battle Barge", "Capital"]; - var _frigates = ["Strike Cruiser", "Frigate"]; - var _ship_name_class = obj_ini.ship_class[index]; - if (array_contains(_escorts, _ship_name_class)){ - return "escort"; - } else if (array_contains(_capitals, _ship_name_class)){ - return "capital"; - }else if (array_contains(_frigates, _ship_name_class)){ - return "frigate"; - } - return _ship_name_class; +function player_ships_class(UUID) { + var _escorts = ["Escort", "Hunter", "Gladius"]; + var _capitals = ["Gloriana", "Battle Barge", "Capital"]; + var _frigates = ["Strike Cruiser", "Frigate"]; + var _ship_struct = fetch_ship(UUID); + var _ship_class = _ship_struct.class; + + if (array_contains(_escorts, _ship_class)) { + return "escort"; + } else if (array_contains(_capitals, _ship_class)) { + return "capital"; + } else if (array_contains(_frigates, _ship_class)) { + return "frigate"; + } + + return _ship_class; } -function ship_bombard_score(ship_id){ - var _bomb_score = 0; - static weapon_bomb_scores = { - "Bombardment Cannons" : { - value : 1, - }, - "Macro Bombardment Cannons" : { - value : 2, - }, - "Plasma Cannon" : { - value : 4 - }, - "Torpedo Tubes" : { - value : 1 - } - } - for (var b=0;b0){ - new_ship_button(obj_ini.ship[_ship_index],_ship_index); + for (var s = 0; s < array_length(_ships); s++) { + _ship_struct = fetch_ship(_ships[s]); + if (_ship_struct.cargo.carrying > 0) { + new_ship_button(_ship_struct.name, _ships[s]); } } } diff --git a/scripts/scr_ruins_reward/scr_ruins_reward.gml b/scripts/scr_ruins_reward/scr_ruins_reward.gml index 32d2b01a7d..627ae909b2 100644 --- a/scripts/scr_ruins_reward/scr_ruins_reward.gml +++ b/scripts/scr_ruins_reward/scr_ruins_reward.gml @@ -55,7 +55,7 @@ function scr_ruins_reward(star_system, planet, _ruins) { } else if (loot="artifact"){ if (_chosen_ship>-1){ - var last_artifact = scr_add_artifact("random", "random", 4, planet, _chosen_ship + 500); + var last_artifact = scr_add_artifact("random", "random", 4, fetch_ship(_chosen_ship).name, _chosen_ship); scr_event_log("","Artifact recovered from Ancient Ruins."); var pop = instance_create(0,0,obj_popup); diff --git a/scripts/scr_specialist_training/scr_specialist_training.gml b/scripts/scr_specialist_training/scr_specialist_training.gml index a2263b94a9..07192e73b6 100644 --- a/scripts/scr_specialist_training/scr_specialist_training.gml +++ b/scripts/scr_specialist_training/scr_specialist_training.gml @@ -394,13 +394,15 @@ function techmarine_training(){ // Remove from ship if (obj_controller.faction_status[eFACTION.Mechanicus] != "War") { - if (unit.ship_location>-1){ - var man_size=unit.get_unit_size(); - obj_ini.ship_carrying[unit.ship_location]-=man_size; + if (unit.ship_location != "") { + var man_size = unit.get_unit_size(); + var _ship_struct = fetch_ship(unit.ship_location); + _ship_struct.carrying -= man_size; + array_delete(_ship_struct.cargo.unit_list, array_get_index(_ship_struct.cargo.unit_list, unit.ship_location), 1); } - obj_ini.loc[0][open_slot]="Terra"; - unit.planet_location=4; - unit.ship_location=-1; + obj_ini.loc[0][open_slot] = "Terra"; + unit.planet_location = 4; + unit.ship_location = ""; } unit.update_weapon_one(""); unit.update_weapon_two(""); diff --git a/scripts/scr_start_load/scr_start_load.gml b/scripts/scr_start_load/scr_start_load.gml index 889d251141..c473b7e380 100644 --- a/scripts/scr_start_load/scr_start_load.gml +++ b/scripts/scr_start_load/scr_start_load.gml @@ -1,254 +1,271 @@ +// i feel like there definatly is or should be a generic function for this???? +function load_vehicles(_companies, _equip, fship_struct, size) { + obj_ini.veh_wid[_companies, _equip] = 0; + obj_ini.veh_lid[_companies, _equip] = fship_struct.UUID; + obj_ini.veh_loc[_companies, _equip] = fship_struct.location; + fship_struct.cargo.carrying += size; +} + + function scr_start_load(fleet, load_from_star, load_options) { // fleet: the fleet object // load_from_star: star object // this distributes the marines and vehicles to the correct ships if the chapter is fleet-based or a home-based chapter - var _unit, _comp, _marine, total_vehic_size; - var total_distribute_squads = [[],[],[],[],[],[],[],[]]; + var _unit, _comp, _marine, total_vehic_size; + var total_distribute_squads = [[],[],[],[],[],[],[],[]]; - var escort_load = load_options[0]; - var split_scouts = load_options[1]; - var split_vets = load_options[2]; - var _splintered = scr_has_disadv("Splintered"); - if (_splintered){ - split_vets = 1; - split_scouts = 1; - escort_load = 1; - } - var comp_has_units=[]; - for (_comp=0;_comp<10;_comp++;){ - comp_has_units[_comp]=false - for (_unit=0;_unit<20;_unit++){ - if (obj_ini.name[_comp][_unit] != ""){ - comp_has_units[_comp] = true; - break; - } - } - } + var escort_load = load_options[0]; + var split_scouts = load_options[1]; + var split_vets = load_options[2]; + var _splintered = scr_has_disadv("Splintered"); + if (_splintered){ + split_vets = 1; + split_scouts = 1; + escort_load = 1; + } + var comp_has_units=[]; + for (_comp=0;_comp<10;_comp++;){ + comp_has_units[_comp]=false + for (_unit=0;_unit<20;_unit++){ + if (obj_ini.name[_comp][_unit] != ""){ + comp_has_units[_comp] = true; + break; + } + } + } - if (split_vets){ - var comp_split=0; - for (var squads=0;squads7 || !comp_has_units[comp_split+2]) then comp_split =0; - if (obj_ini.squads[squads].base_company==1){ - array_push(total_distribute_squads[comp_split], squads); - comp_split++; - } - } - } - if (split_scouts){ - var comp_split=0; - for (var squads=0;squads7 || !comp_has_units[comp_split+2]) then comp_split =0; - if (obj_ini.squads[squads].base_company==10){ - array_push(total_distribute_squads[comp_split], squads); - comp_split++; - } - } - } - // i feel like there definatly is or should be a generic function for this???? - var _vehicles = ["Rhino", "Predator", "Land Speeder", "Land Raider", "Whirlwind"] - function load_vehicles(_companies, _equip ,_ship, size){ - obj_ini.veh_wid[_companies, _equip] = 0; - obj_ini.veh_lid[_companies, _equip] = _ship; - obj_ini.veh_loc[_companies, _equip] = obj_ini.ship_location[_ship]; - obj_ini.ship_carrying[_ship] += size; - } + if (split_vets){ + var comp_split=0; + for (var squads=0;squads7 || !comp_has_units[comp_split+2]) then comp_split =0; + if (obj_ini.squads[squads].base_company==1){ + array_push(total_distribute_squads[comp_split], squads); + comp_split++; + } + } + } + if (split_scouts){ + var comp_split=0; + for (var squads=0;squads7 || !comp_has_units[comp_split+2]) then comp_split =0; + if (obj_ini.squads[squads].base_company==10){ + array_push(total_distribute_squads[comp_split], squads); + comp_split++; + } + } + } + var _vehicles = ["Rhino", "Predator", "Land Speeder", "Land Raider", "Whirlwind"] var ship_size, _companies_loaded; - _company_size = 0; var ship = 0; //ship_size = obj_ini.ship_size[ship]; _companies_loaded = 1; - var ship_return = 1; - var ship_has_space =true; + var ship_return = 1; + var ship_has_space =true; + - - //loop through companies. try and load whole company onto single ship else spread company across largest ships with remaining space - var ship_loop_start = 0; - for (_comp = 0; _comp<10;_comp++){ - if ((split_vets == 1 && _comp == 1) || (!comp_has_units[_comp])) then continue; - if (ship_loop_start>=array_length(obj_ini.ship_carrying)){ - ship_loop_start=array_length(obj_ini.ship_carrying); - } - total_vehic_size = 0; - var _company_size = 0; - var company_loader =[];//array of companies marines - var company_vehicle = [];//array of companies vehicles - var ship_fit = true; + //loop through companies. try and load whole company onto single ship else spread company across largest ships with remaining space + var ship_loop_start = 0; + var _ship_UUIDs = struct_get_names(INI_USHIPROOT); + var _ship_count = array_length(_ship_UUIDs); + for (_comp = 0; _comp < 10; _comp++) { + if ((split_vets == 1 && _comp == 1) || (!comp_has_units[_comp])) { continue; } + if (ship_loop_start >= _ship_count) { + ship_loop_start = _ship_count; + } + var _ship_UUID = _ship_UUIDs[ship_loop_start]; + var _ship_struct = fetch_ship(_ship_UUID); + total_vehic_size = 0; + var _company_size = 0; + var company_loader = [];//array of companies marines + var company_vehicle = [];//array of companies vehicles + var ship_fit = true; - for (_unit =0; _unit<(array_length(obj_ini.role[_comp])-1); _unit++){ - _marine = obj_ini.TTRPG[_comp, _unit]; - // check if marine exists - if (_marine.name() != "") { - //calculate marine space - var marine_size = _marine.get_unit_size(); - _company_size += marine_size; - array_push(company_loader, _marine); + for (_unit = 0; _unit < (array_length(obj_ini.role[_comp]) - 1); _unit++) { + _marine = obj_ini.TTRPG[_comp, _unit]; + // check if marine exists + if (_marine.name() != "") { + //calculate marine space + var marine_size = _marine.get_unit_size(); + _company_size += marine_size; + array_push(company_loader, _marine); + } + } + if (_comp > 1) && (_comp < 10) { + var company_squad_dist = total_distribute_squads[_comp - 2]; + for (var squad = 0; squad < array_length(company_squad_dist); squad++) { + for (var squad_member = 0;squad_member < array_length(obj_ini.squads[company_squad_dist[squad]].members); squad_member++) { + var squaddy = obj_ini.squads[company_squad_dist[squad]].members[squad_member]; + _marine = fetch_unit(squaddy); + var marine_size = _marine.get_unit_size(); + _company_size += marine_size; + array_push(company_loader, _marine); + } + } + } - } - } - if (_comp > 1) and (_comp < 10){ - var squaddy; - var company_squad_dist = total_distribute_squads[_comp-2]; - for (var squad=0;squad obj_ini.ship_capacity[ship_loop_start]){ - ship_fit = false; - } - //if entire company won't fit on ship test to see if there is any ship in the fleet the company will fit on; - if (ship_fit == false){ - for (ship_loop = ship_loop_start; ship_loop< array_length(obj_ini.ship_carrying);ship_loop++){ - if (escort_load == 2) and (obj_ini.ship_capacity[ship_loop] < 250){continue} - if ((obj_ini.ship_carrying[ship_loop] + _company_size) <= obj_ini.ship_capacity[ship_loop]){ - //load marines - for (var m = 0; m _ship_struct.cargo.capacity) { + ship_fit = false; + } + //if entire company won't fit on ship test to see if there is any ship in the fleet the company will fit on; + if (ship_fit == false) { + for (var ship_loop = ship_loop_start; ship_loop < _ship_count; ship_loop++) { + _ship_UUID = _ship_UUIDs[ship_loop]; + _ship_struct = fetch_ship(_ship_UUID); + if (escort_load == 2) && (_ship_struct.cargo.capacity < 250) { continue; } + if ((_ship_struct.cargo.carrying + _company_size) <= _ship_struct.cargo.capacity) { + //load marines + for (var m = 0; m < array_length(company_loader); m++) { + company_loader[m].load_marine(_ship_UUID); + } + //load vehicles + for (var m = 0; m < array_length(company_vehicle); m++) { + load_vehicles(company_vehicle[m][0], company_vehicle[m][1], _ship_struct, company_vehicle[m][2]); + } + ship_fit = true; + ship_loop_start = ship_loop + 1; + break; + } + } + if (!ship_fit ) { + for (var ship_loop = 1; ship_loop < ship_loop_start; ship_loop++) { + _ship_UUID = _ship_UUIDs[ship_loop]; + _ship_struct = fetch_ship(_ship_UUID); + if (escort_load == 2) && (_ship_struct.cargo.capacity < 250) { continue; } + if ((_ship_struct.cargo.carrying + _company_size) <= _ship_struct.cargo.capacity) { + //load marines + for (var m = 0; m < array_length(company_loader); m++) { + company_loader[m].load_marine(_ship_UUID); + } + //load vehicles + for (var m = 0; m < array_length(company_vehicle); m++) { + load_vehicles(company_vehicle[m][0], company_vehicle[m][1], _ship_struct, company_vehicle[m][2]); + } + ship_fit = true; + break; + } + } + } + if (!ship_fit) { + //see if all troops can be grouped together + for (var ship_loop = ship_loop_start; ship_loop < _ship_count; ship_loop++) { + _ship_UUID = _ship_UUIDs[ship_loop]; + _ship_struct = fetch_ship(_ship_UUID); + if (escort_load == 2) && (_ship_struct.cargo.capacity < 250) { continue; } + if ((_ship_struct.cargo.carrying + _company_size - total_vehic_size) <= _ship_struct.cargo.capacity) { + //load marines + for (var m = 0; m < array_length(company_loader); m++) { + company_loader[m].load_marine(_ship_UUID); + } + ship_fit = true; + ship_loop_start++; + break; + } + } + if (!ship_fit) { + for (var ship_loop = 1; ship_loop < ship_loop_start; ship_loop++) { + _ship_UUID = _ship_UUIDs[ship_loop]; + _ship_struct = fetch_ship(_ship_UUID); + if (escort_load == 2) && (_ship_struct.cargo.capacity < 250) { continue; } + if ((_ship_struct.cargo.carrying + _company_size - total_vehic_size) <= _ship_struct.cargo.capacity) { + //load marines + for (var m = 0; m < array_length(company_loader); m++) { + company_loader[m].load_marine(_ship_UUID); + } + ship_fit = true; + break; + } + } + } + } + // if there are no ships that will hold the entire company or all the troops loop all ships and jam pac the fuckers in it + if (!ship_fit) { + for (var ship_loop = 1; ship_loop < _ship_count; ship_loop++) { + _ship_UUID = _ship_UUIDs[ship_loop]; + _ship_struct = fetch_ship(_ship_UUID); + if (escort_load == 2) && (_ship_struct.cargo.capacity < 250) { continue; } + if (_ship_struct.cargo.carrying < _ship_struct.cargo.capacity) { + ship_has_space = true; + // new arrays that will contain troops that didn't get loaded + var comp_edit = []; + var veh_edit = []; - } - } - if (!ship_fit ){ - for (ship_loop = 1; ship_loop-1){ - obj_ini.artifact_loc[unload] = obj_ini.ship[valid_ship]; - obj_ini.artifact_sid[unload] = 500+valid_ship; - } - } - if (cur_arti.identified()>0){ - var _identifiable = cur_arti.is_identifiable() + for (var i = 0; i < array_length(obj_ini.artifact); i++) { + unload = i; + if (obj_ini.artifact[unload] == "") { continue; } + cur_arti = obj_ini.artifact_struct[unload]; + if (cur_arti.loc() == "") { + var valid_ship = get_valid_player_ship(); + if (valid_ship != "") { + cur_arti.set_ship_id(valid_ship); + } + } + if (cur_arti.identified() > 0) { + _identifiable = cur_arti.is_identifiable(); - if (instance_exists(obj_p_fleet)) and (!_identifiable){ - var _arti_fleet = find_ships_fleet(cur_arti.ship_id()); - if (_arti_fleet!="none"){ - if (array_length(_arti_fleet.capital_num)){ - _identifiable = true; - cur_arti.set_ship_id(_arti_fleet.capital_num[0]); - } - } - } - - if (_identifiable) then obj_ini.artifact_identified[unload]-=1; - if (obj_ini.artifact_identified[unload]=0) then scr_alert("green","artifact","Artifact ("+string(obj_ini.artifact[unload])+") has been identified.",0,0); - } - _identifiable=false; - } + if (instance_exists(obj_p_fleet) && !_identifiable) { + var _arti_fleet = find_ships_fleet(cur_arti.ship_id()); + if (_arti_fleet != "none") { + if (_arti_fleet.capital_number) { + _identifiable = true; + var _capital_UUIDs = struct_get_names(_arti_fleet.capital); + cur_arti.set_ship_id(capital_UUIDs[0]); + } + } + } + + if (_identifiable) { obj_ini.artifact_identified[unload] -= 1; } + if (obj_ini.artifact_identified[unload] == 0) { scr_alert("green", "artifact", $"Artifact {obj_ini.artifact[unload]} has been identified.", 0, 0); } + } + _identifiable = false; + } unload=0; diff --git a/scripts/scr_ui_manage/scr_ui_manage.gml b/scripts/scr_ui_manage/scr_ui_manage.gml index 018dcc61dc..9cf9b0426d 100644 --- a/scripts/scr_ui_manage/scr_ui_manage.gml +++ b/scripts/scr_ui_manage/scr_ui_manage.gml @@ -2,9 +2,9 @@ function load_marines_into_ship(system, ship, units, reload = false) { static _load_into_ship = function(system, ship, units, size, loop, reload) { var load_from_star = star_by_name(system); if (is_struct(units[loop])) { - units[loop].load_marine(sh_ide[ship], load_from_star); + units[loop].load_marine(sh_uuid[ship], load_from_star); ma_loc[loop] = sh_loc[ship]; - ma_lid[loop] = sh_ide[ship]; + ma_lid[loop] = sh_uuid[ship]; ma_wid[loop] = 0; } else if (is_array(units[loop]) && ma_loc[loop] == system && sh_loc[ship] == system) { var vehicle = units[loop]; @@ -13,18 +13,19 @@ function load_marines_into_ship(system, ship, units, reload = false) { var start_ship = _get(obj_ini.veh_lid, vehicle); var start_planet = _get(obj_ini.veh_wid, vehicle); ma_loc[loop] = sh_loc[ship]; - ma_lid[loop] = sh_ide[ship]; + ma_lid[loop] = sh_uuid[ship]; ma_wid[loop] = 0; _set(obj_ini.veh_loc, vehicle, sh_name[ship]); - _set(obj_ini.veh_lid, vehicle, sh_ide[ship]); + _set(obj_ini.veh_lid, vehicle, sh_uuid[ship]); _set(obj_ini.veh_wid, vehicle, 0); - _set(obj_ini.veh_uid, vehicle, sh_uid[ship]); - obj_ini.ship_carrying[sh_ide[ship]] += size; + var _ship_struct = fetch_ship(sh_uuid[ship]); + _ship_struct.cargo.carrying += size; if (start_planet) { load_from_star.p_player[start_planet] -= size; } else if (start_ship) { - obj_ini.ship_carrying[start_ship] -= size; + var _start_ship_struct = fetch_ship(start_ship); + _start_ship_struct.cargo.carrying -= size; } set_vehicle_last_ship(vehicle, true); @@ -37,13 +38,13 @@ function load_marines_into_ship(system, ship, units, reload = false) { var _unit = units[q]; var _is_marine = !is_array(_unit); if (!reload) { - _unit_ship_id = ship; + _unit_ship_uuid = ship; } else { if (_is_marine) { - _unit_ship_id = array_get_index(sh_uid, _unit.last_ship.uid); + _unit_ship_uuid = array_get_index(sh_uuid, _unit.last_ship); } else { var last_ship_data = fetch_deep_array(obj_ini.last_ship, _unit); - _unit_ship_id = array_get_index(sh_uid, last_ship_data.uid); + _unit_ship_uuid = array_get_index(sh_uuid, last_ship_data); } } @@ -54,20 +55,17 @@ function load_marines_into_ship(system, ship, units, reload = false) { var _unit_size = _vehic_size; } - if (_unit_ship_id == -1) { - if (reload){ - if (_is_marine){ - _unit.last_ship = { - uid: "", - name: "" - }; + if (_unit_ship_id == "") { + if (reload) { + if (_is_marine) { + _unit.last_ship = ""; } else { set_vehicle_last_ship(_unit, true) } } continue; } - if (_unit_ship_id 0 && selecting_ship > -1; + var moveship_possible = !array_contains(invalid_locations, selecting_location) && man_size > 0 && selecting_ship != ""; if (moveship_possible) { button.alpha = 1; if (button.draw()) { diff --git a/scripts/scr_ui_refresh/scr_ui_refresh.gml b/scripts/scr_ui_refresh/scr_ui_refresh.gml index e1338acf45..fbb2851fbd 100644 --- a/scripts/scr_ui_refresh/scr_ui_refresh.gml +++ b/scripts/scr_ui_refresh/scr_ui_refresh.gml @@ -4,7 +4,7 @@ function scr_ui_refresh() { man_size = 0; selecting_location = ""; selecting_types = ""; - selecting_ship = -1; + selecting_ship = ""; sel_uid = 0; reset_manage_arrays(); @@ -13,4 +13,4 @@ function scr_ui_refresh() { sel_loading = -1; unload = 0; alarm[6] = 7; -} \ No newline at end of file +} 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 c8229ff8a5..2d08932908 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 @@ -14,15 +14,17 @@ function UnitQuickFindPanel() constructor{ view_area = "fleets"; static update_garrison_log = function(){ - try{ - for (var i = 0;i-1){ - obj_ini.ship_carrying[unit.ship_location]+=unit.get_unit_size(); - } + } else if (unit_location[0] == location_types.ship) { + if (unit.ship_location != "") { + var _ship_struct = fetch_ship(unit.ship_location); + _ship_struct.cargo.carrying[unit.ship_location] += unit.get_unit_size(); + } } } try{ @@ -74,9 +77,10 @@ function UnitQuickFindPanel() constructor{ array_push(garrison_log[$ unit_location].units, unit); garrison_log[$ unit_location].vehicles++; } - } else if (obj_ini.veh_lid[co][u]>-1){ - obj_ini.ship_carrying[obj_ini.veh_lid[co][u]]+=scr_unit_size("",obj_ini.veh_role[co][u],true); - } + } else if (obj_ini.veh_lid[co][u] >- 1) { + var _ship_struct = fetch_ship(obj_ini.veh_lid[co][u]); + _ship_struct.cargo.carrying += scr_unit_size("", obj_ini.veh_role[co][u], true); + } } }catch(_exception){ handle_exception(_exception); @@ -533,7 +537,7 @@ function toggle_selection_borders(){ if (is_struct(display_unit[p])){ var unit=display_unit[p]; var mar_id = unit.marine_number; - if (unit.ship_location>-1) and (obj_ini.loc[unit.company][mar_id]!="Mechanicus Vessel"){ + if (unit.ship_location != "") && (obj_ini.loc[unit.company][mar_id] != "Mechanicus Vessel") { unit.is_boarder = !unit.is_boarder; } } @@ -703,8 +707,8 @@ function load_selection(){ function unload_selection(){ //show_debug_message("{0},{1},{2}",obj_controller.selecting_ship,man_size,selecting_location); - if (man_size>0) and (obj_controller.selecting_ship>=0) and (!instance_exists(obj_star_select)) - and (selecting_location!="Terra" && selecting_location!="Mechanicus Vessel" && selecting_location!="Warp" && selecting_location!="Lost") { + if (man_size > 0) && (obj_controller.selecting_ship != "") && (!instance_exists(obj_star_select)) + && (selecting_location != "Terra" && selecting_location != "Mechanicus Vessel" && selecting_location != "Warp" && selecting_location != "Lost") { cooldown=8000; var boba=0; var unload_star = star_by_name(selecting_location); @@ -726,7 +730,8 @@ function unload_selection(){ boba.loading_name=selecting_location; boba.depth=self.depth-50; // sel_uid=obj_ini.ship_uid[selecting_ship]; - scr_company_load(obj_ini.ship_location[selecting_ship]); + var _ship_struct = fetch_ship(selecting_ship); + scr_company_load(_ship_struct.location); } } } diff --git a/scripts/scr_uuid_generate/scr_uuid_generate.yy b/scripts/scr_uuid_generate/scr_uuid_generate.yy index 0debde1deb..f546dcbf89 100644 --- a/scripts/scr_uuid_generate/scr_uuid_generate.yy +++ b/scripts/scr_uuid_generate/scr_uuid_generate.yy @@ -5,8 +5,8 @@ "isDnD":false, "name":"scr_uuid_generate", "parent":{ - "name":"Scripts", - "path":"folders/Scripts.yy" + "name":"UUID Suite", + "path":"folders/Scripts/UUID Suite.yy" }, "resourceType":"GMScript", "resourceVersion":"2.0" diff --git a/scripts/scr_uuid_management/scr_uuid_management.gml b/scripts/scr_uuid_management/scr_uuid_management.gml new file mode 100644 index 0000000000..d9528d54b6 --- /dev/null +++ b/scripts/scr_uuid_management/scr_uuid_management.gml @@ -0,0 +1,11 @@ +// Mult line macros basically +function scr_uuid_delete_unit(fUUID) { + gml_pragma("forceinline"); + struct_remove(UUNITROOT, fUUID); +} + +function scr_uuid_delete_ship(fUUID) { + gml_pragma("forceinline"); + struct_remove(USHIPROOT, fUUID); +} +// diff --git a/scripts/scr_uuid_management/scr_uuid_management.yy b/scripts/scr_uuid_management/scr_uuid_management.yy new file mode 100644 index 0000000000..8c0c0d94fb --- /dev/null +++ b/scripts/scr_uuid_management/scr_uuid_management.yy @@ -0,0 +1,13 @@ +{ + "$GMScript":"v1", + "%Name":"scr_uuid_management", + "isCompatibility":false, + "isDnD":false, + "name":"scr_uuid_management", + "parent":{ + "name":"UUID Suite", + "path":"folders/Scripts/UUID Suite.yy" + }, + "resourceType":"GMScript", + "resourceVersion":"2.0" +}