1 #include "raptor_weapons.qh"
5 METHOD(RaptorCannon, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
6 bool isPlayer = IS_PLAYER(actor);
7 entity player = isPlayer ? actor : actor.owner;
8 entity veh = player.vehicle;
9 // 1 [wait] 1 [wait] 2 [wait] 2 [wait] [wait]
10 float t = autocvar_g_vehicle_raptor_cannon_refire * (1 + veh.misc_bulletcounter == 4);
12 if (weapon_prepareattack(thiswep, player, weaponentity, false, t)) {
13 if (isPlayer) W_SetupShot_Dir(player, weaponentity, v_forward, false, 0, SND_Null, CH_WEAPON_B, 0);
14 vector org = w_shotorg;
15 vector dir = w_shotdir;
17 veh.misc_bulletcounter += 1;
18 org = (veh.misc_bulletcounter <= 2) ? gettaginfo(veh.gun1, gettagindex(veh.gun1, "fire1"))
19 : (((veh.misc_bulletcounter == 4) ? veh.misc_bulletcounter = 0 : 0), gettaginfo(veh.gun2, gettagindex(veh.gun2, "fire1")));
21 veh.vehicle_energy -= autocvar_g_vehicle_raptor_cannon_cost;
24 vehicles_projectile(veh, EFFECT_RAPTOR_MUZZLEFLASH.eent_eff_name, SND_LASERGUN_FIRE,
25 org, normalize(dir + randomvec() * autocvar_g_vehicle_raptor_cannon_spread) * autocvar_g_vehicle_raptor_cannon_speed,
26 autocvar_g_vehicle_raptor_cannon_damage, autocvar_g_vehicle_raptor_cannon_radius, autocvar_g_vehicle_raptor_cannon_force, 0,
27 DEATH_VH_RAPT_CANNON.m_id, PROJECTILE_RAPTORCANNON, 0, true, true, player);
28 weapon_thinkf(player, weaponentity, WFRAME_FIRE1, 0, w_ready);
31 METHOD(RaptorCannon, wr_checkammo1, bool(RacerAttack thiswep, entity actor, .entity weaponentity)) {
32 bool isPlayer = IS_PLAYER(actor);
33 entity player = isPlayer ? actor : actor.owner;
34 entity veh = player.vehicle;
35 return isPlayer || veh.vehicle_energy >= autocvar_g_vehicle_raptor_cannon_cost;
39 void raptor_bombdrop(entity this);
40 METHOD(RaptorBomb, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
41 bool isPlayer = IS_PLAYER(actor);
42 entity player = isPlayer ? actor : actor.owner;
43 entity veh = player.vehicle;
45 if (!isPlayer || weapon_prepareattack(thiswep, player, weaponentity, true, autocvar_g_vehicle_raptor_bombs_refire)) {
46 entity e = (veh) ? veh : player;
48 weapon_thinkf(player, weaponentity, WFRAME_FIRE2, 0, w_ready);
52 void raptor_flare_think(entity this);
53 void raptor_flare_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force);
54 void raptor_flare_touch(entity this, entity toucher);
56 METHOD(RaptorFlare, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
57 bool isPlayer = IS_PLAYER(actor);
58 entity player = isPlayer ? actor : actor.owner;
59 entity veh = player.vehicle;
61 if (!isPlayer || weapon_prepareattack(thiswep, player, weaponentity, true, autocvar_g_vehicle_raptor_flare_refire)) {
62 for(int i = 0; i < 3; ++i) {
63 entity _flare = spawn();
64 setmodel(_flare, MDL_VEH_RAPTOR_FLARE);
65 _flare.effects = EF_LOWPRECISION | EF_FLAME;
67 setorigin(_flare, actor.origin - '0 0 16');
68 set_movetype(_flare, MOVETYPE_TOSS);
69 _flare.gravity = 0.15;
70 _flare.velocity = 0.25 * actor.velocity + (v_forward + randomvec() * 0.25)* -500;
71 setthink(_flare, raptor_flare_think);
72 _flare.nextthink = time;
73 _flare.owner = veh ? veh : player;
74 _flare.solid = SOLID_CORPSE;
75 _flare.takedamage = DAMAGE_YES;
76 _flare.event_damage = raptor_flare_damage;
78 _flare.tur_impacttime = time + autocvar_g_vehicle_raptor_flare_lifetime;
79 settouch(_flare, raptor_flare_touch);
81 weapon_thinkf(player, weaponentity, WFRAME_FIRE2, 0, w_ready);
86 void raptor_bomblet_boom(entity this)
88 RadiusDamage (this, this.realowner, autocvar_g_vehicle_raptor_bomblet_damage,
89 autocvar_g_vehicle_raptor_bomblet_edgedamage,
90 autocvar_g_vehicle_raptor_bomblet_radius, NULL, NULL,
91 autocvar_g_vehicle_raptor_bomblet_force, DEATH_VH_RAPT_BOMB.m_id, DMG_NOWEP, NULL);
95 void raptor_bomblet_touch(entity this, entity toucher)
97 if(toucher == this.owner)
100 PROJECTILE_TOUCH(this, toucher);
101 setthink(this, raptor_bomblet_boom);
102 this.nextthink = time + random() * autocvar_g_vehicle_raptor_bomblet_explode_delay;
105 void raptor_bomb_burst(entity this)
108 if(autocvar_g_vehicle_raptor_bomblet_alt)
110 this.nextthink = time;
111 traceline(this.origin, this.origin + (normalize(this.velocity) * autocvar_g_vehicle_raptor_bomblet_alt), MOVE_NORMAL, this);
112 if((trace_fraction == 1.0) || (vdist(this.origin - this.owner.origin, <, autocvar_g_vehicle_raptor_bomblet_radius)))
114 UpdateCSQCProjectile(this);
122 Damage_DamageInfo(this.origin, 0, 0, 0, '0 0 0', DEATH_VH_RAPT_FRAGMENT.m_id, 0, this);
124 for(i = 0; i < autocvar_g_vehicle_raptor_bomblets; ++i)
127 setorigin(bomblet, this.origin);
129 set_movetype(bomblet, MOVETYPE_TOSS);
130 settouch(bomblet, raptor_bomblet_touch);
131 setthink(bomblet, raptor_bomblet_boom);
132 bomblet.nextthink = time + 5;
133 bomblet.owner = this.owner;
134 bomblet.realowner = this.realowner;
135 bomblet.velocity = normalize(normalize(this.velocity) + (randomvec() * autocvar_g_vehicle_raptor_bomblet_spread)) * vlen(this.velocity);
137 PROJECTILE_MAKETRIGGER(bomblet);
138 CSQCProjectile(bomblet, true, PROJECTILE_RAPTORBOMBLET, true);
144 void raptor_bomb_touch(entity this, entity toucher)
146 raptor_bomb_burst(this);
149 void raptor_bombdrop(entity this)
151 entity bomb_1, bomb_2;
156 vector org = gettaginfo(this, gettagindex(this, "bombmount_left"));
157 setorigin(bomb_1, org);
158 org = gettaginfo(this, gettagindex(this, "bombmount_right"));
159 setorigin(bomb_2, org);
161 set_movetype(bomb_1, MOVETYPE_BOUNCE);
162 set_movetype(bomb_2, MOVETYPE_BOUNCE);
163 bomb_1.velocity = bomb_2.velocity = this.velocity;
164 settouch(bomb_1, raptor_bomb_touch);
165 settouch(bomb_2, raptor_bomb_touch);
166 setthink(bomb_1, raptor_bomb_burst);
167 setthink(bomb_2, raptor_bomb_burst);
168 bomb_1.cnt = bomb_2.cnt = time + 10;
170 if(autocvar_g_vehicle_raptor_bomblet_alt)
171 bomb_1.nextthink = bomb_2.nextthink = time;
173 bomb_1.nextthink = bomb_2.nextthink = time + autocvar_g_vehicle_raptor_bomblet_time;
175 bomb_1.owner = bomb_2.owner = this;
176 bomb_1.realowner = bomb_2.realowner = this.owner;
177 bomb_1.solid = bomb_2.solid = SOLID_BBOX;
178 bomb_1.gravity = bomb_2.gravity = 1;
180 PROJECTILE_MAKETRIGGER(bomb_1);
181 PROJECTILE_MAKETRIGGER(bomb_2);
183 CSQCProjectile(bomb_1, true, PROJECTILE_RAPTORBOMB, true);
184 CSQCProjectile(bomb_2, true, PROJECTILE_RAPTORBOMB, true);
187 void raptor_flare_touch(entity this, entity toucher)
192 void raptor_flare_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
194 this.health -= damage;
199 void raptor_flare_think(entity this)
201 this.nextthink = time + 0.1;
202 IL_EACH(g_projectiles, it.enemy == this.owner,
204 if(vdist(this.origin - it.origin, <, autocvar_g_vehicle_raptor_flare_range))
205 if(random() > autocvar_g_vehicle_raptor_flare_chase)
209 if(this.tur_impacttime < time)
217 void RaptorCBShellfragDraw(entity this)
222 Movetype_Physics_MatchTicrate(this, autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
223 this.avelocity += randomvec() * 15;
224 this.renderflags = 0;
227 this.alpha = bound(0, this.nextthink - time, 1);
229 if(this.alpha < ALPHA_MIN_VISIBLE)
233 void RaptorCBShellfragToss(vector _org, vector _vel, vector _ang)
235 entity sfrag = spawn();
236 setmodel(sfrag, MDL_VEH_RAPTOR_CB_FRAGMENT);
237 setorigin(sfrag, _org);
239 set_movetype(sfrag, MOVETYPE_BOUNCE);
240 sfrag.gravity = 0.15;
241 sfrag.solid = SOLID_CORPSE;
243 sfrag.draw = RaptorCBShellfragDraw;
244 IL_PUSH(g_drawables, sfrag);
246 sfrag.velocity = _vel;
247 sfrag.avelocity = prandomvec() * vlen(sfrag.velocity);
250 sfrag.move_time = time;
251 sfrag.damageforcescale = 4;
253 sfrag.nextthink = time + 3;
254 sfrag.cnt = time + 2;
256 sfrag.drawmask = MASK_NORMAL;