Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: custom stat scaling property for weapons #73

Draft
wants to merge 1 commit into
base: release/0.10.0.0
Choose a base branch
from
Draft
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
27 changes: 23 additions & 4 deletions scripts/scr_marine_struct/scr_marine_struct.gml
Original file line number Diff line number Diff line change
Expand Up @@ -1707,6 +1707,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data={})
_wep1.owner_data("chapter");
_wep2.owner_data("chapter");
}
ranged_att += get_weapon_stat_bonus(_wep1) + get_weapon_stat_bonus(_wep2);
var primary_weapon= new equipment_struct({},"");
var secondary_weapon= new equipment_struct({},"");
if (carry_data[0]>carry_data[1]){
Expand Down Expand Up @@ -1858,10 +1859,10 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data={})
static melee_attack = function(weapon_slot=0){
encumbered_melee=false;
melee_att = 100*(((weapon_skill/100) * (strength/20)) + (experience()/1000)+0.1);
var explanation_string = string_concat("#Stats: ", format_number_with_sign(round(((melee_att/100)-1)*100)), "%#");
explanation_string += " Base: +10%#";
explanation_string += string_concat(" WSxSTR: ", format_number_with_sign(round((((weapon_skill/100)*(strength/20))-1)*100)), "%#");
explanation_string += string_concat(" EXP: ", format_number_with_sign(round((experience()/1000)*100)), "%#");
var explanation_string = "1";
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): Hardcoded "1" value appears to be temporary debug code

The explanation string construction was commented out and replaced with a hardcoded "1". This might affect game feedback and debugging capabilities.

// explanation_string += " Base: +10%#";
// explanation_string += string_concat(" WSxSTR: ", format_number_with_sign(round((((weapon_skill/100)*(strength/20))-1)*100)), "%#");
// explanation_string += string_concat(" EXP: ", format_number_with_sign(round((experience()/1000)*100)), "%#");

melee_carrying = melee_hands_limit();
var _wep1 = get_weapon_one_data();
Expand All @@ -1872,6 +1873,9 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data={})
_wep1.owner_data("chapter");
_wep2.owner_data("chapter");
}

melee_att += get_weapon_stat_bonus(_wep1) + get_weapon_stat_bonus(_wep2);

var primary_weapon;
var secondary_weapon="none";
if (weapon_slot==0){
Expand Down Expand Up @@ -1983,6 +1987,21 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data={})
return melee_damage_data;
};

static get_weapon_stat_bonus = function(_weapon) {
var _total_bonus = 0;
if (_weapon.stat_scaling != 0) {
var _stats = struct_get_names(_weapon.stat_scaling);
for (var i = 0; i < array_length(stats); i++) {
var _stat_name = stats[i];
var _stat_value = variable_struct_get(self, stat_name);
if (stat_value != 0) {
_total_bonus += variable_struct_get(_weapon.stat_scaling, stat_name) * stat_value;
}
}
}
return _total_bonus;
}

//TODO just did this so that we're not loosing featuring but this porbably needs a rethink
static hammer_of_wrath = function(){
var wrath = new equipment_struct({},"");
Expand Down
10 changes: 7 additions & 3 deletions scripts/scr_weapon/scr_weapon.gml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ global.weapons = {
"spli": 4,
"arp": 0,
"tags": ["chain", "sword"],
"stat_scaling": {
"strength": 1.2,
"dexterity": 1.4,
}
},
"Chainaxe": {
"abbreviation": "ChAxe",
Expand Down Expand Up @@ -2314,13 +2318,13 @@ global.gear = {

function equipment_struct(item_data, core_type,quality="none") constructor{
//This could be done with 2d arrays [[],[]]
var names = ["hp_mod", "description","damage_resistance_mod", "ranged_mod", "melee_mod","armour_value" ,"attack","melee_hands","ranged_hands","ammo","range","spli","arp","special_description", "special_properties", "abbreviation","tags","name","second_profiles","req_exp"];
var defaults = [0,"",0,0,0,0,0,0,0,0,0,0,0,"",[],"",[],"",[],0];
var names = ["hp_mod", "description","damage_resistance_mod", "ranged_mod", "melee_mod","armour_value" ,"attack","melee_hands","ranged_hands","ammo","range","spli","arp","special_description", "special_properties", "abbreviation","tags","name","second_profiles","req_exp", "stat_scaling"];
var defaults = [0,"",0,0,0,0,0,0,0,0,0,0,0,"",[],"",[],"",[],0, 0];
type = core_type;
for (var i=0;i<array_length(names);i++){
if (struct_exists(item_data,names[i])){
self[$names[i]] = item_data[$names[i]];
if (quality!="none"){
if (quality!="none" && names[i] != "stat_scaling"){
if (is_struct(self[$names[i]])){
if (struct_exists(self[$names[i]],quality)){
self[$names[i]]=self[$names[i]][$quality];
Expand Down