From 485fdef1cf0de6886d7ad213df8df45961edd634 Mon Sep 17 00:00:00 2001 From: GalacticChimp Date: Fri, 10 Nov 2023 19:05:08 +0100 Subject: [PATCH 01/11] Initial code cleanup and beautification --- objects/obj_saveload/Alarm_0.gml | 139 +- objects/obj_saveload/Alarm_1.gml | 23 +- objects/obj_saveload/Alarm_2.gml | 6 +- objects/obj_saveload/Alarm_3.gml | 7 +- objects/obj_saveload/Alarm_4.gml | 28 +- objects/obj_saveload/Create_0.gml | 180 +- objects/obj_saveload/Destroy_0.gml | 48 +- objects/obj_saveload/Draw_0.gml | 601 ++++--- objects/obj_saveload/KeyPress_1.gml | 5 +- objects/obj_saveload/Mouse_60.gml | 29 +- objects/obj_saveload/Mouse_61.gml | 47 +- objects/obj_saveload/Step_0.gml | 30 +- scripts/scr_load/scr_load.gml | 2484 +++++++++++++++------------ scripts/scr_save/scr_save.gml | 2095 +++++++++++----------- 14 files changed, 3042 insertions(+), 2680 deletions(-) diff --git a/objects/obj_saveload/Alarm_0.gml b/objects/obj_saveload/Alarm_0.gml index e6c74bb1a..6b815207b 100644 --- a/objects/obj_saveload/Alarm_0.gml +++ b/objects/obj_saveload/Alarm_0.gml @@ -1,57 +1,124 @@ +// SAVE -if (save_part=6){txt="Praise to the Machine God";with(obj_controller){scr_save(5,obj_saveload.save_number);}trickle=50;} - -if (save_part=5){txt="Astartes Registry";with(obj_controller){scr_save(4,obj_saveload.save_number);}trickle=40;save_part=6;} - -if (save_part=4){txt="Sacred Anointing of Oil";with(obj_controller){scr_save(3,obj_saveload.save_number);}trickle=10;save_part=5;} - -if (save_part=3){txt="Charting Sector";with(obj_controller){scr_save(2,obj_saveload.save_number);}trickle=10;save_part=4;} +if (save_part = 6) { + txt = "Praise to the Machine God"; + with(obj_controller) { + scr_save(5, obj_saveload.save_number); + } + trickle = 50; +} -if (save_part=2){txt="Finding Servo Skulls";with(obj_controller){scr_save(1,obj_saveload.save_number);}trickle=10;save_part=3;} +if (save_part = 5) { + txt = "Astartes Registry"; + with(obj_controller) { + scr_save(4, obj_saveload.save_number); + } + trickle = 40; + save_part = 6; +} -if (save_part=1){ - if (file_exists("save"+string(save_number)+".ini")) then file_delete("save"+string(save_number)+".ini"); - if (file_exists("screen"+string(save_number)+".png")) then file_delete("screen"+string(save_number)+".png"); - ini_open("saves.ini");ini_section_delete(string(save_number));ini_close(); - obj_saveload.save[save_number]=0; - save_part+=1;trickle=10; - txt="Preparing"; +if (save_part = 4) { + txt = "Sacred Anointing of Oil"; + with(obj_controller) { + scr_save(3, obj_saveload.save_number); + } + trickle = 10; + save_part = 5; } +if (save_part = 3) { + txt = "Charting Sector"; + with(obj_controller) { + scr_save(2, obj_saveload.save_number); + } + trickle = 10; + save_part = 4; +} +if (save_part = 2) { + txt = "Finding Servo Skulls"; + with(obj_controller) { + scr_save(1, obj_saveload.save_number); + } + trickle = 10; + save_part = 3; +} +if (save_part = 1) { + if (file_exists("save" + string(save_number) + ".ini")) then file_delete("save" + string(save_number) + ".ini"); + if (file_exists("screen" + string(save_number) + ".png")) then file_delete("screen" + string(save_number) + ".png"); + ini_open("saves.ini"); + ini_section_delete(string(save_number)); + ini_close(); + obj_saveload.save[save_number] = 0; + save_part += 1; + trickle = 10; + txt = "Preparing"; +} +// LOAD +if (load_part = 6) { + txt = "Praise to the Machine God"; + if (global.restart > 0) then txt = "Praise be to the Emperor"; + with(obj_controller) { + scr_load(5, global.load); + } + trickle = 50; + if (instance_exists(obj_cuicons)) { + obj_cuicons.alarm[1] = 30; + } +} -if (load_part=6){ - txt="Praise to the Machine God";if (global.restart>0) then txt="Praise be to the Emperor";with(obj_controller){scr_load(5,global.load);}trickle=50; - - if (instance_exists(obj_cuicons)){ - obj_cuicons.alarm[1]=30; +if (load_part = 5) { + txt = "Sacred Anointing of Oil"; + if (global.restart > 0) then txt = "Speed Dialing Howling Banshee"; + with(obj_controller) { + scr_load(4, global.load); } - + trickle = 10; + load_part = 6; } -if (load_part=5){txt="Sacred Anointing of Oil";if (global.restart>0) then txt="Speed Dialing Howling Banshee";with(obj_controller){scr_load(4,global.load);}trickle=10;load_part=6;} - -if (load_part=4){ - with(obj_star){if (x2>5) and (y2>5) then buddy=instance_nearest(x2,y2,obj_star);} - txt="Astartes Registry";if (global.restart>0) then txt="Donning Power Armour";with(obj_controller){scr_load(3,global.load);}trickle=40;load_part=5; +if (load_part = 4) { + with(obj_star) { + if (x2 > 5) and(y2 > 5) then buddy = instance_nearest(x2, y2, obj_star); + } + txt = "Astartes Registry"; + if (global.restart > 0) then txt = "Donning Power Armour"; + with(obj_controller) { + scr_load(3, global.load); + } + trickle = 40; + load_part = 5; } -if (load_part=3){txt="Charting Sector";if (global.restart>0) then txt="Rousing the Machine Spirit";with(obj_controller){scr_load(2,global.load);}trickle=10;load_part=4;} - -if (load_part=2){txt="Finding Servo Skulls";if (global.restart>0) then txt="Turtle Waxing Scalp";with(obj_controller){scr_load(1,global.load);}trickle=10;load_part=3;} - -if (load_part=1){ - if (file_exists("save"+string(global.load)+".ini")){ - load_part+=1; - trickle=10; - txt="Preparing"; +if (load_part = 3) { + txt = "Charting Sector"; + if (global.restart > 0) then txt = "Rousing the Machine Spirit"; + with(obj_controller) { + scr_load(2, global.load); } + trickle = 10; + load_part = 4; } +if (load_part = 2) { + txt = "Finding Servo Skulls"; + if (global.restart > 0) then txt = "Turtle Waxing Scalp"; + with(obj_controller) { + scr_load(1, global.load); + } + trickle = 10; + load_part = 3; +} - +if (load_part = 1) { + if (file_exists("save" + string(global.load) + ".ini")) { + load_part += 1; + trickle = 10; + txt = "Preparing"; + } +} \ No newline at end of file diff --git a/objects/obj_saveload/Alarm_1.gml b/objects/obj_saveload/Alarm_1.gml index 46d5ef74b..de89fb5e9 100644 --- a/objects/obj_saveload/Alarm_1.gml +++ b/objects/obj_saveload/Alarm_1.gml @@ -1,16 +1,17 @@ +obj_controller.menu = 0; +obj_controller.zui = 0; +obj_controller.invis = false; +obj_cursor.image_alpha = 1; +obj_controller.cooldown = 20; -obj_controller.menu=0;obj_controller.zui=0;obj_controller.invis=false; -obj_cursor.image_alpha=1;obj_controller.cooldown=20; - - -if (global.restart>0){ - instance_create(0,0,obj_restart_vars); +if (global.restart > 0) { + instance_create(0, 0, obj_restart_vars); scr_restart_variables(3); - - with(obj_ini){instance_destroy();} + + with(obj_ini) { + instance_destroy(); + } room_goto(Creation); } -instance_destroy(); - - +instance_destroy(); \ No newline at end of file diff --git a/objects/obj_saveload/Alarm_2.gml b/objects/obj_saveload/Alarm_2.gml index d89363e8e..6a2c90b81 100644 --- a/objects/obj_saveload/Alarm_2.gml +++ b/objects/obj_saveload/Alarm_2.gml @@ -1,5 +1,3 @@ +screen_save("screen" + string(save_number) + ".png"); -screen_save("screen"+string(save_number)+".png"); - -alarm[3]=1; - +alarm[3] = 1; \ No newline at end of file diff --git a/objects/obj_saveload/Alarm_3.gml b/objects/obj_saveload/Alarm_3.gml index e9e3aff40..482c90f10 100644 --- a/objects/obj_saveload/Alarm_3.gml +++ b/objects/obj_saveload/Alarm_3.gml @@ -1,4 +1,3 @@ -hide=0; -obj_controller.invis=false; -obj_controller.zui=1; - +hide = 0; +obj_controller.invis = false; +obj_controller.zui = 1; \ No newline at end of file diff --git a/objects/obj_saveload/Alarm_4.gml b/objects/obj_saveload/Alarm_4.gml index 47ec398f8..c909f92c6 100644 --- a/objects/obj_saveload/Alarm_4.gml +++ b/objects/obj_saveload/Alarm_4.gml @@ -1,12 +1,16 @@ - - -if (sprite_exists(img1)){sprite_delete(img1);} -if (sprite_exists(img2)){sprite_delete(img2);} -if (sprite_exists(img3)){sprite_delete(img3);} -if (sprite_exists(img4)){sprite_delete(img4);} -if (file_exists(working_directory + "\\screen"+string(save[top])+".png")) then img1=sprite_add(working_directory + "\\screen"+string(save[top])+".png",1,0,0,0,0); -if (file_exists(working_directory + "\\screen"+string(save[top+1])+".png")) then img2=sprite_add(working_directory + "\\screen"+string(save[top+1])+".png",1,0,0,0,0); -if (file_exists(working_directory + "\\screen"+string(save[top+2])+".png")) then img3=sprite_add(working_directory + "\\screen"+string(save[top+2])+".png",1,0,0,0,0); -if (file_exists(working_directory + "\\screen"+string(save[top+3])+".png")) then img4=sprite_add(working_directory + "\\screen"+string(save[top+3])+".png",1,0,0,0,0); - - +if (sprite_exists(img1)) { + sprite_delete(img1); +} +if (sprite_exists(img2)) { + sprite_delete(img2); +} +if (sprite_exists(img3)) { + sprite_delete(img3); +} +if (sprite_exists(img4)) { + sprite_delete(img4); +} +if (file_exists(working_directory + "\\screen" + string(save[top]) + ".png")) then img1 = sprite_add(working_directory + "\\screen" + string(save[top]) + ".png", 1, 0, 0, 0, 0); +if (file_exists(working_directory + "\\screen" + string(save[top + 1]) + ".png")) then img2 = sprite_add(working_directory + "\\screen" + string(save[top + 1]) + ".png", 1, 0, 0, 0, 0); +if (file_exists(working_directory + "\\screen" + string(save[top + 2]) + ".png")) then img3 = sprite_add(working_directory + "\\screen" + string(save[top + 2]) + ".png", 1, 0, 0, 0, 0); +if (file_exists(working_directory + "\\screen" + string(save[top + 3]) + ".png")) then img4 = sprite_add(working_directory + "\\screen" + string(save[top + 3]) + ".png", 1, 0, 0, 0, 0); \ No newline at end of file diff --git a/objects/obj_saveload/Create_0.gml b/objects/obj_saveload/Create_0.gml index 2f47f95cf..95fcfb4f4 100644 --- a/objects/obj_saveload/Create_0.gml +++ b/objects/obj_saveload/Create_0.gml @@ -1,109 +1,101 @@ - -scr_image("loading",-50,0,0,0,0); - -menu=0;// 1 : save, 2: load -save_part=0; -load_part=0; -save_number=0; -trickle=0; -txt=""; -hide=0; -cooldown=10; -bar=0; -slow=0; -saves=0; -highlighting=0; -spr_screen=0; -first_open=0; -max_ini=0; -mouse_left=0; -reset=0; -splash=choose(0,1,2,3,4); - -debug=""; - -top=1; - -if (instance_exists(obj_controller)){ - if (obj_controller.zoomed=1){ - with(obj_controller){scr_zoom();} +scr_image("loading", -50, 0, 0, 0, 0); + +menu = 0; // 1 : save, 2: load +save_part = 0; +load_part = 0; +save_number = 0; +trickle = 0; +txt = ""; +hide = 0; +cooldown = 10; +bar = 0; +slow = 0; +saves = 0; +highlighting = 0; +spr_screen = 0; +first_open = 0; +max_ini = 0; +mouse_left = 0; +reset = 0; +splash = choose(0, 1, 2, 3, 4); + +debug = ""; + +top = 1; + +if (instance_exists(obj_controller)) { + if (obj_controller.zoomed = 1) { + with(obj_controller) { + scr_zoom(); + } } } - -var i;i=-1;saves=0; -repeat(201){i+=1; - save[i]=0;save_turn[i]=0; - save_chapter[i]=""; - save_master[i]=""; - save_marines[i]=0; - save_date[i]=""; - save_time[i]=0; - screen_exists[i]=false; - spr_screen[i]=0; - save_seed[i]=0; +var i = -1; +saves = 0; +repeat(201) { + i += 1; + save[i] = 0; + save_turn[i] = 0; + save_chapter[i] = ""; + save_master[i] = ""; + save_marines[i] = 0; + save_date[i] = ""; + save_time[i] = 0; + screen_exists[i] = false; + spr_screen[i] = 0; + save_seed[i] = 0; } -i=0; -repeat(100){i+=1; - if (file_exists("save"+string(i)+".ini")){ - saves+=1;save[saves]=i; + +i = 0; +repeat(100) { + i += 1; + if (file_exists("save" + string(i) + ".ini")) { + saves += 1; + save[saves] = i; } - if (!file_exists("save"+string(i)+".ini")) and (i>0) and (max_ini=0) then max_ini=i; - if (file_exists("save"+string(i+1)+".ini")) and (max_ini>0) then max_ini=0; + if (!file_exists("save" + string(i) + ".ini")) and(i > 0) and(max_ini = 0) then max_ini = i; + if (file_exists("save" + string(i + 1) + ".ini")) and(max_ini > 0) then max_ini = 0; } -first_open=saves+1; - - +first_open = saves + 1; +img1 = 0; +img2 = 0; +img3 = 0; +img4 = 0; -img1=0; -img2=0; -img3=0; -img4=0; - - - - -if (file_exists("saves.ini")){ +if (file_exists("saves.ini")) { ini_open("saves.ini"); - i=-1; - repeat(200){i+=1; - if (save[i]>0){ - if (ini_section_exists(string(save[i]))){ - save_turn[save[i]]=ini_read_real(string(save[i]),"turn",0); - save_chapter[save[i]]=ini_read_string(string(save[i]),"chapter_name","Error"); - save_master[save[i]]=ini_read_string(string(save[i]),"master_name","Error"); - save_marines[save[i]]=ini_read_real(string(save[i]),"marines",0); - save_date[save[i]]=ini_read_string(string(save[i]),"date","Error"); - save_time[save[i]]=ini_read_real(string(save[i]),"time",0); - save_seed[save[i]]=ini_read_real(string(save[i]),"seed",0); - - /*if (file_exists(working_directory + "\screen"+string(save[i])+".png")){ - screen_exists[i]=true; - spr_screen[save[i]]=sprite_add(working_directory + "\screen"+string(save[save[i]])+".png",1,0,0,0,0); - }*/ + i = -1; + repeat(200) { + i += 1; + if (save[i] > 0) { + if (ini_section_exists(string(save[i]))) { + save_turn[save[i]] = ini_read_real(string(save[i]), "turn", 0); + save_chapter[save[i]] = ini_read_string(string(save[i]), "chapter_name", "Error"); + save_master[save[i]] = ini_read_string(string(save[i]), "master_name", "Error"); + save_marines[save[i]] = ini_read_real(string(save[i]), "marines", 0); + save_date[save[i]] = ini_read_string(string(save[i]), "date", "Error"); + save_time[save[i]] = ini_read_real(string(save[i]), "time", 0); + save_seed[save[i]] = ini_read_real(string(save[i]), "seed", 0); } - if (!ini_section_exists(string(i))){ - save_turn[i]=-50; - save_chapter[i]="Unknown Save Data"; - save_master[i]="Unknown"; - save_marines[i]=-50; - save_date[i]=""; - save_time[i]=0; + if (!ini_section_exists(string(i))) { + save_turn[i] = -50; + save_chapter[i] = "Unknown Save Data"; + save_master[i] = "Unknown"; + save_marines[i] = -50; + save_date[i] = ""; + save_time[i] = 0; } } } - - - if (file_exists(working_directory + "\\screen"+string(save[1])+".png")) then img1=sprite_add(working_directory + "\\screen"+string(save[1])+".png",1,0,0,0,0); - if (file_exists(working_directory + "\\screen"+string(save[2])+".png")) then img2=sprite_add(working_directory + "\\screen"+string(save[2])+".png",1,0,0,0,0); - if (file_exists(working_directory + "\\screen"+string(save[3])+".png")) then img3=sprite_add(working_directory + "\\screen"+string(save[3])+".png",1,0,0,0,0); - if (file_exists(working_directory + "\\screen"+string(save[4])+".png")) then img4=sprite_add(working_directory + "\\screen"+string(save[4])+".png",1,0,0,0,0); - - - ini_close(); -} -/* */ -/* */ + + if (file_exists(working_directory + "\\screen" + string(save[1]) + ".png")) then img1 = sprite_add(working_directory + "\\screen" + string(save[1]) + ".png", 1, 0, 0, 0, 0); + if (file_exists(working_directory + "\\screen" + string(save[2]) + ".png")) then img2 = sprite_add(working_directory + "\\screen" + string(save[2]) + ".png", 1, 0, 0, 0, 0); + if (file_exists(working_directory + "\\screen" + string(save[3]) + ".png")) then img3 = sprite_add(working_directory + "\\screen" + string(save[3]) + ".png", 1, 0, 0, 0, 0); + if (file_exists(working_directory + "\\screen" + string(save[4]) + ".png")) then img4 = sprite_add(working_directory + "\\screen" + string(save[4]) + ".png", 1, 0, 0, 0, 0); + + ini_close(); +} \ No newline at end of file diff --git a/objects/obj_saveload/Destroy_0.gml b/objects/obj_saveload/Destroy_0.gml index b098efbc4..236c7148a 100644 --- a/objects/obj_saveload/Destroy_0.gml +++ b/objects/obj_saveload/Destroy_0.gml @@ -1,28 +1,26 @@ +scr_image("loading", -666, 0, 0, 0, 0); -scr_image("loading",-666,0,0,0,0); - -var i;i=-1; -/*repeat(201){i+=1; - if (screen_exists[save[i]]=true) and (sprite_exists(spr_screen[save[i]])){ - sprite_delete(spr_screen[save[i]]); - } -}*/ - - -if (sprite_exists(img1)){sprite_delete(img1);} -if (sprite_exists(img2)){sprite_delete(img2);} -if (sprite_exists(img3)){sprite_delete(img3);} -if (sprite_exists(img4)){sprite_delete(img4);} - - - -if (!audio_is_playing(snd_royal)) and (instance_exists(obj_controller)){ - audio_play_sound(snd_royal,0,1);audio_sound_gain(snd_royal,0,0); - - var nope;nope=0; - if (obj_controller.master_volume=0) or (obj_controller.music_volume=0) then nope=1; - if (nope!=1){audio_sound_gain(snd_royal,0.25*obj_controller.master_volume*obj_controller.music_volume,2000);} +if (sprite_exists(img1)) { + sprite_delete(img1); +} +if (sprite_exists(img2)) { + sprite_delete(img2); +} +if (sprite_exists(img3)) { + sprite_delete(img3); } +if (sprite_exists(img4)) { + sprite_delete(img4); +} + +if (!audio_is_playing(snd_royal)) and(instance_exists(obj_controller)) { + audio_play_sound(snd_royal, 0, 1); + audio_sound_gain(snd_royal, 0, 0); -/* */ -/* */ + var nope; + nope = 0; + if (obj_controller.master_volume = 0) or(obj_controller.music_volume = 0) then nope = 1; + if (nope != 1) { + audio_sound_gain(snd_royal, 0.25 * obj_controller.master_volume * obj_controller.music_volume, 2000); + } +} \ No newline at end of file diff --git a/objects/obj_saveload/Draw_0.gml b/objects/obj_saveload/Draw_0.gml index b5fabb6aa..a3431a3b8 100644 --- a/objects/obj_saveload/Draw_0.gml +++ b/objects/obj_saveload/Draw_0.gml @@ -1,309 +1,340 @@ var __b__; __b__ = action_if_variable(hide, 0, 0); -if __b__ -{ - -var xx,yy; -xx=__view_get( e__VW.XView, 0 )+0;yy=__view_get( e__VW.YView, 0 )+0; -if (instance_exists(obj_main_menu)){xx=0;yy=0;} - - - - -// if /*(menu=0) and */(save_part+load_part>0){// This is the loading bar - -/*if (save_part+load_part>0){ - draw_set_color(0); - draw_rectangle(0,0,room_width,room_height,0); - draw_sprite(spr_saveload,0,xx,yy+345); - - draw_set_color(50688);draw_rectangle(xx+74,yy+147,xx+566,yy+202,0); - draw_set_color(c_gray);draw_rectangle(min(xx+74+((bar/100)*492),xx+566),yy+147,xx+566,yy+202,0); - draw_set_color(38144);draw_rectangle(xx+74,yy+147,xx+566,yy+202,1); - - draw_set_halign(fa_center);draw_set_font(fnt_large); - if (save_part>0) then draw_text_transformed(xx+320,yy+94,"Saving",2,1.5,0); - if (load_part>0) and (global.restart=0) then draw_text_transformed(xx+320,yy+94,"Loading",2,1.5,0); - if (load_part>0) and (global.restart>0) then draw_text_transformed(xx+320,yy+94,"Restarting",2,1.5,0); - - draw_set_font(fnt_menu); - draw_text(xx+320,yy+209,string(txt)); -}*/ - - -if (save_part+load_part>0){ - draw_set_color(0); - - // - // draw_sprite(spr_load_splash,splash,xx+0,yy+0); - scr_image("loading0",splash,xx+0,yy+0,1600,900); - // - - draw_sprite(spr_loadbar_empty,0,xx+1047,yy+875); - draw_sprite(spr_loadbar,0,xx+1047,yy+875); - draw_sprite(spr_loadbar_cover,bar,xx+1047,yy+875); - - if (save_part>0) then draw_sprite(spr_load_text,1,xx+1068,yy+821); - if (load_part>0) and (global.restart=0) then draw_sprite(spr_load_text,0,xx+1068,yy+821); - if (load_part>0) and (global.restart>0) then draw_sprite(spr_load_text,2,xx+1068,yy+821); - - /*draw_rectangle(0,0,room_width,room_height,0); - draw_sprite(spr_saveload,0,xx,yy+345); - - draw_set_color(50688);draw_rectangle(xx+74,yy+147,xx+566,yy+202,0); - draw_set_color(c_gray);draw_rectangle(min(xx+74+((bar/100)*492),xx+566),yy+147,xx+566,yy+202,0); - draw_set_color(38144);draw_rectangle(xx+74,yy+147,xx+566,yy+202,1); - - draw_set_halign(fa_center);draw_set_font(fnt_large); - if (save_part>0) then draw_text_transformed(xx+320,yy+94,"Saving",2,1.5,0); - if (load_part>0) and (global.restart=0) then draw_text_transformed(xx+320,yy+94,"Loading",2,1.5,0); - if (load_part>0) and (global.restart>0) then draw_text_transformed(xx+320,yy+94,"Restarting",2,1.5,0); - - draw_set_font(fnt_menu); - draw_text(xx+320,yy+209,string(txt));*/ -} - - - - -if (menu=1) or (menu=2){// This is the other one - draw_set_color(0);draw_set_alpha(0.75); - if (room_get_name(room)!="Main_Menu") then draw_rectangle(0,0,room_width,room_height,0); - if (room_get_name(room)="Main_Menu") then draw_rectangle(0,0,room_width,707,0); - draw_set_alpha(1); - - draw_set_color(c_red); - draw_set_font(fnt_40k_14); - draw_set_halign(fa_left); - // draw_text(xx+40,yy+730,"Menu: "+string(menu)+", First Open: "+string(first_open)+", Top Save: "+string(top)); - // draw_text(xx+40,yy+730,string(debug)); - draw_set_halign(fa_center); - - draw_set_color(0); - - draw_sprite(spr_save_header,0,xx+0,yy+27); - if (menu=1) then draw_sprite(spr_save_headers,1,xx+800,yy+60); - if (menu=2) then draw_sprite(spr_save_headers,0,xx+800,yy+60); - draw_sprite(spr_save_footer,0,xx+0,yy+797); - - var o,x2,y2,s;o=top;x2=__view_get( e__VW.XView, 0 )+32;y2=__view_get( e__VW.YView, 0 )+166;s=0; - repeat(4){ - if ((save[o]>0) or ((first_open=o) and (menu=1)) or (global.load=o) or (save_number=o)) and (save_number=0){s=save[o]; - draw_set_font(fnt_40k_30b); - draw_set_halign(fa_left); - draw_set_color(0); - - draw_rectangle(x2+56,y2+5,x2+238,y2+123,0); - draw_rectangle(x2+258,y2+25,x2+1480,y2+80,0); - - /*if (file_exists("screen"+string(o)+".png")) and (instance_exists(spr_screen[o])){ - draw_sprite_stretched(spr_screen[o],0,x2+64,y2+28,166,94); - }*/ - - if (o=top) and (save[o]!=0) and (img1!=0) and (sprite_exists(img1)){draw_sprite_stretched(img1,0,x2+64,y2+28,166,94);} - if (o=top+1) and (save[o]!=0) and (img2!=0) and (sprite_exists(img2)){draw_sprite_stretched(img2,0,x2+64,y2+28,166,94);} - if (o=top+2) and (save[o]!=0) and (img3!=0) and (sprite_exists(img3)){draw_sprite_stretched(img3,0,x2+64,y2+28,166,94);} - if (o=top+3) and (save[o]!=0) and (img4!=0) and (sprite_exists(img4)){draw_sprite_stretched(img4,0,x2+64,y2+28,166,94);} - - - var high;high=0; - if (scr_hit(x2,y2,x2+1526,y2+149)=true){ - // high=1; - debug="Save:"+string(save[o])+", array position:"+string(o)+", turn:"+string(save_turn[o]); - } - draw_sprite(spr_save_data,0,x2,y2); - - draw_text_transformed(x2+23,y2+62,string_hash_to_newline(o),1.1,1.1,0); - draw_text_transformed(x2+270,y2+10,string_hash_to_newline("Chapter"),0.9,0.9,0); - draw_text_transformed(x2+774,y2+10,string_hash_to_newline("Marines"),0.9,0.9,0); - draw_text_transformed(x2+1024,y2+10,string_hash_to_newline("Turn"),0.9,0.9,0); - draw_text_transformed(x2+1274,y2+10,string_hash_to_newline("Game Time"),0.9,0.9,0); - - draw_set_color(c_gray); - if (first_open!=o){ - draw_text_transformed(x2+270,y2+48,string_hash_to_newline(string(save_chapter[save[o]])+" ("+string(save_date[save[o]])+")"),0.7,0.7,0); - draw_text_transformed(x2+774,y2+48,string_hash_to_newline(string(save_marines[save[o]])),0.7,0.7,0); - draw_text_transformed(x2+1024,y2+48,string_hash_to_newline(string(save_turn[save[o]])),0.7,0.7,0); - var ohboy,result,tsec,tmin,thour,tday; - ohboy=save_time[save[o]];result=""; - tsec=0;tmin=0;thour=0;tday=0; - if (ohboy>0){ - tday=floor(ohboy/86400);if (tday>=1) then ohboy-=(tday*86400); - thour=floor(ohboy/3600);if (thour>=1) then ohboy-=(thour*3600); - tmin=floor(ohboy/60);if (tmin>=1) then ohboy-=(tmin*60); - tsec=ohboy; - - if (tday>0) then result+=string(tday)+"d "; - if (thour=0) then result+="00:"; - if (thour>0) and (thour<10) then result+="0"+string(thour)+":"; - if (thour>=10) then result+=string(thour)+":"; - if (tmin=0) then result+="00:"; - if (tmin>0) and (tmin<10) then result+="0"+string(tmin)+":"; - if (tmin>=10) then result+=string(tmin)+":"; - if (tsec=0) then result+="00"; - if (tsec>0) and (tsec<10) then result+="0"+string(tsec); - if (tsec>=10) then result+=string(tsec); +if __b__ { + + var xx, yy; + xx = __view_get(e__VW.XView, 0) + 0; + yy = __view_get(e__VW.YView, 0) + 0; + if (instance_exists(obj_main_menu)) { + xx = 0; + yy = 0; + } + + + if (save_part + load_part > 0) { + draw_set_color(0); + + scr_image("loading0", splash, xx + 0, yy + 0, 1600, 900); + + draw_sprite(spr_loadbar_empty, 0, xx + 1047, yy + 875); + draw_sprite(spr_loadbar, 0, xx + 1047, yy + 875); + draw_sprite(spr_loadbar_cover, bar, xx + 1047, yy + 875); + + if (save_part > 0) then draw_sprite(spr_load_text, 1, xx + 1068, yy + 821); + if (load_part > 0) and(global.restart = 0) then draw_sprite(spr_load_text, 0, xx + 1068, yy + 821); + if (load_part > 0) and(global.restart > 0) then draw_sprite(spr_load_text, 2, xx + 1068, yy + 821); + } + + if (menu = 1) or(menu = 2) { // This is the other one + draw_set_color(0); + draw_set_alpha(0.75); + if (room_get_name(room) != "Main_Menu") then draw_rectangle(0, 0, room_width, room_height, 0); + if (room_get_name(room) = "Main_Menu") then draw_rectangle(0, 0, room_width, 707, 0); + draw_set_alpha(1); + + draw_set_color(c_red); + draw_set_font(fnt_40k_14); + draw_set_halign(fa_left); + draw_set_halign(fa_center); + + draw_set_color(0); + + draw_sprite(spr_save_header, 0, xx + 0, yy + 27); + if (menu = 1) then draw_sprite(spr_save_headers, 1, xx + 800, yy + 60); + if (menu = 2) then draw_sprite(spr_save_headers, 0, xx + 800, yy + 60); + draw_sprite(spr_save_footer, 0, xx + 0, yy + 797); + + var o, x2, y2, s; + o = top; + x2 = __view_get(e__VW.XView, 0) + 32; + y2 = __view_get(e__VW.YView, 0) + 166; + s = 0; + repeat(4) { + if ((save[o] > 0) or((first_open = o) and(menu = 1)) or(global.load = o) or(save_number = o)) and(save_number = 0) { + s = save[o]; + draw_set_font(fnt_40k_30b); + draw_set_halign(fa_left); + draw_set_color(0); + + draw_rectangle(x2 + 56, y2 + 5, x2 + 238, y2 + 123, 0); + draw_rectangle(x2 + 258, y2 + 25, x2 + 1480, y2 + 80, 0); + + if (o = top) and(save[o] != 0) and(img1 != 0) and(sprite_exists(img1)) { + draw_sprite_stretched(img1, 0, x2 + 64, y2 + 28, 166, 94); + } + if (o = top + 1) and(save[o] != 0) and(img2 != 0) and(sprite_exists(img2)) { + draw_sprite_stretched(img2, 0, x2 + 64, y2 + 28, 166, 94); + } + if (o = top + 2) and(save[o] != 0) and(img3 != 0) and(sprite_exists(img3)) { + draw_sprite_stretched(img3, 0, x2 + 64, y2 + 28, 166, 94); + } + if (o = top + 3) and(save[o] != 0) and(img4 != 0) and(sprite_exists(img4)) { + draw_sprite_stretched(img4, 0, x2 + 64, y2 + 28, 166, 94); + } + + + var high; + high = 0; + if (scr_hit(x2, y2, x2 + 1526, y2 + 149) = true) { + // high=1; + debug = "Save:" + string(save[o]) + ", array position:" + string(o) + ", turn:" + string(save_turn[o]); + } + draw_sprite(spr_save_data, 0, x2, y2); + + draw_text_transformed(x2 + 23, y2 + 62, string_hash_to_newline(o), 1.1, 1.1, 0); + draw_text_transformed(x2 + 270, y2 + 10, string_hash_to_newline("Chapter"), 0.9, 0.9, 0); + draw_text_transformed(x2 + 774, y2 + 10, string_hash_to_newline("Marines"), 0.9, 0.9, 0); + draw_text_transformed(x2 + 1024, y2 + 10, string_hash_to_newline("Turn"), 0.9, 0.9, 0); + draw_text_transformed(x2 + 1274, y2 + 10, string_hash_to_newline("Game Time"), 0.9, 0.9, 0); + + draw_set_color(c_gray); + if (first_open != o) { + draw_text_transformed(x2 + 270, y2 + 48, string_hash_to_newline(string(save_chapter[save[o]]) + " (" + string(save_date[save[o]]) + ")"), 0.7, 0.7, 0); + draw_text_transformed(x2 + 774, y2 + 48, string_hash_to_newline(string(save_marines[save[o]])), 0.7, 0.7, 0); + draw_text_transformed(x2 + 1024, y2 + 48, string_hash_to_newline(string(save_turn[save[o]])), 0.7, 0.7, 0); + var ohboy, result, tsec, tmin, thour, tday; + ohboy = save_time[save[o]]; + result = ""; + tsec = 0; + tmin = 0; + thour = 0; + tday = 0; + if (ohboy > 0) { + tday = floor(ohboy / 86400); + if (tday >= 1) then ohboy -= (tday * 86400); + thour = floor(ohboy / 3600); + if (thour >= 1) then ohboy -= (thour * 3600); + tmin = floor(ohboy / 60); + if (tmin >= 1) then ohboy -= (tmin * 60); + tsec = ohboy; + + if (tday > 0) then result += string(tday) + "d "; + if (thour = 0) then result += "00:"; + if (thour > 0) and(thour < 10) then result += "0" + string(thour) + ":"; + if (thour >= 10) then result += string(thour) + ":"; + if (tmin = 0) then result += "00:"; + if (tmin > 0) and(tmin < 10) then result += "0" + string(tmin) + ":"; + if (tmin >= 10) then result += string(tmin) + ":"; + if (tsec = 0) then result += "00"; + if (tsec > 0) and(tsec < 10) then result += "0" + string(tsec); + if (tsec >= 10) then result += string(tsec); + } + draw_text_transformed(x2 + 1274, y2 + 48, string_hash_to_newline(string(result)), 0.7, 0.7, 0); } - draw_text_transformed(x2+1274,y2+48,string_hash_to_newline(string(result)),0.7,0.7,0); + if (first_open = o) and(menu = 1) then draw_text_transformed(x2 + 270, y2 + 48, string_hash_to_newline("(EMPTY SAVE SLOT)"), 0.7, 0.7, 0); } - if (first_open=o) and (menu=1) then draw_text_transformed(x2+270,y2+48,string_hash_to_newline("(EMPTY SAVE SLOT)"),0.7,0.7,0); - } - - draw_set_font(fnt_40k_30b);draw_set_halign(fa_center); - - if (save[o]>0){ - // Delete Data - draw_set_alpha(1); - draw_set_color(c_gray);draw_rectangle(x2+807,y2+113,x2+951,y2+146,0); - draw_set_color(c_black);draw_rectangle(x2+807,y2+113,x2+951,y2+146,1); - draw_text_transformed(x2+879,y2+117,string_hash_to_newline("Delete Game"),0.7,0.7,0); - if (scr_hit(x2+807,y2+113,x2+951,y2+146)=true){ - draw_set_alpha(0.1);draw_set_color(c_white);draw_rectangle(x2+807,y2+113,x2+951,y2+146,0);draw_set_alpha(1); - if (mouse_left>=1) and (!instance_exists(obj_popup)) and (cooldown<=0){// Clear - var com;com=instance_create(0,0,obj_popup); - com.image="fuklaw";com.title="Delete Save Game?"; - com.text="Are you sure you wish to delete Save "+string(save[o])+"- "+string(save_chapter[save[o]])+"?"; - com.option1="Yes";com.option2="No";com.save=o; - com.woopwoopwoop=menu;com.owner=top; + + draw_set_font(fnt_40k_30b); + draw_set_halign(fa_center); + + if (save[o] > 0) { + // Delete Data + draw_set_alpha(1); + draw_set_color(c_gray); + draw_rectangle(x2 + 807, y2 + 113, x2 + 951, y2 + 146, 0); + draw_set_color(c_black); + draw_rectangle(x2 + 807, y2 + 113, x2 + 951, y2 + 146, 1); + draw_text_transformed(x2 + 879, y2 + 117, string_hash_to_newline("Delete Game"), 0.7, 0.7, 0); + if (scr_hit(x2 + 807, y2 + 113, x2 + 951, y2 + 146) = true) { + draw_set_alpha(0.1); + draw_set_color(c_white); + draw_rectangle(x2 + 807, y2 + 113, x2 + 951, y2 + 146, 0); + draw_set_alpha(1); + if (mouse_left >= 1) and(!instance_exists(obj_popup)) and(cooldown <= 0) { // Clear + var com; + com = instance_create(0, 0, obj_popup); + com.image = "fuklaw"; + com.title = "Delete Save Game?"; + com.text = "Are you sure you wish to delete Save " + string(save[o]) + "- " + string(save_chapter[save[o]]) + "?"; + com.option1 = "Yes"; + com.option2 = "No"; + com.save = o; + com.woopwoopwoop = menu; + com.owner = top; + } } } - } - - - if (menu=2) and (save[o]>0){// Restart - draw_set_alpha(1); - draw_set_color(c_gray);draw_rectangle(x2+977,y2+113,x2+1121,y2+146,0); - draw_set_color(c_black);draw_rectangle(x2+977,y2+113,x2+1121,y2+146,1); - draw_text_transformed(x2+1050,y2+117,string_hash_to_newline("Restart Game"),0.7,0.7,0); - if (scr_hit(x2+977,y2+113,x2+1121,y2+146)=true){ - draw_set_alpha(0.1);draw_set_color(c_white);draw_rectangle(x2+977,y2+113,x2+1121,y2+146,0);draw_set_alpha(1); - if (mouse_left>=1) and (!instance_exists(obj_popup)) and (cooldown<=0){ - if (file_exists("save"+string(save[o])+".ini")){// Resets the data - global.restart=1;global.load=save[o]; - menu=0;load_part=1;obj_cursor.image_alpha=0;splash=choose(0,1,2,3,4); - - if (instance_exists(obj_main_menu)){ - with(obj_main_menu){ + + + if (menu = 2) and(save[o] > 0) { // Restart + draw_set_alpha(1); + draw_set_color(c_gray); + draw_rectangle(x2 + 977, y2 + 113, x2 + 1121, y2 + 146, 0); + draw_set_color(c_black); + draw_rectangle(x2 + 977, y2 + 113, x2 + 1121, y2 + 146, 1); + draw_text_transformed(x2 + 1050, y2 + 117, string_hash_to_newline("Restart Game"), 0.7, 0.7, 0); + if (scr_hit(x2 + 977, y2 + 113, x2 + 1121, y2 + 146) = true) { + draw_set_alpha(0.1); + draw_set_color(c_white); + draw_rectangle(x2 + 977, y2 + 113, x2 + 1121, y2 + 146, 0); + draw_set_alpha(1); + if (mouse_left >= 1) and(!instance_exists(obj_popup)) and(cooldown <= 0) { + if (file_exists("save" + string(save[o]) + ".ini")) { // Resets the data + global.restart = 1; + global.load = save[o]; + menu = 0; + load_part = 1; + obj_cursor.image_alpha = 0; + splash = choose(0, 1, 2, 3, 4); + + if (instance_exists(obj_main_menu)) { + with(obj_main_menu) { + part_particles_clear(p_system); + instance_destroy(); + } + } + + with(obj_controller) { + instance_destroy(); + } + with(obj_creation) { + instance_destroy(); + } + with(obj_ini) { + instance_destroy(); + } + with(obj_star) { + instance_destroy(); + } + with(obj_all_fleet) { + instance_destroy(); + } + with(obj_popup) { + instance_destroy(); + } + audio_stop_all(); + + room_goto(Game); + } + } + } + + draw_set_alpha(1); + draw_set_color(c_gray); + draw_rectangle(x2 + 1317, y2 + 113, x2 + 1461, y2 + 146, 0); + draw_set_color(c_black); + draw_rectangle(x2 + 1317, y2 + 113, x2 + 1461, y2 + 146, 1); + draw_text_transformed(x2 + 1385, y2 + 117, string_hash_to_newline("Load Game"), 0.7, 0.7, 0); + if (scr_hit(x2 + 1317, y2 + 113, x2 + 1461, y2 + 146) = true) { + draw_set_alpha(0.1); + draw_set_color(c_white); + draw_rectangle(x2 + 1317, y2 + 113, x2 + 1461, y2 + 146, 0); + draw_set_alpha(1); + + if (mouse_left >= 1) and(!instance_exists(obj_popup)) and(cooldown <= 0) { // Load + global.load = save[o]; + menu = 0; + load_part = 1; + obj_cursor.image_alpha = 0; + splash = choose(0, 1, 2, 3, 4); + + // show_message("loading 'save"+string(save[o])+".ini'"); + + if (instance_exists(obj_main_menu)) { + with(obj_main_menu) { part_particles_clear(p_system); instance_destroy(); } } - - with(obj_controller){instance_destroy();} - with(obj_creation){instance_destroy();} - with(obj_ini){instance_destroy();} - with(obj_star){instance_destroy();} - with(obj_all_fleet){instance_destroy();} - with(obj_popup){instance_destroy();} + + with(obj_controller) { + instance_destroy(); + } + with(obj_creation) { + instance_destroy(); + } + with(obj_ini) { + instance_destroy(); + } + with(obj_star) { + instance_destroy(); + } + with(obj_all_fleet) { + instance_destroy(); + } + with(obj_popup) { + instance_destroy(); + } audio_stop_all(); - + room_goto(Game); } } } - - draw_set_alpha(1); - draw_set_color(c_gray);draw_rectangle(x2+1317,y2+113,x2+1461,y2+146,0); - draw_set_color(c_black);draw_rectangle(x2+1317,y2+113,x2+1461,y2+146,1); - draw_text_transformed(x2+1385,y2+117,string_hash_to_newline("Load Game"),0.7,0.7,0); - if (scr_hit(x2+1317,y2+113,x2+1461,y2+146)=true){ - draw_set_alpha(0.1);draw_set_color(c_white);draw_rectangle(x2+1317,y2+113,x2+1461,y2+146,0);draw_set_alpha(1); - - if (mouse_left>=1) and (!instance_exists(obj_popup)) and (cooldown<=0){// Load - global.load=save[o];menu=0;load_part=1;obj_cursor.image_alpha=0;splash=choose(0,1,2,3,4); - - // show_message("loading 'save"+string(save[o])+".ini'"); - - if (instance_exists(obj_main_menu)){ - with(obj_main_menu){ - part_particles_clear(p_system); - instance_destroy(); + + if (menu = 1) and((save[o] > 0) or(first_open = o)) { // Save + draw_set_alpha(1); + draw_set_color(c_gray); + draw_rectangle(x2 + 1317, y2 + 113, x2 + 1461, y2 + 146, 0); + draw_set_color(c_black); + draw_rectangle(x2 + 1317, y2 + 113, x2 + 1461, y2 + 146, 1); + draw_text_transformed(x2 + 1386, y2 + 117, string_hash_to_newline("Save Game"), 0.7, 0.7, 0); + if (scr_hit(x2 + 1317, y2 + 113, x2 + 1461, y2 + 146) = true) { + draw_set_alpha(0.1); + draw_set_color(c_white); + draw_rectangle(x2 + 1317, y2 + 113, x2 + 1461, y2 + 146, 0); + draw_set_alpha(1); + if (mouse_left >= 1) and(cooldown <= 0) { + var onceh; + onceh = 0; + if (instance_exists(obj_main_menu)) { + with(obj_main_menu) { + part_particles_clear(p_system); + } + } + + // If open slot then set the save.ini to the maximum + if (!file_exists("save" + string(save[o]) + ".ini")) or(save[o] = 0) and(onceh = 0) { + save_part = 1; + menu = 0; + save_number = max_ini; + obj_cursor.image_alpha = 0; + splash = choose(0, 1, 2, 3, 4); + with(obj_new_button) { + instance_destroy(); + } + with(obj_ingame_menu) { + instance_destroy(); + } + // Other here + alarm[0] = 1; + onceh = 1; + } + // If file exists then overright + if (file_exists("save" + string(save[o]) + ".ini")) { + file_delete("save" + string(save[o]) + ".ini"); + if (file_exists("screen" + string(save[o]) + ".png")) then file_delete("screen" + string(save[o]) + ".png"); + save_part = 1; + menu = 0; + save_number = o; + obj_cursor.image_alpha = 0; + splash = choose(0, 1, 2, 3, 4); + with(obj_new_button) { + instance_destroy(); + } + with(obj_ingame_menu) { + instance_destroy(); + } + // Other here + alarm[0] = 1; + onceh = 1; } } - - with(obj_controller){instance_destroy();} - with(obj_creation){instance_destroy();} - with(obj_ini){instance_destroy();} - with(obj_star){instance_destroy();} - with(obj_all_fleet){instance_destroy();} - with(obj_popup){instance_destroy();} - audio_stop_all(); - - room_goto(Game); } } + + o += 1; + y2 += 158; } - - if (menu=1) and ((save[o]>0) or (first_open=o)){// Save - draw_set_alpha(1); - draw_set_color(c_gray);draw_rectangle(x2+1317,y2+113,x2+1461,y2+146,0); - draw_set_color(c_black);draw_rectangle(x2+1317,y2+113,x2+1461,y2+146,1); - draw_text_transformed(x2+1386,y2+117,string_hash_to_newline("Save Game"),0.7,0.7,0); - if (scr_hit(x2+1317,y2+113,x2+1461,y2+146)=true){ - draw_set_alpha(0.1);draw_set_color(c_white);draw_rectangle(x2+1317,y2+113,x2+1461,y2+146,0);draw_set_alpha(1); - if (mouse_left>=1) and (cooldown<=0){var onceh;onceh=0; - if (instance_exists(obj_main_menu)){with(obj_main_menu){part_particles_clear(p_system);}} - - // If open slot then set the save.ini to the maximum - if (!file_exists("save"+string(save[o])+".ini")) or (save[o]=0) and (onceh=0){ - save_part=1;menu=0;save_number=max_ini;obj_cursor.image_alpha=0;splash=choose(0,1,2,3,4); - with(obj_new_button){instance_destroy();} - with(obj_ingame_menu){instance_destroy();} - // Other here - alarm[0]=1;onceh=1; - } - // If file exists then overright - if (file_exists("save"+string(save[o])+".ini")){file_delete("save"+string(save[o])+".ini"); - if (file_exists("screen"+string(save[o])+".png")) then file_delete("screen"+string(save[o])+".png"); - save_part=1;menu=0;save_number=o;obj_cursor.image_alpha=0;splash=choose(0,1,2,3,4); - with(obj_new_button){instance_destroy();} - with(obj_ingame_menu){instance_destroy();} - // Other here - alarm[0]=1;onceh=1; - } - } + + if (instance_exists(obj_main_menu_buttons)) { + if (obj_main_menu_buttons.fade > 0) { + draw_set_color(0); + draw_set_alpha(obj_main_menu_buttons.fade / 40); + draw_rectangle(0, 0, room_width, room_height, 0); } + draw_set_alpha(1); } - - o+=1;y2+=158; - } - - // 32,166 - - -if (instance_exists(obj_main_menu_buttons)){ - if (obj_main_menu_buttons.fade>0){ - draw_set_color(0); - draw_set_alpha(obj_main_menu_buttons.fade/40); - draw_rectangle(0,0,room_width,room_height,0); } - draw_set_alpha(1); -} - -} - - - - - -/*draw_set_color(c_red);draw_set_font(fnt_menu); -draw_set_alpha(1);draw_text(xx+30,yy+30,"First Open: "+string(first_open)); -draw_set_alpha(1);draw_text(xx+30,yy+50,"save1: "+string(save[1])); -draw_set_alpha(1);draw_text(xx+30,yy+70,"save2: "+string(save[2])); -draw_set_alpha(1);draw_text(xx+30,yy+90,"save3: "+string(save[3])); -draw_set_alpha(1);draw_text(xx+30,yy+110,"save4: "+string(save[4])); -draw_set_alpha(1);draw_text(xx+30,yy+130,"save5: "+string(save[5])); -draw_set_alpha(1);draw_text(xx+30,yy+150,"save6: "+string(save[6])); -draw_set_alpha(1);draw_text(xx+30,yy+170,"save7: "+string(save[7])); -draw_set_alpha(1);draw_text(xx+30,yy+190,"save8: "+string(save[8])); -draw_set_alpha(1);draw_text(xx+30,yy+210,"save9: "+string(save[9])); -draw_set_alpha(1);draw_text(xx+30,yy+230,"save10: "+string(save[10])); -draw_set_alpha(1);draw_text(xx+30,yy+250,"save11: "+string(save[11])); -draw_set_alpha(1);draw_text(xx+30,yy+270,"save12: "+string(save[12]));*/ - - - -/* */ -} -/* */ +} \ No newline at end of file diff --git a/objects/obj_saveload/KeyPress_1.gml b/objects/obj_saveload/KeyPress_1.gml index 0b0ebff51..18b9b741d 100644 --- a/objects/obj_saveload/KeyPress_1.gml +++ b/objects/obj_saveload/KeyPress_1.gml @@ -1,4 +1 @@ - -reset=0; - - +reset = 0; \ No newline at end of file diff --git a/objects/obj_saveload/Mouse_60.gml b/objects/obj_saveload/Mouse_60.gml index 387b29675..210737c38 100644 --- a/objects/obj_saveload/Mouse_60.gml +++ b/objects/obj_saveload/Mouse_60.gml @@ -1,15 +1,18 @@ +if (slow < 0) then slow = 0; +slow += 1; -if (slow<0) then slow=0; -slow+=1; - -if (slow>=3){ - if (top>1){top-=1; - if (sprite_exists(img4)){sprite_delete(img4);} - img4=img3;img3=img2;img2=img1; - if (file_exists(working_directory + "\\screen"+string(save[top])+".png")) then img1=sprite_add(working_directory + "\\screen"+string(save[top])+".png",1,0,0,0,0); - if (!sprite_exists(img3)) and (file_exists(working_directory + "\\screen"+string(save[top+2])+".png")) then img3=sprite_add(working_directory + "\\screen"+string(save[top+3])+".png",1,0,0,0,0); - if (!sprite_exists(img2)) and (file_exists(working_directory + "\\screen"+string(save[top+1])+".png")) then img2=sprite_add(working_directory + "\\screen"+string(save[top+2])+".png",1,0,0,0,0); - if (!sprite_exists(img1)) and (file_exists(working_directory + "\\screen"+string(save[top])+".png")) then img1=sprite_add(working_directory + "\\screen"+string(save[top])+".png",1,0,0,0,0); +if (slow >= 3) { + if (top > 1) { + top -= 1; + if (sprite_exists(img4)) { + sprite_delete(img4); + } + img4 = img3; + img3 = img2; + img2 = img1; + if (file_exists(working_directory + "\\screen" + string(save[top]) + ".png")) then img1 = sprite_add(working_directory + "\\screen" + string(save[top]) + ".png", 1, 0, 0, 0, 0); + if (!sprite_exists(img3)) and(file_exists(working_directory + "\\screen" + string(save[top + 2]) + ".png")) then img3 = sprite_add(working_directory + "\\screen" + string(save[top + 3]) + ".png", 1, 0, 0, 0, 0); + if (!sprite_exists(img2)) and(file_exists(working_directory + "\\screen" + string(save[top + 1]) + ".png")) then img2 = sprite_add(working_directory + "\\screen" + string(save[top + 2]) + ".png", 1, 0, 0, 0, 0); + if (!sprite_exists(img1)) and(file_exists(working_directory + "\\screen" + string(save[top]) + ".png")) then img1 = sprite_add(working_directory + "\\screen" + string(save[top]) + ".png", 1, 0, 0, 0, 0); } -} - +} \ No newline at end of file diff --git a/objects/obj_saveload/Mouse_61.gml b/objects/obj_saveload/Mouse_61.gml index d9f929549..4b0f010a3 100644 --- a/objects/obj_saveload/Mouse_61.gml +++ b/objects/obj_saveload/Mouse_61.gml @@ -1,34 +1,21 @@ +if (slow > 0) then slow = 0; +slow -= 1; -if (slow>0) then slow=0; -slow-=1; +if (slow <= -3) { + if (top + 3 <= saves) { + top += 1; -if (slow<=-3){ - if (top+3<=saves){top+=1; - - img1=img2;img2=img3;img3=img4; - - if (sprite_exists(img4)){sprite_delete(img4);} - - if (file_exists(working_directory + "\\screen"+string(save[top+3])+".png")) then img4=sprite_add(working_directory + "\\screen"+string(save[top+3])+".png",1,0,0,0,0); - if (!sprite_exists(img3)) and (file_exists(working_directory + "\\screen"+string(save[top+2])+".png")) then img3=sprite_add(working_directory + "\\screen"+string(save[top+2])+".png",1,0,0,0,0); - if (!sprite_exists(img2)) and (file_exists(working_directory + "\\screen"+string(save[top+1])+".png")) then img2=sprite_add(working_directory + "\\screen"+string(save[top+1])+".png",1,0,0,0,0); - if (!sprite_exists(img1)) and (file_exists(working_directory + "\\screen"+string(save[top])+".png")) then img1=sprite_add(working_directory + "\\screen"+string(save[top])+".png",1,0,0,0,0); - - - - /* - if (sprite_exists(img1)){sprite_delete(img1);} - if (sprite_exists(img2)){sprite_delete(img2);} - if (sprite_exists(img3)){sprite_delete(img3);} - if (sprite_exists(img4)){sprite_delete(img4);} - if (file_exists(working_directory + "\screen"+string(save[top])+".png")) then img1=sprite_add(working_directory + "\screen"+string(save[top])+".png",1,0,0,0,0); - if (file_exists(working_directory + "\screen"+string(save[top+1])+".png")) then img2=sprite_add(working_directory + "\screen"+string(save[top+1])+".png",1,0,0,0,0); - if (file_exists(working_directory + "\screen"+string(save[top+2])+".png")) then img3=sprite_add(working_directory + "\screen"+string(save[top+2])+".png",1,0,0,0,0); - if (file_exists(working_directory + "\screen"+string(save[top+3])+".png")) then img4=sprite_add(working_directory + "\screen"+string(save[top+3])+".png",1,0,0,0,0); - */ - } -} + img1 = img2; + img2 = img3; + img3 = img4; + if (sprite_exists(img4)) { + sprite_delete(img4); + } -/* */ -/* */ + if (file_exists(working_directory + "\\screen" + string(save[top + 3]) + ".png")) then img4 = sprite_add(working_directory + "\\screen" + string(save[top + 3]) + ".png", 1, 0, 0, 0, 0); + if (!sprite_exists(img3)) and(file_exists(working_directory + "\\screen" + string(save[top + 2]) + ".png")) then img3 = sprite_add(working_directory + "\\screen" + string(save[top + 2]) + ".png", 1, 0, 0, 0, 0); + if (!sprite_exists(img2)) and(file_exists(working_directory + "\\screen" + string(save[top + 1]) + ".png")) then img2 = sprite_add(working_directory + "\\screen" + string(save[top + 1]) + ".png", 1, 0, 0, 0, 0); + if (!sprite_exists(img1)) and(file_exists(working_directory + "\\screen" + string(save[top]) + ".png")) then img1 = sprite_add(working_directory + "\\screen" + string(save[top]) + ".png", 1, 0, 0, 0, 0); + } +} \ No newline at end of file diff --git a/objects/obj_saveload/Step_0.gml b/objects/obj_saveload/Step_0.gml index cb0b22e0a..6d5ab1722 100644 --- a/objects/obj_saveload/Step_0.gml +++ b/objects/obj_saveload/Step_0.gml @@ -1,16 +1,20 @@ - -if (cooldown>=0) then cooldown-=1; -reset+=1; -if (reset>=50){ - slow=0;reset=0; +if (cooldown >= 0) then cooldown -= 1; +reset += 1; +if (reset >= 50) { + slow = 0; + reset = 0; } -if (trickle>-1){ - - trickle-=1; - if (trickle>0) then bar+=1; - if (trickle=0) then alarm[0]=1; - - if (bar+1>=100) and (bar!=100){trickle=-1;bar=100;alarm[0]=-1;alarm[1]=20;} -} +if (trickle > -1) { + + trickle -= 1; + if (trickle > 0) then bar += 1; + if (trickle = 0) then alarm[0] = 1; + if (bar + 1 >= 100) and(bar != 100) { + trickle = -1; + bar = 100; + alarm[0] = -1; + alarm[1] = 20; + } +} \ No newline at end of file diff --git a/scripts/scr_load/scr_load.gml b/scripts/scr_load/scr_load.gml index 2ec509501..5bd9587c6 100644 --- a/scripts/scr_load/scr_load.gml +++ b/scripts/scr_load/scr_load.gml @@ -1,1129 +1,1365 @@ function scr_load(argument0, argument1) { - - function load_marine_struct(company, marine){ - var marStruct = ini_read_string("Mar","Struct"+string(company)+"."+string(marine),""); - if (marStruct != ""){ - marStruct = json_parse(base64_decode(marStruct)); - obj_ini.TTRPG[company, marine] = new TTRPG_stats("chapter", company, marine, "blank"); - obj_ini.TTRPG[company, marine].load_json_data(marStruct); - } else {obj_ini.TTRPG[company, marine] = new TTRPG_stats("chapter", company, marine,"blank");} - }; - var rang,i,g,stars,pfleets,efleets; - rang=0;i=0;g=0;stars=0;pfleets=0;efleets=0; - - - - if (argument0=1) or (argument0=0){ - - debugl("Loading slot "+string(argument1)); - var save_file_name = "save"+string(argument1)+".ini"; - - if(file_exists("tsave.ini")) - { - // file_copy() will fail if destination file already exists - file_delete("tsave.ini"); - } - - if(file_exists(save_file_name)) - { - file_copy(save_file_name,"tsave.ini"); - } - else - { - debugl("Could not load save game " + save_file_name + ", file does not exist."); - game_restart(); - } - - // TODO temporary disabled. Will be reenabled during ironman/autosave feature task - //file_decrypt("tsave.ini","p"); - ini_open("tsave.ini"); - - // Global variables - global.chapter_name=ini_read_string("Save","chapter_name","Error"); // - obj_ini.sector_name=ini_read_string("Save","sector_name","Error"); // - - // TODO make it either throw error (if version is wrong) or try to upgrade the saved game data and version - global.version=ini_read_string("Save","version",0); - global.game_seed=ini_read_real("Save","game_seed",0); - obj_ini.use_custom_icon=ini_read_real("Save","use_custom_icon",0); - - obj_controller.play_time=ini_read_real("Save","play_time",0); - - obj_ini.progenitor=ini_read_real("Save","founding",0); - // global.founding_secret=ini_read_string("Save","founding_secret","Error"); - global.custom=ini_read_real("Save","custom",1); - stars=ini_read_real("Save","stars",0); - // pfleets=ini_read_real("Save","p_fleets",0); - // efleets=ini_read_real("Save","en_fleets",0); - g=ini_read_real("Save","sod",0); - random_set_seed(g);g=0; - var corrupt;corrupt=1; - corrupt=ini_read_real("Save","corrupt",1); - - if (corrupt=1){ - game_restart(); - } - - // obj_controller variables here - obj_controller.load_game=argument1; - global.cheat_req = ini_read_real("boolean", "cheat_req", 0); - global.cheat_gene = ini_read_real("boolean", "cheat_gene", 0); - global.cheat_debug = ini_read_real("boolean", "cheat_debug", 0); - global.cheat_disp = ini_read_real("boolean", "cheat_disp", 0); - obj_controller.cheatyface=ini_read_real("Controller","cheatyface",0); - obj_controller.x=ini_read_real("Controller","x",obj_controller.x); - obj_controller.y=ini_read_real("Controller","y",obj_controller.y); - obj_controller.was_zoomed=ini_read_real("Controller","was_zoomed",0); - obj_controller.zoomed=ini_read_real("Controller","zoomed",0); - obj_controller.chaos_rating=ini_read_real("Controller","chaos_rating",0); - obj_controller.fleet_type=ini_read_string("Controller","fleet_type",""); // - obj_ini.fleet_type=round(ini_read_real("Controller","ifleet_type",0)); - obj_controller.homeworld_rule=ini_read_real("Controller","home_rule",1); - - obj_controller.star_names=ini_read_string("Controller","star_names","Error"); // - obj_controller.craftworld=ini_read_real("Controller","craftworld",0); - - obj_controller.turn=ini_read_real("Controller","turn",0); - obj_controller.last_event=ini_read_real("Controller","last_event",0); - obj_controller.last_mission=ini_read_real("Controller","last_mission",0); - obj_controller.last_world_inspection=ini_read_real("Controller","last_world_inspection",0); - obj_controller.last_fleet_inspection=ini_read_real("Controller","last_fleet_inspection",0); - obj_controller.chaos_turn=ini_read_real("Controller","chaos_turn",0); - obj_controller.chaos_fleets=ini_read_real("Controller","chaos_fleets",0); - obj_controller.tau_fleets=ini_read_real("Controller","tau_fleets",0); - obj_controller.tau_stars=ini_read_real("Controller","tau_stars",0); - obj_controller.tau_messenger=ini_read_real("Controller","tau_messenger",0); - obj_controller.fleet_all=ini_read_real("Controller","fleet_all",0); - obj_ini.tolerant=ini_read_real("Controller","tolerant",0); - obj_ini.stability=ini_read_real("Controller","stability",5); - obj_ini.purity=ini_read_real("Controller","purity",5); - obj_controller.tolerant=ini_read_real("Controller","tolerant",0); - obj_controller.unload=ini_read_real("Controller","unload",0); - obj_controller.diplomacy=0; - obj_controller.trading=0; - obj_controller.audience=0; - obj_controller.force_goodbye=0; - obj_controller.combat=0; - obj_controller.new_vehicles=ini_read_real("Controller","new_vehicles",0); - obj_controller.hurssy=ini_read_real("Controller","hurssy",0); - obj_controller.hurssy_time=ini_read_real("Controller","hurssy_time",0); - obj_controller.artifacts=ini_read_real("Controller","artifacts",0); - obj_controller.popup_master_crafted=ini_read_real("Controller","pmc",0); - obj_controller.select_wounded=ini_read_real("Controller","wndsel",1); - obj_ini.imperium_disposition=ini_read_real("Controller","imdis",40); - obj_controller.terra_direction=ini_read_real("Controller","terra_dir",floor(random(360))+1); - - obj_controller.stc_wargear=ini_read_real("Controller","stc_wargear",0); - obj_controller.stc_vehicles=ini_read_real("Controller","stc_vehicles",0); - obj_controller.stc_ships=ini_read_real("Controller","stc_ships",0); - obj_controller.stc_un_total=ini_read_real("Controller","stc_un_total",0); - obj_controller.stc_wargear_un=ini_read_real("Controller","stc_wargear_un",0); - obj_controller.stc_vehicles_un=ini_read_real("Controller","stc_vehicles_un",0); - obj_controller.stc_ships_un=ini_read_real("Controller","stc_ships_un",0); - var j;j=0;repeat(6){j+=1;obj_controller.stc_bonus[j]=ini_read_real("Controller","stc_bonus_"+string(j),0);} - j=-1;repeat(5){j+=1;obj_ini.adv[j]=ini_read_string("Controller","adv"+string(j),"");obj_ini.dis[j]=ini_read_string("Controller","dis"+string(j),"");} // - - - - // Player scheduled event - obj_controller.fest_type=ini_read_string("Controller","f_t",""); // - - if (obj_controller.fest_type!=""){ - obj_controller.fest_sid=ini_read_real("Controller","f_si",0); - obj_controller.fest_wid=ini_read_real("Controller","f_wi",0); - obj_controller.fest_planet=ini_read_real("Controller","f_pl",0); - obj_controller.fest_star=ini_read_string("Controller","f_st",""); // - obj_controller.fest_cost=ini_read_real("Controller","f_co",0); - obj_controller.fest_warp=ini_read_real("Controller","f_wa",0); - obj_controller.fest_scheduled=ini_read_real("Controller","f_sch",0); - obj_controller.fest_lav=ini_read_real("Controller","f_la",0); - obj_controller.fest_locals=ini_read_real("Controller","f_lo",0); - obj_controller.fest_feature1=ini_read_real("Controller","f_f1",0); - obj_controller.fest_feature2=ini_read_real("Controller","f_f2",0); - obj_controller.fest_feature3=ini_read_real("Controller","f_f3",0); - obj_controller.fest_display=ini_read_real("Controller","f_di",0); - obj_controller.fest_display_tags=ini_read_string("Controller","f_dit",""); // - obj_controller.fest_repeats=ini_read_real("Controller","f_re",0); - obj_controller.fest_honor_co=ini_read_real("Controller","f_hc",0); - obj_controller.fest_honor_id=ini_read_real("Controller","f_hi",0); - obj_controller.fest_honoring=ini_read_real("Controller","f_hon",0); - } - obj_controller.fest_feasts=ini_read_real("Controller","f_fee",0); - obj_controller.fest_boozes=ini_read_real("Controller","f_boo",0); - obj_controller.fest_drugses=ini_read_real("Controller","f_dru",0); - obj_controller.recent_happenings=ini_read_real("Controller","rech",0); - var i;i=-1; - repeat(obj_controller.recent_happenings+1){i+=1; - if (recent_type[i]!=""){ - obj_controller.recent_type[i]=ini_write_string("Controller","rect"+string(i),""); - obj_controller.recent_keyword[i]=ini_write_string("Controller","reck"+string(i),""); - // obj_controller.recent_turn[i]=ini_write_real("Controller","recu"+string(i),0); - // obj_controller.recent_number[i]=ini_write_real("Controller","recn"+string(i),0); - } - } - - - - obj_controller.last_attack_form=ini_read_real("Formation","last_attack",1);if (obj_controller.last_attack_form=0) then obj_controller.last_attack_form=1; - obj_controller.last_raid_form=ini_read_real("Formation","last_raid",3);if (obj_controller.last_raid_form=0) then obj_controller.last_raid_form=3; - j=0;repeat(16){j+=1; - obj_controller.bat_formation[j]=ini_read_string("Formation","form"+string(j),""); // - if (obj_controller.bat_formation[j]!="") or (j<=3){ - obj_controller.bat_formation_type[j]=ini_read_real("Formation","form_type"+string(j),0); - if (bat_formation[j]="")and (obj_controller.bat_formation_type[j]=0){ - if (j=1){obj_controller.bat_formation[j]="Attack";obj_controller.bat_formation_type[j]=1;} - if (j=2){obj_controller.bat_formation[j]="Defend";obj_controller.bat_formation_type[j]=1;} - if (j=3){obj_controller.bat_formation[j]="Raid";obj_controller.bat_formation_type[j]=2;} - } - obj_controller.bat_deva_for[j]=ini_read_real("Formation","deva"+string(j),1); - obj_controller.bat_assa_for[j]=ini_read_real("Formation","assa"+string(j),4); - obj_controller.bat_tact_for[j]=ini_read_real("Formation","tact"+string(j),2); - obj_controller.bat_vete_for[j]=ini_read_real("Formation","vete"+string(j),2); - obj_controller.bat_hire_for[j]=ini_read_real("Formation","hire"+string(j),3); - obj_controller.bat_libr_for[j]=ini_read_real("Formation","libr"+string(j),3); - obj_controller.bat_comm_for[j]=ini_read_real("Formation","comm"+string(j),3); - obj_controller.bat_tech_for[j]=ini_read_real("Formation","tech"+string(j),3); - obj_controller.bat_term_for[j]=ini_read_real("Formation","term"+string(j),3); - obj_controller.bat_hono_for[j]=ini_read_real("Formation","hono"+string(j),3); - obj_controller.bat_drea_for[j]=ini_read_real("Formation","drea"+string(j),5); - obj_controller.bat_rhin_for[j]=ini_read_real("Formation","rhin"+string(j),6); - obj_controller.bat_pred_for[j]=ini_read_real("Formation","pred"+string(j),7); - obj_controller.bat_land_for[j]=ini_read_real("Formation","land"+string(j),7); - obj_controller.bat_scou_for[j]=ini_read_real("Formation","scou"+string(j),1); - } - } - - obj_controller.useful_info=ini_read_string("Controller","useful_info",""); - obj_controller.random_event_next=ini_read_real("Controller","random_event_next","0"); - obj_controller.gene_sold=ini_read_real("Controller","gene_sold",0); - obj_controller.gene_xeno=ini_read_real("Controller","gene_xeno",0); - obj_controller.gene_tithe=ini_read_real("Controller","gene_tithe",24); - obj_controller.gene_iou=ini_read_real("Controller","gene_iou",0); - - obj_controller.und_armouries=ini_read_real("Controller","und_armouries",0); - obj_controller.und_gene_vaults=ini_read_real("Controller","und_gene_vaults",0); - obj_controller.und_lairs=ini_read_real("Controller","und_lairs",0); - - obj_controller.penitent=ini_read_real("Controller","penitent",0); - obj_controller.penitent_current=ini_read_real("Controller","penitent_current",0); - obj_controller.penitent_max=ini_read_real("Controller","penitent_max",0); - obj_controller.penitent_turnly=ini_read_real("Controller","penitent_turnly",0); - obj_controller.penitent_turn=ini_read_real("Controller","penitent_turn",0); - obj_controller.penitent_end=ini_read_real("Controller","penitent_end",0); - obj_controller.blood_debt=ini_read_real("Controller","penitent_blood",0); - - obj_controller.training_apothecary=ini_read_real("Controller","training_apothecary",0); - obj_controller.apothecary_points=ini_read_real("Controller","apothecary_points",0); - obj_controller.apothecary_aspirant=ini_read_real("Controller","apothecary_aspirant",0); - obj_controller.training_chaplain=ini_read_real("Controller","training_chaplain",0); - obj_controller.chaplain_points=ini_read_real("Controller","chaplain_points",0); - obj_controller.chaplain_aspirant=ini_read_real("Controller","chaplain_aspirant",0); - obj_controller.training_psyker=ini_read_real("Controller","training_psyker",0); - obj_controller.psyker_points=ini_read_real("Controller","psyker_points",0); - obj_controller.psyker_aspirant=ini_read_real("Controller","psyker_aspirant",0); - obj_controller.training_techmarine=ini_read_real("Controller","training_techmarine",0); - obj_controller.tech_points=ini_read_real("Controller","tech_points",0); - obj_controller.tech_aspirant=ini_read_real("Controller","tech_aspirant",0); - - obj_controller.penitorium=ini_read_real("Controller","penitorium",0); - - obj_controller.recruiting_worlds=ini_read_string("Controller","recruiting_worlds",""); - obj_controller.recruiting=ini_read_real("Controller","recruiting",0); - obj_controller.recruit_trial=ini_read_string("Controller","trial","Blood Duel"); - obj_controller.recruits=ini_read_real("Controller","recruits",0); - obj_controller.recruit_last=ini_read_real("Controller","recruit_last",0); - - var g;g=-1;repeat(30){g+=1; - obj_controller.command_set[g]=ini_read_real("Controller","command"+string(g),0); - } - if (obj_controller.command_set[20]=0) and (obj_controller.command_set[21]=0) and (obj_controller.command_set[22]=0) then obj_controller.command_set[20]=1; - if (obj_controller.command_set[23]=0) and (obj_controller.command_set[24]=0) then obj_controller.command_set[24]=1; - - - ini_read_real("Controller","blandify",0); - var g;g=-1;repeat(obj_controller.recruits){g+=1; - obj_controller.recruit_name[g]=ini_read_string("Recruit","rcr"+string(g),"Error"); - // ini_write_string("Recruit","rcr"+string(g),obj_controller.recruit_name[g]); - obj_controller.recruit_corruption[g]=ini_read_real("Recruit","rcr_cr"+string(g),0); - obj_controller.recruit_distance[g]=ini_read_real("Recruit","rcr_ds"+string(g),0); - obj_controller.recruit_training[g]=ini_read_real("Recruit","rcr_tr"+string(g),0); - obj_controller.recruit_exp[g]=ini_read_real("Recruit","rcr_ex"+string(g),0); - } - var g;g=-1;repeat(30){g+=1; - obj_controller.loyal[g]=ini_read_string("Controller","lyl"+string(g),"Error"); - obj_controller.loyal_num[g]=ini_read_real("Controller","lyl_nm"+string(g),0); - obj_controller.loyal_tm[g]=ini_read_real("Controller","lyl_tm"+string(g),0); - } - var g;g=-1;repeat(30){g+=1; - obj_controller.inquisitor[g]=ini_read_string("Controller","inq"+string(g),"Error"); - obj_controller.inquisitor_gender[g]=ini_read_real("Controller","inq_ge"+string(g),1); - obj_controller.inquisitor_type[g]=ini_read_string("Controller","inq_ty"+string(g),"Error"); - } - - var g;g=-1;repeat(14){g+=1; - obj_controller.faction[g]=ini_read_string("Factions","fac"+string(g),"Error"); - obj_controller.disposition[g]=ini_read_real("Factions","dis"+string(g),0); - obj_controller.disposition_max[g]=ini_read_real("Factions","dis_max"+string(g),0); - - obj_controller.faction_leader[g]=ini_read_string("Factions","lead"+string(g),"Error"); - obj_controller.faction_gender[g]=ini_read_real("Factions","gen"+string(g),1); - obj_controller.faction_title[g]=ini_read_string("Factions","title"+string(g),"Error"); - obj_controller.faction_status[g]=ini_read_string("Factions","status"+string(g),"Error"); - obj_controller.faction_defeated[g]=ini_read_real("Factions","defeated"+string(g),0); - obj_controller.known[g]=ini_read_real("Factions","known"+string(g),0); - - obj_controller.annoyed[g]=ini_read_real("Factions","annoyed"+string(g),0); - obj_controller.ignore[g]=ini_read_real("Factions","ignore"+string(g),0); - obj_controller.turns_ignored[g]=ini_read_real("Factions","turns_ignored"+string(g),0); - obj_controller.audien[g]=ini_read_real("Factions","audience"+string(g),0); - obj_controller.audien_topic[g]=ini_read_string("Factions","audience_topic"+string(g),""); - } - // - var g;g=0; - repeat(50){g+=1; - obj_controller.quest[g]=ini_read_string("Ongoing","quest"+string(g),""); - obj_controller.quest_faction[g]=ini_read_real("Ongoing","quest_faction"+string(g),0); - obj_controller.quest_end[g]=ini_read_real("Ongoing","quest_end"+string(g),0); - } - var g;g=0; - repeat(99){g+=1; - obj_controller.event[g]=ini_read_string("Ongoing","event"+string(g),""); - obj_controller.event_duration[g]=ini_read_real("Ongoing","event_duration"+string(g),0); - } - // - obj_controller.justmet=0; - obj_controller.check_number=ini_read_real("Controller","check_number",0); - obj_controller.year_fraction=ini_read_real("Controller","year_fraction",0); - obj_controller.year=ini_read_real("Controller","year",0); - obj_controller.millenium=ini_read_real("Controller","millenium",0); - // - obj_controller.requisition=ini_read_real("Controller","req",0); - // - obj_controller.income=ini_read_real("Controller","income",0); - obj_controller.income_last=ini_read_real("Controller","income_last",0); - obj_controller.income_base=ini_read_real("Controller","income_base",0); - obj_controller.income_home=ini_read_real("Controller","income_home",0); - obj_controller.income_forge=ini_read_real("Controller","income_forge",0); - obj_controller.income_agri=ini_read_real("Controller","income_agri",0); - obj_controller.income_recruiting=ini_read_real("Controller","income_recruiting",0); - obj_controller.income_training=ini_read_real("Controller","income_training",0); - obj_controller.income_fleet=ini_read_real("Controller","income_fleet",0); - obj_controller.income_trade=ini_read_real("Controller","income_trade",0); - obj_controller.loyalty=ini_read_real("Controller","loyalty",0); - obj_controller.loyalty_hidden=ini_read_real("Controller","loyalty_hidden",0); - obj_controller.inqis_flag_lair=ini_read_real("Controller","flag_lair",0); - obj_controller.inqis_flag_gene=ini_read_real("Controller","flag_gene",0); - obj_controller.gene_seed=ini_read_real("Controller","gene_seed",0); - obj_controller.marines=ini_read_real("Controller","marines",0); - obj_controller.command=ini_read_real("Controller","command",0); - obj_controller.info_chips=ini_read_real("Controller","info_chips",0); - obj_controller.inspection_passes=ini_read_real("Controller","inspection_passes",0); - obj_controller.recruiting_worlds_bought=ini_read_real("Controller","recruiting_worlds_bought",0); - obj_controller.last_weapons_tab=ini_read_real("Controller","lwt",1); - // - obj_ini.battle_cry=ini_read_string("Ini","battle_cry","Error"); - // obj_ini.fortress_name=ini_read_string("Ini","fortress_name","Error"); - obj_ini.flagship_name=ini_read_string("Ini","flagship_name","Error"); - obj_ini.home_name=ini_read_string("Ini","home_name","Error"); - obj_ini.home_type=ini_read_string("Ini","home_type","Error"); - obj_ini.recruiting_name=ini_read_string("Ini","recruiting_name","Error"); - obj_ini.recruiting_type=ini_read_string("Ini","recruiting_type","Error"); - - - var tempa,tempa2,q,good;q=0;good=0;tempa="";tempa2=0; - scr_colors_initialize(); - - tempa=ini_read_string("Controller","main_color","Error");tempa2=0; - q=0;good=0;repeat(30){q+=1;if (tempa=col[q]) and (good=0){good=q;tempa2=q;}} - obj_controller.main_color=tempa2;obj_ini.main_color=tempa2; - - tempa=ini_read_string("Controller","secondary_color","Error");tempa2=0; - q=0;good=0;repeat(30){q+=1;if (tempa=col[q]) and (good=0){good=q;tempa2=q;}} - obj_controller.secondary_color=tempa2;obj_ini.secondary_color=tempa2; - - tempa=ini_read_string("Controller","trim_color","Error");tempa2=0; - q=0;good=0;repeat(30){q+=1;if (tempa=col[q]) and (good=0){good=q;tempa2=q;}} - obj_controller.trim_color=tempa2;obj_ini.trim_color=tempa2; - - tempa=ini_read_string("Controller","pauldron2_color","Error");tempa2=0; - q=0;good=0;repeat(30){q+=1;if (tempa=col[q]) and (good=0){good=q;tempa2=q;}} - obj_controller.pauldron2_color=tempa2;obj_ini.pauldron2_color=tempa2; - - tempa=ini_read_string("Controller","pauldron_color","Error");tempa2=0; - q=0;good=0;repeat(30){q+=1;if (tempa=col[q]) and (good=0){good=q;tempa2=q;}} - obj_controller.pauldron_color=tempa2;obj_ini.pauldron_color=tempa2; - - tempa=ini_read_string("Controller","lens_color","Error");tempa2=0; - q=0;good=0;repeat(30){q+=1;if (tempa=col[q]) and (good=0){good=q;tempa2=q;}} - obj_controller.lens_color=tempa2;obj_ini.lens_color=tempa2; - - tempa=ini_read_string("Controller","weapon_color","Error");tempa2=0; - q=0;good=0;repeat(30){q+=1;if (tempa=col[q]) and (good=0){good=q;tempa2=q;}} - obj_controller.weapon_color=tempa2;obj_ini.weapon_color=tempa2; - - obj_controller.col_special=ini_read_real("Controller","col_special",0);obj_ini.col_special=obj_controller.col_special; - obj_controller.trim=ini_read_real("Controller","trimmed",0);obj_ini.trim=obj_controller.trim; - obj_ini.skin_color=ini_read_real("Controller","skin_color",0);obj_controller.skin_color=obj_ini.skin_color; - - obj_ini.adept_name=ini_read_string("Controller","adept_name","Error"); - obj_ini.recruiter_name=ini_read_string("Controller","recruiter_name","Error"); - // obj_ini.progenitor=ini_read_string("Controller","progenitor","Error"); - obj_ini.mutation=ini_read_string("Controller","mutation","Error"); - obj_ini.successor_chapters=ini_read_real("Controller","successors",0); - obj_ini.progenitor_disposition=ini_read_real("Controller","progenitor_disposition",0); - obj_ini.imperium_disposition=ini_read_real("Controller","imperium_disposition",0); - obj_controller.astartes_disposition=ini_read_real("Controller","astartes_disposition",0); - - obj_controller.bat_devastator_column=ini_read_real("Controller","bat_devastator_column",1); - obj_controller.bat_assault_column=ini_read_real("Controller","bat_assault_column",4); - obj_controller.bat_tactical_column=ini_read_real("Controller","bat_tactical_column",2); - obj_controller.bat_veteran_column=ini_read_real("Controller","bat_veteran_column",2); - obj_controller.bat_hire_column=ini_read_real("Controller","bat_hire_column",3); - obj_controller.bat_librarian_column=ini_read_real("Controller","bat_librarian_column",3); - obj_controller.bat_command_column=ini_read_real("Controller","bat_command_column",3); - obj_controller.bat_techmarine_column=ini_read_real("Controller","bat_techmarine_column",3); - obj_controller.bat_terminator_column=ini_read_real("Controller","bat_terminator_column",3); - obj_controller.bat_honor_column=ini_read_real("Controller","bat_honor_column",3); - obj_controller.bat_dreadnought_column=ini_read_real("Controller","bat_dreadnought_column",5); - obj_controller.bat_rhino_column=ini_read_real("Controller","bat_rhino_column",6); - obj_controller.bat_predator_column=ini_read_real("Controller","bat_preadtor_column",7); - obj_controller.bat_landraiders_column=ini_read_real("Controller","bat_landraiders_column",7); - obj_controller.bat_scout_column=ini_read_real("Controller","bat_scout_column",1); - - ini_close(); - } - - - if (argument0=2) or (argument0=0){debugl("Loading slot "+string(argument1)+" part 2"); - ini_open("tsave.ini"); - - stars=ini_read_real("Save","stars",0); - - // Stars - var i;i=-1; - repeat(stars){i+=1; - var new_star;new_star=instance_create(0,0,obj_star); - - new_star.name=ini_read_string("Star","sr"+string(i)+"name",""); - new_star.star=ini_read_string("Star","sr"+string(i)+"star",""); - new_star.planets=ini_read_real("Star","sr"+string(i)+"planets",0); - new_star.owner=ini_read_real("Star","sr"+string(i)+"owner",0); - new_star.x=ini_read_real("Star","sr"+string(i)+"x",0); - new_star.y=ini_read_real("Star","sr"+string(i)+"y",0); - new_star.x2=ini_read_real("Star","sr"+string(i)+"x2",0); - new_star.y2=ini_read_real("Star","sr"+string(i)+"y2",0); - new_star.old_x=ini_read_real("Star","sr"+string(i)+"ox",0); - new_star.old_y=ini_read_real("Star","sr"+string(i)+"oy",0); - - new_star.vision=ini_read_real("Star","sr"+string(i)+"vision",1); - new_star.storm=ini_read_real("Star","sr"+string(i)+"storm",0); - new_star.trader=ini_read_real("Star","sr"+string(i)+"trader",0); - new_star.craftworld=ini_read_real("Star","sr"+string(i)+"craftworld",0); - new_star.space_hulk=ini_read_real("Star","sr"+string(i)+"spacehulk",0); - if (new_star.space_hulk=1) then new_star.sprite_index=spr_star_hulk; - - var g;g=0; - repeat(4){g+=1; - if (new_star.planets>=g){ - new_star.planet[g]=ini_read_real("Star","sr"+string(i)+"plan"+string(g),0); - new_star.dispo[g]=ini_read_real("Star","sr"+string(i)+"dispo"+string(g),-10); - new_star.p_type[g]=ini_read_string("Star","sr"+string(i)+"type"+string(g),""); - new_star.p_feature[g] = []; - var p_features = ini_read_string("Star","sr"+string(i)+"feat"+string(g),""); - if (p_features != ""){ - var p_features = json_parse(base64_decode(p_features)); - for (var feat = 0;feat < array_length(p_features);feat++){ - var new_feat = new new_planet_feature(p_features[feat].f_type); - new_feat.load_json_data(p_features[feat]); - array_push(new_star.p_feature[g], new_feat); - } - } - new_star.p_owner[g]=ini_read_real("Star","sr"+string(i)+"own"+string(g),0); - new_star.p_first[g]=ini_read_real("Star","sr"+string(i)+"fir"+string(g),0); - new_star.p_population[g]=ini_read_real("Star","sr"+string(i)+"popul"+string(g),0); - new_star.p_max_population[g]=ini_read_real("Star","sr"+string(i)+"maxpop"+string(g),0); - new_star.p_large[g]=ini_read_real("Star","sr"+string(i)+"large"+string(g),0); - new_star.p_pop[g]=ini_read_string("Star","sr"+string(i)+"pop"+string(g),""); - new_star.p_guardsmen[g]=ini_read_real("Star","sr"+string(i)+"guard"+string(g),0); - new_star.p_pdf[g]=ini_read_real("Star","sr"+string(i)+"pdf"+string(g),0); - new_star.p_fortified[g]=ini_read_real("Star","sr"+string(i)+"forti"+string(g),0); - new_star.p_station[g]=ini_read_real("Star","sr"+string(i)+"stat"+string(g),0); - - new_star.p_player[g]=ini_read_real("Star","sr"+string(i)+"play"+string(g),0); - new_star.p_lasers[g]=ini_read_real("Star","sr"+string(i)+"p_lasers"+string(g),0); - new_star.p_silo[g]=ini_read_real("Star","sr"+string(i)+"p_silo"+string(g),0); - new_star.p_defenses[g]=ini_read_real("Star","sr"+string(i)+"p_defenses"+string(g),0); - new_star.p_upgrades[g] = []; - var p_upgrades = ini_read_string("Star","sr"+string(i)+"upg"+string(g),""); - if (p_upgrades != ""){ - var p_upgrades = json_parse(base64_decode(p_upgrades)); - for (var feat = 0;feat < array_length(p_upgrades);feat++){ - var new_feat = new new_planet_feature(p_upgrades[feat].f_type); - new_feat.load_json_data(p_upgrades[feat]); - array_push(new_star.p_upgrades[g], new_feat); - } - } - - new_star.p_orks[g]=ini_read_real("Star","sr"+string(i)+"or"+string(g),0); - new_star.p_tau[g]=ini_read_real("Star","sr"+string(i)+"ta"+string(g),0); - new_star.p_eldar[g]=ini_read_real("Star","sr"+string(i)+"el"+string(g),0); - new_star.p_traitors[g]=ini_read_real("Star","sr"+string(i)+"tr"+string(g),0); - new_star.p_chaos[g]=ini_read_real("Star","sr"+string(i)+"ch"+string(g),0); - new_star.p_demons[g]=ini_read_real("Star","sr"+string(i)+"de"+string(g),0); - new_star.p_sisters[g]=ini_read_real("Star","sr"+string(i)+"si"+string(g),0); - new_star.p_necrons[g]=ini_read_real("Star","sr"+string(i)+"ne"+string(g),0); - new_star.p_tyranids[g]=ini_read_real("Star","sr"+string(i)+"tyr"+string(g),0); - new_star.p_halp[g]=ini_read_real("Star","sr"+string(i)+"halp"+string(g),0); - - new_star.p_heresy[g]=ini_read_real("Star","sr"+string(i)+"heresy"+string(g),0); - new_star.p_hurssy[g]=ini_read_real("Star","sr"+string(i)+"hurssy"+string(g),0); - new_star.p_hurssy_time[g]=ini_read_real("Star","sr"+string(i)+"hurssy_time"+string(g),0); - new_star.p_heresy_secret[g]=ini_read_real("Star","sr"+string(i)+"heresy_secret"+string(g),0); - new_star.p_influence[g]=ini_read_real("Star","sr"+string(i)+"influence"+string(g),0); - new_star.p_raided[g]=ini_read_real("Star","sr"+string(i)+"raided"+string(g),0); - - - - /* - ini_write_string("Star","sr"+string(i)+"prob"+string(g)+".1",instance_array[i].p_problem[g,1]); - ini_write_real("Star","sr"+string(i)+"time"+string(g)+".1",instance_array[i].p_timer[g,1]); - - ini_write_string("Star","sr"+string(i)+"prob"+string(g)+"2",instance_array[i].p_problem[g,2]); - ini_write_real("Star","sr"+string(i)+"time"+string(g)+".2",instance_array[i].p_timer[g,2]); - - ini_write_string("Star","sr"+string(i)+"prob"+string(g)+".3",instance_array[i].p_problem[g,3]); - ini_write_real("Star","sr"+string(i)+"time"+string(g)+".3",instance_array[i].p_timer[g,3]); - - ini_write_string("Star","sr"+string(i)+"prob"+string(g)+".4",instance_array[i].p_problem[g,4]); - ini_write_real("Star","sr"+string(i)+"time"+string(g)+".4",instance_array[i].p_timer[g,4]); - */ - - - - new_star.p_problem[g,1]=ini_read_string("Star","sr"+string(i)+"prob"+string(g)+".1",""); - new_star.p_timer[g,1]=ini_read_real("Star","sr"+string(i)+"time"+string(g)+".1",0); - new_star.p_problem[g,2]=ini_read_string("Star","sr"+string(i)+"prob"+string(g)+".2",""); - new_star.p_timer[g,2]=ini_read_real("Star","sr"+string(i)+"time"+string(g)+".2",0); - new_star.p_problem[g,3]=ini_read_string("Star","sr"+string(i)+"prob"+string(g)+".3",""); - new_star.p_timer[g,3]=ini_read_real("Star","sr"+string(i)+"time"+string(g)+".3",0); - new_star.p_problem[g,4]=ini_read_string("Star","sr"+string(i)+"prob"+string(g)+".4",""); - new_star.p_timer[g,4]=ini_read_real("Star","sr"+string(i)+"time"+string(g)+".4",0); - } - } - } - - // obj_ini - obj_ini.home_name=ini_read_string("Ini","home_name","Error"); - obj_ini.home_type=ini_read_string("Ini","home_type","Error"); - obj_ini.recruiting_name=ini_read_string("Ini","recruiting_name","Error"); - obj_ini.recruiting_type=ini_read_string("Ini","recruiting_type","Error"); - obj_ini.chapter_name=ini_read_string("Ini","chapter_name","Error"); - obj_ini.fortress_name=ini_read_string("Ini","fortress_name","Error"); - obj_ini.flagship_name=ini_read_string("Ini","flagship_name","Error"); - obj_ini.icon=ini_read_real("Ini","icon",0); - obj_ini.icon_name=ini_read_string("Ini","icon_name","custom1"); - global.icon_name=obj_ini.icon_name; - obj_ini.man_size=ini_read_real("Ini","man_size",0); - obj_ini.strin=ini_read_string("Ini","strin1",""); - obj_ini.strin2=ini_read_string("Ini","strin2",""); - obj_ini.psy_powers=ini_read_string("Ini","psy_powers","default"); - - obj_ini.companies=ini_read_real("Ini","companies",10); - var i;i=-1;repeat(21){i+=1;obj_ini.company_title[i]=ini_read_string("Ini","comp_title"+string(i),"");} - var i;i=-1;repeat(121){i+=1;obj_ini.slave_batch_num[i]=ini_read_real("Ini","slave_num_"+string(i),0);obj_ini.slave_batch_eta[i]=ini_read_real("Ini","slave_eta_"+string(i),0);} - - - - obj_ini.master_autarch=ini_read_real("Ini","master_autarch",0); - obj_ini.master_avatar=ini_read_real("Ini","master_avatar",0); - obj_ini.master_farseer=ini_read_real("Ini","master_farseer",0); - obj_ini.master_aspect=ini_read_real("Ini","master_aspect",0); - obj_ini.master_eldar=ini_read_real("Ini","master_eldar",0); - obj_ini.master_eldar_vehicles=ini_read_real("Ini","master_eldar_vehicles",0); - obj_ini.master_tau=ini_read_real("Ini","master_tau",0); - obj_ini.master_battlesuits=ini_read_real("Ini","master_battlesuits",0); - obj_ini.master_kroot=ini_read_real("Ini","master_kroot",0); - obj_ini.master_tau_vehicles=ini_read_real("Ini","master_tau_vehicles",0); - obj_ini.master_ork_boyz=ini_read_real("Ini","master_ork_boyz",0); - obj_ini.master_ork_nobz=ini_read_real("Ini","master_ork_nobz",0); - obj_ini.master_ork_warboss=ini_read_real("Ini","master_ork_warboss",0); - obj_ini.master_ork_vehicles=ini_read_real("Ini","master_ork_vehicles",0); - obj_ini.master_heretics=ini_read_real("Ini","master_heretics",0); - obj_ini.master_chaos_marines=ini_read_real("Ini","master_chaos_marines",0); - obj_ini.master_lesser_demons=ini_read_real("Ini","master_lesser_demons",0); - obj_ini.master_greater_demons=ini_read_real("Ini","master_greater_demons",0); - obj_ini.master_chaos_vehicles=ini_read_real("Ini","master_chaos_vehicles",0); - obj_ini.master_gaunts=ini_read_real("Ini","master_gaunts",0); - obj_ini.master_warriors=ini_read_real("Ini","master_warriors",0); - obj_ini.master_carnifex=ini_read_real("Ini","master_carnifex",0); - obj_ini.master_synapse=ini_read_real("Ini","master_synapse",0); - obj_ini.master_tyrant=ini_read_real("Ini","master_tyrant",0); - obj_ini.master_gene=ini_read_real("Ini","master_gene",0); - obj_ini.master_necron_overlord=ini_read_real("Ini","master_necron_overlord",0); - obj_ini.master_destroyer=ini_read_real("Ini","master_destroyer",0); - obj_ini.master_necron=ini_read_real("Ini","master_necron",0); - obj_ini.master_wraith=ini_read_real("Ini","master_wraith",0); - obj_ini.master_necron_vehicles=ini_read_real("Ini","master_necron_vehicles",0); - obj_ini.master_monolith=ini_read_real("Ini","master_monolith",0); - obj_ini.master_special_killed=ini_read_string("Ini","master_special",""); - // - obj_ini.preomnor=ini_read_real("Ini","preomnor",0); - obj_ini.voice=ini_read_real("Ini","voice",0); - obj_ini.doomed=ini_read_real("Ini","doomed",0); - obj_ini.lyman=ini_read_real("Ini","lyman",0); - obj_ini.omophagea=ini_read_real("Ini","omophagea",0); - obj_ini.ossmodula=ini_read_real("Ini","ossmodula",0); - obj_ini.membrane=ini_read_real("Ini","membrane",0); - obj_ini.zygote=ini_read_real("Ini","zygote",0); - obj_ini.betchers=ini_read_real("Ini","betchers",0); - obj_ini.catalepsean=ini_read_real("Ini","catalepsean",0); - obj_ini.secretions=ini_read_real("Ini","secretions",0); - obj_ini.occulobe=ini_read_real("Ini","occulobe",0); - obj_ini.mucranoid=ini_read_real("Ini","mucranoid",0); - // - obj_ini.master_name=ini_read_string("Ini","master_name","Error"); - obj_ini.chief_librarian_name=ini_read_string("Ini","chief_name","Error"); - obj_ini.high_chaplain_name=ini_read_string("Ini","high_name","Error"); - obj_ini.high_apothecary_name=ini_read_string("Ini","high2_name","Error"); - obj_ini.forge_master_name=ini_read_string("Ini","forgey_name","Error"); - obj_ini.lord_admiral_name=ini_read_string("Ini","lord_name","Error"); - // - obj_ini.chaplain_ranged=ini_read_string("Ini","chaplain_ranged","Error"); - obj_ini.chaplain_melee=ini_read_string("Ini","chaplain_melee","Error"); - obj_ini.apothecary_ranged=ini_read_string("Ini","apothecary_ranged","Error"); - obj_ini.apothecary_melee=ini_read_string("Ini","apothecary_melee","Error"); - obj_ini.sergeant_ranged=ini_read_string("Ini","sergeant_ranged","Error"); - obj_ini.sergeant_melee=ini_read_string("Ini","sergeant_melee","Error"); - obj_ini.scout_ranged=ini_read_string("Ini","scout_ranged","Error"); - obj_ini.scout_melee=ini_read_string("Ini","scout_melee","Error"); - obj_ini.honor_ranged=ini_read_string("Ini","honor_ranged","Error"); - obj_ini.honor_melee=ini_read_string("Ini","honor_melee","Error"); - obj_ini.honor_mobi=ini_read_string("Ini","honor_mobi","Error"); - obj_ini.forbidden_unit1=ini_read_string("Ini","forbidden_unit1","Error"); - obj_ini.forbidden_unit2=ini_read_string("Ini","forbidden_unit2","Error"); - obj_ini.forbidden_unit3=ini_read_string("Ini","forbidden_unit3","Error"); - // - var g;g=-1; - repeat(150){g+=1; - obj_ini.equipment[g]=ini_read_string("Ini","equipment"+string(g),""); - obj_ini.equipment_type[g]=ini_read_string("Ini","equipment_type"+string(g),""); - obj_ini.equipment_number[g]=ini_read_real("Ini","equipment_number"+string(g),0); - obj_ini.equipment_condition[g]=ini_read_real("Ini","equipment_condition"+string(g),0); - - if (g<=20){ - obj_ini.artifact[g]=ini_read_string("Ini","artifact"+string(g),""); - obj_ini.artifact_tags[g]=ini_read_string("Ini","artifact_tags"+string(g),""); - obj_ini.artifact_identified[g]=ini_read_real("Ini","artifact_ident"+string(g),0); - obj_ini.artifact_condition[g]=ini_read_real("Ini","artifact_condition"+string(g),0); - obj_ini.artifact_loc[g]=ini_read_string("Ini","artifact_loc"+string(g),""); - obj_ini.artifact_sid[g]=ini_read_real("Ini","artifact_sid"+string(g),0); - } - } - // - obj_ini.ship_location[0]=""; - - - if (global.restart=0){ - var g;g=-1;repeat(200){g+=1; - obj_ini.ship[g]=ini_read_string("Ships","shi"+string(g),""); - obj_ini.ship_uid[g]=ini_read_real("Ships","shi_uid"+string(g),0); - obj_ini.ship_class[g]=ini_read_string("Ships","shi_class"+string(g),""); - // - obj_ini.ship_size[g]=ini_read_real("Ships","shi_size"+string(g),0); - obj_ini.ship_leadership[g]=ini_read_real("Ships","shi_leadership"+string(g),0); - obj_ini.ship_hp[g]=ini_read_real("Ships","shi_hp"+string(g),0); - obj_ini.ship_maxhp[g]=ini_read_real("Ships","shi_maxhp"+string(g),0); - - if (obj_ini.ship_maxhp[g]<200) and (obj_ini.ship_maxhp[g]!=0){ - obj_ini.ship_hp[g]=obj_ini.ship_hp[g]*2; - obj_ini.ship_maxhp[g]=obj_ini.ship_maxhp[g]*2; - } - - obj_ini.ship_location[g]=ini_read_string("Ships","shi_location"+string(g),""); - obj_ini.ship_shields[g]=ini_read_real("Ships","shi_shields"+string(g),0); - obj_ini.ship_conditions[g]=ini_read_string("Ships","shi_conditions"+string(g),""); - obj_ini.ship_speed[g]=ini_read_real("Ships","shi_speed"+string(g),0); - obj_ini.ship_turning[g]=ini_read_real("Ships","shi_turning"+string(g),0); - obj_ini.ship_front_armour[g]=ini_read_real("Ships","shi_front_ac"+string(g),0); - obj_ini.ship_other_armour[g]=ini_read_real("Ships","shi_other_ac"+string(g),0); - obj_ini.ship_weapons[g]=ini_read_real("Ships","shi_weapons"+string(g),0); - // - obj_ini.ship_wep[g,1]=ini_read_string("Ships","shi"+string(g)+"wep1",""); - obj_ini.ship_facing[g,1]=ini_read_string("Ships","shi"+string(g)+"facing1",""); - obj_ini.ship_condition[g,1]=ini_read_string("Ships","shi"+string(g)+"condition1",""); - obj_ini.ship_wep[g,2]=ini_read_string("Ships","shi"+string(g)+"wep2",""); - obj_ini.ship_facing[g,2]=ini_read_string("Ships","shi"+string(g)+"facing2",""); - obj_ini.ship_condition[g,2]=ini_read_string("Ships","shi"+string(g)+"condition2",""); - obj_ini.ship_wep[g,3]=ini_read_string("Ships","shi"+string(g)+"wep3",""); - obj_ini.ship_facing[g,3]=ini_read_string("Ships","shi"+string(g)+"facing3",""); - obj_ini.ship_condition[g,3]=ini_read_string("Ships","shi"+string(g)+"condition3",""); - obj_ini.ship_wep[g,4]=ini_read_string("Ships","shi"+string(g)+"wep4",""); - obj_ini.ship_facing[g,4]=ini_read_string("Ships","shi"+string(g)+"facing4",""); - obj_ini.ship_condition[g,4]=ini_read_string("Ships","shi"+string(g)+"condition4",""); - obj_ini.ship_wep[g,5]=ini_read_string("Ships","shi"+string(g)+"wep5",""); - obj_ini.ship_facing[g,5]=ini_read_string("Ships","shi"+string(g)+"facing5",""); - obj_ini.ship_condition[g,5]=ini_read_string("Ships","shi"+string(g)+"condition5",""); - // - obj_ini.ship_capacity[g]=ini_read_real("Ships","shi_capacity"+string(g),0); - obj_ini.ship_carrying[g]=ini_read_real("Ships","shi_carrying"+string(g),0); - obj_ini.ship_contents[g]=ini_read_string("Ships","shi_contents"+string(g),""); - obj_ini.ship_turrets[g]=ini_read_real("Ships","shi_turrets"+string(g),0); - } - } - // the fun begins here - ini_close(); - } - - - - - if (argument0=3) or (argument0=0){debugl("Loading slot "+string(argument1)+" part 3"); - ini_open("tsave.ini"); - - var coh,mah,good; - good=0;coh=100;mah=-1; - - if (global.restart=0){ - var coh,mah,good; - good=0;coh=10;mah=205; - repeat(2255){ - if (good=0){ - mah-=1; - if (mah=0){mah=205;coh-=1;} - - // var temp_name;temp_name=""; - // temp_name=ini_read_string("Veh","rol"+string(coh)+"."+string(mah),""); - - // if (temp_name!=""){ - obj_ini.veh_race[coh,mah]=ini_read_real("Veh","co"+string(coh)+"."+string(mah),0); - obj_ini.veh_loc[coh,mah]=ini_read_string("Veh","lo"+string(coh)+"."+string(mah),""); - obj_ini.veh_role[coh,mah]=ini_read_string("Veh","rol"+string(coh)+"."+string(mah),"");// temp_name; - obj_ini.veh_lid[coh,mah]=ini_read_real("Veh","lid"+string(coh)+"."+string(mah),0); - obj_ini.veh_uid[coh,mah]=ini_read_real("Veh","uid"+string(coh)+"."+string(mah),0); - obj_ini.veh_wid[coh,mah]=ini_read_real("Veh","wid"+string(coh)+"."+string(mah),0); - - obj_ini.veh_wep1[coh,mah]=ini_read_string("Veh","w1"+string(coh)+"."+string(mah),""); - obj_ini.veh_wep2[coh,mah]=ini_read_string("Veh","w2"+string(coh)+"."+string(mah),""); - obj_ini.veh_wep3[coh,mah]=ini_read_string("Veh","w3"+string(coh)+"."+string(mah),""); - obj_ini.veh_upgrade[coh,mah]=ini_read_string("Veh","up"+string(coh)+"."+string(mah),""); - obj_ini.veh_acc[coh,mah]=ini_read_string("Veh","ac"+string(coh)+"."+string(mah),""); - - obj_ini.veh_hp[coh,mah]=ini_read_real("Veh","hp"+string(coh)+"."+string(mah),0); - obj_ini.veh_chaos[coh,mah]=ini_read_real("Veh","cha"+string(coh)+"."+string(mah),0); - // ini_write_real("Veh","pil"+string(coh)+"."+string(mah),obj_ini.veh_pilots[coh,mah]); - // } - if (coh=1) and (mah=1) then good=1; - } - } - - var coh,mah,good; - good=0;coh=100;mah=-1; - repeat(31){mah+=1; - obj_ini.race[coh,mah]=ini_read_real("Mar","co"+string(coh)+"."+string(mah),0); - obj_ini.name[coh,mah]=ini_read_string("Mar","num"+string(coh)+"."+string(mah),""); - obj_ini.role[coh,mah]=ini_read_string("Mar","rol"+string(coh)+"."+string(mah),""); - obj_ini.wep1[coh,mah]=ini_read_string("Mar","w1"+string(coh)+"."+string(mah),""); - obj_ini.wep2[coh,mah]=ini_read_string("Mar","w2"+string(coh)+"."+string(mah),""); - obj_ini.armour[coh,mah]=ini_read_string("Mar","ar"+string(coh)+"."+string(mah),""); - obj_ini.gear[coh,mah]=ini_read_string("Mar","ge"+string(coh)+"."+string(mah),""); - obj_ini.mobi[coh,mah]=ini_read_string("Mar","mb"+string(coh)+"."+string(mah),""); - } - for (coh=0;coh<=10;coh++){ - for (mah=0;mah<=500;mah++){ - - // var temp_name;temp_name=""; - // temp_name=ini_read_string("Mar","rol"+string(coh)+"."+string(mah),"Error"); - - obj_ini.race[coh,mah]=ini_read_real("Mar","co"+string(coh)+"."+string(mah),0); - obj_ini.loc[coh,mah]=ini_read_string("Mar","lo"+string(coh)+"."+string(mah),""); - obj_ini.name[coh,mah]=ini_read_string("Mar","num"+string(coh)+"."+string(mah),""); - obj_ini.role[coh,mah]=ini_read_string("Mar","rol"+string(coh)+"."+string(mah),"");// temp_name; - obj_ini.lid[coh,mah]=ini_read_real("Mar","li"+string(coh)+"."+string(mah),0); - obj_ini.bio[coh,mah]=ini_read_real("Mar","bio"+string(coh)+"."+string(mah),0); - obj_ini.wid[coh,mah]=ini_read_real("Mar","wi"+string(coh)+"."+string(mah),0); - - if (coh=0){ - if (obj_ini.role[coh,mah]="Chapter Master"){ - obj_ini.race[coh,mah]=1; - }else if (obj_ini.role[coh,mah]="Master of Sanctity"){ - obj_ini.race[coh,mah]=1; - }else if (obj_ini.role[coh,mah]="Master of the Apothecarion"){ - obj_ini.race[coh,mah]=1; - } else if (obj_ini.role[coh,mah]="Forge Master") then obj_ini.race[coh,mah]=1; - if (string_count("Chief",obj_ini.role[coh,mah])>0) then obj_ini.race[coh,mah]=1; + + function load_marine_struct(company, marine) { + var marStruct = ini_read_string("Mar", "Struct" + string(company) + "." + string(marine), ""); + if (marStruct != "") { + marStruct = json_parse(base64_decode(marStruct)); + obj_ini.TTRPG[company, marine] = new TTRPG_stats("chapter", company, marine, "blank"); + obj_ini.TTRPG[company, marine].load_json_data(marStruct); + } else { + obj_ini.TTRPG[company, marine] = new TTRPG_stats("chapter", company, marine, "blank"); + } + }; + var rang, i, g, stars, pfleets, efleets; + rang = 0; + i = 0; + g = 0; + stars = 0; + pfleets = 0; + efleets = 0; + + + + if (argument0 = 1) or(argument0 = 0) { + + debugl("Loading slot " + string(argument1)); + var save_file_name = "save" + string(argument1) + ".ini"; + + if (file_exists("tsave.ini")) { + // file_copy() will fail if destination file already exists + file_delete("tsave.ini"); + } + + if (file_exists(save_file_name)) { + file_copy(save_file_name, "tsave.ini"); + } else { + debugl("Could not load save game " + save_file_name + ", file does not exist."); + game_restart(); + } + + // TODO temporary disabled. Will be reenabled during ironman/autosave feature task + //file_decrypt("tsave.ini","p"); + ini_open("tsave.ini"); + + // Global variables + global.chapter_name = ini_read_string("Save", "chapter_name", "Error"); // + obj_ini.sector_name = ini_read_string("Save", "sector_name", "Error"); // + + // TODO make it either throw error (if version is wrong) or try to upgrade the saved game data and version + global.version = ini_read_string("Save", "version", 0); + global.game_seed = ini_read_real("Save", "game_seed", 0); + obj_ini.use_custom_icon = ini_read_real("Save", "use_custom_icon", 0); + + obj_controller.play_time = ini_read_real("Save", "play_time", 0); + + obj_ini.progenitor = ini_read_real("Save", "founding", 0); + // global.founding_secret=ini_read_string("Save","founding_secret","Error"); + global.custom = ini_read_real("Save", "custom", 1); + stars = ini_read_real("Save", "stars", 0); + // pfleets=ini_read_real("Save","p_fleets",0); + // efleets=ini_read_real("Save","en_fleets",0); + g = ini_read_real("Save", "sod", 0); + random_set_seed(g); + g = 0; + var corrupt; + corrupt = 1; + corrupt = ini_read_real("Save", "corrupt", 1); + + if (corrupt = 1) { + game_restart(); + } + + // obj_controller variables here + obj_controller.load_game = argument1; + global.cheat_req = ini_read_real("boolean", "cheat_req", 0); + global.cheat_gene = ini_read_real("boolean", "cheat_gene", 0); + global.cheat_debug = ini_read_real("boolean", "cheat_debug", 0); + global.cheat_disp = ini_read_real("boolean", "cheat_disp", 0); + obj_controller.cheatyface = ini_read_real("Controller", "cheatyface", 0); + obj_controller.x = ini_read_real("Controller", "x", obj_controller.x); + obj_controller.y = ini_read_real("Controller", "y", obj_controller.y); + obj_controller.was_zoomed = ini_read_real("Controller", "was_zoomed", 0); + obj_controller.zoomed = ini_read_real("Controller", "zoomed", 0); + obj_controller.chaos_rating = ini_read_real("Controller", "chaos_rating", 0); + obj_controller.fleet_type = ini_read_string("Controller", "fleet_type", ""); // + obj_ini.fleet_type = round(ini_read_real("Controller", "ifleet_type", 0)); + obj_controller.homeworld_rule = ini_read_real("Controller", "home_rule", 1); + + obj_controller.star_names = ini_read_string("Controller", "star_names", "Error"); // + obj_controller.craftworld = ini_read_real("Controller", "craftworld", 0); + + obj_controller.turn = ini_read_real("Controller", "turn", 0); + obj_controller.last_event = ini_read_real("Controller", "last_event", 0); + obj_controller.last_mission = ini_read_real("Controller", "last_mission", 0); + obj_controller.last_world_inspection = ini_read_real("Controller", "last_world_inspection", 0); + obj_controller.last_fleet_inspection = ini_read_real("Controller", "last_fleet_inspection", 0); + obj_controller.chaos_turn = ini_read_real("Controller", "chaos_turn", 0); + obj_controller.chaos_fleets = ini_read_real("Controller", "chaos_fleets", 0); + obj_controller.tau_fleets = ini_read_real("Controller", "tau_fleets", 0); + obj_controller.tau_stars = ini_read_real("Controller", "tau_stars", 0); + obj_controller.tau_messenger = ini_read_real("Controller", "tau_messenger", 0); + obj_controller.fleet_all = ini_read_real("Controller", "fleet_all", 0); + obj_ini.tolerant = ini_read_real("Controller", "tolerant", 0); + obj_ini.stability = ini_read_real("Controller", "stability", 5); + obj_ini.purity = ini_read_real("Controller", "purity", 5); + obj_controller.tolerant = ini_read_real("Controller", "tolerant", 0); + obj_controller.unload = ini_read_real("Controller", "unload", 0); + obj_controller.diplomacy = 0; + obj_controller.trading = 0; + obj_controller.audience = 0; + obj_controller.force_goodbye = 0; + obj_controller.combat = 0; + obj_controller.new_vehicles = ini_read_real("Controller", "new_vehicles", 0); + obj_controller.hurssy = ini_read_real("Controller", "hurssy", 0); + obj_controller.hurssy_time = ini_read_real("Controller", "hurssy_time", 0); + obj_controller.artifacts = ini_read_real("Controller", "artifacts", 0); + obj_controller.popup_master_crafted = ini_read_real("Controller", "pmc", 0); + obj_controller.select_wounded = ini_read_real("Controller", "wndsel", 1); + obj_ini.imperium_disposition = ini_read_real("Controller", "imdis", 40); + obj_controller.terra_direction = ini_read_real("Controller", "terra_dir", floor(random(360)) + 1); + + obj_controller.stc_wargear = ini_read_real("Controller", "stc_wargear", 0); + obj_controller.stc_vehicles = ini_read_real("Controller", "stc_vehicles", 0); + obj_controller.stc_ships = ini_read_real("Controller", "stc_ships", 0); + obj_controller.stc_un_total = ini_read_real("Controller", "stc_un_total", 0); + obj_controller.stc_wargear_un = ini_read_real("Controller", "stc_wargear_un", 0); + obj_controller.stc_vehicles_un = ini_read_real("Controller", "stc_vehicles_un", 0); + obj_controller.stc_ships_un = ini_read_real("Controller", "stc_ships_un", 0); + var j; + j = 0; + repeat(6) { + j += 1; + obj_controller.stc_bonus[j] = ini_read_real("Controller", "stc_bonus_" + string(j), 0); + } + j = -1; + repeat(5) { + j += 1; + obj_ini.adv[j] = ini_read_string("Controller", "adv" + string(j), ""); + obj_ini.dis[j] = ini_read_string("Controller", "dis" + string(j), ""); + } // + + + + // Player scheduled event + obj_controller.fest_type = ini_read_string("Controller", "f_t", ""); // + + if (obj_controller.fest_type != "") { + obj_controller.fest_sid = ini_read_real("Controller", "f_si", 0); + obj_controller.fest_wid = ini_read_real("Controller", "f_wi", 0); + obj_controller.fest_planet = ini_read_real("Controller", "f_pl", 0); + obj_controller.fest_star = ini_read_string("Controller", "f_st", ""); // + obj_controller.fest_cost = ini_read_real("Controller", "f_co", 0); + obj_controller.fest_warp = ini_read_real("Controller", "f_wa", 0); + obj_controller.fest_scheduled = ini_read_real("Controller", "f_sch", 0); + obj_controller.fest_lav = ini_read_real("Controller", "f_la", 0); + obj_controller.fest_locals = ini_read_real("Controller", "f_lo", 0); + obj_controller.fest_feature1 = ini_read_real("Controller", "f_f1", 0); + obj_controller.fest_feature2 = ini_read_real("Controller", "f_f2", 0); + obj_controller.fest_feature3 = ini_read_real("Controller", "f_f3", 0); + obj_controller.fest_display = ini_read_real("Controller", "f_di", 0); + obj_controller.fest_display_tags = ini_read_string("Controller", "f_dit", ""); // + obj_controller.fest_repeats = ini_read_real("Controller", "f_re", 0); + obj_controller.fest_honor_co = ini_read_real("Controller", "f_hc", 0); + obj_controller.fest_honor_id = ini_read_real("Controller", "f_hi", 0); + obj_controller.fest_honoring = ini_read_real("Controller", "f_hon", 0); + } + obj_controller.fest_feasts = ini_read_real("Controller", "f_fee", 0); + obj_controller.fest_boozes = ini_read_real("Controller", "f_boo", 0); + obj_controller.fest_drugses = ini_read_real("Controller", "f_dru", 0); + obj_controller.recent_happenings = ini_read_real("Controller", "rech", 0); + var i; + i = -1; + repeat(obj_controller.recent_happenings + 1) { + i += 1; + if (recent_type[i] != "") { + obj_controller.recent_type[i] = ini_write_string("Controller", "rect" + string(i), ""); + obj_controller.recent_keyword[i] = ini_write_string("Controller", "reck" + string(i), ""); + } + } + + + + obj_controller.last_attack_form = ini_read_real("Formation", "last_attack", 1); + if (obj_controller.last_attack_form = 0) then obj_controller.last_attack_form = 1; + obj_controller.last_raid_form = ini_read_real("Formation", "last_raid", 3); + if (obj_controller.last_raid_form = 0) then obj_controller.last_raid_form = 3; + j = 0; + repeat(16) { + j += 1; + obj_controller.bat_formation[j] = ini_read_string("Formation", "form" + string(j), ""); // + if (obj_controller.bat_formation[j] != "") or(j <= 3) { + obj_controller.bat_formation_type[j] = ini_read_real("Formation", "form_type" + string(j), 0); + if (bat_formation[j] = "") and(obj_controller.bat_formation_type[j] = 0) { + if (j = 1) { + obj_controller.bat_formation[j] = "Attack"; + obj_controller.bat_formation_type[j] = 1; + } + if (j = 2) { + obj_controller.bat_formation[j] = "Defend"; + obj_controller.bat_formation_type[j] = 1; + } + if (j = 3) { + obj_controller.bat_formation[j] = "Raid"; + obj_controller.bat_formation_type[j] = 2; + } + } + obj_controller.bat_deva_for[j] = ini_read_real("Formation", "deva" + string(j), 1); + obj_controller.bat_assa_for[j] = ini_read_real("Formation", "assa" + string(j), 4); + obj_controller.bat_tact_for[j] = ini_read_real("Formation", "tact" + string(j), 2); + obj_controller.bat_vete_for[j] = ini_read_real("Formation", "vete" + string(j), 2); + obj_controller.bat_hire_for[j] = ini_read_real("Formation", "hire" + string(j), 3); + obj_controller.bat_libr_for[j] = ini_read_real("Formation", "libr" + string(j), 3); + obj_controller.bat_comm_for[j] = ini_read_real("Formation", "comm" + string(j), 3); + obj_controller.bat_tech_for[j] = ini_read_real("Formation", "tech" + string(j), 3); + obj_controller.bat_term_for[j] = ini_read_real("Formation", "term" + string(j), 3); + obj_controller.bat_hono_for[j] = ini_read_real("Formation", "hono" + string(j), 3); + obj_controller.bat_drea_for[j] = ini_read_real("Formation", "drea" + string(j), 5); + obj_controller.bat_rhin_for[j] = ini_read_real("Formation", "rhin" + string(j), 6); + obj_controller.bat_pred_for[j] = ini_read_real("Formation", "pred" + string(j), 7); + obj_controller.bat_land_for[j] = ini_read_real("Formation", "land" + string(j), 7); + obj_controller.bat_scou_for[j] = ini_read_real("Formation", "scou" + string(j), 1); + } + } + + obj_controller.useful_info = ini_read_string("Controller", "useful_info", ""); + obj_controller.random_event_next = ini_read_real("Controller", "random_event_next", "0"); + obj_controller.gene_sold = ini_read_real("Controller", "gene_sold", 0); + obj_controller.gene_xeno = ini_read_real("Controller", "gene_xeno", 0); + obj_controller.gene_tithe = ini_read_real("Controller", "gene_tithe", 24); + obj_controller.gene_iou = ini_read_real("Controller", "gene_iou", 0); + + obj_controller.und_armouries = ini_read_real("Controller", "und_armouries", 0); + obj_controller.und_gene_vaults = ini_read_real("Controller", "und_gene_vaults", 0); + obj_controller.und_lairs = ini_read_real("Controller", "und_lairs", 0); + + obj_controller.penitent = ini_read_real("Controller", "penitent", 0); + obj_controller.penitent_current = ini_read_real("Controller", "penitent_current", 0); + obj_controller.penitent_max = ini_read_real("Controller", "penitent_max", 0); + obj_controller.penitent_turnly = ini_read_real("Controller", "penitent_turnly", 0); + obj_controller.penitent_turn = ini_read_real("Controller", "penitent_turn", 0); + obj_controller.penitent_end = ini_read_real("Controller", "penitent_end", 0); + obj_controller.blood_debt = ini_read_real("Controller", "penitent_blood", 0); + + obj_controller.training_apothecary = ini_read_real("Controller", "training_apothecary", 0); + obj_controller.apothecary_points = ini_read_real("Controller", "apothecary_points", 0); + obj_controller.apothecary_aspirant = ini_read_real("Controller", "apothecary_aspirant", 0); + obj_controller.training_chaplain = ini_read_real("Controller", "training_chaplain", 0); + obj_controller.chaplain_points = ini_read_real("Controller", "chaplain_points", 0); + obj_controller.chaplain_aspirant = ini_read_real("Controller", "chaplain_aspirant", 0); + obj_controller.training_psyker = ini_read_real("Controller", "training_psyker", 0); + obj_controller.psyker_points = ini_read_real("Controller", "psyker_points", 0); + obj_controller.psyker_aspirant = ini_read_real("Controller", "psyker_aspirant", 0); + obj_controller.training_techmarine = ini_read_real("Controller", "training_techmarine", 0); + obj_controller.tech_points = ini_read_real("Controller", "tech_points", 0); + obj_controller.tech_aspirant = ini_read_real("Controller", "tech_aspirant", 0); + + obj_controller.penitorium = ini_read_real("Controller", "penitorium", 0); + + obj_controller.recruiting_worlds = ini_read_string("Controller", "recruiting_worlds", ""); + obj_controller.recruiting = ini_read_real("Controller", "recruiting", 0); + obj_controller.recruit_trial = ini_read_string("Controller", "trial", "Blood Duel"); + obj_controller.recruits = ini_read_real("Controller", "recruits", 0); + obj_controller.recruit_last = ini_read_real("Controller", "recruit_last", 0); + + var g; + g = -1; + repeat(30) { + g += 1; + obj_controller.command_set[g] = ini_read_real("Controller", "command" + string(g), 0); + } + if (obj_controller.command_set[20] = 0) and(obj_controller.command_set[21] = 0) and(obj_controller.command_set[22] = 0) then obj_controller.command_set[20] = 1; + if (obj_controller.command_set[23] = 0) and(obj_controller.command_set[24] = 0) then obj_controller.command_set[24] = 1; + + + ini_read_real("Controller", "blandify", 0); + var g; + g = -1; + repeat(obj_controller.recruits) { + g += 1; + obj_controller.recruit_name[g] = ini_read_string("Recruit", "rcr" + string(g), "Error"); + // ini_write_string("Recruit","rcr"+string(g),obj_controller.recruit_name[g]); + obj_controller.recruit_corruption[g] = ini_read_real("Recruit", "rcr_cr" + string(g), 0); + obj_controller.recruit_distance[g] = ini_read_real("Recruit", "rcr_ds" + string(g), 0); + obj_controller.recruit_training[g] = ini_read_real("Recruit", "rcr_tr" + string(g), 0); + obj_controller.recruit_exp[g] = ini_read_real("Recruit", "rcr_ex" + string(g), 0); + } + var g; + g = -1; + repeat(30) { + g += 1; + obj_controller.loyal[g] = ini_read_string("Controller", "lyl" + string(g), "Error"); + obj_controller.loyal_num[g] = ini_read_real("Controller", "lyl_nm" + string(g), 0); + obj_controller.loyal_tm[g] = ini_read_real("Controller", "lyl_tm" + string(g), 0); + } + var g; + g = -1; + repeat(30) { + g += 1; + obj_controller.inquisitor[g] = ini_read_string("Controller", "inq" + string(g), "Error"); + obj_controller.inquisitor_gender[g] = ini_read_real("Controller", "inq_ge" + string(g), 1); + obj_controller.inquisitor_type[g] = ini_read_string("Controller", "inq_ty" + string(g), "Error"); + } + + var g; + g = -1; + repeat(14) { + g += 1; + obj_controller.faction[g] = ini_read_string("Factions", "fac" + string(g), "Error"); + obj_controller.disposition[g] = ini_read_real("Factions", "dis" + string(g), 0); + obj_controller.disposition_max[g] = ini_read_real("Factions", "dis_max" + string(g), 0); + + obj_controller.faction_leader[g] = ini_read_string("Factions", "lead" + string(g), "Error"); + obj_controller.faction_gender[g] = ini_read_real("Factions", "gen" + string(g), 1); + obj_controller.faction_title[g] = ini_read_string("Factions", "title" + string(g), "Error"); + obj_controller.faction_status[g] = ini_read_string("Factions", "status" + string(g), "Error"); + obj_controller.faction_defeated[g] = ini_read_real("Factions", "defeated" + string(g), 0); + obj_controller.known[g] = ini_read_real("Factions", "known" + string(g), 0); + + obj_controller.annoyed[g] = ini_read_real("Factions", "annoyed" + string(g), 0); + obj_controller.ignore[g] = ini_read_real("Factions", "ignore" + string(g), 0); + obj_controller.turns_ignored[g] = ini_read_real("Factions", "turns_ignored" + string(g), 0); + obj_controller.audien[g] = ini_read_real("Factions", "audience" + string(g), 0); + obj_controller.audien_topic[g] = ini_read_string("Factions", "audience_topic" + string(g), ""); + } + // + var g; + g = 0; + repeat(50) { + g += 1; + obj_controller.quest[g] = ini_read_string("Ongoing", "quest" + string(g), ""); + obj_controller.quest_faction[g] = ini_read_real("Ongoing", "quest_faction" + string(g), 0); + obj_controller.quest_end[g] = ini_read_real("Ongoing", "quest_end" + string(g), 0); + } + var g; + g = 0; + repeat(99) { + g += 1; + obj_controller.event[g] = ini_read_string("Ongoing", "event" + string(g), ""); + obj_controller.event_duration[g] = ini_read_real("Ongoing", "event_duration" + string(g), 0); + } + // + obj_controller.justmet = 0; + obj_controller.check_number = ini_read_real("Controller", "check_number", 0); + obj_controller.year_fraction = ini_read_real("Controller", "year_fraction", 0); + obj_controller.year = ini_read_real("Controller", "year", 0); + obj_controller.millenium = ini_read_real("Controller", "millenium", 0); + // + obj_controller.requisition = ini_read_real("Controller", "req", 0); + // + obj_controller.income = ini_read_real("Controller", "income", 0); + obj_controller.income_last = ini_read_real("Controller", "income_last", 0); + obj_controller.income_base = ini_read_real("Controller", "income_base", 0); + obj_controller.income_home = ini_read_real("Controller", "income_home", 0); + obj_controller.income_forge = ini_read_real("Controller", "income_forge", 0); + obj_controller.income_agri = ini_read_real("Controller", "income_agri", 0); + obj_controller.income_recruiting = ini_read_real("Controller", "income_recruiting", 0); + obj_controller.income_training = ini_read_real("Controller", "income_training", 0); + obj_controller.income_fleet = ini_read_real("Controller", "income_fleet", 0); + obj_controller.income_trade = ini_read_real("Controller", "income_trade", 0); + obj_controller.loyalty = ini_read_real("Controller", "loyalty", 0); + obj_controller.loyalty_hidden = ini_read_real("Controller", "loyalty_hidden", 0); + obj_controller.inqis_flag_lair = ini_read_real("Controller", "flag_lair", 0); + obj_controller.inqis_flag_gene = ini_read_real("Controller", "flag_gene", 0); + obj_controller.gene_seed = ini_read_real("Controller", "gene_seed", 0); + obj_controller.marines = ini_read_real("Controller", "marines", 0); + obj_controller.command = ini_read_real("Controller", "command", 0); + obj_controller.info_chips = ini_read_real("Controller", "info_chips", 0); + obj_controller.inspection_passes = ini_read_real("Controller", "inspection_passes", 0); + obj_controller.recruiting_worlds_bought = ini_read_real("Controller", "recruiting_worlds_bought", 0); + obj_controller.last_weapons_tab = ini_read_real("Controller", "lwt", 1); + // + obj_ini.battle_cry = ini_read_string("Ini", "battle_cry", "Error"); + // obj_ini.fortress_name=ini_read_string("Ini","fortress_name","Error"); + obj_ini.flagship_name = ini_read_string("Ini", "flagship_name", "Error"); + obj_ini.home_name = ini_read_string("Ini", "home_name", "Error"); + obj_ini.home_type = ini_read_string("Ini", "home_type", "Error"); + obj_ini.recruiting_name = ini_read_string("Ini", "recruiting_name", "Error"); + obj_ini.recruiting_type = ini_read_string("Ini", "recruiting_type", "Error"); + + + var tempa, tempa2, q, good; + q = 0; + good = 0; + tempa = ""; + tempa2 = 0; + scr_colors_initialize(); + + tempa = ini_read_string("Controller", "main_color", "Error"); + tempa2 = 0; + q = 0; + good = 0; + repeat(30) { + q += 1; + if (tempa = col[q]) and(good = 0) { + good = q; + tempa2 = q; + } + } + obj_controller.main_color = tempa2; + obj_ini.main_color = tempa2; + + tempa = ini_read_string("Controller", "secondary_color", "Error"); + tempa2 = 0; + q = 0; + good = 0; + repeat(30) { + q += 1; + if (tempa = col[q]) and(good = 0) { + good = q; + tempa2 = q; + } + } + obj_controller.secondary_color = tempa2; + obj_ini.secondary_color = tempa2; + + tempa = ini_read_string("Controller", "trim_color", "Error"); + tempa2 = 0; + q = 0; + good = 0; + repeat(30) { + q += 1; + if (tempa = col[q]) and(good = 0) { + good = q; + tempa2 = q; + } + } + obj_controller.trim_color = tempa2; + obj_ini.trim_color = tempa2; + + tempa = ini_read_string("Controller", "pauldron2_color", "Error"); + tempa2 = 0; + q = 0; + good = 0; + repeat(30) { + q += 1; + if (tempa = col[q]) and(good = 0) { + good = q; + tempa2 = q; + } + } + obj_controller.pauldron2_color = tempa2; + obj_ini.pauldron2_color = tempa2; + + tempa = ini_read_string("Controller", "pauldron_color", "Error"); + tempa2 = 0; + q = 0; + good = 0; + repeat(30) { + q += 1; + if (tempa = col[q]) and(good = 0) { + good = q; + tempa2 = q; + } + } + obj_controller.pauldron_color = tempa2; + obj_ini.pauldron_color = tempa2; + + tempa = ini_read_string("Controller", "lens_color", "Error"); + tempa2 = 0; + q = 0; + good = 0; + repeat(30) { + q += 1; + if (tempa = col[q]) and(good = 0) { + good = q; + tempa2 = q; + } + } + obj_controller.lens_color = tempa2; + obj_ini.lens_color = tempa2; + + tempa = ini_read_string("Controller", "weapon_color", "Error"); + tempa2 = 0; + q = 0; + good = 0; + repeat(30) { + q += 1; + if (tempa = col[q]) and(good = 0) { + good = q; + tempa2 = q; + } + } + obj_controller.weapon_color = tempa2; + obj_ini.weapon_color = tempa2; + + obj_controller.col_special = ini_read_real("Controller", "col_special", 0); + obj_ini.col_special = obj_controller.col_special; + obj_controller.trim = ini_read_real("Controller", "trimmed", 0); + obj_ini.trim = obj_controller.trim; + obj_ini.skin_color = ini_read_real("Controller", "skin_color", 0); + obj_controller.skin_color = obj_ini.skin_color; + + obj_ini.adept_name = ini_read_string("Controller", "adept_name", "Error"); + obj_ini.recruiter_name = ini_read_string("Controller", "recruiter_name", "Error"); + // obj_ini.progenitor=ini_read_string("Controller","progenitor","Error"); + obj_ini.mutation = ini_read_string("Controller", "mutation", "Error"); + obj_ini.successor_chapters = ini_read_real("Controller", "successors", 0); + obj_ini.progenitor_disposition = ini_read_real("Controller", "progenitor_disposition", 0); + obj_ini.imperium_disposition = ini_read_real("Controller", "imperium_disposition", 0); + obj_controller.astartes_disposition = ini_read_real("Controller", "astartes_disposition", 0); + + obj_controller.bat_devastator_column = ini_read_real("Controller", "bat_devastator_column", 1); + obj_controller.bat_assault_column = ini_read_real("Controller", "bat_assault_column", 4); + obj_controller.bat_tactical_column = ini_read_real("Controller", "bat_tactical_column", 2); + obj_controller.bat_veteran_column = ini_read_real("Controller", "bat_veteran_column", 2); + obj_controller.bat_hire_column = ini_read_real("Controller", "bat_hire_column", 3); + obj_controller.bat_librarian_column = ini_read_real("Controller", "bat_librarian_column", 3); + obj_controller.bat_command_column = ini_read_real("Controller", "bat_command_column", 3); + obj_controller.bat_techmarine_column = ini_read_real("Controller", "bat_techmarine_column", 3); + obj_controller.bat_terminator_column = ini_read_real("Controller", "bat_terminator_column", 3); + obj_controller.bat_honor_column = ini_read_real("Controller", "bat_honor_column", 3); + obj_controller.bat_dreadnought_column = ini_read_real("Controller", "bat_dreadnought_column", 5); + obj_controller.bat_rhino_column = ini_read_real("Controller", "bat_rhino_column", 6); + obj_controller.bat_predator_column = ini_read_real("Controller", "bat_preadtor_column", 7); + obj_controller.bat_landraiders_column = ini_read_real("Controller", "bat_landraiders_column", 7); + obj_controller.bat_scout_column = ini_read_real("Controller", "bat_scout_column", 1); + + ini_close(); + } + + + if (argument0 = 2) or(argument0 = 0) { + debugl("Loading slot " + string(argument1) + " part 2"); + ini_open("tsave.ini"); + + stars = ini_read_real("Save", "stars", 0); + + // Stars + var i; + i = -1; + repeat(stars) { + i += 1; + var new_star; + new_star = instance_create(0, 0, obj_star); + + new_star.name = ini_read_string("Star", "sr" + string(i) + "name", ""); + new_star.star = ini_read_string("Star", "sr" + string(i) + "star", ""); + new_star.planets = ini_read_real("Star", "sr" + string(i) + "planets", 0); + new_star.owner = ini_read_real("Star", "sr" + string(i) + "owner", 0); + new_star.x = ini_read_real("Star", "sr" + string(i) + "x", 0); + new_star.y = ini_read_real("Star", "sr" + string(i) + "y", 0); + new_star.x2 = ini_read_real("Star", "sr" + string(i) + "x2", 0); + new_star.y2 = ini_read_real("Star", "sr" + string(i) + "y2", 0); + new_star.old_x = ini_read_real("Star", "sr" + string(i) + "ox", 0); + new_star.old_y = ini_read_real("Star", "sr" + string(i) + "oy", 0); + + new_star.vision = ini_read_real("Star", "sr" + string(i) + "vision", 1); + new_star.storm = ini_read_real("Star", "sr" + string(i) + "storm", 0); + new_star.trader = ini_read_real("Star", "sr" + string(i) + "trader", 0); + new_star.craftworld = ini_read_real("Star", "sr" + string(i) + "craftworld", 0); + new_star.space_hulk = ini_read_real("Star", "sr" + string(i) + "spacehulk", 0); + if (new_star.space_hulk = 1) then new_star.sprite_index = spr_star_hulk; + + var g; + g = 0; + repeat(4) { + g += 1; + if (new_star.planets >= g) { + new_star.planet[g] = ini_read_real("Star", "sr" + string(i) + "plan" + string(g), 0); + new_star.dispo[g] = ini_read_real("Star", "sr" + string(i) + "dispo" + string(g), -10); + new_star.p_type[g] = ini_read_string("Star", "sr" + string(i) + "type" + string(g), ""); + new_star.p_feature[g] = []; + var p_features = ini_read_string("Star", "sr" + string(i) + "feat" + string(g), ""); + if (p_features != "") { + var p_features = json_parse(base64_decode(p_features)); + for (var feat = 0; feat < array_length(p_features); feat++) { + var new_feat = new new_planet_feature(p_features[feat].f_type); + new_feat.load_json_data(p_features[feat]); + array_push(new_star.p_feature[g], new_feat); + } + } + new_star.p_owner[g] = ini_read_real("Star", "sr" + string(i) + "own" + string(g), 0); + new_star.p_first[g] = ini_read_real("Star", "sr" + string(i) + "fir" + string(g), 0); + new_star.p_population[g] = ini_read_real("Star", "sr" + string(i) + "popul" + string(g), 0); + new_star.p_max_population[g] = ini_read_real("Star", "sr" + string(i) + "maxpop" + string(g), 0); + new_star.p_large[g] = ini_read_real("Star", "sr" + string(i) + "large" + string(g), 0); + new_star.p_pop[g] = ini_read_string("Star", "sr" + string(i) + "pop" + string(g), ""); + new_star.p_guardsmen[g] = ini_read_real("Star", "sr" + string(i) + "guard" + string(g), 0); + new_star.p_pdf[g] = ini_read_real("Star", "sr" + string(i) + "pdf" + string(g), 0); + new_star.p_fortified[g] = ini_read_real("Star", "sr" + string(i) + "forti" + string(g), 0); + new_star.p_station[g] = ini_read_real("Star", "sr" + string(i) + "stat" + string(g), 0); + + new_star.p_player[g] = ini_read_real("Star", "sr" + string(i) + "play" + string(g), 0); + new_star.p_lasers[g] = ini_read_real("Star", "sr" + string(i) + "p_lasers" + string(g), 0); + new_star.p_silo[g] = ini_read_real("Star", "sr" + string(i) + "p_silo" + string(g), 0); + new_star.p_defenses[g] = ini_read_real("Star", "sr" + string(i) + "p_defenses" + string(g), 0); + new_star.p_upgrades[g] = []; + var p_upgrades = ini_read_string("Star", "sr" + string(i) + "upg" + string(g), ""); + if (p_upgrades != "") { + var p_upgrades = json_parse(base64_decode(p_upgrades)); + for (var feat = 0; feat < array_length(p_upgrades); feat++) { + var new_feat = new new_planet_feature(p_upgrades[feat].f_type); + new_feat.load_json_data(p_upgrades[feat]); + array_push(new_star.p_upgrades[g], new_feat); + } + } + + new_star.p_orks[g] = ini_read_real("Star", "sr" + string(i) + "or" + string(g), 0); + new_star.p_tau[g] = ini_read_real("Star", "sr" + string(i) + "ta" + string(g), 0); + new_star.p_eldar[g] = ini_read_real("Star", "sr" + string(i) + "el" + string(g), 0); + new_star.p_traitors[g] = ini_read_real("Star", "sr" + string(i) + "tr" + string(g), 0); + new_star.p_chaos[g] = ini_read_real("Star", "sr" + string(i) + "ch" + string(g), 0); + new_star.p_demons[g] = ini_read_real("Star", "sr" + string(i) + "de" + string(g), 0); + new_star.p_sisters[g] = ini_read_real("Star", "sr" + string(i) + "si" + string(g), 0); + new_star.p_necrons[g] = ini_read_real("Star", "sr" + string(i) + "ne" + string(g), 0); + new_star.p_tyranids[g] = ini_read_real("Star", "sr" + string(i) + "tyr" + string(g), 0); + new_star.p_halp[g] = ini_read_real("Star", "sr" + string(i) + "halp" + string(g), 0); + + new_star.p_heresy[g] = ini_read_real("Star", "sr" + string(i) + "heresy" + string(g), 0); + new_star.p_hurssy[g] = ini_read_real("Star", "sr" + string(i) + "hurssy" + string(g), 0); + new_star.p_hurssy_time[g] = ini_read_real("Star", "sr" + string(i) + "hurssy_time" + string(g), 0); + new_star.p_heresy_secret[g] = ini_read_real("Star", "sr" + string(i) + "heresy_secret" + string(g), 0); + new_star.p_influence[g] = ini_read_real("Star", "sr" + string(i) + "influence" + string(g), 0); + new_star.p_raided[g] = ini_read_real("Star", "sr" + string(i) + "raided" + string(g), 0); + new_star.p_problem[g, 1] = ini_read_string("Star", "sr" + string(i) + "prob" + string(g) + ".1", ""); + new_star.p_timer[g, 1] = ini_read_real("Star", "sr" + string(i) + "time" + string(g) + ".1", 0); + new_star.p_problem[g, 2] = ini_read_string("Star", "sr" + string(i) + "prob" + string(g) + ".2", ""); + new_star.p_timer[g, 2] = ini_read_real("Star", "sr" + string(i) + "time" + string(g) + ".2", 0); + new_star.p_problem[g, 3] = ini_read_string("Star", "sr" + string(i) + "prob" + string(g) + ".3", ""); + new_star.p_timer[g, 3] = ini_read_real("Star", "sr" + string(i) + "time" + string(g) + ".3", 0); + new_star.p_problem[g, 4] = ini_read_string("Star", "sr" + string(i) + "prob" + string(g) + ".4", ""); + new_star.p_timer[g, 4] = ini_read_real("Star", "sr" + string(i) + "time" + string(g) + ".4", 0); + } + } + } + + // obj_ini + obj_ini.home_name = ini_read_string("Ini", "home_name", "Error"); + obj_ini.home_type = ini_read_string("Ini", "home_type", "Error"); + obj_ini.recruiting_name = ini_read_string("Ini", "recruiting_name", "Error"); + obj_ini.recruiting_type = ini_read_string("Ini", "recruiting_type", "Error"); + obj_ini.chapter_name = ini_read_string("Ini", "chapter_name", "Error"); + obj_ini.fortress_name = ini_read_string("Ini", "fortress_name", "Error"); + obj_ini.flagship_name = ini_read_string("Ini", "flagship_name", "Error"); + obj_ini.icon = ini_read_real("Ini", "icon", 0); + obj_ini.icon_name = ini_read_string("Ini", "icon_name", "custom1"); + global.icon_name = obj_ini.icon_name; + obj_ini.man_size = ini_read_real("Ini", "man_size", 0); + obj_ini.strin = ini_read_string("Ini", "strin1", ""); + obj_ini.strin2 = ini_read_string("Ini", "strin2", ""); + obj_ini.psy_powers = ini_read_string("Ini", "psy_powers", "default"); + + obj_ini.companies = ini_read_real("Ini", "companies", 10); + var i; + i = -1; + repeat(21) { + i += 1; + obj_ini.company_title[i] = ini_read_string("Ini", "comp_title" + string(i), ""); + } + var i; + i = -1; + repeat(121) { + i += 1; + obj_ini.slave_batch_num[i] = ini_read_real("Ini", "slave_num_" + string(i), 0); + obj_ini.slave_batch_eta[i] = ini_read_real("Ini", "slave_eta_" + string(i), 0); + } + + obj_ini.master_autarch = ini_read_real("Ini", "master_autarch", 0); + obj_ini.master_avatar = ini_read_real("Ini", "master_avatar", 0); + obj_ini.master_farseer = ini_read_real("Ini", "master_farseer", 0); + obj_ini.master_aspect = ini_read_real("Ini", "master_aspect", 0); + obj_ini.master_eldar = ini_read_real("Ini", "master_eldar", 0); + obj_ini.master_eldar_vehicles = ini_read_real("Ini", "master_eldar_vehicles", 0); + obj_ini.master_tau = ini_read_real("Ini", "master_tau", 0); + obj_ini.master_battlesuits = ini_read_real("Ini", "master_battlesuits", 0); + obj_ini.master_kroot = ini_read_real("Ini", "master_kroot", 0); + obj_ini.master_tau_vehicles = ini_read_real("Ini", "master_tau_vehicles", 0); + obj_ini.master_ork_boyz = ini_read_real("Ini", "master_ork_boyz", 0); + obj_ini.master_ork_nobz = ini_read_real("Ini", "master_ork_nobz", 0); + obj_ini.master_ork_warboss = ini_read_real("Ini", "master_ork_warboss", 0); + obj_ini.master_ork_vehicles = ini_read_real("Ini", "master_ork_vehicles", 0); + obj_ini.master_heretics = ini_read_real("Ini", "master_heretics", 0); + obj_ini.master_chaos_marines = ini_read_real("Ini", "master_chaos_marines", 0); + obj_ini.master_lesser_demons = ini_read_real("Ini", "master_lesser_demons", 0); + obj_ini.master_greater_demons = ini_read_real("Ini", "master_greater_demons", 0); + obj_ini.master_chaos_vehicles = ini_read_real("Ini", "master_chaos_vehicles", 0); + obj_ini.master_gaunts = ini_read_real("Ini", "master_gaunts", 0); + obj_ini.master_warriors = ini_read_real("Ini", "master_warriors", 0); + obj_ini.master_carnifex = ini_read_real("Ini", "master_carnifex", 0); + obj_ini.master_synapse = ini_read_real("Ini", "master_synapse", 0); + obj_ini.master_tyrant = ini_read_real("Ini", "master_tyrant", 0); + obj_ini.master_gene = ini_read_real("Ini", "master_gene", 0); + obj_ini.master_necron_overlord = ini_read_real("Ini", "master_necron_overlord", 0); + obj_ini.master_destroyer = ini_read_real("Ini", "master_destroyer", 0); + obj_ini.master_necron = ini_read_real("Ini", "master_necron", 0); + obj_ini.master_wraith = ini_read_real("Ini", "master_wraith", 0); + obj_ini.master_necron_vehicles = ini_read_real("Ini", "master_necron_vehicles", 0); + obj_ini.master_monolith = ini_read_real("Ini", "master_monolith", 0); + obj_ini.master_special_killed = ini_read_string("Ini", "master_special", ""); + // + obj_ini.preomnor = ini_read_real("Ini", "preomnor", 0); + obj_ini.voice = ini_read_real("Ini", "voice", 0); + obj_ini.doomed = ini_read_real("Ini", "doomed", 0); + obj_ini.lyman = ini_read_real("Ini", "lyman", 0); + obj_ini.omophagea = ini_read_real("Ini", "omophagea", 0); + obj_ini.ossmodula = ini_read_real("Ini", "ossmodula", 0); + obj_ini.membrane = ini_read_real("Ini", "membrane", 0); + obj_ini.zygote = ini_read_real("Ini", "zygote", 0); + obj_ini.betchers = ini_read_real("Ini", "betchers", 0); + obj_ini.catalepsean = ini_read_real("Ini", "catalepsean", 0); + obj_ini.secretions = ini_read_real("Ini", "secretions", 0); + obj_ini.occulobe = ini_read_real("Ini", "occulobe", 0); + obj_ini.mucranoid = ini_read_real("Ini", "mucranoid", 0); + // + obj_ini.master_name = ini_read_string("Ini", "master_name", "Error"); + obj_ini.chief_librarian_name = ini_read_string("Ini", "chief_name", "Error"); + obj_ini.high_chaplain_name = ini_read_string("Ini", "high_name", "Error"); + obj_ini.high_apothecary_name = ini_read_string("Ini", "high2_name", "Error"); + obj_ini.forge_master_name = ini_read_string("Ini", "forgey_name", "Error"); + obj_ini.lord_admiral_name = ini_read_string("Ini", "lord_name", "Error"); + // + obj_ini.chaplain_ranged = ini_read_string("Ini", "chaplain_ranged", "Error"); + obj_ini.chaplain_melee = ini_read_string("Ini", "chaplain_melee", "Error"); + obj_ini.apothecary_ranged = ini_read_string("Ini", "apothecary_ranged", "Error"); + obj_ini.apothecary_melee = ini_read_string("Ini", "apothecary_melee", "Error"); + obj_ini.sergeant_ranged = ini_read_string("Ini", "sergeant_ranged", "Error"); + obj_ini.sergeant_melee = ini_read_string("Ini", "sergeant_melee", "Error"); + obj_ini.scout_ranged = ini_read_string("Ini", "scout_ranged", "Error"); + obj_ini.scout_melee = ini_read_string("Ini", "scout_melee", "Error"); + obj_ini.honor_ranged = ini_read_string("Ini", "honor_ranged", "Error"); + obj_ini.honor_melee = ini_read_string("Ini", "honor_melee", "Error"); + obj_ini.honor_mobi = ini_read_string("Ini", "honor_mobi", "Error"); + obj_ini.forbidden_unit1 = ini_read_string("Ini", "forbidden_unit1", "Error"); + obj_ini.forbidden_unit2 = ini_read_string("Ini", "forbidden_unit2", "Error"); + obj_ini.forbidden_unit3 = ini_read_string("Ini", "forbidden_unit3", "Error"); + // + var g; + g = -1; + repeat(150) { + g += 1; + obj_ini.equipment[g] = ini_read_string("Ini", "equipment" + string(g), ""); + obj_ini.equipment_type[g] = ini_read_string("Ini", "equipment_type" + string(g), ""); + obj_ini.equipment_number[g] = ini_read_real("Ini", "equipment_number" + string(g), 0); + obj_ini.equipment_condition[g] = ini_read_real("Ini", "equipment_condition" + string(g), 0); + + if (g <= 20) { + obj_ini.artifact[g] = ini_read_string("Ini", "artifact" + string(g), ""); + obj_ini.artifact_tags[g] = ini_read_string("Ini", "artifact_tags" + string(g), ""); + obj_ini.artifact_identified[g] = ini_read_real("Ini", "artifact_ident" + string(g), 0); + obj_ini.artifact_condition[g] = ini_read_real("Ini", "artifact_condition" + string(g), 0); + obj_ini.artifact_loc[g] = ini_read_string("Ini", "artifact_loc" + string(g), ""); + obj_ini.artifact_sid[g] = ini_read_real("Ini", "artifact_sid" + string(g), 0); + } + } + // + obj_ini.ship_location[0] = ""; + + + if (global.restart = 0) { + var g; + g = -1; + repeat(200) { + g += 1; + obj_ini.ship[g] = ini_read_string("Ships", "shi" + string(g), ""); + obj_ini.ship_uid[g] = ini_read_real("Ships", "shi_uid" + string(g), 0); + obj_ini.ship_class[g] = ini_read_string("Ships", "shi_class" + string(g), ""); + // + obj_ini.ship_size[g] = ini_read_real("Ships", "shi_size" + string(g), 0); + obj_ini.ship_leadership[g] = ini_read_real("Ships", "shi_leadership" + string(g), 0); + obj_ini.ship_hp[g] = ini_read_real("Ships", "shi_hp" + string(g), 0); + obj_ini.ship_maxhp[g] = ini_read_real("Ships", "shi_maxhp" + string(g), 0); + + if (obj_ini.ship_maxhp[g] < 200) and(obj_ini.ship_maxhp[g] != 0) { + obj_ini.ship_hp[g] = obj_ini.ship_hp[g] * 2; + obj_ini.ship_maxhp[g] = obj_ini.ship_maxhp[g] * 2; + } + + obj_ini.ship_location[g] = ini_read_string("Ships", "shi_location" + string(g), ""); + obj_ini.ship_shields[g] = ini_read_real("Ships", "shi_shields" + string(g), 0); + obj_ini.ship_conditions[g] = ini_read_string("Ships", "shi_conditions" + string(g), ""); + obj_ini.ship_speed[g] = ini_read_real("Ships", "shi_speed" + string(g), 0); + obj_ini.ship_turning[g] = ini_read_real("Ships", "shi_turning" + string(g), 0); + obj_ini.ship_front_armour[g] = ini_read_real("Ships", "shi_front_ac" + string(g), 0); + obj_ini.ship_other_armour[g] = ini_read_real("Ships", "shi_other_ac" + string(g), 0); + obj_ini.ship_weapons[g] = ini_read_real("Ships", "shi_weapons" + string(g), 0); + // + obj_ini.ship_wep[g, 1] = ini_read_string("Ships", "shi" + string(g) + "wep1", ""); + obj_ini.ship_facing[g, 1] = ini_read_string("Ships", "shi" + string(g) + "facing1", ""); + obj_ini.ship_condition[g, 1] = ini_read_string("Ships", "shi" + string(g) + "condition1", ""); + obj_ini.ship_wep[g, 2] = ini_read_string("Ships", "shi" + string(g) + "wep2", ""); + obj_ini.ship_facing[g, 2] = ini_read_string("Ships", "shi" + string(g) + "facing2", ""); + obj_ini.ship_condition[g, 2] = ini_read_string("Ships", "shi" + string(g) + "condition2", ""); + obj_ini.ship_wep[g, 3] = ini_read_string("Ships", "shi" + string(g) + "wep3", ""); + obj_ini.ship_facing[g, 3] = ini_read_string("Ships", "shi" + string(g) + "facing3", ""); + obj_ini.ship_condition[g, 3] = ini_read_string("Ships", "shi" + string(g) + "condition3", ""); + obj_ini.ship_wep[g, 4] = ini_read_string("Ships", "shi" + string(g) + "wep4", ""); + obj_ini.ship_facing[g, 4] = ini_read_string("Ships", "shi" + string(g) + "facing4", ""); + obj_ini.ship_condition[g, 4] = ini_read_string("Ships", "shi" + string(g) + "condition4", ""); + obj_ini.ship_wep[g, 5] = ini_read_string("Ships", "shi" + string(g) + "wep5", ""); + obj_ini.ship_facing[g, 5] = ini_read_string("Ships", "shi" + string(g) + "facing5", ""); + obj_ini.ship_condition[g, 5] = ini_read_string("Ships", "shi" + string(g) + "condition5", ""); + // + obj_ini.ship_capacity[g] = ini_read_real("Ships", "shi_capacity" + string(g), 0); + obj_ini.ship_carrying[g] = ini_read_real("Ships", "shi_carrying" + string(g), 0); + obj_ini.ship_contents[g] = ini_read_string("Ships", "shi_contents" + string(g), ""); + obj_ini.ship_turrets[g] = ini_read_real("Ships", "shi_turrets" + string(g), 0); + } + } + // the fun begins here + ini_close(); + } + + + + + if (argument0 = 3) or(argument0 = 0) { + debugl("Loading slot " + string(argument1) + " part 3"); + ini_open("tsave.ini"); + + var coh, mah, good; + good = 0; + coh = 100; + mah = -1; + + if (global.restart = 0) { + var coh, mah, good; + good = 0; + coh = 10; + mah = 205; + repeat(2255) { + if (good = 0) { + mah -= 1; + if (mah = 0) { + mah = 205; + coh -= 1; + } + obj_ini.veh_race[coh, mah] = ini_read_real("Veh", "co" + string(coh) + "." + string(mah), 0); + obj_ini.veh_loc[coh, mah] = ini_read_string("Veh", "lo" + string(coh) + "." + string(mah), ""); + obj_ini.veh_role[coh, mah] = ini_read_string("Veh", "rol" + string(coh) + "." + string(mah), ""); // temp_name; + obj_ini.veh_lid[coh, mah] = ini_read_real("Veh", "lid" + string(coh) + "." + string(mah), 0); + obj_ini.veh_uid[coh, mah] = ini_read_real("Veh", "uid" + string(coh) + "." + string(mah), 0); + obj_ini.veh_wid[coh, mah] = ini_read_real("Veh", "wid" + string(coh) + "." + string(mah), 0); + + obj_ini.veh_wep1[coh, mah] = ini_read_string("Veh", "w1" + string(coh) + "." + string(mah), ""); + obj_ini.veh_wep2[coh, mah] = ini_read_string("Veh", "w2" + string(coh) + "." + string(mah), ""); + obj_ini.veh_wep3[coh, mah] = ini_read_string("Veh", "w3" + string(coh) + "." + string(mah), ""); + obj_ini.veh_upgrade[coh, mah] = ini_read_string("Veh", "up" + string(coh) + "." + string(mah), ""); + obj_ini.veh_acc[coh, mah] = ini_read_string("Veh", "ac" + string(coh) + "." + string(mah), ""); + + obj_ini.veh_hp[coh, mah] = ini_read_real("Veh", "hp" + string(coh) + "." + string(mah), 0); + obj_ini.veh_chaos[coh, mah] = ini_read_real("Veh", "cha" + string(coh) + "." + string(mah), 0); + if (coh = 1) and(mah = 1) then good = 1; + } + } + + var coh, mah, good; + good = 0; + coh = 100; + mah = -1; + repeat(31) { + mah += 1; + obj_ini.race[coh, mah] = ini_read_real("Mar", "co" + string(coh) + "." + string(mah), 0); + obj_ini.name[coh, mah] = ini_read_string("Mar", "num" + string(coh) + "." + string(mah), ""); + obj_ini.role[coh, mah] = ini_read_string("Mar", "rol" + string(coh) + "." + string(mah), ""); + obj_ini.wep1[coh, mah] = ini_read_string("Mar", "w1" + string(coh) + "." + string(mah), ""); + obj_ini.wep2[coh, mah] = ini_read_string("Mar", "w2" + string(coh) + "." + string(mah), ""); + obj_ini.armour[coh, mah] = ini_read_string("Mar", "ar" + string(coh) + "." + string(mah), ""); + obj_ini.gear[coh, mah] = ini_read_string("Mar", "ge" + string(coh) + "." + string(mah), ""); + obj_ini.mobi[coh, mah] = ini_read_string("Mar", "mb" + string(coh) + "." + string(mah), ""); + } + for (coh = 0; coh <= 10; coh++) { + for (mah = 0; mah <= 500; mah++) { + obj_ini.race[coh, mah] = ini_read_real("Mar", "co" + string(coh) + "." + string(mah), 0); + obj_ini.loc[coh, mah] = ini_read_string("Mar", "lo" + string(coh) + "." + string(mah), ""); + obj_ini.name[coh, mah] = ini_read_string("Mar", "num" + string(coh) + "." + string(mah), ""); + obj_ini.role[coh, mah] = ini_read_string("Mar", "rol" + string(coh) + "." + string(mah), ""); // temp_name; + obj_ini.lid[coh, mah] = ini_read_real("Mar", "li" + string(coh) + "." + string(mah), 0); + obj_ini.bio[coh, mah] = ini_read_real("Mar", "bio" + string(coh) + "." + string(mah), 0); + obj_ini.wid[coh, mah] = ini_read_real("Mar", "wi" + string(coh) + "." + string(mah), 0); + + if (coh = 0) { + if (obj_ini.role[coh, mah] = "Chapter Master") { + obj_ini.race[coh, mah] = 1; + } else if (obj_ini.role[coh, mah] = "Master of Sanctity") { + obj_ini.race[coh, mah] = 1; + } else if (obj_ini.role[coh, mah] = "Master of the Apothecarion") { + obj_ini.race[coh, mah] = 1; + } else if (obj_ini.role[coh, mah] = "Forge Master") then obj_ini.race[coh, mah] = 1; + if (string_count("Chief", obj_ini.role[coh, mah]) > 0) then obj_ini.race[coh, mah] = 1; } - obj_ini.wep1[coh,mah]=ini_read_string("Mar","w1"+string(coh)+"."+string(mah),""); - obj_ini.wep2[coh,mah]=ini_read_string("Mar","w2"+string(coh)+"."+string(mah),""); - obj_ini.armour[coh,mah]=ini_read_string("Mar","ar"+string(coh)+"."+string(mah),""); - obj_ini.gear[coh,mah]=ini_read_string("Mar","ge"+string(coh)+"."+string(mah),""); - obj_ini.mobi[coh,mah]=ini_read_string("Mar","mb"+string(coh)+"."+string(mah),""); - - var arc,teh,teh2;arc=0;teh="";teh2="";// Give daemon weapons their dialogue lines - for (arc=1;arc<6;arc++){ - teh2=choose("Daemonic1a|","Daemonic2a|","Daemonic3a|","Daemonic4a|"); - if (arc=1) then teh=obj_ini.wep1[coh,mah]; - if (arc=2) then teh=obj_ini.wep2[coh,mah]; - if (arc=3) then teh=obj_ini.armour[coh,mah]; - if (arc=4) then teh=obj_ini.gear[coh,mah]; - if (arc=5) then teh=obj_ini.mobi[coh,mah]; - if (string_pos("&",teh)>0){ - if (string_count("Daemonic|",teh)>0) then teh=string_replace(teh,"Daemonic|",teh2); - if (arc=1) then obj_ini.wep1[coh,mah]=teh; - if (arc=2) then obj_ini.wep2[coh,mah]=teh; - if (arc=3) then obj_ini.armour[coh,mah]=teh; - if (arc=4) then obj_ini.gear[coh,mah]=teh; - if (arc=5) then obj_ini.mobi[coh,mah]=teh; + obj_ini.wep1[coh, mah] = ini_read_string("Mar", "w1" + string(coh) + "." + string(mah), ""); + obj_ini.wep2[coh, mah] = ini_read_string("Mar", "w2" + string(coh) + "." + string(mah), ""); + obj_ini.armour[coh, mah] = ini_read_string("Mar", "ar" + string(coh) + "." + string(mah), ""); + obj_ini.gear[coh, mah] = ini_read_string("Mar", "ge" + string(coh) + "." + string(mah), ""); + obj_ini.mobi[coh, mah] = ini_read_string("Mar", "mb" + string(coh) + "." + string(mah), ""); + + var arc, teh, teh2; + arc = 0; + teh = ""; + teh2 = ""; // Give daemon weapons their dialogue lines + for (arc = 1; arc < 6; arc++) { + teh2 = choose("Daemonic1a|", "Daemonic2a|", "Daemonic3a|", "Daemonic4a|"); + if (arc = 1) then teh = obj_ini.wep1[coh, mah]; + if (arc = 2) then teh = obj_ini.wep2[coh, mah]; + if (arc = 3) then teh = obj_ini.armour[coh, mah]; + if (arc = 4) then teh = obj_ini.gear[coh, mah]; + if (arc = 5) then teh = obj_ini.mobi[coh, mah]; + if (string_pos("&", teh) > 0) { + if (string_count("Daemonic|", teh) > 0) then teh = string_replace(teh, "Daemonic|", teh2); + if (arc = 1) then obj_ini.wep1[coh, mah] = teh; + if (arc = 2) then obj_ini.wep2[coh, mah] = teh; + if (arc = 3) then obj_ini.armour[coh, mah] = teh; + if (arc = 4) then obj_ini.gear[coh, mah] = teh; + if (arc = 5) then obj_ini.mobi[coh, mah] = teh; } } - obj_ini.hp[coh,mah]=ini_read_real("Mar","hp"+string(coh)+"."+string(mah),0); - obj_ini.chaos[coh,mah]=ini_read_real("Mar","cha"+string(coh)+"."+string(mah),0); - obj_ini.experience[coh,mah]=ini_read_real("Mar","exp"+string(coh)+"."+string(mah),0); - obj_ini.age[coh,mah]=ini_read_real("Mar","ag"+string(coh)+"."+string(mah),0); - obj_ini.spe[coh,mah]=ini_read_string("Mar","spe"+string(coh)+"."+string(mah),""); - obj_ini.god[coh,mah]=ini_read_real("Mar","god"+string(coh)+"."+string(mah),0); - load_marine_struct(coh,mah); - } - } - - - if (string_count(obj_ini.spe[0,1],"$")>0) then obj_controller.born_leader=1; - - coh=100;mah=-1; - repeat(21){mah+=1; - obj_ini.race[coh,mah]=ini_read_real("Mar","co"+string(coh)+"."+string(mah),0); - obj_ini.role[coh,mah]=ini_read_string("Mar","rol"+string(coh)+"."+string(mah),""); - obj_ini.wep1[coh,mah]=ini_read_string("Mar","w1"+string(coh)+"."+string(mah),""); - obj_ini.wep2[coh,mah]=ini_read_string("Mar","w2"+string(coh)+"."+string(mah),""); - obj_ini.armour[coh,mah]=ini_read_string("Mar","ar"+string(coh)+"."+string(mah),""); - obj_ini.gear[coh,mah]=ini_read_string("Mar","ge"+string(coh)+"."+string(mah),""); - obj_ini.mobi[coh,mah]=ini_read_string("Mar","mb"+string(coh)+"."+string(mah),""); - } - coh=102;mah=-1; - repeat(21){mah+=1; - obj_ini.race[coh,mah]=ini_read_string("Mar","co"+string(coh)+"."+string(mah),0); - obj_ini.role[coh,mah]=ini_read_string("Mar","rol"+string(coh)+"."+string(mah),""); - obj_ini.wep1[coh,mah]=ini_read_string("Mar","w1"+string(coh)+"."+string(mah),""); - obj_ini.wep2[coh,mah]=ini_read_string("Mar","w2"+string(coh)+"."+string(mah),""); - obj_ini.armour[coh,mah]=ini_read_string("Mar","ar"+string(coh)+"."+string(mah),""); - obj_ini.gear[coh,mah]=ini_read_string("Mar","ge"+string(coh)+"."+string(mah),""); - obj_ini.mobi[coh,mah]=ini_read_string("Mar","mb"+string(coh)+"."+string(mah),""); - } - - obj_ini.squads = []; - var squad_fetch = ini_read_string("Mar","squads",""); - if (squad_fetch != ""){ - squad_fetch = json_parse(base64_decode(squad_fetch)); - for (i=0;i0) then sprite_index=spr_fleet_civilian; - if (owner=3) then sprite_index=spr_fleet_mechanicus; - if (owner=4) and (string_count("_fleet",trade_goods)>0) and (target>0){ - target=instance_nearest(target_x,target_y,obj_p_fleet); - } - if (owner=4) then sprite_index=spr_fleet_inquisition; - if (owner=6) then sprite_index=spr_fleet_eldar; - if (owner=7) then sprite_index=spr_fleet_ork; - if (owner=8) then sprite_index=spr_fleet_tau; - if (owner=9) then sprite_index=spr_fleet_tyranid; - if (owner=10) then sprite_index=spr_fleet_chaos; - image_speed=0; - } - - - - if (file_exists("save"+string(argument1)+"log.ini")){ - // ini_open("save"+string(argument1)+"log.ini"); - ini_open("tsave.ini"); - - var g,bobby,bobby2,stars;bobby="";bobby2="";g=0; - stars=ini_read_real("Save","stars",0); - bobby+=string(stars)+"|"; - bobby+=string(global.chapter_name)+"|"; - bobby+=string(obj_ini.sector_name)+"|"; - bobby+=string(obj_controller.turn)+"|"; - g=ini_read_real("Save","sod",0); - ini_close();file_delete("tsave.ini"); - bobby+=string(g)+"|"; - - ini_open("save"+string(argument1)+"log.ini"); - bobby2=string(ini_read_real("Main","data1",random(500)))+"|"; - bobby2+=ini_read_string("Main","data2","error")+"|"; - bobby2+=ini_read_string("Main","data3","error")+"|"; - bobby2+=string(ini_read_real("Main","data4",random(500)))+"|"; - bobby2+=string(ini_read_real("Main","data5",random(500)))+"|"; - - // show_message(string(bobby)+" - "+string(bobby2)); - // window_set_fullscreen(true); - - if (bobby=bobby2) then obj_controller.good_log=1; - instance_create(-100,-100,obj_event_log); - - with(obj_all_fleet){ - alarm[11]=10; - } - - ini_close(); - } - - obj_saveload.alarm[1]=30; - obj_controller.invis=false; - global.load=0; - debugl("Loading slot "+string(argument1)+" completed"); - } - - -} + obj_ini.hp[coh, mah] = ini_read_real("Mar", "hp" + string(coh) + "." + string(mah), 0); + obj_ini.chaos[coh, mah] = ini_read_real("Mar", "cha" + string(coh) + "." + string(mah), 0); + obj_ini.experience[coh, mah] = ini_read_real("Mar", "exp" + string(coh) + "." + string(mah), 0); + obj_ini.age[coh, mah] = ini_read_real("Mar", "ag" + string(coh) + "." + string(mah), 0); + obj_ini.spe[coh, mah] = ini_read_string("Mar", "spe" + string(coh) + "." + string(mah), ""); + obj_ini.god[coh, mah] = ini_read_real("Mar", "god" + string(coh) + "." + string(mah), 0); + load_marine_struct(coh, mah); + } + } + + + if (string_count(obj_ini.spe[0, 1], "$") > 0) then obj_controller.born_leader = 1; + + coh = 100; + mah = -1; + repeat(21) { + mah += 1; + obj_ini.race[coh, mah] = ini_read_real("Mar", "co" + string(coh) + "." + string(mah), 0); + obj_ini.role[coh, mah] = ini_read_string("Mar", "rol" + string(coh) + "." + string(mah), ""); + obj_ini.wep1[coh, mah] = ini_read_string("Mar", "w1" + string(coh) + "." + string(mah), ""); + obj_ini.wep2[coh, mah] = ini_read_string("Mar", "w2" + string(coh) + "." + string(mah), ""); + obj_ini.armour[coh, mah] = ini_read_string("Mar", "ar" + string(coh) + "." + string(mah), ""); + obj_ini.gear[coh, mah] = ini_read_string("Mar", "ge" + string(coh) + "." + string(mah), ""); + obj_ini.mobi[coh, mah] = ini_read_string("Mar", "mb" + string(coh) + "." + string(mah), ""); + } + coh = 102; + mah = -1; + repeat(21) { + mah += 1; + obj_ini.race[coh, mah] = ini_read_string("Mar", "co" + string(coh) + "." + string(mah), 0); + obj_ini.role[coh, mah] = ini_read_string("Mar", "rol" + string(coh) + "." + string(mah), ""); + obj_ini.wep1[coh, mah] = ini_read_string("Mar", "w1" + string(coh) + "." + string(mah), ""); + obj_ini.wep2[coh, mah] = ini_read_string("Mar", "w2" + string(coh) + "." + string(mah), ""); + obj_ini.armour[coh, mah] = ini_read_string("Mar", "ar" + string(coh) + "." + string(mah), ""); + obj_ini.gear[coh, mah] = ini_read_string("Mar", "ge" + string(coh) + "." + string(mah), ""); + obj_ini.mobi[coh, mah] = ini_read_string("Mar", "mb" + string(coh) + "." + string(mah), ""); + } + + obj_ini.squads = []; + var squad_fetch = ini_read_string("Mar", "squads", ""); + if (squad_fetch != "") { + squad_fetch = json_parse(base64_decode(squad_fetch)); + for (i = 0; i < array_length(squad_fetch); i++) { + array_push(obj_ini.squads, new unit_squad()); + obj_ini.squads[i].load_json_data(json_parse(squad_fetch[i])); + } + } + + obj_ini.squad_types = json_parse(base64_decode(ini_read_string("Mar", "squad_types", ""))); + + } + + + ini_close(); + } + + + + if (argument0 = 4) or(argument0 = 0) { + debugl("Loading slot " + string(argument1) + " part 4"); // PLAYER FLEET OBJECTS + ini_open("tsave.ini"); + + var num, i, fla; + // Temporary artifact objects + num = ini_read_real("Controller", "temp_arti", 0); + i = -1; + fla = 0; + repeat(num) { + i += 1; + fla = instance_create(0, 0, obj_temp_arti); + fla.x = ini_read_real("Star", "ar" + string(i) + "x", 0); + fla.y = ini_read_real("Star", "ar" + string(i) + "y", 0); + } + + num = ini_read_real("Save", "p_fleets", 0); + i = -1; + fla = 0; + + repeat(num) { + i += 1; + fla = instance_create(0, 0, obj_p_fleet); + fla.image_index = ini_read_real("Fleet", "pf" + string(i) + "image", 0); + fla.x = ini_read_real("Fleet", "pf" + string(i) + "x", 0); + fla.y = ini_read_real("Fleet", "pf" + string(i) + "y", 0); + fla.capital_number = ini_read_real("Fleet", "pf" + string(i) + "capitals", 0); + fla.frigate_number = ini_read_real("Fleet", "pf" + string(i) + "frigates", 0); + fla.escort_number = ini_read_real("Fleet", "pf" + string(i) + "escorts", 0); + fla.selected = ini_read_real("Fleet", "pf" + string(i) + "selected", 0); + fla.capital_health = ini_read_real("Fleet", "pf" + string(i) + "capital_hp", 0); + fla.frigate_health = ini_read_real("Fleet", "pf" + string(i) + "frigate_hp", 0); + fla.escort_health = ini_read_real("Fleet", "pf" + string(i) + "escort_hp", 0); + fla.action = ini_read_string("Fleet", "pf" + string(i) + "action", ""); + fla.action_x = ini_read_real("Fleet", "pf" + string(i) + "action_x", 0); + fla.action_y = ini_read_real("Fleet", "pf" + string(i) + "action_y", 0); + fla.action_spd = ini_read_real("Fleet", "pf" + string(i) + "action_spd", 0); + fla.action_eta = ini_read_real("Fleet", "pf" + string(i) + "action_eta", 0); + // fla.connected=ini_read_real("Fleet","pf"+string(i)+"",0); + fla.acted = ini_read_real("Fleet", "pf" + string(i) + "acted", 0); + fla.hurssy = ini_read_real("Fleet", "pf" + string(i) + "hurssy", 0); + fla.hurssy_time = ini_read_real("Fleet", "pf" + string(i) + "hurssy_time", 0); + fla.orbiting = ini_read_real("Fleet", "pf" + string(i) + "orb", 0); + + var g; + g = -1; + repeat(10) { + g += 1; + fla.capital[g] = ini_read_string("Fleet", "pf" + string(i) + "capital" + string(g), ""); + fla.capital_num[g] = ini_read_real("Fleet", "pf" + string(i) + "capital_num" + string(g), 0); + fla.capital_sel[g] = ini_read_real("Fleet", "pf" + string(i) + "capital_sel" + string(g), 0); + fla.capital_uid[g] = ini_read_real("Fleet", "pf" + string(i) + "capital_uid" + string(g), 0); + } + g = -1; + repeat(21) { + g += 1; + fla.frigate[g] = ini_read_string("Fleet", "pf" + string(i) + "frigate" + string(g), ""); + fla.frigate_num[g] = ini_read_real("Fleet", "pf" + string(i) + "frigate_num" + string(g), 0); + fla.frigate_sel[g] = ini_read_real("Fleet", "pf" + string(i) + "frigate_sel" + string(g), 0); + fla.frigate_uid[g] = ini_read_real("Fleet", "pf" + string(i) + "frigate_uid" + string(g), 0); + } + g = -1; + repeat(35) { + g += 1; + fla.escort[g] = ini_read_string("Fleet", "pf" + string(i) + "escort" + string(g), ""); + fla.escort_num[g] = ini_read_real("Fleet", "pf" + string(i) + "escort_num" + string(g), 0); + fla.escort_sel[g] = ini_read_real("Fleet", "pf" + string(i) + "escort_sel" + string(g), 0); + fla.escort_uid[g] = ini_read_real("Fleet", "pf" + string(i) + "escort_uid" + string(g), 0); + } + } + + // ENEMY FLEET OBJECTS + num = ini_read_real("Save", "en_fleets", 0); + i = -1; + fla = 0; + + repeat(num) { + i += 1; + fla = instance_create(0, 0, obj_en_fleet); + fla.owner = ini_read_real("Fleet", "ef" + string(i) + "owner", 0); + fla.x = ini_read_real("Fleet", "ef" + string(i) + "x", 0); + fla.y = ini_read_real("Fleet", "ef" + string(i) + "y", 0); + fla.sprite_index = ini_read_real("Fleet", "ef" + string(i) + "sprite", 0); + fla.image_index = ini_read_real("Fleet", "ef" + string(i) + "image", 0); + fla.image_alpha = ini_read_real("Fleet", "ef" + string(i) + "alpha", 1); + fla.capital_number = ini_read_real("Fleet", "ef" + string(i) + "capitals", 0); + fla.frigate_number = ini_read_real("Fleet", "ef" + string(i) + "frigates", 0); + fla.escort_number = ini_read_real("Fleet", "ef" + string(i) + "escorts", 0); + fla.selected = ini_read_real("Fleet", "ef" + string(i) + "selected", 0); + fla.action = ini_read_string("Fleet", "ef" + string(i) + "action", ""); + fla.action_x = ini_read_real("Fleet", "ef" + string(i) + "action_x", 0); + fla.action_y = ini_read_real("Fleet", "ef" + string(i) + "action_y", 0); + fla.home_x = ini_read_real("Fleet", "ef" + string(i) + "home_x", 0); + fla.home_y = ini_read_real("Fleet", "ef" + string(i) + "home_y", 0); + fla.target = ini_read_real("Fleet", "ef" + string(i) + "target", 0); + fla.target_x = ini_read_real("Fleet", "ef" + string(i) + "target_x", 0); + fla.target_y = ini_read_real("Fleet", "ef" + string(i) + "target_y", 0); + fla.action_spd = ini_read_real("Fleet", "ef" + string(i) + "action_spd", 0); + fla.action_eta = ini_read_real("Fleet", "ef" + string(i) + "action_eta", 0); + fla.connected = ini_read_real("Fleet", "ef" + string(i) + "connected", 0); + fla.loaded = ini_read_real("Fleet", "ef" + string(i) + "loaded", 0); + fla.trade_goods = ini_read_string("Fleet", "ef" + string(i) + "trade", ""); + fla.guardsmen = ini_read_real("Fleet", "guardsmen" + string(i) + "guardsmen", 0); + fla.orbiting = ini_read_real("Fleet", "ef" + string(i) + "orb", 0); + fla.navy = ini_read_real("Fleet", "ef" + string(i) + "navy", 0); + fla.guardsmen_unloaded = ini_read_real("Fleet", "ef" + string(i) + "unl", 0); + + if (fla.navy = 1) { + var e; + e = -1; + repeat(20) { + e += 1; + fla.capital_imp[e] = ini_read_real("Fleet", "ef" + string(i) + "navy_cap." + string(e), 0); + fla.capital_max_imp[e] = ini_read_real("Fleet", "ef" + string(i) + "navy_cap_max." + string(e), 0); + } + e = -1; + repeat(30) { + e += 1; + fla.frigate_imp[e] = ini_read_real("Fleet", "ef" + string(i) + "navy_fri." + string(e), 0); + fla.frigate_max_imp[e] = ini_read_real("Fleet", "ef" + string(i) + "navy_fri_max." + string(e), 0); + fla.escort_imp[e] = ini_read_real("Fleet", "ef" + string(i) + "navy_esc." + string(e), 0); + fla.escort_max_imp[e] = ini_read_real("Fleet", "ef" + string(i) + "navy_esc_max." + string(e), 0); + } + } + + } + with(obj_en_fleet) { + if (owner = 0) then instance_destroy(); + } + ini_close(); + } + + if (argument0 = 5) or(argument0 = 0) { + ini_open("tsave.ini"); + // file_delete("tsave.ini"); + + var i; + i = 0; + obj_controller.restart_name = ini_read_string("Res", "nm", ""); + obj_controller.restart_founding = ini_read_real("Res", "found", 0); + obj_controller.restart_secret = ini_read_string("Res", "secre", ""); + obj_controller.restart_title[0] = ini_read_string("Res", "tit0", ""); + var i; + i = 0; + repeat(11) { + i += 1; + obj_controller.restart_title[i] = ini_read_string("Res", "tit" + string(i), ""); + } + obj_controller.restart_icon = ini_read_real("Res", "ico", 0); + obj_controller.restart_icon_name = ini_read_string("Res", "icn", ""); + obj_controller.restart_powers = ini_read_string("Res", "power", ""); + var ad; + ad = -1; + repeat(5) { + ad += 1; + obj_controller.restart_adv[ad] = ini_read_string("Res", "adv" + string(ad), ""); + obj_controller.restart_dis[ad] = ini_read_string("Res", "dis" + string(ad), ""); + } + obj_controller.restart_recruiting_type = ini_read_string("Res", "rcrtyp", ""); + obj_controller.restart_trial = ini_read_string("Res", "trial", ""); + obj_controller.restart_recruiting_name = ini_read_string("Res", "rcrnam", ""); + obj_controller.restart_home_type = ini_read_string("Res", "homtyp", ""); + obj_controller.restart_home_name = ini_read_string("Res", "homnam", ""); + obj_controller.restart_flagship_name = ini_read_string("Res", "flagship", ""); + obj_controller.restart_fleet_type = ini_read_real("Res", "flit", 0); + obj_controller.restart_recruiting_exists = ini_read_real("Res", "recr_e", 0); + obj_controller.restart_homeworld_exists = ini_read_real("Res", "home_e", 0); + obj_controller.restart_homeworld_rule = ini_read_real("Res", "home_r", 0); + obj_controller.restart_battle_cry = ini_read_string("Res", "cry", ""); + + + with(obj_controller) { + scr_colors_initialize(); + scr_shader_initialize(); + } + + var tempa, tempa2, q, good; + tempa = ""; + tempa2 = 0; + q = 0; + good = 0; + + tempa = ini_read_string("Res", "maincol", ""); + tempa2 = 0; + q = 0; + good = 0; + repeat(30) { + q += 1; + if (tempa = obj_controller.col[q]) and(good = 0) { + good = q; + tempa2 = q; + } + } + obj_controller.restart_main_color = tempa2; + + tempa = ini_read_string("Res", "seccol", ""); + tempa2 = 0; + q = 0; + good = 0; + repeat(30) { + q += 1; + if (tempa = obj_controller.col[q]) and(good = 0) { + good = q; + tempa2 = q; + } + } + obj_controller.restart_secondary_color = tempa2; + + tempa = ini_read_string("Res", "tricol", ""); + tempa2 = 0; + q = 0; + good = 0; + repeat(30) { + q += 1; + if (tempa = obj_controller.col[q]) and(good = 0) { + good = q; + tempa2 = q; + } + } + obj_controller.restart_trim_color = tempa2; + + tempa = ini_read_string("Res", "paul2col", ""); + tempa2 = 0; + q = 0; + good = 0; + repeat(30) { + q += 1; + if (tempa = obj_controller.col[q]) and(good = 0) { + good = q; + tempa2 = q; + } + } + obj_controller.restart_pauldron2_color = tempa2; + + tempa = ini_read_string("Res", "paul1col", ""); + tempa2 = 0; + q = 0; + good = 0; + repeat(30) { + q += 1; + if (tempa = obj_controller.col[q]) and(good = 0) { + good = q; + tempa2 = q; + } + } + obj_controller.restart_pauldron_color = tempa2; + + tempa = ini_read_string("Res", "lenscol", ""); + tempa2 = 0; + q = 0; + good = 0; + repeat(30) { + q += 1; + if (tempa = obj_controller.col[q]) and(good = 0) { + good = q; + tempa2 = q; + } + } + obj_controller.restart_lens_color = tempa2; + + tempa = ini_read_string("Res", "wepcol", ""); + tempa2 = 0; + q = 0; + good = 0; + repeat(30) { + q += 1; + if (tempa = obj_controller.col[q]) and(good = 0) { + good = q; + tempa2 = q; + } + } + obj_controller.restart_weapon_color = tempa2; + + // + + obj_controller.restart_col_special = ini_read_real("Res", "speccol", 0); + obj_controller.restart_trim = ini_read_real("Res", "trim", 0); + obj_controller.restart_skin_color = ini_read_real("Res", "skin", 0); + obj_controller.restart_hapothecary = ini_read_string("Res", "hapo", ""); + obj_controller.restart_hchaplain = ini_read_string("Res", "hcha", ""); + obj_controller.restart_clibrarian = ini_read_string("Res", "clib", ""); + obj_controller.restart_fmaster = ini_read_string("Res", "fmas", ""); + obj_controller.restart_recruiter = ini_read_string("Res", "recruiter", ""); + obj_controller.restart_admiral = ini_read_string("Res", "admir", ""); + obj_controller.restart_equal_specialists = ini_read_real("Res", "eqspec", 0); + if (ini_read_string("Res", "load2", 0) != 0) { + obj_controller.restart_load_to_ships = json_parse(base64_decode(ini_read_string("Res", "load2", 0))); + } else { + obj_controller.restart_load_to_ships = [0, 0, 0] + } + obj_controller.restart_successors = ini_read_string("Res", "successors", 0); + + obj_controller.restart_mutations = ini_read_real("Res", "muta", 0); + obj_controller.restart_preomnor = ini_read_real("Res", "preo", 0); + obj_controller.restart_voice = ini_read_real("Res", "voic", 0); + obj_controller.restart_doomed = ini_read_real("Res", "doom", 0); + obj_controller.restart_lyman = ini_read_real("Res", "lyma", 0); + obj_controller.restart_omophagea = ini_read_real("Res", "omop", 0); + obj_controller.restart_ossmodula = ini_read_real("Res", "ossm", 0); + obj_controller.restart_membrane = ini_read_real("Res", "memb", 0); + obj_controller.restart_zygote = ini_read_real("Res", "zygo", 0); + obj_controller.restart_betchers = ini_read_real("Res", "betc", 0); + obj_controller.restart_catalepsean = ini_read_real("Res", "catal", 0); + obj_controller.restart_secretions = ini_read_real("Res", "secr", 0); + obj_controller.restart_occulobe = ini_read_real("Res", "occu", 0); + obj_controller.restart_mucranoid = ini_read_real("Res", "mucra", 0); + obj_controller.restart_master_name = ini_read_string("Res", "master_name", ""); + obj_controller.restart_master_melee = ini_read_real("Res", "master_melee", 0); + obj_controller.restart_master_ranged = ini_read_real("Res", "master_ranged", 0); + obj_controller.restart_master_specialty = ini_read_real("Res", "master_specialty", 0); + obj_controller.restart_strength = ini_read_real("Res", "strength", 0); + obj_controller.restart_cooperation = ini_read_real("Res", "cooperation", 0); + obj_controller.restart_purity = ini_read_real("Res", "purity", 0); + obj_controller.restart_stability = ini_read_real("Res", "stability", 0); + obj_controller.squads = false; + + i = 99; + repeat(3) { + i += 1; + var o; + o = 1; + repeat(14) { + o += 1; + if (o = 11) then o = 12; + if (o = 13) then o = 14; + + obj_controller.r_race[i, o] = ini_read_real("Res", "r_race" + string(i) + "." + string(o), 0); + obj_controller.r_role[i, o] = ini_read_string("Res", "r_role" + string(i) + "." + string(o), ""); + obj_controller.r_wep1[i, o] = ini_read_string("Res", "r_wep1" + string(i) + "." + string(o), ""); + obj_controller.r_wep2[i, o] = ini_read_string("Res", "r_wep2" + string(i) + "." + string(o), ""); + obj_controller.r_armour[i, o] = ini_read_string("Res", "r_armour" + string(i) + "." + string(o), ""); + obj_controller.r_mobi[i, o] = ini_read_string("Res", "r_mobi" + string(i) + "." + string(o), ""); + obj_controller.r_gear[i, o] = ini_read_string("Res", "r_gear" + string(i) + "." + string(o), ""); + } + } // 100 is defaults, 101 is the allowable starting equipment + + ini_close(); + + + + + with(obj_en_fleet) { + if (owner = 2) and(string_count("colon", trade_goods) = 0) then sprite_index = spr_fleet_imperial; + if (owner = 2) and(string_count("colon", trade_goods) > 0) then sprite_index = spr_fleet_civilian; + if (owner = 3) then sprite_index = spr_fleet_mechanicus; + if (owner = 4) and(string_count("_fleet", trade_goods) > 0) and(target > 0) { + target = instance_nearest(target_x, target_y, obj_p_fleet); + } + if (owner = 4) then sprite_index = spr_fleet_inquisition; + if (owner = 6) then sprite_index = spr_fleet_eldar; + if (owner = 7) then sprite_index = spr_fleet_ork; + if (owner = 8) then sprite_index = spr_fleet_tau; + if (owner = 9) then sprite_index = spr_fleet_tyranid; + if (owner = 10) then sprite_index = spr_fleet_chaos; + image_speed = 0; + } + + + + if (file_exists("save" + string(argument1) + "log.ini")) { + ini_open("tsave.ini"); + + var g, bobby, bobby2, stars; + bobby = ""; + bobby2 = ""; + g = 0; + stars = ini_read_real("Save", "stars", 0); + bobby += string(stars) + "|"; + bobby += string(global.chapter_name) + "|"; + bobby += string(obj_ini.sector_name) + "|"; + bobby += string(obj_controller.turn) + "|"; + g = ini_read_real("Save", "sod", 0); + ini_close(); + file_delete("tsave.ini"); + bobby += string(g) + "|"; + + ini_open("save" + string(argument1) + "log.ini"); + bobby2 = string(ini_read_real("Main", "data1", random(500))) + "|"; + bobby2 += ini_read_string("Main", "data2", "error") + "|"; + bobby2 += ini_read_string("Main", "data3", "error") + "|"; + bobby2 += string(ini_read_real("Main", "data4", random(500))) + "|"; + bobby2 += string(ini_read_real("Main", "data5", random(500))) + "|"; + + if (bobby = bobby2) then obj_controller.good_log = 1; + instance_create(-100, -100, obj_event_log); + + with(obj_all_fleet) { + alarm[11] = 10; + } + + ini_close(); + } + + obj_saveload.alarm[1] = 30; + obj_controller.invis = false; + global.load = 0; + debugl("Loading slot " + string(argument1) + " completed"); + } + + +} \ No newline at end of file diff --git a/scripts/scr_save/scr_save.gml b/scripts/scr_save/scr_save.gml index 2ce495095..44f28aeee 100644 --- a/scripts/scr_save/scr_save.gml +++ b/scripts/scr_save/scr_save.gml @@ -1,1025 +1,1070 @@ - -function scr_save(save_slot,save_id) { - - var num, tot; - num=0;tot=0; - - num=instance_number(obj_star); - instance_array[tot]=0; - - // if (file_exists("save1.ini")) then file_delete("save1.ini"); - // argument 0 = the part of the save to do - //save_id = the save ID - - if (save_slot=1) or (save_slot=0){debugl("Saving to slot "+string(save_id)); - ini_open("save"+string(save_id)+".ini"); - // Global variables - ini_write_string("Save","chapter_name",global.chapter_name); - ini_write_string("Save","sector_name",obj_ini.sector_name); - ini_write_string("Save","version",global.version); - ini_write_real("Save","play_time",play_time); - ini_write_real("Save","game_seed",global.game_seed); - ini_write_real("Save","use_custom_icon",obj_ini.use_custom_icon); - var t,month,day,year,hour,minute,pm; - t=date_current_datetime(); - month=date_get_month(t); - day=date_get_day(t); - year=date_get_year(t); - hour=date_get_hour(t); - minute=date_get_minute(t); - pm="AM"; - if (hour=12) then pm="PM"; - if (hour>12) and (hour<24){pm="PM";hour-=12;} - if (hour=24){pm="AM";hour-=12;} - if (hour=0) then hour=12; - - var mahg;mahg=minute; - if (mahg<10) then minute="0"+string(mahg); - - // if (minute<10) then minute="0"+string(minute); - - ini_write_string("Save","date",string(month)+"/"+string(day)+"/"+string(year)+" ("+string(hour)+":"+string(minute)+" "+string(pm)+")"); - ini_write_real("Save","founding",obj_ini.progenitor); - // ini_write_string("Save","founding_secret",global.founding_secret); - ini_write_real("Save","custom",global.custom); - ini_write_real("Save","stars",instance_number(obj_star)); - ini_write_real("Save","p_fleets",instance_number(obj_p_fleet)); - ini_write_real("Save","en_fleets",instance_number(obj_en_fleet)); - ini_write_real("Save","sod",random_get_seed()); - ini_write_real("Save","corrupt",1); - // obj_controller variables here - ini_write_real("boolean", "cheat_req", global.cheat_req); - ini_write_real("boolean", "cheat_gene", global.cheat_gene); - ini_write_real("boolean", "cheat_debug", global.cheat_debug); - ini_write_real("boolean", "cheat_disp", global.cheat_disp); - ini_write_real("Controller","cheatyface",obj_controller.cheatyface); - ini_write_real("Controller","x",obj_controller.x); - ini_write_real("Controller","y",obj_controller.y); - ini_write_real("Controller","alll",obj_controller.alll); - ini_write_real("Controller","was_zoomed",obj_controller.was_zoomed); - ini_write_real("Controller","zoomed",obj_controller.zoomed); - ini_write_real("Controller","chaos_rating",obj_controller.chaos_rating); - ini_write_string("Controller","fleet_type",obj_controller.fleet_type); - ini_write_real("Controller","ifleet_type",obj_ini.fleet_type); - ini_write_real("Controller","home_rule",obj_controller.homeworld_rule); - ini_write_string("Controller","star_names",obj_controller.star_names); - ini_write_real("Controller","craworld",obj_controller.craftworld); - ini_write_real("Controller","turn",obj_controller.turn); - ini_write_real("Controller","last_event",obj_controller.last_event); - ini_write_real("Controller","last_mission",obj_controller.last_mission); - ini_write_real("Controller","last_world_inspection",obj_controller.last_world_inspection); - ini_write_real("Controller","last_fleet_inspection",obj_controller.last_fleet_inspection); - ini_write_real("Controller","chaos_turn",obj_controller.chaos_turn); - ini_write_real("Controller","chaos_fleets",obj_controller.chaos_fleets); - ini_write_real("Controller","tau_fleets",obj_controller.tau_fleets); - ini_write_real("Controller","tau_stars",obj_controller.tau_stars); - ini_write_real("Controller","tau_messenger",obj_controller.tau_messenger); - ini_write_real("Controller","fleet_all",obj_controller.fleet_all); - ini_write_real("Controller","tolerant",obj_ini.tolerant); - ini_write_real("Controller","stability",obj_ini.stability); - ini_write_real("Controller","purity",obj_ini.purity); - ini_write_real("Controller","unload",obj_controller.unload); - ini_write_real("Controller","diplomacy",obj_controller.diplomacy); - ini_write_real("Controller","trading",obj_controller.trading); - ini_write_real("Controller","audience",obj_controller.audience); - ini_write_real("Controller","force_goodbye",obj_controller.force_goodbye); - ini_write_real("Controller","combat",obj_controller.combat); - ini_write_real("Controller","new_vehicles",obj_controller.new_vehicles); - ini_write_real("Controller","hurssy",obj_controller.hurssy); - ini_write_real("Controller","hurssy_time",obj_controller.hurssy_time); - ini_write_real("Controller","artifacts",obj_controller.artifacts); - ini_write_real("Controller","pmc",obj_controller.popup_master_crafted); - ini_write_real("Controller","wndsel",obj_controller.select_wounded); - ini_write_real("Controller","imdis",obj_ini.imperium_disposition); - ini_write_real("Controller","terra_dir",obj_controller.terra_direction); - ini_write_real("Controller","stc_wargear",obj_controller.stc_wargear); - ini_write_real("Controller","stc_vehicles",obj_controller.stc_vehicles); - ini_write_real("Controller","stc_ships",obj_controller.stc_ships); - ini_write_real("Controller","stc_un_total",obj_controller.stc_un_total); - ini_write_real("Controller","stc_wargear_un",obj_controller.stc_wargear_un); - ini_write_real("Controller","stc_vehicles_un",obj_controller.stc_vehicles_un); - ini_write_real("Controller","stc_ships_un",obj_controller.stc_ships_un); - var j;j=0;repeat(6){j+=1;ini_write_real("Controller","stc_bonus_"+string(j),obj_controller.stc_bonus[j]);} - - j=0;repeat(4){j+=1; - ini_write_string("Controller","adv"+string(j),obj_ini.adv[j]); - ini_write_string("Controller","dis"+string(j),obj_ini.dis[j]); - } - - - // Player scheduled event - if (obj_controller.fest_type!=""){ - ini_write_real("Controller","f_si",obj_controller.fest_sid); - ini_write_real("Controller","f_wi",obj_controller.fest_wid); - ini_write_real("Controller","f_pl",obj_controller.fest_planet); - ini_write_string("Controller","f_st",obj_controller.fest_star); - ini_write_string("Controller","f_t",obj_controller.fest_type); - ini_write_real("Controller","f_co",obj_controller.fest_cost); - ini_write_real("Controller","f_wa",obj_controller.fest_warp); - ini_write_real("Controller","f_sch",obj_controller.fest_scheduled); - ini_write_real("Controller","f_la",obj_controller.fest_lav); - ini_write_real("Controller","f_lo",obj_controller.fest_locals); - ini_write_real("Controller","f_f1",obj_controller.fest_feature1); - ini_write_real("Controller","f_f2",obj_controller.fest_feature2); - ini_write_real("Controller","f_f3",obj_controller.fest_feature3); - ini_write_real("Controller","f_di",obj_controller.fest_display); - ini_write_string("Controller","f_dit",obj_controller.fest_display_tags); - ini_write_real("Controller","f_re",obj_controller.fest_repeats); - ini_write_real("Controller","f_hc",obj_controller.fest_honor_co); - ini_write_real("Controller","f_hi",obj_controller.fest_honor_id); - ini_write_real("Controller","f_hon",obj_controller.fest_honoring); - } - ini_write_real("Controller","f_fee",obj_controller.fest_feasts); - ini_write_real("Controller","f_boo",obj_controller.fest_boozes); - ini_write_real("Controller","f_dru",obj_controller.fest_drugses); - ini_write_real("Controller","rech",obj_controller.recent_happenings); - var i;i=-1; - repeat(600){i+=1; - if (recent_type[i]!=""){ - ini_write_string("Controller","rect"+string(i),obj_controller.recent_type[i]); - ini_write_string("Controller","reck"+string(i),obj_controller.recent_keyword[i]); - ini_write_real("Controller","recu"+string(i),obj_controller.recent_turn[i]); - ini_write_real("Controller","recn"+string(i),obj_controller.recent_number[i]); - } - } - - - ini_write_real("Formation","last_attack",obj_controller.last_attack_form); - ini_write_real("Formation","last_raid",obj_controller.last_raid_form); - j=0;repeat(14){j+=1; - if (obj_controller.bat_formation[j]!=""){ - ini_write_string("Formation","form"+string(j),obj_controller.bat_formation[j]); - ini_write_real("Formation","form_type"+string(j),obj_controller.bat_formation_type[j]); - ini_write_real("Formation","deva"+string(j),obj_controller.bat_deva_for[j]); - ini_write_real("Formation","assa"+string(j),obj_controller.bat_assa_for[j]); - ini_write_real("Formation","tact"+string(j),obj_controller.bat_tact_for[j]); - ini_write_real("Formation","vete"+string(j),obj_controller.bat_vete_for[j]); - ini_write_real("Formation","hire"+string(j),obj_controller.bat_hire_for[j]); - ini_write_real("Formation","libr"+string(j),obj_controller.bat_libr_for[j]); - ini_write_real("Formation","comm"+string(j),obj_controller.bat_comm_for[j]); - ini_write_real("Formation","tech"+string(j),obj_controller.bat_tech_for[j]); - ini_write_real("Formation","term"+string(j),obj_controller.bat_term_for[j]); - ini_write_real("Formation","hono"+string(j),obj_controller.bat_hono_for[j]); - ini_write_real("Formation","drea"+string(j),obj_controller.bat_drea_for[j]); - ini_write_real("Formation","rhin"+string(j),obj_controller.bat_rhin_for[j]); - ini_write_real("Formation","pred"+string(j),obj_controller.bat_pred_for[j]); - ini_write_real("Formation","land"+string(j),obj_controller.bat_land_for[j]); - ini_write_real("Formation","scou"+string(j),obj_controller.bat_scou_for[j]); - } - } - - - - - - ini_write_string("Controller","random_event_next",obj_controller.random_event_next); - - ini_write_string("Controller","useful_info",obj_controller.useful_info); - ini_write_real("Controller","random_event_next",obj_controller.random_event_next); - ini_write_real("Controller","gene_sold",obj_controller.gene_sold); - ini_write_real("Controller","gene_xeno",obj_controller.gene_xeno); - ini_write_real("Controller","gene_tithe",obj_controller.gene_tithe); - ini_write_real("Controller","gene_iou",obj_controller.gene_iou); - - ini_write_real("Controller","und_armouries",obj_controller.und_armouries); - ini_write_real("Controller","und_gene_vaults",obj_controller.und_gene_vaults); - ini_write_real("Controller","und_lairs",obj_controller.und_lairs); - - // - ini_write_real("Controller","penitent",obj_controller.penitent); - ini_write_real("Controller","penitent_current",obj_controller.penitent_current); - ini_write_real("Controller","penitent_max",obj_controller.penitent_max); - ini_write_real("Controller","penitent_turnly",obj_controller.penitent_turnly); - ini_write_real("Controller","penitent_turn",obj_controller.penitent_turn); - ini_write_real("Controller","penitent_end",obj_controller.penitent_end); - ini_write_real("Controller","penitent_blood",obj_controller.blood_debt); - // - ini_write_real("Controller","training_apothecary",obj_controller.training_apothecary); - ini_write_real("Controller","apothecary_points",obj_controller.apothecary_points); - ini_write_real("Controller","apothecary_aspirant",obj_controller.apothecary_aspirant); - ini_write_real("Controller","training_chaplain",obj_controller.training_chaplain); - ini_write_real("Controller","chaplain_points",obj_controller.chaplain_points); - ini_write_real("Controller","chaplain_aspirant",obj_controller.chaplain_aspirant); - ini_write_real("Controller","training_psyker",obj_controller.training_psyker); - ini_write_real("Controller","psyker_points",obj_controller.psyker_points); - ini_write_real("Controller","psyker_aspirant",obj_controller.psyker_aspirant); - ini_write_real("Controller","training_techmarine",obj_controller.training_techmarine); - ini_write_real("Controller","tech_points",obj_controller.tech_points); - ini_write_real("Controller","tech_aspirant",obj_controller.tech_aspirant); - - ini_write_real("Controller","penitorium",obj_controller.penitorium); - - ini_write_string("Controller","recruiting_worlds",obj_controller.recruiting_worlds); - ini_write_real("Controller","recruiting",obj_controller.recruiting); - ini_write_string("Controller","trial",obj_controller.recruit_trial); - ini_write_real("Controller","recruits",obj_controller.recruits); - ini_write_real("Controller","recruit_last",obj_controller.recruit_last); - // - var g;g=-1;repeat(30){g+=1; - ini_write_real("Controller","command"+string(g),obj_controller.command_set[g]); - } - ini_write_real("Controller","blandify",obj_controller.blandify); - var g;g=-1;repeat(201){g+=1; - ini_write_string("Recruit","rcr"+string(g),obj_controller.recruit_name[g]); - ini_write_real("Recruit","rcr_cr"+string(g),obj_controller.recruit_corruption[g]); - ini_write_real("Recruit","rcr_ds"+string(g),obj_controller.recruit_distance[g]); - ini_write_real("Recruit","rcr_tr"+string(g),obj_controller.recruit_training[g]); - ini_write_real("Recruit","rcr_ex"+string(g),obj_controller.recruit_exp[g]); - } - var g;g=-1;repeat(30){g+=1; - ini_write_string("Controller","lyl"+string(g),obj_controller.loyal[g]); - ini_write_real("Controller","lyl_nm"+string(g),obj_controller.loyal_num[g]); - ini_write_real("Controller","lyl_tm"+string(g),obj_controller.loyal_time[g]); - } - var g;g=-1;repeat(11){g+=1; - ini_write_string("Controller","inq"+string(g),obj_controller.inquisitor[g]); - ini_write_real("Controller","inq_ge"+string(g),obj_controller.inquisitor_gender[g]); - ini_write_string("Controller","inq_ty"+string(g),obj_controller.inquisitor_type[g]); - } - // - var g;g=-1;repeat(14){g+=1; - ini_write_string("Factions","fac"+string(g),obj_controller.faction[g]); - ini_write_real("Factions","dis"+string(g),obj_controller.disposition[g]); - ini_write_real("Factions","dis_max"+string(g),obj_controller.disposition_max[g]); - - ini_write_string("Factions","lead"+string(g),obj_controller.faction_leader[g]); - ini_write_real("Factions","gen"+string(g),obj_controller.faction_gender[g]); - ini_write_string("Factions","title"+string(g),obj_controller.faction_title[g]); - ini_write_string("Factions","status"+string(g),obj_controller.faction_status[g]); - ini_write_real("Factions","defeated"+string(g),obj_controller.faction_defeated[g]); - ini_write_real("Factions","known"+string(g),known[g]); - - ini_write_real("Factions","annoyed"+string(g),obj_controller.annoyed[g]); - ini_write_real("Factions","ignore"+string(g),obj_controller.ignore[g]); - ini_write_real("Factions","turns_ignored"+string(g),obj_controller.turns_ignored[g]); - - ini_write_real("Factions","audience"+string(g),obj_controller.audien[g]); - ini_write_string("Factions","audience_topic"+string(g),obj_controller.audien_topic[g]); - } - // - var g;g=0; - repeat(50){g+=1; - ini_write_string("Ongoing","quest"+string(g),obj_controller.quest[g]); - ini_write_real("Ongoing","quest_faction"+string(g),obj_controller.quest_faction[g]); - ini_write_real("Ongoing","quest_end"+string(g),obj_controller.quest_end[g]); - } - var g;g=0; - repeat(99){g+=1; - ini_write_string("Ongoing","event"+string(g),obj_controller.event[g]); - ini_write_real("Ongoing","event_duration"+string(g),obj_controller.event_duration[g]); - } - // - ini_write_real("Controller","justmet",obj_controller.faction_justmet); - ini_write_real("Controller","check_number",obj_controller.check_number); - ini_write_real("Controller","year_fraction",obj_controller.year_fraction); - ini_write_real("Controller","year",obj_controller.year); - ini_write_real("Controller","millenium",obj_controller.millenium); - // - ini_write_real("Controller","req",obj_controller.requisition); - // - ini_write_real("Controller","income",obj_controller.income); - ini_write_real("Controller","income_last",obj_controller.income_last); - ini_write_real("Controller","income_base",obj_controller.income_base); - ini_write_real("Controller","income_home",obj_controller.income_home); - ini_write_real("Controller","income_forge",obj_controller.income_forge); - ini_write_real("Controller","income_agri",obj_controller.income_agri); - ini_write_real("Controller","income_recruiting",obj_controller.income_recruiting); - ini_write_real("Controller","income_training",obj_controller.income_training); - ini_write_real("Controller","income_fleet",obj_controller.income_fleet); - ini_write_real("Controller","income_trade",obj_controller.income_trade); - ini_write_real("Controller","loyalty",obj_controller.loyalty); - ini_write_real("Controller","loyalty_hidden",obj_controller.loyalty_hidden); - ini_write_real("Controller","flag_lair",obj_controller.inqis_flag_lair); - ini_write_real("Controller","flag_gene",obj_controller.inqis_flag_gene); - - - ini_write_real("Controller","gene_seed",obj_controller.gene_seed); - ini_write_real("Controller","marines",obj_controller.marines); - ini_write_real("Controller","command",obj_controller.command); - ini_write_real("Controller","info_chips",obj_controller.info_chips); - ini_write_real("Controller","inspection_passes",obj_controller.inspection_passes); - ini_write_real("Controller","recruiting_worlds_bought",obj_controller.recruiting_worlds_bought); - ini_write_real("Controller","lwt",obj_controller.last_weapons_tab); - - ini_write_real("Controller","bat_devastator_column",obj_controller.bat_devastator_column); - ini_write_real("Controller","bat_assault_column",obj_controller.bat_assault_column); - ini_write_real("Controller","bat_tactical_column",obj_controller.bat_tactical_column); - ini_write_real("Controller","bat_veteran_column",obj_controller.bat_veteran_column); - ini_write_real("Controller","bat_hire_column",obj_controller.bat_hire_column); - ini_write_real("Controller","bat_librarian_column",obj_controller.bat_librarian_column); - ini_write_real("Controller","bat_command_column",obj_controller.bat_command_column); - ini_write_real("Controller","bat_techmarine_column",obj_controller.bat_techmarine_column); - ini_write_real("Controller","bat_terminator_column",obj_controller.bat_terminator_column); - ini_write_real("Controller","bat_honor_column",obj_controller.bat_honor_column); - ini_write_real("Controller","bat_dreadnought_column",obj_controller.bat_dreadnought_column); - ini_write_real("Controller","bat_rhino_column",obj_controller.bat_rhino_column); - ini_write_real("Controller","bat_predator_column",obj_controller.bat_predator_column); - ini_write_real("Controller","bat_landraider_column",obj_controller.bat_landraider_column); - ini_write_real("Controller","bat_scout_column",obj_controller.bat_scout_column); - - ini_close(); - } - - - if (save_slot=2) or (save_slot=0){debugl("Saving to slot "+string(save_id)+" part 2"); - ini_open("save"+string(save_id)+".ini"); - // Stars - - var num;num=instance_number(obj_star);instance_array=0; - for (i=0; i=g){ - ini_write_real("Star","sr"+string(i)+"plan"+string(g),instance_array[i].planet[g]); - ini_write_real("Star","sr"+string(i)+"dispo"+string(g),instance_array[i].dispo[g]); - ini_write_string("Star","sr"+string(i)+"type"+string(g),instance_array[i].p_type[g]); - var save_features = []; - if (array_length(instance_array[i].p_feature[g])> 0){ - for (var f = 0;f < array_length(instance_array[i].p_feature[g]);f++){ - save_features[f]=0; - var copy_feature = instance_array[i].p_feature[g][f]; - var new_feature = {}; - var names = variable_struct_get_names(copy_feature); - for (var name = 0; name < array_length(names); name++) { - if (!is_method(copy_feature[$ names[name]])){ - variable_struct_set(new_feature, names[name],copy_feature[$ names[name]]) - } - } - save_features[f] = new_feature; - } - } - ini_write_string("Star","sr"+string(i)+"feat"+string(g),base64_encode(json_stringify(save_features))); - ini_write_real("Star","sr"+string(i)+"own"+string(g),instance_array[i].p_owner[g]); - ini_write_real("Star","sr"+string(i)+"fir"+string(g),instance_array[i].p_first[g]); - ini_write_real("Star","sr"+string(i)+"popul"+string(g),instance_array[i].p_population[g]); - ini_write_real("Star","sr"+string(i)+"maxpop"+string(g),instance_array[i].p_max_population[g]); - ini_write_real("Star","sr"+string(i)+"large"+string(g),instance_array[i].p_large[g]); - ini_write_string("Star","sr"+string(i)+"pop"+string(g),instance_array[i].p_pop[g]); - ini_write_real("Star","sr"+string(i)+"guard"+string(g),instance_array[i].p_guardsmen[g]); - ini_write_real("Star","sr"+string(i)+"pdf"+string(g),instance_array[i].p_pdf[g]); - ini_write_real("Star","sr"+string(i)+"forti"+string(g),instance_array[i].p_fortified[g]); - ini_write_real("Star","sr"+string(i)+"stat"+string(g),instance_array[i].p_station[g]); - - ini_write_real("Star","sr"+string(i)+"play"+string(g),instance_array[i].p_player[g]); - if (instance_array[i].p_first[g]=1) or (instance_array[i].p_owner[g]=1){ - ini_write_real("Star","sr"+string(i)+"p_lasers"+string(g),instance_array[i].p_lasers[g]); - ini_write_real("Star","sr"+string(i)+"p_silo"+string(g),instance_array[i].p_silo[g]); - ini_write_real("Star","sr"+string(i)+"p_defenses"+string(g),instance_array[i].p_defenses[g]); - } - save_features = []; - if (array_length(instance_array[i].p_upgrades[g])> 0){ - for (var f = 0;f < array_length(instance_array[i].p_upgrades[g]);f++){ - save_features[f]=0; - var copy_feature = instance_array[i].p_upgrades[g][f]; - var new_feature = {}; - var names = variable_struct_get_names(copy_feature); - for (var name = 0; name < array_length(names); name++) { - if (!is_method(copy_feature[$ names[name]])){ - variable_struct_set(new_feature, names[name],copy_feature[$ names[name]]) - } - } - save_features[f] = new_feature; - } - } - ini_write_string("Star","sr"+string(i)+"upg"+string(g),base64_encode(json_stringify(save_features))); - ini_write_real("Star","sr"+string(i)+"or"+string(g),instance_array[i].p_orks[g]); - ini_write_real("Star","sr"+string(i)+"ta"+string(g),instance_array[i].p_tau[g]); - ini_write_real("Star","sr"+string(i)+"el"+string(g),instance_array[i].p_eldar[g]); - ini_write_real("Star","sr"+string(i)+"tr"+string(g),instance_array[i].p_traitors[g]); - ini_write_real("Star","sr"+string(i)+"ch"+string(g),instance_array[i].p_chaos[g]); - ini_write_real("Star","sr"+string(i)+"de"+string(g),instance_array[i].p_demons[g]); - ini_write_real("Star","sr"+string(i)+"si"+string(g),instance_array[i].p_sisters[g]); - ini_write_real("Star","sr"+string(i)+"ne"+string(g),instance_array[i].p_necrons[g]); - ini_write_real("Star","sr"+string(i)+"tyr"+string(g),instance_array[i].p_tyranids[g]); - ini_write_real("Star","sr"+string(i)+"halp"+string(g),instance_array[i].p_halp[g]); - - ini_write_real("Star","sr"+string(i)+"hurssy"+string(g),instance_array[i].p_hurssy[g]); - ini_write_real("Star","sr"+string(i)+"hurssy_time"+string(g),instance_array[i].p_hurssy_time[g]); - ini_write_real("Star","sr"+string(i)+"heresy"+string(g),instance_array[i].p_heresy[g]); - ini_write_real("Star","sr"+string(i)+"heresy_secret"+string(g),instance_array[i].p_heresy_secret[g]); - ini_write_real("Star","sr"+string(i)+"influence"+string(g),instance_array[i].p_influence[g]); - ini_write_real("Star","sr"+string(i)+"raided"+string(g),instance_array[i].p_raided[g]); - - ini_write_string("Star","sr"+string(i)+"prob"+string(g)+".1",instance_array[i].p_problem[g,1]); - ini_write_real("Star","sr"+string(i)+"time"+string(g)+".1",instance_array[i].p_timer[g,1]); - - ini_write_string("Star","sr"+string(i)+"prob"+string(g)+".2",instance_array[i].p_problem[g,2]); - ini_write_real("Star","sr"+string(i)+"time"+string(g)+".2",instance_array[i].p_timer[g,2]); - - ini_write_string("Star","sr"+string(i)+"prob"+string(g)+".3",instance_array[i].p_problem[g,3]); - ini_write_real("Star","sr"+string(i)+"time"+string(g)+".3",instance_array[i].p_timer[g,3]); - - ini_write_string("Star","sr"+string(i)+"prob"+string(g)+".4",instance_array[i].p_problem[g,4]); - ini_write_real("Star","sr"+string(i)+"time"+string(g)+".4",instance_array[i].p_timer[g,4]); - } - } - } - - - // Temporary artifact objects - ini_write_real("Controller","temp_arti",instance_number(obj_temp_arti)); - num=instance_number(obj_temp_arti);instance_array=0; - for (i=0; i 0){ - for (var i = 0;i < array_length(obj_ini.squads);i++){ - array_push(squad_copies, obj_ini.squads[i].jsonify()); - } - } - ini_write_string("Mar","squads",base64_encode(json_stringify(squad_copies))); - ini_write_string("Mar","squad_types",base64_encode(json_stringify(obj_ini.squad_types))); - - coh=100;mah=-1; - repeat(21){mah+=1; - if (obj_ini.role[coh,mah]!=""){ - ini_write_string("Mar","rol"+string(coh)+"."+string(mah),obj_ini.role[coh,mah]); - ini_write_string("Mar","w1"+string(coh)+"."+string(mah),obj_ini.wep1[coh,mah]); - ini_write_string("Mar","w2"+string(coh)+"."+string(mah),obj_ini.wep2[coh,mah]); - ini_write_string("Mar","ar"+string(coh)+"."+string(mah),obj_ini.armour[coh,mah]); - ini_write_string("Mar","ge"+string(coh)+"."+string(mah),obj_ini.gear[coh,mah]); - ini_write_string("Mar","mb"+string(coh)+"."+string(mah),obj_ini.mobi[coh,mah]); - } - } - coh=102;mah=-1; - repeat(21){mah+=1; - if (obj_ini.role[coh,mah]!=""){ - ini_write_string("Mar","rol"+string(coh)+"."+string(mah),obj_ini.role[coh,mah]); - ini_write_string("Mar","w1"+string(coh)+"."+string(mah),obj_ini.wep1[coh,mah]); - ini_write_string("Mar","w2"+string(coh)+"."+string(mah),obj_ini.wep2[coh,mah]); - ini_write_string("Mar","ar"+string(coh)+"."+string(mah),obj_ini.armour[coh,mah]); - ini_write_string("Mar","ge"+string(coh)+"."+string(mah),obj_ini.gear[coh,mah]); - ini_write_string("Mar","mb"+string(coh)+"."+string(mah),obj_ini.mobi[coh,mah]); - } - } - ini_close(); - } - - if (save_slot=5) or (save_slot=0){ - ini_open("save"+string(save_id)+".ini"); - - obj_saveload.hide=1; - obj_controller.invis=true; - obj_saveload.alarm[2]=2; - - var svt,svc,svm,smr,svd; - svt=0;svc="";svm="";smr=0;svd=""; - svt=ini_read_real("Controller","turn",0); - svc=ini_read_string("Save","chapter_name","Error"); - svm=ini_read_string("Ini","master_name","Error"); - smr=ini_read_real("Controller","marines",0); - svd=ini_read_string("Save","date","Error"); - ini_write_real("Save","corrupt",0); - ini_close(); - - ini_open("saves.ini"); - ini_write_real(string(save_id),"turn",svt); - ini_write_string(string(save_id),"chapter_name",svc); - ini_write_string(string(save_id),"master_name",svm); - ini_write_real(string(save_id),"marines",smr); - ini_write_string(string(save_id),"date",svd); - ini_write_real(string(save_id),"time",obj_controller.play_time); - ini_write_real(string(save_id),"seed",global.game_seed); - ini_close(); - - // TODO temporary disabled. Will be reenabled during ironman/autosave feature task - //file_encrypt("save"+string(save_id)+".ini","p"); - - // This saves the log in an unencrypted file - instance_activate_object(obj_event_log); - file_delete("save"+string(save_id)+"log.ini"); - ini_open("save"+string(save_id)+"log.ini"); - var t;t=0; - ini_write_real("Main","data1",instance_number(obj_star)); - ini_write_string("Main","data2",global.chapter_name); - ini_write_string("Main","data3",obj_ini.sector_name); - ini_write_real("Main","data4",obj_controller.turn); - ini_write_real("Main","data5",random_get_seed()); - - repeat(600){t+=1; - if (obj_event_log.event_text[t]!=""){ - ini_write_string("Log","a."+string(t),obj_event_log.event_text[t]); - ini_write_string("Log","b."+string(t),obj_event_log.event_date[t]); - ini_write_real("Log","c."+string(t),obj_event_log.event_turn[t]); - ini_write_string("Log","d."+string(t),obj_event_log.event_color[t]); - } - } - ini_close(); - - obj_saveload.save[save_id]=1; - - debugl("Saving to slot "+string(save_id)+" complete"); - } - - // Finish here - - - - // scr_load(); - - - /* - - probably need to add something like - - comp1_marines - comp1_vehicles - - these will be loaded into a temporary variable and determine how many times the checks need to repeat - - - - - - - - - //////////////////////////////// - ////////Loading//////////////////////// - ////////////////////////////////// - ini_open(saveFile); - num = ini_read_real("Save", "count", 0); //get the number of instances - - for ( i = 0; i < num; i += 1) - { - myID = ini_read_real( "Save", "object" + string(i), 0); //loads id from file - myX = ini_read_real( "Save", "object" + string(i) + "x", 0); //loads x from file - myY = ini_read_real( "Save", "object" + string(i) + "y", 0); //loads y from file - - instance_create( myX, myY, myID); - } - ini_close(); - - - - - 1. Make it so that save files are named 'Save1', 'Save2', etc, then store the name of the save file that appears in the game as part of the save file. - - 2. Check if 'Save1' exists, 'Save2', etc, and display them accordingly by reading their names from the file - - 3. When clicked, load the file by its FILENAME. When the user deletes a file, remove it and rename all the files with names AFTER it (for example, if Save3 was deleted, rename Save4 to Save3, and Save5 to Save4). This way, the structure stays tidy. - - - file_exists(fname) Returns whether the file with the given name exists (true) or not (false). - - - - - Use Splash Webpage(from d&d) ! (hehe) Usually you want to open in browser not in game (splash_show_web(url,delay) shows only in game ) - - Note: You can use working_directory to point the folder where the game is - - - - */ - - -} +function scr_save(save_slot, save_id) { + + var num, tot; + num = 0; + tot = 0; + + num = instance_number(obj_star); + instance_array[tot] = 0; + + // if (file_exists("save1.ini")) then file_delete("save1.ini"); + // argument 0 = the part of the save to do + //save_id = the save ID + + if (save_slot = 1) or(save_slot = 0) { + debugl("Saving to slot " + string(save_id)); + ini_open("save" + string(save_id) + ".ini"); + // Global variables + ini_write_string("Save", "chapter_name", global.chapter_name); + ini_write_string("Save", "sector_name", obj_ini.sector_name); + ini_write_string("Save", "version", global.version); + ini_write_real("Save", "play_time", play_time); + ini_write_real("Save", "game_seed", global.game_seed); + ini_write_real("Save", "use_custom_icon", obj_ini.use_custom_icon); + var t, month, day, year, hour, minute, pm; + t = date_current_datetime(); + month = date_get_month(t); + day = date_get_day(t); + year = date_get_year(t); + hour = date_get_hour(t); + minute = date_get_minute(t); + pm = "AM"; + if (hour = 12) then pm = "PM"; + if (hour > 12) and(hour < 24) { + pm = "PM"; + hour -= 12; + } + if (hour = 24) { + pm = "AM"; + hour -= 12; + } + if (hour = 0) then hour = 12; + + var mahg; + mahg = minute; + if (mahg < 10) then minute = "0" + string(mahg); + + // if (minute<10) then minute="0"+string(minute); + + ini_write_string("Save", "date", string(month) + "/" + string(day) + "/" + string(year) + " (" + string(hour) + ":" + string(minute) + " " + string(pm) + ")"); + ini_write_real("Save", "founding", obj_ini.progenitor); + // ini_write_string("Save","founding_secret",global.founding_secret); + ini_write_real("Save", "custom", global.custom); + ini_write_real("Save", "stars", instance_number(obj_star)); + ini_write_real("Save", "p_fleets", instance_number(obj_p_fleet)); + ini_write_real("Save", "en_fleets", instance_number(obj_en_fleet)); + ini_write_real("Save", "sod", random_get_seed()); + ini_write_real("Save", "corrupt", 1); + // obj_controller variables here + ini_write_real("boolean", "cheat_req", global.cheat_req); + ini_write_real("boolean", "cheat_gene", global.cheat_gene); + ini_write_real("boolean", "cheat_debug", global.cheat_debug); + ini_write_real("boolean", "cheat_disp", global.cheat_disp); + ini_write_real("Controller", "cheatyface", obj_controller.cheatyface); + ini_write_real("Controller", "x", obj_controller.x); + ini_write_real("Controller", "y", obj_controller.y); + ini_write_real("Controller", "alll", obj_controller.alll); + ini_write_real("Controller", "was_zoomed", obj_controller.was_zoomed); + ini_write_real("Controller", "zoomed", obj_controller.zoomed); + ini_write_real("Controller", "chaos_rating", obj_controller.chaos_rating); + ini_write_string("Controller", "fleet_type", obj_controller.fleet_type); + ini_write_real("Controller", "ifleet_type", obj_ini.fleet_type); + ini_write_real("Controller", "home_rule", obj_controller.homeworld_rule); + ini_write_string("Controller", "star_names", obj_controller.star_names); + ini_write_real("Controller", "craworld", obj_controller.craftworld); + ini_write_real("Controller", "turn", obj_controller.turn); + ini_write_real("Controller", "last_event", obj_controller.last_event); + ini_write_real("Controller", "last_mission", obj_controller.last_mission); + ini_write_real("Controller", "last_world_inspection", obj_controller.last_world_inspection); + ini_write_real("Controller", "last_fleet_inspection", obj_controller.last_fleet_inspection); + ini_write_real("Controller", "chaos_turn", obj_controller.chaos_turn); + ini_write_real("Controller", "chaos_fleets", obj_controller.chaos_fleets); + ini_write_real("Controller", "tau_fleets", obj_controller.tau_fleets); + ini_write_real("Controller", "tau_stars", obj_controller.tau_stars); + ini_write_real("Controller", "tau_messenger", obj_controller.tau_messenger); + ini_write_real("Controller", "fleet_all", obj_controller.fleet_all); + ini_write_real("Controller", "tolerant", obj_ini.tolerant); + ini_write_real("Controller", "stability", obj_ini.stability); + ini_write_real("Controller", "purity", obj_ini.purity); + ini_write_real("Controller", "unload", obj_controller.unload); + ini_write_real("Controller", "diplomacy", obj_controller.diplomacy); + ini_write_real("Controller", "trading", obj_controller.trading); + ini_write_real("Controller", "audience", obj_controller.audience); + ini_write_real("Controller", "force_goodbye", obj_controller.force_goodbye); + ini_write_real("Controller", "combat", obj_controller.combat); + ini_write_real("Controller", "new_vehicles", obj_controller.new_vehicles); + ini_write_real("Controller", "hurssy", obj_controller.hurssy); + ini_write_real("Controller", "hurssy_time", obj_controller.hurssy_time); + ini_write_real("Controller", "artifacts", obj_controller.artifacts); + ini_write_real("Controller", "pmc", obj_controller.popup_master_crafted); + ini_write_real("Controller", "wndsel", obj_controller.select_wounded); + ini_write_real("Controller", "imdis", obj_ini.imperium_disposition); + ini_write_real("Controller", "terra_dir", obj_controller.terra_direction); + ini_write_real("Controller", "stc_wargear", obj_controller.stc_wargear); + ini_write_real("Controller", "stc_vehicles", obj_controller.stc_vehicles); + ini_write_real("Controller", "stc_ships", obj_controller.stc_ships); + ini_write_real("Controller", "stc_un_total", obj_controller.stc_un_total); + ini_write_real("Controller", "stc_wargear_un", obj_controller.stc_wargear_un); + ini_write_real("Controller", "stc_vehicles_un", obj_controller.stc_vehicles_un); + ini_write_real("Controller", "stc_ships_un", obj_controller.stc_ships_un); + var j; + j = 0; + repeat(6) { + j += 1; + ini_write_real("Controller", "stc_bonus_" + string(j), obj_controller.stc_bonus[j]); + } + + j = 0; + repeat(4) { + j += 1; + ini_write_string("Controller", "adv" + string(j), obj_ini.adv[j]); + ini_write_string("Controller", "dis" + string(j), obj_ini.dis[j]); + } + + + // Player scheduled event + if (obj_controller.fest_type != "") { + ini_write_real("Controller", "f_si", obj_controller.fest_sid); + ini_write_real("Controller", "f_wi", obj_controller.fest_wid); + ini_write_real("Controller", "f_pl", obj_controller.fest_planet); + ini_write_string("Controller", "f_st", obj_controller.fest_star); + ini_write_string("Controller", "f_t", obj_controller.fest_type); + ini_write_real("Controller", "f_co", obj_controller.fest_cost); + ini_write_real("Controller", "f_wa", obj_controller.fest_warp); + ini_write_real("Controller", "f_sch", obj_controller.fest_scheduled); + ini_write_real("Controller", "f_la", obj_controller.fest_lav); + ini_write_real("Controller", "f_lo", obj_controller.fest_locals); + ini_write_real("Controller", "f_f1", obj_controller.fest_feature1); + ini_write_real("Controller", "f_f2", obj_controller.fest_feature2); + ini_write_real("Controller", "f_f3", obj_controller.fest_feature3); + ini_write_real("Controller", "f_di", obj_controller.fest_display); + ini_write_string("Controller", "f_dit", obj_controller.fest_display_tags); + ini_write_real("Controller", "f_re", obj_controller.fest_repeats); + ini_write_real("Controller", "f_hc", obj_controller.fest_honor_co); + ini_write_real("Controller", "f_hi", obj_controller.fest_honor_id); + ini_write_real("Controller", "f_hon", obj_controller.fest_honoring); + } + ini_write_real("Controller", "f_fee", obj_controller.fest_feasts); + ini_write_real("Controller", "f_boo", obj_controller.fest_boozes); + ini_write_real("Controller", "f_dru", obj_controller.fest_drugses); + ini_write_real("Controller", "rech", obj_controller.recent_happenings); + var i; + i = -1; + repeat(600) { + i += 1; + if (recent_type[i] != "") { + ini_write_string("Controller", "rect" + string(i), obj_controller.recent_type[i]); + ini_write_string("Controller", "reck" + string(i), obj_controller.recent_keyword[i]); + ini_write_real("Controller", "recu" + string(i), obj_controller.recent_turn[i]); + ini_write_real("Controller", "recn" + string(i), obj_controller.recent_number[i]); + } + } + + + ini_write_real("Formation", "last_attack", obj_controller.last_attack_form); + ini_write_real("Formation", "last_raid", obj_controller.last_raid_form); + j = 0; + repeat(14) { + j += 1; + if (obj_controller.bat_formation[j] != "") { + ini_write_string("Formation", "form" + string(j), obj_controller.bat_formation[j]); + ini_write_real("Formation", "form_type" + string(j), obj_controller.bat_formation_type[j]); + ini_write_real("Formation", "deva" + string(j), obj_controller.bat_deva_for[j]); + ini_write_real("Formation", "assa" + string(j), obj_controller.bat_assa_for[j]); + ini_write_real("Formation", "tact" + string(j), obj_controller.bat_tact_for[j]); + ini_write_real("Formation", "vete" + string(j), obj_controller.bat_vete_for[j]); + ini_write_real("Formation", "hire" + string(j), obj_controller.bat_hire_for[j]); + ini_write_real("Formation", "libr" + string(j), obj_controller.bat_libr_for[j]); + ini_write_real("Formation", "comm" + string(j), obj_controller.bat_comm_for[j]); + ini_write_real("Formation", "tech" + string(j), obj_controller.bat_tech_for[j]); + ini_write_real("Formation", "term" + string(j), obj_controller.bat_term_for[j]); + ini_write_real("Formation", "hono" + string(j), obj_controller.bat_hono_for[j]); + ini_write_real("Formation", "drea" + string(j), obj_controller.bat_drea_for[j]); + ini_write_real("Formation", "rhin" + string(j), obj_controller.bat_rhin_for[j]); + ini_write_real("Formation", "pred" + string(j), obj_controller.bat_pred_for[j]); + ini_write_real("Formation", "land" + string(j), obj_controller.bat_land_for[j]); + ini_write_real("Formation", "scou" + string(j), obj_controller.bat_scou_for[j]); + } + } + + + + + ini_write_string("Controller", "random_event_next", obj_controller.random_event_next); + + ini_write_string("Controller", "useful_info", obj_controller.useful_info); + ini_write_real("Controller", "random_event_next", obj_controller.random_event_next); + ini_write_real("Controller", "gene_sold", obj_controller.gene_sold); + ini_write_real("Controller", "gene_xeno", obj_controller.gene_xeno); + ini_write_real("Controller", "gene_tithe", obj_controller.gene_tithe); + ini_write_real("Controller", "gene_iou", obj_controller.gene_iou); + + ini_write_real("Controller", "und_armouries", obj_controller.und_armouries); + ini_write_real("Controller", "und_gene_vaults", obj_controller.und_gene_vaults); + ini_write_real("Controller", "und_lairs", obj_controller.und_lairs); + + // + ini_write_real("Controller", "penitent", obj_controller.penitent); + ini_write_real("Controller", "penitent_current", obj_controller.penitent_current); + ini_write_real("Controller", "penitent_max", obj_controller.penitent_max); + ini_write_real("Controller", "penitent_turnly", obj_controller.penitent_turnly); + ini_write_real("Controller", "penitent_turn", obj_controller.penitent_turn); + ini_write_real("Controller", "penitent_end", obj_controller.penitent_end); + ini_write_real("Controller", "penitent_blood", obj_controller.blood_debt); + // + ini_write_real("Controller", "training_apothecary", obj_controller.training_apothecary); + ini_write_real("Controller", "apothecary_points", obj_controller.apothecary_points); + ini_write_real("Controller", "apothecary_aspirant", obj_controller.apothecary_aspirant); + ini_write_real("Controller", "training_chaplain", obj_controller.training_chaplain); + ini_write_real("Controller", "chaplain_points", obj_controller.chaplain_points); + ini_write_real("Controller", "chaplain_aspirant", obj_controller.chaplain_aspirant); + ini_write_real("Controller", "training_psyker", obj_controller.training_psyker); + ini_write_real("Controller", "psyker_points", obj_controller.psyker_points); + ini_write_real("Controller", "psyker_aspirant", obj_controller.psyker_aspirant); + ini_write_real("Controller", "training_techmarine", obj_controller.training_techmarine); + ini_write_real("Controller", "tech_points", obj_controller.tech_points); + ini_write_real("Controller", "tech_aspirant", obj_controller.tech_aspirant); + + ini_write_real("Controller", "penitorium", obj_controller.penitorium); + + ini_write_string("Controller", "recruiting_worlds", obj_controller.recruiting_worlds); + ini_write_real("Controller", "recruiting", obj_controller.recruiting); + ini_write_string("Controller", "trial", obj_controller.recruit_trial); + ini_write_real("Controller", "recruits", obj_controller.recruits); + ini_write_real("Controller", "recruit_last", obj_controller.recruit_last); + // + var g; + g = -1; + repeat(30) { + g += 1; + ini_write_real("Controller", "command" + string(g), obj_controller.command_set[g]); + } + ini_write_real("Controller", "blandify", obj_controller.blandify); + var g; + g = -1; + repeat(201) { + g += 1; + ini_write_string("Recruit", "rcr" + string(g), obj_controller.recruit_name[g]); + ini_write_real("Recruit", "rcr_cr" + string(g), obj_controller.recruit_corruption[g]); + ini_write_real("Recruit", "rcr_ds" + string(g), obj_controller.recruit_distance[g]); + ini_write_real("Recruit", "rcr_tr" + string(g), obj_controller.recruit_training[g]); + ini_write_real("Recruit", "rcr_ex" + string(g), obj_controller.recruit_exp[g]); + } + var g; + g = -1; + repeat(30) { + g += 1; + ini_write_string("Controller", "lyl" + string(g), obj_controller.loyal[g]); + ini_write_real("Controller", "lyl_nm" + string(g), obj_controller.loyal_num[g]); + ini_write_real("Controller", "lyl_tm" + string(g), obj_controller.loyal_time[g]); + } + var g; + g = -1; + repeat(11) { + g += 1; + ini_write_string("Controller", "inq" + string(g), obj_controller.inquisitor[g]); + ini_write_real("Controller", "inq_ge" + string(g), obj_controller.inquisitor_gender[g]); + ini_write_string("Controller", "inq_ty" + string(g), obj_controller.inquisitor_type[g]); + } + // + var g; + g = -1; + repeat(14) { + g += 1; + ini_write_string("Factions", "fac" + string(g), obj_controller.faction[g]); + ini_write_real("Factions", "dis" + string(g), obj_controller.disposition[g]); + ini_write_real("Factions", "dis_max" + string(g), obj_controller.disposition_max[g]); + + ini_write_string("Factions", "lead" + string(g), obj_controller.faction_leader[g]); + ini_write_real("Factions", "gen" + string(g), obj_controller.faction_gender[g]); + ini_write_string("Factions", "title" + string(g), obj_controller.faction_title[g]); + ini_write_string("Factions", "status" + string(g), obj_controller.faction_status[g]); + ini_write_real("Factions", "defeated" + string(g), obj_controller.faction_defeated[g]); + ini_write_real("Factions", "known" + string(g), known[g]); + + ini_write_real("Factions", "annoyed" + string(g), obj_controller.annoyed[g]); + ini_write_real("Factions", "ignore" + string(g), obj_controller.ignore[g]); + ini_write_real("Factions", "turns_ignored" + string(g), obj_controller.turns_ignored[g]); + + ini_write_real("Factions", "audience" + string(g), obj_controller.audien[g]); + ini_write_string("Factions", "audience_topic" + string(g), obj_controller.audien_topic[g]); + } + // + var g; + g = 0; + repeat(50) { + g += 1; + ini_write_string("Ongoing", "quest" + string(g), obj_controller.quest[g]); + ini_write_real("Ongoing", "quest_faction" + string(g), obj_controller.quest_faction[g]); + ini_write_real("Ongoing", "quest_end" + string(g), obj_controller.quest_end[g]); + } + var g; + g = 0; + repeat(99) { + g += 1; + ini_write_string("Ongoing", "event" + string(g), obj_controller.event[g]); + ini_write_real("Ongoing", "event_duration" + string(g), obj_controller.event_duration[g]); + } + // + ini_write_real("Controller", "justmet", obj_controller.faction_justmet); + ini_write_real("Controller", "check_number", obj_controller.check_number); + ini_write_real("Controller", "year_fraction", obj_controller.year_fraction); + ini_write_real("Controller", "year", obj_controller.year); + ini_write_real("Controller", "millenium", obj_controller.millenium); + // + ini_write_real("Controller", "req", obj_controller.requisition); + // + ini_write_real("Controller", "income", obj_controller.income); + ini_write_real("Controller", "income_last", obj_controller.income_last); + ini_write_real("Controller", "income_base", obj_controller.income_base); + ini_write_real("Controller", "income_home", obj_controller.income_home); + ini_write_real("Controller", "income_forge", obj_controller.income_forge); + ini_write_real("Controller", "income_agri", obj_controller.income_agri); + ini_write_real("Controller", "income_recruiting", obj_controller.income_recruiting); + ini_write_real("Controller", "income_training", obj_controller.income_training); + ini_write_real("Controller", "income_fleet", obj_controller.income_fleet); + ini_write_real("Controller", "income_trade", obj_controller.income_trade); + ini_write_real("Controller", "loyalty", obj_controller.loyalty); + ini_write_real("Controller", "loyalty_hidden", obj_controller.loyalty_hidden); + ini_write_real("Controller", "flag_lair", obj_controller.inqis_flag_lair); + ini_write_real("Controller", "flag_gene", obj_controller.inqis_flag_gene); + + + ini_write_real("Controller", "gene_seed", obj_controller.gene_seed); + ini_write_real("Controller", "marines", obj_controller.marines); + ini_write_real("Controller", "command", obj_controller.command); + ini_write_real("Controller", "info_chips", obj_controller.info_chips); + ini_write_real("Controller", "inspection_passes", obj_controller.inspection_passes); + ini_write_real("Controller", "recruiting_worlds_bought", obj_controller.recruiting_worlds_bought); + ini_write_real("Controller", "lwt", obj_controller.last_weapons_tab); + + ini_write_real("Controller", "bat_devastator_column", obj_controller.bat_devastator_column); + ini_write_real("Controller", "bat_assault_column", obj_controller.bat_assault_column); + ini_write_real("Controller", "bat_tactical_column", obj_controller.bat_tactical_column); + ini_write_real("Controller", "bat_veteran_column", obj_controller.bat_veteran_column); + ini_write_real("Controller", "bat_hire_column", obj_controller.bat_hire_column); + ini_write_real("Controller", "bat_librarian_column", obj_controller.bat_librarian_column); + ini_write_real("Controller", "bat_command_column", obj_controller.bat_command_column); + ini_write_real("Controller", "bat_techmarine_column", obj_controller.bat_techmarine_column); + ini_write_real("Controller", "bat_terminator_column", obj_controller.bat_terminator_column); + ini_write_real("Controller", "bat_honor_column", obj_controller.bat_honor_column); + ini_write_real("Controller", "bat_dreadnought_column", obj_controller.bat_dreadnought_column); + ini_write_real("Controller", "bat_rhino_column", obj_controller.bat_rhino_column); + ini_write_real("Controller", "bat_predator_column", obj_controller.bat_predator_column); + ini_write_real("Controller", "bat_landraider_column", obj_controller.bat_landraider_column); + ini_write_real("Controller", "bat_scout_column", obj_controller.bat_scout_column); + + ini_close(); + } + + + if (save_slot = 2) or(save_slot = 0) { + debugl("Saving to slot " + string(save_id) + " part 2"); + ini_open("save" + string(save_id) + ".ini"); + // Stars + + var num; + num = instance_number(obj_star); + instance_array = 0; + for (i = 0; i < num; i += 1) { + instance_array[i] = instance_find(obj_star, i); + // save crap here + ini_write_string("Star", "sr" + string(i) + "name", instance_array[i].name); + ini_write_string("Star", "sr" + string(i) + "star", instance_array[i].star); + ini_write_real("Star", "sr" + string(i) + "planets", instance_array[i].planets); + ini_write_real("Star", "sr" + string(i) + "owner", instance_array[i].owner); + + ini_write_real("Star", "sr" + string(i) + "x", instance_array[i].x); + ini_write_real("Star", "sr" + string(i) + "y", instance_array[i].y); + ini_write_real("Star", "sr" + string(i) + "x2", instance_array[i].x2); + ini_write_real("Star", "sr" + string(i) + "y2", instance_array[i].y2); + ini_write_real("Star", "sr" + string(i) + "ox", instance_array[i].old_x); + ini_write_real("Star", "sr" + string(i) + "oy", instance_array[i].old_y); + + ini_write_real("Star", "sr" + string(i) + "vision", instance_array[i].vision); + ini_write_real("Star", "sr" + string(i) + "storm", instance_array[i].storm); + ini_write_real("Star", "sr" + string(i) + "trader", instance_array[i].trader); + ini_write_real("Star", "sr" + string(i) + "craftworld", instance_array[i].craftworld); + ini_write_real("Star", "sr" + string(i) + "spacehulk", instance_array[i].space_hulk); + + var g; + g = 0; + repeat(4) { + g += 1; + if (instance_array[i].planets >= g) { + ini_write_real("Star", "sr" + string(i) + "plan" + string(g), instance_array[i].planet[g]); + ini_write_real("Star", "sr" + string(i) + "dispo" + string(g), instance_array[i].dispo[g]); + ini_write_string("Star", "sr" + string(i) + "type" + string(g), instance_array[i].p_type[g]); + var save_features = []; + if (array_length(instance_array[i].p_feature[g]) > 0) { + for (var f = 0; f < array_length(instance_array[i].p_feature[g]); f++) { + save_features[f] = 0; + var copy_feature = instance_array[i].p_feature[g][f]; + var new_feature = {}; + var names = variable_struct_get_names(copy_feature); + for (var name = 0; name < array_length(names); name++) { + if (!is_method(copy_feature[$ names[name]])) { + variable_struct_set(new_feature, names[name], copy_feature[$ names[name]]) + } + } + save_features[f] = new_feature; + } + } + ini_write_string("Star", "sr" + string(i) + "feat" + string(g), base64_encode(json_stringify(save_features))); + ini_write_real("Star", "sr" + string(i) + "own" + string(g), instance_array[i].p_owner[g]); + ini_write_real("Star", "sr" + string(i) + "fir" + string(g), instance_array[i].p_first[g]); + ini_write_real("Star", "sr" + string(i) + "popul" + string(g), instance_array[i].p_population[g]); + ini_write_real("Star", "sr" + string(i) + "maxpop" + string(g), instance_array[i].p_max_population[g]); + ini_write_real("Star", "sr" + string(i) + "large" + string(g), instance_array[i].p_large[g]); + ini_write_string("Star", "sr" + string(i) + "pop" + string(g), instance_array[i].p_pop[g]); + ini_write_real("Star", "sr" + string(i) + "guard" + string(g), instance_array[i].p_guardsmen[g]); + ini_write_real("Star", "sr" + string(i) + "pdf" + string(g), instance_array[i].p_pdf[g]); + ini_write_real("Star", "sr" + string(i) + "forti" + string(g), instance_array[i].p_fortified[g]); + ini_write_real("Star", "sr" + string(i) + "stat" + string(g), instance_array[i].p_station[g]); + + ini_write_real("Star", "sr" + string(i) + "play" + string(g), instance_array[i].p_player[g]); + if (instance_array[i].p_first[g] = 1) or(instance_array[i].p_owner[g] = 1) { + ini_write_real("Star", "sr" + string(i) + "p_lasers" + string(g), instance_array[i].p_lasers[g]); + ini_write_real("Star", "sr" + string(i) + "p_silo" + string(g), instance_array[i].p_silo[g]); + ini_write_real("Star", "sr" + string(i) + "p_defenses" + string(g), instance_array[i].p_defenses[g]); + } + save_features = []; + if (array_length(instance_array[i].p_upgrades[g]) > 0) { + for (var f = 0; f < array_length(instance_array[i].p_upgrades[g]); f++) { + save_features[f] = 0; + var copy_feature = instance_array[i].p_upgrades[g][f]; + var new_feature = {}; + var names = variable_struct_get_names(copy_feature); + for (var name = 0; name < array_length(names); name++) { + if (!is_method(copy_feature[$ names[name]])) { + variable_struct_set(new_feature, names[name], copy_feature[$ names[name]]) + } + } + save_features[f] = new_feature; + } + } + ini_write_string("Star", "sr" + string(i) + "upg" + string(g), base64_encode(json_stringify(save_features))); + ini_write_real("Star", "sr" + string(i) + "or" + string(g), instance_array[i].p_orks[g]); + ini_write_real("Star", "sr" + string(i) + "ta" + string(g), instance_array[i].p_tau[g]); + ini_write_real("Star", "sr" + string(i) + "el" + string(g), instance_array[i].p_eldar[g]); + ini_write_real("Star", "sr" + string(i) + "tr" + string(g), instance_array[i].p_traitors[g]); + ini_write_real("Star", "sr" + string(i) + "ch" + string(g), instance_array[i].p_chaos[g]); + ini_write_real("Star", "sr" + string(i) + "de" + string(g), instance_array[i].p_demons[g]); + ini_write_real("Star", "sr" + string(i) + "si" + string(g), instance_array[i].p_sisters[g]); + ini_write_real("Star", "sr" + string(i) + "ne" + string(g), instance_array[i].p_necrons[g]); + ini_write_real("Star", "sr" + string(i) + "tyr" + string(g), instance_array[i].p_tyranids[g]); + ini_write_real("Star", "sr" + string(i) + "halp" + string(g), instance_array[i].p_halp[g]); + + ini_write_real("Star", "sr" + string(i) + "hurssy" + string(g), instance_array[i].p_hurssy[g]); + ini_write_real("Star", "sr" + string(i) + "hurssy_time" + string(g), instance_array[i].p_hurssy_time[g]); + ini_write_real("Star", "sr" + string(i) + "heresy" + string(g), instance_array[i].p_heresy[g]); + ini_write_real("Star", "sr" + string(i) + "heresy_secret" + string(g), instance_array[i].p_heresy_secret[g]); + ini_write_real("Star", "sr" + string(i) + "influence" + string(g), instance_array[i].p_influence[g]); + ini_write_real("Star", "sr" + string(i) + "raided" + string(g), instance_array[i].p_raided[g]); + + ini_write_string("Star", "sr" + string(i) + "prob" + string(g) + ".1", instance_array[i].p_problem[g, 1]); + ini_write_real("Star", "sr" + string(i) + "time" + string(g) + ".1", instance_array[i].p_timer[g, 1]); + + ini_write_string("Star", "sr" + string(i) + "prob" + string(g) + ".2", instance_array[i].p_problem[g, 2]); + ini_write_real("Star", "sr" + string(i) + "time" + string(g) + ".2", instance_array[i].p_timer[g, 2]); + + ini_write_string("Star", "sr" + string(i) + "prob" + string(g) + ".3", instance_array[i].p_problem[g, 3]); + ini_write_real("Star", "sr" + string(i) + "time" + string(g) + ".3", instance_array[i].p_timer[g, 3]); + + ini_write_string("Star", "sr" + string(i) + "prob" + string(g) + ".4", instance_array[i].p_problem[g, 4]); + ini_write_real("Star", "sr" + string(i) + "time" + string(g) + ".4", instance_array[i].p_timer[g, 4]); + } + } + } + + + // Temporary artifact objects + ini_write_real("Controller", "temp_arti", instance_number(obj_temp_arti)); + num = instance_number(obj_temp_arti); + instance_array = 0; + for (i = 0; i < num; i += 1) { + instance_array[i] = instance_find(obj_temp_arti, i); + ini_write_real("Star", "ar" + string(i) + "x", instance_array[i].x); + ini_write_real("Star", "ar" + string(i) + "y", instance_array[i].y); + } + + // PLAYER FLEET OBJECTS + num = 0; + tot = 0; + num = instance_number(obj_p_fleet); + instance_array[tot] = 0; + + for (i = 0; i < num; i += 1) { + instance_array[i] = instance_find(obj_p_fleet, i); + + ini_write_real("Fleet", "pf" + string(i) + "image", instance_array[i].image_index); + ini_write_real("Fleet", "pf" + string(i) + "x", instance_array[i].x); + ini_write_real("Fleet", "pf" + string(i) + "y", instance_array[i].y); + ini_write_real("Fleet", "pf" + string(i) + "capitals", instance_array[i].capital_number); + ini_write_real("Fleet", "pf" + string(i) + "frigates", instance_array[i].frigate_number); + ini_write_real("Fleet", "pf" + string(i) + "escorts", instance_array[i].escort_number); + ini_write_real("Fleet", "pf" + string(i) + "selected", instance_array[i].selected); + ini_write_real("Fleet", "pf" + string(i) + "capital_hp", instance_array[i].capital_health); + ini_write_real("Fleet", "pf" + string(i) + "frigate_hp", instance_array[i].frigate_health); + ini_write_real("Fleet", "pf" + string(i) + "escort_hp", instance_array[i].escort_health); + ini_write_string("Fleet", "pf" + string(i) + "action", instance_array[i].action); + ini_write_real("Fleet", "pf" + string(i) + "action_x", instance_array[i].action_x); + ini_write_real("Fleet", "pf" + string(i) + "action_y", instance_array[i].action_y); + ini_write_real("Fleet", "pf" + string(i) + "action_spd", instance_array[i].action_spd); + ini_write_real("Fleet", "pf" + string(i) + "action_eta", instance_array[i].action_eta); + ini_write_real("Fleet", "pf" + string(i) + "connected", instance_array[i].connected); + ini_write_real("Fleet", "pf" + string(i) + "acted", instance_array[i].acted); + ini_write_real("Fleet", "pf" + string(i) + "hurssy", instance_array[i].hurssy); + ini_write_real("Fleet", "pf" + string(i) + "hurssy_time", instance_array[i].hurssy_time); + ini_write_real("Fleet", "pf" + string(i) + "orb", instance_array[i].orbiting); + var g; + g = -1; + repeat(10) { + g += 1; + ini_write_string("Fleet", "pf" + string(i) + "capital" + string(g), instance_array[i].capital[g]); + ini_write_real("Fleet", "pf" + string(i) + "capital_num" + string(g), instance_array[i].capital_num[g]); + ini_write_real("Fleet", "pf" + string(i) + "capital_sel" + string(g), instance_array[i].capital_sel[g]); + ini_write_real("Fleet", "pf" + string(i) + "capital_uid" + string(g), instance_array[i].capital_uid[g]); + } + g = -1; + repeat(21) { + g += 1; + ini_write_string("Fleet", "pf" + string(i) + "frigate" + string(g), instance_array[i].frigate[g]); + ini_write_real("Fleet", "pf" + string(i) + "frigate_num" + string(g), instance_array[i].frigate_num[g]); + ini_write_real("Fleet", "pf" + string(i) + "frigate_sel" + string(g), instance_array[i].frigate_sel[g]); + ini_write_real("Fleet", "pf" + string(i) + "frigate_uid" + string(g), instance_array[i].frigate_uid[g]); + } + g = -1; + repeat(35) { + g += 1; + ini_write_string("Fleet", "pf" + string(i) + "escort" + string(g), instance_array[i].escort[g]); + ini_write_real("Fleet", "pf" + string(i) + "escort_num" + string(g), instance_array[i].escort_num[g]); + ini_write_real("Fleet", "pf" + string(i) + "escort_sel" + string(g), instance_array[i].escort_sel[g]); + ini_write_real("Fleet", "pf" + string(i) + "escort_uid" + string(g), instance_array[i].escort_uid[g]); + } + } + + // ENEMY FLEET OBJECTS + num = 0; + tot = 0; + num = instance_number(obj_en_fleet); + instance_array[tot] = 0; + + for (i = 0; i < num; i += 1) { + instance_array[i] = instance_find(obj_en_fleet, i); + ini_write_real("Fleet", "ef" + string(i) + "owner", instance_array[i].owner); + ini_write_real("Fleet", "ef" + string(i) + "x", instance_array[i].x); + ini_write_real("Fleet", "ef" + string(i) + "y", instance_array[i].y); + ini_write_real("Fleet", "ef" + string(i) + "sprite", instance_array[i].sprite_index); + ini_write_real("Fleet", "ef" + string(i) + "image", instance_array[i].image_index); + ini_write_real("Fleet", "ef" + string(i) + "alpha", instance_array[i].image_alpha); + ini_write_real("Fleet", "ef" + string(i) + "capitals", instance_array[i].capital_number); + ini_write_real("Fleet", "ef" + string(i) + "frigates", instance_array[i].frigate_number); + ini_write_real("Fleet", "ef" + string(i) + "escorts", instance_array[i].escort_number); + ini_write_real("Fleet", "ef" + string(i) + "selected", instance_array[i].selected); + ini_write_string("Fleet", "ef" + string(i) + "action", instance_array[i].action); + ini_write_real("Fleet", "ef" + string(i) + "action_x", instance_array[i].action_x); + ini_write_real("Fleet", "ef" + string(i) + "action_y", instance_array[i].action_y); + ini_write_real("Fleet", "ef" + string(i) + "home_x", instance_array[i].home_x); + ini_write_real("Fleet", "ef" + string(i) + "home_y", instance_array[i].home_y); + + ini_write_real("Fleet", "ef" + string(i) + "target", instance_array[i].target); + ini_write_real("Fleet", "ef" + string(i) + "target_x", instance_array[i].target_x); + ini_write_real("Fleet", "ef" + string(i) + "target_y", instance_array[i].target_y); + + ini_write_real("Fleet", "ef" + string(i) + "action_spd", instance_array[i].action_spd); + ini_write_real("Fleet", "ef" + string(i) + "action_eta", instance_array[i].action_eta); + ini_write_real("Fleet", "ef" + string(i) + "connected", instance_array[i].connected); + ini_write_real("Fleet", "ef" + string(i) + "loaded", instance_array[i].loaded); + ini_write_string("Fleet", "ef" + string(i) + "trade", instance_array[i].trade_goods); + ini_write_real("Fleet", "ef" + string(i) + "guardsmen", instance_array[i].guardsmen); + ini_write_real("Fleet", "ef" + string(i) + "orb", instance_array[i].orbiting); + ini_write_real("Fleet", "ef" + string(i) + "navy", instance_array[i].navy); + ini_write_real("Fleet", "ef" + string(i) + "unl", instance_array[i].guardsmen_unloaded); + + if (instance_array[i].navy = 1) { + var e; + e = -1; + repeat(20) { + e += 1; + ini_write_real("Fleet", "ef" + string(i) + "navy_cap." + string(e), instance_array[i].capital_imp[e]); + ini_write_real("Fleet", "ef" + string(i) + "navy_cap_max." + string(e), instance_array[i].capital_max_imp[e]); + } + e = -1; + repeat(30) { + e += 1; + ini_write_real("Fleet", "ef" + string(i) + "navy_fri." + string(e), instance_array[i].frigate_imp[e]); + ini_write_real("Fleet", "ef" + string(i) + "navy_fri_max." + string(e), instance_array[i].frigate_max_imp[e]); + ini_write_real("Fleet", "ef" + string(i) + "navy_esc." + string(e), instance_array[i].escort_imp[e]); + ini_write_real("Fleet", "ef" + string(i) + "navy_esc_max." + string(e), instance_array[i].escort_max_imp[e]); + } + } + } + + // obj_ini + ini_write_string("Ini", "home_name", obj_ini.home_name); + ini_write_string("Ini", "home_type", obj_ini.home_type); + ini_write_string("Ini", "recruiting_name", obj_ini.recruiting_name); + ini_write_string("Ini", "recruiting_type", obj_ini.recruiting_type); + ini_write_string("Ini", "chapter_name", obj_ini.chapter_name); + // ini_write_string("Ini","fortress_name",obj_ini.fortress_name); + ini_write_string("Ini", "flagship_name", obj_ini.flagship_name); + ini_write_real("Ini", "icon", obj_ini.icon); + ini_write_string("Ini", "icon_name", obj_ini.icon_name); + ini_write_real("Ini", "man_size", obj_ini.man_size); + ini_write_string("Ini", "strin1", obj_ini.strin); + ini_write_string("Ini", "strin2", obj_ini.strin2); + ini_write_string("Ini", "psy_powers", obj_ini.psy_powers); + + ini_write_real("Ini", "companies", obj_ini.companies); + var i; + i = -1; + repeat(21) { + i += 1; + ini_write_string("Ini", "comp_title" + string(i), obj_ini.company_title[i]); + } + var i; + i = -1; + repeat(121) { + i += 1; + ini_write_real("Ini", "slave_num_" + string(i), obj_ini.slave_batch_num[i]); + ini_write_real("Ini", "slave_eta_" + string(i), obj_ini.slave_batch_eta[i]); + } + + ini_write_string("Ini", "battle_cry", obj_ini.battle_cry); + + ini_write_string("Controller", "main_color", obj_controller.col[obj_controller.main_color]); + ini_write_string("Controller", "secondary_color", obj_controller.col[obj_controller.secondary_color]); + ini_write_string("Controller", "trim_color", obj_controller.col[obj_controller.trim_color]); + ini_write_string("Controller", "pauldron2_color", obj_controller.col[obj_controller.pauldron2_color]); + ini_write_string("Controller", "pauldron_color", obj_controller.col[obj_controller.pauldron_color]); + ini_write_string("Controller", "lens_color", obj_controller.col[obj_controller.lens_color]); + ini_write_string("Controller", "weapon_color", obj_controller.col[obj_controller.weapon_color]); + ini_write_real("Controller", "col_special", obj_controller.col_special); + ini_write_real("Controller", "trimmed", obj_controller.trim); + ini_write_real("Controller", "skin_color", obj_ini.skin_color); + + ini_write_string("Ini", "adept_name", obj_controller.adept_name); + ini_write_string("Ini", "recruiter_name", obj_controller.recruiter_name); + // ini_write_string("Ini","progenitor",obj_controller.progenitor); + ini_write_string("Ini", "mutation", obj_controller.mutation); + ini_write_real("Ini", "successors", obj_controller.successor_chapters); + ini_write_real("Ini", "progenitor_disposition", obj_controller.progenitor_disposition); + ini_write_real("Ini", "imperium_disposition", obj_controller.imperium_disposition); + ini_write_real("Ini", "astartes_disposition", obj_controller.astartes_disposition); + + ini_write_real("Ini", "master_autarch", obj_ini.master_autarch); + ini_write_real("Ini", "master_avatar", obj_ini.master_avatar); + ini_write_real("Ini", "master_farseer", obj_ini.master_farseer); + ini_write_real("Ini", "master_aspect", obj_ini.master_aspect); + ini_write_real("Ini", "master_eldar", obj_ini.master_eldar); + ini_write_real("Ini", "master_eldar_vehicles", obj_ini.master_eldar_vehicles); + ini_write_real("Ini", "master_tau", obj_ini.master_tau); + ini_write_real("Ini", "master_battlesuits", obj_ini.master_battlesuits); + ini_write_real("Ini", "master_kroot", obj_ini.master_kroot); + ini_write_real("Ini", "master_tau_vehicles", obj_ini.master_tau_vehicles); + ini_write_real("Ini", "master_ork_boyz", obj_ini.master_ork_boyz); + ini_write_real("Ini", "master_ork_nobz", obj_ini.master_ork_nobz); + ini_write_real("Ini", "master_ork_warboss", obj_ini.master_ork_warboss); + ini_write_real("Ini", "master_ork_vehicles", obj_ini.master_ork_vehicles); + ini_write_real("Ini", "master_heretics", obj_ini.master_heretics); + ini_write_real("Ini", "master_chaos_marines", obj_ini.master_chaos_marines); + ini_write_real("Ini", "master_lesser_demons", obj_ini.master_lesser_demons); + ini_write_real("Ini", "master_greater_demons", obj_ini.master_greater_demons); + ini_write_real("Ini", "master_chaos_vehicles", obj_ini.master_chaos_vehicles); + ini_write_real("Ini", "master_gaunts", obj_ini.master_gaunts); + ini_write_real("Ini", "master_warriors", obj_ini.master_warriors); + ini_write_real("Ini", "master_carnifex", obj_ini.master_carnifex); + ini_write_real("Ini", "master_synapse", obj_ini.master_synapse); + ini_write_real("Ini", "master_tyrant", obj_ini.master_tyrant); + ini_write_real("Ini", "master_gene", obj_ini.master_gene); + ini_write_real("Ini", "master_necron_overlord", obj_ini.master_necron_overlord); + ini_write_real("Ini", "master_destroyer", obj_ini.master_destroyer); + ini_write_real("Ini", "master_necron", obj_ini.master_necron); + ini_write_real("Ini", "master_wraith", obj_ini.master_wraith); + ini_write_real("Ini", "master_necron_vehicles", obj_ini.master_necron_vehicles); + ini_write_real("Ini", "master_monolith", obj_ini.master_monolith); + ini_write_string("Ini", "master_special", obj_ini.master_special_killed); + + + // + ini_write_real("Ini", "preomnor", obj_ini.preomnor); + ini_write_real("Ini", "voice", obj_ini.voice); + ini_write_real("Ini", "doomed", obj_ini.doomed); + ini_write_real("Ini", "lyman", obj_ini.lyman); + ini_write_real("Ini", "omophagea", obj_ini.omophagea); + ini_write_real("Ini", "ossmodula", obj_ini.ossmodula); + ini_write_real("Ini", "membrane", obj_ini.membrane); + ini_write_real("Ini", "zygote", obj_ini.zygote); + ini_write_real("Ini", "betchers", obj_ini.betchers); + ini_write_real("Ini", "catalepsean", obj_ini.catalepsean); + ini_write_real("Ini", "secretions", obj_ini.secretions); + ini_write_real("Ini", "occulobe", obj_ini.occulobe); + ini_write_real("Ini", "mucranoid", obj_ini.mucranoid); + // + ini_write_string("Ini", "master_name", obj_ini.master_name); + ini_write_string("Ini", "chief_name", obj_ini.chief_librarian_name); + ini_write_string("Ini", "high_name", obj_ini.high_chaplain_name); + ini_write_string("Ini", "high2_name", obj_ini.high_apothecary_name); + ini_write_string("Ini", "forgey_name", obj_ini.forge_master_name); + ini_write_string("Ini", "lord_name", obj_ini.lord_admiral_name); + // + var g; + g = 0; + repeat(150) { + g += 1; + if (obj_ini.equipment[g] != "") { + ini_write_string("Ini", "equipment" + string(g), obj_ini.equipment[g]); + ini_write_string("Ini", "equipment_type" + string(g), obj_ini.equipment_type[g]); + ini_write_real("Ini", "equipment_number" + string(g), obj_ini.equipment_number[g]); + ini_write_real("Ini", "equipment_condition" + string(g), obj_ini.equipment_condition[g]); + } + if (obj_ini.artifact[g] != "") { + ini_write_string("Ini", "artifact" + string(g), obj_ini.artifact[g]); + ini_write_string("Ini", "artifact_tags" + string(g), obj_ini.artifact_tags[g]); + ini_write_real("Ini", "artifact_ident" + string(g), obj_ini.artifact_identified[g]); + ini_write_real("Ini", "artifact_condition" + string(g), obj_ini.artifact_condition[g]); + ini_write_string("Ini", "artifact_loc" + string(g), obj_ini.artifact_loc[g]); + ini_write_real("Ini", "artifact_sid" + string(g), obj_ini.artifact_sid[g]); + } + } + // + var g; + g = 0; + repeat(200) { + g += 1; + ini_write_string("Ships", "shi" + string(g), obj_ini.ship[g]); + ini_write_real("Ships", "shi_uid" + string(g), obj_ini.ship_uid[g]); + ini_write_string("Ships", "shi_class" + string(g), obj_ini.ship_class[g]); + + ini_write_real("Ships", "shi_size" + string(g), obj_ini.ship_size[g]); + ini_write_real("Ships", "shi_leadership" + string(g), obj_ini.ship_leadership[g]); + ini_write_real("Ships", "shi_hp" + string(g), obj_ini.ship_hp[g]); + ini_write_real("Ships", "shi_maxhp" + string(g), obj_ini.ship_maxhp[g]); + ini_write_string("Ships", "shi_location" + string(g), obj_ini.ship_location[g]); + ini_write_real("Ships", "shi_shields" + string(g), obj_ini.ship_shields[g]); + ini_write_string("Ships", "shi_conditions" + string(g), obj_ini.ship_conditions[g]); + ini_write_real("Ships", "shi_speed" + string(g), obj_ini.ship_speed[g]); + ini_write_real("Ships", "shi_turning" + string(g), obj_ini.ship_turning[g]); + ini_write_real("Ships", "shi_front_ac" + string(g), obj_ini.ship_front_armour[g]); + ini_write_real("Ships", "shi_other_ac" + string(g), obj_ini.ship_other_armour[g]); + ini_write_real("Ships", "shi_weapons" + string(g), obj_ini.ship_weapons[g]); + // + ini_write_string("Ships", "shi" + string(g) + "wep1", obj_ini.ship_wep[g, 1]); + ini_write_string("Ships", "shi" + string(g) + "facing1", obj_ini.ship_wep_facing[g, 1]); + ini_write_string("Ships", "shi" + string(g) + "condition1", obj_ini.ship_wep_condition[g, 1]); + // + ini_write_string("Ships", "shi" + string(g) + "wep2", obj_ini.ship_wep[g, 2]); + ini_write_string("Ships", "shi" + string(g) + "facing2", obj_ini.ship_wep_facing[g, 2]); + ini_write_string("Ships", "shi" + string(g) + "condition2", obj_ini.ship_wep_condition[g, 2]); + // + ini_write_string("Ships", "shi" + string(g) + "wep3", obj_ini.ship_wep[g, 3]); + ini_write_string("Ships", "shi" + string(g) + "facing3", obj_ini.ship_wep_facing[g, 3]); + ini_write_string("Ships", "shi" + string(g) + "condition3", obj_ini.ship_wep_condition[g, 3]); + // + ini_write_string("Ships", "shi" + string(g) + "wep4", obj_ini.ship_wep[g, 4]); + ini_write_string("Ships", "shi" + string(g) + "facing4", obj_ini.ship_wep_facing[g, 4]); + ini_write_string("Ships", "shi" + string(g) + "condition4", obj_ini.ship_wep_condition[g, 4]); + // + ini_write_string("Ships", "shi" + string(g) + "wep5", obj_ini.ship_wep[g, 5]); + ini_write_string("Ships", "shi" + string(g) + "facing5", obj_ini.ship_wep_facing[g, 5]); + ini_write_string("Ships", "shi" + string(g) + "condition5", obj_ini.ship_wep_condition[g, 5]); + // + ini_write_real("Ships", "shi_capacity" + string(g), obj_ini.ship_capacity[g]); + ini_write_real("Ships", "shi_carrying" + string(g), obj_ini.ship_carrying[g]); + ini_write_string("Ships", "shi_contents" + string(g), obj_ini.ship_contents[g]); + ini_write_real("Ships", "shi_turrets" + string(g), obj_ini.ship_turrets[g]); + } + // the fun begins here + ini_close(); + } + + + if (save_slot = 3) or(save_slot = 0) { + debugl("Saving to slot " + string(save_id) + " part 3"); + ini_open("save" + string(save_id) + ".ini"); + var coh, mah, good; + good = 0; + coh = 10; + mah = 100; + repeat(1000) { + if (good = 0) { + mah -= 1; + if (mah = 0) { + mah = 100; + coh -= 1; + } + if (obj_ini.veh_role[coh, mah] != "") { + ini_write_real("Veh", "co" + string(coh) + "." + string(mah), obj_ini.veh_race[coh, mah]); + ini_write_string("Veh", "lo" + string(coh) + "." + string(mah), obj_ini.veh_loc[coh, mah]); + ini_write_string("Veh", "rol" + string(coh) + "." + string(mah), obj_ini.veh_role[coh, mah]); + ini_write_real("Veh", "lid" + string(coh) + "." + string(mah), obj_ini.veh_lid[coh, mah]); + ini_write_real("Veh", "uid" + string(coh) + "." + string(mah), obj_ini.veh_uid[coh, mah]); + ini_write_real("Veh", "wid" + string(coh) + "." + string(mah), obj_ini.veh_wid[coh, mah]); + + ini_write_string("Veh", "w1" + string(coh) + "." + string(mah), obj_ini.veh_wep1[coh, mah]); + ini_write_string("Veh", "w2" + string(coh) + "." + string(mah), obj_ini.veh_wep2[coh, mah]); + ini_write_string("Veh", "w3" + string(coh) + "." + string(mah), obj_ini.veh_wep3[coh, mah]); + ini_write_string("Veh", "up" + string(coh) + "." + string(mah), obj_ini.veh_upgrade[coh, mah]); + ini_write_string("Veh", "ac" + string(coh) + "." + string(mah), obj_ini.veh_acc[coh, mah]); + + ini_write_real("Veh", "hp" + string(coh) + "." + string(mah), obj_ini.veh_hp[coh, mah]); + ini_write_real("Veh", "cha" + string(coh) + "." + string(mah), obj_ini.veh_chaos[coh, mah]); + // ini_write_real("Veh","pil"+string(coh)+"."+string(mah),obj_ini.veh_pilots[coh,mah]); + } + if (coh = 1) and(mah = 1) then good = 1; + } + } + + + + + var i; + i = 0; + ini_write_string("Res", "nm", obj_controller.restart_name); + ini_write_real("Res", "found", obj_controller.restart_founding); + ini_write_string("Res", "secre", obj_controller.restart_secret); + ini_write_string("Res", "tit0", obj_controller.restart_title[0]); + var i; + i = 0; + repeat(11) { + i += 1; + ini_write_string("Res", "tit" + string(i), obj_controller.restart_title[i]); + } + ini_write_real("Res", "ico", obj_controller.restart_icon); + ini_write_string("Res", "icn", obj_controller.restart_icon_name); + ini_write_string("Res", "power", obj_controller.restart_powers); + var ad; + ad = -1; + repeat(5) { + ad += 1; + ini_write_string("Res", "adv" + string(ad), obj_controller.restart_adv[ad]); + ini_write_string("Res", "dis" + string(ad), obj_controller.restart_dis[ad]); + } + ini_write_string("Res", "rcrtyp", obj_controller.restart_recruiting_type); + ini_write_string("Res", "trial", obj_controller.restart_trial); + ini_write_string("Res", "rcrnam", obj_controller.restart_recruiting_name); + ini_write_string("Res", "homtyp", obj_controller.restart_home_type); + ini_write_string("Res", "homnam", obj_controller.restart_home_name); + + ini_write_real("Res", "flit", obj_controller.restart_fleet_type); + ini_write_real("Res", "recr_e", obj_controller.restart_recruiting_exists); + ini_write_real("Res", "home_e", obj_controller.restart_homeworld_exists); + ini_write_real("Res", "home_r", obj_controller.restart_homeworld_rule); + ini_write_string("Res", "cry", obj_controller.restart_battle_cry); + ini_write_string("Res", "flagship", obj_controller.restart_flagship_name); + ini_write_string("Res", "maincol", obj_controller.col[obj_controller.restart_main_color]); + ini_write_string("Res", "seccol", obj_controller.col[obj_controller.restart_secondary_color]); + ini_write_string("Res", "tricol", obj_controller.col[obj_controller.restart_trim_color]); + ini_write_string("Res", "paul2col", obj_controller.col[obj_controller.restart_pauldron2_color]); + ini_write_string("Res", "paul1col", obj_controller.col[obj_controller.restart_pauldron_color]); + ini_write_string("Res", "lenscol", obj_controller.col[obj_controller.restart_lens_color]); + ini_write_string("Res", "wepcol", obj_controller.col[obj_controller.restart_weapon_color]); + ini_write_real("Res", "speccol", obj_controller.restart_col_special); + ini_write_real("Res", "trim", obj_controller.restart_trim); + ini_write_real("Res", "skin", obj_controller.restart_skin_color); + ini_write_string("Res", "hapo", obj_controller.restart_hapothecary); + ini_write_string("Res", "hcha", obj_controller.restart_hchaplain); + ini_write_string("Res", "clib", obj_controller.restart_clibrarian); + ini_write_string("Res", "fmas", obj_controller.restart_fmaster); + ini_write_string("Res", "recruiter", obj_controller.restart_recruiter); + ini_write_string("Res", "admir", obj_controller.restart_admiral); + ini_write_real("Res", "eqspec", obj_controller.restart_equal_specialists); + ini_write_string("Res", "load2", base64_encode(json_stringify(obj_controller.restart_load_to_ships))); + ini_write_real("Res", "successors", obj_controller.restart_successors); + ini_write_real("Res", "muta", obj_controller.restart_mutations); + ini_write_real("Res", "preo", obj_controller.restart_preomnor); + ini_write_real("Res", "voic", obj_controller.restart_voice); + ini_write_real("Res", "doom", obj_controller.restart_doomed); + ini_write_real("Res", "lyma", obj_controller.restart_lyman); + ini_write_real("Res", "omop", obj_controller.restart_omophagea); + ini_write_real("Res", "ossm", obj_controller.restart_ossmodula); + ini_write_real("Res", "memb", obj_controller.restart_membrane); + ini_write_real("Res", "zygo", obj_controller.restart_zygote); + ini_write_real("Res", "betc", obj_controller.restart_betchers); + ini_write_real("Res", "catal", obj_controller.restart_catalepsean); + ini_write_real("Res", "secr", obj_controller.restart_secretions); + ini_write_real("Res", "occu", obj_controller.restart_occulobe); + ini_write_real("Res", "mucra", obj_controller.restart_mucranoid); + ini_write_string("Res", "master_name", obj_controller.restart_master_name); + ini_write_real("Res", "master_melee", obj_controller.restart_master_melee); + ini_write_real("Res", "master_ranged", obj_controller.restart_master_ranged); + ini_write_real("Res", "master_specialty", obj_controller.restart_master_specialty); + ini_write_real("Res", "strength", obj_controller.restart_strength); + ini_write_real("Res", "cooperation", obj_controller.restart_cooperation); + ini_write_real("Res", "purity", obj_controller.restart_purity); + ini_write_real("Res", "stability", obj_controller.restart_stability); + i = 99; + repeat(3) { + i += 1; + var o; + o = 1; + repeat(14) { + o += 1; + if (o = 11) then o = 12; + if (o = 13) then o = 14; + ini_write_real("Res", "r_race" + string(i) + "." + string(o), obj_controller.r_race[i, o]); + ini_write_string("Res", "r_role" + string(i) + "." + string(o), obj_controller.r_role[i, o]); + ini_write_string("Res", "r_wep1" + string(i) + "." + string(o), obj_controller.r_wep1[i, o]); + ini_write_string("Res", "r_wep2" + string(i) + "." + string(o), obj_controller.r_wep2[i, o]); + ini_write_string("Res", "r_armour" + string(i) + "." + string(o), obj_controller.r_armour[i, o]); + ini_write_string("Res", "r_mobi" + string(i) + "." + string(o), obj_controller.r_mobi[i, o]); + ini_write_string("Res", "r_gear" + string(i) + "." + string(o), obj_controller.r_gear[i, o]); + } + } // 100 is defaults, 101 is the allowable starting equipment + + + ini_close(); + } + + if (save_slot = 4) or(save_slot = 0) { + debugl("Saving to slot " + string(save_id) + " part 4"); + ini_open("save" + string(save_id) + ".ini"); + var coh, mah, good; + good = 0; + coh = 100; + mah = 0; + repeat(30) { + mah += 1; + if (obj_ini.role[coh, mah] != "") { + ini_write_real("Mar", "co" + string(coh) + "." + string(mah), obj_ini.race[coh, mah]); + ini_write_string("Mar", "num" + string(coh) + "." + string(mah), obj_ini.name[coh, mah]); + ini_write_string("Mar", "rol" + string(coh) + "." + string(mah), obj_ini.role[coh, mah]); + ini_write_string("Mar", "w1" + string(coh) + "." + string(mah), obj_ini.wep1[coh, mah]); + ini_write_string("Mar", "w2" + string(coh) + "." + string(mah), obj_ini.wep2[coh, mah]); + ini_write_string("Mar", "ar" + string(coh) + "." + string(mah), obj_ini.armour[coh, mah]); + ini_write_string("Mar", "ge" + string(coh) + "." + string(mah), obj_ini.gear[coh, mah]); + ini_write_string("Mar", "mb" + string(coh) + "." + string(mah), obj_ini.mobi[coh, mah]); + } + } + for (coh = 0; coh <= 10; coh++) { + for (mah = 0; mah <= 500; mah++) { + if (obj_ini.name[coh, mah] != "") { + ini_write_real("Mar", "co" + string(coh) + "." + string(mah), obj_ini.race[coh, mah]); + ini_write_string("Mar", "lo" + string(coh) + "." + string(mah), obj_ini.loc[coh, mah]); + ini_write_string("Mar", "num" + string(coh) + "." + string(mah), obj_ini.name[coh, mah]); + ini_write_string("Mar", "rol" + string(coh) + "." + string(mah), obj_ini.role[coh, mah]); + ini_write_real("Mar", "li" + string(coh) + "." + string(mah), obj_ini.lid[coh, mah]); + ini_write_real("Mar", "bio" + string(coh) + "." + string(mah), obj_ini.bio[coh, mah]); + ini_write_real("Mar", "wi" + string(coh) + "." + string(mah), obj_ini.wid[coh, mah]); + + ini_write_string("Mar", "w1" + string(coh) + "." + string(mah), obj_ini.wep1[coh, mah]); + ini_write_string("Mar", "w2" + string(coh) + "." + string(mah), obj_ini.wep2[coh, mah]); + ini_write_string("Mar", "ar" + string(coh) + "." + string(mah), obj_ini.armour[coh, mah]); + ini_write_string("Mar", "ge" + string(coh) + "." + string(mah), obj_ini.gear[coh, mah]); + ini_write_string("Mar", "mb" + string(coh) + "." + string(mah), obj_ini.mobi[coh, mah]); + + ini_write_real("Mar", "hp" + string(coh) + "." + string(mah), obj_ini.TTRPG[coh, mah].hp()); + ini_write_real("Mar", "cha" + string(coh) + "." + string(mah), obj_ini.chaos[coh, mah]); + ini_write_real("Mar", "exp" + string(coh) + "." + string(mah), obj_ini.experience[coh, mah]); + ini_write_real("Mar", "ag" + string(coh) + "." + string(mah), obj_ini.age[coh, mah]); + ini_write_string("Mar", "spe" + string(coh) + "." + string(mah), obj_ini.spe[coh, mah]); + ini_write_real("Mar", "god" + string(coh) + "." + string(mah), obj_ini.god[coh, mah]); + if (!is_struct(obj_ini.TTRPG[coh, mah])) { + TTRPG[coh, mah] = new TTRPG_stats("chapter", coh, mah, "blank"); + } else { + ini_write_string("Mar", "Struct" + string(coh) + "." + string(mah), base64_encode(jsonify_marine_struct(coh, mah))); + } + } + } + } + var squad_copies = []; + if (array_length(obj_ini.squads) > 0) { + for (var i = 0; i < array_length(obj_ini.squads); i++) { + array_push(squad_copies, obj_ini.squads[i].jsonify()); + } + } + ini_write_string("Mar", "squads", base64_encode(json_stringify(squad_copies))); + ini_write_string("Mar", "squad_types", base64_encode(json_stringify(obj_ini.squad_types))); + + coh = 100; + mah = -1; + repeat(21) { + mah += 1; + if (obj_ini.role[coh, mah] != "") { + ini_write_string("Mar", "rol" + string(coh) + "." + string(mah), obj_ini.role[coh, mah]); + ini_write_string("Mar", "w1" + string(coh) + "." + string(mah), obj_ini.wep1[coh, mah]); + ini_write_string("Mar", "w2" + string(coh) + "." + string(mah), obj_ini.wep2[coh, mah]); + ini_write_string("Mar", "ar" + string(coh) + "." + string(mah), obj_ini.armour[coh, mah]); + ini_write_string("Mar", "ge" + string(coh) + "." + string(mah), obj_ini.gear[coh, mah]); + ini_write_string("Mar", "mb" + string(coh) + "." + string(mah), obj_ini.mobi[coh, mah]); + } + } + coh = 102; + mah = -1; + repeat(21) { + mah += 1; + if (obj_ini.role[coh, mah] != "") { + ini_write_string("Mar", "rol" + string(coh) + "." + string(mah), obj_ini.role[coh, mah]); + ini_write_string("Mar", "w1" + string(coh) + "." + string(mah), obj_ini.wep1[coh, mah]); + ini_write_string("Mar", "w2" + string(coh) + "." + string(mah), obj_ini.wep2[coh, mah]); + ini_write_string("Mar", "ar" + string(coh) + "." + string(mah), obj_ini.armour[coh, mah]); + ini_write_string("Mar", "ge" + string(coh) + "." + string(mah), obj_ini.gear[coh, mah]); + ini_write_string("Mar", "mb" + string(coh) + "." + string(mah), obj_ini.mobi[coh, mah]); + } + } + ini_close(); + } + + if (save_slot = 5) or(save_slot = 0) { + ini_open("save" + string(save_id) + ".ini"); + + obj_saveload.hide = 1; + obj_controller.invis = true; + obj_saveload.alarm[2] = 2; + + var svt, svc, svm, smr, svd; + svt = 0; + svc = ""; + svm = ""; + smr = 0; + svd = ""; + svt = ini_read_real("Controller", "turn", 0); + svc = ini_read_string("Save", "chapter_name", "Error"); + svm = ini_read_string("Ini", "master_name", "Error"); + smr = ini_read_real("Controller", "marines", 0); + svd = ini_read_string("Save", "date", "Error"); + ini_write_real("Save", "corrupt", 0); + ini_close(); + + ini_open("saves.ini"); + ini_write_real(string(save_id), "turn", svt); + ini_write_string(string(save_id), "chapter_name", svc); + ini_write_string(string(save_id), "master_name", svm); + ini_write_real(string(save_id), "marines", smr); + ini_write_string(string(save_id), "date", svd); + ini_write_real(string(save_id), "time", obj_controller.play_time); + ini_write_real(string(save_id), "seed", global.game_seed); + ini_close(); + + // TODO temporary disabled. Will be reenabled during ironman/autosave feature task + //file_encrypt("save"+string(save_id)+".ini","p"); + + // This saves the log in an unencrypted file + instance_activate_object(obj_event_log); + file_delete("save" + string(save_id) + "log.ini"); + ini_open("save" + string(save_id) + "log.ini"); + var t; + t = 0; + ini_write_real("Main", "data1", instance_number(obj_star)); + ini_write_string("Main", "data2", global.chapter_name); + ini_write_string("Main", "data3", obj_ini.sector_name); + ini_write_real("Main", "data4", obj_controller.turn); + ini_write_real("Main", "data5", random_get_seed()); + + repeat(600) { + t += 1; + if (obj_event_log.event_text[t] != "") { + ini_write_string("Log", "a." + string(t), obj_event_log.event_text[t]); + ini_write_string("Log", "b." + string(t), obj_event_log.event_date[t]); + ini_write_real("Log", "c." + string(t), obj_event_log.event_turn[t]); + ini_write_string("Log", "d." + string(t), obj_event_log.event_color[t]); + } + } + ini_close(); + + obj_saveload.save[save_id] = 1; + + debugl("Saving to slot " + string(save_id) + " complete"); + } +} \ No newline at end of file From 915f39c2f61a8672a65dac0b60627cc7d0dd5c93 Mon Sep 17 00:00:00 2001 From: GalacticChimp Date: Fri, 10 Nov 2023 19:12:13 +0100 Subject: [PATCH 02/11] small cleanup --- scripts/scr_load/scr_load.gml | 47 ++++++++++++++++------------------- scripts/scr_save/scr_save.gml | 29 ++++++++------------- 2 files changed, 32 insertions(+), 44 deletions(-) diff --git a/scripts/scr_load/scr_load.gml b/scripts/scr_load/scr_load.gml index 5bd9587c6..817ebc073 100644 --- a/scripts/scr_load/scr_load.gml +++ b/scripts/scr_load/scr_load.gml @@ -1,4 +1,4 @@ -function scr_load(argument0, argument1) { +function scr_load(load_process_stage, save_id) { function load_marine_struct(company, marine) { var marStruct = ini_read_string("Mar", "Struct" + string(company) + "." + string(marine), ""); @@ -10,20 +10,20 @@ function scr_load(argument0, argument1) { obj_ini.TTRPG[company, marine] = new TTRPG_stats("chapter", company, marine, "blank"); } }; - var rang, i, g, stars, pfleets, efleets; - rang = 0; - i = 0; - g = 0; - stars = 0; - pfleets = 0; - efleets = 0; + var rang = 0; + var i = 0; + var g = 0; + var stars = 0; + var pfleets = 0; + var efleets = 0; - if (argument0 = 1) or(argument0 = 0) { - debugl("Loading slot " + string(argument1)); - var save_file_name = "save" + string(argument1) + ".ini"; + if (load_process_stage = 1) or(load_process_stage = 0) { + + debugl("Loading slot " + string(save_id)); + var save_file_name = "save" + string(save_id) + ".ini"; if (file_exists("tsave.ini")) { // file_copy() will fail if destination file already exists @@ -53,11 +53,8 @@ function scr_load(argument0, argument1) { obj_controller.play_time = ini_read_real("Save", "play_time", 0); obj_ini.progenitor = ini_read_real("Save", "founding", 0); - // global.founding_secret=ini_read_string("Save","founding_secret","Error"); global.custom = ini_read_real("Save", "custom", 1); stars = ini_read_real("Save", "stars", 0); - // pfleets=ini_read_real("Save","p_fleets",0); - // efleets=ini_read_real("Save","en_fleets",0); g = ini_read_real("Save", "sod", 0); random_set_seed(g); g = 0; @@ -70,7 +67,7 @@ function scr_load(argument0, argument1) { } // obj_controller variables here - obj_controller.load_game = argument1; + obj_controller.load_game = save_id; global.cheat_req = ini_read_real("boolean", "cheat_req", 0); global.cheat_gene = ini_read_real("boolean", "cheat_gene", 0); global.cheat_debug = ini_read_real("boolean", "cheat_debug", 0); @@ -518,8 +515,8 @@ function scr_load(argument0, argument1) { } - if (argument0 = 2) or(argument0 = 0) { - debugl("Loading slot " + string(argument1) + " part 2"); + if (load_process_stage = 2) or(load_process_stage = 0) { + debugl("Loading slot " + string(save_id) + " part 2"); ini_open("tsave.ini"); stars = ini_read_real("Save", "stars", 0); @@ -802,8 +799,8 @@ function scr_load(argument0, argument1) { - if (argument0 = 3) or(argument0 = 0) { - debugl("Loading slot " + string(argument1) + " part 3"); + if (load_process_stage = 3) or(load_process_stage = 0) { + debugl("Loading slot " + string(save_id) + " part 3"); ini_open("tsave.ini"); var coh, mah, good; @@ -962,8 +959,8 @@ function scr_load(argument0, argument1) { - if (argument0 = 4) or(argument0 = 0) { - debugl("Loading slot " + string(argument1) + " part 4"); // PLAYER FLEET OBJECTS + if (load_process_stage = 4) or(load_process_stage = 0) { + debugl("Loading slot " + string(save_id) + " part 4"); // PLAYER FLEET OBJECTS ini_open("tsave.ini"); var num, i, fla; @@ -1094,7 +1091,7 @@ function scr_load(argument0, argument1) { ini_close(); } - if (argument0 = 5) or(argument0 = 0) { + if (load_process_stage = 5) or(load_process_stage = 0) { ini_open("tsave.ini"); // file_delete("tsave.ini"); @@ -1321,7 +1318,7 @@ function scr_load(argument0, argument1) { - if (file_exists("save" + string(argument1) + "log.ini")) { + if (file_exists("save" + string(save_id) + "log.ini")) { ini_open("tsave.ini"); var g, bobby, bobby2, stars; @@ -1338,7 +1335,7 @@ function scr_load(argument0, argument1) { file_delete("tsave.ini"); bobby += string(g) + "|"; - ini_open("save" + string(argument1) + "log.ini"); + ini_open("save" + string(save_id) + "log.ini"); bobby2 = string(ini_read_real("Main", "data1", random(500))) + "|"; bobby2 += ini_read_string("Main", "data2", "error") + "|"; bobby2 += ini_read_string("Main", "data3", "error") + "|"; @@ -1358,7 +1355,7 @@ function scr_load(argument0, argument1) { obj_saveload.alarm[1] = 30; obj_controller.invis = false; global.load = 0; - debugl("Loading slot " + string(argument1) + " completed"); + debugl("Loading slot " + string(save_id) + " completed"); } diff --git a/scripts/scr_save/scr_save.gml b/scripts/scr_save/scr_save.gml index 44f28aeee..f9a451a59 100644 --- a/scripts/scr_save/scr_save.gml +++ b/scripts/scr_save/scr_save.gml @@ -1,17 +1,12 @@ -function scr_save(save_slot, save_id) { - - var num, tot; - num = 0; - tot = 0; - - num = instance_number(obj_star); - instance_array[tot] = 0; +function scr_save(save_process_stage, save_id) { + var num = instance_number(obj_star); + instance_array[0] = 0; // if (file_exists("save1.ini")) then file_delete("save1.ini"); // argument 0 = the part of the save to do //save_id = the save ID - if (save_slot = 1) or(save_slot = 0) { + if (save_process_stage = 1) or(save_process_stage = 0) { debugl("Saving to slot " + string(save_id)); ini_open("save" + string(save_id) + ".ini"); // Global variables @@ -358,7 +353,7 @@ function scr_save(save_slot, save_id) { } - if (save_slot = 2) or(save_slot = 0) { + if (save_process_stage = 2) or(save_process_stage = 0) { debugl("Saving to slot " + string(save_id) + " part 2"); ini_open("save" + string(save_id) + ".ini"); // Stars @@ -489,10 +484,8 @@ function scr_save(save_slot, save_id) { } // PLAYER FLEET OBJECTS - num = 0; - tot = 0; num = instance_number(obj_p_fleet); - instance_array[tot] = 0; + instance_array[0] = 0; for (i = 0; i < num; i += 1) { instance_array[i] = instance_find(obj_p_fleet, i); @@ -545,10 +538,8 @@ function scr_save(save_slot, save_id) { } // ENEMY FLEET OBJECTS - num = 0; - tot = 0; num = instance_number(obj_en_fleet); - instance_array[tot] = 0; + instance_array[0] = 0; for (i = 0; i < num; i += 1) { instance_array[i] = instance_find(obj_en_fleet, i); @@ -780,7 +771,7 @@ function scr_save(save_slot, save_id) { } - if (save_slot = 3) or(save_slot = 0) { + if (save_process_stage = 3) or(save_process_stage = 0) { debugl("Saving to slot " + string(save_id) + " part 3"); ini_open("save" + string(save_id) + ".ini"); var coh, mah, good; @@ -917,7 +908,7 @@ function scr_save(save_slot, save_id) { ini_close(); } - if (save_slot = 4) or(save_slot = 0) { + if (save_process_stage = 4) or(save_process_stage = 0) { debugl("Saving to slot " + string(save_id) + " part 4"); ini_open("save" + string(save_id) + ".ini"); var coh, mah, good; @@ -1006,7 +997,7 @@ function scr_save(save_slot, save_id) { ini_close(); } - if (save_slot = 5) or(save_slot = 0) { + if (save_process_stage = 5) or(save_process_stage = 0) { ini_open("save" + string(save_id) + ".ini"); obj_saveload.hide = 1; From 773470930754ba4b449cda657978bb7b5051757e Mon Sep 17 00:00:00 2001 From: GalacticChimp Date: Fri, 10 Nov 2023 21:15:00 +0100 Subject: [PATCH 03/11] Prepared basic setup for new save system --- objects/obj_saveload/Alarm_0.gml | 24 +++++++++--- objects/obj_saveload/Create_0.gml | 1 + objects/obj_saveload/Draw_0.gml | 63 ++++++++++++++---------------- options/windows/options_windows.yy | 2 +- scripts/scr_save/scr_save.gml | 40 ++++++++++++++++--- 5 files changed, 84 insertions(+), 46 deletions(-) diff --git a/objects/obj_saveload/Alarm_0.gml b/objects/obj_saveload/Alarm_0.gml index 6b815207b..a541023e7 100644 --- a/objects/obj_saveload/Alarm_0.gml +++ b/objects/obj_saveload/Alarm_0.gml @@ -1,9 +1,20 @@ // SAVE +if(save_part = 1){ + txt = "Praise to the Machine God"; + with(obj_controller) { + scr_save(1, obj_saveload.save_number, obj_saveload.save_file); + } + obj_saveload.save[save_number] = 1; + trickle = 5; +} + +/* + if (save_part = 6) { txt = "Praise to the Machine God"; with(obj_controller) { - scr_save(5, obj_saveload.save_number); + scr_save(5, obj_saveload.save_number, _save_file); } trickle = 50; } @@ -11,7 +22,7 @@ if (save_part = 6) { if (save_part = 5) { txt = "Astartes Registry"; with(obj_controller) { - scr_save(4, obj_saveload.save_number); + scr_save(4, obj_saveload.save_number, _save_file); } trickle = 40; save_part = 6; @@ -20,7 +31,7 @@ if (save_part = 5) { if (save_part = 4) { txt = "Sacred Anointing of Oil"; with(obj_controller) { - scr_save(3, obj_saveload.save_number); + scr_save(3, obj_saveload.save_number, _save_file); } trickle = 10; save_part = 5; @@ -29,7 +40,7 @@ if (save_part = 4) { if (save_part = 3) { txt = "Charting Sector"; with(obj_controller) { - scr_save(2, obj_saveload.save_number); + scr_save(2, obj_saveload.save_number, _save_file); } trickle = 10; save_part = 4; @@ -38,14 +49,14 @@ if (save_part = 3) { if (save_part = 2) { txt = "Finding Servo Skulls"; with(obj_controller) { - scr_save(1, obj_saveload.save_number); + scr_save(1, obj_saveload.save_number, _save_file); } trickle = 10; save_part = 3; } if (save_part = 1) { - if (file_exists("save" + string(save_number) + ".ini")) then file_delete("save" + string(save_number) + ".ini"); + if (file_exists(_save_file)) then file_delete(_save_file); if (file_exists("screen" + string(save_number) + ".png")) then file_delete("screen" + string(save_number) + ".png"); ini_open("saves.ini"); ini_section_delete(string(save_number)); @@ -55,6 +66,7 @@ if (save_part = 1) { trickle = 10; txt = "Preparing"; } +*/ // LOAD diff --git a/objects/obj_saveload/Create_0.gml b/objects/obj_saveload/Create_0.gml index 95fcfb4f4..8fe48a0ba 100644 --- a/objects/obj_saveload/Create_0.gml +++ b/objects/obj_saveload/Create_0.gml @@ -4,6 +4,7 @@ menu = 0; // 1 : save, 2: load save_part = 0; load_part = 0; save_number = 0; +save_file = ""; trickle = 0; txt = ""; hide = 0; diff --git a/objects/obj_saveload/Draw_0.gml b/objects/obj_saveload/Draw_0.gml index a3431a3b8..046b92316 100644 --- a/objects/obj_saveload/Draw_0.gml +++ b/objects/obj_saveload/Draw_0.gml @@ -275,55 +275,52 @@ if __b__ { draw_rectangle(x2 + 1317, y2 + 113, x2 + 1461, y2 + 146, 0); draw_set_alpha(1); if (mouse_left >= 1) and(cooldown <= 0) { - var onceh; - onceh = 0; + var _clicked_exactly_once = 0; if (instance_exists(obj_main_menu)) { with(obj_main_menu) { part_particles_clear(p_system); } } + // Check save folder + var _saves_folder = program_directory + "\saves"; + if (!directory_exists(_saves_folder)) then directory_create(_saves_folder); + + // Check open slot + var _open_slot_id = save[o]; + var _potential_open_slot_save_file = _saves_folder + $"\\save{_open_slot_id}.json"; + // If open slot then set the save.ini to the maximum - if (!file_exists("save" + string(save[o]) + ".ini")) or(save[o] = 0) and(onceh = 0) { - save_part = 1; - menu = 0; + if (!file_exists(_potential_open_slot_save_file)) or(_open_slot_id = 0) and(_clicked_exactly_once = 0) { save_number = max_ini; - obj_cursor.image_alpha = 0; - splash = choose(0, 1, 2, 3, 4); - with(obj_new_button) { - instance_destroy(); - } - with(obj_ingame_menu) { - instance_destroy(); - } - // Other here - alarm[0] = 1; - onceh = 1; } // If file exists then overright - if (file_exists("save" + string(save[o]) + ".ini")) { - file_delete("save" + string(save[o]) + ".ini"); - if (file_exists("screen" + string(save[o]) + ".png")) then file_delete("screen" + string(save[o]) + ".png"); - save_part = 1; - menu = 0; + if (file_exists(_potential_open_slot_save_file)) { + file_delete(_potential_open_slot_save_file); save_number = o; - obj_cursor.image_alpha = 0; - splash = choose(0, 1, 2, 3, 4); - with(obj_new_button) { - instance_destroy(); - } - with(obj_ingame_menu) { - instance_destroy(); - } - // Other here - alarm[0] = 1; - onceh = 1; } + + // Set rest of state + save_file = _saves_folder + $"\\save{save_number}.json"; + save_part = 1; + menu = 0; + obj_cursor.image_alpha = 0; + splash = choose(0, 1, 2, 3, 4); + with(obj_new_button) { + instance_destroy(); + } + with(obj_ingame_menu) { + instance_destroy(); + } + + // Other here + alarm[0] = 1; + _clicked_exactly_once = 1; } } } - o += 1; + o++; y2 += 158; } diff --git a/options/windows/options_windows.yy b/options/windows/options_windows.yy index 7320e64c9..89567ed8e 100644 --- a/options/windows/options_windows.yy +++ b/options/windows/options_windows.yy @@ -8,7 +8,7 @@ "option_windows_copy_exe_to_dest": false, "option_windows_copyright_info": "", "option_windows_description_info": "Become the 40,000th warhammer", - "option_windows_disable_sandbox": false, + "option_windows_disable_sandbox": true, "option_windows_display_cursor": false, "option_windows_display_name": "Chapter Master Adeptus Dominus 0.8.1.1", "option_windows_enable_steam": false, diff --git a/scripts/scr_save/scr_save.gml b/scripts/scr_save/scr_save.gml index f9a451a59..6ca825279 100644 --- a/scripts/scr_save/scr_save.gml +++ b/scripts/scr_save/scr_save.gml @@ -1,10 +1,37 @@ -function scr_save(save_process_stage, save_id) { - var num = instance_number(obj_star); +function scr_save(save_process_stage, save_id, save_file) { +var num = instance_number(obj_star); instance_array[0] = 0; - // if (file_exists("save1.ini")) then file_delete("save1.ini"); - // argument 0 = the part of the save to do - //save_id = the save ID + // HMMMMMMMM +// Maybe https://manual.yoyogames.com/GameMaker_Language/GML_Reference/File_Handling/Encoding_And_Hashing/json_stringify.htm +// will allow to just copy all data that I need with minimal changes? +// or at least create Save(), Load() in relevant objects/scripts, to simplify everything? + +// also https://manual.yoyogames.com/GameMaker_Language/GML_Reference/File_Handling/Encoding_And_Hashing/Encoding_And_Hashing.htm +// https://manual.yoyogames.com/GameMaker_Language/GML_Reference/File_Handling/Encoding_And_Hashing/json_encode.htm + + // TODO enums + if (save_process_stage = 1) or(save_process_stage = 0) { + debugl("Saving to slot " + string(save_id)); + var _save_file_handle = file_text_open_write(save_file); + if(_save_file_handle == - 1){ + debugl("Saving to slot " + string(save_id) + " error, could not create/open file: " + save_file); + return; + } + + file_text_write_string(_save_file_handle, json_stringify(global.chapter_name, true)); + file_text_close(_save_file_handle); + obj_saveload.save[save_id] = 1; + debugl("Saving to slot " + string(save_id) + " complete"); + //ERROR add Save() functions, which will prepare structs, ready for saving + } +} + +/* + +function scr_save(save_process_stage, save_id, save_file) { + var num = instance_number(obj_star); + instance_array[0] = 0; if (save_process_stage = 1) or(save_process_stage = 0) { debugl("Saving to slot " + string(save_id)); @@ -1058,4 +1085,5 @@ function scr_save(save_process_stage, save_id) { debugl("Saving to slot " + string(save_id) + " complete"); } -} \ No newline at end of file +} +*/ \ No newline at end of file From 73a4dd22ad325c65040083bcd1f3495d62a7c730 Mon Sep 17 00:00:00 2001 From: GalacticChimp Date: Sat, 11 Nov 2023 00:34:51 +0100 Subject: [PATCH 04/11] good progress on serialization --- objects/obj_ini/Create_0.gml | 259 +++++++- scripts/scr_save/scr_save.gml | 1078 +-------------------------------- 2 files changed, 257 insertions(+), 1080 deletions(-) diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index 15a4139b1..9e23707b0 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -57,14 +57,6 @@ repeat(11){ } v=0;company=0; - -/*if (obj_creation.fleet_type=3){ - obj_controller.penitent=1; - obj_controller.penitent_max=(obj_creation.maximum_size*1000)+300; - if (obj_creation.chapter_name="Lamenters") then obj_controller.penitent_max=100300; - obj_controller.penitent_current=300; -}*/ - check_number=0; year_fraction=0; year=0; @@ -72,20 +64,253 @@ millenium=0; company_spawn_buffs = []; role_spawn_buffs ={}; -/* if (global.load=0){ - if (obj_creation.custom>0) then scr_initialize_custom(); - if (obj_creation.custom=0) then scr_initialize_standard(); -}*/ - if (instance_exists(obj_creation)) then custom=obj_creation.custom; if (global.load=0) then scr_initialize_custom(); +Serialize = function() { + var _ini_data = + { + sector_name, + use_custom_icon, + progenitor, + fleet_type, + tolerant, + stability, + purity, + imperium_disposition, + advantages: [ + adv[1], + adv[2], + adv[3], + adv[4] + ], + disadvantages: [ + dis[1], + dis[2], + dis[3], + dis[4] + ], + home_name, + home_type, + recruiting_name, + recruiting_type, + chapter_name, + // TODO ? fortress_name, + flagship_name, + icon, + icon_name, + man_size, + strin, + strin2, + psy_powers, + companies, + company_titles: [], + slave_batches: [], + battle_cry, + skin_color, + master_autarch, + master_avatar, + master_farseer, + master_aspect, + master_eldar, + master_eldar_vehicles, + master_tau, + master_battlesuits, + master_kroot, + master_tau_vehicles, + master_ork_boyz, + master_ork_nobz, + master_ork_warboss, + master_ork_vehicles, + master_heretics, + master_chaos_marines, + master_lesser_demons, + master_greater_demons, + master_chaos_vehicles, + master_gaunts, + master_warriors, + master_carnifex, + master_synapse, + master_tyrant, + master_gene, + master_necron_overlord, + master_destroyer, + master_necron, + master_wraith, + master_necron_vehicles, + master_monolith, + master_special_killed, + preomnor, + voice, + doomed, + lyman, + omophagea, + ossmodula, + membrane, + zygote, + betchers, + catalepsean, + secretions, + occulobe, + mucranoid, + master_name, + chief_librarian_name, + high_chaplain_name, + high_apothecary_name, + forge_master_name, + lord_admiral_name, + equipment:[], + artifacts:[], + ships:[], + vehicles:[], + }; + + // TODO add indexes to allow easier debugging? + + for(var i = 0; i <= 20; i++){ + _ini_data.company_titles[i] = $"{obj_ini.company_title[i]}"; + } + + for(var i = 0; i <= 120; i++){ + _ini_data.slave_batches[i] = { + slave_batch_num: obj_ini.slave_batch_num[i], + slave_batch_eta: obj_ini.slave_batch_eta[i] + } + } + + for(var i = 1; i <= 150; i++){ + + if(obj_ini.equipment[i] == "") then continue; + + _ini_data.equipment[i] = { + name: obj_ini.equipment[i], + type: obj_ini.equipment_type[i], + amount: obj_ini.equipment_number[i], + condition: obj_ini.equipment_condition[i], + } + } + + for(var i = 1; i <= 150; i++){ + + if(obj_ini.artifact[i] == "") then continue; + + _ini_data.artifacts[i] = { + name: obj_ini.artifact[i], + tags: obj_ini.artifact_tags[i], + is_identified: obj_ini.artifact_identified[i], + condition: obj_ini.artifact_condition[i], + location: obj_ini.artifact_loc[i], + sid: obj_ini.artifact_sid[i], + } + } + + for(var i = 1; i <= 200; i++){ + _ini_data.ships[i] = { + name: obj_ini.ship[i], + uid: obj_ini.ship_uid[i], + class: obj_ini.ship_class[i], + size: obj_ini.ship_size[i], + leadership: obj_ini.ship_leadership[i], + hp: obj_ini.ship_hp[i], + maxhp: obj_ini.ship_maxhp[i], + location: obj_ini.ship_location[i], + shields: obj_ini.ship_shields[i], + conditions: obj_ini.ship_conditions[i], + speed: obj_ini.ship_speed[i], + turning: obj_ini.ship_turning[i], + front_armour: obj_ini.ship_front_armour[i], + other_armour: obj_ini.ship_other_armour[i], + weapons_amount: obj_ini.ship_weapons[i], + weapons: [ + { + name: obj_ini.ship_wep[i][1], + facing: obj_ini.ship_wep_facing[i][1], + condition: obj_ini.ship_wep_condition[i][1], + }, + { + name: obj_ini.ship_wep[i][2], + facing: obj_ini.ship_wep_facing[i][2], + condition: obj_ini.ship_wep_condition[i][2], + }, + { + name: obj_ini.ship_wep[i][3], + facing: obj_ini.ship_wep_facing[i][3], + condition: obj_ini.ship_wep_condition[i][3], + }, + { + name: obj_ini.ship_wep[i][4], + facing: obj_ini.ship_wep_facing[i][4], + condition: obj_ini.ship_wep_condition[i][4], + }, + { + name: obj_ini.ship_wep[i][5], + facing: obj_ini.ship_wep_facing[i][5], + condition: obj_ini.ship_wep_condition[i][5], + }, + ], + capacity: obj_ini.ship_capacity[i], + carrying: obj_ini.ship_carrying[i], + contents: obj_ini.ship_contents[i], + turrets: obj_ini.ship_turrets[i], + } + } + + // I think the below tries to iterate over vehicles backwards + // TODO but why not forwards? + var is_iteration_finished = false; + var company_index = 10; + var entity_in_company_index = 100; + var safety_threshold = 1100; + var iteration = 0; + + // TODO refactor into only checking actually existing entities + while(!is_iteration_finished) + { + iteration++; + + entity_in_company_index--; + if(entity_in_company_index == 0){ + // go to next company, this one is fully checked + entity_in_company_index = 100; + company_index--; + } + if(obj_ini.veh_role[company_index,entity_in_company_index] != ""){ + _ini_data.vehicles[iteration] = { + company_index: company_index, + entity_in_company_index: entity_in_company_index, + race: obj_ini.veh_race[company_index][entity_in_company_index], // TODO Got no idea what this does + location: obj_ini.veh_loc[company_index][entity_in_company_index], + role: obj_ini.veh_role[company_index][entity_in_company_index], + lid: obj_ini.veh_lid[company_index][entity_in_company_index], // TODO Got no idea what this does + uid: obj_ini.veh_uid[company_index][entity_in_company_index], // TODO Got no idea what this does + wid: obj_ini.veh_wid[company_index][entity_in_company_index], // TODO Got no idea what this does + weapons:[ + obj_ini.veh_wep1[company_index][entity_in_company_index], + obj_ini.veh_wep2[company_index][entity_in_company_index], + obj_ini.veh_wep3[company_index][entity_in_company_index], + ], + upgrade: obj_ini.veh_upgrade[company_index][entity_in_company_index], + accessory: obj_ini.veh_acc[company_index][entity_in_company_index], + hp: obj_ini.veh_hp[company_index][entity_in_company_index], + chaos_corruption_level: obj_ini.veh_chaos[company_index][entity_in_company_index], + pilots: obj_ini.veh_pilots[company_index][entity_in_company_index], // TODO this one looks not fully implemented + } + } -// 135; -// with(obj_creation){instance_destroy();} + if(company_index == 1 and entity_in_company_index == 1){ + // At this point all possible vehicles have been checked + is_iteration_finished = true; + } + + if(iteration >= safety_threshold){ + debugl("obj_ini.Serialize(): serializing Vehicles took too long, cancelling..."); + is_iteration_finished = true; + } + + } -/* */ -/* */ + return _ini_data; +} \ No newline at end of file diff --git a/scripts/scr_save/scr_save.gml b/scripts/scr_save/scr_save.gml index 6ca825279..ca284b140 100644 --- a/scripts/scr_save/scr_save.gml +++ b/scripts/scr_save/scr_save.gml @@ -11,7 +11,7 @@ var num = instance_number(obj_star); // https://manual.yoyogames.com/GameMaker_Language/GML_Reference/File_Handling/Encoding_And_Hashing/json_encode.htm // TODO enums - if (save_process_stage = 1) or(save_process_stage = 0) { + if (save_process_stage = 1) or(save_process_stage = 0) { // TODO why 0? debugl("Saving to slot " + string(save_id)); var _save_file_handle = file_text_open_write(save_file); if(_save_file_handle == - 1){ @@ -19,1071 +19,23 @@ var num = instance_number(obj_star); return; } - file_text_write_string(_save_file_handle, json_stringify(global.chapter_name, true)); + //file_text_write_string(_save_file_handle, json_stringify(global.chapter_name, true)); + file_text_write_string(_save_file_handle, json_stringify(new SavedGameData(), true)); file_text_close(_save_file_handle); obj_saveload.save[save_id] = 1; debugl("Saving to slot " + string(save_id) + " complete"); - //ERROR add Save() functions, which will prepare structs, ready for saving } } -/* - -function scr_save(save_process_stage, save_id, save_file) { - var num = instance_number(obj_star); - instance_array[0] = 0; - - if (save_process_stage = 1) or(save_process_stage = 0) { - debugl("Saving to slot " + string(save_id)); - ini_open("save" + string(save_id) + ".ini"); - // Global variables - ini_write_string("Save", "chapter_name", global.chapter_name); - ini_write_string("Save", "sector_name", obj_ini.sector_name); - ini_write_string("Save", "version", global.version); - ini_write_real("Save", "play_time", play_time); - ini_write_real("Save", "game_seed", global.game_seed); - ini_write_real("Save", "use_custom_icon", obj_ini.use_custom_icon); - var t, month, day, year, hour, minute, pm; - t = date_current_datetime(); - month = date_get_month(t); - day = date_get_day(t); - year = date_get_year(t); - hour = date_get_hour(t); - minute = date_get_minute(t); - pm = "AM"; - if (hour = 12) then pm = "PM"; - if (hour > 12) and(hour < 24) { - pm = "PM"; - hour -= 12; - } - if (hour = 24) { - pm = "AM"; - hour -= 12; - } - if (hour = 0) then hour = 12; - - var mahg; - mahg = minute; - if (mahg < 10) then minute = "0" + string(mahg); - - // if (minute<10) then minute="0"+string(minute); - - ini_write_string("Save", "date", string(month) + "/" + string(day) + "/" + string(year) + " (" + string(hour) + ":" + string(minute) + " " + string(pm) + ")"); - ini_write_real("Save", "founding", obj_ini.progenitor); - // ini_write_string("Save","founding_secret",global.founding_secret); - ini_write_real("Save", "custom", global.custom); - ini_write_real("Save", "stars", instance_number(obj_star)); - ini_write_real("Save", "p_fleets", instance_number(obj_p_fleet)); - ini_write_real("Save", "en_fleets", instance_number(obj_en_fleet)); - ini_write_real("Save", "sod", random_get_seed()); - ini_write_real("Save", "corrupt", 1); - // obj_controller variables here - ini_write_real("boolean", "cheat_req", global.cheat_req); - ini_write_real("boolean", "cheat_gene", global.cheat_gene); - ini_write_real("boolean", "cheat_debug", global.cheat_debug); - ini_write_real("boolean", "cheat_disp", global.cheat_disp); - ini_write_real("Controller", "cheatyface", obj_controller.cheatyface); - ini_write_real("Controller", "x", obj_controller.x); - ini_write_real("Controller", "y", obj_controller.y); - ini_write_real("Controller", "alll", obj_controller.alll); - ini_write_real("Controller", "was_zoomed", obj_controller.was_zoomed); - ini_write_real("Controller", "zoomed", obj_controller.zoomed); - ini_write_real("Controller", "chaos_rating", obj_controller.chaos_rating); - ini_write_string("Controller", "fleet_type", obj_controller.fleet_type); - ini_write_real("Controller", "ifleet_type", obj_ini.fleet_type); - ini_write_real("Controller", "home_rule", obj_controller.homeworld_rule); - ini_write_string("Controller", "star_names", obj_controller.star_names); - ini_write_real("Controller", "craworld", obj_controller.craftworld); - ini_write_real("Controller", "turn", obj_controller.turn); - ini_write_real("Controller", "last_event", obj_controller.last_event); - ini_write_real("Controller", "last_mission", obj_controller.last_mission); - ini_write_real("Controller", "last_world_inspection", obj_controller.last_world_inspection); - ini_write_real("Controller", "last_fleet_inspection", obj_controller.last_fleet_inspection); - ini_write_real("Controller", "chaos_turn", obj_controller.chaos_turn); - ini_write_real("Controller", "chaos_fleets", obj_controller.chaos_fleets); - ini_write_real("Controller", "tau_fleets", obj_controller.tau_fleets); - ini_write_real("Controller", "tau_stars", obj_controller.tau_stars); - ini_write_real("Controller", "tau_messenger", obj_controller.tau_messenger); - ini_write_real("Controller", "fleet_all", obj_controller.fleet_all); - ini_write_real("Controller", "tolerant", obj_ini.tolerant); - ini_write_real("Controller", "stability", obj_ini.stability); - ini_write_real("Controller", "purity", obj_ini.purity); - ini_write_real("Controller", "unload", obj_controller.unload); - ini_write_real("Controller", "diplomacy", obj_controller.diplomacy); - ini_write_real("Controller", "trading", obj_controller.trading); - ini_write_real("Controller", "audience", obj_controller.audience); - ini_write_real("Controller", "force_goodbye", obj_controller.force_goodbye); - ini_write_real("Controller", "combat", obj_controller.combat); - ini_write_real("Controller", "new_vehicles", obj_controller.new_vehicles); - ini_write_real("Controller", "hurssy", obj_controller.hurssy); - ini_write_real("Controller", "hurssy_time", obj_controller.hurssy_time); - ini_write_real("Controller", "artifacts", obj_controller.artifacts); - ini_write_real("Controller", "pmc", obj_controller.popup_master_crafted); - ini_write_real("Controller", "wndsel", obj_controller.select_wounded); - ini_write_real("Controller", "imdis", obj_ini.imperium_disposition); - ini_write_real("Controller", "terra_dir", obj_controller.terra_direction); - ini_write_real("Controller", "stc_wargear", obj_controller.stc_wargear); - ini_write_real("Controller", "stc_vehicles", obj_controller.stc_vehicles); - ini_write_real("Controller", "stc_ships", obj_controller.stc_ships); - ini_write_real("Controller", "stc_un_total", obj_controller.stc_un_total); - ini_write_real("Controller", "stc_wargear_un", obj_controller.stc_wargear_un); - ini_write_real("Controller", "stc_vehicles_un", obj_controller.stc_vehicles_un); - ini_write_real("Controller", "stc_ships_un", obj_controller.stc_ships_un); - var j; - j = 0; - repeat(6) { - j += 1; - ini_write_real("Controller", "stc_bonus_" + string(j), obj_controller.stc_bonus[j]); - } - - j = 0; - repeat(4) { - j += 1; - ini_write_string("Controller", "adv" + string(j), obj_ini.adv[j]); - ini_write_string("Controller", "dis" + string(j), obj_ini.dis[j]); - } - - - // Player scheduled event - if (obj_controller.fest_type != "") { - ini_write_real("Controller", "f_si", obj_controller.fest_sid); - ini_write_real("Controller", "f_wi", obj_controller.fest_wid); - ini_write_real("Controller", "f_pl", obj_controller.fest_planet); - ini_write_string("Controller", "f_st", obj_controller.fest_star); - ini_write_string("Controller", "f_t", obj_controller.fest_type); - ini_write_real("Controller", "f_co", obj_controller.fest_cost); - ini_write_real("Controller", "f_wa", obj_controller.fest_warp); - ini_write_real("Controller", "f_sch", obj_controller.fest_scheduled); - ini_write_real("Controller", "f_la", obj_controller.fest_lav); - ini_write_real("Controller", "f_lo", obj_controller.fest_locals); - ini_write_real("Controller", "f_f1", obj_controller.fest_feature1); - ini_write_real("Controller", "f_f2", obj_controller.fest_feature2); - ini_write_real("Controller", "f_f3", obj_controller.fest_feature3); - ini_write_real("Controller", "f_di", obj_controller.fest_display); - ini_write_string("Controller", "f_dit", obj_controller.fest_display_tags); - ini_write_real("Controller", "f_re", obj_controller.fest_repeats); - ini_write_real("Controller", "f_hc", obj_controller.fest_honor_co); - ini_write_real("Controller", "f_hi", obj_controller.fest_honor_id); - ini_write_real("Controller", "f_hon", obj_controller.fest_honoring); - } - ini_write_real("Controller", "f_fee", obj_controller.fest_feasts); - ini_write_real("Controller", "f_boo", obj_controller.fest_boozes); - ini_write_real("Controller", "f_dru", obj_controller.fest_drugses); - ini_write_real("Controller", "rech", obj_controller.recent_happenings); - var i; - i = -1; - repeat(600) { - i += 1; - if (recent_type[i] != "") { - ini_write_string("Controller", "rect" + string(i), obj_controller.recent_type[i]); - ini_write_string("Controller", "reck" + string(i), obj_controller.recent_keyword[i]); - ini_write_real("Controller", "recu" + string(i), obj_controller.recent_turn[i]); - ini_write_real("Controller", "recn" + string(i), obj_controller.recent_number[i]); - } - } - - - ini_write_real("Formation", "last_attack", obj_controller.last_attack_form); - ini_write_real("Formation", "last_raid", obj_controller.last_raid_form); - j = 0; - repeat(14) { - j += 1; - if (obj_controller.bat_formation[j] != "") { - ini_write_string("Formation", "form" + string(j), obj_controller.bat_formation[j]); - ini_write_real("Formation", "form_type" + string(j), obj_controller.bat_formation_type[j]); - ini_write_real("Formation", "deva" + string(j), obj_controller.bat_deva_for[j]); - ini_write_real("Formation", "assa" + string(j), obj_controller.bat_assa_for[j]); - ini_write_real("Formation", "tact" + string(j), obj_controller.bat_tact_for[j]); - ini_write_real("Formation", "vete" + string(j), obj_controller.bat_vete_for[j]); - ini_write_real("Formation", "hire" + string(j), obj_controller.bat_hire_for[j]); - ini_write_real("Formation", "libr" + string(j), obj_controller.bat_libr_for[j]); - ini_write_real("Formation", "comm" + string(j), obj_controller.bat_comm_for[j]); - ini_write_real("Formation", "tech" + string(j), obj_controller.bat_tech_for[j]); - ini_write_real("Formation", "term" + string(j), obj_controller.bat_term_for[j]); - ini_write_real("Formation", "hono" + string(j), obj_controller.bat_hono_for[j]); - ini_write_real("Formation", "drea" + string(j), obj_controller.bat_drea_for[j]); - ini_write_real("Formation", "rhin" + string(j), obj_controller.bat_rhin_for[j]); - ini_write_real("Formation", "pred" + string(j), obj_controller.bat_pred_for[j]); - ini_write_real("Formation", "land" + string(j), obj_controller.bat_land_for[j]); - ini_write_real("Formation", "scou" + string(j), obj_controller.bat_scou_for[j]); - } - } - - - - - ini_write_string("Controller", "random_event_next", obj_controller.random_event_next); - - ini_write_string("Controller", "useful_info", obj_controller.useful_info); - ini_write_real("Controller", "random_event_next", obj_controller.random_event_next); - ini_write_real("Controller", "gene_sold", obj_controller.gene_sold); - ini_write_real("Controller", "gene_xeno", obj_controller.gene_xeno); - ini_write_real("Controller", "gene_tithe", obj_controller.gene_tithe); - ini_write_real("Controller", "gene_iou", obj_controller.gene_iou); - - ini_write_real("Controller", "und_armouries", obj_controller.und_armouries); - ini_write_real("Controller", "und_gene_vaults", obj_controller.und_gene_vaults); - ini_write_real("Controller", "und_lairs", obj_controller.und_lairs); - - // - ini_write_real("Controller", "penitent", obj_controller.penitent); - ini_write_real("Controller", "penitent_current", obj_controller.penitent_current); - ini_write_real("Controller", "penitent_max", obj_controller.penitent_max); - ini_write_real("Controller", "penitent_turnly", obj_controller.penitent_turnly); - ini_write_real("Controller", "penitent_turn", obj_controller.penitent_turn); - ini_write_real("Controller", "penitent_end", obj_controller.penitent_end); - ini_write_real("Controller", "penitent_blood", obj_controller.blood_debt); - // - ini_write_real("Controller", "training_apothecary", obj_controller.training_apothecary); - ini_write_real("Controller", "apothecary_points", obj_controller.apothecary_points); - ini_write_real("Controller", "apothecary_aspirant", obj_controller.apothecary_aspirant); - ini_write_real("Controller", "training_chaplain", obj_controller.training_chaplain); - ini_write_real("Controller", "chaplain_points", obj_controller.chaplain_points); - ini_write_real("Controller", "chaplain_aspirant", obj_controller.chaplain_aspirant); - ini_write_real("Controller", "training_psyker", obj_controller.training_psyker); - ini_write_real("Controller", "psyker_points", obj_controller.psyker_points); - ini_write_real("Controller", "psyker_aspirant", obj_controller.psyker_aspirant); - ini_write_real("Controller", "training_techmarine", obj_controller.training_techmarine); - ini_write_real("Controller", "tech_points", obj_controller.tech_points); - ini_write_real("Controller", "tech_aspirant", obj_controller.tech_aspirant); - - ini_write_real("Controller", "penitorium", obj_controller.penitorium); - - ini_write_string("Controller", "recruiting_worlds", obj_controller.recruiting_worlds); - ini_write_real("Controller", "recruiting", obj_controller.recruiting); - ini_write_string("Controller", "trial", obj_controller.recruit_trial); - ini_write_real("Controller", "recruits", obj_controller.recruits); - ini_write_real("Controller", "recruit_last", obj_controller.recruit_last); - // - var g; - g = -1; - repeat(30) { - g += 1; - ini_write_real("Controller", "command" + string(g), obj_controller.command_set[g]); - } - ini_write_real("Controller", "blandify", obj_controller.blandify); - var g; - g = -1; - repeat(201) { - g += 1; - ini_write_string("Recruit", "rcr" + string(g), obj_controller.recruit_name[g]); - ini_write_real("Recruit", "rcr_cr" + string(g), obj_controller.recruit_corruption[g]); - ini_write_real("Recruit", "rcr_ds" + string(g), obj_controller.recruit_distance[g]); - ini_write_real("Recruit", "rcr_tr" + string(g), obj_controller.recruit_training[g]); - ini_write_real("Recruit", "rcr_ex" + string(g), obj_controller.recruit_exp[g]); - } - var g; - g = -1; - repeat(30) { - g += 1; - ini_write_string("Controller", "lyl" + string(g), obj_controller.loyal[g]); - ini_write_real("Controller", "lyl_nm" + string(g), obj_controller.loyal_num[g]); - ini_write_real("Controller", "lyl_tm" + string(g), obj_controller.loyal_time[g]); - } - var g; - g = -1; - repeat(11) { - g += 1; - ini_write_string("Controller", "inq" + string(g), obj_controller.inquisitor[g]); - ini_write_real("Controller", "inq_ge" + string(g), obj_controller.inquisitor_gender[g]); - ini_write_string("Controller", "inq_ty" + string(g), obj_controller.inquisitor_type[g]); - } - // - var g; - g = -1; - repeat(14) { - g += 1; - ini_write_string("Factions", "fac" + string(g), obj_controller.faction[g]); - ini_write_real("Factions", "dis" + string(g), obj_controller.disposition[g]); - ini_write_real("Factions", "dis_max" + string(g), obj_controller.disposition_max[g]); - - ini_write_string("Factions", "lead" + string(g), obj_controller.faction_leader[g]); - ini_write_real("Factions", "gen" + string(g), obj_controller.faction_gender[g]); - ini_write_string("Factions", "title" + string(g), obj_controller.faction_title[g]); - ini_write_string("Factions", "status" + string(g), obj_controller.faction_status[g]); - ini_write_real("Factions", "defeated" + string(g), obj_controller.faction_defeated[g]); - ini_write_real("Factions", "known" + string(g), known[g]); - - ini_write_real("Factions", "annoyed" + string(g), obj_controller.annoyed[g]); - ini_write_real("Factions", "ignore" + string(g), obj_controller.ignore[g]); - ini_write_real("Factions", "turns_ignored" + string(g), obj_controller.turns_ignored[g]); - - ini_write_real("Factions", "audience" + string(g), obj_controller.audien[g]); - ini_write_string("Factions", "audience_topic" + string(g), obj_controller.audien_topic[g]); - } - // - var g; - g = 0; - repeat(50) { - g += 1; - ini_write_string("Ongoing", "quest" + string(g), obj_controller.quest[g]); - ini_write_real("Ongoing", "quest_faction" + string(g), obj_controller.quest_faction[g]); - ini_write_real("Ongoing", "quest_end" + string(g), obj_controller.quest_end[g]); - } - var g; - g = 0; - repeat(99) { - g += 1; - ini_write_string("Ongoing", "event" + string(g), obj_controller.event[g]); - ini_write_real("Ongoing", "event_duration" + string(g), obj_controller.event_duration[g]); - } - // - ini_write_real("Controller", "justmet", obj_controller.faction_justmet); - ini_write_real("Controller", "check_number", obj_controller.check_number); - ini_write_real("Controller", "year_fraction", obj_controller.year_fraction); - ini_write_real("Controller", "year", obj_controller.year); - ini_write_real("Controller", "millenium", obj_controller.millenium); - // - ini_write_real("Controller", "req", obj_controller.requisition); - // - ini_write_real("Controller", "income", obj_controller.income); - ini_write_real("Controller", "income_last", obj_controller.income_last); - ini_write_real("Controller", "income_base", obj_controller.income_base); - ini_write_real("Controller", "income_home", obj_controller.income_home); - ini_write_real("Controller", "income_forge", obj_controller.income_forge); - ini_write_real("Controller", "income_agri", obj_controller.income_agri); - ini_write_real("Controller", "income_recruiting", obj_controller.income_recruiting); - ini_write_real("Controller", "income_training", obj_controller.income_training); - ini_write_real("Controller", "income_fleet", obj_controller.income_fleet); - ini_write_real("Controller", "income_trade", obj_controller.income_trade); - ini_write_real("Controller", "loyalty", obj_controller.loyalty); - ini_write_real("Controller", "loyalty_hidden", obj_controller.loyalty_hidden); - ini_write_real("Controller", "flag_lair", obj_controller.inqis_flag_lair); - ini_write_real("Controller", "flag_gene", obj_controller.inqis_flag_gene); - - - ini_write_real("Controller", "gene_seed", obj_controller.gene_seed); - ini_write_real("Controller", "marines", obj_controller.marines); - ini_write_real("Controller", "command", obj_controller.command); - ini_write_real("Controller", "info_chips", obj_controller.info_chips); - ini_write_real("Controller", "inspection_passes", obj_controller.inspection_passes); - ini_write_real("Controller", "recruiting_worlds_bought", obj_controller.recruiting_worlds_bought); - ini_write_real("Controller", "lwt", obj_controller.last_weapons_tab); - - ini_write_real("Controller", "bat_devastator_column", obj_controller.bat_devastator_column); - ini_write_real("Controller", "bat_assault_column", obj_controller.bat_assault_column); - ini_write_real("Controller", "bat_tactical_column", obj_controller.bat_tactical_column); - ini_write_real("Controller", "bat_veteran_column", obj_controller.bat_veteran_column); - ini_write_real("Controller", "bat_hire_column", obj_controller.bat_hire_column); - ini_write_real("Controller", "bat_librarian_column", obj_controller.bat_librarian_column); - ini_write_real("Controller", "bat_command_column", obj_controller.bat_command_column); - ini_write_real("Controller", "bat_techmarine_column", obj_controller.bat_techmarine_column); - ini_write_real("Controller", "bat_terminator_column", obj_controller.bat_terminator_column); - ini_write_real("Controller", "bat_honor_column", obj_controller.bat_honor_column); - ini_write_real("Controller", "bat_dreadnought_column", obj_controller.bat_dreadnought_column); - ini_write_real("Controller", "bat_rhino_column", obj_controller.bat_rhino_column); - ini_write_real("Controller", "bat_predator_column", obj_controller.bat_predator_column); - ini_write_real("Controller", "bat_landraider_column", obj_controller.bat_landraider_column); - ini_write_real("Controller", "bat_scout_column", obj_controller.bat_scout_column); - - ini_close(); - } - - - if (save_process_stage = 2) or(save_process_stage = 0) { - debugl("Saving to slot " + string(save_id) + " part 2"); - ini_open("save" + string(save_id) + ".ini"); - // Stars - - var num; - num = instance_number(obj_star); - instance_array = 0; - for (i = 0; i < num; i += 1) { - instance_array[i] = instance_find(obj_star, i); - // save crap here - ini_write_string("Star", "sr" + string(i) + "name", instance_array[i].name); - ini_write_string("Star", "sr" + string(i) + "star", instance_array[i].star); - ini_write_real("Star", "sr" + string(i) + "planets", instance_array[i].planets); - ini_write_real("Star", "sr" + string(i) + "owner", instance_array[i].owner); - - ini_write_real("Star", "sr" + string(i) + "x", instance_array[i].x); - ini_write_real("Star", "sr" + string(i) + "y", instance_array[i].y); - ini_write_real("Star", "sr" + string(i) + "x2", instance_array[i].x2); - ini_write_real("Star", "sr" + string(i) + "y2", instance_array[i].y2); - ini_write_real("Star", "sr" + string(i) + "ox", instance_array[i].old_x); - ini_write_real("Star", "sr" + string(i) + "oy", instance_array[i].old_y); - - ini_write_real("Star", "sr" + string(i) + "vision", instance_array[i].vision); - ini_write_real("Star", "sr" + string(i) + "storm", instance_array[i].storm); - ini_write_real("Star", "sr" + string(i) + "trader", instance_array[i].trader); - ini_write_real("Star", "sr" + string(i) + "craftworld", instance_array[i].craftworld); - ini_write_real("Star", "sr" + string(i) + "spacehulk", instance_array[i].space_hulk); - - var g; - g = 0; - repeat(4) { - g += 1; - if (instance_array[i].planets >= g) { - ini_write_real("Star", "sr" + string(i) + "plan" + string(g), instance_array[i].planet[g]); - ini_write_real("Star", "sr" + string(i) + "dispo" + string(g), instance_array[i].dispo[g]); - ini_write_string("Star", "sr" + string(i) + "type" + string(g), instance_array[i].p_type[g]); - var save_features = []; - if (array_length(instance_array[i].p_feature[g]) > 0) { - for (var f = 0; f < array_length(instance_array[i].p_feature[g]); f++) { - save_features[f] = 0; - var copy_feature = instance_array[i].p_feature[g][f]; - var new_feature = {}; - var names = variable_struct_get_names(copy_feature); - for (var name = 0; name < array_length(names); name++) { - if (!is_method(copy_feature[$ names[name]])) { - variable_struct_set(new_feature, names[name], copy_feature[$ names[name]]) - } - } - save_features[f] = new_feature; - } - } - ini_write_string("Star", "sr" + string(i) + "feat" + string(g), base64_encode(json_stringify(save_features))); - ini_write_real("Star", "sr" + string(i) + "own" + string(g), instance_array[i].p_owner[g]); - ini_write_real("Star", "sr" + string(i) + "fir" + string(g), instance_array[i].p_first[g]); - ini_write_real("Star", "sr" + string(i) + "popul" + string(g), instance_array[i].p_population[g]); - ini_write_real("Star", "sr" + string(i) + "maxpop" + string(g), instance_array[i].p_max_population[g]); - ini_write_real("Star", "sr" + string(i) + "large" + string(g), instance_array[i].p_large[g]); - ini_write_string("Star", "sr" + string(i) + "pop" + string(g), instance_array[i].p_pop[g]); - ini_write_real("Star", "sr" + string(i) + "guard" + string(g), instance_array[i].p_guardsmen[g]); - ini_write_real("Star", "sr" + string(i) + "pdf" + string(g), instance_array[i].p_pdf[g]); - ini_write_real("Star", "sr" + string(i) + "forti" + string(g), instance_array[i].p_fortified[g]); - ini_write_real("Star", "sr" + string(i) + "stat" + string(g), instance_array[i].p_station[g]); - - ini_write_real("Star", "sr" + string(i) + "play" + string(g), instance_array[i].p_player[g]); - if (instance_array[i].p_first[g] = 1) or(instance_array[i].p_owner[g] = 1) { - ini_write_real("Star", "sr" + string(i) + "p_lasers" + string(g), instance_array[i].p_lasers[g]); - ini_write_real("Star", "sr" + string(i) + "p_silo" + string(g), instance_array[i].p_silo[g]); - ini_write_real("Star", "sr" + string(i) + "p_defenses" + string(g), instance_array[i].p_defenses[g]); - } - save_features = []; - if (array_length(instance_array[i].p_upgrades[g]) > 0) { - for (var f = 0; f < array_length(instance_array[i].p_upgrades[g]); f++) { - save_features[f] = 0; - var copy_feature = instance_array[i].p_upgrades[g][f]; - var new_feature = {}; - var names = variable_struct_get_names(copy_feature); - for (var name = 0; name < array_length(names); name++) { - if (!is_method(copy_feature[$ names[name]])) { - variable_struct_set(new_feature, names[name], copy_feature[$ names[name]]) - } - } - save_features[f] = new_feature; - } - } - ini_write_string("Star", "sr" + string(i) + "upg" + string(g), base64_encode(json_stringify(save_features))); - ini_write_real("Star", "sr" + string(i) + "or" + string(g), instance_array[i].p_orks[g]); - ini_write_real("Star", "sr" + string(i) + "ta" + string(g), instance_array[i].p_tau[g]); - ini_write_real("Star", "sr" + string(i) + "el" + string(g), instance_array[i].p_eldar[g]); - ini_write_real("Star", "sr" + string(i) + "tr" + string(g), instance_array[i].p_traitors[g]); - ini_write_real("Star", "sr" + string(i) + "ch" + string(g), instance_array[i].p_chaos[g]); - ini_write_real("Star", "sr" + string(i) + "de" + string(g), instance_array[i].p_demons[g]); - ini_write_real("Star", "sr" + string(i) + "si" + string(g), instance_array[i].p_sisters[g]); - ini_write_real("Star", "sr" + string(i) + "ne" + string(g), instance_array[i].p_necrons[g]); - ini_write_real("Star", "sr" + string(i) + "tyr" + string(g), instance_array[i].p_tyranids[g]); - ini_write_real("Star", "sr" + string(i) + "halp" + string(g), instance_array[i].p_halp[g]); - - ini_write_real("Star", "sr" + string(i) + "hurssy" + string(g), instance_array[i].p_hurssy[g]); - ini_write_real("Star", "sr" + string(i) + "hurssy_time" + string(g), instance_array[i].p_hurssy_time[g]); - ini_write_real("Star", "sr" + string(i) + "heresy" + string(g), instance_array[i].p_heresy[g]); - ini_write_real("Star", "sr" + string(i) + "heresy_secret" + string(g), instance_array[i].p_heresy_secret[g]); - ini_write_real("Star", "sr" + string(i) + "influence" + string(g), instance_array[i].p_influence[g]); - ini_write_real("Star", "sr" + string(i) + "raided" + string(g), instance_array[i].p_raided[g]); - - ini_write_string("Star", "sr" + string(i) + "prob" + string(g) + ".1", instance_array[i].p_problem[g, 1]); - ini_write_real("Star", "sr" + string(i) + "time" + string(g) + ".1", instance_array[i].p_timer[g, 1]); - - ini_write_string("Star", "sr" + string(i) + "prob" + string(g) + ".2", instance_array[i].p_problem[g, 2]); - ini_write_real("Star", "sr" + string(i) + "time" + string(g) + ".2", instance_array[i].p_timer[g, 2]); - - ini_write_string("Star", "sr" + string(i) + "prob" + string(g) + ".3", instance_array[i].p_problem[g, 3]); - ini_write_real("Star", "sr" + string(i) + "time" + string(g) + ".3", instance_array[i].p_timer[g, 3]); - - ini_write_string("Star", "sr" + string(i) + "prob" + string(g) + ".4", instance_array[i].p_problem[g, 4]); - ini_write_real("Star", "sr" + string(i) + "time" + string(g) + ".4", instance_array[i].p_timer[g, 4]); - } - } - } - - - // Temporary artifact objects - ini_write_real("Controller", "temp_arti", instance_number(obj_temp_arti)); - num = instance_number(obj_temp_arti); - instance_array = 0; - for (i = 0; i < num; i += 1) { - instance_array[i] = instance_find(obj_temp_arti, i); - ini_write_real("Star", "ar" + string(i) + "x", instance_array[i].x); - ini_write_real("Star", "ar" + string(i) + "y", instance_array[i].y); - } - - // PLAYER FLEET OBJECTS - num = instance_number(obj_p_fleet); - instance_array[0] = 0; - - for (i = 0; i < num; i += 1) { - instance_array[i] = instance_find(obj_p_fleet, i); - - ini_write_real("Fleet", "pf" + string(i) + "image", instance_array[i].image_index); - ini_write_real("Fleet", "pf" + string(i) + "x", instance_array[i].x); - ini_write_real("Fleet", "pf" + string(i) + "y", instance_array[i].y); - ini_write_real("Fleet", "pf" + string(i) + "capitals", instance_array[i].capital_number); - ini_write_real("Fleet", "pf" + string(i) + "frigates", instance_array[i].frigate_number); - ini_write_real("Fleet", "pf" + string(i) + "escorts", instance_array[i].escort_number); - ini_write_real("Fleet", "pf" + string(i) + "selected", instance_array[i].selected); - ini_write_real("Fleet", "pf" + string(i) + "capital_hp", instance_array[i].capital_health); - ini_write_real("Fleet", "pf" + string(i) + "frigate_hp", instance_array[i].frigate_health); - ini_write_real("Fleet", "pf" + string(i) + "escort_hp", instance_array[i].escort_health); - ini_write_string("Fleet", "pf" + string(i) + "action", instance_array[i].action); - ini_write_real("Fleet", "pf" + string(i) + "action_x", instance_array[i].action_x); - ini_write_real("Fleet", "pf" + string(i) + "action_y", instance_array[i].action_y); - ini_write_real("Fleet", "pf" + string(i) + "action_spd", instance_array[i].action_spd); - ini_write_real("Fleet", "pf" + string(i) + "action_eta", instance_array[i].action_eta); - ini_write_real("Fleet", "pf" + string(i) + "connected", instance_array[i].connected); - ini_write_real("Fleet", "pf" + string(i) + "acted", instance_array[i].acted); - ini_write_real("Fleet", "pf" + string(i) + "hurssy", instance_array[i].hurssy); - ini_write_real("Fleet", "pf" + string(i) + "hurssy_time", instance_array[i].hurssy_time); - ini_write_real("Fleet", "pf" + string(i) + "orb", instance_array[i].orbiting); - var g; - g = -1; - repeat(10) { - g += 1; - ini_write_string("Fleet", "pf" + string(i) + "capital" + string(g), instance_array[i].capital[g]); - ini_write_real("Fleet", "pf" + string(i) + "capital_num" + string(g), instance_array[i].capital_num[g]); - ini_write_real("Fleet", "pf" + string(i) + "capital_sel" + string(g), instance_array[i].capital_sel[g]); - ini_write_real("Fleet", "pf" + string(i) + "capital_uid" + string(g), instance_array[i].capital_uid[g]); - } - g = -1; - repeat(21) { - g += 1; - ini_write_string("Fleet", "pf" + string(i) + "frigate" + string(g), instance_array[i].frigate[g]); - ini_write_real("Fleet", "pf" + string(i) + "frigate_num" + string(g), instance_array[i].frigate_num[g]); - ini_write_real("Fleet", "pf" + string(i) + "frigate_sel" + string(g), instance_array[i].frigate_sel[g]); - ini_write_real("Fleet", "pf" + string(i) + "frigate_uid" + string(g), instance_array[i].frigate_uid[g]); - } - g = -1; - repeat(35) { - g += 1; - ini_write_string("Fleet", "pf" + string(i) + "escort" + string(g), instance_array[i].escort[g]); - ini_write_real("Fleet", "pf" + string(i) + "escort_num" + string(g), instance_array[i].escort_num[g]); - ini_write_real("Fleet", "pf" + string(i) + "escort_sel" + string(g), instance_array[i].escort_sel[g]); - ini_write_real("Fleet", "pf" + string(i) + "escort_uid" + string(g), instance_array[i].escort_uid[g]); - } - } - - // ENEMY FLEET OBJECTS - num = instance_number(obj_en_fleet); - instance_array[0] = 0; - - for (i = 0; i < num; i += 1) { - instance_array[i] = instance_find(obj_en_fleet, i); - ini_write_real("Fleet", "ef" + string(i) + "owner", instance_array[i].owner); - ini_write_real("Fleet", "ef" + string(i) + "x", instance_array[i].x); - ini_write_real("Fleet", "ef" + string(i) + "y", instance_array[i].y); - ini_write_real("Fleet", "ef" + string(i) + "sprite", instance_array[i].sprite_index); - ini_write_real("Fleet", "ef" + string(i) + "image", instance_array[i].image_index); - ini_write_real("Fleet", "ef" + string(i) + "alpha", instance_array[i].image_alpha); - ini_write_real("Fleet", "ef" + string(i) + "capitals", instance_array[i].capital_number); - ini_write_real("Fleet", "ef" + string(i) + "frigates", instance_array[i].frigate_number); - ini_write_real("Fleet", "ef" + string(i) + "escorts", instance_array[i].escort_number); - ini_write_real("Fleet", "ef" + string(i) + "selected", instance_array[i].selected); - ini_write_string("Fleet", "ef" + string(i) + "action", instance_array[i].action); - ini_write_real("Fleet", "ef" + string(i) + "action_x", instance_array[i].action_x); - ini_write_real("Fleet", "ef" + string(i) + "action_y", instance_array[i].action_y); - ini_write_real("Fleet", "ef" + string(i) + "home_x", instance_array[i].home_x); - ini_write_real("Fleet", "ef" + string(i) + "home_y", instance_array[i].home_y); - - ini_write_real("Fleet", "ef" + string(i) + "target", instance_array[i].target); - ini_write_real("Fleet", "ef" + string(i) + "target_x", instance_array[i].target_x); - ini_write_real("Fleet", "ef" + string(i) + "target_y", instance_array[i].target_y); - - ini_write_real("Fleet", "ef" + string(i) + "action_spd", instance_array[i].action_spd); - ini_write_real("Fleet", "ef" + string(i) + "action_eta", instance_array[i].action_eta); - ini_write_real("Fleet", "ef" + string(i) + "connected", instance_array[i].connected); - ini_write_real("Fleet", "ef" + string(i) + "loaded", instance_array[i].loaded); - ini_write_string("Fleet", "ef" + string(i) + "trade", instance_array[i].trade_goods); - ini_write_real("Fleet", "ef" + string(i) + "guardsmen", instance_array[i].guardsmen); - ini_write_real("Fleet", "ef" + string(i) + "orb", instance_array[i].orbiting); - ini_write_real("Fleet", "ef" + string(i) + "navy", instance_array[i].navy); - ini_write_real("Fleet", "ef" + string(i) + "unl", instance_array[i].guardsmen_unloaded); - - if (instance_array[i].navy = 1) { - var e; - e = -1; - repeat(20) { - e += 1; - ini_write_real("Fleet", "ef" + string(i) + "navy_cap." + string(e), instance_array[i].capital_imp[e]); - ini_write_real("Fleet", "ef" + string(i) + "navy_cap_max." + string(e), instance_array[i].capital_max_imp[e]); - } - e = -1; - repeat(30) { - e += 1; - ini_write_real("Fleet", "ef" + string(i) + "navy_fri." + string(e), instance_array[i].frigate_imp[e]); - ini_write_real("Fleet", "ef" + string(i) + "navy_fri_max." + string(e), instance_array[i].frigate_max_imp[e]); - ini_write_real("Fleet", "ef" + string(i) + "navy_esc." + string(e), instance_array[i].escort_imp[e]); - ini_write_real("Fleet", "ef" + string(i) + "navy_esc_max." + string(e), instance_array[i].escort_max_imp[e]); - } - } - } - - // obj_ini - ini_write_string("Ini", "home_name", obj_ini.home_name); - ini_write_string("Ini", "home_type", obj_ini.home_type); - ini_write_string("Ini", "recruiting_name", obj_ini.recruiting_name); - ini_write_string("Ini", "recruiting_type", obj_ini.recruiting_type); - ini_write_string("Ini", "chapter_name", obj_ini.chapter_name); - // ini_write_string("Ini","fortress_name",obj_ini.fortress_name); - ini_write_string("Ini", "flagship_name", obj_ini.flagship_name); - ini_write_real("Ini", "icon", obj_ini.icon); - ini_write_string("Ini", "icon_name", obj_ini.icon_name); - ini_write_real("Ini", "man_size", obj_ini.man_size); - ini_write_string("Ini", "strin1", obj_ini.strin); - ini_write_string("Ini", "strin2", obj_ini.strin2); - ini_write_string("Ini", "psy_powers", obj_ini.psy_powers); - - ini_write_real("Ini", "companies", obj_ini.companies); - var i; - i = -1; - repeat(21) { - i += 1; - ini_write_string("Ini", "comp_title" + string(i), obj_ini.company_title[i]); - } - var i; - i = -1; - repeat(121) { - i += 1; - ini_write_real("Ini", "slave_num_" + string(i), obj_ini.slave_batch_num[i]); - ini_write_real("Ini", "slave_eta_" + string(i), obj_ini.slave_batch_eta[i]); - } - - ini_write_string("Ini", "battle_cry", obj_ini.battle_cry); - - ini_write_string("Controller", "main_color", obj_controller.col[obj_controller.main_color]); - ini_write_string("Controller", "secondary_color", obj_controller.col[obj_controller.secondary_color]); - ini_write_string("Controller", "trim_color", obj_controller.col[obj_controller.trim_color]); - ini_write_string("Controller", "pauldron2_color", obj_controller.col[obj_controller.pauldron2_color]); - ini_write_string("Controller", "pauldron_color", obj_controller.col[obj_controller.pauldron_color]); - ini_write_string("Controller", "lens_color", obj_controller.col[obj_controller.lens_color]); - ini_write_string("Controller", "weapon_color", obj_controller.col[obj_controller.weapon_color]); - ini_write_real("Controller", "col_special", obj_controller.col_special); - ini_write_real("Controller", "trimmed", obj_controller.trim); - ini_write_real("Controller", "skin_color", obj_ini.skin_color); - - ini_write_string("Ini", "adept_name", obj_controller.adept_name); - ini_write_string("Ini", "recruiter_name", obj_controller.recruiter_name); - // ini_write_string("Ini","progenitor",obj_controller.progenitor); - ini_write_string("Ini", "mutation", obj_controller.mutation); - ini_write_real("Ini", "successors", obj_controller.successor_chapters); - ini_write_real("Ini", "progenitor_disposition", obj_controller.progenitor_disposition); - ini_write_real("Ini", "imperium_disposition", obj_controller.imperium_disposition); - ini_write_real("Ini", "astartes_disposition", obj_controller.astartes_disposition); - - ini_write_real("Ini", "master_autarch", obj_ini.master_autarch); - ini_write_real("Ini", "master_avatar", obj_ini.master_avatar); - ini_write_real("Ini", "master_farseer", obj_ini.master_farseer); - ini_write_real("Ini", "master_aspect", obj_ini.master_aspect); - ini_write_real("Ini", "master_eldar", obj_ini.master_eldar); - ini_write_real("Ini", "master_eldar_vehicles", obj_ini.master_eldar_vehicles); - ini_write_real("Ini", "master_tau", obj_ini.master_tau); - ini_write_real("Ini", "master_battlesuits", obj_ini.master_battlesuits); - ini_write_real("Ini", "master_kroot", obj_ini.master_kroot); - ini_write_real("Ini", "master_tau_vehicles", obj_ini.master_tau_vehicles); - ini_write_real("Ini", "master_ork_boyz", obj_ini.master_ork_boyz); - ini_write_real("Ini", "master_ork_nobz", obj_ini.master_ork_nobz); - ini_write_real("Ini", "master_ork_warboss", obj_ini.master_ork_warboss); - ini_write_real("Ini", "master_ork_vehicles", obj_ini.master_ork_vehicles); - ini_write_real("Ini", "master_heretics", obj_ini.master_heretics); - ini_write_real("Ini", "master_chaos_marines", obj_ini.master_chaos_marines); - ini_write_real("Ini", "master_lesser_demons", obj_ini.master_lesser_demons); - ini_write_real("Ini", "master_greater_demons", obj_ini.master_greater_demons); - ini_write_real("Ini", "master_chaos_vehicles", obj_ini.master_chaos_vehicles); - ini_write_real("Ini", "master_gaunts", obj_ini.master_gaunts); - ini_write_real("Ini", "master_warriors", obj_ini.master_warriors); - ini_write_real("Ini", "master_carnifex", obj_ini.master_carnifex); - ini_write_real("Ini", "master_synapse", obj_ini.master_synapse); - ini_write_real("Ini", "master_tyrant", obj_ini.master_tyrant); - ini_write_real("Ini", "master_gene", obj_ini.master_gene); - ini_write_real("Ini", "master_necron_overlord", obj_ini.master_necron_overlord); - ini_write_real("Ini", "master_destroyer", obj_ini.master_destroyer); - ini_write_real("Ini", "master_necron", obj_ini.master_necron); - ini_write_real("Ini", "master_wraith", obj_ini.master_wraith); - ini_write_real("Ini", "master_necron_vehicles", obj_ini.master_necron_vehicles); - ini_write_real("Ini", "master_monolith", obj_ini.master_monolith); - ini_write_string("Ini", "master_special", obj_ini.master_special_killed); - - - // - ini_write_real("Ini", "preomnor", obj_ini.preomnor); - ini_write_real("Ini", "voice", obj_ini.voice); - ini_write_real("Ini", "doomed", obj_ini.doomed); - ini_write_real("Ini", "lyman", obj_ini.lyman); - ini_write_real("Ini", "omophagea", obj_ini.omophagea); - ini_write_real("Ini", "ossmodula", obj_ini.ossmodula); - ini_write_real("Ini", "membrane", obj_ini.membrane); - ini_write_real("Ini", "zygote", obj_ini.zygote); - ini_write_real("Ini", "betchers", obj_ini.betchers); - ini_write_real("Ini", "catalepsean", obj_ini.catalepsean); - ini_write_real("Ini", "secretions", obj_ini.secretions); - ini_write_real("Ini", "occulobe", obj_ini.occulobe); - ini_write_real("Ini", "mucranoid", obj_ini.mucranoid); - // - ini_write_string("Ini", "master_name", obj_ini.master_name); - ini_write_string("Ini", "chief_name", obj_ini.chief_librarian_name); - ini_write_string("Ini", "high_name", obj_ini.high_chaplain_name); - ini_write_string("Ini", "high2_name", obj_ini.high_apothecary_name); - ini_write_string("Ini", "forgey_name", obj_ini.forge_master_name); - ini_write_string("Ini", "lord_name", obj_ini.lord_admiral_name); - // - var g; - g = 0; - repeat(150) { - g += 1; - if (obj_ini.equipment[g] != "") { - ini_write_string("Ini", "equipment" + string(g), obj_ini.equipment[g]); - ini_write_string("Ini", "equipment_type" + string(g), obj_ini.equipment_type[g]); - ini_write_real("Ini", "equipment_number" + string(g), obj_ini.equipment_number[g]); - ini_write_real("Ini", "equipment_condition" + string(g), obj_ini.equipment_condition[g]); - } - if (obj_ini.artifact[g] != "") { - ini_write_string("Ini", "artifact" + string(g), obj_ini.artifact[g]); - ini_write_string("Ini", "artifact_tags" + string(g), obj_ini.artifact_tags[g]); - ini_write_real("Ini", "artifact_ident" + string(g), obj_ini.artifact_identified[g]); - ini_write_real("Ini", "artifact_condition" + string(g), obj_ini.artifact_condition[g]); - ini_write_string("Ini", "artifact_loc" + string(g), obj_ini.artifact_loc[g]); - ini_write_real("Ini", "artifact_sid" + string(g), obj_ini.artifact_sid[g]); - } - } - // - var g; - g = 0; - repeat(200) { - g += 1; - ini_write_string("Ships", "shi" + string(g), obj_ini.ship[g]); - ini_write_real("Ships", "shi_uid" + string(g), obj_ini.ship_uid[g]); - ini_write_string("Ships", "shi_class" + string(g), obj_ini.ship_class[g]); - - ini_write_real("Ships", "shi_size" + string(g), obj_ini.ship_size[g]); - ini_write_real("Ships", "shi_leadership" + string(g), obj_ini.ship_leadership[g]); - ini_write_real("Ships", "shi_hp" + string(g), obj_ini.ship_hp[g]); - ini_write_real("Ships", "shi_maxhp" + string(g), obj_ini.ship_maxhp[g]); - ini_write_string("Ships", "shi_location" + string(g), obj_ini.ship_location[g]); - ini_write_real("Ships", "shi_shields" + string(g), obj_ini.ship_shields[g]); - ini_write_string("Ships", "shi_conditions" + string(g), obj_ini.ship_conditions[g]); - ini_write_real("Ships", "shi_speed" + string(g), obj_ini.ship_speed[g]); - ini_write_real("Ships", "shi_turning" + string(g), obj_ini.ship_turning[g]); - ini_write_real("Ships", "shi_front_ac" + string(g), obj_ini.ship_front_armour[g]); - ini_write_real("Ships", "shi_other_ac" + string(g), obj_ini.ship_other_armour[g]); - ini_write_real("Ships", "shi_weapons" + string(g), obj_ini.ship_weapons[g]); - // - ini_write_string("Ships", "shi" + string(g) + "wep1", obj_ini.ship_wep[g, 1]); - ini_write_string("Ships", "shi" + string(g) + "facing1", obj_ini.ship_wep_facing[g, 1]); - ini_write_string("Ships", "shi" + string(g) + "condition1", obj_ini.ship_wep_condition[g, 1]); - // - ini_write_string("Ships", "shi" + string(g) + "wep2", obj_ini.ship_wep[g, 2]); - ini_write_string("Ships", "shi" + string(g) + "facing2", obj_ini.ship_wep_facing[g, 2]); - ini_write_string("Ships", "shi" + string(g) + "condition2", obj_ini.ship_wep_condition[g, 2]); - // - ini_write_string("Ships", "shi" + string(g) + "wep3", obj_ini.ship_wep[g, 3]); - ini_write_string("Ships", "shi" + string(g) + "facing3", obj_ini.ship_wep_facing[g, 3]); - ini_write_string("Ships", "shi" + string(g) + "condition3", obj_ini.ship_wep_condition[g, 3]); - // - ini_write_string("Ships", "shi" + string(g) + "wep4", obj_ini.ship_wep[g, 4]); - ini_write_string("Ships", "shi" + string(g) + "facing4", obj_ini.ship_wep_facing[g, 4]); - ini_write_string("Ships", "shi" + string(g) + "condition4", obj_ini.ship_wep_condition[g, 4]); - // - ini_write_string("Ships", "shi" + string(g) + "wep5", obj_ini.ship_wep[g, 5]); - ini_write_string("Ships", "shi" + string(g) + "facing5", obj_ini.ship_wep_facing[g, 5]); - ini_write_string("Ships", "shi" + string(g) + "condition5", obj_ini.ship_wep_condition[g, 5]); - // - ini_write_real("Ships", "shi_capacity" + string(g), obj_ini.ship_capacity[g]); - ini_write_real("Ships", "shi_carrying" + string(g), obj_ini.ship_carrying[g]); - ini_write_string("Ships", "shi_contents" + string(g), obj_ini.ship_contents[g]); - ini_write_real("Ships", "shi_turrets" + string(g), obj_ini.ship_turrets[g]); - } - // the fun begins here - ini_close(); - } - - - if (save_process_stage = 3) or(save_process_stage = 0) { - debugl("Saving to slot " + string(save_id) + " part 3"); - ini_open("save" + string(save_id) + ".ini"); - var coh, mah, good; - good = 0; - coh = 10; - mah = 100; - repeat(1000) { - if (good = 0) { - mah -= 1; - if (mah = 0) { - mah = 100; - coh -= 1; - } - if (obj_ini.veh_role[coh, mah] != "") { - ini_write_real("Veh", "co" + string(coh) + "." + string(mah), obj_ini.veh_race[coh, mah]); - ini_write_string("Veh", "lo" + string(coh) + "." + string(mah), obj_ini.veh_loc[coh, mah]); - ini_write_string("Veh", "rol" + string(coh) + "." + string(mah), obj_ini.veh_role[coh, mah]); - ini_write_real("Veh", "lid" + string(coh) + "." + string(mah), obj_ini.veh_lid[coh, mah]); - ini_write_real("Veh", "uid" + string(coh) + "." + string(mah), obj_ini.veh_uid[coh, mah]); - ini_write_real("Veh", "wid" + string(coh) + "." + string(mah), obj_ini.veh_wid[coh, mah]); - - ini_write_string("Veh", "w1" + string(coh) + "." + string(mah), obj_ini.veh_wep1[coh, mah]); - ini_write_string("Veh", "w2" + string(coh) + "." + string(mah), obj_ini.veh_wep2[coh, mah]); - ini_write_string("Veh", "w3" + string(coh) + "." + string(mah), obj_ini.veh_wep3[coh, mah]); - ini_write_string("Veh", "up" + string(coh) + "." + string(mah), obj_ini.veh_upgrade[coh, mah]); - ini_write_string("Veh", "ac" + string(coh) + "." + string(mah), obj_ini.veh_acc[coh, mah]); - - ini_write_real("Veh", "hp" + string(coh) + "." + string(mah), obj_ini.veh_hp[coh, mah]); - ini_write_real("Veh", "cha" + string(coh) + "." + string(mah), obj_ini.veh_chaos[coh, mah]); - // ini_write_real("Veh","pil"+string(coh)+"."+string(mah),obj_ini.veh_pilots[coh,mah]); - } - if (coh = 1) and(mah = 1) then good = 1; - } - } - - - - - var i; - i = 0; - ini_write_string("Res", "nm", obj_controller.restart_name); - ini_write_real("Res", "found", obj_controller.restart_founding); - ini_write_string("Res", "secre", obj_controller.restart_secret); - ini_write_string("Res", "tit0", obj_controller.restart_title[0]); - var i; - i = 0; - repeat(11) { - i += 1; - ini_write_string("Res", "tit" + string(i), obj_controller.restart_title[i]); - } - ini_write_real("Res", "ico", obj_controller.restart_icon); - ini_write_string("Res", "icn", obj_controller.restart_icon_name); - ini_write_string("Res", "power", obj_controller.restart_powers); - var ad; - ad = -1; - repeat(5) { - ad += 1; - ini_write_string("Res", "adv" + string(ad), obj_controller.restart_adv[ad]); - ini_write_string("Res", "dis" + string(ad), obj_controller.restart_dis[ad]); - } - ini_write_string("Res", "rcrtyp", obj_controller.restart_recruiting_type); - ini_write_string("Res", "trial", obj_controller.restart_trial); - ini_write_string("Res", "rcrnam", obj_controller.restart_recruiting_name); - ini_write_string("Res", "homtyp", obj_controller.restart_home_type); - ini_write_string("Res", "homnam", obj_controller.restart_home_name); - - ini_write_real("Res", "flit", obj_controller.restart_fleet_type); - ini_write_real("Res", "recr_e", obj_controller.restart_recruiting_exists); - ini_write_real("Res", "home_e", obj_controller.restart_homeworld_exists); - ini_write_real("Res", "home_r", obj_controller.restart_homeworld_rule); - ini_write_string("Res", "cry", obj_controller.restart_battle_cry); - ini_write_string("Res", "flagship", obj_controller.restart_flagship_name); - ini_write_string("Res", "maincol", obj_controller.col[obj_controller.restart_main_color]); - ini_write_string("Res", "seccol", obj_controller.col[obj_controller.restart_secondary_color]); - ini_write_string("Res", "tricol", obj_controller.col[obj_controller.restart_trim_color]); - ini_write_string("Res", "paul2col", obj_controller.col[obj_controller.restart_pauldron2_color]); - ini_write_string("Res", "paul1col", obj_controller.col[obj_controller.restart_pauldron_color]); - ini_write_string("Res", "lenscol", obj_controller.col[obj_controller.restart_lens_color]); - ini_write_string("Res", "wepcol", obj_controller.col[obj_controller.restart_weapon_color]); - ini_write_real("Res", "speccol", obj_controller.restart_col_special); - ini_write_real("Res", "trim", obj_controller.restart_trim); - ini_write_real("Res", "skin", obj_controller.restart_skin_color); - ini_write_string("Res", "hapo", obj_controller.restart_hapothecary); - ini_write_string("Res", "hcha", obj_controller.restart_hchaplain); - ini_write_string("Res", "clib", obj_controller.restart_clibrarian); - ini_write_string("Res", "fmas", obj_controller.restart_fmaster); - ini_write_string("Res", "recruiter", obj_controller.restart_recruiter); - ini_write_string("Res", "admir", obj_controller.restart_admiral); - ini_write_real("Res", "eqspec", obj_controller.restart_equal_specialists); - ini_write_string("Res", "load2", base64_encode(json_stringify(obj_controller.restart_load_to_ships))); - ini_write_real("Res", "successors", obj_controller.restart_successors); - ini_write_real("Res", "muta", obj_controller.restart_mutations); - ini_write_real("Res", "preo", obj_controller.restart_preomnor); - ini_write_real("Res", "voic", obj_controller.restart_voice); - ini_write_real("Res", "doom", obj_controller.restart_doomed); - ini_write_real("Res", "lyma", obj_controller.restart_lyman); - ini_write_real("Res", "omop", obj_controller.restart_omophagea); - ini_write_real("Res", "ossm", obj_controller.restart_ossmodula); - ini_write_real("Res", "memb", obj_controller.restart_membrane); - ini_write_real("Res", "zygo", obj_controller.restart_zygote); - ini_write_real("Res", "betc", obj_controller.restart_betchers); - ini_write_real("Res", "catal", obj_controller.restart_catalepsean); - ini_write_real("Res", "secr", obj_controller.restart_secretions); - ini_write_real("Res", "occu", obj_controller.restart_occulobe); - ini_write_real("Res", "mucra", obj_controller.restart_mucranoid); - ini_write_string("Res", "master_name", obj_controller.restart_master_name); - ini_write_real("Res", "master_melee", obj_controller.restart_master_melee); - ini_write_real("Res", "master_ranged", obj_controller.restart_master_ranged); - ini_write_real("Res", "master_specialty", obj_controller.restart_master_specialty); - ini_write_real("Res", "strength", obj_controller.restart_strength); - ini_write_real("Res", "cooperation", obj_controller.restart_cooperation); - ini_write_real("Res", "purity", obj_controller.restart_purity); - ini_write_real("Res", "stability", obj_controller.restart_stability); - i = 99; - repeat(3) { - i += 1; - var o; - o = 1; - repeat(14) { - o += 1; - if (o = 11) then o = 12; - if (o = 13) then o = 14; - ini_write_real("Res", "r_race" + string(i) + "." + string(o), obj_controller.r_race[i, o]); - ini_write_string("Res", "r_role" + string(i) + "." + string(o), obj_controller.r_role[i, o]); - ini_write_string("Res", "r_wep1" + string(i) + "." + string(o), obj_controller.r_wep1[i, o]); - ini_write_string("Res", "r_wep2" + string(i) + "." + string(o), obj_controller.r_wep2[i, o]); - ini_write_string("Res", "r_armour" + string(i) + "." + string(o), obj_controller.r_armour[i, o]); - ini_write_string("Res", "r_mobi" + string(i) + "." + string(o), obj_controller.r_mobi[i, o]); - ini_write_string("Res", "r_gear" + string(i) + "." + string(o), obj_controller.r_gear[i, o]); - } - } // 100 is defaults, 101 is the allowable starting equipment - - - ini_close(); - } - - if (save_process_stage = 4) or(save_process_stage = 0) { - debugl("Saving to slot " + string(save_id) + " part 4"); - ini_open("save" + string(save_id) + ".ini"); - var coh, mah, good; - good = 0; - coh = 100; - mah = 0; - repeat(30) { - mah += 1; - if (obj_ini.role[coh, mah] != "") { - ini_write_real("Mar", "co" + string(coh) + "." + string(mah), obj_ini.race[coh, mah]); - ini_write_string("Mar", "num" + string(coh) + "." + string(mah), obj_ini.name[coh, mah]); - ini_write_string("Mar", "rol" + string(coh) + "." + string(mah), obj_ini.role[coh, mah]); - ini_write_string("Mar", "w1" + string(coh) + "." + string(mah), obj_ini.wep1[coh, mah]); - ini_write_string("Mar", "w2" + string(coh) + "." + string(mah), obj_ini.wep2[coh, mah]); - ini_write_string("Mar", "ar" + string(coh) + "." + string(mah), obj_ini.armour[coh, mah]); - ini_write_string("Mar", "ge" + string(coh) + "." + string(mah), obj_ini.gear[coh, mah]); - ini_write_string("Mar", "mb" + string(coh) + "." + string(mah), obj_ini.mobi[coh, mah]); - } - } - for (coh = 0; coh <= 10; coh++) { - for (mah = 0; mah <= 500; mah++) { - if (obj_ini.name[coh, mah] != "") { - ini_write_real("Mar", "co" + string(coh) + "." + string(mah), obj_ini.race[coh, mah]); - ini_write_string("Mar", "lo" + string(coh) + "." + string(mah), obj_ini.loc[coh, mah]); - ini_write_string("Mar", "num" + string(coh) + "." + string(mah), obj_ini.name[coh, mah]); - ini_write_string("Mar", "rol" + string(coh) + "." + string(mah), obj_ini.role[coh, mah]); - ini_write_real("Mar", "li" + string(coh) + "." + string(mah), obj_ini.lid[coh, mah]); - ini_write_real("Mar", "bio" + string(coh) + "." + string(mah), obj_ini.bio[coh, mah]); - ini_write_real("Mar", "wi" + string(coh) + "." + string(mah), obj_ini.wid[coh, mah]); - - ini_write_string("Mar", "w1" + string(coh) + "." + string(mah), obj_ini.wep1[coh, mah]); - ini_write_string("Mar", "w2" + string(coh) + "." + string(mah), obj_ini.wep2[coh, mah]); - ini_write_string("Mar", "ar" + string(coh) + "." + string(mah), obj_ini.armour[coh, mah]); - ini_write_string("Mar", "ge" + string(coh) + "." + string(mah), obj_ini.gear[coh, mah]); - ini_write_string("Mar", "mb" + string(coh) + "." + string(mah), obj_ini.mobi[coh, mah]); - - ini_write_real("Mar", "hp" + string(coh) + "." + string(mah), obj_ini.TTRPG[coh, mah].hp()); - ini_write_real("Mar", "cha" + string(coh) + "." + string(mah), obj_ini.chaos[coh, mah]); - ini_write_real("Mar", "exp" + string(coh) + "." + string(mah), obj_ini.experience[coh, mah]); - ini_write_real("Mar", "ag" + string(coh) + "." + string(mah), obj_ini.age[coh, mah]); - ini_write_string("Mar", "spe" + string(coh) + "." + string(mah), obj_ini.spe[coh, mah]); - ini_write_real("Mar", "god" + string(coh) + "." + string(mah), obj_ini.god[coh, mah]); - if (!is_struct(obj_ini.TTRPG[coh, mah])) { - TTRPG[coh, mah] = new TTRPG_stats("chapter", coh, mah, "blank"); - } else { - ini_write_string("Mar", "Struct" + string(coh) + "." + string(mah), base64_encode(jsonify_marine_struct(coh, mah))); - } - } - } - } - var squad_copies = []; - if (array_length(obj_ini.squads) > 0) { - for (var i = 0; i < array_length(obj_ini.squads); i++) { - array_push(squad_copies, obj_ini.squads[i].jsonify()); - } - } - ini_write_string("Mar", "squads", base64_encode(json_stringify(squad_copies))); - ini_write_string("Mar", "squad_types", base64_encode(json_stringify(obj_ini.squad_types))); - - coh = 100; - mah = -1; - repeat(21) { - mah += 1; - if (obj_ini.role[coh, mah] != "") { - ini_write_string("Mar", "rol" + string(coh) + "." + string(mah), obj_ini.role[coh, mah]); - ini_write_string("Mar", "w1" + string(coh) + "." + string(mah), obj_ini.wep1[coh, mah]); - ini_write_string("Mar", "w2" + string(coh) + "." + string(mah), obj_ini.wep2[coh, mah]); - ini_write_string("Mar", "ar" + string(coh) + "." + string(mah), obj_ini.armour[coh, mah]); - ini_write_string("Mar", "ge" + string(coh) + "." + string(mah), obj_ini.gear[coh, mah]); - ini_write_string("Mar", "mb" + string(coh) + "." + string(mah), obj_ini.mobi[coh, mah]); - } - } - coh = 102; - mah = -1; - repeat(21) { - mah += 1; - if (obj_ini.role[coh, mah] != "") { - ini_write_string("Mar", "rol" + string(coh) + "." + string(mah), obj_ini.role[coh, mah]); - ini_write_string("Mar", "w1" + string(coh) + "." + string(mah), obj_ini.wep1[coh, mah]); - ini_write_string("Mar", "w2" + string(coh) + "." + string(mah), obj_ini.wep2[coh, mah]); - ini_write_string("Mar", "ar" + string(coh) + "." + string(mah), obj_ini.armour[coh, mah]); - ini_write_string("Mar", "ge" + string(coh) + "." + string(mah), obj_ini.gear[coh, mah]); - ini_write_string("Mar", "mb" + string(coh) + "." + string(mah), obj_ini.mobi[coh, mah]); - } - } - ini_close(); - } - - if (save_process_stage = 5) or(save_process_stage = 0) { - ini_open("save" + string(save_id) + ".ini"); - - obj_saveload.hide = 1; - obj_controller.invis = true; - obj_saveload.alarm[2] = 2; - - var svt, svc, svm, smr, svd; - svt = 0; - svc = ""; - svm = ""; - smr = 0; - svd = ""; - svt = ini_read_real("Controller", "turn", 0); - svc = ini_read_string("Save", "chapter_name", "Error"); - svm = ini_read_string("Ini", "master_name", "Error"); - smr = ini_read_real("Controller", "marines", 0); - svd = ini_read_string("Save", "date", "Error"); - ini_write_real("Save", "corrupt", 0); - ini_close(); - - ini_open("saves.ini"); - ini_write_real(string(save_id), "turn", svt); - ini_write_string(string(save_id), "chapter_name", svc); - ini_write_string(string(save_id), "master_name", svm); - ini_write_real(string(save_id), "marines", smr); - ini_write_string(string(save_id), "date", svd); - ini_write_real(string(save_id), "time", obj_controller.play_time); - ini_write_real(string(save_id), "seed", global.game_seed); - ini_close(); - - // TODO temporary disabled. Will be reenabled during ironman/autosave feature task - //file_encrypt("save"+string(save_id)+".ini","p"); - - // This saves the log in an unencrypted file - instance_activate_object(obj_event_log); - file_delete("save" + string(save_id) + "log.ini"); - ini_open("save" + string(save_id) + "log.ini"); - var t; - t = 0; - ini_write_real("Main", "data1", instance_number(obj_star)); - ini_write_string("Main", "data2", global.chapter_name); - ini_write_string("Main", "data3", obj_ini.sector_name); - ini_write_real("Main", "data4", obj_controller.turn); - ini_write_real("Main", "data5", random_get_seed()); - - repeat(600) { - t += 1; - if (obj_event_log.event_text[t] != "") { - ini_write_string("Log", "a." + string(t), obj_event_log.event_text[t]); - ini_write_string("Log", "b." + string(t), obj_event_log.event_date[t]); - ini_write_real("Log", "c." + string(t), obj_event_log.event_turn[t]); - ini_write_string("Log", "d." + string(t), obj_event_log.event_color[t]); - } - } - ini_close(); - - obj_saveload.save[save_id] = 1; - - debugl("Saving to slot " + string(save_id) + " complete"); - } -} -*/ \ No newline at end of file +function SavedGameData() constructor +{ + version = global.version; + global_data = { + chapter_name : global.chapter_name, + game_seed : global.game_seed + } + controller = { + play_time : obj_controller.play_time + } + ini = obj_ini.Serialize(); +} \ No newline at end of file From 6260b1fc70ea39484667ae89f65e39720764b4bf Mon Sep 17 00:00:00 2001 From: GalacticChimp Date: Sat, 11 Nov 2023 02:00:44 +0100 Subject: [PATCH 05/11] about 33% of save part of the save system rework is done --- objects/obj_ini/Create_0.gml | 270 +++++++++++++----- .../scr_marine_struct/scr_marine_struct.gml | 12 +- scripts/scr_squads/scr_squads.gml | 8 +- 3 files changed, 214 insertions(+), 76 deletions(-) diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index 9e23707b0..ca956bd50 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -69,8 +69,10 @@ if (instance_exists(obj_creation)) then custom=obj_creation.custom; if (global.load=0) then scr_initialize_custom(); Serialize = function() { - var _ini_data = - { + + // general data + + var _ini_data = { sector_name, use_custom_icon, progenitor, @@ -160,28 +162,38 @@ Serialize = function() { high_apothecary_name, forge_master_name, lord_admiral_name, - equipment:[], - artifacts:[], - ships:[], - vehicles:[], + equipment: [], + artifacts: [], + ships: [], + vehicles: [], + marines: [], + squads:[], + squad_types, }; // TODO add indexes to allow easier debugging? - for(var i = 0; i <= 20; i++){ + // Company titles // TODO add Companies as well? + + for (var i = 0; i <= 20; i++) { _ini_data.company_titles[i] = $"{obj_ini.company_title[i]}"; } - for(var i = 0; i <= 120; i++){ + // Slave batches + + for (var i = 0; i <= 120; i++) { _ini_data.slave_batches[i] = { slave_batch_num: obj_ini.slave_batch_num[i], slave_batch_eta: obj_ini.slave_batch_eta[i] } } - - for(var i = 1; i <= 150; i++){ - if(obj_ini.equipment[i] == "") then continue; + // Equipment + + for (var i = 1; i <= 150; i++) { + + if (obj_ini.equipment[i] == "") then + continue; _ini_data.equipment[i] = { name: obj_ini.equipment[i], @@ -191,10 +203,13 @@ Serialize = function() { } } - for(var i = 1; i <= 150; i++){ + // Artifacts + + for (var i = 1; i <= 150; i++) { + + if (obj_ini.artifact[i] == "") then + continue; - if(obj_ini.artifact[i] == "") then continue; - _ini_data.artifacts[i] = { name: obj_ini.artifact[i], tags: obj_ini.artifact_tags[i], @@ -205,79 +220,81 @@ Serialize = function() { } } - for(var i = 1; i <= 200; i++){ + // Ships + + for (var i = 1; i <= 200; i++) { _ini_data.ships[i] = { - name: obj_ini.ship[i], - uid: obj_ini.ship_uid[i], - class: obj_ini.ship_class[i], - size: obj_ini.ship_size[i], - leadership: obj_ini.ship_leadership[i], - hp: obj_ini.ship_hp[i], - maxhp: obj_ini.ship_maxhp[i], - location: obj_ini.ship_location[i], - shields: obj_ini.ship_shields[i], - conditions: obj_ini.ship_conditions[i], - speed: obj_ini.ship_speed[i], - turning: obj_ini.ship_turning[i], - front_armour: obj_ini.ship_front_armour[i], - other_armour: obj_ini.ship_other_armour[i], - weapons_amount: obj_ini.ship_weapons[i], - weapons: [ - { - name: obj_ini.ship_wep[i][1], - facing: obj_ini.ship_wep_facing[i][1], - condition: obj_ini.ship_wep_condition[i][1], - }, - { - name: obj_ini.ship_wep[i][2], - facing: obj_ini.ship_wep_facing[i][2], - condition: obj_ini.ship_wep_condition[i][2], - }, - { - name: obj_ini.ship_wep[i][3], - facing: obj_ini.ship_wep_facing[i][3], - condition: obj_ini.ship_wep_condition[i][3], - }, - { - name: obj_ini.ship_wep[i][4], - facing: obj_ini.ship_wep_facing[i][4], - condition: obj_ini.ship_wep_condition[i][4], - }, - { - name: obj_ini.ship_wep[i][5], - facing: obj_ini.ship_wep_facing[i][5], - condition: obj_ini.ship_wep_condition[i][5], - }, - ], - capacity: obj_ini.ship_capacity[i], - carrying: obj_ini.ship_carrying[i], - contents: obj_ini.ship_contents[i], - turrets: obj_ini.ship_turrets[i], + name: obj_ini.ship[i], + uid: obj_ini.ship_uid[i], + class: obj_ini.ship_class[i], + size: obj_ini.ship_size[i], + leadership: obj_ini.ship_leadership[i], + hp: obj_ini.ship_hp[i], + maxhp: obj_ini.ship_maxhp[i], + location: obj_ini.ship_location[i], + shields: obj_ini.ship_shields[i], + conditions: obj_ini.ship_conditions[i], + speed: obj_ini.ship_speed[i], + turning: obj_ini.ship_turning[i], + front_armour: obj_ini.ship_front_armour[i], + other_armour: obj_ini.ship_other_armour[i], + weapons_amount: obj_ini.ship_weapons[i], + weapons: [{ + name: obj_ini.ship_wep[i][1], + facing: obj_ini.ship_wep_facing[i][1], + condition: obj_ini.ship_wep_condition[i][1], + }, + { + name: obj_ini.ship_wep[i][2], + facing: obj_ini.ship_wep_facing[i][2], + condition: obj_ini.ship_wep_condition[i][2], + }, + { + name: obj_ini.ship_wep[i][3], + facing: obj_ini.ship_wep_facing[i][3], + condition: obj_ini.ship_wep_condition[i][3], + }, + { + name: obj_ini.ship_wep[i][4], + facing: obj_ini.ship_wep_facing[i][4], + condition: obj_ini.ship_wep_condition[i][4], + }, + { + name: obj_ini.ship_wep[i][5], + facing: obj_ini.ship_wep_facing[i][5], + condition: obj_ini.ship_wep_condition[i][5], + }, + ], + capacity: obj_ini.ship_capacity[i], + carrying: obj_ini.ship_carrying[i], + contents: obj_ini.ship_contents[i], + turrets: obj_ini.ship_turrets[i], } } + // Vehicles + // I think the below tries to iterate over vehicles backwards // TODO but why not forwards? var is_iteration_finished = false; var company_index = 10; var entity_in_company_index = 100; var safety_threshold = 1100; - var iteration = 0; - + var iteration = -1; + // TODO refactor into only checking actually existing entities - while(!is_iteration_finished) - { + while (!is_iteration_finished) { iteration++; entity_in_company_index--; - if(entity_in_company_index == 0){ + if (entity_in_company_index == 0) { // go to next company, this one is fully checked entity_in_company_index = 100; company_index--; } - if(obj_ini.veh_role[company_index,entity_in_company_index] != ""){ + if (obj_ini.veh_role[company_index, entity_in_company_index] != "") { _ini_data.vehicles[iteration] = { company_index: company_index, entity_in_company_index: entity_in_company_index, @@ -287,7 +304,7 @@ Serialize = function() { lid: obj_ini.veh_lid[company_index][entity_in_company_index], // TODO Got no idea what this does uid: obj_ini.veh_uid[company_index][entity_in_company_index], // TODO Got no idea what this does wid: obj_ini.veh_wid[company_index][entity_in_company_index], // TODO Got no idea what this does - weapons:[ + weapons: [ obj_ini.veh_wep1[company_index][entity_in_company_index], obj_ini.veh_wep2[company_index][entity_in_company_index], obj_ini.veh_wep3[company_index][entity_in_company_index], @@ -297,19 +314,128 @@ Serialize = function() { hp: obj_ini.veh_hp[company_index][entity_in_company_index], chaos_corruption_level: obj_ini.veh_chaos[company_index][entity_in_company_index], pilots: obj_ini.veh_pilots[company_index][entity_in_company_index], // TODO this one looks not fully implemented - } + } } - if(company_index == 1 and entity_in_company_index == 1){ + if (company_index == 1 and entity_in_company_index == 1) { // At this point all possible vehicles have been checked is_iteration_finished = true; } - if(iteration >= safety_threshold){ + if (iteration >= safety_threshold) { debugl("obj_ini.Serialize(): serializing Vehicles took too long, cancelling..."); is_iteration_finished = true; } - + + } + + // Marines + + company_index = 100; + entity_in_company_index = 1; + iterator = -1; + + // HQ Marines?? + for (entity_in_company_index = 1; entity_in_company_index <= 30; entity_in_company_index++) { + iterator++; + if (obj_ini.role[company_index][entity_in_company_index] != "") { + _ini_data.marines[iterator] = { + race: obj_ini.race[company_index][entity_in_company_index], + name: obj_ini.name[company_index][entity_in_company_index], + role: obj_ini.role[company_index][entity_in_company_index], + weapon_1: obj_ini.wep1[company_index][entity_in_company_index], + weapon_2: obj_ini.wep2[company_index][entity_in_company_index], + armour: obj_ini.armour[company_index][entity_in_company_index], + gear: obj_ini.gear[company_index][entity_in_company_index], + mobility_item: obj_ini.mobi[company_index][entity_in_company_index], + } + } + } + + // Company Marines? + for (company_index = 0; company_index <= 10; company_index++) { + for (entity_in_company_index = 0; entity_in_company_index <= 500; entity_in_company_index++) { + iterator++; + if (obj_ini.name[company_index][entity_in_company_index] != "") { + _ini_data.marines[iterator] = { + race: obj_ini.race[company_index][entity_in_company_index], + location: obj_ini.loc[company_index][entity_in_company_index], + name: obj_ini.name[company_index][entity_in_company_index], + role: obj_ini.role[company_index][entity_in_company_index], + lid: obj_ini.lid[company_index][entity_in_company_index], // TODO Got no idea what this does + bio: obj_ini.bio[company_index][entity_in_company_index], // TODO Got no idea what this does + wid: obj_ini.wid[company_index][entity_in_company_index], // TODO Got no idea what this does + weapon_1: obj_ini.wep1[company_index][entity_in_company_index], + weapon_2: obj_ini.wep2[company_index][entity_in_company_index], + armour: obj_ini.armour[company_index][entity_in_company_index], + gear: obj_ini.gear[company_index][entity_in_company_index], + mobility_item: obj_ini.mobi[company_index][entity_in_company_index], + hp: obj_ini.TTRPG[company_index][entity_in_company_index].hp(), + chaos_corruption_level: obj_ini.chaos[company_index][entity_in_company_index], + experience: obj_ini.experience[company_index][entity_in_company_index], + age: obj_ini.age[company_index][entity_in_company_index], + is_special: obj_ini.spe[company_index][entity_in_company_index], // TODO Got no idea what this does + god: obj_ini.god[company_index][entity_in_company_index], // TODO Got no idea what this does + } + + if(is_struct(obj_ini.TTRPG[company_index][entity_in_company_index])){ + _ini_data.marines[iterator].ttrpg_stats = obj_ini.TTRPG[company_index][entity_in_company_index]; + } + else + { + debugl($"obj_ini.Serialize(): Marine [{company_index}][{entity_in_company_index}] has no TTRPG_stats struct, creating blank..."); + _ini_data.marines[iterator].ttrpg_stats = new TTRPG_stats("chapter",company_index,entity_in_company_index,"blank"); + } + } + } + } + + // Squads + + var squad_array_length = array_length(obj_ini.squads); + if (squad_array_length > 0) { + for (var i = 0; i < squad_array_length; i++) { + var squad_copy = obj_ini.squads[i].serialize(); + _ini_data.squads[i] = squad_copy; + } + } + + // TODO what are these 2? + + company_index = 100; + entity_in_company_index = 0; + // iterator = -1; + + for(entity_in_company_index = 0; entity_in_company_index <= 20; entity_in_company_index++){ + iterator++; + if(obj_ini.role[company_index][entity_in_company_index] != ""){ + _ini_data.marines[iterator] = { + role: obj_ini.role[company_index][entity_in_company_index], + weapon_1: obj_ini.wep1[company_index][entity_in_company_index], + weapon_2: obj_ini.wep2[company_index][entity_in_company_index], + armour: obj_ini.armour[company_index][entity_in_company_index], + gear: obj_ini.gear[company_index][entity_in_company_index], + mobility_item: obj_ini.mobi[company_index][entity_in_company_index], + } + } + } + + company_index = 102; + entity_in_company_index = 0; + // iterator = -1; + + for(entity_in_company_index = 0; entity_in_company_index <= 20; entity_in_company_index++){ + iterator++; + if(obj_ini.role[company_index][entity_in_company_index] != ""){ + _ini_data.marines[iterator] = { + role: obj_ini.role[company_index][entity_in_company_index], + weapon_1: obj_ini.wep1[company_index][entity_in_company_index], + weapon_2: obj_ini.wep2[company_index][entity_in_company_index], + armour: obj_ini.armour[company_index][entity_in_company_index], + gear: obj_ini.gear[company_index][entity_in_company_index], + mobility_item: obj_ini.mobi[company_index][entity_in_company_index], + } + } } return _ini_data; diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index 91b66f981..e75669e94 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -1148,7 +1148,12 @@ function TTRPG_stats(faction, comp, mar, class = "marine") constructor{ } } function jsonify_marine_struct(company, marine){ - var copy_marine_struct = obj_ini.TTRPG[company, marine]; //grab marine structure + var new_marine = serialize_marine_struct(company,marine); + return json_stringify(new_marine); + } + +function serialize_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 @@ -1158,5 +1163,6 @@ function jsonify_marine_struct(company, marine){ variable_struct_set(new_marine, names[name],copy_part); //if key value is not a method add to copy structure } } - return json_stringify(new_marine); - } \ No newline at end of file + + return new_marine; +} \ No newline at end of file diff --git a/scripts/scr_squads/scr_squads.gml b/scripts/scr_squads/scr_squads.gml index 8f35a5702..3f19c0058 100644 --- a/scripts/scr_squads/scr_squads.gml +++ b/scripts/scr_squads/scr_squads.gml @@ -325,6 +325,11 @@ function unit_squad(squad_type) constructor{ // for saving squads static jsonify = function(){ + var new_struct = serialize(); + return json_stringify(new_struct); + } + + static serialize = function(){ var copy_struct = self; //grab marine structure var new_struct = {}; var copy_part; @@ -335,7 +340,8 @@ function unit_squad(squad_type) constructor{ variable_struct_set(new_struct, names[name],copy_part); //if key value is not a method add to copy structure } } - return json_stringify(new_struct); + + return new_struct; } //function for loading in squad save data From c7b9bfe52a11c3a06be47d621e6a1221784f68e3 Mon Sep 17 00:00:00 2001 From: GalacticChimp Date: Sat, 11 Nov 2023 12:02:05 +0100 Subject: [PATCH 06/11] only saving non-empty entities now + storing indexes --- objects/obj_ini/Create_0.gml | 239 ++++++++++++++++++----------------- 1 file changed, 122 insertions(+), 117 deletions(-) diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index ca956bd50..d032777fc 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -167,63 +167,75 @@ Serialize = function() { ships: [], vehicles: [], marines: [], - squads:[], + squads: [], squad_types, }; - // TODO add indexes to allow easier debugging? - // Company titles // TODO add Companies as well? for (var i = 0; i <= 20; i++) { - _ini_data.company_titles[i] = $"{obj_ini.company_title[i]}"; + + if (obj_ini.company_title[i] == "") then continue; + + array_push(_ini_data.company_titles,{ + _index: i, + title: $"{obj_ini.company_title[i]}", + }); } // Slave batches for (var i = 0; i <= 120; i++) { - _ini_data.slave_batches[i] = { - slave_batch_num: obj_ini.slave_batch_num[i], - slave_batch_eta: obj_ini.slave_batch_eta[i] - } + + if (obj_ini.slave_batch_num[i] == 0) then continue; + + array_push(_ini_data.slave_batches,{ + _index: i, + amount: obj_ini.slave_batch_num[i], + eta: obj_ini.slave_batch_eta[i], + }); } // Equipment for (var i = 1; i <= 150; i++) { - if (obj_ini.equipment[i] == "") then - continue; + if (obj_ini.equipment[i] == "") then continue; - _ini_data.equipment[i] = { + array_push(_ini_data.equipment,{ + _index: i, name: obj_ini.equipment[i], type: obj_ini.equipment_type[i], amount: obj_ini.equipment_number[i], condition: obj_ini.equipment_condition[i], - } + }); } // Artifacts for (var i = 1; i <= 150; i++) { - if (obj_ini.artifact[i] == "") then - continue; + if (obj_ini.artifact[i] == "") then continue; - _ini_data.artifacts[i] = { + array_push(_ini_data.artifacts,{ + _index: i, name: obj_ini.artifact[i], tags: obj_ini.artifact_tags[i], is_identified: obj_ini.artifact_identified[i], condition: obj_ini.artifact_condition[i], location: obj_ini.artifact_loc[i], sid: obj_ini.artifact_sid[i], - } + }); } // Ships for (var i = 1; i <= 200; i++) { - _ini_data.ships[i] = { + + if (obj_ini.ship[i] == "") then continue; + + array_push(_ini_data.ships,{ + _index: i, name: obj_ini.ship[i], uid: obj_ini.ship_uid[i], class: obj_ini.ship_class[i], @@ -239,36 +251,26 @@ Serialize = function() { front_armour: obj_ini.ship_front_armour[i], other_armour: obj_ini.ship_other_armour[i], weapons_amount: obj_ini.ship_weapons[i], - weapons: [{ - name: obj_ini.ship_wep[i][1], - facing: obj_ini.ship_wep_facing[i][1], - condition: obj_ini.ship_wep_condition[i][1], - }, - { - name: obj_ini.ship_wep[i][2], - facing: obj_ini.ship_wep_facing[i][2], - condition: obj_ini.ship_wep_condition[i][2], - }, - { - name: obj_ini.ship_wep[i][3], - facing: obj_ini.ship_wep_facing[i][3], - condition: obj_ini.ship_wep_condition[i][3], - }, - { - name: obj_ini.ship_wep[i][4], - facing: obj_ini.ship_wep_facing[i][4], - condition: obj_ini.ship_wep_condition[i][4], - }, - { - name: obj_ini.ship_wep[i][5], - facing: obj_ini.ship_wep_facing[i][5], - condition: obj_ini.ship_wep_condition[i][5], - }, - ], + weapons: [], capacity: obj_ini.ship_capacity[i], carrying: obj_ini.ship_carrying[i], contents: obj_ini.ship_contents[i], turrets: obj_ini.ship_turrets[i], + }); + + // Try add ship weapons + var _last_pushed_ship = array_last(_ini_data.ships); + if (_last_pushed_ship.weapons_amount == 0) then continue; + + for (j = 1; j <= 5; j++) { + if (obj_ini.ship_wep[i][j] == "") then continue; + + array_push(_last_pushed_ship.weapons,{ + _index: j, + name: obj_ini.ship_wep[i][j], + facing: obj_ini.ship_wep_facing[i][j], + condition: obj_ini.ship_wep_condition[i][j], + }); } } @@ -295,7 +297,7 @@ Serialize = function() { } if (obj_ini.veh_role[company_index, entity_in_company_index] != "") { - _ini_data.vehicles[iteration] = { + array_push(_ini_data.vehicles,{ company_index: company_index, entity_in_company_index: entity_in_company_index, race: obj_ini.veh_race[company_index][entity_in_company_index], // TODO Got no idea what this does @@ -314,7 +316,7 @@ Serialize = function() { hp: obj_ini.veh_hp[company_index][entity_in_company_index], chaos_corruption_level: obj_ini.veh_chaos[company_index][entity_in_company_index], pilots: obj_ini.veh_pilots[company_index][entity_in_company_index], // TODO this one looks not fully implemented - } + }); } if (company_index == 1 and entity_in_company_index == 1) { @@ -333,110 +335,113 @@ Serialize = function() { company_index = 100; entity_in_company_index = 1; - iterator = -1; // HQ Marines?? for (entity_in_company_index = 1; entity_in_company_index <= 30; entity_in_company_index++) { - iterator++; - if (obj_ini.role[company_index][entity_in_company_index] != "") { - _ini_data.marines[iterator] = { + if (obj_ini.role[company_index][entity_in_company_index] == "") then continue; + + array_push(_ini_data.marines,{ + company_index: company_index, + entity_in_company_index: entity_in_company_index, + race: obj_ini.race[company_index][entity_in_company_index], + name: obj_ini.name[company_index][entity_in_company_index], + role: obj_ini.role[company_index][entity_in_company_index], + weapon_1: obj_ini.wep1[company_index][entity_in_company_index], + weapon_2: obj_ini.wep2[company_index][entity_in_company_index], + armour: obj_ini.armour[company_index][entity_in_company_index], + gear: obj_ini.gear[company_index][entity_in_company_index], + mobility_item: obj_ini.mobi[company_index][entity_in_company_index], + }); + } + + // Company Marines? + for (company_index = 0; company_index <= 10; company_index++) { + for (entity_in_company_index = 0; entity_in_company_index <= 500; entity_in_company_index++) { + + if (obj_ini.name[company_index][entity_in_company_index] == "") then continue; + + array_push(_ini_data.marines,{ + company_index: company_index, + entity_in_company_index: entity_in_company_index, race: obj_ini.race[company_index][entity_in_company_index], + location: obj_ini.loc[company_index][entity_in_company_index], name: obj_ini.name[company_index][entity_in_company_index], role: obj_ini.role[company_index][entity_in_company_index], + lid: obj_ini.lid[company_index][entity_in_company_index], // TODO Got no idea what this does + bio: obj_ini.bio[company_index][entity_in_company_index], // TODO Got no idea what this does + wid: obj_ini.wid[company_index][entity_in_company_index], // TODO Got no idea what this does weapon_1: obj_ini.wep1[company_index][entity_in_company_index], weapon_2: obj_ini.wep2[company_index][entity_in_company_index], armour: obj_ini.armour[company_index][entity_in_company_index], gear: obj_ini.gear[company_index][entity_in_company_index], mobility_item: obj_ini.mobi[company_index][entity_in_company_index], - } - } - } - - // Company Marines? - for (company_index = 0; company_index <= 10; company_index++) { - for (entity_in_company_index = 0; entity_in_company_index <= 500; entity_in_company_index++) { - iterator++; - if (obj_ini.name[company_index][entity_in_company_index] != "") { - _ini_data.marines[iterator] = { - race: obj_ini.race[company_index][entity_in_company_index], - location: obj_ini.loc[company_index][entity_in_company_index], - name: obj_ini.name[company_index][entity_in_company_index], - role: obj_ini.role[company_index][entity_in_company_index], - lid: obj_ini.lid[company_index][entity_in_company_index], // TODO Got no idea what this does - bio: obj_ini.bio[company_index][entity_in_company_index], // TODO Got no idea what this does - wid: obj_ini.wid[company_index][entity_in_company_index], // TODO Got no idea what this does - weapon_1: obj_ini.wep1[company_index][entity_in_company_index], - weapon_2: obj_ini.wep2[company_index][entity_in_company_index], - armour: obj_ini.armour[company_index][entity_in_company_index], - gear: obj_ini.gear[company_index][entity_in_company_index], - mobility_item: obj_ini.mobi[company_index][entity_in_company_index], - hp: obj_ini.TTRPG[company_index][entity_in_company_index].hp(), - chaos_corruption_level: obj_ini.chaos[company_index][entity_in_company_index], - experience: obj_ini.experience[company_index][entity_in_company_index], - age: obj_ini.age[company_index][entity_in_company_index], - is_special: obj_ini.spe[company_index][entity_in_company_index], // TODO Got no idea what this does - god: obj_ini.god[company_index][entity_in_company_index], // TODO Got no idea what this does - } - - if(is_struct(obj_ini.TTRPG[company_index][entity_in_company_index])){ - _ini_data.marines[iterator].ttrpg_stats = obj_ini.TTRPG[company_index][entity_in_company_index]; - } - else - { - debugl($"obj_ini.Serialize(): Marine [{company_index}][{entity_in_company_index}] has no TTRPG_stats struct, creating blank..."); - _ini_data.marines[iterator].ttrpg_stats = new TTRPG_stats("chapter",company_index,entity_in_company_index,"blank"); - } + hp: obj_ini.TTRPG[company_index][entity_in_company_index].hp(), + chaos_corruption_level: obj_ini.chaos[company_index][entity_in_company_index], + experience: obj_ini.experience[company_index][entity_in_company_index], + age: obj_ini.age[company_index][entity_in_company_index], + is_special: obj_ini.spe[company_index][entity_in_company_index], // TODO Got no idea what this does + god: obj_ini.god[company_index][entity_in_company_index], // TODO Got no idea what this does + }); + + if (is_struct(obj_ini.TTRPG[company_index][entity_in_company_index])) { + array_last(_ini_data.marines).ttrpg_stats = obj_ini.TTRPG[company_index][entity_in_company_index]; + } else { + debugl($"obj_ini.Serialize(): Marine [{company_index}][{entity_in_company_index}] has no TTRPG_stats struct, creating blank..."); + array_last(_ini_data.marines).ttrpg_stats = new TTRPG_stats("chapter", company_index, entity_in_company_index, "blank"); } } } // Squads - var squad_array_length = array_length(obj_ini.squads); + var squad_array_length = array_length(obj_ini.squads); if (squad_array_length > 0) { for (var i = 0; i < squad_array_length; i++) { - var squad_copy = obj_ini.squads[i].serialize(); - _ini_data.squads[i] = squad_copy; + array_push(_ini_data.squads,obj_ini.squads[i].serialize()); } } - // TODO what are these 2? + // TODO what are these 2 loops supposed to represent?? company_index = 100; entity_in_company_index = 0; - // iterator = -1; - for(entity_in_company_index = 0; entity_in_company_index <= 20; entity_in_company_index++){ - iterator++; - if(obj_ini.role[company_index][entity_in_company_index] != ""){ - _ini_data.marines[iterator] = { - role: obj_ini.role[company_index][entity_in_company_index], - weapon_1: obj_ini.wep1[company_index][entity_in_company_index], - weapon_2: obj_ini.wep2[company_index][entity_in_company_index], - armour: obj_ini.armour[company_index][entity_in_company_index], - gear: obj_ini.gear[company_index][entity_in_company_index], - mobility_item: obj_ini.mobi[company_index][entity_in_company_index], - } - } + for (entity_in_company_index = 0; entity_in_company_index <= 20; entity_in_company_index++) { + + if (obj_ini.role[company_index][entity_in_company_index] == "") then continue; + + array_push(_ini_data.marines,{ + company_index: company_index, + entity_in_company_index: entity_in_company_index, + role: obj_ini.role[company_index][entity_in_company_index], + weapon_1: obj_ini.wep1[company_index][entity_in_company_index], + weapon_2: obj_ini.wep2[company_index][entity_in_company_index], + armour: obj_ini.armour[company_index][entity_in_company_index], + gear: obj_ini.gear[company_index][entity_in_company_index], + mobility_item: obj_ini.mobi[company_index][entity_in_company_index], + }); } company_index = 102; entity_in_company_index = 0; - // iterator = -1; - for(entity_in_company_index = 0; entity_in_company_index <= 20; entity_in_company_index++){ - iterator++; - if(obj_ini.role[company_index][entity_in_company_index] != ""){ - _ini_data.marines[iterator] = { - role: obj_ini.role[company_index][entity_in_company_index], - weapon_1: obj_ini.wep1[company_index][entity_in_company_index], - weapon_2: obj_ini.wep2[company_index][entity_in_company_index], - armour: obj_ini.armour[company_index][entity_in_company_index], - gear: obj_ini.gear[company_index][entity_in_company_index], - mobility_item: obj_ini.mobi[company_index][entity_in_company_index], - } - } + for (entity_in_company_index = 0; entity_in_company_index <= 20; entity_in_company_index++) { + + if (obj_ini.role[company_index][entity_in_company_index] == "") then continue; + + array_push(_ini_data.marines,{ + company_index: company_index, + entity_in_company_index: entity_in_company_index, + role: obj_ini.role[company_index][entity_in_company_index], + weapon_1: obj_ini.wep1[company_index][entity_in_company_index], + weapon_2: obj_ini.wep2[company_index][entity_in_company_index], + armour: obj_ini.armour[company_index][entity_in_company_index], + gear: obj_ini.gear[company_index][entity_in_company_index], + mobility_item: obj_ini.mobi[company_index][entity_in_company_index], + }); } + // TODO add more stuff + return _ini_data; } \ No newline at end of file From e19f6d8d7f85309995756461e210d11c6c9bfee3 Mon Sep 17 00:00:00 2001 From: GalacticChimp Date: Sat, 11 Nov 2023 14:11:21 +0100 Subject: [PATCH 07/11] obj_controller now gets serialized to json (finished about 66% of save part of save system rework) --- objects/obj_controller/Create_0.gml | 419 ++++++++++++++++++++++++++++ objects/obj_ini/Create_0.gml | 13 +- scripts/scr_load/scr_load.gml | 1 - scripts/scr_save/scr_save.gml | 6 +- 4 files changed, 428 insertions(+), 11 deletions(-) diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index 0e6104b84..eb87f9591 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -1648,3 +1648,422 @@ if (vih>=5){ remov=string_length(string(temp[65])+string(temp[66])+string(temp[67])+string(temp[68])+string(temp[69]))+1; action_set_alarm(2, 0); + +#region serialization + +serialize = function() { + + // general data and inits + + var _ctrl_data = { + play_time, + cheatyface, + x, + y, + alll, + zoom: { + was_zoomed, + zoomed + }, + chaos_rating, + fleet_type, + homeworld_rule, + star_names, + craftworld, + turn, + last_event, + last_mission, + last_world_inspection, + last_fleet_inspection, + chaos_turn, + chaos_fleets, + tau_fleets, + tau_stars, + tau_messenger, + fleet_all, + unload, + diplomacy, + trading, + audience, + force_goodbye, + combat, + new_vehicles, + hurssy, + hurssy_time, + artifacts, + popup_master_crafted, + select_wounded, + terra_direction, + stc: { + wargear: stc_wargear, + vehicles: stc_vehicles, + ships: stc_ships, + un_total: stc_un_total, + wargear_un: stc_wargear_un, + vehicles_un: stc_vehicles_un, + ships_un: stc_ships_un, + bonuses: [ + stc_bonus[1], + stc_bonus[2], + stc_bonus[3], + stc_bonus[4], + stc_bonus[5], + stc_bonus[6], + ], + }, + player_scheduled_event: { + feasts: fest_feasts, + booze: fest_boozes, + drugs: fest_drugses, + }, + recent_happenings, + recent_types: [], + formation: { + last_attack: last_attack_form, + last_raid: last_raid_form, + formation_lines: [], + }, + random_event_next, + genes: { + sold: gene_sold, + xeno: gene_xeno, + tithe: gene_tithe, + iou: gene_iou, + }, + underground_structures: { + armouries: und_armouries, + gene_vaults: und_gene_vaults, + lairs: und_lairs, + }, + penitence: { + is_penitent: penitent, + current: penitent_current, + maximum: penitent_max, + turnly: penitent_turnly, + turn: penitent_turn, + turns_left: penitent_end, + blood_debt, + penitorium + }, + training: { + training_apothecary, + apothecary_points, + apothecary_aspirant, + training_chaplain, + chaplain_points, + chaplain_aspirant, + training_psyker, + psyker_points, + psyker_aspirant, + training_techmarine, + tech_points, + tech_aspirant + }, + recruitment: { + worlds: recruiting_worlds, + recruiting, + trial: recruit_trial, + recruits, + last: recruit_last, + recruiting_worlds_bought, + recruits_list: [], + }, + commands: [], + blandify, + inquisitors: [], + factions: [], + quests: [], + events: [], + just_met_faction: faction_justmet, + check_number, + datetime: { + year, + year_fraction, + millenium + }, + economy: { + requisition, + gene_seed, + income: { + current: income, + last: income_last, + base: income_base, + home: income_home, + forge: income_forge, + agri: income_agri, + recruiting: income_recruiting, + training: income_training, + fleet: income_fleet, + trade: income_trade, + }, + }, + loyalty: { + current: loyalty, + hidden: loyalty_hidden, + modifiers: [], + }, + flags: [{ + inquisitor_lair_flag: inqis_flag_lair + }, + { + inquisitor_gene_flag: inqis_flag_gene + } + ], + marines_amount: marines, + command, + info_chips, + inspection_passes, + last_weapons_tab, + battle_columns: [{ + devastators: bat_devastator_column + }, + { + assaults: bat_assault_column + }, + { + tacticals: bat_tactical_column + }, + { + veterans: bat_veteran_column + }, + { + hirelings: bat_hire_column + }, + { + librarians: bat_librarian_column + }, + { + hq: bat_command_column + }, + { + techmarines: bat_techmarine_column + }, + { + terminators: bat_terminator_column + }, + { + honor_guards: bat_honor_column + }, + { + dreadnoughts: bat_dreadnought_column + }, + { + rhinos: bat_rhino_column + }, + { + predators: bat_predator_column + }, + { + land_raiders: bat_landraider_column + }, + { + scouts: bat_scout_column + }, + ], + colors: { + main: obj_controller.col[obj_controller.main_color], + secondary: obj_controller.col[obj_controller.secondary_color], + trim: obj_controller.col[obj_controller.trim_color], + pauldron_2: obj_controller.col[obj_controller.pauldron2_color], + pauldron: obj_controller.col[obj_controller.pauldron_color], + lens: obj_controller.col[obj_controller.lens_color], + weapon: obj_controller.col[obj_controller.weapon_color], + special: obj_controller.col_special, + is_trimmed: obj_controller.trim, + }, + adept_name, + recruiter_name, + progenitor, + mutation, + successor_chapters, + dispositions: { // TODO is this different from Factions' dispositions? + progenitor: progenitor_disposition, + imperium: imperium_disposition, + astartes: astartes_disposition, + }, + // restart:{} // TODO this is getting removed, no need to prepare Restart vars if we already serialize everything we need + }; + + // Player scheduled event + + if (fest_type != "") { + _ctrl_data.player_scheduled_event.sid = fest_sid; // TODO ??? + _ctrl_data.player_scheduled_event.wid = fest_wid; // TODO ??? + _ctrl_data.player_scheduled_event.planet = fest_planet; + _ctrl_data.player_scheduled_event.star = fest_star; + _ctrl_data.player_scheduled_event.type = fest_type; + _ctrl_data.player_scheduled_event.cost = fest_cost; + _ctrl_data.player_scheduled_event.warp = fest_warp; + _ctrl_data.player_scheduled_event.is_scheduled = fest_scheduled; + _ctrl_data.player_scheduled_event.lav = fest_lav; // TODO ??? + _ctrl_data.player_scheduled_event.locals = fest_locals; + _ctrl_data.player_scheduled_event.features = [ + fest_feature1, + fest_feature2, + fest_feature3, + ]; + _ctrl_data.player_scheduled_event.display = fest_display; + _ctrl_data.player_scheduled_event.display_tags = fest_display_tags; + _ctrl_data.player_scheduled_event.repeats = fest_repeats; + _ctrl_data.player_scheduled_event.honor_company = fest_honor_co; // TODO not sure + _ctrl_data.player_scheduled_event.honor_id = fest_honor_id; + _ctrl_data.player_scheduled_event.is_honoring = fest_honoring; + } + + // Recent type + + for (var i = 0; i < 600; i++) { + if (recent_type[i] == "") then continue; + + array_push(_ctrl_data.recent_types, { + _index: i, + type: recent_type[i], + keyword: recent_keyword[i], + turn: recent_turn[i], + number: recent_number[i], + }); + } + + // Formation and attacks + + for (var i = 1; i <= 14; i++) { + if (bat_formation[i] == "") then continue; + + array_push(_ctrl_data.formation.formation_lines, { + _index: i, + name: bat_formation[i], + positions: { + devastators: bat_deva_for[i], + assaults: bat_assa_for[i], + tacticals: bat_tact_for[i], + veterans: bat_vete_for[i], + hirelings: bat_hire_for[i], + librarians: bat_libr_for[i], + hq: bat_comm_for[i], + techmarines: bat_tech_for[i], + terminators: bat_term_for[i], + honor_guard: bat_hono_for[i], + dreadnoughts: bat_drea_for[i], + rhinos: bat_rhin_for[i], + predators: bat_pred_for[i], + land_raiders: bat_land_for[i], + scouts: bat_scou_for[i], + }, + }); + } + + // Command + + for (var i = 0; i < 30; i++) { + + if(command_set[i] == 0) then continue; + + array_push(_ctrl_data.commands, { + _index: i, + is_set: command_set[i], + }); + } + + // Recruits + + for (var i = 0; i <= 200; i++) { + + if(recruit_name[i] == "") then continue; + + array_push(_ctrl_data.recruitment.recruits_list, { + _index: i, + name: recruit_name[i], + corruption: recruit_corruption[i], + distance: recruit_distance[i], + training: recruit_training[i], + exp: recruit_exp[i], + }); + } + + // Loyalty + + for (var i = 0; i < 30; i++) { + + if(loyal[i] == "") then continue; + + array_push(_ctrl_data.loyalty.modifiers, { + _index: i, + name: loyal[i], + amount: loyal_num[i], + time: loyal_time[i], + }); + } + + // Inquisitors + + for (var i = 0; i < 11; i++) { + + if(inquisitor[i] == "") then continue; + + array_push(_ctrl_data.inquisitors, { + _index: i, + name: inquisitor[i], + gender: inquisitor_gender[i], + type: inquisitor_type[i] + }); + } + + // Factions + + for (var i = 0; i < 14; i++) { + + if(faction[i] == "") then continue; + + array_push(_ctrl_data.factions, { + _index: i, + name: faction[i], + disposition: disposition[i], + disposition_max: disposition_max[i], + leader: { + name: faction_leader[i], + gender: faction_gender[i], + title: faction_title[i] + }, + status: faction_status[i], + is_defeated: faction_defeated[i], + is_known: known[i], + is_annoyed: annoyed[i], + is_ignored: ignore[i], + turns_ignored: turns_ignored[i], + is_audience: audien[i], + audience_topic: audien_topic[i], + }); + } + + + // Quests + + for (var i = 1; i <= 50; i++) { + + if(quest[i] == "") then continue; + + array_push(_ctrl_data.quests, { + _index: i, + name: quest[i], + faction: quest_faction[i], + ends_in: quest_end[i], + }); + } + + // Events + + for (var i = 1; i <= 99; i++) { + + if(event[i] == "") then continue; + + array_push(_ctrl_data.events, { + _index: i, + name: event[i], + duration: event_duration[i], + }); + } + + return _ctrl_data +} + +#endregion serialization \ No newline at end of file diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index d032777fc..5daf064bf 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -68,9 +68,11 @@ if (instance_exists(obj_creation)) then custom=obj_creation.custom; if (global.load=0) then scr_initialize_custom(); -Serialize = function() { +#region serialization - // general data +serialize = function() { + + // general data and inits var _ini_data = { sector_name, @@ -284,7 +286,6 @@ Serialize = function() { var safety_threshold = 1100; var iteration = -1; - // TODO refactor into only checking actually existing entities while (!is_iteration_finished) { iteration++; @@ -441,7 +442,7 @@ Serialize = function() { }); } - // TODO add more stuff - return _ini_data; -} \ No newline at end of file +} + +#endregion serialization \ No newline at end of file diff --git a/scripts/scr_load/scr_load.gml b/scripts/scr_load/scr_load.gml index 817ebc073..849dc9835 100644 --- a/scripts/scr_load/scr_load.gml +++ b/scripts/scr_load/scr_load.gml @@ -950,7 +950,6 @@ function scr_load(load_process_stage, save_id) { } obj_ini.squad_types = json_parse(base64_decode(ini_read_string("Mar", "squad_types", ""))); - } diff --git a/scripts/scr_save/scr_save.gml b/scripts/scr_save/scr_save.gml index ca284b140..6f38d85f4 100644 --- a/scripts/scr_save/scr_save.gml +++ b/scripts/scr_save/scr_save.gml @@ -34,8 +34,6 @@ function SavedGameData() constructor chapter_name : global.chapter_name, game_seed : global.game_seed } - controller = { - play_time : obj_controller.play_time - } - ini = obj_ini.Serialize(); + controller = obj_controller.serialize(); + ini = obj_ini.serialize(); } \ No newline at end of file From 9abf44eccc447dc73351dcb819e0dfe5436a7f34 Mon Sep 17 00:00:00 2001 From: GalacticChimp Date: Sat, 18 Nov 2023 18:09:18 +0100 Subject: [PATCH 08/11] Serialized remaining global stuff --- objects/obj_controller/Create_0.gml | 2 +- scripts/scr_save/scr_save.gml | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index eb87f9591..021e0b70d 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -1670,7 +1670,7 @@ serialize = function() { homeworld_rule, star_names, craftworld, - turn, + current_turn: turn, last_event, last_mission, last_world_inspection, diff --git a/scripts/scr_save/scr_save.gml b/scripts/scr_save/scr_save.gml index 6f38d85f4..15cd333d8 100644 --- a/scripts/scr_save/scr_save.gml +++ b/scripts/scr_save/scr_save.gml @@ -29,10 +29,20 @@ var num = instance_number(obj_star); function SavedGameData() constructor { - version = global.version; + game_version= global.version; + timestamp = date_datetime_string(date_current_datetime()); global_data = { - chapter_name : global.chapter_name, - game_seed : global.game_seed + chapter_name: global.chapter_name, + game_seed: global.game_seed, + founding_secret: global.founding_secret, + is_custom_chapter: global.custom, + cheats:{ + req: global.cheat_req, + gene: global.cheat_gene, + debug: global.cheat_debug, + disp: global.cheat_disp, + }, + sod: random_get_seed() // TODO what? looks like a checksum? } controller = obj_controller.serialize(); ini = obj_ini.serialize(); From 1aa577a9aae862511772136303194f3f6996c564 Mon Sep 17 00:00:00 2001 From: GalacticChimp Date: Sat, 18 Nov 2023 21:36:17 +0100 Subject: [PATCH 09/11] everything should be serialized now --- objects/obj_en_fleet/Create_0.gml | 250 ++++++++++++--- objects/obj_p_fleet/Create_0.gml | 79 +++++ objects/obj_star/Create_0.gml | 294 +++++++++++++----- .../scr_planetary_feature.gml | 51 +++ scripts/scr_save/scr_save.gml | 41 ++- 5 files changed, 590 insertions(+), 125 deletions(-) diff --git a/objects/obj_en_fleet/Create_0.gml b/objects/obj_en_fleet/Create_0.gml index 717478c10..6a3371550 100644 --- a/objects/obj_en_fleet/Create_0.gml +++ b/objects/obj_en_fleet/Create_0.gml @@ -1,61 +1,217 @@ +owner = 0; +capital_number = 0; +frigate_number = 0; +escort_number = 0; +guardsmen = 0; +home_x = 0; +home_y = 0; +selected = 0; +ret = 0; +hurt = 0; +orbiting = 0; +rep = 3; +minimum_eta = 0; +navy = 0; +guardsmen_ratio = 0; +guardsmen_unloaded = 0; +ii_check = floor(random(5)) + 1; +etah = 0; +safe = 0; -owner=0; -capital_number=0; -frigate_number=0; -escort_number=0; -guardsmen=0; -home_x=0; -home_y=0; -selected=0; -ret=0; -hurt=0; -orbiting=0; -rep=3; -minimum_eta=0; -navy=0; -guardsmen_ratio=0; -guardsmen_unloaded=0; -ii_check=floor(random(5))+1; -etah=0;safe=0; - -image_xscale=1.25;image_yscale=1.25; - -var i;i=-1; -repeat(21){i+=1; - capital[i]="";capital_num[i]=0;capital_sel[i]=1;capital_imp[i]=0;capital_max_imp[i]=0; +image_xscale = 1.25; +image_yscale = 1.25; + +var i; +i = -1; +repeat(21) { + i += 1; + capital[i] = ""; + capital_num[i] = 0; + capital_sel[i] = 1; + capital_imp[i] = 0; + capital_max_imp[i] = 0; } -var i;i=-1; -repeat(31){i+=1; - frigate[i]="";frigate_num[i]=0;frigate_sel[i]=1;frigate_imp[i]=0;frigate_max_imp[i]=0; +var i; +i = -1; +repeat(31) { + i += 1; + frigate[i] = ""; + frigate_num[i] = 0; + frigate_sel[i] = 1; + frigate_imp[i] = 0; + frigate_max_imp[i] = 0; } -var i;i=-1; -repeat(31){i+=1; - escort[i]="";escort_num[i]=0;escort_sel[i]=1;escort_imp[i]=0;escort_max_imp[i]=0; +var i; +i = -1; +repeat(31) { + i += 1; + escort[i] = ""; + escort_num[i] = 0; + escort_sel[i] = 1; + escort_imp[i] = 0; + escort_max_imp[i] = 0; } -image_speed=0; +image_speed = 0; + + +action = ""; +action_x = 0; +action_y = 0; +target = 0; +target_x = 0; +target_y = 0; +action_spd = 64; +if (owner <= 6) then action_spd = 128; +action_eta = 0; +connected = 0; +loaded = 0; + +trade_goods = ""; + + +capital_health = 100; +frigate_health = 100; +escort_health = 100; + +alarm[8] = 1; + +#region serialization + +serialize = function(fleet_index) { + var _enemy_fleet_data = { + _index: fleet_index, + owner_index: owner, + position: { + x, + y, + }, + sprite_index, + image_index, + image_alpha, + capital_ships_count: capital_number, + capital_ships: [], + capital_hp: capital_health, + frigate_ships_count: frigate_number, + frigate_ships: [], + frigate_hp: frigate_health, + escort_ships_count: escort_number, + escort_ships: [], + escort_hp: escort_health, + selected, + action: { + name: action, + position: { + x: action_x, + y: action_y, + }, + speed: action_spd, + eta: action_eta, + }, + home: { + position: { + x: home_x, + y: home_y, + } + }, + target: { + name: target, + position: { + x: target_x, + y: target_y + } + }, + is_connected: connected, + is_loaded: loaded, + trade_goods, + guardsmen, + orbiting, + is_imperial_navy: navy, + guardsmen_unloaded, + }; + + // TODO, why are these special? + if (_enemy_fleet_data.is_imperial_navy) { + + // Capital ships + var imperial_capital_ship_count = array_length(capital_imp); -action=""; -action_x=0; -action_y=0; -target=0; -target_x=0; -target_y=0; -action_spd=64; -if (owner<=6) then action_spd=128; -action_eta=0; -connected=0; -loaded=0; + if(imperial_capital_ship_count != _enemy_fleet_data.capital_ships_count){ + show_debug_message($"obj_en_fleet.create_0.serialize(): imperial_capital_ship_count != _enemy_fleet_data.capital_ships_count: ({imperial_capital_ship_count} != {_enemy_fleet_data.capital_ships_count})"); + } -trade_goods=""; + for (var s = 0; s < imperial_capital_ship_count; s++) { + if(!capital_imp[s]) + { + continue; + } + var _ship_data = { + _index: s, + //name: capital[s], // TODO Doesn't seem to be used + //num: capital_num[s], // TODO Doesn't seem to be used + //sel: capital_sel[s], // TODO Doesn't seem to be used + crew_amount: capital_imp[s], + crew_amount_max: capital_max_imp[s], + }; + array_push(_enemy_fleet_data.capital_ships, _ship_data); + } -capital_health=100; -frigate_health=100; -escort_health=100; + // Frigate ships -alarm[8]=1; + var imperial_frigate_ship_count = array_length(frigate_imp); + + if(imperial_frigate_ship_count != _enemy_fleet_data.frigate_ships_count){ + show_debug_message($"obj_en_fleet.create_0.serialize(): imperial_frigate_ship_count != _enemy_fleet_data.frigate_ships_count: ({imperial_frigate_ship_count} != {_enemy_fleet_data.frigate_ships_count})"); + } + + for (var s = 0; s < imperial_frigate_ship_count; s++) { + if(!frigate_imp[s]) + { + continue; + } + + var _ship_data = { + _index: s, + //name: frigate[s], // TODO Doesn't seem to be used + //num: frigate_num[s], // TODO Doesn't seem to be used + //sel: frigate_sel[s], // TODO Doesn't seem to be used + crew_amount: frigate_imp[s], + crew_amount_max: frigate_max_imp[s], + }; + array_push(_enemy_fleet_data.frigate_ships, _ship_data); + } + + // Escort ships + + var imperial_escort_ship_count = array_length(escort_imp); + + if(imperial_escort_ship_count != _enemy_fleet_data.escort_ships_count){ + show_debug_message($"obj_en_fleet.create_0.serialize(): imperial_escort_ship_count != _enemy_fleet_data.escort_ships_count: ({imperial_escort_ship_count} != {_enemy_fleet_data.escort_ships_count})"); + } + + for (var s = 0; s < imperial_escort_ship_count; s++) { + if(!escort_imp[s]) + { + continue; + } + + var _ship_data = { + _index: s, + // name: escort[s], // TODO Doesn't seem to be used + // num: escort_num[s], // TODO Doesn't seem to be used + // sel: escort_sel[s], // TODO Doesn't seem to be used + crew_amount: escort_imp[s], + crew_amount_max: escort_max_imp[s], + }; + array_push(_enemy_fleet_data.escort_ships, _ship_data); + } + } + + return _enemy_fleet_data; +} +#endregion \ No newline at end of file diff --git a/objects/obj_p_fleet/Create_0.gml b/objects/obj_p_fleet/Create_0.gml index 6e39f520e..4f5d41375 100644 --- a/objects/obj_p_fleet/Create_0.gml +++ b/objects/obj_p_fleet/Create_0.gml @@ -50,3 +50,82 @@ connected=0; acted=0; hurssy=0; hurssy_time=0; + +#region serialization + +serialize = function(fleet_index){ + _fleet_data = { + _index: fleet_index, + image_index, + position:{ + x, + y, + }, + capital_ships_count: capital_number, + capital_ships:[], + frigate_ships_count: frigate_number, + frigate_ships:[], + escort_ships_count: escort_number, + escort_ships:[], + selected, + capital_hp: capital_health, + frigate_hp: frigate_health, + escort_hp: escort_health, + current_action: { + name: action, + position: { + x: action_x, + y: action_y + }, + speed: action_spd, + eta: action_eta, + }, + has_acted_this_turn: acted, + hurssy, + hurssy_time, + orbiting, + }; + + // Capital ships + + for(var s = 0; s < _fleet_data.capital_ships_count; s++){ + var _ship_data = { + _index: s, + name: capital[s], + num: capital_num[s], + sel: capital_sel[s], + uid: capital_uid[s], + }; + array_push(_fleet_data.capital_ships, _ship_data); + } + + // Frigate ships + + for(var s = 0; s < _fleet_data.frigate_ships_count; s++){ + var _ship_data = { + _index: s, + name: frigate[s], + num: frigate_num[s], + sel: frigate_sel[s], + uid: frigate_uid[s], + }; + array_push(_fleet_data.frigate_ships, _ship_data); + } + + // Escort ships + + for(var s = 0; s < _fleet_data.escort_ships_count; s++){ + var _ship_data = { + _index: s, + name: escort[s], + num: escort_num[s], + sel: escort_sel[s], + uid: escort_uid[s], + }; + array_push(_fleet_data.escort_ships, _ship_data); + } + + return _fleet_data; +} + +#endregion \ No newline at end of file diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index 85be107fb..7f44f1d81 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -1,94 +1,234 @@ // Creates all variables, sets up default variables for different planets and if there is a fleet orbiting a system/planet -craftworld=0;// orbit_angle=0;orbit_radius=0; -space_hulk=0; -old_x=0; -old_y=0; +craftworld = 0; // orbit_angle=0;orbit_radius=0; +space_hulk = 0; +old_x = 0; +old_y = 0; -if (((x>=(room_width-150)) and (y<=450)) or (y<100)) and (global.load==0){// was 300 +if (((x >= (room_width - 150)) and(y <= 450)) or(y < 100)) and(global.load == 0) { // was 300 instance_destroy(); } -var run=0; -name=""; -star=""; -planets=0; -owner=2; -image_speed=0; -image_alpha=0; -x2=0; -y2=0; -buddy=0; -if (global.load==0) then alarm[0]=1; -storm=0; -storm_image=0; -trader=0; -visited=0; +var run = 0; +name = ""; +star = ""; +planets = 0; +owner = 2; +image_speed = 0; +image_alpha = 0; +x2 = 0; +y2 = 0; +buddy = 0; +if (global.load == 0) then alarm[0] = 1; +storm = 0; +storm_image = 0; +trader = 0; +visited = 0; // sets up default planet variables -for(run=1; run<=8; run++){ - planet[run]=0; - dispo[run]=-50; - p_type[run]=""; - p_feature[run]=[]; - p_owner[run]=0; - p_first[run]=0; - p_population[run]=0; - p_max_population[run]=0; - p_large[run]=0; - p_pop[run]=""; - p_guardsmen[run]=0; - p_pdf[run]=0; - p_fortified[run]=0; - p_station[run]=0; - warlord=0; +for (run = 1; run <= 8; run++) { + planet[run] = 0; + dispo[run] = -50; + p_type[run] = ""; + p_feature[run] = []; + p_owner[run] = 0; + p_first[run] = 0; + p_population[run] = 0; + p_max_population[run] = 0; + p_large[run] = 0; + p_pop[run] = ""; + p_guardsmen[run] = 0; + p_pdf[run] = 0; + p_fortified[run] = 0; + p_station[run] = 0; + warlord = 0; // Whether or not player forces are on the planet - p_player[run]=0; - p_lasers[run]=0; - p_silo[run]=0; - p_defenses[run]=0; - p_upgrades[run]=[]; + p_player[run] = 0; + p_lasers[run] = 0; + p_silo[run] = 0; + p_defenses[run] = 0; + p_upgrades[run] = []; // v how much of a problem they are from 1-5 - p_orks[run]=0; - p_tau[run]=0; - p_eldar[run]=0; - p_tyranids[run]=0; - p_traitors[run]=0; - p_chaos[run]=0; - p_demons[run]=0; - p_sisters[run]=0; - p_necrons[run]=0; - p_halp[run]=0; + p_orks[run] = 0; + p_tau[run] = 0; + p_eldar[run] = 0; + p_tyranids[run] = 0; + p_traitors[run] = 0; + p_chaos[run] = 0; + p_demons[run] = 0; + p_sisters[run] = 0; + p_necrons[run] = 0; + p_halp[run] = 0; // current planet heresy - p_heresy[run]=0; - p_hurssy[run]=0; - p_hurssy_time[run]=0; - p_heresy_secret[run]=0; - p_influence[run]=0; - p_raided[run]=0; + p_heresy[run] = 0; + p_hurssy[run] = 0; + p_hurssy_time[run] = 0; + p_heresy_secret[run] = 0; + p_influence[run] = 0; + p_raided[run] = 0; // - p_problem[0,run]=""; - p_timer[0,run]=0; - p_problem[1,run]=""; - p_timer[1,run]=0; - p_problem[2,run]=""; - p_timer[2,run]=0; - p_problem[3,run]=""; - p_timer[3,run]=0; - p_problem[4,run]=""; - p_timer[4,run]=0; - p_problem[5,run]=""; - p_timer[5,run]=0; + p_problem[0, run] = ""; + p_timer[0, run] = 0; + p_problem[1, run] = ""; + p_timer[1, run] = 0; + p_problem[2, run] = ""; + p_timer[2, run] = 0; + p_problem[3, run] = ""; + p_timer[3, run] = 0; + p_problem[4, run] = ""; + p_timer[4, run] = 0; + p_problem[5, run] = ""; + p_timer[5, run] = 0; } -for(run=8; run<=30; run++){ - present_fleet[run]=0; +for (run = 8; run <= 30; run++) { + present_fleet[run] = 0; } -vision=1; +vision = 1; // present_fleets=0; // tau_fleets=0; -ai_a=-1; -ai_b=-1; -ai_c=-1; -ai_d=-1; -ai_e=-1; +ai_a = -1; +ai_b = -1; +ai_c = -1; +ai_d = -1; +ai_e = -1; + +#region serialization + +serialize = function(star_index) { + + // General stuff and init + + var _star_data = { + _index: star_index, + name, + type: star, + owner_index: owner, + position: { + x, + y, + x2, + y2, + old_x, + old_y, + }, + is_visible: vision, + has_storm: storm, + trader, + is_craftworld: craftworld, + is_space_hulk: space_hulk, + planet_count: planets, + planets: [], + }; + + // Planets + + for (var p = 0; p < planets; p++) { + var _planet = planet[p]; + if (!_planet) { + // TODO debug log error + continue; + } + var _planet_data = { + _index: p, + //name: _planet, // TODO this is basically is_planet, does it make sense to store this? + disposition: dispo[p], + type: p_type[p], + feature_count: array_length(p_feature[p]), + features: [], + owner_index: p_owner[p], + first: p_first[p], + population: p_population[p], + max_population: p_max_population[p], + is_large: p_large[p], + pop: p_pop[p], + guardsmen: p_guardsmen[p], + pdf: p_pdf[p], + fortified: p_fortified[p], + station: p_station[p], + player: p_player[p], // TODO ??? + player_defense_structures: {}, + player_upgrade_structures_count: array_length(p_upgrades[p]), + player_upgrade_structures: [], + hurssy: p_hurssy[p], + hurssy_time: p_hurssy_time[p], + heresy: p_heresy[p], + heresy_secret: p_heresy_secret[p], + influence: p_influence[p], + raided: p_raided[p], + problems: [], + }; + + // Planetary Features + + for (var f = 0; f < _planet_data.feature_count; f++) { + var _feature = p_feature[p][f]; + var _feature_data = 0; + + if (!_feature) { + // TODO debug log warning/error + } else { + _feature_data = _feature.serialize(f); + } + + array_push(_planet_data.features, _feature_data); + } + + // Planetary Player Structures + + if (_planet_data.first == 1 || _planet_data.owner_index == 1) { // Belongs to Player + _planet_data.player_defense_structures.lasers = p_lasers[p]; + _planet_data.player_defense_structures.silos = p_silo[p]; + _planet_data.player_defense_structures.defenses = p_defenses[p]; + } + + // Planetary Player Upgrades + + for (var u = 0; u < _planet_data.player_upgrade_structures_count; u++) { + var _planetary_upgrade = p_upgrades[p][u]; + var _planetary_upgrade_data = 0; + + if (!_planetary_upgrade) { + // TODO debug log warning/error + } else { + _planetary_upgrade_data = _planetary_upgrade.serialize(u); + } + + array_push(_planet_data.player_upgrade_structures, _planetary_upgrade_data); + } + + // Planetary Faction presence + + _planet_data.faction_presence = { + orks: p_orks[p], + tau: p_tau[p], + eldar: p_eldar[p], + traitors: p_traitors[p], + chaos: p_chaos[p], + demons: p_demons[p], + sisters: p_sisters[p], + necrons: p_necrons[p], + tyranids: p_tyranids[p], + halp: p_halp[p], // TODO ??? + }; + + // Planetary Problems + + for(var i = 1; i <= 4; i++){ + array_push( + _planet_data.problems, + { + _index: i, + problem: p_problem[p][i], + timer: p_timer[p][i] + }); + } + + // Push planet data + array_push(_star_data.planets, _planet_data); + } + + return _star_data; +} + +#endregion serialization \ No newline at end of file diff --git a/scripts/scr_planetary_feature/scr_planetary_feature.gml b/scripts/scr_planetary_feature/scr_planetary_feature.gml index 639b66c86..e28d65f5a 100644 --- a/scripts/scr_planetary_feature/scr_planetary_feature.gml +++ b/scripts/scr_planetary_feature/scr_planetary_feature.gml @@ -218,6 +218,57 @@ function new_planet_feature(feature_type, other_data={}) constructor{ variable_struct_set(self, names[i], variable_struct_get(data, names[i])) } } + +#region serialization + + serialize = function(index){ + + // General data and init + + var _planetary_feature_data = { + _index: index, + type: f_type, + display_name: planet_display + } + + // Handle concrete types + + switch(f_type){ + case P_features.Secret_Base: + case P_features.Arsenal: + case P_features.Gene_Vault: + _planetary_feature_data.constructed_on_turn = built; + break; + default: + break; + } + + switch(f_type){ + case P_features.Secret_Base: + _planetary_feature_data.built_structures = { + forge, + hippo, + beastarium, + torture, + narcotics, + relic, + cookery, + vox, + librarium, + throne, + stasis, + swimming, + stock, + } + break; + default: + break; + } + + return _planetary_feature_data; + } + +#endregion } // returns an array of all the positions that a certain planet feature occurs on th p_feature array of a planet diff --git a/scripts/scr_save/scr_save.gml b/scripts/scr_save/scr_save.gml index 15cd333d8..9d850aade 100644 --- a/scripts/scr_save/scr_save.gml +++ b/scripts/scr_save/scr_save.gml @@ -29,9 +29,10 @@ var num = instance_number(obj_star); function SavedGameData() constructor { - game_version= global.version; timestamp = date_datetime_string(date_current_datetime()); + global_data = { + game_version: global.version, chapter_name: global.chapter_name, game_seed: global.game_seed, founding_secret: global.founding_secret, @@ -44,6 +45,44 @@ function SavedGameData() constructor }, sod: random_get_seed() // TODO what? looks like a checksum? } + controller = obj_controller.serialize(); + ini = obj_ini.serialize(); + + star_count= instance_number(obj_star); + stars=[]; + + for(var s = 0; s < star_count; s++){ + var star = instance_find(obj_star, s); + array_push(stars, star.serialize(s)); + }; + + // Temporary artifact objects + // TODO this looks like something which should be removed/merged + temporary_artifact_count = instance_number(obj_temp_arti); + temporary_artifacts = []; + + for(var tio = 0; tio < temporary_artifact_count; tio++){ + var _temporary_artifact_object = instance_find(obj_temp_arti, i); + array_push(temporary_artifacts, _temporary_artifact_object); + } + + player_fleet_count = instance_number(obj_p_fleet); + player_fleets = []; + + for(var pf = 0; pf < player_fleet_count; pf++){ + var _player_fleet = instance_find(obj_p_fleet, pf); + var _player_fleet_data = _player_fleet.serialize(pf); + array_push(player_fleets, _player_fleet_data); + } + + enemy_fleet_count = instance_number(obj_en_fleet); + enemy_fleets = []; + + for(var ef = 0; ef < enemy_fleet_count; ef++){ + var _enemy_fleet = instance_find(obj_en_fleet, ef); + var _enemy_fleet_data = _enemy_fleet.serialize(ef); + array_push(enemy_fleets, _enemy_fleet_data); + } } \ No newline at end of file From 67974b559d0683fae3c2602b31de501d00b20647 Mon Sep 17 00:00:00 2001 From: GalacticChimp Date: Sat, 18 Nov 2023 21:42:47 +0100 Subject: [PATCH 10/11] simplified serialization in obj_controller and obj_ini --- objects/obj_controller/Create_0.gml | 18 +-- objects/obj_ini/Create_0.gml | 204 ++++++++++++++-------------- 2 files changed, 111 insertions(+), 111 deletions(-) diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index 021e0b70d..5fd28d84f 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -1861,15 +1861,15 @@ serialize = function() { }, ], colors: { - main: obj_controller.col[obj_controller.main_color], - secondary: obj_controller.col[obj_controller.secondary_color], - trim: obj_controller.col[obj_controller.trim_color], - pauldron_2: obj_controller.col[obj_controller.pauldron2_color], - pauldron: obj_controller.col[obj_controller.pauldron_color], - lens: obj_controller.col[obj_controller.lens_color], - weapon: obj_controller.col[obj_controller.weapon_color], - special: obj_controller.col_special, - is_trimmed: obj_controller.trim, + main: col[main_color], + secondary: col[secondary_color], + trim: col[trim_color], + pauldron_2: col[pauldron2_color], + pauldron: col[pauldron_color], + lens: col[lens_color], + weapon: col[weapon_color], + special: col_special, + is_trimmed: trim, }, adept_name, recruiter_name, diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index 5daf064bf..eae862773 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -177,11 +177,11 @@ serialize = function() { for (var i = 0; i <= 20; i++) { - if (obj_ini.company_title[i] == "") then continue; + if (company_title[i] == "") then continue; array_push(_ini_data.company_titles,{ _index: i, - title: $"{obj_ini.company_title[i]}", + title: $"{company_title[i]}", }); } @@ -189,12 +189,12 @@ serialize = function() { for (var i = 0; i <= 120; i++) { - if (obj_ini.slave_batch_num[i] == 0) then continue; + if (slave_batch_num[i] == 0) then continue; array_push(_ini_data.slave_batches,{ _index: i, - amount: obj_ini.slave_batch_num[i], - eta: obj_ini.slave_batch_eta[i], + amount: slave_batch_num[i], + eta: slave_batch_eta[i], }); } @@ -202,14 +202,14 @@ serialize = function() { for (var i = 1; i <= 150; i++) { - if (obj_ini.equipment[i] == "") then continue; + if (equipment[i] == "") then continue; array_push(_ini_data.equipment,{ _index: i, - name: obj_ini.equipment[i], - type: obj_ini.equipment_type[i], - amount: obj_ini.equipment_number[i], - condition: obj_ini.equipment_condition[i], + name: equipment[i], + type: equipment_type[i], + amount: equipment_number[i], + condition: equipment_condition[i], }); } @@ -217,16 +217,16 @@ serialize = function() { for (var i = 1; i <= 150; i++) { - if (obj_ini.artifact[i] == "") then continue; + if (artifact[i] == "") then continue; array_push(_ini_data.artifacts,{ _index: i, - name: obj_ini.artifact[i], - tags: obj_ini.artifact_tags[i], - is_identified: obj_ini.artifact_identified[i], - condition: obj_ini.artifact_condition[i], - location: obj_ini.artifact_loc[i], - sid: obj_ini.artifact_sid[i], + name: artifact[i], + tags: artifact_tags[i], + is_identified: artifact_identified[i], + condition: artifact_condition[i], + location: artifact_loc[i], + sid: artifact_sid[i], }); } @@ -234,30 +234,30 @@ serialize = function() { for (var i = 1; i <= 200; i++) { - if (obj_ini.ship[i] == "") then continue; + if (ship[i] == "") then continue; array_push(_ini_data.ships,{ _index: i, - name: obj_ini.ship[i], - uid: obj_ini.ship_uid[i], - class: obj_ini.ship_class[i], - size: obj_ini.ship_size[i], - leadership: obj_ini.ship_leadership[i], - hp: obj_ini.ship_hp[i], - maxhp: obj_ini.ship_maxhp[i], - location: obj_ini.ship_location[i], - shields: obj_ini.ship_shields[i], - conditions: obj_ini.ship_conditions[i], - speed: obj_ini.ship_speed[i], - turning: obj_ini.ship_turning[i], - front_armour: obj_ini.ship_front_armour[i], - other_armour: obj_ini.ship_other_armour[i], - weapons_amount: obj_ini.ship_weapons[i], + name: ship[i], + uid: ship_uid[i], + class: ship_class[i], + size: ship_size[i], + leadership: ship_leadership[i], + hp: ship_hp[i], + maxhp: ship_maxhp[i], + location: ship_location[i], + shields: ship_shields[i], + conditions: ship_conditions[i], + speed: ship_speed[i], + turning: ship_turning[i], + front_armour: ship_front_armour[i], + other_armour: ship_other_armour[i], + weapons_amount: ship_weapons[i], weapons: [], - capacity: obj_ini.ship_capacity[i], - carrying: obj_ini.ship_carrying[i], - contents: obj_ini.ship_contents[i], - turrets: obj_ini.ship_turrets[i], + capacity: ship_capacity[i], + carrying: ship_carrying[i], + contents: ship_contents[i], + turrets: ship_turrets[i], }); // Try add ship weapons @@ -265,13 +265,13 @@ serialize = function() { if (_last_pushed_ship.weapons_amount == 0) then continue; for (j = 1; j <= 5; j++) { - if (obj_ini.ship_wep[i][j] == "") then continue; + if (ship_wep[i][j] == "") then continue; array_push(_last_pushed_ship.weapons,{ _index: j, - name: obj_ini.ship_wep[i][j], - facing: obj_ini.ship_wep_facing[i][j], - condition: obj_ini.ship_wep_condition[i][j], + name: ship_wep[i][j], + facing: ship_wep_facing[i][j], + condition: ship_wep_condition[i][j], }); } } @@ -297,26 +297,26 @@ serialize = function() { company_index--; } - if (obj_ini.veh_role[company_index, entity_in_company_index] != "") { + if (veh_role[company_index, entity_in_company_index] != "") { array_push(_ini_data.vehicles,{ company_index: company_index, entity_in_company_index: entity_in_company_index, - race: obj_ini.veh_race[company_index][entity_in_company_index], // TODO Got no idea what this does - location: obj_ini.veh_loc[company_index][entity_in_company_index], - role: obj_ini.veh_role[company_index][entity_in_company_index], - lid: obj_ini.veh_lid[company_index][entity_in_company_index], // TODO Got no idea what this does - uid: obj_ini.veh_uid[company_index][entity_in_company_index], // TODO Got no idea what this does - wid: obj_ini.veh_wid[company_index][entity_in_company_index], // TODO Got no idea what this does + race: veh_race[company_index][entity_in_company_index], // TODO Got no idea what this does + location: veh_loc[company_index][entity_in_company_index], + role: veh_role[company_index][entity_in_company_index], + lid: veh_lid[company_index][entity_in_company_index], // TODO Got no idea what this does + uid: veh_uid[company_index][entity_in_company_index], // TODO Got no idea what this does + wid: veh_wid[company_index][entity_in_company_index], // TODO Got no idea what this does weapons: [ - obj_ini.veh_wep1[company_index][entity_in_company_index], - obj_ini.veh_wep2[company_index][entity_in_company_index], - obj_ini.veh_wep3[company_index][entity_in_company_index], + veh_wep1[company_index][entity_in_company_index], + veh_wep2[company_index][entity_in_company_index], + veh_wep3[company_index][entity_in_company_index], ], - upgrade: obj_ini.veh_upgrade[company_index][entity_in_company_index], - accessory: obj_ini.veh_acc[company_index][entity_in_company_index], - hp: obj_ini.veh_hp[company_index][entity_in_company_index], - chaos_corruption_level: obj_ini.veh_chaos[company_index][entity_in_company_index], - pilots: obj_ini.veh_pilots[company_index][entity_in_company_index], // TODO this one looks not fully implemented + upgrade: veh_upgrade[company_index][entity_in_company_index], + accessory: veh_acc[company_index][entity_in_company_index], + hp: veh_hp[company_index][entity_in_company_index], + chaos_corruption_level: veh_chaos[company_index][entity_in_company_index], + pilots: veh_pilots[company_index][entity_in_company_index], // TODO this one looks not fully implemented }); } @@ -339,19 +339,19 @@ serialize = function() { // HQ Marines?? for (entity_in_company_index = 1; entity_in_company_index <= 30; entity_in_company_index++) { - if (obj_ini.role[company_index][entity_in_company_index] == "") then continue; + if (role[company_index][entity_in_company_index] == "") then continue; array_push(_ini_data.marines,{ company_index: company_index, entity_in_company_index: entity_in_company_index, - race: obj_ini.race[company_index][entity_in_company_index], - name: obj_ini.name[company_index][entity_in_company_index], - role: obj_ini.role[company_index][entity_in_company_index], - weapon_1: obj_ini.wep1[company_index][entity_in_company_index], - weapon_2: obj_ini.wep2[company_index][entity_in_company_index], - armour: obj_ini.armour[company_index][entity_in_company_index], - gear: obj_ini.gear[company_index][entity_in_company_index], - mobility_item: obj_ini.mobi[company_index][entity_in_company_index], + race: race[company_index][entity_in_company_index], + name: name[company_index][entity_in_company_index], + role: role[company_index][entity_in_company_index], + weapon_1: wep1[company_index][entity_in_company_index], + weapon_2: wep2[company_index][entity_in_company_index], + armour: armour[company_index][entity_in_company_index], + gear: gear[company_index][entity_in_company_index], + mobility_item: mobi[company_index][entity_in_company_index], }); } @@ -359,33 +359,33 @@ serialize = function() { for (company_index = 0; company_index <= 10; company_index++) { for (entity_in_company_index = 0; entity_in_company_index <= 500; entity_in_company_index++) { - if (obj_ini.name[company_index][entity_in_company_index] == "") then continue; + if (name[company_index][entity_in_company_index] == "") then continue; array_push(_ini_data.marines,{ company_index: company_index, entity_in_company_index: entity_in_company_index, - race: obj_ini.race[company_index][entity_in_company_index], - location: obj_ini.loc[company_index][entity_in_company_index], - name: obj_ini.name[company_index][entity_in_company_index], - role: obj_ini.role[company_index][entity_in_company_index], - lid: obj_ini.lid[company_index][entity_in_company_index], // TODO Got no idea what this does - bio: obj_ini.bio[company_index][entity_in_company_index], // TODO Got no idea what this does - wid: obj_ini.wid[company_index][entity_in_company_index], // TODO Got no idea what this does - weapon_1: obj_ini.wep1[company_index][entity_in_company_index], - weapon_2: obj_ini.wep2[company_index][entity_in_company_index], - armour: obj_ini.armour[company_index][entity_in_company_index], - gear: obj_ini.gear[company_index][entity_in_company_index], - mobility_item: obj_ini.mobi[company_index][entity_in_company_index], - hp: obj_ini.TTRPG[company_index][entity_in_company_index].hp(), - chaos_corruption_level: obj_ini.chaos[company_index][entity_in_company_index], - experience: obj_ini.experience[company_index][entity_in_company_index], - age: obj_ini.age[company_index][entity_in_company_index], - is_special: obj_ini.spe[company_index][entity_in_company_index], // TODO Got no idea what this does - god: obj_ini.god[company_index][entity_in_company_index], // TODO Got no idea what this does + race: race[company_index][entity_in_company_index], + location: loc[company_index][entity_in_company_index], + name: name[company_index][entity_in_company_index], + role: role[company_index][entity_in_company_index], + lid: lid[company_index][entity_in_company_index], // TODO Got no idea what this does + bio: bio[company_index][entity_in_company_index], // TODO Got no idea what this does + wid: wid[company_index][entity_in_company_index], // TODO Got no idea what this does + weapon_1: wep1[company_index][entity_in_company_index], + weapon_2: wep2[company_index][entity_in_company_index], + armour: armour[company_index][entity_in_company_index], + gear: gear[company_index][entity_in_company_index], + mobility_item: mobi[company_index][entity_in_company_index], + hp: TTRPG[company_index][entity_in_company_index].hp(), + chaos_corruption_level: chaos[company_index][entity_in_company_index], + experience: experience[company_index][entity_in_company_index], + age: age[company_index][entity_in_company_index], + is_special: spe[company_index][entity_in_company_index], // TODO Got no idea what this does + god: god[company_index][entity_in_company_index], // TODO Got no idea what this does }); - if (is_struct(obj_ini.TTRPG[company_index][entity_in_company_index])) { - array_last(_ini_data.marines).ttrpg_stats = obj_ini.TTRPG[company_index][entity_in_company_index]; + if (is_struct(TTRPG[company_index][entity_in_company_index])) { + array_last(_ini_data.marines).ttrpg_stats = TTRPG[company_index][entity_in_company_index]; } else { debugl($"obj_ini.Serialize(): Marine [{company_index}][{entity_in_company_index}] has no TTRPG_stats struct, creating blank..."); array_last(_ini_data.marines).ttrpg_stats = new TTRPG_stats("chapter", company_index, entity_in_company_index, "blank"); @@ -395,10 +395,10 @@ serialize = function() { // Squads - var squad_array_length = array_length(obj_ini.squads); + var squad_array_length = array_length(squads); if (squad_array_length > 0) { for (var i = 0; i < squad_array_length; i++) { - array_push(_ini_data.squads,obj_ini.squads[i].serialize()); + array_push(_ini_data.squads,squads[i].serialize()); } } @@ -409,17 +409,17 @@ serialize = function() { for (entity_in_company_index = 0; entity_in_company_index <= 20; entity_in_company_index++) { - if (obj_ini.role[company_index][entity_in_company_index] == "") then continue; + if (role[company_index][entity_in_company_index] == "") then continue; array_push(_ini_data.marines,{ company_index: company_index, entity_in_company_index: entity_in_company_index, - role: obj_ini.role[company_index][entity_in_company_index], - weapon_1: obj_ini.wep1[company_index][entity_in_company_index], - weapon_2: obj_ini.wep2[company_index][entity_in_company_index], - armour: obj_ini.armour[company_index][entity_in_company_index], - gear: obj_ini.gear[company_index][entity_in_company_index], - mobility_item: obj_ini.mobi[company_index][entity_in_company_index], + role: role[company_index][entity_in_company_index], + weapon_1: wep1[company_index][entity_in_company_index], + weapon_2: wep2[company_index][entity_in_company_index], + armour: armour[company_index][entity_in_company_index], + gear: gear[company_index][entity_in_company_index], + mobility_item: mobi[company_index][entity_in_company_index], }); } @@ -428,17 +428,17 @@ serialize = function() { for (entity_in_company_index = 0; entity_in_company_index <= 20; entity_in_company_index++) { - if (obj_ini.role[company_index][entity_in_company_index] == "") then continue; + if (role[company_index][entity_in_company_index] == "") then continue; array_push(_ini_data.marines,{ company_index: company_index, entity_in_company_index: entity_in_company_index, - role: obj_ini.role[company_index][entity_in_company_index], - weapon_1: obj_ini.wep1[company_index][entity_in_company_index], - weapon_2: obj_ini.wep2[company_index][entity_in_company_index], - armour: obj_ini.armour[company_index][entity_in_company_index], - gear: obj_ini.gear[company_index][entity_in_company_index], - mobility_item: obj_ini.mobi[company_index][entity_in_company_index], + role: role[company_index][entity_in_company_index], + weapon_1: wep1[company_index][entity_in_company_index], + weapon_2: wep2[company_index][entity_in_company_index], + armour: armour[company_index][entity_in_company_index], + gear: gear[company_index][entity_in_company_index], + mobility_item: mobi[company_index][entity_in_company_index], }); } From 9751429afe9b7b9e3dd782966356078018b8e266 Mon Sep 17 00:00:00 2001 From: GalacticChimp Date: Fri, 1 Dec 2023 11:26:59 +0100 Subject: [PATCH 11/11] small faction enum tweaks --- objects/obj_controller/Create_0.gml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index 04670ac1f..d94848a1a 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -917,14 +917,15 @@ enum eFACTION { Imperium, Mechanicus, Inquisition, - Ecclesiarchy, + Ecclesiarchy, // 5, last Imperial faction Eldar, Ork, Tau, Tyranids, - Chaos, + Chaos, // 10 Heretics, - Necrons = 13 + Placeholder_1, // 12, not used anywhere currently, will be removed after creating proper structs for Factions + Necrons // 13 } faction[0]=""; disposition[0]=0;