Some hook & nade stuff
authorMario <zacjardine@y7mail.com>
Sat, 29 Aug 2015 15:14:04 +0000 (01:14 +1000)
committerMario <zacjardine@y7mail.com>
Sat, 29 Aug 2015 15:14:04 +0000 (01:14 +1000)
balance-nexuiz25.cfg
balance-overkill.cfg
balance-samual.cfg
balance-xdf.cfg
balance-xonotic.cfg
balance-xpm.cfg
qcsrc/server/autocvars.qh
qcsrc/server/g_hook.qc
qcsrc/server/mutators/events.qh
qcsrc/server/mutators/mutator_nades.qc

index 95680da..6e18dc0 100644 (file)
@@ -218,6 +218,10 @@ set g_balance_grapplehook_airfriction 0.2
 set g_balance_grapplehook_health 130
 set g_balance_grapplehook_damagedbycontents 0
 set g_balance_grapplehook_refire 0.2
+set g_balance_grapplehook_nade_time 0.7
+set g_balance_grapplehook_crouchslide 0
+set g_balance_grapplehook_gravity 0
+set g_balance_grapplehook_pull_frozen 0
 // }}}
 
 // {{{ port-o-launch
index bf390c2..a99d342 100644 (file)
@@ -218,6 +218,10 @@ set g_balance_grapplehook_airfriction 0.2
 set g_balance_grapplehook_health 50
 set g_balance_grapplehook_damagedbycontents 1
 set g_balance_grapplehook_refire 0.2
+set g_balance_grapplehook_nade_time 0.7
+set g_balance_grapplehook_crouchslide 0
+set g_balance_grapplehook_gravity 0
+set g_balance_grapplehook_pull_frozen 0
 // }}}
 
 // {{{ port-o-launch
index cb49497..379bc20 100644 (file)
@@ -218,6 +218,10 @@ set g_balance_grapplehook_airfriction 0.2
 set g_balance_grapplehook_health 50
 set g_balance_grapplehook_damagedbycontents 1
 set g_balance_grapplehook_refire 0.2
+set g_balance_grapplehook_nade_time 0.7
+set g_balance_grapplehook_crouchslide 0
+set g_balance_grapplehook_gravity 0
+set g_balance_grapplehook_pull_frozen 0
 // }}}
 
 // {{{ port-o-launch
index 4852a59..07d4c6c 100644 (file)
@@ -218,6 +218,10 @@ set g_balance_grapplehook_airfriction 0.2
 set g_balance_grapplehook_health 130
 set g_balance_grapplehook_damagedbycontents 0
 set g_balance_grapplehook_refire 0.2
+set g_balance_grapplehook_nade_time 0.7
+set g_balance_grapplehook_crouchslide 0
+set g_balance_grapplehook_gravity 0
+set g_balance_grapplehook_pull_frozen 0
 // }}}
 
 // {{{ port-o-launch
index 76ba515..3bc87d6 100644 (file)
@@ -218,6 +218,10 @@ set g_balance_grapplehook_airfriction 0.2
 set g_balance_grapplehook_health 50
 set g_balance_grapplehook_damagedbycontents 1
 set g_balance_grapplehook_refire 0.2
+set g_balance_grapplehook_nade_time 0.7
+set g_balance_grapplehook_crouchslide 0
+set g_balance_grapplehook_gravity 0
+set g_balance_grapplehook_pull_frozen 0
 // }}}
 
 // {{{ port-o-launch
index e785528..a99044a 100644 (file)
@@ -218,6 +218,10 @@ set g_balance_grapplehook_airfriction 0.2
 set g_balance_grapplehook_health 50
 set g_balance_grapplehook_damagedbycontents 1
 set g_balance_grapplehook_refire 0.2
+set g_balance_grapplehook_nade_time 0.7
+set g_balance_grapplehook_crouchslide 0
+set g_balance_grapplehook_gravity 0
+set g_balance_grapplehook_pull_frozen 0
 // }}}
 
 // {{{ port-o-launch
index 37d4bfd..f6ac64e 100644 (file)
@@ -337,6 +337,10 @@ bool autocvar_g_fullbrightitems;
 bool autocvar_g_fullbrightplayers;
 #define autocvar_g_grappling_hook cvar("g_grappling_hook")
 int autocvar_g_grappling_hook_tarzan;
+int autocvar_g_balance_grapplehook_pull_frozen;
+float autocvar_g_balance_grapplehook_nade_time;
+bool autocvar_g_balance_grapplehook_gravity;
+bool autocvar_g_balance_grapplehook_crouchslide;
 bool autocvar_g_hitplots;
 string autocvar_g_hitplots_individuals;
 float autocvar_g_jetpack_acceleration_side;
