]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/weapons/weapon/hook.qc
Sneak in another feature (simple option to enable ammo in the grappling hook mutator)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / hook.qc
1 #include "hook.qh"
2 #ifndef IMPLEMENTATION
3 CLASS(Hook, Weapon)
4 /* ammotype  */ ATTRIB(Hook, ammo_field, .int, ammo_fuel);
5 /* impulse   */ ATTRIB(Hook, impulse, int, 0);
6 /* flags     */ ATTRIB(Hook, spawnflags, int, WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH);
7 /* rating    */ ATTRIB(Hook, bot_pickupbasevalue, float, 0);
8 /* color     */ ATTRIB(Hook, wpcolor, vector, '0 0.5 0');
9 /* modelname */ ATTRIB(Hook, mdl, string, "hookgun");
10 #ifdef GAMEQC
11 /* model     */ ATTRIB(Hook, m_model, Model, MDL_HOOK_ITEM);
12 #endif
13 /* crosshair */ ATTRIB(Hook, w_crosshair, string, "gfx/crosshairhook");
14 /* crosshair */ ATTRIB(Hook, w_crosshair_size, float, 0.5);
15 /* wepimg    */ ATTRIB(Hook, model2, string, "weaponhook");
16 /* refname   */ ATTRIB(Hook, netname, string, "hook");
17 /* wepname   */ ATTRIB(Hook, m_name, string, _("Grappling Hook"));
18         ATTRIB(Hook, ammo_factor, float, 1);
19
20 #define X(BEGIN, P, END, class, prefix) \
21         BEGIN(class) \
22                 P(class, prefix, ammo, float, PRI) \
23                 P(class, prefix, animtime, float, BOTH) \
24                 P(class, prefix, damageforcescale, float, SEC) \
25                 P(class, prefix, damage, float, SEC) \
26                 P(class, prefix, duration, float, SEC) \
27                 P(class, prefix, edgedamage, float, SEC) \
28                 P(class, prefix, force, float, SEC) \
29                 P(class, prefix, gravity, float, SEC) \
30                 P(class, prefix, health, float, SEC) \
31                 P(class, prefix, hooked_ammo, float, PRI) \
32                 P(class, prefix, hooked_time_free, float, PRI) \
33                 P(class, prefix, hooked_time_max, float, PRI) \
34                 P(class, prefix, lifetime, float, SEC) \
35                 P(class, prefix, power, float, SEC) \
36                 P(class, prefix, radius, float, SEC) \
37                 P(class, prefix, refire, float, BOTH) \
38                 P(class, prefix, speed, float, SEC) \
39         P(class, prefix, switchdelay_drop, float, NONE) \
40                 P(class, prefix, switchdelay_raise, float, NONE) \
41         P(class, prefix, weaponreplace, string, NONE) \
42         P(class, prefix, weaponstartoverride, float, NONE) \
43         P(class, prefix, weaponstart, float, NONE) \
44         P(class, prefix, weaponthrowable, float, NONE) \
45         END()
46     W_PROPS(X, Hook, hook)
47 #undef X
48
49 ENDCLASS(Hook)
50 REGISTER_WEAPON(HOOK, hook, NEW(Hook));
51
52 CLASS(OffhandHook, OffhandWeapon)
53 #ifdef SVQC
54     METHOD(OffhandHook, offhand_think, void(OffhandHook this, entity actor, bool key_pressed))
55     {
56         Weapon wep = WEP_HOOK;
57         .entity weaponentity = weaponentities[1];
58         wep.wr_think(wep, actor, weaponentity, key_pressed ? 1 : 0);
59     }
60 #endif
61 ENDCLASS(OffhandHook)
62 OffhandHook OFFHAND_HOOK; STATIC_INIT(OFFHAND_HOOK) { OFFHAND_HOOK = NEW(OffhandHook); }
63
64 #ifdef SVQC
65
66 .float dmg;
67 .float dmg_edge;
68 .float dmg_radius;
69 .float dmg_force;
70 .float dmg_power;
71 .float dmg_duration;
72 .float dmg_last;
73 .float hook_refire;
74 .float hook_time_hooked;
75 .float hook_time_fueldecrease;
76 #endif
77 #endif
78 #ifdef IMPLEMENTATION
79 #ifdef SVQC
80
81 spawnfunc(weapon_hook) { weapon_defaultspawnfunc(this, WEP_HOOK); }
82
83 void W_Hook_ExplodeThink(entity this)
84 {
85         float dt, dmg_remaining_next, f;
86
87         dt = time - this.teleport_time;
88         dmg_remaining_next = (bound(0, 1 - dt / this.dmg_duration, 1) ** this.dmg_power);
89
90         f = this.dmg_last - dmg_remaining_next;
91         this.dmg_last = dmg_remaining_next;
92
93         RadiusDamage(this, this.realowner, this.dmg * f, this.dmg_edge * f, this.dmg_radius, this.realowner, NULL, this.dmg_force * f, this.projectiledeathtype, NULL);
94         this.projectiledeathtype |= HITTYPE_BOUNCE;
95         //RadiusDamage(this, NULL, this.dmg * f, this.dmg_edge * f, this.dmg_radius, NULL, NULL, this.dmg_force * f, this.projectiledeathtype, NULL);
96
97         if(dt < this.dmg_duration)
98                 this.nextthink = time + 0.05; // soon
99         else
100                 delete(this);
101 }
102
103 void W_Hook_Explode2(entity this)
104 {
105         this.event_damage = func_null;
106         settouch(this, func_null);
107         this.effects |= EF_NODRAW;
108
109         setthink(this, W_Hook_ExplodeThink);
110         this.nextthink = time;
111         this.dmg = WEP_CVAR_SEC(hook, damage);
112         this.dmg_edge = WEP_CVAR_SEC(hook, edgedamage);
113         this.dmg_radius = WEP_CVAR_SEC(hook, radius);
114         this.dmg_force = WEP_CVAR_SEC(hook, force);
115         this.dmg_power = WEP_CVAR_SEC(hook, power);
116         this.dmg_duration = WEP_CVAR_SEC(hook, duration);
117         this.teleport_time = time;
118         this.dmg_last = 1;
119         set_movetype(this, MOVETYPE_NONE);
120 }
121
122 void W_Hook_Explode2_use(entity this, entity actor, entity trigger)
123 {
124         W_Hook_Explode2(this);
125 }
126
127 void W_Hook_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
128 {
129         if(this.health <= 0)
130                 return;
131
132         if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
133                 return; // g_projectiles_damage says to halt
134
135         this.health = this.health - damage;
136
137         if(this.health <= 0)
138                 W_PrepareExplosionByDamage(this, this.realowner, W_Hook_Explode2);
139 }
140
141 void W_Hook_Touch2(entity this, entity toucher)
142 {
143         PROJECTILE_TOUCH(this, toucher);
144         this.use(this, NULL, NULL);
145 }
146
147 void W_Hook_Attack2(Weapon thiswep, entity actor, .entity weaponentity)
148 {
149         //W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(hook, ammo)); // WEAPONTODO: Figure out how to handle ammo with hook secondary (gravitybomb)
150         W_SetupShot(actor, weaponentity, false, 4, SND_HOOKBOMB_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hook, damage));
151
152         entity gren = new(hookbomb);
153         gren.owner = gren.realowner = actor;
154         gren.bot_dodge = true;
155         gren.bot_dodgerating = WEP_CVAR_SEC(hook, damage);
156         set_movetype(gren, MOVETYPE_TOSS);
157         PROJECTILE_MAKETRIGGER(gren);
158         gren.projectiledeathtype = WEP_HOOK.m_id | HITTYPE_SECONDARY;
159         setorigin(gren, w_shotorg);
160         setsize(gren, '0 0 0', '0 0 0');
161
162         gren.nextthink = time + WEP_CVAR_SEC(hook, lifetime);
163         setthink(gren, adaptor_think2use_hittype_splash);
164         gren.use = W_Hook_Explode2_use;
165         settouch(gren, W_Hook_Touch2);
166
167         gren.takedamage = DAMAGE_YES;
168         gren.health = WEP_CVAR_SEC(hook, health);
169         gren.damageforcescale = WEP_CVAR_SEC(hook, damageforcescale);
170         gren.event_damage = W_Hook_Damage;
171         gren.damagedbycontents = true;
172         IL_PUSH(g_damagedbycontents, gren);
173         gren.missile_flags = MIF_SPLASH | MIF_ARC;
174
175         gren.velocity = '0 0 1' * WEP_CVAR_SEC(hook, speed);
176         if (autocvar_g_projectiles_newton_style)
177                 gren.velocity = gren.velocity + actor.velocity;
178
179         gren.gravity = WEP_CVAR_SEC(hook, gravity);
180         //W_SetupProjVelocity_Basic(gren); // just falling down!
181
182         gren.angles = '0 0 0';
183         gren.flags = FL_PROJECTILE;
184         IL_PUSH(g_projectiles, gren);
185         IL_PUSH(g_bot_dodge, gren);
186
187         CSQCProjectile(gren, true, PROJECTILE_HOOKBOMB, true);
188
189         MUTATOR_CALLHOOK(EditProjectile, actor, gren);
190 }
191
192 METHOD(Hook, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
193 {
194     if (fire & 1) {
195         if(!actor.(weaponentity).hook)
196         if(!(actor.(weaponentity).hook_state & HOOK_WAITING_FOR_RELEASE))
197         if(time > actor.(weaponentity).hook_refire)
198         if(weapon_prepareattack(thiswep, actor, weaponentity, false, -1))
199         {
200             W_DecreaseAmmo(thiswep, actor, thiswep.ammo_factor * WEP_CVAR_PRI(hook, ammo), weaponentity);
201             actor.(weaponentity).hook_state |= HOOK_FIRING;
202             actor.(weaponentity).hook_state |= HOOK_WAITING_FOR_RELEASE;
203             weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hook, animtime), w_ready);
204         }
205     } else {
206         actor.(weaponentity).hook_state |= HOOK_REMOVING;
207         actor.(weaponentity).hook_state &= ~HOOK_WAITING_FOR_RELEASE;
208     }
209
210     if(fire & 2)
211     {
212         if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(hook, refire)))
213         {
214             W_Hook_Attack2(thiswep, actor, weaponentity);
215             weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hook, animtime), w_ready);
216         }
217     }
218
219     if(actor.(weaponentity).hook)
220     {
221         // if hooked, no bombs, and increase the timer
222         actor.(weaponentity).hook_refire = max(actor.(weaponentity).hook_refire, time + WEP_CVAR_PRI(hook, refire) * W_WeaponRateFactor(actor));
223
224         // hook also inhibits health regeneration, but only for 1 second
225         if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
226             actor.pauseregen_finished = max(actor.pauseregen_finished, time + autocvar_g_balance_pause_fuel_regen);
227     }
228
229     if(actor.(weaponentity).hook && actor.(weaponentity).hook.state == 1)
230     {
231         float hooked_time_max = WEP_CVAR_PRI(hook, hooked_time_max);
232         if(hooked_time_max > 0)
233         {
234             if( time > actor.(weaponentity).hook_time_hooked + hooked_time_max )
235                 actor.(weaponentity).hook_state |= HOOK_REMOVING;
236         }
237
238         float hooked_fuel = thiswep.ammo_factor * WEP_CVAR_PRI(hook, hooked_ammo);
239         if(hooked_fuel > 0)
240         {
241             if( time > actor.(weaponentity).hook_time_fueldecrease )
242             {
243                 if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
244                 {
245                     if( actor.ammo_fuel >= (time - actor.(weaponentity).hook_time_fueldecrease) * hooked_fuel )
246                     {
247                         W_DecreaseAmmo(thiswep, actor, (time - actor.(weaponentity).hook_time_fueldecrease) * hooked_fuel, weaponentity);
248                         actor.(weaponentity).hook_time_fueldecrease = time;
249                         // decrease next frame again
250                     }
251                     else
252                     {
253                         actor.ammo_fuel = 0;
254                         actor.(weaponentity).hook_state |= HOOK_REMOVING;
255                         if(actor.(weaponentity).m_weapon != WEP_Null) // offhand
256                                 W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
257                     }
258                 }
259             }
260         }
261     }
262     else
263     {
264         actor.(weaponentity).hook_time_hooked = time;
265         actor.(weaponentity).hook_time_fueldecrease = time + WEP_CVAR_PRI(hook, hooked_time_free);
266     }
267
268     actor.(weaponentity).hook_state = BITSET(actor.(weaponentity).hook_state, HOOK_PULLING, (!PHYS_INPUT_BUTTON_CROUCH(actor) || !autocvar_g_balance_grapplehook_crouchslide));
269
270     if (actor.(weaponentity).hook_state & HOOK_FIRING)
271     {
272         if (actor.(weaponentity).hook)
273             RemoveHook(actor.(weaponentity).hook);
274         FireGrapplingHook(actor, weaponentity);
275         actor.(weaponentity).hook_state &= ~HOOK_FIRING;
276         actor.(weaponentity).hook_refire = max(actor.(weaponentity).hook_refire, time + autocvar_g_balance_grapplehook_refire * W_WeaponRateFactor(actor));
277     }
278     else if (actor.(weaponentity).hook_state & HOOK_REMOVING)
279     {
280         if (actor.(weaponentity).hook)
281             RemoveHook(actor.(weaponentity).hook);
282         actor.(weaponentity).hook_state &= ~HOOK_REMOVING;
283     }
284 }
285 METHOD(Hook, wr_setup, void(entity thiswep, entity actor, .entity weaponentity))
286 {
287         actor.(weaponentity).hook_state &= ~HOOK_WAITING_FOR_RELEASE;
288 }
289 METHOD(Hook, wr_checkammo1, bool(Hook thiswep, entity actor, .entity weaponentity))
290 {
291     if (!thiswep.ammo_factor) return true;
292
293     if(actor.(weaponentity).hook)
294         return actor.ammo_fuel > 0;
295
296     return actor.ammo_fuel >= WEP_CVAR_PRI(hook, ammo);
297 }
298 METHOD(Hook, wr_checkammo2, bool(Hook thiswep, entity actor, .entity weaponentity))
299 {
300     // infinite ammo for now
301     return true; // actor.ammo_cells >= WEP_CVAR_SEC(hook, ammo); // WEAPONTODO: see above
302 }
303 METHOD(Hook, wr_resetplayer, void(entity thiswep, entity actor))
304 {
305     RemoveGrapplingHooks(actor);
306     for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
307     {
308         .entity weaponentity = weaponentities[slot];
309         actor.(weaponentity).hook_time = 0;
310         actor.(weaponentity).hook_refire = time;
311     }
312 }
313 METHOD(Hook, wr_killmessage, Notification(entity thiswep))
314 {
315     return WEAPON_HOOK_MURDER;
316 }
317
318 #endif
319 #ifdef CSQC
320
321 METHOD(Hook, wr_impacteffect, void(entity thiswep, entity actor))
322 {
323     vector org2;
324     org2 = w_org + w_backoff * 2;
325     pointparticles(EFFECT_HOOK_EXPLODE, org2, '0 0 0', 1);
326     if(!w_issilent)
327         sound(actor, CH_SHOTS, SND_HOOKBOMB_IMPACT, VOL_BASE, ATTN_NORM);
328 }
329
330 #endif
331
332 #ifdef CSQC
333 #include <lib/csqcmodel/interpolate.qh>
334 #include <lib/warpzone/common.qh>
335
336 float autocvar_cl_grapplehook_alpha = 1;
337
338 void Draw_CylindricLine(vector from, vector to, float thickness, string texture, float aspect, float shift, vector rgb, float theAlpha, float drawflag, vector vieworg);
339
340 entityclass(Hook);
341 class(Hook) .entity HookType; // ENT_CLIENT_*
342 class(Hook) .vector origin;
343 class(Hook) .vector velocity;
344 class(Hook) .float HookSilent;
345 class(Hook) .float HookRange;
346
347 string Draw_GrapplingHook_trace_callback_tex;
348 float Draw_GrapplingHook_trace_callback_rnd;
349 vector Draw_GrapplingHook_trace_callback_rgb;
350 float Draw_GrapplingHook_trace_callback_a;
351 void Draw_GrapplingHook_trace_callback(vector start, vector hit, vector end)
352 {
353         float i;
354         vector vorg;
355         vorg = WarpZone_TransformOrigin(WarpZone_trace_transform, view_origin);
356         for(i = 0; i < Draw_GrapplingHook_trace_callback_a; ++i)
357                 Draw_CylindricLine(hit, start, 8, Draw_GrapplingHook_trace_callback_tex, 0.25, Draw_GrapplingHook_trace_callback_rnd, Draw_GrapplingHook_trace_callback_rgb, min(1, Draw_GrapplingHook_trace_callback_a - i), DRAWFLAG_NORMAL, vorg);
358         Draw_GrapplingHook_trace_callback_rnd += 0.25 * vlen(hit - start) / 8;
359 }
360
361 class(Hook) .float teleport_time;
362 void Draw_GrapplingHook(entity this)
363 {
364         vector a, b, atrans;
365         string tex;
366         vector rgb;
367         float t;
368         vector vs;
369         float intensity, offset;
370
371         if(this.teleport_time)
372         if(time > this.teleport_time)
373         {
374                 sound (this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM); // safeguard
375                 this.teleport_time = 0;
376         }
377
378         InterpolateOrigin_Do(this);
379
380         int s = W_GunAlign(viewmodels[this.cnt], STAT(GUNALIGN)) - 1;
381
382         switch(this.HookType)
383         {
384                 default:
385                 case NET_ENT_CLIENT_HOOK:
386                         vs = hook_shotorigin[s];
387                         break;
388                 case NET_ENT_CLIENT_ARC_BEAM:
389                         vs = lightning_shotorigin[s];
390                         break;
391         }
392
393         if((this.owner.sv_entnum == player_localentnum - 1))
394         {
395                 switch(this.HookType)
396                 {
397                         default:
398                         case NET_ENT_CLIENT_HOOK:
399                                 if(autocvar_chase_active > 0)
400                                         a = csqcplayer.origin;
401                                 else
402                                         a = view_origin + view_forward * vs.x + view_right * -vs.y + view_up * vs.z;
403                                 b = this.origin;
404                                 break;
405                         case NET_ENT_CLIENT_ARC_BEAM:
406                                 if(this.HookRange)
407                                         b = view_origin + view_forward * this.HookRange;
408                                 else
409                                         b = view_origin + view_forward * vlen(this.velocity - this.origin); // honor original length of beam!
410                                 WarpZone_TraceLine(view_origin, b, MOVE_NORMAL, NULL);
411                                 b = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
412                                 a = view_origin + view_forward * vs.x + view_right * -vs.y + view_up * vs.z;
413                                 break;
414                 }
415         }
416         else
417         {
418                 switch(this.HookType)
419                 {
420                         default:
421                         case NET_ENT_CLIENT_HOOK:
422                                 a = this.velocity;
423                                 b = this.origin;
424                                 break;
425                         case NET_ENT_CLIENT_ARC_BEAM:
426                                 a = this.origin;
427                                 b = this.velocity;
428                                 break;
429                 }
430         }
431
432         t = entcs_GetTeamColor(this.owner.sv_entnum);
433
434         switch(this.HookType)
435         {
436                 default:
437                 case NET_ENT_CLIENT_HOOK:
438                         intensity = autocvar_cl_grapplehook_alpha;
439                         offset = 0;
440                         switch(t)
441                         {
442                                 case NUM_TEAM_1: tex = "particles/hook_red"; rgb = '1 0.3 0.3'; break;
443                                 case NUM_TEAM_2: tex = "particles/hook_blue"; rgb = '0.3 0.3 1'; break;
444                                 case NUM_TEAM_3: tex = "particles/hook_yellow"; rgb = '1 1 0.3'; break;
445                                 case NUM_TEAM_4: tex = "particles/hook_pink"; rgb = '1 0.3 1'; break;
446                                 default: tex = "particles/hook_white"; rgb = entcs_GetColor(this.sv_entnum - 1); break;
447                         }
448                         break;
449                 case NET_ENT_CLIENT_ARC_BEAM: // todo
450                         intensity = bound(0.2, 1 + Noise_Pink(this, frametime) * 1 + Noise_Burst(this, frametime, 0.03) * 0.3, 2);
451                         offset = Noise_Brown(this, frametime) * 10;
452                         tex = "particles/lgbeam";
453                         rgb = '1 1 1';
454                         break;
455         }
456
457         MUTATOR_CALLHOOK(DrawGrapplingHook, this, tex, rgb, t);
458         tex = M_ARGV(1, string);
459         rgb = M_ARGV(2, vector);
460
461         Draw_GrapplingHook_trace_callback_tex = tex;
462         Draw_GrapplingHook_trace_callback_rnd = offset;
463         Draw_GrapplingHook_trace_callback_rgb = rgb;
464         Draw_GrapplingHook_trace_callback_a = intensity;
465         WarpZone_TraceBox_ThroughZone(a, '0 0 0', '0 0 0', b, ((this.HookType == NET_ENT_CLIENT_HOOK) ? MOVE_NOTHING : MOVE_NORMAL), NULL, NULL, Draw_GrapplingHook_trace_callback);
466         Draw_GrapplingHook_trace_callback_tex = string_null;
467
468         atrans = WarpZone_TransformOrigin(WarpZone_trace_transform, a);
469
470         switch(this.HookType)
471         {
472                 default:
473                 case NET_ENT_CLIENT_HOOK:
474                         if(vdist(trace_endpos - atrans, >, 0.5))
475                         {
476                                 setorigin(this, trace_endpos); // hook endpoint!
477                                 this.angles = vectoangles(trace_endpos - atrans);
478                                 this.drawmask = MASK_NORMAL;
479                         }
480                         else
481                         {
482                                 this.drawmask = 0;
483                         }
484                         break;
485                 case NET_ENT_CLIENT_ARC_BEAM:
486                         setorigin(this, a); // beam origin!
487                         break;
488         }
489
490         switch(this.HookType)
491         {
492                 default:
493                 case NET_ENT_CLIENT_HOOK:
494                         break;
495                 case NET_ENT_CLIENT_ARC_BEAM:
496                         pointparticles(EFFECT_ARC_LIGHTNING2, trace_endpos, normalize(atrans - trace_endpos), frametime * intensity); // todo: new effect
497                         break;
498         }
499 }
500
501 void Remove_GrapplingHook(entity this)
502 {
503         sound (this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
504
505         for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
506         {
507                 entity wep = viewmodels[slot];
508                 if(wep.hook == this)
509                         wep.hook = NULL;
510         }
511 }
512
513 NET_HANDLE(ENT_CLIENT_HOOK, bool bIsNew)
514 {
515         this.HookType = NET_ENT_CLIENT_HOOK;
516
517         int sf = ReadByte();
518
519         this.HookSilent = (sf & 0x80);
520         this.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
521
522         InterpolateOrigin_Undo(this);
523
524         if(sf & 1)
525         {
526                 int myowner = ReadByte();
527                 int slot = ReadByte();
528                 this.owner = playerslots[myowner - 1];
529                 this.sv_entnum = myowner;
530                 if(myowner == player_localentnum)
531                         viewmodels[slot].hook = this;
532                 this.cnt = slot;
533                 switch(this.HookType)
534                 {
535                         default:
536                         case NET_ENT_CLIENT_HOOK:
537                                 this.HookRange = 0;
538                                 break;
539                         case NET_ENT_CLIENT_ARC_BEAM:
540                                 this.HookRange = ReadCoord();
541                                 break;
542                 }
543         }
544         if(sf & 2)
545         {
546                 this.origin_x = ReadCoord();
547                 this.origin_y = ReadCoord();
548                 this.origin_z = ReadCoord();
549                 setorigin(this, this.origin);
550         }
551         if(sf & 4)
552         {
553                 this.velocity_x = ReadCoord();
554                 this.velocity_y = ReadCoord();
555                 this.velocity_z = ReadCoord();
556         }
557
558         InterpolateOrigin_Note(this);
559
560         if(bIsNew || !this.teleport_time)
561         {
562                 this.draw = Draw_GrapplingHook;
563                 IL_PUSH(g_drawables, this);
564                 this.entremove = Remove_GrapplingHook;
565
566                 switch(this.HookType)
567                 {
568                         default:
569                         case NET_ENT_CLIENT_HOOK:
570                                 // for the model
571                                 setmodel(this, MDL_HOOK);
572                                 this.drawmask = MASK_NORMAL;
573                                 break;
574                         case NET_ENT_CLIENT_ARC_BEAM:
575                                 sound (this, CH_SHOTS_SINGLE, SND_LGBEAM_FLY, VOL_BASE, ATTEN_NORM);
576                                 break;
577                 }
578         }
579
580         this.teleport_time = time + 10;
581         return true;
582 }
583
584 // TODO: hook: temporarily transform this.origin for drawing the model along warpzones!
585 #endif
586
587 #endif