Faction

Faction post thumbnail image

Factions control how entities interact with each other. Use faction settings to decide when an entity is hostile toward other entities, and what groups or types of entities it can damage.

Faction properties are divided into group and type. Group factions allow you to set what faction groups an entity belongs to, and then what groups that entity will attack and damage. Type factions are the legacy type based method. They target an entity using its type (Player, NPC, Enemy, etc.). You can combine both for extremely nuanced faction behavior.

Group

The group properties enable you to make an entity member of one more of the A through Z factions, control whatever A through Z factions it is hostile to, and determine which factions it can hit with attacks. As an example, if an entity is hostile toward faction C, that means it is hostile toward any entities that are members of the C faction.

Member

faction_member <factions>

Default: faction_member a

Factions entity is a member of. Accepts one more of the following:

  • az – Entity is a member of this faction.
  • all – Entity is a member of all a through z factions.
  • neutral – Entity is a member of the neutral faction. Neutral has no special effect and is ignored by hostile/damage faction properties.
  • no_copy – Normally faction properties copy to sub entities and alternate models (ex. projectiles, weapons). If the parent or target model property has no_copy, that property is not copied.
  • player_verses – No effect.
  • type_inclusive – No effect.
  • type_exclusive – No effect.

Damage Direct

faction_damage_direct <factions>

Default: faction_damage_direct a type_inclusive

Factions entity can damage with normal attacks. Accepts one or more of the following.

  • az – Entity can damage members of these factions.
  • all – Entity can damage members of all a through z factions.
  • neutral – No effect.
  • no_copy – Normally faction properties copy to sub entities and alternate models (ex. projectiles, weapons). If the parent or target model property has no_copy, that property is not copied.
  • player_verses – Ignore level and menu settings for damaging other players.
  • type_inclusive – Include Type Damage Direct (see below). Both the faction and type checks must pass to damage another entity.
  • type_exclusive – Only use type_damage_direct.

Damage Indirect

faction_damage_indirect <factions>

Default: faction_damage_direct a type_inclusive

Factions entity can damage when thrown or blasted. For example, when a player throws an enemy into a group of other enemies, this property controls what entities the thrown enemy will hit. Accepts one or more of the following.

  • az – Entity can damage members of these factions.
  • all – Entity can damage members of all a through z factions.
  • neutral – No effect.
  • no_copy – Normally faction properties copy to sub entities and alternate models (ex. projectiles, weapons). If the parent or target model property has no_copy, that property is not copied.
  • player_verses – Ignore level and menu settings for damaging other players.
  • type_inclusive – Include Type Damage Indirect (see below). Both the faction and type checks must pass to damage another entity.
  • type_exclusive – Only use type_damage_indirect.

Hostile

faction_hostile <factions>

Default: faction_hostile a type_inclusive

Factions entity is hostile toward. Accepts one or more of the following.

  • az – Entity is hostile toward members of these factions.
  • all – Entity is hostile toward members of all a through z factions.
  • neutral – No effect.
  • no_copy – Normally faction properties copy to sub entities and alternate models (ex. projectiles, weapons). If the parent or target model property has no_copy, that property is not copied.
  • player_verses – Ignore level and menu settings for hostility other players.
  • type_inclusive – Include Type Hostile (see below). Both the faction and type checks must pass to be hostile toward another entity.
  • type_exclusive – Only use type_hostile.

Type

Prior to 4.0, OpenBOR relied solely on entity type for factions. Type properties target other entity’s types. To enable Type checking, you need to assign one of the Type factions to the appropriate faction group properties (see above).

Faction type properties have different defaults depending on the the model’s own type. For example, Enemy types are hostile to and able to hit players, and when thrown cause indirect damage to other enemies.

end_level, enemy, item, none, npc, obstacle, panel, player, projectile, shot, steamer, text_box, trap

Damage Direct

faction_type_damage_direct <types>

Default: Varies, see Type overview.

Entity types this entity can damage with normal attacks. Accepts one or more of the following. Default value depends on model’s type, and is usually appropriate for that type’s needs (example: Player types can damage enemies and obstacles).

  • Any valid types. Entity can damage these types.
  • no_copy – Normally faction properties copy to sub entities and alternate models (ex. projectiles, weapons). If the parent or target model property has no_copy, that property is not copied.

