#include "arc.qh"
#ifdef SVQC
+#include <common/gamemodes/gamemode/onslaught/sv_onslaught.qh>
+#include <common/gamemodes/gamemode/onslaught/sv_generator.qh>
bool W_Arc_Beam_Send(entity this, entity to, int sf)
{
void W_Arc_Bolt_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if(this.health <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
return;
if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1))
return; // g_projectiles_damage says to halt
- this.health = this.health - damage;
+ TakeResource(this, RES_HEALTH, damage);
this.angles = vectoangles(this.velocity);
- if(this.health <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
W_PrepareExplosionByDamage(this, attacker, getthink(this));
}
missile.bot_dodgerating = WEP_CVAR(arc, bolt_damage);
missile.takedamage = DAMAGE_YES;
- missile.health = WEP_CVAR(arc, bolt_health);
+ SetResourceExplicit(missile, RES_HEALTH, WEP_CVAR(arc, bolt_health));
missile.damageforcescale = WEP_CVAR(arc, bolt_damageforcescale);
missile.event_damage = W_Arc_Bolt_Damage;
missile.damagedbycontents = true;
if(
!IS_PLAYER(own)
||
- (!thiswep.wr_checkammo1(thiswep, own, weaponentity) && !(own.items & IT_UNLIMITED_WEAPON_AMMO))
- ||
IS_DEAD(own)
||
- forbidWeaponUse(own)
+ !weapon_prepareattack_check(thiswep, own, weaponentity, this.beam_bursting, -1)
||
own.(weaponentity).m_switchweapon != WEP_ARC
||
}
if(this == own.(weaponentity).arc_beam) { own.(weaponentity).arc_beam = NULL; }
- if(!thiswep.wr_checkammo1(thiswep, own, weaponentity) && !(own.items & IT_UNLIMITED_WEAPON_AMMO))
+ if(!thiswep.wr_checkammo1(thiswep, own, weaponentity) && !(own.items & IT_UNLIMITED_AMMO))
{
// note: this doesn't force the switch
W_SwitchToOtherWeapon(own, weaponentity);
- own.(weaponentity).arc_BUTTON_ATCK_prev = false; // hax
}
+ own.(weaponentity).arc_BUTTON_ATCK_prev = false; // allow switching weapons
delete(this);
return;
}
// decrease ammo
float coefficient = frametime;
- if(!(own.items & IT_UNLIMITED_WEAPON_AMMO))
+ if(!(own.items & IT_UNLIMITED_AMMO))
{
float rootammo;
if(burst)
if(rootammo)
{
- coefficient = min(coefficient, GetResourceAmount(own, thiswep.ammo_type) / rootammo);
- SetResourceAmount(own, thiswep.ammo_type, max(0, GetResourceAmount(own, thiswep.ammo_type) - (rootammo * frametime)));
+ coefficient = min(coefficient, GetResource(own, thiswep.ammo_type) / rootammo);
+ SetResource(own, thiswep.ammo_type, max(0, GetResource(own, thiswep.ammo_type) - (rootammo * frametime)));
}
}
float heat_speed = burst ? WEP_CVAR(arc, burst_heat) : WEP_CVAR(arc, beam_heat);
W_SetupShot_Range(
own,
- weaponentity, // TODO
+ weaponentity,
true,
0,
SND_Null,
0,
WEP_CVAR(arc, beam_damage) * coefficient,
WEP_CVAR(arc, beam_range),
- WEP_ARC.m_id
+ thiswep.m_id
);
// After teleport, "lock" the beam until the teleport is confirmed.
(1 - (WEP_CVAR(arc, beam_returnspeed) * frametime)),
min(WEP_CVAR(arc, beam_maxangle) / angle, 1)
);
- this.beam_dir = normalize((w_shotdir * (1 - blendfactor)) + (this.beam_dir * blendfactor));
+ if(vdist(this.beam_dir - w_shotdir, <, 0.01))
+ this.beam_dir = w_shotdir;
+ else
+ this.beam_dir = normalize((w_shotdir * (1 - blendfactor)) + (this.beam_dir * blendfactor));
}
else
{
(1 - (WEP_CVAR(arc, beam_returnspeed) * frametime)),
1
);
- this.beam_dir = normalize((w_shotdir * (1 - blendfactor)) + (this.beam_dir * blendfactor));
+ if(vdist(this.beam_dir - w_shotdir, <, 0.01))
+ this.beam_dir = w_shotdir;
+ else
+ this.beam_dir = normalize((w_shotdir * (1 - blendfactor)) + (this.beam_dir * blendfactor));
}
// network information: beam direction
beam_endpos = WarpZone_TransformOrigin(WarpZone_trace_transform, beam_endpos);
new_dir = WarpZone_TransformVelocity(WarpZone_trace_transform, new_dir);
- float is_player = (
+ bool is_player = (
IS_PLAYER(trace_ent)
||
trace_ent.classname == "body"
IS_MONSTER(trace_ent)
);
- if(trace_ent && trace_ent.takedamage && (is_player || WEP_CVAR(arc, beam_nonplayerdamage)))
+ if(trace_ent)
{
- // calculate our own hit origin as trace_endpos tends to jump around annoyingly (to player origin?)
- // NO. trace_endpos should be just fine. If not,
- // that's an engine bug that needs proper debugging.
- vector hitorigin = trace_endpos;
-
- float falloff = ExponentialFalloff(
- WEP_CVAR(arc, beam_falloff_mindist),
- WEP_CVAR(arc, beam_falloff_maxdist),
- WEP_CVAR(arc, beam_falloff_halflifedist),
- vlen(WarpZone_UnTransformOrigin(WarpZone_trace_transform, hitorigin) - w_shotorg)
- );
-
- if(is_player && SAME_TEAM(own, trace_ent))
+ if(SAME_TEAM(own, trace_ent))
{
- float roothealth, rootarmor;
- if(burst)
+ float roothealth = ((burst) ? WEP_CVAR(arc, burst_healing_hps) : WEP_CVAR(arc, beam_healing_hps));
+ float rootarmor = ((burst) ? WEP_CVAR(arc, burst_healing_aps) : WEP_CVAR(arc, beam_healing_aps));
+ float hplimit = ((IS_PLAYER(trace_ent)) ? WEP_CVAR(arc, beam_healing_hmax) : RES_LIMIT_NONE);
+ Heal(trace_ent, own, (roothealth * coefficient), hplimit);
+ if(IS_PLAYER(trace_ent) && rootarmor)
{
- roothealth = WEP_CVAR(arc, burst_healing_hps);
- rootarmor = WEP_CVAR(arc, burst_healing_aps);
+ if(GetResource(trace_ent, RES_ARMOR) <= WEP_CVAR(arc, beam_healing_amax))
+ {
+ GiveResourceWithLimit(trace_ent, RES_ARMOR, (rootarmor * coefficient), WEP_CVAR(arc, beam_healing_amax));
+ trace_ent.pauserotarmor_finished = max(
+ trace_ent.pauserotarmor_finished,
+ time + autocvar_g_balance_pause_armor_rot
+ );
+ }
}
- else
- {
- roothealth = WEP_CVAR(arc, beam_healing_hps);
- rootarmor = WEP_CVAR(arc, beam_healing_aps);
- }
-
- if(trace_ent.health <= WEP_CVAR(arc, beam_healing_hmax) && roothealth)
- {
- trace_ent.health = min(
- trace_ent.health + (roothealth * coefficient),
- WEP_CVAR(arc, beam_healing_hmax)
- );
- }
- if(trace_ent.armorvalue <= WEP_CVAR(arc, beam_healing_amax) && rootarmor)
- {
- trace_ent.armorvalue = min(
- trace_ent.armorvalue + (rootarmor * coefficient),
- WEP_CVAR(arc, beam_healing_amax)
- );
- }
-
- // stop rot, set visual effect
if(roothealth || rootarmor)
- {
- trace_ent.pauserothealth_finished = max(
- trace_ent.pauserothealth_finished,
- time + autocvar_g_balance_pause_health_rot
- );
- trace_ent.pauserotarmor_finished = max(
- trace_ent.pauserotarmor_finished,
- time + autocvar_g_balance_pause_armor_rot
- );
new_beam_type = ARC_BT_HEAL;
- }
}
- else
+ else if(trace_ent.takedamage && (is_player || WEP_CVAR(arc, beam_nonplayerdamage)))
{
+ // calculate our own hit origin as trace_endpos tends to jump around annoyingly (to player origin?)
+ // NO. trace_endpos should be just fine. If not,
+ // that's an engine bug that needs proper debugging.
+ vector hitorigin = trace_endpos;
+
+ float falloff = ExponentialFalloff(
+ WEP_CVAR(arc, beam_falloff_mindist),
+ WEP_CVAR(arc, beam_falloff_maxdist),
+ WEP_CVAR(arc, beam_falloff_halflifedist),
+ vlen(WarpZone_UnTransformOrigin(WarpZone_trace_transform, hitorigin) - w_shotorg)
+ );
+
float rootdamage;
if(is_player)
{
{
accuracy_add(
own,
- WEP_ARC.m_id,
+ WEP_ARC,
0,
rootdamage * coefficient * falloff
);
getthink(beam)(beam);
}
-void Arc_Smoke(entity actor, .entity weaponentity)
+void W_Arc_Attack(Weapon thiswep, entity actor, .entity weaponentity, int fire)
{
+ if(!actor.(weaponentity).arc_beam || wasfreed(actor.(weaponentity).arc_beam))
+ {
+ w_ready(thiswep, actor, weaponentity, fire);
+ return;
+ }
+
+ // attack handled by the beam itself, this is just a loop to keep the attack happening!
+
+ // NOTE: arc doesn't use a refire
+ //ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR_PRI(arc, refire) * W_WeaponRateFactor(actor);
+ actor.(weaponentity).wframe = WFRAME_FIRE1;
+ weapon_thinkf(actor, weaponentity, WFRAME_DONTCHANGE, WEP_CVAR(arc, beam_animtime), W_Arc_Attack);
+}
+void Arc_Smoke(Weapon thiswep, entity actor, .entity weaponentity, int fire)
+{
+ // TODO: spamming this without checking any refires is asking for trouble!
makevectors(actor.v_angle);
- W_SetupShot_Range(actor,weaponentity,true,0,SND_Null,0,0,0,WEP_ARC.m_id); // TODO: probably doesn't need deathtype, since this is just a prefire effect
+ W_SetupShot_Range(actor,weaponentity,false,0,SND_Null,0,0,0,thiswep.m_id); // TODO: probably doesn't need deathtype, since this is just a prefire effect
vector smoke_origin = w_shotorg + actor.velocity*frametime;
if ( actor.arc_overheat > time )
{
if ( random() < actor.(weaponentity).arc_heat_percent )
Send_Effect(EFFECT_ARC_SMOKE, smoke_origin, '0 0 0', 1 );
- if ( PHYS_INPUT_BUTTON_ATCK(actor) || PHYS_INPUT_BUTTON_ATCK2(actor) )
+ if ( (fire & 1) || (fire & 2) )
{
Send_Effect(EFFECT_ARC_OVERHEAT_FIRE, smoke_origin, w_shotdir, 1 );
if ( !actor.arc_smoke_sound )
}
if ( actor.arc_smoke_sound && ( actor.arc_overheat <= time ||
- !( PHYS_INPUT_BUTTON_ATCK(actor) || PHYS_INPUT_BUTTON_ATCK2(actor) ) ) || actor.(weaponentity).m_switchweapon != WEP_ARC )
+ !( PHYS_INPUT_BUTTON_ATCK(actor) || PHYS_INPUT_BUTTON_ATCK2(actor) ) ) || actor.(weaponentity).m_switchweapon != thiswep )
{
actor.arc_smoke_sound = 0;
sound(actor, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
METHOD(Arc, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
{
Arc_Player_SetHeat(actor, weaponentity);
- Arc_Smoke(actor, weaponentity);
+ Arc_Smoke(thiswep, actor, weaponentity, fire);
bool beam_fire2 = ((fire & 2) && !WEP_CVAR(arc, bolt));
if (time >= actor.arc_overheat)
if ((fire & 1) || beam_fire2 || actor.(weaponentity).arc_beam.beam_bursting)
{
-
+ #if 0
if(actor.(weaponentity).arc_BUTTON_ATCK_prev)
{
#if 0
#endif
weapon_thinkf(actor, weaponentity, WFRAME_DONTCHANGE, WEP_CVAR(arc, beam_animtime), w_ready);
}
+ #endif
if((!actor.(weaponentity).arc_beam) || wasfreed(actor.(weaponentity).arc_beam))
{
if(!actor.(weaponentity).arc_BUTTON_ATCK_prev)
{
- weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready);
+ actor.(weaponentity).wframe = WFRAME_FIRE1;
+ weapon_thinkf(actor, weaponentity, WFRAME_DONTCHANGE, WEP_CVAR(arc, beam_animtime), W_Arc_Attack);
actor.(weaponentity).arc_BUTTON_ATCK_prev = true;
}
}
}
else if(fire & 2)
{
- if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(arc, bolt_refire)))
+ if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR(arc, bolt_refire)))
{
W_Arc_Attack_Bolt(thiswep, actor, weaponentity);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(arc, bolt_refire), w_ready);
if(actor.(weaponentity).arc_BUTTON_ATCK_prev)
{
- int slot = weaponslot(weaponentity);
sound(actor, CH_WEAPON_A, SND_ARC_STOP, VOL_BASE, ATTN_NORM);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready);
- ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(arc, beam_refire) * W_WeaponRateFactor(actor);
+ ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR(arc, beam_refire) * W_WeaponRateFactor(actor);
}
actor.(weaponentity).arc_BUTTON_ATCK_prev = false;
}
METHOD(Arc, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
- return ((!WEP_CVAR(arc, beam_ammo)) || (GetResourceAmount(actor, thiswep.ammo_type) > 0));
+ return ((!WEP_CVAR(arc, beam_ammo)) || (GetResource(actor, thiswep.ammo_type) > 0));
}
METHOD(Arc, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
if(WEP_CVAR(arc, bolt))
{
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(arc, bolt_ammo);
+ float ammo_amount = GetResource(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)) || (GetResourceAmount(actor, thiswep.ammo_type) > 0));
+ ((!WEP_CVAR(arc, burst_ammo)) || (GetResource(actor, thiswep.ammo_type) > 0));
}
METHOD(Arc, wr_killmessage, Notification(entity thiswep))
{
Draw_CylindricLine(start, end, thickness, beam.beam_image, 0.25, -time * 3, beam.beam_color, beam.beam_alpha, DRAWFLAG_NORMAL, transformed_view_org);
else
{
- R_BeginPolygon(beam.beam_image, DRAWFLAG_NORMAL); // DRAWFLAG_ADDITIVE
+ R_BeginPolygon(beam.beam_image, DRAWFLAG_NORMAL, false); // DRAWFLAG_ADDITIVE
R_PolygonVertex(
top,
'0 0.5 0' + ('0 0.5 0' * (thickness / beam.beam_thickness)),
// into a weapon system for client code.
// find where we are aiming
- makevectors(((autocvar_chase_active) ? warpzone_save_view_angles : view_angles));
- vector forward = v_forward;
- vector right = v_right;
- vector up = v_up;
+ vector myviewangle = ((autocvar_chase_active) ? warpzone_save_view_angles : view_angles);
+ vector forward, right, up;
+ MAKE_VECTORS(myviewangle, forward, right, up);
entity wepent = viewmodels[this.beam_slot];
if(autocvar_chase_active)
else
{ start_pos = this.origin; }
- int v_shot_idx; // used later
- (v_shot_idx = gettagindex(wepent, "shot")) || (v_shot_idx = gettagindex(wepent, "tag_shot"));
- if(v_shot_idx && this.beam_usevieworigin == 2)
- start_pos = gettaginfo(wepent, v_shot_idx) - '0 0 2';
-
// trace forward with an estimation
WarpZone_TraceLine(
start_pos,
this
);
+ int v_shot_idx; // used later
+ (v_shot_idx = gettagindex(wepent, "shot")) || (v_shot_idx = gettagindex(wepent, "tag_shot"));
+ if(v_shot_idx && this.beam_usevieworigin == 2)
+ start_pos = gettaginfo(wepent, v_shot_idx) - '0 0 2';
+
// untransform in case our trace went through a warpzone
vector end_pos = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
{
this.beam_dir = wantdir;
this.beam_initialized = true;
+
+ this.beam_muzzleentity.drawmask = MASK_NORMAL; // NOTE: this works around the muzzle entity flashing on the middle of the screen for a frame
}
if(this.beam_dir != wantdir)
// if the angle is greater than maxangle, force the blendfactor to make this the maximum factor
float blendfactor = bound(
0,
- (1 - (this.beam_returnspeed * frametime)),
+ (1 - (this.beam_returnspeed * dt)),
min(this.beam_maxangle / angle, 1)
);
this.beam_dir = normalize((wantdir * (1 - blendfactor)) + (this.beam_dir * blendfactor));
// the radius is not too far yet, no worries :D
float blendfactor = bound(
0,
- (1 - (this.beam_returnspeed * frametime)),
+ (1 - (this.beam_returnspeed * dt)),
1
);
this.beam_dir = normalize((wantdir * (1 - blendfactor)) + (this.beam_dir * blendfactor));
this.beam_hiteffect,
last_origin,
beamdir * -1,
- frametime * 2
+ dt * 2
);
}
if(this.beam_hitlight[0])
this.beam_muzzleeffect,
original_start_pos + wantdir * 20,
wantdir * 1000,
- frametime * 0.1
+ dt * 0.1
);
}
if(this.beam_muzzlelight[0])
flash = spawn();
flash.owner = this;
flash.effects = EF_ADDITIVE | EF_FULLBRIGHT;
- flash.drawmask = MASK_NORMAL;
+ //flash.drawmask = MASK_NORMAL;
flash.solid = SOLID_NOT;
flash.avelocity_z = 5000;
setattachment(flash, this, "");