]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Create spawn event entity handler, more work on spawning effects
authorSamual Lenks <samual@xonotic.org>
Mon, 13 May 2013 23:19:02 +0000 (19:19 -0400)
committerSamual Lenks <samual@xonotic.org>
Mon, 13 May 2013 23:19:02 +0000 (19:19 -0400)
qcsrc/client/Main.qc
qcsrc/common/constants.qh
qcsrc/server/cl_client.qc
qcsrc/server/spawnpoints.qc

index 78aa98f8ee4b1493bcc43cf65ebc444fcae4f8b9..e480d0ef132cda38ee8ec42c2499fae3369cc94b 100644 (file)
@@ -695,45 +695,88 @@ void Ent_ReadAccuracy(void)
                        f *= 2;
        }
 }
-.float last_spawn_time;
+
 void Spawn_Draw(void)
 {
-       pointparticles(particleeffectnum("EF_STARDUST"), self.origin, '0 0 2', bound(0, frametime, 0.1));
+       pointparticles(self.cnt, self.origin, '0 0 2', bound(0, frametime, 0.1));
 }
 
-void Ent_ReadSpawnPoint(float is_new)
+void Ent_ReadSpawnPoint(float is_new) // entity for spawnpoint
 {
-       float sendflag = ReadByte();
+       float teamnum = ReadByte();
+       self.origin_x = ReadShort();
+       self.origin_y = ReadShort();
+       self.origin_z = ReadShort();
+
+       if(is_new)
+       {
+               switch(teamnum)
+               {
+                       default: self.cnt = particleeffectnum("EF_STARDUST"); break;
+               }
+               
+               //self.colormod = '200 0 0'; //colormapPaletteColor(teamnum - 1, FALSE);
+
+               //setsize(self, PL_MIN, PL_MAX);
+
+               //droptofloor();
+
+               //self.mdl = "models/domination/dom_unclaimed.md3";
+               //precache_model(self.mdl);
+               //setmodel(self, self.mdl);
+               self.drawmask = MASK_NORMAL;
+               self.movetype = MOVETYPE_NOCLIP;
+               self.draw = Spawn_Draw;
+               
+       }
+
+       print(sprintf("Ent_ReadSpawnPoint(is_new = %d); origin = %s, team = %d (%s)\n", is_new, vtos(self.origin), teamnum, "foobar"));
+}
 
-       if(sendflag & 1)
+void Ent_ReadSpawnEvent(float is_new)
+{
+       // If entnum is 0, ONLY do the local spawn actions
+       // this way the server can disable the sending of
+       // spawn origin or such to clients if wanted.
+       float entnum = ReadByte();
+       
+       if(entnum)
        {
-               self.team = ReadByte();
                self.origin_x = ReadShort();
                self.origin_y = ReadShort();
                self.origin_z = ReadShort();
+
+               if(is_new)
+               {
+                       float teamnum = GetPlayerColor(entnum - 1);
+                       //if(autocvar_cl_spawn_event_sound)
+                       {
+                               sound(self, CH_TRIGGER, "misc/spawn.wav", VOL_BASE, ATTN_NORM);
+                       }
+                       //if(autocvar_cl_spawn_event_particles)
+                       {
+                               switch(teamnum)
+                               {
+                                       default: pointparticles(particleeffectnum("red_cap"), self.origin, '0 0 0', 1); break;
+                               }
+                       }
+               }
        }
-       if(sendflag & 2)
+       
+       // local spawn actions
+       if(is_new && (!entnum || (entnum == player_localentnum)))
        {
-               self.last_spawn_time = ReadLong();
-       }
+               zoomin_effect = 1;
+               current_viewzoom = (1 / bound(1, autocvar_cl_spawnzoom_factor, 16));
 
-       if(self.last_spawn_time) { pointparticles(particleeffectnum("fireball_muzzleflash"), self.origin, '0 0 2', 1); self.last_spawn_time = 0; }
+               if(autocvar_cl_unpress_zoom_on_spawn)
+               {
+                       localcmd("-zoom\n");
+                       button_zoom = FALSE;
+               }
+       }
        
-
-       self.colormod = '200 0 0'; //colormapPaletteColor(self.team - 1, FALSE);
-
-       //setsize(self, PL_MIN, PL_MAX);
-
-       //droptofloor();
-
-       //self.mdl = "models/domination/dom_unclaimed.md3";
-       //precache_model(self.mdl);
-       //setmodel(self, self.mdl);
-       self.drawmask = MASK_NORMAL;
-       self.movetype = MOVETYPE_NOCLIP;
-       self.draw = Spawn_Draw;
-
-       print(sprintf("Ent_ReadSpawnPoint(is_new = %d); origin = %s, team = %d (%s)\n", is_new, vtos(self.origin), self.team, "foobar"));
+       print(sprintf("Ent_ReadSpawnEvent(is_new = %d); origin = %s, entnum = %d (%s), localentnum = %d\n", is_new, vtos(self.origin), entnum, player_localentnum, "foobar"));
 }
 
 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
