Add TE_CSQC_LIGHTNINGARC
authortzork <tzork@f962a42d-fe04-0410-a3ab-8c8b0445ebaa>
Fri, 27 Mar 2009 08:24:26 +0000 (08:24 +0000)
committertzork <tzork@f962a42d-fe04-0410-a3ab-8c8b0445ebaa>
Fri, 27 Mar 2009 08:24:26 +0000 (08:24 +0000)
git-svn-id: svn://svn.icculus.org/nexuiz/trunk@6315 f962a42d-fe04-0410-a3ab-8c8b0445ebaa

data/qcsrc/client/Main.qc
data/qcsrc/client/effects.qc [new file with mode: 0644]
data/qcsrc/client/progs.src
data/qcsrc/common/constants.qh

index 62c34e9..af17e46 100644 (file)
@@ -56,7 +56,7 @@ void CSQC_Init(void)
        }\r
 #pragma target FTE\r
 #endif\r
-       \r
+\r
        float i;\r
        CSQC_CheckEngine();\r
        dprint_load();\r
@@ -114,7 +114,7 @@ void CSQC_Init(void)
 \r
        teams = Sort_Spawn();\r
        players = Sort_Spawn();\r
-       \r
+\r
        GetTeam(COLOR_SPECTATOR, true); // add specs first\r
 \r
        cvar_clientsettemp("_supports_weaponpriority", "1");\r
@@ -292,7 +292,7 @@ float CSQC_ConsoleCommand(string strMessage)
        // Tokenize String\r
        //argc = tokenize(strMessage);\r
        argc = tokenize_sane(strMessage);\r
-       \r
+\r
        // Acquire Command\r
        local string strCmd;\r
        strCmd = argv(0);\r
@@ -498,7 +498,7 @@ void GameCommand(string msg)
        {\r
                print("Invalid command. For a list of supported commands, try cl_cmd help.\n");\r
        }\r
-       \r
+\r
        return;\r
 }\r
 \r
@@ -512,7 +512,7 @@ float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
 {\r
        local float bSkipKey;\r
        bSkipKey = false;\r
-       \r
+\r
        if(menu_visible)\r
                if(menu_action(bInputType, nPrimary, nSecondary))\r
                        return TRUE;\r
@@ -605,7 +605,7 @@ void Ent_ReadPlayerScore()
 \r
        if(o.sort_prev)\r
                Sbar_UpdatePlayerPos(o); // if not registered, we cannot do this yet!\r
-       \r
+\r
        self.entremove = Ent_RemovePlayerScore;\r
 }\r
 \r
@@ -613,7 +613,7 @@ void Ent_ReadTeamScore()
 {\r
        float i;\r
        entity o;\r
-       \r
+\r
        self.team = ReadByte();\r
        o = self.owner = GetTeam(self.team, true);\r
 \r
@@ -669,7 +669,7 @@ void Ent_ClientData()
        }\r
        else\r
                angles_held_status = 0;\r
-       \r
+\r
        if(newspectatee_status != spectatee_status)\r
        {\r
                // clear race stuff\r
@@ -779,7 +779,7 @@ void(float bIsNewEntity) CSQC_Ent_Update =
                        error(strcat("unknown entity type in CSQC_Ent_Update: ", ftos(self.enttype), "\n"));\r
                        break;\r
        }\r
-       \r
+\r
        time = savetime;\r
 };\r
 // Destructor, but does NOT deallocate the entity by calling remove(). Also\r
@@ -829,7 +829,7 @@ void CSQC_Parse_Print(string strMessage)
        print(ColorTranslateRGB(strMessage));\r
 }\r
 \r
-// CSQC_Parse_CenterPrint : Provides the centerprint string in the first parameter that the server provided.  \r
+// CSQC_Parse_CenterPrint : Provides the centerprint string in the first parameter that the server provided.\r
 void CSQC_Parse_CenterPrint(string strMessage)\r
 {\r
        centerprint(strMessage);\r
@@ -1019,12 +1019,16 @@ float CSQC_Parse_TempEntity()
                        Net_ReadNexgunBeamParticle();\r
                        bHandled = true;\r
                        break;\r
+        case TE_CSQC_LIGHTNINGARC:\r
+            Net_ReadLightningarc();\r
+            bHandled = true;\r
+            break;\r
                default:\r
                        // No special logic for this temporary entity; return 0 so the engine can handle it\r
                        bHandled = false;\r
                        break;\r
        }\r
-               \r
+\r
        return bHandled;\r
 }\r
 \r
@@ -1053,13 +1057,13 @@ string getcommandkey(string text, string command)
        keys = db_get(binddb, command);\r
        if(csqc_flags & CSQC_FLAG_READPICTURE)\r
        {\r
-               if (!keys) \r
+               if (!keys)\r
                {\r
                        n = tokenize_insane(findkeysforcommand(command)); // uses '...' strings\r
                        for(j = 0; j < n; ++j)\r
                        {\r
                                k = stof(argv(j));\r
-                               if(k != -1) \r
+                               if(k != -1)\r
                                {\r
                                        if ("" == keys)\r
                                                keys = keynumtostring(k);\r
@@ -1069,12 +1073,12 @@ string getcommandkey(string text, string command)
                                        ++l;\r
                                        if (sbar_showbinds_limit > 0 && sbar_showbinds_limit >= l) break;\r
                                }\r
-                       \r
+\r
                        }\r
                        db_put(binddb, command, keys);\r
                }\r
        }\r
