]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_hook.qc
fix turrets for onslaught: default them to have no team and attack nobody if not...
[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"), self.owner, 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         if(g_grappling_hook) // offhand hook
62         {
63                 startitem_failed = TRUE;
64                 remove(self);
65                 return;
66         }
67         weapon_defaultspawnfunc(WEP_HOOK);
68 }
69
70 float w_hook(float req)
71 {
72         if (req == WR_AIM)
73         {
74                 // ... sorry ...
75         }
76         else if (req == WR_THINK)
77         {
78                 if (self.BUTTON_ATCK || self.BUTTON_HOOK)
79                 {
80                         if(!self.hook)
81                         if not(self.hook_state & HOOK_WAITING_FOR_RELEASE)
82                         if (weapon_prepareattack(0, cvar("g_balance_hook_primary_refire")))
83                         {
84                                 if not(self.items & IT_UNLIMITED_AMMO)
85                                         self.ammo_cells = self.ammo_cells - cvar("g_balance_hook_primary_ammo");
86                                 self.hook_state |= HOOK_FIRING;
87                                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hook_primary_animtime"), w_ready);
88                         }
89                 }
90
91                 if (self.BUTTON_ATCK2)
92                 {
93                         if (weapon_prepareattack(1, cvar("g_balance_hook_secondary_refire")))
94                         {
95                                 W_Hook_Attack2();
96                                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hook_secondary_animtime"), w_ready);
97                         }
98                 }
99
100                 if (self.BUTTON_CROUCH)
101                 {
102                         self.hook_state (-) HOOK_PULLING;
103                         if (self.BUTTON_ATCK || self.BUTTON_HOOK)
104                                 self.hook_state (-) HOOK_RELEASING;
105                         else
106                                 self.hook_state |= HOOK_RELEASING;
107                 }
108                 else
109                 {
110                         self.hook_state |= HOOK_PULLING;
111                         self.hook_state (-) HOOK_RELEASING;
112
113                         if (self.BUTTON_ATCK || self.BUTTON_HOOK)
114                         {
115                                 // already fired
116                                 if(self.hook)
117                                         self.hook_state |= HOOK_WAITING_FOR_RELEASE;
118                         }
119                         else
120                         {
121                                 self.hook_state |= HOOK_REMOVING;
122                                 self.hook_state (-) HOOK_WAITING_FOR_RELEASE;
123                         }
124                 }
125         }
126         else if (req == WR_PRECACHE)
127         {
128                 precache_model ("models/weapons/g_hookgun.md3");
129                 precache_model ("models/weapons/v_hookgun.md3");
130                 precache_model ("models/weapons/w_hookgun.zym");
131                 precache_sound ("weapons/hook_fire.wav");
132                 precache_sound ("weapons/hook_impact.wav");
133                 precache_sound ("weapons/hookbomb_fire.wav");
134                 precache_sound ("weapons/hookbomb_impact.wav");
135         }
136         else if (req == WR_SETUP)
137         {
138                 weapon_setup(WEP_HOOK);
139         }
140         else if (req == WR_CHECKAMMO1)
141         {
142                 return self.ammo_cells >= cvar("g_balance_hook_primary_ammo");
143         }
144         else if (req == WR_CHECKAMMO2)
145         {
146                 return self.ammo_cells >= cvar("g_balance_hook_secondary_ammo");
147         }
148         else if (req == WR_SUICIDEMESSAGE)
149                 w_deathtypestring = "did the impossible";
150         else if (req == WR_KILLMESSAGE)
151                 w_deathtypestring = "has run into #'s gravity bomb";
152         return TRUE;
153 };