]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a mutator hook for customizing the eventchase effect; onslaught now makes use...
authorterencehill <piuntn@gmail.com>
Sat, 10 Sep 2016 20:54:27 +0000 (22:54 +0200)
committerterencehill <piuntn@gmail.com>
Sat, 10 Sep 2016 20:59:40 +0000 (22:59 +0200)
qcsrc/client/autocvars.qh
qcsrc/client/mutators/events.qh
qcsrc/client/view.qc
qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc

index 9cbbcb5f7ee61f2207ed7a691ba88438397b9d80..8e2c722e8f374ec8baee0f4a0204ad1f296fcc04 100644 (file)
@@ -412,8 +412,6 @@ float autocvar_cl_hitsound_max_pitch = 1.5;
 float autocvar_cl_hitsound_nom_damage = 25;
 float autocvar_cl_hitsound_antispam_time;
 int autocvar_cl_eventchase_death = 1;
-vector autocvar_cl_eventchase_generator_viewoffset = '0 0 80';
-float autocvar_cl_eventchase_generator_distance = 400;
 float autocvar_cl_eventchase_distance = 140;
 float autocvar_cl_eventchase_speed = 1.3;
 vector autocvar_cl_eventchase_maxs = '12 12 8';
index a852fdbe472437e96c4ffbbf9a2f5bd498f2335a..1792183f1ccd6e5f5d7da6f9ca3ef1969b175397 100644 (file)
@@ -88,6 +88,15 @@ MUTATOR_HOOKABLE(GetModelParams, EV_GetModelParams);
        /**/
 MUTATOR_HOOKABLE(WantEventchase, EV_WantEventchase);
 
+/** allow customizing 3rd person mode effect */
+#define EV_CustomizeEventchase(i, o) \
+       /** entity id */ i(entity, MUTATOR_ARGV_0_entity) \
+       /* current_view_origin_override */ o(vector, MUTATOR_ARGV_0_vector) \
+       /* view_offset_override */ o(vector, MUTATOR_ARGV_1_vector) \
+       /* chase_distance_override */ o(float, MUTATOR_ARGV_0_float) \
+       /**/
+MUTATOR_HOOKABLE(CustomizeEventchase, EV_CustomizeEventchase);
+
 #define EV_AnnouncerOption(i, o) \
        /** announcer string */  i(string, MUTATOR_ARGV_0_string) \
        /** announcer string */ o(string, MUTATOR_ARGV_0_string) \
index e5f8b6a580969ee76a0687fd19aee735a756afa1..3134a24ed28fed2c9b917d4d279b31053dee9b46 100644 (file)
@@ -1490,8 +1490,6 @@ void CSQC_UpdateView(entity this, float w, float h)
                        cvar_set("chase_active", "0");
 
                float vehicle_chase = (hud != HUD_NORMAL && (autocvar_cl_eventchase_vehicle || spectatee_status > 0));
-               float ons_roundlost = (gametype == MAPINFO_TYPE_ONSLAUGHT && STAT(ROUNDLOST));
-               entity gen = NULL;
 
                float vehicle_viewdist = 0;
                vector vehicle_viewofs = '0 0 0';
@@ -1506,18 +1504,18 @@ void CSQC_UpdateView(entity this, float w, float h)
                        }
                }
 
-               if(ons_roundlost) // TODO: move this junk to a client mutator for onslaught (possible using the WantEventchase hook)
+               if(WantEventchase(this))
                {
-                       IL_EACH(g_onsgenerators, it.health <= 0,
+                       vector current_view_origin_override = '0 0 0';
+                       vector view_offset_override = '0 0 0';
+                       float chase_distance_override = 0;
+                       bool custom_eventchase = MUTATOR_CALLHOOK(CustomizeEventchase, this);
+                       if(custom_eventchase)
                        {
-                               gen = it;
-                               break;
-                       });
-                       if(!gen)
-                               ons_roundlost = false; // don't enforce the 3rd person camera if there is no dead generator to show
-               }
-               if(WantEventchase(this) || (!autocvar_cl_orthoview && ons_roundlost))
-               {
+                               current_view_origin_override = M_ARGV(0, vector);
+                               view_offset_override = M_ARGV(1, vector);
+                               chase_distance_override = M_ARGV(0, float);
+                       }
                        eventchase_running = true;
 
                        entity local_player = ((csqcplayer) ? csqcplayer : CSQCModel_server2csqc(player_localentnum - 1));
@@ -1526,7 +1524,8 @@ void CSQC_UpdateView(entity this, float w, float h)
 
                        // make special vector since we can't use view_origin (It is one frame old as of this code, it gets set later with the results this code makes.)
                        vector current_view_origin = (csqcplayer ? csqcplayer.origin : pmove_org);
-                       if(ons_roundlost) { current_view_origin = gen.origin; }
+                       if (custom_eventchase)
+                               current_view_origin = current_view_origin_override;
 
                        // detect maximum viewoffset and use it
                        vector view_offset = autocvar_cl_eventchase_viewoffset;
@@ -1537,7 +1536,8 @@ void CSQC_UpdateView(entity this, float w, float h)
                                else
                                        view_offset = autocvar_cl_eventchase_vehicle_viewoffset;
                        }
-                       if(ons_roundlost) { view_offset = autocvar_cl_eventchase_generator_viewoffset; }
+                       if (custom_eventchase)
+                               view_offset = view_offset_override;
 
                        if(view_offset)
                        {
@@ -1560,7 +1560,8 @@ void CSQC_UpdateView(entity this, float w, float h)
                                else
                                        chase_distance = autocvar_cl_eventchase_vehicle_distance;
                        }
-                       if(ons_roundlost) { chase_distance = autocvar_cl_eventchase_generator_distance; }
+                       if (custom_eventchase)
+                               chase_distance = chase_distance_override;
 
                        if(autocvar_cl_eventchase_speed && eventchase_current_distance < chase_distance)
                                eventchase_current_distance += autocvar_cl_eventchase_speed * (chase_distance - eventchase_current_distance) * frametime; // slow down the further we get
index 36926b754b0bcb8f0c92b4f1c734d8391c3cafc6..a30dd7d07e1c2da7b91a20edf9478d4a15e8e0d4 100644 (file)
@@ -1 +1,46 @@
 #include "onslaught.qh"
+
+#ifdef CSQC
+
+REGISTER_MUTATOR(cl_ons, true);
+
+float ons_roundlost;
+vector generator_origin;
+vector autocvar_cl_eventchase_generator_viewoffset = '0 0 80';
+float autocvar_cl_eventchase_generator_distance = 400;
+MUTATOR_HOOKFUNCTION(cl_ons, WantEventchase)
+{
+       ons_roundlost = STAT(ROUNDLOST);
+       entity gen = NULL;
+       if(ons_roundlost)
+       {
+               IL_EACH(g_onsgenerators, it.health <= 0,
+               {
+                       gen = it;
+                       break;
+               });
+               if(!gen)
+                       ons_roundlost = false; // don't enforce the 3rd person camera if there is no dead generator to show
+       }
+
+       if(ons_roundlost)
+       {
+               generator_origin = gen.origin;
+               return true;
+       }
+       return false;
+}
+
+MUTATOR_HOOKFUNCTION(cl_ons, CustomizeEventchase)
+{
+       if(ons_roundlost)
+       {
+               M_ARGV(0, vector) = generator_origin;
+               M_ARGV(1, vector) = autocvar_cl_eventchase_generator_viewoffset;
+               M_ARGV(0, float) = autocvar_cl_eventchase_generator_distance;
+               return true;
+       }
+       return false;
+}
+
+#endif