Skip to content

Commit 0ec4930

Browse files
committed
Minor gene-seed recovery alteration and string improvments
1 parent 8ef11bf commit 0ec4930

6 files changed

Lines changed: 81 additions & 54 deletions

File tree

objects/obj_ncombat/Alarm_5.gml

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ if (obj_ncombat.defeat == 0) {
8080
_column_id.veh_hp[_vehicle_id] = roll_dice(1, 10, "high");
8181
_column_id.veh_dead[_vehicle_id] = false;
8282
vehicles_saved_count++;
83-
vehicle_deaths--;
8483

8584
if (!struct_exists(obj_ncombat.vehicles_saved_counts, _vehicle_type)) {
8685
obj_ncombat.vehicles_saved_counts[$ _vehicle_type] = 1;
@@ -96,7 +95,6 @@ if (obj_ncombat.defeat == 0) {
9695
_column_id.veh_dead[_vehicle_id] = false;
9796
vehicle_recovery_score -= _candidate.priority;
9897
vehicles_saved_count++;
99-
vehicle_deaths--;
10098

10199
if (!struct_exists(obj_ncombat.vehicles_saved_counts, _vehicle_type)) {
102100
obj_ncombat.vehicles_saved_counts[$ _vehicle_type] = 1;
@@ -114,8 +112,9 @@ with (obj_pnunit) {
114112
}
115113

116114
var _total_deaths = final_marine_deaths + final_command_deaths;
117-
if (_total_deaths > 0 || injured > 0 || units_saved_count > 0) {
118-
newline = $"{_total_deaths + injured + units_saved_count}x units were critically injured.";
115+
var _total_injured = _total_deaths + injured + units_saved_count;
116+
if (_total_injured > 0) {
117+
newline = $"{string_plural_count("unit", _total_injured)} {smart_verb("was", _total_injured)} critically injured.";
119118
newline_color = "red";
120119
scr_newtext();
121120

@@ -130,7 +129,7 @@ if (_total_deaths > 0 || injured > 0 || units_saved_count > 0) {
130129
_units_saved_string += smart_delimeter_sign(_unit_roles, i, false);
131130
}
132131

133-
newline = $"{units_saved_count}x were saved by the {string_plural(roles[eROLE.Apothecary], apothecaries_alive)}. ({_units_saved_string})";
132+
newline = $"{units_saved_count}x {smart_verb("was", units_saved_count)} saved by the {string_plural(roles[eROLE.Apothecary], apothecaries_alive)}. ({_units_saved_string})";
134133
scr_newtext();
135134
}
136135

@@ -156,7 +155,7 @@ if (_total_deaths > 0 || injured > 0 || units_saved_count > 0) {
156155
}
157156

158157
newline = " ";
159-
scr_newtext();
158+
scr_newtext();
160159
}
161160

162161

@@ -166,31 +165,27 @@ if (ground_mission){
166165
}
167166
};
168167

169-
seed_saved = (min(seed_max, apothecaries_alive * 40));
170-
if (obj_ini.doomed) then seed_saved=0;
171-
if (seed_saved>0) then obj_controller.gene_seed+=seed_saved;
168+
if (seed_lost > 0) {
169+
if (obj_ini.doomed) {
170+
newline = $"Chapter mutation prevents retrieving gene-seed. {seed_lost} gene-seed lost.";
171+
scr_newtext();
172+
} else if (!apothecaries_alive) {
173+
newline = $"No able-bodied {roles[eROLE.Apothecary]}. {seed_lost} gene-seed lost.";
174+
scr_newtext();
175+
} else {
176+
seed_saved = min(seed_harvestable, apothecaries_alive * 40);
177+
newline = $"{seed_saved} gene-seed was recovered; {seed_lost - seed_harvestable} was lost due damage; {seed_harvestable - seed_saved} was left to rot;";
178+
scr_newtext();
179+
}
172180

173-
if (obj_ini.doomed && !apothecaries_alive){
174-
part3=$"Chapter Mutation prevents retrieving Gene-Seed. {seed_max} Gene-Seed lost.";
175-
newline=part3;
176-
scr_newtext();
177-
newline=" ";
178-
scr_newtext();
179-
}else if (!apothecaries_alive && !obj_ini.doomed){
180-
part3=$"No able-bodied {roles[eROLE.Apothecary]}. {seed_max} Gene-Seed lost.";
181-
newline=part3;scr_newtext();
182-
newline=" ";scr_newtext();
183-
}else if (apothecaries_alive>0 && final_marine_deaths+final_command_deaths>0 && !obj_ini.doomed){
184-
part3=$"Gene-Seed Recovered: {seed_saved}(";
185-
part3 += seed_saved ? $"{round((seed_saved/seed_max)*100)}" : "0";
186-
part3 += "%)";
187-
newline=part3;
188-
scr_newtext();
189-
newline=" ";
181+
if (seed_saved > 0) {
182+
obj_controller.gene_seed += seed_saved;
183+
}
184+
185+
newline = " ";
190186
scr_newtext();
191187
}
192188

193-
194189
if (red_thirst>2){
195190
var voodoo="";
196191

@@ -207,9 +202,9 @@ newline = " ";
207202
scr_newtext();
208203

209204

210-
211-
if (vehicles_saved_count > 0 || vehicle_deaths > 0) {
212-
newline = $"{string_plural_count("Vehicle", vehicle_deaths + vehicles_saved_count)} were critically damaged during battle.";
205+
var _total_damaged_count = vehicle_deaths + vehicles_saved_count;
206+
if (_total_damaged_count > 0) {
207+
newline = $"{string_plural_count("vehicle", _total_damaged_count)} {smart_verb("was", _total_damaged_count)} critically damaged during battle.";
213208
newline_color="red";
214209
scr_newtext();
215210

@@ -224,24 +219,24 @@ if (vehicles_saved_count > 0 || vehicle_deaths > 0) {
224219
_vehicles_saved_string += smart_delimeter_sign(_vehicle_types, i, false);
225220
}
226221

227-
newline = $"{string_plural(roles[eROLE.Techmarine], techmarines_alive)} were able to restore {vehicles_saved_count}. ({_vehicles_saved_string})";
222+
newline = $"{string_plural(roles[eROLE.Techmarine], techmarines_alive)} {smart_verb("was", techmarines_alive)} able to restore {vehicles_saved_count}. ({_vehicles_saved_string})";
228223
scr_newtext();
229224
}
230225

231226
if (vehicle_deaths > 0) {
232227
var _vehicles_lost_string = "";
233-
var _vehicle_types = struct_get_names(vehicles_lost_counts);
228+
var _vehicle_types = struct_get_names(vehicles_lost_counts);
234229

235-
for (var i = 0; i < array_length(_vehicle_types); i++) {
236-
var _vehicle_type = _vehicle_types[i];
237-
var _lost_count = vehicles_lost_counts[$ _vehicle_type];
230+
for (var i = 0; i < array_length(_vehicle_types); i++) {
231+
var _vehicle_type = _vehicle_types[i];
232+
var _lost_count = vehicles_lost_counts[$ _vehicle_type];
238233
_vehicles_lost_string += $"{string_plural_count(_vehicle_type, _lost_count)}";
239234
_vehicles_lost_string += smart_delimeter_sign(_vehicle_types, i, false);
240235
}
241236

242-
newline += $"{vehicle_deaths} were lost forever. ({_vehicles_lost_string})";
243-
newline_color="red";
244-
scr_newtext();
237+
newline += $"{vehicle_deaths} {smart_verb("was", vehicle_deaths)} lost forever. ({_vehicles_lost_string})";
238+
newline_color="red";
239+
scr_newtext();
245240
}
246241

247242
newline = " ";
@@ -915,7 +910,7 @@ if (endline=0){
915910
if (defeat=1){
916911
player_forces=0;
917912
if (ground_mission){
918-
obj_ground_mission.recoverable_gene_seed = seed_max;
913+
obj_ground_mission.recoverable_gene_seed = seed_lost;
919914
}
920915

921916
}

objects/obj_ncombat/Create_0.gml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ vehicle_recovery_score=0;
146146
injured=0;
147147
command_injured=0;
148148
seed_saved=0;
149-
seed_max=0;
149+
seed_lost=0;
150+
seed_harvestable=0;
150151
units_saved_count=0;
151152
units_saved_counts={};
152153
vehicles_saved_counts={};

objects/obj_p_assra/Alarm_0.gml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ for (o=0;o<array_length(origin.board_co);o++){
66
i=origin.board_id[o];
77
unit = fetch_unit([co, i]);
88
if (unit.hp()<=-15) and (obj_ini.race[co][i]=1) and (unit.name()!=""){
9-
var seed_max=0;
9+
var seed_lost=0;
1010
if (apothecary<=0){
1111
if (unit.IsSpecialist("standard")){
1212
obj_fleet.fallen_command+=1;
@@ -17,8 +17,8 @@ for (o=0;o<array_length(origin.board_co);o++){
1717
if (apothecary_had>0){
1818
if (unit.base_group=="astartes"){
1919
var age=obj_ini.age[co][i];
20-
if (age<=((obj_controller.millenium*1000)+obj_controller.year)-10) and (obj_ini.zygote=0) then seed_max+=1;
21-
if (age<=((obj_controller.millenium*1000)+obj_controller.year)-5) then seed_max+=1;
20+
if (age<=((obj_controller.millenium*1000)+obj_controller.year)-10) and (obj_ini.zygote=0) then seed_lost+=1;
21+
if (age<=((obj_controller.millenium*1000)+obj_controller.year)-5) then seed_lost+=1;
2222
}
2323
}
2424

@@ -31,7 +31,7 @@ for (o=0;o<array_length(origin.board_co);o++){
3131

3232
scr_kill_unit(co,i)
3333

34-
if (obj_fleet.capital+obj_fleet.frigate+obj_fleet.escort>0) then obj_controller.gene_seed+=seed_max;
34+
if (obj_fleet.capital+obj_fleet.frigate+obj_fleet.escort>0) then obj_controller.gene_seed+=seed_lost;
3535
}else if (apothecary>0){
3636
unit.add_or_sub_health(irandom_range(9,14));
3737
apothecary-=0.5;

scripts/scr_after_combat/scr_after_combat.gml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,22 +201,24 @@ function after_battle_part2() {
201201
if (obj_ini.race[marine_co[i], marine_id[i]] == 1) {
202202
var _birthday = obj_ini.age[marine_co[i], marine_id[i]];
203203
var _current_year = (obj_controller.millenium * 1000) + obj_controller.year;
204-
var _harvestable_seed = 0;
205-
var _total_seed = 0;
204+
var _seed_harvestable = 0;
205+
var _seed_lost = 0;
206206

207207
if (_birthday <= (_current_year - 10) && obj_ini.zygote == 0) {
208-
_total_seed++;
209-
if (irandom_range(1, 20) > 1) {
210-
_harvestable_seed++;
208+
_seed_lost++;
209+
if (irandom_range(1, 10) > 1) {
210+
_seed_harvestable++;
211211
}
212212
}
213213
if (_birthday <= (_current_year - 5)) {
214-
_total_seed++;
215-
if (irandom_range(1, 20) > 1) {
216-
_harvestable_seed++;
214+
_seed_lost++;
215+
if (irandom_range(1, 10) > 1) {
216+
_seed_harvestable++;
217217
}
218218
}
219-
obj_ncombat.seed_max += _total_seed;
219+
220+
obj_ncombat.seed_harvestable += _seed_harvestable;
221+
obj_ncombat.seed_lost += _seed_lost;
220222
}
221223

222224
var last=0;

scripts/scr_roster/scr_roster.gml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ function Roster() constructor{
226226
var _roster_types = struct_get_names(possible_local_roster);
227227
for (var i=0;i<array_length(_roster_types);i++){
228228
var _roster_type_name = _roster_types[i];
229-
var _roster_type_count = selected_roster[$_roster_type_name];
229+
var _roster_type_count = possible_local_roster[$_roster_type_name];
230230

231231
roster_local_string += $"{string_plural_count(_roster_type_name, _roster_type_count)}";
232232
roster_local_string += smart_delimeter_sign(_roster_types, i, false);

scripts/scr_string_functions/scr_string_functions.gml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,3 +281,32 @@ function base64_encode_advanced(input_string) {
281281

282282
return _encoded_string;
283283
}
284+
285+
/// @param {string} _verb The verb to be transformed (e.g., "was", "is", "has", etc.).
286+
/// @param {number} _variable A value determining singular (1) or plural (any value other than 1).
287+
/// @returns {string}
288+
function smart_verb(_verb, _variable) {
289+
var _result = _verb;
290+
291+
if (_variable != 1) {
292+
switch (_verb) {
293+
case "was":
294+
_result = "were";
295+
break;
296+
case "is":
297+
_result = "are";
298+
break;
299+
case "has":
300+
_result = "have";
301+
break;
302+
case "do":
303+
_result = "do";
304+
break;
305+
default:
306+
_result = _verb;
307+
break;
308+
}
309+
}
310+
311+
return _result;
312+
}

0 commit comments

Comments
 (0)