|
1 | 1 | // Script assets have changed for v2.3.0 see |
2 | 2 | // 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 | + } |
7 | 16 |
|
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; |
12 | 21 | } |
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", "+"); |
16 | 24 | } |
17 | 25 | _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); |
20 | 28 | } |
21 | 29 |
|
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] = ""; |
36 | 44 | obj_ini.TTRPG[company][unit_slot] = new TTRPG_stats("chapter", company, unit_slot, "blank"); // create new empty unit structure |
37 | 45 | } |
38 | 46 |
|
39 | 47 | 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; |
60 | 77 | } |
61 | | - } |
62 | | - scr_kill_unit(company, unit_slot); |
| 78 | + } |
| 79 | + scr_kill_unit(company, unit_slot); |
63 | 80 | } |
0 commit comments