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

Vehicle boat/traction update #17687

Merged
merged 16 commits into from
Jul 21, 2016

Conversation

Coolthulhu
Copy link
Contributor

Mostly refactoring for future land vehicle/boat split.
Wheel configuration, traction etc. functions got a bool boat argument. If false, it checks the wheels. If true, the boat parts.

Other code changes:

  • Removed hardcoded division by 9 of wheel area. Adjusted k_mass so that it doesn't change from current values.
  • Removed some hardcoded boat checks
  • Changed the "nothing grabbed" condition from grab_point == tripoint_zero to grab_type == OBJECT_NONE. This allows grabbing stuff below self

Gameplay changes:

  • Updated vehicle push/pull. Had to, because vehicle push/pull is related to all of: traction, wheel configuration, pivoting. All of those were changed here, so vehicle grab could easily regress otherwise. On the positive side, the changes make dragging bicycles a much less painful experience for the user - I didn't manage to lose my grabbed bike by walking around.
  • Added a "K traction" display to vehicle interaction menu. It displays the multiplier on acceleration (1.0 or less) due to bad traction, calculated for dirt (the most common terrain for offroading).
  • Added a warning message when acceleration of a vehicle is 0. Can happen when biking on a heavy vehicle, for example.

@mugling
Copy link
Contributor

mugling commented Jul 17, 2016

Needs rebase

@Coolthulhu
Copy link
Contributor Author

Rebased

@mugling mugling self-assigned this Jul 21, 2016
@mugling
Copy link
Contributor

mugling commented Jul 21, 2016

On the positive side, the changes make dragging bicycles a much less painful experience for the user

This is a significant improvement

@@ -3531,6 +3531,15 @@ std::set<fault_id> item::faults_potential() const
return res;
}

int item::wheel_area() const
{
if( !is_wheel() ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

overly verbose. item.cpp is already obese.

return is_wheel() ? type->wheel->diameter * type->wheel->width : 0

@mugling
Copy link
Contributor

mugling commented Jul 21, 2016

Vehicle movement functions need some further documentation starting with the k_* family. The work you're doing on this is excellent but it's very hard to follow without such documentation.

Can you provide a skeleton outline on the github wiki of how vehicles actually move as this would probably accelerate review of vehicle PR's and possibly encourage other developers to assist. It doesn't need to be all encompassing but having something there also encourages future contributions to the documentation.

@Coolthulhu
Copy link
Contributor Author

Cleaned up

Not sure how to document the k_*. Their exact values aren't all that relevant, except when we're talking about balance. The way they're used is generally just multiplication.

@mugling
Copy link
Contributor

mugling commented Jul 21, 2016

Not sure how to document the k_*

Can you provide an overview/introduction as to how the whole system works?

@Coolthulhu
Copy link
Contributor Author

Can you provide an overview/introduction as to how the whole system works?

Maximum speed is multiplied by k_dynamics and k_mass.
Safe speed is multiplied by k_dynamics and k_mass ^ 2.
Acceleration is multiplied by k_dynamics, k_mass ^2 and k_traction.
k_dynamics = k_friction * k_aerodynamics

@@ -1445,6 +1445,55 @@ void veh_interact::display_veh ()
wrefresh (w_disp);
}

std::string wheel_state_description( const vehicle &veh )
Copy link
Contributor

Choose a reason for hiding this comment

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

static?

float fr0 = 1000.0;
float kf = ( fr0 / (fr0 + wheels_area()) );
return kf;
constexpr float fr0 = 9000.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

magic value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was always magic, kept for compatibility.

Copy link
Contributor

Choose a reason for hiding this comment

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

Any idea what it means?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assume it's just there for the numbers to look right.
It doesn't really model any real life effect.

Copy link
Contributor

Choose a reason for hiding this comment

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

Might be best to document is as unknown magical value - at least that makes it clear future removal would be acceptable


// Combined coefficient of aerodynamic and wheel friction resistance of vehicle, 0-1.0.
// 1.0 means it's ideal form and have no resistance at all. 0 -- it won't move
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this still hold true because it's more descriptive than the below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I copy+paste "0 means won't move, 1 means ideal" to every k_* description?

Copy link
Contributor

@mugling mugling Jul 21, 2016

Choose a reason for hiding this comment

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

No but you could wrap the whole family of k_* functions in a doxygen scope and explain that there

@Coolthulhu
Copy link
Contributor Author

How about this?

@mugling
Copy link
Contributor

mugling commented Jul 21, 2016

Better but I'd wrap the whole lot in a doxygen scope and provide a short summary.

The function documentation would be better in the style of the preamble one you gave for k_traction

@Coolthulhu
Copy link
Contributor Author

How to scope multiple functions and provide one description for all of them and specific descriptions for details for each function?

@mugling
Copy link
Contributor

mugling commented Jul 21, 2016

There is an example starting at item.h:1209

@Coolthulhu
Copy link
Contributor Author

How about this?

@mugling
Copy link
Contributor

mugling commented Jul 21, 2016

Perfect.

Now they have definitions the VEHICLE stats dumper would benefit from dumping of those values - can you add them to dump.cpp as it will help in identifying any changes in future PR's.

Apart from that looks good to go

@Coolthulhu
Copy link
Contributor Author

Added the same info that veh_interact.cpp displays to dump.cpp

@@ -147,7 +147,10 @@ void game::dump_stats( const std::string& what, dump_mode mode )

} else if( what == "VEHICLE" ) {
header = {
"Name", "Weight (empty)", "Weight (fueled)"
"Name", "Weight (empty)", "Weight (fueled)",
"Max velocity", "Safe velocity", "Acceleration",
Copy link
Contributor

Choose a reason for hiding this comment

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

What are the units of max velocity, safe velocity and acceleration?

@mugling
Copy link
Contributor

mugling commented Jul 21, 2016

k_mass doesn't appear to do much. Is that a regression from this PR or has it always been there?

@Coolthulhu
Copy link
Contributor Author

k_mass doesn't appear to do much.

?

@mugling
Copy link
Contributor

mugling commented Jul 21, 2016

Dump the vehicle stats. All vehicles are 99%

@Coolthulhu
Copy link
Contributor Author

I forgot a to include a magic constant I removed from wheels_area in k_mass.

@mugling mugling merged commit 6f69357 into CleverRaven:master Jul 21, 2016
@Coolthulhu Coolthulhu deleted the vehicle-boat-disp branch June 15, 2020 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants