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

bool buff_Swapper_cond (entity e)
 MUTATOR_HOOKFUNCTION (buffs, ForbidThrowCurrentWeapon)

Function Documentation

◆ buff_Swapper_cond()

bool buff_Swapper_cond ( entity e)

Definition at line 4 of file swapper.qc.

5{
7 && !IS_DEAD(e) && !STAT(FROZEN, e) && !e.vehicle);
8}
#define IS_DEAD(s)
Definition player.qh:244
#define IS_PLAYER(s)
Definition player.qh:242
#define STAT(...)
Definition stats.qh:94
noref entity WarpZone_SearchInRadius_otherent
Free to use in the callback.
Definition common.qh:71
#define DIFF_TEAM(a, b)
Definition teams.qh:242

References DIFF_TEAM, entity(), IS_DEAD, IS_PLAYER, STAT, and WarpZone_SearchInRadius_otherent.

Referenced by MUTATOR_HOOKFUNCTION().

◆ MUTATOR_HOOKFUNCTION()

MUTATOR_HOOKFUNCTION ( buffs ,
ForbidThrowCurrentWeapon  )

Definition at line 9 of file swapper.qc.

10{
12 return;
13
14 entity player = M_ARGV(0, entity);
15 if (!StatusEffects_active(BUFF_SWAPPER, player))
16 return;
17
20 entity closest = NULL;
21 float head_dist2, closest_dist2 = 0;
22 for (; head; head = head.chain)
23 {
24 head_dist2 = vlen2(head.WarpZone_findradius_dist);
25 if (!closest || head_dist2 < closest_dist2) // new closest
26 {
27 closest_dist2 = head_dist2;
28 closest = head;
29 }
30 }
31 if (closest == NULL)
32 return;
33
34 vector my_org = player.origin;
35 vector my_center = CENTER_OF_ENT(player);
36 vector my_vel = player.velocity;
37 vector my_ang = player.angles;
38 vector their_org = closest.origin;
39 vector their_center = CENTER_OF_ENT(closest);
40 vector their_vel = closest.velocity;
41 vector their_ang = closest.angles;
42
43 Drop_Special_Items(closest);
44
45 MUTATOR_CALLHOOK(PortalTeleport, player); // initiate flag dropper
46
47 setorigin(player, their_org);
48 setorigin(closest, my_org);
49
50 closest.velocity = my_vel;
51 closest.angles = my_ang;
52 if (IS_BOT_CLIENT(closest))
53 {
54 closest.v_angle = closest.angles;
55 bot_aim_reset(closest);
56 }
57 closest.fixangle = true;
58 closest.oldorigin = my_org;
59 closest.oldvelocity = my_vel;
60 player.velocity = their_vel;
61 player.angles = their_ang;
62 if (IS_BOT_CLIENT(player))
63 {
64 player.v_angle = player.angles;
65 bot_aim_reset(player);
66 }
67 player.fixangle = true;
68 player.oldorigin = their_org;
69 player.oldvelocity = their_vel;
70
71 // set pusher so player gets the kill if they fall into void
72 closest.pusher = player;
73 closest.pushltime = time + autocvar_g_maxpushtime;
74 closest.istypefrag = PHYS_INPUT_BUTTON_CHAT(closest);
75
76 Send_Effect(EFFECT_SWAPPER, their_center, '0 0 0', 1);
77 Send_Effect(EFFECT_SWAPPER, my_center, '0 0 0', 1);
78
79 sound(player, CH_TRIGGER, SND_KA_RESPAWN, VOL_BASE, ATTEN_NORM);
80 sound(closest, CH_TRIGGER, SND_KA_RESPAWN, VOL_BASE, ATTEN_NORM);
81
82 // TODO: add a counter to handle how many times one can teleport, and a delay to prevent spam
84 return true;
85}
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 PHYS_INPUT_BUTTON_CHAT(s)
Definition player.qh:161
float game_stopped
Definition stats.qh:81
#define CENTER_OF_ENT(ent)
Definition util.qh:10
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:155
entity WarpZone_SearchInRadius(vector org, float rad, float nomonsters, WarpZone_FindRadius_cond_callback_t cb)
Modified findradius aware of warpzones, that only includes entities that meet the "cb" criteria.
Definition common.qc:680
#define MOVE_NOTHING
Definition common.qh:35
@ 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:96
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:285
bool buff_Swapper_cond(entity e)
Definition swapper.qc:4
float autocvar_g_buffs_swapper_range
Definition swapper.qh:6
#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(), buff_Swapper_cond(), CENTER_OF_ENT, CH_TRIGGER, Drop_Special_Items(), entity(), game_stopped, IS_BOT_CLIENT, M_ARGV, MOVE_NOTHING, MUTATOR_CALLHOOK, MUTATOR_RETURNVALUE, NULL, PHYS_INPUT_BUTTON_CHAT, Send_Effect(), sound, STATUSEFFECT_REMOVE_NORMAL, StatusEffects_active(), time, vector, vlen2, VOL_BASE, WarpZone_SearchInRadius(), and WarpZone_SearchInRadius_otherent.