5 void W_RocketPropelledChainsaw_Explode(entity this, entity directhitentity)
7 this.event_damage = func_null;
8 this.takedamage = DAMAGE_NO;
10 RadiusDamage (this, this.realowner, WEP_CVAR_PRI(rpc, damage), WEP_CVAR_PRI(rpc, edgedamage), WEP_CVAR_PRI(rpc, radius), NULL, NULL, WEP_CVAR_PRI(rpc, force), this.projectiledeathtype, directhitentity);
15 void W_RocketPropelledChainsaw_Explode_think(entity this)
17 W_RocketPropelledChainsaw_Explode(this, NULL);
20 void W_RocketPropelledChainsaw_Touch (entity this, entity toucher)
22 if(WarpZone_Projectile_Touch(this, toucher))
26 W_RocketPropelledChainsaw_Explode(this, toucher);
29 void W_RocketPropelledChainsaw_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
34 if (!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
35 return; // g_projectiles_damage says to halt
37 this.health = this.health - damage;
40 W_PrepareExplosionByDamage(this, attacker, W_RocketPropelledChainsaw_Explode_think);
43 void W_RocketPropelledChainsaw_Think(entity this)
51 this.cnt = vlen(this.velocity);
52 this.wait = this.cnt * sys_frametime;
53 this.pos1 = normalize(this.velocity);
55 tracebox(this.origin, this.mins, this.maxs, this.origin + this.pos1 * (2 * this.wait), MOVE_NORMAL, this);
56 if(IS_PLAYER(trace_ent))
57 Damage (trace_ent, this, this.realowner, WEP_CVAR_PRI(rpc, damage2), this.projectiledeathtype, this.origin, normalize(this.origin - other.origin) * WEP_CVAR_PRI(rpc, force));
59 this.velocity = this.pos1 * (this.cnt + (WEP_CVAR_PRI(rpc, speedaccel) * sys_frametime));
61 UpdateCSQCProjectile(this);
62 this.nextthink = time;
65 void W_RocketPropelledChainsaw_Attack (Weapon thiswep, entity actor, .entity weaponentity)
67 entity missile = spawn(); //WarpZone_RefSys_SpawnSameRefSys(actor);
68 entity flash = spawn ();
70 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(rpc, ammo), weaponentity);
71 W_SetupShot_ProjectileSize (actor, weaponentity, '-3 -3 -3', '3 3 3', false, 5, SND_ROCKET_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(rpc, damage));
72 Send_Effect(EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
73 PROJECTILE_MAKETRIGGER(missile);
75 missile.owner = missile.realowner = actor;
76 missile.bot_dodge = true;
77 missile.bot_dodgerating = WEP_CVAR_PRI(rpc, damage) * 2;
79 missile.takedamage = DAMAGE_YES;
80 missile.damageforcescale = WEP_CVAR_PRI(rpc, damageforcescale);
81 missile.health = WEP_CVAR_PRI(rpc, health);
82 missile.event_damage = W_RocketPropelledChainsaw_Damage;
83 missile.damagedbycontents = true;
84 IL_PUSH(g_damagedbycontents, missile);
85 set_movetype(missile, MOVETYPE_FLY);
87 missile.projectiledeathtype = WEP_RPC.m_id;
88 setsize (missile, '-3 -3 -3', '3 3 3'); // give it some size so it can be shot
90 setorigin(missile, w_shotorg - v_forward * 3); // move it back so it hits the wall at the right point
91 W_SetupProjVelocity_Basic(missile, WEP_CVAR_PRI(rpc, speed), 0);
93 settouch(missile, W_RocketPropelledChainsaw_Touch);
95 setthink(missile, W_RocketPropelledChainsaw_Think);
96 missile.cnt = time + WEP_CVAR_PRI(rpc, lifetime);
97 missile.nextthink = time;
98 missile.flags = FL_PROJECTILE;
99 IL_PUSH(g_projectiles, missile);
100 IL_PUSH(g_bot_dodge, missile);
102 CSQCProjectile(missile, true, PROJECTILE_RPC, false);
104 setmodel(flash, MDL_RPC_MUZZLEFLASH); // precision set below
105 SUB_SetFade (flash, time, 0.1);
106 flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
107 W_AttachToShotorg(actor, weaponentity, flash, '5 0 0');
108 missile.pos1 = missile.velocity;
110 MUTATOR_CALLHOOK(EditProjectile, actor, missile);
113 METHOD(RocketPropelledChainsaw, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
115 PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR_PRI(rpc, speed), 0, WEP_CVAR_PRI(rpc, lifetime), false);
118 METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
120 if ((WEP_CVAR_SEC(rpc, refire_type) == 1) && (fire & 2) && (time >= actor.jump_interval))
122 // Secondary uses it's own refire timer if refire_type is 1.
123 actor.jump_interval = time + WEP_CVAR_SEC(rpc, refire) * W_WeaponRateFactor(actor);
124 // Ugly hack to reuse the fire mode of the blaster.
125 makevectors(actor.v_angle);
126 Weapon oldwep = actor.(weaponentity).m_weapon; // we can't avoid this hack
127 actor.(weaponentity).m_weapon = WEP_BLASTER;
131 WEP_BLASTER.m_id | HITTYPE_SECONDARY,
132 WEP_CVAR_SEC(rpc, shotangle),
133 WEP_CVAR_SEC(rpc, damage),
134 WEP_CVAR_SEC(rpc, edgedamage),
135 WEP_CVAR_SEC(rpc, radius),
136 WEP_CVAR_SEC(rpc, force),
137 WEP_CVAR_SEC(rpc, speed),
138 WEP_CVAR_SEC(rpc, spread),
139 WEP_CVAR_SEC(rpc, delay),
140 WEP_CVAR_SEC(rpc, lifetime)
142 actor.(weaponentity).m_weapon = oldwep;
143 if ((actor.(weaponentity).wframe == WFRAME_IDLE) ||
144 (actor.(weaponentity).wframe == WFRAME_FIRE2))
146 // Set secondary fire animation.
148 actor.(weaponentity).wframe = WFRAME_FIRE2;
149 a = actor.(weaponentity).anim_fire2;
150 a.z *= g_weaponratefactor;
151 FOREACH_CLIENT(true, LAMBDA(
152 if (it == actor || (IS_SPEC(it) && it.enemy == actor))
154 wframe_send(it, actor.(weaponentity), a, true);
157 animdecide_setaction(actor, ANIMACTION_SHOOT, true);
160 if (WEP_CVAR(rpc, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR_PRI(rpc, ammo))
163 thiswep.wr_reload(thiswep, actor, weaponentity);
166 if (fire & 1) // Primary attack
168 if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(rpc, refire)))
172 W_RocketPropelledChainsaw_Attack(thiswep, actor, weaponentity);
173 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(rpc, animtime), w_ready);
176 if ((fire & 2) && (WEP_CVAR_SEC(rpc, refire_type) == 0)) // Secondary attack
178 if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(rpc, refire)))
182 // ugly instagib hack to reuse the fire mode of the laser
183 makevectors(actor.v_angle);
184 Weapon oldwep = actor.(weaponentity).m_weapon; // we can't avoid this hack
185 actor.(weaponentity).m_weapon = WEP_BLASTER;
189 WEP_BLASTER.m_id | HITTYPE_SECONDARY,
190 WEP_CVAR_SEC(rpc, shotangle),
191 WEP_CVAR_SEC(rpc, damage),
192 WEP_CVAR_SEC(rpc, edgedamage),
193 WEP_CVAR_SEC(rpc, radius),
194 WEP_CVAR_SEC(rpc, force),
195 WEP_CVAR_SEC(rpc, speed),
196 WEP_CVAR_SEC(rpc, spread),
197 WEP_CVAR_SEC(rpc, delay),
198 WEP_CVAR_SEC(rpc, lifetime)
200 actor.(weaponentity).m_weapon = oldwep;
201 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(rpc, animtime), w_ready);
205 METHOD(RocketPropelledChainsaw, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
207 float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(rpc, ammo);
208 ammo_amount += actor.(weaponentity).(weapon_load[WEP_RPC.m_id]) >= WEP_CVAR_PRI(rpc, ammo);
212 METHOD(RocketPropelledChainsaw, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
214 float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(rpc, ammo);
215 ammo_amount += actor.(weaponentity).(weapon_load[WEP_RPC.m_id]) >= WEP_CVAR_SEC(rpc, ammo);
219 METHOD(RocketPropelledChainsaw, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
221 W_Reload(actor, weaponentity, WEP_CVAR_PRI(rpc, ammo), SND_RELOAD);
224 METHOD(RocketPropelledChainsaw, wr_suicidemessage, Notification(entity thiswep))
226 if((w_deathtype & HITTYPE_BOUNCE) || (w_deathtype & HITTYPE_SPLASH))
227 return WEAPON_RPC_SUICIDE_SPLASH;
229 return WEAPON_RPC_SUICIDE_DIRECT;
232 METHOD(RocketPropelledChainsaw, wr_killmessage, Notification(entity thiswep))
234 if(w_deathtype & HITTYPE_SECONDARY)
235 return WEAPON_BLASTER_MURDER;
236 else if((w_deathtype & HITTYPE_BOUNCE) || (w_deathtype & HITTYPE_SPLASH))
237 return WEAPON_RPC_MURDER_SPLASH;
239 return WEAPON_RPC_MURDER_DIRECT;
246 METHOD(RocketPropelledChainsaw, wr_impacteffect, void(entity thiswep, entity actor))
249 org2 = w_org + w_backoff * 12;
250 pointparticles(EFFECT_ROCKET_EXPLODE, org2, '0 0 0', 1);
252 sound(actor, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);