CA: fix name tags getting displayed above eliminated players (when they are spectating or observing)
It fixes #1813
See merge request !388
seta g_waypointsprite_tactical 1 "tactical overlay on turrets when in a vehicle"
seta cl_damagetext "1" "Draw damage dealt where you hit the enemy"
-seta cl_damagetext_format "-{total}" "How to format the damage text. {health}, {armor}, {total}"
+seta cl_damagetext_format "-{total}" "How to format the damage text. {health}, {armor}, {total}, {potential}, {potential_health}"
seta cl_damagetext_color "1 1 0" "Damage text color"
seta cl_damagetext_color_per_weapon "0" "Damage text uses weapon color"
seta cl_damagetext_size "8" "Damage text font size"
set g_spawn_near_teammate 0 "if set, players prefer spawns near a team mate"
set g_spawn_near_teammate_distance 640 "max distance to consider a spawn to be near a team mate"
set g_spawn_near_teammate_ignore_spawnpoint 0 "ignore spawnpoints and spawn right at team mates, if 2, clients can ignore this option"
+set g_spawn_near_teammate_ignore_spawnpoint_max 10 "if set, test at most this many of the available teammates"
set g_spawn_near_teammate_ignore_spawnpoint_delay 2.5 "how long to wait before its OK to spawn at a player after someone just spawned at this player"
-set g_spawn_near_teammate_ignore_spawnpoint_delay_death 0 "how long to wait before its OK to spawn at a player after death"
+set g_spawn_near_teammate_ignore_spawnpoint_delay_death 3 "how long to wait before its OK to spawn at a player after death"
set g_spawn_near_teammate_ignore_spawnpoint_check_health 1 "only allow spawn at this player if their health is full"
set g_spawn_near_teammate_ignore_spawnpoint_closetodeath 1 "spawn as close to death location as possible"
set g_walljump_delay 1 "Minimum delay between wall jumps"
set g_walljump_force 300 "How far to bounce/jump off the wall"
set g_walljump_velocity_xy_factor 1.15 "How much to slow down along horizontal axis, higher value = higher deceleration, if factor is < 1, you accelerate by wall jumping"
-set g_walljump_velocity_z_factor 0.5 "Upwards velocity factor, multiplied by normal jump velocity"
\ No newline at end of file
+set g_walljump_velocity_z_factor 0.5 "Upwards velocity factor, multiplied by normal jump velocity"
int weapon_stats = weapon_accuracy[i - WEP_FIRST];
WepSet set = it.m_wepset;
- if (weapon_stats < 0)
+ if (weapon_stats < 0 && !((weapons_stat & set) || (weapons_inmap & set)))
{
- if (!(weapons_stat & set) && (it.spawnflags & WEP_FLAG_HIDDEN || it.spawnflags & WEP_FLAG_MUTATORBLOCKED))
- nHidden += 1;
- else if (!(weapons_stat & set || weapons_inmap & set))
+ if (((it.spawnflags & WEP_FLAG_HIDDEN) || (it.spawnflags & WEP_FLAG_MUTATORBLOCKED)))
+ ++nHidden;
+ else
++disownedcnt;
}
});
int weapon_stats = weapon_accuracy[i - WEP_FIRST];
WepSet set = it.m_wepset;
- if (weapon_stats < 0 && !(weapons_stat & set || weapons_inmap & set))
+ if (weapon_stats < 0 && !((weapons_stat & set) || (weapons_inmap & set)))
continue;
float weapon_alpha;
#if defined(CSQC) || defined(MENUQC)
// no translatable cvar description please
AUTOCVAR_SAVE(cl_damagetext, bool, true, "Draw damage dealt where you hit the enemy");
-AUTOCVAR_SAVE(cl_damagetext_format, string, "-{total}", "How to format the damage text. {health}, {armor}, {total}");
+AUTOCVAR_SAVE(cl_damagetext_format, string, "-{total}", "How to format the damage text. {health}, {armor}, {total}, {potential}, {potential_health}");
STATIC_INIT(DamageText_LegacyFormat) {
if (strstrofs(autocvar_cl_damagetext_format, "{", 0) < 0) autocvar_cl_damagetext_format = "-{total}";
}
ATTRIB(DamageText, m_friendlyfire, bool, false);
ATTRIB(DamageText, m_damage, int, 0);
ATTRIB(DamageText, m_armordamage, int, 0);
+ ATTRIB(DamageText, m_potential_damage, int, 0);
ATTRIB(DamageText, m_deathtype, int, 0);
ATTRIB(DamageText, time_prev, float, time);
s = strreplace("{health}", sprintf("%d", rint(this.m_damage / DAMAGETEXT_PRECISION_MULTIPLIER)), s);
s = strreplace("{armor}", sprintf("%d", rint(this.m_armordamage / DAMAGETEXT_PRECISION_MULTIPLIER)), s);
s = strreplace("{total}", sprintf("%d", rint((this.m_damage + this.m_armordamage) / DAMAGETEXT_PRECISION_MULTIPLIER)), s);
+ s = strreplace("{potential}", sprintf("%d", rint(this.m_potential_damage/DAMAGETEXT_PRECISION_MULTIPLIER)), s);
+ s = strreplace("{potential_health}", sprintf("%d", rint((this.m_potential_damage - this.m_armordamage)/DAMAGETEXT_PRECISION_MULTIPLIER)), s);
drawcolorcodedstring2_builtin(pos, s, this.m_size * '1 1 0', rgb, this.alpha, DRAWFLAG_NORMAL);
}
}
ATTRIB(DamageText, draw2d, void(DamageText), DamageText_draw2d);
- void DamageText_update(DamageText this, vector _origin, int _health, int _armor, int _deathtype) {
+ void DamageText_update(DamageText this, vector _origin, int _health, int _armor, int _potential_damage, int _deathtype) {
this.m_damage = _health;
this.m_armordamage = _armor;
+ this.m_potential_damage = _potential_damage;
this.m_deathtype = _deathtype;
setorigin(this, _origin);
this.alpha = autocvar_cl_damagetext_alpha_start;
}
- CONSTRUCTOR(DamageText, int _group, vector _origin, int _health, int _armor, int _deathtype, bool _friendlyfire) {
+ CONSTRUCTOR(DamageText, int _group, vector _origin, int _health, int _armor, int _potential_damage, int _deathtype, bool _friendlyfire) {
CONSTRUCT(DamageText);
this.m_group = _group;
this.m_friendlyfire = _friendlyfire;
- DamageText_update(this, _origin, _health, _armor, _deathtype);
+ DamageText_update(this, _origin, _health, _armor, _potential_damage, _deathtype);
IL_PUSH(g_drawables_2d, this);
}
ENDCLASS(DamageText)
const float health = M_ARGV(2, float);
const float armor = M_ARGV(3, float);
const int deathtype = M_ARGV(5, int);
+ const float potential_damage = M_ARGV(6, float);
const vector location = hit.origin;
FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
if (
int flags = SAME_TEAM(hit, attacker); // BIT(0)
if (health >= DAMAGETEXT_SHORT_LIMIT) flags |= BIT(1);
if (armor >= DAMAGETEXT_SHORT_LIMIT) flags |= BIT(2);
+ if (potential_damage >= DAMAGETEXT_SHORT_LIMIT) flags |= BIT(3);
msg_entity = it;
WriteHeader(MSG_ONE, damagetext);
else WriteShort(MSG_ONE, health * DAMAGETEXT_PRECISION_MULTIPLIER);
if (armor >= DAMAGETEXT_SHORT_LIMIT) WriteInt24_t(MSG_ONE, armor * DAMAGETEXT_PRECISION_MULTIPLIER);
else WriteShort(MSG_ONE, armor * DAMAGETEXT_PRECISION_MULTIPLIER);
+ if (potential_damage >= DAMAGETEXT_SHORT_LIMIT) WriteInt24_t(MSG_ONE, potential_damage * DAMAGETEXT_PRECISION_MULTIPLIER);
+ else WriteShort(MSG_ONE, potential_damage * DAMAGETEXT_PRECISION_MULTIPLIER);
}
));
}
int flags = ReadByte();
bool friendlyfire = flags & 1;
- int health, armor;
+ int health, armor, potential_damage;
if (flags & BIT(1)) health = ReadInt24_t();
else health = ReadShort();
if (flags & BIT(2)) armor = ReadInt24_t();
else armor = ReadShort();
+ if (flags & BIT(3)) potential_damage = ReadInt24_t();
+ else potential_damage = ReadShort();
return = true;
if (autocvar_cl_damagetext) {
if (autocvar_cl_damagetext_accumulate_range) {
for (entity e = findradius(location, autocvar_cl_damagetext_accumulate_range); e; e = e.chain) {
if (e.instanceOfDamageText && e.m_group == group && e.alpha > autocvar_cl_damagetext_accumulate_alpha_rel * autocvar_cl_damagetext_alpha_start) {
- DamageText_update(e, location, e.m_damage + health, e.m_armordamage + armor, deathtype);
+ DamageText_update(e, location, e.m_damage + health, e.m_armordamage + armor, e.m_potential_damage + potential_damage, deathtype);
return;
}
}
}
- make_impure(NEW(DamageText, group, location, health, armor, deathtype, friendlyfire));
+ make_impure(NEW(DamageText, group, location, health, armor, potential_damage, deathtype, friendlyfire));
}
}
#endif
setDependent(e, "cl_damagetext", 1, 1);
this.TR(this);
this.TR(this);
+ // friendly fire
this.TD(this, 1, 3, e = makeXonoticCheckBox(0, "cl_damagetext_friendlyfire", _("Draw damage numbers for friendly fire")));
setDependent(e, "cl_damagetext", 1, 1);
this.TR(this);
start_items |= IT_UNLIMITED_SUPERWEAPONS;
}
+MUTATOR_HOOKFUNCTION(mutator_instagib, SetWeaponArena)
+{
+ // turn weapon arena off
+ M_ARGV(0, string) = "off";
+}
+
void replace_with_insta_cells(entity item)
{
entity e = spawn();
start_weapons = warmup_start_weapons = WEPSET(SHOTGUN);
}
+MUTATOR_HOOKFUNCTION(melee_only, SetWeaponArena)
+{
+ // turn weapon arena off
+ M_ARGV(0, string) = "off";
+}
+
MUTATOR_HOOKFUNCTION(melee_only, ForbidThrowCurrentWeapon)
{
return true;
METHOD(NadeOffhand, offhand_think, void(NadeOffhand this, entity player, bool key_pressed))
{
entity held_nade = player.nade;
- if (held_nade)
- {
- player.nade_timer = bound(0, (time - held_nade.nade_time_primed) / autocvar_g_nades_nade_lifetime, 1);
- // LOG_TRACEF("%d %d", player.nade_timer, time - held_nade.nade_time_primed);
- makevectors(player.angles);
- held_nade.velocity = player.velocity;
- setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0);
- held_nade.angles_y = player.angles.y;
-
- if (time + 0.1 >= held_nade.wait)
- toss_nade(player, false, '0 0 0', time + 0.05);
- }
if (!CanThrowNade(player)) return;
if (!(time > player.nade_refire)) return;
if (player.nade && (player.offhand != OFFHAND_NADE || (player.weapons & WEPSET(HOOK)))) OFFHAND_NADE.offhand_think(OFFHAND_NADE, player, player.nade_altbutton);
+ entity held_nade = player.nade;
+ if (held_nade)
+ {
+ player.nade_timer = bound(0, (time - held_nade.nade_time_primed) / autocvar_g_nades_nade_lifetime, 1);
+ // LOG_TRACEF("%d %d", player.nade_timer, time - held_nade.nade_time_primed);
+ makevectors(player.angles);
+ held_nade.velocity = player.velocity;
+ setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0);
+ held_nade.angles_y = player.angles.y;
+
+ if (time + 0.1 >= held_nade.wait)
+ toss_nade(player, false, '0 0 0', time + 0.05);
+ }
+
if(IS_PLAYER(player))
{
if ( autocvar_g_nades_bonus && autocvar_g_nades )
start_weapons = warmup_start_weapons = ok_start_items;
}
+MUTATOR_HOOKFUNCTION(ok, SetWeaponArena)
+{
+ // turn weapon arena off
+ M_ARGV(0, string) = "off";
+}
+
MUTATOR_HOOKFUNCTION(ok, BuildMutatorsString)
{
M_ARGV(0, string) = strcat(M_ARGV(0, string), ":OK");
#include "sv_spawn_near_teammate.qh"
+const float FLOAT_MAX = 340282346638528859811704183484516925440.0f;
+
float autocvar_g_spawn_near_teammate_distance;
int autocvar_g_spawn_near_teammate_ignore_spawnpoint;
+int autocvar_g_spawn_near_teammate_ignore_spawnpoint_max;
float autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay;
float autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay_death;
-int autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health;
+bool autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health;
bool autocvar_g_spawn_near_teammate_ignore_spawnpoint_closetodeath;
REGISTER_MUTATOR(spawn_near_teammate, cvar("g_spawn_near_teammate"));
.entity msnt_lookat;
.float msnt_timer;
-.vector msnt_deathloc;
.float cvar_cl_spawn_near_teammate;
player.msnt_timer = time + autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay_death;
entity best_mate = NULL;
- vector best_spot = '0 0 0';
- float pc = 0, best_dist = 0, dist = 0;
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
- if((autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health >= 0 && it.health >= autocvar_g_balance_health_regenstable) || autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health == 0)
- if(!IS_DEAD(it))
- if(it.msnt_timer < time)
- if(SAME_TEAM(player, it))
- if(time > it.spawnshieldtime) // spawn shielding
- if(!forbidWeaponUse(it))
- if(STAT(FROZEN, it) == 0)
- if(it != player)
+ vector best_pos = '0 0 0';
+ float best_dist2 = FLOAT_MAX;
+ int tested = 0;
+ FOREACH_CLIENT_RANDOM(IS_PLAYER(it), LAMBDA(
+ if (autocvar_g_spawn_near_teammate_ignore_spawnpoint_max && tested >= autocvar_g_spawn_near_teammate_ignore_spawnpoint_max) break;
+ if (!SAME_TEAM(player, it)) continue;
+ if (autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health && it.health < autocvar_g_balance_health_regenstable) continue;
+ if (IS_DEAD(it)) continue;
+ if (time < it.msnt_timer) continue;
+ if (time < it.spawnshieldtime) continue;
+ if (forbidWeaponUse(it)) continue;
+ if (it == player) continue;
+
+ tested++; // i consider a teammate to be available when he passes the checks above
+
+ vector horiz_vel = vec2(it.velocity);
+ // when walking slowly sideways, we assume the player wants a clear shot ahead - spawn behind him according to where he's looking
+ // when running fast, spawn behind him according to his direction of movement to prevent colliding with the newly spawned player
+ if (vdist(horiz_vel, >, autocvar_sv_maxspeed + 50))
+ fixedmakevectors(vectoangles(horiz_vel));
+ else
+ fixedmakevectors(it.angles); // .angles is the angle of the model - usually/always 0 pitch
+
+ // test different spots close to mate - trace upwards so it works on uneven surfaces
+ // don't spawn in front of player or directly behind to avoid players shooting each other
+ // test the potential spots in pairs (first pair is better than second and so on) but don't prefer one side
+ RandomSelection_Init();
+ for(int i = 0; i < 6; ++i)
{
- tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - '0 0 100', MOVE_NOMONSTERS, it);
- if(trace_fraction != 1.0)
- if(!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY))
+ switch(i)
{
- pc = pointcontents(trace_endpos + '0 0 1');
- if(pc == CONTENT_EMPTY)
+ case 0:
+ tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_forward * 64 + v_right * 128 + v_up * 64, MOVE_NOMONSTERS, it);
+ break;
+ case 1:
+ tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_forward * 64 - v_right * 128 + v_up * 64, MOVE_NOMONSTERS, it);
+ break;
+ case 2:
+ tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin + v_right * 192 + v_up * 64, MOVE_NOMONSTERS, it);
+ break;
+ case 3:
+ tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_right * 192 + v_up * 64, MOVE_NOMONSTERS, it);
+ break;
+ case 4:
+ tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_forward * 128 + v_right * 64 + v_up * 64, MOVE_NOMONSTERS, it);
+ break;
+ case 5:
+ tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_forward * 128 - v_right * 64 + v_up * 64, MOVE_NOMONSTERS, it);
+ break;
+ }
+
+ vector horizontal_trace_endpos = trace_endpos;
+ //te_lightning1(NULL, it.origin, horizontal_trace_endpos);
+ if (trace_fraction != 1.0) goto skip;
+
+ // 400 is about the height of a typical laser jump (in overkill)
+ // not traceline because we need space for the whole player, not just his origin
+ tracebox(horizontal_trace_endpos, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), horizontal_trace_endpos - '0 0 400', MOVE_NORMAL, it);
+ vector vectical_trace_endpos = trace_endpos;
+ //te_lightning1(NULL, horizontal_trace_endpos, vectical_trace_endpos);
+ if (trace_startsolid) goto skip; // inside another player
+ if (trace_fraction == 1.0) goto skip; // above void or too high
+ if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY) goto skip;
+ if (pointcontents(vectical_trace_endpos) != CONTENT_EMPTY) goto skip; // no lava or slime (or water which i assume would be annoying anyway)
+ if (tracebox_hits_trigger_hurt(horizontal_trace_endpos, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), vectical_trace_endpos)) goto skip;
+
+ // make sure the spawned player will have floor ahead (or at least a wall - he shouldn't fall as soon as he starts moving)
+ vector floor_test_start = vectical_trace_endpos + v_up * STAT(PL_MAX, NULL).z + v_forward * STAT(PL_MAX, NULL).x; // top front of player's bbox - highest point we know is not inside solid
+ traceline(floor_test_start, floor_test_start + v_forward * 100 - v_up * 128, MOVE_NOMONSTERS, it);
+ //te_beam(NULL, floor_test_start, trace_endpos);
+ if (trace_fraction == 1.0) goto skip;
+
+ if (autocvar_g_nades) {
+ bool nade_in_range = false;
+ IL_EACH(g_projectiles, it.classname == "nade",
{
- if(vdist(it.velocity, >, 5))
- fixedmakevectors(vectoangles(it.velocity));
- else
- fixedmakevectors(it.angles);
+ if (vdist(it.origin - vectical_trace_endpos, <, autocvar_g_nades_nade_radius)) {
+ nade_in_range = true;
+ goto skip;
+ }
+ });
+ if (nade_in_range) goto skip;
+ }
+
+ // here, we know we found a good spot
+ RandomSelection_Add(it, 0, string_null, vectical_trace_endpos, 1, 1);
+ //te_lightning1(NULL, vectical_trace_endpos, vectical_trace_endpos + v_forward * 10);
- for(pc = 0; pc < 4; ++pc) // test 4 diffrent spots close to mate
+LABEL(skip)
+ if (i % 2 == 1 && RandomSelection_chosen_ent)
+ {
+ if (autocvar_g_spawn_near_teammate_ignore_spawnpoint_closetodeath)
+ {
+ float dist2 = vlen2(RandomSelection_chosen_ent.origin - player.death_origin);
+ if (dist2 < best_dist2)
{
- switch(pc)
- {
- case 0:
- tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin + v_right * 128, MOVE_NOMONSTERS, it);
- break;
- case 1:
- tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_right * 128 , MOVE_NOMONSTERS, it);
- break;
- case 2:
- tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin + v_right * 128 - v_forward * 64, MOVE_NOMONSTERS, it);
- break;
- case 3:
- tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_right * 128 - v_forward * 64, MOVE_NOMONSTERS, it);
- break;
- //case 4:
- //tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_forward * 128, MOVE_NOMONSTERS, it);
- //break;
- }
-
- if(trace_fraction == 1.0)
- {
- traceline(trace_endpos + '0 0 4', trace_endpos - '0 0 100', MOVE_NOMONSTERS, it);
- if(trace_fraction != 1.0)
- {
- if(autocvar_g_spawn_near_teammate_ignore_spawnpoint_closetodeath)
- {
- dist = vlen(trace_endpos - player.msnt_deathloc);
- if(dist < best_dist || best_dist == 0)
- {
- best_dist = dist;
- best_spot = trace_endpos;
- best_mate = it;
- }
- }
- else
- {
- setorigin(player, trace_endpos);
- player.angles = it.angles;
- player.angles_z = 0; // never spawn tilted even if the spot says to
- it.msnt_timer = time + autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay;
- return;
- }
- }
- }
+ best_dist2 = dist2;
+ best_pos = RandomSelection_chosen_vec;
+ best_mate = RandomSelection_chosen_ent;
}
}
+ else
+ {
+ setorigin(player, RandomSelection_chosen_vec);
+ player.angles = RandomSelection_chosen_ent.angles;
+ player.angles_z = 0; // never spawn tilted even if the spot says to
+ RandomSelection_chosen_ent.msnt_timer = time + autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay;
+ return;
+ }
+ break; // don't test the other spots near this teammate, go to the next one
}
}
));
if(autocvar_g_spawn_near_teammate_ignore_spawnpoint_closetodeath)
- if(best_dist)
+ if(best_mate)
{
- setorigin(player, best_spot);
+ setorigin(player, best_pos);
player.angles = best_mate.angles;
player.angles_z = 0; // never spawn tilted even if the spot says to
best_mate.msnt_timer = time + autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay;
}
}
-MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerDies)
-{
- entity frag_target = M_ARGV(0, entity);
-
- frag_target.msnt_deathloc = frag_target.origin;
-}
-
REPLICATE(cvar_cl_spawn_near_teammate, bool, "cl_spawn_near_teammate");
#include "train.qh"
.float train_wait_turning;
+.entity future_target;
void train_next(entity this);
#ifdef SVQC
void train_use(entity this, entity actor, entity trigger);
{
entity targ, cp;
vector ang;
- targ = find(NULL, targetname, this.target);
+ targ = this.future_target;
if((this.spawnflags & 1) && targ.curvetarget)
cp = find(NULL, targetname, targ.curvetarget);
else
#endif
#ifdef SVQC
- entity tg = find(NULL, targetname, this.target);
+ entity tg = this.future_target;
if(tg.spawnflags & 4)
{
this.use = train_use;
}
}
+entity train_next_find(entity this)
+{
+ if(this.target_random)
+ {
+ RandomSelection_Init();
+ for(entity t = NULL; (t = find(t, targetname, this.target));)
+ {
+ RandomSelection_AddEnt(t, 1, 0);
+ }
+ return RandomSelection_chosen_ent;
+ }
+ else
+ {
+ return find(NULL, targetname, this.target);
+ }
+}
+
void train_next(entity this)
{
- entity targ, cp = NULL;
+ entity targ = NULL, cp = NULL;
vector cp_org = '0 0 0';
- targ = find(NULL, targetname, this.target);
+ targ = this.future_target;
+
this.target = targ.target;
+ this.target_random = targ.target_random;
+ this.future_target = train_next_find(targ);
+
if (this.spawnflags & 1)
{
if(targ.curvetarget)
void func_train_find(entity this)
{
- entity targ;
- targ = find(NULL, targetname, this.target);
+ entity targ = train_next_find(this);
this.target = targ.target;
+ this.target_random = targ.target_random;
+ // save the future target for later
+ this.future_target = train_next_find(targ);
if (this.target == "")
objerror(this, "func_train_find: no next target");
SUB_SETORIGIN(this, targ.origin - this.view_ofs);
#include "rootdialog.qh"
CLASS(XonoticUid2NameDialog, XonoticRootDialog)
METHOD(XonoticUid2NameDialog, fill, void(entity));
- ATTRIB(XonoticUid2NameDialog, title, string);
+ ATTRIB(XonoticUid2NameDialog, title, string, "");
ATTRIB(XonoticUid2NameDialog, color, vector, SKINCOLOR_DIALOG_TEAMSELECT);
ATTRIB(XonoticUid2NameDialog, intendedWidth, float, 0.5);
ATTRIB(XonoticUid2NameDialog, rows, float, 4);
SLIST_CATEGORY(CAT_SERVERS, "CAT_NORMAL", "CAT_SERVERS", CTX(_("SLCAT^Servers"))) \
SLIST_CATEGORY(CAT_XPM, "CAT_NORMAL", "CAT_SERVERS", CTX(_("SLCAT^Competitive Mode"))) \
SLIST_CATEGORY(CAT_MODIFIED, "", "CAT_SERVERS", CTX(_("SLCAT^Modified Servers"))) \
- SLIST_CATEGORY(CAT_OVERKILL, "", "CAT_SERVERS", CTX(_("SLCAT^Overkill Mode"))) \
- SLIST_CATEGORY(CAT_INSTAGIB, "", "CAT_SERVERS", CTX(_("SLCAT^InstaGib Mode"))) \
+ SLIST_CATEGORY(CAT_OVERKILL, "", "CAT_SERVERS", CTX(_("SLCAT^Overkill"))) \
+ SLIST_CATEGORY(CAT_INSTAGIB, "", "CAT_SERVERS", CTX(_("SLCAT^InstaGib"))) \
SLIST_CATEGORY(CAT_DEFRAG, "", "CAT_SERVERS", CTX(_("SLCAT^Defrag Mode")))
#define SLIST_CATEGORY_AUTOCVAR(name) autocvar_menu_slist_categories_##name##_override
#define FOREACH_CLIENT(cond, body) FOREACH_CLIENTSLOT(IS_CLIENT(it) && (cond), body)
+// using the "inside out" version of knuth-fisher-yates shuffle
+// https://en.wikipedia.org/wiki/Fisher–Yates_shuffle
+entity _FCR_clients[255];
+bool _FCR_entered = false;
+#define FOREACH_CLIENT_RANDOM(cond, body) \
+ MACRO_BEGIN { \
+ if (_FCR_entered) LOG_FATAL("FOREACH_CLIENT_RANDOM must not be nested"); \
+ _FCR_entered = true; \
+ int _cnt = 0; \
+ FOREACH_CLIENT(cond, LAMBDA( \
+ int _j = floor(random() * (_cnt + 1)); \
+ if (_j == _cnt) \
+ { \
+ _FCR_clients[_cnt] = it; \
+ } \
+ else \
+ { \
+ _FCR_clients[_cnt] = _FCR_clients[_j]; \
+ _FCR_clients[_j] = it; \
+ } \
+ _cnt++; \
+ )); \
+ for (int _i = 0; _i < _cnt; ++_i) \
+ { \
+ const noref int i = _i; \
+ ITER_CONST noref entity it = _FCR_clients[i]; \
+ if (cond) { LAMBDA(body) } \
+ } \
+ _FCR_entered = false; \
+ } MACRO_END
+
// NOTE: FOR_EACH_MONSTER deprecated! Use the following instead: IL_EACH(g_monsters, true, { code; });
#include <common/effects/all.qh>
/** armor */ i(float, MUTATOR_ARGV_3_float) \
/** location */ i(vector, MUTATOR_ARGV_4_vector) \
/** deathtype */ i(int, MUTATOR_ARGV_5_int) \
+ /** potential_damage */ i(float, MUTATOR_ARGV_6_float) \
/**/
MUTATOR_HOOKABLE(PlayerDamaged, EV_PlayerDamaged);
{
WeaponStats_LogDamage(awep.m_id, abot, PS(this).m_weapon.m_id, vbot, dh + da);
}
- if (dh + da)
+ if (damage)
{
- MUTATOR_CALLHOOK(PlayerDamaged, attacker, this, dh, da, hitloc, deathtype);
+ MUTATOR_CALLHOOK(PlayerDamaged, attacker, this, dh, da, hitloc, deathtype, damage);
}
if (this.health < 1)