]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/crylink.qc
Merge branch 'master' into Mario/target_teleporter_v2
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / crylink.qc
index e76117dc459cc66950ec1db9258eb89bf5c19511..82b47037615e1d51cf6808e5ba55cf9fcb7a9493 100644 (file)
@@ -1,74 +1,5 @@
 #include "crylink.qh"
-#ifndef IMPLEMENTATION
-CLASS(Crylink, Weapon)
-/* ammotype  */ ATTRIB(Crylink, ammo_field, .int, ammo_cells);
-/* impulse   */ ATTRIB(Crylink, impulse, int, 6);
-/* flags     */ ATTRIB(Crylink, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH | WEP_FLAG_CANCLIMB);
-/* rating    */ ATTRIB(Crylink, bot_pickupbasevalue, float, 6000);
-/* color     */ ATTRIB(Crylink, wpcolor, vector, '1 0.5 1');
-/* modelname */ ATTRIB(Crylink, mdl, string, "crylink");
-#ifdef GAMEQC
-/* model     */ ATTRIB(Crylink, m_model, Model, MDL_CRYLINK_ITEM);
-#endif
-/* crosshair */ ATTRIB(Crylink, w_crosshair, string, "gfx/crosshaircrylink");
-/* crosshair */ ATTRIB(Crylink, w_crosshair_size, float, 0.5);
-/* wepimg    */ ATTRIB(Crylink, model2, string, "weaponcrylink");
-/* refname   */ ATTRIB(Crylink, netname, string, "crylink");
-/* wepname   */ ATTRIB(Crylink, m_name, string, _("Crylink"));
-
-#define X(BEGIN, P, END, class, prefix) \
-       BEGIN(class) \
-               P(class, prefix, ammo, float, BOTH) \
-        P(class, prefix, animtime, float, BOTH) \
-        P(class, prefix, bouncedamagefactor, float, BOTH) \
-        P(class, prefix, bounces, float, BOTH) \
-        P(class, prefix, damage, float, BOTH) \
-        P(class, prefix, edgedamage, float, BOTH) \
-        P(class, prefix, force, float, BOTH) \
-        P(class, prefix, joindelay, float, BOTH) \
-        P(class, prefix, joinexplode, float, BOTH) \
-        P(class, prefix, joinexplode_damage, float, BOTH) \
-        P(class, prefix, joinexplode_edgedamage, float, BOTH) \
-        P(class, prefix, joinexplode_force, float, BOTH) \
-        P(class, prefix, joinexplode_radius, float, BOTH) \
-        P(class, prefix, joinspread, float, BOTH) \
-        P(class, prefix, linkexplode, float, BOTH) \
-        P(class, prefix, middle_fadetime, float, BOTH) \
-        P(class, prefix, middle_lifetime, float, BOTH) \
-        P(class, prefix, other_fadetime, float, BOTH) \
-        P(class, prefix, other_lifetime, float, BOTH) \
-        P(class, prefix, radius, float, BOTH) \
-        P(class, prefix, refire, float, BOTH) \
-        P(class, prefix, reload_ammo, float, NONE) \
-        P(class, prefix, reload_time, float, NONE) \
-        P(class, prefix, secondary, float, NONE) \
-        P(class, prefix, shots, float, BOTH) \
-        P(class, prefix, speed, float, BOTH) \
-        P(class, prefix, spreadtype, float, SEC) \
-        P(class, prefix, spread, float, BOTH) \
-        P(class, prefix, switchdelay_drop, float, NONE) \
-        P(class, prefix, switchdelay_raise, float, NONE) \
-        P(class, prefix, weaponreplace, string, NONE) \
-        P(class, prefix, weaponstartoverride, float, NONE) \
-        P(class, prefix, weaponstart, float, NONE) \
-        P(class, prefix, weaponthrowable, float, NONE) \
-       END()
-       W_PROPS(X, Crylink, crylink)
-#undef X
-
-ENDCLASS(Crylink)
-REGISTER_WEAPON(CRYLINK, crylink, NEW(Crylink));
-
-#ifdef SVQC
-.float gravity;
-.float crylink_waitrelease;
-.entity crylink_lastgroup;
 
