Skip to content

Commit

Permalink
The Mech Update (#2829)
Browse files Browse the repository at this point in the history
* The Mech Update

* Finish the JSON bits

* Updates to open and close behavior

* Fixes

* Update turret.json

* Update game.cpp

* Update data/json/items/generic.json

Co-authored-by: scarf <greenscarf005@gmail.com>

* Make the salvaged lasers still at least lighter than the rebuilt ones

---------

Co-authored-by: scarf <greenscarf005@gmail.com>
  • Loading branch information
chaosvolt and scarf005 authored Jul 16, 2023
1 parent 15a099f commit 588ea97
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 11 deletions.
24 changes: 24 additions & 0 deletions data/json/items/generic.json
Original file line number Diff line number Diff line change
Expand Up @@ -2666,6 +2666,30 @@
"volume": "750 ml",
"category": "spare_parts"
},
{
"id": "gatling_mech_laser_salvaged",
"copy-from": "cerberus_laser",
"looks_like": "gatling_mech_laser",
"type": "GENERIC",
"color": "blue",
"name": { "str": "salvaged CMES gatling laser" },
"description": "A rapid-fire weapon system stripped from a wrecked combat exoskeleton. No longer usable as a weapon in its current condition.",
"material": [ "superalloy", "plastic" ],
"weight": "39 kg",
"volume": "11 L"
},
{
"id": "recon_mech_laser_salvaged",
"copy-from": "cerberus_laser",
"looks_like": "recon_mech_laser",
"type": "GENERIC",
"color": "blue",
"name": { "str": "salvaged RMES marksman laser" },
"description": "A long-range weapon system stripped from a wrecked recon exoskeleton. No longer usable as a weapon in its current condition.",
"material": [ "superalloy", "plastic" ],
"weight": "12 kg",
"volume": "5500 ml"
},
{
"id": "light_bulb",
"type": "GENERIC",
Expand Down
34 changes: 29 additions & 5 deletions data/json/items/gun/ups.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,26 @@
"material": [ "superalloy", "plastic" ],
"color": "blue",
"range": 30,
"ranged_damage": { "damage_type": "heat", "amount": 20, "armor_penetration": 4 },
"ranged_damage": { "damage_type": "heat", "amount": 40, "armor_penetration": 5 },
"dispersion": 100,
"loudness": 12,
"ups_charges": 20,
"modes": [ [ "DEFAULT", "3 rd.", 3 ], [ "BURST", "5 rd.", 5 ], [ "AUTO", "high auto", 15 ] ],
"ups_charges": 50,
"modes": [ [ "DEFAULT", "semi", 1 ], [ "BURST", "burst", 5 ], [ "AUTO", "auto", 10 ] ],
"ammo_effects": [ "LASER", "PLASMA_BUBBLE", "INCENDIARY" ],
"extend": { "flags": [ "NO_UNWIELD", "NO_SALVAGE", "NO_REPAIR", "UNBREAKABLE_MELEE" ] }
},
{
"id": "gatling_mech_laser_rebuilt",
"copy-from": "gatling_mech_laser",
"type": "GUN",
"name": { "str": "rebuilt CMES gatling laser" },
"description": "A rapid-fire weapon system stripped from a combat mech, modified for handheld use. While less efficient and too bulky to fire without proper support, its rotating-barrel laser system can still spray death downrange with ease.",
"weight": "40 kg",
"dispersion": 200,
"ups_charges": 80,
"extend": { "flags": [ "MOUNTED_GUN" ] },
"delete": { "flags": [ "NO_UNWIELD", "NO_SALVAGE", "NO_REPAIR", "UNBREAKABLE_MELEE" ] }
},
{
"id": "recon_mech_laser",
"copy-from": "rifle_energy",
Expand All @@ -68,13 +80,25 @@
"material": [ "superalloy", "plastic" ],
"color": "blue",
"range": 45,
"ranged_damage": { "damage_type": "heat", "amount": 30, "armor_penetration": 4 },
"ranged_damage": { "damage_type": "heat", "amount": 80, "armor_penetration": 10 },
"dispersion": 15,
"loudness": 1,
"ups_charges": 50,
"ups_charges": 100,
"ammo_effects": [ "LASER", "PLASMA_BUBBLE", "INCENDIARY" ],
"extend": { "flags": [ "NO_UNWIELD", "NO_REPAIR", "NO_SALVAGE", "UNBREAKABLE_MELEE" ] }
},
{
"id": "recon_mech_laser_rebuilt",
"copy-from": "recon_mech_laser",
"type": "GUN",
"name": { "str": "rebuilt RMES marksman laser" },
"description": "A long-range weapon system stripped from a recon mech, modified for handheld use. While less efficient and too bulky to fire without proper support, it's still a quiet and relatively accurate marksman laser rifle.",
"weight": "13 kg",
"dispersion": 30,
"ups_charges": 160,
"extend": { "flags": [ "MOUNTED_GUN" ] },
"delete": { "flags": [ "NO_UNWIELD", "NO_REPAIR", "NO_SALVAGE", "UNBREAKABLE_MELEE" ] }
},
{
"id": "laser_cannon",
"copy-from": "rifle_energy",
Expand Down
2 changes: 2 additions & 0 deletions data/json/monsters/mechsuits.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"NOHEAD",
"NO_BREATHE",
"RIDEABLE_MECH",
"MECH_DEFENSIVE",
"PRIORITIZE_TARGETS",
"PATH_AVOID_DANGER_2"
]
Expand Down Expand Up @@ -91,6 +92,7 @@
"NOHEAD",
"NO_BREATHE",
"RIDEABLE_MECH",
"MECH_DEFENSIVE",
"PRIORITIZE_TARGETS",
"PATH_AVOID_DANGER_2",
"LOUDMOVES"
Expand Down
28 changes: 28 additions & 0 deletions data/json/recipes/weapon/ranged.json
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,34 @@
"qualities": [ { "id": "SAW_M_FINE", "level": 1 }, { "id": "SCREW_FINE", "level": 1 } ],
"components": [ [ [ "cerberus_laser", 1 ] ], [ [ "battery_ups", 1 ] ], [ [ "cable", 15 ] ] ]
},
{
"type": "recipe",
"result": "gatling_mech_laser_rebuilt",
"category": "CC_WEAPON",
"subcategory": "CSC_WEAPON_RANGED",
"skill_used": "electronics",
"skills_required": [ [ "fabrication", 5 ], [ "gun", 1 ] ],
"difficulty": 7,
"time": "30 m",
"autolearn": true,
"using": [ [ "welding_standard", 5 ], [ "steel_tiny", 2 ] ],
"qualities": [ { "id": "SAW_M_FINE", "level": 1 }, { "id": "SCREW_FINE", "level": 1 } ],
"components": [ [ [ "gatling_mech_laser_salvaged", 1 ] ], [ [ "battery_ups", 1 ] ], [ [ "cable", 25 ] ] ]
},
{
"type": "recipe",
"result": "gatling_mech_laser_rebuilt",
"category": "CC_WEAPON",
"subcategory": "CSC_WEAPON_RANGED",
"skill_used": "electronics",
"skills_required": [ [ "fabrication", 5 ], [ "gun", 1 ] ],
"difficulty": 7,
"time": "30 m",
"autolearn": true,
"using": [ [ "welding_standard", 5 ], [ "steel_tiny", 2 ] ],
"qualities": [ { "id": "SAW_M_FINE", "level": 1 }, { "id": "SCREW_FINE", "level": 1 } ],
"components": [ [ [ "gatling_mech_laser_salvaged", 1 ] ], [ [ "battery_ups", 1 ] ], [ [ "cable", 25 ] ] ]
},
{
"type": "recipe",
"result": "m2browning_sawn",
Expand Down
11 changes: 8 additions & 3 deletions data/json/uncraft/generic.json
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,7 @@
"using": [ [ "soldering_standard", 30 ], [ "welding_standard", 20 ] ],
"qualities": [ { "id": "SCREW", "level": 1 }, { "id": "WRENCH", "level": 1 }, { "id": "SAW_M", "level": 1 } ],
"components": [
[ [ "recon_mech_laser_salvaged", 1 ] ],
[ [ "ai_module", 1 ] ],
[ [ "sensor_module", 1 ] ],
[ [ "memory_module", 1 ] ],
Expand All @@ -1025,7 +1026,8 @@
[ [ "power_supply", 20 ] ],
[ [ "storage_battery", 2 ] ],
[ [ "plut_cell", 4 ] ],
[ [ "mil_plate", 15 ] ]
[ [ "mil_plate", 15 ] ],
[ [ "alloy_sheet", 25 ] ]
]
},
{
Expand All @@ -1046,7 +1048,8 @@
[ [ "power_supply", 20 ] ],
[ [ "storage_battery", 2 ] ],
[ [ "plut_cell", 4 ] ],
[ [ "mil_plate", 6 ] ]
[ [ "mil_plate", 6 ] ],
[ [ "alloy_sheet", 15 ] ]
]
},
{
Expand All @@ -1058,6 +1061,7 @@
"using": [ [ "soldering_standard", 30 ], [ "welding_standard", 20 ] ],
"qualities": [ { "id": "SCREW", "level": 1 }, { "id": "WRENCH", "level": 1 }, { "id": "SAW_M", "level": 1 } ],
"components": [
[ [ "gatling_mech_laser_salvaged", 1 ] ],
[ [ "ai_module", 1 ] ],
[ [ "sensor_module", 1 ] ],
[ [ "memory_module", 1 ] ],
Expand All @@ -1067,7 +1071,8 @@
[ [ "power_supply", 20 ] ],
[ [ "storage_battery", 2 ] ],
[ [ "plut_cell", 4 ] ],
[ [ "mil_plate", 20 ] ]
[ [ "mil_plate", 20 ] ],
[ [ "alloy_sheet", 20 ] ]
]
},
{
Expand Down
28 changes: 28 additions & 0 deletions data/json/vehicleparts/turret.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,34 @@
"removal": { "skills": [ [ "mechanics", 3 ] ] }
}
},
{
"id": "mounted_gatling_mech_laser_rebuilt",
"copy-from": "turret",
"type": "vehicle_part",
"name": { "str": "mounted gatling laser" },
"item": "gatling_mech_laser_rebuilt",
"color": "blue",
"broken_color": "blue",
"breaks_into": [ { "item": "scrap", "count": 14 }, { "item": "steel_chunk", "count": 6 }, { "item": "steel_lump", "count": 2 } ],
"requirements": {
"install": { "skills": [ [ "mechanics", 6 ], [ "electronics", 6 ] ] },
"removal": { "skills": [ [ "mechanics", 4 ] ] }
}
},
{
"id": "mounted_recon_mech_laser_rebuilt",
"copy-from": "turret",
"type": "vehicle_part",
"name": { "str": "mounted marksman laser" },
"item": "recon_mech_laser_rebuilt",
"color": "blue",
"broken_color": "blue",
"breaks_into": [ { "item": "scrap", "count": 14 }, { "item": "steel_chunk", "count": 6 }, { "item": "steel_lump", "count": 2 } ],
"requirements": {
"install": { "skills": [ [ "mechanics", 6 ], [ "electronics", 6 ] ] },
"removal": { "skills": [ [ "mechanics", 4 ] ] }
}
},
{
"id": "m249",
"copy-from": "turret",
Expand Down
9 changes: 9 additions & 0 deletions src/avatar_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,15 @@ bool avatar_action::move( avatar &you, map &m, const tripoint &d )
if( !veh1->handle_potential_theft( you ) ) {
return true;
} else {
// This check must be present in both avatar_action::move and map::open_door for vehiclepart doors specifically,
// having it in just one does not prevent opening doors on horseback, for some insane reason.
if( you.is_mounted() ) {
auto mon = you.mounted_creature.get();
if( !mon->has_flag( MF_RIDEABLE_MECH ) ) {
// Message is printed by the other check in map::open_door
return false;
}
}
if( outside_vehicle ) {
veh1->open_all_at( dpart );
} else {
Expand Down
17 changes: 16 additions & 1 deletion src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5470,7 +5470,22 @@ void game::examine( const tripoint &examp )
if( c != nullptr ) {
monster *mon = dynamic_cast<monster *>( c );
if( mon != nullptr ) {
add_msg( _( "There is a %s." ), mon->get_name() );
if( mon->battery_item && mon->has_effect( effect_pet ) ) {
const itype &type = *mon->type->mech_battery;
int max_charge = type.magazine->capacity;
float charge_percent;
if( mon->battery_item ) {
charge_percent = static_cast<float>( mon->battery_item->ammo_remaining() ) / max_charge * 100;
} else {
charge_percent = 0.0;
}
add_msg( _( "There is a %s. Battery level: %d%%" ), mon->get_name(),
static_cast<int>( charge_percent ) );
} else {
add_msg( _( "There is a %s." ), mon->get_name() );
}


if( mon->has_effect( effect_pet ) && !u.is_mounted() ) {
if( monexamine::pet_menu( *mon ) ) {
return;
Expand Down
11 changes: 10 additions & 1 deletion src/handle_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1856,7 +1856,13 @@ bool game::handle_action()
if( u.has_active_mutation( trait_SHELL2 ) ) {
add_msg( m_info, _( "You can't open things while you're in your shell." ) );
} else if( u.is_mounted() ) {
add_msg( m_info, _( "You can't open things while you're riding." ) );
auto mon = u.mounted_creature.get();
if( !mon->has_flag( MF_RIDEABLE_MECH ) ) {
add_msg( m_info, _( "You can't open things while you're riding." ) );
break;
} else {
open();
}
} else {
open();
}
Expand All @@ -1869,6 +1875,9 @@ bool game::handle_action()
auto mon = u.mounted_creature.get();
if( !mon->has_flag( MF_RIDEABLE_MECH ) ) {
add_msg( m_info, _( "You can't close things while you're riding." ) );
break;
} else {
close();
}
} else if( mouse_target ) {
doors::close_door( m, u, *mouse_target );
Expand Down
23 changes: 22 additions & 1 deletion src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3979,11 +3979,18 @@ bool map::open_door( const tripoint &p, const bool inside, const bool check_only
avatar &you = get_avatar();
const auto &ter = this->ter( p ).obj();
const auto &furn = this->furn( p ).obj();

if( ter.open ) {
if( has_flag( "OPENCLOSE_INSIDE", p ) && !inside ) {
return false;
}

if( you.is_mounted() ) {
auto mon = you.mounted_creature.get();
if( !mon->has_flag( MF_RIDEABLE_MECH ) ) {
add_msg( m_info, _( "You can't open things while you're riding." ) );
return false;
}
}
if( !check_only ) {
sounds::sound( p, 6, sounds::sound_t::movement, _( "swish" ), true,
"open_door", ter.id.str() );
Expand All @@ -4001,6 +4008,13 @@ bool map::open_door( const tripoint &p, const bool inside, const bool check_only
if( has_flag( "OPENCLOSE_INSIDE", p ) && !inside ) {
return false;
}
if( you.is_mounted() ) {
auto mon = you.mounted_creature.get();
if( !mon->has_flag( MF_RIDEABLE_MECH ) ) {
add_msg( m_info, _( "You can't open things while you're riding." ) );
return false;
}
}

if( !check_only ) {
sounds::sound( p, 6, sounds::sound_t::movement, _( "swish" ), true,
Expand All @@ -4012,6 +4026,13 @@ bool map::open_door( const tripoint &p, const bool inside, const bool check_only
} else if( const optional_vpart_position vp = veh_at( p ) ) {
int openable = vp->vehicle().next_part_to_open( vp->part_index(), true );
if( openable >= 0 ) {
if( you.is_mounted() ) {
auto mon = you.mounted_creature.get();
if( !mon->has_flag( MF_RIDEABLE_MECH ) ) {
add_msg( m_info, _( "You can't open things while you're riding." ) );
return false;
}
}
if( !check_only ) {
if( !vp->vehicle().handle_potential_theft( you ) ) {
return false;
Expand Down

0 comments on commit 588ea97

Please sign in to comment.