4 /* ammotype */ //ATTRIB(Blaster, ammo_field, .int, ammo_none);
5 /* impulse */ ATTRIB(Blaster, impulse, int, 1);
6 /* flags */ ATTRIB(Blaster, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH);
7 /* rating */ ATTRIB(Blaster, bot_pickupbasevalue, float, 0);
8 /* color */ ATTRIB(Blaster, wpcolor, vector, '1 0.5 0.5');
9 /* modelname */ ATTRIB(Blaster, mdl, string, "laser");
11 /* model */ ATTRIB(Blaster, m_model, Model, MDL_BLASTER_ITEM);
13 /* crosshair */ ATTRIB(Blaster, w_crosshair, string, "gfx/crosshairlaser");
14 /* crosshair */ ATTRIB(Blaster, w_crosshair_size, float, 0.5);
15 /* wepimg */ ATTRIB(Blaster, model2, string, "weaponlaser");
16 /* refname */ ATTRIB(Blaster, netname, string, "blaster");
17 /* wepname */ ATTRIB(Blaster, m_name, string, _("Blaster"));
19 #define X(BEGIN, P, END, class, prefix) \
21 P(class, prefix, animtime, float, BOTH) \
22 P(class, prefix, damage, float, BOTH) \
23 P(class, prefix, delay, float, BOTH) \
24 P(class, prefix, edgedamage, float, BOTH) \
25 P(class, prefix, force, float, BOTH) \
26 P(class, prefix, force_zscale, float, BOTH) \
27 P(class, prefix, lifetime, float, BOTH) \
28 P(class, prefix, radius, float, BOTH) \
29 P(class, prefix, refire, float, BOTH) \
30 P(class, prefix, secondary, float, NONE) \
31 P(class, prefix, shotangle, float, BOTH) \
32 P(class, prefix, speed, float, BOTH) \
33 P(class, prefix, spread, float, BOTH) \
34 P(class, prefix, switchdelay_drop, float, NONE) \
35 P(class, prefix, switchdelay_raise, float, NONE) \
36 P(class, prefix, weaponreplace, string, NONE) \
37 P(class, prefix, weaponstartoverride, float, NONE) \
38 P(class, prefix, weaponstart, float, NONE) \
39 P(class, prefix, weaponthrowable, float, NONE) \
41 W_PROPS(X, Blaster, blaster)
45 REGISTER_WEAPON(BLASTER, blaster, NEW(Blaster));
48 .float blaster_damage;
49 .float blaster_edgedamage;
50 .float blaster_radius;
52 .float blaster_lifetime;
57 spawnfunc(weapon_blaster) { weapon_defaultspawnfunc(this, WEP_BLASTER); }
58 spawnfunc(weapon_laser) { spawnfunc_weapon_blaster(this); }
60 void W_Blaster_Touch(entity this, entity toucher)
62 PROJECTILE_TOUCH(this, toucher);
64 this.event_damage = func_null;
70 this.blaster_edgedamage,
75 this.projectiledeathtype,
82 void W_Blaster_Think(entity this)
84 set_movetype(this, MOVETYPE_FLY);
85 setthink(this, SUB_Remove);
86 this.nextthink = time + this.blaster_lifetime;
87 CSQCProjectile(this, true, PROJECTILE_BLASTER, true);
90 void W_Blaster_Attack(
104 vector s_forward = v_forward * cos(atk_shotangle * DEG2RAD) + v_up * sin(atk_shotangle * DEG2RAD);
106 W_SetupShot_Dir(actor, weaponentity, s_forward, false, 3, SND_LASERGUN_FIRE, CH_WEAPON_B, atk_damage);
107 Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
109 entity missile = new(blasterbolt);
110 missile.owner = missile.realowner = actor;
111 missile.bot_dodge = true;
112 missile.bot_dodgerating = atk_damage;
113 PROJECTILE_MAKETRIGGER(missile);
115 missile.blaster_damage = atk_damage;
116 missile.blaster_edgedamage = atk_edgedamage;
117 missile.blaster_radius = atk_radius;
118 missile.blaster_force = atk_force;
119 missile.blaster_lifetime = atk_lifetime;
121 setorigin(missile, w_shotorg);
122 setsize(missile, '0 0 0', '0 0 0');
124 W_SetupProjVelocity_Explicit(
135 missile.angles = vectoangles(missile.velocity);
137 //missile.glow_color = 250; // 244, 250
138 //missile.glow_size = 120;
140 settouch(missile, W_Blaster_Touch);
141 missile.flags = FL_PROJECTILE;
142 IL_PUSH(g_projectiles, missile);
143 IL_PUSH(g_bot_dodge, missile);
144 missile.missile_flags = MIF_SPLASH;
145 missile.projectiledeathtype = atk_deathtype;
146 setthink(missile, W_Blaster_Think);
147 missile.nextthink = time + atk_delay;
149 MUTATOR_CALLHOOK(EditProjectile, actor, missile);
151 if (time >= missile.nextthink)
153 getthink(missile)(missile);
157 METHOD(Blaster, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
159 if(WEP_CVAR(blaster, secondary))
161 if((random() * (WEP_CVAR_PRI(blaster, damage) + WEP_CVAR_SEC(blaster, damage))) > WEP_CVAR_PRI(blaster, damage))
162 { PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, WEP_CVAR_SEC(blaster, speed), 0, WEP_CVAR_SEC(blaster, lifetime), false); }
164 { PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR_PRI(blaster, speed), 0, WEP_CVAR_PRI(blaster, lifetime), false); }
167 { PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR_PRI(blaster, speed), 0, WEP_CVAR_PRI(blaster, lifetime), false); }
170 METHOD(Blaster, wr_think, void(Blaster thiswep, entity actor, .entity weaponentity, int fire))
174 if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(blaster, refire)))
180 WEP_CVAR_PRI(blaster, shotangle),
181 WEP_CVAR_PRI(blaster, damage),
182 WEP_CVAR_PRI(blaster, edgedamage),
183 WEP_CVAR_PRI(blaster, radius),
184 WEP_CVAR_PRI(blaster, force),
185 WEP_CVAR_PRI(blaster, speed),
186 WEP_CVAR_PRI(blaster, spread),
187 WEP_CVAR_PRI(blaster, delay),
188 WEP_CVAR_PRI(blaster, lifetime)
190 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(blaster, animtime), w_ready);
195 switch(WEP_CVAR(blaster, secondary))
197 case 0: // switch to last used weapon
199 if(actor.(weaponentity).m_switchweapon == WEP_BLASTER) // don't do this if already switching
200 W_LastWeapon(actor, weaponentity);
204 case 1: // normal projectile secondary
206 if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(blaster, refire)))
211 WEP_BLASTER.m_id | HITTYPE_SECONDARY,
212 WEP_CVAR_SEC(blaster, shotangle),
213 WEP_CVAR_SEC(blaster, damage),
214 WEP_CVAR_SEC(blaster, edgedamage),
215 WEP_CVAR_SEC(blaster, radius),
216 WEP_CVAR_SEC(blaster, force),
217 WEP_CVAR_SEC(blaster, speed),
218 WEP_CVAR_SEC(blaster, spread),
219 WEP_CVAR_SEC(blaster, delay),
220 WEP_CVAR_SEC(blaster, lifetime)
222 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(blaster, animtime), w_ready);
231 METHOD(Blaster, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
233 return true; // infinite ammo
236 METHOD(Blaster, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
238 return true; // blaster has infinite ammo
241 METHOD(Blaster, wr_suicidemessage, Notification(entity thiswep))
243 return WEAPON_BLASTER_SUICIDE;
246 METHOD(Blaster, wr_killmessage, Notification(entity thiswep))
248 return WEAPON_BLASTER_MURDER;
254 METHOD(Blaster, wr_impacteffect, void(entity thiswep, entity actor))
257 org2 = w_org + w_backoff * 6;
258 pointparticles(EFFECT_BLASTER_IMPACT, org2, w_backoff * 1000, 1);
259 if(!w_issilent) { sound(actor, CH_SHOTS, SND_LASERIMPACT, VOL_BASE, ATTN_NORM); }