]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/devastator.qc
Merge branch 'master' into Mario/wepent_experimental
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / devastator.qc
index db014bb861520fb185204458ee316afe8e544803..a6473b39274c552dc2520dc218b08cfb42fcbc91 100644 (file)
@@ -40,6 +40,7 @@ CLASS(Devastator, Weapon)
         P(class, prefix, remote_edgedamage, float, NONE) \
         P(class, prefix, remote_force, float, NONE) \
         P(class, prefix, remote_jump_damage, float, NONE) \
+        P(class, prefix, remote_jump_force, float, NONE) \
         P(class, prefix, remote_jump_radius, float, NONE) \
         P(class, prefix, remote_jump_velocity_z_add, float, NONE) \
         P(class, prefix, remote_jump_velocity_z_max, float, NONE) \
@@ -62,7 +63,7 @@ ENDCLASS(Devastator)
 REGISTER_WEAPON(DEVASTATOR, devastator, NEW(Devastator));
 
 #ifdef SVQC
-.float rl_release[MAX_WEAPONSLOTS];
+.float rl_release;
 .float rl_detonate_later;
 #endif
 #endif
@@ -142,50 +143,56 @@ void W_Devastator_DoRemoteExplode(entity this, .entity weaponentity)
        this.event_damage = func_null;
        this.takedamage = DAMAGE_NO;
 
-       float handled_as_rocketjump = false;
+       bool handled_as_rocketjump = false;
+       entity head = NULL;
 
-       entity head = WarpZone_FindRadius(
-               this.origin,
-               WEP_CVAR(devastator, remote_jump_radius),
-               false
-       );
-
-       while(head)
+       if(WEP_CVAR(devastator, remote_jump_radius))
        {
-               if(head.takedamage && (head == this.realowner))
+               head = WarpZone_FindRadius(
+                       this.origin,
+                       WEP_CVAR(devastator, remote_jump_radius),
+                       false
+               );
+
+               while(head)
                {
-                       float distance_to_head = vlen(this.origin - head.WarpZone_findradius_nearest);
-                       if(distance_to_head <= WEP_CVAR(devastator, remote_jump_radius))
+                       if(head.takedamage && (head == this.realowner))
                        {
-                               // we handled this as a rocketjump :)
-                               handled_as_rocketjump = true;
-
-                               // modify velocity
-                               head.velocity_x *= 0.9;
-                               head.velocity_y *= 0.9;
-                               head.velocity_z = bound(
-                                       WEP_CVAR(devastator, remote_jump_velocity_z_min),
-                                       head.velocity.z + WEP_CVAR(devastator, remote_jump_velocity_z_add),
-                                       WEP_CVAR(devastator, remote_jump_velocity_z_max)
-                               );
-
-                               // now do the damage
-                               RadiusDamage(
-                                       this,
-                                       head,
-                                       WEP_CVAR(devastator, remote_jump_damage),
-                                       WEP_CVAR(devastator, remote_jump_damage),
-                                       WEP_CVAR(devastator, remote_jump_radius),
-                                       NULL,
-                                       head,
-                                       0,
-                                       this.projectiledeathtype | HITTYPE_BOUNCE,
-                                       NULL
-                               );
-                               break;
+                               if(vdist(this.origin - head.WarpZone_findradius_nearest, <=, WEP_CVAR(devastator, remote_jump_radius)))
+                               {
+                                       // we handled this as a rocketjump :)
+                                       handled_as_rocketjump = true;
+
+                                       // modify velocity
+                                       if(WEP_CVAR(devastator, remote_jump_velocity_z_add))
+                                       {
+                                               head.velocity_x *= 0.9;
+                                               head.velocity_y *= 0.9;
+                                               head.velocity_z = bound(
+                                                       WEP_CVAR(devastator, remote_jump_velocity_z_min),
+                                                       head.velocity.z + WEP_CVAR(devastator, remote_jump_velocity_z_add),
+                                                       WEP_CVAR(devastator, remote_jump_velocity_z_max)
+                                               );
+                                       }
+
+                                       // now do the damage
+                                       RadiusDamage(
+                                               this,
+                                               head,
+                                               WEP_CVAR(devastator, remote_jump_damage),
+                                               WEP_CVAR(devastator, remote_jump_damage),
+                                               WEP_CVAR(devastator, remote_jump_radius),
+                                               NULL,
+                                               head,
+                                               (WEP_CVAR(devastator, remote_jump_force) ? WEP_CVAR(devastator, remote_jump_force) : 0),
+                                               this.projectiledeathtype | HITTYPE_BOUNCE,
+                                               NULL
+                                       );
+                                       break;
+                               }
                        }
+                       head = head.chain;
                }
-               head = head.chain;
        }
 
        RadiusDamage(
@@ -286,10 +293,8 @@ void W_Devastator_Think(entity this)
        .entity weaponentity = this.weaponentity_fld;
        if(this.realowner.(weaponentity).m_weapon == WEP_DEVASTATOR)
        {
-               int slot = weaponslot(weaponentity);
-
                if(this == this.realowner.(weaponentity).lastrocket)
-               if(!this.realowner.rl_release[slot])
+               if(!this.realowner.(weaponentity).rl_release)
                if(!PHYS_INPUT_BUTTON_ATCK2(this))
                if(WEP_CVAR(devastator, guiderate))
                if(time > this.pushltime)
@@ -385,6 +390,7 @@ void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity)
        missile.health = WEP_CVAR(devastator, health);
        missile.event_damage = W_Devastator_Damage;
        missile.damagedbycontents = true;
+       IL_PUSH(g_damagedbycontents, missile);
 
        set_movetype(missile, MOVETYPE_FLY);
        PROJECTILE_MAKETRIGGER(missile);
@@ -417,10 +423,10 @@ void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity)
        MUTATOR_CALLHOOK(EditProjectile, actor, missile);
 }
 
