From: Jakob MG Date: Tue, 10 Jul 2012 08:19:48 +0000 (+0200) Subject: Some preparations to enable bot's to use vehicles X-Git-Tag: xonotic-v0.7.0~111^2^2~3 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=15383f84978fe9908bebda277b88c00e2675acc3;p=xonotic%2Fxonotic-data.pk3dir.git Some preparations to enable bot's to use vehicles --- diff --git a/qcsrc/server/vehicles/spiderbot.qc b/qcsrc/server/vehicles/spiderbot.qc index 42bd7902b..7795fe324 100644 --- a/qcsrc/server/vehicles/spiderbot.qc +++ b/qcsrc/server/vehicles/spiderbot.qc @@ -307,6 +307,11 @@ void spiderbot_rocket_do() self.gun2.cnt = time + self.attack_finished_single; } +float spiderbot_aiframe() +{ + +} + float spiderbot_frame() { vector ad, vf; @@ -325,11 +330,6 @@ float spiderbot_frame() player.BUTTON_ZOOM = 0; player.BUTTON_CROUCH = 0; player.switchweapon = 0; - - if(player.impulse == 12) - { - dprint("WOOOOOOOOOOOtotototototOOOOOOOOOOOOttt\n"); - } #if 1 // 0 to enable per-gun impact aux crosshairs diff --git a/qcsrc/server/vehicles/vehicles.qc b/qcsrc/server/vehicles/vehicles.qc index 2f6a191bf..534b6d45f 100644 --- a/qcsrc/server/vehicles/vehicles.qc +++ b/qcsrc/server/vehicles/vehicles.qc @@ -45,6 +45,9 @@ float SendAuxiliaryXhair(entity to, float sf) void UpdateAuxiliaryXhair(entity own, vector loc, vector clr, float axh_id) { + if (clienttype(own) != CLIENTTYPE_REAL) + return; + entity axh; axh_id = bound(0, axh_id, MAX_AXH); @@ -97,6 +100,9 @@ void SendAuxiliaryXhair2(entity own, vector loc, vector clr, float axh_id) **/ void CSQCVehicleSetup(entity own, float vehicle_id) { + if (clienttype(own) != CLIENTTYPE_REAL) + return; + msg_entity = own; WriteByte(MSG_ONE, SVC_TEMPENTITY); @@ -554,18 +560,18 @@ void vehicles_touch() if(other.vehicle != world) return; - // Remove this when bots know how to use vehicles. - if (clienttype(other) != CLIENTTYPE_REAL) - return; - vehicles_enter(); } - +float autocvar_g_vehicles_allow_bots = 0; void vehicles_enter() { // Remove this when bots know how to use vehicles - if (clienttype(other) != CLIENTTYPE_REAL) - return; + + if (clienttype(other) == CLIENTTYPE_BOT) + if (autocvar_g_vehicles_allow_bots) + dprint("Bot enters vehicle\n"); // This is where we need to disconnect (some, all?) normal bot AI and hand over to vehicle's _aiframe() + else + return; if(self.phase > time) return; @@ -622,23 +628,26 @@ void vehicles_enter() self.team = self.owner.team; self.flags -= FL_NOTARGET; - - msg_entity = other; - WriteByte (MSG_ONE, SVC_SETVIEWPORT); - WriteEntity(MSG_ONE, self.vehicle_viewport); - - WriteByte (MSG_ONE, SVC_SETVIEWANGLES); - if(self.tur_head) - { - WriteAngle(MSG_ONE, self.tur_head.angles_x + self.angles_x); // tilt - WriteAngle(MSG_ONE, self.tur_head.angles_y + self.angles_y); // yaw - WriteAngle(MSG_ONE, 0); // roll - } - else + + if (clienttype(other) == CLIENTTYPE_REAL) { - WriteAngle(MSG_ONE, self.angles_x * -1); // tilt - WriteAngle(MSG_ONE, self.angles_y); // yaw - WriteAngle(MSG_ONE, 0); // roll + msg_entity = other; + WriteByte (MSG_ONE, SVC_SETVIEWPORT); + WriteEntity(MSG_ONE, self.vehicle_viewport); + + WriteByte (MSG_ONE, SVC_SETVIEWANGLES); + if(self.tur_head) + { + WriteAngle(MSG_ONE, self.tur_head.angles_x + self.angles_x); // tilt + WriteAngle(MSG_ONE, self.tur_head.angles_y + self.angles_y); // yaw + WriteAngle(MSG_ONE, 0); // roll + } + else + { + WriteAngle(MSG_ONE, self.angles_x * -1); // tilt + WriteAngle(MSG_ONE, self.angles_y); // yaw + WriteAngle(MSG_ONE, 0); // roll + } } vehicles_clearrturn(); @@ -731,15 +740,18 @@ void vehicles_exit(float eject) if (self.owner) { - msg_entity = self.owner; - WriteByte (MSG_ONE, SVC_SETVIEWPORT); - WriteEntity( MSG_ONE, self.owner); - - WriteByte (MSG_ONE, SVC_SETVIEWANGLES); - WriteAngle(MSG_ONE, 0); // pich - WriteAngle(MSG_ONE, self.angles_y); // yaw - WriteAngle(MSG_ONE, 0); // roll - + if (clienttype(self.owner) == CLIENTTYPE_REAL) + { + msg_entity = self.owner; + WriteByte (MSG_ONE, SVC_SETVIEWPORT); + WriteEntity( MSG_ONE, self.owner); + + WriteByte (MSG_ONE, SVC_SETVIEWANGLES); + WriteAngle(MSG_ONE, 0); // pich + WriteAngle(MSG_ONE, self.angles_y); // yaw + WriteAngle(MSG_ONE, 0); // roll + } + setsize(self.owner, PL_MIN,PL_MAX); self.owner.takedamage = DAMAGE_AIM; @@ -755,6 +767,13 @@ void vehicles_exit(float eject) self.owner.switchweapon = self.switchweapon; //self.owner.BUTTON_USE = 0; + if(self.owner.flagcarried) + { + self.owner.flagcarried.scale = 0.6; + setattachment(self.owner.flagcarried, self.owner, ""); + setorigin(self.owner.flagcarried, FLAG_CARRY_POS); + } + CSQCVehicleSetup(self.owner, HUD_NORMAL); } @@ -772,12 +791,6 @@ void vehicles_exit(float eject) else self.team = self.tur_head.team; - if(self.owner.flagcarried) - { - self.owner.flagcarried.scale = 0.6; - setattachment(self.owner.flagcarried, self.owner, ""); - setorigin(self.owner.flagcarried, FLAG_CARRY_POS); - } sound (self, CH_TRIGGER_SINGLE, "misc/null.wav", 1, ATTN_NORM); self.vehicle_exit(eject);