X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Farc.qc;h=23e3dbcb2bc8d235e2921f45ab8803570bd0ea35;hb=7198f69860902c5f8bd6b200db25101353b91316;hp=88ba1c768c63cacf23e4ac0524f8dbb181ea13e6;hpb=f03ecd022b871d302176764d819b1a07eeda7997;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 88ba1c768..23e3dbcb2 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -1,151 +1,6 @@ #include "arc.qh" -#ifndef IMPLEMENTATION -CLASS(Arc, Weapon) -/* ammotype */ ATTRIB(Arc, ammo_field, .int, ammo_cells); -/* impulse */ ATTRIB(Arc, impulse, int, 3); -/* flags */ ATTRIB(Arc, spawnflags, int, WEP_FLAG_NORMAL); -/* rating */ ATTRIB(Arc, bot_pickupbasevalue, float, BOT_PICKUP_RATING_HIGH); -/* color */ ATTRIB(Arc, wpcolor, vector, '1 1 1'); -/* modelname */ ATTRIB(Arc, mdl, string, "arc"); -#ifdef GAMEQC -/* model */ ATTRIB(Arc, m_model, Model, MDL_ARC_ITEM); -#endif -/* crosshair */ ATTRIB(Arc, w_crosshair, string, "gfx/crosshairhlac"); -/* crosshair */ ATTRIB(Arc, w_crosshair_size, float, 0.7); -/* wepimg */ ATTRIB(Arc, model2, string, "weaponarc"); -/* refname */ ATTRIB(Arc, netname, string, "arc"); -/* wepname */ ATTRIB(Arc, m_name, string, _("Arc")); - -#define X(BEGIN, P, END, class, prefix) \ - BEGIN(class) \ - P(class, prefix, bolt, float, NONE) \ - P(class, prefix, bolt_ammo, float, NONE) \ - P(class, prefix, bolt_damageforcescale, float, NONE) \ - P(class, prefix, bolt_damage, float, NONE) \ - P(class, prefix, bolt_edgedamage, float, NONE) \ - P(class, prefix, bolt_force, float, NONE) \ - P(class, prefix, bolt_health, float, NONE) \ - P(class, prefix, bolt_lifetime, float, NONE) \ - P(class, prefix, bolt_radius, float, NONE) \ - P(class, prefix, bolt_refire, float, NONE) \ - P(class, prefix, bolt_speed, float, NONE) \ - P(class, prefix, bolt_spread, float, NONE) \ - P(class, prefix, beam_ammo, float, NONE) \ - P(class, prefix, beam_animtime, float, NONE) \ - P(class, prefix, beam_botaimlifetime, float, NONE) \ - P(class, prefix, beam_botaimspeed, float, NONE) \ - P(class, prefix, beam_damage, float, NONE) \ - P(class, prefix, beam_degreespersegment, float, NONE) \ - P(class, prefix, beam_distancepersegment, float, NONE) \ - P(class, prefix, beam_falloff_halflifedist, float, NONE) \ - P(class, prefix, beam_falloff_maxdist, float, NONE) \ - P(class, prefix, beam_falloff_mindist, float, NONE) \ - P(class, prefix, beam_force, float, NONE) \ - P(class, prefix, beam_healing_amax, float, NONE) \ - P(class, prefix, beam_healing_aps, float, NONE) \ - P(class, prefix, beam_healing_hmax, float, NONE) \ - P(class, prefix, beam_healing_hps, float, NONE) \ - P(class, prefix, beam_heat, float, NONE) /* heat increase per second (primary) */ \ - P(class, prefix, beam_maxangle, float, NONE) \ - P(class, prefix, beam_nonplayerdamage, float, NONE) \ - P(class, prefix, beam_range, float, NONE) \ - P(class, prefix, beam_refire, float, NONE) \ - P(class, prefix, beam_returnspeed, float, NONE) \ - P(class, prefix, beam_tightness, float, NONE) \ - P(class, prefix, burst_ammo, float, NONE) \ - P(class, prefix, burst_damage, float, NONE) \ - P(class, prefix, burst_healing_aps, float, NONE) \ - P(class, prefix, burst_healing_hps, float, NONE) \ - P(class, prefix, burst_heat, float, NONE) /* heat increase per second (secondary) */ \ - P(class, prefix, cooldown, float, NONE) /* heat decrease per second when resting */ \ - P(class, prefix, cooldown_release, float, NONE) /* delay weapon re-use when releasing button */ \ - P(class, prefix, overheat_max, float, NONE) /* maximum heat before jamming */ \ - P(class, prefix, overheat_min, float, NONE) /* minimum heat to wait for cooldown */ \ - 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, Arc, arc) -#undef X - -ENDCLASS(Arc) -REGISTER_WEAPON(ARC, arc, NEW(Arc)); - - -#ifdef GAMEQC -const float ARC_MAX_SEGMENTS = 20; -vector arc_shotorigin[4]; -.vector beam_start; -.vector beam_dir; -.vector beam_wantdir; -.int beam_type; - -const int ARC_BT_MISS = 0x00; -const int ARC_BT_WALL = 0x01; -const int ARC_BT_HEAL = 0x02; -const int ARC_BT_HIT = 0x03; -const int ARC_BT_BURST_MISS = 0x10; -const int ARC_BT_BURST_WALL = 0x11; -const int ARC_BT_BURST_HEAL = 0x12; -const int ARC_BT_BURST_HIT = 0x13; -const int ARC_BT_BURSTMASK = 0x10; - -const int ARC_SF_SETTINGS = BIT(0); -const int ARC_SF_START = BIT(1); -const int ARC_SF_WANTDIR = BIT(2); -const int ARC_SF_BEAMDIR = BIT(3); -const int ARC_SF_BEAMTYPE = BIT(4); -const int ARC_SF_LOCALMASK = ARC_SF_START | ARC_SF_WANTDIR | ARC_SF_BEAMDIR; -#endif -#ifdef SVQC -.entity arc_beam; -.bool arc_BUTTON_ATCK_prev; // for better animation control -.float beam_prev; -.float beam_initialized; -.float beam_bursting; -.float beam_teleporttime; -.float beam_heat; // (beam) amount of heat produced -.float arc_overheat; // (dropped arc/player) time during which it's too hot -.float arc_cooldown; // (dropped arc/player) cooling speed -.float arc_heat_percent = _STAT(ARC_HEAT); -.float arc_smoke_sound; -#endif -#ifdef CSQC -.vector beam_color; -.float beam_alpha; -.float beam_thickness; -.entity beam_traileffect; -.entity beam_hiteffect; -.float beam_hitlight[4]; // 0: radius, 123: rgb -.entity beam_muzzleeffect; -.float beam_muzzlelight[4]; // 0: radius, 123: rgb -.string beam_image; - -.entity beam_muzzleentity; - -.float beam_degreespersegment; -.float beam_distancepersegment; -.float beam_usevieworigin; -.float beam_initialized; -.float beam_maxangle; -.float beam_range; -.float beam_returnspeed; -.float beam_tightness; -.vector beam_shotorigin; - -entity Draw_ArcBeam_callback_entity; -float Draw_ArcBeam_callback_last_thickness; -vector Draw_ArcBeam_callback_last_top; // NOTE: in same coordinate system as player. -vector Draw_ArcBeam_callback_last_bottom; // NOTE: in same coordinate system as player. -#endif -#endif -#ifdef IMPLEMENTATION #ifdef SVQC -spawnfunc(weapon_arc) { weapon_defaultspawnfunc(this, WEP_ARC); } bool W_Arc_Beam_Send(entity this, entity to, int sf) { @@ -317,14 +172,15 @@ void W_Arc_Attack_Bolt(Weapon thiswep, entity actor, .entity weaponentity) void W_Arc_Beam_Think(entity this) { .entity weaponentity = this.weaponentity_fld; - if(this != this.owner.(weaponentity).arc_beam) + entity own = this.owner; + if(this != own.(weaponentity).arc_beam) { delete(this); return; } float burst = 0; - if( (PHYS_INPUT_BUTTON_ATCK2(this.owner) && !WEP_CVAR(arc, bolt)) || this.beam_bursting) + if( (PHYS_INPUT_BUTTON_ATCK2(own) && !WEP_CVAR(arc, bolt)) || this.beam_bursting) { if(!this.beam_bursting) this.beam_bursting = true; @@ -334,19 +190,19 @@ void W_Arc_Beam_Think(entity this) Weapon thiswep = WEP_ARC; if( - !IS_PLAYER(this.owner) + !IS_PLAYER(own) || - (this.owner.(thiswep.ammo_field) <= 0 && !(this.owner.items & IT_UNLIMITED_WEAPON_AMMO)) + (!thiswep.wr_checkammo1(thiswep, own, weaponentity) && !(own.items & IT_UNLIMITED_WEAPON_AMMO)) || - IS_DEAD(this.owner) + IS_DEAD(own) || - forbidWeaponUse(this.owner) + forbidWeaponUse(own) || - this.owner.(weaponentity).m_switchweapon != WEP_ARC + own.(weaponentity).m_switchweapon != WEP_ARC || - (!PHYS_INPUT_BUTTON_ATCK(this.owner) && !burst ) + (!PHYS_INPUT_BUTTON_ATCK(own) && !burst ) || - this.owner.vehicle + own.vehicle || (WEP_CVAR(arc, overheat_max) > 0 && this.beam_heat >= WEP_CVAR(arc, overheat_max)) ) @@ -366,8 +222,8 @@ void W_Arc_Beam_Think(entity this) if ( cooldown_speed ) { if ( WEP_CVAR(arc, cooldown_release) || (WEP_CVAR(arc, overheat_max) > 0 && this.beam_heat >= WEP_CVAR(arc, overheat_max)) ) - this.owner.arc_overheat = time + this.beam_heat / cooldown_speed; - this.owner.arc_cooldown = cooldown_speed; + own.arc_overheat = time + this.beam_heat / cooldown_speed; + own.arc_cooldown = cooldown_speed; } if ( WEP_CVAR(arc, overheat_max) > 0 && this.beam_heat >= WEP_CVAR(arc, overheat_max) ) @@ -378,14 +234,12 @@ void W_Arc_Beam_Think(entity this) } } - if(this == this.owner.(weaponentity).arc_beam) { this.owner.(weaponentity).arc_beam = NULL; } - entity own = this.owner; - Weapon w = WEP_ARC; - if(!w.wr_checkammo1(w, own, weaponentity) && !w.wr_checkammo2(w, own, weaponentity)) - if(!(own.items & IT_UNLIMITED_WEAPON_AMMO)) + if(this == own.(weaponentity).arc_beam) { own.(weaponentity).arc_beam = NULL; } + if(!thiswep.wr_checkammo1(thiswep, own, weaponentity) && !(own.items & IT_UNLIMITED_WEAPON_AMMO)) { // note: this doesn't force the switch W_SwitchToOtherWeapon(own, weaponentity); + own.(weaponentity).arc_BUTTON_ATCK_prev = false; // hax } delete(this); return; @@ -393,7 +247,7 @@ void W_Arc_Beam_Think(entity this) // decrease ammo float coefficient = frametime; - if(!(this.owner.items & IT_UNLIMITED_WEAPON_AMMO)) + if(!(own.items & IT_UNLIMITED_WEAPON_AMMO)) { float rootammo; if(burst) @@ -403,17 +257,17 @@ void W_Arc_Beam_Think(entity this) if(rootammo) { - coefficient = min(coefficient, this.owner.(thiswep.ammo_field) / rootammo); - this.owner.(thiswep.ammo_field) = max(0, this.owner.(thiswep.ammo_field) - (rootammo * frametime)); + coefficient = min(coefficient, GetResourceAmount(own, thiswep.ammo_type) / rootammo); + SetResourceAmount(own, thiswep.ammo_type, max(0, GetResourceAmount(own, thiswep.ammo_type) - (rootammo * frametime))); } } float heat_speed = burst ? WEP_CVAR(arc, burst_heat) : WEP_CVAR(arc, beam_heat); this.beam_heat = min( WEP_CVAR(arc, overheat_max), this.beam_heat + heat_speed*frametime ); - makevectors(this.owner.v_angle); + makevectors(own.v_angle); W_SetupShot_Range( - this.owner, + own, weaponentity, // TODO true, 0, @@ -424,7 +278,7 @@ void W_Arc_Beam_Think(entity this) ); // After teleport, "lock" the beam until the teleport is confirmed. - if (time < this.beam_teleporttime + ANTILAG_LATENCY(this.owner)) { + if (time < this.beam_teleporttime + ANTILAG_LATENCY(own)) { w_shotdir = this.beam_dir; } @@ -539,12 +393,12 @@ void W_Arc_Beam_Think(entity this) vector new_dir = normalize(new_origin - last_origin); WarpZone_traceline_antilag( - this.owner, + own, last_origin, new_origin, MOVE_NORMAL, - this.owner, - ANTILAG_LATENCY(this.owner) + own, + ANTILAG_LATENCY(own) ); // Do all the transforms for warpzones right now, as we already @@ -578,7 +432,7 @@ void W_Arc_Beam_Think(entity this) vlen(WarpZone_UnTransformOrigin(WarpZone_trace_transform, hitorigin) - w_shotorg) ); - if(is_player && SAME_TEAM(this.owner, trace_ent)) + if(is_player && SAME_TEAM(own, trace_ent)) { float roothealth, rootarmor; if(burst) @@ -634,10 +488,10 @@ void W_Arc_Beam_Think(entity this) else { rootdamage = WEP_CVAR(arc, beam_nonplayerdamage); } - if(accuracy_isgooddamage(this.owner, trace_ent)) + if(accuracy_isgooddamage(own, trace_ent)) { accuracy_add( - this.owner, + own, WEP_ARC.m_id, 0, rootdamage * coefficient * falloff @@ -646,8 +500,8 @@ void W_Arc_Beam_Think(entity this) Damage( trace_ent, - this.owner, - this.owner, + own, + own, rootdamage * coefficient * falloff, WEP_ARC.m_id, hitorigin, @@ -678,7 +532,7 @@ void W_Arc_Beam_Think(entity this) this.beam_type = new_beam_type; } - this.owner.(weaponentity).beam_prev = time; + own.(weaponentity).beam_prev = time; this.nextthink = time; } @@ -842,19 +696,19 @@ METHOD(Arc, wr_init, void(entity thiswep)) } METHOD(Arc, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { - return ((!WEP_CVAR(arc, beam_ammo)) || (actor.(thiswep.ammo_field) > 0)); + return ((!WEP_CVAR(arc, beam_ammo)) || (GetResourceAmount(actor, thiswep.ammo_type) > 0)); } METHOD(Arc, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity)) { if(WEP_CVAR(arc, bolt)) { - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(arc, bolt_ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(arc, bolt_ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_ARC.m_id]) >= WEP_CVAR(arc, bolt_ammo); return ammo_amount; } else return WEP_CVAR(arc, overheat_max) > 0 && - ((!WEP_CVAR(arc, burst_ammo)) || (actor.(thiswep.ammo_field) > 0)); + ((!WEP_CVAR(arc, burst_ammo)) || (GetResourceAmount(actor, thiswep.ammo_type) > 0)); } METHOD(Arc, wr_killmessage, Notification(entity thiswep)) { @@ -1318,7 +1172,7 @@ NET_HANDLE(ENT_CLIENT_ARC_BEAM, bool isnew) IL_PUSH(g_drawables, this); this.entremove = Remove_ArcBeam; this.move_time = time; - loopsound(this, CH_SHOTS_SINGLE, SND(ARC_LOOP), VOL_BASE, ATTEN_NORM); + loopsound(this, CH_SHOTS_SINGLE, SND_ARC_LOOP, VOL_BASE, ATTEN_NORM); flash = spawn(); flash.owner = this; @@ -1657,4 +1511,3 @@ NET_HANDLE(ENT_CLIENT_ARC_BEAM, bool isnew) } #endif -#endif