Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChapterMaster.yyp
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,7 @@
{"id":{"name":"scr_load_controller","path":"scripts/scr_load_controller/scr_load_controller.yy",},},
{"id":{"name":"scr_load","path":"scripts/scr_load/scr_load.yy",},},
{"id":{"name":"scr_log","path":"scripts/scr_log/scr_log.yy",},},
{"id":{"name":"scr_loot_table","path":"scripts/scr_loot_table/scr_loot_table.yy",},},
{"id":{"name":"scr_loyalty","path":"scripts/scr_loyalty/scr_loyalty.yy",},},
{"id":{"name":"scr_manage_task_selector","path":"scripts/scr_manage_task_selector/scr_manage_task_selector.yy",},},
{"id":{"name":"scr_management","path":"scripts/scr_management/scr_management.yy",},},
Expand Down
3 changes: 3 additions & 0 deletions scripts/scr_cheatcode/scr_cheatcode.gml
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ function scr_cheatcode(argument0) {
case "orkinvasion":
out_of_system_warboss();
break;
case "rollloot":
show_debug_message(find_loot());
break;

}
}
Expand Down
31 changes: 30 additions & 1 deletion scripts/scr_equipment_struct/scr_equipment_struct.gml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ function EquipmentStruct(item_data, core_type, quality_request = "none") constru
req_exp = 0;
maintenance = 0;
specials = "";
loot = {
base : 100,
}
quality = quality_request == "none" ? "standard" : quality_request;
// Struct defaults end;

Expand All @@ -42,10 +45,36 @@ function EquipmentStruct(item_data, core_type, quality_request = "none") constru
// _struct_key = "";
}
}
if (!struct_exists(loot, "base")){
loot.base = 100;
}

if (has_tag("xenos")){
loot.base = 4;
} else if has_tag("heavy_ranged"){
loot.base = 75;
}else if has_tag("plasma"){
loot.base = 75;
}else if has_tag("energy"){
loot.base = 75;
}

if (has_tag("dreadnought")){
loot.base = 7;
} else if (has_tag("vehicle")){
loot.base = 9;
}


if has_tag("terminator"){
loot.base = 10;
}else if has_tag("ancient"){
loot.base = 5;
}
Comment on lines +52 to +73
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Warning: Loot value override cascade detected.

Your machine logic contains multiple separate if-else chains that can overwrite previous loot.base values. For example, an item with tags ["heavy_ranged", "terminator"] will have its loot.base set to 75, then overwritten to 10.

Consider consolidating into a single priority-based logic chain:

