]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/devastator.qc
My version of rocket flying
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / devastator.qc
index f4ef7ad32c08b320d139348908b42e7c95cb54bb..d2de5098cd7f3ddff53eb5d165fe55d3600ed76c 100644 (file)
@@ -1,8 +1,6 @@
 #include "devastator.qh"
 
 #ifdef SVQC
-spawnfunc(weapon_devastator) { weapon_defaultspawnfunc(this, WEP_DEVASTATOR); }
-spawnfunc(weapon_rocketlauncher) { spawnfunc_weapon_devastator(this); }
 
 .entity lastrocket;
 
@@ -40,6 +38,7 @@ void W_Devastator_Explode(entity this, entity directhitentity)
                NULL,
                WEP_CVAR(devastator, force),
                this.projectiledeathtype,
+               this.weaponentity_fld,
                directhitentity
        );
 
@@ -114,6 +113,7 @@ void W_Devastator_DoRemoteExplode(entity this, .entity weaponentity)
                                                head,
                                                (WEP_CVAR(devastator, remote_jump_force) ? WEP_CVAR(devastator, remote_jump_force) : 0),
                                                this.projectiledeathtype | HITTYPE_BOUNCE,
+                                               this.weaponentity_fld,
                                                NULL
                                        );
                                        break;
@@ -133,6 +133,7 @@ void W_Devastator_DoRemoteExplode(entity this, .entity weaponentity)
                NULL,
                WEP_CVAR(devastator, remote_force),
                this.projectiledeathtype | HITTYPE_BOUNCE,
+               this.weaponentity_fld,
                NULL
        );
 
@@ -234,11 +235,19 @@ void W_Devastator_Think(entity this)
                        else
                                f = 1;
 
+                       vector md = this.realowner.(weaponentity).movedir;
+                       vector vecs = ((md.x > 0) ? md : '0 0 0');
+
+                       vector dv = v_right * -vecs.y + v_up * vecs.z;
+
+                       if(!W_DualWielding(this.realowner))
+                               dv = '0 0 0'; // don't override!
+
                        velspeed = vlen(this.velocity);
 
                        makevectors(this.realowner.v_angle);
                        desireddir = WarpZone_RefSys_TransformVelocity(this.realowner, this, v_forward);
-                       desiredorigin = WarpZone_RefSys_TransformOrigin(this.realowner, this, this.realowner.origin + this.realowner.view_ofs);
+                       desiredorigin = WarpZone_RefSys_TransformOrigin(this.realowner, this, this.realowner.origin + this.realowner.view_ofs + dv);
                        olddir = normalize(this.velocity);
 
                        // now it gets tricky... we want to move like some curve to approximate the target direction
@@ -278,7 +287,7 @@ void W_Devastator_Touch(entity this, entity toucher)
        W_Devastator_Explode(this, toucher);
 }
 
-void W_Devastator_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
+void W_Devastator_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
 {
        if(this.health <= 0)
                return;
@@ -293,11 +302,11 @@ void W_Devastator_Damage(entity this, entity inflictor, entity attacker, float d
                W_PrepareExplosionByDamage(this, attacker, W_Devastator_Explode_think);
 }
 
-void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity)
+void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
        W_DecreaseAmmo(thiswep, actor, WEP_CVAR(devastator, ammo), weaponentity);
 
-       W_SetupShot_ProjectileSize(actor, weaponentity, '-3 -3 -3', '3 3 3', false, 5, SND_ROCKET_FIRE, CH_WEAPON_A, WEP_CVAR(devastator, damage));
+       W_SetupShot_ProjectileSize(actor, weaponentity, '-3 -3 -3', '3 3 3', false, 5, SND_ROCKET_FIRE, CH_WEAPON_A, WEP_CVAR(devastator, damage), WEP_DEVASTATOR.m_id);
        Send_Effect(EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
 
        entity missile = WarpZone_RefSys_SpawnSameRefSys(actor);
@@ -325,7 +334,12 @@ void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity)
        missile.projectiledeathtype = WEP_DEVASTATOR.m_id;
        setsize(missile, '-3 -3 -3', '3 3 3'); // give it some size so it can be shot
 
-       setorigin(missile, w_shotorg - v_forward * 3); // move it back so it hits the wall at the right point
+    bool rocketFlying = boolean(fire & 2);
+    if (rocketFlying) {
+           setorigin(missile, w_shotorg);
+    } else {
+           setorigin(missile, w_shotorg - (v_forward * 3)); // move it back so it hits the wall at the right point
+       }
        W_SetupProjVelocity_Basic(missile, WEP_CVAR(devastator, speedstart), 0);
        missile.angles = vectoangles(missile.velocity);
 
@@ -349,6 +363,10 @@ void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity)
 
        // common properties
        MUTATOR_CALLHOOK(EditProjectile, actor, missile);
+
+       if (rocketFlying) {
+        W_Devastator_RemoteExplode(missile, weaponentity);
+       }
 }
 
 METHOD(Devastator, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
@@ -440,7 +458,7 @@ METHOD(Devastator, wr_think, void(entity thiswep, entity actor, .entity weaponen
             if(actor.(weaponentity).rl_release || WEP_CVAR(devastator, guidestop))
             if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(devastator, refire)))
             {
-                W_Devastator_Attack(thiswep, actor, weaponentity);
+                W_Devastator_Attack(thiswep, actor, weaponentity, fire);
                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(devastator, animtime), w_ready);
                 actor.(weaponentity).rl_release = 0;
             }