X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fw_crylink.qc;h=4d4430206feab00a0f9c965bc5174782d4ce3fbd;hb=1a65f7bb6bae1bb6d1a40d3e2eda30c822052313;hp=45675b28e4657c8b98280d389bb6a048627e3b40;hpb=fbb52b893f7be6bf4073f1853761c4f2fc11a343;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/w_crylink.qc b/qcsrc/common/weapons/w_crylink.qc index 45675b28e..4d4430206 100644 --- a/qcsrc/common/weapons/w_crylink.qc +++ b/qcsrc/common/weapons/w_crylink.qc @@ -1,14 +1,18 @@ #ifdef REGISTER_WEAPON REGISTER_WEAPON( -/* WEP_##id */ CRYLINK, -/* function */ w_crylink, -/* ammotype */ ammo_cells, -/* impulse */ 6, -/* flags */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH, -/* rating */ BOT_PICKUP_RATING_MID, -/* model */ "crylink", -/* netname */ "crylink", -/* fullname */ _("Crylink") +/* WEP_##id */ CRYLINK, +/* function */ W_Crylink, +/* ammotype */ ammo_cells, +/* impulse */ 6, +/* flags */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH, +/* rating */ BOT_PICKUP_RATING_MID, +/* color */ '1 0.5 1', +/* modelname */ "crylink", +/* simplemdl */ "foobar", +/* crosshair */ "gfx/crosshaircrylink 0.5", +/* wepimg */ "weaponcrylink", +/* refname */ "crylink", +/* wepname */ _("Crylink") ); #define CRYLINK_SETTINGS(w_cvar,w_prop) CRYLINK_SETTINGS_LIST(w_cvar, w_prop, CRYLINK, crylink) @@ -45,7 +49,8 @@ REGISTER_WEAPON( w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \ w_prop(id, sn, string, weaponreplace, weaponreplace) \ w_prop(id, sn, float, weaponstart, weaponstart) \ - w_prop(id, sn, float, weaponstartoverride, weaponstartoverride) + w_prop(id, sn, float, weaponstartoverride, weaponstartoverride) \ + w_prop(id, sn, float, weaponthrowable, weaponthrowable) #ifdef SVQC CRYLINK_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP) @@ -58,7 +63,7 @@ CRYLINK_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP) #endif #else #ifdef SVQC -void spawnfunc_weapon_crylink() { weapon_defaultspawnfunc(WEP_CRYLINK); } +void spawnfunc_weapon_crylink(void) { weapon_defaultspawnfunc(WEP_CRYLINK); } void W_Crylink_CheckLinks(entity e) { @@ -107,7 +112,7 @@ void W_Crylink_Reset(void) } // force projectile to explode -void W_Crylink_LinkExplode (entity e, entity e2) +void W_Crylink_LinkExplode(entity e, entity e2) { float a; @@ -118,15 +123,15 @@ void W_Crylink_LinkExplode (entity e, entity e2) if(e == e.realowner.crylink_lastgroup) e.realowner.crylink_lastgroup = world; - + float isprimary = !(e.projectiledeathtype & HITTYPE_SECONDARY); - + RadiusDamage(e, e.realowner, WEP_CVAR_BOTH(crylink, isprimary, damage) * a, WEP_CVAR_BOTH(crylink, isprimary, edgedamage) * a, WEP_CVAR_BOTH(crylink, isprimary, radius), world, world, WEP_CVAR_BOTH(crylink, isprimary, force) * a, e.projectiledeathtype, other); W_Crylink_LinkExplode(e.queuenext, e2); e.classname = "spike_oktoremove"; - remove (e); + remove(e); } // adjust towards center @@ -217,7 +222,7 @@ vector W_Crylink_LinkJoin(entity e, float jspeed) return targ_origin; } -void W_Crylink_LinkJoinEffect_Think() +void W_Crylink_LinkJoinEffect_Think(void) { // is there at least 2 projectiles very close? entity e, p; @@ -236,7 +241,7 @@ void W_Crylink_LinkJoinEffect_Think() if(n >= 2) { float isprimary = !(e.projectiledeathtype & HITTYPE_SECONDARY); - + if(WEP_CVAR_BOTH(crylink, isprimary, joinexplode)) { n /= WEP_CVAR_BOTH(crylink, isprimary, shots); @@ -261,7 +266,7 @@ void W_Crylink_LinkJoinEffect_Think() float W_Crylink_Touch_WouldHitFriendly(entity projectile, float rad) { - entity head = WarpZone_FindRadius((projectile.origin + (projectile.mins + projectile.maxs) * 0.5), rad + MAX_DAMAGEEXTRARADIUS, FALSE); + entity head = WarpZone_FindRadius((projectile.origin + (projectile.mins + projectile.maxs) * 0.5), rad + MAX_DAMAGEEXTRARADIUS, false); float hit_friendly = 0; float hit_enemy = 0; @@ -274,15 +279,15 @@ float W_Crylink_Touch_WouldHitFriendly(entity projectile, float rad) else ++hit_enemy; } - + head = head.chain; } - return (hit_enemy ? FALSE : hit_friendly); + return (hit_enemy ? false : hit_friendly); } // NO bounce protection, as bounces are limited! -void W_Crylink_Touch (void) +void W_Crylink_Touch(void) { float finalhit; float f; @@ -301,14 +306,14 @@ void W_Crylink_Touch (void) f *= a; float totaldamage = RadiusDamage(self, self.realowner, WEP_CVAR_BOTH(crylink, isprimary, damage) * f, WEP_CVAR_BOTH(crylink, isprimary, edgedamage) * f, WEP_CVAR_BOTH(crylink, isprimary, radius), world, world, WEP_CVAR_BOTH(crylink, isprimary, force) * f, self.projectiledeathtype, other); - + if(totaldamage && ((WEP_CVAR_BOTH(crylink, isprimary, linkexplode) == 2) || ((WEP_CVAR_BOTH(crylink, isprimary, linkexplode) == 1) && !W_Crylink_Touch_WouldHitFriendly(self, WEP_CVAR_BOTH(crylink, isprimary, radius))))) { if(self == self.realowner.crylink_lastgroup) self.realowner.crylink_lastgroup = world; W_Crylink_LinkExplode(self.queuenext, self); self.classname = "spike_oktoremove"; - remove (self); + remove(self); return; } else if(finalhit) @@ -324,16 +329,16 @@ void W_Crylink_Touch (void) self.projectiledeathtype |= HITTYPE_BOUNCE; // commented out as it causes a little hitch... //if(proj.cnt == 0) - // CSQCProjectile(proj, TRUE, PROJECTILE_CRYLINK, TRUE); + // CSQCProjectile(proj, true, PROJECTILE_CRYLINK, true); } -void W_Crylink_Fadethink (void) +void W_Crylink_Fadethink(void) { W_Crylink_Dequeue(self); remove(self); } -void W_Crylink_Attack (void) +void W_Crylink_Attack(void) { float counter, shots; entity proj, prevproj, firstproj; @@ -348,7 +353,7 @@ void W_Crylink_Attack (void) if(WEP_CVAR_PRI(crylink, joinexplode)) maxdmg += WEP_CVAR_PRI(crylink, joinexplode_damage); - W_SetupShot (self, FALSE, 2, "weapons/crylink_fire.wav", CH_WEAPON_A, maxdmg); + W_SetupShot(self, false, 2, "weapons/crylink_fire.wav", CH_WEAPON_A, maxdmg); forward = v_forward; right = v_right; up = v_up; @@ -358,11 +363,11 @@ void W_Crylink_Attack (void) proj = prevproj = firstproj = world; for(counter = 0; counter < shots; ++counter) { - proj = spawn (); + proj = spawn(); proj.reset = W_Crylink_Reset; proj.realowner = proj.owner = self; proj.classname = "spike"; - proj.bot_dodge = TRUE; + proj.bot_dodge = true; proj.bot_dodgerating = WEP_CVAR_PRI(crylink, damage); if(shots == 1) { proj.queuenext = proj; @@ -389,21 +394,21 @@ void W_Crylink_Attack (void) proj.projectiledeathtype = WEP_CRYLINK; //proj.gravity = 0.001; - setorigin (proj, w_shotorg); + setorigin(proj, w_shotorg); setsize(proj, '0 0 0', '0 0 0'); s = '0 0 0'; - if (counter == 0) + if(counter == 0) s = '0 0 0'; else { makevectors('0 360 0' * (0.75 + (counter - 0.5) / (shots - 1))); - s_y = v_forward_x; - s_z = v_forward_y; + s.y = v_forward.x; + s.z = v_forward.y; } s = s * WEP_CVAR_PRI(crylink, spread) * g_weaponspreadfactor; - W_SetupProjectileVelocityEx(proj, w_shotdir + right * s_y + up * s_z, v_up, WEP_CVAR_PRI(crylink, speed), 0, 0, 0, FALSE); + W_SetupProjVelocity_Explicit(proj, w_shotdir + right * s.y + up * s.z, v_up, WEP_CVAR_PRI(crylink, speed), 0, 0, 0, false); proj.touch = W_Crylink_Touch; proj.think = W_Crylink_Fadethink; @@ -423,14 +428,14 @@ void W_Crylink_Attack (void) proj.cnt = WEP_CVAR_PRI(crylink, bounces); //proj.scale = 1 + 1 * proj.cnt; - proj.angles = vectoangles (proj.velocity); + proj.angles = vectoangles(proj.velocity); //proj.glow_size = 20; proj.flags = FL_PROJECTILE; proj.missile_flags = MIF_SPLASH; - - CSQCProjectile(proj, TRUE, (proj.cnt ? PROJECTILE_CRYLINK_BOUNCING : PROJECTILE_CRYLINK), TRUE); + + CSQCProjectile(proj, true, (proj.cnt ? PROJECTILE_CRYLINK_BOUNCING : PROJECTILE_CRYLINK), true); other = proj; MUTATOR_CALLHOOK(EditProjectile); } @@ -442,7 +447,7 @@ void W_Crylink_Attack (void) } } -void W_Crylink_Attack2 (void) +void W_Crylink_Attack2(void) { float counter, shots; entity proj, prevproj, firstproj; @@ -457,7 +462,7 @@ void W_Crylink_Attack2 (void) if(WEP_CVAR_SEC(crylink, joinexplode)) maxdmg += WEP_CVAR_SEC(crylink, joinexplode_damage); - W_SetupShot (self, FALSE, 2, "weapons/crylink_fire2.wav", CH_WEAPON_A, maxdmg); + W_SetupShot(self, false, 2, "weapons/crylink_fire2.wav", CH_WEAPON_A, maxdmg); forward = v_forward; right = v_right; up = v_up; @@ -467,11 +472,11 @@ void W_Crylink_Attack2 (void) proj = prevproj = firstproj = world; for(counter = 0; counter < shots; ++counter) { - proj = spawn (); + proj = spawn(); proj.reset = W_Crylink_Reset; proj.realowner = proj.owner = self; proj.classname = "spike"; - proj.bot_dodge = TRUE; + proj.bot_dodge = true; proj.bot_dodgerating = WEP_CVAR_SEC(crylink, damage); if(shots == 1) { proj.queuenext = proj; @@ -498,29 +503,29 @@ void W_Crylink_Attack2 (void) proj.projectiledeathtype = WEP_CRYLINK | HITTYPE_SECONDARY; //proj.gravity = 0.001; - setorigin (proj, w_shotorg); + setorigin(proj, w_shotorg); setsize(proj, '0 0 0', '0 0 0'); if(WEP_CVAR_SEC(crylink, spreadtype) == 1) { s = '0 0 0'; - if (counter == 0) + if(counter == 0) s = '0 0 0'; else { makevectors('0 360 0' * (0.75 + (counter - 0.5) / (shots - 1))); - s_y = v_forward_x; - s_z = v_forward_y; + s.y = v_forward.x; + s.z = v_forward.y; } s = s * WEP_CVAR_SEC(crylink, spread) * g_weaponspreadfactor; - s = w_shotdir + right * s_y + up * s_z; + s = w_shotdir + right * s.y + up * s.z; } else { s = (w_shotdir + (((counter + 0.5) / shots) * 2 - 1) * v_right * WEP_CVAR_SEC(crylink, spread) * g_weaponspreadfactor); } - W_SetupProjectileVelocityEx(proj, s, v_up, WEP_CVAR_SEC(crylink, speed), 0, 0, 0, FALSE); + W_SetupProjVelocity_Explicit(proj, s, v_up, WEP_CVAR_SEC(crylink, speed), 0, 0, 0, false); proj.touch = W_Crylink_Touch; proj.think = W_Crylink_Fadethink; if(counter == (shots - 1) / 2) @@ -539,14 +544,14 @@ void W_Crylink_Attack2 (void) proj.cnt = WEP_CVAR_SEC(crylink, bounces); //proj.scale = 1 + 1 * proj.cnt; - proj.angles = vectoangles (proj.velocity); + proj.angles = vectoangles(proj.velocity); //proj.glow_size = 20; proj.flags = FL_PROJECTILE; proj.missile_flags = MIF_SPLASH; - - CSQCProjectile(proj, TRUE, (proj.cnt ? PROJECTILE_CRYLINK_BOUNCING : PROJECTILE_CRYLINK), TRUE); + + CSQCProjectile(proj, true, (proj.cnt ? PROJECTILE_CRYLINK_BOUNCING : PROJECTILE_CRYLINK), true); other = proj; MUTATOR_CALLHOOK(EditProjectile); } @@ -558,29 +563,29 @@ void W_Crylink_Attack2 (void) } } -float w_crylink(float req) +bool W_Crylink(int req) { float ammo_amount; switch(req) { case WR_AIM: { - if (random() < 0.10) - self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(crylink, speed), 0, WEP_CVAR_PRI(crylink, middle_lifetime), FALSE); + if(random() < 0.10) + self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(crylink, speed), 0, WEP_CVAR_PRI(crylink, middle_lifetime), false); else - self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_SEC(crylink, speed), 0, WEP_CVAR_SEC(crylink, middle_lifetime), FALSE); - - return TRUE; + self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_SEC(crylink, speed), 0, WEP_CVAR_SEC(crylink, middle_lifetime), false); + + return true; } case WR_THINK: { if(autocvar_g_balance_crylink_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo))) // forced reload WEP_ACTION(self.weapon, WR_RELOAD); - if (self.BUTTON_ATCK) + if(self.BUTTON_ATCK) { - if (self.crylink_waitrelease != 1) - if (weapon_prepareattack(0, WEP_CVAR_PRI(crylink, refire))) + if(self.crylink_waitrelease != 1) + if(weapon_prepareattack(0, WEP_CVAR_PRI(crylink, refire))) { W_Crylink_Attack(); weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(crylink, animtime), w_ready); @@ -589,17 +594,17 @@ float w_crylink(float req) if(self.BUTTON_ATCK2 && autocvar_g_balance_crylink_secondary) { - if (self.crylink_waitrelease != 2) - if (weapon_prepareattack(1, WEP_CVAR_SEC(crylink, refire))) + if(self.crylink_waitrelease != 2) + if(weapon_prepareattack(1, WEP_CVAR_SEC(crylink, refire))) { W_Crylink_Attack2(); weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(crylink, animtime), w_ready); } } - if ((self.crylink_waitrelease == 1 && !self.BUTTON_ATCK) || (self.crylink_waitrelease == 2 && !self.BUTTON_ATCK2)) + if((self.crylink_waitrelease == 1 && !self.BUTTON_ATCK) || (self.crylink_waitrelease == 2 && !self.BUTTON_ATCK2)) { - if (!self.crylink_lastgroup || time > self.crylink_lastgroup.teleport_time) + if(!self.crylink_lastgroup || time > self.crylink_lastgroup.teleport_time) { // fired and released now! if(self.crylink_lastgroup) @@ -607,7 +612,7 @@ float w_crylink(float req) vector pos; entity linkjoineffect; float isprimary = (self.crylink_waitrelease == 1); - + pos = W_Crylink_LinkJoin(self.crylink_lastgroup, WEP_CVAR_BOTH(crylink, isprimary, joinspread) * WEP_CVAR_BOTH(crylink, isprimary, speed)); linkjoineffect = spawn(); @@ -618,7 +623,7 @@ float w_crylink(float req) setorigin(linkjoineffect, pos); } self.crylink_waitrelease = 0; - if(!w_crylink(WR_CHECKAMMO1) && !w_crylink(WR_CHECKAMMO2)) + if(!W_Crylink(WR_CHECKAMMO1) && !W_Crylink(WR_CHECKAMMO2)) if(!(self.items & IT_UNLIMITED_WEAPON_AMMO)) { // ran out of ammo! @@ -627,27 +632,27 @@ float w_crylink(float req) } } } - - return TRUE; + + return true; } case WR_INIT: { - precache_model ("models/weapons/g_crylink.md3"); - precache_model ("models/weapons/v_crylink.md3"); - precache_model ("models/weapons/h_crylink.iqm"); - precache_sound ("weapons/crylink_fire.wav"); - precache_sound ("weapons/crylink_fire2.wav"); - precache_sound ("weapons/crylink_linkjoin.wav"); - CRYLINK_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP) - return TRUE; + precache_model("models/weapons/g_crylink.md3"); + precache_model("models/weapons/v_crylink.md3"); + precache_model("models/weapons/h_crylink.iqm"); + precache_sound("weapons/crylink_fire.wav"); + precache_sound("weapons/crylink_fire2.wav"); + precache_sound("weapons/crylink_linkjoin.wav"); + CRYLINK_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP); + return true; } case WR_CHECKAMMO1: { // don't "run out of ammo" and switch weapons while waiting for release if(self.crylink_lastgroup && self.crylink_waitrelease) - return TRUE; + return true; - ammo_amount = self.AMMO_VAL(WEP_CRYLINK) >= WEP_CVAR_PRI(crylink, ammo); + ammo_amount = self.WEP_AMMO(CRYLINK) >= WEP_CVAR_PRI(crylink, ammo); ammo_amount += self.(weapon_load[WEP_CRYLINK]) >= WEP_CVAR_PRI(crylink, ammo); return ammo_amount; } @@ -655,21 +660,21 @@ float w_crylink(float req) { // don't "run out of ammo" and switch weapons while waiting for release if(self.crylink_lastgroup && self.crylink_waitrelease) - return TRUE; + return true; - ammo_amount = self.AMMO_VAL(WEP_CRYLINK) >= WEP_CVAR_SEC(crylink, ammo); + ammo_amount = self.WEP_AMMO(CRYLINK) >= WEP_CVAR_SEC(crylink, ammo); ammo_amount += self.(weapon_load[WEP_CRYLINK]) >= WEP_CVAR_SEC(crylink, ammo); return ammo_amount; } case WR_CONFIG: { - CRYLINK_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS) - return TRUE; + CRYLINK_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS); + return true; } case WR_RELOAD: { W_Reload(min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo)), "weapons/reload.wav"); - return TRUE; + return true; } case WR_SUICIDEMESSAGE: { @@ -680,11 +685,11 @@ float w_crylink(float req) return WEAPON_CRYLINK_MURDER; } } - return TRUE; + return false; } #endif #ifdef CSQC -float w_crylink(float req) +bool W_Crylink(int req) { switch(req) { @@ -704,17 +709,22 @@ float w_crylink(float req) if(!w_issilent) sound(self, CH_SHOTS, "weapons/crylink_impact.wav", VOL_BASE, ATTN_NORM); } - - return TRUE; + + return true; } case WR_INIT: { precache_sound("weapons/crylink_impact2.wav"); precache_sound("weapons/crylink_impact.wav"); - return TRUE; + return true; + } + case WR_ZOOMRETICLE: + { + // no weapon specific image for this weapon + return false; } } - return TRUE; + return false; } #endif #endif