- METHOD(Rifle, wr_aim, void(entity thiswep))
- {
- self.BUTTON_ATCK=false;
- self.BUTTON_ATCK2=false;
- if(vlen(self.origin-self.enemy.origin) > 1000)
- self.bot_secondary_riflemooth = 0;
- if(self.bot_secondary_riflemooth == 0)
- {
- if(bot_aim(1000000, 0, 0.001, false))
- {
- self.BUTTON_ATCK = true;
- if(random() < 0.01) self.bot_secondary_riflemooth = 1;
- }
- }
- else
- {
- if(bot_aim(1000000, 0, 0.001, false))
- {
- self.BUTTON_ATCK2 = true;
- if(random() < 0.03) self.bot_secondary_riflemooth = 0;
- }
- }
- }
- METHOD(Rifle, wr_think, void(entity thiswep, entity actor, int slot, int fire))
- {
- if(autocvar_g_balance_rifle_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo))) { // forced reload
- Weapon w = get_weaponinfo(actor.weapon);
- w.wr_reload(w);
- } else
- {
- actor.rifle_accumulator = bound(time - WEP_CVAR(rifle, bursttime), actor.rifle_accumulator, time);
- if(fire & 1)
- if(weapon_prepareattack_check(thiswep, actor, slot, false, WEP_CVAR_PRI(rifle, refire)))
- if(time >= actor.rifle_accumulator + WEP_CVAR_PRI(rifle, burstcost))
- {
- weapon_prepareattack_do(actor, slot, false, WEP_CVAR_PRI(rifle, refire));
- W_Rifle_BulletHail(slot, WEP_CVAR_PRI(rifle, bullethail), W_Rifle_Attack, WFRAME_FIRE1, WEP_CVAR_PRI(rifle, animtime), WEP_CVAR_PRI(rifle, refire));
- actor.rifle_accumulator += WEP_CVAR_PRI(rifle, burstcost);
- }
- if(fire & 2)
- {
- if(WEP_CVAR(rifle, secondary))
- {
- if(WEP_CVAR_SEC(rifle, reload)) {
- Weapon w = get_weaponinfo(actor.weapon);
- w.wr_reload(w);
- } else
- {
- if(weapon_prepareattack_check(thiswep, actor, slot, true, WEP_CVAR_SEC(rifle, refire)))
- if(time >= actor.rifle_accumulator + WEP_CVAR_SEC(rifle, burstcost))
- {
- weapon_prepareattack_do(actor, slot, true, WEP_CVAR_SEC(rifle, refire));
- W_Rifle_BulletHail(slot, WEP_CVAR_SEC(rifle, bullethail), W_Rifle_Attack2, WFRAME_FIRE2, WEP_CVAR_SEC(rifle, animtime), WEP_CVAR_PRI(rifle, refire));
- actor.rifle_accumulator += WEP_CVAR_SEC(rifle, burstcost);
- }
- }
- }
- }
- }
- }
- METHOD(Rifle, wr_init, void(entity thiswep))
- {
- RIFLE_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
- }
- METHOD(Rifle, wr_checkammo1, bool(entity thiswep))
- {
- float ammo_amount = self.WEP_AMMO(RIFLE) >= WEP_CVAR_PRI(rifle, ammo);
- ammo_amount += self.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_PRI(rifle, ammo);
- return ammo_amount;
- }
- METHOD(Rifle, wr_checkammo2, bool(entity thiswep))
- {
- float ammo_amount = self.WEP_AMMO(RIFLE) >= WEP_CVAR_SEC(rifle, ammo);
- ammo_amount += self.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_SEC(rifle, ammo);
- return ammo_amount;
- }
- METHOD(Rifle, wr_config, void(entity thiswep))
- {
- RIFLE_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
- }
- METHOD(Rifle, wr_resetplayer, void(entity thiswep))
- {
- self.rifle_accumulator = time - WEP_CVAR(rifle, bursttime);
- }
- METHOD(Rifle, wr_reload, void(entity thiswep))
- {
- W_Reload(self, min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo)), SND(RELOAD));
- }
- METHOD(Rifle, wr_suicidemessage, int(entity thiswep))
- {
- return WEAPON_THINKING_WITH_PORTALS;
- }
- METHOD(Rifle, wr_killmessage, int(entity thiswep))
- {
- if(w_deathtype & HITTYPE_SECONDARY)
- {
- if(w_deathtype & HITTYPE_BOUNCE)
- return WEAPON_RIFLE_MURDER_HAIL_PIERCING;
- else
- return WEAPON_RIFLE_MURDER_HAIL;
- }
- else
- {
- if(w_deathtype & HITTYPE_BOUNCE)
- return WEAPON_RIFLE_MURDER_PIERCING;
- else
- return WEAPON_RIFLE_MURDER;
- }
- }
+METHOD(Rifle, wr_aim, void(entity thiswep, entity actor))
+{
+ PHYS_INPUT_BUTTON_ATCK(actor) = false;
+ PHYS_INPUT_BUTTON_ATCK2(actor) = false;
+ if(vdist(actor.origin - actor.enemy.origin, >, 1000))
+ actor.bot_secondary_riflemooth = 0;
+ if(actor.bot_secondary_riflemooth == 0)
+ {
+ if(bot_aim(actor, 1000000, 0, 0.001, false))
+ {
+ PHYS_INPUT_BUTTON_ATCK(actor) = true;
+ if(random() < 0.01) actor.bot_secondary_riflemooth = 1;
+ }
+ }
+ else
+ {
+ if(bot_aim(actor, 1000000, 0, 0.001, false))
+ {
+ PHYS_INPUT_BUTTON_ATCK2(actor) = true;
+ if(random() < 0.03) actor.bot_secondary_riflemooth = 0;
+ }
+ }
+}
+METHOD(Rifle, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
+{
+ if(autocvar_g_balance_rifle_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo))) { // forced reload
+ thiswep.wr_reload(thiswep, actor, weaponentity);
+ } else
+ {
+ actor.rifle_accumulator = bound(time - WEP_CVAR(rifle, bursttime), actor.rifle_accumulator, time);
+ if(fire & 1)
+ if(weapon_prepareattack_check(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(rifle, refire)))
+ if(time >= actor.rifle_accumulator + WEP_CVAR_PRI(rifle, burstcost))
+ {
+ weapon_prepareattack_do(actor, weaponentity, false, WEP_CVAR_PRI(rifle, refire));
+ W_Rifle_BulletHail(actor, weaponentity, WEP_CVAR_PRI(rifle, bullethail), W_Rifle_Attack, WFRAME_FIRE1, WEP_CVAR_PRI(rifle, animtime), WEP_CVAR_PRI(rifle, refire));
+ actor.rifle_accumulator += WEP_CVAR_PRI(rifle, burstcost);
+ }
+ if(fire & 2)
+ {
+ if(WEP_CVAR(rifle, secondary))
+ {
+ if(WEP_CVAR_SEC(rifle, reload)) {
+ thiswep.wr_reload(thiswep, actor, weaponentity);
+ } else
+ {
+ if(weapon_prepareattack_check(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(rifle, refire)))
+ if(time >= actor.rifle_accumulator + WEP_CVAR_SEC(rifle, burstcost))
+ {
+ weapon_prepareattack_do(actor, weaponentity, true, WEP_CVAR_SEC(rifle, refire));
+ W_Rifle_BulletHail(actor, weaponentity, WEP_CVAR_SEC(rifle, bullethail), W_Rifle_Attack2, WFRAME_FIRE2, WEP_CVAR_SEC(rifle, animtime), WEP_CVAR_PRI(rifle, refire));
+ actor.rifle_accumulator += WEP_CVAR_SEC(rifle, burstcost);
+ }
+ }
+ }
+ }
+ }
+}
+METHOD(Rifle, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
+{
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(rifle, ammo);
+ ammo_amount += actor.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_PRI(rifle, ammo);
+ return ammo_amount;
+}
+METHOD(Rifle, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
+{
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(rifle, ammo);
+ ammo_amount += actor.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_SEC(rifle, ammo);
+ return ammo_amount;
+}
+METHOD(Rifle, wr_resetplayer, void(entity thiswep, entity actor))
+{
+ actor.rifle_accumulator = time - WEP_CVAR(rifle, bursttime);
+}
+METHOD(Rifle, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
+{
+ W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo)), SND_RELOAD);
+}
+METHOD(Rifle, wr_suicidemessage, Notification(entity thiswep))
+{
+ return WEAPON_THINKING_WITH_PORTALS;
+}
+METHOD(Rifle, wr_killmessage, Notification(entity thiswep))
+{
+ if(w_deathtype & HITTYPE_SECONDARY)
+ {
+ if(w_deathtype & HITTYPE_BOUNCE)
+ return WEAPON_RIFLE_MURDER_HAIL_PIERCING;
+ else
+ return WEAPON_RIFLE_MURDER_HAIL;
+ }
+ else
+ {
+ if(w_deathtype & HITTYPE_BOUNCE)
+ return WEAPON_RIFLE_MURDER_PIERCING;
+ else
+ return WEAPON_RIFLE_MURDER;
+ }
+}
+METHOD(Rifle, wr_zoom, bool(entity thiswep, entity actor))
+{
+ return PHYS_INPUT_BUTTON_ATCK2(actor) && WEP_CVAR(rifle, secondary) == 0;
+}