Allow Citizens to use SMG1 and AR2 alt-fire modes in HL2 and episodic #1338
+791
−144
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds support for alt-fire to citizens carrying the following weapons:
weapon_smg1
)weapon_ar2
)Demonstration video: https://www.youtube.com/watch?v=AsqEgg_6UPU
Citizens carry a limited number of SMG1 grenades and energy balls, governed by the ConVar
sk_citizen_grenades
and additionally exposed by Hammer integer variableNumGrenades
. Several new schedules and tasks (largely adapted from Combine soldier altfire behavior) have also been added, andweapon_smg1
attack handling behavior has also been refactored to support NPC altfire events, with credit given to @Bitl for the initial SMG1 NPC altfire implementation present in Firefight: Reloaded.The following tasks have been added to
CNPC_Citizen
:TASK_CIT_FACE_TOSS_DIR
; aiming towards alt-fire targetTASK_CIT_GET_PATH_TO_FORCED_GREN_LOS
; get acceptable path for forced grenade/energy ball alt-fireTASK_CIT_DEFER_SQUAD_GRENADES
; delays other squad members' alt-fires by a specified periodTASK_CIT_PLAY_SEQUENCE_FACE_ALTFIRE_TARGET
; invokes SMG1/AR2 alt-fire attack activityThe following schedules have been added to
CNPC_Citizen
:SCHED_CITIZEN_FORCED_GRENADE_FIRE
; forFireGrenadeAtTarget
inputSCHED_CITIZEN_AR2_ALTFIRE
; Alt-fire scheduleSCHED_CITIZEN_MOVE_TO_FORCED_GREN_LOS
; move to acceptable path for forced grenade/energy ball alt-fireThe following functions have been added to
CNPC_Citizen
:void CNPC_Citizen::SelectScheduleAttack()
(called byCNPC_Citizen::SelectScheduleCombat()
for the explicit purpose of selecting primary and alt-fire schedules)bool CNPC_Citizen::CanAltFireEnemy( bool bUseFreeKnowledge )
; check for alt-fire applicabilityint CNPC_Citizen::RangeAttack2Conditions( float flDot, float flDist )
void CNPC_Citizen::DelayAltFireAttack( float flDelay )
; delay alt-fire attack for selfvoid CNPC_Citizen::DelaySquadAltFireAttack( float flDelay )
; delay alt-fire attack for squad membersvoid CNPC_Citizen::InputFireGrenadeAtTarget( inputdata_t& inputdata )
; for inputFireGrenadeAtTarget
One new input has been added to the in-game entity
npc_citizen
:FireGrenadeAtTarget
; Forces an NPC to fire a grenade/energy ball at a target. Accepts an NPC (like annpc_bullseye
ornpc_combine_s
wD_HT
relations) as a target parameter.This depends on #1320 to merge, and additionally requires an FGD update in
halflife2.fgd
to account for changes in the Citizen code: