diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index c0609e0aee..94ee4c34c1 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -118,7 +118,6 @@ {"$GMIncludedFile":"","%Name":"psychic_disciplines.json","CopyToMask":-1,"filePath":"datafiles/data","name":"psychic_disciplines.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"psychic_powers.json","CopyToMask":-1,"filePath":"datafiles/data","name":"psychic_powers.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"traits.json","CopyToMask":-1,"filePath":"datafiles/data","name":"traits.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, - {"$GMIncludedFile":"","%Name":"custom_icons_help.txt","CopyToMask":153157610357391598,"filePath":"datafiles/icons","name":"custom_icons_help.txt","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"1.png","CopyToMask":-1,"filePath":"datafiles/images/advisor/splash","name":"1.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"11.png","CopyToMask":-1,"filePath":"datafiles/images/advisor/splash","name":"11.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"12.png","CopyToMask":-1,"filePath":"datafiles/images/advisor/splash","name":"12.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, @@ -436,7 +435,6 @@ {"$GMIncludedFile":"","%Name":"resources.png","CopyToMask":-1,"filePath":"datafiles/images/ui","name":"resources.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"load_sets.json","CopyToMask":-1,"filePath":"datafiles/main/chapter_symbols","name":"load_sets.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"pauldron.png","CopyToMask":-1,"filePath":"datafiles/main/chapter_symbols/ultramarines","name":"pauldron.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, - {"$GMIncludedFile":"","%Name":"pauldron.png","CopyToMask":-1,"filePath":"datafiles/main/chapter_symbols/Ultramarines","name":"pauldron.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"1.JSON","CopyToMask":-1,"filePath":"datafiles/main/chapters","name":"1.JSON","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"10.JSON","CopyToMask":-1,"filePath":"datafiles/main/chapters","name":"10.JSON","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"11.JSON","CopyToMask":-1,"filePath":"datafiles/main/chapters","name":"11.JSON","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, diff --git a/datafiles/README.md b/datafiles/README.md index 57662084b4..3fdff39556 100644 --- a/datafiles/README.md +++ b/datafiles/README.md @@ -2,27 +2,13 @@ ## How can I add new custom chapter icons? -Add them to the icons folder in the root of your game (ChapterMaster/icons/your_image.png). - Custom icons must be .png and 141x141 pixels or greater in size. -Note that MS Paint can save as .png files, but for some reason the encoding does not work. You will have to use a different image editing program to save/create .png files for Chapter Master. +Note that MS Paint can save as .png files, but for some reason the encoding does not work. You will have to use a different image editing program to save/create .png files. Non-square icons will be smooshed as needed when they are displayed. -Follow the name formatting shown below: - -custom1.png -custom2.png -custom3.png -custom4.png -custom5.png -custom6.png -custom7.png -custom8.png -custom9.png -custom10.png -custom11.png -etc. +Add them to the folder shown bellow, following the example name format: +`C:\Users\\AppData\Local\ChapterMaster\Custom Files\Custom Icons\custom*.png` (replace * with a number from 1 to 99) ## Where are the save files stored? diff --git a/datafiles/data/psychic_disciplines.json b/datafiles/data/psychic_disciplines.json index c1739b0e4b..99852f67a0 100644 --- a/datafiles/data/psychic_disciplines.json +++ b/datafiles/data/psychic_disciplines.json @@ -176,9 +176,9 @@ "name": "Telekinesis", "prefix": "TEL", "powers": [ + "assail", "crush", "shockwave", - "wave_of_force", "telekinetic_dome", "spatial_distortion", "vortex_of_doom" diff --git a/datafiles/data/psychic_powers.json b/datafiles/data/psychic_powers.json index 11ecf890d2..670010cbc9 100644 --- a/datafiles/data/psychic_powers.json +++ b/datafiles/data/psychic_powers.json @@ -678,6 +678,22 @@ I see no reason to have these named structs, as their names are not used for any } } }, + "assail": { + "name": "Assail", + "type": "attack", + "range": 6, + "target_type": "enemy_unit", + "max_kills": 3, + "magnitude": 100, + "armour_piercing": 0, + "flavour_text": { + "default": { + "text": [ + "- a boulder of rock raises from the ground and flies towards his foes." + ] + } + } + }, "crush": { "name": "Crush", "type": "attack", diff --git a/datafiles/icons/custom_icons_help.txt b/datafiles/icons/custom_icons_help.txt deleted file mode 100644 index 719d0e554e..0000000000 --- a/datafiles/icons/custom_icons_help.txt +++ /dev/null @@ -1,20 +0,0 @@ - -Custom icons must be .png and 141x141 pixels or greater in size. Note that MS Paint can save as .png files, but for some reason the encoding does not work. You will have to use a different image editing program to save/create .png files for Chapter Master. - -Non-square icons will be smooshed as needed when they are displayed. - -Follow the name formatting shown below: - -custom1.png -custom2.png -custom3.png -custom4.png -custom5.png -custom6.png -custom7.png -custom8.png -custom9.png -custom10.png -custom11.png -... -etc. diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index 65d61984f2..8d01453e58 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -1392,7 +1392,7 @@ spec_train_data = [ name : "Librarian", min_exp : 30, coord_offset : [0, -7], - req : [["psionic", 7, "exmore"]] + req : [["psionic", 1, "exmore"]] }, { name : "Chaplain", diff --git a/objects/obj_controller/Step_0.gml b/objects/obj_controller/Step_0.gml index 3aa2ce26f0..1e3019342e 100644 --- a/objects/obj_controller/Step_0.gml +++ b/objects/obj_controller/Step_0.gml @@ -1,509 +1,856 @@ -// Handles most logic for main menus, audio and checks if cheats are enabled -// TODO refactor will wait untill squads PR (#76) is merged -if (menu == 0 && zoomed == 0 && !instance_exists(obj_ingame_menu)){ - scr_zoom_keys(); -} -if (double_click>=0) then double_click-=1; -if (text_bar>0){ - text_bar+=1; - if (menu==1) and (managing>0) then obj_ini.company_title[managing]=keyboard_string; - if (menu==24) and (formating>0) and (formating>3) then bat_formation[formating]=keyboard_string; -} -if (text_bar>60) then text_bar=1; -if (bar_fix>0){ - bar_fix=-1; - scr_ui_formation_bars(); -} -// TODO change this into a constructor which is in a separated script -if (fest_scheduled==0) and (fest_sid+fest_wid>0) and (menu!=12.1){ - fest_sid=0; - fest_wid=0; - fest_planet=0; - fest_type=""; - fest_cost=0; - fest_lav=0; - fest_locals=0; - fest_feature1=0; - fest_feature2=0; - fest_feature3=0; - fest_display=0; - fest_repeats=0; - fest_honor_co=0; - fest_honor_id=0; - fest_attend=""; -} +try { + // Handles most logic for main menus, audio and checks if cheats are enabled + // TODO refactor will wait untill squads PR (#76) is merged + if (menu == 0 && zoomed == 0 && !instance_exists(obj_ingame_menu)) { + scr_zoom_keys(); + } + if (double_click >= 0) { + double_click -= 1; + } + if (text_bar > 0) { + text_bar += 1; + if ((menu == 1) && (managing > 0)) { + obj_ini.company_title[managing] = keyboard_string; + } + if ((menu == 24) && (formating > 0) && (formating > 3)) { + bat_formation[formating] = keyboard_string; + } + } + if (text_bar > 60) { + text_bar = 1; + } + if (bar_fix > 0) { + bar_fix = -1; + scr_ui_formation_bars(); + } + // TODO change this into a constructor which is in a separated script + if ((fest_scheduled == 0) && (fest_sid + fest_wid > 0) && (menu != 12.1)) { + fest_sid = 0; + fest_wid = 0; + fest_planet = 0; + fest_type = ""; + fest_cost = 0; + fest_lav = 0; + fest_locals = 0; + fest_feature1 = 0; + fest_feature2 = 0; + fest_feature3 = 0; + fest_display = 0; + fest_repeats = 0; + fest_honor_co = 0; + fest_honor_id = 0; + fest_attend = ""; + } -if (menu!=24) and (formating>0) then formating=0; + if ((menu != 24) && (formating > 0)) { + formating = 0; + } -if (instance_exists(obj_formation_bar)) and ((menu!=24) or (formating<=0)){ - with(obj_formation_bar){instance_destroy();} - with(obj_temp8){instance_destroy();} - formating=0; -} -// Sounds -if (sound_in>=0) then sound_in-=1; -if (sound_in==0) and (sound_to!=""){ - audio_stop_all(); - var nope=false; - if (sound_to=="blood"){ - global.sound_playing=audio_play_sound(snd_blood,0,true); - audio_sound_gain(global.sound_playing, 0, 0); - nope=false; - if (obj_controller.master_volume=0) or (obj_controller.music_volume=0) then nope=true; - if (!nope){audio_sound_gain(global.sound_playing,0.2*obj_controller.master_volume*obj_controller.music_volume,2000);} - } - if (sound_to=="royal"){ - global.sound_playing=audio_play_sound(snd_royal,0,true); - audio_sound_gain(global.sound_playing, 0, 0); - nope=false; - if (obj_controller.master_volume=0) or (obj_controller.music_volume=0) then nope=true; - if (!nope){audio_sound_gain(global.sound_playing,0.25*obj_controller.master_volume*obj_controller.music_volume,2000);} + if (instance_exists(obj_formation_bar) && ((menu != 24) || (formating <= 0))) { + with(obj_formation_bar) { + instance_destroy(); + } + with(obj_temp8) { + instance_destroy(); + } + formating = 0; } -} -// Cheat codes -if (cheatcode != ""){ - cheatyface = 1; -} -if (cheatcode == "req" && global.cheat_req == 0){ - global.cheat_req = 1; - obj_controller.tempRequisition = obj_controller.requisition; - obj_controller.requisition = 51234; -} -else if (cheatcode == "req" && global.cheat_req == 1){ - global.cheat_req = 0; - obj_controller.requisition = obj_controller.tempRequisition; -} -if (cheatcode == "seed" && global.cheat_gene == 0){ - global.cheat_gene = 1; - obj_controller.tempGene_seed = obj_controller.gene_seed; - obj_controller.gene_seed = 9999; -} -else if (cheatcode == "seed" && global.cheat_gene == 1){ - global.cheat_gene = 0; - obj_controller.gene_seed = obj_controller.tempGene_seed; -} -if (cheatcode == "dep"){ - global.cheat_disp = 1; - obj_controller.disposition[2] = 100; - obj_controller.disposition[3] = 100; - obj_controller.disposition[4] = 100; - obj_controller.disposition[5] = 100; - obj_controller.disposition[6] = 100; - obj_controller.disposition[7] = 100; - obj_controller.disposition[8] = 100; - obj_controller.disposition[9] = 100; - obj_controller.disposition[10] = 100; -} -if (cheatcode == "debug" && global.cheat_debug == 0){ - global.cheat_debug = 1; -} -else if (cheatcode == "debug" && global.cheat_debug == 1){ - global.cheat_debug = 0; -} -if (cheatcode == "test"){ - diplomacy = 10.5; - scr_dialogue("test"); -} -if (global.cheat_req == 1 && obj_controller.requisition != 51234){ - obj_controller.requisition = 51234; -} -cheatcode = "" -if (menu != 17.5 && instance_exists(obj_event_log)){ - obj_event_log.help = 0; -} -if ((!instance_exists(obj_event_log)) && instance_exists(obj_controller)){ - instance_activate_object(obj_event_log); -} -if (!instance_exists(obj_ingame_menu)){ - play_second += 1; - if (play_second >= 30){ - play_second = 0; - play_time += 1; - window_old = window_data; - window_data = (((((((string(window_get_x()) + "|") + string(window_get_y())) + "|") + string(window_get_width())) + "|") + string(window_get_height())) + "|"); - if (window_get_fullscreen() == 1){ - window_old = "fullscreen"; - window_data = "fullscreen"; - } - if (window_data != "fullscreen" && window_get_fullscreen() == 0){ - if (window_data != window_old){ - ini_open("saves.ini"); - ini_write_string("Settings", "window_data", (((((((string(window_get_x()) + "|") + string(window_get_y())) + "|") + string(window_get_width())) + "|") + string(window_get_height())) + "|")); - ini_close(); + // Sounds + if (sound_in >= 0) { + sound_in -= 1; + } + if ((sound_in == 0) && (sound_to != "")) { + audio_stop_all(); + var nope = false; + if (sound_to == "blood") { + global.sound_playing = audio_play_sound(snd_blood, 0, true); + audio_sound_gain(global.sound_playing, 0, 0); + nope = false; + if ((obj_controller.master_volume == 0) || (obj_controller.music_volume == 0)) { + nope = true; + } + if (!nope) { + audio_sound_gain(global.sound_playing, 0.2 * obj_controller.master_volume * obj_controller.music_volume, 2000); + } + } + if (sound_to == "royal") { + global.sound_playing = audio_play_sound(snd_royal, 0, true); + audio_sound_gain(global.sound_playing, 0, 0); + nope = false; + if ((obj_controller.master_volume == 0) || (obj_controller.music_volume == 0)) { + nope = true; + } + if (!nope) { + audio_sound_gain(global.sound_playing, 0.25 * obj_controller.master_volume * obj_controller.music_volume, 2000); } } } -} -// Nope // Cleans up menu -if (menu!=60) and (instance_exists(obj_temp_build)){ - if (obj_temp_build.isnew==1) then menu=60; - with(obj_shop){instance_destroy();} - with(obj_managment_panel){instance_destroy();} - with(obj_drop_select){instance_destroy();} - with(obj_star_select){instance_destroy();} - with(obj_fleet_select){instance_destroy();} -} -// Return to star selection -if (menu==0) and (instance_exists(obj_temp_build)){ - obj_controller.selecting_planet=obj_temp_build.planet; - // Pass variables to obj_controller.temp[t]=""; here - instance_create(obj_temp_build.x,obj_temp_build.y,obj_star_select); - obj_star_select.loading_name=obj_controller.selected.name; - popup=3; - with(obj_temp_build){instance_destroy();} -} -// REMOVE -if (menu!=60) and (instance_exists(obj_temp_build)){ - with(obj_temp_build){instance_destroy();} -} + // Cheat codes + if (cheatcode != "") { + cheatyface = 1; + } + if (cheatcode == "req" && global.cheat_req == 0) { + global.cheat_req = 1; + obj_controller.tempRequisition = obj_controller.requisition; + obj_controller.requisition = 51234; + } else if (cheatcode == "req" && global.cheat_req == 1) { + global.cheat_req = 0; + obj_controller.requisition = obj_controller.tempRequisition; + } + if (cheatcode == "seed" && global.cheat_gene == 0) { + global.cheat_gene = 1; + obj_controller.tempGene_seed = obj_controller.gene_seed; + obj_controller.gene_seed = 9999; + } else if (cheatcode == "seed" && global.cheat_gene == 1) { + global.cheat_gene = 0; + obj_controller.gene_seed = obj_controller.tempGene_seed; + } + if (cheatcode == "dep") { + global.cheat_disp = 1; + obj_controller.disposition[2] = 100; + obj_controller.disposition[3] = 100; + obj_controller.disposition[4] = 100; + obj_controller.disposition[5] = 100; + obj_controller.disposition[6] = 100; + obj_controller.disposition[7] = 100; + obj_controller.disposition[8] = 100; + obj_controller.disposition[9] = 100; + obj_controller.disposition[10] = 100; + } + if (cheatcode == "debug" && global.cheat_debug == 0) { + global.cheat_debug = 1; + } else if (cheatcode == "debug" && global.cheat_debug == 1) { + global.cheat_debug = 0; + } + if (cheatcode == "test") { + diplomacy = 10.5; + scr_dialogue("test"); + } + if (global.cheat_req == 1 && obj_controller.requisition != 51234) { + obj_controller.requisition = 51234; + } + cheatcode = ""; + if (menu != 17.5 && instance_exists(obj_event_log)) { + obj_event_log.help = 0; + } + if ((!instance_exists(obj_event_log)) && instance_exists(obj_controller)) { + instance_activate_object(obj_event_log); + } + if (!instance_exists(obj_ingame_menu)) { + play_second += 1; + if (play_second >= 30) { + play_second = 0; + play_time += 1; + window_old = window_data; + window_data = ((((((string(window_get_x()) + "|") + string(window_get_y())) + "|") + string(window_get_width())) + "|") + string(window_get_height())) + "|"; + if (window_get_fullscreen() == 1) { + window_old = "fullscreen"; + window_data = "fullscreen"; + } + if (window_data != "fullscreen" && window_get_fullscreen() == 0) { + if (window_data != window_old) { + ini_open("saves.ini"); + ini_write_string("Settings", "window_data", (((((((string(window_get_x()) + "|") + string(window_get_y())) + "|") + string(window_get_width())) + "|") + string(window_get_height())) + "|")); + ini_close(); + } + } + } + } + // Nope // Cleans up menu + if ((menu != 60) && instance_exists(obj_temp_build)) { + if (obj_temp_build.isnew == 1) { + menu = 60; + } + with(obj_shop) { + instance_destroy(); + } + with(obj_managment_panel) { + instance_destroy(); + } + with(obj_drop_select) { + instance_destroy(); + } + with(obj_star_select) { + instance_destroy(); + } + with(obj_fleet_select) { + instance_destroy(); + } + } + // Return to star selection + if ((menu == 0) && instance_exists(obj_temp_build)) { + obj_controller.selecting_planet = obj_temp_build.planet; + // Pass variables to obj_controller.temp[t]=""; here + instance_create(obj_temp_build.x, obj_temp_build.y, obj_star_select); + obj_star_select.loading_name = obj_controller.selected.name; + popup = 3; + with(obj_temp_build) { + instance_destroy(); + } + } + // REMOVE + if ((menu != 60) && instance_exists(obj_temp_build)) { + with(obj_temp_build) { + instance_destroy(); + } + } -if (text_selected!="") and (text_selected!="none") then text_bar+=1; -if (text_bar>60) then text_bar=1; + if ((text_selected != "") && (text_selected != "none")) { + text_bar += 1; + } + if (text_bar > 60) { + text_bar = 1; + } -if (obj_controller.disposition[4]<=20) or (obj_controller.loyalty<=33) and (demanding==0) then demanding=1; -if (obj_controller.disposition[4]>20) and (obj_controller.loyalty>33) and (demanding==1) then demanding=0; + if ((obj_controller.disposition[4] <= 20) || (obj_controller.loyalty <= 33) && (demanding == 0)) { + demanding = 1; + } + if ((obj_controller.disposition[4] > 20) && (obj_controller.loyalty > 33) && (demanding == 1)) { + demanding = 0; + } -main_map_move_keys(); + main_map_move_keys(); -// For testing purposes -if (is_test_map=true) then with(obj_en_fleet){ - if (owner = eFACTION.Imperium){ - capital_number=0; - frigate_number=1; - escort_number=2; + // For testing purposes + if (is_test_map == true) { + with(obj_en_fleet) { + if (owner == eFACTION.Imperium) { + capital_number = 0; + frigate_number = 1; + escort_number = 2; + } + } + } + // Menu selection screens + var freq = 150; + if (l_options > 0) { + l_options += 1; + } + if (l_options > 105) { + l_options = 0; + } + if ((l_options == 0) && (floor(random(freq)) == 3)) { + l_options = 1; + } + if (l_menu > 0) { + l_menu += 1; + } + if (l_menu > 105) { + l_menu = 0; + } + if ((l_menu == 0) && (floor(random(freq)) == 3)) { + l_menu = 1; } -} -// Menu selection screens -var freq=150; -if (l_options>0) then l_options+=1; -if (l_options>105) then l_options=0; -if (l_options==0) and (floor(random(freq))==3) then l_options=1; -if (l_menu>0) then l_menu+=1; -if (l_menu>105) then l_menu=0; -if (l_menu==0) and (floor(random(freq))==3) then l_menu=1; - -if (l_manage>0) then l_manage+=1; -if (l_manage>141) then l_manage=0; -if (l_manage==0) and (floor(random(freq))==3) then l_manage=1; -if (l_settings>0) then l_settings+=1; -if (l_settings>141) then l_settings=0; -if (l_settings==0) and (floor(random(freq))==3) then l_settings=1; - -if (l_apothecarium>0) then l_apothecarium+=1; -if (l_apothecarium>113) then l_apothecarium=0; -if (l_apothecarium==0) and (floor(random(freq))==3) then l_apothecarium=1; -if (l_reclusium>0) then l_reclusium+=1; -if (l_reclusium>113) then l_reclusium=0; -if (l_reclusium==0) and (floor(random(freq))==3) then l_reclusium=1; -if (l_librarium>0) then l_librarium+=1; -if (l_librarium>113) then l_librarium=0; -if (l_librarium==0) and (floor(random(freq))==3) then l_librarium=1; -if (l_armoury>0) then l_armoury+=1; -if (l_armoury>113) then l_armoury=0; -if (l_armoury==0) and (floor(random(freq))==3) then l_armoury=1; -if (l_recruitment>0) then l_recruitment+=1; -if (l_recruitment>113) then l_recruitment=0; -if (l_recruitment==0) and (floor(random(freq))==3) then l_recruitment=1; -if (l_fleet>0) then l_fleet+=1; -if (l_fleet>113) then l_fleet=0; -if (l_fleet==0) and (floor(random(freq))==3) then l_fleet=1; - -if (l_diplomacy>0) then l_diplomacy+=1; -if (l_diplomacy>141) then l_diplomacy=0; -if (l_diplomacy==0) and (floor(random(freq))==3) then l_diplomacy=1; -if (l_log>0) then l_log+=1; -if (l_log>141) then l_log=0; -if (l_log==0) and (floor(random(freq))==3) then l_log=1; -if (l_turn>0) then l_turn+=1; -if (l_turn>141) then l_turn=0; -if (l_turn==0) and (floor(random(freq))==3) then l_turn=1; - -if (new_buttons_hide==1) and (y_slide<43){ - if (y_slide<43) then y_slide+=2; - if (new_buttons_frame<24) then new_buttons_frame+=1; -} -if (new_buttons_hide==0) and (y_slide>0){ - if (y_slide>0) then y_slide-=2; - if (new_buttons_frame>0) then new_buttons_frame-=1; -} -if (new_buttons_hide==1) and (y_slide<43){ - if (y_slide<43) then y_slide+=2; - if (new_buttons_frame<24) then new_buttons_frame+=1; -} -if (new_buttons_hide==0) and (y_slide>0){ - if (y_slide>0) then y_slide-=2; - if (new_buttons_frame>0) then new_buttons_frame-=1; -} -if ((new_buttons_hide+hide_banner>0)) and (new_banner_x<161) then new_banner_x+=(161/11); -if ((new_buttons_hide+hide_banner==0)) and (new_banner_x>0) then new_banner_x-=(161/11); - -if (y_slide<0) then y_slide=0; -if (new_banner_x<0) then new_banner_x=0; -if (y_slide>0) then new_button_highlight=""; -// Checks which menu was clicked -var high=""; -var stop = 0; -// Which menu is highlighted - -if (menu=14) and (!instance_exists(obj_shop)) then instance_create(0,0,obj_shop); -if (menu!=14) and (instance_exists(obj_shop)) then with(obj_shop){instance_destroy();} - -if (instance_exists(obj_ingame_menu)) or (instance_exists(obj_saveload)) then exit; -// Default view -if (menu==1 && (managing>0 || managing<0)){ - if (!view_squad){ - var c=0,fx=""; - var xx, yy, bb=""; - xx=__view_get( e__VW.XView, 0 )+0; - yy=__view_get( e__VW.YView, 0 )+0; - - if (managing<=10) then c=managing; - if (managing>20) then c=managing-10; - - var top,sel,temp1="",temp2="",temp3="",temp4="",temp5="",force_tool=0; - top=man_current; - sel=top; - var unit = ""; - yy+=77; - } - if (is_struct(temp[120])){ - var ach=0,damage_res=1,armour_value=0; - // Checks if the marine is not hidden - var unit = temp[120]; - if (!is_array(last_unit)){ - last_unit=[0,0]; - } - if (unit.base_group != "none") && (last_unit[1]!=unit.marine_number || last_unit[0]!=unit.company){ - last_unit=[unit.company,unit.marine_number] - marine_armour[0]=unit.armour(); - fix_right=0; - equip_data = unit.unit_equipment_data(); - temp[100]="1"; - if (unit.race()!=1) then temp[100]=unit.race(); - - damage_res = unit.damage_resistance(); - - if (is_struct(equip_data.armour_data)){ - temp[103]=equip_data.armour_data.item_tooltip_desc_gen(); - } else {temp[103]=""} - // Sets up the description for the equipement of current marine - //temp[103]=""; - // Gear - temp[104]=unit.gear(); - if (is_struct(equip_data.gear_data)){ - temp[105]=equip_data.gear_data.item_tooltip_desc_gen(); - } else { - temp[105]=""; - } - //if (string_count("&",temp[104])>0) then temp[104]=clean_tags(temp[104]); - // Mobility Item - temp[106]=unit.mobility_item(); - if (is_struct(equip_data.mobility_data)){ - temp[107]=equip_data.mobility_data.item_tooltip_desc_gen(); - } else { - temp[107]=""; - } - temp[108]=unit.weapon_one(); - if (is_struct(equip_data.weapon_one_data)){ - temp[109]=equip_data.weapon_one_data.item_tooltip_desc_gen(); - } else { - temp[109]=""; + if (l_manage > 0) { + l_manage += 1; + } + if (l_manage > 141) { + l_manage = 0; + } + if ((l_manage == 0) && (floor(random(freq)) == 3)) { + l_manage = 1; + } + if (l_settings > 0) { + l_settings += 1; + } + if (l_settings > 141) { + l_settings = 0; + } + if ((l_settings == 0) && (floor(random(freq)) == 3)) { + l_settings = 1; + } + + if (l_apothecarium > 0) { + l_apothecarium += 1; + } + if (l_apothecarium > 113) { + l_apothecarium = 0; + } + if ((l_apothecarium == 0) && (floor(random(freq)) == 3)) { + l_apothecarium = 1; + } + if (l_reclusium > 0) { + l_reclusium += 1; + } + if (l_reclusium > 113) { + l_reclusium = 0; + } + if ((l_reclusium == 0) && (floor(random(freq)) == 3)) { + l_reclusium = 1; + } + if (l_librarium > 0) { + l_librarium += 1; + } + if (l_librarium > 113) { + l_librarium = 0; + } + if ((l_librarium == 0) && (floor(random(freq)) == 3)) { + l_librarium = 1; + } + if (l_armoury > 0) { + l_armoury += 1; + } + if (l_armoury > 113) { + l_armoury = 0; + } + if ((l_armoury == 0) && (floor(random(freq)) == 3)) { + l_armoury = 1; + } + if (l_recruitment > 0) { + l_recruitment += 1; + } + if (l_recruitment > 113) { + l_recruitment = 0; + } + if ((l_recruitment == 0) && (floor(random(freq)) == 3)) { + l_recruitment = 1; + } + if (l_fleet > 0) { + l_fleet += 1; + } + if (l_fleet > 113) { + l_fleet = 0; + } + if ((l_fleet == 0) && (floor(random(freq)) == 3)) { + l_fleet = 1; + } + + if (l_diplomacy > 0) { + l_diplomacy += 1; + } + if (l_diplomacy > 141) { + l_diplomacy = 0; + } + if ((l_diplomacy == 0) && (floor(random(freq)) == 3)) { + l_diplomacy = 1; + } + if (l_log > 0) { + l_log += 1; + } + if (l_log > 141) { + l_log = 0; + } + if ((l_log == 0) && (floor(random(freq)) == 3)) { + l_log = 1; + } + if (l_turn > 0) { + l_turn += 1; + } + if (l_turn > 141) { + l_turn = 0; + } + if ((l_turn == 0) && (floor(random(freq)) == 3)) { + l_turn = 1; + } + + if ((new_buttons_hide == 1) && (y_slide < 43)) { + if (y_slide < 43) { + y_slide += 2; + } + if (new_buttons_frame < 24) { + new_buttons_frame += 1; + } + } + if ((new_buttons_hide == 0) && (y_slide > 0)) { + if (y_slide > 0) { + y_slide -= 2; + } + if (new_buttons_frame > 0) { + new_buttons_frame -= 1; + } + } + if ((new_buttons_hide == 1) && (y_slide < 43)) { + if (y_slide < 43) { + y_slide += 2; + } + if (new_buttons_frame < 24) { + new_buttons_frame += 1; + } + } + if ((new_buttons_hide == 0) && (y_slide > 0)) { + if (y_slide > 0) { + y_slide -= 2; + } + if (new_buttons_frame > 0) { + new_buttons_frame -= 1; + } + } + + if ((new_buttons_hide + hide_banner > 0) && (new_banner_x < 161)) { + new_banner_x += 161 / 11; + } + if ((new_buttons_hide + hide_banner == 0) && (new_banner_x > 0)) { + new_banner_x -= 161 / 11; + } + + if (y_slide < 0) { + y_slide = 0; + } + if (new_banner_x < 0) { + new_banner_x = 0; + } + if (y_slide > 0) { + new_button_highlight = ""; + } + // Checks which menu was clicked + var high = ""; + var stop = 0; + // Which menu is highlighted + + if ((menu == 14) && (!instance_exists(obj_shop))) { + instance_create(0, 0, obj_shop); + } + if ((menu != 14) && instance_exists(obj_shop)) { + with(obj_shop) { + instance_destroy(); + } + } + + if (instance_exists(obj_ingame_menu) || instance_exists(obj_saveload)) { + exit; + } + // Default view + if (menu == 1 && (managing > 0 || managing < 0)) { + if (!view_squad) { + var c = 0, + fx = ""; + var xx, yy, bb = ""; + xx = __view_get(e__VW.XView, 0) + 0; + yy = __view_get(e__VW.YView, 0) + 0; + + if (managing <= 10) { + c = managing; + } + if (managing > 20) { + c = managing - 10; } - temp[110]=unit.weapon_two(); - if (is_struct(equip_data.weapon_two_data)){ - temp[111]=equip_data.weapon_two_data.item_tooltip_desc_gen(); - } else { - temp[111]=""; - } - //if (string_count("&",temp[106])>0) then temp[106]=clean_tags(temp[106]); - // Experience - temp[113]=string(floor(unit.experience)); - // Psyker things - temp[119] = ""; - temp[123] = ""; - var _psy_powers_known = unit.powers_known; - var _psy_powers_count = array_length(_psy_powers_known); - if (_psy_powers_count > 0){ - var _psy_discipline = unit.psy_discipline(); - var _psy_discipline_name = get_discipline_data(_psy_discipline, "name"); - temp[119]=$"{unit.psionic}/{_psy_powers_count}"; - - var _tooltip = ""; - _tooltip += $"Psychic Rating: {unit.psionic}"; - - var _equipment_psychic_amplification = unit.gear_special_value("psychic_amplification"); - var _character_psychic_amplification = unit.psychic_amplification() * 100; - var _equipment_psychic_focus = unit.gear_special_value("psychic_focus"); - var _character_psychic_focus = unit.psychic_focus(); - var _perils_chance = unit.perils_chance() / 10; - _tooltip += $"\nAmplification from Equipment: {_equipment_psychic_amplification}%"; - _tooltip += $"\nAmplification from Attributes: {_character_psychic_amplification}%"; - - _tooltip += $"\n\nInvocation Failure Chance: {max(PSY_CAST_DIFFICULTY_MIN, PSY_CAST_DIFFICULTY_BASE - _equipment_psychic_focus - _character_psychic_focus)}%"; - _tooltip += $"\nFocus from Equipment: {_equipment_psychic_focus}%"; - _tooltip += $"\nFocus from Attributes: {_character_psychic_focus}%"; - - _tooltip += $"\n\nPerils of the Warp Chance: {_perils_chance}%"; - - _tooltip += $"\n\nMain Discipline: {_psy_discipline_name}"; - _tooltip += $"\nKnown Powers: "; - for (var i = 0; i < _psy_powers_count; i++) { - _tooltip += get_power_data(_psy_powers_known[i], "name"); - if (i < _psy_powers_count - 1) { - _tooltip += ", "; - } - } - temp[123] = _tooltip; + + var top, sel, temp1 = "", + temp2 = "", + temp3 = "", + temp4 = "", + temp5 = "", + force_tool = 0; + top = man_current; + sel = top; + var unit = ""; + yy += 77; + } + if (is_struct(temp[120])) { + var ach = 0, + damage_res = 1, + armour_value = 0; + // Checks if the marine is not hidden + var unit = temp[120]; + if (!is_array(last_unit)) { + last_unit = [0, 0]; } - // Corruption - if (obj_controller.chaos_rating>0) and (temp[119]!="") then temp[119]+="#"+string(max(0,unit.corruption()))+"% Corruption."; - if (obj_controller.chaos_rating>0) and (temp[119]="") then temp[119]=string(max(0,unit.corruption()))+"% Corruption."; - // Melee Attack - temp[116]=unit.melee_attack(); - // Ranged Attack - temp[117]=unit.ranged_attack(); - // Damage Resistance - temp[118] = string(damage_res)+"%"; - if (is_struct(temp[121])){ - try{ - temp[121].destroy_image(); + if ((unit.base_group != "none") && (last_unit[1] != unit.marine_number || last_unit[0] != unit.company)) { + last_unit = [unit.company, unit.marine_number]; + marine_armour[0] = unit.armour(); + fix_right = 0; + equip_data = unit.unit_equipment_data(); + temp[100] = "1"; + if (unit.race() != 1) { + temp[100] = unit.race(); + } + + damage_res = unit.damage_resistance(); + + if (is_struct(equip_data.armour_data)) { + temp[103] = equip_data.armour_data.item_tooltip_desc_gen(); + } else { + temp[103] = ""; + } + // Sets up the description for the equipement of current marine + //temp[103]=""; + // Gear + temp[104] = unit.gear(); + if (is_struct(equip_data.gear_data)) { + temp[105] = equip_data.gear_data.item_tooltip_desc_gen(); + } else { + temp[105] = ""; + } + //if (string_count("&",temp[104])>0) then temp[104]=clean_tags(temp[104]); + // Mobility Item + temp[106] = unit.mobility_item(); + if (is_struct(equip_data.mobility_data)) { + temp[107] = equip_data.mobility_data.item_tooltip_desc_gen(); + } else { + temp[107] = ""; + } + temp[108] = unit.weapon_one(); + if (is_struct(equip_data.weapon_one_data)) { + temp[109] = equip_data.weapon_one_data.item_tooltip_desc_gen(); + } else { + temp[109] = ""; + } + temp[110] = unit.weapon_two(); + if (is_struct(equip_data.weapon_two_data)) { + temp[111] = equip_data.weapon_two_data.item_tooltip_desc_gen(); + } else { + temp[111] = ""; + } + //if (string_count("&",temp[106])>0) then temp[106]=clean_tags(temp[106]); + // Experience + temp[113] = string(floor(unit.experience)); + // Psyker things + temp[119] = ""; + temp[123] = ""; + var _psy_powers_known = unit.powers_known; + var _psy_powers_count = array_length(_psy_powers_known); + if (_psy_powers_count > 0) { + var _psy_discipline = unit.psy_discipline(); + var _psy_discipline_name = get_discipline_data(_psy_discipline, "name"); + temp[119] = $"{unit.psionic}/{_psy_powers_count}"; + + var _tooltip = ""; + _tooltip += $"Psychic Rating: {unit.psionic}"; + + var _equipment_psychic_amplification = unit.gear_special_value("psychic_amplification"); + var _character_psychic_amplification = unit.psychic_amplification() * 100; + var _equipment_psychic_focus = unit.gear_special_value("psychic_focus"); + var _character_psychic_focus = unit.psychic_focus(); + var _perils_chance = unit.perils_chance() / 10; + _tooltip += $"\nAmplification from Equipment: {_equipment_psychic_amplification}%"; + _tooltip += $"\nAmplification from Attributes: {_character_psychic_amplification}%"; + + _tooltip += $"\n\nInvocation Failure Chance: {max(PSY_CAST_DIFFICULTY_MIN, PSY_CAST_DIFFICULTY_BASE - _equipment_psychic_focus - _character_psychic_focus)}%"; + _tooltip += $"\nFocus from Equipment: {_equipment_psychic_focus}%"; + _tooltip += $"\nFocus from Attributes: {_character_psychic_focus}%"; + + _tooltip += $"\n\nPerils of the Warp Chance: {_perils_chance}%"; + + _tooltip += $"\n\nMain Discipline: {_psy_discipline_name}"; + _tooltip += $"\nKnown Powers: "; + for (var i = 0; i < _psy_powers_count; i++) { + _tooltip += get_power_data(_psy_powers_known[i], "name"); + if (i < _psy_powers_count - 1) { + _tooltip += ", "; + } + } + temp[123] = _tooltip; + } + // Corruption + if ((obj_controller.chaos_rating > 0) && (temp[119] != "")) { + temp[119] += "#" + string(max(0, unit.corruption())) + "% Corruption."; + } + if ((obj_controller.chaos_rating > 0) && (temp[119] == "")) { + temp[119] = string(max(0, unit.corruption())) + "% Corruption."; } - delete temp[121]; + // Melee Attack + temp[116] = unit.melee_attack(); + // Ranged Attack + temp[117] = unit.ranged_attack(); + // Damage Resistance + temp[118] = string(damage_res) + "%"; + temp[130] = "Health damage taken by the marine is reduced by this percentage. This happens after the flat reduction from armor.\n\nContributing factors:\n"; + var equipment_types = ["armour", "weapon_one", "weapon_two", "mobility", "gear"]; + for (var i = 0; i < array_length(equipment_types); i++) { + var equipment_type = equipment_types[i]; + var dr = 0; + var name = ""; + switch (equipment_type) { + case "armour": + dr = unit.get_armour_data("damage_resistance_mod"); + name = unit.get_armour_data("name"); + break; + case "weapon_one": + dr = unit.get_weapon_one_data("damage_resistance_mod"); + name = unit.get_weapon_one_data("name"); + break; + case "weapon_two": + dr = unit.get_weapon_two_data("damage_resistance_mod"); + name = unit.get_weapon_two_data("name"); + break; + case "mobility": + dr = unit.get_mobility_data("damage_resistance_mod"); + name = unit.get_mobility_data("name"); + break; + case "gear": + dr = unit.get_gear_data("damage_resistance_mod"); + name = unit.get_gear_data("name"); + break; + } + if (dr != 0) { + temp[130] += $"{name}: {dr}%\n"; + } + } + temp[130] += string("CON: {0}%\nEXP: {1}%", round(unit.constitution / 2), round(unit.experience / 10)); + if (is_struct(temp[121])) { + try { + temp[121].destroy_image(); + } + delete temp[121]; + } + temp[124] = $"{round(unit.hp())}/{round(unit.max_health())}"; // Health Tracker + temp[125] = $"A measure how much punishment the creature can take. Marines can go into the negatives and still survive, but they'll require a bionic to become fighting fit once more.\n\nContributing factors:\nCON: {round(100 * (1 + ((unit.constitution - 40) * 0.025)))}\n"; + for (var i = 0; i < array_length(equipment_types); i++) { + var equipment_type = equipment_types[i]; + var hp_mod = 0; + var name = ""; + switch (equipment_type) { + case "armour": + hp_mod = unit.get_armour_data("hp_mod"); + name = unit.get_armour_data("name"); + break; + case "weapon_one": + hp_mod = unit.get_weapon_one_data("hp_mod"); + name = unit.get_weapon_one_data("name"); + break; + case "weapon_two": + hp_mod = unit.get_weapon_two_data("hp_mod"); + name = unit.get_weapon_two_data("name"); + break; + case "mobility": + hp_mod = unit.get_mobility_data("hp_mod"); + name = unit.get_mobility_data("name"); + break; + case "gear": + hp_mod = unit.get_gear_data("hp_mod"); + name = unit.get_gear_data("name"); + break; + } + if (hp_mod != 0) { + temp[125] += $"{name}: {format_number_with_sign(hp_mod)}%\n"; + } + } + temp[126] = $"{unit.armour_calc()}"; // Armour Rating + temp[127] = "Reduces incoming damage at a flat rate. Certain enemies may attack in ways that may bypass your armor entirely, for example power weapons and some warp sorceries.\n\nContributing factors:\n"; + for (var i = 0; i < array_length(equipment_types); i++) { + var equipment_type = equipment_types[i]; + var ac = 0; + var name = ""; + switch (equipment_type) { + case "armour": + ac = unit.get_armour_data("armour_value"); + name = unit.get_armour_data("name"); + break; + case "weapon_one": + ac = unit.get_weapon_one_data("armour_value"); + name = unit.get_weapon_one_data("name"); + break; + case "weapon_two": + ac = unit.get_weapon_two_data("armour_value"); + name = unit.get_weapon_two_data("name"); + break; + case "mobility": + ac = unit.get_mobility_data("armour_value"); + name = unit.get_mobility_data("name"); + break; + case "gear": + ac = unit.get_gear_data("armour_value"); + name = unit.get_gear_data("name"); + break; + } + if (ac != 0) { + temp[127] += $"{name}: {ac}\n"; + } + } + if (obj_controller.stc_bonus[1] == 5 || obj_controller.stc_bonus[2] == 3) { + temp[127] += $"STC Bonus: x1.05\n"; + } + temp[128] = $"{unit.bionics}"; + var _body_parts = ARR_body_parts; + var _body_parts_display = ARR_body_parts_display; + temp[129] = "Bionic Augmentation is something a unit can do to both enhance their capabilities, but also replace a missing limb to get back into the fight."; + temp[129] += "\nThere is a limit of 10 Bionic augmentations. After that the damage is so extensive that a marine requires a dreadnought to keep going."; + temp[129] += "\nFor everyone else? It's time for the emperor's mercy."; + temp[129] += "\n\nCurrent Bionic Augmentations:\n"; + for (var part = 0; part < array_length(_body_parts); part++) { + if (struct_exists(unit.body[$ _body_parts[part]], "bionic")) { + var part_display = _body_parts_display[part]; + temp[129] += $"Bionic {part_display}"; + switch (part_display) { + case "Left Leg": + case "Right Leg": + temp[129] += $" (CON: +2 STR: +1 DEX: -2)\n"; + break; + case "Left Eye": + case "Right Eye": + temp[129] += $" (CON: +1 WIS: +1 DEX: +1)\n"; + break; + case "Left Arm": + case "Right Arm": + temp[129] += $" (CON: +2 STR: +2 WS: -1)\n"; + break; + case "Torso": + temp[129] += $" (CON: +4 STR: +1 DEX: -1)\n"; + break; + case "Throat": + temp[129] += $" (CHA: -1)\n"; + break; + case "Jaw": + case "Head": + temp[129] += $" (CON: +1)\n"; + break; + } + } + } + temp[121] = unit.draw_unit_image(); + + temp[122] = unit.handle_stat_growth(); + /*if (man[sel]="vehicle"){ + // TODO + }*/ } - temp[121] = unit.draw_unit_image(); + } + } - temp[122] = unit.handle_stat_growth(); - /*if (man[sel]="vehicle"){ - // TODO - }*/ + if (global.load > 0) { + exit; + } + if (menu == 0) { + otha = 0; + } + // Sound controls + if ((cooldown >= 0) && (cooldown < 9000)) { + cooldown -= 1; + } + if (click > 0) { + click = -1; + audio_play_sound(snd_click, -80, 0); + audio_sound_gain(snd_click, 0.25 * master_volume * effect_volume, 0); + } + if (click2 > 0) { + click2 = -1; + audio_play_sound(snd_click_small, -80, 0); + audio_sound_gain(snd_click_small, 0.25 * master_volume * effect_volume, 0); + } + // Return artifact + if (qsfx == 1) { + qsfx = 0; + scr_quest(0, "artifact_return", 4, turn == 1); + } + // Diplomacy options + if (diplomacy == 0) { + trading_artifact = 0; + } + + if ((trading_artifact == 0) && (trading == 0) && (trading_artifact == 0) && (faction_justmet == 1) && (questing == 0) && (trading_demand == 0) && (complex_event == false)) { + for (var h = 1; h <= 4; h++) { + obj_controller.diplo_option[h] = ""; + obj_controller.diplo_goto[h] = ""; } - } -} + } -if (global.load>0) then exit; -if (menu==0) then otha=0; -// Sound controls -if (cooldown>=0) and (cooldown<9000) then cooldown-=1; -if (click>0){ - click=-1; - audio_play_sound(snd_click,-80,0); - audio_sound_gain(snd_click,0.25*master_volume*effect_volume,0); -} -if (click2>0){ - click2=-1; - audio_play_sound(snd_click_small,-80,0); - audio_sound_gain(snd_click_small,0.25*master_volume*effect_volume,0); -} -// Return artifact -if (qsfx==1){ - qsfx=0; - scr_quest(0,"artifact_return",4,turn=1); -} -// Diplomacy options -if (diplomacy==0) then trading_artifact=0; + income = income_base + income_home + income_forge + income_agri + income_training + income_fleet + income_trade + income_tribute; -if (trading_artifact==0) and (trading==0) and (trading_artifact==0) -and (faction_justmet==1) and (questing==0) and (trading_demand==0) and (complex_event==false){ - for(var h=1; h<=4; h++){ - obj_controller.diplo_option[h]=""; - obj_controller.diplo_goto[h]=""; + if ((menu == 20) && ((diplomacy > 0) || ((diplomacy < -5) && (diplomacy > -6)))) { + if (string_length(diplo_txt) < string_length(diplo_text)) { + diplo_char += 2; + diplo_txt = string_copy(diplo_text, 0, diplo_char); + } + if (diplo_alpha < 1) { + diplo_alpha += 0.05; + } } -} + // Check if fleet is minimized or not + if (instance_exists(obj_popup)) { + if (obj_popup.type == 99) { + fleet_minimized = 1; + } + } + // Rrepair ships + if ((menu == 0) && (repair_ships > 0) && (instance_number(obj_turn_end) == 0) && (instance_number(obj_popup) == 0)) { + repair_ships = 0; -income=income_base+income_home+income_forge+income_agri+income_training+income_fleet+income_trade+income_tribute; + var pip = instance_create(0, 0, obj_popup); + pip.title = "Ships Repaired"; + pip.text = "In accordance with the Imperial Repair License, all " + string(obj_ini.chapter_name) + " ships orbiting friendly planets have been repaired. Note that repaired ships, and their fleets, are unable to act further this turn."; + pip.image = "shipyard"; + pip.cooldown = 15; -if (menu==20) and ((diplomacy>0) or ((diplomacy<-5) and (diplomacy>-6))){ - if (string_length(diplo_txt) 0)) { + acted = 2; + } + if ((frigate_health < 100) && (frigate_number > 0)) { + acted = 2; + } + if ((escort_health < 100) && (escort_number > 0)) { + acted = 2; + } + } + for (var i = 1; i < array_length(obj_ini.ship); i++) { + if ((obj_ini.ship_location[i] != "Warp") && (obj_ini.ship_location[i] != "Lost")) { + obj_ini.ship_hp[i] = obj_ini.ship_maxhp[i]; + } + } + // TODO need something here to veryify that the ships are within a friendly star system } - if (diplo_alpha<1) then diplo_alpha+=0.05; -} -// Check if fleet is minimized or not -if (instance_exists(obj_popup)){ - if (obj_popup.type=99) then fleet_minimized=1; -} -// Rrepair ships -if (menu==0) and (repair_ships>0) and (instance_number(obj_turn_end)==0) and (instance_number(obj_popup)==0){ - repair_ships=0; - - var pip=instance_create(0,0,obj_popup); - pip.title="Ships Repaired"; - pip.text="In accordance with the Imperial Repair License, all "+string(obj_ini.chapter_name)+" ships orbiting friendly planets have been repaired. Note that repaired ships, and their fleets, are unable to act further this turn."; - pip.image="shipyard"; - pip.cooldown=15; - - with(obj_p_fleet){ - if (capital_health<100) and (capital_number>0) then acted=2; - if (frigate_health<100) and (frigate_number>0) then acted=2; - if (escort_health<100) and (escort_number>0) then acted=2; - } - for(var i=1; i0){ - cooldown=8; - var b=selecting_ship; - - var unit,company, unit_id; - for(var q=0; q -1 && b0) and (man_size==0) and ((selecting_location!="") or (selecting_types!="") or (selecting_planet!=0) or (selecting_ship!=-1)){ - selecting_location=""; - selecting_types=""; - selecting_planet=0; - selecting_ship=-1; -} + // Unloads units from a ship + if (unload > 0) { + cooldown = 8; + var b = selecting_ship; + + var unit, company, unit_id; + 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; + } + if (unit.name() == "") { + continue; + } + unit_id = unit.marine_number; + company = unit.company; + obj_ini.loc[company][unit_id] = obj_ini.ship_location[b]; + unit.ship_location = -1; + unit.planet_location = unload; + obj_ini.uid[company][unit_id] = 0; -if (marines<=0) and (alarm[7]=-1) and (!instance_exists(obj_fleet_controller)) and (!instance_exists(obj_ncombat)) then alarm[7]=15; + ma_loc[q] = obj_ini.ship_location[b]; + ma_lid[q] = -1; + 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_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_wid[q] = unload; + } + } + selecting_location = ""; + 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; + } + reset_ship_manage_arrays(); + cooldown = 10; + sel_loading = -1; + man_size = 0; + unload = 0; + with(obj_star_select) { + instance_destroy(); + } + } + // Resets selections + if ((managing > 0) && (man_size == 0) && ((selecting_location != "") || (selecting_types != "") || (selecting_planet != 0) || (selecting_ship != -1))) { + selecting_location = ""; + selecting_types = ""; + selecting_planet = 0; + selecting_ship = -1; + } + + if ((marines <= 0) && (alarm[7] == -1) && (!instance_exists(obj_fleet_controller)) && (!instance_exists(obj_ncombat))) { + alarm[7] = 15; + } +} catch (_exception) { + handle_exception(_exception); +} diff --git a/objects/obj_cuicons/Alarm_0.gml b/objects/obj_cuicons/Alarm_0.gml index d7f83d1619..2a2a806da0 100644 --- a/objects/obj_cuicons/Alarm_0.gml +++ b/objects/obj_cuicons/Alarm_0.gml @@ -1,12 +1,12 @@ - - -var i;i=0; -repeat(300){i+=1; - if (spr_custom[i]!=0) and (i!=custom_using) and (sprite_exists(spr_custom_icon[i])){ - if (file_exists(working_directory + "\\icons\\custom"+string(i)+".png")){ - sprite_delete(spr_custom_icon[i]);spr_custom_icon[i]=-1;spr_custom[i]=0; +var i; +i = 0; +repeat (300) { + i += 1; + if ((spr_custom[i] != 0) && (i != custom_using) && sprite_exists(spr_custom_icon[i])) { + if (file_exists($"{PATH_custom_icons}{i}.png")) { + sprite_delete(spr_custom_icon[i]); + spr_custom_icon[i] = -1; + spr_custom[i] = 0; } } } - - diff --git a/objects/obj_cuicons/Alarm_1.gml b/objects/obj_cuicons/Alarm_1.gml index 5f90d91ce8..63c429e01a 100644 --- a/objects/obj_cuicons/Alarm_1.gml +++ b/objects/obj_cuicons/Alarm_1.gml @@ -1,41 +1,56 @@ +global.custom_icons = 0; -global.custom_icons=0; +if (string_count("custom", obj_ini.icon_name) > 0) { + var cusl; + cusl = string_replace(obj_ini.icon_name, "custom", ""); + cusl = real(cusl); + if (cusl > 0) { + custom_using = cusl; + } -if (string_count("custom",obj_ini.icon_name)>0){ - var cusl;cusl=string_replace(obj_ini.icon_name,"custom","");cusl=real(cusl); - if (cusl>0) then custom_using=cusl; - - var i;i=-1; - repeat(300){i+=1; - if (spr_custom[i]!=0) and (sprite_exists(spr_custom_icon[i])){ - if (file_exists(working_directory + "\\icons\\custom"+string(i)+".png")){ - sprite_delete(spr_custom_icon[i]);spr_custom_icon[i]=-1;spr_custom[i]=0; + var i; + i = -1; + repeat (300) { + i += 1; + if ((spr_custom[i] != 0) && sprite_exists(spr_custom_icon[i])) { + if (file_exists($"{PATH_custom_icons}{i}.png")) { + sprite_delete(spr_custom_icon[i]); + spr_custom_icon[i] = -1; + spr_custom[i] = 0; } } } - - global.custom_icons=0; - - if (custom_using>0){ - var i;i=0;spr_custom[0]=0;spr_custom_icon[0]=0; - repeat(300){i+=1;spr_custom[i]=0;spr_custom_icon[i]=-1; - if (file_exists(working_directory + "\\icons\\custom"+string(i)+".png")) and (i=custom_using){ - global.custom_icons+=1;spr_custom[i]=1; - spr_custom_icon[i]=sprite_add(working_directory + "\\icons\\custom"+string(i)+".png",1,0,0,0,0); + + global.custom_icons = 0; + + if (custom_using > 0) { + var i; + i = 0; + spr_custom[0] = 0; + spr_custom_icon[0] = 0; + repeat (300) { + i += 1; + spr_custom[i] = 0; + spr_custom_icon[i] = -1; + if (file_exists($"{PATH_custom_icons}{i}.png") && (i == custom_using)) { + global.custom_icons += 1; + spr_custom[i] = 1; + spr_custom_icon[i] = sprite_add($"{PATH_custom_icons}{i}.png", 1, 0, 0, 0, 0); } } } } -if (string_count("custom",obj_ini.icon_name)=0){ - var i;i=0; - repeat(300){i+=1; - if (spr_custom[i]!=0) and (i!=custom_using) and (sprite_exists(spr_custom_icon[i])){ - if (file_exists(working_directory + "\\icons\\custom"+string(i)+".png")){ - sprite_delete(spr_custom_icon[i]);spr_custom_icon[i]=-1;spr_custom[i]=0; +if (string_count("custom", obj_ini.icon_name) == 0) { + var i; + i = 0; + repeat (300) { + i += 1; + if ((spr_custom[i] != 0) && (i != custom_using) && sprite_exists(spr_custom_icon[i])) { + if (file_exists($"{PATH_custom_icons}{i}.png")) { + sprite_delete(spr_custom_icon[i]); + spr_custom_icon[i] = -1; + spr_custom[i] = 0; } } } } - - - diff --git a/objects/obj_cuicons/Alarm_2.gml b/objects/obj_cuicons/Alarm_2.gml index 9ed285e1ef..d5ee6a73c0 100644 --- a/objects/obj_cuicons/Alarm_2.gml +++ b/objects/obj_cuicons/Alarm_2.gml @@ -1,33 +1,38 @@ - -var i;i=-1; -repeat(300){i+=1; - if (spr_custom[i]!=0) and (sprite_exists(spr_custom_icon[i])){ - if (file_exists(working_directory + "\\icons\\custom"+string(i)+".png")) and (spr_custom[i]>0){ - sprite_delete(spr_custom_icon[i]);spr_custom_icon[i]=-1;spr_custom[i]=0; +var i; +i = -1; +repeat (300) { + i += 1; + if ((spr_custom[i] != 0) && sprite_exists(spr_custom_icon[i])) { + if (file_exists($"{PATH_custom_icons}{i}.png") && (spr_custom[i] > 0)) { + sprite_delete(spr_custom_icon[i]); + spr_custom_icon[i] = -1; + spr_custom[i] = 0; } } } - - -global.custom_icons=0; - -if (custom_using>0) or (room_get_name(room)="Main_Menu"){ - var i;i=0;spr_custom[0]=0;spr_custom_icon[0]=0; - repeat(300){i+=1;spr_custom[i]=0;spr_custom_icon[i]=-1; - if (file_exists(working_directory + "\\icons\\custom"+string(i)+".png")){ - spr_custom_icon[i]=sprite_add(working_directory + "\\icons\\custom"+string(i)+".png",1,false,false,0,0); +global.custom_icons = 0; + +if ((custom_using > 0) || (room_get_name(room) == "Main_Menu")) { + var i; + i = 0; + spr_custom[0] = 0; + spr_custom_icon[0] = 0; + repeat (300) { + i += 1; + spr_custom[i] = 0; + spr_custom_icon[i] = -1; + if (file_exists($"{PATH_custom_icons}{i}.png")) { + spr_custom_icon[i] = sprite_add($"{PATH_custom_icons}{i}.png", 1, false, false, 0, 0); // if (file_exists(working_directory + "\icons\custom"+string(i)+".png")) then show_message("'working_directory + \icons\custom"+string(i)+".png' exists"); - + // var fucking;fucking=spr_custom_icon[i]; // if (sprite_exists(fucking)) then show_message("the pulled sprite_add 'spr_custom_icon["+string(i)+"]' works"); - - global.custom_icons+=1;spr_custom[i]=1; - + + global.custom_icons += 1; + spr_custom[i] = 1; + // show_message("spr_custom_icon["+string(i)+"] has been loaded from 'working_directory + \icons\custom"+string(i)+".png'"); } } } - - - diff --git a/objects/obj_cuicons/Destroy_0.gml b/objects/obj_cuicons/Destroy_0.gml index 9d0f48abdf..8a159afc4f 100644 --- a/objects/obj_cuicons/Destroy_0.gml +++ b/objects/obj_cuicons/Destroy_0.gml @@ -1,14 +1,14 @@ - -global.custom_icons=0; - -var i;i=-1; -repeat(300){i+=1; - if (spr_custom[i]!=0){ - if (file_exists("\\icons\\custom"+string(i)+".png")){ - sprite_delete(spr_custom_icon[i]);spr_custom_icon[i]=0;spr_custom[i]=0; +global.custom_icons = 0; + +var i; +i = -1; +repeat (300) { + i += 1; + if (spr_custom[i] != 0) { + if (file_exists($"{PATH_custom_icons}{i}.png")) { + sprite_delete(spr_custom_icon[i]); + spr_custom_icon[i] = 0; + spr_custom[i] = 0; } } } - - - diff --git a/objects/obj_en_fleet/Alarm_1.gml b/objects/obj_en_fleet/Alarm_1.gml index 3ce2790783..a47a82b93d 100644 --- a/objects/obj_en_fleet/Alarm_1.gml +++ b/objects/obj_en_fleet/Alarm_1.gml @@ -935,7 +935,7 @@ if (action=="" && _is_orbiting){ } -if (action="move") and (action_eta>5000){ +if (action=="move") and (action_eta>5000){ var woop = instance_nearest(x,y,obj_star); if (woop.storm=0){ action_eta-=10000; diff --git a/objects/obj_p_fleet/Alarm_1.gml b/objects/obj_p_fleet/Alarm_1.gml index a3e972f9d4..93336a35aa 100644 --- a/objects/obj_p_fleet/Alarm_1.gml +++ b/objects/obj_p_fleet/Alarm_1.gml @@ -46,8 +46,7 @@ try_and_report_loop("player alarm 1",function(){ action_x=x+lengthdir_x(600,dr); action_y=y+lengthdir_y(600,dr); action="crusade2"; - action_eta=choose(3,4,5); - alarm[4]=1; + set_fleet_movement(false, "crusade2"); } if (action_eta=0) and (action="crusade2"){ with(obj_star){ @@ -64,8 +63,9 @@ try_and_report_loop("player alarm 1",function(){ var ret=instance_nearest(x,y,obj_star); action_x=ret.x; action_y=ret.y; - action="crusade3";action_eta=floor(point_distance(x,y,ret.x,ret.y)/128)+1; - alarm[4]=1;instance_activate_object(obj_star); + action="crusade3"; + set_fleet_movement(false, "crusade3"); + instance_activate_object(obj_star); } if (action_eta=0) and (action="crusade3"){ // Popup here @@ -85,7 +85,13 @@ try_and_report_loop("player alarm 1",function(){ orbiting=steh; // show_message("Present Fleets at alarm[1]: "+string(steh.present_fleets)); - var b;b=0;repeat(4){b+=1;if (steh.p_first[b]<=5) and (steh.dispo[b]>-30) and (steh.dispo[b]<0) then steh.dispo[b]=min(obj_ini.imperium_disposition,obj_controller.disposition[2])+choose(-1,-2,-3,-4,0,1,2,3,4);} + var b=0; + for (var i=1;i<=steh.planets;i++){ + if (steh.p_first[b]<=5) and (steh.dispo[b]>-30) and (steh.dispo[b]<0){ + steh.dispo[b]=min(obj_ini.imperium_disposition,obj_controller.disposition[2])+irandom(8)-4; + } + + } if (steh.p_owner[1]=5) or (steh.p_owner[2]=5) or (steh.p_owner[3]=5) or (steh.p_owner[4]=5){ if (obj_controller.faction_defeated[5]=0) and (obj_controller.known[eFACTION.Ecclesiarchy]=0) then obj_controller.known[eFACTION.Ecclesiarchy]=1; } diff --git a/scripts/__init_external/__init_external.gml b/scripts/__init_external/__init_external.gml index eb381b2ae2..ff4a8c9a63 100644 --- a/scripts/__init_external/__init_external.gml +++ b/scripts/__init_external/__init_external.gml @@ -18,7 +18,11 @@ function __init_external() { if (!directory_exists("Logs")) { directory_create("Logs"); } + if (!directory_exists("Custom Files\\Custom Icons")) { + directory_create("Custom Files\\Custom Icons"); + } + #macro PATH_custom_icons $"Custom Files\\Custom Icons\\custom" #macro PATH_last_messages $"Logs/last_messages.log" var _log_file = file_text_open_write(PATH_last_messages); diff --git a/scripts/exp_and_exp_growth/exp_and_exp_growth.gml b/scripts/exp_and_exp_growth/exp_and_exp_growth.gml index 9acd251b9c..eeb5c17a20 100644 --- a/scripts/exp_and_exp_growth/exp_and_exp_growth.gml +++ b/scripts/exp_and_exp_growth/exp_and_exp_growth.gml @@ -243,7 +243,7 @@ function unit_stat_growth(grow_stat=false){ return undefined; } } else { - show_debug_message($"{total_traited}") + // show_debug_message($"{total_traited}") return stat_gain_chances; } diff --git a/scripts/scr_ComplexSet/scr_ComplexSet.gml b/scripts/scr_ComplexSet/scr_ComplexSet.gml index 1e9df9adcb..38541fa42f 100644 --- a/scripts/scr_ComplexSet/scr_ComplexSet.gml +++ b/scripts/scr_ComplexSet/scr_ComplexSet.gml @@ -413,7 +413,7 @@ function ComplexSet(unit) constructor{ var armour_sampler = shader_get_sampler_index(armour_texture, "armour_texture"); texture_set_stage(armour_sampler, tex_texture); - show_debug_message($"{_tex_data.areas[t]}"); + // show_debug_message($"{_tex_data.areas[t]}"); var _replace_col = shader_get_uniform(armour_texture, "replace_colour"); shader_set_uniform_f_array(_replace_col, _tex_data.areas[t]); draw_sprite(_sprite,choice ?? 0,x_surface_offset,y_surface_offset); diff --git a/scripts/scr_clean/scr_clean.gml b/scripts/scr_clean/scr_clean.gml index efe8271ea5..bc74c94e5c 100644 --- a/scripts/scr_clean/scr_clean.gml +++ b/scripts/scr_clean/scr_clean.gml @@ -3,12 +3,12 @@ /// @param {id.Instance} _target_column - The column instance to clean up /// @returns {undefined} No return value; modifies target column directly function compress_enemy_array(_target_column) { - if (!instance_exists(_target_column)) { - return; - } + if (!instance_exists(_target_column)) { + return; + } - with (_target_column) { - // Define all data arrays to be processed with their default values + with(_target_column) { + // Define all data arrays to be processed with their default values var _data_arrays = [{ arr: dudes, def: "" @@ -32,13 +32,13 @@ function compress_enemy_array(_target_column) { def: 0 }]; - // Track which slots are empty - var _empty_slots = array_create(20, false); - for (var i = 1; i < array_length(_empty_slots); i++) { - if (dudes_num[i] <= 0) { - _empty_slots[i] = true; - } - } + // Track which slots are empty + var _empty_slots = array_create(20, false); + for (var i = 1; i < array_length(_empty_slots); i++) { + if (dudes_num[i] <= 0) { + _empty_slots[i] = true; + } + } // Compress arrays using a pointer that doesn't restart from beginning var pos = 1; @@ -54,22 +54,21 @@ function compress_enemy_array(_target_column) { // Only backtrack if we're not at the beginning if (pos > 1) { - pos--; // Check this position again in case we need to shift more + pos--; // Check this position again in case we need to shift more } } else { - pos++; // Move to next position + pos++; // Move to next position } } - } + } } - /// @function destroy_empty_column /// @description Destroys the column if it's empty /// @param {id.Instance} _target_column - The column instance to clean up function destroy_empty_column(_target_column) { // Destroy empty non-player columns to conserve memory and processing - with (_target_column) { + with(_target_column) { if ((men + veh + medi == 0) && (owner != 1)) { instance_destroy(); } @@ -101,7 +100,6 @@ function check_dead_marines(unit_struct, unit_index) { obj_ncombat.red_thirst = 2; } - if (unit_struct.IsSpecialist("dreadnoughts")) { dreads -= 1; } else { @@ -125,7 +123,7 @@ function scr_clean(target_object, target_is_infantry, hostile_shots, hostile_dam // hostile_splash: The splash damage modifier. Indicates if the weapon affects multiple targets or has an area-of-effect component. try { - with (target_object) { + with(target_object) { if (obj_ncombat.wall_destroyed == 1) { exit; } @@ -136,7 +134,7 @@ function scr_clean(target_object, target_is_infantry, hostile_shots, hostile_dam var unit_type = ""; // ### Vehicle Damage Processing ### - if (!target_is_infantry and veh > 0) { + if (!target_is_infantry && veh > 0) { var you = -1; // Find valid vehicle targets @@ -191,28 +189,24 @@ function scr_clean(target_object, target_is_infantry, hostile_shots, hostile_dam // Flavor messages scr_flavor2(units_lost, unit_type, hostile_range, hostile_weapon, vehicle_hits, hostile_splash); } - - } // ### Marine + Dreadnought Processing ### - if (target_is_infantry and (men + dreads > 0)) { + if (target_is_infantry && (men + dreads > 0)) { man_hits = total_hits - vehicle_hits; // Find valid infantry targets var valid_marines = []; for (var m = 0; m < array_length(unit_struct); m++) { var unit = unit_struct[m]; - if (is_struct(unit) && - unit.hp() > 0 && - marine_dead[m] == 0) { + if (is_struct(unit) && unit.hp() > 0 && marine_dead[m] == 0) { array_push(valid_marines, m); } } // Apply damage for each shot for (var shot = 0; shot < man_hits; shot++) { - if (array_length(valid_marines) == 0){ + if (array_length(valid_marines) == 0) { break; // No valid targets left } @@ -226,31 +220,43 @@ function scr_clean(target_object, target_is_infantry, hostile_shots, hostile_dam // Apply damage var _shot_luck = roll_dice(1, 100, "low"); var _modified_damage = 0; - if (_shot_luck <= 5){ + if (_shot_luck <= 5) { _modified_damage = hostile_damage - (2 * marine_ac[marine_index]); - } else if (_shot_luck > 95){ + } else if (_shot_luck > 95) { _modified_damage = hostile_damage; } else { _modified_damage = hostile_damage - marine_ac[marine_index]; } if (_modified_damage > 0) { - var damage_resistance = (marine.damage_resistance() / 100); - if (marine_mshield[marine_index] > 0) damage_resistance += 0.1; - if (marine_fiery[marine_index] > 0) damage_resistance += 0.15; - if (marine_fshield[marine_index] > 0) damage_resistance += 0.08; - if (marine_quick[marine_index] > 0) damage_resistance += 0.2; // TODO: only if melee - if (marine_dome[marine_index] > 0) damage_resistance += 0.15; + var damage_resistance = marine.damage_resistance() / 100; + if (marine_mshield[marine_index] > 0) { + damage_resistance += 0.1; + } + if (marine_fiery[marine_index] > 0) { + damage_resistance += 0.15; + } + if (marine_fshield[marine_index] > 0) { + damage_resistance += 0.08; + } + if (marine_quick[marine_index] > 0) { + damage_resistance += 0.2; + } // TODO: only if melee + if (marine_dome[marine_index] > 0) { + damage_resistance += 0.15; + } if (marine_iron[marine_index] > 0) { if (damage_resistance <= 0) { marine.add_or_sub_health(20); } else { - damage_resistance += (marine_iron[marine_index] / 5); + damage_resistance += marine_iron[marine_index] / 5; } } _modified_damage = round(_modified_damage * (1 - damage_resistance)); } - if (_modified_damage < 0 && hostile_weapon == "Fleshborer") _modified_damage = 1.5; + if (_modified_damage < 0 && hostile_weapon == "Fleshborer") { + _modified_damage = 1.5; + } /* if (hostile_weapon == "Web Spinner") { var webr = floor(random(100)) + 1; var chunk = max(10, 62 - (marine_ac[marine_index] * 2)); @@ -260,7 +266,7 @@ function scr_clean(target_object, target_is_infantry, hostile_shots, hostile_dam // Check if marine is dead if (check_dead_marines(marine, marine_index)) { - // Remove dead infantry from further hits + // Remove dead infantry from further hits array_delete(valid_marines, marine_index, 1); units_lost++; } @@ -277,7 +283,7 @@ function scr_clean(target_object, target_is_infantry, hostile_shots, hostile_dam instance_deactivate_object(id); } } - } catch(_exception) { + } catch (_exception) { handle_exception(_exception); } } diff --git a/scripts/scr_company_struct/scr_company_struct.gml b/scripts/scr_company_struct/scr_company_struct.gml index 95aeb45323..739ac12d8a 100644 --- a/scripts/scr_company_struct/scr_company_struct.gml +++ b/scripts/scr_company_struct/scr_company_struct.gml @@ -64,14 +64,16 @@ function CompanyStruct(comp) constructor{ x1 : xx+center_width[0], y1 : yy+center_height[0]+6, color:c_red, - label : "<--" + label : "<--", + tooltip : "Press Left arrow to toggle" }); next_squad_button = new UnitButtonObject({ x1 : xx+center_width[1]-44, y1 : yy+center_height[0]+6, color:c_red, - label : "-->" + label : "-->", + tooltip : "Press tab to toggle" }); garrison_button = new UnitButtonObject({ @@ -79,7 +81,7 @@ function CompanyStruct(comp) constructor{ y1 : yy+center_height[0]+150, color:c_red, label : "Garrison Duty", - tooltip : "Having squads assigned to Garrison Duty will increase relations with a planet over time, it will also bolster planet defence forces in case of attack, and reduce corruption growth." + tooltip : "Having squads assigned to Garrison Duty will increase relations with a planet over time, it will also bolster planet defence forces in case of attack, and reduce corruption growth. Press G to toggle" }); sabotage_button = new UnitButtonObject({ @@ -268,7 +270,10 @@ function CompanyStruct(comp) constructor{ send_on_mission=true; mission_type="garrison"; } - + + garrison_button.keystroke = press_exclusive(ord("G")); + previous_squad_button.keystroke = press_exclusive(vk_left); + next_squad_button.keystroke = press_exclusive(vk_tab); if (array_contains(current_squad.class, "scout")) || (array_contains(current_squad.class, "bike")){ if (sabotage_button.draw()){ send_on_mission=true; @@ -286,7 +291,7 @@ function CompanyStruct(comp) constructor{ draw_text_transformed(xx+bound_width[0]+5, yy+bound_height[0]+125, $"Assignment : {cur_assignment.type}",1,1,0); var tooltip_text = "Cancel Assignment" var cancel_but = draw_unit_buttons([xx+bound_width[0]+5, yy+bound_height[0]+150],tooltip_text,[1,1],c_red,,,,true); - if(point_and_click(cancel_but)){ + if(point_and_click(cancel_but) || keyboard_check_pressed(ord("C"))){ var cancel_system=noone; with (obj_star){ if (name == squad_loc.system){ diff --git a/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml b/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml index 6d7e12456d..1ed13d05d8 100644 --- a/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml +++ b/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml @@ -456,7 +456,7 @@ function setup_complex_livery_shader(setup_role, game_setup=false, unit = "none" } else { shader_set_uniform_f_array(shader_get_uniform(full_livery_shader, "robes_colour_replace"), cloth_col); } - show_debug_message(data_set); + // show_debug_message(data_set); var _textures = { } diff --git a/scripts/scr_controller_helpers/scr_controller_helpers.gml b/scripts/scr_controller_helpers/scr_controller_helpers.gml index 6cb100e23b..1aacb9f78b 100644 --- a/scripts/scr_controller_helpers/scr_controller_helpers.gml +++ b/scripts/scr_controller_helpers/scr_controller_helpers.gml @@ -1,508 +1,565 @@ +//TODO make enum to store menu area codes +function scr_menu_clear_up(specific_area_function) { + var spec_func = specific_area_function; + with(obj_controller) { + var menu_action_allowed = action_if_number(obj_saveload, 0, 0) && action_if_number(obj_drop_select, 0, 0) && action_if_number(obj_popup_dialogue, 0, 0) && action_if_number(obj_ncombat, 0, 0); + + if (menu_action_allowed) { + if (combat != 0) { + exit; + } + if (scrollbar_engaged != 0) { + exit; + } + if (instance_exists(obj_ingame_menu)) { + exit; + } + if (instance_exists(obj_turn_end) && (obj_controller.complex_event != true) && (!instance_exists(obj_temp_meeting))) { + if ((obj_turn_end.popups_end == 1) && (audience == 0) && (cooldown <= 0)) { + with(obj_turn_end) { + instance_destroy(); + } + } + } + if (instance_exists(obj_turn_end) && (audience == 0)) { + exit; + } + if (instance_exists(obj_star_select)) { + exit; + } + if (instance_exists(obj_bomb_select)) { + exit; + } + if ((zoomed == 0) && (cooldown <= 0) && (menu >= 500) && (menu <= 510)) { + if (mouse_y >= __view_get(e__VW.YView, 0) + 27) { + cooldown = 8000; + if ((menu >= 500) && (temp[menu - 434] == "")) { + menu = 0; + exit; + } + if ((menu < 503) && (menu != 0)) { + menu += 1; + } + } + } -//TODO make enum to store menu area codes -function scr_menu_clear_up(specific_area_function){ - var spec_func = specific_area_function; - with(obj_controller){ - var menu_action_allowed = (action_if_number(obj_saveload, 0, 0) && - action_if_number(obj_drop_select, 0, 0) && - action_if_number(obj_popup_dialogue, 0, 0) && - action_if_number(obj_ncombat, 0, 0)); - - if (menu_action_allowed){ - if (combat!=0) then exit; - if (scrollbar_engaged!=0) then exit; - if (instance_exists(obj_ingame_menu)) then exit; - - - if (instance_exists(obj_turn_end)) and (obj_controller.complex_event!=true) and (!instance_exists(obj_temp_meeting)){ - if (obj_turn_end.popups_end==1) and (audience==0) and (cooldown<=0) then with(obj_turn_end){instance_destroy();} - } - if (instance_exists(obj_turn_end)) and (audience==0) then exit; - if (instance_exists(obj_star_select)) then exit; - if (instance_exists(obj_bomb_select)) then exit; - - if (zoomed==0) and (cooldown<=0) and (menu>=500) and (menu<=510){ - - if (mouse_y>=__view_get( e__VW.YView, 0 )+27){ - cooldown=8000; - if (menu>=500) and (temp[menu-434]=""){ - menu=0; - exit; - } - if (menu<503) and (menu!=0) then menu+=1; - } - } - - if (menu>=500) then exit; - - var zoomeh=0,diyst=999; - xx=__view_get( e__VW.XView, 0 ); - yy=__view_get( e__VW.YView, 0 ); - zoomeh=zoomed; - - if (menu==0) then hide_banner=0;// 136 ; - - if (instance_exists(obj_temp_build)){ - if (obj_temp_build.isnew==1) then exit; - } - return spec_func(); - } - } - return false; -} + if (menu >= 500) { + exit; + } + var zoomeh = 0, + diyst = 999; + xx = __view_get(e__VW.XView, 0); + yy = __view_get(e__VW.YView, 0); + zoomeh = zoomed; -function scr_change_menu(specific_area_function){ - var continue_sequence = false; - with (obj_controller){ - set_zoom_to_default(); - continue_sequence = scr_menu_clear_up(function(){ - if (zoomed==0) && (diplomacy==0){ - return true; - } - }); - if (continue_sequence){ - with(obj_fleet_select){instance_destroy();} - with(obj_popup){instance_destroy();} - specific_area_function(); - } - } -} + if (menu == 0) { + hide_banner = 0; + } // 136 ; -function scr_in_game_help(){ - scr_change_menu(function(){ - with (obj_controller){ - if (zoomed == 0) and (!instance_exists(obj_ingame_menu)) and (!instance_exists(obj_popup)){ - set_zoom_to_default(); - if (menu!=17.5){ - menu=17.5; - cooldown=8000; - click=1; - hide_banner=0; - instance_activate_object(obj_event_log); - obj_event_log.top=1; - obj_event_log.help=1; - } else { - menu=0; - click=1; - hide_banner=0; - } - managing=0; - view_squad=false; - unit_profile=false; - } - }}); -} -function scr_in_game_menu(){ - scr_change_menu(function(){ - if (!instance_exists(obj_ingame_menu)) and (!instance_exists(obj_popup)) and (!obj_controller.zoomed){ - // Main Menu - with (obj_controller) { - menu=0; - hide_banner=0; - location_viewer.update_garrison_log(); - managing=0; - } - set_zoom_to_default(); - instance_create(0,0,obj_ingame_menu); - } - }); + if (instance_exists(obj_temp_build)) { + if (obj_temp_build.isnew == 1) { + exit; + } + } + return spec_func(); + } + } + return false; } -function basic_manage_settings(){ - menu=1; - popup=0; - selected=0; - hide_banner=1; - diplomacy=0; - zoomed=0; - view_squad=false; - management_buttons = { - squad_toggle : new UnitButtonObject({ - style : "pixel", - label : "Squad View", - tooltip : "Click here or press S to toggle Squad View." - }), - - profile_toggle : new UnitButtonObject({ - style : "pixel", - label : "Show Profile", - tooltip : "Click here or press P to show unit profile." - }), - - bio_toggle : new UnitButtonObject({ - style : "pixel", - label : "Show Bio", - tooltip : "Click here or press B to Toggle Unit Biography." - }), +function scr_change_menu(specific_area_function) { + var continue_sequence = false; + with(obj_controller) { + set_zoom_to_default(); + continue_sequence = scr_menu_clear_up(function() { + if ((zoomed == 0) && (diplomacy == 0)) { + return true; + } + }); + if (continue_sequence) { + with(obj_fleet_select) { + instance_destroy(); + } + with(obj_popup) { + instance_destroy(); + } + specific_area_function(); + } } } -function scr_toggle_manage(){ - scr_change_menu(function(){ - with (obj_controller){ - if (menu!=1){ - basic_manage_settings(); - } - else if (menu==1){ - menu=0; - hide_banner=0; - location_viewer.update_garrison_log(); - } - managing=0; - } - }); + +function scr_in_game_help() { + scr_change_menu(function() { + with(obj_controller) { + if ((zoomed == 0) && (!instance_exists(obj_ingame_menu)) && (!instance_exists(obj_popup))) { + set_zoom_to_default(); + if (menu != 17.5) { + menu = 17.5; + cooldown = 8000; + click = 1; + hide_banner = 0; + instance_activate_object(obj_event_log); + obj_event_log.top = 1; + obj_event_log.help = 1; + } else { + menu = 0; + click = 1; + hide_banner = 0; + } + managing = 0; + view_squad = false; + unit_profile = false; + } + } + }); } -function scr_toggle_setting(){ - scr_change_menu(function(){ - with (obj_controller){ - if (menu!=21){ - menu=21; - popup=0; - selected=0; - hide_banner=1; +function scr_in_game_menu() { + scr_change_menu(function() { + if ((!instance_exists(obj_ingame_menu)) && (!instance_exists(obj_popup)) && (!obj_controller.zoomed)) { + // Main Menu + with(obj_controller) { + menu = 0; + hide_banner = 0; + location_viewer.update_garrison_log(); + managing = 0; + } + set_zoom_to_default(); + instance_create(0, 0, obj_ingame_menu); } - else if (menu==21){ - if (!settings) { - menu=0; - cooldown=8000; - click=1; - hide_banner=0; - } - else if (settings) { - menu=21; - cooldown=8000; - click=1; - settings=0; + }); +} + +function basic_manage_settings() { + menu = 1; + popup = 0; + selected = 0; + hide_banner = 1; + diplomacy = 0; + zoomed = 0; + view_squad = false; + management_buttons = { + squad_toggle: new UnitButtonObject({ + style: "pixel", + label: "Squad View", + tooltip: "Click here or press S to toggle Squad View." + }), + profile_toggle: new UnitButtonObject({ + style: "pixel", + label: "Show Profile", + tooltip: "Click here or press P to show unit profile." + }), + bio_toggle: new UnitButtonObject({ + style: "pixel", + label: "Show Bio", + tooltip: "Click here or press B to Toggle Unit Biography." + }) + }; +} + +function scr_toggle_manage() { + scr_change_menu(function() { + with(obj_controller) { + if (menu != 1) { + basic_manage_settings(); + scr_management(1); + } else if (menu == 1) { + menu = 0; + hide_banner = 0; + location_viewer.update_garrison_log(); } + managing = 0; } - } }); } -function scr_toggle_apothecarion(){ - scr_change_menu(function(){ - with (obj_controller){ - menu_adept=0; - hide_banner=1; - if (scr_role_count("Master of the Apothecarion","0")==0) then menu_adept=1; - if (menu!=11){ - menu=11; - - temp[36]=scr_role_count(obj_ini.role[100][15],""); + +function scr_toggle_setting() { + scr_change_menu(function() { + with(obj_controller) { + if (menu != 21) { + menu = 21; + popup = 0; + selected = 0; + hide_banner = 1; + } else if (menu == 21) { + if (!settings) { + menu = 0; + cooldown = 8000; + click = 1; + hide_banner = 0; + } else if (settings) { + menu = 21; + cooldown = 8000; + click = 1; + settings = 0; + } + } } - else if (menu==11){ - menu=0; - + }); +} + +function scr_toggle_apothecarion() { + scr_change_menu(function() { + with(obj_controller) { + menu_adept = 0; + hide_banner = 1; + if (scr_role_count("Master of the Apothecarion", "0") == 0) { + menu_adept = 1; + } + if (menu != 11) { + menu = 11; + + temp[36] = scr_role_count(obj_ini.role[100][15], ""); + } else if (menu == 11) { + menu = 0; + } + managing = 0; } - managing=0; - } - }); + }); } -function scr_toggle_reclu(){ - scr_change_menu(function(){ - with (obj_controller){ - menu_adept=0; - hide_banner=1; - if (scr_role_count("Master of Sanctity","0")==0) then menu_adept=1; - if (menu!=12){ - menu=12; - - temp[36]=string(scr_role_count(obj_ini.role[100][14],"field")); - temp[37]=string(scr_role_count(obj_ini.role[100][14],"home")); - penitorium=0; - - // Get list of jailed marines - var p=0; - for (var c = 0; c < 11; c++) { - for (var e = 0; e < array_length(obj_ini.god[c]); e++) { - if (obj_ini.god[c][e] == 10){ - p+=1; - penit_co[p]=c; - penit_id[p]=e; - penitorium+=1; +function scr_toggle_reclu() { + scr_change_menu(function() { + with(obj_controller) { + menu_adept = 0; + hide_banner = 1; + if (scr_role_count("Master of Sanctity", "0") == 0) { + menu_adept = 1; + } + if (menu != 12) { + menu = 12; + + temp[36] = string(scr_role_count(obj_ini.role[100][14], "field")); + temp[37] = string(scr_role_count(obj_ini.role[100][14], "home")); + penitorium = 0; + + // Get list of jailed marines + var p = 0; + for (var c = 0; c < 11; c++) { + for (var e = 0; e < array_length(obj_ini.god[c]); e++) { + if (obj_ini.god[c][e] == 10) { + p += 1; + penit_co[p] = c; + penit_id[p] = e; + penitorium += 1; + } } } + } else if (menu == 12) { + menu = 0; + + location_viewer.update_garrison_log(); } + managing = 0; } - else if (menu==12){ - menu=0; - - location_viewer.update_garrison_log(); - } - managing=0; - } - }); + }); } -function scr_toggle_lib(){ - scr_change_menu(function(){ - with (obj_controller){ - menu_adept=0; - hide_banner=1; - if (scr_role_count("Chief "+string(obj_ini.role[100][17]),"0")==0) then menu_adept=1; - if (menu!=13){ - menu=13; - - if (artifacts>0) and (menu_artifact==0) then menu_artifact=1; - temp[36]=scr_role_count(obj_ini.role[100][17],""); - temp[37]=scr_role_count("Codiciery",""); - temp[38]=scr_role_count("Lexicanum",""); - artifact_equip = new ShutterButton(); - artifact_gift = new ShutterButton(); - artifact_destroy = new ShutterButton(); - artifact_namer = new TextBarArea(xx + 622, yy + 460, 350); - set_chapter_arti_data(); - } - else if (menu==13){ - menu=0; - - location_viewer.update_garrison_log(); +function scr_toggle_lib() { + scr_change_menu(function() { + with(obj_controller) { + menu_adept = 0; + hide_banner = 1; + if (scr_role_count("Chief " + string(obj_ini.role[100][17]), "0") == 0) { + menu_adept = 1; + } + if (menu != 13) { + menu = 13; + + if ((artifacts > 0) && (menu_artifact == 0)) { + menu_artifact = 1; + } + temp[36] = scr_role_count(obj_ini.role[100][17], ""); + temp[37] = scr_role_count("Codiciery", ""); + temp[38] = scr_role_count("Lexicanum", ""); + artifact_equip = new ShutterButton(); + artifact_gift = new ShutterButton(); + artifact_destroy = new ShutterButton(); + artifact_namer = new TextBarArea(xx + 622, yy + 460, 350); + set_chapter_arti_data(); + } else if (menu == 13) { + menu = 0; + + location_viewer.update_garrison_log(); + } + managing = 0; } - managing=0; - } - }); + }); } -function scr_toggle_armamentarium(){ - scr_change_menu(function(){ - with (obj_controller){ - menu_adept=0; - hide_banner=1; - if (scr_role_count("Forge Master","0")==0) then menu_adept=1; - if (menu!=14) { - set_up_armentarium(); - }else if (menu==14){ - menu=0; - +function scr_toggle_armamentarium() { + scr_change_menu(function() { + with(obj_controller) { + menu_adept = 0; + hide_banner = 1; + if (scr_role_count("Forge Master", "0") == 0) { + menu_adept = 1; + } + if (menu != 14) { + set_up_armentarium(); + } else if (menu == 14) { + menu = 0; + } + managing = 0; } - managing=0; - } - }); + }); } -function scr_toggle_recruiting(){ - scr_change_menu(function(){ - with (obj_controller){ - var geh=0,good=0; - for(geh=1; geh<=50; geh++){ - geh+=1; - if (good==0){ - if (obj_ini.role[10,geh]==obj_ini.role[100][5]) and (obj_ini.name[10,geh]==obj_ini.recruiter_name) then good=geh; +function scr_toggle_recruiting() { + scr_change_menu(function() { + with(obj_controller) { + var geh = 0, + good = 0; + for (geh = 1; geh <= 50; geh++) { + geh += 1; + if (good == 0) { + if ((obj_ini.role[10, geh] == obj_ini.role[100][5]) && (obj_ini.name[10, geh] == obj_ini.recruiter_name)) { + good = geh; + } + } } - } - menu_adept=0; - hide_banner=1; - - if (menu!=15) { - set_up_recruitment_view(); - } else if (menu==15){ - menu=0; - - location_viewer.update_garrison_log(); - } + menu_adept = 0; + hide_banner = 1; - managing=0; - } - }); -} + if (menu != 15) { + set_up_recruitment_view(); + } else if (menu == 15) { + menu = 0; -function scr_toggle_fleet_area(){ - scr_change_menu(function(){ - with (obj_controller){ - menu_adept=0; - hide_banner=1; - var geh=0,good=0; - for(geh=1; geh<=50; geh++){ - if (good==0){ - if (obj_ini.role[4,geh]=obj_ini.role[100][5]) and (obj_ini.name[10,geh]=obj_ini.lord_admiral_name) then good=geh; - } - } - if (menu!=16){ - //TODO rewrite all this shit when fleets finally become OOP - menu=16; - - cooldown=8000; - click=1; - for (var i=37;i<=41;i++){ - temp[i] = ""; - } - - for(var i=101;i<120;i++){ - temp[i]=""; - } - - var g=0,u=0,m=0,d=0; - temp[37] = 0; - temp[38] = 0; - temp[39] = 0; - for(var i=0; i5){ - var him=instance_nearest(action_x,action_y,obj_star); - if (point_distance(action_x,action_y,him.x,him.y)<10){ - him.present_fleet[20]=1; - } - } - } - - if (instance_exists(obj_p_fleet)){obj_p_fleet.alarm[1]=1;} - if (instance_exists(obj_en_fleet)){obj_en_fleet.alarm[1]=1;} - if (instance_exists(obj_crusade)){obj_crusade.alarm[0]=2;} - - player_forge_data.player_forges=0; - requisition+=income; - scr_income(); - gene_tithe-=1; - - // Do that after the combats and all of that crap - with(obj_star){ - ai_a=2; - ai_b=3; - ai_c=4; - ai_d=5; - ai_e=5; - if (p_type[1]=="Craftworld"){ - instance_deactivate_object(id); - } - } - alarm[5]=6; - instance_create(0,0,obj_turn_end); - scr_turn_first(); - } - } - - if (menu==1){ - menu=0; - cooldown=8000; - click=1; - hide_banner=0; - } - managing=0; - /*with(obj_ini){ - for (var i=0;i<11;i++){ - scr_company_order(i); - } - }*/ - location_viewer.update_garrison_log(); - } - }); +function scr_end_turn() { + scr_change_menu(function() { + with(obj_controller) { + if ((menu == 0) && (cooldown <= 0)) { + if (location_viewer.hide_sequence == 0) { + location_viewer.hide_sequence++; + } + cooldown = 8; + menu = 0; + + if (!instance_exists(obj_turn_end)) { + ok = 1; + } + if (instance_exists(obj_turn_end)) { + if (obj_turn_end.popups_end == 1) { + ok = 1; + } + } + + if (ok == 1) { + obj_controller.end_turn_insights = {}; + with(obj_turn_end) { + instance_destroy(); + } + with(obj_star_event) { + instance_destroy(); + } + cooldown = 8; + audio_play_sound(snd_end_turn, -50, 0); + audio_sound_gain(snd_end_turn, master_volume * effect_volume, 0); + + turn += 1; + with(obj_star) { + for (var i = 0; i <= 21; i++) { + present_fleet[i] = 0; + } + } + with(obj_p_fleet) { + if ((action == "move") && (obj_controller.faction_status[eFACTION.Imperium] == "War")) { + var him = instance_nearest(action_x, action_y, obj_star); + if (point_distance(action_x, action_y, him.x, him.y) < 10) { + him.present_fleet[20] = 1; + } + } + } + with(obj_en_fleet) { + if ((action == "move") && (owner > 5)) { + var him = instance_nearest(action_x, action_y, obj_star); + if (point_distance(action_x, action_y, him.x, him.y) < 10) { + him.present_fleet[20] = 1; + } + } + } + + if (instance_exists(obj_p_fleet)) { + obj_p_fleet.alarm[1] = 1; + } + if (instance_exists(obj_en_fleet)) { + obj_en_fleet.alarm[1] = 1; + } + if (instance_exists(obj_crusade)) { + obj_crusade.alarm[0] = 2; + } + + player_forge_data.player_forges = 0; + requisition += income; + scr_income(); + gene_tithe -= 1; + + // Do that after the combats and all of that crap + with(obj_star) { + ai_a = 2; + ai_b = 3; + ai_c = 4; + ai_d = 5; + ai_e = 5; + if (p_type[1] == "Craftworld") { + instance_deactivate_object(id); + } + } + alarm[5] = 6; + instance_create(0, 0, obj_turn_end); + scr_turn_first(); + } + } + + if (menu == 1) { + menu = 0; + cooldown = 8000; + click = 1; + hide_banner = 0; + } + managing = 0; + /*with(obj_ini){ + for (var i=0;i<11;i++){ + scr_company_order(i); + } + }*/ + location_viewer.update_garrison_log(); + } + }); } diff --git a/scripts/scr_creation_draw_slides/scr_creation_draw_slides.gml b/scripts/scr_creation_draw_slides/scr_creation_draw_slides.gml index cf0689c5f7..07779820f2 100644 --- a/scripts/scr_creation_draw_slides/scr_creation_draw_slides.gml +++ b/scripts/scr_creation_draw_slides/scr_creation_draw_slides.gml @@ -186,7 +186,11 @@ function draw_chapter_select(){ if (chap.icon > global.normal_icons_count) { if (string_starts_with(chap.icon_name, "custom")) { var cuicon = obj_cuicons.spr_custom_icon[chap.icon - normal_and_builtin]; - draw_sprite_stretched(cuicon, 0, grid.x1, grid.y1, grid.w, grid.h); + if (cuicon != -1) { + draw_sprite_stretched(cuicon, 0, grid.x1, grid.y1, grid.w, grid.h); + } else { + draw_sprite_stretched(spr_icon_chapters, 0, grid.x1, grid.y1, grid.w, grid.h); + } } else { draw_sprite_stretched(spr_icon_chapters, chap.icon - global.normal_icons_count, grid.x1, grid.y1, grid.w, grid.h); } diff --git a/scripts/scr_crusade/scr_crusade.gml b/scripts/scr_crusade/scr_crusade.gml index 30d3a74104..56bbad64f3 100644 --- a/scripts/scr_crusade/scr_crusade.gml +++ b/scripts/scr_crusade/scr_crusade.gml @@ -167,23 +167,23 @@ function launch_crusade(){ return false; } else{ - var assigned_crusade = false; - for(var i = 1; i <= star_id.planets;i++){ - assigned_crusade = add_new_problem(i, "great_crusade", 36,star_id); - if (assigned_crusade>0) then break; - } - if(!assigned_crusade){ - log_error("RE: Crusade, couldn't assign a crusade at the system"); + + //TODO decide the target/purpose of the crusade to create more variety and to help with post crusade rewards + var _nearest_player_fleet = get_nearest_player_fleet(star_id.x, star_id.y); + if (_nearest_player_fleet == "none"){ return false; } - else{ - //TODO decide the target/purpose of the crusade to create more variety and to help with post crusade rewards - scr_popup("Crusade","Fellow Astartes legions are preparing to embark on a Crusade to a nearby sector. Your forces are expected at "+string(star_id.name)+"; 36 turns from now your ships there shall begin their journey.","crusade",""); - var star_alert = instance_create(star_id.x+16,star_id.y-24,obj_star_event); - star_alert.image_alpha=1; - star_alert.image_speed=1; - scr_event_log("","A Crusade is called; our forces are expected at "+string(star_id.name)+" in 36 months.", star_id.name); - return true; + var travel_leeway = 10; + if (_nearest_player_fleet.action == "move"){ + travel_leeway += _nearest_player_fleet.eta; } + var _eta = get_viable_travel_time(travel_leeway, _nearest_player_fleet.x, _nearest_player_fleet.y, star_id.x,star_id.y, _nearest_player_fleet,false) + scr_popup("Crusade",$"Fellow Astartes legions are preparing to embark on a Crusade to a nearby sector. Your forces are expected at {star_id.name}; {_eta} months from now your ships there shall begin their journey.","crusade",""); + var star_alert = instance_create(star_id.x+16,star_id.y-24,obj_star_event); + star_alert.image_alpha=1; + star_alert.image_speed=1; + scr_event_log("",$"A Crusade is called; our forces are expected at {star_id.name} in {_eta} months.", star_id.name); + assigned_crusade = add_new_problem(irandom_range(1 ,star_id.planets), "great_crusade", _eta,star_id); + return true; } } 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 6ff6d3a9f9..81e650f325 100644 --- a/scripts/scr_draw_management_unit/scr_draw_management_unit.gml +++ b/scripts/scr_draw_management_unit/scr_draw_management_unit.gml @@ -1,148 +1,155 @@ +function scr_draw_management_unit(selected, yy = 0, xx = 0, draw = true) { + var assignment = "none"; + var unit; + var string_role = ""; + var health_string = ""; + var eventing = false; + var jailed = false; + var impossible = !is_struct(display_unit[selected]) && !is_array(display_unit[selected]); + var is_man = false; + if (man[selected] == "man" && is_struct(display_unit[selected])) { + is_man = true; + unit = display_unit[selected]; + if (unit.name() == "" || unit.base_group == "none") { + return "continue"; + } + var unit_specialist = is_specialist(unit.role()); + var unit_location_string = ""; + if (unit.in_jail()) { + jailed = true; + unit_location_string = "=Penitorium="; + } else { + var unit_location = unit.marine_location(); + string_role = unit.name_role(); + unit_specialism_option = false; + //TODO make static to handle + unit_location_string = string(ma_loc[selected]); + if (unit_location[0] == location_types.planet) { + unit_location_string = unit_location[2]; + //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]]; + } + assignment = unit.assignment(); + if (assignment != "none") { + unit_location_string += $"({assignment})"; + } else if ((fest_planet == 0) && (fest_sid > -1) && (fest_repeats > 0) && (ma_lid[selected] == fest_sid)) { + unit_location_string = "=Event="; + eventing = true; + } else if ((fest_planet == 1) && (fest_wid > 0) && (fest_repeats > 0) && (ma_wid[selected] == fest_wid) && (ma_loc[selected] == fest_star)) { + unit_location_string = "=Event="; + eventing = true; + } + } + if (draw) { + health_string = $"{round((unit.hp() / unit.max_health()) * 100)}% HP"; + + var exp_string = $"{round(ma_exp[selected])} EXP"; + + ma_ar = ""; + ma_we1 = ""; + ma_we2 = ""; + ma_ge = ""; + ma_mb = ""; + ttt = 0; + ar_ar = 0; + ar_we1 = 0; + ar_we2 = 0; + ar_ge = 0; + ar_mb = 0; + //TODO handle recursively -function scr_draw_management_unit(selected, yy=0, xx=0, draw=true){ - var assignment ="none"; - var unit; - var string_role=""; - var health_string=""; - var eventing=false; - jailed = false; - var impossible = (!is_struct(display_unit[selected]) && !is_array(display_unit[selected])); - var is_man=false; - if (man[selected]=="man" && is_struct(display_unit[selected])){ - is_man = true; - unit = display_unit[selected]; - if (unit.name()=="" || unit.base_group=="none"){ - return "continue"; - } - var unit_specialist = is_specialist(unit.role()); - var unit_location_string=""; - if (unit.in_jail()){ - jailed=true; - unit_location_string="=Penitorium="; - } else { - var unit_location = unit.marine_location(); - string_role=unit.name_role(); - unit_specialism_option=false; - //TODO make static to handle - unit_location_string=string(ma_loc[selected]); - if (unit_location[0]==location_types.planet){ - unit_location_string = unit_location[2]; - //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]] - }; - assignment=unit.assignment(); - if (assignment!="none"){ - unit_location_string += $"({assignment})"; - }else if (fest_planet==0) and (fest_sid>-1) and (fest_repeats>0) and (ma_lid[selected]==fest_sid){ - unit_location_string="=Event="; - eventing=true; - }else if (fest_planet==1) and (fest_wid>0) and (fest_repeats>0) and (ma_wid[selected]==fest_wid) and (ma_loc[selected]==fest_star){ - unit_location_string="=Event="; - eventing=true; - } - } - if (draw) { - health_string=$"{round((unit.hp()/unit.max_health())*100)}% HP"; - - var exp_string= $"{round(ma_exp[selected])} EXP"; - - ma_ar="";ma_we1="";ma_we2="";ma_ge="";ma_mb="";ttt=0; - ar_ar=0;ar_we1=0;ar_we2=0;ar_ge=0;ar_mb=0; - //TODO handle recursively - - - if (ma_armour[selected]!=""){ - ma_ar=gear_weapon_data("armour",unit.armour(),"abbreviation"); - ma_ar=is_string(ma_ar) ? ma_ar : ""; + if (ma_armour[selected] != "") { + ma_ar = gear_weapon_data("armour", unit.armour(), "abbreviation"); + ma_ar = is_string(ma_ar) ? ma_ar : ""; } - if (ma_gear[selected]!=""){ - ma_ge=gear_weapon_data("gear",unit.gear(),"abbreviation"); - ma_ge=is_string(ma_ge) ? ma_ge : "" ; + if (ma_gear[selected] != "") { + ma_ge = gear_weapon_data("gear", unit.gear(), "abbreviation"); + ma_ge = is_string(ma_ge) ? ma_ge : ""; } - if (ma_mobi[selected]!=""){ - ma_mb=gear_weapon_data("mobility",unit.mobility_item(),"abbreviation"); - ma_mb=is_string(ma_mb) ? ma_mb : "" ; + if (ma_mobi[selected] != "") { + ma_mb = gear_weapon_data("mobility", unit.mobility_item(), "abbreviation"); + ma_mb = is_string(ma_mb) ? ma_mb : ""; } - if (ma_wep1[selected]!=""){ - ma_we1=gear_weapon_data("weapon",unit.weapon_one(),"abbreviation"); - ma_we1=is_string(ma_we1) ? ma_we1 : ""; + if (ma_wep1[selected] != "") { + ma_we1 = gear_weapon_data("weapon", unit.weapon_one(), "abbreviation"); + ma_we1 = is_string(ma_we1) ? ma_we1 : ""; } - if (ma_wep2[selected]!=""){ - ma_we2=gear_weapon_data("weapon",unit.weapon_two(),"abbreviation"); - ma_we2=is_string(ma_we1) ? ma_we2 : ""; + if (ma_wep2[selected] != "") { + ma_we2 = gear_weapon_data("weapon", unit.weapon_two(), "abbreviation"); + ma_we2 = is_string(ma_we1) ? ma_we2 : ""; } } - }else if (man[selected]=="vehicle" && is_array(display_unit[selected]) && draw){ + } else if (man[selected] == "vehicle" && is_array(display_unit[selected]) && draw) { // string_role="v "+string(managing)+"."+string(ide[selected]); - string_role=string(ma_role[selected]); - unit_location_string=string(ma_loc[selected]); - - 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]] + string_role = string(ma_role[selected]); + unit_location_string = string(ma_loc[selected]); + + 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]]; } - health_string=string(round(ma_health[selected]))+"% HP"; - exp_string=""; + health_string = string(round(ma_health[selected])) + "% HP"; + exp_string = ""; // Need abbreviations here - ma_ar=""; - ma_we1=""; - ma_we2=""; - ma_ge=""; - ma_mb=""; - ttt=0; - ar_ar=0; - ar_we1=0; - ar_we2=0; - ar_ge=0; - ar_mb=0; + ma_ar = ""; + ma_we1 = ""; + ma_we2 = ""; + ma_ge = ""; + ma_mb = ""; + ttt = 0; + ar_ar = 0; + ar_we1 = 0; + ar_we2 = 0; + ar_ge = 0; + ar_mb = 0; //TODO handle recursively - if (ma_armour[selected]!=""){ - ma_ar=gear_weapon_data("weapon",ma_armour[selected],"abbreviation"); - ma_ar=is_string(ma_ar) ? ma_ar : ""; - } - if (ma_gear[selected]!=""){ - ma_ge=gear_weapon_data("armour",ma_gear[selected],"abbreviation"); - ma_ge=is_string(ma_ge) ? ma_ge : "" ; - } - if (ma_mobi[selected]!=""){ - ma_mb=gear_weapon_data("gear",ma_mobi[selected],"abbreviation"); - ma_mb=is_string(ma_mb) ? ma_mb : "" ; + if (ma_armour[selected] != "") { + ma_ar = gear_weapon_data("weapon", ma_armour[selected], "abbreviation"); + ma_ar = is_string(ma_ar) ? ma_ar : ""; + } + if (ma_gear[selected] != "") { + ma_ge = gear_weapon_data("armour", ma_gear[selected], "abbreviation"); + ma_ge = is_string(ma_ge) ? ma_ge : ""; + } + if (ma_mobi[selected] != "") { + ma_mb = gear_weapon_data("gear", ma_mobi[selected], "abbreviation"); + ma_mb = is_string(ma_mb) ? ma_mb : ""; } - if (ma_wep1[selected]!=""){ - ma_we1=gear_weapon_data("weapon",ma_wep1[selected],"abbreviation"); - ma_we1=is_string(ma_we1) ? ma_we1 : ""; - } - if (ma_wep2[selected]!=""){ - ma_we2=gear_weapon_data("weapon",ma_wep2[selected],"abbreviation"); - ma_we2=is_string(ma_we1) ? ma_we2 : ""; - // temp5=string(ma_wep1[selected])+", "+string(ma_wep2[selected])+" + "+string(ma_gear[selected]); - } - } - - if (draw && !impossible && ma_view[selected]){ - draw_set_alpha(1); - draw_set_color(c_black); - draw_rectangle(xx+25,yy+64,xx+974,yy+85,0); - draw_set_color(c_white); - if ((mouse_x>=xx+25 && mouse_y>=yy+64 && mouse_x= xx + 25 && mouse_y >= yy + 64 && mouse_x < xx + 974 && mouse_y < yy + 85) { + draw_set_alpha(0.3); + draw_rectangle(xx + 25, yy + 64, xx + 974, yy + 85, 0); + } + if (man_sel[selected] == 1) { + draw_set_alpha(0.2); + draw_rectangle(xx + 25, yy + 64, xx + 974, yy + 85, 0); + } + + unit_specialism_option = false; + spec_tip = ""; + draw_set_color(c_gray); + draw_set_alpha(1); + draw_rectangle(xx + 25, yy + 64, xx + 974, yy + 85, 1); if (man[selected] == "man" && is_struct(display_unit[selected])) { if (!unit_specialist) { var unit = display_unit[selected]; @@ -151,29 +158,21 @@ function scr_draw_management_unit(selected, yy=0, xx=0, draw=true){ var _data, valid = false; var _circle_coords = [xx + 321, yy + 77]; - var _circle_radius = 3 + var _circle_radius = 3; for (var s = 0; s <= 3; s++) { _data = obj_controller.spec_train_data[s]; var valid = stat_valuator(_data.req, unit); if (valid) { unit_specialism_option = true; - var _draw_coords = [ - _circle_coords[0] + _data.coord_offset[0], - _circle_coords[1] + _data.coord_offset[1], - ]; - - var _draw_coords_mouse = [ - _draw_coords[0] - _circle_radius, - _draw_coords[1] - _circle_radius, - _draw_coords[0] + _circle_radius, - _draw_coords[1] + _circle_radius - ]; + var _draw_coords = [_circle_coords[0] + _data.coord_offset[0], _circle_coords[1] + _data.coord_offset[1]]; + + var _draw_coords_mouse = [_draw_coords[0] - _circle_radius, _draw_coords[1] - _circle_radius, _draw_coords[0] + _circle_radius, _draw_coords[1] + _circle_radius]; specialistdir = unit.specialist_tooltips(_data.name, _data.min_exp); if (scr_hit(_draw_coords_mouse)) { - draw_set_alpha(0.8) + draw_set_alpha(0.8); if (scr_click_left()) { - switch _data.name { + switch (_data.name) { case "Techmarine": unit.role_tag[eROLE_TAG.Techmarine] = !unit.role_tag[eROLE_TAG.Techmarine]; break; @@ -191,285 +190,310 @@ function scr_draw_management_unit(selected, yy=0, xx=0, draw=true){ } draw_circle_colour(_draw_coords[0], _draw_coords[1], _circle_radius, specialistdir.colors[0], specialistdir.colors[1], 0); - draw_set_alpha(1.0) + draw_set_alpha(1.0); array_push(potential_tooltip, [specialistdir.spec_tip, _draw_coords_mouse]); } } } } - // Squads - var sqi=""; - draw_set_color(c_black); - var squad_colours=[c_teal,c_red,c_green,c_orange,c_aqua,c_fuchsia,c_green,c_blue,c_fuchsia,c_maroon]; - if (squad[selected]!=-1){ - var _squad_modulo = squad[selected]%10; - draw_set_color(squad_colours[_squad_modulo]) - } - - if (selected>0 && selectedselected){ - var _cur_squad = squad[selected]; - var _next_squad = squad[selected+1]; - var _prev_squad = squad[selected-1]; - if (_cur_squad==_next_squad){ - if (squad[selected]!=_prev_squad){ - sqi="top"; - } else { - sqi="mid" - } - } - else if (squad[selected]==_prev_squad){ - sqi="bot"; - } - } - //TODO handle recursively with an array - draw_rectangle(xx+25,yy+64,xx+25+8,yy+85,0); - draw_set_color(c_gray); - - if (sqi==""){ - draw_rectangle(xx+25,yy+64,xx+25+8,yy+85,1); - }else if (sqi=="mid"){ - draw_line(xx+25,yy+64,xx+25,yy+85); - }else if (sqi=="top" || sqi=="bot"){ - draw_line(xx+25,yy+64,xx+25+28,yy+64); - draw_line(xx+25,yy+64,xx+25,yy+85); - } - - draw_line(xx+25+8,yy+64,xx+25+8,yy+85); - // was 885 - // 974 - - if (man[selected]="man") and (ma_ar="") then draw_set_alpha(0.5); - var name_xr=1; - - for (var k = 0; k<10; k++){ - if ((string_width(string_hash_to_newline(string_role))*name_xr)>184-8) then name_xr-=0.05; - } - - var hpText = [xx+240+8, yy+66, string_hash_to_newline(string(health_string))]; // HP - var xpText = [xx+330+8, yy+66, exp_string]; // EXP - var hpColor = c_gray; - var xpColor = c_gray; - // Draw EXP value and set up health color - if (man[selected] == "man"){ - if (ma_promote[selected] >= 10){ - hpColor = c_red; - array_push(health_tooltip, ["Critical Health State! Bionic augmentation is required!", [xx+250, yy+64, xx+300, yy+85]]); - }else if (ma_promote[selected] > 0 && !unit_specialist && obj_controller.command_set[2] != 0){ - xpColor = c_yellow; - array_push(promotion_tooltip, ["Promotion Recommended", [xx+335, yy+64, xx+385, yy+85]]); - } - draw_text_color(xpText[0], xpText[1], xpText[2], xpColor, xpColor, xpColor, xpColor, 1); - } - // Draw the health value with the defined colors - draw_text_color(hpText[0], hpText[1], hpText[2], hpColor, hpColor, hpColor, hpColor, 1); - - // Draw the name - draw_set_color(c_gray); - draw_text_transformed(xx+27+8,yy+66,string_hash_to_newline(string(string_role)),name_xr,1,0); - draw_text_transformed(xx+27.5+8,yy+66.5,string_hash_to_newline(string(string_role)),name_xr,1,0); - - // Draw current location - if (unit_location_string=="Mechanicus Vessel") or (unit_location_string=="Terra IV") or (unit_location_string=="=Penitorium=") or (assignment!="none") then draw_set_alpha(0.5); - var truncatedLocation = string_truncate(string(unit_location_string), 130); // Truncate the location string to 100 pixels - draw_text(xx+430+8,yy+66,truncatedLocation);// LOC - draw_set_alpha(1); - - if (ma_loc[selected]=="Mechanicus Vessel"){ - draw_sprite(spr_loc_icon,2,xx+427+8,yy+66); - } else { - if (man[selected]=="man"){ - c = managing<=10 ? managing : 0; - var unit = display_unit[selected]; - - if (ma_lid[selected]>-1) and (ma_wid[selected]==0){ - draw_sprite( - spr_loc_icon, - unit.is_boarder ? 2 : 1, - xx+427+8, - yy+66); - } else if (ma_wid[selected]>0){ - draw_sprite(spr_loc_icon,0,xx+427+8,yy+66); - } - }else{ - if (ma_lid[selected]==-1) and (ma_wid[selected]>0) then draw_sprite(spr_loc_icon,0,xx+427+8,yy+66); - if (ma_lid[selected]>-1) and (ma_wid[selected]==0) then draw_sprite(spr_loc_icon,1,xx+427+8,yy+66); - } - } - //TODO handle recursively - if (man[selected]=="man"){ - var xoffset=0; - draw_set_color(c_gray); - if (ar_ar==1) then draw_set_color(c_gray); - if (ar_ar==2) then draw_set_color(881503); - draw_text(xx+573,yy+66,string_hash_to_newline(string(ma_ar))); - - - xoffset+=string_width(string_hash_to_newline(ma_ar))+15; - draw_set_color(c_gray); - if (ar_mb==1) then draw_set_color(c_gray); - if (ar_mb==2) then draw_set_color(881503); - draw_text(xx+573+xoffset,yy+66,string_hash_to_newline(string(ma_mb))); - - xoffset+=string_width(string_hash_to_newline(ma_mb))+15; - draw_set_color(c_gray); - if (ar_ge==1) then draw_set_color(c_gray); - if (ar_ge==2) then draw_set_color(881503); - draw_text(xx+573+xoffset,yy+66,string_hash_to_newline(string(ma_ge))); - - xoffset+=string_width(string_hash_to_newline(ma_ge))+15; - draw_set_color(c_gray); - if (ar_we1==1) then draw_set_color(c_gray); - if (ar_we1==2) then draw_set_color(881503); - draw_text(xx+573+xoffset,yy+66,string_hash_to_newline(string(ma_we1))); - - xoffset+=string_width(string_hash_to_newline(ma_we1))+15; - draw_set_color(c_gray); - if (ar_we2==1) then draw_set_color(c_gray); - if (ar_we2==2) then draw_set_color(881503); - draw_text(xx+573+xoffset,yy+66,string_hash_to_newline(string(ma_we2))); - } - var cols = [c_gray,c_gray, 881503] - if (man[selected]!="man"){ - var xoffset=0; - //Vehicle Upgrade - draw_set_color(cols[ar_ge]); - draw_text(xx+573,yy+66,string_hash_to_newline(string(ma_ge))); - - //Vehicle accessory - xoffset+=string_width(string_hash_to_newline(ma_ge))+15; - draw_set_color(cols[ar_mb]); - draw_text(xx+573+xoffset,yy+66,string_hash_to_newline(string(ma_mb))); - - //Vehicle wep 1 - xoffset+=string_width(string_hash_to_newline(ma_mb))+15; - draw_set_color(cols[ar_we1]); - draw_text(xx+573+xoffset,yy+66,string_hash_to_newline(string(ma_we1))); - - //Vehicle wep 2 - xoffset+=string_width(string_hash_to_newline(ma_we1))+15; - draw_set_color(cols[ar_we2]); - draw_text(xx+573+xoffset,yy+66,string_hash_to_newline(string(ma_we2))); - - //Vehicle wep 3 - xoffset+=string_width(string_hash_to_newline(ma_we2))+15; - draw_set_color(cols[ar_ar]); - draw_text(xx+573+xoffset,yy+66,string_hash_to_newline(string(ma_ar))); - } - } - var no_location = (selecting_location==""); + // Squads + var sqi = ""; + draw_set_color(c_black); + var squad_colours = [c_teal, c_red, c_green, c_orange, c_aqua, c_fuchsia, c_green, c_blue, c_fuchsia, c_maroon]; + if (squad[selected] != -1) { + var _squad_modulo = squad[selected] % 10; + draw_set_color(squad_colours[_squad_modulo]); + } + + if (selected > 0 && selected < array_length(display_unit) - 1 && array_length(squad) - 1 > selected) { + var _cur_squad = squad[selected]; + var _next_squad = squad[selected + 1]; + var _prev_squad = squad[selected - 1]; + if (_cur_squad == _next_squad) { + if (squad[selected] != _prev_squad) { + sqi = "top"; + } else { + sqi = "mid"; + } + } else if (squad[selected] == _prev_squad) { + sqi = "bot"; + } + } + //TODO handle recursively with an array + draw_rectangle(xx + 25, yy + 64, xx + 25 + 8, yy + 85, 0); + draw_set_color(c_gray); + + if (sqi == "") { + draw_rectangle(xx + 25, yy + 64, xx + 25 + 8, yy + 85, 1); + } else if (sqi == "mid") { + draw_line(xx + 25, yy + 64, xx + 25, yy + 85); + } else if (sqi == "top" || sqi == "bot") { + draw_line(xx + 25, yy + 64, xx + 25 + 28, yy + 64); + draw_line(xx + 25, yy + 64, xx + 25, yy + 85); + } + + draw_line(xx + 25 + 8, yy + 64, xx + 25 + 8, yy + 85); + // was 885 + // 974 + + if ((man[selected] == "man") && (ma_ar == "")) { + draw_set_alpha(0.5); + } + var name_xr = 1; + + for (var k = 0; k < 10; k++) { + if ((string_width(string_hash_to_newline(string_role)) * name_xr) > 184 - 8) { + name_xr -= 0.05; + } + } + + var hpText = [xx + 240 + 8, yy + 66, string_hash_to_newline(string(health_string))]; // HP + var xpText = [xx + 330 + 8, yy + 66, exp_string]; // EXP + var hpColor = c_gray; + var xpColor = c_gray; + // Draw EXP value and set up health color + if (man[selected] == "man") { + if (ma_promote[selected] >= 10) { + hpColor = c_red; + array_push(health_tooltip, ["Critical Health State! Bionic augmentation is required!", [xx + 250, yy + 64, xx + 300, yy + 85]]); + } else if (ma_promote[selected] > 0 && !unit_specialist && obj_controller.command_set[2] != 0) { + xpColor = c_yellow; + array_push(promotion_tooltip, ["Promotion Recommended", [xx + 335, yy + 64, xx + 385, yy + 85]]); + } + draw_text_color(xpText[0], xpText[1], xpText[2], xpColor, xpColor, xpColor, xpColor, 1); + } + // Draw the health value with the defined colors + draw_text_color(hpText[0], hpText[1], hpText[2], hpColor, hpColor, hpColor, hpColor, 1); + + // Draw the name + draw_set_color(c_gray); + draw_text_transformed(xx + 27 + 8, yy + 66, string_hash_to_newline(string(string_role)), name_xr, 1, 0); + draw_text_transformed(xx + 27.5 + 8, yy + 66.5, string_hash_to_newline(string(string_role)), name_xr, 1, 0); + + // Draw current location + if ((unit_location_string == "Mechanicus Vessel") || (unit_location_string == "Terra IV") || (unit_location_string == "=Penitorium=") || (assignment != "none")) { + draw_set_alpha(0.5); + } + var truncatedLocation = string_truncate(string(unit_location_string), 130); // Truncate the location string to 100 pixels + draw_text(xx + 430 + 8, yy + 66, truncatedLocation); // LOC + draw_set_alpha(1); + + if (ma_loc[selected] == "Mechanicus Vessel") { + draw_sprite(spr_loc_icon, 2, xx + 427 + 8, yy + 66); + } else { + if (man[selected] == "man") { + c = managing <= 10 ? managing : 0; + var unit = display_unit[selected]; + + if ((ma_lid[selected] > -1) && (ma_wid[selected] == 0)) { + draw_sprite(spr_loc_icon, unit.is_boarder ? 2 : 1, xx + 427 + 8, yy + 66); + } else if (ma_wid[selected] > 0) { + draw_sprite(spr_loc_icon, 0, xx + 427 + 8, yy + 66); + } + } else { + if ((ma_lid[selected] == -1) && (ma_wid[selected] > 0)) { + draw_sprite(spr_loc_icon, 0, xx + 427 + 8, yy + 66); + } + if ((ma_lid[selected] > -1) && (ma_wid[selected] == 0)) { + draw_sprite(spr_loc_icon, 1, xx + 427 + 8, yy + 66); + } + } + } + //TODO handle recursively + if (man[selected] == "man") { + var xoffset = 0; + draw_set_color(c_gray); + if (ar_ar == 1) { + draw_set_color(c_gray); + } + if (ar_ar == 2) { + draw_set_color(881503); + } + draw_text(xx + 573, yy + 66, string_hash_to_newline(string(ma_ar))); + + xoffset += string_width(string_hash_to_newline(ma_ar)) + 15; + draw_set_color(c_gray); + if (ar_mb == 1) { + draw_set_color(c_gray); + } + if (ar_mb == 2) { + draw_set_color(881503); + } + draw_text(xx + 573 + xoffset, yy + 66, string_hash_to_newline(string(ma_mb))); + + xoffset += string_width(string_hash_to_newline(ma_mb)) + 15; + draw_set_color(c_gray); + if (ar_ge == 1) { + draw_set_color(c_gray); + } + if (ar_ge == 2) { + draw_set_color(881503); + } + draw_text(xx + 573 + xoffset, yy + 66, string_hash_to_newline(string(ma_ge))); + + xoffset += string_width(string_hash_to_newline(ma_ge)) + 15; + draw_set_color(c_gray); + if (ar_we1 == 1) { + draw_set_color(c_gray); + } + if (ar_we1 == 2) { + draw_set_color(881503); + } + draw_text(xx + 573 + xoffset, yy + 66, string_hash_to_newline(string(ma_we1))); + + xoffset += string_width(string_hash_to_newline(ma_we1)) + 15; + draw_set_color(c_gray); + if (ar_we2 == 1) { + draw_set_color(c_gray); + } + if (ar_we2 == 2) { + draw_set_color(881503); + } + draw_text(xx + 573 + xoffset, yy + 66, string_hash_to_newline(string(ma_we2))); + } + var cols = [c_gray, c_gray, 881503]; + if (man[selected] != "man") { + var xoffset = 0; + //Vehicle Upgrade + draw_set_color(cols[ar_ge]); + draw_text(xx + 573, yy + 66, string_hash_to_newline(string(ma_ge))); + + //Vehicle accessory + xoffset += string_width(string_hash_to_newline(ma_ge)) + 15; + draw_set_color(cols[ar_mb]); + draw_text(xx + 573 + xoffset, yy + 66, string_hash_to_newline(string(ma_mb))); + + //Vehicle wep 1 + xoffset += string_width(string_hash_to_newline(ma_mb)) + 15; + draw_set_color(cols[ar_we1]); + draw_text(xx + 573 + xoffset, yy + 66, string_hash_to_newline(string(ma_we1))); + + //Vehicle wep 2 + xoffset += string_width(string_hash_to_newline(ma_we1)) + 15; + draw_set_color(cols[ar_we2]); + draw_text(xx + 573 + xoffset, yy + 66, string_hash_to_newline(string(ma_we2))); + + //Vehicle wep 3 + xoffset += string_width(string_hash_to_newline(ma_we2)) + 15; + draw_set_color(cols[ar_ar]); + draw_text(xx + 573 + xoffset, yy + 66, string_hash_to_newline(string(ma_ar))); + } + } + var no_location = selecting_location == ""; var wrong_location = false; - if (!no_location){ - if (selecting_ship>-1){ - if (ma_lid[selected]==-1){ - wrong_location=true; - } else { - wrong_location = obj_ini.ship_location[ma_lid[selected]] != selecting_location; - } - } else { - wrong_location = ma_loc[selected]!=selecting_location; - } + if (!no_location) { + if (selecting_ship > -1) { + if (ma_lid[selected] == -1) { + wrong_location = true; + } else { + wrong_location = obj_ini.ship_location[ma_lid[selected]] != selecting_location; + } + } else { + wrong_location = ma_loc[selected] != selecting_location; + } } - if (!wrong_location){ - wrong_location = (ma_loc[selected] == "Terra"); + if (!wrong_location) { + wrong_location = ma_loc[selected] == "Terra"; } - - var unclickable = (eventing || jailed || wrong_location || impossible || instance_exists(obj_star_select)); - - if (!unclickable){ - var changed = false; - - if (sel_all!="") { - if(sel_all == "all"){ - changed = true; - } else if (sel_all=="vehicle" && !is_man){ - changed = true; - } else if(sel_all=="man" && is_man){ - changed = true; - } else if (sel_all=="Command" && is_man){ - if (unit.IsSpecialist("command")){ - changed=true - } else if (unit.squad!="none"){ - if (obj_ini.squads[unit.squad].type=="command_squad"){ - changed=true - } - } - } else if (ma_role[selected] == sel_all){ - changed = true; - } - } - if (filter_mode && changed){ - ma_view[selected] = !ma_view[selected]; - changed = false; - } else if (changed){ - man_sel[selected] = !man_sel[selected]; - } - if (!ma_view[selected]){ - changed = false; - man_sel[selected]=false; - } - - // individual click - if (draw && scrollbar_engaged==0 && ma_view[selected]){ - if (point_and_click([xx+25+8, yy+64, xx+974, yy+85]) && rectangle_action==-1 /*squad[selected]=squad_sel*/){ - if (double_click<1){ - double_was=selected; - double_click=12; - } else if (double_was==selected) { - double_unit=selected; - } - //drag selection action - drag_square = [mouse_x, mouse_y, mouse_x, mouse_y]; - rectangle_action = !man_sel[selected]; - man_sel[selected] = !man_sel[selected]; - changed = true; - } else if (rectangle_action!=-1){ - if (rectangle_in_rectangle(xx+25+8,yy+64,xx+974,yy+85, drag_square[0], drag_square[1], mouse_x, mouse_y)>0 && man_sel[selected]!=rectangle_action ){ - man_sel[selected] = rectangle_action; - changed = true; - } - } - if (squad_sel!=-1) and (squad[selected]!=0){ - if (squad_sel==squad[selected] && man_sel[selected] != squad_sel_action){ - man_sel[selected] = squad_sel_action; - changed = true; - } - } - } - if (changed){ - if(no_location){ - selecting_location=ma_loc[selected]; - selecting_ship=ma_lid[selected]; - selecting_planet=ma_wid[selected]; - } - ma_loc[selected] = selecting_location; - var unit_man_size = is_man ? unit.get_unit_size() : scr_unit_size("",ma_role[selected],true); - if (man_sel[selected]){ - man_size+=unit_man_size; - } else { - man_size-=unit_man_size; - } - } - //squad select button - if (point_and_click([xx+25,yy+64,xx+25+8,yy+85]) && draw){ - if (squad_sel==-1) and (squad[selected]!=0){ - squad_sel=squad[selected]; - squad_sel_count=2; + + var unclickable = eventing || jailed || wrong_location || impossible || instance_exists(obj_star_select); + + if (!unclickable) { + var changed = false; + + if (sel_all != "") { + if (sel_all == "all") { + changed = true; + } else if (sel_all == "vehicle" && !is_man) { + changed = true; + } else if (sel_all == "man" && is_man) { + changed = true; + } else if (sel_all == "Command" && is_man) { + if (unit.IsSpecialist("command")) { + changed = true; + } else if (unit.squad != "none") { + if (obj_ini.squads[unit.squad].type == "command_squad") { + changed = true; + } + } + } else if (ma_role[selected] == sel_all) { + changed = true; + } + } + if (filter_mode && changed) { + ma_view[selected] = !ma_view[selected]; + changed = false; + } else if (changed) { + man_sel[selected] = !man_sel[selected]; + } + if (!ma_view[selected]) { + changed = false; + man_sel[selected] = false; + } + + // individual click + if (draw && scrollbar_engaged == 0 && ma_view[selected]) { + if (point_and_click([xx + 25 + 8, yy + 64, xx + 974, yy + 85]) && rectangle_action == -1 /*squad[selected]=squad_sel*/ ) { + if (double_click < 1) { + double_was = selected; + double_click = 12; + } else if (double_was == selected) { + double_unit = selected; + } + //drag selection action + drag_square = [mouse_x, mouse_y, mouse_x, mouse_y]; + rectangle_action = !man_sel[selected]; + man_sel[selected] = !man_sel[selected]; + changed = true; + } else if (rectangle_action != -1) { + if (rectangle_in_rectangle(xx + 25 + 8, yy + 64, xx + 974, yy + 85, drag_square[0], drag_square[1], mouse_x, mouse_y) > 0 && man_sel[selected] != rectangle_action) { + man_sel[selected] = rectangle_action; + changed = true; + } + } + if ((squad_sel != -1) && (squad[selected] != 0)) { + if (squad_sel == squad[selected] && man_sel[selected] != squad_sel_action) { + man_sel[selected] = squad_sel_action; + changed = true; + } + } + } + if (changed) { + if (no_location) { + selecting_location = ma_loc[selected]; + selecting_ship = ma_lid[selected]; + selecting_planet = ma_wid[selected]; + } + ma_loc[selected] = selecting_location; + var unit_man_size = is_man ? unit.get_unit_size() : scr_unit_size("", ma_role[selected], true); + if (man_sel[selected]) { + man_size += unit_man_size; + } else { + man_size -= unit_man_size; + } + } + //squad select button + if (point_and_click([xx + 25, yy + 64, xx + 25 + 8, yy + 85]) && draw) { + if ((squad_sel == -1) && (squad[selected] != 0)) { + squad_sel = squad[selected]; + squad_sel_count = 2; squad_sel_action = !man_sel[selected]; } - } + } } - if (is_man){ - force_tool=0; - if (temp[101] == $"{unit.role()} {unit.name}") - and ((temp[102]!=unit.armour()) or (temp[104]!=unit.gear()) or (temp[106]=unit.mobility_item()) - or (temp[108]!=unit.weapon_one()) or (temp[110]!=unit.weapon_two()) - or (temp[114]="refresh")) then force_tool=1; - - if (((mouse_x>=xx+25 && mouse_y>=yy+64 && mouse_x= xx + 25 && mouse_y >= yy + 64 && mouse_x < xx + 974 && mouse_y < yy + 85) || force_tool == 1) && is_struct(unit)) { temp[120] = unit; // unit_struct } } - if (!ma_view[selected]) return "continue"; + if (!ma_view[selected]) { + return "continue"; + } } diff --git a/scripts/scr_draw_unit_image/scr_draw_unit_image.gml b/scripts/scr_draw_unit_image/scr_draw_unit_image.gml index 26fd69595a..aefe881e5e 100644 --- a/scripts/scr_draw_unit_image/scr_draw_unit_image.gml +++ b/scripts/scr_draw_unit_image/scr_draw_unit_image.gml @@ -5,7 +5,7 @@ enum ShaderType { Lens, Trim, RightPauldron, - Weapon + Weapon, } enum UnitSpecialization { @@ -42,58 +42,61 @@ enum ArmourType { Scout, Terminator, Dreadnought, - None + None, } -function set_and_clear_surface(_surface){ + +function set_and_clear_surface(_surface) { surface_set_target(_surface); - draw_clear_alpha(c_white,0); - surface_reset_target(); - surface_free(_surface) + draw_clear_alpha(c_white, 0); + surface_reset_target(); + surface_free(_surface); } -function UnitImage(unit_surface) constructor{ + +function UnitImage(unit_surface) constructor { u_surface = unit_surface; - static draw = function (xx, yy, _background=false){ - if (_background){ - draw_rectangle_color_simple(xx-1,yy-1,xx+1+166,yy+271+1,0,c_black); - draw_rectangle_color_simple(xx-1,yy-1,xx+166+1,yy+271+1,1,c_gray); - draw_rectangle_color_simple(xx-2,yy-2,xx+166+2,yy+2+271,1,c_black); - draw_rectangle_color_simple(xx-3,yy-3,xx+166+3,yy+3+271,1,c_gray); - } - if (sprite_exists(u_surface)){ - draw_sprite(u_surface, 0,xx-200,yy-90); + + static draw = function(xx, yy, _background = false) { + if (_background) { + draw_rectangle_color_simple(xx - 1, yy - 1, xx + 1 + 166, yy + 271 + 1, 0, c_black); + draw_rectangle_color_simple(xx - 1, yy - 1, xx + 166 + 1, yy + 271 + 1, 1, c_gray); + draw_rectangle_color_simple(xx - 2, yy - 2, xx + 166 + 2, yy + 2 + 271, 1, c_black); + draw_rectangle_color_simple(xx - 3, yy - 3, xx + 166 + 3, yy + 3 + 271, 1, c_gray); } - } + if (sprite_exists(u_surface)) { + draw_sprite(u_surface, 0, xx - 200, yy - 90); + } + }; - static draw_part = function (xx, yy,left,top,width,height, _background=false){ - if (_background){ - draw_rectangle_color_simple(xx-1+left,yy-1+top,xx+1+width,yy+height+1,0,c_black); - draw_rectangle_color_simple(xx-1+left,yy-1+top,xx+width+1,yy+height+1,1,c_gray); - draw_rectangle_color_simple(xx-2+left,yy-2+top,xx+width+2,yy+2+height,1,c_black); - draw_rectangle_color_simple(xx-3+left,yy-3+top,xx+width+3,yy+3+height,1,c_gray); - } - if (sprite_exists(u_surface)){ - draw_sprite_part(u_surface,0, left+200, top+90, width,height, xx,yy); - } - } + static draw_part = function(xx, yy, left, top, width, height, _background = false) { + if (_background) { + draw_rectangle_color_simple(xx - 1 + left, yy - 1 + top, xx + 1 + width, yy + height + 1, 0, c_black); + draw_rectangle_color_simple(xx - 1 + left, yy - 1 + top, xx + width + 1, yy + height + 1, 1, c_gray); + draw_rectangle_color_simple(xx - 2 + left, yy - 2 + top, xx + width + 2, yy + 2 + height, 1, c_black); + draw_rectangle_color_simple(xx - 3 + left, yy - 3 + top, xx + width + 3, yy + 3 + height, 1, c_gray); + } + if (sprite_exists(u_surface)) { + draw_sprite_part(u_surface, 0, left + 200, top + 90, width, height, xx, yy); + } + }; - static destroy_image = function(){ - if (sprite_exists(u_surface)){ + static destroy_image = function() { + if (sprite_exists(u_surface)) { sprite_delete(u_surface); } - } + }; } -function BaseColor(R,G,B) constructor{ - r=R; - g=G; - b=B; +function BaseColor(R, G, B) constructor { + r = R; + g = G; + b = B; } //TODO this is a laxy fix and can be written better function set_shader_color(shaderType, colorIndex) { var findShader, setShader; - if (instance_exists(obj_controller)){ - with (obj_controller){ + if (instance_exists(obj_controller)) { + with(obj_controller) { switch (shaderType) { case ShaderType.Body: setShader = colour_to_set1; @@ -117,10 +120,10 @@ function set_shader_color(shaderType, colorIndex) { setShader = colour_to_set7; break; } - shader_set_uniform_f(setShader, col_r[colorIndex]/255, col_g[colorIndex]/255, col_b[colorIndex]/255); + shader_set_uniform_f(setShader, col_r[colorIndex] / 255, col_g[colorIndex] / 255, col_b[colorIndex] / 255); } - } else if (instance_exists(obj_creation)){ - with (obj_controller){ + } else if (instance_exists(obj_creation)) { + with(obj_controller) { switch (shaderType) { case ShaderType.Body: setShader = colour_to_set1; @@ -144,8 +147,8 @@ function set_shader_color(shaderType, colorIndex) { setShader = colour_to_set7; break; } - shader_set_uniform_f(setShader, col_r[colorIndex]/255, col_g[colorIndex]/255, col_b[colorIndex]/255); - } + shader_set_uniform_f(setShader, col_r[colorIndex] / 255, col_g[colorIndex] / 255, col_b[colorIndex] / 255); + } } } @@ -158,50 +161,50 @@ enum BackType { Jump, } -function make_colour_from_array(col_array){ - return make_color_rgb(col_array[0] *255, col_array[1] * 255, col_array[2] * 255); +function make_colour_from_array(col_array) { + return make_color_rgb(col_array[0] * 255, col_array[1] * 255, col_array[2] * 255); } -function set_shader_to_base_values(){ - with (obj_controller){ - shader_set_uniform_f_array(colour_to_find1, body_colour_find ); - shader_set_uniform_f_array(colour_to_set1, body_colour_replace ); - shader_set_uniform_f_array(colour_to_find2, secondary_colour_find ); - shader_set_uniform_f_array(colour_to_set2, secondary_colour_replace ); - shader_set_uniform_f_array(colour_to_find3, pauldron_colour_find ); - shader_set_uniform_f_array(colour_to_set3, pauldron_colour_replace ); - shader_set_uniform_f_array(colour_to_find4, lens_colour_find ); - shader_set_uniform_f_array(colour_to_set4, lens_colour_replace ); - shader_set_uniform_f_array(colour_to_find5, trim_colour_find ); - shader_set_uniform_f_array(colour_to_set5, trim_colour_replace ); - shader_set_uniform_f_array(colour_to_find6, pauldron2_colour_find ); - shader_set_uniform_f_array(colour_to_set6, pauldron2_colour_replace ); - shader_set_uniform_f_array(colour_to_find7, weapon_colour_find ); - shader_set_uniform_f_array(colour_to_set7, weapon_colour_replace ); - } - shader_set_uniform_i(shader_get_uniform(sReplaceColor, "u_blend_modes"), 0); +function set_shader_to_base_values() { + with(obj_controller) { + shader_set_uniform_f_array(colour_to_find1, body_colour_find); + shader_set_uniform_f_array(colour_to_set1, body_colour_replace); + shader_set_uniform_f_array(colour_to_find2, secondary_colour_find); + shader_set_uniform_f_array(colour_to_set2, secondary_colour_replace); + shader_set_uniform_f_array(colour_to_find3, pauldron_colour_find); + shader_set_uniform_f_array(colour_to_set3, pauldron_colour_replace); + shader_set_uniform_f_array(colour_to_find4, lens_colour_find); + shader_set_uniform_f_array(colour_to_set4, lens_colour_replace); + shader_set_uniform_f_array(colour_to_find5, trim_colour_find); + shader_set_uniform_f_array(colour_to_set5, trim_colour_replace); + shader_set_uniform_f_array(colour_to_find6, pauldron2_colour_find); + shader_set_uniform_f_array(colour_to_set6, pauldron2_colour_replace); + shader_set_uniform_f_array(colour_to_find7, weapon_colour_find); + shader_set_uniform_f_array(colour_to_set7, weapon_colour_replace); + } + shader_set_uniform_i(shader_get_uniform(sReplaceColor, "u_blend_modes"), 0); } -function set_shader_array(shader_array){ - for (var i=0;i-1){ +function set_shader_array(shader_array) { + for (var i = 0; i < array_length(shader_array); i++) { + if (shader_array[i] > -1) { set_shader_color(i, shader_array[i]); } } } /// @mixin -function scr_draw_unit_image(_background=false){ - static draw_unit_hands = function(x_surface_offset, y_surface_offset, armour_type, specialist_colours, hide_bionics, right_left){ +function scr_draw_unit_image(_background = false) { + static draw_unit_hands = function(x_surface_offset, y_surface_offset, armour_type, specialist_colours, hide_bionics, right_left) { shader_set(full_livery_shader); if (arm_variant[right_left] == 1) { return; } - if (armour_type != ArmourType.None){ + if (armour_type != ArmourType.None) { var offset_x = x_surface_offset; var offset_y = y_surface_offset; - switch(armour_type){ + switch (armour_type) { case ArmourType.Terminator: var _hand_spr = spr_terminator_hands; break; @@ -214,7 +217,7 @@ function scr_draw_unit_image(_background=false){ var _hand_spr = spr_pa_hands; break; } - if (hand_variant[right_left] > 0){ + if (hand_variant[right_left] > 0) { var _spr_index = (hand_variant[right_left] - 1) * 2; if (right_left == 2) { _spr_index += (specialist_colours >= 2) ? 1 : 0; @@ -224,9 +227,9 @@ function scr_draw_unit_image(_background=false){ } } // Draw bionic hands - if (hand_variant[right_left] == 1){ - if (armour_type == ArmourType.Normal && !hide_bionics && struct_exists(body[$ (right_left == 1 ? "right_arm" : "left_arm")], "bionic")) { - var bionic_hand = body[$ (right_left == 1 ? "right_arm" : "left_arm")][$ "bionic"]; + if (hand_variant[right_left] == 1) { + if (armour_type == ArmourType.Normal && !hide_bionics && struct_exists(body[$(right_left == 1 ? "right_arm" : "left_arm")], "bionic")) { + var bionic_hand = body[$(right_left == 1 ? "right_arm" : "left_arm")][$ "bionic"]; var bionic_spr_index = bionic_hand.variant * 2; if (right_left == 2) { bionic_spr_index += (specialist_colours >= 2) ? 1 : 0; @@ -239,28 +242,28 @@ function scr_draw_unit_image(_background=false){ } }; - - var _role = active_roles(); - var complex_set={}; + var complex_set = {}; var x_surface_offset = 200; var y_surface_offset = 110; - - var xx=__view_get( e__VW.XView, 0 )+0, yy=__view_get( e__VW.YView, 0 )+0, bb="", img=0; + var xx = __view_get(e__VW.XView, 0) + 0, + yy = __view_get(e__VW.YView, 0) + 0, + bb = "", + img = 0; var _controller = instance_exists(obj_controller); var _creation = instance_exists(obj_creation); var unit_surface = _controller ? obj_controller.marine_surface : obj_creation.marine_surface; - if (!surface_exists(unit_surface)){ + if (!surface_exists(unit_surface)) { var _obj = _controller ? obj_controller : obj_creation; - with (_obj){ + with(_obj) { marine_surface = surface_create(600, 600); unit_surface = marine_surface; } } surface_set_target(unit_surface); - draw_clear_alpha(c_black, 0);//RESET surface + draw_clear_alpha(c_black, 0); //RESET surface draw_set_font(fnt_40k_14b); draw_set_color(c_gray); @@ -268,237 +271,237 @@ function scr_draw_unit_image(_background=false){ var progenitor_visuals = _controller ? obj_controller.progenitor_visuals : 0; try { - if (name_role()!="") and (base_group=="astartes"){ - for (var i = 1; i <= 2; i++) { - ui_weapon[i]=spr_weapon_blank; - arm_variant[i]=1; - hand_variant[i]=1; - hand_on_top[i]=false; - ui_spec[i]=false; - ui_twoh[i]=false; - ui_xmod[i]=0; - ui_ymod[i]=0; - new_weapon_draw[i]=false; - } - var draw_backpack = true; - var ui_force_both=false; - var pauldron_trim=false; - var armour_bypass = false; - var hide_bionics = false; - var robes_bypass = false; - var robes_hood_bypass = false; - var halo_bypass = false; - var arm_bypass = false; - var armour_draw = []; - var specialist_colours= instance_exists(obj_creation) ? obj_creation.col_special : obj_ini.col_special; - var specific_armour_sprite = "none"; - var unit_chapter = _creation? obj_creation.chapter_name : global.chapter_name; - var unit_role = role(); - var unit_wep1=weapon_one(); - var unit_wep2=weapon_two(); - var unit_armour=armour(); - var unit_gear=gear(); - var unit_back=mobility_item() - var unit_specialization=UnitSpecialization.None; - var unit_special_colours=0; - var skin_color=obj_creation ? 0 :obj_ini.skin_color; - var armour_type = ArmourType.Normal; - var armour_sprite = spr_weapon_blank; - var complex_livery = false; - var back_equipment = BackType.None; - var psy_hood = false; - var skull_mask = false; - var servo_arm = 0; - var servo_harness = 0; - var halo = 0; - var reverent_guardians = false; - var tech_brothers_trait = -5; - var body_part; - var dev_trait = 0; - static _body_parts = ARR_body_parts; - - // if (unit_role=="Chapter Master"){unit_specialization=111;} - // // Honour Guard - // else if (unit_role==obj_ini.role[100,2]){unit_specialization=14;} - // Chaplain - if (is_specialist(unit_role,"chap",true)){ - if (unit_chapter== "Iron Hands"){ - unit_specialization=UnitSpecialization.IronFather; - } else if (unit_chapter == "Space Wolves") { - unit_specialization=UnitSpecialization.WolfPriest; - } else { - unit_specialization=UnitSpecialization.Chaplain; - } - } - // Techmarine - else if (is_specialist(unit_role,"forge",true)){ - if (unit_chapter== "Iron Hands"){ - unit_specialization=UnitSpecialization.IronFather; - } else { - unit_specialization=UnitSpecialization.Techmarine; - } - } - // Apothecary - else if (is_specialist(unit_role,"apoth",true)){ - if (unit_chapter == "Space Wolves") { - unit_specialization=UnitSpecialization.WolfPriest; - } else { - unit_specialization=UnitSpecialization.Apothecary; + if ((name_role() != "") && (base_group == "astartes")) { + for (var i = 1; i <= 2; i++) { + ui_weapon[i] = spr_weapon_blank; + arm_variant[i] = 1; + hand_variant[i] = 1; + hand_on_top[i] = false; + ui_spec[i] = false; + ui_twoh[i] = false; + ui_xmod[i] = 0; + ui_ymod[i] = 0; + new_weapon_draw[i] = false; + } + var draw_backpack = true; + var ui_force_both = false; + var pauldron_trim = false; + var armour_bypass = false; + var hide_bionics = false; + var robes_bypass = false; + var robes_hood_bypass = false; + var halo_bypass = false; + var arm_bypass = false; + var armour_draw = []; + var specialist_colours = instance_exists(obj_creation) ? obj_creation.col_special : obj_ini.col_special; + var specific_armour_sprite = "none"; + var unit_chapter = _creation ? obj_creation.chapter_name : global.chapter_name; + var unit_role = role(); + var unit_wep1 = weapon_one(); + var unit_wep2 = weapon_two(); + var unit_armour = armour(); + var unit_gear = gear(); + var unit_back = mobility_item(); + var unit_specialization = UnitSpecialization.None; + var unit_special_colours = 0; + var skin_color = obj_creation ? 0 : obj_ini.skin_color; + var armour_type = ArmourType.Normal; + var armour_sprite = spr_weapon_blank; + var complex_livery = false; + var back_equipment = BackType.None; + var psy_hood = false; + var skull_mask = false; + var servo_arm = 0; + var servo_harness = 0; + var halo = 0; + var reverent_guardians = false; + var tech_brothers_trait = -5; + var body_part; + var dev_trait = 0; + static _body_parts = ARR_body_parts; + + // if (unit_role=="Chapter Master"){unit_specialization=111;} + // // Honour Guard + // else if (unit_role==obj_ini.role[100,2]){unit_specialization=14;} + // Chaplain + if (is_specialist(unit_role, "chap", true)) { + if (unit_chapter == "Iron Hands") { + unit_specialization = UnitSpecialization.IronFather; + } else if (unit_chapter == "Space Wolves") { + unit_specialization = UnitSpecialization.WolfPriest; + } else { + unit_specialization = UnitSpecialization.Chaplain; + } + } else // Techmarine + if (is_specialist(unit_role, "forge", true)) { + if (unit_chapter == "Iron Hands") { + unit_specialization = UnitSpecialization.IronFather; + } else { + unit_specialization = UnitSpecialization.Techmarine; + } + } else // Apothecary + if (is_specialist(unit_role, "apoth", true)) { + if (unit_chapter == "Space Wolves") { + unit_specialization = UnitSpecialization.WolfPriest; + } else { + unit_specialization = UnitSpecialization.Apothecary; + } + } else // Librarian + if (is_specialist(unit_role, "libs", true)) { + unit_specialization = UnitSpecialization.Librarian; + } else // Death Company + if (unit_role == "Death Company") { + unit_specialization = UnitSpecialization.DeathCompany; + } + // Dark Angels + if (unit_chapter == "Dark Angels") { + // Deathwing + if (company == 1) { + unit_special_colours = UnitSpecialColours.Deathwing; + } else // Ravenwing + if (company == 2) { + unit_special_colours = UnitSpecialColours.Ravenwing; + } } - } - // Librarian - else if (is_specialist(unit_role,"libs",true)){unit_specialization=UnitSpecialization.Librarian;} - // Death Company - else if (unit_role=="Death Company"){unit_specialization=UnitSpecialization.DeathCompany;} - // Dark Angels - if (unit_chapter=="Dark Angels"){ - // Deathwing - if (company == 1) { - unit_special_colours=UnitSpecialColours.Deathwing; - } - // Ravenwing - else if (company == 2) { - unit_special_colours=UnitSpecialColours.Ravenwing; + // Blood Angels gold + if ((unit_role == _role[eROLE.HonourGuard] || unit_role == "Chapter Master") && (unit_chapter == "Blood Angels")) { + unit_special_colours = UnitSpecialColours.Gold; } - } - // Blood Angels gold - if ((unit_role==_role[eROLE.HonourGuard] || unit_role=="Chapter Master")) and (unit_chapter=="Blood Angels"){ - unit_special_colours=UnitSpecialColours.Gold; - } - // Sets up the description for the equipement of current marine + // Sets up the description for the equipement of current marine - if (scr_has_adv("Reverent Guardians")){ - if (array_contains([UnitSpecialization.Chaplain, UnitSpecialization.WolfPriest, UnitSpecialization.Librarian], unit_specialization) || unit_role=="Chapter Master"){ + if (scr_has_adv("Reverent Guardians")) { + if (array_contains([UnitSpecialization.Chaplain, UnitSpecialization.WolfPriest, UnitSpecialization.Librarian], unit_specialization) || unit_role == "Chapter Master") { reverent_guardians = true; + } } - } - if (unit_gear == "Psychic Hood"){ - psy_hood = true; - } + if (unit_gear == "Psychic Hood") { + psy_hood = true; + } - if (array_contains([UnitSpecialization.Chaplain, UnitSpecialization.WolfPriest], unit_specialization)) then skull_mask = true; - - // if (_armour_type!=ArType.Norm) then draw_backpack=false; + if (array_contains([UnitSpecialization.Chaplain, UnitSpecialization.WolfPriest], unit_specialization)) { + skull_mask = true; + } - if (unit_back="Servo-arm"){ - servo_arm=1; - } else if (unit_back="Servo-harness"){ - servo_harness=1; - } + // if (_armour_type!=ArType.Norm) then draw_backpack=false; - if (unit_gear == "Iron Halo"){ - halo = 1; - } + if (unit_back == "Servo-arm") { + servo_arm = 1; + } else if (unit_back == "Servo-harness") { + servo_harness = 1; + } - switch(unit_armour){ - case "Scout Armour": - armour_type = ArmourType.Scout; - break; - case "Terminator Armour": - case "Tartaros": - armour_type = ArmourType.Terminator; - break; - case "Dreadnought": - armour_type = ArmourType.Dreadnought; - break; - case ITEM_NAME_NONE: - case "": - case "None": - armour_type = ArmourType.None; - break; - } - - draw_backpack = armour_type==ArmourType.Normal; - - if (armour_type!=ArmourType.Dreadnought && armour_type!=ArmourType.None){ - if (weapon_one()!=""){ - scr_ui_display_weapons(1,unit_armour,weapon_one(), armour_type); - } - - if (weapon_two()!="") and (ui_twoh[1]==false){ - scr_ui_display_weapons(2,unit_armour,weapon_two(), armour_type); + if (unit_gear == "Iron Halo") { + halo = 1; } - } - //if(shader_is_compiled(sReplaceColor)){ - //shader_set(sReplaceColor); - - //set_shader_to_base_values(); - - //TODO make some sort of reusable structure to handle this sort of colour logic - // also not ideal way of creating colour variation but it's a first pass - var shader_array_set = array_create(8, -1); - - pauldron_trim=_controller ? obj_controller.trim : obj_creation.trim; - //TODO complex shader means no need for all this edge case stuff - - - // Blood Angels Death Company Marines - if (unit_specialization==UnitSpecialization.DeathCompany){ - shader_array_set[ShaderType.Body] = Colors.Black; - shader_array_set[ShaderType.Helmet] = Colors.Black; - shader_array_set[ShaderType.LeftPauldron] = Colors.Black; - shader_array_set[ShaderType.Lens] = Colors.Red; - shader_array_set[ShaderType.Trim] = Colors.Black; - shader_array_set[ShaderType.RightPauldron] = Colors.Black; - shader_array_set[ShaderType.Weapon] = Colors.Dark_Red; - pauldron_trim=0; - specialist_colours=0; - } - - // Dark Angels Deathwing - if (unit_special_colours == UnitSpecialColours.Deathwing){ - if !array_contains([_role[eROLE.Chaplain],_role[eROLE.Librarian], _role[eROLE.Techmarine]], unit_role){ - shader_array_set[ShaderType.Body] = Colors.Deathwing; - shader_array_set[ShaderType.Trim] = Colors.Light_Caliban_Green; - if (unit_role != _role[eROLE.Apothecary]){ - shader_array_set[ShaderType.Helmet] = Colors.Deathwing; - } + switch (unit_armour) { + case "Scout Armour": + armour_type = ArmourType.Scout; + break; + case "Terminator Armour": + case "Tartaros": + armour_type = ArmourType.Terminator; + break; + case "Dreadnought": + armour_type = ArmourType.Dreadnought; + break; + case ITEM_NAME_NONE: + case "": + case "None": + armour_type = ArmourType.None; + break; } - if !array_contains([_role[eROLE.Chaplain],_role[eROLE.Techmarine]], unit_role){ - shader_array_set[ShaderType.RightPauldron] = Colors.Deathwing; + + draw_backpack = armour_type == ArmourType.Normal; + + if (armour_type != ArmourType.Dreadnought && armour_type != ArmourType.None) { + if (weapon_one() != "") { + scr_ui_display_weapons(1, unit_armour, weapon_one(), armour_type); + } + + if ((weapon_two() != "") && (ui_twoh[1] == false)) { + scr_ui_display_weapons(2, unit_armour, weapon_two(), armour_type); + } } - shader_array_set[ShaderType.LeftPauldron] = Colors.Deathwing; - pauldron_trim=0; - specialist_colours=0; - } - - // Dark Angels Ravenwing - if (unit_special_colours == UnitSpecialColours.Ravenwing){ - if !array_contains([_role[eROLE.Chaplain],_role[eROLE.Librarian], _role[eROLE.Techmarine],_role[eROLE.Apothecary]], unit_role){ + + //if(shader_is_compiled(sReplaceColor)){ + //shader_set(sReplaceColor); + + //set_shader_to_base_values(); + + //TODO make some sort of reusable structure to handle this sort of colour logic + // also not ideal way of creating colour variation but it's a first pass + var shader_array_set = array_create(8, -1); + + pauldron_trim = _controller ? obj_controller.trim : obj_creation.trim; + //TODO complex shader means no need for all this edge case stuff + + // Blood Angels Death Company Marines + if (unit_specialization == UnitSpecialization.DeathCompany) { shader_array_set[ShaderType.Body] = Colors.Black; shader_array_set[ShaderType.Helmet] = Colors.Black; - } - if !array_contains([_role[eROLE.Chaplain],_role[eROLE.Techmarine]], unit_role){ + shader_array_set[ShaderType.LeftPauldron] = Colors.Black; + shader_array_set[ShaderType.Lens] = Colors.Red; + shader_array_set[ShaderType.Trim] = Colors.Black; shader_array_set[ShaderType.RightPauldron] = Colors.Black; + shader_array_set[ShaderType.Weapon] = Colors.Dark_Red; + pauldron_trim = 0; + specialist_colours = 0; + } + + // Dark Angels Deathwing + if (unit_special_colours == UnitSpecialColours.Deathwing) { + if (!array_contains([_role[eROLE.Chaplain], _role[eROLE.Librarian], _role[eROLE.Techmarine]], unit_role)) { + shader_array_set[ShaderType.Body] = Colors.Deathwing; + shader_array_set[ShaderType.Trim] = Colors.Light_Caliban_Green; + if (unit_role != _role[eROLE.Apothecary]) { + shader_array_set[ShaderType.Helmet] = Colors.Deathwing; + } + } + if (!array_contains([_role[eROLE.Chaplain], _role[eROLE.Techmarine]], unit_role)) { + shader_array_set[ShaderType.RightPauldron] = Colors.Deathwing; + } + shader_array_set[ShaderType.LeftPauldron] = Colors.Deathwing; + pauldron_trim = 0; + specialist_colours = 0; } - shader_array_set[ShaderType.LeftPauldron] = Colors.Black; - pauldron_trim=0; - specialist_colours=0; - } - // Dark Angels Captains - if (unit_chapter == "Dark Angels" && unit_role == _role[eROLE.Captain] && company != 1){ - shader_array_set[ShaderType.RightPauldron] = Colors.Dark_Red; - shader_array_set[ShaderType.Helmet] = Colors.Deathwing; - pauldron_trim=0; - specialist_colours=0; - } + // Dark Angels Ravenwing + if (unit_special_colours == UnitSpecialColours.Ravenwing) { + if (!array_contains([_role[eROLE.Chaplain], _role[eROLE.Librarian], _role[eROLE.Techmarine], _role[eROLE.Apothecary]], unit_role)) { + shader_array_set[ShaderType.Body] = Colors.Black; + shader_array_set[ShaderType.Helmet] = Colors.Black; + } + if (!array_contains([_role[eROLE.Chaplain], _role[eROLE.Techmarine]], unit_role)) { + shader_array_set[ShaderType.RightPauldron] = Colors.Black; + } + shader_array_set[ShaderType.LeftPauldron] = Colors.Black; + pauldron_trim = 0; + specialist_colours = 0; + } - // Dark Angels Honour Guard - if (unit_chapter == "Dark Angels" && unit_role == _role[eROLE.HonourGuard]){ - shader_array_set[ShaderType.Body] = Colors.Deathwing; - shader_array_set[ShaderType.RightPauldron] = Colors.Deathwing; - shader_array_set[ShaderType.LeftPauldron] = Colors.Deathwing; - shader_array_set[ShaderType.Trim] = Colors.Copper; - pauldron_trim=0; - specialist_colours=0; - } - //We can return to the custom shader values at any time during draw doing this - set_shader_array(shader_array_set); - // Marine draw sequence - /* + // Dark Angels Captains + if (unit_chapter == "Dark Angels" && unit_role == _role[eROLE.Captain] && company != 1) { + shader_array_set[ShaderType.RightPauldron] = Colors.Dark_Red; + shader_array_set[ShaderType.Helmet] = Colors.Deathwing; + pauldron_trim = 0; + specialist_colours = 0; + } + + // Dark Angels Honour Guard + if (unit_chapter == "Dark Angels" && unit_role == _role[eROLE.HonourGuard]) { + shader_array_set[ShaderType.Body] = Colors.Deathwing; + shader_array_set[ShaderType.RightPauldron] = Colors.Deathwing; + shader_array_set[ShaderType.LeftPauldron] = Colors.Deathwing; + shader_array_set[ShaderType.Trim] = Colors.Copper; + pauldron_trim = 0; + specialist_colours = 0; + } + //We can return to the custom shader values at any time during draw doing this + set_shader_array(shader_array_set); + // Marine draw sequence + /* main secondary pauldron @@ -507,329 +510,352 @@ function scr_draw_unit_image(_background=false){ pauldron2 weapon */ - - //Rejoice! - // draw_sprite(spr_marine_base,img,x_surface_offset,y_surface_offset); - - if (unit_armour!=""){ - var yep=0; - if scr_has_adv("Devastator Doctrine"){ - dev_trait=1 - } - if (unit_specialization == UnitSpecialization.Techmarine){ - if (scr_has_adv("Tech-Brothers")){ - tech_brothers_trait=0 - } - } - }else { - armour_sprite=spr_weapon_blank; - }// Define armour - - // Draw the lights - if (unit_specialization == UnitSpecialization.Apothecary) and (unit_armour!="") and (back_equipment == BackType.None){ - if (unit_armour=="Terminator Armour") then draw_sprite(spr_gear_apoth,0,x_surface_offset,y_surface_offset-22); // for terminators - else draw_sprite(spr_gear_apoth,0,x_surface_offset,y_surface_offset-6); // for normal power armour - } - - // Draw Techmarine gear - if (servo_arm > 0 || servo_harness > 0) && (!arm_bypass) { - var arm_offset_y = 0; - if (unit_armour == "Terminator Armour" || unit_armour == "Tartaros") { - arm_offset_y -= 18; - } - - draw_sprite(servo_arm > 0? spr_servo_arm : spr_servo_harness, 0, x_surface_offset, y_surface_offset + arm_offset_y); - } - if (armour_type==ArmourType.None){ - if (unit_role=="Chapter Master" && unit_chapter=="Doom Benefactors") then skin_color=6; - - draw_sprite(spr_marine_base,skin_color,x_surface_offset,y_surface_offset); - - // if (skin_color!=6) then draw_sprite(spr_clothing_colors,clothing_style,x_surface_offset,y_surface_offset); - } else { - - var _complex_armours = ["MK3 Iron Armour", "Terminator Armour","Tartaros","MK7 Aquila", "Power Armour", "MK8 Errant","Artificer Armour", "MK4 Maximus", "MK5 Heresy", "MK6 Corvus", "Dreadnought", "Scout Armour"]; - if (array_contains(_complex_armours, unit_armour)){ - complex_set = new ComplexSet(self); - complex_livery = true; - } - - if (armour_type==ArmourType.Normal && complex_livery && unit_role==_role[2]){ - complex_set.add_group({ - right_leg : spr_artificer_right_leg, - left_leg : spr_artificer_left_leg, - chest_variants : spr_artificer_chest, - thorax_variants : spr_artificer_thorax, - mouth_variants : spr_artificer_mouth - }); - } - - // Draw the Iron Halo - if (halo==1 && !halo_bypass){ - var halo_offset_y = 0; - var halo_color=0; - var halo_type = 2; - if (array_contains(["Raven Guard", "Dark Angels"], unit_chapter)) { - halo_color = 1; - } - if (unit_armour=="Terminator Armour"){ - halo_type = 2; - halo_offset_y -= 20; - } else if (unit_armour=="Tartaros"){ - halo_type = 2; - halo_offset_y -= 20; - } - draw_sprite(spr_gear_halo,halo_type+halo_color,x_surface_offset,y_surface_offset+halo_offset_y); - } - - if (armour_type == ArmourType.Terminator && complex_livery){ - for (var part = 0; part < array_length(_body_parts); part++) { - if (struct_exists(body[$ _body_parts[part]], "bionic")) { - - var body_part = _body_parts[part]; - var bionic = body[$ body_part][$ "bionic"]; - switch (body_part) { - case "left_eye": - complex_set.add_to_area("left_eye", spr_indomitus_left_eye_bionic); - break; - - case "right_eye": - complex_set.add_to_area("right_eye", spr_indomitus_right_eye_bionic); - break; - - case "left_leg": - complex_set.add_to_area("left_leg", spr_indomitus_left_leg_bionic); - break; - - case "right_leg": - complex_set.add_to_area("right_leg", spr_indomitus_right_leg_bionic); - break; - } + //Rejoice! + // draw_sprite(spr_marine_base,img,x_surface_offset,y_surface_offset); - } - } - } - if (armour_type == ArmourType.Normal && (!robes_bypass || !robes_hood_bypass)) { - var robe_offset_x = 0; - var robe_offset_y = 0; - var hood_offset_x = 0; - var hood_offset_y = 0; - if (armour_type == ArmourType.Scout) { - robe_offset_x = 1; - robe_offset_y = 10; - hood_offset_x = 1; - hood_offset_y = 10; - } - if (struct_exists(body[$ "head"],"hood") && !robes_hood_bypass) { - draw_sprite(spr_marine_cloth_hood,0,x_surface_offset+hood_offset_x,y_surface_offset+hood_offset_y); - } - if (struct_exists(body[$ "torso"],"robes") && !robes_bypass) { - if (body.torso.robes == 0){ - complex_set.add_to_area("robe",spr_marine_robes); - } else if (body.torso.robes == 1) { - if (scr_has_disadv("Warp Tainted") && !modest_livery){ - complex_set.add_to_area("robes",spr_binders_robes); - } else { - complex_set.add_to_area("robes",spr_marine_robes); - } - } else { - complex_set.add_to_area("tabbard",spr_cloth_tabbard); + if (unit_armour != "") { + var yep = 0; + if (scr_has_adv("Devastator Doctrine")) { + dev_trait = 1; + } + if (unit_specialization == UnitSpecialization.Techmarine) { + if (scr_has_adv("Tech-Brothers")) { + tech_brothers_trait = 0; } - } - } - - if (armour_type==ArmourType.Normal && complex_livery){ - if (struct_exists(body[$ "right_leg"], "bionic")) { - complex_set.replace_area("right_leg",spr_bionic_leg_right); - } - } - if (armour_type==ArmourType.Normal && complex_livery){ - if (struct_exists(body[$ "left_leg"], "bionic")) { - complex_set.replace_area("left_leg",spr_bionic_leg_left); - } - } - - if (complex_livery){ - if (armour_type==ArmourType.Normal && psy_hood){ - complex_set.replace_area("crown", spr_psy_hood_complex); - } - for (var part = 0; part < array_length(_body_parts); part++) { - if (struct_exists(body[$ _body_parts[part]], "bionic")) { - if (armour_type == ArmourType.Normal) { + } + } else { + armour_sprite = spr_weapon_blank; + } // Define armour + + // Draw the lights + if ((unit_specialization == UnitSpecialization.Apothecary) && (unit_armour != "") && (back_equipment == BackType.None)) { + if (unit_armour == "Terminator Armour") { + draw_sprite(spr_gear_apoth, 0, x_surface_offset, y_surface_offset - 22); // for terminators + } else { + draw_sprite(spr_gear_apoth, 0, x_surface_offset, y_surface_offset - 6); + } // for normal power armour + } + + // Draw Techmarine gear + if ((servo_arm > 0 || servo_harness > 0) && (!arm_bypass)) { + var arm_offset_y = 0; + if (unit_armour == "Terminator Armour" || unit_armour == "Tartaros") { + arm_offset_y -= 18; + } + + draw_sprite(servo_arm > 0 ? spr_servo_arm : spr_servo_harness, 0, x_surface_offset, y_surface_offset + arm_offset_y); + } + + if (armour_type == ArmourType.None) { + if (unit_role == "Chapter Master" && unit_chapter == "Doom Benefactors") { + skin_color = 6; + } + + draw_sprite(spr_marine_base, skin_color, x_surface_offset, y_surface_offset); + + // if (skin_color!=6) then draw_sprite(spr_clothing_colors,clothing_style,x_surface_offset,y_surface_offset); + } else { + var _complex_armours = ["MK3 Iron Armour", "Terminator Armour", "Tartaros", "MK7 Aquila", "Power Armour", "MK8 Errant", "Artificer Armour", "MK4 Maximus", "MK5 Heresy", "MK6 Corvus", "Dreadnought", "Scout Armour"]; + if (array_contains(_complex_armours, unit_armour)) { + complex_set = new ComplexSet(self); + complex_livery = true; + } + + if (armour_type == ArmourType.Normal && complex_livery && unit_role == _role[2]) { + complex_set.add_group({ + right_leg: spr_artificer_right_leg, + left_leg: spr_artificer_left_leg, + chest_variants: spr_artificer_chest, + thorax_variants: spr_artificer_thorax, + mouth_variants: spr_artificer_mouth + }); + } + + // Draw the Iron Halo + if (halo == 1 && !halo_bypass) { + var halo_offset_y = 0; + var halo_color = 0; + var halo_type = 2; + if (array_contains(["Raven Guard", "Dark Angels"], unit_chapter)) { + halo_color = 1; + } + if (unit_armour == "Terminator Armour") { + halo_type = 2; + halo_offset_y -= 20; + } else if (unit_armour == "Tartaros") { + halo_type = 2; + halo_offset_y -= 20; + } + draw_sprite(spr_gear_halo, halo_type + halo_color, x_surface_offset, y_surface_offset + halo_offset_y); + } + + if (armour_type == ArmourType.Terminator && complex_livery) { + for (var part = 0; part < array_length(_body_parts); part++) { + if (struct_exists(body[$ _body_parts[part]], "bionic")) { var body_part = _body_parts[part]; var bionic = body[$ body_part][$ "bionic"]; switch (body_part) { case "left_eye": - complex_set.add_to_area("left_eye", spr_bionic_left_eyes); + complex_set.add_to_area("left_eye", spr_indomitus_left_eye_bionic); break; - + case "right_eye": - complex_set.add_to_area("right_eye", spr_bionic_right_eyes); + complex_set.add_to_area("right_eye", spr_indomitus_right_eye_bionic); + break; + + case "left_leg": + complex_set.add_to_area("left_leg", spr_indomitus_left_leg_bionic); + break; + + case "right_leg": + complex_set.add_to_area("right_leg", spr_indomitus_right_leg_bionic); break; - } } } } - } - // Draw torso - if (!armour_bypass){ - if (complex_livery){ - if (struct_exists(complex_set, "armour")){ - complex_set.x_surface_offset = x_surface_offset; - complex_set.y_surface_offset = y_surface_offset - complex_set.draw(); - } else if (specific_armour_sprite!="none"){ - if (sprite_exists(specific_armour_sprite)){ - draw_sprite(specific_armour_sprite,0,x_surface_offset,y_surface_offset); + if (armour_type == ArmourType.Normal && (!robes_bypass || !robes_hood_bypass)) { + var robe_offset_x = 0; + var robe_offset_y = 0; + var hood_offset_x = 0; + var hood_offset_y = 0; + if (armour_type == ArmourType.Scout) { + robe_offset_x = 1; + robe_offset_y = 10; + hood_offset_x = 1; + hood_offset_y = 10; + } + if (struct_exists(body[$ "head"], "hood") && !robes_hood_bypass) { + draw_sprite(spr_marine_cloth_hood, 0, x_surface_offset + hood_offset_x, y_surface_offset + hood_offset_y); + } + if (struct_exists(body[$ "torso"], "robes") && !robes_bypass) { + if (body.torso.robes == 0) { + complex_set.add_to_area("robe", spr_marine_robes); + } else if (body.torso.robes == 1) { + if (scr_has_disadv("Warp Tainted") && !modest_livery) { + complex_set.add_to_area("robes", spr_binders_robes); + } else { + complex_set.add_to_area("robes", spr_marine_robes); + } + } else { + complex_set.add_to_area("tabbard", spr_cloth_tabbard); } - } - } else{ - draw_sprite(armour_sprite,specialist_colours,x_surface_offset,y_surface_offset); - } - } else if (array_length(armour_draw)){ - draw_sprite(armour_draw[0], armour_draw[1],x_surface_offset,y_surface_offset); - } - - // Draw decals, features and other stuff - if (dev_trait>=10) and (!modest_livery) then draw_sprite(armour_sprite,dev_trait,x_surface_offset,y_surface_offset);// Devastator Doctrine battle damage - // if (tech_brothers_trait>=0) and (modest_livery=0) then draw_sprite(spr_gear_techb,tech_brothers_trait,x_surface_offset,y_surface_offset);// Tech-Brothers bling - //sgt helms - - // Apothecary Details - if (unit_specialization == UnitSpecialization.Apothecary){ - if (unit_armour=="Tartaros"){ - draw_sprite(spr_gear_apoth,1, x_surface_offset,y_surface_offset-6);// was y_draw-4 with old tartar - }else if (unit_armour=="Terminator Armour"){ - draw_sprite(spr_gear_apoth,1,x_surface_offset,y_surface_offset-6); - }else{ - draw_sprite(spr_gear_apoth,1,x_surface_offset,y_surface_offset); - } - if (gear() == "Narthecium"){ - if (armour_type==ArmourType.Normal) { - draw_sprite(spr_narthecium_2,0,x_surface_offset+66,y_surface_offset+5); - } else if (armour_type!=ArmourType.Normal && armour_type!=ArmourType.Dreadnought){ - draw_sprite(spr_narthecium_2,0,x_surface_offset+92,y_surface_offset+5); } } - } - } - // Draw Custom Helmets - if (armour_type==ArmourType.Normal && !armour_bypass){ - if (unit_role == _role[eROLE.Champion]) { - draw_sprite(spr_helm_decorations,1,x_surface_offset,y_surface_offset); + if (armour_type == ArmourType.Normal && complex_livery) { + if (struct_exists(body[$ "right_leg"], "bionic")) { + complex_set.replace_area("right_leg", spr_bionic_leg_right); + } + } + if (armour_type == ArmourType.Normal && complex_livery) { + if (struct_exists(body[$ "left_leg"], "bionic")) { + complex_set.replace_area("left_leg", spr_bionic_leg_left); + } + } + + if (complex_livery) { + if (armour_type == ArmourType.Normal && psy_hood) { + complex_set.replace_area("crown", spr_psy_hood_complex); + } + for (var part = 0; part < array_length(_body_parts); part++) { + if (struct_exists(body[$ _body_parts[part]], "bionic")) { + if (armour_type == ArmourType.Normal) { + var body_part = _body_parts[part]; + var bionic = body[$ body_part][$ "bionic"]; + switch (body_part) { + case "left_eye": + complex_set.add_to_area("left_eye", spr_bionic_left_eyes); + break; + + case "right_eye": + complex_set.add_to_area("right_eye", spr_bionic_right_eyes); + break; + } + } + } + } + } + // Draw torso + if (!armour_bypass) { + if (complex_livery) { + if (struct_exists(complex_set, "armour")) { + complex_set.x_surface_offset = x_surface_offset; + complex_set.y_surface_offset = y_surface_offset; + complex_set.draw(); + } else if (specific_armour_sprite != "none") { + if (sprite_exists(specific_armour_sprite)) { + draw_sprite(specific_armour_sprite, 0, x_surface_offset, y_surface_offset); + } + } + } else { + draw_sprite(armour_sprite, specialist_colours, x_surface_offset, y_surface_offset); + } + } else if (array_length(armour_draw)) { + draw_sprite(armour_draw[0], armour_draw[1], x_surface_offset, y_surface_offset); + } + + // Draw decals, features and other stuff + if ((dev_trait >= 10) && (!modest_livery)) { + draw_sprite(armour_sprite, dev_trait, x_surface_offset, y_surface_offset); + } // Devastator Doctrine battle damage + // if (tech_brothers_trait>=0) and (modest_livery=0) then draw_sprite(spr_gear_techb,tech_brothers_trait,x_surface_offset,y_surface_offset);// Tech-Brothers bling + //sgt helms + + // Apothecary Details + if (unit_specialization == UnitSpecialization.Apothecary) { + if (unit_armour == "Tartaros") { + draw_sprite(spr_gear_apoth, 1, x_surface_offset, y_surface_offset - 6); // was y_draw-4 with old tartar + } else if (unit_armour == "Terminator Armour") { + draw_sprite(spr_gear_apoth, 1, x_surface_offset, y_surface_offset - 6); + } else { + draw_sprite(spr_gear_apoth, 1, x_surface_offset, y_surface_offset); + } + if (gear() == "Narthecium") { + if (armour_type == ArmourType.Normal) { + draw_sprite(spr_narthecium_2, 0, x_surface_offset + 66, y_surface_offset + 5); + } else if (armour_type != ArmourType.Normal && armour_type != ArmourType.Dreadnought) { + draw_sprite(spr_narthecium_2, 0, x_surface_offset + 92, y_surface_offset + 5); + } + } + } } - if (unit_role == _role[eROLE.Sergeant] || unit_role == _role[eROLE.VeteranSergeant]) { - draw_sprite(spr_helm_decorations,1,x_surface_offset,y_surface_offset); + + // Draw Custom Helmets + if (armour_type == ArmourType.Normal && !armour_bypass) { + if (unit_role == _role[eROLE.Champion]) { + draw_sprite(spr_helm_decorations, 1, x_surface_offset, y_surface_offset); + } + if (unit_role == _role[eROLE.Sergeant] || unit_role == _role[eROLE.VeteranSergeant]) { + draw_sprite(spr_helm_decorations, 1, x_surface_offset, y_surface_offset); + } + } else if (unit_armour == "Terminator Armour" && !armour_bypass) { + if (unit_role == _role[eROLE.Champion]) { + draw_sprite(spr_helm_decorations, 0, x_surface_offset, y_surface_offset - 10); + } + if (unit_role == _role[eROLE.Sergeant] || unit_role == _role[eROLE.VeteranSergeant]) { + draw_sprite(spr_helm_decorations, 0, x_surface_offset, y_surface_offset - 10); + } } - } - else if (unit_armour=="Terminator Armour" && !armour_bypass){ - if (unit_role == _role[eROLE.Champion]) { - draw_sprite(spr_helm_decorations,0,x_surface_offset,y_surface_offset-10); + + var shield_offset_x = 0; + var shield_offset_y = 0; + if (unit_armour == "Terminator Armour") { + shield_offset_x = -15; + shield_offset_y = -10; + } else if (unit_armour == "Tartaros") { + shield_offset_x = -8; } - if (unit_role == _role[eROLE.Sergeant] || unit_role == _role[eROLE.VeteranSergeant]) { - draw_sprite(spr_helm_decorations,0,x_surface_offset,y_surface_offset-10); + if (gear() == "Combat Shield") { + if (unit_role == _role[eROLE.Champion]) { + draw_sprite(spr_gear_combat_shield, 1, x_surface_offset + shield_offset_x, y_surface_offset + shield_offset_y); + } else { + draw_sprite(spr_gear_combat_shield, 0, x_surface_offset + shield_offset_x, y_surface_offset + shield_offset_y); + } } - } - var shield_offset_x = 0; - var shield_offset_y = 0; - if (unit_armour=="Terminator Armour"){ - shield_offset_x = -15; - shield_offset_y = -10; - } else if (unit_armour=="Tartaros") { - shield_offset_x = -8; - } - if (gear() == "Combat Shield"){ - if (unit_role == _role[eROLE.Champion]){ - draw_sprite (spr_gear_combat_shield, 1, x_surface_offset + shield_offset_x, y_surface_offset + shield_offset_y); - } else { - draw_sprite (spr_gear_combat_shield, 0, x_surface_offset + shield_offset_x, y_surface_offset + shield_offset_y); + // Draw hands bellow the weapon sprite; + for (var i = 1; i <= 2; i++) { + if (!hand_on_top[i]) { + draw_unit_hands(x_surface_offset, y_surface_offset, armour_type, specialist_colours, hide_bionics, i); + } } - } - - // Draw hands bellow the weapon sprite; - for (var i = 1; i <= 2; i++) { - if (!hand_on_top[i]) then draw_unit_hands(x_surface_offset, y_surface_offset, armour_type, specialist_colours, hide_bionics, i); - } - // // Draw weapons + // // Draw weapons - if (!new_weapon_draw[1]) { - if (ui_weapon[1]!=0) and (sprite_exists(ui_weapon[1])){ - if (ui_twoh[1]==false) and (ui_twoh[2]==false){ - draw_sprite(ui_weapon[1],0,x_surface_offset+ui_xmod[1],y_surface_offset+ui_ymod[1]); - } - if (ui_twoh[1]==true){ - draw_sprite(ui_weapon[1],0,x_surface_offset+ui_xmod[1],y_surface_offset+ui_ymod[1]); - if (ui_force_both==true){ - if (specialist_colours<=1) then draw_sprite(ui_weapon[1],0,x_surface_offset+ui_xmod[1],y_surface_offset+ui_ymod[1]); - if (specialist_colours>=2) then draw_sprite(ui_weapon[1],1,x_surface_offset+ui_xmod[1],y_surface_offset+ui_ymod[1]); + if (!new_weapon_draw[1]) { + if ((ui_weapon[1] != 0) && sprite_exists(ui_weapon[1])) { + if ((ui_twoh[1] == false) && (ui_twoh[2] == false)) { + draw_sprite(ui_weapon[1], 0, x_surface_offset + ui_xmod[1], y_surface_offset + ui_ymod[1]); + } + if (ui_twoh[1] == true) { + draw_sprite(ui_weapon[1], 0, x_surface_offset + ui_xmod[1], y_surface_offset + ui_ymod[1]); + if (ui_force_both == true) { + if (specialist_colours <= 1) { + draw_sprite(ui_weapon[1], 0, x_surface_offset + ui_xmod[1], y_surface_offset + ui_ymod[1]); + } + if (specialist_colours >= 2) { + draw_sprite(ui_weapon[1], 1, x_surface_offset + ui_xmod[1], y_surface_offset + ui_ymod[1]); + } + } } } + } else { + if ((ui_weapon[1] != 0) && sprite_exists(ui_weapon[1])) { + draw_sprite(ui_weapon[1], 0, x_surface_offset + ui_xmod[1], y_surface_offset + ui_ymod[1]); + } } - } else { - if (ui_weapon[1]!=0) and (sprite_exists(ui_weapon[1])){ - draw_sprite(ui_weapon[1],0,x_surface_offset+ui_xmod[1],y_surface_offset+ui_ymod[1]); - } - } - if (!new_weapon_draw[2]) { - if (ui_weapon[2]!=0) and (sprite_exists(ui_weapon[2])) and ((ui_twoh[1]==false || ui_force_both==true)){ - if (ui_spec[2]==false){ - draw_sprite(ui_weapon[2],1,x_surface_offset+ui_xmod[2],y_surface_offset+ui_ymod[2]); + if (!new_weapon_draw[2]) { + if ((ui_weapon[2] != 0) && sprite_exists(ui_weapon[2]) && (ui_twoh[1] == false || ui_force_both == true)) { + if (ui_spec[2] == false) { + draw_sprite(ui_weapon[2], 1, x_surface_offset + ui_xmod[2], y_surface_offset + ui_ymod[2]); + } + if (ui_spec[2] == true) { + draw_sprite(ui_weapon[2], 1, x_surface_offset + ui_xmod[2], y_surface_offset + ui_ymod[2]); + } } - if (ui_spec[2]==true){ - draw_sprite(ui_weapon[2],1,x_surface_offset+ui_xmod[2],y_surface_offset+ui_ymod[2]); + } else { + if ((ui_weapon[2] != 0) && sprite_exists(ui_weapon[2])) { + draw_sprite_flipped(ui_weapon[2], 0, x_surface_offset + ui_xmod[2], y_surface_offset + ui_ymod[2]); } } - } else { - if (ui_weapon[2]!=0) and (sprite_exists(ui_weapon[2])){ - draw_sprite_flipped(ui_weapon[2],0,x_surface_offset+ui_xmod[2],y_surface_offset+ui_ymod[2]); - } - } + // Draw hands above the weapon sprite; + for (var i = 1; i <= 2; i++) { + if (hand_on_top[i]) { + draw_unit_hands(x_surface_offset, y_surface_offset, armour_type, specialist_colours, hide_bionics, i); + } + } - // Draw hands above the weapon sprite; - for (var i = 1; i <= 2; i++) { - if (hand_on_top[i]) then draw_unit_hands(x_surface_offset, y_surface_offset, armour_type, specialist_colours, hide_bionics, i); - } - - // if (reverent_guardians=1) then draw_sprite(spr_pack_brazier,1,x_surface_offset,y_surface_offset); - if (armour_type==ArmourType.Dreadnought){ - var left_arm = dreadnought_sprite_components(weapon_two()); - var colour_scheme = specialist_colours<=1 ? 0 : 1; - draw_sprite(left_arm,colour_scheme,x_surface_offset,y_surface_offset); - colour_scheme += 2; - var right_arm = dreadnought_sprite_components(weapon_one()); - draw_sprite(right_arm,colour_scheme,x_surface_offset,y_surface_offset); - } - /*}else{ + // if (reverent_guardians=1) then draw_sprite(spr_pack_brazier,1,x_surface_offset,y_surface_offset); + if (armour_type == ArmourType.Dreadnought) { + var left_arm = dreadnought_sprite_components(weapon_two()); + var colour_scheme = specialist_colours <= 1 ? 0 : 1; + draw_sprite(left_arm, colour_scheme, x_surface_offset, y_surface_offset); + colour_scheme += 2; + var right_arm = dreadnought_sprite_components(weapon_one()); + draw_sprite(right_arm, colour_scheme, x_surface_offset, y_surface_offset); + } + /*}else{ draw_set_color(c_gray); draw_text(0,0,string_hash_to_newline("Color swap shader#did not compile")); }*/ - // if (race()!="1"){draw_set_color(38144);draw_rectangle(0,x_surface_offset,y_surface_offset+166,0+231,0);} - } - }catch(_exception) { + // if (race()!="1"){draw_set_color(38144);draw_rectangle(0,x_surface_offset,y_surface_offset+166,0+231,0);} + } + } catch (_exception) { handle_exception(_exception); } draw_set_alpha(1); - if (name_role()!=""){ - if (race()=="3"){ - if (string_count("Techpriest",name_role())>0) then draw_sprite(spr_techpriest,0,x_surface_offset,y_surface_offset); - }else if (race()=="4"){ - if (string_count("Crusader",name_role())>0) then draw_sprite(spr_crusader,0,x_surface_offset,y_surface_offset); - }else if (race()=="5"){ - if (string_count("Sister of Battle",name_role())>0) then draw_sprite(spr_sister_of_battle,0,x_surface_offset,y_surface_offset); - if (string_count("Sister Hospitaler",name_role())>0) then draw_sprite(spr_sister_hospitaler,0,x_surface_offset,y_surface_offset); - }else if (race()=="6"){ - if (string_count("Ranger",name_role())>0) then draw_sprite(spr_eldar_hire,0,x_surface_offset,y_surface_offset); - if (string_count("Howling Banshee",name_role())>0) then draw_sprite(spr_eldar_hire,1,x_surface_offset,y_surface_offset); + if (name_role() != "") { + if (race() == "3") { + if (string_count("Techpriest", name_role()) > 0) { + draw_sprite(spr_techpriest, 0, x_surface_offset, y_surface_offset); + } + } else if (race() == "4") { + if (string_count("Crusader", name_role()) > 0) { + draw_sprite(spr_crusader, 0, x_surface_offset, y_surface_offset); + } + } else if (race() == "5") { + if (string_count("Sister of Battle", name_role()) > 0) { + draw_sprite(spr_sister_of_battle, 0, x_surface_offset, y_surface_offset); + } + if (string_count("Sister Hospitaler", name_role()) > 0) { + draw_sprite(spr_sister_hospitaler, 0, x_surface_offset, y_surface_offset); + } + } else if (race() == "6") { + if (string_count("Ranger", name_role()) > 0) { + draw_sprite(spr_eldar_hire, 0, x_surface_offset, y_surface_offset); + } + if (string_count("Howling Banshee", name_role()) > 0) { + draw_sprite(spr_eldar_hire, 1, x_surface_offset, y_surface_offset); + } + } + if (string_count("Skitarii", name_role()) > 0) { + draw_sprite(spr_skitarii, 0, x_surface_offset, y_surface_offset); } - if (string_count("Skitarii",name_role())>0) then draw_sprite(spr_skitarii,0,x_surface_offset,y_surface_offset); } surface_reset_target(); /*shader_set_uniform_i(shader_get_uniform(sReplaceColor, "u_blend_modes"), 2); @@ -838,17 +864,15 @@ function scr_draw_unit_image(_background=false){ //surface_free(unit_surface); shader_reset(); var _complex_sprite_names = struct_get_names(complex_set); - for (var i=0;i=array_length(formation_possible)){ - formation_current = 0; + + // Planet icon here + // draw_rectangle(xx+1084,yy+215,xx+1142,yy+273,0); + + // Formation + formation.x1 = x1 + 420; + formation.y1 = y1 + 80; + formation.str1 = $"Formation: {obj_controller.bat_formation[formation_possible[formation_current]]}"; + formation.update(); + formation.draw(); + if (formation.clicked()) { + formation_current++; + if (formation_current >= array_length(formation_possible)) { + formation_current = 0; + } } + + // Ships Are Up, Fuck Me + draw_set_color(c_gray); + draw_text(x1 + 40, 273, "Available Forces:"); } - - // Ships Are Up, Fuck Me - draw_set_color(c_gray); - draw_text(x1 + 40, 273, "Available Forces:"); - } - var e = 0; - var sigh = 0; - var sip = 1; - var column = 1; - var row = 1; - var x8 = 552; - var y8 = 299; - - var add_ground = 0; - - // Local force button; - - // Ship buttons; - if (purge != DropType.PurgeBombard){ - var _local_button = roster.local_button; - _local_button.x1 = x8 - _local_button.y1 = y8 - _local_button.update(); - _local_button.draw(); - if (_local_button.clicked()) { - roster.update_roster(); - } - } - y8 += 21; - - var _all_active = true; - - for (var e=0;e 0) { - loop_cycle += array_length(roster.vehicle_buttons); - } - var _squad_length = array_length(roster.squad_buttons); - var _button; - for (var i = 0; i < loop_cycle; i++){ - - if (i<_squad_length){ - _button = roster.squad_buttons[i]; - } else { - _button = roster.vehicle_buttons[i-_squad_length]; + _ship_button.x1 = x8; + _ship_button.y1 = y8; + _ship_button.update(); + _ship_button.draw(); + if (_ship_button.clicked()) { + roster.update_roster(); + } + if (_ship_button.hover()) { + roster.update_local_string(_ship_button.ship_id); + } + if (!_ship_button.active) { + _all_active = false; + } + y8 += 21; + if (e % 9 == 0 && e != 0) { + y8 = 320; + x8 = 700; + } } - if (_x_offset + _button.width > 590){ - _row++; - _x_offset = 0; - } - _button.x1 = (_squads_box.x1) + _x_offset; - _button.y1 = (_squads_box.y1 + string_height(_squads_box.header) + 10) + _row * 28; - _button.update(); - _button.draw(); + var _select_all_button = roster.select_all_ships; - if (_button.clicked()) { + if (_select_all_button.draw()) { + for (var e = 0; e < array_length(roster.ships); e++) { + var _ship_button = roster.ships[e]; + _ship_button.active = !_ship_button.active; + } roster.update_roster(); } + draw_set_font(fnt_40k_14); + draw_set_color(c_gray); + draw_set_alpha(1); - _x_offset += _button.width +10; - } - - // draw_text(x2 + 14, y2 + 352, string_hash_to_newline("Selection: " + string(smin) + "/" + string(smax))); - - // Target - var race_quantity = 0; - if (purge == DropType.RaidAttack){ - var target_race = "", - target_threat = "", - race_quantity = 0; - var races = ["", "Ecclesiarchy", "Eldar", "Orks", "Tau", "Tyranids", "Heretics", "CSMs", "Daemons", "Necrons"]; - var threat_levels = ["", "Minima (1)", "Parvus (2)", "Moderatus (3)", "Significus (4)", "Enormicus (5)", "Extremis (6)"]; - var race_quantities = [0, sisters, eldar, ork, tau, tyranids, traitors, csm, demons, necrons]; - - if (attacking >= 5 && attacking <= 13) { - race_quantity = race_quantities[attacking - 4]; - target_race = races[attacking - 4]; + // Unit types buttons; + var _squads_box = { + header: "Selected Squads:", + x1: x1 + 40, + y1: y2 - 180 + }; + draw_text(_squads_box.x1, _squads_box.y1, _squads_box.header); + var _x_offset = 0; + var _row = 0; + var loop_cycle = array_length(roster.squad_buttons); + if (array_length(roster.vehicle_buttons) > 0) { + loop_cycle += array_length(roster.vehicle_buttons); } + var _squad_length = array_length(roster.squad_buttons); + var _button; + for (var i = 0; i < loop_cycle; i++) { + if (i < _squad_length) { + _button = roster.squad_buttons[i]; + } else { + _button = roster.vehicle_buttons[i - _squad_length]; + } - if (race_quantity >= 1 && race_quantity <= 6) { - target_threat = threat_levels[race_quantity]; - } else if (race_quantity >= 6) { - target_threat = threat_levels[6]; - } - target.x1 = formation.x1; - target.y1 = formation.y2 + 10; - target.str1 = "Target: "; - if (race_quantity != 0) { - target.str1 += $"{target_race} ({target_threat} Threat)"; - } else { - target.str1 += "None"; + if (_x_offset + _button.width > 590) { + _row++; + _x_offset = 0; + } + _button.x1 = _squads_box.x1 + _x_offset; + _button.y1 = (_squads_box.y1 + string_height(_squads_box.header) + 10) + _row * 28; + _button.update(); + _button.draw(); + + if (_button.clicked()) { + roster.update_roster(); + } + + _x_offset += _button.width + 10; } - target.update(); - target.draw(); - draw_sprite(spr_faction_icons, attacking, x2 - 100, y1 + 40); - var q = 0; - repeat(20) { - q += 1; - if (target.clicked() && force_present[q] != 0) { - if (attacking != force_present[q] && force_present[q] > 0) { - attacking = force_present[q]; + + // draw_text(x2 + 14, y2 + 352, string_hash_to_newline("Selection: " + string(smin) + "/" + string(smax))); + + // Target + var race_quantity = 0; + if (purge == DropType.RaidAttack) { + var target_race = "", + target_threat = "", + race_quantity = 0; + var races = ["", "Ecclesiarchy", "Eldar", "Orks", "Tau", "Tyranids", "Heretics", "CSMs", "Daemons", "Necrons"]; + var threat_levels = ["", "Minima (1)", "Parvus (2)", "Moderatus (3)", "Significus (4)", "Enormicus (5)", "Extremis (6)"]; + var race_quantities = [0, sisters, eldar, ork, tau, tyranids, traitors, csm, demons, necrons]; + + if (attacking >= 5 && attacking <= 13) { + race_quantity = race_quantities[attacking - 4]; + target_race = races[attacking - 4]; + } + + if (race_quantity >= 1 && race_quantity <= 6) { + target_threat = threat_levels[race_quantity]; + } else if (race_quantity >= 6) { + target_threat = threat_levels[6]; + } + target.x1 = formation.x1; + target.y1 = formation.y2 + 10; + target.str1 = "Target: "; + if (race_quantity != 0) { + target.str1 += $"{target_race} ({target_threat} Threat)"; + } else { + target.str1 += "None"; + } + target.update(); + target.draw(); + draw_sprite(spr_faction_icons, attacking, x2 - 100, y1 + 40); + var q = 0; + repeat(20) { + q += 1; + if (target.clicked() && force_present[q] != 0) { + if (attacking != force_present[q] && force_present[q] > 0) { + attacking = force_present[q]; + } } } + target.locked = force_present[q] == 0; } - target.locked = (force_present[q] == 0); - } - // Back / Purge buttons - btn_back.x1 = x3 - 100; - btn_back.y1 = y2 - 60; - btn_back.update(); - btn_back.draw(); - if (btn_back.clicked()) { - menu = 0; - purge = 0; - instance_destroy(); - } + // Back / Purge buttons + btn_back.x1 = x3 - 100; + btn_back.y1 = y2 - 60; + btn_back.update(); + btn_back.draw(); + if (btn_back.clicked()) { + menu = 0; + purge = 0; + instance_destroy(); + } - // Attack / Raid buttons - btn_attack.x1 = btn_back.x1 + btn_attack.width + 10; - btn_attack.y1 = btn_back.y1; - if (purge == DropType.RaidAttack){ - btn_attack.str1 = (attack) ? "ATTACK!": "RAID!" - btn_attack.active = (array_length(roster.selected_units) > 0 && race_quantity > 0); - } - else if (purge>1){ - btn_attack.str1 = "PURGE" - btn_attack.active = (array_length(roster.selected_units) > 0) - } - btn_attack.update(); - btn_attack.draw(); - if (btn_attack.clicked()) { - if (purge == 0){ - combating = 1; // Start battle here - - if (attack = 1) then obj_controller.last_attack_form = formation_possible[formation_current]; - if (attack = 0) then obj_controller.last_raid_form = formation_possible[formation_current]; - - instance_deactivate_all(true); - instance_activate_object(obj_controller); - instance_activate_object(obj_ini); - instance_activate_object(obj_drop_select); - - // 135 ; temporary balancing - if (sh_target != -50) { - sh_target.acted += 1; - } + // Attack / Raid buttons + btn_attack.x1 = btn_back.x1 + btn_attack.width + 10; + btn_attack.y1 = btn_back.y1; + if (purge == DropType.RaidAttack) { + btn_attack.str1 = (attack) ? "ATTACK!" : "RAID!"; + btn_attack.active = array_length(roster.selected_units) > 0 && race_quantity > 0; + } else if (purge > 1) { + btn_attack.str1 = "PURGE"; + btn_attack.active = array_length(roster.selected_units) > 0; + } + btn_attack.update(); + btn_attack.draw(); + if (btn_attack.clicked()) { + if (purge == 0) { + combating = 1; // Start battle here + + if (attack == 1) { + obj_controller.last_attack_form = formation_possible[formation_current]; + } + if (attack == 0) { + obj_controller.last_raid_form = formation_possible[formation_current]; + } - if (attacking == 10) or (attacking == 11) { - remove_planet_problem(planet_number, "meeting", p_target); - remove_planet_problem(planet_number, "meeting_trap", p_target); - } + instance_deactivate_all(true); + instance_activate_object(obj_controller); + instance_activate_object(obj_ini); + instance_activate_object(obj_drop_select); - instance_create(0, 0, obj_ncombat); - obj_ncombat.battle_object = p_target; - obj_ncombat.battle_loc = p_target.name; - obj_ncombat.battle_id = planet_number; - obj_ncombat.dropping = 1 - attack; - obj_ncombat.attacking = attack; - obj_ncombat.enemy = attacking; - obj_ncombat.formation_set = formation_possible[formation_current]; - obj_ncombat.defending = false; - obj_ncombat.local_forces = roster.local_button.active - - var _planet = obj_ncombat.battle_object.p_feature[obj_ncombat.battle_id] - if (obj_ncombat.battle_object.space_hulk = 1) then obj_ncombat.battle_special = "space_hulk"; - if (planet_feature_bool(_planet, P_features.Warlord6) == 1) and(obj_ncombat.enemy = 6) and(obj_controller.faction_defeated[6] = 0) then obj_ncombat.leader = 1; - if (obj_ncombat.enemy = 7) and(obj_controller.faction_defeated[7] <= 0) { - if (planet_feature_bool(_planet, P_features.OrkWarboss)) { - obj_ncombat.leader = 1; - obj_ncombat.Warlord = _planet[search_planet_features(_planet, P_features.OrkWarboss)[0]]; + // 135 ; temporary balancing + if (sh_target != -50) { + sh_target.acted += 1; } - } - if (obj_ncombat.enemy = 9) and(obj_ncombat.battle_object.space_hulk = 0) { - if (has_problem_planet(planet_number, "tyranid_org", p_target)) then obj_ncombat.battle_special = "tyranid_org"; - } + if ((attacking == 10) || (attacking == 11)) { + remove_planet_problem(planet_number, "meeting", p_target); + remove_planet_problem(planet_number, "meeting_trap", p_target); + } - if (obj_ncombat.enemy = 11) { - if (planet_feature_bool(obj_ncombat.battle_object.p_feature[obj_ncombat.battle_id], P_features.World_Eaters) == 1) { - obj_ncombat.battle_special = "world_eaters"; + instance_create(0, 0, obj_ncombat); + obj_ncombat.battle_object = p_target; + obj_ncombat.battle_loc = p_target.name; + obj_ncombat.battle_id = planet_number; + obj_ncombat.dropping = 1 - attack; + obj_ncombat.attacking = attack; + obj_ncombat.enemy = attacking; + obj_ncombat.formation_set = formation_possible[formation_current]; + obj_ncombat.defending = false; + obj_ncombat.local_forces = roster.local_button.active; + + var _planet = obj_ncombat.battle_object.p_feature[obj_ncombat.battle_id]; + if (obj_ncombat.battle_object.space_hulk == 1) { + obj_ncombat.battle_special = "space_hulk"; + } + if ((planet_feature_bool(_planet, P_features.Warlord6) == 1) && (obj_ncombat.enemy == 6) && (obj_controller.faction_defeated[6] == 0)) { obj_ncombat.leader = 1; } - } + if ((obj_ncombat.enemy == 7) && (obj_controller.faction_defeated[7] <= 0)) { + if (planet_feature_bool(_planet, P_features.OrkWarboss)) { + obj_ncombat.leader = 1; + obj_ncombat.Warlord = _planet[search_planet_features(_planet, P_features.OrkWarboss)[0]]; + } + } - var _threats = [0,0,0,0,0,sisters,eldar,ork,tau, tyranids, traitors,csm, demons, necrons]; - if (obj_ncombat.enemy >=5 && obj_ncombat.enemy<=13){ - obj_ncombat.threat = _threats[obj_ncombat.enemy]; - } + if ((obj_ncombat.enemy == 9) && (obj_ncombat.battle_object.space_hulk == 0)) { + if (has_problem_planet(planet_number, "tyranid_org", p_target)) { + obj_ncombat.battle_special = "tyranid_org"; + } + } - if (obj_ncombat.enemy = 8) { - var eth; - eth = 0; - eth = scr_quest(4, "ethereal_capture", 8, 0); - if (eth > 0) and(obj_ncombat.battle_object.p_owner[obj_ncombat.battle_id] = 8) { - var rolli; - rolli = irandom_range(1, 100) - if (obj_ncombat.threat = 6) and(rolli <= 80) then obj_ncombat.ethereal = 1; - if (obj_ncombat.threat = 5) and(rolli <= 65) then obj_ncombat.ethereal = 1; - if (obj_ncombat.threat = 4) and(rolli <= 50) then obj_ncombat.ethereal = 1; - if (obj_ncombat.threat = 3) and(rolli <= 35) then obj_ncombat.ethereal = 1; + if (obj_ncombat.enemy == 11) { + if (planet_feature_bool(obj_ncombat.battle_object.p_feature[obj_ncombat.battle_id], P_features.World_Eaters) == 1) { + obj_ncombat.battle_special = "world_eaters"; + obj_ncombat.leader = 1; + } + } + + var _threats = [0, 0, 0, 0, 0, sisters, eldar, ork, tau, tyranids, traitors, csm, demons, necrons]; + if (obj_ncombat.enemy >= 5 && obj_ncombat.enemy <= 13) { + obj_ncombat.threat = _threats[obj_ncombat.enemy]; } - // show_message("Ethereal Quest?: "+string(eth)+"#Ethereal?: "+string(obj_ncombat.ethereal)); - } - // if (obj_ncombat.threat>1) and (obj_ncombat.enemy!=13) then obj_ncombat.threat-=1; - if (obj_ncombat.threat > 1) and(obj_ncombat.battle_special != "world_eaters") and(attack = 0) then obj_ncombat.threat -= 1; - if (obj_ncombat.threat < 1) then obj_ncombat.threat = 1; - if (obj_ncombat.enemy = 10) and(obj_ncombat.battle_object.p_type[obj_ncombat.battle_id] = "Daemon") then obj_ncombat.threat = 7; - - var _battle_place = obj_ncombat.battle_object; - var _battle_sub_loc = obj_ncombat.battle_id; - var _chaos_lord_jump_possible = (attacking = 0|| attacking = 10|| attacking = 11); - var _no_know_chaos = (_battle_place.p_traitors[_battle_sub_loc] == 0 && _battle_place.p_chaos[_battle_sub_loc] == 0); - - var _chaos_warlord_present = planet_feature_bool(_battle_place.p_feature[obj_ncombat.battle_id], P_features.Warlord10); - - var _chaos_popup_turn_reached = obj_controller.turn >= obj_controller.chaos_turn; - - var _chaos_unknown = (obj_controller.known[eFACTION.Chaos] == 0) and (obj_controller.faction_gender[10] = 1); - - if (_chaos_lord_jump_possible && _no_know_chaos) { - if (_chaos_popup_turn_reached && _chaos_warlord_present){ - if (_chaos_unknown) { - var pop; - pop = instance_create(0, 0, obj_popup); - pop.image = "chaos_symbol"; - pop.title = "Concealed Heresy"; - pop.text = $"Your astartes set out and begin to cleanse {planet_numeral_name(_battle_sub_loc,_battle_place)} of possible heresy. The general populace appears to be devout in their faith, but a disturbing trend appears- the odd citizen cursing your forces, frothing at the mouth, and screaming out heresy most foul. One week into the cleansing a large hostile force is detected approaching and encircling your forces."; - cancel_combat(); - combating = 0; - instance_activate_all(); - exit; - + if (obj_ncombat.enemy == 8) { + var eth; + eth = 0; + eth = scr_quest(4, "ethereal_capture", 8, 0); + if ((eth > 0) && (obj_ncombat.battle_object.p_owner[obj_ncombat.battle_id] == 8)) { + var rolli; + rolli = irandom_range(1, 100); + if ((obj_ncombat.threat == 6) && (rolli <= 80)) { + obj_ncombat.ethereal = 1; + } + if ((obj_ncombat.threat == 5) && (rolli <= 65)) { + obj_ncombat.ethereal = 1; + } + if ((obj_ncombat.threat == 4) && (rolli <= 50)) { + obj_ncombat.ethereal = 1; + } + if ((obj_ncombat.threat == 3) && (rolli <= 35)) { + obj_ncombat.ethereal = 1; + } } - if (obj_controller.known[eFACTION.Chaos] >= 2 && obj_controller.faction_gender[10] = 1){ - with(obj_drop_select) { - obj_ncombat.enemy = 11; - obj_ncombat.threat = 0; + // show_message("Ethereal Quest?: "+string(eth)+"#Ethereal?: "+string(obj_ncombat.ethereal)); + } + + // if (obj_ncombat.threat>1) and (obj_ncombat.enemy!=13) then obj_ncombat.threat-=1; + if ((obj_ncombat.threat > 1) && (obj_ncombat.battle_special != "world_eaters") && (attack == 0)) { + obj_ncombat.threat -= 1; + } + if (obj_ncombat.threat < 1) { + obj_ncombat.threat = 1; + } + if ((obj_ncombat.enemy == 10) && (obj_ncombat.battle_object.p_type[obj_ncombat.battle_id] == "Daemon")) { + obj_ncombat.threat = 7; + } + + var _battle_place = obj_ncombat.battle_object; + var _battle_sub_loc = obj_ncombat.battle_id; + var _chaos_lord_jump_possible = attacking == 0 || attacking == 10 || attacking == 11; + var _no_know_chaos = _battle_place.p_traitors[_battle_sub_loc] == 0 && _battle_place.p_chaos[_battle_sub_loc] == 0; + + var _chaos_warlord_present = planet_feature_bool(_battle_place.p_feature[obj_ncombat.battle_id], P_features.Warlord10); + + var _chaos_popup_turn_reached = obj_controller.turn >= obj_controller.chaos_turn; + + var _chaos_unknown = (obj_controller.known[eFACTION.Chaos] == 0) && (obj_controller.faction_gender[10] == 1); + + if (_chaos_lord_jump_possible && _no_know_chaos) { + if (_chaos_popup_turn_reached && _chaos_warlord_present) { + if (_chaos_unknown) { + var pop; + pop = instance_create(0, 0, obj_popup); + pop.image = "chaos_symbol"; + pop.title = "Concealed Heresy"; + pop.text = $"Your astartes set out and begin to cleanse {planet_numeral_name(_battle_sub_loc, _battle_place)} of possible heresy. The general populace appears to be devout in their faith, but a disturbing trend appears- the odd citizen cursing your forces, frothing at the mouth, and screaming out heresy most foul. One week into the cleansing a large hostile force is detected approaching and encircling your forces."; cancel_combat(); combating = 0; - instance_destroy(); instance_activate_all(); exit; } + if (obj_controller.known[eFACTION.Chaos] >= 2 && obj_controller.faction_gender[10] == 1) { + with(obj_drop_select) { + obj_ncombat.enemy = 11; + obj_ncombat.threat = 0; + cancel_combat(); + combating = 0; + instance_destroy(); + instance_activate_all(); + exit; + } + } } } - } - scr_battle_allies(); - setup_battle_formations(); - roster.add_to_battle(); - } else if (purge >1){ - draw_set_alpha(0.2); - draw_rectangle(954, 556, 1043, 579, 0); - draw_set_alpha(1); - var _purge_score=0; - if (purge == 2) { - _purge_score = roster.purge_bombard_score(); - } + scr_battle_allies(); + setup_battle_formations(); + roster.add_to_battle(); + } else if (purge > 1) { + draw_set_alpha(0.2); + draw_rectangle(954, 556, 1043, 579, 0); + draw_set_alpha(1); + var _purge_score = 0; + if (purge == 2) { + _purge_score = roster.purge_bombard_score(); + } - if (purge >= 3) { - _purge_score = array_length(roster.selected_units); - } + if (purge >= 3) { + _purge_score = array_length(roster.selected_units); + } - scr_purge_world(p_target, planet_number, purge , _purge_score); + scr_purge_world(p_target, planet_number, purge, _purge_score); + } } } - } + // Purge shit happens bellow; + // God, save us; + if (menu == 0) { + if (purge == 1) {} else if (purge >= 2) { + draw_set_halign(fa_center); + draw_set_font(fnt_40k_30b); - // Purge shit happens bellow; - // God, save us; - if (menu == 0) { - if (purge == 1) { - - - } else if (purge >= 2) { - draw_set_halign(fa_center); - draw_set_font(fnt_40k_30b); + // 2 is bombardment - // 2 is bombardment + var x2 = 535; + var y2 = 200; - var x2 = 535; - var y2 = 200; + draw_set_halign(fa_left); + draw_set_color(c_gray); + var _purge_strings = ["Bombard Purging {0}", "Fire Cleansing {0}", "Selective Purging {0}", "Assassinate Governor ({0})"]; + var _planet_string = planet_numeral_name(planet_number, p_target); + draw_text_transformed(x2 + 14, y2 + 12, string(_purge_strings[purge - 2], _planet_string), 0.6, 0.6, 0); - draw_set_halign(fa_left); - draw_set_color(c_gray); - var _purge_strings = ["Bombard Purging {0}", "Fire Cleansing {0}","Selective Purging {0}", "Assassinate Governor ({0})"]; - var _planet_string = planet_numeral_name(planet_number, p_target); - draw_text_transformed(x2 + 14, y2 + 12, string(_purge_strings[purge-2],_planet_string), 0.6, 0.6, 0); + // Disposition here + var succession = 0, + pp = planet_number; + + var succession = has_problem_planet(pp, "succession", p_target); + + if (((p_target.dispo[pp] >= 0) && (p_target.p_owner[pp] <= 5) && (p_target.p_population[pp] > 0)) && (!succession)) { + var wack = 0; + draw_set_color(c_blue); + draw_rectangle(x2 + 12, y2 + 53, x2 + 12 + max(0, (min(100, p_target.dispo[pp]) * 4.37)), y2 + 71, 0); + } + draw_set_color(c_gray); + draw_rectangle(x2 + 12, y2 + 53, x2 + 449, y2 + 71, 1); + draw_set_color(c_white); + + draw_set_font(fnt_40k_14b); + draw_set_halign(fa_center); + if (!succession) { + if ((p_target.dispo[pp] >= 0) && (p_target.p_first[pp] <= 5) && (p_target.p_owner[pp] <= 5) && (p_target.p_population[pp] > 0)) { + draw_text(x2 + 231, y2 + 54, string_hash_to_newline("Disposition: " + string(min(100, p_target.dispo[pp])) + "/100")); + } + if ((p_target.dispo[pp] > -30) && (p_target.dispo[pp] < 0) && (p_target.p_owner[pp] <= 5) && (p_target.p_population[pp] > 0)) { + draw_text(x2 + 231, y2 + 54, string_hash_to_newline("Disposition: ???/100")); + } + if (((p_target.dispo[pp] >= 0) && (p_target.p_first[pp] <= 5) && (p_target.p_owner[pp] > 5)) || (p_target.p_population[pp] <= 0)) { + draw_text(x2 + 231, y2 + 54, string_hash_to_newline("-------------")); + } + if (p_target.dispo[pp] <= -3000) { + draw_text(x2 + 231, y2 + 54, "Chapter Rule"); + } + } + if (succession == 1) { + draw_text(x2 + 231, y2 + 54, "War of Succession"); + } + + draw_set_color(c_gray); + draw_set_font(fnt_40k_14); + draw_set_halign(fa_left); + + // Planet icon here + draw_rectangle(x2 + 459, y2 + 14, x2 + 516, y2 + 71, 0); - // Disposition here - var succession = 0, - pp = planet_number + draw_set_font(fnt_40k_14); + draw_set_color(c_gray); + draw_set_alpha(1); - var succession = has_problem_planet(pp, "succession", p_target); + var smin, smax; + var w; + w = -1; + smin = 0; + smax = 0; - if ((p_target.dispo[pp] >= 0) and(p_target.p_owner[pp] <= 5) and(p_target.p_population[pp] > 0)) and (!succession) { - var wack = 0; - draw_set_color(c_blue); - draw_rectangle(x2 + 12, y2 + 53, x2 + 12 + max(0, (min(100, p_target.dispo[pp]) * 4.37)), y2 + 71, 0); + //draw_text(x2 + 14, y2 + 352, string_hash_to_newline("Selection: " + string(smin) + "/" + string(smax))); } - draw_set_color(c_gray); - draw_rectangle(x2 + 12, y2 + 53, x2 + 449, y2 + 71, 1); - draw_set_color(c_white); - - draw_set_font(fnt_40k_14b); - draw_set_halign(fa_center); - if (!succession) { - if (p_target.dispo[pp] >= 0) and(p_target.p_first[pp] <= 5) and(p_target.p_owner[pp] <= 5) and(p_target.p_population[pp] > 0) then draw_text(x2 + 231, y2 + 54, string_hash_to_newline("Disposition: " + string(min(100, p_target.dispo[pp])) + "/100")); - if (p_target.dispo[pp] > -30) and(p_target.dispo[pp] < 0) and(p_target.p_owner[pp] <= 5) and(p_target.p_population[pp] > 0) then draw_text(x2 + 231, y2 + 54, string_hash_to_newline("Disposition: ???/100")); - if ((p_target.dispo[pp] >= 0) and(p_target.p_first[pp] <= 5) and(p_target.p_owner[pp] > 5)) or(p_target.p_population[pp] <= 0) then draw_text(x2 + 231, y2 + 54, string_hash_to_newline("-------------")); - if (p_target.dispo[pp] <= -3000) then draw_text(x2 + 231, y2 + 54, "Chapter Rule"); + } + } +} + +function collect_local_units() { + // + // I think this script is used to count local forces. l_ meaning local. + // + ship_use[500] = 0; + ship_max[500] = l_size; + purge_d = ship_max[500]; + + if (purge == 1) { + if (sh_target != -50) { + max_ships = sh_target.capital_number + sh_target.frigate_number + sh_target.escort_number; + + if (sh_target.acted >= 1) { + instance_destroy(); } - if (succession = 1) then draw_text(x2 + 231, y2 + 54, "War of Succession"); - draw_set_color(c_gray); - draw_set_font(fnt_40k_14); - draw_set_halign(fa_left); + var tump; + tump = 0; + + var i, q, b; + i = -1; + q = -1; + b = -1; + repeat(sh_target.capital_number) { + b += 1; + if (sh_target.capital[b] != "") { + i += 1; + ship[i] = sh_target.capital[i]; + + ship_use[i] = 0; + tump = sh_target.capital_num[i]; + ship_max[i] = obj_ini.ship_carrying[tump]; + ship_ide[i] = tump; + + ship_size[i] = 3; + + purge_a += 3; + purge_b += ship_max[i]; + purge_c += ship_max[i]; + purge_d += ship_max[i]; + } + } + q = -1; + repeat(sh_target.frigate_number) { + q += 1; + if (sh_target.frigate[q] != "") { + i += 1; + ship[i] = sh_target.frigate[q]; - // Planet icon here - draw_rectangle(x2 + 459, y2 + 14, x2 + 516, y2 + 71, 0); + ship_use[i] = 0; + tump = sh_target.frigate_num[q]; + ship_max[i] = obj_ini.ship_carrying[tump]; + ship_ide[i] = tump; - draw_set_font(fnt_40k_14); - draw_set_color(c_gray); - draw_set_alpha(1); + ship_size[i] = 2; + + purge_a += 1; + purge_b += ship_max[i]; + purge_c += ship_max[i]; + purge_d += ship_max[i]; + } + } + q = -1; + repeat(sh_target.escort_number) { + q += 1; + if ((sh_target.escort[q] != "") && (obj_ini.ship_carrying[sh_target.escort_num[q]] > 0)) { + i += 1; + ship[i] = sh_target.escort[q]; + ship_use[i] = 0; + tump = sh_target.escort_num[q]; + ship_max[i] = obj_ini.ship_carrying[tump]; + ship_ide[i] = tump; - var smin, smax; - var w; - w = -1; - smin = 0; - smax = 0; + ship_size[i] = 1; + purge_b += ship_max[i]; + purge_c += ship_max[i]; + purge_d += ship_max[i]; + } + } + } - //draw_text(x2 + 14, y2 + 352, string_hash_to_newline("Selection: " + string(smin) + "/" + string(smax))); + if (p_target.p_player[planet_number] > 0) { + max_ships += 1; } - } -} -} + var pp = planet_number; + purge_d = p_target.p_type[pp] != "Dead"; -function collect_local_units(){ - // - // I think this script is used to count local forces. l_ meaning local. - // - ship_use[500]=0; - ship_max[500]=l_size; - purge_d=ship_max[500]; - - if (purge==1) - { - - - - - if (sh_target!=-50){ - - max_ships=sh_target.capital_number+sh_target.frigate_number+sh_target.escort_number; - - - if (sh_target.acted>=1) then instance_destroy(); - - var tump;tump=0; - - var i, q, b;i=-1;q=-1;b=-1; - repeat(sh_target.capital_number){ - b+=1; - if (sh_target.capital[b]!=""){ - i+=1; - ship[i]=sh_target.capital[i]; - - ship_use[i]=0; - tump=sh_target.capital_num[i]; - ship_max[i]=obj_ini.ship_carrying[tump]; - ship_ide[i]=tump; - - ship_size[i]=3; - - purge_a+=3; - purge_b+=ship_max[i];purge_c+=ship_max[i];purge_d+=ship_max[i]; - } - } - q=-1; - repeat(sh_target.frigate_number){ - q+=1; - if (sh_target.frigate[q]!=""){ - i+=1; - ship[i]=sh_target.frigate[q]; - - ship_use[i]=0; - tump=sh_target.frigate_num[q]; - ship_max[i]=obj_ini.ship_carrying[tump]; - ship_ide[i]=tump; - - ship_size[i]=2; - - purge_a+=1; - purge_b+=ship_max[i]; - purge_c+=ship_max[i]; - purge_d+=ship_max[i]; - } - } - q=-1; - repeat(sh_target.escort_number){ - q+=1; - if (sh_target.escort[q]!="") and (obj_ini.ship_carrying[sh_target.escort_num[q]]>0){ - i+=1; - ship[i]=sh_target.escort[q]; - - ship_use[i]=0; - tump=sh_target.escort_num[q]; - ship_max[i]=obj_ini.ship_carrying[tump]; - ship_ide[i]=tump; - - ship_size[i]=1; - - purge_b+=ship_max[i]; - purge_c+=ship_max[i]; - purge_d+=ship_max[i]; - } - } - - } - - if (p_target.p_player[planet_number]>0) then max_ships+=1; - var pp=planet_number; - purge_d = p_target.p_type[pp]!="Dead"; - - if (has_problem_planet(pp,"succession",p_target)) then purge_d=0 - - if (p_target.dispo[pp]<-2000) then purge_d=0; - - if (planet_feature_bool(p_target.p_feature[pp],P_features.Monastery)==1) and (obj_controller.homeworld_rule!=1) then purge_d=0; - - if (p_target.p_type[pp]="Dead") then purge_d=0; - - - } -} + if (has_problem_planet(pp, "succession", p_target)) { + purge_d = 0; + } + + if (p_target.dispo[pp] < -2000) { + purge_d = 0; + } + if ((planet_feature_bool(p_target.p_feature[pp], P_features.Monastery) == 1) && (obj_controller.homeworld_rule != 1)) { + purge_d = 0; + } + if (p_target.p_type[pp] == "Dead") { + purge_d = 0; + } + } +} 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 3d15cf45eb..3e14b3412d 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -111,24 +111,27 @@ function scr_enemy_ai_d() { } if (has_problem_planet_and_time(i, "great_crusade", 0)>-1){ - var flet,cont,dir;cont=0; - flet=instance_nearest(x,y,obj_p_fleet); + var dir; + var join_crusade=false; + var _player_fleet = instance_nearest(x,y,obj_p_fleet); - if (flet.action="") then cont=1; - if (cont=1) and (point_distance(x,y,flet.x,flet.y)<40) then cont=2; + if (_player_fleet.action=""){ + if (point_distance(x, y, _player_fleet.x, _player_fleet.y)<10 ){ + join_crusade=true; + } + } - if (cont=2){ - flet.action="crusade1"; + if (join_crusade){ dir=point_direction(room_width/2,room_height/2,x,y); - flet.action_x=x+lengthdir_x(2000,dir); - flet.action_y=y+lengthdir_y(2000,dir); - // flet.action_eta=floor(random(8))+12; - flet.action_eta=floor(random(8))+2; - flet.alarm[4]=1; + with (_player_fleet){ + action_x=x+lengthdir_x(1200,dir); + action_y=y+lengthdir_y(1200,dir); + set_fleet_movement(false, "crusade1"); + } + scr_alert("green","crusade","Fleet embarks upon Crusade.",x,y); scr_event_log("","Fleet embarks upon Crusade."); - } - if (cont=1) or (cont=0){ + }else { // hit loyalty here obj_controller.disposition[2]-=5; obj_controller.disposition[4]-=10; diff --git a/scripts/scr_equipment_struct/scr_equipment_struct.gml b/scripts/scr_equipment_struct/scr_equipment_struct.gml index ee82ca5fd2..bce149a477 100644 --- a/scripts/scr_equipment_struct/scr_equipment_struct.gml +++ b/scripts/scr_equipment_struct/scr_equipment_struct.gml @@ -1,4 +1,4 @@ -function EquipmentStruct(item_data, core_type, quality_request="none") constructor{ +function EquipmentStruct(item_data, core_type, quality_request = "none") constructor { type = core_type; // Struct defaults; @@ -24,7 +24,7 @@ function EquipmentStruct(item_data, core_type, quality_request="none") construct req_exp = 0; maintenance = 0; specials = ""; - quality = quality_request == "none" ? "standard" : quality_request; + quality = quality_request == "none" ? "standard" : quality_request; // Struct defaults end; // Loop through teh data, to fill the struct; @@ -44,148 +44,139 @@ function EquipmentStruct(item_data, core_type, quality_request="none") construct } // Placeholder maintenance values; - if (maintenance == 0){ - if (has_tags(["heavy_ranged","power", "plasma", "melta"])){ + if (maintenance == 0) { + if (has_tags(["heavy_ranged", "power", "plasma", "melta"])) { maintenance = 0.05; } } // All methods and functions are bllow; - static item_tooltip_desc_gen = function(){ + static item_tooltip_desc_gen = function() { item_desc_tooltip = ""; var stat_order; var item_type = type; - if (type==""){ - if struct_exists(global.gear[$ "armour"],name){ + if (type == "") { + if (struct_exists(global.gear[$ "armour"], name)) { item_type = "armour"; - } - else if struct_exists(global.gear[$ "mobility"],name){ + } else if (struct_exists(global.gear[$ "mobility"], name)) { item_type = "mobility"; - } - else if struct_exists(global.gear[$ "gear"],name){ + } else if (struct_exists(global.gear[$ "gear"], name)) { item_type = "gear"; - } - else if struct_exists(global.weapons,name){ + } else if (struct_exists(global.weapons, name)) { item_type = "weapon"; - } - else{ + } else { item_desc_tooltip = "Error: Item not found!"; return item_desc_tooltip; } } switch (item_type) { default: - stat_order = ["description", "special_description", "quality", "armour_value", "damage_resistance_mod", "hp_mod", "ranged_mod", "melee_mod", "attack", "spli", "range", "ammo", "melee_hands", "ranged_hands", "maintenance","special_properties", "req_exp", "tags", "specials"]; + stat_order = ["description", "special_description", "quality", "armour_value", "damage_resistance_mod", "hp_mod", "ranged_mod", "melee_mod", "attack", "spli", "range", "ammo", "melee_hands", "ranged_hands", "maintenance", "special_properties", "req_exp", "tags", "specials"]; break; case "weapon": - stat_order = ["description", "special_description", "quality", "attack", "spli", "range", "ammo", "ranged_mod", "melee_mod", "armour_value", "hp_mod", "damage_resistance_mod", "melee_hands", "ranged_hands", "maintenance","special_properties", "req_exp", "tags", "specials"]; + stat_order = ["description", "special_description", "quality", "attack", "spli", "range", "ammo", "ranged_mod", "melee_mod", "armour_value", "hp_mod", "damage_resistance_mod", "melee_hands", "ranged_hands", "maintenance", "special_properties", "req_exp", "tags", "specials"]; break; - } - + } + for (var i = 0; i < array_length(stat_order); i++) { var stat = stat_order[i]; switch (stat) { case "description": - if (description!=""){ - item_desc_tooltip += $"{description}##" + if (description != "") { + item_desc_tooltip += $"{description}##"; } break; case "quality": - if (quality!=""){ - item_desc_tooltip += $"Quality: {quality_string_conversion(quality)}##" + if (quality != "") { + item_desc_tooltip += $"Quality: {quality_string_conversion(quality)}##"; } break; case "armour_value": - if (armour_value!=0){ - if item_type = "armour"{ - item_desc_tooltip += $"Armour: {armour_value}#" - } - else{ - item_desc_tooltip += $"Armour: {format_number_with_sign(armour_value)}#" + if (armour_value != 0) { + if (item_type == "armour") { + item_desc_tooltip += $"Armour: {armour_value}#"; + } else { + item_desc_tooltip += $"Armour: {format_number_with_sign(armour_value)}#"; } } break; case "hp_mod": - if (hp_mod!=0){ - item_desc_tooltip += $"Health Mod: {format_number_with_sign(hp_mod)}%#" + if (hp_mod != 0) { + item_desc_tooltip += $"Health Mod: {format_number_with_sign(hp_mod)}%#"; } break; case "damage_resistance_mod": - if (damage_resistance_mod!=0){ - item_desc_tooltip += $"Damage Res: {format_number_with_sign(damage_resistance_mod)}%#" + if (damage_resistance_mod != 0) { + item_desc_tooltip += $"Damage Res: {format_number_with_sign(damage_resistance_mod)}%#"; } break; case "attack": - if (attack!=0){ - item_desc_tooltip += $"Damage: {attack}#" + if (attack != 0) { + item_desc_tooltip += $"Damage: {attack}#"; } break; case "spli": - if item_type = "weapon"{ - item_desc_tooltip += $"Max Kills: {max(1, spli)}#" - } + if (item_type == "weapon") { + item_desc_tooltip += $"Max Kills: {max(1, spli)}#"; + } break; case "ranged_mod": - if (ranged_mod!=0){ - item_desc_tooltip += $"Ranged Mod: {format_number_with_sign(ranged_mod)}%#" + if (ranged_mod != 0) { + item_desc_tooltip += $"Ranged Mod: {format_number_with_sign(ranged_mod)}%#"; } break; case "melee_mod": - if (melee_mod!=0){ - item_desc_tooltip += $"Melee Mod: {format_number_with_sign(melee_mod)}%#" + if (melee_mod != 0) { + item_desc_tooltip += $"Melee Mod: {format_number_with_sign(melee_mod)}%#"; } break; case "ammo": - if (ammo!=0){ - item_desc_tooltip += $"Ammo: {ammo}#" + if (ammo != 0) { + item_desc_tooltip += $"Ammo: {ammo}#"; } break; case "range": - if (range>1.1){ - item_desc_tooltip += $"Range: {range}#" + if (range > 1.1) { + item_desc_tooltip += $"Range: {range}#"; } break; case "melee_hands": if (melee_hands != 0) { - if item_type = "weapon"{ - item_desc_tooltip += $"Melee Burden: {melee_hands}#" - } - else{ - item_desc_tooltip += $"Melee Burden Cap: {format_number_with_sign(melee_hands)}#" + if (item_type == "weapon") { + item_desc_tooltip += $"Melee Burden: {melee_hands}#"; + } else { + item_desc_tooltip += $"Melee Burden Cap: {format_number_with_sign(melee_hands)}#"; } } break; case "ranged_hands": if (ranged_hands != 0) { - if item_type = "weapon"{ - item_desc_tooltip += $"Ranged Burden: {ranged_hands}#" - } - else{ - item_desc_tooltip += $"Ranged Burden Cap: {format_number_with_sign(ranged_hands)}#" + if (item_type == "weapon") { + item_desc_tooltip += $"Ranged Burden: {ranged_hands}#"; + } else { + item_desc_tooltip += $"Ranged Burden Cap: {format_number_with_sign(ranged_hands)}#"; } } break; case "special_properties": var special_properties_array = []; - if (array_length(special_properties)>0){ + if (array_length(special_properties) > 0) { for (var k = 0; k < array_length(special_properties); k++) { array_push(special_properties_array, special_properties[k]); } } - if (arp>0){ - array_push(special_properties_array, "Armour Piercing") - } - else if (arp<0){ - array_push(special_properties_array, "Low Penetration") + if (arp > 0) { + array_push(special_properties_array, "Armour Piercing"); + } else if (arp < 0) { + array_push(special_properties_array, "Low Penetration"); } - if (array_length(second_profiles)>0){ + if (array_length(second_profiles) > 0) { for (var h = 0; h < array_length(second_profiles); h++) { if (string_pos("Integrated", second_profiles[h]) == 0) { var integrated_member = "Integrated " + second_profiles[h]; array_push(special_properties_array, integrated_member); - } - else{ + } else { array_push(special_properties_array, second_profiles[h]); } } @@ -199,58 +190,58 @@ function EquipmentStruct(item_data, core_type, quality_request="none") construct var _special = _specials[j]; var _special_value = specials[$ _special]; _specials_string += $"{format_underscore_string(_special)} ({_special_value})"; - array_push(special_properties_array, _specials_string) + array_push(special_properties_array, _specials_string); } } - if (array_length(special_properties_array) > 0){ - var special_properties_string = "" + if (array_length(special_properties_array) > 0) { + var special_properties_string = ""; for (var j = 0; j < array_length(special_properties_array); j++) { - special_properties_string += special_properties_array[j] + special_properties_string += special_properties_array[j]; if (j < array_length(special_properties_array) - 1) { - special_properties_string += ", " + special_properties_string += ", "; } } - item_desc_tooltip += $"#Properties:#{special_properties_string}#" + item_desc_tooltip += $"#Properties:#{special_properties_string}#"; } break; case "special_description": - if (special_description!=""){ - item_desc_tooltip += $"#{special_description}#" + if (special_description != "") { + item_desc_tooltip += $"#{special_description}#"; } break; case "req_exp": - if (req_exp>0){ - item_desc_tooltip += $"#Requires {req_exp} EXP#" + if (req_exp > 0) { + item_desc_tooltip += $"#Requires {req_exp} EXP#"; } break; case "tags": - if (array_length(tags)>0){ - var tagString = "" + if (array_length(tags) > 0) { + var tagString = ""; for (var j = 0; j < array_length(tags); j++) { - tagString += tags[j] + tagString += tags[j]; if (j < array_length(tags) - 1) { - tagString += ", " + tagString += ", "; } } - item_desc_tooltip += $"#Keywords:#{tagString}#" + item_desc_tooltip += $"#Keywords:#{tagString}#"; } break; case "maintenance": - if (maintenance>0){ - item_desc_tooltip += $"Maintenance: {maintenance}#" + if (maintenance > 0) { + item_desc_tooltip += $"Maintenance: {maintenance}#"; } break; } } - return item_desc_tooltip - } + return item_desc_tooltip; + }; - static has_tag = function(tag){ + static has_tag = function(tag) { return array_contains(tags, tag); - } + }; - static special_value = function(special){ + static special_value = function(special) { if (is_struct(specials)) { var _specials = struct_get_names(specials); for (var j = 0; j < array_length(_specials); j++) { @@ -262,165 +253,172 @@ function EquipmentStruct(item_data, core_type, quality_request="none") construct } } return 0; - } + }; - static has_tags = function(search_tags){ - var satisfied=false; - var wanted_tags_length=array_length(search_tags); - for (var i=0;i0 && obj_controller.stc_bonus[1]<5){ - if (obj_controller.stc_bonus[1]==2 && has_tag("chain")){ - attack*=1.07; - } else if (obj_controller.stc_bonus[1]==3 && has_tag("flame")){ - attack*=1.1; - }else if (obj_controller.stc_bonus[1]==4 && has_tag("explosive")){ - attack*=1.07; - }else if (obj_controller.stc_bonus[1]==1 && has_tag("bolt")){ - attack*=1.07; + static owner_data = function(owner) { + //centralization of bonuses originating from weapon improvements e.g STCs + if (owner == "chapter") { + if (type == "weapon") { + if (obj_controller.stc_bonus[1] > 0 && obj_controller.stc_bonus[1] < 5) { + if (obj_controller.stc_bonus[1] == 2 && has_tag("chain")) { + attack *= 1.07; + } else if (obj_controller.stc_bonus[1] == 3 && has_tag("flame")) { + attack *= 1.1; + } else if (obj_controller.stc_bonus[1] == 4 && has_tag("explosive")) { + attack *= 1.07; + } else if (obj_controller.stc_bonus[1] == 1 && has_tag("bolt")) { + attack *= 1.07; } } - if (obj_controller.stc_bonus[2]>0 && obj_controller.stc_bonus[2]<3){ - if (obj_controller.stc_bonus[2]==1 && has_tag("fist")){ - attack*=1.1; - } else if (obj_controller.stc_bonus[2]==2 && has_tag("plasma")){ - attack*=1.1; - } + if (obj_controller.stc_bonus[2] > 0 && obj_controller.stc_bonus[2] < 3) { + if (obj_controller.stc_bonus[2] == 1 && has_tag("fist")) { + attack *= 1.1; + } else if (obj_controller.stc_bonus[2] == 2 && has_tag("plasma")) { + attack *= 1.1; + } } } } - } + }; } -function gear_weapon_data(search_area="any",item,wanted_data="all", sub_class=false, quality_request="standard"){ - var item_data_set=false; - var equip_area=false; - gear_areas = ["gear","armour","mobility"]; - if (search_area=="any"){ - data_found=false; - for (i=0;i<3;i++){ - if (struct_exists(global.gear[$ gear_areas[i]],item)){ - equip_area=global.gear; - item_data_set=global.gear[$ gear_areas[i]][$item]; - data_found=true; - search_area=gear_areas[i]; + +function gear_weapon_data(search_area = "any", item, wanted_data = "all", sub_class = false, quality_request = "standard") { + var item_data_set = false; + var equip_area = false; + gear_areas = ["gear", "armour", "mobility"]; + if (search_area == "any") { + data_found = false; + for (i = 0; i < 3; i++) { + if (struct_exists(global.gear[$ gear_areas[i]], item)) { + equip_area = global.gear; + item_data_set = global.gear[$ gear_areas[i]][$ item]; + data_found = true; + search_area = gear_areas[i]; break; - } + } } - if (!data_found){ - equip_area=global.weapons; - if (struct_exists(equip_area,item)){ - item_data_set=equip_area[$item]; - search_area="weapon"; + if (!data_found) { + equip_area = global.weapons; + if (struct_exists(equip_area, item)) { + item_data_set = equip_area[$ item]; + search_area = "weapon"; } } } else { - if (array_contains(gear_areas,search_area)){ - equip_area=global.gear; - if (struct_exists(equip_area[$ search_area],item)){ - item_data_set = equip_area[$ search_area][$ item] - } - } else if (search_area=="weapon"){ - equip_area=global.weapons; - if (struct_exists(equip_area,item)){ - item_data_set=equip_area[$item] - search_area="weapon"; - } + if (array_contains(gear_areas, search_area)) { + equip_area = global.gear; + if (struct_exists(equip_area[$ search_area], item)) { + item_data_set = equip_area[$ search_area][$ item]; + } + } else if (search_area == "weapon") { + equip_area = global.weapons; + if (struct_exists(equip_area, item)) { + item_data_set = equip_area[$ item]; + search_area = "weapon"; + } } } - if (is_struct(item_data_set)){ - if (wanted_data=="all"){ - item_data_set.name=item; - return new EquipmentStruct(item_data_set,search_area,quality_request); + if (is_struct(item_data_set)) { + if (wanted_data == "all") { + item_data_set.name = item; + return new EquipmentStruct(item_data_set, search_area, quality_request); } - if (struct_exists(item_data_set, wanted_data)){ - if (is_struct(item_data_set[$ wanted_data])){ - if (struct_exists(item_data_set[$ wanted_data], quality_request)){ + if (struct_exists(item_data_set, wanted_data)) { + if (is_struct(item_data_set[$ wanted_data])) { + if (struct_exists(item_data_set[$ wanted_data], quality_request)) { return item_data_set[$ wanted_data][$ quality_request]; } else { - if (struct_exists(item_data_set[$ wanted_data],"standard")){ - return item_data_set[$ wanted_data][$ "standard"] + if (struct_exists(item_data_set[$ wanted_data], "standard")) { + return item_data_set[$ wanted_data][$ "standard"]; } else { - return 0;//default value + return 0; //default value } } } else { - return item_data_set[$ wanted_data] + return item_data_set[$ wanted_data]; } } else { - return 0;//default value + return 0; //default value } - } - return false;//nothing found + } + return false; //nothing found } -function quality_string_conversion(quality_request){ +function quality_string_conversion(quality_request) { var quality_conversions = { - standard:"Normal", - master_crafted:"Master Crafted", - artificer:"Articifer", - artifact:"Artifact", - exemplary:"Exemplary" + standard: "Normal", + master_crafted: "Master Crafted", + artificer: "Articifer", + artifact: "Artifact", + exemplary: "Exemplary" + }; + if (struct_exists(quality_conversions, quality_request)) { + return quality_conversions[$ quality_request]; + } else { + return ""; } - if (struct_exists(quality_conversions, quality_request)){ - return quality_conversions[$ quality_request] - } else {return "";} } -function quality_color(_item_quality){ - switch(_item_quality){ +function quality_color(_item_quality) { + switch (_item_quality) { case "standard": - return(draw_get_color()) + return draw_get_color(); break; case "master_crafted": - return(#bf9340); + return #bf9340; break; case "artificer": - return(#bf4040); + return #bf4040; break; case "artifact": - return(#40bfbf); + return #40bfbf; break; case "exemplary": - return(#80bf40); + return #80bf40; break; } } -function format_number_with_sign(number){ +function format_number_with_sign(number) { return number > 0 ? "+" + string(number) : string(number); -} - +} \ 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 184ff3fb8b..377d79ed39 100644 --- a/scripts/scr_fleet_functions/scr_fleet_functions.gml +++ b/scripts/scr_fleet_functions/scr_fleet_functions.gml @@ -139,13 +139,13 @@ function is_orbiting(){ return false; } -function set_fleet_movement(fastest_route = true){ +function set_fleet_movement(fastest_route = true, new_action="move"){ action = ""; if (action==""){ turns_static = 0; - var sys, mine, fleet; + var mine, fleet; var connected=0,cont=0,target_dist=0; if (fastest_route){ mine=instance_nearest(x,y,obj_star); @@ -158,20 +158,25 @@ function set_fleet_movement(fastest_route = true){ complex_route = path; action_x = targ.x; action_y = targ.y; - set_fleet_movement(false); + set_fleet_movement(false, new_action); } else { - set_fleet_movement(false); + set_fleet_movement(false, new_action); } } else { - set_fleet_movement(false); + set_fleet_movement(false, new_action); } } else { - sys=instance_nearest(action_x,action_y,obj_star); + var _target_sys = instance_nearest(action_x,action_y,obj_star); + var _target_is_sys = false; + + if (instance_exists(_target_sys)){ + _target_is_sys = point_distance(_target_sys.x, _target_sys.y, action_x, action_y)<10; + } mine=instance_nearest(x,y,obj_star); - var eta = calculate_fleet_eta(x,y,action_x,action_y,action_spd,instance_exists(sys),is_orbiting(),warp_able); + var eta = calculate_fleet_eta(x,y,action_x,action_y,action_spd,_target_is_sys,is_orbiting(),warp_able); action_eta = eta; if (action_eta<=0) or (owner != eFACTION.Inquisition){ action_eta=eta; @@ -183,10 +188,9 @@ function set_fleet_movement(fastest_route = true){ // action_x=sys.x; // action_y=sys.y; orbiting = false; - action="move"; - + action=new_action; + minimum_eta=1; if (minimum_eta>action_eta) and (minimum_eta>0) then action_eta=minimum_eta; - minimum_eta=0; } } } diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index 4d9c7ac3b8..7738c815c6 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -18,100 +18,139 @@ the string (usually max) is guidance so in the instance of max it will pick the larger value of the mean and the gauss function return */ // will swap these out for enums or some better method as i develop where this is going -#macro ARR_body_parts ["left_leg", "right_leg", "torso", "right_arm", "left_arm", "left_eye", "right_eye", "throat", "jaw","head"] -#macro ARR_body_parts_display ["Left Leg", "Right Leg", "Torso", "Right Arm", "Left Arm", "Left Eye", "Right Eye", "Throat", "Jaw","Head"] -global.religions={ - "imperial_cult":{"name":"Imperial Cult"}, - "cult_mechanicus":{"name":"Cult Mechanicus"}, - "eight_fold_path":{"name":"The Eight Fold Path"} +#macro ARR_body_parts ["left_leg", "right_leg", "torso", "right_arm", "left_arm", "left_eye", "right_eye", "throat", "jaw", "head"] +#macro ARR_body_parts_display ["Left Leg", "Right Leg", "Torso", "Right Arm", "Left Arm", "Left Eye", "Right Eye", "Throat", "Jaw", "Head"] +global.religions = { + "imperial_cult": { + "name": "Imperial Cult" + }, + "cult_mechanicus": { + "name": "Cult Mechanicus" + }, + "eight_fold_path": { + "name": "The Eight Fold Path" + } }; -#macro ARR_power_armour ["MK7 Aquila","MK6 Corvus","MK5 Heresy","MK3 Iron Armour","MK4 Maximus","Power Armour"] +#macro ARR_power_armour ["MK7 Aquila", "MK6 Corvus", "MK5 Heresy", "MK3 Iron Armour", "MK4 Maximus", "Power Armour"] enum location_types { - planet, - ship, - space_hulk, - ancient_ruins, - warp + planet, + ship, + space_hulk, + ancient_ruins, + warp, } -#macro ARR_psy_levels ["Rho","Pi","Omicron","Xi","Nu","Mu","Lambda","Kappa","Iota","Theta","Eta","Zeta","Epsilon","Delta","Gamma","Beta","Alpha","Alpha Plus","Beta","Gamma Plus"] -#macro ARR_negative_psy_levels ["Rho","Sigma","Tau","Upsilon","Phi","Chi","Psi","Omega"] - -global.base_stats = { //tempory stats subject to change by anyone that wishes to try their luck - "chapter_master":{ // TODO consider allowing the player to change the starting stats of the chapter master, and closest advisors, especially for custom chapters - title : "Adeptus Astartes", - strength:[42,5], - constitution:[44,3], - dexterity:[44,3], - weapon_skill : [50,5, "max"], - ballistic_skill : [50,5, "max"], - intelligence:[44,3], - wisdom:[44,3], - charisma :[40,3], - religion : "imperial_cult", - piety : [30,3], - luck :10, - technology :[30,3], - base_group : "astartes", - }, - "marine":{ - title : "Adeptus Astartes", - strength:[40,4], - constitution:[40,3], - weapon_skill : [40,5], - ballistic_skill : [40,5], - dexterity:[40,3], - intelligence:[40,3], - wisdom:[40,3], - charisma :[30,5], - religion : "imperial_cult", - piety : [30,3], - luck :10, - technology :[30,3], - skills: { - weapons:{ - "bolter":3, "chainsword":3, "ccw":3, "bolt_pistol":3}}, - start_gear:{"armour":"Power Armour", "wep1":"Chainsword", "wep2":"Chainsword"}, - base_group : "astartes", - }, - "scout":{ - title : "Adeptus Astartes", - strength:[36,4], - constitution:[36,3], - weapon_skill : [30,2,"max"], - ballistic_skill : [30,2,"max"], - dexterity:[36,3], - intelligence:[38,3], - wisdom:[35,3], - charisma :[30,5], - religion : "imperial_cult", - piety : [28,3], - luck :10, - technology :[28,3], - skills: {weapons:{"bolter":3, "chainsword":3, "ccw":3, "bolt_pistol":3}}, - start_gear:{"armour":"Power Armour", "wep1":"Bolter", "wep2":"Chainsword"}, // Scouts should probably have access only to scout armour, and perhaps some stuff from hirelings - base_group : "astartes", - }, - "dreadnought":{ - title : "Adeptus Astartes", - strength:[70,4], - constitution:[75,3], - weapon_skill : [55,5], - ballistic_skill : [55,5], - dexterity:[30,3], - intelligence:[45,3], - wisdom:[50,3], - charisma :[35,3], - religion : "imperial_cult", - piety : [32,3], - luck :10, - technology :[30,3], - skills: {weapons:{"bolter":3, "chainsword":3, "ccw":3, "bolt_pistol":3}}, - start_gear:{"armour":"Power Armour", "wep1":"Bolter", "wep2":"Chainsword"}, - base_group : "astartes", - traits:["ancient","slow_and_purposeful","lead_example","zealous_faith",choose("still_standing","beast_slayer","lone_survivor")] - }, - /* TODO - check and tweak if necessary +#macro ARR_psy_levels ["Rho", "Pi", "Omicron", "Xi", "Nu", "Mu", "Lambda", "Kappa", "Iota", "Theta", "Eta", "Zeta", "Epsilon", "Delta", "Gamma", "Beta", "Alpha", "Alpha Plus", "Beta", "Gamma Plus"] +#macro ARR_negative_psy_levels ["Rho", "Sigma", "Tau", "Upsilon", "Phi", "Chi", "Psi", "Omega"] + +global.base_stats = { + //tempory stats subject to change by anyone that wishes to try their luck + "chapter_master": { + // TODO consider allowing the player to change the starting stats of the chapter master, and closest advisors, especially for custom chapters + title: "Adeptus Astartes", + strength: [42, 5], + constitution: [44, 3], + dexterity: [44, 3], + weapon_skill: [50, 5, "max"], + ballistic_skill: [50, 5, "max"], + intelligence: [44, 3], + wisdom: [44, 3], + charisma: [40, 3], + religion: "imperial_cult", + piety: [30, 3], + luck: 10, + technology: [30, 3], + base_group: "astartes", + }, + "marine": { + title: "Adeptus Astartes", + strength: [40, 4], + constitution: [40, 3], + weapon_skill: [40, 5], + ballistic_skill: [40, 5], + dexterity: [40, 3], + intelligence: [40, 3], + wisdom: [40, 3], + charisma: [30, 5], + religion: "imperial_cult", + piety: [30, 3], + luck: 10, + technology: [30, 3], + skills: { + weapons: { + "bolter": 3, + "chainsword": 3, + "ccw": 3, + "bolt_pistol": 3 + } + }, + start_gear: { + "armour": "Power Armour", + "wep1": "Chainsword", + "wep2": "Chainsword" + }, + base_group: "astartes" + }, + "scout": { + title: "Adeptus Astartes", + strength: [36, 4], + constitution: [36, 3], + weapon_skill: [30, 2, "max"], + ballistic_skill: [30, 2, "max"], + dexterity: [36, 3], + intelligence: [38, 3], + wisdom: [35, 3], + charisma: [30, 5], + religion: "imperial_cult", + piety: [28, 3], + luck: 10, + technology: [28, 3], + skills: { + weapons: { + "bolter": 3, + "chainsword": 3, + "ccw": 3, + "bolt_pistol": 3 + } + }, + start_gear: { + "armour": "Power Armour", + "wep1": "Bolter", + "wep2": "Chainsword" + }, // Scouts should probably have access only to scout armour, and perhaps some stuff from hirelings + base_group: "astartes", + }, + "dreadnought": { + title: "Adeptus Astartes", + strength: [70, 4], + constitution: [75, 3], + weapon_skill: [55, 5], + ballistic_skill: [55, 5], + dexterity: [30, 3], + intelligence: [45, 3], + wisdom: [50, 3], + charisma: [35, 3], + religion: "imperial_cult", + piety: [32, 3], + luck: 10, + technology: [30, 3], + skills: { + weapons: { + "bolter": 3, + "chainsword": 3, + "ccw": 3, + "bolt_pistol": 3 + } + }, + start_gear: { + "armour": "Power Armour", + "wep1": "Bolter", + "wep2": "Chainsword" + }, + base_group: "astartes", + traits: ["ancient", "slow_and_purposeful", "lead_example", "zealous_faith", choose("still_standing", "beast_slayer", "lone_survivor")] + }, + /* TODO - check and tweak if necessary "chapter_servitor":{ title : "Chapter Servitor", strength:[36,4], @@ -132,1916 +171,2075 @@ global.base_stats = { //tempory stats subject to change by anyone that wishes to traits:["lobotomized"], }, */ - // TODO - add more hirelings on the imperial side... - "skitarii":{ - title : "Skitarii", - strength : [12,1], // I don't think skitarii are particularly strong - constitution : [15,1], - weapon_skill : [12,1], - ballistic_skill : [20,1], - dexterity : [25,1], - intelligence : [25,1], - wisdom : [10,1], // Hm, no, very unwise... - charisma : [5,1], // Talking in binary does not help to make many friends - religion : "cult_mechanicus", - piety : [20,1], - luck : 10, // I don't see the point to make them less lucky than space marines - technology : [30,1], - skills: {weapons:{"Hellgun":1,}}, - start_gear:{ - wep2 : "", - wep1 : "Hellgun", - armour : "Skitarii Armour", - gear : "", - mobi : "", - }, - base_group : "skitarii", - }, - "tech_priest":{ - title : "Tech Priest", - strength : [15,1], - constitution : [30,1], - weapon_skill : [15,1], - ballistic_skill : [25,3], - dexterity : [25,3], - intelligence : [30,3], - wisdom : [20,2], - charisma : [30,2], // Considering their voicelines in DoW:DC and SS, I'd say they can have charisma - religion : "cult_mechanicus", - piety : [45,3], - luck : 10, - technology : [55,3], - skills: { - weapons:{ - "Power Axe":2, "Laspistol":2, "Hellgun":1, - } // TODO - add skills for Servo-arm(m) - }, - start_gear:{"armour":"Dragon Scales", "wep1":"Power Axe", "wep2":"Laspistol", "mobi":"Servo-arm"}, - base_group : "tech_priest", - }, - "eldar_ranger":{ // TODO rename this - title : "Eldar Ranger", // TODO - that should be Eldar - strength : [25,1], - constitution : [30,2], - weapon_skill : [45,4], - ballistic_skill : [45,4], - dexterity : [50,5], // Dexterity should be eldar 'specialization' - intelligence : [35,3], - wisdom : [50,3], - charisma : [20,2], // Arrogance from cultural stuff, supposedly - religion : "cult_mechanicus", // TODO - add eldar faith - piety : [30,5], // I think eldar rangers can be either - faithful to the path or more cynical - luck : 10, - technology : [20,1], // Elves in most fiction tend to be kind of bad at technology, right? - skills: { - weapons:{ - "Ranger Long Rifle":3, "Shuriken Pistol":3, "Eldar Power Sword":3}}, // TODO - check if these actually work - start_gear:{"armour":"Ranger Armour", "wep1":"Ranger Long Rifle", "wep2":"Eldar Power Sword"}, // TODO - add Eldar Armour - base_group : "skitarii", // Might want to rename this - }, - "inquisition_crusader":{ - title : "Inquisition Crusader", - strength : [10,1], // 10 is considered standard for a chad-like Imperial Guardsman - constitution : [10,1], - weapon_skill : [10,1], - ballistic_skill : [10,1], - dexterity : [10,1], - intelligence : [10,1], - wisdom : [12,1], // They may know a bit more than average imperial - charisma : [10,1], - religion : "imperial_cult", - piety : [30,5], // Supposedly, they can be radical or puritan... - luck : 10, - technology : [8,1], - skills : {}, // TODO consider what skills are needed for this bloke - start_gear:{"armour":"Light Power Armour", "wep1":"Power Sword", "wep2":"Combat Shield"}, // TODO - add Light variant of Power Armour - base_group : "human", - }, - /* TODO - add psychic capabilities + // TODO - add more hirelings on the imperial side... + "skitarii": { + title: "Skitarii", + strength: [12, 1], // I don't think skitarii are particularly strong + constitution: [15, 1], + weapon_skill: [12, 1], + ballistic_skill: [20, 1], + dexterity: [25, 1], + intelligence: [25, 1], + wisdom: [10, 1], // Hm, no, very unwise... + charisma: [5, 1], // Talking in binary does not help to make many friends + religion: "cult_mechanicus", + piety: [20, 1], + luck: 10, // I don't see the point to make them less lucky than space marines + technology: [30, 1], + skills: { + weapons: { + "Hellgun": 1 + } + }, + start_gear: { + wep2: "", + wep1: "Hellgun", + armour: "Skitarii Armour", + gear: "", + mobi: "" + }, + base_group: "skitarii", + }, + "tech_priest": { + title: "Tech Priest", + strength: [15, 1], + constitution: [30, 1], + weapon_skill: [15, 1], + ballistic_skill: [25, 3], + dexterity: [25, 3], + intelligence: [30, 3], + wisdom: [20, 2], + charisma: [30, 2], // Considering their voicelines in DoW:DC and SS, I'd say they can have charisma + religion: "cult_mechanicus", + piety: [45, 3], + luck: 10, + technology: [55, 3], + skills: { + weapons: { + "Power Axe": 2, + "Laspistol": 2, + "Hellgun": 1 + }, // TODO - add skills for Servo-arm(m) + }, + start_gear: { + "armour": "Dragon Scales", + "wep1": "Power Axe", + "wep2": "Laspistol", + "mobi": "Servo-arm" + }, + base_group: "tech_priest", + }, + "eldar_ranger": { + // TODO rename this + title: "Eldar Ranger", // TODO - that should be Eldar + strength: [25, 1], + constitution: [30, 2], + weapon_skill: [45, 4], + ballistic_skill: [45, 4], + dexterity: [50, 5], // Dexterity should be eldar 'specialization' + intelligence: [35, 3], + wisdom: [50, 3], + charisma: [20, 2], // Arrogance from cultural stuff, supposedly + religion: "cult_mechanicus", // TODO - add eldar faith + piety: [30, 5], // I think eldar rangers can be either - faithful to the path or more cynical + luck: 10, + technology: [20, 1], // Elves in most fiction tend to be kind of bad at technology, right? + skills: { + weapons: { + "Ranger Long Rifle": 3, + "Shuriken Pistol": 3, + "Eldar Power Sword": 3 + } + }, // TODO - check if these actually work + start_gear: { + "armour": "Ranger Armour", + "wep1": "Ranger Long Rifle", + "wep2": "Eldar Power Sword" + }, // TODO - add Eldar Armour + base_group: "skitarii", // Might want to rename this + }, + "inquisition_crusader": { + title: "Inquisition Crusader", + strength: [10, 1], // 10 is considered standard for a chad-like Imperial Guardsman + constitution: [10, 1], + weapon_skill: [10, 1], + ballistic_skill: [10, 1], + dexterity: [10, 1], + intelligence: [10, 1], + wisdom: [12, 1], // They may know a bit more than average imperial + charisma: [10, 1], + religion: "imperial_cult", + piety: [30, 5], // Supposedly, they can be radical or puritan... + luck: 10, + technology: [8, 1], + skills: {}, // TODO consider what skills are needed for this bloke + start_gear: { + "armour": "Light Power Armour", + "wep1": "Power Sword", + "wep2": "Combat Shield" + }, // TODO - add Light variant of Power Armour + base_group: "human", + }, + /* TODO - add psychic capabilities "sanctioned_psyker":{ title: "Sanctioned Psyker", } */ - "sister_of_battle":{ - title : "Sister of Battle", - strength : [12,1], - constitution : [12,1], // TODO - consider making it that hireling armour boosts constitution, and possibly other stats - weapon_skill : [15,1], - ballistic_skill : [15,1], - dexterity : [22,1], - intelligence : [10,1], - wisdom : [10,1], - charisma : [10,1], - religion : "imperial_cult", - piety : [50,2], // Fanatics, for most part - luck : 10, - technology : [8,1], - skills: { - weapons:{ - "Light Bolter":1, "Bolt Pistol":1, "Chainsword":1, "Sarissa":1}}, - start_gear:{"armour":"Sororitas Power Armour", "wep1":"Light Bolter", "wep2":""}, - base_group : "human", - // traits:["zealous_faith"], - }, - "sister_hospitaler":{ - title : "Sister Hospitaler", - strength : [11,1], - constitution : [12,1], // TODO - consider making it that hireling armour boosts constitution - weapon_skill : [13,1], - ballistic_skill : [13,1], - dexterity : [11,1], - intelligence : [12,1], - wisdom : [11,1], - charisma : [10,1], - religion : "imperial_cult", - piety : [50,2], // Fanatics, for most part - luck : 10, - technology : [12,1], // They probably know a bit more, due to medical studies - skills: { - weapons:{ - "Light Bolter":2, "Bolt Pistol":2, "Chainsword":2, "Sarissa":2}}, - start_gear:{"armour":"Sororitas Power Armour", "wep1":"Light Bolter", "wep2":"", "gear":"Sororitas Medkit"}, - base_group : "human", - // traits:["zealous_faith"], - }, - "ork_sniper":{ // I'm gonna make the stats basically the same as the shoota boy in the stat calculator - title : "Ork Sniper", - strength : [20,2], - constitution : [20,2], - weapon_skill : [9,1], - ballistic_skill : [20,2], - dexterity : [6,1], - intelligence : [10,1], - wisdom : [10,1], - charisma : [10,1], - religion : "gorkamorka", - piety : [20,2], // I'm not sure how would one even properly value this... how attached the ork is to the WAAAGH energy field? - luck : 10, - technology : [20,2], - skills: { - weapons:{ - "Sniper Rifle":1, "Choppa":1}}, - start_gear:{"armour":"Ork Armour", "wep1":"Sniper Rifle", "wep2":"Choppa"}, - base_group : "ork", - }, - "flash_git":{ // For this one, Big shoota ork will be used - title : "Flash Git", - strength : [40,3], - constitution : [40,3], - weapon_skill : [25,2], - ballistic_skill : [40,3], - dexterity : [8,1], - intelligence : [20,2], - wisdom : [20,2], - charisma : [14,1], - religion : "gorkamorka", - piety : [20,2], - luck : 10, - technology : [30,3], - skills: { - weapons:{ - "Sniper Rifle":1, "Snazzgun":2, "Choppa":2}}, - start_gear:{"armour":"Ork Armour", "wep1":"Snazzgun", "wep2":"Choppa"}, // Consider giving a "Power Klaw" instead of Choppa, and better armour - base_group : "ork", - } - // TODO - add more hireling types -} -function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data={}) constructor{ - constitution=0; strength=0;luck=0;dexterity=0;wisdom=0;piety=0;charisma=0;technology=0;intelligence=0;weapon_skill=0;ballistic_skill=0;size = 0;planet_location=0; - if (!instance_exists(obj_controller) && class!="blank"){//game start unit planet location - planet_location = obj_ini.home_planet; - } - ship_location=-1; - last_ship = {uid : "", name : ""}; - religion="none"; - master_loyalty = 0; - job="none"; - psionic=0; - corruption=0; - religion_sub_cult = "none"; - base_group = "none"; - role_history = []; + "sister_of_battle": { + title: "Sister of Battle", + strength: [12, 1], + constitution: [12, 1], // TODO - consider making it that hireling armour boosts constitution, and possibly other stats + weapon_skill: [15, 1], + ballistic_skill: [15, 1], + dexterity: [22, 1], + intelligence: [10, 1], + wisdom: [10, 1], + charisma: [10, 1], + religion: "imperial_cult", + piety: [50, 2], // Fanatics, for most part + luck: 10, + technology: [8, 1], + skills: { + weapons: { + "Light Bolter": 1, + "Bolt Pistol": 1, + "Chainsword": 1, + "Sarissa": 1 + } + }, + start_gear: { + "armour": "Sororitas Power Armour", + "wep1": "Light Bolter", + "wep2": "" + }, + base_group: "human", // traits:["zealous_faith"], + }, + "sister_hospitaler": { + title: "Sister Hospitaler", + strength: [11, 1], + constitution: [12, 1], // TODO - consider making it that hireling armour boosts constitution + weapon_skill: [13, 1], + ballistic_skill: [13, 1], + dexterity: [11, 1], + intelligence: [12, 1], + wisdom: [11, 1], + charisma: [10, 1], + religion: "imperial_cult", + piety: [50, 2], // Fanatics, for most part + luck: 10, + technology: [12, 1], // They probably know a bit more, due to medical studies + skills: { + weapons: { + "Light Bolter": 2, + "Bolt Pistol": 2, + "Chainsword": 2, + "Sarissa": 2 + } + }, + start_gear: { + "armour": "Sororitas Power Armour", + "wep1": "Light Bolter", + "wep2": "", + "gear": "Sororitas Medkit" + }, + base_group: "human", // traits:["zealous_faith"], + }, + "ork_sniper": { + // I'm gonna make the stats basically the same as the shoota boy in the stat calculator + title: "Ork Sniper", + strength: [20, 2], + constitution: [20, 2], + weapon_skill: [9, 1], + ballistic_skill: [20, 2], + dexterity: [6, 1], + intelligence: [10, 1], + wisdom: [10, 1], + charisma: [10, 1], + religion: "gorkamorka", + piety: [20, 2], // I'm not sure how would one even properly value this... how attached the ork is to the WAAAGH energy field? + luck: 10, + technology: [20, 2], + skills: { + weapons: { + "Sniper Rifle": 1, + "Choppa": 1 + } + }, + start_gear: { + "armour": "Ork Armour", + "wep1": "Sniper Rifle", + "wep2": "Choppa" + }, + base_group: "ork", + }, + "flash_git": { + // For this one, Big shoota ork will be used + title: "Flash Git", + strength: [40, 3], + constitution: [40, 3], + weapon_skill: [25, 2], + ballistic_skill: [40, 3], + dexterity: [8, 1], + intelligence: [20, 2], + wisdom: [20, 2], + charisma: [14, 1], + religion: "gorkamorka", + piety: [20, 2], + luck: 10, + technology: [30, 3], + skills: { + weapons: { + "Sniper Rifle": 1, + "Snazzgun": 2, + "Choppa": 2 + } + }, + start_gear: { + "armour": "Ork Armour", + "wep1": "Snazzgun", + "wep2": "Choppa" + }, // Consider giving a "Power Klaw" instead of Choppa, and better armour + base_group: "ork", + }, // TODO - add more hireling types +}; + +function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {}) constructor { + constitution = 0; + strength = 0; + luck = 0; + dexterity = 0; + wisdom = 0; + piety = 0; + charisma = 0; + technology = 0; + intelligence = 0; + weapon_skill = 0; + ballistic_skill = 0; + size = 0; + planet_location = 0; + if (!instance_exists(obj_controller) && class != "blank") { + //game start unit planet location + planet_location = obj_ini.home_planet; + } + ship_location = -1; + last_ship = { + uid: "", + name: "" + }; + religion = "none"; + master_loyalty = 0; + job = "none"; + psionic = 0; + corruption = 0; + religion_sub_cult = "none"; + base_group = "none"; + role_history = []; enum eROLE_TAG { Techmarine = 0, - Librarian = 1, - Chaplain = 2, - Apothecary = 3 + Librarian = 1, + Chaplain = 2, + Apothecary = 3, } role_tag = [0, 0, 0, 0]; // [Techmarine, Librarian, Chaplain, Apothecary] // maybe add to list instead? - encumbered_ranged=false; - encumbered_melee=false; - home_world=""; - company = comp; //marine company - marine_number = mar; //marine number in company - squad = "none"; - stat_point_exp_marker = 0; - bionics=0; - favorite=false; - spawn_data = other_spawn_data; - unit_health=0; - if (faction=="chapter" && !struct_exists(spawn_data, "recruit_data")){ - spawn_data.recruit_data = { - recruit_world : obj_ini.recruiting_type, - aspirant_trial : obj_ini.recruit_trial - }; - } - experience = 0; - turn_stat_gains = {}; - powers_known = []; - - static set_exp = function(new_val){ - experience = new_val - var _powers_learned = 0; - - if (IsSpecialist("libs")) { - _powers_learned = update_powers(); - } - - // 0 is returned to have the same return format as in add_exp, to avoid confusion; - return [0, _powers_learned]; - }//change exp - - static handle_stat_growth = unit_stat_growth; - - static add_exp = add_unit_exp; - - static armour = function(raw=false){ - var wep = obj_ini.armour[company][marine_number]; - if (is_string(wep) || raw) then return wep; - return obj_ini.artifact[wep]; - }; - static role = function(){ - return obj_ini.role[company][marine_number]; - }; - - static squad_role = function(){ - var temp_role = role(); - if (squad != "none"){ - if (struct_exists(obj_ini.squad_types[$ obj_ini.squads[squad].type], temp_role)){ - var role_info = obj_ini.squad_types[$ obj_ini.squads[squad].type][$ temp_role] - if (struct_exists(role_info, "role")){ - temp_role = role_info[$ "role"]; - } - } - } - return string(temp_role) - }; - - static IsSpecialist = function(search_type="standard",include_trainee=false){ - return is_specialist(role(), search_type,include_trainee) - } - static update_role = function(new_role){ - if(role()==new_role){ - return "no change" - } - if (base_group=="astartes"){ - if (role() == obj_ini.role[100][12] && new_role!=obj_ini.role[100][12]){ - if (!get_body_data("black_carapace","torso")){ - alter_body("torso", "black_carapace", true); - stat_boosts( - {strength:4, - constitution:4, - dexterity:4 - })//will decide on if these are needed - } - } - if (!is_specialist(role())){//logs changes too and from specialist status - if (is_specialist(new_role)){ - obj_controller.marines-=1; - obj_controller.command+=1; - } - } else { - if (!is_specialist(new_role)){ - obj_controller.marines+=1; - obj_controller.command-=1; - } - } - } - obj_ini.role[company][marine_number]= new_role; - if instance_exists(obj_controller){ - array_push(role_history ,[role(), obj_controller.turn]) - } - if (new_role==obj_ini.role[100][5]){ - if (company==2) then obj_ini.watch_master_name=name(); - if (company==3) then obj_ini.arsenal_master_name=name(); - if (company==4) then obj_ini.lord_admiral_name=name(); - if (company==5) then obj_ini.march_master_name=name(); - if (company==6) then obj_ini.rites_master_name=name(); - if (company==7) then obj_ini.chief_victualler_name=name(); - if (company==8) then obj_ini.lord_executioner_name=name(); - if (company==9) then obj_ini.relic_master_name=name(); - if (company==10) then obj_ini.recruiter_name=name(); - scr_recent("captain_promote",name(),company); - } else if (new_role==obj_ini.role[100][4]){ - scr_recent("terminator_promote",name(),company); - } else if (new_role==obj_ini.role[100][2]){ - scr_recent("honor_promote",name(),company); - } else if (new_role==obj_ini.role[100][6]){ - - var dread_weapons = ["Close Combat Weapon","Force Staff","Twin Linked Lascannon","Assault Cannon","Missile Launcher","Plasma Cannon", "Multi-Melta", "Twin Linked Heavy Bolter"]; - - if (!array_contains(dread_weapons,weapon_one())){ + encumbered_ranged = false; + encumbered_melee = false; + home_world = ""; + company = comp; //marine company + marine_number = mar; //marine number in company + squad = "none"; + stat_point_exp_marker = 0; + bionics = 0; + favorite = false; + spawn_data = other_spawn_data; + unit_health = 0; + if (faction == "chapter" && !struct_exists(spawn_data, "recruit_data")) { + spawn_data.recruit_data = { + recruit_world: obj_ini.recruiting_type, + aspirant_trial: obj_ini.recruit_trial + }; + } + experience = 0; + turn_stat_gains = {}; + powers_known = []; + + static set_exp = function(new_val) { + experience = new_val; + var _powers_learned = 0; + + if (IsSpecialist("libs")) { + _powers_learned = update_powers(); + } + + // 0 is returned to have the same return format as in add_exp, to avoid confusion; + return [0, _powers_learned]; + }; //change exp + + static handle_stat_growth = unit_stat_growth; + + static add_exp = add_unit_exp; + + static armour = function(raw = false) { + var wep = obj_ini.armour[company][marine_number]; + if (is_string(wep) || raw) { + return wep; + } + return obj_ini.artifact[wep]; + }; + + static role = function() { + return obj_ini.role[company][marine_number]; + }; + + static squad_role = function() { + var temp_role = role(); + if (squad != "none") { + if (struct_exists(obj_ini.squad_types[$ obj_ini.squads[squad].type], temp_role)) { + var role_info = obj_ini.squad_types[$ obj_ini.squads[squad].type][$ temp_role]; + if (struct_exists(role_info, "role")) { + temp_role = role_info[$ "role"]; + } + } + } + return string(temp_role); + }; + + static IsSpecialist = function(search_type = "standard", include_trainee = false) { + return is_specialist(role(), search_type, include_trainee); + }; + + static update_role = function(new_role) { + if (role() == new_role) { + return "no change"; + } + if (base_group == "astartes") { + if (role() == obj_ini.role[100][12] && new_role != obj_ini.role[100][12]) { + if (!get_body_data("black_carapace", "torso")) { + alter_body("torso", "black_carapace", true); + stat_boosts({ + strength: 4, + constitution: 4, + dexterity: 4 + }); //will decide on if these are needed + } + } + if (!is_specialist(role())) { + //logs changes too and from specialist status + if (is_specialist(new_role)) { + obj_controller.marines -= 1; + obj_controller.command += 1; + } + } else { + if (!is_specialist(new_role)) { + obj_controller.marines += 1; + obj_controller.command -= 1; + } + } + } + obj_ini.role[company][marine_number] = new_role; + if (instance_exists(obj_controller)) { + array_push(role_history, [role(), obj_controller.turn]); + } + if (new_role == obj_ini.role[100][5]) { + if (company == 2) { + obj_ini.watch_master_name = name(); + } + if (company == 3) { + obj_ini.arsenal_master_name = name(); + } + if (company == 4) { + obj_ini.lord_admiral_name = name(); + } + if (company == 5) { + obj_ini.march_master_name = name(); + } + if (company == 6) { + obj_ini.rites_master_name = name(); + } + if (company == 7) { + obj_ini.chief_victualler_name = name(); + } + if (company == 8) { + obj_ini.lord_executioner_name = name(); + } + if (company == 9) { + obj_ini.relic_master_name = name(); + } + if (company == 10) { + obj_ini.recruiter_name = name(); + } + scr_recent("captain_promote", name(), company); + } else if (new_role == obj_ini.role[100][4]) { + scr_recent("terminator_promote", name(), company); + } else if (new_role == obj_ini.role[100][2]) { + scr_recent("honor_promote", name(), company); + } else if (new_role == obj_ini.role[100][6]) { + var dread_weapons = ["Close Combat Weapon", "Force Staff", "Twin Linked Lascannon", "Assault Cannon", "Missile Launcher", "Plasma Cannon", "Multi-Melta", "Twin Linked Heavy Bolter"]; + + if (!array_contains(dread_weapons, weapon_one())) { update_weapon_one(""); } - if (!array_contains(dread_weapons,weapon_two())){ + if (!array_contains(dread_weapons, weapon_two())) { update_weapon_two(""); - } - } - }; - - static mobility_item = function(raw=false){ - var wep = obj_ini.mobi[company][marine_number]; - if (is_string(wep) || raw) then return wep; - return obj_ini.artifact[wep]; - }; - static hp = function(){ - return unit_health; //return current unit_health - }; - static add_or_sub_health = function(health_augment){ - unit_health+=health_augment; - unit_health = min(unit_health, max_health()); - } - static healing = function(apoth){ - if (hp()<=0) then exit; - var health_portion = 20; - var m_health = max_health(); - var new_health; - if (apoth){ - if (base_group == "astartes"){ - if (gene_seed_mutations[$ "ossmodula"]){ - health_portion=6; - }else{ - health_portion=4; - } - } else { - health_portion=10; - } - } else { - if (base_group == "astartes"){ - health_portion = 8; - if (gene_seed_mutations[$ "ossmodula"]){ - health_portion = 10; - } - } - } - new_health=hp()+(m_health/health_portion); - if (new_health>m_health) then new_health=m_health; - update_health(new_health); - } - static update_health = function(new_health){ - unit_health = min(new_health, max_health()); - }; - - static hp_portion = function(){ - return (hp()/max_health()); - } - static get_unit_size = function(){ - var unit_role = role(); - var arm = armour(); - var sz = 0; - sz = 1; - var bulky_armour = ["Terminator Armour", "Tartaros"] - if (string_count("Dread",arm)>0) {sz+=5;} else if (array_contains(bulky_armour,arm)){sz +=1}; - //var mobi = mobility_item(); - /*if (mobi == "Jump Pack"){ + } + } + }; + + static mobility_item = function(raw = false) { + var wep = obj_ini.mobi[company][marine_number]; + if (is_string(wep) || raw) { + return wep; + } + return obj_ini.artifact[wep]; + }; + + static hp = function() { + return unit_health; //return current unit_health + }; + + static add_or_sub_health = function(health_augment) { + unit_health += health_augment; + unit_health = min(unit_health, max_health()); + }; + + static healing = function(apoth) { + if (hp() <= 0) { + exit; + } + var health_portion = 20; + var m_health = max_health(); + var new_health; + if (apoth) { + if (base_group == "astartes") { + if (gene_seed_mutations[$ "ossmodula"]) { + health_portion = 6; + } else { + health_portion = 4; + } + } else { + health_portion = 10; + } + } else { + if (base_group == "astartes") { + health_portion = 8; + if (gene_seed_mutations[$ "ossmodula"]) { + health_portion = 10; + } + } + } + new_health = hp() + (m_health / health_portion); + if (new_health > m_health) { + new_health = m_health; + } + update_health(new_health); + }; + + static update_health = function(new_health) { + unit_health = min(new_health, max_health()); + }; + + static hp_portion = function() { + return hp() / max_health(); + }; + + static get_unit_size = function() { + var unit_role = role(); + var arm = armour(); + var sz = 0; + sz = 1; + var bulky_armour = ["Terminator Armour", "Tartaros"]; + if (string_count("Dread", arm) > 0) { + sz += 5; + } else if (array_contains(bulky_armour, arm)) { + sz += 1; + } + //var mobi = mobility_item(); + /*if (mobi == "Jump Pack"){ sz++; }*/ - if (unit_role == "Chapter Master"){sz++} - size =sz; - return size - }; - mobility_item_quality = "standard"; - armour_quality="standard"; - - //Unit update equip slot functions held in sscr_unit_equip_functions - static update_armour = scr_update_unit_armour; - static update_weapon_one = scr_update_unit_weapon_one; - static update_weapon_two = scr_update_unit_weapon_two; - static update_gear = scr_update_unit_gear; - static update_mobility_item = scr_update_unit_mobility_item; - - static max_health =function(base=false){ - var max_h = 100 * (1+((constitution - 40)*0.025)); - if (!base){ - max_h += gear_weapon_data("armour", armour(), "hp_mod"); - max_h += gear_weapon_data("gear", gear(), "hp_mod"); - max_h += gear_weapon_data("mobility", mobility_item(), "hp_mod"); - max_h += gear_weapon_data("weapon", weapon_one(), "hp_mod"); - max_h += gear_weapon_data("weapon", weapon_two(), "hp_mod"); - } - return max_h; - }; - - static increase_max_health = function(increase){ - return max_health() + (increase*(1+((constitution - 40)*0.025))); //calculate the effect of unit_health buffs - }; - - // used both to load unit data from save and to add preset base_stats - static load_json_data = function(data){ //this also allows us to create a pre set of anysort for a marine - try { - var names = variable_struct_get_names(data); - for (var i = 0; i < array_length(names); i++) { - variable_struct_set(self, names[i], variable_struct_get(data, names[i])) - } - } catch (_exception) { - handle_exception(_exception); - } - }; - - traits = []; //marine trait list - feats = []; - allegiance =faction; //faction alligience defaults to the chapter - - static stat_boosts = function(stat_boosters){ - var stats = ARR_stat_list; - var edits = struct_get_names(stat_boosters); - var edit_stat,random_stat,stat_mod; - for (var stat_iter =0; stat_iter 2){ - if (edit_stat[2] == "max"){ - stat_mod = max(stat_mod, edit_stat[0]); - } else if(edit_stat[2] == "min") { - stat_mod = min(stat_mod, edit_stat[0]); - } - } - } else { - stat_mod = edit_stat - } - if (stats[stat_iter] == "constitution"){ - balance_value = (hp()/max_health()); - } - variable_struct_set(self,stats[stat_iter], (variable_struct_get(self, stats[stat_iter])+ stat_mod)); - if (stats[stat_iter] == "constitution"){ - update_health(max_health()*balance_value) - } - } - } - } - //adds a trait to a marines trait list - static add_trait = function(trait){ - var balance_value; - if struct_exists(global.trait_list, trait){ - if (!array_contains(traits, trait)){ - var selec_trait = global.trait_list[$ trait]; - stat_boosts(selec_trait); - array_push(traits, trait); - } - } - }; - - static has_trait = marine_has_trait; - - static add_feat = function(feat){ - feat_data = {}; - if struct_exists(global.trait_list, feat.ident){ - feat_data = global.trait_list[$ feat.ident]; - var feat_name_set = struct_get_names(feat); - for (var i=0;i2){ - if (edit_stat[2] == "max"){ - variable_struct_set(self, stats[stat_iter], max(stat_mod, edit_stat[0])); - } else if (edit_stat[2] == "min"){ - variable_struct_set(self, stats[stat_iter], min(stat_mod, edit_stat[0])); - } else { - variable_struct_set(self, stats[stat_iter], stat_mod); - } - } else { - variable_struct_set(self, stats[stat_iter], stat_mod); - } - } - } - }; - body = generate_marine_body(); -//body parts list can be extended as much as people want - - static alter_body = function(body_slot, body_item_key, new_body_data, overwrite=true){//overwrite means it will replace any existing data - if (struct_exists(body, body_slot)){ - if (!(struct_exists(body[$ body_slot], body_item_key)) || overwrite){ - body[$ body_slot][$ body_item_key] = new_body_data; - } - } else { - return "invalid body area"; - } - } + if (unit_role == "Chapter Master") { + sz++; + } + size = sz; + return size; + }; + + mobility_item_quality = "standard"; + armour_quality = "standard"; + + //Unit update equip slot functions held in sscr_unit_equip_functions + static update_armour = scr_update_unit_armour; + static update_weapon_one = scr_update_unit_weapon_one; + static update_weapon_two = scr_update_unit_weapon_two; + static update_gear = scr_update_unit_gear; + static update_mobility_item = scr_update_unit_mobility_item; + + static max_health = function(base = false) { + var max_h = 100 * (1 + ((constitution - 40) * 0.025)); + if (!base) { + max_h += gear_weapon_data("armour", armour(), "hp_mod"); + max_h += gear_weapon_data("gear", gear(), "hp_mod"); + max_h += gear_weapon_data("mobility", mobility_item(), "hp_mod"); + max_h += gear_weapon_data("weapon", weapon_one(), "hp_mod"); + max_h += gear_weapon_data("weapon", weapon_two(), "hp_mod"); + } + return max_h; + }; + + static increase_max_health = function(increase) { + return max_health() + (increase * (1 + ((constitution - 40) * 0.025))); //calculate the effect of unit_health buffs + }; + + // used both to load unit data from save and to add preset base_stats + static load_json_data = function(data) { + //this also allows us to create a pre set of anysort for a marine + try { + var names = variable_struct_get_names(data); + for (var i = 0; i < array_length(names); i++) { + variable_struct_set(self, names[i], variable_struct_get(data, names[i])); + } + } catch (_exception) { + handle_exception(_exception); + } + }; + + traits = []; //marine trait list + feats = []; + allegiance = faction; //faction alligience defaults to the chapter + + static stat_boosts = function(stat_boosters) { + var stats = ARR_stat_list; + var edits = struct_get_names(stat_boosters); + var edit_stat, random_stat, stat_mod; + for (var stat_iter = 0; stat_iter < array_length(stats); stat_iter++) { + if (array_contains(edits, stats[stat_iter])) { + edit_stat = variable_struct_get(stat_boosters, stats[stat_iter]); + if (is_array(edit_stat)) { + stat_mod = floor(gauss(edit_stat[0], edit_stat[1])); + if (array_length(edit_stat) > 2) { + if (edit_stat[2] == "max") { + stat_mod = max(stat_mod, edit_stat[0]); + } else if (edit_stat[2] == "min") { + stat_mod = min(stat_mod, edit_stat[0]); + } + } + } else { + stat_mod = edit_stat; + } + if (stats[stat_iter] == "constitution") { + balance_value = hp() / max_health(); + } + variable_struct_set(self, stats[stat_iter], (variable_struct_get(self, stats[stat_iter]) + stat_mod)); + if (stats[stat_iter] == "constitution") { + update_health(max_health() * balance_value); + } + } + } + }; + + //adds a trait to a marines trait list + static add_trait = function(trait) { + var balance_value; + if (struct_exists(global.trait_list, trait)) { + if (!array_contains(traits, trait)) { + var selec_trait = global.trait_list[$ trait]; + stat_boosts(selec_trait); + array_push(traits, trait); + } + } + }; + + static has_trait = marine_has_trait; + + static add_feat = function(feat) { + feat_data = {}; + if (struct_exists(global.trait_list, feat.ident)) { + feat_data = global.trait_list[$ feat.ident]; + var feat_name_set = struct_get_names(feat); + for (var i = 0; i < array_length(feat_name_set); i++) { + feat_data[$ feat_name_set[i]] = feat[$ feat_name_set[i]]; + } + } else { + feat_data = feat; + } + stat_boosts(feat_data); + array_push(feats, feat_data); + }; + + static distribute_traits = scr_marine_trait_spawning; + + static alter_equipment = alter_unit_equipment; + static stat_display = scr_draw_unit_stat_data; + static draw_unit_image = scr_draw_unit_image; + static display_wepaons = scr_ui_display_weapons; + static unit_profile_text = scr_unit_detail_text; + static has_equipped = unit_has_equipped; + + static unit_equipment_data = function() { + var armour_data = get_armour_data(); + var gear_data = get_gear_data(); + var mobility_data = get_mobility_data(); + var weapon_one_data = get_weapon_one_data(); + var weapon_two_data = get_weapon_two_data(); + var equip_data = { + armour_data: armour_data, + gear_data: gear_data, + mobility_data: mobility_data, + weapon_one_data: weapon_one_data, + weapon_two_data: weapon_two_data + }; + return equip_data; + }; + + //takes dict and plumbs dict values into unit struct + if (array_contains(variable_struct_get_names(global.base_stats), class)) { + load_json_data(global.base_stats[$ class]); + } + var edit_stat, stat_mod; + var stats = ["constitution", "strength", "luck", "dexterity", "wisdom", "piety", "charisma", "technology", "intelligence", "weapon_skill", "ballistic_skill"]; + for (var stat_iter = 0; stat_iter < array_length(stats); stat_iter++) { + if (struct_exists(self, stats[stat_iter])) { + if (is_array(variable_struct_get(self, stats[stat_iter]))) { + edit_stat = variable_struct_get(self, stats[stat_iter]); + stat_mod = floor(gauss(edit_stat[0], edit_stat[1])); + if (array_length(edit_stat) > 2) { + if (edit_stat[2] == "max") { + variable_struct_set(self, stats[stat_iter], max(stat_mod, edit_stat[0])); + } else if (edit_stat[2] == "min") { + variable_struct_set(self, stats[stat_iter], min(stat_mod, edit_stat[0])); + } else { + variable_struct_set(self, stats[stat_iter], stat_mod); + } + } else { + variable_struct_set(self, stats[stat_iter], stat_mod); + } + } + } + } + body = generate_marine_body(); - static get_body_data = scr_get_body_data; + //body parts list can be extended as much as people want - if (struct_exists(self,"start_gear")){ - if (base_group!="marine"){ - alter_equipment(start_gear,false,false); - } else { - alter_equipment(start_gear,true,true); - } - } - static equipment_maintenance_burden = function(){ - var burden = 0.0; - burden+=get_armour_data("maintenance"); - burden+=get_gear_data("maintenance"); - burden+=get_mobility_data("maintenance"); - burden+=get_weapon_one_data("maintenance"); - burden+=get_weapon_two_data("maintenance"); - if (has_trait("tinkerer")){ - burden *= 0.33; - } - return burden; - } - /*ey so i got this concept where basically take away luck, ballistic_skill and weapon_skill + static alter_body = function(body_slot, body_item_key, new_body_data, overwrite = true) { + //overwrite means it will replace any existing data + if (struct_exists(body, body_slot)) { + if (!struct_exists(body[$ body_slot], body_item_key) || overwrite) { + body[$ body_slot][$ body_item_key] = new_body_data; + } + } else { + return "invalid body area"; + } + }; + + static get_body_data = scr_get_body_data; + + if (struct_exists(self, "start_gear")) { + if (base_group != "marine") { + alter_equipment(start_gear, false, false); + } else { + alter_equipment(start_gear, true, true); + } + } + + static equipment_maintenance_burden = function() { + var burden = 0.0; + burden += get_armour_data("maintenance"); + burden += get_gear_data("maintenance"); + burden += get_mobility_data("maintenance"); + burden += get_weapon_one_data("maintenance"); + burden += get_weapon_two_data("maintenance"); + if (has_trait("tinkerer")) { + burden *= 0.33; + } + return burden; + }; + + /*ey so i got this concept where basically take away luck, ballistic_skill and weapon_skill there are 8 other stats each of which will have more attached aspects and game play elements they effect as time goes on, so that means between the 8 other stats if you had a choice of two there are 64 (or 56 if you exclude double counts) variations of a choice of two, this means each chapter could have two "values" maybe in terms of recruitment maybe in terms of just general chapter stuff. that could be chosen to give boostes to the other stats so as an example salamanders could have the chapter values as */ - loyalty = 0; - switch base_group{ - case "astartes": //basic marine class //adds specific mechanics not releveant to most units - loyalty = 100; - - var _astartes_trait_dist = global.astartes_trait_dist; - distribute_traits(_astartes_trait_dist); - - if (instance_exists(obj_controller)){ - role_history = [[obj_ini.role[company][marine_number], obj_controller.turn]]; //marines_promotion and demotion history - marine_ascension = ((obj_controller.millenium*1000)+obj_controller.year); // on what day did this marine begin to exist - } else { - role_history = [[obj_ini.role[company][marine_number], "pre_game"]]; - marine_ascension = "pre_game"; // on what day did turn did this marine begin to exist - } - - roll_psionics(); - - alter_body("torso","black_carapace",true); - if (class=="scout" && global.chapter_name!="Space Wolves"){ - alter_body("torso","black_carapace",false); - } - if (faction ="chapter"){ - allegiance = global.chapter_name; - } - - assign_inherent_mutations(); - assign_random_mutations(); - - if (gene_seed_mutations[$ "voice"] == 1){ - charisma-=2; - } - - static assign_inherent_mutations = function() { - gene_seed_mutations = { - "preomnor": obj_ini.preomnor, - "lyman": obj_ini.lyman, - "omophagea": obj_ini.omophagea, - "ossmodula": obj_ini.ossmodula, - "zygote": obj_ini.zygote, - "betchers": obj_ini.betchers, - "catalepsean": obj_ini.catalepsean, - "occulobe": obj_ini.occulobe, - "mucranoid": obj_ini.mucranoid, - "membrane": obj_ini.membrane, - "voice": obj_ini.voice - }; - }; - - static assign_random_mutations = function() { - var _mutation_roll = roll_personal_dice(1, 100, "high", self); - var _mutation_threshold = 100 - obj_ini.stability; - if (_mutation_roll <= _mutation_threshold) { - var _mutation_names = struct_get_names(gene_seed_mutations); - var _possible_mutations = []; - for (var i = 0; i < array_length(_mutation_names); i++) { - var _mutation = _mutation_names[i]; - if (gene_seed_mutations[$ _mutation] == 0) { - array_push(_possible_mutations, _mutation); - } - } - - var _mutations_assigned = 0; - repeat (array_length(_possible_mutations)) { - if (array_length(_possible_mutations) > 0) { - var _picked_mutation = array_random_index(_possible_mutations); - gene_seed_mutations[$ _possible_mutations[_picked_mutation]] = 1; - array_delete(_possible_mutations, _picked_mutation, 1); - _mutations_assigned++; - _mutation_threshold = max(_mutation_threshold - 5 * _mutations_assigned, 0); - if (_mutation_roll <= _mutation_threshold) { - continue; - } else { - break; - } - } else { - break; - } - } - } - }; - - //array index 0 == trait to add - // array index 1 == probability e.g 99,98 == if (irandom(99)>98){add_trait} - // array index 3 == probability modifiers - - if (global.chapter_name=="Space Wolves") or (obj_ini.progenitor == ePROGENITOR.SPACE_WOLVES) { - religion_sub_cult = "The Allfather"; - } else if(global.chapter_name=="Salamanders") or (obj_ini.progenitor == ePROGENITOR.SALAMANDERS) { - religion_sub_cult = "The Promethean Cult"; - } else if (global.chapter_name=="Iron Hands" || obj_ini.progenitor == ePROGENITOR.IRON_HANDS) { - religion_sub_cult = "The Cult of Iron"; - } - - var _robe_chance = 5; - if (global.chapter_name == "Black Templars"){ - _robe_chance += 70; - } else if (scr_has_style("Knightly")){ - _robe_chance += 50; - } - if (irandom(100) <= _robe_chance) { - body.torso.robes = irandom(2); - if (body[$"torso"].robes == 0 && irandom(1) == 0){ - body[$"head"].hood = 1; - } - } - - var _cloak_chance = 5; - if (role() == obj_ini.role[100][eROLE.Chaplain]) { - _cloak_chance += 25; - } else if (IsSpecialist("libs")) { - _cloak_chance += 75; - } - if (irandom(100) <= _cloak_chance) { - if (global.chapter_name == "Salamanders") { - body.cloak.type = "scale"; - } else if (global.chapter_name == "Space Wolves") { - body.cloak.type = "pelt"; - } else { - body.cloak.type = "cloth"; - body.cloak.variation = irandom(100); - body.cloak.image_0 = irandom(100); - body.cloak.image_1 = irandom(100); - } - } - break; - case "tech_priest": - loyalty = obj_controller.disposition[eFACTION.Mechanicus]-10; - religeon = "cult_mechanicus"; - bionics = (irandom(5)+4); - add_trait("flesh_is_weak"); - psionic = irandom(4); - 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); - } - static calculate_death = function(death_threshold = 25, death_random=50,apothecary=true, death_type="normal"){ - dies = false; - death_random += luck; - death_threshold+=luck; - if (death_type=="normal"){ - death_threshold += (constitution/10); - if (has_trait("very_hard_to_kill")){ - death_threshold += 3; - } - } - var chance = irandom(death_random); - if (death_random>death_threshold){ - dies = true; - } - return false; - } - - static add_bionics = function(area="none", bionic_quality="any", from_armoury=true){ - if (from_armoury && scr_item_count("Bionics",bionic_quality)<1){ - return "no bionics"; - }else if (from_armoury){ - remove_quality = scr_add_item("Bionics",-1, bionic_quality); - } else { - remove_quality=choose("standard","standard","standard","standard","standard", "master_crafted","artifact"); - } - var new_bionic_pos, part, new_bionic = {quality :scr_add_item}; - if (bionics < 10){ - if (has_trait("flesh_is_weak")){ - add_or_sub_health(40); - } else { - add_or_sub_health(30); - } - var bionic_possible = []; - var _body_parts = ARR_body_parts; - for (var body_part = 0; body_part < array_length(_body_parts);body_part++){ - part = _body_parts[body_part]; - if (!get_body_data("bionic",part)){ - array_push(bionic_possible, part); - } - } - if (array_length(bionic_possible) > 0){ - if (area!="none"){ - if (array_contains(bionic_possible, area)){ - new_bionic_pos = area; - } else { - return 0; - } - } else { - new_bionic_pos = bionic_possible[irandom(array_length(bionic_possible)-1)]; - } - bionics++; - alter_body(new_bionic_pos, "bionic",new_bionic) - if (array_contains(["left_leg", "right_leg"], new_bionic_pos)){ - constitution += 2; - strength++; - dexterity -= 2; - body[$ new_bionic_pos][$"bionic"].variant=irandom(100); - }else if (array_contains(["left_eye", "right_eye"], new_bionic_pos)){ - body[$ new_bionic_pos][$"bionic"].variant=irandom(100); - constitution += 1; - wisdom += 1; - dexterity++; - } else if (array_contains(["left_arm", "right_arm"], new_bionic_pos)){ - body[$ new_bionic_pos][$"bionic"].variant=irandom(100); - constitution += 2; - strength += 2; - weapon_skill--; - } else if (new_bionic_pos == "torso"){ - constitution += 4; - strength++; - dexterity--; - } else if (new_bionic_pos == "throat"){ - charisma--; - }else{ - constitution++; - } - if (has_trait("flesh_is_weak")){ - piety++; - } - } - if (hp()>max_health()){update_health(max_health())} - } - }; - static age = function(){ - var real_age = obj_ini.age[company][marine_number]; - return real_age; - };// age - - static update_age = function(new_val){ - obj_ini.age[company][marine_number] = new_val; - }; - - static name = function(){ - return obj_ini.name[company][marine_number]; - };// get marine name - - static gear = function(raw=false){ - var wep = obj_ini.gear[company][marine_number]; - if (is_string(wep) || raw) then return wep; - return obj_ini.artifact[wep]; - }; - - 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 - } - - static weapon_one = function(raw=false){ - var wep = obj_ini.wep1[company][marine_number]; - if (is_string(wep) || raw) then return wep; - return obj_ini.artifact[wep]; - }; - - static equipments_qual_string = function(slot, art_only=false){ - var item; - var quality; - switch (slot){ - case "wep1": - item = weapon_one(true); - quality = weapon_one_quality; - break; - case "wep2": - item = weapon_two(true); - quality = weapon_two_quality; - break; - case "armour": - item = armour(true); - quality = armour_quality; - break; - case "gear": - item = gear(true); - quality = gear_quality; - break; - case "mobi": - item = mobility_item(true); - quality =mobility_item_quality; - break; - } - - var is_artifact = !is_string(item); - if (!is_artifact && art_only == false){ - return $"{item}"; - } else if (is_artifact) { - if (obj_ini.artifact_struct[item].name==""){ - return $"{obj_ini.artifact[item]}"; - } else { - return obj_ini.artifact_struct[item].name; - } - } else { - return $"{item}"; - } - } - - weapon_one_data={quality:"standard"}; - weapon_one_quality = "standard"; - - static weapon_viable = function(new_weapon,quality){ - viable = true; - qual_string = quality; - if (scr_item_count(new_weapon, quality)>0){ - var exp_require = gear_weapon_data("weapon", new_weapon, "req_exp", false, quality); - if (exp_require>experience){ - viable = false; - qual_string = "exp_low"; - } - quality=scr_add_item(new_weapon,-1,quality); - if (quality == "no_item") then return [false, "no_items"] - qual_string = quality!=undefined? quality:"standard"; - } else { - viable = false; - qual_string = "no_items"; - } - if (new_weapon=="Company Standard"){ - if (role()!=obj_ini.role[100][11]){ - viable = false; - qual_string = "wrong_role"; - } - } - return [viable, qual_string]; - } - - static weapon_two = function(raw=false){ - var wep = obj_ini.wep2[company][marine_number]; - if (is_string(wep) || raw) then return wep; - return obj_ini.artifact[wep]; - }; - - weapon_two_quality="standard"; - - static specials = function(){ - return obj_ini.spe[company][marine_number]; - }; - - static specials_array = function(){ - var _specials_array = string_split(obj_ini.spe[company][marine_number], "|", true); - return _specials_array; - }; - - static psy_discipline = function(){ - var _specials_array = specials_array(); - var _first_power_prefix = string_letters(_specials_array[0]); - var _discipline = match_power_prefix(_first_power_prefix); - - return _discipline ?? ""; - }; - - static update_powers = function() { - var _powers_limit = 0; - var _powers_known_count = 0; - var _discipline_powers_max = 0; - var _powers_learned = 0; - var _abilities_string = specials(); - - var _discipline_prefix = get_discipline_data(obj_ini.psy_powers, "prefix"); - var _discipline_powers = get_discipline_data(obj_ini.psy_powers, "powers"); - _discipline_powers_max = array_length(_discipline_powers); - - _powers_limit = floor(experience / 30); - _powers_known_count = string_count(string(_discipline_prefix), _abilities_string); - - while ((_powers_known_count < _powers_limit) && (_powers_known_count < _discipline_powers_max)) { - var _power_index = _powers_known_count; - if (string_count(string(_power_index), _abilities_string) == 0) { - _powers_known_count++; - _powers_learned++; - obj_ini.spe[company, marine_number] += string(_discipline_prefix) + string(_power_index) + "|"; - array_push(powers_known, _discipline_powers[_power_index]); - } - } - - return _powers_learned; - }; - - static roll_psionic_increase = function() { - if (psionic < 12) { - var _psionic_difficulty = (psionic * 50) - experience; - - var _dice_roll = roll_personal_dice(1, _psionic_difficulty, "high", self); - if (_dice_roll == _psionic_difficulty) { - psionic++; - add_battle_log_message($"{name_role()} was touched by the warp!", 999, 135); - } - } - }; - - static roll_psionics = function() { - var _dice_count = marine_ascension == "pre_game" ? 1 : 2; - var _psionics_roll = roll_dice(_dice_count, 100); - - if (scr_has_adv("Warp Touched")) { - if (_psionics_roll < 170) { - var _second_roll = roll_personal_dice(_dice_count, 100, "high", self); - _psionics_roll = _second_roll > _psionics_roll ? _second_roll : _psionics_roll; - } - } else if (scr_has_disadv("Psyker Intolerant")) { - if (_psionics_roll >= 170) { - var _second_roll = roll_personal_dice(_dice_count, 100, "low", self); - _psionics_roll = _second_roll < _psionics_roll ? _second_roll : _psionics_roll; - } - } - - if (_psionics_roll == 200) { - psionic = 12; - } else if (_psionics_roll >= 199) { - psionic = 11; - } else if (_psionics_roll >= 198) { - psionic = 10; - } else if (_psionics_roll >= 196) { - psionic = 9; - } else if (_psionics_roll >= 194) { - psionic = 8; - } else if (_psionics_roll >= 190) { - psionic = 7; - } else if (_psionics_roll >= 186) { - psionic = 6; - } else if (_psionics_roll >= 182) { - psionic = 5; - } else if (_psionics_roll >= 178) { - psionic = 4; - } else if (_psionics_roll >= 174) { - psionic = 3; - } else if (_psionics_roll >= 170) { - psionic = 2; - } else if (_psionics_roll >= 22) { - psionic = 1; - } else if (_psionics_roll >= 17) { - psionic = 0; - } else if (_psionics_roll >= 12) { - psionic = -1; - } else if (_psionics_roll >= 8) { - psionic = -2; - } else if (_psionics_roll >= 5) { - psionic = -3; - } else if (_psionics_roll >= 3) { - psionic = -4; - } else if (_psionics_roll >= 2) { - psionic = -5; - } else { - psionic = -6; - } - } - - static role_refresh = function() { - if (role() == "Lexicanum" && psionic >= 5 && experience > 50) { - update_role("Codiciery"); - } else if (role() == "Codiciery" && psionic >= 8 && experience > 100) { - update_role(obj_ini.role[100][eROLE.Librarian]); - } - }; - - static race = function(){ - return obj_ini.race[company][marine_number]; - }; - - //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"){ - return gear_weapon_data("armour", armour(), type, false, armour_quality); - } - static get_gear_data= function(type="all"){ - return gear_weapon_data("gear", gear(), type, false, gear_quality); - } - static get_mobility_data= function(type="all"){ - return gear_weapon_data("mobility", mobility_item(), type, false, mobility_item_quality); - } - static get_weapon_one_data= function(type="all"){ - return gear_weapon_data("weapon", weapon_one(), type, false, weapon_one_quality); - } - static get_weapon_two_data= function(type="all"){ - return gear_weapon_data("weapon", weapon_two(), type, false, weapon_two_quality); - } - static damage_resistance = function(){ - damage_res = 0; - damage_res+=get_armour_data("damage_resistance_mod"); - damage_res+=get_gear_data("damage_resistance_mod"); - damage_res+=get_mobility_data("damage_resistance_mod"); - damage_res+=get_weapon_one_data("damage_resistance_mod"); - damage_res+=get_weapon_two_data("damage_resistance_mod"); - damage_res = min(75, damage_res+floor(((constitution*0.005) + (experience/1000))*100)); - return damage_res; - }; - - static ranged_hands_limit = function(){ - var ranged_carrying = 0; - var carry_string = ""; - var ranged_hands_limit = 2; - - var wep_one_carry = get_weapon_one_data("ranged_hands"); - if (wep_one_carry != 0){ - ranged_carrying += wep_one_carry; - carry_string += $"{weapon_one()}: {wep_one_carry}#"; - } - var wep_two_carry = get_weapon_two_data("ranged_hands"); - if (wep_two_carry != 0){ - ranged_carrying += wep_two_carry; - carry_string += $"{weapon_two()}: {wep_two_carry}#"; - } - if ranged_carrying != 0{ - carry_string = $" =Carrying=#" + carry_string; - } - - carry_string += $" =Maximum=#" - if (base_group == "astartes"){ - ranged_hands_limit = 2 - } else if base_group == "tech_priest" { - ranged_hands_limit = 1+(technology/100); - } else if base_group == "human" { - ranged_hands_limit = 1; - } - carry_string+=$"Base: {ranged_hands_limit}#"; - if (strength>=50){ - ranged_hands_limit+=0.5; - carry_string+="STR: +0.5#"; - } - if (ballistic_skill>=50){ - ranged_hands_limit+=0.25; - carry_string+="BS: +0.25#"; - } - var armour_carry = get_armour_data("ranged_hands"); - if (armour_carry!=0){ - ranged_hands_limit+=armour_carry; - carry_string+=$"{armour()}: {format_number_with_sign(armour_carry)}#"; - } - var gear_carry = get_gear_data("ranged_hands"); - if (gear_carry!=0){ - ranged_hands_limit+=gear_carry; - carry_string+=$"{gear()}: {format_number_with_sign(gear_carry)}#"; - } - var mobility_carry = get_mobility_data("ranged_hands"); - if (mobility_carry!=0){ - ranged_hands_limit+=mobility_carry; - carry_string+=$"{mobility_item()}: {format_number_with_sign(mobility_carry)}#"; - } - return [ranged_carrying,ranged_hands_limit,carry_string] - } - - static ranged_attack = function(weapon_slot=0){ - encumbered_ranged=false; - //base modifyer based on unit skill set - ranged_att = 100*(((ballistic_skill/50) + (dexterity/400)+ (experience/500))); - var final_range_attack=0; - var explanation_string = $"Stat Mod: x{ranged_att/100}# BS: x{ballistic_skill/50}# DEX: x{dexterity/400}# EXP: x{experience/500}#"; - //determine capavbility to weild bulky weapons - var carry_data =ranged_hands_limit(); - - //base multiplyer - var range_multiplyer = 1; - - //grab generic structs for weapons - var _wep1 = get_weapon_one_data(); - var _wep2 = get_weapon_two_data(); - - if (!is_struct(_wep1)) then _wep1 = new EquipmentStruct({},""); - if (!is_struct(_wep2)) then _wep2 = new EquipmentStruct({},""); - if (allegiance==global.chapter_name){ - _wep1.owner_data("chapter"); - _wep2.owner_data("chapter"); - } - var primary_weapon= new EquipmentStruct({},""); - var secondary_weapon= new EquipmentStruct({},""); - if (carry_data[0]>carry_data[1]){ - encumbered_ranged=true; - ranged_att*=0.6; - explanation_string+=$"Encumbered:X0.6#"; - } - if (weapon_slot==0){ - //decide if any weapons are ranged - if (_wep1.range<1.1 && _wep2.range<1.1){ - if (array_length(_wep1.second_profiles) + array_length(_wep2.second_profiles) ==0){ - ranged_damage_data = [final_range_attack,explanation_string,carry_data,primary_weapon, secondary_weapon]; - } else { - var other_profiles = array_concat(_wep1.second_profiles,_wep2.second_profiles); - for (var sec = 0;sec1.1 && sec_profile.attack>0){ - final_range_attack+=(sec_profile.attack*(ranged_att/100)); - explanation_string+=$"{sec_profile.name} +{sec_profile.attack}#"; - } - } - } - if (array_length(_wep1.second_profiles)>0) then primary_weapon=gear_weapon_data("weapon",_wep1.second_profiles[0],"all",false,weapon_one_quality); - if (array_length(_wep2.second_profiles)>0) then primary_weapon=gear_weapon_data("weapon",_wep2.second_profiles[0],"all",false,weapon_two_quality); - ranged_damage_data = [final_range_attack,explanation_string,carry_data,primary_weapon, secondary_weapon]; - } - return ranged_damage_data; - } else { - if (_wep1.range<=1.1){ - primary_weapon=_wep2; - } else if (_wep2.range<=1.1){ - primary_weapon=_wep1; - } else { - //if both weapons are ranged pick best - if (_wep1.attack>_wep2.attack){ - primary_weapon=_wep1; - secondary_weapon=_wep2; - } else{ - secondary_weapon=_wep1; - primary_weapon=_wep2; - } - } - } - } else { - if (weapon_slot==1){ - primary_weapon=_wep1; - } else if (weapon_slot==2){ - primary_weapon=_wep2; - } - }; - //calculate chapter specific bonus - if (allegiance==global.chapter_name){//calculate player specific bonuses - if (primary_weapon.has_tag("bolt")){ - if (scr_has_adv("Bolter Drilling") && base_group=="astartes"){ - range_multiplyer+=0.15; - explanation_string+=$"Bolter Drilling:X1.15#" - } - } - if (primary_weapon.has_tag("energy")){ - if (scr_has_adv("Ryzan Patronage") && base_group=="astartes"){ - range_multiplyer+=0.15; - explanation_string+=$"Ryzan Craftsmanship:X1.15#" - } - } - if (primary_weapon.has_tag("heavy_ranged")){ - if (scr_has_adv("Devastator Doctrine") && base_group=="astartes"){ - range_multiplyer+=0.15; - explanation_string+=$"Devastator Doctrine:X1.15#" - } - } - } - if (!encumbered_ranged){ - var total_gear_mod=0; - total_gear_mod+=get_armour_data("ranged_mod"); - total_gear_mod+=get_gear_data("ranged_mod"); - total_gear_mod+=get_mobility_data("ranged_mod"); - total_gear_mod+=_wep1.ranged_mod; - total_gear_mod+=_wep2.ranged_mod; - ranged_att+=total_gear_mod; - explanation_string+=$"Gear Mod: x{(total_gear_mod/100)+1}#"; - if (has_trait("feet_floor") && mobility_item()!=""){ - ranged_att*=0.9; - explanation_string+=$"{global.trait_list.feet_floor.display_name}:X0.9#"; - } - } - //return final ranged damage output - final_range_attack = floor((ranged_att/100)* primary_weapon.attack); - explanation_string = $"{primary_weapon.name}: {primary_weapon.attack}#" + explanation_string - if (!encumbered_ranged){ - if (primary_weapon.has_tag("pistol") &&secondary_weapon.has_tag("pistol")){ - final_range_attack+=floor((ranged_att/100)* secondary_weapon.attack); - explanation_string+=$"Dual Pistols: +{secondary_weapon.attack}#"; - } else if (secondary_weapon.attack>0){ - var second_attack =floor((ranged_att/100)* secondary_weapon.attack)*0.5; - final_range_attack+=second_attack; - explanation_string+=$"Secondary: +{second_attack}#"; - } - } - ranged_damage_data = [final_range_attack,explanation_string,carry_data,primary_weapon, secondary_weapon]; - return ranged_damage_data; - }; - - static melee_hands_limit = function(){ - var melee_carrying = 0; - var carry_string = ""; - var melee_hands_limit = 2; - - var wep_one_carry = get_weapon_one_data("melee_hands"); - if (wep_one_carry != 0){ - melee_carrying += wep_one_carry; - carry_string += $"{weapon_one()}: {wep_one_carry}#"; - } - var wep_two_carry = get_weapon_two_data("melee_hands"); - if (wep_two_carry != 0){ - melee_carrying += wep_two_carry; - carry_string += $"{weapon_two()}: {wep_two_carry}#"; - } - if melee_carrying != 0{ - carry_string = $" =Carrying=#" + carry_string; - } - - carry_string += $" =Maximum=#" - if (base_group == "astartes"){ - melee_hands_limit = 2 - } else if base_group == "tech_priest" { - melee_hands_limit = 1+(technology/100); - } else if base_group == "human" { - melee_hands_limit = 1; - } - carry_string+="Base: 2#"; - if (strength>=50){ - melee_hands_limit+=0.25; - carry_string+="STR: +0.25#"; - } - if (weapon_skill>=50){ - melee_hands_limit+=0.25; - carry_string+="WS: +0.25#"; - } - if (has_trait("champion")){ - melee_hands_limit+=0.25; - carry_string+="Champion: +0.25#"; - } - var armour_carry = get_armour_data("melee_hands") - if (armour_carry!=0){ - melee_hands_limit+=armour_carry; - carry_string+=$"{armour()}: {format_number_with_sign(armour_carry)}#"; - } - var gear_carry = get_gear_data("melee_hands"); - if (gear_carry!=0){ - melee_hands_limit+=gear_carry; - carry_string+=$"{gear()}: {format_number_with_sign(gear_carry)}#"; - } - var mobility_carry = get_mobility_data("melee_hands"); - if (mobility_carry!=0){ - melee_hands_limit+=mobility_carry; - carry_string+=$"{mobility_item()}: {format_number_with_sign(mobility_carry)}#"; - } - return [melee_carrying,melee_hands_limit,carry_string] - } - static melee_attack = function(weapon_slot=0){ - encumbered_melee=false; - melee_att = 100*(((weapon_skill/100) * (strength/20)) + (experience/1000)+0.1); - var explanation_string = string_concat("#Stats: ", format_number_with_sign(round(((melee_att/100)-1)*100)), "%#"); - explanation_string += " Base: +10%#"; - explanation_string += string_concat(" WSxSTR: ", format_number_with_sign(round((((weapon_skill/100)*(strength/20))-1)*100)), "%#"); - explanation_string += string_concat(" EXP: ", format_number_with_sign(round((experience/1000)*100)), "%#"); - - melee_carrying = melee_hands_limit(); - var _wep1 = get_weapon_one_data(); - var _wep2 = get_weapon_two_data(); - if (!is_struct(_wep1)) then _wep1 = new EquipmentStruct({},""); - if (!is_struct(_wep2)) then _wep2 = new EquipmentStruct({},""); - if (allegiance==global.chapter_name){ - _wep1.owner_data("chapter"); - _wep2.owner_data("chapter"); - } - var primary_weapon; - var secondary_weapon="none"; - if (weapon_slot==0){ - //if player has not melee weapons - var valid1 = ((_wep1.range<=1.1 && _wep1.range!=0) || (_wep1.has_tags(["pistol","flame"]))); - var valid2 = ((_wep2.range<=1.1 && _wep2.range!=0) || (_wep2.has_tags(["pistol","flame"]))); - if (!valid1 && !valid2){ - primary_weapon=new EquipmentStruct({},"");//create blank weapon struct - primary_weapon.attack=strength/3;//calculate damage from player fists - primary_weapon.name="fists"; - primary_weapon.range = 1; - primary_weapon.ammo = -1; - } else { - if (!valid1 && valid2){ - primary_weapon=_wep2; - } else if (valid1 && !valid2){ - primary_weapon=_wep1; - } else { - var highest = _wep1.attack>_wep2.attack ? _wep1 :_wep2; - var lowest = _wep1.attack<=_wep2.attack ? _wep1 :_wep2; - if (!highest.has_tags(["pistol","flame"])){ - primary_weapon = highest; - secondary_weapon=lowest; - }else if (!lowest.has_tags(["pistol","flame"])){ - primary_weapon = lowest; - secondary_weapon=highest; - } else { - primary_weapon=highest; - melee_att*=0.5; - if (primary_weapon.has_tag("flame")){ - explanation_string+=$"Primary is Flame: -50%#" - } else if primary_weapon.has_tag("pistol"){ - explanation_string+=$"Primary is Pistol: -50%#" - } - secondary_weapon=lowest; - } - } - } - } else { - if (weapon_slot==1){ - primary_weapon=_wep1; - } else if (weapon_slot==2){ - primary_weapon=_wep2; - } - } - - var basic_wep_string = $"{primary_weapon.name}: {primary_weapon.attack}#"; - - if (psionic > 0){ - if (has_force_weapon()){ - var psychic_bonus = psionic * 20; - psychic_bonus *= 0.5 + (wisdom / 100); - psychic_bonus *= 0.5 + (experience / 100); - psychic_bonus *= IsSpecialist("libs") ? 1 : 0.25; - psychic_bonus = round(psychic_bonus); - primary_weapon.attack += psychic_bonus; - basic_wep_string += $"Psychic Power: +{psychic_bonus}#"; - } - } - - explanation_string = basic_wep_string + explanation_string; - - if (melee_carrying[0]>melee_carrying[1]){ - encumbered_melee=true; - melee_att*=0.6; - explanation_string+=$"Encumbered: x0.6#" - } - if (!encumbered_melee){ - var total_gear_mod=0; - total_gear_mod+=get_armour_data("melee_mod"); - total_gear_mod+=get_gear_data("melee_mod"); - total_gear_mod+=get_mobility_data("melee_mod"); - total_gear_mod+=_wep1.melee_mod; - total_gear_mod+=_wep2.melee_mod; - melee_att+=total_gear_mod; - explanation_string+=$"#Gear Mod: {(total_gear_mod/100)*100}%#"; - //TODO make trait data like this more structured to be able to be moddable - if (has_trait("feet_floor") && mobility_item()!=""){ - melee_att*=0.9; - explanation_string+=$"{global.trait_list.feet_floor.display_name}: x0.9#"; - } - if (primary_weapon.has_tag("fist") && has_trait("brawler")){ - melee_att*=1.1; - explanation_string+=$"{global.trait_list.brawler.display_name}: x1.1#"; - } - if (primary_weapon.has_tag("power") && has_trait("duelist")){ - melee_att*=1.3; - explanation_string+=$"{global.trait_list.duelist.display_name}: x1.3#"; - } - } - var final_attack = floor((melee_att/100)*primary_weapon.attack); - if (secondary_weapon!="none" && !encumbered_melee){ - var side_arm_data="Standard: x0.5"; - var secondary_modifier = 0.5; - if (primary_weapon.has_tag("dual") && secondary_weapon.has_tag("dual")){ - secondary_modifier=1 - side_arm_data="Dual: x1"; - } else if (secondary_weapon.has_tag("pistol")){ - if (melee_carrying[0]+0.8>=melee_carrying[1]){ - secondary_modifier=0; - }else { - secondary_modifier = 0.6; - side_arm_data="Pistol: x0.8"; - } - } else if (secondary_weapon.has_tag("flame")){ - secondary_modifier = 0.3; - side_arm_data="Flame: x0.3"; - } - var side_arm = floor(secondary_modifier*((melee_att/100)*secondary_weapon.attack)); - if (side_arm>0){ - final_attack+=side_arm; - explanation_string+=$"Side Arm: +{side_arm}({side_arm_data})#"; - } - } - melee_damage_data=[final_attack,explanation_string,melee_carrying,primary_weapon, secondary_weapon]; - return melee_damage_data; - }; - - static has_force_weapon = function(){ - var _wep1 = get_weapon_one_data(); - var _wep2 = get_weapon_two_data(); - - if (is_struct(_wep1) && _wep1.has_tag("force")) { - return true; - } - - if (is_struct(_wep2) && _wep2.has_tag("force")) { - return true; - } - - return false; - } - - //TODO just did this so that we're not loosing featuring but this porbably needs a rethink - static hammer_of_wrath = function(){ - var _melee_attack = melee_damage_data[0]; - var _melee_weapon = melee_damage_data[3]; - - var wrath = new EquipmentStruct({ - attack : _melee_attack * 0.75, - name : "Hammer of Wrath", - range : 2, - ammo : 6, - spli : _melee_weapon.spli, - arp : _melee_weapon.arp - },"weapon"); - - var wrath_melee = new EquipmentStruct({ - attack : _melee_attack * 1.25, - name : "Hammer of Wrath(M)", - range : 1, - ammo : 8, - spli : _melee_weapon.spli, - arp : _melee_weapon.arp, - },"weapon"); - - wrath.second_profiles = [wrath_melee]; - - return wrath; - } - - static armour_calc = function(){ - armour_rating=0; - armour_rating+=get_armour_data("armour_value") - armour_rating+=get_weapon_one_data("armour_value") - armour_rating+=get_mobility_data("armour_value") - armour_rating+=get_gear_data("armour_value") - armour_rating+=get_weapon_two_data("armour_value") - if (armour() != ""&& allegiance==global.chapter_name){ // STC Bonuses - if (obj_controller.stc_bonus[1] == 5) { - armour_rating*=1.05 - } - if (obj_controller.stc_bonus[2] == 3) { - armour_rating*=1.05 - } - } - return armour_rating; - } - - static assignment = function(){ - if (squad != "none"){ - if (obj_ini.squads[squad].assignment != "none"){ - return obj_ini.squads[squad].assignment.type; - } - } - if (job != "none"){ - return job.type; - } else { - return "none" - } - } - - static remove_from_squad = function(){ - if (squad != "none"){ - if (squad < array_length(obj_ini.squads)){ - for (var r=0;r 0){ //if marine is on planet - location_id = 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; - } - 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_id0) then star.p_player[current_location[1]]-=size; - } - } - } 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]) and ((obj_ini.ship_carrying[ship] + size) <= obj_ini.ship_capacity[ship])){ - obj_ini.ship_carrying[off_loading_ship] -= 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 - } - } - }; - - - 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]; - } else { - last_ship = { - uid : "", - name : "" - } - } - } - - 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]]; - planet_location=planet_number; - ship_location=-1; - get_unit_size(); - system.p_player[planet_number]+= size; - obj_ini.ship_carrying[current_location[1]] -= size; - } - } else { - ship_location=-1; - obj_ini.loc[company][marine_number]=system.name; - planet_location=planet_number; - system.p_player[planet_number]+= size; - } - } - - static allocate_unit_to_fresh_spawn = function(type="default"){ - var homestar = "none"; - var spawn_location_chosen = false; - if ((type="home") or (type="default")) and (obj_ini.fleet_type==ePlayerBase.home_world){ - var homestar = star_by_name(obj_ini.home_name); - } else if (type !="ship"){ - var homestar = star_by_name(type); - } - /* if (!spawn_location_chosen){ - - }*/ - if (homestar!="none"){ - for (var i=1;i<=homestar.planets;i++){ - if (homestar.p_owner[i]==eFACTION.Player|| - (obj_controller.faction_status[eFACTION.Imperium]!="War" && - array_contains(obj_controller.imperial_factions, homestar.p_owner[i]))){ - planet_location = i; - obj_ini.loc[company][marine_number]=obj_ini.home_name; - spawn_location_chosen=true; - } - } - } - if (!spawn_location_chosen){ - var player_fleet = get_largest_player_fleet(); - if (player_fleet != "none"){ - get_unit_size(); - load_unit_to_fleet(player_fleet,self); - spawn_location_chosen=true; - } - //TODO add more work arounds in case of no valid spawn point - if (!spawn_location_chosen){ - if (player_fleet != "none"){ - - } - } - } - } - - static specialist_tooltips = specialistfunct; - static is_at_location = function(location="", planet=0, ship=-1){ - var is_at_loc = false; - if (planet>0){ - if (obj_ini.loc[company][marine_number]==location && planet_location=planet){ - is_at_loc=true; - } - } else if (ship>-1){ - if (ship_location==ship){ - is_at_loc=true; - } - } else if (ship==-1 && planet==0){ - if (ship_location>-1){ - if (obj_ini.ship_location[ship_location]==location){ - is_at_loc=true; - } - } else if (obj_ini.loc[company][marine_number]==location){ - is_at_loc=true; - } - } - return is_at_loc; - } - - static edit_corruption = function (edit){ - corruption = edit > 0 ?min(100, corruption+edit) : max(0, corruption+edit); - } + loyalty = 0; + switch (base_group) { + case "astartes": //basic marine class //adds specific mechanics not releveant to most units + loyalty = 100; + + var _astartes_trait_dist = global.astartes_trait_dist; + distribute_traits(_astartes_trait_dist); + + if (instance_exists(obj_controller)) { + role_history = [ + [obj_ini.role[company][marine_number], obj_controller.turn] + ]; //marines_promotion and demotion history + marine_ascension = (obj_controller.millenium * 1000) + obj_controller.year; // on what day did this marine begin to exist + } else { + role_history = [ + [obj_ini.role[company][marine_number], "pre_game"] + ]; + marine_ascension = "pre_game"; // on what day did turn did this marine begin to exist + } - static in_jail = function(){ - return (obj_ini.god[company,marine_number]>=10); - } + roll_psionics(); - static forge_point_generation = unit_forge_point_generation; + alter_body("torso", "black_carapace", true); + if (class == "scout" && global.chapter_name != "Space Wolves") { + alter_body("torso", "black_carapace", false); + } + if (faction == "chapter") { + allegiance = global.chapter_name; + } - static apothecary_point_generation = unit_apothecary_points_gen; + assign_inherent_mutations(); + assign_random_mutations(); - static marine_assembling = scr_marine_game_spawn_constructions; + if (gene_seed_mutations[$ "voice"] == 1) { + charisma -= 2; + } - static random_update_armour = scr_marine_spawn_armour; + static assign_inherent_mutations = function() { + gene_seed_mutations = { + "preomnor": obj_ini.preomnor, + "lyman": obj_ini.lyman, + "omophagea": obj_ini.omophagea, + "ossmodula": obj_ini.ossmodula, + "zygote": obj_ini.zygote, + "betchers": obj_ini.betchers, + "catalepsean": obj_ini.catalepsean, + "occulobe": obj_ini.occulobe, + "mucranoid": obj_ini.mucranoid, + "membrane": obj_ini.membrane, + "voice": obj_ini.voice + }; + }; + + static assign_random_mutations = function() { + var _mutation_roll = roll_personal_dice(1, 100, "high", self); + var _mutation_threshold = 100 - obj_ini.stability; + if (_mutation_roll <= _mutation_threshold) { + var _mutation_names = struct_get_names(gene_seed_mutations); + var _possible_mutations = []; + for (var i = 0; i < array_length(_mutation_names); i++) { + var _mutation = _mutation_names[i]; + if (gene_seed_mutations[$ _mutation] == 0) { + array_push(_possible_mutations, _mutation); + } + } + + var _mutations_assigned = 0; + repeat(array_length(_possible_mutations)) { + if (array_length(_possible_mutations) > 0) { + var _picked_mutation = array_random_index(_possible_mutations); + gene_seed_mutations[$ _possible_mutations[_picked_mutation]] = 1; + array_delete(_possible_mutations, _picked_mutation, 1); + _mutations_assigned++; + _mutation_threshold = max(_mutation_threshold - 5 * _mutations_assigned, 0); + if (_mutation_roll <= _mutation_threshold) { + continue; + } else { + break; + } + } else { + break; + } + } + } + }; + + //array index 0 == trait to add + // array index 1 == probability e.g 99,98 == if (irandom(99)>98){add_trait} + // array index 3 == probability modifiers + + if ((global.chapter_name == "Space Wolves") || (obj_ini.progenitor == ePROGENITOR.SPACE_WOLVES)) { + religion_sub_cult = "The Allfather"; + } else if ((global.chapter_name == "Salamanders") || (obj_ini.progenitor == ePROGENITOR.SALAMANDERS)) { + religion_sub_cult = "The Promethean Cult"; + } else if (global.chapter_name == "Iron Hands" || obj_ini.progenitor == ePROGENITOR.IRON_HANDS) { + religion_sub_cult = "The Cult of Iron"; + } - static roll_age = scr_marine_spawn_age; + var _robe_chance = 5; + if (global.chapter_name == "Black Templars") { + _robe_chance += 70; + } else if (scr_has_style("Knightly")) { + _robe_chance += 50; + } + if (irandom(100) <= _robe_chance) { + body.torso.robes = irandom(2); + if (body[$ "torso"].robes == 0 && irandom(1) == 0) { + body[$ "head"].hood = 1; + } + } - static roll_experience = function() { - var _exp = 0; - var _age_bonus = age(); - var _gauss_sd_mod = 14; + var _cloak_chance = 5; + if (role() == obj_ini.role[100][eROLE.Chaplain]) { + _cloak_chance += 25; + } else if (IsSpecialist("libs")) { + _cloak_chance += 75; + } + if (irandom(100) <= _cloak_chance) { + if (global.chapter_name == "Salamanders") { + body.cloak.type = "scale"; + } else if (global.chapter_name == "Space Wolves") { + body.cloak.type = "pelt"; + } else { + body.cloak.type = "cloth"; + body.cloak.variation = irandom(100); + body.cloak.image_0 = irandom(100); + body.cloak.image_1 = irandom(100); + } + } + break; + case "tech_priest": + loyalty = obj_controller.disposition[eFACTION.Mechanicus] - 10; + religeon = "cult_mechanicus"; + bionics = irandom(5) + 4; + add_trait("flesh_is_weak"); + psionic = irandom(4); + break; + } - _exp = _age_bonus; - _exp = max(0, floor(gauss(_exp, _exp / _gauss_sd_mod))); - add_exp(_exp); - } + 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); + }; + + static calculate_death = function(death_threshold = 25, death_random = 50, apothecary = true, death_type = "normal") { + dies = false; + death_random += luck; + death_threshold += luck; + if (death_type == "normal") { + death_threshold += constitution / 10; + if (has_trait("very_hard_to_kill")) { + death_threshold += 3; + } + } + var chance = irandom(death_random); + if (death_random > death_threshold) { + dies = true; + } + return false; + }; + + static add_bionics = function(area = "none", bionic_quality = "any", from_armoury = true) { + if (from_armoury && scr_item_count("Bionics", bionic_quality) < 1) { + return "no bionics"; + } else if (from_armoury) { + remove_quality = scr_add_item("Bionics", -1, bionic_quality); + } else { + remove_quality = choose("standard", "standard", "standard", "standard", "standard", "master_crafted", "artifact"); + } + var new_bionic_pos, part, new_bionic = { + quality: scr_add_item + }; + if (bionics < 10) { + if (has_trait("flesh_is_weak")) { + add_or_sub_health(40); + } else { + add_or_sub_health(30); + } + var bionic_possible = []; + var _body_parts = ARR_body_parts; + for (var body_part = 0; body_part < array_length(_body_parts); body_part++) { + part = _body_parts[body_part]; + if (!get_body_data("bionic", part)) { + array_push(bionic_possible, part); + } + } + if (array_length(bionic_possible) > 0) { + if (area != "none") { + if (array_contains(bionic_possible, area)) { + new_bionic_pos = area; + } else { + return 0; + } + } else { + new_bionic_pos = bionic_possible[irandom(array_length(bionic_possible) - 1)]; + } + bionics++; + alter_body(new_bionic_pos, "bionic", new_bionic); + if (array_contains(["left_leg", "right_leg"], new_bionic_pos)) { + constitution += 2; + strength++; + dexterity -= 2; + body[$ new_bionic_pos][$ "bionic"].variant = irandom(100); + } else if (array_contains(["left_eye", "right_eye"], new_bionic_pos)) { + body[$ new_bionic_pos][$ "bionic"].variant = irandom(100); + constitution += 1; + wisdom += 1; + dexterity++; + } else if (array_contains(["left_arm", "right_arm"], new_bionic_pos)) { + body[$ new_bionic_pos][$ "bionic"].variant = irandom(100); + constitution += 2; + strength += 2; + weapon_skill--; + } else if (new_bionic_pos == "torso") { + constitution += 4; + strength++; + dexterity--; + } else if (new_bionic_pos == "throat") { + charisma--; + } else { + constitution++; + } + if (has_trait("flesh_is_weak")) { + piety++; + } + } + if (hp() > max_health()) { + update_health(max_health()); + } + } + }; - static assign_reactionary_traits = function() { - var _age = age(); - var _exp = experience; - var _total_score = _age + _exp; - - if (_total_score > 280){ - add_trait("ancient"); - } else if (_total_score > 180){ - add_trait("old_guard"); - } else if (_total_score > 100){ - add_trait("seasoned"); - } - } + static age = function() { + var real_age = obj_ini.age[company][marine_number]; + return real_age; + }; // age - static set_default_equipment= function(from_armoury=true, to_armoury=true, quality="any"){ - var role_match=-1; - for (var i=0; i<24;i++){ - if (obj_ini.role[100][i] == role()){ - role_match=i; - break; - } - } - if (role_match!=-1){ - alter_equipment({ - "wep1":obj_ini.wep1[100][role_match], - "wep2":obj_ini.wep2[100][role_match], - "mobi":obj_ini.mobi[100][role_match], - "armour":obj_ini.armour[100][role_match], - "gear":obj_ini.gear[100][role_match] - }, - from_armoury, - to_armoury, - quality); - } - } + static update_age = function(new_val) { + obj_ini.age[company][marine_number] = new_val; + }; - static equipped_artifacts=function(){ - artis = [ - weapon_one(true), - weapon_two(true), - gear(true), - armour(true), - mobility_item(true), - ]; - var arti_length = array_length(artis); - for (var i=0;i 0) { + var exp_require = gear_weapon_data("weapon", new_weapon, "req_exp", false, quality); + if (exp_require > experience) { + viable = false; + qual_string = "exp_low"; + } + quality = scr_add_item(new_weapon, -1, quality); + if (quality == "no_item") { + return [false, "no_items"]; + } + qual_string = quality != undefined ? quality : "standard"; + } else { + viable = false; + qual_string = "no_items"; + } + if (new_weapon == "Company Standard") { + if (role() != obj_ini.role[100][11]) { + viable = false; + qual_string = "wrong_role"; + } + } + return [viable, qual_string]; + }; + + static weapon_two = function(raw = false) { + var wep = obj_ini.wep2[company][marine_number]; + if (is_string(wep) || raw) { + return wep; + } + return obj_ini.artifact[wep]; + }; + + weapon_two_quality = "standard"; + + static specials = function() { + return obj_ini.spe[company][marine_number]; + }; + + static specials_array = function() { + var _specials_array = string_split(obj_ini.spe[company][marine_number], "|", true); + return _specials_array; + }; + + static psy_discipline = function() { + var _specials_array = specials_array(); + var _first_power_prefix = string_letters(_specials_array[0]); + var _discipline = match_power_prefix(_first_power_prefix); + + return _discipline ?? ""; + }; + + static update_powers = function() { + var _powers_limit = 0; + var _powers_known_count = 0; + var _discipline_powers_max = 0; + var _powers_learned = 0; + var _abilities_string = specials(); + + var _discipline_prefix = get_discipline_data(obj_ini.psy_powers, "prefix"); + var _discipline_powers = get_discipline_data(obj_ini.psy_powers, "powers"); + _discipline_powers_max = array_length(_discipline_powers); + + _powers_limit = floor(experience / 30); + _powers_known_count = string_count(string(_discipline_prefix), _abilities_string); + + while ((_powers_known_count < _powers_limit) && (_powers_known_count < _discipline_powers_max)) { + var _power_index = _powers_known_count; + if (string_count(string(_power_index), _abilities_string) == 0) { + _powers_known_count++; + _powers_learned++; + obj_ini.spe[company, marine_number] += string(_discipline_prefix) + string(_power_index) + "|"; + array_push(powers_known, _discipline_powers[_power_index]); + } + } - return _total_special_value; - } + return _powers_learned; + }; - static psychic_amplification = function() { - return round((psionic - 2) + (experience / 100)); - } + static roll_psionic_increase = function() { + if (psionic < 12) { + var _psionic_difficulty = (psionic * 50) - experience; - static psychic_focus = function() { - return round((experience * 0.05) + (wisdom * 0.4)); - } + var _dice_roll = roll_personal_dice(1, _psionic_difficulty, "high", self); + if (_dice_roll == _psionic_difficulty) { + psionic++; + add_battle_log_message($"{name_role()} was touched by the warp!", 999, 135); + } + } + }; - static perils_chance = function() { - var _perils_threshold = PSY_PERILS_CHANCE_BASE; + static roll_psionics = function() { + var _dice_count = marine_ascension == "pre_game" ? 1 : 2; + var _psionics_roll = roll_dice(_dice_count, 100); - if (instance_exists(obj_ncombat)) { - _perils_threshold += obj_ncombat.global_perils; - } - - if (has_trait("warp_tainted")) { - _perils_threshold -= 5; - } - - if (has_trait("favoured_by_the_warp")) { - _perils_threshold -= 5; - } + if (scr_has_adv("Warp Touched")) { + if (_psionics_roll < 170) { + var _second_roll = roll_personal_dice(_dice_count, 100, "high", self); + _psionics_roll = _second_roll > _psionics_roll ? _second_roll : _psionics_roll; + } + } else if (scr_has_disadv("Psyker Intolerant")) { + if (_psionics_roll >= 170) { + var _second_roll = roll_personal_dice(_dice_count, 100, "low", self); + _psionics_roll = _second_roll < _psionics_roll ? _second_roll : _psionics_roll; + } + } + + if (_psionics_roll == 200) { + psionic = 12; + } else if (_psionics_roll >= 199) { + psionic = 11; + } else if (_psionics_roll >= 198) { + psionic = 10; + } else if (_psionics_roll >= 196) { + psionic = 9; + } else if (_psionics_roll >= 194) { + psionic = 8; + } else if (_psionics_roll >= 190) { + psionic = 7; + } else if (_psionics_roll >= 186) { + psionic = 6; + } else if (_psionics_roll >= 182) { + psionic = 5; + } else if (_psionics_roll >= 178) { + psionic = 4; + } else if (_psionics_roll >= 174) { + psionic = 3; + } else if (_psionics_roll >= 170) { + psionic = 2; + } else if (_psionics_roll >= 22) { + psionic = 1; + } else if (_psionics_roll >= 17) { + psionic = 0; + } else if (_psionics_roll >= 12) { + psionic = -1; + } else if (_psionics_roll >= 8) { + psionic = -2; + } else if (_psionics_roll >= 5) { + psionic = -3; + } else if (_psionics_roll >= 3) { + psionic = -4; + } else if (_psionics_roll >= 2) { + psionic = -5; + } else { + psionic = -6; + } + }; + + static role_refresh = function() { + if (role() == "Lexicanum" && psionic >= 5 && experience > 50) { + update_role("Codiciery"); + } else if (role() == "Codiciery" && psionic >= 8 && experience > 100) { + update_role(obj_ini.role[100][eROLE.Librarian]); + } + }; + + static race = function() { + return obj_ini.race[company][marine_number]; + }; + + //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") { + return gear_weapon_data("armour", armour(), type, false, armour_quality); + }; + + static get_gear_data = function(type = "all") { + return gear_weapon_data("gear", gear(), type, false, gear_quality); + }; + + static get_mobility_data = function(type = "all") { + return gear_weapon_data("mobility", mobility_item(), type, false, mobility_item_quality); + }; + + static get_weapon_one_data = function(type = "all") { + return gear_weapon_data("weapon", weapon_one(), type, false, weapon_one_quality); + }; + + static get_weapon_two_data = function(type = "all") { + return gear_weapon_data("weapon", weapon_two(), type, false, weapon_two_quality); + }; + + static damage_resistance = function() { + damage_res = 0; + damage_res += get_armour_data("damage_resistance_mod"); + damage_res += get_gear_data("damage_resistance_mod"); + damage_res += get_mobility_data("damage_resistance_mod"); + damage_res += get_weapon_one_data("damage_resistance_mod"); + damage_res += get_weapon_two_data("damage_resistance_mod"); + damage_res = min(75, damage_res + floor(((constitution * 0.005) + (experience / 1000)) * 100)); + return damage_res; + }; + + static ranged_hands_limit = function() { + var ranged_carrying = 0; + var carry_string = ""; + var ranged_hands_limit = 2; + + var wep_one_carry = get_weapon_one_data("ranged_hands"); + if (wep_one_carry != 0) { + ranged_carrying += wep_one_carry; + carry_string += $"{weapon_one()}: {wep_one_carry}#"; + } + var wep_two_carry = get_weapon_two_data("ranged_hands"); + if (wep_two_carry != 0) { + ranged_carrying += wep_two_carry; + carry_string += $"{weapon_two()}: {wep_two_carry}#"; + } + if (ranged_carrying != 0) { + carry_string = $" =Carrying=#" + carry_string; + } + + carry_string += $" =Maximum=#"; + if (base_group == "astartes") { + ranged_hands_limit = 2; + } else if (base_group == "tech_priest") { + ranged_hands_limit = 1 + (technology / 100); + } else if (base_group == "human") { + ranged_hands_limit = 1; + } + carry_string += $"Base: {ranged_hands_limit}#"; + if (strength >= 50) { + ranged_hands_limit += 0.5; + carry_string += "STR: +0.5#"; + } + if (ballistic_skill >= 50) { + ranged_hands_limit += 0.25; + carry_string += "BS: +0.25#"; + } + var armour_carry = get_armour_data("ranged_hands"); + if (armour_carry != 0) { + ranged_hands_limit += armour_carry; + carry_string += $"{armour()}: {format_number_with_sign(armour_carry)}#"; + } + var gear_carry = get_gear_data("ranged_hands"); + if (gear_carry != 0) { + ranged_hands_limit += gear_carry; + carry_string += $"{gear()}: {format_number_with_sign(gear_carry)}#"; + } + var mobility_carry = get_mobility_data("ranged_hands"); + if (mobility_carry != 0) { + ranged_hands_limit += mobility_carry; + carry_string += $"{mobility_item()}: {format_number_with_sign(mobility_carry)}#"; + } + return [ranged_carrying, ranged_hands_limit, carry_string]; + }; + + static ranged_attack = function(weapon_slot = 0) { + encumbered_ranged = false; + //base modifyer based on unit skill set + ranged_att = 100 * ((ballistic_skill / 50) + (dexterity / 400) + (experience / 500)); + var final_range_attack = 0; + var explanation_string = $"Stat Mod: x{ranged_att / 100}# BS: x{ballistic_skill / 50}# DEX: x{dexterity / 400}# EXP: x{experience / 500}#"; + //determine capavbility to weild bulky weapons + var carry_data = ranged_hands_limit(); + + //base multiplyer + var range_multiplyer = 1; + + //grab generic structs for weapons + var _wep1 = get_weapon_one_data(); + var _wep2 = get_weapon_two_data(); + + if (!is_struct(_wep1)) { + _wep1 = new EquipmentStruct({}, ""); + } + if (!is_struct(_wep2)) { + _wep2 = new EquipmentStruct({}, ""); + } + if (allegiance == global.chapter_name) { + _wep1.owner_data("chapter"); + _wep2.owner_data("chapter"); + } + var primary_weapon = new EquipmentStruct({}, ""); + var secondary_weapon = new EquipmentStruct({}, ""); + if (carry_data[0] > carry_data[1]) { + encumbered_ranged = true; + ranged_att *= 0.6; + explanation_string += $"Encumbered:X0.6#"; + } + if (weapon_slot == 0) { + //decide if any weapons are ranged + if (_wep1.range < 1.1 && _wep2.range < 1.1) { + if (array_length(_wep1.second_profiles) + array_length(_wep2.second_profiles) == 0) { + ranged_damage_data = [final_range_attack, explanation_string, carry_data, primary_weapon, secondary_weapon]; + } else { + var other_profiles = array_concat(_wep1.second_profiles, _wep2.second_profiles); + for (var sec = 0; sec < array_length(other_profiles); sec++) { + var sec_profile = gear_weapon_data("weapon", other_profiles[sec], "all", false, weapon_one_quality); + if (is_struct(sec_profile)) { + if (sec_profile.range > 1.1 && sec_profile.attack > 0) { + final_range_attack += sec_profile.attack * (ranged_att / 100); + explanation_string += $"{sec_profile.name} +{sec_profile.attack}#"; + } + } + } + if (array_length(_wep1.second_profiles) > 0) { + primary_weapon = gear_weapon_data("weapon", _wep1.second_profiles[0], "all", false, weapon_one_quality); + } + if (array_length(_wep2.second_profiles) > 0) { + primary_weapon = gear_weapon_data("weapon", _wep2.second_profiles[0], "all", false, weapon_two_quality); + } + ranged_damage_data = [final_range_attack, explanation_string, carry_data, primary_weapon, secondary_weapon]; + } + return ranged_damage_data; + } else { + if (_wep1.range <= 1.1) { + primary_weapon = _wep2; + } else if (_wep2.range <= 1.1) { + primary_weapon = _wep1; + } else { + //if both weapons are ranged pick best + if (_wep1.attack > _wep2.attack) { + primary_weapon = _wep1; + secondary_weapon = _wep2; + } else { + secondary_weapon = _wep1; + primary_weapon = _wep2; + } + } + } + } else { + if (weapon_slot == 1) { + primary_weapon = _wep1; + } else if (weapon_slot == 2) { + primary_weapon = _wep2; + } + } + //calculate chapter specific bonus + if (allegiance == global.chapter_name) { + //calculate player specific bonuses + if (primary_weapon.has_tag("bolt")) { + if (scr_has_adv("Bolter Drilling") && base_group == "astartes") { + range_multiplyer += 0.15; + explanation_string += $"Bolter Drilling:X1.15#"; + } + } + if (primary_weapon.has_tag("energy")) { + if (scr_has_adv("Ryzan Patronage") && base_group == "astartes") { + range_multiplyer += 0.15; + explanation_string += $"Ryzan Craftsmanship:X1.15#"; + } + } + if (primary_weapon.has_tag("heavy_ranged")) { + if (scr_has_adv("Devastator Doctrine") && base_group == "astartes") { + range_multiplyer += 0.15; + explanation_string += $"Devastator Doctrine:X1.15#"; + } + } + } + if (!encumbered_ranged) { + var total_gear_mod = 0; + total_gear_mod += get_armour_data("ranged_mod"); + total_gear_mod += get_gear_data("ranged_mod"); + total_gear_mod += get_mobility_data("ranged_mod"); + total_gear_mod += _wep1.ranged_mod; + total_gear_mod += _wep2.ranged_mod; + ranged_att += total_gear_mod; + explanation_string += $"Gear Mod: x{(total_gear_mod / 100) + 1}#"; + if (has_trait("feet_floor") && mobility_item() != "") { + ranged_att *= 0.9; + explanation_string += $"{global.trait_list.feet_floor.display_name}:X0.9#"; + } + } + //return final ranged damage output + final_range_attack = floor((ranged_att / 100) * primary_weapon.attack); + explanation_string = $"{primary_weapon.name}: {primary_weapon.attack}#" + explanation_string; + if (!encumbered_ranged) { + if (primary_weapon.has_tag("pistol") && secondary_weapon.has_tag("pistol")) { + final_range_attack += floor((ranged_att / 100) * secondary_weapon.attack); + explanation_string += $"Dual Pistols: +{secondary_weapon.attack}#"; + } else if (secondary_weapon.attack > 0) { + var second_attack = floor((ranged_att / 100) * secondary_weapon.attack) * 0.5; + final_range_attack += second_attack; + explanation_string += $"Secondary: +{second_attack}#"; + } + } + ranged_damage_data = [final_range_attack, explanation_string, carry_data, primary_weapon, secondary_weapon]; + return ranged_damage_data; + }; + + static melee_hands_limit = function() { + var melee_carrying = 0; + var carry_string = ""; + var melee_hands_limit = 2; + + var wep_one_carry = get_weapon_one_data("melee_hands"); + if (wep_one_carry != 0) { + melee_carrying += wep_one_carry; + carry_string += $"{weapon_one()}: {wep_one_carry}#"; + } + var wep_two_carry = get_weapon_two_data("melee_hands"); + if (wep_two_carry != 0) { + melee_carrying += wep_two_carry; + carry_string += $"{weapon_two()}: {wep_two_carry}#"; + } + if (melee_carrying != 0) { + carry_string = $" =Carrying=#" + carry_string; + } + + carry_string += $" =Maximum=#"; + if (base_group == "astartes") { + melee_hands_limit = 2; + } else if (base_group == "tech_priest") { + melee_hands_limit = 1 + (technology / 100); + } else if (base_group == "human") { + melee_hands_limit = 1; + } + carry_string += "Base: 2#"; + if (strength >= 50) { + melee_hands_limit += 0.25; + carry_string += "STR: +0.25#"; + } + if (weapon_skill >= 50) { + melee_hands_limit += 0.25; + carry_string += "WS: +0.25#"; + } + if (has_trait("champion")) { + melee_hands_limit += 0.25; + carry_string += "Champion: +0.25#"; + } + var armour_carry = get_armour_data("melee_hands"); + if (armour_carry != 0) { + melee_hands_limit += armour_carry; + carry_string += $"{armour()}: {format_number_with_sign(armour_carry)}#"; + } + var gear_carry = get_gear_data("melee_hands"); + if (gear_carry != 0) { + melee_hands_limit += gear_carry; + carry_string += $"{gear()}: {format_number_with_sign(gear_carry)}#"; + } + var mobility_carry = get_mobility_data("melee_hands"); + if (mobility_carry != 0) { + melee_hands_limit += mobility_carry; + carry_string += $"{mobility_item()}: {format_number_with_sign(mobility_carry)}#"; + } + return [melee_carrying, melee_hands_limit, carry_string]; + }; + + static melee_attack = function(weapon_slot = 0) { + encumbered_melee = false; + melee_att = 100 * (((weapon_skill / 100) * (strength / 20)) + (experience / 1000) + 0.1); + var explanation_string = string_concat("#Stats: ", format_number_with_sign(round(((melee_att / 100) - 1) * 100)), "%#"); + explanation_string += " Base: +10%#"; + explanation_string += string_concat(" WSxSTR: ", format_number_with_sign(round((((weapon_skill / 100) * (strength / 20)) - 1) * 100)), "%#"); + explanation_string += string_concat(" EXP: ", format_number_with_sign(round((experience / 1000) * 100)), "%#"); + + melee_carrying = melee_hands_limit(); + var _wep1 = get_weapon_one_data(); + var _wep2 = get_weapon_two_data(); + if (!is_struct(_wep1)) { + _wep1 = new EquipmentStruct({}, ""); + } + if (!is_struct(_wep2)) { + _wep2 = new EquipmentStruct({}, ""); + } + if (allegiance == global.chapter_name) { + _wep1.owner_data("chapter"); + _wep2.owner_data("chapter"); + } + var primary_weapon; + var secondary_weapon = "none"; + if (weapon_slot == 0) { + //if player has not melee weapons + var valid1 = (_wep1.range <= 1.1 && _wep1.range != 0) || _wep1.has_tags(["pistol", "flame"]); + var valid2 = (_wep2.range <= 1.1 && _wep2.range != 0) || _wep2.has_tags(["pistol", "flame"]); + if (!valid1 && !valid2) { + primary_weapon = new EquipmentStruct({}, ""); //create blank weapon struct + primary_weapon.attack = strength / 3; //calculate damage from player fists + primary_weapon.name = "fists"; + primary_weapon.range = 1; + primary_weapon.ammo = -1; + } else { + if (!valid1 && valid2) { + primary_weapon = _wep2; + } else if (valid1 && !valid2) { + primary_weapon = _wep1; + } else { + var highest = _wep1.attack > _wep2.attack ? _wep1 : _wep2; + var lowest = _wep1.attack <= _wep2.attack ? _wep1 : _wep2; + if (!highest.has_tags(["pistol", "flame"])) { + primary_weapon = highest; + secondary_weapon = lowest; + } else if (!lowest.has_tags(["pistol", "flame"])) { + primary_weapon = lowest; + secondary_weapon = highest; + } else { + primary_weapon = highest; + melee_att *= 0.5; + if (primary_weapon.has_tag("flame")) { + explanation_string += $"Primary is Flame: -50%#"; + } else if (primary_weapon.has_tag("pistol")) { + explanation_string += $"Primary is Pistol: -50%#"; + } + secondary_weapon = lowest; + } + } + } + } else { + if (weapon_slot == 1) { + primary_weapon = _wep1; + } else if (weapon_slot == 2) { + primary_weapon = _wep2; + } + } + + var basic_wep_string = $"{primary_weapon.name}: {primary_weapon.attack}#"; + + if (psionic > 0) { + if (has_force_weapon()) { + var psychic_bonus = psionic * 20; + psychic_bonus *= 0.5 + (wisdom / 100); + psychic_bonus *= 0.5 + (experience / 100); + psychic_bonus *= IsSpecialist("libs") ? 1 : 0.25; + psychic_bonus = round(psychic_bonus); + primary_weapon.attack += psychic_bonus; + basic_wep_string += $"Psychic Power: +{psychic_bonus}#"; + } + } + + explanation_string = basic_wep_string + explanation_string; + + if (melee_carrying[0] > melee_carrying[1]) { + encumbered_melee = true; + melee_att *= 0.6; + explanation_string += $"Encumbered: x0.6#"; + } + if (!encumbered_melee) { + var total_gear_mod = 0; + total_gear_mod += get_armour_data("melee_mod"); + total_gear_mod += get_gear_data("melee_mod"); + total_gear_mod += get_mobility_data("melee_mod"); + total_gear_mod += _wep1.melee_mod; + total_gear_mod += _wep2.melee_mod; + melee_att += total_gear_mod; + explanation_string += $"#Gear Mod: {(total_gear_mod / 100) * 100}%#"; + //TODO make trait data like this more structured to be able to be moddable + if (has_trait("feet_floor") && mobility_item() != "") { + melee_att *= 0.9; + explanation_string += $"{global.trait_list.feet_floor.display_name}: x0.9#"; + } + if (primary_weapon.has_tag("fist") && has_trait("brawler")) { + melee_att *= 1.1; + explanation_string += $"{global.trait_list.brawler.display_name}: x1.1#"; + } + if (primary_weapon.has_tag("power") && has_trait("duelist")) { + melee_att *= 1.3; + explanation_string += $"{global.trait_list.duelist.display_name}: x1.3#"; + } + } + var final_attack = floor((melee_att / 100) * primary_weapon.attack); + if (secondary_weapon != "none" && !encumbered_melee) { + var side_arm_data = "Standard: x0.5"; + var secondary_modifier = 0.5; + if (primary_weapon.has_tag("dual") && secondary_weapon.has_tag("dual")) { + secondary_modifier = 1; + side_arm_data = "Dual: x1"; + } else if (secondary_weapon.has_tag("pistol")) { + if (melee_carrying[0] + 0.8 >= melee_carrying[1]) { + secondary_modifier = 0; + } else { + secondary_modifier = 0.6; + side_arm_data = "Pistol: x0.8"; + } + } else if (secondary_weapon.has_tag("flame")) { + secondary_modifier = 0.3; + side_arm_data = "Flame: x0.3"; + } + var side_arm = floor(secondary_modifier * ((melee_att / 100) * secondary_weapon.attack)); + if (side_arm > 0) { + final_attack += side_arm; + explanation_string += $"Side Arm: +{side_arm}({side_arm_data})#"; + } + } + melee_damage_data = [final_attack, explanation_string, melee_carrying, primary_weapon, secondary_weapon]; + return melee_damage_data; + }; + + static has_force_weapon = function() { + var _wep1 = get_weapon_one_data(); + var _wep2 = get_weapon_two_data(); + + if (is_struct(_wep1) && _wep1.has_tag("force")) { + return true; + } + + if (is_struct(_wep2) && _wep2.has_tag("force")) { + return true; + } + + return false; + }; + + //TODO just did this so that we're not loosing featuring but this porbably needs a rethink + static hammer_of_wrath = function() { + var _melee_attack = melee_damage_data[0]; + var _melee_weapon = melee_damage_data[3]; + + var wrath = new EquipmentStruct({ + attack: _melee_attack * 0.75, + name: "Hammer of Wrath", + range: 2, + ammo: 6, + spli: _melee_weapon.spli, + arp: _melee_weapon.arp + }, "weapon"); + + var wrath_melee = new EquipmentStruct({ + attack: _melee_attack * 1.25, + name: "Hammer of Wrath(M)", + range: 1, + ammo: 8, + spli: _melee_weapon.spli, + arp: _melee_weapon.arp + }, "weapon"); + + wrath.second_profiles = [wrath_melee]; + + return wrath; + }; + + static armour_calc = function() { + armour_rating = 0; + armour_rating += get_armour_data("armour_value"); + armour_rating += get_weapon_one_data("armour_value"); + armour_rating += get_mobility_data("armour_value"); + armour_rating += get_gear_data("armour_value"); + armour_rating += get_weapon_two_data("armour_value"); + if (armour() != "" && allegiance == global.chapter_name) { + // STC Bonuses + if (obj_controller.stc_bonus[1] == 5) { + armour_rating *= 1.05; + } + if (obj_controller.stc_bonus[2] == 3) { + armour_rating *= 1.05; + } + } + return armour_rating; + }; + + static assignment = function() { + if (squad != "none") { + if (obj_ini.squads[squad].assignment != "none") { + return obj_ini.squads[squad].assignment.type; + } + } + if (job != "none") { + return job.type; + } else { + return "none"; + } + }; + + static remove_from_squad = function() { + if (squad != "none") { + if (squad < array_length(obj_ini.squads)) { + for (var r = 0; r < array_length(obj_ini.squads[squad].members); r++) { + squad_member = obj_ini.squads[squad].members[r]; + if ((squad_member[0] == company) && (squad_member[1] == marine_number)) { + array_delete(obj_ini.squads[squad].members, r, 1); + } + } + } + squad = "none"; + } + }; + + static squad_type = function() { + var _type = "none"; + if (squad != "none") { + if (squad < array_length(obj_ini.squads)) { + return obj_ini.squads[squad].type; + } + } + return _type; + }; + + static add_to_squad = function(new_squad) { + if (squad != "none") { + if (new_squad == squad) { + exit; + } + remove_from_squad(); + } + squad = new_squad; + var _squad = fetch_squad(squad); + _squad.add_member(company, marine_number); + }; + + static marine_location = function() { + var location_id, location_name; + var location_type = planet_location; + if (location_type > 0) { + //if marine is on planet + location_id = 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; + } + 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]; + } + } + return [location_type, location_id, location_name]; + }; + + //quick way of getting name and role combined in string + static name_role = function() { + var temp_role = role(); + if (squad != "none") { + if (struct_exists(obj_ini.squad_types[$ obj_ini.squads[squad].type], temp_role)) { + var role_info = obj_ini.squad_types[$ obj_ini.squads[squad].type][$ temp_role]; + if (struct_exists(role_info, "role")) { + temp_role = role_info[$ "role"]; + } + } + } + return string("{0} {1}", temp_role, name()); + }; + + static full_title = function() { + return $"{squad_role()} of the {company_roman} Company"; + }; + + static company_roman = function() { + return $"{scr_roman_numerals()[company - 1]}"; + }; + + static load_marine = function(ship, 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]; + set_last_ship(); + if (assignment() != "none") { + return "on assignment"; + } + if (target_ship_location == "home") { + target_ship_location = obj_ini.home_name; + } + + if (current_location[0] == location_types.planet) { + //if marine is on a planet + if (current_location[2] == "home") { + 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])) { + 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 + + if (star == "none") { + star = star_by_name(system); + } + if (star != "none") { + if (star.p_player[current_location[1]] > 0) { + star.p_player[current_location[1]] -= size; + } + } + } + } 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 + ship_location = ship; // change marine location to new ship + obj_ini.ship_carrying[ship] += 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]; + } else { + last_ship = { + uid: "", + name: "" + }; + } + }; + + 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]]; + planet_location = planet_number; + ship_location = -1; + get_unit_size(); + system.p_player[planet_number] += size; + obj_ini.ship_carrying[current_location[1]] -= size; + } + } else { + ship_location = -1; + obj_ini.loc[company][marine_number] = system.name; + planet_location = planet_number; + system.p_player[planet_number] += size; + } + }; + + static allocate_unit_to_fresh_spawn = function(type = "default") { + var homestar = "none"; + var spawn_location_chosen = false; + if (((type == "home") || (type == "default")) && (obj_ini.fleet_type == ePlayerBase.home_world)) { + var homestar = star_by_name(obj_ini.home_name); + } else if (type != "ship") { + var homestar = star_by_name(type); + } + /* if (!spawn_location_chosen){ - _perils_threshold = max(_perils_threshold, PSY_PERILS_CHANCE_MIN); + }*/ + if (homestar != "none") { + for (var i = 1; i <= homestar.planets; i++) { + if (homestar.p_owner[i] == eFACTION.Player || (obj_controller.faction_status[eFACTION.Imperium] != "War" && array_contains(obj_controller.imperial_factions, homestar.p_owner[i]))) { + planet_location = i; + obj_ini.loc[company][marine_number] = obj_ini.home_name; + spawn_location_chosen = true; + } + } + } + if (!spawn_location_chosen) { + var player_fleet = get_largest_player_fleet(); + if (player_fleet != "none") { + get_unit_size(); + load_unit_to_fleet(player_fleet, self); + spawn_location_chosen = true; + } + //TODO add more work arounds in case of no valid spawn point + if (!spawn_location_chosen) { + if (player_fleet != "none") {} + } + } + }; - return _perils_threshold; - } + static specialist_tooltips = specialistfunct; - static movement_after_math = function(end_company=company, end_slot=marine_number){ - if (squad != "none"){ - var squad_data = obj_ini.squads[squad]; - var squad_member; - - for (var r=0;r 0) { + if (obj_ini.loc[company][marine_number] == location && planet_location == planet) { + is_at_loc = true; + } + } else if (ship > -1) { + if (ship_location == ship) { + is_at_loc = true; + } + } else if (ship == -1 && planet == 0) { + if (ship_location > -1) { + if (obj_ini.ship_location[ship_location] == location) { + is_at_loc = true; + } + } else if (obj_ini.loc[company][marine_number] == location) { + is_at_loc = true; + } + } + return is_at_loc; + }; + + static edit_corruption = function(edit) { + corruption = edit > 0 ? min(100, corruption + edit) : max(0, corruption + edit); + }; + + static in_jail = function() { + return obj_ini.god[company, marine_number] >= 10; + }; + + static forge_point_generation = unit_forge_point_generation; + + static apothecary_point_generation = unit_apothecary_points_gen; + + static marine_assembling = scr_marine_game_spawn_constructions; + + static random_update_armour = scr_marine_spawn_armour; + + static roll_age = scr_marine_spawn_age; + + static roll_experience = function() { + var _exp = 0; + var _age_bonus = age(); + var _gauss_sd_mod = 14; + + _exp = _age_bonus; + _exp = max(0, floor(gauss(_exp, _exp / _gauss_sd_mod))); + add_exp(_exp); + }; + + static assign_reactionary_traits = function() { + var _age = age(); + var _exp = experience; + var _total_score = _age + _exp; + + if (_total_score > 280) { + add_trait("ancient"); + } else if (_total_score > 180) { + add_trait("old_guard"); + } else if (_total_score > 100) { + add_trait("seasoned"); + } + }; + + static set_default_equipment = function(from_armoury = true, to_armoury = true, quality = "any") { + var role_match = -1; + for (var i = 0; i < 24; i++) { + if (obj_ini.role[100][i] == role()) { + role_match = i; + break; + } + } + if (role_match != -1) { + alter_equipment({ + "wep1": obj_ini.wep1[100][role_match], + "wep2": obj_ini.wep2[100][role_match], + "mobi": obj_ini.mobi[100][role_match], + "armour": obj_ini.armour[100][role_match], + "gear": obj_ini.gear[100][role_match] + }, from_armoury, to_armoury, quality); + } + }; + + static equipped_artifacts = function() { + artis = [weapon_one(true), weapon_two(true), gear(true), armour(true), mobility_item(true)]; + var arti_length = array_length(artis); + for (var i = 0; i < arti_length; i++) { + if (is_string(artis[i])) { + array_delete(artis, i, 1); + i--; + arti_length--; + } + } + return artis; + }; + + static equipped_artifact_tag = function(tag) { + var cur_artis = equipped_artifacts(); + var arti; + var has_tag = false; + for (var i = 0; i < array_length(cur_artis); i++) { + arti = obj_ini.artifact_struct[cur_artis[i]]; + has_tag = arti.has_tag(tag); + if (has_tag) { + break; + } + } + return has_tag; + }; + + static get_stat_line = function() { + return { + "constitution": constitution, + "strength": strength, + "luck": luck, + "dexterity": dexterity, + "wisdom": wisdom, + "piety": piety, + "charisma": charisma, + "technology": technology, + "intelligence": intelligence, + "weapon_skill": weapon_skill, + "ballistic_skill": ballistic_skill + }; + }; + + //TODO: Make this into a universal stat gathering function from all gear, for any stat; + static gear_special_value = function(special_id) { + var _total_special_value = 0; + + var _all_data = [get_armour_data(), get_gear_data(), get_mobility_data(), get_weapon_one_data(), get_weapon_two_data()]; + + for (var i = 0; i < array_length(_all_data); i++) { + var _equipment_piece = _all_data[i]; + if (is_struct(_equipment_piece)) { + _total_special_value += _equipment_piece.special_value(special_id); + } + } + + return _total_special_value; + }; + + static psychic_amplification = function() { + return round((psionic - 2) + (experience / 100)); + }; + + static psychic_focus = function() { + return round((experience * 0.05) + (wisdom * 0.4)); + }; + + static perils_chance = function() { + var _perils_threshold = PSY_PERILS_CHANCE_BASE; + + if (instance_exists(obj_ncombat)) { + _perils_threshold += obj_ncombat.global_perils; + } + + if (has_trait("warp_tainted")) { + _perils_threshold -= 5; + } + + if (has_trait("favoured_by_the_warp")) { + _perils_threshold -= 5; + } + + _perils_threshold = max(_perils_threshold, PSY_PERILS_CHANCE_MIN); + + return _perils_threshold; + }; + + static movement_after_math = function(end_company = company, end_slot = marine_number) { + if (squad != "none") { + var squad_data = obj_ini.squads[squad]; + var squad_member; + + for (var r = 0; r < array_length(squad_data.members); r++) { + squad_member = squad_data.members[r]; + if (squad_member[0] == company && squad_member[1] == marine_number) { + if (squad_data.base_company != end_company) { + array_delete(squad_data.members, r, 1); + squad = "none"; + // if unit will no longer be same company as squad remove unit from squad + } else { + squad_data.members[r] = [end_company, end_slot]; + } + } + } + } + + var arti, artifact_list = equipped_artifacts(); + for (var i = 0; i < array_length(artifact_list); i++) { + arti = obj_ini.artifact_struct[artifact_list[i]]; + arti.bearer = [end_company, end_slot]; + } + }; } -function jsonify_marine_struct(company, marine){ - var copy_marine_struct = obj_ini.TTRPG[company, marine]; //grab marine structure - var new_marine = {}; - var copy_part; - var names = variable_struct_get_names(copy_marine_struct); // get all keys within structure - for (var name = 0; name < array_length(names); name++) { //loop through keys to find which ones are methods as they can't be saved as a json string - if (!is_method(copy_marine_struct[$ names[name]])){ - copy_part = DeepCloneStruct(copy_marine_struct[$ names[name]]); - variable_struct_set(new_marine, names[name],copy_part); //if key value is not a method add to copy structure - delete copy_part; - } - } - return json_stringify(new_marine); + +function jsonify_marine_struct(company, marine) { + var copy_marine_struct = obj_ini.TTRPG[company, marine]; //grab marine structure + var new_marine = {}; + var copy_part; + var names = variable_struct_get_names(copy_marine_struct); // get all keys within structure + for (var name = 0; name < array_length(names); name++) { + //loop through keys to find which ones are methods as they can't be saved as a json string + if (!is_method(copy_marine_struct[$ names[name]])) { + copy_part = DeepCloneStruct(copy_marine_struct[$ names[name]]); + variable_struct_set(new_marine, names[name], copy_part); //if key value is not a method add to copy structure + delete copy_part; + } + } + return json_stringify(new_marine); } /// @param {Array} unit where unit[0] is company and unit[1] is the position /// @returns {Struct.TTRPG_stats} unit -function fetch_unit(unit){ - return obj_ini.TTRPG[unit[0]][unit[1]]; +function fetch_unit(unit) { + return obj_ini.TTRPG[unit[0]][unit[1]]; } - - diff --git a/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml b/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml index c9fdf3c58a..7385f0f07c 100644 --- a/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml +++ b/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml @@ -586,7 +586,7 @@ function player_fleet_selected_count(fleet="none"){ -function get_nearest_player_fleet(nearest_x, nearest_y, is_static=false, is_moving=false){ +function get_nearest_player_fleet(nearest_x, nearest_y, is_static=false, is_moving=false, stop_complex_actions = true){ var chosen_fleet = "none"; if instance_exists(obj_p_fleet){ with(obj_p_fleet){ @@ -594,6 +594,11 @@ function get_nearest_player_fleet(nearest_x, nearest_y, is_static=false, is_movi if (viable && is_moving){ if (action!="move") then viable = false; } + if (stop_complex_actions){ + if (string_count("crusade", action) || action == "Lost"){ + viable = false; + } + } if (!viable) then continue; if (point_in_rectangle(x, y, 0, 0, room_width, room_height)){ if (chosen_fleet=="none"){ diff --git a/scripts/scr_powers/scr_powers.gml b/scripts/scr_powers/scr_powers.gml index 4c6cd74aed..74d6aa129e 100644 --- a/scripts/scr_powers/scr_powers.gml +++ b/scripts/scr_powers/scr_powers.gml @@ -1,6 +1,6 @@ //TODO: a bunch of stuff in this file and related to it uses strings, replace them with constants; -#macro PSY_DISCIPLINES_STARTING ["librarius", "biomancy", "pyromancy","telekinesis","rune_magic"] +#macro PSY_DISCIPLINES_STARTING ["librarius", "biomancy", "pyromancy", "telekinesis", "rune_magic"] #macro PSY_PERILS_CHANCE_MIN 1 #macro PSY_PERILS_CHANCE_BASE 10 @@ -55,7 +55,6 @@ function scr_powers(caster_id) { var _known_powers = _unit.powers_known; var _power_id = select_psychic_power(_unit); - //TODO: All tome related logic in this file has to be reworked; //! Tomes are broken, just don't bother with them atm; /* var _tome_data = process_tome_mechanics(_unit, caster_id); @@ -109,7 +108,7 @@ function scr_powers(caster_id) { if ((_power_id == "force_dome") || (_power_id == "stormbringer")) { var _buff_casts = 8; - repeat (_buff_casts) { + repeat(_buff_casts) { var _target_data = find_valid_target(_power_data); _marine_index = _target_data.index; _marine_column = _target_data.column; @@ -131,7 +130,7 @@ function scr_powers(caster_id) { } } else if (_power_id == "fire_shield") { var _buff_casts = 9; - repeat (_buff_casts) { + repeat(_buff_casts) { var _target_data = find_valid_target(_power_data); _marine_index = _target_data.index; _marine_column = _target_data.column; @@ -143,7 +142,7 @@ function scr_powers(caster_id) { marine_iron[caster_id] += 1; } else if (_power_id == "endurance") { var _buff_casts = 5; - repeat (_buff_casts) { + repeat(_buff_casts) { var _target_data = find_valid_target(_power_data); _marine_index = _target_data.index; _marine_column = _target_data.column; @@ -153,7 +152,7 @@ function scr_powers(caster_id) { } } else if (_power_id == "hysterical_frenzy") { var _buff_casts = 5; - repeat (_buff_casts) { + repeat(_buff_casts) { var _target_data = find_valid_target(_power_data); _marine_index = _target_data.index; _marine_column = _target_data.column; @@ -559,7 +558,15 @@ function roll_perils_strength(_unit) { /// @param {real} _unit_id - The caster's ID /// @returns {struct} Tome-related data and modifiers function process_tome_mechanics(_unit, _unit_id) { - var _result = {has_tome: false, discipline: "", powers: [], perils_chance: 0, perils_strength: 0, using_tome: false, cast_flavour_text: ""}; + var _result = { + has_tome: false, + discipline: "", + powers: [], + perils_chance: 0, + perils_strength: 0, + using_tome: false, + cast_flavour_text: "" + }; var _unit_weapon_one_data = _unit.get_weapon_one_data(); var _unit_weapon_two_data = _unit.get_weapon_two_data(); @@ -606,14 +613,17 @@ function process_tome_mechanics(_unit, _unit_id) { /// @param {struct} _power_data - Data about the power being used /// @returns {struct} The target information with column and index function find_valid_target(_power_data) { - var _result = {column: noone, index: undefined}; + var _result = { + column: noone, + index: undefined + }; var _target_vehicles = _power_data.target_type == "enemy_vehicle"; // Create a priority queue for potential targets var _targets_queue = ds_priority_create(); if (_power_data.type == "attack") { - with (obj_enunit) { + with(obj_enunit) { var _distance = point_distance(other.x, other.y, x, y) / 10; if (_distance <= _power_data.range) { ds_priority_add(_targets_queue, id, _distance); @@ -633,7 +643,7 @@ function find_valid_target(_power_data) { } } } else { - with (obj_pnunit) { + with(obj_pnunit) { var _distance = point_distance(other.x, other.y, x, y) / 10; if (_distance <= _power_data.range) { ds_priority_add(_targets_queue, id, _distance); @@ -680,7 +690,7 @@ function check_cast_success(_unit) { var _equipment_psychic_focus = _unit.gear_special_value("psychic_focus"); var _attribute_psychic_focus = _unit.psychic_focus(); - var _cast_difficulty = PSY_CAST_DIFFICULTY_BASE; //TODO: Make this more dynamic; + var _cast_difficulty = PSY_CAST_DIFFICULTY_BASE; //TODO: Make this more dynamic; _cast_difficulty -= _equipment_psychic_focus; _cast_difficulty -= _attribute_psychic_focus; @@ -697,7 +707,6 @@ function check_cast_success(_unit) { return _cast_successful; } - /// @function select_psychic_power /// @param {struct} _unit - The caster unit /// @returns {string} The ID of the selected power diff --git a/scripts/scr_random_event/scr_random_event.gml b/scripts/scr_random_event/scr_random_event.gml index 1c68fa04f5..c653868288 100644 --- a/scripts/scr_random_event/scr_random_event.gml +++ b/scripts/scr_random_event/scr_random_event.gml @@ -90,7 +90,7 @@ function scr_random_event(execute_now) { [ EVENT.warp_storms, EVENT.enemy_forces, - //EVENT.crusade, // Reportly breaks often because of lack of imperial fleets and eats player ships // TODO LOW CRUSADE_EVENT // fix + EVENT.crusade, // Reportly breaks often because of lack of imperial fleets and eats player ships // TODO LOW CRUSADE_EVENT // fix EVENT.enemy, // Save-scumming event, Should probably base this on something else than tech-scavs EVENT.mutation, EVENT.ship_lost, // Another save-scumming event, mainly due to rarity of player ships diff --git a/scripts/scr_shoot/scr_shoot.gml b/scripts/scr_shoot/scr_shoot.gml index 6771bd8b23..f77b7b4ab0 100644 --- a/scripts/scr_shoot/scr_shoot.gml +++ b/scripts/scr_shoot/scr_shoot.gml @@ -1,186 +1,217 @@ function scr_shoot(weapon_index_position, target_object, target_type, damage_data, melee_or_ranged) { - try { - // weapon_index_position: Weapon number - // target_object: Target object - // target_type: Target dudes - // damage_data: "att" or "arp" or "highest" - // melee_or_ranged: melee or ranged - - // This massive clusterfuck of a script uses the newly determined weapon and target data to attack and assign damage - for (var j = 1; j <= 100; j++) { - obj_ncombat.dead_ene[j] = ""; - obj_ncombat.dead_ene_n[j] = 0; - } - obj_ncombat.dead_enemies = 0; - - var hostile_type; - var hostile_damage; - var hostile_weapon; - var hostile_range; - var hostile_splash; - var aggregate_damage = att[weapon_index_position]; - var armour_pierce = apa[weapon_index_position]; - if (obj_ncombat.wall_destroyed = 1) then exit; - - if (weapon_index_position >= 0) and (instance_exists(target_object)) and (owner==2) { - var stop, damage_type, doom; - var shots_fired = wep_num[weapon_index_position]; - if (shots_fired = 0 || ammo[weapon_index_position] == 0) then exit; - doom = 0; - if (shots_fired != 1) and(melee_or_ranged != "melee") { - switch (obj_ncombat.enemy) { - case eFACTION.Ecclesiarchy: - doom = 0.3; - break; - case eFACTION.Eldar: - doom = 0.4; - break; - case eFACTION.Ork: - doom = 0.2; - break; - case eFACTION.Tau: - doom = 0.4; - break; - case eFACTION.Tyranids: - doom = 0.4; - break; - } - } - if (obj_ncombat.enemy = 11) { - aggregate_damage = round(aggregate_damage * 1.15); - armour_pierce = round(armour_pierce * 1.15); - } - if (obj_ncombat.enemy = 10) and(obj_ncombat.threat = 7) then doom = 1; - - damage_type = ""; - stop = 0; - - if (ammo[weapon_index_position] > 0) then ammo[weapon_index_position] -= 1; - - if (damage_data == "medi") { - damage_type = "att"; - if (aggregate_damage < armour_pierce) then damage_type = "arp"; - } else { - damage_type = damage_data; - } - if (wep[weapon_index_position] = "Web Spinner") then damage_type = "status"; - - var attack_count_mod = max(1, splash[weapon_index_position]); - - if (damage_type = "status") and(stop = 0) and(shots_fired > 0) { - var damage_per_weapon = 0, - hit_number = shots_fired; - if (melee_or_ranged != "wall") { - shots_fired *= attack_count_mod; - } - if (hit_number > 0) and(melee_or_ranged != "wall") and(instance_exists(target_object)) { - if (wep_owner[weapon_index_position] == "assorted"){ target_object.hostile_shooters = 999;} - else if (wep_owner[weapon_index_position] != "assorted"){ target_object.hostile_shooters = 1;} - hostile_damage = 0; - hostile_weapon = wep[weapon_index_position]; - hostile_type = 1; - hostile_range = range[weapon_index_position]; - hostile_splash = attack_count_mod; - - scr_clean(target_object, hostile_type, hit_number, hostile_damage, hostile_weapon, hostile_range, hostile_splash); - } - } else if (damage_type = "att") and(aggregate_damage > 0) and(stop = 0) and(shots_fired > 0) { - var damage_per_weapon, hit_number; - - damage_per_weapon = aggregate_damage; - - if (melee_or_ranged = "melee") { - if (shots_fired > (target_object.men - target_object.dreads) * 2) { - doom = ((target_object.men - target_object.dreads) * 2) / shots_fired; - } - } - - hit_number = shots_fired; - - if (doom != 0) and(shots_fired > 1) { - damage_per_weapon = floor((doom * damage_per_weapon)); - hit_number = floor(hit_number * doom); - } - if (melee_or_ranged != "wall") { - shots_fired *= attack_count_mod; - } - - if (hit_number > 0) and(melee_or_ranged != "wall") and(instance_exists(target_object)) { - if (wep_owner[weapon_index_position] = "assorted") then target_object.hostile_shooters = 999; - if (wep_owner[weapon_index_position] != "assorted") then target_object.hostile_shooters = 1; - hostile_damage = damage_per_weapon / hit_number; - hostile_weapon = wep[weapon_index_position]; - hostile_type = 1; - hostile_range = range[weapon_index_position]; - hostile_splash = attack_count_mod; - if (hostile_splash > 1) then hostile_damage += attack_count_mod * 3; - - scr_clean(target_object, hostile_type, hit_number, hostile_damage, hostile_weapon, hostile_range, hostile_splash); - } - } else if ((damage_type = "arp") or(damage_type = "dread")) and(armour_pierce > 0) and(stop = 0) and(shots_fired > 0) { - var damage_per_weapon, hit_number; - damage_per_weapon = aggregate_damage; - if (aggregate_damage = 0) then damage_per_weapon = shots_fired; - - if (melee_or_ranged = "melee") { - if (shots_fired > ((target_object.veh + target_object.dreads) * 5)) { - doom = ((target_object.veh + target_object.dreads) * 5) / shots_fired; - } - } - hit_number = shots_fired; - - if (doom != 0) and(shots_fired > 1) { - damage_per_weapon = floor((doom * damage_per_weapon)); - hit_number = floor(hit_number * doom); - } - if (melee_or_ranged != "wall") { - shots_fired *= attack_count_mod; - } - - if (damage_per_weapon = 0) then damage_per_weapon = shots_fired * doom; - - if (hit_number > 0 && instance_exists(target_object)) { - hostile_weapon = wep[weapon_index_position]; - hostile_range = range[weapon_index_position]; - hostile_splash = attack_count_mod; - hostile_damage = damage_per_weapon / hit_number; - if (hostile_splash > 1) then hostile_damage += attack_count_mod * 3; - if (melee_or_ranged == "wall") { - var dest = 0; - - hostile_damage -= target_object.ac[1]; - hostile_damage = max(0, hostile_damage); - hostile_damage = round(hostile_damage) * hit_number; - target_object.hp[1] -= hostile_damage; - if (target_object.hp[1] <= 0) dest = 1; - obj_nfort.hostile_weapons = hostile_weapon; - obj_nfort.hostile_shots = hit_number; - obj_nfort.hostile_damage = hostile_damage; - - scr_flavor2(dest, "wall", hostile_range, hostile_weapon, hit_number, hostile_splash); - } else { - target_object.hostile_shooters = (wep_owner[weapon_index_position] == "assorted") ? 999 : 1; - hostile_type = 0; - - scr_clean(target_object, hostile_type, hit_number, hostile_damage, hostile_weapon, hostile_range, hostile_splash); - } - } - } - } - - if (instance_exists(target_object)) and(owner == eFACTION.Player) { - // show_debug_message("{0}, {1}, {2}, {3}, {4}", wep_num[weapon_index_position], wep[weapon_index_position], splash[weapon_index_position], range[weapon_index_position], att[weapon_index_position]) - var shots_fired = 0; - var stop = 0; - var damage_type = ""; - - if (weapon_index_position >= 0) { - shots_fired = wep_num[weapon_index_position]; - } - - if (shots_fired = 0) then exit; - - /*if (weapon_index_position<-40){ + try { + // weapon_index_position: Weapon number + // target_object: Target object + // target_type: Target dudes + // damage_data: "att" or "arp" or "highest" + // melee_or_ranged: melee or ranged + + // This massive clusterfuck of a script uses the newly determined weapon and target data to attack and assign damage + for (var j = 1; j <= 100; j++) { + obj_ncombat.dead_ene[j] = ""; + obj_ncombat.dead_ene_n[j] = 0; + } + obj_ncombat.dead_enemies = 0; + + var hostile_type; + var hostile_damage; + var hostile_weapon; + var hostile_range; + var hostile_splash; + var aggregate_damage = att[weapon_index_position]; + var armour_pierce = apa[weapon_index_position]; + if (obj_ncombat.wall_destroyed == 1) { + exit; + } + + if ((weapon_index_position >= 0) && instance_exists(target_object) && (owner == 2)) { + var stop, damage_type, doom; + var shots_fired = wep_num[weapon_index_position]; + if (shots_fired == 0 || ammo[weapon_index_position] == 0) { + exit; + } + doom = 0; + if ((shots_fired != 1) && (melee_or_ranged != "melee")) { + switch (obj_ncombat.enemy) { + case eFACTION.Ecclesiarchy: + doom = 0.3; + break; + case eFACTION.Eldar: + doom = 0.4; + break; + case eFACTION.Ork: + doom = 0.2; + break; + case eFACTION.Tau: + doom = 0.4; + break; + case eFACTION.Tyranids: + doom = 0.4; + break; + } + } + if (obj_ncombat.enemy == 11) { + aggregate_damage = round(aggregate_damage * 1.15); + armour_pierce = round(armour_pierce * 1.15); + } + if ((obj_ncombat.enemy == 10) && (obj_ncombat.threat == 7)) { + doom = 1; + } + + damage_type = ""; + stop = 0; + + if (ammo[weapon_index_position] > 0) { + ammo[weapon_index_position] -= 1; + } + + if (damage_data == "medi") { + damage_type = "att"; + if (aggregate_damage < armour_pierce) { + damage_type = "arp"; + } + } else { + damage_type = damage_data; + } + if (wep[weapon_index_position] == "Web Spinner") { + damage_type = "status"; + } + + var attack_count_mod = max(1, splash[weapon_index_position]); + + if ((damage_type == "status") && (stop == 0) && (shots_fired > 0)) { + var damage_per_weapon = 0, + hit_number = shots_fired; + if (melee_or_ranged != "wall") { + shots_fired *= attack_count_mod; + } + if ((hit_number > 0) && (melee_or_ranged != "wall") && instance_exists(target_object)) { + if (wep_owner[weapon_index_position] == "assorted") { + target_object.hostile_shooters = 999; + } else if (wep_owner[weapon_index_position] != "assorted") { + target_object.hostile_shooters = 1; + } + hostile_damage = 0; + hostile_weapon = wep[weapon_index_position]; + hostile_type = 1; + hostile_range = range[weapon_index_position]; + hostile_splash = attack_count_mod; + + scr_clean(target_object, hostile_type, hit_number, hostile_damage, hostile_weapon, hostile_range, hostile_splash); + } + } else if ((damage_type == "att") && (aggregate_damage > 0) && (stop == 0) && (shots_fired > 0)) { + var damage_per_weapon, hit_number; + + damage_per_weapon = aggregate_damage; + + if (melee_or_ranged == "melee") { + if (shots_fired > (target_object.men - target_object.dreads) * 2) { + doom = ((target_object.men - target_object.dreads) * 2) / shots_fired; + } + } + + hit_number = shots_fired; + + if ((doom != 0) && (shots_fired > 1)) { + damage_per_weapon = floor((doom * damage_per_weapon)); + hit_number = floor(hit_number * doom); + } + if (melee_or_ranged != "wall") { + shots_fired *= attack_count_mod; + } + + if ((hit_number > 0) && (melee_or_ranged != "wall") && instance_exists(target_object)) { + if (wep_owner[weapon_index_position] == "assorted") { + target_object.hostile_shooters = 999; + } + if (wep_owner[weapon_index_position] != "assorted") { + target_object.hostile_shooters = 1; + } + hostile_damage = damage_per_weapon / hit_number; + hostile_weapon = wep[weapon_index_position]; + hostile_type = 1; + hostile_range = range[weapon_index_position]; + hostile_splash = attack_count_mod; + if (hostile_splash > 1) { + hostile_damage += attack_count_mod * 3; + } + + scr_clean(target_object, hostile_type, hit_number, hostile_damage, hostile_weapon, hostile_range, hostile_splash); + } + } else if (((damage_type == "arp") || (damage_type == "dread")) && (armour_pierce > 0) && (stop == 0) && (shots_fired > 0)) { + var damage_per_weapon, hit_number; + damage_per_weapon = aggregate_damage; + if (aggregate_damage == 0) { + damage_per_weapon = shots_fired; + } + + if (melee_or_ranged == "melee") { + if (shots_fired > ((target_object.veh + target_object.dreads) * 5)) { + doom = ((target_object.veh + target_object.dreads) * 5) / shots_fired; + } + } + hit_number = shots_fired; + + if ((doom != 0) && (shots_fired > 1)) { + damage_per_weapon = floor((doom * damage_per_weapon)); + hit_number = floor(hit_number * doom); + } + if (melee_or_ranged != "wall") { + shots_fired *= attack_count_mod; + } + + if (damage_per_weapon == 0) { + damage_per_weapon = shots_fired * doom; + } + + if (hit_number > 0 && instance_exists(target_object)) { + hostile_weapon = wep[weapon_index_position]; + hostile_range = range[weapon_index_position]; + hostile_splash = attack_count_mod; + hostile_damage = damage_per_weapon / hit_number; + if (hostile_splash > 1) { + hostile_damage += attack_count_mod * 3; + } + if (melee_or_ranged == "wall") { + var dest = 0; + + hostile_damage -= target_object.ac[1]; + hostile_damage = max(0, hostile_damage); + hostile_damage = round(hostile_damage) * hit_number; + target_object.hp[1] -= hostile_damage; + if (target_object.hp[1] <= 0) { + dest = 1; + } + obj_nfort.hostile_weapons = hostile_weapon; + obj_nfort.hostile_shots = hit_number; + obj_nfort.hostile_damage = hostile_damage; + + scr_flavor2(dest, "wall", hostile_range, hostile_weapon, hit_number, hostile_splash); + } else { + target_object.hostile_shooters = (wep_owner[weapon_index_position] == "assorted") ? 999 : 1; + hostile_type = 0; + + scr_clean(target_object, hostile_type, hit_number, hostile_damage, hostile_weapon, hostile_range, hostile_splash); + } + } + } + } + + if (instance_exists(target_object) && (owner == eFACTION.Player)) { + // show_debug_message("{0}, {1}, {2}, {3}, {4}", wep_num[weapon_index_position], wep[weapon_index_position], splash[weapon_index_position], range[weapon_index_position], att[weapon_index_position]) + var shots_fired = 0; + var stop = 0; + var damage_type = ""; + + if (weapon_index_position >= 0) { + shots_fired = wep_num[weapon_index_position]; + } + + if (shots_fired == 0) { + exit; + } + + /*if (weapon_index_position<-40){ if (weapon_index_position=-53){ if (player_silos>30) then shots_fired=30; if (player_silos<30) then shots_fired=player_silos; @@ -190,271 +221,323 @@ function scr_shoot(weapon_index_position, target_object, target_type, damage_dat } }*/ - - while (target_type < array_length(target_object.dudes_hp)) { - if (target_object.dudes_hp[target_type] == 0) { - target_type++; - stop = 1; - } else { - stop = 0; - break; - } - } - - if (weapon_index_position >= 0) { - if (ammo[weapon_index_position] = 0) then stop = 1; - if (ammo[weapon_index_position] > 0) then ammo[weapon_index_position] -= 1; - } - if (wep[weapon_index_position] == "Missile Silo") then obj_ncombat.player_silos -= min(obj_ncombat.player_silos, 30); - - if (damage_data != "highest") then damage_type = damage_data; - if (damage_data = "highest") and(weapon_index_position >= 0) { - damage_type = "att"; - if (aggregate_damage >= 100) and(armour_pierce > 0) then damage_type = "arp"; - } - if (damage_data = "highest") { - if (weapon_index_position = -51 || weapon_index_position = -52 || weapon_index_position = -53) then damage_type = "att"; - } - - if (weapon_index_position >= 0) or(weapon_index_position < -40) { // Normal shooting - var overkill = 0, - damage_remaining = 0, - shots_remaining = 0; - - var that_works = false; - - if (weapon_index_position >= 0) { - if (aggregate_damage > 0) and(stop = 0) then that_works = true; - } - if (weapon_index_position < -40) and(stop = 0) then that_works = true; - - if (that_works = true) { - var damage_per_weapon = 0, - c = 0, - target_armour_value = 0, - ap = 0, - wii = ""; - attack_count_mod = 0; - - if (weapon_index_position >= 0) { - damage_per_weapon = (aggregate_damage / wep_num[weapon_index_position]); - ap = armour_pierce; - } // Average damage - if (weapon_index_position < -40) { - wii = ""; - attack_count_mod = 3; - - if (weapon_index_position = -51) { - wii = "Heavy Bolter Emplacement"; - at = 160; - armour_pierce = 0; - } - if (weapon_index_position = -52) { - wii = "Missile Launcher Emplacement"; - at = 200; - armour_pierce = 1; - } - if (weapon_index_position = -53) { - wii = "Missile Silo"; - at = 250; - ar = 0; - } - } - - target_armour_value = target_object.dudes_ac[target_type]; - - if (target_object.dudes_vehicle[target_type]) { - if (armour_pierce = 0) then target_armour_value = target_armour_value * 6; - if (armour_pierce = -1) then target_armour_value = damage_per_weapon; - } else { - if (armour_pierce = 1) then target_armour_value = 0; - if (armour_pierce = -1) then target_armour_value = target_armour_value * 6; - } - - attack_count_mod = max(1, splash[weapon_index_position]); - - final_hit_damage_value = damage_per_weapon - (target_armour_value * attack_count_mod); //damage armour reduction - - final_hit_damage_value *= target_object.dudes_dr[target_type]; //damage_resistance mod - - if (final_hit_damage_value <= 0) then final_hit_damage_value = 0; // Average after armour - - c = shots_fired * final_hit_damage_value; // New damage - - var casualties, onceh = 0, - ponies = 0; - - casualties = min(floor(c / target_object.dudes_hp[target_type]), shots_fired * attack_count_mod); - - ponies = target_object.dudes_num[target_type]; - if (target_object.dudes_num[target_type] = 1) and((target_object.dudes_hp[target_type] - c) <= 0) { - casualties = 1; - } - - if (target_object.dudes_num[target_type] - casualties < 0) { - overkill = casualties - target_object.dudes_num[target_type]; - damage_remaining = c - (overkill * target_object.dudes_hp[target_type]); - - shots_remaining = round(damage_remaining / damage_per_weapon); - } - - if (target_object.dudes_num[target_type] - casualties < 0) then casualties = ponies; - if (casualties < 0) then casualties = 0; - - if (casualties >= 1) { - - var iii = 0, - found = 0, - openz = 0; - for (iii = 0; iii <= 40; iii++) { - iii += 1; - if (found = 0) { - if (obj_ncombat.dead_ene[iii] = "") and(openz = 0) then openz = iii; - if (obj_ncombat.dead_ene[iii] = target_object.dudes[target_type]) and(found = 0) { - found = iii; - obj_ncombat.dead_ene_n[obj_ncombat.dead_enemies] += casualties; - } - } - } - if (found = 0) { - obj_ncombat.dead_enemies += 1; - obj_ncombat.dead_ene[openz] = string(target_object.dudes[target_type]); - obj_ncombat.dead_ene_n[openz] = casualties; - } - } - - var k = 0; - if (damage_remaining > 0) and(shots_remaining > 0) then repeat(10) { - if (damage_remaining > 0) and(shots_remaining > 0) { - var godd; - godd = 0; - k = target_type; - - // Find similar target in this same group - repeat(10) { - k += 1; - if (godd = 0) { - if (target_object.dudes_num[k] > 0) and(target_object.dudes_vehicle[k] = target_object.dudes_vehicle[target_type]) { - godd = k; - } - } - } - k = target_type; - if (godd = 0) then repeat(10) { - k -= 1; - if (godd = 0) and(k >= 1) { - if (target_object.dudes_num[k] > 0) and(target_object.dudes_vehicle[k] = target_object.dudes_vehicle[target_type]) { - godd = k; - } - } - } - - // Found damage_per_weapon similar target to get the damage - if (godd > 0) and(damage_remaining > 0) and(shots_remaining > 0) { - var a2, b2, c2, target_armour_value2, ap2; - ap2 = damage_remaining; - a2 = damage_per_weapon; // Average damage - - target_armour_value2 = target_object.dudes_ac[godd]; - if (target_object.dudes_vehicle[godd] = 0) { - if (ap2 = 1) then target_armour_value2 = 0; - if (ap2 = -1) then target_armour_value2 = target_armour_value2 * 6; - } - if (target_object.dudes_vehicle[godd] = 1) { - if (ap2 = 0) then target_armour_value2 = target_armour_value2 * 6; - if (ap2 = -1) then target_armour_value2 = damage_per_weapon; - } - b2 = a2 - target_armour_value2; - if (b2 <= 0) then b2 = 0; // Average after armour - - c2 = b2 * shots_remaining; // New damage - - var casualties2, ponies2, onceh2; - onceh2 = 0; - ponies2 = 0; - if (attack_count_mod <= 1) then casualties2 = min(floor(c2 / target_object.dudes_hp[godd]), shots_remaining); - - if (attack_count_mod > 1) then casualties2 = floor(c2 / target_object.dudes_hp[godd]); - ponies2 = target_object.dudes_num[godd]; - if (target_object.dudes_num[godd] = 1) and((target_object.dudes_hp[godd] - c2) <= 0) { - casualties2 = 1; - } - if (target_object.dudes_num[godd] < casualties2) then casualties2 = target_object.dudes_num[godd]; - if (casualties2 < 1) { - casualties2 = 0; - damage_remaining = 0; - overkill = 0; - shots_remaining = 0; - } - - if (casualties2 >= 1) and(shots_fired > 0) { - var iii, found, openz; - iii = 0; - found = 0; - openz = 0; - repeat(40) { - iii += 1; - if (found = 0) { - if (obj_ncombat.dead_ene[iii] = "") and(openz = 0) then openz = iii; - if (obj_ncombat.dead_ene[iii] = target_object.dudes[godd]) and(found = 0) { - found = iii; - obj_ncombat.dead_ene_n[obj_ncombat.dead_enemies] += casualties; - } - } - } - if (found = 0) { - obj_ncombat.dead_enemies += 1; - obj_ncombat.dead_ene[openz] = string(target_object.dudes[godd]); - obj_ncombat.dead_ene_n[openz] = casualties; - } - - /*obj_ncombat.dead_enemies+=1; + while (target_type < array_length(target_object.dudes_hp)) { + if (target_object.dudes_hp[target_type] == 0) { + target_type++; + stop = 1; + } else { + stop = 0; + break; + } + } + + if (weapon_index_position >= 0) { + if (ammo[weapon_index_position] == 0) { + stop = 1; + } + if (ammo[weapon_index_position] > 0) { + ammo[weapon_index_position] -= 1; + } + } + if (wep[weapon_index_position] == "Missile Silo") { + obj_ncombat.player_silos -= min(obj_ncombat.player_silos, 30); + } + + if (damage_data != "highest") { + damage_type = damage_data; + } + if ((damage_data == "highest") && (weapon_index_position >= 0)) { + damage_type = "att"; + if ((aggregate_damage >= 100) && (armour_pierce > 0)) { + damage_type = "arp"; + } + } + if (damage_data == "highest") { + if (weapon_index_position == -51 || weapon_index_position == -52 || weapon_index_position == -53) { + damage_type = "att"; + } + } + + if ((weapon_index_position >= 0) || (weapon_index_position < -40)) { + // Normal shooting + var overkill = 0, + damage_remaining = 0, + shots_remaining = 0; + + var that_works = false; + + if (weapon_index_position >= 0) { + if ((aggregate_damage > 0) && (stop == 0)) { + that_works = true; + } + } + if ((weapon_index_position < -40) && (stop == 0)) { + that_works = true; + } + + if (that_works == true) { + var damage_per_weapon = 0, + c = 0, + target_armour_value = 0, + ap = 0, + wii = ""; + attack_count_mod = 0; + + if (weapon_index_position >= 0) { + damage_per_weapon = aggregate_damage / wep_num[weapon_index_position]; + ap = armour_pierce; + } // Average damage + if (weapon_index_position < -40) { + wii = ""; + attack_count_mod = 3; + + if (weapon_index_position == -51) { + wii = "Heavy Bolter Emplacement"; + at = 160; + armour_pierce = 0; + } + if (weapon_index_position == -52) { + wii = "Missile Launcher Emplacement"; + at = 200; + armour_pierce = 1; + } + if (weapon_index_position == -53) { + wii = "Missile Silo"; + at = 250; + ar = 0; + } + } + + target_armour_value = target_object.dudes_ac[target_type]; + + if (target_object.dudes_vehicle[target_type]) { + if (armour_pierce == 0) { + target_armour_value = target_armour_value * 6; + } + if (armour_pierce == -1) { + target_armour_value = damage_per_weapon; + } + } else { + if (armour_pierce == 1) { + target_armour_value = 0; + } + if (armour_pierce == -1) { + target_armour_value = target_armour_value * 6; + } + } + + attack_count_mod = max(1, splash[weapon_index_position]); + + final_hit_damage_value = damage_per_weapon - (target_armour_value * attack_count_mod); //damage armour reduction + + final_hit_damage_value *= target_object.dudes_dr[target_type]; //damage_resistance mod + + if (final_hit_damage_value <= 0) { + final_hit_damage_value = 0; + } // Average after armour + + c = shots_fired * final_hit_damage_value; // New damage + + var casualties, onceh = 0, + ponies = 0; + + casualties = min(floor(c / target_object.dudes_hp[target_type]), shots_fired * attack_count_mod); + + ponies = target_object.dudes_num[target_type]; + if ((target_object.dudes_num[target_type] == 1) && ((target_object.dudes_hp[target_type] - c) <= 0)) { + casualties = 1; + } + + if (target_object.dudes_num[target_type] - casualties < 0) { + overkill = casualties - target_object.dudes_num[target_type]; + damage_remaining = c - (overkill * target_object.dudes_hp[target_type]); + + shots_remaining = round(damage_remaining / damage_per_weapon); + } + + if (target_object.dudes_num[target_type] - casualties < 0) { + casualties = ponies; + } + if (casualties < 0) { + casualties = 0; + } + + if (casualties >= 1) { + var iii = 0, + found = 0, + openz = 0; + for (iii = 0; iii <= 40; iii++) { + iii += 1; + if (found == 0) { + if ((obj_ncombat.dead_ene[iii] == "") && (openz == 0)) { + openz = iii; + } + if ((obj_ncombat.dead_ene[iii] == target_object.dudes[target_type]) && (found == 0)) { + found = iii; + obj_ncombat.dead_ene_n[obj_ncombat.dead_enemies] += casualties; + } + } + } + if (found == 0) { + obj_ncombat.dead_enemies += 1; + obj_ncombat.dead_ene[openz] = string(target_object.dudes[target_type]); + obj_ncombat.dead_ene_n[openz] = casualties; + } + } + + var k = 0; + if ((damage_remaining > 0) && (shots_remaining > 0)) { + repeat(10) { + if ((damage_remaining > 0) && (shots_remaining > 0)) { + var godd; + godd = 0; + k = target_type; + + // Find similar target in this same group + repeat(10) { + k += 1; + if (godd == 0) { + if ((target_object.dudes_num[k] > 0) && (target_object.dudes_vehicle[k] == target_object.dudes_vehicle[target_type])) { + godd = k; + } + } + } + k = target_type; + if (godd == 0) { + repeat(10) { + k -= 1; + if ((godd == 0) && (k >= 1)) { + if ((target_object.dudes_num[k] > 0) && (target_object.dudes_vehicle[k] == target_object.dudes_vehicle[target_type])) { + godd = k; + } + } + } + } + + // Found damage_per_weapon similar target to get the damage + if ((godd > 0) && (damage_remaining > 0) && (shots_remaining > 0)) { + var a2, b2, c2, target_armour_value2, ap2; + ap2 = damage_remaining; + a2 = damage_per_weapon; // Average damage + + target_armour_value2 = target_object.dudes_ac[godd]; + if (target_object.dudes_vehicle[godd] == 0) { + if (ap2 == 1) { + target_armour_value2 = 0; + } + if (ap2 == -1) { + target_armour_value2 = target_armour_value2 * 6; + } + } + if (target_object.dudes_vehicle[godd] == 1) { + if (ap2 == 0) { + target_armour_value2 = target_armour_value2 * 6; + } + if (ap2 == -1) { + target_armour_value2 = damage_per_weapon; + } + } + b2 = a2 - target_armour_value2; + if (b2 <= 0) { + b2 = 0; + } // Average after armour + + c2 = b2 * shots_remaining; // New damage + + var casualties2, ponies2, onceh2; + onceh2 = 0; + ponies2 = 0; + if (attack_count_mod <= 1) { + casualties2 = min(floor(c2 / target_object.dudes_hp[godd]), shots_remaining); + } + + if (attack_count_mod > 1) { + casualties2 = floor(c2 / target_object.dudes_hp[godd]); + } + ponies2 = target_object.dudes_num[godd]; + if ((target_object.dudes_num[godd] == 1) && ((target_object.dudes_hp[godd] - c2) <= 0)) { + casualties2 = 1; + } + if (target_object.dudes_num[godd] < casualties2) { + casualties2 = target_object.dudes_num[godd]; + } + if (casualties2 < 1) { + casualties2 = 0; + damage_remaining = 0; + overkill = 0; + shots_remaining = 0; + } + + if ((casualties2 >= 1) && (shots_fired > 0)) { + var iii, found, openz; + iii = 0; + found = 0; + openz = 0; + repeat(40) { + iii += 1; + if (found == 0) { + if ((obj_ncombat.dead_ene[iii] == "") && (openz == 0)) { + openz = iii; + } + if ((obj_ncombat.dead_ene[iii] == target_object.dudes[godd]) && (found == 0)) { + found = iii; + obj_ncombat.dead_ene_n[obj_ncombat.dead_enemies] += casualties; + } + } + } + if (found == 0) { + obj_ncombat.dead_enemies += 1; + obj_ncombat.dead_ene[openz] = string(target_object.dudes[godd]); + obj_ncombat.dead_ene_n[openz] = casualties; + } + + /*obj_ncombat.dead_enemies+=1; if (casualties2=1) then obj_ncombat.dead_ene[obj_ncombat.dead_enemies]="1 "+string(target_object.dudes[godd]); if (casualties2>1) then obj_ncombat.dead_ene[obj_ncombat.dead_enemies]=string(casualties2)+" "+string(target_object.dudes[godd]); obj_ncombat.dead_enemies+=1; obj_ncombat.dead_ene[obj_ncombat.dead_enemies]=string(target_object.dudes[godd]); obj_ncombat.dead_ene_n[obj_ncombat.dead_enemies]=casualties;*/ - target_object.dudes_num[godd] -= casualties2; - obj_ncombat.enemy_forces -= casualties2; - } - - if (casualties2 >= 1) { - if (target_object.dudes_num[godd] <= 0) { - overkill = casualties2 - target_object.dudes_num[godd]; - damage_remaining -= casualties2 * target_object.dudes_hp[godd]; - - var proportional_shots; - proportional_shots = round(damage_remaining / a2); - shots_remaining = proportional_shots; - - // show_message("killed "+string(casualties2)+"x "+string(target_object.dudes[godd])); - // show_message("did "+string(c)+" damage with "+string(proportional_shots)+" shots fired, have "+string(damage_remaining)+" damage remaining"); - } - } - - } - } - } // End repeat 10 - scr_flavor(weapon_index_position, target_object, target_type, shots_fired - wep_rnum[weapon_index_position], casualties); - - if (target_object.dudes_num[target_type] = 1) and(c > 0) then target_object.dudes_hp[target_type] -= c; // Need special flavor here for just damaging - - if (casualties >= 1) { - target_object.dudes_num[target_type] -= casualties; - obj_ncombat.enemy_forces -= casualties; - - } - } - } - - if (stop = 0) { + target_object.dudes_num[godd] -= casualties2; + obj_ncombat.enemy_forces -= casualties2; + } + + if (casualties2 >= 1) { + if (target_object.dudes_num[godd] <= 0) { + overkill = casualties2 - target_object.dudes_num[godd]; + damage_remaining -= casualties2 * target_object.dudes_hp[godd]; + + var proportional_shots; + proportional_shots = round(damage_remaining / a2); + shots_remaining = proportional_shots; + + // show_message("killed "+string(casualties2)+"x "+string(target_object.dudes[godd])); + // show_message("did "+string(c)+" damage with "+string(proportional_shots)+" shots fired, have "+string(damage_remaining)+" damage remaining"); + } + } + } + } + } + } // End repeat 10 + scr_flavor(weapon_index_position, target_object, target_type, shots_fired - wep_rnum[weapon_index_position], casualties); + + if ((target_object.dudes_num[target_type] == 1) && (c > 0)) { + target_object.dudes_hp[target_type] -= c; + } // Need special flavor here for just damaging + + if (casualties >= 1) { + target_object.dudes_num[target_type] -= casualties; + obj_ncombat.enemy_forces -= casualties; + } + } + } + + if (stop == 0) { compress_enemy_array(target_object); destroy_empty_column(target_object); - } - - } - } catch(_exception) { - handle_exception(_exception); - } -} \ No newline at end of file + } + } + } catch (_exception) { + handle_exception(_exception); + } +} diff --git a/scripts/scr_star_travel_algorithm/scr_star_travel_algorithm.gml b/scripts/scr_star_travel_algorithm/scr_star_travel_algorithm.gml index b1e7407799..b50dd523f9 100644 --- a/scripts/scr_star_travel_algorithm/scr_star_travel_algorithm.gml +++ b/scripts/scr_star_travel_algorithm/scr_star_travel_algorithm.gml @@ -114,4 +114,10 @@ function determine_warp_join(star_a, star_b){ } } return lane_strength; +} + + +function get_viable_travel_time(time_abundance, start_x,start_y, xx,yy,fleet, start_from_star=false){ + var alg_calc = new FastestRouteAlgorithm(start_x,start_y, xx,yy,fleet, start_from_star); + return alg_calc.final_route_info[1] + time_abundance; } \ No newline at end of file diff --git a/scripts/scr_ui_manage/scr_ui_manage.gml b/scripts/scr_ui_manage/scr_ui_manage.gml index bea4b7440b..597f295f6b 100644 --- a/scripts/scr_ui_manage/scr_ui_manage.gml +++ b/scripts/scr_ui_manage/scr_ui_manage.gml @@ -1,4 +1,4 @@ -function load_marines_into_ship(system, ship, units, reload=false) { +function load_marines_into_ship(system, ship, units, reload = false) { var _load_into_ship = function(system, ship, units, size, loop, reload) { var load_from_star = star_by_name(system); if (is_struct(units[loop])) { @@ -10,15 +10,15 @@ function load_marines_into_ship(system, ship, units, reload=false) { var vehicle = units[loop]; var _get = fetch_deep_array; var _set = alter_deep_array; - var start_ship = _get(obj_ini.veh_lid,vehicle); - var start_planet = _get(obj_ini.veh_wid,vehicle); + 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_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_wid, vehicle, 0) - _set(obj_ini.veh_uid, vehicle, sh_uid[ship]) + _set(obj_ini.veh_loc, vehicle, sh_name[ship]); + _set(obj_ini.veh_lid, vehicle, sh_ide[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; if (start_planet) { @@ -29,18 +29,18 @@ function load_marines_into_ship(system, ship, units, reload=false) { set_vehicle_last_ship(vehicle, true); } - } + }; for (var q = 0; q < array_length(units); q++) { if (man_sel[q] == 1) { - var _unit_ship_id + var _unit_ship_id; if (!reload) { _unit_ship_id = ship; } else { if (!is_array(units[q])) { _unit_ship_id = array_get_index(sh_uid, units[q].last_ship.uid); } else { - var last_ship_data = fetch_deep_array(obj_ini.last_ship, units[q]); + var last_ship_data = fetch_deep_array(obj_ini.last_ship, units[q]); _unit_ship_id = array_get_index(sh_uid, last_ship_data.uid); } } @@ -53,7 +53,7 @@ function load_marines_into_ship(system, ship, units, reload=false) { } if (_unit_ship_id != undefined && ((sh_cargo[_unit_ship_id] + _unit_size) <= sh_cargo_max[_unit_ship_id])) { - _load_into_ship(system, _unit_ship_id, units, _unit_size, q, reload) + _load_into_ship(system, _unit_ship_id, units, _unit_size, q, reload); man_sel[q] = 0; } } @@ -71,198 +71,202 @@ function load_marines_into_ship(system, ship, units, reload=false) { } } -function alternative_manage_views(x1, y1){ - var _squad_button = management_buttons.squad_toggle; - _squad_button.update({ - x1 : x1+5, - y1 : y1+6, - label : !obj_controller.view_squad && !obj_controller.company_report ? "Squad View" : "Company View", - keystroke : keyboard_check_pressed(ord("S")) - }); - - if (_squad_button.draw(!text_bar)){ - view_squad = !view_squad - if (view_squad){ - new_company_struct(); - } - } - - - if (!view_squad){ - var _profile_toggle = management_buttons.profile_toggle; - _profile_toggle.update({ - label : !unit_profile ? "Show Profile" : "Hide Profile", - x1 : _squad_button.x2, - y1 : _squad_button.y1, - keystroke : keyboard_check_pressed(ord("P")) - }); - if (_profile_toggle.draw(!text_bar)){ - unit_profile = !unit_profile - - } - - if (unit_profile){ - var bio_toggle = management_buttons.bio_toggle; - bio_toggle.update({ - label : !unit_bio ? "Show Bio" : "Hide Bio", - x1 : _profile_toggle.x2, - y1 : _profile_toggle.y1, - keystroke : keyboard_check_pressed(ord("B")) - }); - if (bio_toggle.draw(!text_bar)){ - unit_bio = !unit_bio - } - } - } +function alternative_manage_views(x1, y1) { + var _squad_button = management_buttons.squad_toggle; + _squad_button.update({ + x1: x1 + 5, + y1: y1 + 6, + label: !obj_controller.view_squad && !obj_controller.company_report ? "Squad View" : "Company View", + keystroke: keyboard_check_pressed(ord("S")) + }); + + if (_squad_button.draw(!text_bar)) { + view_squad = !view_squad; + if (view_squad) { + new_company_struct(); + } + } + + if (!view_squad) { + var _profile_toggle = management_buttons.profile_toggle; + _profile_toggle.update({ + label: !unit_profile ? "Show Profile" : "Hide Profile", + x1: _squad_button.x2, + y1: _squad_button.y1, + keystroke: keyboard_check_pressed(ord("P")) + }); + if (_profile_toggle.draw(!text_bar)) { + unit_profile = !unit_profile; + } + + if (unit_profile) { + var bio_toggle = management_buttons.bio_toggle; + bio_toggle.update({ + label: !unit_bio ? "Show Bio" : "Hide Bio", + x1: _profile_toggle.x2, + y1: _profile_toggle.y1, + keystroke: keyboard_check_pressed(ord("B")) + }); + if (bio_toggle.draw(!text_bar)) { + unit_bio = !unit_bio; + } + } + } } function scr_ui_manage() { - if (combat!=0) then exit; - // This is the draw script for showing the main management screen or individual company screens - + if (combat != 0) { + exit; + } + // This is the draw script for showing the main management screen or individual company screens - if (zoomed==0) and (menu==1) and (managing>=0) { - if((managing>0)){ - company_manage_actions(); - } - if (!text_bar){ - ui_manage_hotkeys(); - }; + if ((zoomed == 0) && (menu == 1) && (managing >= 0)) { + if (managing > 0) { + company_manage_actions(); + } + if (!text_bar) { + ui_manage_hotkeys(); + } } - - if (menu==1) and (managing>0 || managing <0){ - if (!mouse_check_button(mb_left)){ - drag_square=[]; - rectangle_action = -1; - } - if (squad_sel_count>0){ - squad_sel_count--; - } - if (squad_sel_count==0){ - squad_sel=-1; - squad_sel_action=-1; - } - if (man_size<1){ - selecting_location=""; - selecting_ship=-1; - selecting_planet=0; - man_size=0; - } - var unit,x1,x2,x3,y1,y2,y3,text; - var romanNumerals=scr_roman_numerals(); - var tooltip_text="",bionic_tooltip="",tooltip_drawing=[]; - var invalid_locations = ["Mechanicus Vessel", "Terra"]; - - var xx=__view_get( e__VW.XView, 0 )+0, yy=__view_get( e__VW.YView, 0 )+0, bb="", img=0; - - // Draw BG - draw_set_alpha(1); - draw_sprite(spr_rock_bg,0,xx,yy); - draw_set_font(fnt_40k_30b); - draw_set_halign(fa_center); - draw_set_color(c_gray);// 38144 - - // Var declarations - var c=0,fx="",skin=obj_ini.skin_color; - static stats_displayed = false; - - if (managing>0){ - if (managing>20){ - c=managing-10; - }else if (managing >= 1) and (managing <=10) { - fx= romanNumerals[managing - 1] + " Company"; - c=managing; - } else if (managing>10) { - switch(managing){ - case 11: - fx="Headquarters" - break; - case 12: - fx="Apothecarion"; - break; - case 13: - fx="Librarium"; - break; - case 14: - fx="Reclusium"; - break; - case 15: - fx="Armamentarium"; - break; - } - } - // Draw the company followed by chapters name - draw_text(xx+800,yy+74,string(fx)+", "+string(global.chapter_name)); - } else if (managing<0){ - if (struct_exists(selection_data, "purpose")){ - draw_text(xx+800,yy+74,$"{selection_data.purpose}"); - } - } - - if (managing<=10 && managing>0){ - var bar_wid=0,click_check, string_h; - draw_set_alpha(0.25); - if (obj_ini.company_title[managing]!="") then bar_wid=max(400,string_width(obj_ini.company_title[managing])); - if (obj_ini.company_title[managing]="") then bar_wid=400; - string_h = string_height("LOL"); - draw_rectangle(xx+800-(bar_wid/2),yy+108,xx+800+(bar_wid/2),yy+100+string_h,1); - click_check = scr_hit(xx+800-(bar_wid/2),yy+108,xx+800+(bar_wid/2),yy+100+string_h); - obj_cursor.image_index=0; - if (!click_check) and (mouse_left==1) and (!cooldown){ - text_bar=false; - }else if(click_check){ - obj_cursor.image_index=2; - - if (!cooldown) and (mouse_left==1) and (!text_bar){ - cooldown=8000; - text_bar=true; - keyboard_string=obj_ini.company_title[managing]; - } - - } - draw_set_alpha(1); - - if (obj_ini.company_title[managing]!="") or (text_bar>0){ - draw_set_font(fnt_fancy); - if (text_bar=0) or (text_bar>31) then draw_text(xx+800,yy+110,$"''{obj_ini.company_title[managing]} {(text_bar>0 && text_bar<=31)?"|":""}'' "); - } - } - - // var we;we=string_width(string(global.chapter_name)+" "+string(fx))/2; - - if (managing>0){ - // Draw arrows - draw_sprite_ext(spr_arrow,0,xx+25,yy+70,2,2,0,c_white,1);// Back - draw_sprite_ext(spr_arrow,0,xx+429,yy+70,2,2,0,c_white,1);// Left - draw_sprite_ext(spr_arrow,1,xx+1110,yy+70,2,2,0,c_white,1);// Right - } else { - scr_manage_task_selector(); - } - var right_ui_block = { - x1: xx + 1008, - y1: yy + 141, - w: 568, - h: 681, - }; - right_ui_block.x2 = right_ui_block.x1 + right_ui_block.w; - right_ui_block.y2 = right_ui_block.y1 + right_ui_block.h; - var actions_block = { - x1: right_ui_block.x1, - y1: yy + 520, - w: 569, - h: 302, - }; - actions_block.x2 = actions_block.x1 + actions_block.w; - actions_block.y2 = actions_block.y1 + actions_block.h; + if ((menu == 1) && (managing > 0 || managing < 0)) { + if (!mouse_check_button(mb_left)) { + drag_square = []; + rectangle_action = -1; + } + if (squad_sel_count > 0) { + squad_sel_count--; + } + if (squad_sel_count == 0) { + squad_sel = -1; + squad_sel_action = -1; + } + if (man_size < 1) { + selecting_location = ""; + selecting_ship = -1; + selecting_planet = 0; + man_size = 0; + } + var unit, x1, x2, x3, y1, y2, y3, text; + var romanNumerals = scr_roman_numerals(); + var tooltip_text = "", bionic_tooltip = "", tooltip_drawing = []; + var invalid_locations = ["Mechanicus Vessel", "Terra"]; - draw_sprite_stretched(spr_data_slate_back, 0, actions_block.x1, actions_block.y1, actions_block.w, actions_block.h); - draw_rectangle_color_simple(actions_block.x1, actions_block.y1, actions_block.x2, actions_block.y2, 1, c_gray); - draw_rectangle_color_simple(actions_block.x1 + 1, actions_block.y1 + 1, actions_block.x2 - 1, actions_block.y2 - 1, 1, c_black); - draw_rectangle_color_simple(actions_block.x1 + 2, actions_block.y1 + 2, actions_block.x2 - 2, actions_block.y2 - 2, 1, c_gray); + var xx = __view_get(e__VW.XView, 0) + 0, yy = __view_get(e__VW.YView, 0) + 0, bb = "", img = 0; - //TODO remove if no longer needed - /*var unit_view_block = { + // Draw BG + draw_set_alpha(1); + draw_sprite(spr_rock_bg, 0, xx, yy); + draw_set_font(fnt_40k_30b); + draw_set_halign(fa_center); + draw_set_color(c_gray); // 38144 + + // Var declarations + var c = 0, fx = "", skin = obj_ini.skin_color; + static stats_displayed = false; + + if (managing > 0) { + if (managing > 20) { + c = managing - 10; + } else if ((managing >= 1) && (managing <= 10)) { + fx = romanNumerals[managing - 1] + " Company"; + c = managing; + } else if (managing > 10) { + switch (managing) { + case 11: + fx = "Headquarters"; + break; + case 12: + fx = "Apothecarion"; + break; + case 13: + fx = "Librarium"; + break; + case 14: + fx = "Reclusium"; + break; + case 15: + fx = "Armamentarium"; + break; + } + } + // Draw the company followed by chapters name + draw_text(xx + 800, yy + 74, string(fx) + ", " + string(global.chapter_name)); + } else if (managing < 0) { + if (struct_exists(selection_data, "purpose")) { + draw_text(xx + 800, yy + 74, $"{selection_data.purpose}"); + } + } + + if (managing <= 10 && managing > 0) { + var bar_wid = 0, click_check, string_h; + draw_set_alpha(0.25); + if (obj_ini.company_title[managing] != "") { + bar_wid = max(400, string_width(obj_ini.company_title[managing])); + } + if (obj_ini.company_title[managing] == "") { + bar_wid = 400; + } + string_h = string_height("LOL"); + draw_rectangle(xx + 800 - (bar_wid / 2), yy + 108, xx + 800 + (bar_wid / 2), yy + 100 + string_h, 1); + click_check = scr_hit(xx + 800 - (bar_wid / 2), yy + 108, xx + 800 + (bar_wid / 2), yy + 100 + string_h); + obj_cursor.image_index = 0; + if ((!click_check) && (mouse_left == 1) && (!cooldown)) { + text_bar = false; + } else if (click_check) { + obj_cursor.image_index = 2; + + if ((!cooldown) && (mouse_left == 1) && (!text_bar)) { + cooldown = 8000; + text_bar = true; + keyboard_string = obj_ini.company_title[managing]; + } + } + draw_set_alpha(1); + + if ((obj_ini.company_title[managing] != "") || (text_bar > 0)) { + draw_set_font(fnt_fancy); + if ((text_bar == 0) || (text_bar > 31)) { + draw_text(xx + 800, yy + 110, $"''{obj_ini.company_title[managing]} {(text_bar > 0 && text_bar <= 31) ? "|" : ""}'' "); + } + } + } + + // var we;we=string_width(string(global.chapter_name)+" "+string(fx))/2; + + if (managing > 0) { + // Draw arrows + draw_sprite_ext(spr_arrow, 0, xx + 25, yy + 70, 2, 2, 0, c_white, 1); // Back + draw_sprite_ext(spr_arrow, 0, xx + 429, yy + 70, 2, 2, 0, c_white, 1); // Left + draw_sprite_ext(spr_arrow, 1, xx + 1110, yy + 70, 2, 2, 0, c_white, 1); // Right + } else { + scr_manage_task_selector(); + } + var right_ui_block = { + x1: xx + 1008, + y1: yy + 141, + w: 568, + h: 681 + }; + right_ui_block.x2 = right_ui_block.x1 + right_ui_block.w; + right_ui_block.y2 = right_ui_block.y1 + right_ui_block.h; + + var actions_block = { + x1: right_ui_block.x1, + y1: yy + 520, + w: 569, + h: 302 + }; + actions_block.x2 = actions_block.x1 + actions_block.w; + actions_block.y2 = actions_block.y1 + actions_block.h; + + draw_sprite_stretched(spr_data_slate_back, 0, actions_block.x1, actions_block.y1, actions_block.w, actions_block.h); + draw_rectangle_color_simple(actions_block.x1, actions_block.y1, actions_block.x2, actions_block.y2, 1, c_gray); + draw_rectangle_color_simple(actions_block.x1 + 1, actions_block.y1 + 1, actions_block.x2 - 1, actions_block.y2 - 1, 1, c_black); + draw_rectangle_color_simple(actions_block.x1 + 2, actions_block.y1 + 2, actions_block.x2 - 2, actions_block.y2 - 2, 1, c_gray); + + //TODO remove if no longer needed + /*var unit_view_block = { x1: right_ui_block.x1, y1: yy + 140, w: 571, @@ -271,34 +275,36 @@ function scr_ui_manage() { unit_view_block.x2 = unit_view_block.x1 + unit_view_block.w; unit_view_block.y2 = unit_view_block.y1 + unit_view_block.h;*/ - draw_set_color(c_white); - draw_sprite_stretched(spr_data_slate_back, 0, xx+1008-1, yy+140, 572, 378); - // draw_sprite_stretched(spr_data_slate_border, 0, xx+1008-1, yy+140, 572, 378); Old Location - // draw_rectangle_color_simple(xx+1007, yy+140, xx+1579, yy+519, 0, c_white, 0.05); - draw_rectangle_color_simple(xx+1007, yy+140, xx+1579, yy+519, 0, 5998382, 0.05); - // Swap between squad view and normal view - draw_set_color(c_gray); - // draw_line(xx+1005,yy+519,xx+1576,yy+519); - draw_set_font(fnt_40k_14b); - var cn=obj_controller; - if (instance_exists(cn)) and (is_struct(temp[120])){ - var selected_unit = temp[120]; //unit struct - ///tooltip_text stacks hover over type tooltips into an array and draws them last so as not to create drawing order issues - draw_set_color(c_red); - var no_other_instances = !instance_exists(obj_temp3) && !instance_exists(obj_popup); - var stat_tool_tip_text; - var button_coords; - var _allow_alternative_views = managing >= 0; - if (!_allow_alternative_views){ - _allow_alternative_views = selection_data.purpose_code=="manage"; - } - if (_allow_alternative_views){ - alternative_manage_views(right_ui_block.x1+5,right_ui_block.y1+6 ); - } + draw_set_color(c_white); + draw_sprite_stretched(spr_data_slate_back, 0, xx + 1008 - 1, yy + 140, 572, 378); + // draw_sprite_stretched(spr_data_slate_border, 0, xx+1008-1, yy+140, 572, 378); Old Location + // draw_rectangle_color_simple(xx+1007, yy+140, xx+1579, yy+519, 0, c_white, 0.05); + draw_rectangle_color_simple(xx + 1007, yy + 140, xx + 1579, yy + 519, 0, 5998382, 0.05); + // Swap between squad view and normal view + draw_set_color(c_gray); + // draw_line(xx+1005,yy+519,xx+1576,yy+519); + draw_set_font(fnt_40k_14b); + var cn = obj_controller; + if (instance_exists(cn) && is_struct(temp[120])) { + var selected_unit = temp[120]; //unit struct + ///tooltip_text stacks hover over type tooltips into an array and draws them last so as not to create drawing order issues + draw_set_color(c_red); + var no_other_instances = !instance_exists(obj_temp3) && !instance_exists(obj_popup); + var stat_tool_tip_text; + var button_coords; + var _allow_alternative_views = managing >= 0; + if (!_allow_alternative_views) { + _allow_alternative_views = selection_data.purpose_code == "manage"; + } + if (_allow_alternative_views) { + alternative_manage_views(right_ui_block.x1 + 5, right_ui_block.y1 + 6); + } - if (!_allow_alternative_views) then unit_profile=true; - //TODO Implement company report - /*var x6=x5+string_width(stat_tool_tip_text)+4; + if (!_allow_alternative_views) { + unit_profile = true; + } + //TODO Implement company report + /*var x6=x5+string_width(stat_tool_tip_text)+4; var y6=y5+string_height(stat_tool_tip_text)+2; draw_unit_buttons([x5,y5,x6,y6], stat_tool_tip_text,[1,1],c_red); if (company_data!={}){ @@ -314,595 +320,476 @@ function scr_ui_manage() { draw_rectangle(x5,y5,x6,y6,0); draw_set_alpha(1); } - */ + */ - // Draw unit image - draw_set_color(c_white); - if (is_struct(temp[121])){ - temp[121].draw(xx+1328, yy+250) - } + // Draw unit image + draw_set_color(c_white); + if (is_struct(temp[121])) { + temp[121].draw(xx + 1328, yy + 250); + } - //TODO implement tooltip explaining potential loyalty hit of demoting a sgt - // Sergeant promotion button - if (view_squad && company_data!={}){ - if (company_data.cur_squad!=0){ - var cur_squad = company_data.grab_current_squad(); - var sgt_possible = cur_squad.type!="command_squad" && !selected_unit.IsSpecialist("squad_leaders"); - if (selected_unit != cur_squad.squad_leader){ - if (point_and_click(draw_unit_buttons([xx+1208+50,yy+210+260], "Make Sgt", [1,1],#50a076,,,sgt_possible?1:0.5)) && sgt_possible){ - cur_squad.change_sgt(selected_unit); - } - } - } - } + //TODO implement tooltip explaining potential loyalty hit of demoting a sgt + // Sergeant promotion button + if (view_squad && company_data != {}) { + if (company_data.cur_squad != 0) { + var cur_squad = company_data.grab_current_squad(); + var sgt_possible = cur_squad.type != "command_squad" && !selected_unit.IsSpecialist("squad_leaders"); + if (selected_unit != cur_squad.squad_leader) { + if (point_and_click(draw_unit_buttons([xx + 1208 + 50, yy + 210 + 260], "Make Sgt", [1, 1], #50a076, , , sgt_possible ? 1 : 0.5)) && sgt_possible) { + cur_squad.change_sgt(selected_unit); + } + } + } + } - // Unit window entries start - var line_color = #50a076; - draw_set_color(line_color); - - // Draw unit name and role - var _name_box = { - x1: xx + 1410, - y1: yy + 177, - text1: "", - text2: "", - text3: selected_unit.name() - } - _name_box.y2 = _name_box.y1 + 20; - _name_box.y3 = _name_box.y2 + 20; - if (selected_unit.company <= 0) { - _name_box.text2 = $"{selected_unit.squad_role()}"; - } else if (selected_unit.IsSpecialist()) { - _name_box.text1 = $"{selected_unit.company_roman()} Company"; - _name_box.text2 = $"{selected_unit.role()}"; - } else { - _name_box.text1 = $"{selected_unit.company_roman()} Company"; - _name_box.text2 = $"{selected_unit.squad_role()}"; - } - draw_set_halign(fa_center); - draw_set_font(fnt_40k_14b); - draw_text_transformed_outline(_name_box.x1,_name_box.y1,_name_box.text1,1,1,0); - draw_text_transformed_outline(_name_box.x1,_name_box.y2,_name_box.text2,1,1,0); - draw_set_font(fnt_40k_30b); - draw_text_transformed_outline(_name_box.x1,_name_box.y3,_name_box.text3,0.7,0.7,0); - - // Draw unit info - draw_set_font(fnt_40k_14); - // Left side of the screen - draw_set_halign(fa_left); - var x_left = xx+1030; - - // Equipment - var armour = selected_unit.armour(); - if (armour!=""){ - text= selected_unit.equipments_qual_string("armour", true); + // Unit window entries start + var line_color = #50a076; + draw_set_color(line_color); + + // Draw unit name and role + var _name_box = { + x1: xx + 1410, + y1: yy + 177, + text1: "", + text2: "", + text3: selected_unit.name() + }; + _name_box.y2 = _name_box.y1 + 20; + _name_box.y3 = _name_box.y2 + 20; + if (selected_unit.company <= 0) { + _name_box.text2 = $"{selected_unit.squad_role()}"; + } else if (selected_unit.IsSpecialist()) { + _name_box.text1 = $"{selected_unit.company_roman()} Company"; + _name_box.text2 = $"{selected_unit.role()}"; + } else { + _name_box.text1 = $"{selected_unit.company_roman()} Company"; + _name_box.text2 = $"{selected_unit.squad_role()}"; + } + draw_set_halign(fa_center); + draw_set_font(fnt_40k_14b); + draw_text_transformed_outline(_name_box.x1, _name_box.y1, _name_box.text1, 1, 1, 0); + draw_text_transformed_outline(_name_box.x1, _name_box.y2, _name_box.text2, 1, 1, 0); + draw_set_font(fnt_40k_30b); + draw_text_transformed_outline(_name_box.x1, _name_box.y3, _name_box.text3, 0.7, 0.7, 0); + + // Draw unit info + draw_set_font(fnt_40k_14); + // Left side of the screen + draw_set_halign(fa_left); + var x_left = xx + 1030; + + // Equipment + var armour = selected_unit.armour(); + if (armour != "") { + text = selected_unit.equipments_qual_string("armour", true); tooltip_text = cn.temp[103]; - x1 = x_left; - y1 = yy+320; - x2 = x1+string_width_ext(text, -1,187); - y2 = y1+string_height_ext(text, -1,187); - draw_set_alpha(1); - draw_text_ext_outline(x1,y1,text,-1,187, 0, quality_color(selected_unit.armour_quality)); - array_push(tooltip_drawing, [tooltip_text, [x1,y1,x2,y2], "Armour"]); - } - - var gear = selected_unit.gear(); - if (selected_unit.gear()!=""){ - text= selected_unit.equipments_qual_string("gear", true); - tooltip_text = cn.temp[105]; - x1 = x_left; - y1 = yy+446; - x2 = x1+string_width_ext(text, -1,187); - y2 = y1+string_height_ext(text, -1,187); - draw_text_ext_outline(x1,y1,text,-1,187, 0, quality_color(selected_unit.gear_quality)); - array_push(tooltip_drawing, [tooltip_text, [x1,y1,x2,y2], "Gear"]); - } - - var mobi = selected_unit.mobility_item(); - if (mobi!=""){ - text= selected_unit.equipments_qual_string("mobi", true); - tooltip_text = cn.temp[107]; - x1 = x_left; - y1 = yy+467; - x2 = x1+string_width_ext(text, -1,187); - y2 = y1+string_height_ext(text, -1,187); - draw_text_ext_outline(x1,y1,text,-1,187, 0, quality_color(selected_unit.mobility_item_quality)); - array_push(tooltip_drawing, [tooltip_text, [x1,y1,x2,y2], "Back/Mobilitiy"]); - } - - var wep1= selected_unit.weapon_one(); - if (wep1!=""){ - text= selected_unit.equipments_qual_string("wep1", true); - tooltip_text = cn.temp[109]; - x1 = x_left; - y1 = yy+345; - x2 = x1+string_width_ext(text, -1,187); - y2 = y1+string_height_ext(text, -1,187); - draw_text_ext_outline(x1,y1,text,-1,187, 0, quality_color(selected_unit.weapon_one_quality)); - array_push(tooltip_drawing, [tooltip_text, [x1,y1,x2,y2], "First Weapon"]); - } - - var wep2 = selected_unit.weapon_two(); - if (wep2!=""){ - text= selected_unit.equipments_qual_string("wep2", true); - tooltip_text = cn.temp[111]; - x1 = x_left; - y1 = yy+395; - x2 = x1+string_width_ext(text, -1,187); - y2 = y1+string_height_ext(text, -1,187); - draw_text_ext_outline(x1,y1,text,-1,187, 0, quality_color(selected_unit.weapon_two_quality)); - array_push(tooltip_drawing, [tooltip_text, [x1,y1,x2,y2], "Second Weapon"]); - } + x1 = x_left; + y1 = yy + 320; + x2 = x1 + string_width_ext(text, -1, 187); + y2 = y1 + string_height_ext(text, -1, 187); + draw_set_alpha(1); + draw_text_ext_outline(x1, y1, text, -1, 187, 0, quality_color(selected_unit.armour_quality)); + array_push(tooltip_drawing, [tooltip_text, [x1, y1, x2, y2], "Armour"]); + } - // Stats - text = $"{selected_unit.bionics}"; // Bionics tracker - x1 = x_left+110; - y1 = yy+208; - x2 = x1+string_width(text); - y2 = y1+string_height(text); - x3 = x1 - 26; - y3 = y1 - 4; - - draw_sprite_stretched(spr_icon_bionics, 0, x3, y3, 24, 24); - draw_text_outline(x1,y1,text); - var _body_parts = ARR_body_parts; - var _body_parts_display = ARR_body_parts_display; - bionic_tooltip = "Bionic Augmentation is something a unit can do to both enhance their capabilities, but also replace a missing limb to get back into the fight."; - bionic_tooltip += "\nThere is a limit of 10 Bionic augmentations. After that the damage is so extensive that a marine requires a dreadnought to keep going."; - bionic_tooltip += "\nFor everyone else? It's time for the emperor's mercy."; - bionic_tooltip += "\n\nCurrent Bionic Augmentations:\n"; - for (var part = 0; part0 && managing<=10){ - var cap_slot=company_data.captain!="none"; - var champ_slot=company_data.champion!="none"; - var ancient_slot=company_data.ancient!="none"; - } - for(var i=0; i0 && managing<=10 && (!cap_slot || !champ_slot || !ancient_slot)){ - if (!cap_slot){ - draw_set_color(c_black); - draw_rectangle(xx+25,yy+64,xx+974,yy+85,0); - draw_set_color(c_gray); - draw_rectangle(xx+25,yy+64,xx+974,yy+85,1); - draw_set_halign(fa_center); - draw_set_color(c_yellow); - draw_text(xx+500,yy+66,"++New Captain Required++") - draw_set_halign(fa_left); - draw_set_color(c_gray); - if (point_and_click([xx+25,yy+64,xx+974,yy+85])){ - var candidates = collect_role_group("captain_candidates"); - group_selection(candidates,{ - purpose:$"{scr_roman_numerals()[managing-1]} Company Captain Candidates", - purpose_code : "captain_promote", - number:1, - system:managing, - feature:"none", - planet : 0, - selections : [], - }); - exit; - } - yy+=20; - cap_slot=true; - continue; - } - if (!champ_slot){ - draw_set_color(c_black); - draw_rectangle(xx+25,yy+64,xx+974,yy+85,0); - draw_set_color(c_gray); - draw_rectangle(xx+25,yy+64,xx+974,yy+85,1); - draw_set_halign(fa_center); - draw_set_color(c_yellow); - draw_text(xx+500,yy+66,"++New Champion Required++") - draw_set_halign(fa_left); - draw_set_color(c_gray); - if (point_and_click([xx+25,yy+64,xx+974,yy+85])){ - var search_params = { - companies:managing, - "stat":[["weapon_skill", 44, "more"]] - }; - var candidates = collect_role_group("standard", "", true,search_params); - group_selection(candidates,{ - purpose:$"{scr_roman_numerals()[managing-1]} Champion Candidates", - purpose_code : "champion_promote", - number:1, - system:managing, - feature:"none", - planet : 0, - selections : [], - }); - exit; - } - yy+=20; - champ_slot=true; - continue; - } - if (!ancient_slot){ - draw_set_color(c_black); - draw_rectangle(xx+25,yy+64,xx+974,yy+85,0); - draw_set_color(c_gray); - draw_rectangle(xx+25,yy+64,xx+974,yy+85,1); - draw_set_halign(fa_center); - draw_set_color(c_yellow); - draw_text(xx+500,yy+66,"++New Ancient Required++") - draw_set_halign(fa_left); - draw_set_color(c_gray); - if (point_and_click([xx+25,yy+64,xx+974,yy+85])){ - var search_params = { - companies:managing, - }; - var candidates = collect_role_group("standard", "", true,search_params); - group_selection(candidates,{ - purpose:$"{scr_roman_numerals()[managing-1]} Company Ancient Candidates", - purpose_code : "ancient_promote", - number:1, - system:managing, - feature:"none", - planet : 0, - selections : [], - }); - exit; - } - yy+=20; - ancient_slot=true; - continue; - } - } - if (sel>=array_length(display_unit)) then break; - while (man[sel]=="hide") and (sel0 ?man_current-1:0; - } - } else if (i==repetitions-1){ - if (point_in_rectangle(mouse_x, mouse_y,xx+25+8,yy+64,xx+974,yy+85) && mouse_check_button(mb_left)){ - man_current = man_current0){ - for(var i=0; i 0 && managing <= 10) { + var cap_slot = company_data.captain != "none"; + var champ_slot = company_data.champion != "none"; + var ancient_slot = company_data.ancient != "none"; + } + for (var i = 0; i < repetitions; i++) { + if (managing > 0 && managing <= 10 && (!cap_slot || !champ_slot || !ancient_slot)) { + if (!cap_slot) { + draw_set_color(c_black); + draw_rectangle(xx + 25, yy + 64, xx + 974, yy + 85, 0); + draw_set_color(c_gray); + draw_rectangle(xx + 25, yy + 64, xx + 974, yy + 85, 1); + draw_set_halign(fa_center); + draw_set_color(c_yellow); + draw_text(xx + 500, yy + 66, "++New Captain Required++"); + draw_set_halign(fa_left); + draw_set_color(c_gray); + if (point_and_click([xx + 25, yy + 64, xx + 974, yy + 85])) { + var candidates = collect_role_group("captain_candidates"); + group_selection(candidates, { + purpose: $"{scr_roman_numerals()[managing - 1]} Company Captain Candidates", + purpose_code: "captain_promote", + number: 1, + system: managing, + feature: "none", + planet: 0, + selections: [] + }); + exit; + } + yy += 20; + cap_slot = true; + continue; + } + if (!champ_slot) { + draw_set_color(c_black); + draw_rectangle(xx + 25, yy + 64, xx + 974, yy + 85, 0); + draw_set_color(c_gray); + draw_rectangle(xx + 25, yy + 64, xx + 974, yy + 85, 1); + draw_set_halign(fa_center); + draw_set_color(c_yellow); + draw_text(xx + 500, yy + 66, "++New Champion Required++"); + draw_set_halign(fa_left); + draw_set_color(c_gray); + if (point_and_click([xx + 25, yy + 64, xx + 974, yy + 85])) { + var search_params = { + companies: managing, + "stat": [ + ["weapon_skill", 44, "more"] + ] + }; + var candidates = collect_role_group("standard", "", true, search_params); + group_selection(candidates, { + purpose: $"{scr_roman_numerals()[managing - 1]} Champion Candidates", + purpose_code: "champion_promote", + number: 1, + system: managing, + feature: "none", + planet: 0, + selections: [] + }); + exit; + } + yy += 20; + champ_slot = true; + continue; + } + if (!ancient_slot) { + draw_set_color(c_black); + draw_rectangle(xx + 25, yy + 64, xx + 974, yy + 85, 0); + draw_set_color(c_gray); + draw_rectangle(xx + 25, yy + 64, xx + 974, yy + 85, 1); + draw_set_halign(fa_center); + draw_set_color(c_yellow); + draw_text(xx + 500, yy + 66, "++New Ancient Required++"); + draw_set_halign(fa_left); + draw_set_color(c_gray); + if (point_and_click([xx + 25, yy + 64, xx + 974, yy + 85])) { + var search_params = { + companies: managing + }; + var candidates = collect_role_group("standard", "", true, search_params); + group_selection(candidates, { + purpose: $"{scr_roman_numerals()[managing - 1]} Company Ancient Candidates", + purpose_code: "ancient_promote", + number: 1, + system: managing, + feature: "none", + planet: 0, + selections: [] + }); + exit; + } + yy += 20; + ancient_slot = true; + continue; + } + } + if (sel >= array_length(display_unit)) { + break; + } + while ((man[sel] == "hide") && (sel < array_length(display_unit) - 1)) { + sel += 1; + } + if (scr_draw_management_unit(sel, yy, xx) == "continue") { + sel++; + i--; + continue; + } + if (i == 0) { + if (point_in_rectangle(mouse_x, mouse_y, xx + 25 + 8, yy + 64, xx + 974, yy + 85) && mouse_check_button(mb_left)) { + man_current = man_current > 0 ? man_current - 1 : 0; + } + } else if (i == repetitions - 1) { + if (point_in_rectangle(mouse_x, mouse_y, xx + 25 + 8, yy + 64, xx + 974, yy + 85) && mouse_check_button(mb_left)) { + man_current = man_current < man_max - man_see ? man_current + 1 : man_current == (man_max - man_see); + man_current++; + } + } + + yy += 20; + sel += 1; + } + if (sel_all != "" || squad_sel_count > 0) { + for (var i = 0; i < top; i++) { + scr_draw_management_unit(i, yy, xx, false); + } + for (var i = sel; i < array_length(display_unit); i++) { + scr_draw_management_unit(i, yy, xx, false); + } + } + sel_all = ""; + + draw_set_color(c_black); + xx = __view_get(e__VW.XView, 0) + 0; + yy = __view_get(e__VW.YView, 0) + 0; + draw_rectangle(xx + 974, yy + 165, xx + 1005, yy + 822, 0); + draw_set_color(c_gray); + draw_rectangle(xx + 974, yy + 165, xx + 1005, yy + 822, 1); + + // Squad outline + draw_rectangle(xx + 25, yy + 142, xx + 14 + 8, yy + 822, 1); + // draw_rectangle(xx+577,yy+64,xx+600,yy+85,1); + // draw_rectangle(xx+577,yy+379,xx+600,yy+400,1); + + draw_set_color(0); + draw_rectangle(xx + 974, yy + 141, xx + 1005, yy + 172, 0); + draw_rectangle(xx + 974, yy + 790, xx + 1005, yy + 822, 0); + draw_set_color(c_gray); + draw_rectangle(xx + 974, yy + 141, xx + 1005, yy + 172, 1); + draw_rectangle(xx + 974, yy + 790, xx + 1005, yy + 822, 1); + + draw_sprite_stretched(spr_arrow, 2, xx + 974, yy + 141, 31, 30); + draw_sprite_stretched(spr_arrow, 3, xx + 974, yy + 791, 31, 30); + + /* draw_set_color(c_black);draw_rectangle(xx+25,yy+400,xx+600,yy+417,0); draw_set_color(38144);draw_rectangle(xx+25,yy+400,xx+600,yy+417,1); draw_line(xx+160,yy+400,xx+160,yy+417); @@ -912,71 +799,71 @@ function scr_ui_manage() { draw_set_font(fnt_menu); draw_set_halign(fa_center); */ - - yy+=8; - //TODO handle recursively - if (!obj_controller.unit_profile) && (!stats_displayed){ - var sel_loading=obj_controller.selecting_ship; - //draws hover over tooltips - function gen_tooltip(tooltip_array) { - for (var i = 0; i < array_length(tooltip_array); i++) { - var tooltip = tooltip_array[i]; - if (point_in_rectangle(mouse_x, mouse_y, tooltip[1][0], tooltip[1][1], tooltip[1][2], tooltip[1][3])) { - tooltip_draw(tooltip[0]); - } - } - } - gen_tooltip(potential_tooltip); - gen_tooltip(promotion_tooltip); - gen_tooltip(health_tooltip); - - // Draw interaction and selection buttons - yy-=8; - draw_set_font(fnt_40k_14b); - draw_set_color(#50a076); - var button = new UnitButtonObject(); + + yy += 8; + //TODO handle recursively + if ((!obj_controller.unit_profile) && (!stats_displayed)) { + var sel_loading = obj_controller.selecting_ship; + //draws hover over tooltips + function gen_tooltip(tooltip_array) { + for (var i = 0; i < array_length(tooltip_array); i++) { + var tooltip = tooltip_array[i]; + if (point_in_rectangle(mouse_x, mouse_y, tooltip[1][0], tooltip[1][1], tooltip[1][2], tooltip[1][3])) { + tooltip_draw(tooltip[0]); + } + } + } + gen_tooltip(potential_tooltip); + gen_tooltip(promotion_tooltip); + gen_tooltip(health_tooltip); + + // Draw interaction and selection buttons + yy -= 8; + draw_set_font(fnt_40k_14b); + draw_set_color(#50a076); + var button = new UnitButtonObject(); button.h = 15; - button.x1 = right_ui_block.x1+1; - button.y1 = right_ui_block.y2-6-30; - button.x2 = button.x1 + 128; - button.y2 = button.y1 + button.h; - // Load/Unload to ship button - button.label = "Load"; - var load_unload_possible = man_size>0; - - button.keystroke = (keyboard_check(vk_shift) && (keyboard_check_pressed(ord("L")))); - button.tooltip = "Press Shift L"; - if (load_unload_possible){ - button.alpha = 1; - if (sel_loading==-1){ - if (button.draw()){ - load_selection(); - } - } else if (sel_loading!=-1){ - button.label = "Unload"; - if (button.draw()){ - unload_selection(); // Unload - ask for planet confirmation - } - } - } else { - button.alpha = 0.5; - button.draw(false); - } - - button.move("down", true); + button.x1 = right_ui_block.x1 + 1; + button.y1 = right_ui_block.y2 - 6 - 30; + button.x2 = button.x1 + 128; + button.y2 = button.y1 + button.h; + // Load/Unload to ship button + button.label = "Load"; + var load_unload_possible = man_size > 0; + + button.keystroke = keyboard_check(vk_shift) && keyboard_check_pressed(ord("L")); + button.tooltip = "Press Shift L"; + if (load_unload_possible) { + button.alpha = 1; + if (sel_loading == -1) { + if (button.draw()) { + load_selection(); + } + } else if (sel_loading != -1) { + button.label = "Unload"; + if (button.draw()) { + unload_selection(); // Unload - ask for planet confirmation + } + } + } else { + button.alpha = 0.5; + button.draw(false); + } + + button.move("down", true); button.label = "Reload"; //button.keystroke = (keyboard_check(vk_shift) && (keyboard_check_pressed(ord("F")))); - if (instance_exists(cn)) and (is_struct(temp[120])) { - button.tooltip = $"{temp[120].last_ship.name}"//Press Shift F"; + if (instance_exists(cn) && is_struct(temp[120])) { + button.tooltip = $"{temp[120].last_ship.name}"; //Press Shift F"; } - reload_possible = man_size>0 && sel_loading==-1; + reload_possible = man_size > 0 && sel_loading == -1; if (reload_possible) { button.alpha = 1; if (button.draw()) { - scr_company_load(selecting_location) - load_marines_into_ship(selecting_location, sh_ide, display_unit, true) + scr_company_load(selecting_location); + load_marines_into_ship(selecting_location, sh_ide, display_unit, true); } } else { button.alpha = 0.5; @@ -984,299 +871,307 @@ function scr_ui_manage() { } button.h = 30; - button.x1 = right_ui_block.x1+26; - button.y1 = right_ui_block.y2-6-30; - button.x2 = button.x1 + button.w; - button.y2 = button.y1 + button.h; - button.move("right", true); - - // // Re equip button - button.label = "Re-equip"; - var equip_possible=!array_contains(invalid_locations, selecting_location) && - man_size>0; - - button.alpha = equip_possible? 1 : 0.5; - button.keystroke = (keyboard_check(vk_shift) && (keyboard_check_pressed(ord("E")))); - button.tooltip = "Press Shift E"; - - if (button.draw() && equip_possible){ - equip_selection(); - } - - button.move("right"); - - // // Promote button - button.label = "Promote"; - - button.keystroke = (keyboard_check(vk_shift) && (keyboard_check_pressed(ord("P")))); - button.tooltip = "Press Shift P"; - - var promote_possible = sel_promoting > 0 && !array_contains(invalid_locations, selecting_location) && man_size>0; - button.alpha = promote_possible? 1 : 0.5; - if (button.draw()){ - if (promote_possible){ - if (sel_promoting==1) and (instance_number(obj_popup)==0){ - var pip=instance_create(0,0,obj_popup); - pip.type=5; - pip.company=managing; - - var god=0,nuuum=0; - for(var f=0; f=1 || is_specialist(ma_role[f], "rank_and_file") || is_specialist(ma_role[f], "squad_leaders")) && man_sel[f]==1){ - nuuum+=1; - if (pip.min_exp==0) then pip.min_exp=ma_exp[f]; - pip.min_exp=min(ma_exp[f],pip.min_exp); - } - if (god==0) and (ma_promote[f]>=1) and (man_sel[f]==1){ - god=1; - pip.unit_role=ma_role[f]; - } - } - if (nuuum>1) then pip.unit_role="Marines"; - pip.units=nuuum; - } - } - } - button.move("right", true); - - // // Put in jail button - button.label = "Jail"; - button.keystroke = (keyboard_check(vk_shift) && (keyboard_check_pressed(ord("J")))); - button.tooltip = "Press Shift J"; - - var jail_possible = man_size>0; - button.alpha = jail_possible ? 1 : 0.5; - if (button.draw()){ - if (jail_possible) then jail_selection(); - } - button.x1 += button.w + button.h_gap; - button.x2 += button.w + button.h_gap; - // // Add bionics button - button.label = "Add Bionics"; - button.keystroke = (keyboard_check(vk_shift) && (keyboard_check_pressed(ord("B")))); - button.tooltip = "Press Shift B"; - var bionics_possible = man_size>0; - button.alpha = bionics_possible ? 1 : 0.5; - if (button.draw()){ - if (bionics_possible) then add_bionics_selection(); - } - - button.move("up", true); - - button.move("left", true, 4) - - - // // Designate as boarder unit - button.label = "Set Boarder"; - button.keystroke = (keyboard_check(vk_shift) && (keyboard_check_pressed(ord("Q")))); - button.tooltip = "Press Shift Q"; - var boarder_possible = sel_loading!=-1 && man_size>0; - button.alpha = boarder_possible ? 1 : 0.5; - if (button.draw() && boarder_possible){ - if (boarder_possible) then toggle_selection_borders(); - } - button.move("right", true); - - // // Reset changes button - button.label = "Reset"; - button.keystroke = (keyboard_check(vk_shift) && (keyboard_check_pressed(ord("R")))); - button.tooltip = "Press Shift R"; - var reset_possible = !array_contains(invalid_locations, selecting_location) && man_size>0; - if reset_possible{ - button.alpha = 1; - if (button.draw()){ - reset_selection_equipment(); - } - } else { - button.alpha = 0.5; - button.draw(false); - } - - button.move("right", true); - - // // Transfer to another company button - button.label = "Transfer"; - button.keystroke = (keyboard_check(vk_shift) && (keyboard_check_pressed(ord("T")))); - button.tooltip = "Press Shift T"; - var transfer_possible = !array_contains(invalid_locations, selecting_location) && man_size>0; - if (transfer_possible){ - button.alpha = 1; - if (button.draw()){ - transfer_selection(); - } - } else { - button.alpha = 0.5; - button.draw(false); - } - - button.move("right", true); - button.label = "Move Ship"; - button.keystroke = (keyboard_check(vk_shift) && (keyboard_check_pressed(ord("M")))); - button.tooltip = "Press Shift M"; - var moveship_possible = !array_contains(invalid_locations, selecting_location) && man_size>0 && selecting_ship>-1; - if (moveship_possible){ - button.alpha = 1; - if (button.draw()){ - load_selection(); - } - } else { - button.alpha = 0.5; - button.draw(false); - } - - - button.move("right", true); - - button.label = "Add Tag"; - button.keystroke = (keyboard_check(vk_shift) && (keyboard_check_pressed(ord("F")))); - button.tooltip = "Coming soon"//Press Shift F"; - tag_possible = man_size>0; - tag_possible = false; - button.alpha = 0.5; - if (tag_possible){ - button.alpha = 1; - if (button.draw()){ - load_selection(); - } - } else { - button.alpha = 0.5; - button.draw(false); - } - - if (sel_uni[1] != "") { - // How much space the selected unit takes - draw_set_font(fnt_40k_30b); - draw_text_transformed(actions_block.x1 + 26, actions_block.y1 + 6,$"Selection: {man_size} space",0.5,0.5,0); - // List of selected units - draw_set_font(fnt_40k_14); - draw_text_ext(actions_block.x1 + 26, actions_block.y1 + 30,selecting_dudes,-1,550); - // Options for the selected unit - // draw_set_font(fnt_40k_30b); - // draw_text_transformed(actions_block.x1 + 4, actions_block.x1 + 64,"Options:",0.5,0.5,0); - - // Select all units button - - button.move("up", true, 4.15); - - button.move("left", true, 4); - - button.label = "Select All"; - button.tooltip = ""; - button.keystroke = false; - button.alpha = 1; - if (button.draw()){ - cooldown=8; - // scr_load_all(loading); //not sure whether loading was intentional or not - sel_all = "all"; - } - - button.move("right", true, 1); - button.label = "Filter Mode"; - button.alpha = filter_mode ? 1 : 0.5; - if (button.draw()){ - filter_mode = !filter_mode; - } - - button.move("left", true, 1); - // Select all infantry button - button.y1 += button.h + button.v_gap + 4; - button.h /= 1.4; - button.w = 128; - button.x2 = button.x1 + button.w; - button.y2 = button.y1 + button.h; - var inf_button_pos = [button.x1, button.y1, button.x2, button.y2]; - button.label = "All Infantry"; - button.alpha = 1; - button.font = fnt_40k_12; - draw_set_font(fnt_40k_12); - if (button.draw()) { - sel_all = "man"; - } - // Select infantry type buttons - for (var i = 1; i <= 8; i++) { - if (sel_uni[i] != "") { - button.move("right", true); - if (i == 4){ - button.move("left", true, 4); - button.move("down", true); - } - button.label = string_truncate(sel_uni[i], 126); - button.alpha = 1; - if (button.draw()){ - sel_all = sel_uni[i]; - } - } - } - } - - // Select all vehicles button - if (sel_veh[1]!=""){ - button.x1 = inf_button_pos[0]; - button.x2 = inf_button_pos[2]; - button.y1 = inf_button_pos[1] + (button.h + button.v_gap) * 2 + 4; - button.y2 = button.y1 + button.h; - button.label = "All Vehicles"; - button.alpha = 1; - if (button.draw()){ - sel_all="vehicle"; - } - // Select vehicle type buttons - for (var i = 1; i <= 8; i++) { - if (sel_veh[i] != "") { - button.move("right", true); - if i == 4{ - button.move("left", true, 4); - button.move("down", true); - } - button.label = string_truncate(sel_veh[i], 126); - button.alpha = 1; - if (button.draw()) { - sel_all = sel_veh[i]; - } - } - } - } - } + button.x1 = right_ui_block.x1 + 26; + button.y1 = right_ui_block.y2 - 6 - 30; + button.x2 = button.x1 + button.w; + button.y2 = button.y1 + button.h; + button.move("right", true); + + // // Re equip button + button.label = "Re-equip"; + var equip_possible = !array_contains(invalid_locations, selecting_location) && man_size > 0; + + button.alpha = equip_possible ? 1 : 0.5; + button.keystroke = keyboard_check(vk_shift) && keyboard_check_pressed(ord("E")); + button.tooltip = "Press Shift E"; + + if (button.draw() && equip_possible) { + equip_selection(); + } - draw_set_color(#3f7e5d); - scr_scrollbar(974,172,1005,790,34,man_max,man_current); - } - if (is_struct(cn.temp[120])){ - if (cn.temp[120].name()!="") and (cn.temp[120].race()!=0){ - draw_set_alpha(1); - var xx=__view_get( e__VW.XView, 0 )+0, yy=__view_get( e__VW.YView, 0 )+0 - if (scr_hit(xx+1208, yy+210, xx+1374, yy+210+272) || obj_controller.unit_profile) && !instance_exists(obj_temp3) && !instance_exists(obj_popup) { - stats_displayed = true; - selected_unit.stat_display(true); - //tooltip_draw(stat_x, stat_y+string_height(stat_display),0,0,100,17); - } else { - stats_displayed = false; - } - with (obj_controller){ - if (view_squad && !instance_exists(obj_popup)){ - if (managing>10){ - view_squad=false; - unit_profile=false; - } else if (company_data!={}){ - company_data.draw_squad_view(); - } - } - } - } - } - var tip, coords; - for (var i=0;i < array_length(tooltip_drawing); i++){ - tip = tooltip_drawing[i]; - coords=tip[1]; - if (scr_hit(coords)){ - tooltip_draw(tip[0], 350, , , , tip[2]); - } - } - } - else if (menu == 30 && (managing > 0 || managing == -1)) { // Load to ships + button.move("right"); + + // // Promote button + button.label = "Promote"; + + button.keystroke = keyboard_check(vk_shift) && keyboard_check_pressed(ord("P")); + button.tooltip = "Press Shift P"; + + var promote_possible = sel_promoting > 0 && !array_contains(invalid_locations, selecting_location) && man_size > 0; + button.alpha = promote_possible ? 1 : 0.5; + if (button.draw()) { + if (promote_possible) { + if ((sel_promoting == 1) && (instance_number(obj_popup) == 0)) { + var pip = instance_create(0, 0, obj_popup); + pip.type = 5; + pip.company = managing; + + var god = 0, nuuum = 0; + for (var f = 0; f < array_length(display_unit); f++) { + if ((ma_promote[f] >= 1 || is_specialist(ma_role[f], "rank_and_file") || is_specialist(ma_role[f], "squad_leaders")) && man_sel[f] == 1) { + nuuum += 1; + if (pip.min_exp == 0) { + pip.min_exp = ma_exp[f]; + } + pip.min_exp = min(ma_exp[f], pip.min_exp); + } + if ((god == 0) && (ma_promote[f] >= 1) && (man_sel[f] == 1)) { + god = 1; + pip.unit_role = ma_role[f]; + } + } + if (nuuum > 1) { + pip.unit_role = "Marines"; + } + pip.units = nuuum; + } + } + } + button.move("right", true); + + // // Put in jail button + button.label = "Jail"; + button.keystroke = keyboard_check(vk_shift) && keyboard_check_pressed(ord("J")); + button.tooltip = "Press Shift J"; + + var jail_possible = man_size > 0; + button.alpha = jail_possible ? 1 : 0.5; + if (button.draw()) { + if (jail_possible) { + jail_selection(); + } + } + button.x1 += button.w + button.h_gap; + button.x2 += button.w + button.h_gap; + // // Add bionics button + button.label = "Add Bionics"; + button.keystroke = keyboard_check(vk_shift) && keyboard_check_pressed(ord("B")); + button.tooltip = "Press Shift B"; + var bionics_possible = man_size > 0; + button.alpha = bionics_possible ? 1 : 0.5; + if (button.draw()) { + if (bionics_possible) { + add_bionics_selection(); + } + } + + button.move("up", true); + + button.move("left", true, 4); + + // // Designate as boarder unit + button.label = "Set Boarder"; + button.keystroke = keyboard_check(vk_shift) && keyboard_check_pressed(ord("Q")); + button.tooltip = "Press Shift Q"; + var boarder_possible = sel_loading != -1 && man_size > 0; + button.alpha = boarder_possible ? 1 : 0.5; + if (button.draw() && boarder_possible) { + if (boarder_possible) { + toggle_selection_borders(); + } + } + button.move("right", true); + + // // Reset changes button + button.label = "Reset"; + button.keystroke = keyboard_check(vk_shift) && keyboard_check_pressed(ord("R")); + button.tooltip = "Press Shift R"; + var reset_possible = !array_contains(invalid_locations, selecting_location) && man_size > 0; + if (reset_possible) { + button.alpha = 1; + if (button.draw()) { + reset_selection_equipment(); + } + } else { + button.alpha = 0.5; + button.draw(false); + } + + button.move("right", true); + + // // Transfer to another company button + button.label = "Transfer"; + button.keystroke = keyboard_check(vk_shift) && keyboard_check_pressed(ord("T")); + button.tooltip = "Press Shift T"; + var transfer_possible = !array_contains(invalid_locations, selecting_location) && man_size > 0; + if (transfer_possible) { + button.alpha = 1; + if (button.draw()) { + transfer_selection(); + } + } else { + button.alpha = 0.5; + button.draw(false); + } + + button.move("right", true); + button.label = "Move Ship"; + button.keystroke = keyboard_check(vk_shift) && keyboard_check_pressed(ord("M")); + button.tooltip = "Press Shift M"; + var moveship_possible = !array_contains(invalid_locations, selecting_location) && man_size > 0 && selecting_ship > -1; + if (moveship_possible) { + button.alpha = 1; + if (button.draw()) { + load_selection(); + } + } else { + button.alpha = 0.5; + button.draw(false); + } + + button.move("right", true); + + button.label = "Add Tag"; + button.keystroke = keyboard_check(vk_shift) && keyboard_check_pressed(ord("F")); + button.tooltip = "Coming soon"; //Press Shift F"; + tag_possible = man_size > 0; + tag_possible = false; + button.alpha = 0.5; + if (tag_possible) { + button.alpha = 1; + if (button.draw()) { + load_selection(); + } + } else { + button.alpha = 0.5; + button.draw(false); + } + + if (sel_uni[1] != "") { + // How much space the selected unit takes + draw_set_font(fnt_40k_30b); + draw_text_transformed(actions_block.x1 + 26, actions_block.y1 + 6, $"Selection: {man_size} space", 0.5, 0.5, 0); + // List of selected units + draw_set_font(fnt_40k_14); + draw_text_ext(actions_block.x1 + 26, actions_block.y1 + 30, selecting_dudes, -1, 550); + // Options for the selected unit + // draw_set_font(fnt_40k_30b); + // draw_text_transformed(actions_block.x1 + 4, actions_block.x1 + 64,"Options:",0.5,0.5,0); + + // Select all units button + + button.move("up", true, 4.15); + + button.move("left", true, 4); + + button.label = "Select All"; + button.tooltip = ""; + button.keystroke = false; + button.alpha = 1; + if (button.draw()) { + cooldown = 8; + // scr_load_all(loading); //not sure whether loading was intentional or not + sel_all = "all"; + } + + button.move("right", true, 1); + button.label = "Filter Mode"; + button.alpha = filter_mode ? 1 : 0.5; + if (button.draw()) { + filter_mode = !filter_mode; + } + + button.move("left", true, 1); + // Select all infantry button + button.y1 += button.h + button.v_gap + 4; + button.h /= 1.4; + button.w = 128; + button.x2 = button.x1 + button.w; + button.y2 = button.y1 + button.h; + var inf_button_pos = [button.x1, button.y1, button.x2, button.y2]; + button.label = "All Infantry"; + button.alpha = 1; + button.font = fnt_40k_12; + draw_set_font(fnt_40k_12); + if (button.draw()) { + sel_all = "man"; + } + // Select infantry type buttons + for (var i = 1; i <= 8; i++) { + if (sel_uni[i] != "") { + button.move("right", true); + if (i == 4) { + button.move("left", true, 4); + button.move("down", true); + } + button.label = string_truncate(sel_uni[i], 126); + button.alpha = 1; + if (button.draw()) { + sel_all = sel_uni[i]; + } + } + } + } + + // Select all vehicles button + if (sel_veh[1] != "") { + button.x1 = inf_button_pos[0]; + button.x2 = inf_button_pos[2]; + button.y1 = inf_button_pos[1] + (button.h + button.v_gap) * 2 + 4; + button.y2 = button.y1 + button.h; + button.label = "All Vehicles"; + button.alpha = 1; + if (button.draw()) { + sel_all = "vehicle"; + } + // Select vehicle type buttons + for (var i = 1; i <= 8; i++) { + if (sel_veh[i] != "") { + button.move("right", true); + if (i == 4) { + button.move("left", true, 4); + button.move("down", true); + } + button.label = string_truncate(sel_veh[i], 126); + button.alpha = 1; + if (button.draw()) { + sel_all = sel_veh[i]; + } + } + } + } + } + + draw_set_color(#3f7e5d); + scr_scrollbar(974, 172, 1005, 790, 34, man_max, man_current); + } + if (is_struct(cn.temp[120])) { + if ((cn.temp[120].name() != "") && (cn.temp[120].race() != 0)) { + draw_set_alpha(1); + var xx = __view_get(e__VW.XView, 0) + 0, yy = __view_get(e__VW.YView, 0) + 0; + if ((scr_hit(xx + 1208, yy + 210, xx + 1374, yy + 210 + 272) || obj_controller.unit_profile) && !instance_exists(obj_temp3) && !instance_exists(obj_popup)) { + stats_displayed = true; + selected_unit.stat_display(true); + //tooltip_draw(stat_x, stat_y+string_height(stat_display),0,0,100,17); + } else { + stats_displayed = false; + } + with (obj_controller) { + if (view_squad && !instance_exists(obj_popup)) { + if (managing > 10) { + view_squad = false; + unit_profile = false; + } else if (company_data != {}) { + company_data.draw_squad_view(); + } + } + } + } + } + var tip, coords; + for (var i = 0; i < array_length(tooltip_drawing); i++) { + tip = tooltip_drawing[i]; + coords = tip[1]; + if (scr_hit(coords)) { + tooltip_draw(tip[0], 350, , , , tip[2]); + } + } + } else if (menu == 30 && (managing > 0 || managing == -1)) { + // Load to ships var xx, yy, bb, img; - bb = ""; img = 0; + bb = ""; + img = 0; xx = __view_get(e__VW.XView, 0) + 0; yy = __view_get(e__VW.YView, 0) + 0; @@ -1352,8 +1247,7 @@ function scr_ui_manage() { var main_rect; var repetitions = min(ship_max, ship_see); - for (var sel = top; sel < repetitions && sel