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(content): Support for antigrav #5502

Draft
wants to merge 15 commits into
base: main
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
17 changes: 17 additions & 0 deletions data/json/items/vehicle/repulsors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"id": "test_repulsor",
"type": "GENERIC",
"category": "veh_parts",
"name": { "str": "test repulsor" },
"description": "This should never be visible in normal play.",
"price": "50000 USD",
"price_postapoc": "250 USD",
"weight": "25000 g",
"volume": "40000 ml",
"looks_like": "broken_eyebot",
"material": "steel",
"symbol": "X",
"color": "blue"
}
]
32 changes: 32 additions & 0 deletions data/json/vehicleparts/repulsors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[
{
"abstract": "repulsor",
"type": "vehicle_part",
"location": "on_roof",
"symbol": "*",
"color": "light_blue",
"broken_symbol": "O",
"broken_color": "light_gray",
"flags": [ "REPULSOR" ],
"description": "A chrome sphere, sprouting wires at all angles. How does this even work?"

Check failure on line 11 in data/json/vehicleparts/repulsors.json

View workflow job for this annotation

GitHub Actions / GCC 12, Ubuntu, Curses

([slow] ~starting_items)=> insufficient spaces at this location. 2 required, but only 1 found.

Check failure on line 11 in data/json/vehicleparts/repulsors.json

View workflow job for this annotation

GitHub Actions / GCC 12, Ubuntu, Curses

(~[slow] ~[.],starting_items)=> insufficient spaces at this location. 2 required, but only 1 found.
},
{
"id": "test_repulsor",
"copy-from": "repulsor",
"type": "vehicle_part",
"name": "test repulsor",
"item": "test_repulsor",
"//": "repulsion is in kilonewtons",
"repulsion": 5,
"requirements": {
"install": { "skills": [ [ "mechanics", 7 ] ], "time": "2 h", "using": [ [ "welding_standard", 20 ] ] },
"removal": { "skills": [ [ "mechanics", 7 ] ], "time": "2 h", "using": [ [ "vehicle_weld_removal", 4 ] ] },
"repair": { "skills": [ [ "mechanics", 8 ] ], "time": "2 h", "using": [ [ "welding_standard", 20 ], [ "steel_tiny", 2 ] ] }
},
"durability": 450,
"description": "This should never be seen outside of testing.",
"damage_modifier": 80,
"breaks_into": [ { "item": "scrap", "count": [ 15, 30 ] }, { "item": "steel_chunk", "count": [ 8, 16 ] } ],
"damage_reduction": { "all": 66 }
}
]
11 changes: 6 additions & 5 deletions src/handle_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1835,7 +1835,7 @@ bool game::handle_action()
}
if( !u.in_vehicle ) {
vertical_move( -1, false );
} else if( veh_ctrl && vp->vehicle().is_rotorcraft() ) {
} else if( veh_ctrl && vp->vehicle().is_aircraft() ) {
pldrive( tripoint_below );
}
break;
Expand All @@ -1850,11 +1850,12 @@ bool game::handle_action()
}
if( !u.in_vehicle ) {
vertical_move( 1, false );
} else if( veh_ctrl && vp->vehicle().is_rotorcraft() ) {
} else if( veh_ctrl && vp->vehicle().is_aircraft() ) {
pldrive( tripoint_above );
} else if( veh_ctrl && vp->vehicle().has_part( "ROTOR" ) &&
!vp->vehicle().has_sufficient_rotorlift() ) {
add_msg( m_bad, _( "The rotors struggle to generate enough lift!" ) );
} else if( veh_ctrl && ( vp->vehicle().has_part( "ROTOR" ) ||
vp->vehicle().has_part( "REPULSOR" ) ) &&
!vp->vehicle().has_sufficient_lift() ) {
add_msg( m_bad, _( "The craft struggles to generate enough lift!" ) );
}
break;

