]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_client.qc
New vehicle system based on weapons system
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_client.qc
index d79c07465a858e5084489a47ef995c8dd3d75638..08a0f027b0ba6c86ef865d89ab5c4ec498c8d8a0 100644 (file)
@@ -170,7 +170,7 @@ void PutObserverInServer (void)
        
        if(self.alivetime)
        {
-               if(!inWarmupStage)
+               if(!warmup_stage)
                        PlayerStats_Event(self, PLAYERSTATS_ALIVETIME, time - self.alivetime);
                self.alivetime = 0;
        }
@@ -297,7 +297,13 @@ void FixPlayermodel()
 
                n = tokenize_console(defaultmodel);
                if(n > 0)
+               {
                        defaultmodel = argv(floor(n * self.model_randomizer));
+                       // However, do NOT randomize if the player-selected model is in the list.
+                       for (i = 0; i < n; ++i)
+                               if ((argv(i) == self.playermodel && defaultskin == stof(self.playerskin)) || argv(i) == strcat(self.playermodel, ":", self.playerskin))
+                                       defaultmodel = argv(i);
+               }
 
                i = strstrofs(defaultmodel, ":", 0);
                if(i >= 0)
@@ -424,7 +430,7 @@ void PutClientInServer (void)
                        self.nex_charge = autocvar_g_balance_nex_charge_start;
                }
 
-               if(inWarmupStage)
+               if(warmup_stage)
                {
                        self.ammo_shells = warmup_start_ammo_shells;
                        self.ammo_nails = warmup_start_ammo_nails;
@@ -433,7 +439,7 @@ void PutClientInServer (void)
                        self.ammo_fuel = warmup_start_ammo_fuel;
                        self.health = warmup_start_health;
                        self.armorvalue = warmup_start_armorvalue;
-                       self.weapons = warmup_start_weapons;
+                       self.weapons = WARMUP_START_WEAPONS;
                }
                else
                {
@@ -593,7 +599,7 @@ void PutClientInServer (void)
                self.weaponname = "";
                self.switchingweapon = 0;
 
-               if(!inWarmupStage)
+               if(!warmup_stage)
                        if(!self.alivetime)
                                self.alivetime = time;
 
@@ -811,7 +817,7 @@ void KillIndicator_Think()
                if(IS_REAL_CLIENT(self.owner))
                {
                        if(self.cnt <= 10)
-                               { Send_Notification(NOTIF_ONE, self.owner, MSG_ANNCE, Announcer_PickNumber(self.cnt)); }
+                               { Send_Notification(NOTIF_ONE, self.owner, MSG_ANNCE, Announcer_PickNumber(CNT_KILL, self.cnt)); }
                }
                self.nextthink = time + 1;
                self.cnt -= 1;
@@ -1604,7 +1610,11 @@ void player_regen (void)
 
                // if player rotted to death...  die!
                if(self.health < 1)
+               {
+                       if(self.vehicle)
+                               vehicles_exit(VHEF_RELESE);
                        self.event_damage(self, self, 1, DEATH_ROT, self.origin, '0 0 0');
+               }
        }
 
        if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
@@ -1910,7 +1920,7 @@ void ShowRespawnCountdown()
                {
                        self.respawn_countdown = number - 1;
                        if(ceil(self.respawn_time - (time + 0.5)) == number) // only say it if it is the same number even in 0.5s; to prevent overlapping sounds
-                               Send_Notification(NOTIF_ONE, self, MSG_ANNCE, Announcer_PickNumber(number)); 
+                               { Send_Notification(NOTIF_ONE, self, MSG_ANNCE, Announcer_PickNumber(CNT_RESPAWN, number)); }
                }
        }
 }
