Skip to content

Commit

Permalink
refactor: load_json_data() try-catch
Browse files Browse the repository at this point in the history
  • Loading branch information
EttyKitty committed Nov 13, 2024
1 parent e55b3aa commit 7626ef6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions scripts/scr_marine_struct/scr_marine_struct.gml
Original file line number Diff line number Diff line change
Expand Up @@ -892,16 +892,23 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data={})
}
return max_h;
};

static increase_max_health = function(increase){
return max_health() + (increase*(1+((constitution - 40)*0.025))); //calculate the effect of unit_health buffs
};

// used both to load unit data from save and to add preset base_stats
static load_json_data = function(data){ //this also allows us to create a pre set of anysort for a marine
var names = variable_struct_get_names(data);
for (var i = 0; i < array_length(names); i++) {
variable_struct_set(self, names[i], variable_struct_get(data, names[i]))
}
try {
var names = variable_struct_get_names(data);
for (var i = 0; i < array_length(names); i++) {
variable_struct_set(self, names[i], variable_struct_get(data, names[i]))
}
} catch (_exception) {
handle_exception(_exception);
}
};

traits = []; //marine trait list
feats = [];
allegiance =faction; //faction alligience defaults to the chapter
Expand Down

0 comments on commit 7626ef6

Please sign in to comment.