Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
swapper.qc File Reference
#include "swapper.qh"
Include dependency graph for swapper.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 MUTATOR_HOOKFUNCTION (buffs, ForbidThrowCurrentWeapon)

Function Documentation

◆ MUTATOR_HOOKFUNCTION()

MUTATOR_HOOKFUNCTION ( buffs ,
ForbidThrowCurrentWeapon  )

Definition at line 4 of file swapper.qc.

5{
7 return;
8
9 entity player = M_ARGV(0, entity);
10 if (StatusEffects_active(BUFF_SWAPPER, player))
11 {
12 entity head = WarpZone_FindRadius(player.origin, autocvar_g_buffs_swapper_range, false);
13 entity closest = NULL;
14 float head_dist2, best_dist2 = autocvar_g_buffs_swapper_range ** 2;
15 for (; head; head = head.chain)
16 if (IS_PLAYER(head) && DIFF_TEAM(head, player))
17 if (!IS_DEAD(head) && !STAT(FROZEN, head) && !head.vehicle)
18 {
19 head_dist2 = vlen2(head.WarpZone_findradius_dist);
20 if (head_dist2 < best_dist2)
21 {
22 best_dist2 = head_dist2;
23 closest = head;
24 }
25 }
26
27 if (closest)
28 {
29 vector my_org = player.origin;
30 vector my_vel = player.velocity;
31 vector my_ang = player.angles;
32 vector their_org = closest.origin;
33 vector their_vel = closest.velocity;
34 vector their_ang = closest.angles;
35
36 Drop_Special_Items(closest);
37
38 MUTATOR_CALLHOOK(PortalTeleport, player); // initiate flag dropper
39
40 setorigin(player, their_org);
41 setorigin(closest, my_org);
42
43 closest.velocity = my_vel;
44 closest.angles = my_ang;
45 if (IS_BOT_CLIENT(closest))
46 {
47 closest.v_angle = closest.angles;
48 bot_aim_reset(closest);
49 }
50 closest.fixangle = true;
51 closest.oldorigin = my_org;
52 closest.oldvelocity = my_vel;
53 player.velocity = their_vel;
54 player.angles = their_ang;
55 if (IS_BOT_CLIENT(player))
56 {
57 player.v_angle = player.angles;
58 bot_aim_reset(player);
59 }
60 player.fixangle = true;
61 player.oldorigin = their_org;
62 player.oldvelocity = their_vel;
63
64 // set pusher so player gets the kill if they fall into void
65 closest.pusher = player;
66 closest.pushltime = time + autocvar_g_maxpushtime;
67 closest.istypefrag = PHYS_INPUT_BUTTON_CHAT(closest);
68
69 Send_Effect(EFFECT_ELECTRO_COMBO, their_org, '0 0 0', 1);
70 Send_Effect(EFFECT_ELECTRO_COMBO, my_org, '0 0 0', 1);
71
72 sound(player, CH_TRIGGER, SND_KA_RESPAWN, VOL_BASE, ATTEN_NORM);
73 sound(closest, CH_TRIGGER, SND_KA_RESPAWN, VOL_BASE, ATTEN_NORM);
74
75 // TODO: add a counter to handle how many times one can teleport, and a delay to prevent spam
77 return true;
78 }
79 }
80}
void bot_aim_reset(entity this)
Definition aim.qc:134
#define MUTATOR_CALLHOOK(id,...)
Definition base.qh:143
#define MUTATOR_RETURNVALUE
Definition base.qh:328
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define M_ARGV(x, type)
Definition events.qh:17
#define IS_DEAD(s)
Definition player.qh:245
#define PHYS_INPUT_BUTTON_CHAT(s)
Definition player.qh:159
#define IS_PLAYER(s)
Definition player.qh:243
float game_stopped
Definition stats.qh:81
float time
float autocvar_g_maxpushtime
Definition damage.qh:17
void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
Definition all.qc:124
#define STAT(...)
Definition stats.qh:82
entity WarpZone_FindRadius(vector org, float rad, bool needlineofsight)
Definition common.qc:686
@ STATUSEFFECT_REMOVE_NORMAL
Effect is being removed by a function, calls regular removal mechanics.
Definition all.qh:28
#define NULL
Definition post.qh:14
vector
Definition self.qh:92
void Drop_Special_Items(entity player)
Definition player.qc:42
const int CH_TRIGGER
Definition sound.qh:12
const float VOL_BASE
Definition sound.qh:36
const float ATTEN_NORM
Definition sound.qh:30
#define sound(e, c, s, v, a)
Definition sound.qh:52
bool StatusEffects_active(StatusEffect this, entity actor)
void buff_RemoveAll(entity actor, int removal_type)
Definition sv_buffs.qc:284
float autocvar_g_buffs_swapper_range
Definition swapper.qh:6
#define DIFF_TEAM(a, b)
Definition teams.qh:242
#define IS_BOT_CLIENT(v)
want: (IS_CLIENT(v) && !IS_REAL_CLIENT(v))
Definition utils.qh:15
#define vlen2(v)
Definition vector.qh:4

References ATTEN_NORM, autocvar_g_buffs_swapper_range, autocvar_g_maxpushtime, bot_aim_reset(), buff_RemoveAll(), CH_TRIGGER, DIFF_TEAM, Drop_Special_Items(), entity(), game_stopped, IS_BOT_CLIENT, IS_DEAD, IS_PLAYER, M_ARGV, MUTATOR_CALLHOOK, MUTATOR_RETURNVALUE, NULL, PHYS_INPUT_BUTTON_CHAT, Send_Effect(), sound, STAT, STATUSEFFECT_REMOVE_NORMAL, StatusEffects_active(), time, vector, vlen2, VOL_BASE, and WarpZone_FindRadius().