Skip to content

Allow Citizens to use SMG1 and AR2 alt-fire modes in HL2 and episodic #1338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

pivotman319-owo
Copy link

@pivotman319-owo pivotman319-owo commented Jun 7, 2025

Description

This PR adds support for alt-fire to citizens carrying the following weapons:

  • SMG1 (weapon_smg1)
  • Combine Pulse Rifle/AR2 (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 variable NumGrenades. Several new schedules and tasks (largely adapted from Combine soldier altfire behavior) have also been added, and weapon_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 target
  • TASK_CIT_GET_PATH_TO_FORCED_GREN_LOS; get acceptable path for forced grenade/energy ball alt-fire
  • TASK_CIT_DEFER_SQUAD_GRENADES; delays other squad members' alt-fires by a specified period
  • TASK_CIT_PLAY_SEQUENCE_FACE_ALTFIRE_TARGET; invokes SMG1/AR2 alt-fire attack activity

The following schedules have been added to CNPC_Citizen:

  • SCHED_CITIZEN_FORCED_GRENADE_FIRE; for FireGrenadeAtTarget input
  • SCHED_CITIZEN_AR2_ALTFIRE; Alt-fire schedule
  • SCHED_CITIZEN_MOVE_TO_FORCED_GREN_LOS; move to acceptable path for forced grenade/energy ball alt-fire

The following functions have been added to CNPC_Citizen:

  • void CNPC_Citizen::SelectScheduleAttack() (called by CNPC_Citizen::SelectScheduleCombat() for the explicit purpose of selecting primary and alt-fire schedules)
  • bool CNPC_Citizen::CanAltFireEnemy( bool bUseFreeKnowledge ); check for alt-fire applicability
  • int CNPC_Citizen::RangeAttack2Conditions( float flDot, float flDist )
  • void CNPC_Citizen::DelayAltFireAttack( float flDelay ); delay alt-fire attack for self
  • void CNPC_Citizen::DelaySquadAltFireAttack( float flDelay ); delay alt-fire attack for squad members
  • void CNPC_Citizen::InputFireGrenadeAtTarget( inputdata_t& inputdata ); for input FireGrenadeAtTarget

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 an npc_bullseye or npc_combine_s w D_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:

@NPCClass base(BaseNPC,Parentname, TalkNPC, PlayerCompanion ) studio() = npc_citizen : "Citizen"
[

	// [...]

	NumGrenades(choices) : "Number of Grenades" : "3" : "How many SMG1 grenades/AR2 energy balls does this citizen have? Select 'None' to disable alt-fire modes." =
	[
		"0" : "None"
		"1" : "1"
		"2" : "2"
		"3" : "3"
		"4" : "4"
		"5" : "5"
		"999999" : "Unlimited"
	]
	
	// [...]
	
	//Inputs
	// [...]
	input FireGrenadeAtTarget(string) : "Fire a grenade or AR2 energy ball at the target. The citizen MUST have an SMG1 or AR2 equipped!"

	// [...]
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant