11-24-2012, 07:29 AM 
	
	
	
	
		hi folks
is it possible to implement a spawnshield mode in Xonotic like the TTS mode in Nexuiz ...
The TTS mode was created by Fish
The code was nearly:
It is very useful in duel matches
When a player connect match the games starts on 0:0 and spawnfrags dosn.t count ...
okidoki - what you all think about ?
GreetZ Su
	
	
is it possible to implement a spawnshield mode in Xonotic like the TTS mode in Nexuiz ...

The TTS mode was created by Fish
The code was nearly:
Code:
Index: data/qcsrc/server/g_damage.qc
===================================================================
--- data/qcsrc/server/g_damage.qc    (revision 8003)
+++ data/qcsrc/server/g_damage.qc    (working copy)
@@ -370,12 +370,38 @@
                     }
                 }
 
+                ///MODIFICATION///
+                local float fragsup, spawnfrag;
+                fragsup = 1;
+                spawnfrag = FALSE;
+                if (tts_spawnshield_mode != 0)
+                    if(time < targ.tts_spawnshieldfinished || (tts_spawnshield_mode == 2 && time < attacker.tts_spawnshieldfinished)) {    
+                        fragsup = 0;
+                        spawnfrag = TRUE;
+                    }
+                if (targ.classname=="corpse") 
+                    fragsup = 0;
+
+                local string typefragremark;
+                local string spawnfragremark;
+                
+                if (targ.buttonchat) typefragremark = "^7type";
+                else typefragremark = "";
+                if (spawnfrag) spawnfragremark = "^2spawn";
+                else spawnfragremark = "";
+
+
                 if(sv_gentle > 0) {
-                    centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s));
+                    centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, blood_message, "^4You scored against ^7", s));
                     centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, a,"^1 scored against you ^7"));
                 } else {
-                    centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, blood_message, "^4You fragged ^7", s));
-                    centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, victim_message, "^1You were fragged by ^7", a));
+                    if((cvar("sv_fragmessage_information_typefrag")) && (targ.BUTTON_CHAT)) {
+                        centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, blood_message, "^4You ^1typefragged ^7", s));
+                        centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, victim_message, "^1You were typefragged by ^7", a));
+                    } else { 
+                        centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, blood_message, "^4You ",spawnfragremark, typefragremark,"^4fragged ^7", s));
+                                                centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, victim_message, "^1You were ",spawnfragremark, typefragremark, "^1fragged by ^7", a));
+                    }
                     attacker.taunt_soundtime = time + 1;
                 }
 
@@ -435,7 +461,7 @@
                     GiveFrags(attacker, targ, 0); // for logging
                 }
                 else
-                    GiveFrags(attacker, targ, 1);
+                    GiveFrags(attacker, targ, fragsup);
 
                 if (targ.killcount > 2) {
                     if(sv_gentle)
@@ -713,6 +739,12 @@
                 self = oldself;
                 return;
             }
+
+            ///MODIFICATION///
+            if ((deathtype == WEP_MINSTANEX) && damage) {
+                attacker.tts_hits ++;
+            }
+
             if (targ.armorvalue && (deathtype == WEP_MINSTANEX) && damage)
             {
                 targ.armorvalue -= 1;
Index: data/qcsrc/server/defs.qh
===================================================================
--- data/qcsrc/server/defs.qh    (revision 8003)
+++ data/qcsrc/server/defs.qh    (working copy)
@@ -623,3 +623,15 @@
 
 .entity clientdata;
 .entity personal;
+
+
+///MODIFICATION///
+.float tts_powerups_invis_fire_recoverfinished;
+.float tts_powerups_invis_fire_recoverduration;
+.float tts_powerups_invis_started;
+.float tts_spawnshieldfinished;
+.float tts_powerups_invis_nextflicker;
+.float tts_hits;
+.float tts_shotsfired;
+float tts_lockedgame;
+float tts_gamefrozen;
Index: data/qcsrc/server/w_minstanex.qc
===================================================================
--- data/qcsrc/server/w_minstanex.qc    (revision 8003)
+++ data/qcsrc/server/w_minstanex.qc    (working copy)
@@ -179,10 +179,27 @@
     {
         if (self.BUTTON_ATCK)
         {
-            if (weapon_prepareattack(0, cvar("g_balance_minstanex_refire")))
+            ///MODIFICATION///
+            local float refire_factor;
+            refire_factor = 1.0;
+            
+            local float actual_refire;
+            actual_refire = cvar("g_balance_minstanex_refire") * refire_factor;
+
+            if (tts_spawnshield_mode == 1 && time < self.tts_spawnshieldfinished)
+                self.tts_spawnshieldfinished = time;
+
+            if (weapon_prepareattack(0, actual_refire))
             {
                 W_MinstaNex_Attack();
                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_minstanex_animtime"), w_ready);
+                ///MODIFICATION///
+                if(g_minstagib && (self.items & IT_STRENGTH) && tts_powerups_invis_fire_recovertime>0) {
+                    self.tts_powerups_invis_fire_recoverfinished =
+                        time + tts_powerups_invis_fire_recovertime;
+                    self.tts_powerups_invis_fire_recoverduration = tts_powerups_invis_fire_recovertime;
+                }                
+                self.tts_shotsfired ++;
             }
         }
         else if (self.BUTTON_ATCK2)
Index: data/qcsrc/server/miscfunctions.qc
===================================================================
--- data/qcsrc/server/miscfunctions.qc    (revision 8003)
+++ data/qcsrc/server/miscfunctions.qc    (working copy)
@@ -1042,6 +1042,30 @@
 float sv_autotaunt;
 float sv_taunt;
 
+
+
+///MODIFICATION///
+// Not all tts_ cvars have a declarator here, but most do.
+// Some are read on the fly, especially the welcomemessage ones
+float tts_powerups_reuse;
+float tts_powerups_invis_claim;
+float tts_powerups_speed_claim;
+
+float tts_powerups_invis_cloaktime;
+float tts_powerups_invis_fire_recovertime;
+float tts_powerups_invis_fire_alpha;
+float tts_powerups_invis_flicker_average;
+float tts_powerups_invis_flicker_deviation;
+float tts_powerups_invis_flicker_duration;
+
+float tts_spawnshield_time;
+float tts_spawnshield_mode;
+
+float tts_laser_jumpinterval;
+
+
+
+
 void readlevelcvars(void)
 {
     g_bugrigs = cvar("g_bugrigs");
@@ -1168,6 +1192,24 @@
     if not(inWarmupStage)
         game_starttime                 = cvar("g_start_delay");
 
+
+    ///MODIFICATION///
+    tts_powerups_reuse = cvar("tts_powerups_reuse");
+    tts_powerups_invis_claim = cvar("tts_powerups_invis_claim");
+    tts_powerups_speed_claim = cvar("tts_powerups_speed_claim");
+    
+    tts_powerups_invis_cloaktime = cvar("tts_powerups_invis_cloaktime");
+    tts_powerups_invis_fire_recovertime = cvar("tts_powerups_invis_fire_recovertime");
+    tts_powerups_invis_fire_alpha = cvar("tts_powerups_invis_fire_alpha");
+    tts_powerups_invis_flicker_average = cvar("tts_powerups_invis_flicker_average");
+    tts_powerups_invis_flicker_deviation = cvar("tts_powerups_invis_flicker_deviation");
+    tts_powerups_invis_flicker_duration = cvar("tts_powerups_invis_flicker_duration");
+            
+    tts_spawnshield_time = cvar("tts_spawnshield_time");
+    tts_spawnshield_mode = cvar("tts_spawnshield_mode");
+    
+    tts_laser_jumpinterval = cvar("tts_laser_jumpinterval");
+
     readplayerstartcvars();
 }
 
Index: data/qcsrc/server/cl_client.qc
===================================================================
--- data/qcsrc/server/cl_client.qc    (revision 8003)
+++ data/qcsrc/server/cl_client.qc    (working copy)
@@ -660,6 +660,10 @@
     }
     else
         self.frags = FRAGS_SPECTATOR;
+
+    ///MODIFICATION///
+    self.tts_hits = 0;
+    self.tts_shotsfired = 0;
 }
 
 float RestrictSkin(float s)
@@ -671,6 +675,104 @@
     return mod(s, 3);
 }
 
+
+
+///MODIFICATION///
+
+float CountActivePlayers() {
+    local entity pl;
+    local float plcnt;
+    local float countbots;
+    if(cvar("tts_gamecommencing_botsareplayers")) {
+        FOR_EACH_PLAYER(pl) plcnt+=1;
+    } else {
+        FOR_EACH_REALPLAYER(pl) plcnt+=1;
+    }
+    return plcnt;
+}
+
+void GameCommencing_Think() {
+    local float plcnt;
+    local entity pl;
+    local entity oldself;
+    
+    // Count number of players again, as they may have
+    // changed since the entity was created.
+    plcnt = CountActivePlayers();
+    
+    //bprint("^1DEBUG: ^3GameCommencing entity think\n");
+    
+    if(plcnt >= 2) {
+        // Output an info message in the console
+        print("^3Second player joined, starting game.\n");
+        
+        // Respawn each player and reset their score
+        FOR_EACH_PLAYER(pl) {
+            oldself = self;
+            self = pl;
+            if(self.flagcarried)
+                DropFlag(self.flagcarried, world, world);
+            self.frags = 0;
+            //self.deaths = 0;
+            self.killcount = 0;
+            //self.tts_kills = 0;
+            //self.tts_suicides = 0;
+            self.tts_hits = 0;
+            self.tts_shotsfired = 0;
+            PlayerScore_Clear(self);
+            PutClientInServer();
+            self = oldself;
+        }
+        
+        // Respawn all items
+        local entity it;
+        for(it=find(world,classname,"minstagib");it!=world;it=find(it,classname,"minstagib")) {
+            // NOTE: Checking for think is paramount! If think is not set,
+            // but nextthink is changed, the server ABORTS!
+            if(it.think)
+                it.nextthink = time;
+        }
+        
+        // Remove dropped weapons
+        for(it=find(world,classname,"droppedweapon");it!=world;it=find(it,classname,"droppedweapon")) {
+            it.think = RemoveItem;
+            it.nextthink = time;
+        }
+    }
+    
+    // Were no longer needed.
+    remove(self);
+}
+
+// Well, I tried to be as descriptive as possible in the function's name
+// It's supposed to be called on player join. If it counts 2 active players,
+// it respawns all players. (Counter-Strike style "Game Commencing")
+void OnJoinCheckAndRespawn() {
+    if(!cvar("tts_gamecommencing") || !g_minstagib) return;
+    
+    local float plcnt;
+    
+    // Count active players
+    plcnt = CountActivePlayers();
+    
+    //bprint(strcat("^1DEBUG: ^3Player count now ",ftos(plcnt),"\n"));
+    
+    if(plcnt==2) {
+        bcenterprint("^3Game commencing...\n");
+        local entity gamecommencing;
+        
+        // Do not spawn game-commencing entity if one already exists
+        if( (gamecommencing=find(world,classname,"gamecommencing_entity")) == world )
+            gamecommencing = spawn();
+        
+        gamecommencing.owner = world;
+        gamecommencing.classname = "gamecommencing_entity";
+        gamecommencing.think = GameCommencing_Think;
+        gamecommencing.nextthink = time + cvar("tts_gamecommencing_delay");
+    }
+}
+
+
 void FixPlayermodel()
 {
     local string defaultmodel;
@@ -985,12 +1087,22 @@
         for (j = WEP_FIRST; j <= WEP_LAST; ++j)
             weapon_action(j, WR_RESETPLAYER);
 
+        ///MODIFICATION///
+        self.tts_powerups_invis_fire_recoverfinished = -1;
+        if (tts_spawnshield_mode != 0) {
+            self.tts_spawnshieldfinished = time + tts_spawnshield_time;
+        } else {
+            self.tts_spawnshieldfinished = 0;
+        }
+        self.tts_powerups_invis_nextflicker = -1;
+
         oldself = self;
         self = spot;
             activator = oldself;
                 SUB_UseTargets();
             activator = world;
         self = oldself;
+
     } else if(self.classname == "observer") {
         PutObserverInServer ();
     }
@@ -2116,6 +2228,9 @@
                 bprint ("^4", self.netname, "^4 is playing now\n");
             if(!cvar("g_campaign"))
                 centerprint(self,""); // clear MOTD
+            ///MODIFICATION///
+            OnJoinCheckAndRespawn();
+
             return;
         } else {
             stuffcmd(self,"menu_showteamselect\n");It is very useful in duel matches

When a player connect match the games starts on 0:0 and spawnfrags dosn.t count ...
okidoki - what you all think about ?
GreetZ Su


![[Image: banner14.png]](http://i57.servimg.com/u/f57/13/61/00/14/banner14.png)

![[Image: 4XODR.png]](http://i.imgur.com/4XODR.png)
 
	![[Image: 542.png]](http://stats.xonotic.org/static/badges/542.png)
![[Image: 230.jpg]](http://stats.xonotic.org/static/badges/230.jpg)