index a9b16d0..d63a2ad 100644 (file)
@@ -138,7 +138,7 @@ void GrapplingHookThink()
                error("Owner lost the hook!\n");
                return;
        }
-       if(LostMovetypeFollow(self) || intermission_running || (round_handler_IsActive() && !round_handler_IsRoundStarted()))
+       if(LostMovetypeFollow(self) || intermission_running || (round_handler_IsActive() && !round_handler_IsRoundStarted()) || ((self.aiment.flags & FL_PROJECTILE) && self.aiment.classname != "nade"))
        {
                RemoveGrapplingHook(self.realowner);
                return;
@@ -161,6 +161,14 @@ void GrapplingHookThink()
        if(self.hook_length < 0)
                self.hook_length = vlen(myorg - self.origin);
 
+       int tarzan = autocvar_g_grappling_hook_tarzan;
+       entity pull_entity = self.realowner;
+       float velocity_multiplier = 1;
+       MUTATOR_CALLHOOK(GrappleHookThink, self, tarzan, pull_entity, velocity_multiplier);
+       tarzan = hook_tarzan;
+       pull_entity = hook_pullentity;
+       velocity_multiplier = hook_velmultiplier;
+
        if(self.state == 1)
        {
                pullspeed = autocvar_g_balance_grapplehook_speed_pull;//2000;
@@ -184,13 +192,15 @@ void GrapplingHookThink()
                // while hanging on the rope, this friction component will help you a
                // bit to control the rope
 
+               bool frozen_pulling = (autocvar_g_grappling_hook_tarzan >= 2 && autocvar_g_balance_grapplehook_pull_frozen);
+
                dir = self.origin - myorg;
                dist = vlen(dir);
                dir = normalize(dir);
 
-               if(autocvar_g_grappling_hook_tarzan)
+               if(tarzan)
                {
-                       v = v0 = WarpZone_RefSys_TransformVelocity(self.realowner, self, self.realowner.velocity);
+                       v = v0 = WarpZone_RefSys_TransformVelocity(pull_entity, self, pull_entity.velocity);
 
                        // first pull the rope...
                        if(self.realowner.hook_state & HOOK_PULLING)
@@ -208,6 +218,9 @@ void GrapplingHookThink()
                                self.hook_length = newlength;
                        }
 
+                       if(pull_entity.movetype == MOVETYPE_FLY)
+                               pull_entity.movetype = MOVETYPE_WALK;
+
                        if(self.realowner.hook_state & HOOK_RELEASING)
                        {
                                newlength = dist;
@@ -221,23 +234,38 @@ void GrapplingHookThink()
                                v = v + frametime * dir * spd * rubberforce;
 
                                dv = ((v - v0) * dir) * dir;
-                               if(autocvar_g_grappling_hook_tarzan >= 2)
+                               if(tarzan >= 2)
                                {
-                                       if(self.aiment.movetype == MOVETYPE_WALK)
+                                       if(self.aiment.movetype == MOVETYPE_WALK || self.aiment.classname == "nade")
                                        {
+                                               entity aim_ent = ((IS_VEHICLE(self.aiment) && self.aiment.owner) ? self.aiment.owner : self.aiment);
                                                v = v - dv * 0.5;
-                                               self.aiment.velocity = self.aiment.velocity - dv * 0.5;
-                                               self.aiment.flags &= ~FL_ONGROUND;
-                                               self.aiment.pusher = self.realowner;
-                                               self.aiment.pushltime = time + autocvar_g_maxpushtime;
-                                               self.aiment.istypefrag = self.aiment.BUTTON_CHAT;
+                                               if((frozen_pulling && self.aiment.frozen) || !frozen_pulling)
+                                               {
+                                                       self.aiment.velocity = self.aiment.velocity - dv * 0.5;
+                                                       self.aiment.flags &= ~FL_ONGROUND;
+                                                       if(self.aiment.flags & FL_PROJECTILE)
+                                                               UpdateCSQCProjectile(self.aiment);
+                                               }
+                                               if(self.aiment.classname == "nade")
+                                                       self.aiment.nextthink = time + autocvar_g_balance_grapplehook_nade_time; // set time after letting go?
+                                               aim_ent.pusher = self.realowner;
+                                               aim_ent.pushltime = time + autocvar_g_maxpushtime;
+                                               aim_ent.istypefrag = aim_ent.BUTTON_CHAT;
                                        }
                                }
 
-                               self.realowner.flags &= ~FL_ONGROUND;
+                               pull_entity.flags &= ~FL_ONGROUND;
                        }
 
-                       self.realowner.velocity = WarpZone_RefSys_TransformVelocity(self, self.realowner, v);
+                       if(!frozen_pulling && !(self.aiment.flags & FL_PROJECTILE))
+                               pull_entity.velocity = WarpZone_RefSys_TransformVelocity(self, pull_entity, v * velocity_multiplier);
+
+                       if(frozen_pulling && autocvar_g_balance_grapplehook_pull_frozen == 2 && !self.aiment.frozen)
+                       {
+                               RemoveGrapplingHook(self.realowner);
+                               return;
+                       }
                }
                else
                {
@@ -273,6 +301,8 @@ void GrapplingHookThink()
 
 void GrapplingHookTouch (void)
 {
+       if(other.movetype == MOVETYPE_FOLLOW)
+               return;
        PROJECTILE_TOUCH;
 
        GrapplingHook_Stop();
@@ -342,7 +372,7 @@ void FireGrapplingHook (void)
        missile.classname = "grapplinghook";
        missile.flags = FL_PROJECTILE;
 
-       missile.movetype = MOVETYPE_FLY;
+       missile.movetype = ((autocvar_g_balance_grapplehook_gravity) ? MOVETYPE_TOSS : MOVETYPE_FLY);
        PROJECTILE_MAKETRIGGER(missile);
 
        //setmodel (missile, "models/hook.md3"); // precision set below
@@ -394,7 +424,7 @@ void FireGrapplingHook (void)
 
 void GrapplingHookFrame()
 {
-       if(g_grappling_hook && timeout_status != TIMEOUT_ACTIVE && self.weapon != WEP_HOOK.m_id)
+       if(g_grappling_hook && timeout_status != TIMEOUT_ACTIVE && self.weapon != WEP_HOOK.m_id && !self.vehicle)
        {
                // offhand hook controls
                if(self.BUTTON_HOOK)
@@ -412,7 +442,7 @@ void GrapplingHookFrame()
                }
 
                self.hook_state &= ~HOOK_RELEASING;
-               if(self.BUTTON_CROUCH)
+               if(self.BUTTON_CROUCH && autocvar_g_balance_grapplehook_crouchslide)
                {
                        self.hook_state &= ~HOOK_PULLING;
                        //self.hook_state |= HOOK_RELEASING;
@@ -423,7 +453,7 @@ void GrapplingHookFrame()
                        //self.hook_state &= ~HOOK_RELEASING;
                }
        }
-       else if(!g_grappling_hook && self.switchweapon != WEP_HOOK.m_id)
+       else if(!g_grappling_hook && self.switchweapon != WEP_HOOK.m_id && !self.vehicle)
        {
                if(self.BUTTON_HOOK && !self.hook_switchweapon)
                        W_SwitchWeapon(WEP_HOOK.m_id);
index d6f0098..25a8d12 100644 (file)
@@ -589,4 +589,18 @@ MUTATOR_HOOKABLE(FixPlayermodel, EV_FixPlayermodel);
 
 /** Return error to play frag remaining announcements */
 MUTATOR_HOOKABLE(Scores_CountFragsRemaining, EV_NO_ARGS);
+
+#define EV_GrappleHookThink(i, o) \
+    /**/ i(entity, self) \
+    /**/ i(int, hook_tarzan) \
+    /**/ o(int, hook_tarzan) \
+    /**/ i(entity, hook_pullentity) \
+    /**/ o(entity, hook_pullentity) \
+    /**/ i(float, hook_velmultiplier) \
+    /**/ o(float, hook_velmultiplier) \
+    /**/
+int hook_tarzan;
+entity hook_pullentity;
+float hook_velmultiplier;
+MUTATOR_HOOKABLE(GrappleHookThink, EV_GrappleHookThink);
 #endif
index bd8cb18..9199fe1 100644 (file)
@@ -290,7 +290,6 @@ void nade_ice_think()
        {
                self.nade_special_time = time+0.7;
 
-
                Send_Effect(EFFECT_ELECTRO_IMPACT, self.origin, '0 0 0', 1);
                Send_Effect(EFFECT_ICEFIELD, self.origin, '0 0 0', 1);
        }
@@ -554,6 +553,11 @@ void nade_boom()
                case NADE_TYPE_MONSTER: nade_monster_boom(); break;
        }
 
+       entity head;
+       for(head = world; (head = find(head, classname, "grapplinghook")); )
+       if(head.aiment == self)
+               RemoveGrapplingHook(head.realowner);
+
        remove(self);
 }
 
@@ -566,6 +570,10 @@ void nade_touch()
                is_weapclip = 1;*/
        if(ITEM_TOUCH_NEEDKILL()) // || is_weapclip)
        {
+               entity head;
+               for(head = world; (head = find(head, classname, "grapplinghook")); )
+               if(head.aiment == self)
+                       RemoveGrapplingHook(head.realowner);
                remove(self);
                return;
        }