Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
okrpc.qc File Reference
Include dependency graph for okrpc.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void W_OverkillRocketPropelledChainsaw_Attack (Weapon thiswep, entity actor,.entity weaponentity)
void W_OverkillRocketPropelledChainsaw_Damage (entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
void W_OverkillRocketPropelledChainsaw_Explode (entity this, entity directhitentity)
void W_OverkillRocketPropelledChainsaw_Explode_think (entity this)
void W_OverkillRocketPropelledChainsaw_Think (entity this)
void W_OverkillRocketPropelledChainsaw_Touch (entity this, entity toucher)

Variables

float m_chainsaw_damage

Function Documentation

◆ W_OverkillRocketPropelledChainsaw_Attack()

void W_OverkillRocketPropelledChainsaw_Attack ( Weapon thiswep,
entity actor,
.entity weaponentity )

Definition at line 101 of file okrpc.qc.

102{
103 entity missile = spawn(); //WarpZone_RefSys_SpawnSameRefSys(actor);
104
105 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(WEP_OVERKILL_RPC, ammo), weaponentity);
106 W_SetupShot_ProjectileSize(actor, weaponentity, '-3 -3 -3', '3 3 3', false, 5, SND_RPC_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(WEP_OVERKILL_RPC, damage), thiswep.m_id);
107 W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir);
108 PROJECTILE_MAKETRIGGER(missile);
109
110 missile.owner = missile.realowner = actor;
111 missile.bot_dodge = true;
112 missile.bot_dodgerating = WEP_CVAR_PRI(WEP_OVERKILL_RPC, damage) * 2;
113
114 missile.takedamage = DAMAGE_YES;
115 missile.damageforcescale = WEP_CVAR_PRI(WEP_OVERKILL_RPC, damageforcescale);
116 SetResourceExplicit(missile, RES_HEALTH, WEP_CVAR_PRI(WEP_OVERKILL_RPC, health));
117 missile.event_damage = W_OverkillRocketPropelledChainsaw_Damage;
118 missile.damagedbycontents = true;
120 set_movetype(missile, MOVETYPE_FLY);
121
122 missile.projectiledeathtype = thiswep.m_id;
123 missile.weaponentity_fld = weaponentity;
124 setsize (missile, '-3 -3 -3', '3 3 3'); // give it some size so it can be shot
125
126 setorigin(missile, w_shotorg - v_forward * 3); // move it back so it hits the wall at the right point
127 W_SetupProjVelocity_Basic(missile, WEP_CVAR_PRI(WEP_OVERKILL_RPC, speed), 0);
128
130
132 missile.cnt = time + WEP_CVAR_PRI(WEP_OVERKILL_RPC, lifetime);
133 missile.nextthink = time;
134 missile.flags = FL_PROJECTILE;
135 IL_PUSH(g_projectiles, missile);
136 IL_PUSH(g_bot_dodge, missile);
137
138 CSQCProjectile(missile, true, PROJECTILE_RPC, false);
139
140 missile.m_chainsaw_damage = 0;
141
142 MUTATOR_CALLHOOK(EditProjectile, actor, missile);
143}
IntrusiveList g_bot_dodge
Definition api.qh:150
#define MUTATOR_CALLHOOK(id,...)
Definition base.qh:143
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
int m_id
Definition weapon.qh:43
float lifetime
Definition powerups.qc:23
const int FL_PROJECTILE
Definition constants.qh:77
float time
vector v_forward
#define spawn
void CSQCProjectile(entity e, float clientanimate, int type, float docull)
IntrusiveList g_damagedbycontents
Definition damage.qh:143
float damageforcescale
float speed
Definition dynlight.qc:9
SetResourceExplicit(ent, RES_ARMOR, ReadByte() *DEC_FACTOR)) ENTCS_PROP(NAME
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_FLY
Definition movetypes.qh:138
void W_OverkillRocketPropelledChainsaw_Touch(entity this, entity toucher)
Definition okrpc.qc:38
void W_OverkillRocketPropelledChainsaw_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition okrpc.qc:46
void W_OverkillRocketPropelledChainsaw_Think(entity this)
Definition okrpc.qc:58
const int PROJECTILE_RPC
float health
Legacy fields for the resources. To be removed.
Definition resources.qh:9
#define setthink(e, f)
#define settouch(e, f)
Definition self.qh:77
IntrusiveList g_projectiles
Definition common.qh:70
#define PROJECTILE_MAKETRIGGER(e)
Definition common.qh:46
const int CH_WEAPON_A
Definition sound.qh:7
const int DAMAGE_YES
Definition subs.qh:80
float ammo
Definition sv_turrets.qh:43
vector w_shotdir
Definition tracing.qh:20
#define W_SetupShot_ProjectileSize(ent, wepent, mi, ma, antilag, recoil, snd, chan, maxdamage, deathtype)
Definition tracing.qh:30
vector w_shotorg
Definition tracing.qh:19
#define W_SetupProjVelocity_Basic(ent, pspeed, pspread)
Definition tracing.qh:51
void W_MuzzleFlash(Weapon thiswep, entity actor,.entity weaponentity, vector shotorg, vector shotdir)
Definition all.qc:715
#define WEP_CVAR_PRI(wep, name)
Definition all.qh:338
void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use,.entity weaponentity)

