Main file of the FactionNPC plugin, which makes Half-Life 2 NPCs like or hate players according to the player's
faction; exposes the plugin as factionnpc.
factionnpc.stored lists the NPC classes that side with the Combine or with the rebels, checked by
factionnpc:IsNPCCombine and factionnpc:IsNPCRebel. factionnpc:UpdateNPCRelations and
factionnpc:UpdateNPCRelation set the relationships, and the PlayerSpawn and PlayerSpawnedNPC hooks apply them.
Summary
Hooks
Hooks
Returns whether an NPC belongs to the Combine.
Looks the NPC's class up in factionnpc.stored; floor turrets with the citizen spawn flag
count as rebels.
Parameters
- npc NPC The NPC to check
Returns
- Boolean
truefor Combine NPC classes,falsefor anything else or an invalid entity
See also
Returns whether an NPC is on the rebels' side.
True for classes marked false in factionnpc.stored (citizens, vortigaunts, Alyx and other
resistance characters) and for floor turrets with the citizen spawn flag.
Parameters
- npc NPC The NPC to check
Returns
- Boolean
truefor rebel NPCs,falsefor anything else or an invalid entity
See also
Called when a player spawns; updates every NPC's relationship towards them.
Parameters
- ply Player The player who spawned
factionnpc:PlayerSpawnedNPC(ply, npc)
shared gamemodes/cwhl2rp/plugins/factionnpc/plugin/sh_plugin.lua:146Called after a player spawns an NPC; sets the new NPC's relationships towards all players.
Parameters
- ply Player The player who spawned the NPC
- npc NPC The NPC that was spawned
factionnpc:UpdateNPCRelation(npc)
shared gamemodes/cwhl2rp/plugins/factionnpc/plugin/sh_plugin.lua:125Sets how one NPC feels about every player, based on each player's faction.
Combine NPCs like Combine and admin faction players and hate everyone else; rebel NPCs hate Combine and admin faction players and like everyone else. Both hate the necro and antlion factions. Does nothing for NPCs that are neither Combine nor rebels.
Parameters
- npc NPC The NPC whose relationships are set
See also
factionnpc:UpdateNPCRelations(ply)
shared gamemodes/cwhl2rp/plugins/factionnpc/plugin/sh_plugin.lua:104Sets how every NPC on the map feels about a player, based on the player's faction.
Combine NPCs like Combine and admin faction players and hate everyone else; rebel NPCs hate Combine and admin faction players and like everyone else. Both hate the necro and antlion factions. Does nothing for an invalid entity or a non-player.
Parameters
- ply Player The player the relationships are set towards