]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_hook.qc
add on-hand hook weapon placable by mapper (weapon_hook)
[divverent/nexuiz.git] / data / qcsrc / server / w_hook.qc
1 void W_Hook_Explode2 (void)
2 {
3         vector org2;
4
5         org2 = findbetterlocation (self.origin, 12);
6         pointparticles(particleeffectnum("hookbomb_explode"), org2, '0 0 0', 1);
7         sound (self, CHAN_PROJECTILE, "weapons/hookbomb_impact.wav", VOL_BASE, ATTN_NORM);
8
9         self.event_damage = SUB_Null;
10         RadiusDamage (self, self.owner, cvar("g_balance_hook_secondary_damage"), cvar("g_balance_hook_secondary_edgedamage"), cvar("g_balance_hook_secondary_radius"), world, cvar("g_balance_hook_secondary_force"), self.projectiledeathtype, other);
11
12         remove(self);
13 }
14
15 void W_Hook_Touch2 (void)
16 {
17         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
18         {
19                 remove(self);
20                 return;
21         }
22         self.use();
23 }
24
25 void W_Hook_Attack2()
26 {
27         local entity gren;
28
29         if not(self.items & IT_UNLIMITED_AMMO)
30                 self.ammo_cells = self.ammo_cells - cvar("g_balance_hook_secondary_ammo");
31         W_SetupShot (self, '25 6 -8', FALSE, 4, "weapons/hookbomb_fire.wav");
32
33         gren = spawn ();
34         gren.owner = self;
35         gren.classname = "hookbomb";
36         gren.bot_dodge = TRUE;
37         gren.bot_dodgerating = cvar("g_balance_hook_secondary_damage");
38         gren.movetype = MOVETYPE_TOSS;
39         gren.solid = SOLID_BBOX;
40         gren.effects = EF_LOWPRECISION;
41         gren.modelflags = MF_TRACER2;
42         gren.projectiledeathtype = WEP_HOOK | HITTYPE_SECONDARY;
43         setmodel(gren, "models/grenademodel.md3"); // precision set above // FIXME replace
44         setsize(gren, '0 0 0', '0 0 0');
45         setorigin(gren, w_shotorg);
46
47         gren.nextthink = time + cvar("g_balance_hook_secondary_lifetime");
48         gren.think = adaptor_think2use;
49         gren.use = W_Hook_Explode2;
50         gren.touch = W_Hook_Touch2;
51         gren.velocity = '0 0 1' * cvar("g_balance_hook_secondary_speed");
52         gren.gravity = cvar("g_balance_hook_secondary_gravity");
53         //W_SetupProjectileVelocity(gren); // just falling down!
54
55         gren.angles = '0 0 0';
56         gren.flags = FL_PROJECTILE;
57 }
58
59 void spawnfunc_weapon_hook (void)
60 {
61         weapon_defaultspawnfunc(WEP_HOOK);
62 }
63
64 float w_hook(float req)
65 {
66         if (req == WR_AIM)
67         {
68                 // ... sorry ...
69         }
70         else if (req == WR_THINK)
71         {
72                 if (self.BUTTON_ATCK || self.BUTTON_HOOK)
73                 {
74                         if(!self.hook)
75                         if not(self.hook_state & HOOK_WAITING_FOR_RELEASE)
76                         if (weapon_prepareattack(0, cvar("g_balance_hook_primary_refire")))
77                         {
78                                 if not(self.items & IT_UNLIMITED_AMMO)
79                                         self.ammo_cells = self.ammo_cells - cvar("g_balance_hook_primary_ammo");
80                                 self.hook_state |= HOOK_FIRING;
81                                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hook_primary_animtime"), w_ready);
82                         }
83                 }
84
85                 if (self.BUTTON_ATCK2)
86                 {
87                         if (weapon_prepareattack(1, cvar("g_balance_hook_secondary_refire")))
88                         {
89                                 W_Hook_Attack2();
90                                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hook_secondary_animtime"), w_ready);
91                         }
92                 }
93
94                 if (self.BUTTON_CROUCH)
95                 {
96                         self.hook_state (-) HOOK_PULLING;
97                         if (self.BUTTON_ATCK || self.BUTTON_HOOK)
98                                 self.hook_state (-) HOOK_RELEASING;
99                         else
100                                 self.hook_state |= HOOK_RELEASING;
101                 }
102                 else
103                 {
104                         self.hook_state |= HOOK_PULLING;
105                         self.hook_state (-) HOOK_RELEASING;
106
107                         if (self.BUTTON_ATCK || self.BUTTON_HOOK)
108                         {
109                                 // already fired
110                                 if(self.hook)
111                                         self.hook_state |= HOOK_WAITING_FOR_RELEASE;
112                         }
113                         else
114                         {
115                                 self.hook_state |= HOOK_REMOVING;
116                                 self.hook_state (-) HOOK_WAITING_FOR_RELEASE;
117                         }
118                 }
119         }
120         else if (req == WR_PRECACHE)
121         {
122                 precache_model ("models/weapons/g_hook.md3");
123                 precache_model ("models/weapons/v_hook.md3");
124                 precache_model ("models/weapons/w_hook.zym");
125                 precache_sound ("weapons/hook_fire.wav");
126                 precache_sound ("weapons/hook_impact.wav");
127                 precache_sound ("weapons/hookbomb_fire.wav");
128                 precache_sound ("weapons/hookbomb_impact.wav");
129         }
130         else if (req == WR_SETUP)
131         {
132                 weapon_setup(WEP_HOOK);
133         }
134         else if (req == WR_CHECKAMMO1)
135         {
136                 return self.ammo_cells >= cvar("g_balance_hook_primary_ammo");
137         }
138         else if (req == WR_CHECKAMMO2)
139         {
140                 return self.ammo_cells >= cvar("g_balance_hook_secondary_ammo");
141         }
142         else if (req == WR_SUICIDEMESSAGE)
143                 w_deathtypestring = "did the impossible";
144         else if (req == WR_KILLMESSAGE)
145                 w_deathtypestring = "has run into #'s gravity bomb";
146         return TRUE;
147 };