1 #include "tesla_weapon.qh"
7 entity toast(entity actor, entity from, float range, float damage);
8 SOUND(TeslaCoilTurretAttack_FIRE, W_Sound("electro_fire"));
9 METHOD(TeslaCoilTurretAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
10 bool isPlayer = IS_PLAYER(actor);
12 if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) {
14 turret_initparams(actor);
15 W_SetupShot_Dir(actor, v_forward, false, 0, SND_TeslaCoilTurretAttack_FIRE, CH_WEAPON_B, 0);
16 actor.tur_shotdir_updated = w_shotdir;
17 actor.tur_shotorg = w_shotorg;
18 actor.tur_head = actor;
19 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
22 float d = actor.shot_dmg;
23 float r = actor.target_range;
25 setorigin(e, actor.tur_shotorg);
27 actor.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK;
29 entity t = toast(actor, e,r,d);
32 if (t == NULL) return;
34 actor.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES | TFL_TARGETSELECT_TEAMCHECK;
36 actor.attack_finished_single[0] = time + actor.shot_refire;
37 for (int i = 0; i < 10; ++i) {
40 t = toast(actor, t, r, d);
41 if (t == world) break;
45 e = findchainfloat(railgunhit, 1);
54 entity toast(entity actor, entity from, float range, float damage)
57 entity etarget = world;
63 e = findradius(from.origin,range);
66 if ((e.railgunhit != 1) && (e != from))
68 r = turret_validate_target(actor,e,actor.target_validate_flags);
71 traceline(from.origin,0.5 * (e.absmin + e.absmax),MOVE_WORLDONLY,from);
72 if (trace_fraction == 1.0)
74 d = vlen(e.origin - from.origin);
88 te_csqc_lightningarc(from.origin,etarget.origin);
89 Damage(etarget, actor, actor, damage, DEATH_TURRET_TESLA.m_id, etarget.origin, '0 0 0');
90 etarget.railgunhit = 1;