-    if (has_tag("xenos")){
-        loot.base = 4;
-    } else if has_tag("heavy_ranged"){
-        loot.base = 75;
-    }else if has_tag("plasma"){
-        loot.base = 75;
-    }else if has_tag("energy"){
-        loot.base = 75;
-    }
-
-    if (has_tag("dreadnought")){
-        loot.base = 7;
-    } else  if (has_tag("vehicle")){
-        loot.base = 9;
-    }
-
-
-    if has_tag("terminator"){
-        loot.base = 10;
-    }else if has_tag("ancient"){
-        loot.base = 5;
-    }
+    // Priority-based loot value assignment
+    if (has_tag("xenos")){
+        loot.base = 4;
+    } else if (has_tag("terminator")){
+        loot.base = 10;
+    } else if (has_tag("dreadnought")){
+        loot.base = 7;
+    } else if (has_tag("vehicle")){
+        loot.base = 9;
+    } else if (has_tag("ancient")){
+        loot.base = 5;
+    } else if (has_tags(["heavy_ranged", "plasma", "energy"])){
+        loot.base = 75;
+    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (has_tag("xenos")){
loot.base = 4;
} else if has_tag("heavy_ranged"){
loot.base = 75;
}else if has_tag("plasma"){
loot.base = 75;
}else if has_tag("energy"){
loot.base = 75;
}
if (has_tag("dreadnought")){
loot.base = 7;
} else if (has_tag("vehicle")){
loot.base = 9;
}
if has_tag("terminator"){
loot.base = 10;
}else if has_tag("ancient"){
loot.base = 5;
}
// Priority-based loot value assignment
if (has_tag("xenos")) {
loot.base = 4;
} else if (has_tag("terminator")) {
loot.base = 10;
} else if (has_tag("dreadnought")) {
loot.base = 7;
} else if (has_tag("vehicle")) {
loot.base = 9;
} else if (has_tag("ancient")) {
loot.base = 5;
} else if (has_tags(["heavy_ranged", "plasma", "energy"])) {
loot.base = 75;
}
🤖 Prompt for AI Agents
In scripts/scr_equipment_struct/scr_equipment_struct.gml around lines 52 to 73,
multiple separate if-else chains set loot.base independently, causing later
conditions to overwrite earlier values. Consolidate all tag checks into a single
if-else if chain ordered by priority so that only the highest priority tag sets
loot.base once, preventing unintended overrides.


// Placeholder maintenance values;
if (maintenance == 0) {
if (has_tags(["heavy_ranged", "power", "plasma", "melta"])) {
if (has_tags(["heavy_ranged", "power", "plasma", "melta"]) && maintenance<0.05) {
maintenance = 0.05;
}
}
Expand Down
113 changes: 113 additions & 0 deletions scripts/scr_loot_table/scr_loot_table.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
function find_loot(loot_data={}, loot_value = 200){
var _possible_loots = {};
var _total_lootables = 0;
var _all_loot_names = [];

var _loot_tags = struct_exists(loot_data ,"loot_tags") ? loot_data.loot_tags : [];

var _exclusives = struct_exists(loot_data ,"exclusives") ? loot_data.exclusives : false;

var _mults = struct_exists(loot_data ,"multipliers") ? loot_data.multipliers : false;

var _excludes = struct_exists(loot_data ,"excludes") ? loot_data.excludes : false;

var _weps = global.weapons;
var _armour = global.gear.armour;
var _mobi = global.gear.mobility;

var _all_items_table = array_join(struct_get_names(_weps), struct_get_names(_armour),struct_get_names(_mobi));

for (var i=0;i<array_length(_all_items_table);i++){
var _item = gear_weapon_data(,_all_items_table[i]);
if (_item == false){
continue;
}
if (_exclusives != false){
var _include = false;
for (var e = 0; e<array_length(_exclusives); e++){
if (array_contains(_item.tags, _exclusives[e])){
_include = true;
break;
}
}
if (!_include){
continue;
}
}

if (_excludes != false){
var _include = true;
for (var e =0;e<array_length(_excludes);e++){
if (array_contains(_item.tags, _excludes[e])){
_include = false;
break;
}
}
if (!_include){
continue;
}
}

var _loot_value = _item.loot.base;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Potential null reference accessing loot.base.

If the item lacks a loot property, this will fail. Add defensive checks.

+		if (!struct_exists(_item, "loot") || !struct_exists(_item.loot, "base")) continue;
 		var _loot_value = _item.loot.base;

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In scripts/scr_loot_table/scr_loot_table.gml at line 49, the code accesses
_item.loot.base without verifying if _item.loot exists, which can cause a null
reference error. Add a check to confirm that _item.loot is not null or undefined
before accessing its base property, and handle the case where loot is missing
appropriately to prevent runtime errors.

for (var t = 0;t<array_length(_loot_tags);t++){
if (struct_exists(_item.loot, _loot_tags[t])){
if (_item.loot[$ _loot_tags[t]] > _loot_value){
_loot_value = _item.loot[$ _loot_tags[t]];
}
}
}
var _loot_val = _loot_tags

if (_mults != false){
var _mult_names = struct_get_names(_mults);
for (var e =0;e<array_length(_mult_names);e++){
if (array_contains(_item.tags, _mult_names[e])){
var _mult = _mults[$ _mult_names[e]];
_loot_value *= _mult;
}
}
}

_possible_loots[$_item.name] = [_total_lootables, _total_lootables+_loot_value];
_total_lootables+=_loot_value;
}


var _all_loot_names = struct_get_names(_possible_loots);

if (!array_length(_all_loot_names)){
return {};
}
var _final_loot = {};
var _chosen_loot_val = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Missing semicolon violates sacred syntax.

The Omnissiah demands proper punctuation.

-	var _chosen_loot_val = 0
+	var _chosen_loot_val = 0;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
var _chosen_loot_val = 0
var _chosen_loot_val = 0;
🤖 Prompt for AI Agents
In scripts/scr_loot_table/scr_loot_table.gml at line 80, the variable
declaration for _chosen_loot_val is missing a semicolon at the end. Add a
semicolon after the assignment to properly terminate the statement and comply
with syntax requirements.

while (_chosen_loot_val < loot_value){
var _new_loot = irandom(_total_lootables-1);
for (var i=0;i<array_length(_all_loot_names);i++){
var _lootn = _all_loot_names[i];
var _specific_loot_data = _possible_loots[$ _lootn];
if (_new_loot>= _specific_loot_data[0] && _new_loot<_specific_loot_data[1]){
var _chosen_piece = _lootn;
var _loot_val = max(100-(_specific_loot_data[1] - _specific_loot_data[0]),1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Flawed loot value calculation logic.

The calculation 100-(_specific_loot_data[1] - _specific_loot_data[0]) produces incorrect values. The difference represents the loot weight, not a value to subtract from 100.

-				var _loot_val = max(100-(_specific_loot_data[1] - _specific_loot_data[0]),1);
+				var _loot_val = _specific_loot_data[1] - _specific_loot_data[0];
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
var _loot_val = max(100-(_specific_loot_data[1] - _specific_loot_data[0]),1);
var _loot_val = _specific_loot_data[1] - _specific_loot_data[0];
🤖 Prompt for AI Agents
In scripts/scr_loot_table/scr_loot_table.gml at line 88, the loot value
calculation incorrectly subtracts the loot weight difference from 100, which is
logically flawed. Instead, revise the calculation to directly use the loot
weight or an appropriate formula that reflects the intended loot value without
subtracting the difference from 100. Adjust the expression to correctly
represent the loot value based on the weight data in _specific_loot_data.

if (!struct_exists(_final_loot, _chosen_piece)){
_final_loot[$ _chosen_piece] = 1;
} else {
_final_loot[$ _chosen_piece]++;
}
_chosen_loot_val += _loot_val;

var _add_more = irandom(2);
while (_add_more == 0 && _chosen_loot_val<loot_value){
_final_loot[$ _chosen_piece]++;
_chosen_loot_val += _loot_val;
_add_more = irandom(2);
}

break;
}
}
}

return _final_loot;

}

13 changes: 13 additions & 0 deletions scripts/scr_loot_table/scr_loot_table.yy

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

1 change: 0 additions & 1 deletion scripts/scr_ruins_reward/scr_ruins_reward.gml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ function scr_ruins_reward(star_system, planet, _ruins) {
wep3=choose("Servo-harness");
wen3=choose(1);
}


scr_add_item(wep1,wen1);
scr_add_item(wep2,wen2);
Expand Down
31 changes: 30 additions & 1 deletion scripts/scr_weapon/scr_weapon.gml
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,12 @@ global.weapons = {
"spli": 2,
"arp": 1,
"tags": ["power","boarding", "chain", "fist", "dual", "siege"],
"loot" : {
"base" : 20,
"imperial" : {
"val" : 5,
}
}
},
"Lascutter": {
"abbreviation": "Lasct",
Expand Down Expand Up @@ -470,6 +476,11 @@ global.weapons = {
"spli": 5,
"arp": 1,
"tags": ["power", "axe", "dual"],
"loot" : {
"imperial" : {
"val" : 5,
}
}
},
"Executioner Power Axe": {
"abbreviation": "ExPwrAxe",
Expand Down Expand Up @@ -512,6 +523,11 @@ global.weapons = {
"spli": 2,
"arp": 1,
"tags": ["power", "dual", "fist"],
"loot" : {
"imperial" : {
"val" : 5,
}
}
},
"Power Fists": {
"abbreviation": "PwrFsts",
Expand Down Expand Up @@ -683,6 +699,11 @@ global.weapons = {
"arp": 1,
"tags": ["power", "mace", "siege"],
"req_exp": 100,
"loot" : {
"imperial" : {
"val" : 5,
}
}
},
"Mace of Absolution": {
"abbreviation": "AbsltMace",
Expand Down Expand Up @@ -995,7 +1016,10 @@ global.weapons = {
"range": 2.1,
"spli": 1,
"arp": 1,
"tags": ["melta","boarding"]
"tags": ["melta","boarding"],
"loot" : {
"base" : 8,
}
},
"Multi-Melta": {
"abbreviation": "MltMelt",
Expand Down Expand Up @@ -1630,6 +1654,11 @@ global.weapons = {
"arp": -1,
"tags": ["flame"],
"maintenance" : 0.01,
"loot" : {
"imperial" : {
"val" : 8,
}
}
},
"Underslung Flamer": {
"attack": {
Expand Down
6 changes: 5 additions & 1 deletion sprites/spr_data_slate_border/spr_data_slate_border.yy

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

Loading