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