From 782d5e9cf0561ce07a78cafef5bd7725709aaac3 Mon Sep 17 00:00:00 2001 From: TimePath Date: Sat, 26 Sep 2015 12:31:33 +1000 Subject: [PATCH] Player usable vehicle attack --- qcsrc/common/monsters/monster/mage.qc | 4 +++- qcsrc/common/turrets/unit/plasma_dual.qc | 3 ++- qcsrc/common/vehicles/unit/racer.qc | 26 ++++++++++++++++++++++++ qcsrc/common/weapons/all.qh | 2 +- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/qcsrc/common/monsters/monster/mage.qc b/qcsrc/common/monsters/monster/mage.qc index e8e38824b..a3114812b 100644 --- a/qcsrc/common/monsters/monster/mage.qc +++ b/qcsrc/common/monsters/monster/mage.qc @@ -15,9 +15,11 @@ REGISTER_MONSTER_SIMPLE( #endif } +#include "../../weapons/all.qh" + CLASS(MageSpike, PortoLaunch) /* flags */ ATTRIB(MageSpike, spawnflags, int, WEP_TYPE_OTHER); -/* impulse */ ATTRIB(MageSpike, impulse, int, 5); +/* impulse */ ATTRIB(MageSpike, impulse, int, 9); /* refname */ ATTRIB(MageSpike, netname, string, "magespike"); /* wepname */ ATTRIB(MageSpike, message, string, _("Mage spike")); ENDCLASS(MageSpike) diff --git a/qcsrc/common/turrets/unit/plasma_dual.qc b/qcsrc/common/turrets/unit/plasma_dual.qc index 78cfbe95a..7f761bad1 100644 --- a/qcsrc/common/turrets/unit/plasma_dual.qc +++ b/qcsrc/common/turrets/unit/plasma_dual.qc @@ -11,6 +11,8 @@ REGISTER_TURRET( ); #else +#include "../../weapons/all.qh" + CLASS(PlasmaDualAttack, PortoLaunch) /* flags */ ATTRIB(PlasmaDualAttack, spawnflags, int, WEP_TYPE_OTHER); /* impulse */ ATTRIB(PlasmaDualAttack, impulse, int, 5); @@ -28,7 +30,6 @@ METHOD(PlasmaDualAttack, wr_think, bool(entity thiswep)) { SELFPARAM(); if (self.BUTTON_ATCK) if (weapon_prepareattack(0, WEP_CVAR_PRI(electro, refire))) { - if (!self.target_range) self.target_range = autocvar_g_monsters_target_range; W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); self.tur_shotdir_updated = w_shotdir; self.tur_shotorg = w_shotorg; diff --git a/qcsrc/common/vehicles/unit/racer.qc b/qcsrc/common/vehicles/unit/racer.qc index 62a6e850f..4f8325517 100644 --- a/qcsrc/common/vehicles/unit/racer.qc +++ b/qcsrc/common/vehicles/unit/racer.qc @@ -1,5 +1,6 @@ #ifndef VEHICLE_RACER #define VEHICLE_RACER + #ifndef MENUQC int v_racer(int); #endif @@ -19,6 +20,19 @@ REGISTER_VEHICLE_SIMPLE( this.vehicle_func = v_racer; #endif } + +#include "../../weapons/all.qh" + +CLASS(RacerAttack, PortoLaunch) +/* flags */ ATTRIB(RacerAttack, spawnflags, int, WEP_TYPE_OTHER); +/* impulse */ ATTRIB(RacerAttack, impulse, int, 3); +/* refname */ ATTRIB(RacerAttack, netname, string, "racercannon"); +/* wepname */ ATTRIB(RacerAttack, message, string, _("Racer cannon")); +ENDCLASS(RacerAttack) +REGISTER_WEAPON(RACER, NEW(RacerAttack)) { + localcmd(sprintf("alias weapon_%s \"impulse %d\"\n", this.netname, 230 + this.m_id - 1)); +} + #endif #ifdef IMPLEMENTATION @@ -26,6 +40,18 @@ REGISTER_VEHICLE_SIMPLE( #include "../../effects/effects.qh" #include "../../triggers/trigger/impulse.qh" +void racer_fire_cannon(string tagname); +METHOD(RacerAttack, wr_think, bool(entity thiswep)) { + SELFPARAM(); + if (self.BUTTON_ATCK) + if (weapon_prepareattack(0, 0)) { + W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("lasergun_fire"), CH_WEAPON_B, 0); + racer_fire_cannon("tag_fire1"); + weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), w_ready); + } + return true; +} + bool autocvar_g_vehicle_racer; float autocvar_g_vehicle_racer_speed_afterburn; diff --git a/qcsrc/common/weapons/all.qh b/qcsrc/common/weapons/all.qh index e7f66e979..c2ed2af7b 100644 --- a/qcsrc/common/weapons/all.qh +++ b/qcsrc/common/weapons/all.qh @@ -104,7 +104,7 @@ WepSet ReadWepSet(); // weapon name macros const int WEP_FIRST = 1; -#define WEP_MAXCOUNT 24 // Increase as needed. Can be up to three times as much. +#define WEP_MAXCOUNT 32 // Increase as needed. Can be up to 72. int WEP_COUNT; #define WEP_LAST (WEP_FIRST + WEP_COUNT - 1) WepSet WEPSET_ALL; -- 2.39.2