References ammo, CH_WEAPON_A, CSQCProjectile(), DAMAGE_YES, damageforcescale, entity(), FL_PROJECTILE, g_bot_dodge, g_damagedbycontents, g_projectiles, health, IL_PUSH(), lifetime, Weapon::m_id, MOVETYPE_FLY, MUTATOR_CALLHOOK, PROJECTILE_MAKETRIGGER, PROJECTILE_RPC, set_movetype(), SetResourceExplicit(), setthink, settouch, spawn, speed, time, v_forward, W_DecreaseAmmo(), W_MuzzleFlash(), W_OverkillRocketPropelledChainsaw_Damage(), W_OverkillRocketPropelledChainsaw_Think(), W_OverkillRocketPropelledChainsaw_Touch(), W_SetupProjVelocity_Basic, W_SetupShot_ProjectileSize, w_shotdir, w_shotorg, and WEP_CVAR_PRI.

◆ W_OverkillRocketPropelledChainsaw_Damage()

void W_OverkillRocketPropelledChainsaw_Damage ( entity this,
entity inflictor,
entity attacker,
float damage,
int deathtype,
.entity weaponentity,
vector hitloc,
vector force )

Definition at line 46 of file okrpc.qc.

47{
48 if (GetResource(this, RES_HEALTH) <= 0)
49 return;
50 if (!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
51 return; // g_projectiles_damage says to halt
52
53 TakeResource(this, RES_HEALTH, damage);
54 if (GetResource(this, RES_HEALTH) <= 0)
56}
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
void TakeResource(entity receiver, Resource res_type, float amount)
Takes an entity some resource.
void W_OverkillRocketPropelledChainsaw_Explode_think(entity this)
Definition okrpc.qc:33
float W_CheckProjectileDamage(entity inflictor, entity projowner, int deathtype, float exception)
Definition common.qc:45
void W_PrepareExplosionByDamage(entity this, entity attacker, void(entity this) explode)
Definition common.qc:87

References entity(), GetResource(), TakeResource(), vector, W_CheckProjectileDamage(), W_OverkillRocketPropelledChainsaw_Explode_think(), and W_PrepareExplosionByDamage().

Referenced by W_OverkillRocketPropelledChainsaw_Attack().

◆ W_OverkillRocketPropelledChainsaw_Explode()

void W_OverkillRocketPropelledChainsaw_Explode ( entity this,
entity directhitentity )

Definition at line 7 of file okrpc.qc.

8{
9 this.event_damage = func_null;
10 this.takedamage = DAMAGE_NO;
11
12 float explosion_damage = RadiusDamage(this, this.realowner,
13 WEP_CVAR_PRI(WEP_OVERKILL_RPC, damage),
14 WEP_CVAR_PRI(WEP_OVERKILL_RPC, edgedamage),
15 WEP_CVAR_PRI(WEP_OVERKILL_RPC, radius),
16 NULL,
17 NULL,
18 WEP_CVAR_PRI(WEP_OVERKILL_RPC, force),
21 directhitentity
22 );
23 if (explosion_damage > 0 && this.m_chainsaw_damage > 0)
24 {
25 // if chainsaw hit something, it removed fired damage (so that direct hit is 100%)
26 // now that we also damaged something by explosion we'd go over 100% so let's add the fired damage back
27 accuracy_add(this.realowner, DEATH_WEAPONOF(this.projectiledeathtype), WEP_CVAR(WEP_OVERKILL_RPC, damage), 0, 0); // add to fired
28 }
29
30 delete(this);
31}
void accuracy_add(entity this, Weapon w, float fired, float hit, float real)
update accuracy stats
Definition accuracy.qc:102
float radius
Definition impulse.qh:11
float RadiusDamage(entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity cantbe, entity mustbe, float forceintensity, int deathtype,.entity weaponentity, entity directhitentity)
Definition damage.qc:937
#define DEATH_WEAPONOF(t)
Definition all.qh:47
var void func_null()
float m_chainsaw_damage
Definition okrpc.qc:5
#define NULL
Definition post.qh:14
int projectiledeathtype
Definition common.qh:33
const int DAMAGE_NO
Definition subs.qh:79
float takedamage
Definition subs.qh:78
entity realowner
#define WEP_CVAR(wep, name)
Definition all.qh:337
entity weaponentity_fld

References accuracy_add(), DAMAGE_NO, DEATH_WEAPONOF, entity(), func_null(), m_chainsaw_damage, NULL, projectiledeathtype, radius, RadiusDamage(), realowner, takedamage, weaponentity_fld, WEP_CVAR, and WEP_CVAR_PRI.

Referenced by W_OverkillRocketPropelledChainsaw_Explode_think(), and W_OverkillRocketPropelledChainsaw_Touch().

◆ W_OverkillRocketPropelledChainsaw_Explode_think()

void W_OverkillRocketPropelledChainsaw_Explode_think ( entity this)

Definition at line 33 of file okrpc.qc.

34{
36}
void W_OverkillRocketPropelledChainsaw_Explode(entity this, entity directhitentity)
Definition okrpc.qc:7

References entity(), NULL, and W_OverkillRocketPropelledChainsaw_Explode().

Referenced by W_OverkillRocketPropelledChainsaw_Damage().

◆ W_OverkillRocketPropelledChainsaw_Think()

void W_OverkillRocketPropelledChainsaw_Think ( entity this)

Definition at line 58 of file okrpc.qc.

59{
60 if (this.cnt <= time)
61 {
62 delete(this);
63 return;
64 }
65
66 float myspeed = vlen(this.velocity);
67 float myspeed_accel = myspeed * sys_frametime;
68 vector mydir = this.velocity * (1 / myspeed);
69
70 WarpZone_TraceBox(this.origin, this.mins, this.maxs, this.origin + mydir * (2 * myspeed_accel), MOVE_NORMAL, this);
72 {
73 float hit_damage = WEP_CVAR_PRI(WEP_OVERKILL_RPC, damage2);
75 {
76 if (this.m_chainsaw_damage == 0) // first hit
77 {
78 // The fired damage of the explosion is already counted in the statistics (when launching the chainsaw).
79 // We remove it here so that a direct hit that passes through and doesn't damage anything by the explosion later is still 100%.
80 float fired_damage = hit_damage - WEP_CVAR_PRI(WEP_OVERKILL_RPC, damage);
81 accuracy_add(this.realowner, DEATH_WEAPONOF(this.projectiledeathtype), fired_damage, hit_damage, 0); // add to fired and hit
82 }
83 this.m_chainsaw_damage += hit_damage;
84 }
85 vector hitloc = WarpZone_TransformOrigin(this, this.origin);
86 Damage(trace_ent, this, this.realowner,
87 hit_damage,
90 hitloc,
91 normalize(hitloc - trace_ent.origin) * WEP_CVAR_PRI(WEP_OVERKILL_RPC, force)
92 );
93 }
94
95 this.velocity = mydir * (myspeed + (WEP_CVAR_PRI(WEP_OVERKILL_RPC, speedaccel) * sys_frametime));
96
98 this.nextthink = time;
99}
bool accuracy_isgooddamage(entity attacker, entity targ)
does this damage count towards accuracy stats?
Definition accuracy.qc:133
float cnt
Definition powerups.qc:24
#define IS_PLAYER(s)
Definition player.qh:242
entity trace_ent
const float MOVE_NORMAL
vector mins
vector velocity
vector maxs
float nextthink
vector origin
void UpdateCSQCProjectile(entity e)
void Damage(entity targ, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition damage.qc:484
vector WarpZone_TransformOrigin(entity wz, vector org)
Transforms origin org across warpzone wz.
Definition common.qc:489
#define WarpZone_TraceBox(org, mi, ma, end, nomonsters, forent)
Definition common.qh:49
float vlen(vector v)
vector normalize(vector v)
vector
Definition self.qh:96
float sys_frametime
Definition common.qh:57

References accuracy_add(), accuracy_isgooddamage(), cnt, Damage(), DEATH_WEAPONOF, entity(), IS_PLAYER, m_chainsaw_damage, maxs, mins, MOVE_NORMAL, nextthink, normalize(), origin, projectiledeathtype, realowner, sys_frametime, time, trace_ent, UpdateCSQCProjectile(), vector, velocity, vlen(), WarpZone_TraceBox, WarpZone_TransformOrigin(), weaponentity_fld, and WEP_CVAR_PRI.

Referenced by W_OverkillRocketPropelledChainsaw_Attack().

◆ W_OverkillRocketPropelledChainsaw_Touch()

void W_OverkillRocketPropelledChainsaw_Touch ( entity this,
entity toucher )

Definition at line 38 of file okrpc.qc.

39{
40 if (WarpZone_Projectile_Touch(this, toucher) && wasfreed(this))
41 return;
42
44}
entity entity toucher
Definition self.qh:76
float WarpZone_Projectile_Touch(entity this, entity toucher)
Definition server.qc:344

References entity(), toucher, W_OverkillRocketPropelledChainsaw_Explode(), and WarpZone_Projectile_Touch().

Referenced by W_OverkillRocketPropelledChainsaw_Attack().

Variable Documentation

◆ m_chainsaw_damage

float m_chainsaw_damage