]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix dropwepons not animating. Fix cl_weapon_stay_ (rename cvars). Initiate autocvars...
authorJakob MG <jakob_mg@hotmail.com>
Tue, 31 Jul 2012 05:14:49 +0000 (07:14 +0200)
committerJakob MG <jakob_mg@hotmail.com>
Tue, 31 Jul 2012 05:14:49 +0000 (07:14 +0200)
qcsrc/server/mutators/gamemode_onslaught.qc
qcsrc/server/t_items.qc

index 87a059d72da4bfee388156001bed4f7ee393fd04..8d4da0f9ff7c575f94733f51976643668c9e2298 100644 (file)
@@ -1,6 +1,6 @@
-float autocvar_g_onslaught_spawn_at_controlpoints = FALSE;\r
-float autocvar_g_onslaught_spawn_at_generator = FALSE;\r
-\r
+float autocvar_g_onslaught_spawn_at_controlpoints = FALSE;
+float autocvar_g_onslaught_spawn_at_generator = FALSE;
+
 void onslaught_generator_updatesprite(entity e);
 void onslaught_controlpoint_updatesprite(entity e);
 void onslaught_link_checkupdate();
@@ -20,9 +20,9 @@ void onslaught_link_checkupdate();
 .float lastcaptured;
 
 .string model1, model2, model3;
-\r
-entity ons_red_generator;\r
-entity ons_blue_generator;\r
+
+entity ons_red_generator;
+entity ons_blue_generator;
 
 void ons_gib_damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector vforce)
 {
@@ -405,29 +405,29 @@ void onslaught_generator_think()
                                        if (e.islinked)
                                                d = d + 1;
                                e = e.chain;
-                       }\r
+                       }
                        
                        if(autocvar_g_campaign && autocvar__campaign_testrun)
                                d = d * self.max_health;
                        else
                                d = d * self.max_health / max(30, 60 * autocvar_timelimit_suddendeath);
-                       \r
+                       
                        Damage(self, self, self, d, DEATH_HURTTRIGGER, self.origin, '0 0 0');
                }
                else if (overtime_msg_time)
-                       overtime_msg_time = 0;\r
-        \r
-        if(!self.isshielded && self.wait < time)\r
-        {\r
-            self.wait = time + 5;\r
-            FOR_EACH_PLAYER(e)\r
-            {\r
-                if(e.team == self.team)\r
-                {\r
-                    centerprint(e, "^1Your generator is NOT shielded!\n^7Re-capture controlpoints to shield it!");\r
-                    soundto(MSG_ONE, e, CHAN_AUTO, "kh/alarm.wav", VOL_BASE, ATTN_NONE);    // FIXME: Uniqe sound?\r
-                }                                  \r
-            }                                              \r
+                       overtime_msg_time = 0;
+        
+        if(!self.isshielded && self.wait < time)
+        {
+            self.wait = time + 5;
+            FOR_EACH_PLAYER(e)
+            {
+                if(e.team == self.team)
+                {
+                    centerprint(e, "^1Your generator is NOT shielded!\n^7Re-capture controlpoints to shield it!");
+                    soundto(MSG_ONE, e, CHAN_AUTO, "kh/alarm.wav", VOL_BASE, ATTN_NONE);    // FIXME: Uniqe sound?
+                }                                  
+            }                                              
         }    
        }
 }
@@ -852,10 +852,10 @@ void onslaught_generator_reset()
        self.nextthink = time + 0.2;
        setmodel(self, "models/onslaught/generator.md3");
        setsize(self, '-52 -52 -14', '52 52 75');
-\r
+
        if (!self.noalign)
         droptofloor();
-\r
+
        WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health);
        WaypointSprite_UpdateHealth(self.sprite, self.health);
 }
@@ -906,13 +906,13 @@ void spawnfunc_onslaught_generator()
        precache_sound("onslaught/electricity_explode.wav");
        if (!self.team)
                objerror("team must be set");
-       \r
-       if(self.team == COLOR_TEAM1)\r
-        ons_red_generator = self;\r
-\r
-       if(self.team == COLOR_TEAM2)\r
-        ons_blue_generator = self;\r
-        \r
+       
+       if(self.team == COLOR_TEAM1)
+        ons_red_generator = self;
+
+       if(self.team == COLOR_TEAM2)
+        ons_blue_generator = self;
+        
        self.team_saved = self.team;
        self.colormap = 1024 + (self.team - 1) * 17;
        self.solid = SOLID_BBOX;
