3 /* ammotype */ //ATTRIB(Blaster, ammo_field, .int, ammo_none)
4 /* impulse */ ATTRIB(Blaster, impulse, int, 1)
5 /* flags */ ATTRIB(Blaster, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH);
6 /* rating */ ATTRIB(Blaster, bot_pickupbasevalue, float, 0);
7 /* color */ ATTRIB(Blaster, wpcolor, vector, '1 0.5 0.5');
8 /* modelname */ ATTRIB(Blaster, mdl, string, "laser");
10 /* model */ ATTRIB(Blaster, m_model, Model, MDL_BLASTER_ITEM);
12 /* crosshair */ ATTRIB(Blaster, w_crosshair, string, "gfx/crosshairlaser");
13 /* crosshair */ ATTRIB(Blaster, w_crosshair_size, float, 0.5);
14 /* wepimg */ ATTRIB(Blaster, model2, string, "weaponlaser");
15 /* refname */ ATTRIB(Blaster, netname, string, "blaster");
16 /* wepname */ ATTRIB(Blaster, message, string, _("Blaster"));
18 REGISTER_WEAPON(BLASTER, NEW(Blaster));
20 #define BLASTER_SETTINGS(w_cvar,w_prop) BLASTER_SETTINGS_LIST(w_cvar, w_prop, BLASTER, blaster)
21 #define BLASTER_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
22 w_cvar(id, sn, BOTH, animtime) \
23 w_cvar(id, sn, BOTH, damage) \
24 w_cvar(id, sn, BOTH, delay) \
25 w_cvar(id, sn, BOTH, edgedamage) \
26 w_cvar(id, sn, BOTH, force) \
27 w_cvar(id, sn, BOTH, force_zscale) \
28 w_cvar(id, sn, BOTH, lifetime) \
29 w_cvar(id, sn, BOTH, radius) \
30 w_cvar(id, sn, BOTH, refire) \
31 w_cvar(id, sn, BOTH, shotangle) \
32 w_cvar(id, sn, BOTH, speed) \
33 w_cvar(id, sn, BOTH, spread) \
34 w_cvar(id, sn, NONE, secondary) \
35 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
36 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
37 w_prop(id, sn, string, weaponreplace, weaponreplace) \
38 w_prop(id, sn, float, weaponstart, weaponstart) \
39 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride) \
40 w_prop(id, sn, float, weaponthrowable, weaponthrowable)
43 BLASTER_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
44 .float blaster_damage;
45 .float blaster_edgedamage;
46 .float blaster_radius;
48 .float blaster_lifetime;
53 void spawnfunc_weapon_blaster(void) { weapon_defaultspawnfunc(WEP_BLASTER.m_id); }
54 void spawnfunc_weapon_laser(void) { spawnfunc_weapon_blaster(); }
56 void W_Blaster_Touch(void)
60 self.event_damage = func_null;
66 self.blaster_edgedamage,
71 self.projectiledeathtype,
78 void W_Blaster_Think(void)
80 self.movetype = MOVETYPE_FLY;
81 self.think = SUB_Remove;
82 self.nextthink = time + self.blaster_lifetime;
83 CSQCProjectile(self, true, PROJECTILE_BLASTER, true);
86 void W_Blaster_Attack(
98 vector s_forward = v_forward * cos(atk_shotangle * DEG2RAD) + v_up * sin(atk_shotangle * DEG2RAD);
100 W_SetupShot_Dir(self, s_forward, false, 3, SND(LASERGUN_FIRE), CH_WEAPON_B, atk_damage);
101 Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
103 entity missile = spawn();
104 missile.owner = missile.realowner = self;
105 missile.classname = "blasterbolt";
106 missile.bot_dodge = true;
107 missile.bot_dodgerating = atk_damage;
108 PROJECTILE_MAKETRIGGER(missile);
110 missile.blaster_damage = atk_damage;
111 missile.blaster_edgedamage = atk_edgedamage;
112 missile.blaster_radius = atk_radius;
113 missile.blaster_force = atk_force;
114 missile.blaster_lifetime = atk_lifetime;
116 setorigin(missile, w_shotorg);
117 setsize(missile, '0 0 0', '0 0 0');
119 W_SetupProjVelocity_Explicit(
130 missile.angles = vectoangles(missile.velocity);
132 //missile.glow_color = 250; // 244, 250
133 //missile.glow_size = 120;
135 missile.touch = W_Blaster_Touch;
136 missile.flags = FL_PROJECTILE;
137 missile.missile_flags = MIF_SPLASH;
138 missile.projectiledeathtype = atk_deathtype;
139 missile.think = W_Blaster_Think;
140 missile.nextthink = time + atk_delay;
142 MUTATOR_CALLHOOK(EditProjectile, self, missile);
144 if(time >= missile.nextthink)
146 WITH(entity, self, missile, missile.think());
150 METHOD(Blaster, wr_aim, bool(entity thiswep))
152 if(WEP_CVAR(blaster, secondary))
154 if((random() * (WEP_CVAR_PRI(blaster, damage) + WEP_CVAR_SEC(blaster, damage))) > WEP_CVAR_PRI(blaster, damage))
155 { self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_SEC(blaster, speed), 0, WEP_CVAR_SEC(blaster, lifetime), false); }
157 { self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(blaster, speed), 0, WEP_CVAR_PRI(blaster, lifetime), false); }
160 { self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(blaster, speed), 0, WEP_CVAR_PRI(blaster, lifetime), false); }
165 METHOD(Blaster, wr_think, bool(entity thiswep, bool fire1, bool fire2))
169 if(weapon_prepareattack(0, WEP_CVAR_PRI(blaster, refire)))
173 WEP_CVAR_PRI(blaster, shotangle),
174 WEP_CVAR_PRI(blaster, damage),
175 WEP_CVAR_PRI(blaster, edgedamage),
176 WEP_CVAR_PRI(blaster, radius),
177 WEP_CVAR_PRI(blaster, force),
178 WEP_CVAR_PRI(blaster, speed),
179 WEP_CVAR_PRI(blaster, spread),
180 WEP_CVAR_PRI(blaster, delay),
181 WEP_CVAR_PRI(blaster, lifetime)
183 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(blaster, animtime), w_ready);
188 switch(WEP_CVAR(blaster, secondary))
190 case 0: // switch to last used weapon
192 if(self.switchweapon == WEP_BLASTER.m_id) // don't do this if already switching
197 case 1: // normal projectile secondary
199 if(weapon_prepareattack(1, WEP_CVAR_SEC(blaster, refire)))
202 WEP_BLASTER.m_id | HITTYPE_SECONDARY,
203 WEP_CVAR_SEC(blaster, shotangle),
204 WEP_CVAR_SEC(blaster, damage),
205 WEP_CVAR_SEC(blaster, edgedamage),
206 WEP_CVAR_SEC(blaster, radius),
207 WEP_CVAR_SEC(blaster, force),
208 WEP_CVAR_SEC(blaster, speed),
209 WEP_CVAR_SEC(blaster, spread),
210 WEP_CVAR_SEC(blaster, delay),
211 WEP_CVAR_SEC(blaster, lifetime)
213 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(blaster, animtime), w_ready);
223 METHOD(Blaster, wr_init, bool(entity thiswep))
225 BLASTER_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
229 METHOD(Blaster, wr_setup, bool(entity thiswep))
231 self.ammo_field = ammo_none;
235 METHOD(Blaster, wr_checkammo1, bool(entity thiswep))
237 return true; // infinite ammo
240 METHOD(Blaster, wr_checkammo2, bool(entity thiswep))
242 return true; // blaster has infinite ammo
245 METHOD(Blaster, wr_config, bool(entity thiswep))
247 BLASTER_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
251 METHOD(Blaster, wr_suicidemessage, bool(entity thiswep))
253 return WEAPON_BLASTER_SUICIDE;
256 METHOD(Blaster, wr_killmessage, bool(entity thiswep))
258 return WEAPON_BLASTER_MURDER;
264 METHOD(Blaster, wr_impacteffect, bool(entity thiswep))
267 org2 = w_org + w_backoff * 6;
268 pointparticles(particleeffectnum(EFFECT_BLASTER_IMPACT), org2, w_backoff * 1000, 1);
269 if(!w_issilent) { sound(self, CH_SHOTS, SND_LASERIMPACT, VOL_BASE, ATTN_NORM); }
273 METHOD(Blaster, wr_init, bool(entity thiswep))
278 METHOD(Blaster, wr_zoomreticle, bool(entity thiswep))
280 // no weapon specific image for this weapon