-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add Talker vehicle and EOCs for vehicles #77564
base: master
Are you sure you want to change the base?
Conversation
i guess it would conflict with #77485 much? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick review only. IMO this should wait for #77485 because that PR is already enormous.
// first, let's find our position in current vehicles vector | ||
size_t our_i = 0; | ||
bool found = false; | ||
for( submap *&smap : here.grid ) { | ||
for( size_t i = 0; i < smap->vehicles.size(); i++ ) { | ||
if( smap->vehicles[i].get() == &veh ) { | ||
our_i = i; | ||
src_submap = smap; | ||
found = true; | ||
break; | ||
} | ||
} | ||
if( found ) { | ||
break; | ||
} | ||
} | ||
|
||
if( !found ) { | ||
add_msg_debug( debugmode::DF_MAP, "displace_vehicle [%s] failed", veh.name ); | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// first, let's find our position in current vehicles vector | |
size_t our_i = 0; | |
bool found = false; | |
for( submap *&smap : here.grid ) { | |
for( size_t i = 0; i < smap->vehicles.size(); i++ ) { | |
if( smap->vehicles[i].get() == &veh ) { | |
our_i = i; | |
src_submap = smap; | |
found = true; | |
break; | |
} | |
} | |
if( found ) { | |
break; | |
} | |
} | |
if( !found ) { | |
add_msg_debug( debugmode::DF_MAP, "displace_vehicle [%s] failed", veh.name ); | |
return false; | |
} | |
src_submap = here.get_submap_at_grid( veh.sm_pos.xy() ); |
For master it's probably src_submap = here.get_submap_at_grid( point_rel_sm{ veh.sm_pos.xy() } );
though. It needs the change below too.
dst_submap->ensure_nonuniform(); | ||
veh.set_submap_moved( tripoint( here.bub_from_abs( dp ).x() / SEEX, | ||
here.bub_from_abs( dp ).y() / SEEY, dp.z() ) ); | ||
auto src_submap_veh_it = src_submap->vehicles.begin() + our_i; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto src_submap_veh_it = src_submap->vehicles.begin() + our_i; | |
auto src_submap_veh_it = | |
std::find_if( src_submap->vehicles.begin(), src_submap->vehicles.end(), | |
[&veh]( std::unique_ptr<vehicle> const & v ) { | |
return v.get() == &veh; | |
} ); |
@@ -217,3 +222,195 @@ bool teleport::teleport_to_point( Creature &critter, tripoint target, bool safe, | |||
} | |||
return true; | |||
} | |||
|
|||
bool teleport::teleport_vehicle( vehicle &veh, const tripoint_abs_ms &dp ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you break this function down into logical units?
|
||
class Creature; | ||
|
||
namespace teleport | ||
class vehicle; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
if( jo.has_int( "vehicle_range" ) ) { | ||
vehicle_range = jo.get_int( "vehicle_range" ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs more selection criteria to be useful. But for that we need an in-game use case.
Summary
Infrastructure "EOCs for vehicles"
Purpose of change
Implements #74511
Allow EOCs on vehicles
Describe the solution
Added talker vehicle and implemented some new talker functions for it. Right now the only way to access a vehicle with EOC's is to us the new "u_run_vehicle_eocs" eoc effect or when the "vehicle_moves" event fires. The only effect that works on vehicles is teleport.
Describe alternatives you've considered
So, so many. There are all kinds of powers I could hook up but I'm not sure what would actually get used and design choices would need to be made. Stuff like having vehicles run EOC's the way characters do, turning on/off power/engines. Please comment on this or create an issue and tag me if there is something you'd like to see added to this.
Testing
I used the following json
Additional context