Bind

Bind post thumbnail image

Bind is a set of script accessible entity sub properties that “attach” one entity to another. In addition to position, it is also possible to bind an entity to another entity’s animations and animation frames. Binding is essential for most particle effects, grappling animations, multi-piece boss battles, or any other effect where one entity must overlay another in real time. It is important to note that entities do not bind other entities to themselves, they bind themselves to other entities.

It is logically impossible for an entity to bind itself to more than one target at a time, but there is nothing at all preventing an entity from being the target of multiple binds. This means that one entity might have several other entities binding themselves to it, while that entity may in turn be binding itself to another entity, and so on. Binding is accessible through the get_bind_property() and set_bind_property() functions.

Whenever active binds are present, the engine will execute the following event scripts on the bound entity and the binding target. You may use these to further refine binding control or perform other actions as necessary:

  • On bind update other to self script – Executed by the target of bind. Returns following local variables:
    • self – Pointer to entity executing script.
    • other – Pointer to entity binding itself to self.
    • bind – Pointer to bind property in use by other.
  • On bind update self to other script – Executed by entity currently binding itself. Returns following local variables:
    • self – Pointer to entity executing script.
    • other – Pointer to entity that self is binding to.
    • bind – Pointer to bind property in use by self.
Binding isn’t just for grapples. In this example, the transparent sword trail is a second entity synchronized with binding.

Script Access

Bind is a sub-property of Entity Properties. To access bind, you must first get the entity’s bind pointer. Once you have the bind property pointer, you may get and set bind properties at will.

Get a bind property value.

mixed x = get_bind_property(void <bind pointer>, int <property>);

Modify a bind property value.

mixed new_value = <value>

set_bind_property(void <bind pointer>, int <property>, new_value);

Property List

  • Constant: The openborconstant() used to access property.
  • Type: The property value’s variable type.
  • Description: A short description of what the property is and does.
NameTypeDescription
BIND_PROPERTY_ANIMATION_FRAMEIntegerFrame to match. Provide a frame for entity to bind itself to here. This property has no effect unless the config property is set to use it.
BIND_PROPERTY_ANIMATION_IDIntegerAnimation to match. Provide an animation constant for entity to bind itself to here. This property has no effect unless the config property is set to use it.
BIND_PROPERTY_CONFIGIntegerPrimary binding behaviors. Uses following bitmask constants:

* openborconstant("BIND_CONFIG_ANIMATION_DEFINED") – Attempt to match the animation id provided in animation_id property.

* openborconstant("BIND_CONFIG_ANIMATION_FRAME_DEFINED") – Attempt to match the animation_frame property.

* openborconstant("BIND_CONFIG_ANIMATION_FRAME_TARGET") – Attempt to match target’s current animation frame.

* openborconstant("BIND_CONFIG_ANIMATION_FRAME_REMOVE") – Entity is kills self if it is unable to match frames.

* openborconstant("BIND_CONFIG_ANIMATION_REMOVE") – Entity is killed if it is unable to match animations (i.e. doesn’t have the requested animation available).

* openborconstant("BIND_CONFIG_AXIS_X_LEVEL") – Bind X axis position to arbitrary location in level with offset.

* openborconstant("BIND_CONFIG_AXIS_X_TARGET") – Bind X axis position to target (if any) with offset.

* openborconstant("BIND_CONFIG_AXIS_Y_LEVEL") – Bind Y axis position to arbitrary location in level with offset.

* openborconstant("BIND_CONFIG_AXIS_Y_TARGET") – Bind Y axis position to target (if any) with offset.

* openborconstant("BIND_CONFIG_AXIS_Z_LEVEL") – Bind Z axis position to arbitrary location in level with offset.

* openborconstant("BIND_CONFIG_NONE") – No flags. Assign this directly (not as a bitmask) to reset all flags to 0.

* openborconstant("BIND_CONFIG_OVERRIDE_FALL_LAND") – When in a falling state, disable ground detection.

* openborconstant("BIND_CONFIG_OVERRIDE_DROPFRAME") – Disable dropframe.

* openborconstant("BIND_CONFIG_OVERRIDE_LANDFRAME") – Disable landframe.

* openborconstant("BIND_CONFIG_OVERRIDE_SPECIAL_AI") – Disable specials (when controlled by AI).

* openborconstant("BIND_CONFIG_OVERRIDE_SPECIAL_PLAYER") – Disable specials (when controlled by player).

Tip: Use override flags to resolve behavior conflicts when making custom slams or similar systems. One example is falling behavior during scripted slams when bound entities touch the ground. Native fall landing behaviors activate and ruin the grappling sequence. By using openborconstant("BIND_CONFIG_OVERRIDE_FALL_LAND") flag to disable falling behavior, the problem is eliminated without the need for tedious and potentially buggy workarounds.
BIND_PROPERTY_DIRECTION_ADJUSTIntegerDirectional binding behavior.

* openborconstant("DIRECTION_ADJUST_LEFT") – Always face left.

* openborconstant("DIRECTION_ADJUST_NONE") – No directional binding.

* openborconstant("DIRECTION_ADJUST_OPPOSITE") – Always opposite direction as target.

* openborconstant("DIRECTION_ADJUST_RIGHT") – Always face right.

* openborconstant("DIRECTION_ADJUST_SAME") – Always face same direction as target.
BIND_PROPERTY_META_TAGIntegerTags are attributes not used in any way by engine logic. Employ this to store your own custom information about a bind.
BIND_PROPERTY_OFFSET_XIntegerAdjust the final horizontal position. Positive values adjust toward direction target is facing, negative values adjust away. If not bound to an entity, higher values adjust rightward and vise versa.
BIND_PROPERTY_OFFSET_YIntegerAdjusts the final vertical position. Positive values adjust upward from target, negative values adjust downward.
BIND_PROPERTY_OFFSET_ZIntegerAdjusts the bind position in relation to target’s lateral position. Positive values adjust toward the camera from target, negative values adjust toward the background.
BIND_PROPERTY_SORT_IDIntegerDrawing sort adjustment in relation to target. Drawing order is determined by a combination of sort ID and position on the Z axis. Lower numbered items are drawn first, meaning that higher numbered items will appear over top of them. For example, if the target and entity are on the same Z axis, a value of -1 will place the entity one lower in drawing order compared to the target. The entity would therefore appear to be behind the target. If Z position and sorting ID are both identical, then drawing order will be whichever is updated first on each engine cycle, resulting in possible flicker back and forth.
BIND_PROPERTY_TARGETPointerThe target entity to bind to. If this attribute is empty or null, there is effectively no bind at all. The other attributes will continue to exist, but the engine will not conduct any binding logic.
NameTypeDescription

Legacy

Prior to OpenBOR 4.0, bind properties were not exposed. Binding control was accomplished with the bindentity() function. This function is still available and may be used in conjunction with bind property exposure, but is considered depreciated and will not receive further updates.

bindentity(bound entity, target, offset_x , offset_z, offset_y, direction, animation_match); – Sets up a bind. Unlisted properties receive the following values:

  • animation_frame: 0
  • animation_id: 0
  • config (flags enabled):
    • openborconstant("BIND_CONFIG_AXIS_X_TARGET")
    • openborconstant("BIND_CONFIG_AXIS_Y_TARGET")
    • openborconstant("BIND_CONFIG_AXIS_Z_TARGET")
  • sort_id: -1
  • tag: 0

bindentity(bound entity, NULL()); – Cancel a bind.

Related Post

FilestreamFilestream

Under Construction Filestreams allow CRUD (Create, Read, Update, Delete) operations on user defined files during gameplay. You can sue these to build databases and add persistence features to games.