-METHOD(Devastator, wr_aim, void(entity thiswep, entity actor))
+METHOD(Devastator, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
     // aim and decide to fire if appropriate
-    PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR(devastator, speed), 0, WEP_CVAR(devastator, lifetime), false);
+    PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR(devastator, speed), 0, WEP_CVAR(devastator, lifetime), false);
     if(skill >= 2) // skill 0 and 1 bots won't detonate rockets!
     {
         // decide whether to detonate rockets
@@ -501,19 +507,18 @@ METHOD(Devastator, wr_think, void(entity thiswep, entity actor, .entity weaponen
     if(WEP_CVAR(devastator, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR(devastator, ammo)) { // forced reload
         thiswep.wr_reload(thiswep, actor, weaponentity);
     } else {
-       int slot = weaponslot(weaponentity);
         if(fire & 1)
         {
-            if(actor.rl_release[slot] || WEP_CVAR(devastator, guidestop))
+            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);
                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(devastator, animtime), w_ready);
-                actor.rl_release[slot] = 0;
+                actor.(weaponentity).rl_release = 0;
             }
         }
         else
-            actor.rl_release[slot] = 1;
+            actor.(weaponentity).rl_release = 1;
 
         if(fire & 2)
         if(actor.(weaponentity).m_switchweapon == WEP_DEVASTATOR)
@@ -532,10 +537,9 @@ METHOD(Devastator, wr_think, void(entity thiswep, entity actor, .entity weaponen
         }
     }
 }
-METHOD(Devastator, wr_setup, void(entity thiswep, entity actor))
+METHOD(Devastator, wr_setup, void(entity thiswep, entity actor, .entity weaponentity))
 {
-    for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
-       actor.rl_release[slot] = 1;
+    actor.(weaponentity).rl_release = 1;
 }
 METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
@@ -583,7 +587,7 @@ METHOD(Devastator, wr_resetplayer, void(entity thiswep, entity actor))
     {
        .entity weaponentity = weaponentities[slot];
        actor.(weaponentity).lastrocket = NULL; // stop rocket guiding, no revenge from the grave!
-       actor.rl_release[slot] = 0;
+       actor.(weaponentity).rl_release = 0;
     }
 }
 METHOD(Devastator, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))