TutorialsBack to Tutorials
Generator & RechargerThis Tutorial shows how to set up a Generator that can be Recharger and Hacked.
First you need to use the HL2 Prefab "combine_ball_generator" to create a normal generator. You can find it by clicking the Create Entity icon and then selecting HL2 Prefabs from the Categories and then finding it from the drop down menu. You will need to do some changes to the entities, though. The logic_relays logic_ballgenerator1_disabled and logic_ballgenerator1_enabled call logic_relays relay_combineshieldwall1_off and relay_combineshieldwall1_on by default. Remember to remove or change those outputs if you don't need them.
Generator changes:Select the func_combine_ball_spawner and go to "Target name of the energy ball". Write something like "ball1". This will be the target name of the Combine energy ball that you will see bouncing inside the generator. We will use the target name to explode the ball when the generator is being zapped by a Vortigaunt. In Ball Respawn Time select 1 (instead of the default -1). Now go to the logic_ballgenerator1_disabled add an output to call the Explode input function on prop_combine_ball "ball1". The link will show up red, as ball1 does not exist in Hammer.
Now select the blue shield effect func_brush, which is named brush_ballgenerator1 (the number changes) in the prefab. Copy it, name the new brush brush_ballgenerator1red, and change the texture from effects/com_shield002a to effects/com_shield002a_red. You should also check Start Disabled. Make sure to Disable it when logic_ballgenerator1_disabled is Triggered.
Create two filter_activator_class. Name first filter_bullseye and have Filter Classname as "npc_bullseye" and Filter mode as "Disallow entities that match criteria". Name the second filter filter_combine_balls and have Filter Classname as "prop_combine_ball" and Filter mode as "Disallow entities that match criteria". Then create filter_multi, and name it filter_generator. Use Logic Type "AND", Filter 1 as "filter_bullseye" and Filter 2 as "filter_combine_ball". In the trigger_physics_trap select filter_generator from the filter list as Filter Name. Change Start Disabled to No if you are going to have the generator enabled on map start.
Create a brush with the trigger texture around the generator. Make it into a trigger_multiple and name it something like disturber_generator1. In Filter Name select again filter_generator. In Spawn Flags only check Physics Objects. Add an Output to call the Trigger input function of the logic_ballgenerator1_disabled when the trigger_multiple is triggered. In the logic_ballgenerator1_disabled add an output to Disable the trigger_multiple when the logic_relay is triggered.
Assuming that you want to have the generator start disabled, you have to make sure all the effects of the generator are down on map start. Change Start Disabled to Yes in both func_brushes. In the func_combine_ball_spawner check the spawn flag Start inactive. In the both env_citadel_energy_core named beam_ballgenerator1_fx uncheck the spawn flag Start on. In the env_beam named beam_ballgenerator1 also uncheck the Start on spawn flag.
BullseyeYou need to create a npc_bullseye inside the generator for the Vortigaunt to shoot. ai_relationship is used to make the Vortigaunt hate the bullseye, and a point_template to spawn a new bullseye when the generator is enabled and not hacked.
Place the bullseye in the center, between the beam entities inside the generator, and name it something like bullseye_generator1. The more Health you give to it the longer it takes for the Vortigaunts to take it down. 30 Health means something like two zaps. You can keep all spawn flags unchecked.
Create a new filter_activator_class. Name it filter_vortigaunts_only, Filter mode "Allow entities that match criteria", and "npc_vortigaunt" as the Filter Classname. In the npc_bullseye use filter_vortigaunts_only as the Damage Filter. Add an output to Trigger the logic_ballgenerator1_disabled OnDeath. Just to make sure, add an output to the logic_ballgenerator1_disabled to Kill the bullseye OnTrigger.
Also create a point_template and name it template_bullseye1. Have bullseye_generator1 as Template 1.
Create a ai_relationship so that the Vortigaunts will attack the bullseye. Write "npc_vortigaunt" in the Subject(s). Write bullseye_generator1 as the Target(s). Change Disposition to Hate and Disposition Priority to 1000. Change Radius for subject to determine how close the Vortigaunts have to be to attack the bullseye. We used values close to 300. Have the ai_relationship Start Active Yes, and in spawn flags check "Notify subject of target's location".
InterfaceNow let's add a Combine Interface into the mix. First add hlss_combine_interface somewhere in the map. Name it something like interface1. In the logic_ballgenerator1_disabled add an output to call the GeneratorDisabled input function. In the logic_ballgenerator1_enabled add an output to call the GeneratorEnabled input function.
Now in the interface OnNormalGeneratorEnable Disable the func_brush for the red ball generator effect, and enable the blue effect func_brush. Also Disable the trigger_multiple, disturber_generator1. Call ForceSpawn on the point_template to create the bullseye. OnHackedGeneratorEnable Enable the red func_brush, Disable the blue func_brush, Enable the disturber, and Kill the bullseye.
The Generator is now linked to the Interface.
RechargerNow you want to add a Recharger so that players can enable the generator after the Vortigaunts have disabled it. The button and the effects have to be correctly enabled and disabled when the generator is enabled and disabled.
You can find the prefab for the Recharger from the he_coop/prefabs folder in SourceMods. Add it to your prefabs by copying it to your prefabs folder under source2007 bin (the folder is something like C:\Steam\steamapps\[username]\sourcesdk\bin\source2007\bin\prefabs). Make its tail point at the generator center.
The Recharger should be functional and doesn't need changes itself. You can see that the func_button calls the hlss_weaponstripper to check if the player pressing the button has any AR2 AltFire ammo. The button itself should be locked if the generator starts enabled. The prefab already calls logic_ballgenerator1_enabled by default, but if you have multiple generators and rechargers already in the map, make sure it calls the correct one. Now add a hlss_glow_entity above the func_button. Name it something like glow_recharger1, and have Glow Enabled Yes if the generator starts disabled. In Glow entity name select the prop_dynamic of the Recharger model, named model_recharger1. From the Icon drop down menu select Recharge generator.
Go back to logic_ballgenerator1_enabled and add the following outputs OnTrigger: Lock the recharger func_button. Change of the Color of the env_sprite sprite_recharger_button1 to red "255 0 0". Disable the hlss_glow_entity. Then go to logic_ballgenerator1_disabled and again add the following outputs OnTrigger: Unlock the recharger func_button. Change the Color of the env_sprite to green "0 255 0", and enable the hlss_glow_entity.
Now add an AR2 AltFire ammo crate (item_ammo_crate with "AR2 Alt-Fire Round" as the ammo type) somewhere in the map and name it something like ammocrate_ar2altfire1. Add an hlss_glow_entity above it and name it glow_ammocrate1. Start Glow Enabled, use ammocrate_ar2altfire1 as the Glow entity name, and select "AR2 AltFire" as the Icon. Go back to logic_ballgenerator1_enabled to Disable the glow entity, and logic_ballgenerator1_disabled to Enable the glow entity. Also add an info_node very near the ammo crate so that NPCs can use it.
Recharge Point (AI Recharging Behavior)You might want to have your AI controlled metrocop pals try to recharge unhacked generators as well. This is when hlss_recharge_point comes in. Start by placing a hlss_recharge_point very near the recharger func_button. Have its angle point into the direction of the button. Add an info_node into the position too, but make sure it doesn't clip with the button, when looking from the top view. Name the hlss_recharge_point something like recharge_uniques1, and select the max distance to look for NPCs. In Search Type make sure to select Unique Metrocops (which means our AI controlled Noah, Larson, Anders or Eloise when there is no four players around). Assuming the generator is not enabled on map start, again check the spawn flag Start Active. Then select the item_ammo_crate, ammocrate_ar2altfire as the Ammo Crate, and check the "Need AR2 AltFire ammo to use" spawn flag.
Go to logic_ballgenerator1_enabled and Deactivate the hlss_recharge_point OnTrigger. Go to the hlss_weaponstripper, ammotaker_recharger1 and Deactivate the hlss_recharge_point. Go to the hlss_combine_interface that was connected to the generator, interface1, and add an output to Deactivate the hlss_recharge_point OnHackedOn. Finally add an an output to Activate the hlss_recharge_point OnNormalGeneratorDisable. Now the Metrocops will start doing the behavior only when the generator is not hacked and disabled, and will stop if it suddenly gets hacked or enabled.
You can add a second hlss_recharge_point for Alyx to recharge the generator when it is hacked.
See also: Combine Force Shields
Back to Tutorials