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 87 of file okrpc.qc.

88{
89 entity missile = spawn(); //WarpZone_RefSys_SpawnSameRefSys(actor);
90
91 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(WEP_OVERKILL_RPC, ammo), weaponentity);
92 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);
93 W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir);
95
96 missile.owner = missile.realowner = actor;
97 missile.bot_dodge = true;
98 missile.bot_dodgerating = WEP_CVAR_PRI(WEP_OVERKILL_RPC, damage) * 2;
99
100 missile.takedamage = DAMAGE_YES;
101 missile.damageforcescale = WEP_CVAR_PRI(WEP_OVERKILL_RPC, damageforcescale);
102 SetResourceExplicit(missile, RES_HEALTH, WEP_CVAR_PRI(WEP_OVERKILL_RPC, health));
103 missile.event_damage = W_OverkillRocketPropelledChainsaw_Damage;
104 missile.damagedbycontents = true;
106 set_movetype(missile, MOVETYPE_FLY);
107
108 missile.projectiledeathtype = thiswep.m_id;
109 missile.weaponentity_fld = weaponentity;
110 setsize (missile, '-3 -3 -3', '3 3 3'); // give it some size so it can be shot
111
112 setorigin(missile, w_shotorg - v_forward * 3); // move it back so it hits the wall at the right point
113 W_SetupProjVelocity_Basic(missile, WEP_CVAR_PRI(WEP_OVERKILL_RPC, speed), 0);
114
116
118 missile.cnt = time + WEP_CVAR_PRI(WEP_OVERKILL_RPC, lifetime);
119 missile.nextthink = time;
120 missile.flags = FL_PROJECTILE;
121 IL_PUSH(g_projectiles, missile);
122 IL_PUSH(g_bot_dodge, missile);
123
124 CSQCProjectile(missile, true, PROJECTILE_RPC, false);
125
126 missile.m_chainsaw_damage = 0;
127
128 MUTATOR_CALLHOOK(EditProjectile, actor, missile);
129}
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
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
int m_id
Definition weapon.qh:45
float lifetime
Definition powerups.qc:23
const int FL_PROJECTILE
Definition constants.qh:85
float time
vector v_forward
#define spawn
void CSQCProjectile(entity e, float clientanimate, int type, float docull)
IntrusiveList g_damagedbycontents
Definition damage.qh:135
float damageforcescale
float speed
Definition dynlight.qc:9
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:134
void W_OverkillRocketPropelledChainsaw_Touch(entity this, entity toucher)
Definition okrpc.qc:28
void W_OverkillRocketPropelledChainsaw_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition okrpc.qc:37
void W_OverkillRocketPropelledChainsaw_Think(entity this)
Definition okrpc.qc:51
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:73
IntrusiveList g_projectiles
Definition common.qh:58
#define PROJECTILE_MAKETRIGGER(e)
Definition common.qh:34
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:49
void W_MuzzleFlash(Weapon thiswep, entity actor,.entity weaponentity, vector shotorg, vector shotdir)
Definition all.qc:728
#define WEP_CVAR_PRI(wep, name)
Definition all.qh:322
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 37 of file okrpc.qc.

38{
39 if (GetResource(this, RES_HEALTH) <= 0)
40 return;
41
42 if (!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
43 return; // g_projectiles_damage says to halt
44
45 TakeResource(this, RES_HEALTH, damage);
46
47 if (GetResource(this, RES_HEALTH) <= 0)
49}
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:23
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, WEP_CVAR_PRI(WEP_OVERKILL_RPC, damage), WEP_CVAR_PRI(WEP_OVERKILL_RPC, edgedamage), WEP_CVAR_PRI(WEP_OVERKILL_RPC, radius), NULL, NULL, WEP_CVAR_PRI(WEP_OVERKILL_RPC, force), this.projectiledeathtype, this.weaponentity_fld, directhitentity);
13 if (explosion_damage > 0 && this.m_chainsaw_damage > 0)
14 {
15 // if chainsaw hit something, it removed fired damage (so that direct hit is 100%)
16 // now that we also damaged something by explosion we'd go over 100% so let's add the fired damage back
17 accuracy_add(this.realowner, DEATH_WEAPONOF(this.projectiledeathtype), WEP_CVAR(WEP_OVERKILL_RPC, damage), 0, 0); // add to fired
18 }
19
20 delete(this);
21}
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:981
#define DEATH_WEAPONOF(t)
Definition all.qh:45
var void func_null()
float m_chainsaw_damage
Definition okrpc.qc:5
#define NULL
Definition post.qh:14
int projectiledeathtype
Definition common.qh:21
const int DAMAGE_NO
Definition subs.qh:79
float takedamage
Definition subs.qh:78
entity realowner
#define WEP_CVAR(wep, name)
Definition all.qh:321
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 23 of file okrpc.qc.

24{
26}
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 51 of file okrpc.qc.

52{
53 if(this.cnt <= time)
54 {
55 delete(this);
56 return;
57 }
58
59 float myspeed = vlen(this.velocity);
60 float myspeed_accel = myspeed * sys_frametime;
61 vector mydir = normalize(this.velocity);
62
63 tracebox(this.origin, this.mins, this.maxs, this.origin + mydir * (2 * myspeed_accel), MOVE_NORMAL, this);
65 {
67 {
68 if (this.m_chainsaw_damage == 0) // first hit
69 {
70 // The fired damage of the explosion is already counted in the statistics (when launching the chainsaw).
71 // We remove it here so that a direct hit that passes through and doesn't damage anything by the explosion later is still 100%.
72 float fired_damage = WEP_CVAR_PRI(WEP_OVERKILL_RPC, damage2) - WEP_CVAR_PRI(WEP_OVERKILL_RPC, damage);
73 float hit_damage = WEP_CVAR_PRI(WEP_OVERKILL_RPC, damage2);
74 accuracy_add(this.realowner, DEATH_WEAPONOF(this.projectiledeathtype), fired_damage, hit_damage, 0); // add to fired and hit
75 }
76 this.m_chainsaw_damage += WEP_CVAR_PRI(WEP_OVERKILL_RPC, damage2);
77 }
78 Damage(trace_ent, this, this.realowner, WEP_CVAR_PRI(WEP_OVERKILL_RPC, damage2), this.projectiledeathtype, this.weaponentity_fld, this.origin, normalize(this.origin - trace_ent.origin) * WEP_CVAR_PRI(WEP_OVERKILL_RPC, force));
79 }
80
81 this.velocity = mydir * (myspeed + (WEP_CVAR_PRI(WEP_OVERKILL_RPC, speedaccel) * sys_frametime));
82
84 this.nextthink = time;
85}
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:243
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:503
float vlen(vector v)
vector normalize(vector v)
vector
Definition self.qh:92
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(), 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 28 of file okrpc.qc.

29{
31 if(wasfreed(this))
32 return;
33
35}
entity entity toucher
Definition self.qh:72
float WarpZone_Projectile_Touch(entity this, entity toucher)
Definition server.qc:381

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

Referenced by W_OverkillRocketPropelledChainsaw_Attack().

Variable Documentation

◆ m_chainsaw_damage

float m_chainsaw_damage