@@ -931,7 +931,7 @@ void spawnfunc_onslaught_generator()
        onslaught_generator_damage_spawn(self);
        // spawn shield model which indicates whether this can be damaged
        self.enemy = spawn();
-       setattachment(self.enemy , self, "");\r
+       setattachment(self.enemy , self, "");
        self.enemy.classname = "onslaught_generator_shield";
        self.enemy.solid = SOLID_NOT;
        self.enemy.movetype = MOVETYPE_NONE;
@@ -952,7 +952,7 @@ void spawnfunc_onslaught_generator()
        waypoint_spawnforitem(self);
 
        onslaught_updatelinks();
-       \r
+       
        self.reset = onslaught_generator_reset;
 }
 
@@ -1331,8 +1331,8 @@ void spawnfunc_onslaught_controlpoint()
        setmodel(self, "models/onslaught/controlpoint_pad.md3");
        //setsize(self, '-32 -32 0', '32 32 8');
        if (!self.noalign)
-        droptofloor();\r
-       \r
+        droptofloor();
+       
        setorigin(self, self.origin);
        self.touch = onslaught_controlpoint_touch;
        self.team = 0;
@@ -1346,11 +1346,11 @@ void spawnfunc_onslaught_controlpoint()
        self.enemy.solid = SOLID_NOT;
        self.enemy.movetype = MOVETYPE_NONE;
        self.enemy.effects = EF_ADDITIVE;
-       setmodel(self.enemy , "models/onslaught/controlpoint_shield.md3");\r
-       \r
+       setmodel(self.enemy , "models/onslaught/controlpoint_shield.md3");
+       
        setattachment(self.enemy , self, "");
        //setsize(e, '-32 -32 0', '32 32 128');
-\r
+
        //setorigin(e, self.origin);
        self.enemy.colormap = self.colormap;
 
@@ -1359,7 +1359,7 @@ void spawnfunc_onslaught_controlpoint()
        WaypointSprite_SpawnFixed(string_null, self.origin + '0 0 128', self, sprite, RADARICON_NONE, '0 0 0');
        WaypointSprite_UpdateRule(self.sprite, COLOR_TEAM2, SPRITERULE_TEAMPLAY);
 
-       onslaught_updatelinks();\r
+       onslaught_updatelinks();
        
        self.reset = onslaught_controlpoint_reset;
 }
@@ -1466,8 +1466,8 @@ void spawnfunc_onslaught_link()
                objerror("target and target2 must be set\n");
        InitializeEntity(self, onslaught_link_delayed, INITPRIO_FINDTARGET);
        Net_LinkEntity(self, FALSE, 0, onslaught_link_send);
-}\r
-\r
+}
+
 MUTATOR_HOOKFUNCTION(ons_BuildMutatorsString)
 {
        ret_string = strcat(ret_string, ":ONS");
@@ -1478,28 +1478,28 @@ MUTATOR_HOOKFUNCTION(ons_BuildMutatorsPrettyString)
 {
        ret_string = strcat(ret_string, ", Onslught");
        return 0;
-}\r
-\r
+}
+
 MUTATOR_HOOKFUNCTION(ons_Spawn_Score)
