Skip to content

Commit ce33b89

Browse files
authored
fix: Mission issues with selection and loading (Adeptus-Dominus#617)
1 parent 47e346b commit ce33b89

File tree

7 files changed

+141
-143
lines changed

7 files changed

+141
-143
lines changed

objects/obj_controller/Alarm_5.gml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ if (fest_scheduled>0) and (fest_repeats>0){
817817

818818
research_end();
819819
merge_ork_fleets();
820+
location_viewer.update_mission_log();
820821
//complex route plotting for player fleets
821822
return_lost_ships_chance();
822823
with (obj_p_fleet){

scripts/is_specialist/is_specialist.gml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -347,22 +347,10 @@ function group_selection(group, selection_data){
347347
obj_controller.selection_data = selection_data;
348348
set_zoom_to_default();
349349
with (obj_controller){
350-
menu=1;
351-
onceh=1;
352-
cooldown=8000;
353-
click=1;
354-
popup=0;
355-
selected=0;
356-
hide_banner=1;
350+
basic_manage_settings();
357351
with(obj_fleet_select){instance_destroy();}
358352
with(obj_star_select){instance_destroy();}
359-
view_squad=false;
360-
managing=0;
361-
zoomed=0;
362-
menu=1;
363-
managing=0;
364-
diplomacy=0;
365-
cooldown=8000;
353+
366354
exit_button = new ShutterButton();
367355
proceed_button = new ShutterButton();
368356
selection_data.start_count=0;
@@ -417,7 +405,7 @@ function group_selection(group, selection_data){
417405
man_see=38-4;
418406
}
419407
} catch(_exception) {
420-
handle_exception(_exception);
421-
scr_toggle_manage();//handle and send player back to map
408+
handle_exception(_exception);
409+
scr_toggle_manage();//handle and send player back to map
422410
}
423411
}

scripts/scr_cheatcode/scr_cheatcode.gml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,19 @@ function scr_cheatcode(argument0) {
116116
var last_artifact = scr_add_artifact("good", "inquisition", 0, obj_ini.ship[0], 501);
117117
break;
118118
case "govmission":
119+
var problem = "";
120+
if (array_length(cheat_arguments)){
121+
if (cheat_arguments[0] != "1"){
122+
problem = cheat_arguments[0]
123+
}
124+
}
119125
with (obj_star) {
120126
for (var i = 1; i <= planets; i++) {
121127
var existing_problem = false; //has_any_problem_planet(i);
122128
if (!existing_problem) {
123129
if (p_owner[i] == eFACTION.Imperium) {
124130
show_debug_message("mission");
125-
scr_new_governor_mission(i);
131+
scr_new_governor_mission(i, problem);
126132
}
127133
}
128134
}

scripts/scr_controller_helpers/scr_controller_helpers.gml

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -110,35 +110,40 @@ function scr_in_game_menu(){
110110
}
111111
});
112112
}
113+
114+
function basic_manage_settings(){
115+
menu=1;
116+
popup=0;
117+
selected=0;
118+
hide_banner=1;
119+
diplomacy=0;
120+
zoomed=0;
121+
view_squad=false;
122+
management_buttons = {
123+
squad_toggle : new UnitButtonObject({
124+
style : "pixel",
125+
label : "Squad View",
126+
tooltip : "Click here or press S to toggle Squad View."
127+
}),
128+
129+
profile_toggle : new UnitButtonObject({
130+
style : "pixel",
131+
label : "Show Profile",
132+
tooltip : "Click here or press P to show unit profile."
133+
}),
134+
135+
bio_toggle : new UnitButtonObject({
136+
style : "pixel",
137+
label : "Show Bio",
138+
tooltip : "Click here or press B to Toggle Unit Biography."
139+
}),
140+
}
141+
}
113142
function scr_toggle_manage(){
114143
scr_change_menu(function(){
115144
with (obj_controller){
116145
if (menu!=1){
117-
view_squad=false;
118-
scr_management(1);
119-
menu=1;
120-
popup=0;
121-
selected=0;
122-
hide_banner=1;
123-
management_buttons = {
124-
squad_toggle : new UnitButtonObject({
125-
style : "pixel",
126-
label : "Squad View",
127-
tooltip : "Click here or press S to toggle Squad View."
128-
}),
129-
130-
profile_toggle : new UnitButtonObject({
131-
style : "pixel",
132-
label : "Show Profile",
133-
tooltip : "Click here or press P to show unit profile."
134-
}),
135-
136-
bio_toggle : new UnitButtonObject({
137-
style : "pixel",
138-
label : "Show Bio",
139-
tooltip : "Click here or press B to Toggle Unit Biography."
140-
}),
141-
}
146+
basic_manage_settings();
142147
}
143148
else if (menu==1){
144149
menu=0;

scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,17 @@ function scr_enemy_ai_d() {
5353
}
5454
}
5555
for (var i=1;i<=planets;i++){
56-
if (planet_problemless(i)) then continue;
5756
problem_count_down(i);
57+
if (planet_problemless(i)) then continue;
5858
numeral_name = planet_numeral_name(i);
59+
5960
if (has_problem_planet_and_time(i, "succession", 0)){
6061
var result,alert_text;
6162
var dice1=roll_dice(1, 100);
6263
var dice2=roll_dice(1, 100);
6364

64-
result="";alert_text="";
65+
result="";
66+
alert_text="";
6567
if (dice1<=(p_heresy[i]*2)) then result="chaos";
6668
if (dice2<=(p_influence[i][eFACTION.Tau]*2)) and (result="") then result="tau";
6769
if (result="") then result="imperial";
@@ -387,9 +389,13 @@ function scr_enemy_ai_d() {
387389
if (garrison_mission>-1){
388390
try_and_report_loop("complete garrison mission", complete_garrison_mission,true, [i,garrison_mission]);
389391
}
390-
var beast_hunt = has_problem_planet_and_time(i,"hunt_beast", 0);
391-
if (beast_hunt>-1){
392-
try_and_report_loop("complete beast hunt mission", complete_beast_hunt_mission,true, [i,beast_hunt]);
392+
var _beast_hunt = has_problem_planet_and_time(i,"hunt_beast", 0);
393+
if (_beast_hunt>-1){
394+
try{
395+
complete_beast_hunt_mission(i,_beast_hunt);
396+
} catch (_exception){
397+
handle_exception(exception);
398+
}
393399
}
394400

395401
if ((p_tyranids[i]=3) or (p_tyranids[i]=4)) and (p_population[i]>0){

scripts/scr_mission_functions/scr_mission_functions.gml

Lines changed: 36 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// Script assets have changed for v2.3.0 see
22
// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information
33

4+
5+
function MissionHandler(planet, system) : PlanetData(planet, system) constructor{
6+
7+
}
48
function mission_name_key(mission){
59
var mission_key = {
610
"meeting_trap" : "Chaos Lord Meeting",
@@ -34,29 +38,31 @@ function mission_name_key(mission){
3438
return "none"
3539
}
3640
}
37-
function scr_new_governor_mission(planet){
38-
problem = "";
39-
if p_owner[planet]!=eFACTION.Imperium then exit;
41+
function scr_new_governor_mission(planet, problem = ""){
42+
43+
if p_owner[planet] != eFACTION.Imperium then exit;
4044
var planet_type= p_type[planet];
41-
if (planet_type=="Death"){
42-
problem = choose("hunt_beast", "provide_garrison");
43-
accept_time = 6+irandom(30);
44-
} else if (planet_type == "Hive"){
45-
problem = choose("Show_of_power", "provide_garrison", "purge_enemies", "raid_black_market");
46-
} else if (planet_type == "Temperate"){
47-
problem = choose("provide_garrison", "train_forces", "join_parade");
48-
}else if (planet_type == "Shrine"){
49-
problem = choose("provide_garrison", "join_communion");
50-
}else if (planet_type == "Ice"){
51-
problem = choose("provide_garrison", "hunt_beast");
52-
}else if (planet_type == "Lava"){
53-
problem = choose("provide_garrison", "protect_raiders");
54-
}else if (planet_type == "Agri"){
55-
problem = choose("provide_garrison", "protect_raiders", "recover_artifacts");
56-
}else if (planet_type == "Desert"){
57-
problem = choose("provide_garrison", "protect_raiders", "recover_artifacts");
58-
}else if (planet_type == "Feudal"){
59-
problem = choose("hunt_beast", "protect_raiders");
45+
if (problem == ""){
46+
if (planet_type=="Death"){
47+
problem = choose("hunt_beast", "provide_garrison");
48+
accept_time = 6+irandom(30);
49+
} else if (planet_type == "Hive"){
50+
problem = choose("Show_of_power", "provide_garrison", "purge_enemies", "raid_black_market");
51+
} else if (planet_type == "Temperate"){
52+
problem = choose("provide_garrison", "train_forces", "join_parade");
53+
}else if (planet_type == "Shrine"){
54+
problem = choose("provide_garrison", "join_communion");
55+
}else if (planet_type == "Ice"){
56+
problem = choose("provide_garrison", "hunt_beast");
57+
}else if (planet_type == "Lava"){
58+
problem = choose("provide_garrison", "protect_raiders");
59+
}else if (planet_type == "Agri"){
60+
problem = choose("provide_garrison", "protect_raiders", "recover_artifacts");
61+
}else if (planet_type == "Desert"){
62+
problem = choose("provide_garrison", "protect_raiders", "recover_artifacts");
63+
}else if (planet_type == "Feudal"){
64+
problem = choose("hunt_beast", "protect_raiders");
65+
}
6066
}
6167
var mission_data = {
6268
stage : "preliminary",
@@ -84,31 +90,6 @@ function scr_new_governor_mission(planet){
8490
}
8591
}
8692

87-
88-
function init_garrison_mission(planet, star, mission_slot){
89-
var problems_data = star.p_problem_other_data[planet]
90-
var mission_data = problems_data[mission_slot];
91-
if (mission_data.stage == "preliminary"){
92-
var numeral_name = planet_numeral_name(planet, star);
93-
mission_data.stage = "active";
94-
var garrison_length=(10+irandom(6));
95-
star.p_timer[planet][mission_slot] = garrison_length;
96-
//pop.image="ancient_ruins";
97-
var gar_pop=instance_create(0,0,obj_popup);
98-
//TODO some new universal methods for popups
99-
gar_pop.title=$"Requested Garrison Provided to {numeral_name}";
100-
gar_pop.text=$"The govornor of {numeral_name} Thanks you for considering his request for a garrison, you agree that the garrison will remain for at least {garrison_length} months.";
101-
//pip.image="event_march"
102-
gar_pop.option1="Commence Garrison";
103-
gar_pop.image="";
104-
gar_pop.cooldown=8;
105-
obj_controller.cooldown=8;
106-
scr_event_log("",$"Garrison commited to {numeral_name} for {garrison_length} months.", target.name);
107-
}
108-
}
109-
110-
111-
11293
function init_beast_hunt_mission(planet, star, mission_slot){
11394
var problems_data = star.p_problem_other_data[planet]
11495
var mission_data = problems_data[mission_slot];
@@ -221,10 +202,10 @@ function complete_beast_hunt_mission(targ_planet, problem_index){
221202
} else if (_tough_check[1]>=-10){
222203
if (irandom(100)<_unit.luck){
223204
_unit.add_or_sub_health(-100);
224-
$"{_unit.name_role()} Was injured (health - 100)\n";
205+
_unit_report_string += $"{_unit.name_role()} Was injured (health - 100)\n";
225206
} else {
226207
_unit.add_or_sub_health(-250);
227-
$"{_unit.name_role()} Was Badly injured, it is unknown if he will recover (health - 250)\n";
208+
_unit_report_string += $"{_unit.name_role()} Was Badly injured, it is unknown if he will recover (health - 250)\n";
228209
}
229210
}
230211
}
@@ -238,7 +219,8 @@ function complete_beast_hunt_mission(targ_planet, problem_index){
238219
}
239220
_mission_string += $"\n{_unit_report_string}";
240221
} else {
241-
222+
_mission_string = $"The mission was a failiure. The governor is disapointed and the legend of your chapter has undoubtedly been diminished";
223+
_mission_string += $"\n{_unit_report_string}";
242224
}
243225
scr_popup($"Beast Hunt on {planet_numeral_name(i)}",_mission_string,"","");
244226
remove_planet_problem(targ_planet, "hunt_beast");
@@ -265,20 +247,20 @@ function has_any_problem_planet(planet, star="none"){
265247
}
266248

267249
function planet_problemless(planet, star="none"){
268-
var has_problem = false;
250+
var _problemless = true;
269251
if (star=="none"){
270252
for (var i=0;i<array_length(p_problem[planet]);i++){
271253
if (p_problem[planet][i] != ""){
272-
has_problem=true;
254+
_problemless=false;
273255
break;
274256
}
275257
}
276258
} else {
277259
with (star){
278-
has_problem = planet_problemless(planet);
260+
_problemless = planet_problemless(planet);
279261
}
280262
}
281-
return !has_problem;
263+
return _problemless;
282264
}
283265

284266
/*

0 commit comments

Comments
 (0)