@@ -2039,7 +2049,7 @@ void PrintWelcomeMessage()
        {
                if(self.BUTTON_INFO) // BUTTON_INFO hides initial MOTD
                        self.motd_actived_time = -2; // wait until BUTTON_INFO gets released
-               else if(self.motd_actived_time == -2 || IS_PLAYER(self) || time - self.jointime > autocvar_welcome_message_time)
+               else if(self.motd_actived_time == -2 || IS_PLAYER(self))
                {
                        // instanctly hide MOTD
                        self.motd_actived_time = 0;
@@ -2127,6 +2137,7 @@ void SpectatorThink()
        self.flags |= FL_CLIENT | FL_NOTARGET;
 }
 
+void vehicles_enter (entity pl, entity veh);
 void PlayerUseKey()
 {
        if not(IS_PLAYER(self))
@@ -2137,6 +2148,34 @@ void PlayerUseKey()
         vehicles_exit(VHEF_NORMAL);
         return;
        }
+       else if(autocvar_g_vehicles_enter)
+       {
+               if not(self.freezetag_frozen)
+               if(self.deadflag == DEAD_NO)
+               {
+                       entity head, closest_target = world;
+                       head = WarpZone_FindRadius(self.origin, autocvar_g_vehicles_enter_radius, TRUE);
+                               
+                       while(head) // find the closest acceptable target to enter
+                       {
+                               if(head.vehicle_flags & VHF_ISVEHICLE)
+                               if(head.deadflag == DEAD_NO)
+                               if not(head.owner)
+                               {
+                                       if(closest_target)
+                                       {
+                                               if(vlen(self.origin - head.origin) < vlen(self.origin - closest_target.origin))
+                                               { closest_target = head; }
+                                       }
+                                       else { closest_target = head; }
+                               }
+                               
+                               head = head.chain;
+                       }
+                               
+                       if(closest_target) { vehicles_enter(self, closest_target); return; }
+               }
+       }
        
        // a use key was pressed; call handlers
        MUTATOR_CALLHOOK(PlayerUseKey);
@@ -2152,6 +2191,7 @@ Called every frame for each client before the physics are run
 .float usekeypressed;
 void() nexball_setstatus;
 .float items_added;
+.float last_vehiclecheck;
 void PlayerPreThink (void)
 {
        WarpZone_PlayerPhysics_FixVAngle();
@@ -2230,6 +2270,26 @@ void PlayerPreThink (void)
 #endif
 
        MUTATOR_CALLHOOK(PlayerPreThink);
+       
+       if(autocvar_g_vehicles_enter)
+       if(time > self.last_vehiclecheck)
+       if(IS_PLAYER(self))
+       if not(self.freezetag_frozen)
+       if not(self.vehicle)
+       if(self.deadflag == DEAD_NO)
+       {
+               entity veh;
+               for(veh = world; (veh = findflags(veh, vehicle_flags, VHF_ISVEHICLE)); )
+               if(vlen(veh.origin - self.origin) < autocvar_g_vehicles_enter_radius)
+               if(veh.deadflag == DEAD_NO)
+               if not(veh.owner)
+               if(!veh.team || SAME_TEAM(self, veh))
+                       Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_VEHICLE_ENTER);
+               else if(autocvar_g_vehicles_steal)
+                       Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_VEHICLE_ENTER_STEAL);
+                       
+               self.last_vehiclecheck = time + 1;
+       }
 
        if(!self.cvar_cl_newusekeysupported) // FIXME remove this - it was a stupid idea to begin with, we can JUST use the button
        {
@@ -2541,7 +2601,7 @@ void PlayerPostThink (void)
                        else if(timeleft <= 10)
                        {
                                if(timeleft != self.idlekick_lasttimeleft)
-                                       Send_Notification(NOTIF_ONE, self, MSG_ANNCE, Announcer_PickNumber(timeleft));
+                                       { Send_Notification(NOTIF_ONE, self, MSG_ANNCE, Announcer_PickNumber(CNT_IDLE, timeleft)); }
                                self.idlekick_lasttimeleft = timeleft;
                        }
                }
@@ -2591,7 +2651,7 @@ void PlayerPostThink (void)
        //pointparticles(particleeffectnum("machinegun_impact"), self.origin + self.view_ofs + '0 0 7', '0 0 0', 1);
 
        if(self.waypointsprite_attachedforcarrier)
-               WaypointSprite_UpdateHealth(self.waypointsprite_attachedforcarrier, '1 0 0' * healtharmor_maxdamage(self.health, self.armorvalue, autocvar_g_balance_armor_blockpercent));
+               WaypointSprite_UpdateHealth(self.waypointsprite_attachedforcarrier, '1 0 0' * healtharmor_maxdamage(self.health, self.armorvalue, autocvar_g_balance_armor_blockpercent, DEATH_WEAPON));
 
        playerdemo_write();