Expand Down
6 changes: 3 additions & 3 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ bool map::vehproceed( VehicleList &vehicle_list )
// Then vertical-only movement
if( cur_veh == nullptr ) {
for( wrapped_vehicle &vehs_v : vehicle_list ) {
if( vehs_v.v->is_falling || ( vehs_v.v->is_rotorcraft() && vehs_v.v->get_z_change() != 0 ) ) {
if( vehs_v.v->is_falling || ( vehs_v.v->is_aircraft() && vehs_v.v->get_z_change() != 0 ) ) {
cur_veh = &vehs_v;
break;
}
Expand Down Expand Up @@ -635,7 +635,7 @@ vehicle *map::move_vehicle( vehicle &veh, const tripoint &dp, const tileray &fac
// Split into vertical and horizontal movement
const int &coll_velocity = vertical ? veh.vertical_velocity : veh.velocity;
const int velocity_before = coll_velocity;
if( velocity_before == 0 && !veh.is_rotorcraft() && !veh.is_flying_in_air() ) {
if( velocity_before == 0 && !veh.is_aircraft() && !veh.is_flying_in_air() ) {
debugmsg( "%s tried to move %s with no velocity",
veh.name, vertical ? "vertically" : "horizontally" );
return &veh;
Expand Down Expand Up @@ -697,7 +697,7 @@ vehicle *map::move_vehicle( vehicle &veh, const tripoint &dp, const tileray &fac

const int velocity_after = coll_velocity;
bool can_move = velocity_after != 0 && sgn( velocity_after ) == sgn( velocity_before );
if( dp.z != 0 && veh.is_rotorcraft() ) {
if( dp.z != 0 && veh.is_aircraft() ) {
can_move = true;
}
units::angle coll_turn = 0_degrees;
Expand Down
2 changes: 1 addition & 1 deletion src/overmap_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1880,7 +1880,7 @@ static std::vector<tripoint_abs_omt> get_overmap_path_to( const tripoint_abs_omt
}
player_veh = &vp->vehicle();
// for now we can only handle flyers if already in the air
const bool can_fly = player_veh->is_rotorcraft() && player_veh->is_flying_in_air();
const bool can_fly = player_veh->is_aircraft() && player_veh->is_flying_in_air();
const bool can_float = player_veh->can_float();
const bool can_drive = player_veh->valid_wheel_config();
// TODO: check engines/fuel
Expand Down
12 changes: 6 additions & 6 deletions src/veh_interact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2453,7 +2453,7 @@ void veh_interact::display_stats() const

bool is_boat = !veh->floating.empty();
bool is_ground = !veh->wheelcache.empty() || !is_boat;
bool is_aircraft = veh->is_rotorcraft() && veh->is_flying_in_air();
bool is_aircraft = veh->is_aircraft() && veh->is_flying_in_air();

const auto vel_to_int = []( const double vel ) {
return static_cast<int>( convert_velocity( vel, VU_VEHICLE ) );
Expand Down Expand Up @@ -2481,12 +2481,12 @@ void veh_interact::display_stats() const
if( is_aircraft ) {
print_stat(
_( "Air Safe/Top Speed: <color_light_green>%3d</color>/<color_light_red>%3d</color> %s" ),
vel_to_int( veh->safe_rotor_velocity( false ) ),
vel_to_int( veh->max_rotor_velocity( false ) ),
vel_to_int( veh->safe_aircraft_velocity( false ) ),
vel_to_int( veh->max_air_velocity( false ) ),
velocity_units( VU_VEHICLE ) );
print_stat(
_( "Air Acceleration: <color_light_blue>%3d</color> %s/s" ),
vel_to_int( veh->rotor_acceleration( false ) ),
vel_to_int( veh->aircraft_acceleration( false ) ),
velocity_units( VU_VEHICLE ) );
} else {
if( is_ground ) {
Expand Down Expand Up @@ -2523,10 +2523,10 @@ void veh_interact::display_stats() const
print_stat(
_( "Mass: <color_light_blue>%5.0f</color> %s" ),
convert_weight( veh->total_mass() ), weight_units() );
if( veh->has_part( "ROTOR" ) ) {
if( veh->has_lift() ) {
// convert newton to kg.
units::mass lift_as_mass = units::from_newton(
veh->lift_thrust_of_rotorcraft( true ) );
veh->total_lift( true ) );
print_stat(
_( "Maximum Lift: <color_light_blue>%5.0f</color> %s" ),
convert_weight( lift_as_mass ),
Expand Down
20 changes: 20 additions & 0 deletions src/veh_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,17 @@ void vpart_info::load_rotor( std::optional<vpslot_rotor> &roptr, const JsonObjec
assert( roptr );
}

void vpart_info::load_repulsor( std::optional<vpslot_repulsor> &rpptr, const JsonObject &jo )
{
vpslot_repulsor repulsor_info{};
if( rpptr ) {
repulsor_info = *rpptr;
}
assign( jo, "repulsion", repulsor_info.repulsion );
rpptr = repulsor_info;
assert( rpptr );
}

void vpart_info::load_wheel( std::optional<vpslot_wheel> &whptr, const JsonObject &jo )
{
vpslot_wheel wh_info{};
Expand Down Expand Up @@ -436,6 +447,10 @@ void vpart_info::load( const JsonObject &jo, const std::string &src )
load_rotor( def.rotor_info, jo );
}

if( def.has_flag( "REPULSOR" ) ) {
load_repulsor( def.repulsor_info, jo );
}

if( def.has_flag( "WORKBENCH" ) ) {
load_workbench( def.workbench_info, jo );
}
Expand Down Expand Up @@ -913,6 +928,11 @@ int vpart_info::rotor_diameter() const
return has_flag( VPFLAG_ROTOR ) ? rotor_info->rotor_diameter : 0;
}

float vpart_info::repulsion() const
{
return has_flag( "REPULSOR" ) ? repulsor_info->repulsion : 0;
Copy link
Member

Choose a reason for hiding this comment

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

Worth extracting to a VPFLAG_*, since it's going to be checked a lot.

}

const std::optional<vpslot_workbench> &vpart_info::get_workbench_info() const
{
return workbench_info;
Expand Down
9 changes: 8 additions & 1 deletion src/veh_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ struct vpslot_rotor {
int rotor_diameter = 1;
};

struct vpslot_repulsor {
float repulsion = 1;
};

struct vpslot_workbench {
// Base multiplier applied for crafting here
float multiplier = 1.0f;
Expand All @@ -138,6 +142,7 @@ class vpart_info
std::optional<vpslot_engine> engine_info;
std::optional<vpslot_wheel> wheel_info;
std::optional<vpslot_rotor> rotor_info;
std::optional<vpslot_repulsor> repulsor_info;
std::optional<vpslot_workbench> workbench_info;

public:
Expand Down Expand Up @@ -302,9 +307,10 @@ class vpart_info
int wheel_area() const;
std::vector<std::pair<std::string, int>> wheel_terrain_mod() const;
float wheel_or_rating() const;
/** @name rotor specific functions
/** @name flight specific functions
*/
int rotor_diameter() const;
float repulsion() const;
/**
* Getter for optional workbench info
*/
Expand Down Expand Up @@ -346,6 +352,7 @@ class vpart_info
static void load_wheel( std::optional<vpslot_wheel> &whptr, const JsonObject &jo );
static void load_workbench( std::optional<vpslot_workbench> &wbptr, const JsonObject &jo );
static void load_rotor( std::optional<vpslot_rotor> &roptr, const JsonObject &jo );
static void load_repulsor( std::optional<vpslot_repulsor> &rpptr, const JsonObject &jo );
static void load( const JsonObject &jo, const std::string &src );
static void finalize();
static void check();
Expand Down
Loading
Loading