X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fcrylink.qc;h=9e2bb47416b890eded0d598ae31b485202557ef7;hb=d271f27a5ac351a3a7b39636932f6d661492be1d;hp=43771079e2b50814d896bb11ec9b6cb4980f12ce;hpb=9a3b01ba5da2726001a5ed74645a15ce764a3675;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc index 43771079e..9e2bb4741 100644 --- a/qcsrc/common/weapons/weapon/crylink.qc +++ b/qcsrc/common/weapons/weapon/crylink.qc @@ -1,59 +1,64 @@ #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") -); - -#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) \ - w_cvar(id, sn, BOTH, ammo) \ - w_cvar(id, sn, BOTH, animtime) \ - w_cvar(id, sn, BOTH, damage) \ - w_cvar(id, sn, BOTH, edgedamage) \ - w_cvar(id, sn, BOTH, radius) \ - w_cvar(id, sn, BOTH, force) \ - w_cvar(id, sn, BOTH, spread) \ - w_cvar(id, sn, BOTH, refire) \ - w_cvar(id, sn, BOTH, speed) \ - w_cvar(id, sn, BOTH, shots) \ - w_cvar(id, sn, BOTH, bounces) \ - w_cvar(id, sn, BOTH, bouncedamagefactor) \ - w_cvar(id, sn, BOTH, middle_lifetime) \ - w_cvar(id, sn, BOTH, middle_fadetime) \ - w_cvar(id, sn, BOTH, other_lifetime) \ - w_cvar(id, sn, BOTH, other_fadetime) \ - w_cvar(id, sn, BOTH, linkexplode) \ - w_cvar(id, sn, BOTH, joindelay) \ - w_cvar(id, sn, BOTH, joinspread) \ - w_cvar(id, sn, BOTH, joinexplode) \ - w_cvar(id, sn, BOTH, joinexplode_damage) \ - w_cvar(id, sn, BOTH, joinexplode_edgedamage) \ - w_cvar(id, sn, BOTH, joinexplode_radius) \ - w_cvar(id, sn, BOTH, joinexplode_force) \ - w_cvar(id, sn, SEC, spreadtype) \ - w_cvar(id, sn, NONE, secondary) \ - w_prop(id, sn, float, reloading_ammo, reload_ammo) \ - w_prop(id, sn, float, reloading_time, reload_time) \ - w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \ - 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, weaponthrowable, weaponthrowable) +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, 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 -CRYLINK_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP) .float gravity; .float crylink_waitrelease; .entity crylink_lastgroup; @@ -64,7 +69,7 @@ CRYLINK_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP) #endif #ifdef IMPLEMENTATION #ifdef SVQC -void spawnfunc_weapon_crylink(void) { weapon_defaultspawnfunc(WEP_CRYLINK.m_id); } +spawnfunc(weapon_crylink) { weapon_defaultspawnfunc(this, WEP_CRYLINK); } void W_Crylink_CheckLinks(entity e) { @@ -106,10 +111,10 @@ void W_Crylink_Dequeue(entity e) W_Crylink_Dequeue_Raw(e.realowner, e.queueprev, e, e.queuenext); } -void W_Crylink_Reset(void) -{SELFPARAM(); - W_Crylink_Dequeue(self); - remove(self); +void W_Crylink_Reset(entity this) +{ + W_Crylink_Dequeue(this); + remove(this); } // force projectile to explode @@ -223,7 +228,7 @@ vector W_Crylink_LinkJoin(entity e, float jspeed) return targ_origin; } -void W_Crylink_LinkJoinEffect_Think(void) +void W_Crylink_LinkJoinEffect_Think() {SELFPARAM(); // is there at least 2 projectiles very close? entity e, p; @@ -273,7 +278,7 @@ float W_Crylink_Touch_WouldHitFriendly(entity projectile, float rad) while(head) { - if((head.takedamage != DAMAGE_NO) && (head.deadflag == DEAD_NO)) + if((head.takedamage != DAMAGE_NO) && (!IS_DEAD(head))) { if(SAME_TEAM(head, projectile.realowner)) ++hit_friendly; @@ -288,7 +293,7 @@ float W_Crylink_Touch_WouldHitFriendly(entity projectile, float rad) } // NO bounce protection, as bounces are limited! -void W_Crylink_Touch(void) +void W_Crylink_Touch() {SELFPARAM(); float finalhit; float f; @@ -333,13 +338,13 @@ void W_Crylink_Touch(void) // CSQCProjectile(proj, true, PROJECTILE_CRYLINK, true); } -void W_Crylink_Fadethink(void) +void W_Crylink_Fadethink() {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; @@ -347,14 +352,14 @@ void W_Crylink_Attack(void) vector forward, right, up; float maxdmg; - W_DecreaseAmmo(WEP_CVAR_PRI(crylink, ammo)); + W_DecreaseAmmo(thiswep, self, 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, SND(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; @@ -364,10 +369,9 @@ void W_Crylink_Attack(void) proj = prevproj = firstproj = world; for(counter = 0; counter < shots; ++counter) { - proj = spawn(); + proj = new(spike); proj.reset = W_Crylink_Reset; proj.realowner = proj.owner = self; - proj.classname = "spike"; proj.bot_dodge = true; proj.bot_dodgerating = WEP_CVAR_PRI(crylink, damage); if(shots == 1) { @@ -448,7 +452,7 @@ void W_Crylink_Attack(void) } } -void W_Crylink_Attack2(void) +void W_Crylink_Attack2(Weapon thiswep) {SELFPARAM(); float counter, shots; entity proj, prevproj, firstproj; @@ -456,14 +460,14 @@ void W_Crylink_Attack2(void) vector forward, right, up; float maxdmg; - W_DecreaseAmmo(WEP_CVAR_SEC(crylink, ammo)); + W_DecreaseAmmo(thiswep, self, 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, SND(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; @@ -473,10 +477,9 @@ void W_Crylink_Attack2(void) proj = prevproj = firstproj = world; for(counter = 0; counter < shots; ++counter) { - proj = spawn(); + proj = new(spike); proj.reset = W_Crylink_Reset; proj.realowner = proj.owner = self; - proj.classname = "spike"; proj.bot_dodge = true; proj.bot_dodgerating = WEP_CVAR_SEC(crylink, damage); if(shots == 1) { @@ -564,160 +567,124 @@ void W_Crylink_Attack2(void) } } -bool W_Crylink(int req) -{SELFPARAM(); - 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); - else - 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.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); - } - } - - if(self.BUTTON_ATCK2 && autocvar_g_balance_crylink_secondary) - { - 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_lastgroup || time > self.crylink_lastgroup.teleport_time) - { - // fired and released now! - if(self.crylink_lastgroup) - { - 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(); - linkjoineffect.think = W_Crylink_LinkJoinEffect_Think; - linkjoineffect.classname = "linkjoineffect"; - linkjoineffect.nextthink = time + w_crylink_linkjoin_time; - linkjoineffect.owner = self; - setorigin(linkjoineffect, pos); - } - self.crylink_waitrelease = 0; - if(!W_Crylink(WR_CHECKAMMO1) && !W_Crylink(WR_CHECKAMMO2)) - if(!(self.items & IT_UNLIMITED_WEAPON_AMMO)) - { - // ran out of ammo! - self.cnt = WEP_CRYLINK.m_id; - self.switchweapon = w_getbestweapon(self); - } - } - } - - return true; - } - case WR_INIT: - { - 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; - - 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: - { - // 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); - ammo_amount += self.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_SEC(crylink, ammo); - return ammo_amount; - } - case WR_CONFIG: - { - 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)), SND(RELOAD)); - return true; - } - case WR_SUICIDEMESSAGE: - { - return WEAPON_CRYLINK_SUICIDE; - } - case WR_KILLMESSAGE: - { - return WEAPON_CRYLINK_MURDER; - } - } - return false; +METHOD(Crylink, wr_aim, void(entity thiswep)) +{ + SELFPARAM(); + if(random() < 0.10) + PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(self, WEP_CVAR_PRI(crylink, speed), 0, WEP_CVAR_PRI(crylink, middle_lifetime), false); + else + PHYS_INPUT_BUTTON_ATCK2(self) = bot_aim(self, WEP_CVAR_SEC(crylink, speed), 0, WEP_CVAR_SEC(crylink, middle_lifetime), false); +} +METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) +{ + if(autocvar_g_balance_crylink_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo))) { // forced reload + thiswep.wr_reload(thiswep, actor, weaponentity); + } + + if(fire & 1) + { + if(actor.crylink_waitrelease != 1) + if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(crylink, refire))) + { + W_Crylink_Attack(thiswep); + weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(crylink, animtime), w_ready); + } + } + + if((fire & 2) && autocvar_g_balance_crylink_secondary) + { + if(actor.crylink_waitrelease != 2) + if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(crylink, refire))) + { + W_Crylink_Attack2(thiswep); + weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(crylink, animtime), w_ready); + } + } + + if((actor.crylink_waitrelease == 1 && !(fire & 1)) || (actor.crylink_waitrelease == 2 && !(fire & 2))) + { + if(!actor.crylink_lastgroup || time > actor.crylink_lastgroup.teleport_time) + { + // fired and released now! + if(actor.crylink_lastgroup) + { + vector pos; + entity linkjoineffect; + float isprimary = (actor.crylink_waitrelease == 1); + + pos = W_Crylink_LinkJoin(actor.crylink_lastgroup, WEP_CVAR_BOTH(crylink, isprimary, joinspread) * WEP_CVAR_BOTH(crylink, isprimary, speed)); + + linkjoineffect = new(linkjoineffect); + linkjoineffect.think = W_Crylink_LinkJoinEffect_Think; + linkjoineffect.nextthink = time + w_crylink_linkjoin_time; + linkjoineffect.owner = actor; + setorigin(linkjoineffect, pos); + } + actor.crylink_waitrelease = 0; + if(!thiswep.wr_checkammo1(thiswep) && !thiswep.wr_checkammo2(thiswep)) + if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) + { + // ran out of ammo! + actor.cnt = WEP_CRYLINK.m_id; + PS(actor).m_switchweapon = w_getbestweapon(actor); + } + } + } +} +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; + + float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(crylink, ammo); + ammo_amount += self.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_PRI(crylink, ammo); + return ammo_amount; +} +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; + + float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(crylink, ammo); + ammo_amount += self.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_SEC(crylink, ammo); + return ammo_amount; +} +METHOD(Crylink, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) +{ + SELFPARAM(); + W_Reload(self, min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo)), SND_RELOAD); +} +METHOD(Crylink, wr_suicidemessage, Notification(entity thiswep)) +{ + return WEAPON_CRYLINK_SUICIDE; +} +METHOD(Crylink, wr_killmessage, Notification(entity thiswep)) +{ + return WEAPON_CRYLINK_MURDER; } #endif #ifdef CSQC -bool W_Crylink(int req) -{SELFPARAM(); - switch(req) - { - case WR_IMPACTEFFECT: - { - 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, 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, SND_CRYLINK_IMPACT, VOL_BASE, ATTN_NORM); - } - - return true; - } - case WR_INIT: - { - return true; - } - case WR_ZOOMRETICLE: - { - // no weapon specific image for this weapon - return false; - } - } - return false; +METHOD(Crylink, wr_impacteffect, void(entity thiswep)) +{ + SELFPARAM(); + vector org2; + org2 = w_org + w_backoff * 2; + if(w_deathtype & HITTYPE_SECONDARY) + { + pointparticles(EFFECT_CRYLINK_IMPACT2, org2, '0 0 0', 1); + if(!w_issilent) + sound(self, CH_SHOTS, SND_CRYLINK_IMPACT2, VOL_BASE, ATTN_NORM); + } + else + { + pointparticles(EFFECT_CRYLINK_IMPACT, org2, '0 0 0', 1); + if(!w_issilent) + sound(self, CH_SHOTS, SND_CRYLINK_IMPACT, VOL_BASE, ATTN_NORM); + } } #endif #endif