@@ -822,6 +865,7 @@ void CSQC_Ent_Update(float bIsNewEntity)
                case ENT_CLIENT_ITEM: ItemRead(bIsNewEntity); break;  
                case ENT_CLIENT_BUMBLE_RAYGUN: bumble_raygun_read(bIsNewEntity); break;
                case ENT_CLIENT_SPAWNPOINT: Ent_ReadSpawnPoint(bIsNewEntity); break;
+               case ENT_CLIENT_SPAWNEVENT: Ent_ReadSpawnEvent(bIsNewEntity); break;
                case ENT_CLIENT_NOTIFICATION: Read_Notification(bIsNewEntity); break;
 
                default:
@@ -1143,18 +1187,6 @@ void Net_ReadRace()
        }
 }
 
-void Net_ReadSpawn()
-{
-       zoomin_effect = 1;
-       current_viewzoom = (1 / bound(1, autocvar_cl_spawnzoom_factor, 16));
-
-       if(autocvar_cl_unpress_zoom_on_spawn)
-       {
-               localcmd("-zoom\n");
-               button_zoom = FALSE;
-       }
-}
-
 void Net_TeamNagger()
 {
        teamnagger = 1;
@@ -1224,10 +1256,6 @@ float CSQC_Parse_TempEntity()
                        Net_ReadRace();
                        bHandled = true;
                        break;
-               case TE_CSQC_SPAWN:
-                       Net_ReadSpawn();
-                       bHandled = true;
-                       break;
                case TE_CSQC_ZCURVEPARTICLES:
                        Net_ReadZCurveParticles();
                        bHandled = true;
index 1aa635b455c3bd4395c49b9c7d66611ebf332a33..b399f3857c3454e3c16572d0aed19a7aea627801 100644 (file)
@@ -30,19 +30,18 @@ const float AS_FLOAT                = 8;
 
 const float TE_CSQC_PICTURE = 100;
 const float TE_CSQC_RACE = 101;
-const float TE_CSQC_SPAWN = 102;
-const float TE_CSQC_ZCURVEPARTICLES = 103;
-const float TE_CSQC_NEXGUNBEAMPARTICLE = 104;
-const float TE_CSQC_LIGHTNINGARC = 105;
-const float TE_CSQC_TEAMNAGGER = 106;
-const float TE_CSQC_PINGPLREPORT = 107;
-const float TE_CSQC_TARGET_MUSIC = 108;
-const float TE_CSQC_WEAPONCOMPLAIN = 109;
-const float TE_CSQC_NEX_SCOPE = 110;
-const float TE_CSQC_MINELAYER_MAXMINES = 111;
-const float TE_CSQC_HAGAR_MAXROCKETS = 112;
-const float TE_CSQC_VEHICLESETUP = 113;
-const float TE_CSQC_SVNOTICE = 114;
+const float TE_CSQC_ZCURVEPARTICLES = 102;
+const float TE_CSQC_NEXGUNBEAMPARTICLE = 103;
+const float TE_CSQC_LIGHTNINGARC = 104;
+const float TE_CSQC_TEAMNAGGER = 105;
+const float TE_CSQC_PINGPLREPORT = 106;
+const float TE_CSQC_TARGET_MUSIC = 107;
+const float TE_CSQC_WEAPONCOMPLAIN = 108;
+const float TE_CSQC_NEX_SCOPE = 109;
+const float TE_CSQC_MINELAYER_MAXMINES = 110;
+const float TE_CSQC_HAGAR_MAXROCKETS = 111;
+const float TE_CSQC_VEHICLESETUP = 112;
+const float TE_CSQC_SVNOTICE = 113;
 
 const float RACE_NET_CHECKPOINT_HIT_QUALIFYING = 0; // byte checkpoint, short time, short recordtime, string recordholder
 const float RACE_NET_CHECKPOINT_CLEAR = 1;
@@ -96,7 +95,8 @@ const float ENT_CLIENT_MODEL = 33;
 const float ENT_CLIENT_ITEM = 34;
 const float ENT_CLIENT_BUMBLE_RAYGUN = 35;
 const float ENT_CLIENT_SPAWNPOINT = 36;
-const float ENT_CLIENT_NOTIFICATION = 37;
+const float ENT_CLIENT_SPAWNEVENT = 37;
+const float ENT_CLIENT_NOTIFICATION = 38;
 
 const float ENT_CLIENT_TURRET = 40;
 const float ENT_CLIENT_AUXILIARYXHAIR = 50;
index 1912d83b56c2de458a8929ffa71acadf221fd58c..82428596d4c253ef192ccac899d7883b07b9cbf7 100644 (file)
@@ -354,7 +354,7 @@ PutClientInServer
 Called when a client spawns in the server
 =============
 */
-
+float SpawnEvent_Send(entity to, float sf);
 void PutClientInServer (void)
 {
        if(IS_BOT_CLIENT(self))
@@ -510,11 +510,9 @@ void PutClientInServer (void)
                self.oldvelocity = self.velocity;
                self.fire_endtime = -1;
 
-               msg_entity = self;
-               WRITESPECTATABLE_MSG_ONE({
-                       WriteByte(MSG_ONE, SVC_TEMPENTITY);
-                       WriteByte(MSG_ONE, TE_CSQC_SPAWN);
-               });
+               entity spawnevent = spawn();
+               spawnevent.owner = self;
+               Net_LinkEntity(spawnevent, FALSE, 1, SpawnEvent_Send);
 
                self.model = "";
                FixPlayermodel();
@@ -601,10 +599,9 @@ void PutClientInServer (void)
                                self.alivetime = time;
 
                antilag_clear(self);
-
-               if (autocvar_g_spawnsound)
-                       soundat(world, self.origin, CH_TRIGGER, "misc/spawn.wav", VOL_BASE, ATTN_NORM);
-       } else if(IS_OBSERVER(self)) {
+       }
+       else if(IS_OBSERVER(self))
+       {
                PutObserverInServer ();
        }
 }
