X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fcrylink.qc;h=efa5387646bbf73721a4fd9442f1bcc0d18d3780;hb=6a52ab75ebcb03896b2520de3a18f874c86b214d;hp=08deaf78c4a81e5ade345c1e9fd8590e5fb194bf;hpb=a81365864859ecccf601a8e50768322b6012e90c;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc index 08deaf78c..efa538764 100644 --- a/qcsrc/common/weapons/weapon/crylink.qc +++ b/qcsrc/common/weapons/weapon/crylink.qc @@ -1,19 +1,21 @@ #ifndef IMPLEMENTATION -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, -/* color */ '1 0.5 1', -/* modelname */ "crylink", -/* simplemdl */ "foobar", -/* crosshair */ "gfx/crosshaircrylink 0.5", -/* wepimg */ "weaponcrylink", -/* refname */ "crylink", -/* wepname */ _("Crylink") -); +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); +/* rating */ ATTRIB(Crylink, bot_pickupbasevalue, float, BOT_PICKUP_RATING_MID); +/* color */ ATTRIB(Crylink, wpcolor, vector, '1 0.5 1'); +/* modelname */ ATTRIB(Crylink, mdl, string, "crylink"); +#ifndef MENUQC +/* 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, message, string, _("Crylink")); +ENDCLASS(Crylink) +REGISTER_WEAPON(CRYLINK, NEW(Crylink)); #define CRYLINK_SETTINGS(w_cvar,w_prop) CRYLINK_SETTINGS_LIST(w_cvar, w_prop, CRYLINK, crylink) #define CRYLINK_SETTINGS_LIST(w_cvar,w_prop,id,sn) \ @@ -107,7 +109,7 @@ void W_Crylink_Dequeue(entity e) } void W_Crylink_Reset(void) -{ +{SELFPARAM(); W_Crylink_Dequeue(self); remove(self); } @@ -224,7 +226,7 @@ vector W_Crylink_LinkJoin(entity e, float jspeed) } void W_Crylink_LinkJoinEffect_Think(void) -{ +{SELFPARAM(); // is there at least 2 projectiles very close? entity e, p; float n; @@ -289,7 +291,7 @@ float W_Crylink_Touch_WouldHitFriendly(entity projectile, float rad) // NO bounce protection, as bounces are limited! void W_Crylink_Touch(void) -{ +{SELFPARAM(); float finalhit; float f; float isprimary = !(self.projectiledeathtype & HITTYPE_SECONDARY); @@ -334,27 +336,27 @@ void W_Crylink_Touch(void) } void W_Crylink_Fadethink(void) -{ +{SELFPARAM(); W_Crylink_Dequeue(self); remove(self); } -void W_Crylink_Attack(void) -{ +void W_Crylink_Attack(Weapon thiswep) +{SELFPARAM(); float counter, shots; entity proj, prevproj, firstproj; vector s; vector forward, right, up; float maxdmg; - W_DecreaseAmmo(WEP_CVAR_PRI(crylink, ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR_PRI(crylink, ammo)); maxdmg = WEP_CVAR_PRI(crylink, damage) * WEP_CVAR_PRI(crylink, shots); maxdmg *= 1 + WEP_CVAR_PRI(crylink, bouncedamagefactor) * WEP_CVAR_PRI(crylink, bounces); if(WEP_CVAR_PRI(crylink, joinexplode)) maxdmg += WEP_CVAR_PRI(crylink, joinexplode_damage); - W_SetupShot(self, false, 2, W_Sound("crylink_fire"), CH_WEAPON_A, maxdmg); + W_SetupShot(self, false, 2, SND(CRYLINK_FIRE), CH_WEAPON_A, maxdmg); forward = v_forward; right = v_right; up = v_up; @@ -448,22 +450,22 @@ void W_Crylink_Attack(void) } } -void W_Crylink_Attack2(void) -{ +void W_Crylink_Attack2(Weapon thiswep) +{SELFPARAM(); float counter, shots; entity proj, prevproj, firstproj; vector s; vector forward, right, up; float maxdmg; - W_DecreaseAmmo(WEP_CVAR_SEC(crylink, ammo)); + W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(crylink, ammo)); maxdmg = WEP_CVAR_SEC(crylink, damage) * WEP_CVAR_SEC(crylink, shots); maxdmg *= 1 + WEP_CVAR_SEC(crylink, bouncedamagefactor) * WEP_CVAR_SEC(crylink, bounces); if(WEP_CVAR_SEC(crylink, joinexplode)) maxdmg += WEP_CVAR_SEC(crylink, joinexplode_damage); - W_SetupShot(self, false, 2, W_Sound("crylink_fire2"), CH_WEAPON_A, maxdmg); + W_SetupShot(self, false, 2, SND(CRYLINK_FIRE2), CH_WEAPON_A, maxdmg); forward = v_forward; right = v_right; up = v_up; @@ -564,13 +566,9 @@ void W_Crylink_Attack2(void) } } -bool W_Crylink(int req) -{ - float ammo_amount; - switch(req) - { - case WR_AIM: + METHOD(Crylink, wr_aim, bool(entity thiswep)) { + SELFPARAM(); if(random() < 0.10) self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(crylink, speed), 0, WEP_CVAR_PRI(crylink, middle_lifetime), false); else @@ -578,32 +576,35 @@ bool W_Crylink(int req) return true; } - case WR_THINK: + METHOD(Crylink, wr_think, bool(entity thiswep, bool fire1, bool fire2)) { - 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); + SELFPARAM(); + if(autocvar_g_balance_crylink_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo))) { // forced reload + Weapon w = get_weaponinfo(self.weapon); + w.wr_reload(w); + } - if(self.BUTTON_ATCK) + if(fire1) { if(self.crylink_waitrelease != 1) - if(weapon_prepareattack(0, WEP_CVAR_PRI(crylink, refire))) + if(weapon_prepareattack(false, WEP_CVAR_PRI(crylink, refire))) { - W_Crylink_Attack(); + W_Crylink_Attack(thiswep); weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(crylink, animtime), w_ready); } } - if(self.BUTTON_ATCK2 && autocvar_g_balance_crylink_secondary) + if(fire2 && autocvar_g_balance_crylink_secondary) { if(self.crylink_waitrelease != 2) - if(weapon_prepareattack(1, WEP_CVAR_SEC(crylink, refire))) + if(weapon_prepareattack(true, WEP_CVAR_SEC(crylink, refire))) { - W_Crylink_Attack2(); + W_Crylink_Attack2(thiswep); 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 && !fire1) || (self.crylink_waitrelease == 2 && !fire2)) { if(!self.crylink_lastgroup || time > self.crylink_lastgroup.teleport_time) { @@ -624,7 +625,7 @@ bool W_Crylink(int req) setorigin(linkjoineffect, pos); } self.crylink_waitrelease = 0; - if(!W_Crylink(WR_CHECKAMMO1) && !W_Crylink(WR_CHECKAMMO2)) + if(!thiswep.wr_checkammo1(thiswep) && !thiswep.wr_checkammo2(thiswep)) if(!(self.items & IT_UNLIMITED_WEAPON_AMMO)) { // ran out of ammo! @@ -636,96 +637,81 @@ bool W_Crylink(int req) return true; } - case WR_INIT: + METHOD(Crylink, wr_init, bool(entity thiswep)) { - precache_model(W_Model("g_crylink.md3")); - precache_model(W_Model("v_crylink.md3")); - precache_model(W_Model("h_crylink.iqm")); - precache_sound(W_Sound("crylink_fire")); - precache_sound(W_Sound("crylink_fire2")); - precache_sound(W_Sound("crylink_linkjoin")); CRYLINK_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP); return true; } - case WR_CHECKAMMO1: + METHOD(Crylink, wr_checkammo1, bool(entity thiswep)) { + SELFPARAM(); // don't "run out of ammo" and switch weapons while waiting for release if(self.crylink_lastgroup && self.crylink_waitrelease) return true; - ammo_amount = self.WEP_AMMO(CRYLINK) >= WEP_CVAR_PRI(crylink, ammo); + float ammo_amount = self.WEP_AMMO(CRYLINK) >= WEP_CVAR_PRI(crylink, ammo); ammo_amount += self.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_PRI(crylink, ammo); return ammo_amount; } - case WR_CHECKAMMO2: + METHOD(Crylink, wr_checkammo2, bool(entity thiswep)) { + SELFPARAM(); // don't "run out of ammo" and switch weapons while waiting for release if(self.crylink_lastgroup && self.crylink_waitrelease) return true; - ammo_amount = self.WEP_AMMO(CRYLINK) >= WEP_CVAR_SEC(crylink, ammo); + float ammo_amount = self.WEP_AMMO(CRYLINK) >= WEP_CVAR_SEC(crylink, ammo); ammo_amount += self.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_SEC(crylink, ammo); return ammo_amount; } - case WR_CONFIG: + METHOD(Crylink, wr_config, bool(entity thiswep)) { CRYLINK_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS); return true; } - case WR_RELOAD: + METHOD(Crylink, wr_reload, bool(entity thiswep)) { - W_Reload(min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo)), W_Sound("reload")); + W_Reload(min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo)), SND(RELOAD)); return true; } - case WR_SUICIDEMESSAGE: + METHOD(Crylink, wr_suicidemessage, bool(entity thiswep)) { return WEAPON_CRYLINK_SUICIDE; } - case WR_KILLMESSAGE: + METHOD(Crylink, wr_killmessage, bool(entity thiswep)) { return WEAPON_CRYLINK_MURDER; } - } - return false; -} #endif #ifdef CSQC -bool W_Crylink(int req) -{ - switch(req) - { - case WR_IMPACTEFFECT: + METHOD(Crylink, wr_impacteffect, bool(entity thiswep)) { + SELFPARAM(); vector org2; org2 = w_org + w_backoff * 2; if(w_deathtype & HITTYPE_SECONDARY) { pointparticles(particleeffectnum(EFFECT_CRYLINK_IMPACT2), org2, '0 0 0', 1); if(!w_issilent) - sound(self, CH_SHOTS, W_Sound("crylink_impact2"), VOL_BASE, ATTN_NORM); + sound(self, CH_SHOTS, SND_CRYLINK_IMPACT2, VOL_BASE, ATTN_NORM); } else { pointparticles(particleeffectnum(EFFECT_CRYLINK_IMPACT), org2, '0 0 0', 1); if(!w_issilent) - sound(self, CH_SHOTS, W_Sound("crylink_impact"), VOL_BASE, ATTN_NORM); + sound(self, CH_SHOTS, SND_CRYLINK_IMPACT, VOL_BASE, ATTN_NORM); } return true; } - case WR_INIT: + METHOD(Crylink, wr_init, bool(entity thiswep)) { - precache_sound(W_Sound("crylink_impact2")); - precache_sound(W_Sound("crylink_impact")); return true; } - case WR_ZOOMRETICLE: + METHOD(Crylink, wr_zoomreticle, bool(entity thiswep)) { // no weapon specific image for this weapon return false; } - } - return false; -} #endif #endif