Skip to content

Commit

Permalink
Allow GUNMODs to be used to modify guns that get hot not too hot. (Cl…
Browse files Browse the repository at this point in the history
…everRaven#68772)

* Update item.cpp

オーバーヒート時の銃のシンボル表示処理と冷却処理の変更

* Update item_factory.cpp

オーバーヒート編集GANMODの為の新しいjson読み取りパラメータの追加

* Update itype.h

オーバーヒートシステムを操作するためのGUNMODに必要な変数の宣言

* Update ranged.cpp

オーバーヒートシステムのGUNMODの為のオーバーヒート時の挙動部分のGUNMODによるパラメータ変更を反映するように変更

* Update src/item.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/item.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/item.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/item.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/ranged.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/ranged.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/ranged.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update JSON_INFO.md

GUNMODで使用できるパラメータの説明を追加

* Update doc/JSON_INFO.md

Co-authored-by: Anton Simakov <[email protected]>

* Update doc/JSON_INFO.md

Co-authored-by: Anton Simakov <[email protected]>

* Update doc/JSON_INFO.md

Co-authored-by: Anton Simakov <[email protected]>

* Update doc/JSON_INFO.md

Co-authored-by: Anton Simakov <[email protected]>

* Update doc/JSON_INFO.md

Co-authored-by: Anton Simakov <[email protected]>

* Update doc/JSON_INFO.md

Co-authored-by: Anton Simakov <[email protected]>

* Update item.cpp

* Update doc/JSON_INFO.md

Co-authored-by: ehughsbaird <[email protected]>

* Update doc/JSON_INFO.md

Co-authored-by: ehughsbaird <[email protected]>

* Update doc/JSON_INFO.md

Co-authored-by: ehughsbaird <[email protected]>

* Update doc/JSON_INFO.md

Co-authored-by: ehughsbaird <[email protected]>

* Update doc/JSON_INFO.md

Co-authored-by: ehughsbaird <[email protected]>

* Update doc/JSON_INFO.md

Co-authored-by: ehughsbaird <[email protected]>

* Update laser_gunmods.json

追加機能のモデルケースの追加

* Update ups.json

新機能の為のモデルケースを既存のデータに適用する為の新規スロット追加

* Update data/json/items/gunmod/laser_gunmods.json

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update data/json/items/gunmod/laser_gunmods.json

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update data/json/items/gunmod/laser_gunmods.json

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update data/json/items/gunmod/laser_gunmods.json

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update data/json/items/gun/ups.json

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update data/json/items/gunmod/laser_gunmods.json

Co-authored-by: John Candlebury <[email protected]>

* Update data/json/items/gunmod/laser_gunmods.json

Co-authored-by: John Candlebury <[email protected]>

* Update ups.json

変更を消去します。

* Update laser_gunmods.json

変更を削除します。

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Anton Simakov <[email protected]>
Co-authored-by: ehughsbaird <[email protected]>
Co-authored-by: John Candlebury <[email protected]>
  • Loading branch information
5 people authored Oct 30, 2023
1 parent d44a12b commit 003be07
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 5 deletions.
6 changes: 6 additions & 0 deletions doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3962,6 +3962,12 @@ Gun mods can be defined like this:
"handling_modifier": 4, // Improve gun handling. For example a forward grip might have 6, a bipod 18
"mode_modifier": [ [ "AUTO", "auto", 4 ] ], // Modify firing modes of the gun, to give AUTO or REACH for example
"barrel_length": "45 mm" // Specify a direct barrel length for this gun mod. If used only the first mod with a barrel length will be counted
"overheat_threshold_modifier": 100, // Add a flat amount to gun's "overheat_threshold"; if the threshold is 100, and the modifier is 10, the result is 110; if the modifier is -25, the result is 75
"overheat_threshold_multiplier": 1.5, // Multiply gun's "overheat_threshold" by this number; if the threshold is 100, and the multiplier is 1.5, the result is 150; if the multiplier is 0.8, the result is 80
"cooling_value_modifier": 2, // Add a flat amount to gun's "cooling_value"; works the same as overheat_threshold_modifier
"cooling_value_multiplier": 0.5, // Multiply gun's "cooling_value" by this number; works the same as overheat_threshold_multiplier
"heat_per_shot_modifier": -2, // Add a flat amount to gun's "heat_per_shot"; works the same as overheat_threshold_modifier
"heat_per_shot_multiplier": 2.0, // Multiply the gun's "heat_per_shot" by this number; works the same as overheat_threshold_multiplier
```

Alternately, every item (book, tool, armor, even food) can be used as a gunmod if it has gunmod_data:
Expand Down
23 changes: 20 additions & 3 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6487,11 +6487,17 @@ std::string item::overheat_symbol() const
if( !is_gun() || type->gun->overheat_threshold <= 0.0 ) {
return "";
}
double modifier = 0;
float multiplier = 1.0f;
for( const item *mod : gunmods() ) {
modifier += mod->type->gunmod->overheat_threshold_modifier;
multiplier *= mod->type->gunmod->overheat_threshold_multiplier;
}
if( faults.count( fault_overheat_safety ) ) {
return string_format( _( "<color_light_green>\u2588VNT </color>" ) );
}
switch( std::min( 5, static_cast<int>( get_var( "gun_heat",
0 ) / ( type->gun->overheat_threshold ) * 5.0 ) ) ) {
0 ) / std::max( type->gun->overheat_threshold * multiplier + modifier, 5.0 ) * 5.0 ) ) ) {
case 1:
return "";
case 2:
Expand Down Expand Up @@ -13642,8 +13648,19 @@ bool item::process_blackpowder_fouling( Character *carrier )
bool item::process_gun_cooling( Character *carrier )
{
double heat = get_var( "gun_heat", 0 );
double threshold = type->gun->overheat_threshold;
heat -= type->gun->cooling_value;
double overheat_modifier = 0;
float overheat_multiplier = 1.0f;
double cooling_modifier = 0;
float cooling_multiplier = 1.0f;
for( const item *mod : gunmods() ) {
overheat_modifier += mod->type->gunmod->overheat_threshold_modifier;
overheat_multiplier *= mod->type->gunmod->overheat_threshold_multiplier;
cooling_modifier += mod->type->gunmod->cooling_value_modifier;
cooling_multiplier *= mod->type->gunmod->cooling_value_multiplier;
}
double threshold = std::max( ( type->gun->overheat_threshold * overheat_multiplier ) +
overheat_modifier, 5.0 );
heat -= std::max( ( type->gun->cooling_value * cooling_multiplier ) + cooling_modifier, 0.5 );
set_var( "gun_heat", std::max( 0.0, heat ) );
if( faults.count( fault_overheat_safety ) && heat < threshold * 0.2 ) {
faults.erase( fault_overheat_safety );
Expand Down
6 changes: 6 additions & 0 deletions src/item_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3405,6 +3405,12 @@ void Item_factory::load( islot_gunmod &slot, const JsonObject &jo, const std::st
assign( jo, "ammo_to_fire_modifier", slot.ammo_to_fire_modifier );
assign( jo, "weight_multiplier", slot.weight_multiplier );
assign( jo, "overwrite_min_cycle_recoil", slot.overwrite_min_cycle_recoil );
assign( jo, "overheat_threshold_modifier", slot.overheat_threshold_modifier );
assign( jo, "overheat_threshold_multiplier", slot.overheat_threshold_multiplier );
assign( jo, "cooling_value_modifier", slot.cooling_value_modifier );
assign( jo, "cooling_value_multiplier", slot.cooling_value_multiplier );
assign( jo, "heat_per_shot_modifier", slot.heat_per_shot_modifier );
assign( jo, "heat_per_shot_multiplier", slot.heat_per_shot_multiplier );
// convert aim_speed to FoV and aim_speed_modifier automatically, if FoV is not set
if( slot.aim_speed >= 0 && slot.field_of_view <= 0 ) {
if( slot.aim_speed > 6 ) {
Expand Down
12 changes: 12 additions & 0 deletions src/itype.h
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,18 @@ struct islot_gunmod : common_ranged_data {

// minimum recoil to cycle while this is installed
int overwrite_min_cycle_recoil = -1;

//Manipulate overheat thresholds with fixed values and percentages
double overheat_threshold_modifier = 0;
float overheat_threshold_multiplier = 1.0f;

//Manipulate cooling capacity with fixed values and percentages
double cooling_value_modifier = 0;
float cooling_value_multiplier = 1.0f;

//Manipulation of generated heat by fixed values and percentages
double heat_per_shot_modifier = 0;
float heat_per_shot_multiplier = 1.0f;
};

struct islot_magazine {
Expand Down
16 changes: 14 additions & 2 deletions src/ranged.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,8 +762,19 @@ bool Character::handle_gun_damage( item &it )

bool Character::handle_gun_overheat( item &it )
{
double overheat_modifier = 0;
float overheat_multiplier = 1.0f;
double heat_modifier = 0;
float heat_multiplier = 1.0f;
for( const item *mod : it.gunmods() ) {
overheat_modifier += mod->type->gunmod->overheat_threshold_modifier;
overheat_multiplier *= mod->type->gunmod->overheat_threshold_multiplier;
heat_modifier += mod->type->gunmod->heat_per_shot_modifier;
heat_multiplier *= mod->type->gunmod->heat_per_shot_multiplier;
}
double heat = it.get_var( "gun_heat", 0.0 );
double threshold = it.type->gun->overheat_threshold;
double threshold = std::max( ( it.type->gun->overheat_threshold * overheat_multiplier ) +
overheat_modifier, 5.0 );
const islot_gun &gun_type = *it.type->gun;

if( threshold < 0.0 ) {
Expand Down Expand Up @@ -808,7 +819,8 @@ bool Character::handle_gun_overheat( item &it )
return false;
}
}
it.set_var( "gun_heat", heat + gun_type.heat_per_shot );
it.set_var( "gun_heat", heat + std::max( ( gun_type.heat_per_shot * heat_multiplier ) +
heat_modifier, 0.0 ) );
return true;
}

Expand Down

0 comments on commit 003be07

Please sign in to comment.