-{\r
-    \r
-    /*\r
-    float _neer_home = (random() > 0.5 ? TRUE : FALSE);\r
+{
+    
+    /*
+    float _neer_home = (random() > 0.5 ? TRUE : FALSE);
     
        RandomSelection_Init();
-       \r
-       if(self.team == COLOR_TEAM1)\r
-        RandomSelection_Add(ons_red_generator, 0, string_null, 1, 1);\r
-       \r
-       if(self.team == COLOR_TEAM2)\r
-        RandomSelection_Add(ons_blue_generator, 0, string_null, 1, 1);\r
-       \r
-       entity _cp = findchain(classname, "onslaught_controlpoint"):\r
+       
+       if(self.team == COLOR_TEAM1)
+        RandomSelection_Add(ons_red_generator, 0, string_null, 1, 1);
+       
+       if(self.team == COLOR_TEAM2)
+        RandomSelection_Add(ons_blue_generator, 0, string_null, 1, 1);
+       
+       entity _cp = findchain(classname, "onslaught_controlpoint"):
        while _cp;
-       {\r
+       {
            if(_cp.team == self.team)            
-            RandomSelection_Add(_cp, 0, string_null, 1, 1);\r
-               \r
+            RandomSelection_Add(_cp, 0, string_null, 1, 1);
+               
                _cp = _cp.chain;
        }
 
@@ -1510,108 +1510,108 @@ MUTATOR_HOOKFUNCTION(ons_Spawn_Score)
        }
        else if(self.team == spawn_spot.team)
                spawn_score_x += SPAWN_PRIO_NEAR_TEAMMATE_SAMETEAM; // prefer same team, if we can't find a spawn near teammate
-    \r
-    */\r
+    
+    */
     
        return 0;
-}\r
-\r
-MUTATOR_HOOKFUNCTION(ons_PlayerSpawn)\r
-{\r
-    if(!autocvar_g_onslaught_spawn_at_controlpoints)\r
-        return 0;\r
-        \r
-    if(random() < 0.5)  // 50/50 chane to use default spawnsystem.\r
-        return 0;\r
-    \r
-    float _close_to_home = ((random() > 0.5) ? TRUE : FALSE);\r
-    entity _best, _trg_gen;\r
-    float _score, _best_score = MAX_SHOT_DISTANCE;\r
+}
+
+MUTATOR_HOOKFUNCTION(ons_PlayerSpawn)
+{
+    if(!autocvar_g_onslaught_spawn_at_controlpoints)
+        return 0;
+        
+    if(random() < 0.5)  // 50/50 chane to use default spawnsystem.
+        return 0;
+    
+    float _close_to_home = ((random() > 0.5) ? TRUE : FALSE);
+    entity _best, _trg_gen;
+    float _score, _best_score = MAX_SHOT_DISTANCE;
     
-       RandomSelection_Init();\r
-    \r
-       if(self.team == COLOR_TEAM1)\r
-       {\r
-           if(!_close_to_home)\r
-            _trg_gen = ons_blue_generator;\r
-        else    \r
-            _trg_gen  = ons_red_generator;        \r
-       }\r
-       \r
-       if(self.team == COLOR_TEAM2)\r
-       {\r
-           if(_close_to_home)\r
-            _trg_gen = ons_blue_generator;\r
-        else    \r
-            _trg_gen  = ons_red_generator;        \r
-       }\r
-       \r
-       entity _cp = findchain(classname, "onslaught_controlpoint");\r
+       RandomSelection_Init();
+    
+       if(self.team == COLOR_TEAM1)
+       {
+           if(!_close_to_home)
+            _trg_gen = ons_blue_generator;
+        else    
+            _trg_gen  = ons_red_generator;        
+       }
+       
+       if(self.team == COLOR_TEAM2)
+       {
+           if(_close_to_home)
+            _trg_gen = ons_blue_generator;
+        else    
+            _trg_gen  = ons_red_generator;        
+       }
+       
+       entity _cp = findchain(classname, "onslaught_controlpoint");
        while(_cp)
-       {\r
+       {
            if(_cp.team == self.team)            
-        {            \r
-            _score = vlen(_trg_gen.origin - _cp.origin);\r
-            if(_score < _best_score)\r
-            {\r
-                _best = _cp;\r
-                _best_score = _score;            \r
-            }\r
-        }              \r
+        {            
+            _score = vlen(_trg_gen.origin - _cp.origin);
+            if(_score < _best_score)
+            {
+                _best = _cp;
+                _best_score = _score;            
+            }
+        }              
                _cp = _cp.chain;
-       }\r
-       \r
-    vector _loc;        \r
-    float i;    \r
-    if(_best)\r
-    {\r
-        for(i = 0; i < 10; ++i)\r
-        {\r
-            _loc = _best.origin + '0 0 96';\r
-            _loc += ('0 1 0' * random()) * 128; \r
-            tracebox(_loc, PL_MIN, PL_MAX, _loc, MOVE_NORMAL, self);\r
-            if(trace_fraction == 1.0 && !trace_startsolid)\r
-            {\r
-                setorigin(self, _loc);\r
-                self.angles = normalize(_loc - _best.origin) * RAD2DEG;\r
-                return 0;\r
-            }\r
-        }\r
-    }\r
-    else\r
-    {\r
-        if(!autocvar_g_onslaught_spawn_at_generator)\r
-            return 0;\r
-        \r
-        _trg_gen = ((self.team == COLOR_TEAM1) ? ons_red_generator : ons_blue_generator);\r
-        \r
-        for(i = 0; i < 10; ++i)\r
-        {\r
-            _loc = _trg_gen.origin + '0 0 96';\r
-            _loc += ('0 1 0' * random()) * 128; \r
-            tracebox(_loc, PL_MIN, PL_MAX, _loc, MOVE_NORMAL, self);\r
-            if(trace_fraction == 1.0 && !trace_startsolid)\r
-            {\r
-                setorigin(self, _loc);\r
-                self.angles = normalize(_loc - _trg_gen.origin) * RAD2DEG;\r
-                return 0;\r
-            }\r
-        }\r
-    }\r
-    \r
-    return 0;\r
-}\r
-\r
+       }
+       
+    vector _loc;        
+    float i;    
+    if(_best)
+    {
+        for(i = 0; i < 10; ++i)
+        {
+            _loc = _best.origin + '0 0 96';
+            _loc += ('0 1 0' * random()) * 128; 
+            tracebox(_loc, PL_MIN, PL_MAX, _loc, MOVE_NORMAL, self);
+            if(trace_fraction == 1.0 && !trace_startsolid)
+            {
+                setorigin(self, _loc);
+                self.angles = normalize(_loc - _best.origin) * RAD2DEG;
+                return 0;
+            }
+        }
+    }
+    else
+    {
+        if(!autocvar_g_onslaught_spawn_at_generator)
+            return 0;
+        
+        _trg_gen = ((self.team == COLOR_TEAM1) ? ons_red_generator : ons_blue_generator);
+        
+        for(i = 0; i < 10; ++i)
+        {
+            _loc = _trg_gen.origin + '0 0 96';
+            _loc += ('0 1 0' * random()) * 128; 
+            tracebox(_loc, PL_MIN, PL_MAX, _loc, MOVE_NORMAL, self);
+            if(trace_fraction == 1.0 && !trace_startsolid)
+            {
+                setorigin(self, _loc);
+                self.angles = normalize(_loc - _trg_gen.origin) * RAD2DEG;
+                return 0;
+            }
+        }
+    }
+    
+    return 0;
+}
+
 MUTATOR_DEFINITION(gamemode_onslaught)
 {
        //MUTATOR_HOOK(PlayerDies, nexball_BallDrop, CBC_ORDER_ANY);
        //MUTATOR_HOOK(MakePlayerObserver, nexball_BallDrop, CBC_ORDER_ANY);
-       //MUTATOR_HOOK(ClientDisconnect, nexball_BallDrop, CBC_ORDER_ANY);\r
+       //MUTATOR_HOOK(ClientDisconnect, nexball_BallDrop, CBC_ORDER_ANY);
        //MUTATOR_HOOK(PlayerPreThink, nexball_PlayerPreThink, CBC_ORDER_ANY);
        MUTATOR_HOOK(BuildMutatorsPrettyString, ons_BuildMutatorsPrettyString, CBC_ORDER_ANY);
        MUTATOR_HOOK(BuildMutatorsString, ons_BuildMutatorsString, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerSpawn, ons_PlayerSpawn, CBC_ORDER_ANY);
-       //MUTATOR_HOOK(Spawn_Score, ons_Spawn_Score, CBC_ORDER_ANY);\r
+       //MUTATOR_HOOK(Spawn_Score, ons_Spawn_Score, CBC_ORDER_ANY);
        
        MUTATOR_ONADD
        {
index 2e7b9bfbaf11bdf64403edfe663838d465cd2b2b..fe1c8e8059f2d22da1b55cd6fc8fe1f8b1d93779 100644 (file)
     #define ITS_POWERUP   64
 #define ISF_COLORMAP 16
 #define ISF_DROP 32
+#define ISF_ANGLES 64
 
 .float ItemStatus;
 
 #ifdef CSQC
 
-var float  autocvar_cl_ghost_items = 1;
+var float  autocvar_cl_animate_items = 1;
+var float  autocvar_cl_ghost_items = 0.45;
 var vector autocvar_cl_ghost_items_color = '-1 -1 -1';
 float  autocvar_cl_fullbright_items;
-vector autocvar_cl_staywep_color;
-float  autocvar_cl_staywep_alpha;
-float  autocvar_cl_simple_items;
+vector autocvar_cl_weapon_stay_color = '2 0.5 0.5';
+float  autocvar_cl_weapon_stay_alpha = 0.75;
+float  autocvar_cl_simple_items = 1;
 float  cl_simple_items;
 float  cl_ghost_items_alpha;
 
@@ -29,26 +31,50 @@ float  cl_ghost_items_alpha;
 .vector colormod;
 void ItemDraw()
 {    
-    if(self.ItemStatus & ITS_ANIMATE1)
-    {
-        self.angles += '0 180 0' * frametime;
-        setorigin(self, '0 0 10' + self.oldorigin + '0 0 8' * sin(time * 2));        
-    }    
-    
-    if(self.ItemStatus & ITS_ANIMATE2)
-    {
-        self.angles += '0 -90 0' * frametime;
-        setorigin(self, '0 0 8' + self.oldorigin + '0 0 4' * sin(time * 3));        
-    }
-    
     if(self.gravity)
+    {        
         Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
+        if(self.move_flags & FL_ONGROUND) 
+        { // For some reason move_avelocity gets set to '0 0 0' here ...
+            self.oldorigin = self.origin;
+            self.gravity = 0;
+
+            if(autocvar_cl_animate_items)   
+            { // ... so reset it if animations are requested. 
+                if(self.ItemStatus & ITS_ANIMATE1)
+                    self.move_avelocity = '0 180 0';
+                
+                if(self.ItemStatus & ITS_ANIMATE2)
+                    self.move_avelocity = '0 -90 0';
+            }
+        }
+            
+    }
+    else if (autocvar_cl_animate_items)
+    {        
+        if(self.ItemStatus & ITS_ANIMATE1)
+        {
+            self.angles += self.move_avelocity * frametime;
+            setorigin(self, '0 0 10' + self.oldorigin + '0 0 8' * sin(time * 2));        
+        }    
+        
+        if(self.ItemStatus & ITS_ANIMATE2)
+        {
+            self.angles += self.move_avelocity * frametime;
+            setorigin(self, '0 0 8' + self.oldorigin + '0 0 4' * sin(time * 3));        
+        }
+    }
 }
 
 void ItemDrawSimple()
 {
     if(self.gravity)
+    {        
         Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);    
+        
+        if(self.move_flags & FL_ONGROUND)
+            self.gravity = 0;
+    }
 }
 
 float csqcitems_started; // remove this after a release or two
@@ -78,6 +104,14 @@ void ItemRead(float _IsNew)
         self.oldorigin = self.origin;
     }
     
