Skip to content

Commit

Permalink
fix: Artifact continuity issue (#348)
Browse files Browse the repository at this point in the history
- solves various issues with artifact continuity.
- artifacts were not being destroyed when not being recovered off of
killed marines leaving them in limbo
- occasionally the artifact in question being de-equipped due to being
gifted or some other actor was not equipped to the array loc of the
stated unit
- to solve this the de-equip function now searches for amarine with the
artifact equipped and manually de-equips it from them

## Summary by Sourcery

Fix artifact continuity issues by ensuring artifacts are correctly
de-equipped from units and destroyed when no longer recoverable.

Bug Fixes:
- Resolved issues with artifacts not being destroyed when not recovered
from killed marines.
- Fixed a bug where de-equipping an artifact due to gifting or other
actions did not correctly remove it from the unit\'s inventory.
  • Loading branch information
OH296 authored Dec 28, 2024
1 parent 315aecc commit 02deacc
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 37 deletions.
8 changes: 4 additions & 4 deletions ChapterMaster.yyp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"daemon7.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"daemon8.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"daemon9.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"diplomacy_icons.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"diplomacy10.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"diplomacy11.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"diplomacy12.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
Expand All @@ -183,7 +184,6 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"diplomacy6.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"diplomacy7.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"diplomacy8.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"diplomacy_icons.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"instructions.txt","CopyToMask":9223372036854775807,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"symbol1.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"symbol2.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
Expand Down Expand Up @@ -397,10 +397,10 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"eldar.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"genestealercult.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"hulk.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"imperial.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"imperial_ship.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ork.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"imperial.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ork_ship.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ork.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"sector.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"space_marine.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"star.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
Expand Down Expand Up @@ -1443,6 +1443,6 @@
],
"templateType": null,
"TextureGroups": [
{"resourceType":"GMTextureGroup","resourceVersion":"1.3","name":"Default","autocrop":true,"border":2,"compressFormat":"bz2","customOptions":"","directory":"","groupParent":null,"isScaled":false,"loadType":"default","mipsToGenerate":0,"targets":-1,},
{"resourceType":"GMTextureGroup","resourceVersion":"1.3","name":"Default","autocrop":true,"border":2,"compressFormat":"bz2","directory":"","groupParent":null,"isScaled":false,"loadType":"default","mipsToGenerate":0,"targets":-1,},
],
}
Binary file modified fonts/fnt_menu/fnt_menu.old.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fonts/fnt_menu/fnt_menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 66 additions & 6 deletions scripts/scr_add_artifact/scr_add_artifact.gml
Original file line number Diff line number Diff line change
Expand Up @@ -339,25 +339,85 @@ function ArtifactStruct(Index) constructor{
};

