X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fshotgun.qc;h=fe465e52848bf34d739c8a650bdda87436c8c8a1;hp=b873a9aeb99525aa31f9c54d71d8d29003328a6a;hb=bc3f297ed082b23fb33dd0d8f5dcd33bb0198507;hpb=1a463f974e1c026a16a76dd042ebccb1085ad985 diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index b873a9aeb..fe465e528 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -1,71 +1,15 @@ #include "shotgun.qh" -#ifndef IMPLEMENTATION -CLASS(Shotgun, Weapon) -/* ammotype */ ATTRIB(Shotgun, ammo_field, .int, ammo_shells); -/* impulse */ ATTRIB(Shotgun, impulse, int, 2); -/* flags */ ATTRIB(Shotgun, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN | WEP_TYPE_MELEE_SEC); -/* rating */ ATTRIB(Shotgun, bot_pickupbasevalue, float, 6000); -/* color */ ATTRIB(Shotgun, wpcolor, vector, '0.5 0.25 0'); -/* modelname */ ATTRIB(Shotgun, mdl, string, "shotgun"); -#ifdef GAMEQC -/* model */ ATTRIB(Shotgun, m_model, Model, MDL_SHOTGUN_ITEM); -#endif -/* crosshair */ ATTRIB(Shotgun, w_crosshair, string, "gfx/crosshairshotgun"); -/* crosshair */ ATTRIB(Shotgun, w_crosshair_size, float, 0.65); -/* wepimg */ ATTRIB(Shotgun, model2, string, "weaponshotgun"); -/* refname */ ATTRIB(Shotgun, netname, string, "shotgun"); -/* wepname */ ATTRIB(Shotgun, m_name, string, _("Shotgun")); - -#define X(BEGIN, P, END, class, prefix) \ - BEGIN(class) \ - P(class, prefix, alt_animtime, float, SEC) \ - P(class, prefix, alt_refire, float, SEC) \ - P(class, prefix, ammo, float, PRI) \ - P(class, prefix, animtime, float, BOTH) \ - P(class, prefix, bullets, float, PRI) \ - P(class, prefix, damage, float, BOTH) \ - P(class, prefix, force, float, BOTH) \ - P(class, prefix, melee_delay, float, SEC) \ - P(class, prefix, melee_multihit, float, SEC) \ - P(class, prefix, melee_nonplayerdamage, float, SEC) \ - P(class, prefix, melee_no_doubleslap, float, SEC) \ - P(class, prefix, melee_range, float, SEC) \ - P(class, prefix, melee_swing_side, float, SEC) \ - P(class, prefix, melee_swing_up, float, SEC) \ - P(class, prefix, melee_time, float, SEC) \ - P(class, prefix, melee_traces, float, SEC) \ - 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, solidpenetration, float, PRI) \ - P(class, prefix, spread, float, PRI) \ - 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, Shotgun, shotgun) -#undef X - -ENDCLASS(Shotgun) -REGISTER_WEAPON(SHOTGUN, shotgun, NEW(Shotgun)); - -#endif -#ifdef IMPLEMENTATION #ifdef SVQC -spawnfunc(weapon_shotgun) { weapon_defaultspawnfunc(this, WEP_SHOTGUN); } void W_Shotgun_Attack(Weapon thiswep, entity actor, .entity weaponentity, float isprimary, float ammocount, float damage, float bullets, float spread, float solidpenetration, float force) { W_DecreaseAmmo(thiswep, actor, ammocount, weaponentity); - W_SetupShot(actor, weaponentity, true, 5, SND_SHOTGUN_FIRE, ((isprimary) ? CH_WEAPON_A : CH_WEAPON_SINGLE), damage * bullets); + W_SetupShot(actor, weaponentity, true, 5, SND_SHOTGUN_FIRE, ((isprimary) ? CH_WEAPON_A : CH_WEAPON_SINGLE), damage * bullets, WEP_SHOTGUN.m_id); for(int sc = 0;sc < bullets;sc = sc + 1) - fireBullet(actor, weaponentity, w_shotorg, w_shotdir, spread, solidpenetration, damage, force, WEP_SHOTGUN.m_id, 0); + fireBullet(actor, weaponentity, w_shotorg, w_shotdir, spread, solidpenetration, damage, force, WEP_SHOTGUN.m_id, EFFECT_RIFLE_WEAK); + Send_Effect(EFFECT_SHOTGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, ammocount); @@ -125,7 +69,7 @@ void W_Shotgun_Melee_Think(entity this) + (v_up * swing_factor * WEP_CVAR_SEC(shotgun, melee_swing_up)) + (v_right * swing_factor * WEP_CVAR_SEC(shotgun, melee_swing_side))); - WarpZone_traceline_antilag(this, this.realowner.origin + this.realowner.view_ofs, targpos, false, this.realowner, ANTILAG_LATENCY(this.realowner)); + WarpZone_traceline_antilag(this.realowner, this.realowner.origin + this.realowner.view_ofs, targpos, false, this.realowner, ((IS_CLIENT(this.realowner)) ? ANTILAG_LATENCY(this.realowner) : 0)); // draw lightning beams for debugging //te_lightning2(NULL, targpos, this.realowner.origin + this.realowner.view_ofs + v_forward * 5 - v_up * 5); @@ -134,7 +78,7 @@ void W_Shotgun_Melee_Think(entity this) is_player = (IS_PLAYER(trace_ent) || trace_ent.classname == "body" || IS_MONSTER(trace_ent)); if((trace_fraction < 1) // if trace is good, apply the damage and remove this - && (trace_ent.takedamage == DAMAGE_AIM) + && (trace_ent.takedamage != DAMAGE_NO) && (trace_ent != this.swing_alreadyhit) && (is_player || WEP_CVAR_SEC(shotgun, melee_nonplayerdamage))) { @@ -148,7 +92,7 @@ void W_Shotgun_Melee_Think(entity this) //print(strcat(this.realowner.netname, " hitting ", target_victim.netname, " with ", strcat(ftos(swing_damage), " damage (factor: ", ftos(swing_factor), ") at "), ftos(time), " seconds.\n")); Damage(target_victim, this.realowner, this.realowner, - swing_damage, WEP_SHOTGUN.m_id | HITTYPE_SECONDARY, + swing_damage, WEP_SHOTGUN.m_id | HITTYPE_SECONDARY, this.weaponentity_fld, this.realowner.origin + this.realowner.view_ofs, v_forward * WEP_CVAR_SEC(shotgun, force)); @@ -193,7 +137,8 @@ void W_Shotgun_Attack2(Weapon thiswep, entity actor, .entity weaponentity, int f meleetemp.realowner = actor; setthink(meleetemp, W_Shotgun_Melee_Think); meleetemp.nextthink = time + WEP_CVAR_SEC(shotgun, melee_delay) * W_WeaponRateFactor(actor); - W_SetupShot_Range(actor, weaponentity, true, 0, SND_Null, 0, WEP_CVAR_SEC(shotgun, damage), WEP_CVAR_SEC(shotgun, melee_range)); + meleetemp.weaponentity_fld = weaponentity; + W_SetupShot_Range(actor, weaponentity, true, 0, SND_Null, 0, WEP_CVAR_SEC(shotgun, damage), WEP_CVAR_SEC(shotgun, melee_range), WEP_SHOTGUN.m_id | HITTYPE_SECONDARY); } // alternate secondary weapon frames @@ -297,7 +242,7 @@ METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentit } if(actor.(weaponentity).clip_load >= 0) // we are not currently reloading if(WEP_CVAR(shotgun, secondary) == 1) - if(((fire & 1) && actor.(thiswep.ammo_field) <= 0 && !(actor.items & IT_UNLIMITED_WEAPON_AMMO)) || (fire & 2)) + if(((fire & 1) && GetResourceAmount(actor, thiswep.ammo_type) <= 0 && !(actor.items & IT_UNLIMITED_WEAPON_AMMO)) || (fire & 2)) if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(shotgun, refire))) { // attempt forcing playback of the anim by switching to another anim (that we never play) here... @@ -306,7 +251,7 @@ METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentit } METHOD(Shotgun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(shotgun, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(shotgun, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo); return ammo_amount; } @@ -320,7 +265,7 @@ METHOD(Shotgun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weapon case 1: return true; // melee does not use ammo case 2: // secondary triple shot { - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(shotgun, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(shotgun, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo); return ammo_amount; } @@ -360,4 +305,3 @@ METHOD(Shotgun, wr_impacteffect, void(entity thiswep, entity actor)) } #endif -#endif