-       \r
+\r
        if ("" == keys) {\r
                if (sbar_showbinds > 1)\r
                        return strcat(text, " (not bound)");\r
diff --git a/data/qcsrc/client/effects.qc b/data/qcsrc/client/effects.qc
new file mode 100644 (file)
index 0000000..2acd0ac
--- /dev/null
@@ -0,0 +1,100 @@
+/*\r
+.vector fx_start;\r
+.vector fx_end;\r
+.float  fx_with;\r
+.string fx_texture;\r
+.float  fx_lifetime;\r
+\r
+void SUB_Remove()\r
+{ remove(self); }\r
+\r
+void b_draw()\r
+{\r
+    //Draw_CylindricLine(self.fx_start, self.fx_end, self.fx_with, self.fx_texture, 0, time * 3, '1 1 1', 0.7, DRAWFLAG_ADDITIVE);\r
+    Draw_CylindricLine(self.fx_start, self.fx_end, self.fx_with, self.fx_texture, (self.fx_with/256), 0, '1 1 1', 1, DRAWFLAG_ADDITIVE);\r
+\r
+}\r
+void b_make(vector s,vector e, string t,float l,float z)\r
+{\r
+    entity b;\r
+    b = spawn();\r
+    b.fx_texture = t;\r
+    b.fx_start = s;\r
+    b.fx_end = e;\r
+    b.fx_with = z;\r
+    b.think = SUB_Remove;\r
+    b.nextthink = time + l;\r
+       b.draw = b_draw;\r
+\r
+       //b.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;\r
+}\r
+*/\r
+\r
+void cl_effetcs_lightningarc(vector from, vector to,float seglength,float drifts,float drifte,float branchfactor,float branchfactor_add)\r
+{\r
+    vector direction,dirnew, pos, pos_l;\r
+    float length, steps, steplength, i,drift;\r
+\r
+    length     = vlen(from - to);\r
+    if(length < 1)\r
+        return;\r
+\r
+    steps      = floor(length / seglength);\r
+    if(steps < 1)\r
+    {\r
+        te_lightning1(world,from,to);\r
+        return;\r
+    }\r
+\r
+    steplength = length / steps;\r
+    direction  = normalize(to - from);\r
+    pos_l = from;\r
+    if(length > seglength)\r
+    {\r
+        for(i = 1; i < steps; i += 1)\r
+        {\r
+            drift = drifts * (1 - (i / steps)) + drifte * (i / steps);\r
+            dirnew = normalize(direction * (1 - drift) + randomvec() * drift);\r
+            pos = pos_l +  dirnew * steplength;\r
+            te_lightning1(world,pos_l,pos);\r
+            //b_make(pos_l, pos,"particles/lightning2",0.25,64);\r
+            if(random() < branchfactor)\r
+                cl_effetcs_lightningarc(pos, pos + (dirnew * length * 0.25),seglength,drifts,drifte,min(branchfactor + branchfactor_add,1),branchfactor_add);\r
+\r
+            pos_l = pos;\r
+        }\r
+        te_lightning1(world,pos_l,to);\r
+        //b_make(pos_l, to,"particles/lightning2",0.25,64);\r
+\r
+    }\r
+    else\r
+        te_lightning1(world,from,to);\r
+        //b_make(from, to,"particles/lightning2",0.25,64);\r
+\r
+}\r
+\r
+void Net_ReadLightningarc()\r
+{\r
+       vector from, to;\r
+\r
+    from_x = ReadCoord(); from_y = ReadCoord(); from_z = ReadCoord();\r
+    to_x   = ReadCoord(); to_y   = ReadCoord(); to_z   = ReadCoord();\r
+\r
+    if(cvar("cl_effects_lightningarc_simple"))\r
+    {\r
+        te_lightning1(world,from,to);\r
+    }\r
+    else\r
+    {\r
+        float seglength, drifts, drifte, branchfactor, branchfactor_add;\r
+\r
+        seglength    = cvar("cl_effects_lightningarc_segmentlength");\r
+        drifts       = cvar("cl_effects_lightningarc_drift_start");\r
+        drifte       = cvar("cl_effects_lightningarc_drift_end");\r
+        branchfactor = cvar("cl_effects_lightningarc_branchfactor_start");\r
+        branchfactor = cvar("cl_effects_lightningarc_branchfactor_add");\r
+\r
+        cl_effetcs_lightningarc(from,to,seglength,drifts,drifte,branchfactor,branchfactor_add);\r
+    }\r
+\r
+}\r
index 237af46..1da62fe 100644 (file)
@@ -34,6 +34,7 @@ projectile.qc
 gibs.qc\r
 damage.qc\r
 casings.qc\r
+effects.qc\r
 \r
 Main.qc\r
 View.qc\r
index c49af54..b34a936 100644 (file)
@@ -46,7 +46,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_NEXGUNBEAMPARTICLE = 104;\r
+const float TE_CSQC_LIGHTNINGARC = 105;
 
 const float RACE_NET_CHECKPOINT_HIT_QUALIFYING = 0; // byte checkpoint, short time, short recordtime, string recordholder
 const float RACE_NET_CHECKPOINT_CLEAR = 1;