Damage Indirect

faction_type_damage_indirect <types>

Default: Varies, see Type overview.

Entity types this entity can damage when thrown or blasted. For example, when a player throws an enemy into a group of other enemies, this property controls what entities the thrown enemy will hit. Accepts one or more of the following. Default value depends on model’s type, and is usually appropriate for that type’s needs (example: Enemy types damage other enemies).

  • Any valid types. Entity can damage these types.
  • no_copy – Normally faction properties copy to sub entities and alternate models (ex. projectiles, weapons). If the parent or target model property has no_copy, that property is not copied.

Damage Hostile

faction_type_damage_hostile <types>

Default: Varies, see Type overview.

Entity types this entity is hostile toward. Default value depends on model’s type, and is usually appropriate for that type’s needs (example: Enemy types are hostile toward Players).

  • Any valid types. Entity is hostile toward these types.
  • no_copy – Normally faction properties copy to sub entities and alternate models (ex. projectiles, weapons). If the parent or target model property has no_copy, that property is not copied.

Set Up

Model Text

Use any of the following model text commands to set up starting factions.

This model is a member of faction A and faction B. It is hostile to factions C, D, and E. Note it is also configured to damage its own factions if thrown or blasted into them.

faction_group_damage_direct C D E
faction_group_damage_indirect A B
faction_group_hostile C D E
faction_group_member A B

This model is mostly identical to previous sample, but adds type_inclusive and faction type properties. It is now only hostile toward and able to hit factions C, D, and E if they are enemy or NPC types.

faction_group_damage_direct C D E type_inclusive 
faction_group_damage_indirect A B type_inclusive
faction_group_hostile C D E type_inclusive 
faction_group_member A B

faction_type_damage_direct enemy npc
faction_type_damage_indirect player
faction-type_hostile enemy npc

Spawn

You may use faction commands in level spawn entries to override an entity’s faction settings on spawn. The command syntax is identical to model text. The following spawn starts out ready to fight faction groups G and H.

spawn	Shermie
coords	350 160
faction_group_damage_direct G H
faction_group_damage_indirect E
faction_group_hostile G H
faction_group_member E
at	    10

Script

Factions are accessible to script through the get_faction_property() and set_faction_property() functions.

Get an faction property. The faction property functions accept a faction pointer and a property constant.

mixed x = get_faction_property(void <faction handle>, int <identifier>); 

Modify a faction property value. See the property list for details.

mixed x = <value>;

set_faction_property(void <faction handle>, int <identifier>, x);
ConstantTypeDescription
FACTION_PROPERTY_GROUP_DAMAGE_DIRECTIntegerDamage direct property. Bitwise with following constants.

openborconstant("FACTION_GROUP_NONE")
openborconstant("FACTION_GROUP_NEUTRAL")
openborconstant("FACTION_GROUP_DEFAULT")
openborconstant("FACTION_GROUP_NO_COPY")
openborconstant("FACTION_GROUP_TYPE_INCLUSIVE")
openborconstant("FACTION_GROUP_TYPE_EXCLUSIVE")
openborconstant("FACTION_GROUP_PLAYER_VERSES")
openborconstant("FACTION_GROUP_ALL_NORMAL")
openborconstant("FACTION_GROUP_A")openborconstant("FACTION_GROUP_Z")
FACTION_PROPERTY_GROUP_DAMAGE_INDIRECTIntegerDamage indirect property. Same constants as Damage Direct.
FACTION_PROPERTY_GROUP_HOSTILEIntegerHostile property. Same constants as Damage Direct.
FACTION_PROPERTY_GROUP_MEMBERIntegerMember property. Same constants as Damage Direct.
FACTION_PROPERTY_TYPE_DAMAGE_DIRECTIntegerType damage direct property. Accepts any type constant.
FACTION_PROPERTY_TYPE_DAMAGE_INDIRECTIntegerType damage indirect property. Accepts any type constant.
FACTION_PROPERTY_TYPE_HOSTILEIntegerType hostile property. Accepts any type constant.
ConstantTypeDescription

2 thoughts on “Faction”

Comments are closed.

Related Post