The new engine has a built in faction system specifically for these sorts of cases. It's coming before years end, so if you can hold out just a bit longer, that might be the solution you are looking for. Here's a little sneak preview of how it works:
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
Member
Wiki:
faction_member <factions>
Default: faction_member a
Factions entity is a member of. Accepts one more of the following:
- a … z – 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
Wiki:
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.
- a … z – 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
Wiki:
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.
- a … z – 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
Wiki:
faction_hostile <factions>
Default: faction_hostile a type_inclusive
Factions entity is hostile toward. Accepts one or more of the following.
- a … z – 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.
Wiki:
end_level, enemy, item, none, npc, obstacle, panel, player, projectile, shot, steamer, text_box, trap
Type Damage Direct
Wiki:
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.
Type Damage Indirect
Wiki:
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.
Type Hostile
Wiki:
faction_type_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.
Wiki:
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.
Wiki:
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.
Wiki:
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 a faction property. The faction property functions accept a faction pointer and a property constant.
C:
mixed x = get_faction_property(void <faction handle>, int <identifier>);
Modify a faction property value. See the property list for details.
C:
mixed x = <value>;
set_faction_property(void <faction handle>, int <identifier>, x);
Constant | Type | Description |
---|
FACTION_PROPERTY_GROUP_DAMAGE_DIRECT | Integer | Damage 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_INDIRECT | Integer | Damage indirect property. Same constants as Damage Direct. |
FACTION_PROPERTY_GROUP_HOSTILE | Integer | Hostile property. Same constants as Damage Direct. |
FACTION_PROPERTY_GROUP_MEMBER | Integer | Member property. Same constants as Damage Direct. |
FACTION_PROPERTY_TYPE_DAMAGE_DIRECT | Integer | Type damage direct property. Accepts any type constant. |
FACTION_PROPERTY_TYPE_DAMAGE_INDIRECT | Integer | Type damage indirect property. Accepts any type constant. |
FACTION_PROPERTY_TYPE_HOSTILE | Integer | Type hostile property. Accepts any type constant. |
HTH,
DC