![]() |
DI-Guy C++ SDK Reference
13.0
|
The class that represents a DI-Guy Crowd. More...
#include <diguyCrowd.h>
Public Member Functions | |
General Functions | |
Unless otherwise specified, callable from:
| |
| const char * | get_name () |
| Returns: name of this object; this value will never be NULL. More... | |
| int | set_name (const char *name) |
| This function sets the name of this object. More... | |
| const char * | get_ui_name () |
| Returns: UI name of this object; this value will never be NULL. More... | |
| int | set_ui_name (const char *ui_name) |
| This function sets the UI name of this object. More... | |
| const char * | get_type_name () |
| Returns the type name of the object. More... | |
| int | set_enabled (int enabled) |
| This function enables or disables the crowd. More... | |
| int | get_enabled () |
| Returns: 1 if enabled, 0 if not. More... | |
| void | set_all_members_enabled (int enabled) |
| This function enables or disables all agents in the crowd. More... | |
| float | get_awareness_radius () |
| Returns: The size of the radius around the crowd's character that certain callbacks will be triggered within. More... | |
| int | set_awareness_radius (float radius) |
| Sets the crowd awareness radius. More... | |
Crowd Member Functions | |
Unless otherwise specified, callable from:
| |
| int | add_member (diguyCharacter *character) |
| Adds the passed character to the crowd if not already in it. More... | |
| int | add_all_characters_in_group (diguyCharacterGroup *group) |
| Adds all characters of the group as members of the crowd. More... | |
| int | remove_member (diguyCharacter *character) |
| Removes the passed character from the crowd if it is a member. More... | |
| int | remove_all_members () |
| Removes all members of the crowd. More... | |
| int | is_member (diguyCharacter *character) |
| Returns: 1 if the passed character is a member of the crowd; 0 if not. More... | |
| int | get_num_members () |
| Returns: number of member characters in crowd. More... | |
| diguyCharacter * | get_member_at_index (int index) |
| Returns: crowd member at specified index; NULL if no character at specified index. More... | |
| int | get_index_of_member (diguyCharacter *member) |
| Returns: index of crowd member; -1 if not a member of the crowd. More... | |
| diguyCharacterGroup * | get_associated_group () |
| Returns: diguyCharacterGroup associated with the crowd. More... | |
Attack Functions | |
| int | agents_attack_character (const char *character_name) |
| This is a shortcut for calling diguyCharacter::agent_attack_character() for all members of the crowd. More... | |
| int | agents_attack_group (const char *group_name) |
| This is a shortcut for calling diguyCharacter::agent_attack_group() for all members of the crowd. More... | |
Flee Functions | |
| int | agents_flee_character (const char *character_name, float distance, int danger_level=50) |
| This is a shortcut for calling diguyCharacter::agent_flee_character() for all members of the crowd. More... | |
| int | agents_flee_group (const char *group_name, float distance, int danger_level=50) |
| This is a shortcut for calling diguyCharacter::agent_flee_group() for all members of the crowd. More... | |
| int | agents_flee_crowd (const char *crowd_name, float distance, int danger_level=50) |
| This is a shortcut for calling diguyCharacter::agent_flee_crowd() for all members of the crowd. More... | |
| int | agents_flee_location (float x, float y, float z, float distance, int danger_level=50) |
| This is a shortcut for calling diguyCharacter::agent_flee_location() for all members of the crowd. More... | |
| void | agents_remove_all_flee_objects () |
| This is a shortcut for calling diguyCharacter::agent_remove_all_flee_objects() for all members of the crowd. More... | |
Mingle Functions | |
| int | agents_mingle_in_region (const char *region_name=NULL, const char *subregion=NULL) |
| This is a shortcut for calling diguyCharacter::agent_mingle_in_region() for all members of the crowd. More... | |
Pursue Functions | |
| int | agents_pursue_character (const char *character_name) |
| This is a shortcut for calling diguyCharacter::agent_pursue_character() for all members of the crowd. More... | |
| int | agents_pursue_group (const char *group_name) |
| This is a shortcut for calling diguyCharacter::agent_pursue_group() for all members of the crowd. More... | |
| int | agents_chain_pursue (const char *leader_name) |
| This causes all members of the crowd to start pursuing the individual that is closer to the leader then they are. More... | |
Travel Functions | |
| int | agents_travel_behavior_path (const char *direction=NULL, const char *at_end=NULL, int waypoint_index=-1, float offset_y=0.5f) |
| This is a shortcut for calling diguyCharacter::agent_travel_behavior_path() for all members of the crowd. More... | |
| int | agents_travel_path_shape (const char *path_shape_name, const char *direction=NULL, const char *at_end=NULL, int waypoint_index=-1, float offset_y=0.5f) |
| This is a shortcut for calling diguyCharacter::agent_travel_path_shape() for all members of the crowd. More... | |
| int | agents_travel_region_border (const char *region_name, const char *subregion=NULL) |
| This is a shortcut for calling diguyCharacter::agent_travel_region_border() for all members of the crowd. More... | |
Wander Functions | |
| int | agents_wander_region (const char *region_name=NULL, const char *subregion=NULL) |
| This is a shortcut for calling diguyCharacter::agent_wander_region() for all members of the crowd. More... | |
Other Behavior Functions | |
| int | agents_stop_behavior () |
| This is a shortcut for calling diguyCharacter::agent_stop_behavior() for all members of the crowd. More... | |
| int | set_current_behavior (const char *behavior_name) |
| This is a shortcut for calling diguyCharacter::set_current_behavior() for all members of the crowd. More... | |
| const char * | get_current_behavior (int member_index=0) |
| Returns the current behavior used by crowd, expressed as a string (e.g. More... | |
| int | set_current_behavior_path_shape (const char *behavior_path_shape_name, float max_time_until_move_on=0.0f) |
| Similar to diguyAgentParams::set_behavior_path_shape(). More... | |
| int | set_current_behavior_region (const char *behavior_region_name, const char *subregion=NULL, float max_time_until_move_on=0.0f) |
| Similar to diguyAgentParams::set_behavior_region(). More... | |
| int | set_current_focus_character (const char *focus_character_name) |
| Similar to diguyAgentParams::set_focus_character(). More... | |
| int | set_current_focus_group (const char *focus_group_name) |
| Similar to diguyAgentParams::set_focus_group(). More... | |
| int | set_current_params_from_profile (const char *profile_name, int retain_focus_objects=1, int retain_navigation_values=1) |
| This is a shortcut for calling diguyCharacter::agent_set_current_params_from_profile() for all members of the crowd. More... | |
| void | set_current_behavior_region_border_is_solid (int is_solid) |
| This is a shortcut for calling diguyCharacter::agent_set_current_behavior_region_border_is_solid() for all members of the crowd. More... | |
| void | set_current_postures (diguyMotionPosture posture) |
| Sets the posture of all members of the crowd and restarts their behaviors. More... | |
| void | set_current_variants (diguyMotionVariant variant) |
| Sets the variant of all members of the crowd and restarts their behaviors. More... | |
| int | set_initial_params_from_profile (const char *profile_name) |
| This function is similar to set_current_params_from_profile(), but instead sets initial params. More... | |
Query Functions | |
| int | is_current_behavior (const char *behavior_name, float threshold=0.5f) |
| This is a query function meant to allow for flexible behavior when dealing with a crowd. More... | |
| int | is_current_behavior_and_focus_character (const char *behavior_name, const char *focus_character_name, float threshold=0.5f) |
| Similar to is_current_behavior(), but checks both behavior and focus character. More... | |
| int | is_current_behavior_and_focus_group (const char *behavior_name, const char *group_name, float threshold=0.5f) |
| Similar to is_current_behavior(), but checks both behavior and focus group. More... | |
| int | is_crowd_dead (float threshold=0.5f) |
| Similar to is_current_behavior(), but checks whether characters are dead. More... | |
Companion Crowd Functions | |
| int | add_companion_crowd (diguyCrowd *companion_crowd) |
| This function makes the specified crowd a "companion crowd" of this crowd. More... | |
| int | remove_companion_crowd (diguyCrowd *companion_crowd) |
| This function removes the specified crowd as a companion crowd. More... | |
Avoidance Method Functions | |
Unless otherwise specified, callable from:
| |
| void | set_dynamic_object_avoidance_method (diguyDynamicAvoidanceMethod method) |
| This function sets the dynamic avoidance method that members of this crowd will use to avoid each other. More... | |
| diguyDynamicAvoidanceMethod | get_dynamic_object_avoidance_method () |
| Returns: current dynamic object avoidance method; see set_dynamic_object_avoidance_method() More... | |
| void | set_static_object_avoidance_method (diguyStaticAvoidanceMethod method) |
| This function sets the static avoidance method that members of this crowd will use to avoid walking through fixed walls and objects. More... | |
| diguyStaticAvoidanceMethod | get_static_object_avoidance_method () |
| Returns: current static object avoidance method; see set_static_object_avoidance_method() More... | |
Event Handler Functions | |
Unless otherwise specified, callable from:
| |
| int | map_event_handler_to_callback_id (int callback_id, const char *handler_name) |
| This function maps the event handler with the given name to a callback id. More... | |
| int | unmap_event_handler_from_callback_id (int callback_id, const char *handler_name, int unmap_all_matches=0) |
| This function unmaps the event handler with the given name from a callback id. More... | |
Region Functions | |
Unless otherwise specified, callable from:
| |
| diguyRegion * | find_or_create_region () |
| Returns: diguyRegion associated with the crowd; will be created if it doesn't currently exist. More... | |
| diguyRegion * | get_region () |
| Returns: diguyRegion associated with the crowd; may be NULL. More... | |
Message Functions | |
Unless otherwise specified, callable from:
| |
| void | send_message_to_all_members (const char *message_type, const char *message, const char *message_params=NULL) |
| Equivalent to calling diguyCharacter::agent_accept_message() for all members of the crowd. More... | |
Unit Functions | |
| void | set_unit_type (diguyTacticsUnitType tut) |
| Extra metadata for use by end users. More... | |
| diguyTacticsUnitType | get_unit_type () |
| int | set_unit_leader (diguyCharacter *leader) |
| Extra metadata for use by end users. More... | |
| diguyCharacter * | get_unit_leader () |
Callback Functions | |
Unless otherwise specified, callable from:
| |
| enum | { CALLBACK_ID_CREATE = 1, CALLBACK_ID_DESTROY, CALLBACK_ID_CROWD_MEMBER_KILLED, CALLBACK_ID_CROWD_MEMBER_IMPACT, CALLBACK_ID_NEARBY_SCENE_OBJECT_IMPACT, CALLBACK_ID_NEARBY_WEAPON_FIRED } |
| This is an enumeration of the different callbacks that can be registered with add_callback() and add_callback_script(). More... | |
| diguyCharacter * | get_callback_character () |
| Many of the diguyCrowd callbacks set a callback character which represents if there was a particular character that the callback relates to. More... | |
| diguyImpact * | get_callback_impact () |
| Many of the diguyCrowd callbacks set a callback impact which represents if there was impact that the callback relates to. More... | |
| int | add_callback (int callback_id, diguyCrowdCallback *callback, void *callback_params=0, void *callback_user_data=0) |
| This function adds a user callback. More... | |
| int | remove_callback (int callback_id, diguyCrowdCallback *callback) |
| This function removes a user callback. More... | |
| int | remove_callback_with_user_data (int callback_id, void *callback_user_data) |
| This function removes a user callback. More... | |
| int | add_callback_script (int callback_id, const char *callback_script, const char *callback_script_type=NULL) |
| This function adds a user callback script. More... | |
| int | remove_callback_script (int callback_id, const char *callback_script, const char *callback_script_type=NULL) |
| This function removes a user callback script previously added with add_callback_script(). More... | |
| void | all_members_add_character_callback (int callback_id, diguyCharacterCallback *callback, void *callback_params=NULL, void *callback_user_data=NULL) |
| Equivalent to calling diguyCharacter::add_callback() for all members of the crowd. More... | |
| void | all_members_remove_character_callback (int callback_id, diguyCharacterCallback *callback) |
| Equivalent to calling diguyCharacter::remove_callback() for all members of the crowd. More... | |
| void | all_members_remove_character_callback_with_user_data (int callback_id, void *callback_user_data) |
| Equivalent to calling diguyCharacter::remove_callback_with_user_data() for all members of the crowd. More... | |
| void | all_members_add_character_callback_script (int callback_id, const char *callback_script, const char *callback_script_type=NULL) |
| Equivalent to calling diguyCharacter::add_callback_script() for all members of the crowd. More... | |
| void | all_members_remove_character_callback_script (int callback_id, const char *callback_script, const char *callback_script_type=NULL) |
| Equivalent to calling diguyCharacter::remove_callback_script() for all members of the crowd. More... | |
Private Functions | |
The functions and variables past this point are for internal use only. No external access to them is expected or necessary. | |
| bdiScenarioCrowd * | m_scripted_object |
| A pointer to internal data. More... | |
| class | bdiScenarioCrowd |
| bdiScenarioCrowd * | get_scripted_object () |
| diguyCrowd (bdiScenarioCrowd *scripted_object) | |
| A private constructor. More... | |
| virtual | ~diguyCrowd () |
| A private destructor. More... | |
The class that represents a DI-Guy Crowd.
| anonymous enum |
This is an enumeration of the different callbacks that can be registered with add_callback() and add_callback_script().
CALLBACK_ID_CREATE
This callback will be called when a new crowd is created. Note that this callback can only be added by calling diguyScenario::add_default_crowd_callback(); adding it with diguyCrowd::add_callback() will have no effect, as by that time the crowd has already been created. There is no associated callback character.
CALLBACK_ID_DESTROY
This callback will be called when a crowd is destroyed. There is no associated callback character.
CALLBACK_ID_CROWD_MEMBER_KILLED
This callback will be called when a member of the crowd is killed. - The callback character is the crowd member that was killed. - The callback impact contains the impact information.
CALLBACK_ID_CROWD_MEMBER_IMPACT
Similar to diguyCharacter::CALLBACK_ID_IMPACT, this callback will be called when a member of the crowd is hit by a detonation. If this callback isn't present the impacted character automatically will die. Handling this callback allows for the implementation of custom damage models at a crowd level. - The callback character is the crowd member that was hit. - The callback impact contains the impact information.
CALLBACK_ID_NEARBY_SCENE_OBJECT_IMPACT
This callback will be called when a detonation occurs within the
awareness radius (as set by set_awareness_radius()) of the
crowd's current bounds.
- The callback character is the character that caused the
detonation.
- The callback impact contains the impact information.
CALLBACK_ID_NEARBY_WEAPON_FIRED
This callback will be called when a weapon is fired within the awareness radius (as set by set_awareness_radius()) of the crowd's current bounds. - The callback character is the character that fired the weapon.
Callbacks return a value of type diguyCallbackReturn, which will be DIGUY_CALLBACK_STOP or DIGUY_CALLBACK_CONTINUE. If the callback returns DIGUY_CALLBACK_STOP, the default handler of the function will not be called; the callback is asserting that it has done everything necessary for the function call. If the callback returns DIGUY_CALLBACK_CONTINUE, the default handler for the function will be called after the callback.
Usable From:
| Enumerator | |
|---|---|
| CALLBACK_ID_CREATE | |
| CALLBACK_ID_DESTROY | |
| CALLBACK_ID_CROWD_MEMBER_KILLED | |
| CALLBACK_ID_CROWD_MEMBER_IMPACT | |
| CALLBACK_ID_NEARBY_SCENE_OBJECT_IMPACT | |
| CALLBACK_ID_NEARBY_WEAPON_FIRED | |
|
private |
A private constructor.
|
privatevirtual |
A private destructor.
| const char* diguyCrowd::get_name | ( | ) |
Returns: name of this object; this value will never be NULL.
| int diguyCrowd::set_name | ( | const char * | name | ) |
This function sets the name of this object.
Returns:
0 on success, -1 on failure
| const char* diguyCrowd::get_ui_name | ( | ) |
Returns: UI name of this object; this value will never be NULL.
| int diguyCrowd::set_ui_name | ( | const char * | ui_name | ) |
This function sets the UI name of this object.
The UI name is what shows up in user interface windows that show information about this crowd.
For example, the crowd name may be "crowd_squad1", the UI name may be "Squad 1".
By default the UI name matches the internal name.
Returns:
0 on success, -1 on failure
| const char* diguyCrowd::get_type_name | ( | ) |
Returns the type name of the object.
This pointer will never be NULL.
Returns:
type name of the object
| int diguyCrowd::set_enabled | ( | int | enabled | ) |
This function enables or disables the crowd.
Disabling a crowd does not disable or hide the members of the crowd. It does turn off any effects the crowd may have on agent actions, position, orientation, etc. To enable or disable all agents in the crowd, use set_all_members_enabled() instead.
Disabled crowds also will not interact with companion crowds.
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| int diguyCrowd::get_enabled | ( | ) |
Returns: 1 if enabled, 0 if not.
Available as Decision Bead/Event
| void diguyCrowd::set_all_members_enabled | ( | int | enabled | ) |
This function enables or disables all agents in the crowd.
This is the equivalent to calling diguyCharacter::set_enabled() for all members of the crowd.
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| float diguyCrowd::get_awareness_radius | ( | ) |
Returns: The size of the radius around the crowd's character that certain callbacks will be triggered within.
Callbacks such as: CALLBACK_ID_NEARBY_SCENE_OBJECT_IMPACT, and CALLBACK_ID_NEARBY_WEAPON_FIRED, are affected by this value.
| int diguyCrowd::set_awareness_radius | ( | float | radius | ) |
| int diguyCrowd::add_member | ( | diguyCharacter * | character | ) |
Adds the passed character to the crowd if not already in it.
Returns:
0 if the character is now a part of the crowd; -1 if not
| int diguyCrowd::add_all_characters_in_group | ( | diguyCharacterGroup * | group | ) |
Adds all characters of the group as members of the crowd.
Returns:
Always return 0.
| int diguyCrowd::remove_member | ( | diguyCharacter * | character | ) |
Removes the passed character from the crowd if it is a member.
Returns:
0 if the character was part of the crowd and removed; -1 if not
| int diguyCrowd::remove_all_members | ( | ) |
Removes all members of the crowd.
Returns:
Always return 0.
| int diguyCrowd::is_member | ( | diguyCharacter * | character | ) |
Returns: 1 if the passed character is a member of the crowd; 0 if not.
| int diguyCrowd::get_num_members | ( | ) |
Returns: number of member characters in crowd.
| diguyCharacter* diguyCrowd::get_member_at_index | ( | int | index | ) |
Returns: crowd member at specified index; NULL if no character at specified index.
| int diguyCrowd::get_index_of_member | ( | diguyCharacter * | member | ) |
Returns: index of crowd member; -1 if not a member of the crowd.
| diguyCharacterGroup* diguyCrowd::get_associated_group | ( | ) |
Returns: diguyCharacterGroup associated with the crowd.
| int diguyCrowd::agents_attack_character | ( | const char * | character_name | ) |
This is a shortcut for calling diguyCharacter::agent_attack_character() for all members of the crowd.
This function will implicitly put agents into the attack behavior.
The current focus character will be set the specified character. Pass NULL or the empty string ("") to not change the focus character, but still change to the pursue behavior.
The current focus group will be un-set.
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| int diguyCrowd::agents_attack_group | ( | const char * | group_name | ) |
This is a shortcut for calling diguyCharacter::agent_attack_group() for all members of the crowd.
This function will implicitly put agents into the attack behavior.
The current focus group will be set the specified group. Pass NULL or the empty string ("") to not change the focus group, but still change to the pursue behavior.
The current focus character will be un-set.
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| int diguyCrowd::agents_flee_character | ( | const char * | character_name, |
| float | distance, | ||
| int | danger_level = 50 |
||
| ) |
This is a shortcut for calling diguyCharacter::agent_flee_character() for all members of the crowd.
This function will implicitly put agents into the flee behavior.
Neither the current focus character nor group will be changed by this function.
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| int diguyCrowd::agents_flee_group | ( | const char * | group_name, |
| float | distance, | ||
| int | danger_level = 50 |
||
| ) |
This is a shortcut for calling diguyCharacter::agent_flee_group() for all members of the crowd.
This function will implicitly put agents into the flee behavior.
Neither the current focus character nor group will be changed by this function.
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| int diguyCrowd::agents_flee_crowd | ( | const char * | crowd_name, |
| float | distance, | ||
| int | danger_level = 50 |
||
| ) |
This is a shortcut for calling diguyCharacter::agent_flee_crowd() for all members of the crowd.
This function will implicitly put agents into the flee behavior.
Neither the current focus character nor group will be changed by this function.
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| int diguyCrowd::agents_flee_location | ( | float | x, |
| float | y, | ||
| float | z, | ||
| float | distance, | ||
| int | danger_level = 50 |
||
| ) |
This is a shortcut for calling diguyCharacter::agent_flee_location() for all members of the crowd.
This function will implicitly put agents into the flee behavior.
Neither the current focus character nor group will be changed by this function.
Returns:
0 on success, -1 on failure
| void diguyCrowd::agents_remove_all_flee_objects | ( | ) |
This is a shortcut for calling diguyCharacter::agent_remove_all_flee_objects() for all members of the crowd.
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| int diguyCrowd::agents_mingle_in_region | ( | const char * | region_name = NULL, |
| const char * | subregion = NULL |
||
| ) |
This is a shortcut for calling diguyCharacter::agent_mingle_in_region() for all members of the crowd.
This function will implicitly put agents into the mingle behavior.
Neither the current focus character nor group will be changed by this function.
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| int diguyCrowd::agents_pursue_character | ( | const char * | character_name | ) |
This is a shortcut for calling diguyCharacter::agent_pursue_character() for all members of the crowd.
This function will implicitly put agents into the pursue behavior.
The current focus character will be set the specified character. Pass NULL or the empty string ("") to not change the focus character, but still change to the pursue behavior.
The current focus group will be un-set.
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| int diguyCrowd::agents_pursue_group | ( | const char * | group_name | ) |
This is a shortcut for calling diguyCharacter::agent_pursue_group() for all members of the crowd.
This function will implicitly put agents into the pursue behavior.
The current focus group will be set to the specified group. Pass NULL or the empty string ("") to not change the focus group, but still change to the pursue behavior.
The current focus character will be un-set.
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| int diguyCrowd::agents_chain_pursue | ( | const char * | leader_name | ) |
This causes all members of the crowd to start pursuing the individual that is closer to the leader then they are.
This function will implicitly put all agents except the leader into the pursue behavior.
The current focus character will be set to the next nearest character.
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| int diguyCrowd::agents_travel_behavior_path | ( | const char * | direction = NULL, |
| const char * | at_end = NULL, |
||
| int | waypoint_index = -1, |
||
| float | offset_y = 0.5f |
||
| ) |
This is a shortcut for calling diguyCharacter::agent_travel_behavior_path() for all members of the crowd.
This function will implicitly put agents into the travel behavior.
Neither the current focus character nor group will be changed by this function.
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| int diguyCrowd::agents_travel_path_shape | ( | const char * | path_shape_name, |
| const char * | direction = NULL, |
||
| const char * | at_end = NULL, |
||
| int | waypoint_index = -1, |
||
| float | offset_y = 0.5f |
||
| ) |
This is a shortcut for calling diguyCharacter::agent_travel_path_shape() for all members of the crowd.
This function will implicitly put agents into the travel behavior.
Neither the current focus character nor group will be changed by this function.
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| int diguyCrowd::agents_travel_region_border | ( | const char * | region_name, |
| const char * | subregion = NULL |
||
| ) |
This is a shortcut for calling diguyCharacter::agent_travel_region_border() for all members of the crowd.
This function will implicitly put agents into the travel behavior.
Neither the current focus character nor group will be changed by this function.
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| int diguyCrowd::agents_wander_region | ( | const char * | region_name = NULL, |
| const char * | subregion = NULL |
||
| ) |
This is a shortcut for calling diguyCharacter::agent_wander_region() for all members of the crowd.
This function will implicitly put agents into the wander behavior.
Neither the current focus character nor group will be changed by this function.
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| int diguyCrowd::agents_stop_behavior | ( | ) |
This is a shortcut for calling diguyCharacter::agent_stop_behavior() for all members of the crowd.
This function will implicitly put agents into the none behavior.
Neither the current focus character nor group will be changed by this function.
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| int diguyCrowd::set_current_behavior | ( | const char * | behavior_name | ) |
This is a shortcut for calling diguyCharacter::set_current_behavior() for all members of the crowd.
It's recommended that one of the higher level functions above that set behavior, for example agent_wander_region(), is used. These functions allow for setting the most common parameters that affect the behavior in one function call.
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| const char* diguyCrowd::get_current_behavior | ( | int | member_index = 0 | ) |
Returns the current behavior used by crowd, expressed as a string (e.g.
"travel").
Returns:
string describing current crowd behavior, NULL on error
| int diguyCrowd::set_current_behavior_path_shape | ( | const char * | behavior_path_shape_name, |
| float | max_time_until_move_on = 0.0f |
||
| ) |
Similar to diguyAgentParams::set_behavior_path_shape().
This is a shortcut for setting the current behavior path shape for all characters in the crowd.
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| int diguyCrowd::set_current_behavior_region | ( | const char * | behavior_region_name, |
| const char * | subregion = NULL, |
||
| float | max_time_until_move_on = 0.0f |
||
| ) |
Similar to diguyAgentParams::set_behavior_region().
This is a shortcut for setting the current behavior region for all characters in the crowd.
This function does take an additional argument, max_time_until_move_on. Setting this to 0 will cause all agents that occasionally pause their movement (for example, characters in the wander behavior) to move on to the new behavior region immediately. Passing a higher number will allow agents to finish their "natural" wait interval before moving on to the new region.
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| int diguyCrowd::set_current_focus_character | ( | const char * | focus_character_name | ) |
Similar to diguyAgentParams::set_focus_character().
This is a shortcut for setting the current focus character for all characters in the crowd.
The current focus group will not be affected by this function.
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| int diguyCrowd::set_current_focus_group | ( | const char * | focus_group_name | ) |
Similar to diguyAgentParams::set_focus_group().
This is a shortcut for setting the current focus group for all characters in the crowd.
The current focus character will not be affected by this function.
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| int diguyCrowd::set_current_params_from_profile | ( | const char * | profile_name, |
| int | retain_focus_objects = 1, |
||
| int | retain_navigation_values = 1 |
||
| ) |
This is a shortcut for calling diguyCharacter::agent_set_current_params_from_profile() for all members of the crowd.
This will affect most of the parameters of agents in this crowd, including behavior, posture and variant, etc. Focus character and group by default are changed, but can be left alone by passing 0 for retain_focus_objects.
| profile_name | name of crowd profile whose default parameters should be used |
| retain_focus_objects | pass 1 to change focus objects to those of the named profile, 0 to retain existing settings |
| retain_navigation_values | keeps path_shape, region, subregion, path planner cost values and rules the same |
Returns:
0 on success, -1 on failure
Available as Decision Bead/Event
| void diguyCrowd::set_current_behavior_region_border_is_solid | ( | int | is_solid | ) |
This is a shortcut for calling diguyCharacter::agent_set_current_behavior_region_border_is_solid() for all members of the crowd.
Sets whether the walls of the region the agent is in are solid. If they are, the agent will treat the walls as if they are solid walls in the environment. If not, the agent is free to walk through them.
Pass 1 to make border walls solid, 0 to make them freely passable.
Available as Decision Bead/Event
| void diguyCrowd::set_current_postures | ( | diguyMotionPosture | posture | ) |
Sets the posture of all members of the crowd and restarts their behaviors.
| void diguyCrowd::set_current_variants | ( | diguyMotionVariant | variant | ) |
Sets the variant of all members of the crowd and restarts their behaviors.
| int diguyCrowd::set_initial_params_from_profile | ( | const char * | profile_name | ) |
This function is similar to set_current_params_from_profile(), but instead sets initial params.
| profile_name | name of crowd profile whose default parameters should be used |
Returns:
0 on success, -1 on failure
| int diguyCrowd::is_current_behavior | ( | const char * | behavior_name, |
| float | threshold = 0.5f |
||
| ) |
This is a query function meant to allow for flexible behavior when dealing with a crowd.
If more than threshold ratio are doing behavior_name then the function will return 1. The default 0.5 yields a simple majority check.
Returns:
1 if true, 0 if false
Available as Decision Bead/Event
| int diguyCrowd::is_current_behavior_and_focus_character | ( | const char * | behavior_name, |
| const char * | focus_character_name, | ||
| float | threshold = 0.5f |
||
| ) |
Similar to is_current_behavior(), but checks both behavior and focus character.
| int diguyCrowd::is_current_behavior_and_focus_group | ( | const char * | behavior_name, |
| const char * | group_name, | ||
| float | threshold = 0.5f |
||
| ) |
Similar to is_current_behavior(), but checks both behavior and focus group.
| int diguyCrowd::is_crowd_dead | ( | float | threshold = 0.5f | ) |
Similar to is_current_behavior(), but checks whether characters are dead.
| int diguyCrowd::add_companion_crowd | ( | diguyCrowd * | companion_crowd | ) |
This function makes the specified crowd a "companion crowd" of this crowd.
Crowd members of companion crowds know about each other and will attempt to avoid each other.
If two crowds are not companions, their respective crowd members will make no attempt to avoid each other.
| companion_crowd | name of crowd to become a companion |
Returns:
0 on success, -1 on failure
| int diguyCrowd::remove_companion_crowd | ( | diguyCrowd * | companion_crowd | ) |
This function removes the specified crowd as a companion crowd.
| companion_crowd | name of former companion |
Returns:
0 on success, -1 on failure
| void diguyCrowd::set_dynamic_object_avoidance_method | ( | diguyDynamicAvoidanceMethod | method | ) |
This function sets the dynamic avoidance method that members of this crowd will use to avoid each other.
Dynamic objects are objects that are moving around; these are almost always characters.
The enumeration is defined in diguy_constants.h.
| method | avoidance method to use |
Returns:
0 on success, -1 on failure
| diguyDynamicAvoidanceMethod diguyCrowd::get_dynamic_object_avoidance_method | ( | ) |
Returns: current dynamic object avoidance method; see set_dynamic_object_avoidance_method()
| void diguyCrowd::set_static_object_avoidance_method | ( | diguyStaticAvoidanceMethod | method | ) |
This function sets the static avoidance method that members of this crowd will use to avoid walking through fixed walls and objects.
Usually these are scene objects and fixed props.
The enumeration is defined in diguy_constants.h.
| method | avoidance method to use |
Returns:
0 on success, -1 on failure
| diguyStaticAvoidanceMethod diguyCrowd::get_static_object_avoidance_method | ( | ) |
Returns: current static object avoidance method; see set_static_object_avoidance_method()
| diguyCharacter* diguyCrowd::get_callback_character | ( | ) |
Many of the diguyCrowd callbacks set a callback character which represents if there was a particular character that the callback relates to.
A few of the callbacks do not set this value.
Returns:
pointer of type diguyCharacter; NULL if there was no associated character
| diguyImpact* diguyCrowd::get_callback_impact | ( | ) |
Many of the diguyCrowd callbacks set a callback impact which represents if there was impact that the callback relates to.
A few of the callbacks do not set this value.
Returns:
pointer of type diguyImpact; NULL if there was no associated impact
| int diguyCrowd::add_callback | ( | int | callback_id, |
| diguyCrowdCallback * | callback, | ||
| void * | callback_params = 0, |
||
| void * | callback_user_data = 0 |
||
| ) |
This function adds a user callback.
Callbacks can be removed with remove_callback() or remove_callback_with_user_data().
| callback | pointer to function with prototype diguyCrowdRegionCallback (typedefed above) |
| callback_id | integer id of when this callback is to be called |
| callback_params | not currently used; pass NULL |
| callback_user_data | pointer for user's own use; DI-Guy will do nothing to the contents of this pointer beyond passing it back when the callback is invoked |
Returns:
0 on success, -1 on failure
Callable From:
| int diguyCrowd::remove_callback | ( | int | callback_id, |
| diguyCrowdCallback * | callback | ||
| ) |
This function removes a user callback.
All callbacks matching the specified callback_id and callback function will be removed.
| callback_id | integer id of when this callback is to be called |
| callback | pointer to function with prototype diguyCrowdCallback (typedefed above) |
Returns:
0 on success, -1 on failure
| int diguyCrowd::remove_callback_with_user_data | ( | int | callback_id, |
| void * | callback_user_data | ||
| ) |
This function removes a user callback.
All callbacks matching the specified callback_id and callback_user_data pointer will be removed.
| callback_id | integer id of when this callback is to be called |
| callback_user_data | pointer for user's own use |
Returns:
0 on success, -1 on failure
| int diguyCrowd::add_callback_script | ( | int | callback_id, |
| const char * | callback_script, | ||
| const char * | callback_script_type = NULL |
||
| ) |
This function adds a user callback script.
Callback scripts can be removed with remove_callback_script().
See diguyCharacter::add_callback_script() for an example of use.
| callback_id | integer id of the callback |
| callback_script | script text of callback to be added |
| callback_script_type | the type of script contained in callback_script |
If NULL is passed for callback_script_type, a default script type will be derived based on the default script interpreter of the scenario.
lua specific:
When the script is called, the object for which it is being called will be in the callback_object global.
To pass NULL when calling from a lua script, use nil.
Returns:
0 on success, -1 on failure
| int diguyCrowd::remove_callback_script | ( | int | callback_id, |
| const char * | callback_script, | ||
| const char * | callback_script_type = NULL |
||
| ) |
This function removes a user callback script previously added with add_callback_script().
See diguyCharacter::remove_callback_script() for an example of use.
| callback_id | integer id of the callback |
| callback_script | script text of callback previously added |
| callback_script_type | the type of script contained in callback_script |
If NULL is passed for callback_script, all callback scripts whose ids match callback_id and whose types match callback_script_type will be removed.
If NULL is passed for callback_script_type, a default script type will be derived based on the default script interpreter of the scenario.
lua specific:
To pass NULL when calling from a lua script, use nil.
Returns:
0 on success, -1 on failure
| void diguyCrowd::all_members_add_character_callback | ( | int | callback_id, |
| diguyCharacterCallback * | callback, | ||
| void * | callback_params = NULL, |
||
| void * | callback_user_data = NULL |
||
| ) |
Equivalent to calling diguyCharacter::add_callback() for all members of the crowd.
Note: callback_id should be a diguyCharacter id, not a diguyCrowd id.
Callable From:
| void diguyCrowd::all_members_remove_character_callback | ( | int | callback_id, |
| diguyCharacterCallback * | callback | ||
| ) |
Equivalent to calling diguyCharacter::remove_callback() for all members of the crowd.
Note: callback_id should be a diguyCharacter id, not a diguyCrowd id.
Callable From:
| void diguyCrowd::all_members_remove_character_callback_with_user_data | ( | int | callback_id, |
| void * | callback_user_data | ||
| ) |
Equivalent to calling diguyCharacter::remove_callback_with_user_data() for all members of the crowd.
Note: callback_id should be a diguyCharacter id, not a diguyCrowd id.
Callable From:
| void diguyCrowd::all_members_add_character_callback_script | ( | int | callback_id, |
| const char * | callback_script, | ||
| const char * | callback_script_type = NULL |
||
| ) |
Equivalent to calling diguyCharacter::add_callback_script() for all members of the crowd.
Note: callback_id should be a diguyCharacter id, not a diguyCrowd id.
| void diguyCrowd::all_members_remove_character_callback_script | ( | int | callback_id, |
| const char * | callback_script, | ||
| const char * | callback_script_type = NULL |
||
| ) |
Equivalent to calling diguyCharacter::remove_callback_script() for all members of the crowd.
Note: callback_id should be a diguyCharacter id, not a diguyCrowd id.
| int diguyCrowd::map_event_handler_to_callback_id | ( | int | callback_id, |
| const char * | handler_name | ||
| ) |
This function maps the event handler with the given name to a callback id.
This mapping will be saved in the .dss file and restored when the .dss file is loaded.
Mappings can also be made via the DI-Guy Scenario UI.
The event handler is one of the following:
| callback_id | integer id of callback |
| handler_name | name of the event handler to map |
Returns:
0 on success, -1 on failure
| int diguyCrowd::unmap_event_handler_from_callback_id | ( | int | callback_id, |
| const char * | handler_name, | ||
| int | unmap_all_matches = 0 |
||
| ) |
This function unmaps the event handler with the given name from a callback id.
| callback_id | integer id of callback |
| handler_name | name of the event handler to map |
| unmap_all_matches | pass 0 to unmap only the first match, pass 1 to unmap all matches |
Returns:
0 on success, -1 on failure
| diguyRegion* diguyCrowd::find_or_create_region | ( | ) |
Returns: diguyRegion associated with the crowd; will be created if it doesn't currently exist.
| diguyRegion* diguyCrowd::get_region | ( | ) |
Returns: diguyRegion associated with the crowd; may be NULL.
| void diguyCrowd::send_message_to_all_members | ( | const char * | message_type, |
| const char * | message, | ||
| const char * | message_params = NULL |
||
| ) |
Equivalent to calling diguyCharacter::agent_accept_message() for all members of the crowd.
| message_type | what type of message is being sent |
| message | the message string |
| message_params | optional parameter string |
| void diguyCrowd::set_unit_type | ( | diguyTacticsUnitType | tut | ) |
Extra metadata for use by end users.
| diguyTacticsUnitType diguyCrowd::get_unit_type | ( | ) |
| int diguyCrowd::set_unit_leader | ( | diguyCharacter * | leader | ) |
Extra metadata for use by end users.
| diguyCharacter* diguyCrowd::get_unit_leader | ( | ) |
|
inline |
|
friend |
|
private |
A pointer to internal data.