+    if(sf & ISF_ANGLES) 
+    {
+        self.angles_x = ReadCoord();
+        self.angles_y = ReadCoord();
+        self.angles_z = ReadCoord();        
+        self.move_angles = self.angles;
+    }
+    
     if(sf & ISF_STATUS) // need to read/write status frist so model can handle simple, fb etc.
     {
         self.ItemStatus = ReadByte();    
@@ -104,8 +138,8 @@ void ItemRead(float _IsNew)
             
         if(self.ItemStatus & ITS_STAYWEP)
         {
-            self.colormod = self.glowmod = autocvar_cl_staywep_color;
-            self.alpha = autocvar_cl_staywep_alpha;
+            self.colormod = self.glowmod = autocvar_cl_weapon_stay_color;
+            self.alpha = autocvar_cl_weapon_stay_alpha;
             
         }
         
@@ -167,6 +201,7 @@ void ItemRead(float _IsNew)
     if(sf & ISF_DROP)
     {
         self.gravity = 1;
+        self.move_angles = '0 0 0';
         self.move_movetype = MOVETYPE_TOSS;
         self.move_velocity_x = ReadCoord();
         self.move_velocity_y = ReadCoord();
@@ -181,8 +216,18 @@ void ItemRead(float _IsNew)
         }
         else
             self.move_time = max(self.move_time, time);
-    }    
+    }
+        
+    if(autocvar_cl_animate_items)
+    {        
+        if(self.ItemStatus & ITS_ANIMATE1)
+            self.move_avelocity = '0 180 0';
+                
+        if(self.ItemStatus & ITS_ANIMATE2)
+            self.move_avelocity = '0 -90 0';
+    }
 }
+
 #endif
 
 #ifdef SVQC
@@ -197,7 +242,6 @@ float ItemSend(entity to, float sf)
        WriteByte(MSG_ENTITY, ENT_CLIENT_ITEM); 
        WriteByte(MSG_ENTITY, sf);
 
-        
        //WriteByte(MSG_ENTITY, self.cnt);
     if(sf & ISF_LOCATION)
     {
@@ -205,6 +249,13 @@ float ItemSend(entity to, float sf)
         WriteCoord(MSG_ENTITY, self.origin_y);
         WriteCoord(MSG_ENTITY, self.origin_z);
     }
+    
+    if(sf & ISF_ANGLES)
+    {
+        WriteCoord(MSG_ENTITY, self.angles_x);
+        WriteCoord(MSG_ENTITY, self.angles_y);
+        WriteCoord(MSG_ENTITY, self.angles_z);
+    }
 
     if(sf & ISF_STATUS)
         WriteByte(MSG_ENTITY, self.ItemStatus);
@@ -1043,6 +1094,9 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime,
                        remove (self);
                        return;
                }
+               
+               if(self.angles != '0 0 0')
+            self.SendFlags |= ISF_ANGLES;
 
                self.reset = Item_Reset;
                // it's a level item