From: Jakob MG Date: Mon, 21 Mar 2011 01:44:02 +0000 (+0100) Subject: New cvar g_vehicle_raptor_cannon_locktarget, if 1 lets the raptors cannon lock onto... X-Git-Tag: xonotic-v0.5.0~199^2~11^2~115 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=86d591685961950416c58087d6d2b3f4f07a5b5d;p=xonotic%2Fxonotic-data.pk3dir.git New cvar g_vehicle_raptor_cannon_locktarget, if 1 lets the raptors cannon lock onto and track a target if its udner the crosshaor for long enougth. New cvar g_vehicle_raptor_cannon_predicttarget, if above cvar and this one is 1, cannons also predicts target movement. --- diff --git a/gfx/vehicles/sbot-xhair2.tga b/gfx/vehicles/sbot-xhair2.tga index a66866cba..bb3ade588 100644 Binary files a/gfx/vehicles/sbot-xhair2.tga and b/gfx/vehicles/sbot-xhair2.tga differ diff --git a/qcsrc/client/vehicles/vehicles.qc b/qcsrc/client/vehicles/vehicles.qc index f54156d47..786df248c 100644 --- a/qcsrc/client/vehicles/vehicles.qc +++ b/qcsrc/client/vehicles/vehicles.qc @@ -36,9 +36,12 @@ void AuxiliaryXhair_Draw2D() psize = 0.5 * drawgetimagesize(SPIDER_CROSS2); loc = project_3d_to_2d(self.origin) - 0.5 * psize; - loc_z = 0; - psize_z = 0; - drawpic(loc, SPIDER_CROSS2, psize, '0 1 1', 1, DRAWFLAG_ADDITIVE); + if not (loc_z < 0 || loc_x < 0 || loc_y < 0 || loc_x > vid_conwidth || loc_y > vid_conheight) + { + loc_z = 0; + psize_z = 0; + drawpic(loc, SPIDER_CROSS2, psize, self.colormod, 1, DRAWFLAG_ADDITIVE); + } if(time - self.cnt > 0.1) remove(self); @@ -63,6 +66,11 @@ void Ent_AuxiliaryXhair(float isNew) AuxiliaryXhair.origin_x = ReadCoord(); AuxiliaryXhair.origin_y = ReadCoord(); AuxiliaryXhair.origin_z = ReadCoord(); + + AuxiliaryXhair.colormod_x = ReadByte() / 255; + AuxiliaryXhair.colormod_y = ReadByte() / 255; + AuxiliaryXhair.colormod_z = ReadByte() / 255; + AuxiliaryXhair.drawmask = MASK_NORMAL; AuxiliaryXhair.cnt = time; @@ -188,6 +196,7 @@ void CSQC_RAPTOR_HUD() float movedt; vector where; + if(!dropmark) { dropmark = spawn(); diff --git a/qcsrc/server/vehicles/raptor.qc b/qcsrc/server/vehicles/raptor.qc index 0e215561c..325e10aae 100644 --- a/qcsrc/server/vehicles/raptor.qc +++ b/qcsrc/server/vehicles/raptor.qc @@ -28,6 +28,8 @@ float autocvar_g_vehicle_raptor_guns_turnlimit; float autocvar_g_vehicle_raptor_guns_pitchlimit_up; float autocvar_g_vehicle_raptor_guns_pitchlimit_down; +float autocvar_g_vehicle_raptor_cannon_locktarget; +float autocvar_g_vehicle_raptor_cannon_predicttarget; float autocvar_g_vehicle_raptor_cannon_cost; float autocvar_g_vehicle_raptor_cannon_damage; float autocvar_g_vehicle_raptor_cannon_radius; @@ -374,10 +376,82 @@ float raptor_frame() // Aim the gunz crosshair_trace(player); + vector vf, ad; + if(autocvar_g_vehicle_raptor_cannon_locktarget) + { + if(trace_ent) + { + if(raptor.gun2.enemy != world) + { + if(raptor.gun2.enemy == trace_ent) + raptor.gun2.cnt += 1; + else + raptor.gun2.cnt -= 1; + } + + raptor.gun2.enemy = trace_ent; + + if(raptor.gun2.cnt < 0) + { + raptor.gun2.enemy = world; + raptor.gun2.cnt = 0; + } + + if(raptor.gun2.cnt > 50) + { + raptor.gun2.enemy = world; + raptor.gun2.cnt = 0; + + raptor.gun1.enemy = trace_ent; + raptor.gun1.cnt = time + 1; + } + + // Allready have a lock? + if(raptor.gun1.enemy != world) + { + // Add 0.5 secs of tracking for each trace hit + if(trace_ent == raptor.gun1.enemy) + raptor.gun1.cnt = min(raptor.gun1.cnt + 0.25, time + 5); + + if(raptor.gun1.cnt < time) + raptor.gun1.enemy = world; + } + } + else + raptor.gun2.cnt = max(raptor.gun2.cnt - 1, 0); + + if(raptor.gun1.cnt - time < 0) + raptor.gun1.enemy = world; + + if(autocvar_g_vehicle_raptor_cannon_predicttarget) + { + vector o; + if(raptor.gun1.enemy != world) + { + float i, distance, impact_time; + + vf = real_origin(raptor.gun1.enemy); + ad = vf; + o = raptor.origin; + for(i = 0; i < 4; ++i) + { + + distance = vlen(ad - o); + impact_time = distance / autocvar_g_vehicle_raptor_cannon_speed; + ad = vf + raptor.gun1.enemy.velocity * impact_time; + o = raptor.origin + raptor.velocity * impact_time; + } + trace_endpos = ad; + + } + } + else + trace_endpos = real_origin(raptor.gun1.enemy); + } + ftmp2 = autocvar_g_vehicle_raptor_guns_turnspeed * frametime; ftmp = -ftmp2; - vector vf, ad; // Gun1 df = gettaginfo(raptor.gun1, gettagindex(raptor.gun1, "fire1")); ad += df; @@ -405,11 +479,31 @@ float raptor_frame() raptor.gun2.angles_y = bound(-autocvar_g_vehicle_raptor_guns_turnlimit, df_y + raptor.gun2.angles_y, autocvar_g_vehicle_raptor_guns_turnlimit); - ad = ad * 0.5; - v_forward = vf * 0.5; - traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, raptor); - SpawnOrUpdateAuxiliaryXhair(player, trace_endpos); + if(autocvar_g_vehicle_raptor_cannon_locktarget) + { + if(raptor.gun1.enemy) + { + SpawnOrUpdateAuxiliaryXhair(player, trace_endpos, '1 0 0'); + } + else + { + ad = ad * 0.5; + v_forward = vf * 0.5; + traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, raptor); + + if(raptor.gun2.enemy != world) + { + ftmp = raptor.gun2.cnt / 50; + SpawnOrUpdateAuxiliaryXhair(player, trace_endpos, '1 0 0' * ftmp + '1 1 1' * (1 - ftmp)); + } + else + SpawnOrUpdateAuxiliaryXhair(player, trace_endpos, '1 1 1'); + + } + } + else + SpawnOrUpdateAuxiliaryXhair(player, trace_endpos, '1 1 1'); if(player.BUTTON_ATCK) if(raptor.attack_finished_single <= time) diff --git a/qcsrc/server/vehicles/spiderbot.qc b/qcsrc/server/vehicles/spiderbot.qc index a160c5c04..b8f8279b1 100644 --- a/qcsrc/server/vehicles/spiderbot.qc +++ b/qcsrc/server/vehicles/spiderbot.qc @@ -475,7 +475,7 @@ float spiderbot_frame() v_forward = vf * 0.5; traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, spider); - SpawnOrUpdateAuxiliaryXhair(player, trace_endpos); + SpawnOrUpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload1) + ('0 1 0' * (1 - player.vehicle_reload1))); self = player; return 1; diff --git a/qcsrc/server/vehicles/vehicles.qc b/qcsrc/server/vehicles/vehicles.qc index 008e8a0ff..0e73e9fea 100644 --- a/qcsrc/server/vehicles/vehicles.qc +++ b/qcsrc/server/vehicles/vehicles.qc @@ -16,23 +16,26 @@ float AuxiliaryXhair_SendEntity(entity to, float sf) WriteCoord(MSG_ENTITY, self.origin_x); WriteCoord(MSG_ENTITY, self.origin_y); WriteCoord(MSG_ENTITY, self.origin_z); + + WriteByte(MSG_ENTITY, rint(self.colormod_x * 255)); + WriteByte(MSG_ENTITY, rint(self.colormod_y * 255)); + WriteByte(MSG_ENTITY, rint(self.colormod_z * 255)); + return TRUE; } -void SpawnOrUpdateAuxiliaryXhair(entity own, vector loc) +void SpawnOrUpdateAuxiliaryXhair(entity own, vector loc, vector clr) { if(own.AuxiliaryXhair == world || wasfreed(own.AuxiliaryXhair)) { own.AuxiliaryXhair = spawn(); own.AuxiliaryXhair.owner = own; - //own.AuxiliaryXhair.customizeentityforclient = AuxiliaryXhair_customizeentityforclient; own.AuxiliaryXhair.drawonlytoclient = own; - setorigin(own.AuxiliaryXhair, loc); Net_LinkEntity(own.AuxiliaryXhair, FALSE, 0, AuxiliaryXhair_SendEntity); - return; } + own.AuxiliaryXhair.colormod = clr; setorigin(own.AuxiliaryXhair, loc); own.AuxiliaryXhair.SendFlags |= 0x01; } @@ -40,7 +43,7 @@ void SpawnOrUpdateAuxiliaryXhair(entity own, vector loc) void Release_AuxiliaryXhair(entity from) { // from.AuxiliaryXhair.drawonlytoclient = from.AuxiliaryXhair; - if not (from.AuxiliaryXhair == world || wasfreed(from.AuxiliaryXhair)) + if (from.AuxiliaryXhair != world && !wasfreed(from.AuxiliaryXhair)) remove(from.AuxiliaryXhair); from.AuxiliaryXhair = world; diff --git a/vehicle_raptor.cfg b/vehicle_raptor.cfg index 9def388d5..1c4ccdc59 100644 --- a/vehicle_raptor.cfg +++ b/vehicle_raptor.cfg @@ -30,7 +30,9 @@ set g_vehicle_raptor_guns_turnlimit 10 set g_vehicle_raptor_guns_pitchlimit_up 8 set g_vehicle_raptor_guns_pitchlimit_down 32 -set g_vehicle_raptor_cannon_cost 1 +set g_vehicle_raptor_cannon_locktarget 1 +set g_vehicle_raptor_cannon_predicttarget 1 +g_vehicle_raptor_cannon_cost 1 set g_vehicle_raptor_cannon_damage 10 set g_vehicle_raptor_cannon_radius 25 set g_vehicle_raptor_cannon_refire 0.1