From ec0cf7b417b22d7ff91a8289e5f2187a664ed1a2 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 7 Jul 2016 20:19:35 +1000 Subject: [PATCH] Move gunner enter checking into the bumblebee's file, also fix gunner entering wrong side of the bumblebee when empty --- qcsrc/common/vehicles/sv_vehicles.qc | 20 +++++++---------- qcsrc/common/vehicles/vehicle.qh | 2 ++ qcsrc/common/vehicles/vehicle/bumblebee.qc | 26 +++++++++++++++++----- qcsrc/server/cl_client.qc | 6 ++--- 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc index fb6fd9487..4c3737379 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qc +++ b/qcsrc/common/vehicles/sv_vehicles.qc @@ -892,23 +892,20 @@ void vehicles_enter(entity pl, entity veh) || (pl.vehicle) ) { return; } + Vehicle info = Vehicles_from(veh.vehicleid); + if(autocvar_g_vehicles_enter) // vehicle's touch function should handle this if entering via use key is disabled (TODO) if(veh.vehicle_flags & VHF_MULTISLOT) if(veh.owner && SAME_TEAM(pl, veh)) { - if(!veh.gunner1) - if(time >= veh.gun1.phase) - if(veh.gun1.vehicle_enter) - if(veh.gun1.vehicle_enter(veh, pl)) - return; - - if(!veh.gunner2) - if(time >= veh.gun2.phase) - if(veh.gun2.vehicle_enter) - if(veh.gun2.vehicle_enter(veh, pl)) - return; + // we don't need a return value or anything here + // if successful the owner check below will prevent anything weird + info.vr_gunner_enter(info, veh, pl); } + if(veh.owner) + return; // got here and didn't enter the gunner, return + if(teamplay) if(veh.team) if(DIFF_TEAM(pl, veh)) @@ -1008,7 +1005,6 @@ void vehicles_enter(entity pl, entity veh) MUTATOR_CALLHOOK(VehicleEnter, pl, veh); CSQCModel_UnlinkEntity(veh); - Vehicle info = Vehicles_from(veh.vehicleid); info.vr_enter(info, veh); antilag_clear(pl, CS(pl)); diff --git a/qcsrc/common/vehicles/vehicle.qh b/qcsrc/common/vehicles/vehicle.qh index 8dacc6634..927465ea6 100644 --- a/qcsrc/common/vehicles/vehicle.qh +++ b/qcsrc/common/vehicles/vehicle.qh @@ -46,6 +46,8 @@ CLASS(Vehicle, Object) METHOD(Vehicle, vr_precache, void(Vehicle this)) { } /** (SERVER) called when a player enters this vehicle */ METHOD(Vehicle, vr_enter, void(Vehicle this, entity instance)) { } + /** (SERVER) called when a player enters this vehicle while occupied */ + METHOD(Vehicle, vr_gunner_enter, void(Vehicle this, entity instance, entity actor)) { } /** (SERVER) called when the vehicle re-spawns */ METHOD(Vehicle, vr_spawn, void(Vehicle this, entity instance)) { } /** (SERVER) called when a vehicle hits something */ diff --git a/qcsrc/common/vehicles/vehicle/bumblebee.qc b/qcsrc/common/vehicles/vehicle/bumblebee.qc index 9885269ac..a0c0dd2ec 100644 --- a/qcsrc/common/vehicles/vehicle/bumblebee.qc +++ b/qcsrc/common/vehicles/vehicle/bumblebee.qc @@ -297,15 +297,17 @@ bool bumblebee_gunner_enter(entity this, entity player) if(!vehic.gunner1 && !vehic.gunner2 && ((time >= vehic.gun1.phase) + (time >= vehic.gun2.phase)) == 2) { // we can have some fun - if(vlen2(real_origin(vehic.gun2) - player.origin) < vlen2(real_origin(vehic.gun1) - player.origin)) + vector v1 = gettaginfo(vehic, gettagindex(vehic, "cannon_right")); + vector v2 = gettaginfo(vehic, gettagindex(vehic, "cannon_left")); + if(vlen2(player.origin - v1) < vlen2(player.origin - v2)) { - gunner = vehic.gun2; - vehic.gunner2 = player; + gunner = vehic.gun1; + vehic.gunner1 = player; } else { - gunner = vehic.gun1; - vehic.gunner1 = player; + gunner = vehic.gun2; + vehic.gunner2 = player; } } else if(!vehic.gunner1 && time >= vehic.gun1.phase) { gunner = vehic.gun1; vehic.gunner1 = player; } @@ -737,6 +739,20 @@ METHOD(Bumblebee, vr_enter, void(Bumblebee thisveh, entity instance)) instance.nextthink = 0; instance.movetype = MOVETYPE_BOUNCEMISSILE; } +METHOD(Bumblebee, vr_gunner_enter, void(Bumblebee thisveh, entity instance, entity actor)) +{ + if(!instance.gunner1) + if(time >= instance.gun1.phase) + if(instance.gun1.vehicle_enter) + if(instance.gun1.vehicle_enter(instance, actor)) + return; + + if(!instance.gunner2) + if(time >= instance.gun2.phase) + if(instance.gun2.vehicle_enter) + if(instance.gun2.vehicle_enter(instance, actor)) + return; +} METHOD(Bumblebee, vr_think, void(Bumblebee thisveh, entity instance)) { instance.angles_z *= 0.8; diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 146209528..912086389 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -2168,10 +2168,8 @@ void PlayerPreThink (entity this) { if(!it.team || SAME_TEAM(this, it)) Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_VEHICLE_ENTER); - } - else if(autocvar_g_vehicles_steal) - { - Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_VEHICLE_ENTER_STEAL); + else if(autocvar_g_vehicles_steal) + Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_VEHICLE_ENTER_STEAL); } }); -- 2.39.2