static unequip_from_unit = function(){
try{
if (equipped() && is_array(bearer)){
var b_type = determine_base_type();
var _b_type = determine_base_type();
var unit = fetch_unit(bearer);
if (b_type=="weapon"){
if (_b_type=="weapon"){
if (unit.weapon_one(true) == index){
unit.update_weapon_one("", false, false);
} else if (unit.weapon_two(true) == index){
unit.update_weapon_two("", false, false);
}
} else if (b_type=="gear"){
} else if (_b_type=="gear"){
unit.update_gear("", false, false);
} else if (b_type=="armour"){
} else if (_b_type=="armour"){
unit.update_armour("", false, false);
} else if (b_type=="mobility"){
} else if (_b_type=="mobility"){
unit.update_mobility_item("", false, false);
}
bearer =false;
bearer = false;
obj_ini.artifact_equipped[index] = false;
} else if (equipped()){
var _b_type = determine_base_type();
var _bearer = false;
var _bearer_found = false;
var _unit;
if (_b_type=="weapon"){
for (var co=0;co<obj_ini.companies;co++){
for (var i=0;i<array_length(obj_ini.role[co]);i++){
_unit = fetch_unit([co,i]);
if (_unit.weapon_one(true) == index){
_unit.update_weapon_one("", false, false);
_bearer_found = true
} else if (_unit.weapon_two(true) == index){
_unit.update_weapon_two("", false, false);
_bearer_found = true
}
if (_bearer_found){
break;
}
}
if (_bearer_found){
break;
}
}
} else {
var _find_function = "";
if (_b_type=="gear"){
var _update_function = "update_gear";
_find_function = "gear";
} else if (_b_type=="armour"){
var _update_function = "update_armour";
_find_function = "armour";
} else if (_b_type=="mobility"){
var _update_function = "update_mobility_item";
_find_function = "mobility_item";
}
if (_find_function!=""){
for (var co=0;co<obj_ini.companies;co++){
for (var i=0;i<array_length(obj_ini.role[co]);i++){
var _unit = fetch_unit([co,i]);
if (_unit[$_find_function](true) == index){
_unit[$_update_function]("", false, false);
_bearer_found = true
}
if (_bearer_found){
break;
}
}
if (_bearer_found){
break;
}
}
}
}
}
}catch(_exception){
handle_exception(_exception);
}
bearer = false;
obj_ini.artifact_equipped[index] = false;
}
custom_data = {};
name = "";
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 54 additions & 26 deletions scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,17 @@ function scr_update_unit_armour(new_armour, from_armoury=true, to_armoury=true,
} else {
quality = quality=="any" ? "standard" : quality;
}
if (change_armour != "") and (to_armoury){
if (!is_string(armour(true))){
obj_ini.artifact_equipped[armour(true)]=false;
} else {
scr_add_item(change_armour,1,armour_quality, true);
if (change_armour != ""){
if (to_armoury){
if (!is_string(armour(true))){
obj_ini.artifact_equipped[armour(true)]=false;
} else {
scr_add_item(change_armour,1,armour_quality, true);
}
} else {
if (!is_string(armour(true))){
delete_artifact(armour(true));
}
}
}
var portion = hp_portion();
Expand Down Expand Up @@ -143,11 +149,17 @@ function scr_update_unit_weapon_one(new_weapon,from_armoury=true, to_armoury=tru
quality = quality=="any"?"standard":quality;
}

if (change_wep != "") and (to_armoury){
if (!is_string(weapon_one(true))){
obj_ini.artifact_equipped[weapon_one(true)]=false;
} else {
scr_add_item(change_wep,1, weapon_one_quality, true);
if (change_wep != ""){
if(to_armoury){
if (!is_string(weapon_one(true))){
obj_ini.artifact_equipped[weapon_one(true)]=false;
} else {
scr_add_item(change_wep,1, weapon_one_quality, true);
}
} else {
if (!is_string(weapon_one(true))){
delete_artifact(weapon_one(true));
}
}
}
obj_ini.wep1[company][marine_number] = new_weapon;
Expand Down Expand Up @@ -179,12 +191,18 @@ function scr_update_unit_weapon_two(new_weapon,from_armoury=true, to_armoury=tru
} else {
quality = quality=="any"?"standard":quality;
}
if (change_wep != "") and (to_armoury){
if (!is_string(weapon_two(true))){
obj_ini.artifact_equipped[weapon_two(true)]=false;
}else {
scr_add_item(change_wep,1, weapon_two_quality, true);
}
if (change_wep != ""){
if (to_armoury){
if (!is_string(weapon_two(true))){
obj_ini.artifact_equipped[weapon_two(true)]=false;
}else {
scr_add_item(change_wep,1, weapon_two_quality, true);
}
} else {
if (!is_string(weapon_two(true))){
delete_artifact(weapon_two(true))
}
}
}
obj_ini.wep2[company][marine_number] = new_weapon;
if (arti){
Expand Down Expand Up @@ -223,11 +241,17 @@ function scr_update_unit_gear(new_gear,from_armoury=true, to_armoury=true, quali
}

var portion = hp_portion();
if (change_gear != "" && to_armoury){
if (!is_string(gear(true))){
obj_ini.artifact_equipped[gear(true)]=false;
} else {
scr_add_item(change_gear,1,gear_quality, true);
if (change_gear != ""){
if (to_armoury){
if (!is_string(gear(true))){
obj_ini.artifact_equipped[gear(true)]=false;
} else {
scr_add_item(change_gear,1,gear_quality, true);
}
} else {
if (!is_string(gear(true))){
delete_artifact(gear(true));
}
}
}
obj_ini.gear[company][marine_number] = new_gear;
Expand Down Expand Up @@ -287,11 +311,15 @@ function scr_update_unit_mobility_item(new_mobility_item, from_armoury = true, t
quality= quality=="any"?"standard":quality;
}
var portion = hp_portion();
if (_old_mobility_item != "") and (to_armoury){
if (!is_string(mobility_item(true))){
obj_ini.artifact_equipped[mobility_item(true)]=false;
} else {
scr_add_item(_old_mobility_item,1,mobility_item_quality, true );
if (_old_mobility_item != ""){
if(to_armoury){
if (!is_string(mobility_item(true))){
obj_ini.artifact_equipped[mobility_item(true)]=false;
} else {
scr_add_item(_old_mobility_item,1,mobility_item_quality, true );
}
} else if (!is_string(mobility_item(true))){
delete_artifact(mobility_item(true));
}
}
obj_ini.mobi[company][marine_number] = new_mobility_item;
Expand Down

0 comments on commit 02deacc

Please sign in to comment.