1 void CopyBody(float keepvelocity);
5 float CheatImpulse(float i) { return 0; }
6 float CheatCommand(float argc) { return 0; }
7 float CheatFrame() { return 0; }
8 void CheatInit() { cheatcount_total = world.cheatcount; }
9 void CheatShutdown() { }
10 void CheatInitClient() { }
11 void CheatShutdownClient() { }
12 void Drag_MoveDrag(entity from, entity to) { }
18 float autocvar_sv_cheats;
20 #define CHIMPULSE_SPEEDRUN_INIT 30
21 #define CHIMPULSE_GIVE_ALL 99
22 #define CHIMPULSE_CLONE_MOVING 140
23 #define CHIMPULSE_SPEEDRUN 141
24 #define CHIMPULSE_CLONE_STANDING 142
25 #define CHIMPULSE_TELEPORT 143
26 #define CHIMPULSE_R00T 148
32 sv_cheats = cvar("sv_cheats");
39 void CheatInitClient()
43 void CheatShutdownClient()
47 float CheatsAllowed(float i, float argc, float fr) // the cheat gets passed as argument for possible future ACL checking
49 // dead people cannot cheat
50 if(self.deadflag != DEAD_NO)
52 if(self.classname != "player")
56 if(i == CHIMPULSE_CLONE_MOVING || i == CHIMPULSE_CLONE_STANDING)
57 if(self.lip < sv_clones)
65 if(sv_cheats && autocvar_sv_cheats)
68 // if we get here, player is not allowed to cheat. Log it.
70 bprint(sprintf("Player %s^7 tried to use cheat 'impulse %d'\n", self.netname, i));
72 bprint(sprintf("Player %s^7 tried to use cheat '%s'\n", self.netname, argv(0)));
74 bprint(sprintf("Player %s^7 tried to use cheat frame %d\n", self.netname, fr));
76 bprint(sprintf("Player %s^7 tried to use an unknown cheat\n", self.netname));
81 #define BEGIN_CHEAT_FUNCTION() \
82 float cheating, attempting; \
83 cheating = 0; attempting = 0
86 #define ADD_CHEATS(e,n) \
87 cheatcount_total += n; \
89 #define END_CHEAT_FUNCTION() \
90 ADD_CHEATS(self,cheating); \
92 #define IS_CHEAT(i,argc,fr) \
94 if(!CheatsAllowed(i,argc,fr)) \
97 float CheatImpulse(float i)
99 BEGIN_CHEAT_FUNCTION();
105 case CHIMPULSE_SPEEDRUN_INIT: // deploy personal waypoint
106 // shared with regular waypoint init, so this is not a cheat by itself
109 self.personal = spawn();
110 self.personal.classname = "personal_wp";
112 self.personal.origin = self.origin;
113 self.personal.v_angle = self.v_angle;
114 self.personal.velocity = self.velocity;
115 self.personal.ammo_fuel = self.ammo_fuel;
116 self.personal.health = self.health;
117 self.personal.armorvalue = self.armorvalue;
118 self.personal.weapons = self.weapons;
119 self.personal.items = self.items;
120 self.personal.pauserotarmor_finished = self.pauserotarmor_finished;
121 self.personal.pauserothealth_finished = self.pauserothealth_finished;
122 self.personal.pauserotfuel_finished = self.pauserotfuel_finished;
123 self.personal.pauseregenhealth_finished = self.pauseregenhealth_finished;
124 self.personal.pauseregenarmor_finished = self.pauseregenarmor_finished;
125 self.personal.strength_finished = self.strength_finished;
126 self.personal.invincible_finished = self.invincible_finished;
127 self.personal.teleport_time = time;
128 break; // this part itself doesn't cheat, so let's not count this
129 case CHIMPULSE_CLONE_MOVING:
131 makevectors (self.v_angle);
132 self.velocity = self.velocity + v_forward * 300;
135 self.velocity = self.velocity - v_forward * 300;
138 case CHIMPULSE_CLONE_STANDING:
144 case CHIMPULSE_GIVE_ALL:
146 CheatCommand(tokenize_console("give all"));
147 break; // already counted as cheat
148 case CHIMPULSE_SPEEDRUN:
152 self.speedrunning = TRUE;
153 tracebox(self.personal.origin, self.mins, self.maxs, self.personal.origin, MOVE_WORLDONLY, self);
156 sprint(self, "Cannot move there, cheater - only waypoints set using g_waypointsprite_personal work\n");
160 // Abort speedrun, teleport back
161 setorigin(self, self.personal.origin);
162 self.oldvelocity = self.velocity = self.personal.velocity;
163 self.angles = self.personal.v_angle;
164 self.fixangle = TRUE;
167 bprint("The ", self.flagcarried.netname, " was returned to base by its carrier\n");
168 ReturnFlag(self.flagcarried);
173 self.ammo_fuel = 999;
174 self.health = start_health;
175 self.armorvalue = start_armorvalue;
176 self.weapons |= weaponsInMap;
177 self.pauserotarmor_finished = time + cvar("g_balance_pause_armor_rot_spawn");
178 self.pauserothealth_finished = time + cvar("g_balance_pause_health_rot_spawn");
179 self.pauserotfuel_finished = time + cvar("g_balance_pause_fuel_rot_spawn");
180 self.pauseregenhealth_finished = time + cvar("g_balance_pause_health_regen_spawn");
181 self.pauseregenarmor_finished = time + cvar("g_balance_pause_armor_regen_spawn");
182 self.strength_finished = 0;
183 self.invincible_finished = 0;
187 self.ammo_fuel = self.personal.ammo_fuel;
188 self.health = self.personal.health;
189 self.armorvalue = self.personal.armorvalue;
190 self.weapons = self.personal.weapons;
191 self.items = self.personal.items;
192 self.pauserotarmor_finished = time + self.personal.pauserotarmor_finished - self.personal.teleport_time;
193 self.pauserothealth_finished = time + self.personal.pauserothealth_finished - self.personal.teleport_time;
194 self.pauserotfuel_finished = time + self.personal.pauserotfuel_finished - self.personal.teleport_time;
195 self.pauseregenhealth_finished = time + self.personal.pauseregenhealth_finished - self.personal.teleport_time;
196 self.pauseregenarmor_finished = time + self.personal.pauseregenarmor_finished - self.personal.teleport_time;
197 self.strength_finished = time + self.personal.strength_finished - self.personal.teleport_time;
198 self.invincible_finished = time + self.personal.invincible_finished - self.personal.teleport_time;
203 if(self.deadflag != DEAD_NO)
204 sprint(self, "UR DEAD AHAHAH))\n");
206 sprint(self, "No waypoint set, cheater (use g_waypointsprite_personal to set one)\n");
208 case CHIMPULSE_TELEPORT:
210 if(MoveToRandomMapLocation(self, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, ((sv_cheats >= 2) ? 100000 : 100), 1024, 256))
212 self.angles_x = -self.angles_x;
213 self.fixangle = TRUE;
214 self.velocity = '0 0 0';
218 sprint(self, "Emergency teleport could not find a good location, forget it!\n");
224 if(e.playermodel == "models/player/vixen.iqm")
226 makevectors(e.angles);
227 traceline(e.origin, e.origin + v_right * 256, MOVE_NORMAL, e);
234 org = normalize(org);
235 traceline(e.origin, e.origin + org * 256, MOVE_NORMAL, e); // random direction
238 org = findbetterlocation(trace_endpos, 12);
242 pointparticles(particleeffectnum("rocket_explode"), org, '0 0 0', 1);
243 sound(e2, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
244 RadiusDamage(e2, e, 1000, 0, 128, e, 500, DEATH_CHEAT, world);
247 print("404 Sportsmanship not found.\n");
252 END_CHEAT_FUNCTION();
255 void DragBox_Think();
257 float CheatCommand(float argc)
259 BEGIN_CHEAT_FUNCTION();
269 case "pointparticles":
270 IS_CHEAT(0, argc, 0);
275 // origin (0..1, on crosshair line)
278 effectnum = particleeffectnum(argv(1));
280 crosshair_trace(self);
281 start = (1-f) * self.origin + f * trace_endpos;
284 pointparticles(effectnum, start, end, f);
288 sprint(self, "Usage: sv_cheats 1; restart; cmd pointparticles effectname position(0..1) velocityvector multiplier\n");
290 case "trailparticles":
291 IS_CHEAT(0, argc, 0);
296 effectnum = particleeffectnum(argv(1));
297 W_SetupShot(self, FALSE, FALSE, "",0);
298 traceline(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, MOVE_NORMAL, self);
299 trailparticles(self, effectnum, w_shotorg, trace_endpos);
303 sprint(self, "Usage: sv_cheats 1; restart; cmd trailparticles effectname\n");
306 IS_CHEAT(0, argc, 0);
312 W_SetupShot(self, FALSE, FALSE, "", 0);
313 traceline(w_shotorg, w_shotorg + w_shotdir * 2048, MOVE_NORMAL, self);
314 if((trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT) || trace_fraction == 1)
316 sprint(self, "cannot make stuff there (bad surface)\n");
321 e.model = strzone(argv(1));
322 e.mdl = "rocket_explode";
324 setorigin(e, trace_endpos);
325 e.effects = EF_NOMODELFLAGS;
328 e.angles = fixedvectoangles2(trace_plane_normal, v_forward);
329 e.angles = AnglesTransform_ApplyToAngles(e.angles, '-90 0 0'); // so unrotated models work
333 spawnfunc_func_breakable();
338 tracebox(e.origin, e.mins, e.maxs, e.origin, MOVE_NORMAL, e);
342 sprint(self, "cannot make stuff there (no space)\n");
352 sprint(self, "Usage: sv_cheats 1; restart; cmd make models/... 0/1/2\n");
355 IS_CHEAT(0, argc, 0);
358 race_ImposePenaltyTime(self, stof(argv(1)), argv(2));
362 sprint(self, "Usage: sv_cheats 1; restart; cmd penalty 5.0 AHAHAHAHAHAHAH))\n");
364 case "dragbox_spawn":
365 IS_CHEAT(0, argc, 0);
367 e.classname = "dragbox_box";
368 e.think = DragBox_Think;
370 e.solid = -1; // black
371 setmodel(e, "null"); // network it
373 e.cnt = stof(argv(1));
375 e.cnt = max(0, drag_lastcnt);
378 e.aiment.classname = "dragbox_corner_1";
380 setmodel(e.aiment, "models/marker.md3");
382 setsize(e.aiment, '0 0 0', '0 0 0');
384 setorigin(e.aiment, stov(argv(2)));
387 crosshair_trace(self);
388 setorigin(e.aiment, trace_endpos);
392 e.enemy.classname = "dragbox_corner_2";
394 setmodel(e.enemy, "models/marker.md3");
396 setsize(e.enemy, '0 0 0', '0 0 0');
397 end = normalize(self.origin + self.view_ofs - e.aiment.origin);
398 end_x = (end_x > 0) * 2 - 1;
399 end_y = (end_y > 0) * 2 - 1;
400 end_z = (end_z > 0) * 2 - 1;
402 setorigin(e.enemy, stov(argv(3)));
404 setorigin(e.enemy, e.aiment.origin + 32 * end);
406 e.killindicator = spawn();
407 e.killindicator.classname = "drag_digit";
408 e.killindicator.owner = e;
409 setattachment(e.killindicator, e, "");
410 setorigin(e.killindicator, '0 0 -8');
411 e.killindicator.killindicator = spawn();
412 e.killindicator.killindicator.classname = "drag_digit";
413 e.killindicator.killindicator.owner = e;
414 setattachment(e.killindicator.killindicator, e, "");
415 setorigin(e.killindicator.killindicator, '0 0 8');
418 case "dragpoint_spawn":
419 IS_CHEAT(0, argc, 0);
421 e.classname = "dragpoint";
422 e.think = DragBox_Think;
424 e.solid = 0; // nothing special
425 setmodel(e, "models/marker.md3");
426 setsize(e, PL_MIN, PL_MAX);
429 e.cnt = stof(argv(1));
431 e.cnt = drag_lastcnt;
433 setorigin(e, stov(argv(2)));
436 crosshair_trace(self);
437 setorigin(e, trace_endpos + normalize(self.origin + self.view_ofs - trace_endpos));
438 move_out_of_solid(e);
441 e.killindicator = spawn();
442 e.killindicator.classname = "drag_digit";
443 e.killindicator.owner = e;
444 setattachment(e.killindicator, e, "");
445 setorigin(e.killindicator, '0 0 40');
446 e.killindicator.killindicator = spawn();
447 e.killindicator.killindicator.classname = "drag_digit";
448 e.killindicator.killindicator.owner = e;
449 setattachment(e.killindicator.killindicator, e, "");
450 setorigin(e.killindicator.killindicator, '0 0 56');
454 IS_CHEAT(0, argc, 0);
455 RandomSelection_Init();
456 crosshair_trace(self);
457 for(e = world; (e = find(e, classname, "dragbox_box")); )
458 RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - trace_endpos));
459 for(e = world; (e = find(e, classname, "dragpoint")); )
460 RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - trace_endpos));
461 if(RandomSelection_chosen_ent)
463 remove(RandomSelection_chosen_ent.killindicator.killindicator);
464 remove(RandomSelection_chosen_ent.killindicator);
465 if(RandomSelection_chosen_ent.aiment)
466 remove(RandomSelection_chosen_ent.aiment);
467 if(RandomSelection_chosen_ent.enemy)
468 remove(RandomSelection_chosen_ent.enemy);
469 remove(RandomSelection_chosen_ent);
474 IS_CHEAT(0, argc, 0);
477 RandomSelection_Init();
478 crosshair_trace(self);
479 for(e = world; (e = find(e, classname, "dragbox_box")); )
480 RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - trace_endpos));
481 for(e = world; (e = find(e, classname, "dragpoint")); )
482 RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - trace_endpos));
483 if(RandomSelection_chosen_ent)
485 if(substring(argv(1), 0, 1) == "*")
486 RandomSelection_chosen_ent.cnt = drag_lastcnt = RandomSelection_chosen_ent.cnt + stof(substring(argv(1), 1, -1));
488 RandomSelection_chosen_ent.cnt = drag_lastcnt = stof(argv(1));
493 sprint(self, "Usage: sv_cheats 1; restart; cmd dragbox_setcnt cnt\n");
496 IS_CHEAT(0, argc, 0);
499 f = fopen(argv(1), FILE_WRITE);
500 fputs(f, "cmd drag_clear\n");
501 for(e = world; (e = find(e, classname, "dragbox_box")); )
503 fputs(f, strcat("cmd dragbox_spawn ", ftos(e.cnt), " \"", vtos(e.aiment.origin), "\" \"", vtos(e.enemy.origin), "\"\n"));
505 for(e = world; (e = find(e, classname, "dragpoint")); )
507 fputs(f, strcat("cmd dragpoint_spawn ", ftos(e.cnt), " \"", vtos(e.origin), "\"\n"));
513 sprint(self, "Usage: sv_cheats 1; restart; cmd dragbox_save filename\n");
515 case "drag_saveraceent":
516 IS_CHEAT(0, argc, 0);
519 f = fopen(argv(1), FILE_WRITE);
520 for(e = world; (e = find(e, classname, "dragbox_box")); )
523 fputs(f, "\"classname\" \"trigger_race_checkpoint\"\n");
524 fputs(f, strcat("\"origin\" \"", ftos(e.absmin_x), " ", ftos(e.absmin_y), " ", ftos(e.absmin_z), "\"\n"));
525 fputs(f, strcat("\"maxs\" \"", ftos(e.absmax_x - e.absmin_x), " ", ftos(e.absmax_y - e.absmin_y), " ", ftos(e.absmax_z - e.absmin_z), "\"\n"));
526 fputs(f, strcat("\"cnt\" \"", ftos(e.cnt), "\"\n"));
527 fputs(f, strcat("\"targetname\" \"checkpoint", ftos(e.cnt), "\"\n"));
530 for(e = world; (e = find(e, classname, "dragpoint")); )
534 for(oldself = world; (oldself = find(oldself, classname, "dragbox_box")); )
536 if(e.cnt <= 0 && oldself.cnt == 0 || e.cnt == oldself.cnt)
538 start = start + oldself.origin;
542 start *= 1 / effectnum;
544 fputs(f, "\"classname\" \"info_player_race\"\n");
545 fputs(f, strcat("\"angle\" \"", ftos(vectoyaw(start - e.origin)), "\"\n"));
546 fputs(f, strcat("\"origin\" \"", ftos(e.origin_x), " ", ftos(e.origin_y), " ", ftos(e.origin_z), "\"\n"));
549 fputs(f, "\"target\" \"checkpoint0\"\n");
550 fputs(f, "\"race_place\" \"0\"\n");
554 fputs(f, "\"target\" \"checkpoint0\"\n");
555 fputs(f, "\"race_place\" \"-1\"\n");
559 fputs(f, strcat("\"target\" \"checkpoint", ftos(e.cnt), "\"\n"));
562 // these need race_place
565 for(oldself = world; (oldself = find(oldself, classname, "dragpoint")); )
568 if(vlen(oldself.origin - start) < vlen(e.origin - start))
570 else if(vlen(oldself.origin - start) == vlen(e.origin - start) && num_for_edict(oldself) < num_for_edict(e))
573 fputs(f, strcat("\"race_place\" \"", ftos(effectnum), "\"\n"));
582 sprint(self, "Usage: sv_cheats 1; restart; cmd dragbox_save filename\n");
585 IS_CHEAT(0, argc, 0);
586 for(e = world; (e = find(e, classname, "dragbox_box")); )
588 for(e = world; (e = find(e, classname, "dragbox_corner_1")); )
590 for(e = world; (e = find(e, classname, "dragbox_corner_2")); )
592 for(e = world; (e = find(e, classname, "dragpoint")); )
594 for(e = world; (e = find(e, classname, "drag_digit")); )
599 IS_CHEAT(0, argc, 0);
600 if(argc == 2) if(cvar("g_campaign"))
602 CampaignLevelWarp(stof(argv(1)));
607 IS_CHEAT(0, argc, 0);
608 BITXOR_ASSIGN(self.flags, FL_GODMODE);
609 if(self.flags & FL_GODMODE)
611 sprint(self, "godmode ON\n");
615 sprint(self, "godmode OFF\n");
618 IS_CHEAT(0, argc, 0);
619 BITXOR_ASSIGN(self.flags, FL_NOTARGET);
620 if(self.flags & FL_NOTARGET)
622 sprint(self, "notarget ON\n");
626 sprint(self, "notarget OFF\n");
629 IS_CHEAT(0, argc, 0);
630 if(self.movetype != MOVETYPE_NOCLIP)
632 self.movetype = MOVETYPE_NOCLIP;
633 sprint(self, "noclip ON\n");
638 self.movetype = MOVETYPE_WALK;
639 sprint(self, "noclip OFF\n");
643 IS_CHEAT(0, argc, 0);
644 if(self.movetype != MOVETYPE_FLY)
646 self.movetype = MOVETYPE_FLY;
647 sprint(self, "flmodey ON\n");
652 self.movetype = MOVETYPE_WALK;
653 sprint(self, "flymode OFF\n");
657 IS_CHEAT(0, argc, 0);
658 if(GiveItems(self, 1, argc))
663 END_CHEAT_FUNCTION();
666 void Drag_Begin(entity dragger, entity draggee, vector touchpoint);
667 void Drag_Finish(entity dragger);
668 float Drag_IsDraggable(entity draggee);
669 float Drag_MayChangeAngles(entity draggee);
670 void Drag_MoveForward(entity dragger);
671 void Drag_SetSpeed(entity dragger, float s);
672 void Drag_MoveBackward(entity dragger);
673 void Drag_Update(entity dragger);
674 float Drag_CanDrag(entity dragger);
675 float Drag_IsDragging(entity dragger);
676 void Drag_MoveDrag(entity from, entity to);
681 BEGIN_CHEAT_FUNCTION();
683 if(Drag_IsDragging(self))
687 if(self.impulse == 10 || self.impulse == 15 || self.impulse == 18)
689 Drag_MoveForward(self);
692 else if(self.impulse == 12 || self.impulse == 16 || self.impulse == 19)
694 Drag_MoveBackward(self);
697 else if(self.impulse >= 1 && self.impulse <= 9)
699 Drag_SetSpeed(self, self.impulse - 1);
701 else if(self.impulse == 14)
703 Drag_SetSpeed(self, 9);
716 if(Drag_CanDrag(self))
719 crosshair_trace(self);
721 if(Drag_IsDraggable(trace_ent))
725 IS_CHEAT(0, 0, CHRAME_DRAG);
726 if(trace_ent.draggedby)
727 Drag_Finish(trace_ent.draggedby);
728 if(trace_ent.tag_entity)
729 detach_sameorigin(trace_ent);
730 Drag_Begin(self, trace_ent, trace_endpos);
737 END_CHEAT_FUNCTION();
748 .float dragspeed; // speed of mouse wheel action
749 .float dragdistance; // distance of dragentity's draglocalvector from view_ofs
750 .vector draglocalvector; // local attachment vector of the dragentity
751 .float draglocalangle;
755 void Drag_Begin(entity dragger, entity draggee, vector touchpoint)
759 draggee.dragmovetype = draggee.movetype;
760 draggee.draggravity = draggee.gravity;
761 draggee.movetype = MOVETYPE_WALK;
762 draggee.gravity = 0.00001;
763 draggee.flags &~= FL_ONGROUND;
764 draggee.draggedby = dragger;
766 dragger.dragentity = draggee;
768 dragger.dragdistance = vlen(touchpoint - dragger.origin - dragger.view_ofs);
769 dragger.draglocalangle = draggee.angles_y - dragger.v_angle_y;
770 touchpoint = touchpoint - gettaginfo(draggee, 0);
771 tagscale = pow(vlen(v_forward), -2);
772 dragger.draglocalvector_x = touchpoint * v_forward * tagscale;
773 dragger.draglocalvector_y = touchpoint * v_right * tagscale;
774 dragger.draglocalvector_z = touchpoint * v_up * tagscale;
776 dragger.dragspeed = 64;
779 void Drag_Finish(entity dragger)
782 draggee = dragger.dragentity;
784 dragger.dragentity = world;
785 draggee.draggedby = world;
786 draggee.movetype = draggee.dragmovetype;
787 draggee.gravity = draggee.draggravity;
789 switch(draggee.movetype)
794 case MOVETYPE_FLYMISSILE:
795 case MOVETYPE_BOUNCE:
796 case MOVETYPE_BOUNCEMISSILE:
797 case MOVETYPE_PHYSICS:
800 draggee.velocity = '0 0 0';
804 if((draggee.flags & FL_ITEM) && (vlen(draggee.velocity) < 32))
806 draggee.velocity = '0 0 0';
807 draggee.flags |= FL_ONGROUND; // floating items are FUN
811 float Drag_IsDraggable(entity draggee)
813 // TODO add more checks for bad stuff here
814 if(draggee.classname == "func_bobbing")
816 if(draggee.classname == "door") // FIXME find out why these must be excluded, or work around the problem (trying to drag these causes like 4 fps)
818 if(draggee.classname == "plat")
820 if(draggee.classname == "func_button")
822 if(draggee.model == "")
824 if(draggee.classname == "spectator")
826 if(draggee.classname == "observer")
828 if(draggee.classname == "exteriorweaponentity")
834 float Drag_MayChangeAngles(entity draggee)
836 // TODO add more checks for bad stuff here
837 if(substring(draggee.model, 0, 1) == "*")
842 void Drag_MoveForward(entity dragger)
844 dragger.dragdistance += dragger.dragspeed;
847 void Drag_SetSpeed(entity dragger, float s)
849 dragger.dragspeed = pow(2, s);
852 void Drag_MoveBackward(entity dragger)
854 dragger.dragdistance = max(0, dragger.dragdistance - dragger.dragspeed);
857 void Drag_Update(entity dragger)
859 vector curorigin, neworigin, goodvelocity;
863 draggee = dragger.dragentity;
864 draggee.flags &~= FL_ONGROUND;
866 curorigin = gettaginfo(draggee, 0);
867 curorigin = curorigin + v_forward * dragger.draglocalvector_x + v_right * dragger.draglocalvector_y + v_up * dragger.draglocalvector_z;
868 makevectors(dragger.v_angle);
869 neworigin = dragger.origin + dragger.view_ofs + v_forward * dragger.dragdistance;
870 goodvelocity = (neworigin - curorigin) * (1 / frametime);
872 while(draggee.angles_y - dragger.v_angle_y - dragger.draglocalangle > 180)
873 dragger.draglocalangle += 360;
874 while(draggee.angles_y - dragger.v_angle_y - dragger.draglocalangle <= -180)
875 dragger.draglocalangle -= 360;
877 f = min(frametime * 10, 1);
878 draggee.velocity = draggee.velocity * (1 - f) + goodvelocity * f;
880 if(Drag_MayChangeAngles(draggee))
881 draggee.angles_y = draggee.angles_y * (1 - f) + (dragger.v_angle_y + dragger.draglocalangle) * f;
883 draggee.ltime = max(servertime + serverframetime, draggee.ltime); // fixes func_train breakage
885 te_lightning1(dragger, dragger.origin + dragger.view_ofs, curorigin);
888 float Drag_CanDrag(entity dragger)
890 return (dragger.deadflag == DEAD_NO) || (dragger.classname == "player");
893 float Drag_IsDragging(entity dragger)
895 if(!dragger.dragentity)
897 if(wasfreed(dragger.dragentity) || dragger.dragentity.draggedby != dragger)
899 dragger.dragentity = world;
902 if(!Drag_CanDrag(dragger) || !Drag_IsDraggable(dragger.dragentity))
904 Drag_Finish(dragger);
910 void Drag_MoveDrag(entity from, entity to)
914 to.draggedby = from.draggedby;
915 to.draggedby.dragentity = to;
916 from.draggedby = world;
927 if(self.aiment && self.enemy)
929 self.origin_x = (self.aiment.origin_x + self.enemy.origin_x) * 0.5;
930 self.origin_y = (self.aiment.origin_y + self.enemy.origin_y) * 0.5;
931 self.origin_z = (self.aiment.origin_z + self.enemy.origin_z) * 0.5;
932 self.maxs_x = fabs(self.aiment.origin_x - self.enemy.origin_x) * 0.5;
933 self.maxs_y = fabs(self.aiment.origin_y - self.enemy.origin_y) * 0.5;
934 self.maxs_z = fabs(self.aiment.origin_z - self.enemy.origin_z) * 0.5;
935 self.mins = -1 * self.maxs;
936 setorigin(self, self.origin); setsize(self, self.mins, self.maxs); // link edict
939 if(self.cnt == -1) // actually race_place -1
941 // show "10 10" for qualifying spawns
942 setmodel(self.killindicator, "models/sprites/10.spr32");
943 setmodel(self.killindicator.killindicator, "models/sprites/10.spr32");
945 else if(self.cnt == -2) // actually race_place 0
947 // show "10 0" for loser spawns
948 setmodel(self.killindicator, "models/sprites/10.spr32");
949 setmodel(self.killindicator.killindicator, "models/sprites/0.spr32");
953 setmodel(self.killindicator, strcat("models/sprites/", ftos(mod(self.cnt, 10)), ".spr32"));
954 setmodel(self.killindicator.killindicator, strcat("models/sprites/", ftos(floor(self.cnt / 10)), ".spr32"));
957 self.nextthink = time;