index b84185e52eae3e6ed7b19b59a60352ea2616dc77..bf1a49a9ff9a2aec6632dfba6d6871ee5fb1398c 100644 (file)
@@ -1,39 +1,37 @@
-
-.float last_spawn_time;
-.float send_spawn;
-float Spawn_Send(entity to, float sf)
+float SpawnPoint_Send(entity to, float sf)
 {
        WriteByte(MSG_ENTITY, ENT_CLIENT_SPAWNPOINT);
-       WriteByte(MSG_ENTITY, sf);
-       
-       if(sf & 1)
-       {
-               WriteByte(MSG_ENTITY, self.team);
-               WriteShort(MSG_ENTITY, self.origin_x);
-               WriteShort(MSG_ENTITY, self.origin_y);
-               WriteShort(MSG_ENTITY, self.origin_z);
-       }
-       if(sf & 2)
-       {
-               WriteLong(MSG_ENTITY, self.last_spawn_time);
-       }
-       
+
+       WriteByte(MSG_ENTITY, self.team);
+       WriteShort(MSG_ENTITY, self.origin_x);
+       WriteShort(MSG_ENTITY, self.origin_y);
+       WriteShort(MSG_ENTITY, self.origin_z);
+
        return TRUE;
 }
 
-void Spawn_Think(void)
+float SpawnEvent_Send(entity to, float sf)
 {
-       if(self.send_spawn < 0)
+       float send;
+       
+       WriteByte(MSG_ENTITY, ENT_CLIENT_SPAWNEVENT);
+
+       if(autocvar_g_spawnsound)
        {
-               self.send_spawn = 0;
-               self.SendFlags |= 1;
+               WriteByte(MSG_ENTITY, num_for_edict(self.owner));
+               WriteShort(MSG_ENTITY, self.owner.origin_x);
+               WriteShort(MSG_ENTITY, self.owner.origin_y);
+               WriteShort(MSG_ENTITY, self.owner.origin_z);
+               send = TRUE;
        }
-       else
+       else if((to == self.owner) || (IS_SPEC(to) && (to.enemy == self.owner)) )
        {
-               self.last_spawn_time = self.send_spawn;
-               self.send_spawn = 0;
-               self.SendFlags |= 2;
+               WriteByte(MSG_ENTITY, 0);
+               send = TRUE;
        }
+       else { send = FALSE; }
+
+       return send;
 }
 
 void spawnpoint_use()
@@ -45,8 +43,6 @@ void spawnpoint_use()
                some_spawn_has_been_used = 1;
        }
        print("spawnpoint was used!\n");
-       self.send_spawn = time;
-       self.nextthink = time;
 }
 
 void relocate_spawnpoint()
@@ -104,11 +100,11 @@ void relocate_spawnpoint()
         e.solid = SOLID_TRIGGER;
     }
 
-       self.send_spawn = -1;
-       self.think = Spawn_Think;
-       self.nextthink = time;
+       //self.send_spawn = -1;
+       //self.think = Spawn_Think;
+       //self.nextthink = time;
 
-    Net_LinkEntity(self, FALSE, 0, Spawn_Send);
+    Net_LinkEntity(self, FALSE, 0, SpawnPoint_Send);
 }
 
 void spawnfunc_info_player_survivor (void)
@@ -147,7 +143,7 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck)
                if(spot.target == "")
                        return '-1 0 0';
 
-       if(clienttype(self) == CLIENTTYPE_REAL)
+       if(IS_REAL_CLIENT(self))
        {
                if(spot.restriction == 1)
                        return '-1 0 0';