From 760b1bd07bab94708cc66ad7d30e70418e44193d Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 20 Aug 2016 22:36:33 +1000 Subject: [PATCH] Some minor tweaks and extra mutator hooks --- qcsrc/client/autocvars.qh | 2 +- qcsrc/client/main.qh | 2 +- qcsrc/client/mutators/events.qh | 3 +++ qcsrc/client/view.qc | 11 ++++++++--- .../gamemodes/gamemode/onslaught/onslaught.qc | 8 +++----- qcsrc/common/monsters/sv_monsters.qc | 1 + .../mutators/mutator/campcheck/campcheck.qc | 1 + .../spawn_near_teammate/spawn_near_teammate.qc | 1 + qcsrc/common/stats.qh | 1 + qcsrc/common/triggers/triggers.qc | 15 +++++++++++++-- qcsrc/common/triggers/triggers.qh | 6 ++++++ qcsrc/server/defs.qh | 1 - qcsrc/server/mutators/events.qh | 17 +++++++++++++++++ .../mutators/mutator/gamemode_domination.qh | 2 ++ qcsrc/server/weapons/weaponsystem.qc | 1 + qcsrc/server/weapons/weaponsystem.qh | 2 +- 16 files changed, 60 insertions(+), 14 deletions(-) diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index 0ac857754..65a219720 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -396,7 +396,6 @@ float autocvar_hud_shownames_offset; string autocvar_hud_skin; float autocvar_menu_mouse_speed; string autocvar_menu_skin; -float autocvar_r_drawviewmodel; int autocvar_r_fakelight; int autocvar_r_fullbright; float autocvar_r_letterbox; @@ -456,4 +455,5 @@ vector autocvar_crosshair_rpc_color = '0.2 1.0 0.2'; float autocvar_crosshair_rpc_alpha = 1; float autocvar_crosshair_rpc_size = 1; int autocvar_cl_nade_timer; +bool autocvar_r_drawviewmodel; bool autocvar_cl_items_nofade; diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh index afd0b5e38..e736d9d44 100644 --- a/qcsrc/client/main.qh +++ b/qcsrc/client/main.qh @@ -126,7 +126,7 @@ const int HOOK_END = 2; float g_trueaim_minrange; -float hud; +int hud; float view_quality; int num_spectators; diff --git a/qcsrc/client/mutators/events.qh b/qcsrc/client/mutators/events.qh index b72f7abe1..a852fdbe4 100644 --- a/qcsrc/client/mutators/events.qh +++ b/qcsrc/client/mutators/events.qh @@ -142,3 +142,6 @@ MUTATOR_HOOKABLE(DrawGrapplingHook, EV_DrawGrapplingHook); /** is new to client */ i(bool, MUTATOR_ARGV_1_bool) \ /**/ MUTATOR_HOOKABLE(Ent_Update, EV_Ent_Update); + +/** Return true to not draw crosshair */ +MUTATOR_HOOKABLE(DrawCrosshair, EV_NO_ARGS); diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 339d05209..db6df4dad 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -937,7 +937,7 @@ void HUD_Crosshair(entity this) float f, i, j; vector v; if(!scoreboard_active && !camera_active && intermission != 2 && - spectatee_status != -1 && !csqcplayer.viewloc && + spectatee_status != -1 && !csqcplayer.viewloc && !MUTATOR_CALLHOOK(DrawCrosshair) && !HUD_MinigameMenu_IsOpened() ) { if (!autocvar_crosshair_enabled) // main toggle for crosshair rendering @@ -1337,6 +1337,11 @@ void HUD_Draw(entity this) DrawCircleClippedPic(eX * 0.5 * vid_conwidth + eY * 0.6 * vid_conheight, 0.1 * vid_conheight, "gfx/crosshair_ring.tga", STAT(NADE_TIMER), '0.25 0.90 1' + ('1 0 0' * STAT(NADE_TIMER)) - ('0 1 1' * STAT(NADE_TIMER)), autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE); drawstring_aspect(eY * 0.64 * vid_conheight, ((autocvar_cl_nade_timer == 2) ? _("Nade timer") : ""), eX * vid_conwidth + eY * 0.025 * vid_conheight, '1 1 1', 1, DRAWFLAG_NORMAL); } + else if(STAT(CAPTURE_PROGRESS)) + { + DrawCircleClippedPic(eX * 0.5 * vid_conwidth + eY * 0.6 * vid_conheight, 0.1 * vid_conheight, "gfx/crosshair_ring.tga", STAT(CAPTURE_PROGRESS), '0.25 0.90 1', autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE); + drawstring_aspect(eY * 0.64 * vid_conheight, _("Capture progress"), eX * vid_conwidth + eY * 0.025 * vid_conheight, '1 1 1', 1, DRAWFLAG_NORMAL); + } else if(STAT(REVIVE_PROGRESS)) { DrawCircleClippedPic(eX * 0.5 * vid_conwidth + eY * 0.6 * vid_conheight, 0.1 * vid_conheight, "gfx/crosshair_ring.tga", STAT(REVIVE_PROGRESS), '0.25 0.90 1', autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE); @@ -1368,6 +1373,7 @@ float oldr_useportalculling; float oldr_useinfinitefarclip; void cl_notice_run(); + float prev_myteam; int lasthud; float vh_notice_time; @@ -1825,8 +1831,7 @@ void CSQC_UpdateView(entity this, float w, float h) else if(csqcplayer.viewloc) { setproperty(VF_FOV, GetViewLocationFOV(110)); } // enforce 110 fov, so things dont look odd else { setproperty(VF_FOV, GetCurrentFov(fov)); } - // Camera for demo playback - if(camera_active) + if(camera_active) // Camera for demo playback { if(autocvar_camera_enable) CSQC_Demo_Camera(); diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc index 713c5d7de..a0225f624 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc @@ -76,8 +76,6 @@ bool ons_stalemate; .float teleport_antispam; -.bool ons_roundlost = _STAT(ROUNDLOST); - // waypoint sprites .entity bot_basewaypoint; // generator waypointsprite @@ -1250,7 +1248,7 @@ bool Onslaught_CheckWinner() round_handler_Init(7, autocvar_g_onslaught_warmup, autocvar_g_onslaught_round_timelimit); FOREACH_CLIENT(IS_PLAYER(it), { - it.ons_roundlost = true; + STAT(ROUNDLOST, it) = true; it.player_blocked = true; nades_Clear(it); @@ -1733,7 +1731,7 @@ bool ons_Teleport(entity player, entity tele_target, float range, bool tele_effe MUTATOR_HOOKFUNCTION(ons, reset_map_global) { FOREACH_CLIENT(IS_PLAYER(it), { - it.ons_roundlost = false; + STAT(ROUNDLOST, it) = false; it.ons_deathloc = '0 0 0'; PutClientInServer(it); }); @@ -2008,7 +2006,7 @@ MUTATOR_HOOKFUNCTION(ons, SpectateCopy) entity spectatee = M_ARGV(0, entity); entity client = M_ARGV(1, entity); - client.ons_roundlost = spectatee.ons_roundlost; // make spectators see it too + STAT(ROUNDLOST, client) = STAT(ROUNDLOST, spectatee); // make spectators see it too } MUTATOR_HOOKFUNCTION(ons, SV_ParseClientCommand) diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index ea46be5f1..c72c7461e 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -94,6 +94,7 @@ bool Monster_ValidTarget(entity this, entity targ) || (SAME_TEAM(targ, this)) || (STAT(FROZEN, targ)) || (targ.alpha != 0 && targ.alpha < 0.5) + || (MUTATOR_CALLHOOK(MonsterValidTarget, this, targ)) ) { // if any of the above checks fail, target is not valid diff --git a/qcsrc/common/mutators/mutator/campcheck/campcheck.qc b/qcsrc/common/mutators/mutator/campcheck/campcheck.qc index 1ab6fb462..8be321549 100644 --- a/qcsrc/common/mutators/mutator/campcheck/campcheck.qc +++ b/qcsrc/common/mutators/mutator/campcheck/campcheck.qc @@ -39,6 +39,7 @@ MUTATOR_HOOKFUNCTION(campcheck, PlayerPreThink) if(IS_PLAYER(player)) if(IS_REAL_CLIENT(player)) // bots may camp, but that's no reason to constantly kill them if(!IS_DEAD(player)) + if(!forbidWeaponUse(player)) if(!STAT(FROZEN, player)) if(!PHYS_INPUT_BUTTON_CHAT(player)) if(autocvar_g_campcheck_interval) diff --git a/qcsrc/common/mutators/mutator/spawn_near_teammate/spawn_near_teammate.qc b/qcsrc/common/mutators/mutator/spawn_near_teammate/spawn_near_teammate.qc index b16a6c9ac..20f07e9e4 100644 --- a/qcsrc/common/mutators/mutator/spawn_near_teammate/spawn_near_teammate.qc +++ b/qcsrc/common/mutators/mutator/spawn_near_teammate/spawn_near_teammate.qc @@ -88,6 +88,7 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn) 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) { diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index a24243bb6..c8822926f 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -121,6 +121,7 @@ REGISTER_STAT(REVIVE_PROGRESS, float) REGISTER_STAT(ROUNDLOST, int) REGISTER_STAT(BUFF_TIME, float) REGISTER_STAT(CTF_FLAGSTATUS, int) +REGISTER_STAT(CAPTURE_PROGRESS, float) REGISTER_STAT(ENTRAP_ORB, float) REGISTER_STAT(ENTRAP_ORB_ALPHA, float) REGISTER_STAT(ITEMSTIME, int, autocvar_sv_itemstime) diff --git a/qcsrc/common/triggers/triggers.qc b/qcsrc/common/triggers/triggers.qc index 849d3e8ac..81144aae7 100644 --- a/qcsrc/common/triggers/triggers.qc +++ b/qcsrc/common/triggers/triggers.qc @@ -163,6 +163,7 @@ void trigger_remove_generic(entity this) } #endif + /* ============================== SUB_UseTargets @@ -182,7 +183,8 @@ match (string)this.target and call their .use function ============================== */ -void SUB_UseTargets(entity this, entity actor, entity trigger) + +void SUB_UseTargets_Ex(entity this, entity actor, entity trigger, bool preventReuse) { // // check for a delay @@ -253,7 +255,7 @@ void SUB_UseTargets(entity this, entity actor, entity trigger) int aw_flag = this.antiwall_flag; for(entity t = NULL; (t = find(t, targetname, s)); ) { - if(t.use) + if(t.use && (t.sub_target_used != time || !preventReuse)) { if(this.target_random) { @@ -265,6 +267,8 @@ void SUB_UseTargets(entity this, entity actor, entity trigger) t.antiwall_flag = aw_flag; t.use(t, actor, this); + if(preventReuse) + t.sub_target_used = time; } } } @@ -272,9 +276,16 @@ void SUB_UseTargets(entity this, entity actor, entity trigger) } if(this.target_random && RandomSelection_chosen_ent) + { RandomSelection_chosen_ent.use(RandomSelection_chosen_ent, actor, this); + if(preventReuse) + RandomSelection_chosen_ent.sub_target_used = time; + } } +void SUB_UseTargets(entity this, entity actor, entity trigger) { SUB_UseTargets_Ex(this, actor, trigger, false); } +void SUB_UseTargets_PreventReuse(entity this, entity actor, entity trigger) { SUB_UseTargets_Ex(this, actor, trigger, true); } + void SUB_UseTargets_self(entity this) { SUB_UseTargets(this, NULL, NULL); diff --git a/qcsrc/common/triggers/triggers.qh b/qcsrc/common/triggers/triggers.qh index 8a8eb566c..bc4047fe9 100644 --- a/qcsrc/common/triggers/triggers.qh +++ b/qcsrc/common/triggers/triggers.qh @@ -27,8 +27,14 @@ string trigger_magicear_processmessage_forallears(entity source, float teamsay, void target_voicescript_next(entity pl); void target_voicescript_clear(entity pl); + +void SUB_ForEachTarget_Init(); +void SUB_ForEachTarget(entity s, void(entity, float, vector, string, entity) cback, float recursive, float fdata, vector vdata, string sdata, entity edata); +void SUB_UseTargets_PreventReuse(entity this, entity actor, entity trigger); #endif +.float sub_target_used; + .float volume, atten; .vector dest; diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 53aa317e6..d2b4b148e 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -430,7 +430,6 @@ const int MIF_GUIDED_CONFUSABLE = MIF_GUIDED_HEAT | MIF_GUIDED_AI; #define MISSILE_IS_GUIDED(m) ((m.missile_flags & MIF_GUIDED_ALL) ? true : false) #define MISSILE_IS_TRACKING(m) ((m.missile_flags & MIF_GUIDED_TRACKING) ? true : false) - //// .entity player_stats; diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 0d53e054f..29b1b7abd 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -271,6 +271,15 @@ MUTATOR_HOOKABLE(MonsterMove, EV_MonsterMove); /** called when a monster looks for another target */ MUTATOR_HOOKABLE(MonsterFindTarget, EV_NO_ARGS); +/** + * called when validating a monster's target + */ +#define EV_MonsterValidTarget(i, o) \ + /** monster */ i(entity, MUTATOR_ARGV_0_entity) \ + /** target */ i(entity, MUTATOR_ARGV_1_entity) \ + /**/ +MUTATOR_HOOKABLE(MonsterValidTarget, EV_MonsterValidTarget); + /** called to change a random monster to a miniboss */ #define EV_MonsterCheckBossFlag(i, o) \ /** monster */ i(entity, MUTATOR_ARGV_0_entity) \ @@ -837,3 +846,11 @@ MUTATOR_HOOKABLE(Player_ChangeTeam, EV_Player_ChangeTeam); /** data */ i(string, MUTATOR_ARGV_2_string) \ /**/ MUTATOR_HOOKABLE(URI_GetCallback, EV_URI_GetCallback); + +/** + * return true to prevent weapon use for a player + */ + #define EV_ForbidWeaponUse(i, o) \ + /** player */ i(entity, MUTATOR_ARGV_0_entity) \ + /**/ +MUTATOR_HOOKABLE(ForbidWeaponUse, EV_ForbidWeaponUse); diff --git a/qcsrc/server/mutators/mutator/gamemode_domination.qh b/qcsrc/server/mutators/mutator/gamemode_domination.qh index 399830dad..9a0a1262f 100644 --- a/qcsrc/server/mutators/mutator/gamemode_domination.qh +++ b/qcsrc/server/mutators/mutator/gamemode_domination.qh @@ -1,3 +1,5 @@ #pragma once #include "../gamemode.qh" + +void AnimateDomPoint(entity this); diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index c0ed81e68..2efea3ff5 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -412,6 +412,7 @@ bool forbidWeaponUse(entity player) if (gameover) return true; if (STAT(FROZEN, player)) return true; if (player.weapon_blocked) return true; + if (MUTATOR_CALLHOOK(ForbidWeaponUse, player)) return true; return false; } diff --git a/qcsrc/server/weapons/weaponsystem.qh b/qcsrc/server/weapons/weaponsystem.qh index d0ba63412..b7ca59704 100644 --- a/qcsrc/server/weapons/weaponsystem.qh +++ b/qcsrc/server/weapons/weaponsystem.qh @@ -8,7 +8,7 @@ void CL_SpawnWeaponentity(entity e, .entity weaponentity); vector CL_Weapon_GetShotOrg(float wpn); -float forbidWeaponUse(entity player); +bool forbidWeaponUse(entity player); void W_AttachToShotorg(entity actor, .entity weaponentity, entity flash, vector offset); -- 2.39.2