]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_hook.qc
friendly fire/team damage/mirror damage change; warnings cleanup
[divverent/nexuiz.git] / data / qcsrc / server / w_hook.qc
1 .float dmg;
2 .float dmg_edge;
3 .float dmg_radius;
4 .float dmg_force;
5 .float dmg_power;
6 .float dmg_duration;
7 .float dmg_last;
8
9 void W_Hook_ExplodeThink (void)
10 {
11         float dt, dmg_remaining_next, f;
12
13         dt = time - self.teleport_time;
14         dmg_remaining_next = pow(bound(0, 1 - dt / self.dmg_duration, 1), self.dmg_power);
15
16         f = self.dmg_last - dmg_remaining_next;
17         self.dmg_last = dmg_remaining_next;
18
19         RadiusDamage (self, self.owner, self.dmg * f, self.dmg_edge * f, self.dmg_radius, self.owner, self.dmg_force * f, self.projectiledeathtype, world);
20         //RadiusDamage (self, world, self.dmg * f, self.dmg_edge * f, self.dmg_radius, world, self.dmg_force * f, self.projectiledeathtype, world);
21
22         if(dt < self.dmg_duration)
23                 self.nextthink = time + 0.05; // soon
24         else
25                 remove(self);
26 }
27
28 void W_Hook_Explode2 (void)
29 {
30         vector org2;
31
32         org2 = findbetterlocation (self.origin, 12);
33         pointparticles(particleeffectnum("hookbomb_explode"), org2, '0 0 0', 1);
34         sound (self, CHAN_PROJECTILE, "weapons/hookbomb_impact.wav", VOL_BASE, ATTN_NORM);
35
36         self.event_damage = SUB_Null;
37         self.touch = SUB_Null;
38
39         self.think = W_Hook_ExplodeThink;
40         self.nextthink = time;
41         self.dmg = cvar("g_balance_hook_secondary_damage");
42         self.dmg_edge = cvar("g_balance_hook_secondary_edgedamage");
43         self.dmg_radius = cvar("g_balance_hook_secondary_radius");
44         self.dmg_force = cvar("g_balance_hook_secondary_force");
45         self.dmg_power = cvar("g_balance_hook_secondary_power");
46         self.dmg_duration = cvar("g_balance_hook_secondary_duration");
47         self.teleport_time = time;
48         self.dmg_last = 1;
49         self.movetype = MOVETYPE_NONE;
50 }
51
52 void W_Hook_Touch2 (void)
53 {
54         PROJECTILE_TOUCH;
55         self.use();
56 }
57
58 void W_Hook_Attack2()
59 {
60         local entity gren;
61
62         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
63                 self.ammo_cells = self.ammo_cells - cvar("g_balance_hook_secondary_ammo");
64         W_SetupShot (self, '25 6 -8', FALSE, 4, "weapons/hookbomb_fire.wav");
65
66         gren = spawn ();
67         gren.owner = self;
68         gren.classname = "hookbomb";
69         gren.bot_dodge = TRUE;
70         gren.bot_dodgerating = cvar("g_balance_hook_secondary_damage");
71         gren.movetype = MOVETYPE_TOSS;
72         gren.solid = SOLID_BBOX;
73         gren.effects = EF_LOWPRECISION;
74         gren.modelflags = MF_TRACER2;
75         gren.projectiledeathtype = WEP_HOOK | HITTYPE_SECONDARY;
76         setmodel(gren, "models/grenademodel.md3"); // precision set above // FIXME replace
77         setsize(gren, '0 0 0', '0 0 0');
78         setorigin(gren, w_shotorg);
79
80         gren.nextthink = time + cvar("g_balance_hook_secondary_lifetime");
81         gren.think = adaptor_think2use;
82         gren.use = W_Hook_Explode2;
83         gren.touch = W_Hook_Touch2;
84
85         gren.velocity = '0 0 1' * cvar("g_balance_hook_secondary_speed");
86         if(cvar("g_projectiles_newton_style"))
87                 gren.velocity = gren.velocity + self.velocity;
88
89         gren.gravity = cvar("g_balance_hook_secondary_gravity");
90         //W_SetupProjectileVelocity(gren); // just falling down!
91
92         gren.angles = '0 0 0';
93         gren.flags = FL_PROJECTILE;
94 }
95
96 void spawnfunc_weapon_hook (void)
97 {
98         if(g_grappling_hook) // offhand hook
99         {
100                 startitem_failed = TRUE;
101                 remove(self);
102                 return;
103         }
104         weapon_defaultspawnfunc(WEP_HOOK);
105 }
106
107 float w_hook(float req)
108 {
109         if (req == WR_AIM)
110         {
111                 // ... sorry ...
112         }
113         else if (req == WR_THINK)
114         {
115                 if (self.BUTTON_ATCK || self.BUTTON_HOOK)
116                 {
117                         if(!self.hook)
118                         if not(self.hook_state & HOOK_WAITING_FOR_RELEASE)
119                         if (weapon_prepareattack(0, cvar("g_balance_hook_primary_refire")))
120                         {
121                                 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
122                                         self.ammo_cells = self.ammo_cells - cvar("g_balance_hook_primary_ammo");
123                                 self.hook_state |= HOOK_FIRING;
124                                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hook_primary_animtime"), w_ready);
125                         }
126                 }
127
128                 if (self.BUTTON_ATCK2)
129                 {
130                         if (weapon_prepareattack(1, cvar("g_balance_hook_secondary_refire")))
131                         {
132                                 W_Hook_Attack2();
133                                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hook_secondary_animtime"), w_ready);
134                         }
135                 }
136
137                 if (self.BUTTON_CROUCH)
138                 {
139                         self.hook_state &~= HOOK_PULLING;
140                         if (self.BUTTON_ATCK || self.BUTTON_HOOK)
141                                 self.hook_state &~= HOOK_RELEASING;
142                         else
143                                 self.hook_state |= HOOK_RELEASING;
144                 }
145                 else
146                 {
147                         self.hook_state |= HOOK_PULLING;
148                         self.hook_state &~= HOOK_RELEASING;
149
150                         if (self.BUTTON_ATCK || self.BUTTON_HOOK)
151                         {
152                                 // already fired
153                                 if(self.hook)
154                                         self.hook_state |= HOOK_WAITING_FOR_RELEASE;
155                         }
156                         else
157                         {
158                                 self.hook_state |= HOOK_REMOVING;
159                                 self.hook_state &~= HOOK_WAITING_FOR_RELEASE;
160                         }
161                 }
162         }
163         else if (req == WR_PRECACHE)
164         {
165                 precache_model ("models/weapons/g_hookgun.md3");
166                 precache_model ("models/weapons/v_hookgun.md3");
167                 precache_model ("models/weapons/w_hookgun.zym");
168                 precache_sound ("weapons/hook_fire.wav");
169                 precache_sound ("weapons/hook_impact.wav");
170                 precache_sound ("weapons/hookbomb_fire.wav");
171                 precache_sound ("weapons/hookbomb_impact.wav");
172         }
173         else if (req == WR_SETUP)
174         {
175                 weapon_setup(WEP_HOOK);
176         }
177         else if (req == WR_CHECKAMMO1)
178         {
179                 return self.ammo_cells >= cvar("g_balance_hook_primary_ammo");
180         }
181         else if (req == WR_CHECKAMMO2)
182         {
183                 return self.ammo_cells >= cvar("g_balance_hook_secondary_ammo");
184         }
185         else if (req == WR_SUICIDEMESSAGE)
186                 w_deathtypestring = "did the impossible";
187         else if (req == WR_KILLMESSAGE)
188                 w_deathtypestring = "has run into #'s gravity bomb";
189         return TRUE;
190 };