Skip to content

Commit de92fe9

Browse files
feat: Accept UUIDs
Broken
1 parent f248db0 commit de92fe9

2 files changed

Lines changed: 77 additions & 52 deletions

File tree

Lines changed: 66 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,80 @@
11
// Script assets have changed for v2.3.0 see
22
// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information
3-
function scr_kill_unit(company, unit_slot){
4-
if (obj_ini.role[company][unit_slot]=="Forge Master"){
5-
array_push(obj_ini.previous_forge_masters, obj_ini.name[company][unit_slot]);
6-
}
3+
function scr_kill_unit(company, unit_slot) {
4+
var _unit;
5+
if (is_string(company)) {
6+
_unit = fetch_unit(company);
7+
company = _unit.company;
8+
unit_slot = _unit.marine_number;
9+
} else {
10+
_unit = fetch_unit([company, unit_slot]);
11+
}
12+
13+
if (obj_ini.role[company][unit_slot]=="Forge Master") {
14+
array_push(obj_ini.previous_forge_masters, obj_ini.name[company][unit_slot]);
15+
}
716

8-
if (obj_ini.role[company][unit_slot]="Chapter Master"){
9-
tek="c";
10-
alarm[7]=5;
11-
global.defeat=1;
17+
if (obj_ini.role[company][unit_slot] = "Chapter Master") {
18+
tek = "c";
19+
alarm[7] = 5;
20+
global.defeat = 1;
1221
}
13-
_unit = fetch_unit([company, unit_slot]);
14-
if (_unit.weapon_one()=="Company Standard" || _unit.weapon_two()=="Company Standard"){
15-
scr_loyalty("Lost Standard","+");
22+
if (_unit.weapon_one() == "Company Standard" || _unit.weapon_two() == "Company Standard") {
23+
scr_loyalty("Lost Standard", "+");
1624
}
1725
_unit.remove_from_squad();
18-
struct_remove(obj_ini.UUID_marine, _unit.UUID)
19-
scr_wipe_unit(company, unit_slot)
26+
scr_uuid_delete_unit(_unit.UUID);
27+
scr_wipe_unit(company, unit_slot);
2028
}
2129

22-
function scr_wipe_unit(company, unit_slot){
23-
obj_ini.spe[company][unit_slot]="";
24-
obj_ini.race[company][unit_slot]=0;
25-
obj_ini.loc[company][unit_slot]="";
26-
obj_ini.name[company][unit_slot]="";
27-
obj_ini.wep1[company][unit_slot]="";
28-
obj_ini.role[company][unit_slot]="";
29-
obj_ini.wep2[company][unit_slot]="";
30-
obj_ini.armour[company][unit_slot]="";
31-
obj_ini.gear[company][unit_slot]="";
32-
obj_ini.god[company][unit_slot]=0;
33-
obj_ini.age[company][unit_slot]=0;
34-
obj_ini.mobi[company][unit_slot]="";
35-
obj_ini.bio[company][unit_slot]="";
30+
function scr_wipe_unit(company, unit_slot) {
31+
obj_ini.spe[company][unit_slot] = "";
32+
obj_ini.race[company][unit_slot] = 0;
33+
obj_ini.loc[company][unit_slot] = "";
34+
obj_ini.name[company][unit_slot] = "";
35+
obj_ini.wep1[company][unit_slot] = "";
36+
obj_ini.role[company][unit_slot] = "";
37+
obj_ini.wep2[company][unit_slot] = "";
38+
obj_ini.armour[company][unit_slot] = "";
39+
obj_ini.gear[company][unit_slot] = "";
40+
obj_ini.god[company][unit_slot] = 0;
41+
obj_ini.age[company][unit_slot] = 0;
42+
obj_ini.mobi[company][unit_slot] = "";
43+
obj_ini.bio[company][unit_slot] = "";
3644
obj_ini.TTRPG[company][unit_slot] = new TTRPG_stats("chapter", company, unit_slot, "blank"); // create new empty unit structure
3745
}
3846

3947
function kill_and_recover(company, unit_slot, equipment=true, gene_seed_collect=true){
40-
var unit = obj_ini.TTRPG[company][unit_slot];
41-
if (equipment){
42-
var strip = {
43-
"wep1":"",
44-
"wep2":"",
45-
"mobi":"",
46-
"armour":"",
47-
"gear":"",
48-
};
49-
unit.alter_equipment(strip,false, true);
50-
}
51-
if (gene_seed_collect && unit.base_group=="astartes"){
52-
if (unit.age() > 30 && !obj_ini.zygote && !obj_ini.doomed) then obj_controller.gene_seed+=1;
53-
if (unit.age() > 50 && !obj_ini.doomed) then obj_controller.gene_seed+=1;
54-
}
55-
if (obj_ini.race[company][unit_slot]==1){
56-
if(is_specialist(obj_ini.role[company][unit_slot])){
57-
obj_controller.command-=1;
58-
} else{
59-
obj_controller.marines-=1;
48+
var _unit;
49+
if (is_string(company)) {
50+
_unit = fetch_unit(company);
51+
company = _unit.company;
52+
unit_slot = _unit.marine_number;
53+
} else {
54+
_unit = fetch_unit([company, unit_slot]);
55+
}
56+
57+
if (equipment) {
58+
var strip = {
59+
"wep1" : "",
60+
"wep2" : "",
61+
"mobi" : "",
62+
"armour" : "",
63+
"gear" : ""
64+
};
65+
66+
_unit.alter_equipment(strip, false, true);
67+
}
68+
if (gene_seed_collect && _unit.base_group == "astartes") {
69+
if (_unit.age() > 30 && !obj_ini.zygote && !obj_ini.doomed) { obj_controller.gene_seed += 1; }
70+
if (_unit.age() > 50 && !obj_ini.doomed) { obj_controller.gene_seed += 1; }
71+
}
72+
if (obj_ini.race[company][unit_slot] == 1) {
73+
if(is_specialist(obj_ini.role[company][unit_slot])) {
74+
obj_controller.command -= 1;
75+
} else {
76+
obj_controller.marines -= 1;
6077
}
61-
}
62-
scr_kill_unit(company, unit_slot);
78+
}
79+
scr_kill_unit(company, unit_slot);
6380
}

scripts/scr_marine_struct/scr_marine_struct.gml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2289,8 +2289,16 @@ function jsonify_marine_struct(company, marine) {
22892289
return json_stringify(new_marine);
22902290
}
22912291

2292-
/// @param {Array<Real>} unit where unit[0] is company and unit[1] is the position
2292+
#macro INI_UUNITROOT obj_ini.UUNITROOT
2293+
#macro UUNITROOT UUID_marine
2294+
/// DEPRECATED : @param {Array<Real>} unit where unit[0] is company and unit[1] is the position
2295+
/// @param {<String>} unit where unit is a UUID
22932296
/// @returns {Struct.TTRPG_stats} unit
2294-
function fetch_unit(unit) {
2295-
return obj_ini.TTRPG[unit[0]][unit[1]];
2297+
function fetch_unit(funit) {
2298+
gml_pragma("forceinline");
2299+
if (!is_string(funit)) {
2300+
return obj_ini.TTRPG[funit[0]][funit[1]];
2301+
} else {
2302+
return INI_UUNITROOT[$ funit];
2303+
}
22962304
}

0 commit comments

Comments
 (0)