-.entity queuenext;
-.entity queueprev;
-#endif
-#endif
-#ifdef IMPLEMENTATION
 #ifdef SVQC
 spawnfunc(weapon_crylink) { weapon_defaultspawnfunc(this, WEP_CRYLINK); }
 
@@ -110,7 +41,7 @@ void W_Crylink_Dequeue_Raw(entity own, entity prev, entity me, entity next)
 
 void W_Crylink_Dequeue(entity e)
 {
-       W_Crylink_Dequeue_Raw(e.realowner, e.queueprev, e, e.queuenext);
+       W_Crylink_Dequeue_Raw(e.crylink_owner, e.queueprev, e, e.queuenext);
 }
 
 void W_Crylink_Reset(entity this)
@@ -130,8 +61,8 @@ void W_Crylink_LinkExplode(entity e, entity e2, entity directhitentity)
        a = bound(0, 1 - (time - e.fade_time) * e.fade_rate, 1);
 
        .entity weaponentity = e.weaponentity_fld;
-       if(e == e.realowner.(weaponentity).crylink_lastgroup)
-               e.realowner.(weaponentity).crylink_lastgroup = NULL;
+       if(e == e.crylink_owner.(weaponentity).crylink_lastgroup)
+               e.crylink_owner.(weaponentity).crylink_lastgroup = NULL;
 
        float isprimary = !(e.projectiledeathtype & HITTYPE_SECONDARY);
 
@@ -179,9 +110,9 @@ vector W_Crylink_LinkJoin(entity e, float jspeed)
                return avg_origin; // nothing to do
 
        // yes, mathematically we can do this in ONE step, but beware of 32bit floats...
-       avg_dist = pow(vlen(e.origin - avg_origin), 2);
+       avg_dist = (vlen(e.origin - avg_origin) ** 2);
        for(p = e; (p = p.queuenext) != e; )
-               avg_dist += pow(vlen(WarpZone_RefSys_TransformOrigin(p, e, p.origin) - avg_origin), 2);
+               avg_dist += (vlen(WarpZone_RefSys_TransformOrigin(p, e, p.origin) - avg_origin) ** 2);
        avg_dist *= (1.0 / n);
        avg_dist = sqrt(avg_dist);
 
@@ -321,8 +252,8 @@ void W_Crylink_Touch(entity this, entity toucher)
        if(totaldamage && ((WEP_CVAR_BOTH(crylink, isprimary, linkexplode) == 2) || ((WEP_CVAR_BOTH(crylink, isprimary, linkexplode) == 1) && !W_Crylink_Touch_WouldHitFriendly(this, WEP_CVAR_BOTH(crylink, isprimary, radius)))))
        {
                .entity weaponentity = this.weaponentity_fld;
-               if(this == this.realowner.(weaponentity).crylink_lastgroup)
-                       this.realowner.(weaponentity).crylink_lastgroup = NULL;
+               if(this == this.crylink_owner.(weaponentity).crylink_lastgroup)
+                       this.crylink_owner.(weaponentity).crylink_lastgroup = NULL;
                W_Crylink_LinkExplode(this.queuenext, this, toucher);
                this.classname = "spike_oktoremove";
                delete(this);
@@ -378,6 +309,7 @@ void W_Crylink_Attack(Weapon thiswep, entity actor, .entity weaponentity)
                proj = new(spike);
                proj.reset = W_Crylink_Reset;
                proj.realowner = proj.owner = actor;
+               proj.crylink_owner = actor;
                proj.weaponentity_fld = weaponentity;
                proj.bot_dodge = true;
                proj.bot_dodgerating = WEP_CVAR_PRI(crylink, damage);
@@ -490,6 +422,7 @@ void W_Crylink_Attack2(Weapon thiswep, entity actor, .entity weaponentity)
                proj.weaponentity_fld = weaponentity;
                proj.reset = W_Crylink_Reset;
                proj.realowner = proj.owner = actor;
+               proj.crylink_owner = actor;
                proj.bot_dodge = true;
                proj.bot_dodgerating = WEP_CVAR_SEC(crylink, damage);
                if(shots == 1) {
@@ -695,4 +628,3 @@ METHOD(Crylink, wr_impacteffect, void(entity thiswep, entity actor))
     }
 }
 #endif
-#endif