DI-Guy SDK Documentation  13.8
diguyCrowd.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2024 MAK Technologies, Inc.
3  * All rights reserved.
4  ****************************************************************************/
5 
6 /*********************************************************************
7  **
8  *t diguyCrowd
9  **
10  */
11 
12 #pragma once
13 
14 #ifdef SWIG
15 %module diguyCrowd
16 #else
17 #define CPLUSPLUS_ONLY
18 #endif
19 
20 #ifdef CPLUSPLUS_ONLY
21 
22 #include <diguyMotionSpeedType.h>
23 #include <diguyMotionPosture.h>
24 #include <diguyMotionVariant.h>
25 
26 #include <diguy_typedefs.h> // for diguyCharacterCallback diguyCrowdCallback
27 
28 class bdiScenarioCrowd;
29 class diguyCharacter;
31 class diguyCrowd;
32 class diguyImpact;
33 class diguyPathShape;
34 class diguyRegion;
36 class DtAggregateStateRepository;
37 
38 
39 #endif
40 
41 #include <declspec_diguy.h>
42 
43 #include <stddef.h>
44 
51 class BDI_DECLSPEC_diguy diguyCrowd
52 {
53 /*****************************************************************************/
63 public:
64 
65  /*l
66  *b Returns:
67  **
68  ** name of this object; this value will never be NULL
69  */
70  const char* get_name();
71 
72  /*l
73  *b Description:
74  **
75  ** This function sets the name of this object.
76  **
77  *b Returns:
78  **
79  ** 0 on success, -1 on failure
80  */
81  int set_name(const char* name);
82 
83  /*l
84  *b Returns:
85  **
86  ** UI name of this object; this value will never be NULL
87  */
88  const char* get_ui_name();
89 
90  /*l
91  *b Description:
92  **
93  ** This function sets the UI name of this object. The UI name is what
94  ** shows up in user interface windows that show information about this
95  ** crowd.
96  **
97  ** For example, the crowd name may be "crowd_squad1", the UI name may
98  ** be "Squad 1".
99  **
100  ** By default the UI name matches the internal name.
101  **
102  *b Returns:
103  **
104  ** 0 on success, -1 on failure
105  */
106  int set_ui_name(const char* ui_name);
107 
108  /*l
109  *b Description:
110  **
111  ** Returns the type name of the object. This pointer will never be
112  ** NULL.
113  **
114  *b Returns:
115  **
116  ** type name of the object
117  */
118  const char* get_type_name();
119 
120  /*l
121  *b Description:
122  **
123  ** This function enables or disables the crowd.
124  **
125  ** Disabling a crowd does not disable or hide the members of the
126  ** crowd. It does turn off any effects the crowd may have on agent
127  ** actions, position, orientation, etc. To enable or disable all
128  ** agents in the crowd, use set_all_members_enabled() instead.
129  **
130  ** Disabled crowds also will not interact with companion crowds.
131  **
132  *b Returns:
133  **
134  ** 0 on success, -1 on failure
135  **
136  *b Available as Decision Bead/Event
137  */
138  int set_enabled(int enabled);
139 
140  /*l
141  *b Returns:
142  **
143  ** 1 if enabled, 0 if not
144  **
145  *b Available as Decision Bead/Event
146  */
147  int get_enabled();
148 
149  /*l
150  *b Description:
151  **
152  ** This function enables or disables all agents in the crowd. This is
153  ** the equivalent to calling diguyCharacter::set_enabled() for all
154  ** members of the crowd.
155  **
156  *b Returns:
157  **
158  ** 0 on success, -1 on failure
159  **
160  *b Available as Decision Bead/Event
161  */
162  void set_all_members_enabled(int enabled);
163 
164  /*l
165  **
166  *b Returns:
167  **
168  ** The size of the radius around the crowd's character that certain
169  ** callbacks will be triggered within. Callbacks such as:
170  ** CALLBACK_ID_NEARBY_SCENE_OBJECT_IMPACT, and
171  ** CALLBACK_ID_NEARBY_WEAPON_FIRED, are affected by this value.
172  */
173  float get_awareness_radius();
174 
175  /*l
176  **
177  *b Description:
178  **
179  ** Sets the crowd awareness radius. See get_awareness_radius().
180  **
181  *b Returns:
182  **
183  ** 0 on success, -1 on failure
184  */
185  int set_awareness_radius(float radius);
186 
187 
188 /*****************************************************************************/
198  /*l
199  *b Description:
200  **
201  ** Adds the passed character to the crowd if not already in it.
202  **
203  *b Returns:
204  **
205  ** 0 if the character is now a part of the crowd;
206  ** -1 if not
207  */
208  int add_member(diguyCharacter* character);
209 
210  /*l
211  *b Description:
212  **
213  ** Adds all characters of the group as members of the crowd.
214  **
215  *b Returns:
216  **
217  ** Always return 0.
218  */
219  int add_all_characters_in_group(diguyCharacterGroup* group);
220 
221  /*l
222  *b Description:
223  **
224  ** Removes the passed character from the crowd if it is a member.
225  **
226  *b Returns:
227  **
228  ** 0 if the character was part of the crowd and removed;
229  ** -1 if not
230  */
231  int remove_member(diguyCharacter* character);
232 
233  /*l
234  *b Description:
235  **
236  ** Removes all members of the crowd.
237  **
238  *b Returns:
239  **
240  ** Always return 0.
241  */
242  int remove_all_members();
243 
244  /*l
245  *b Returns:
246  **
247  ** 1 if the passed character is a member of the crowd; 0 if not
248  */
249  int is_member(diguyCharacter* character);
250 
251  /*l
252  *b Returns:
253  **
254  ** number of member characters in crowd
255  */
256  int get_num_members();
257 
258  /*l
259  *b Returns:
260  **
261  ** crowd member at specified index; NULL if no character at specified
262  ** index
263  */
264  diguyCharacter* get_member_at_index(int index);
265 
266  /*l
267  *b Returns:
268  **
269  ** index of crowd member; -1 if not a member of the crowd
270  */
271  int get_index_of_member(diguyCharacter* member);
272 
273  /*l
274  *b Returns:
275  **
276  ** diguyCharacterGroup associated with the crowd
277  */
278  diguyCharacterGroup* get_associated_group();
279 
280 
281 /*****************************************************************************/
297  /*l
298  *b Description:
299  **
300  ** This is a shortcut for calling
301  ** diguyCharacter::agent_attack_character() for all members of the
302  ** crowd.
303  **
304  ** This function will implicitly put agents into the attack behavior.
305  **
306  ** The current focus character will be set the specified character.
307  ** Pass NULL or the empty string ("") to not change the focus
308  ** character, but still change to the pursue behavior.
309  **
310  ** The current focus group will be un-set.
311  **
312  *b Returns:
313  **
314  ** 0 on success, -1 on failure
315  **
316  *b Available as Decision Bead/Event
317  */
318  int agents_attack_character(const char* character_name);
319 
320  /*l
321  *b Description:
322  **
323  ** This is a shortcut for calling diguyCharacter::agent_attack_group()
324  ** for all members of the crowd.
325  **
326  ** This function will implicitly put agents into the attack behavior.
327  **
328  ** The current focus group will be set the specified group. Pass NULL
329  ** or the empty string ("") to not change the focus group, but still
330  ** change to the pursue behavior.
331  **
332  ** The current focus character will be un-set.
333  **
334  *b Returns:
335  **
336  ** 0 on success, -1 on failure
337  **
338  *b Available as Decision Bead/Event
339  */
340  int agents_attack_group(const char* group_name);
341 
348  /*l
349  *b Description:
350  **
351  ** This is a shortcut for calling
352  ** diguyCharacter::agent_flee_character() for all members of the
353  ** crowd.
354  **
355  ** This function will implicitly put agents into the flee behavior.
356  **
357  ** Neither the current focus character nor group will be changed by
358  ** this function.
359  **
360  *b Returns:
361  **
362  ** 0 on success, -1 on failure
363  **
364  *b Available as Decision Bead/Event
365  */
366  int agents_flee_character(const char* character_name,
367  float distance,
368  int danger_level = 50);
369 
370  /*l
371  *b Description:
372  **
373  ** This is a shortcut for calling diguyCharacter::agent_flee_group()
374  ** for all members of the crowd.
375  **
376  ** This function will implicitly put agents into the flee behavior.
377  **
378  ** Neither the current focus character nor group will be changed by
379  ** this function.
380  **
381  *b Returns:
382  **
383  ** 0 on success, -1 on failure
384  **
385  *b Available as Decision Bead/Event
386  */
387  int agents_flee_group(const char* group_name,
388  float distance,
389  int danger_level = 50);
390 
391  /*l
392  *b Description:
393  **
394  ** This is a shortcut for calling diguyCharacter::agent_flee_crowd()
395  ** for all members of the crowd.
396  **
397  ** This function will implicitly put agents into the flee behavior.
398  **
399  ** Neither the current focus character nor group will be changed by
400  ** this function.
401  **
402  *b Returns:
403  **
404  ** 0 on success, -1 on failure
405  **
406  *b Available as Decision Bead/Event
407  */
408  int agents_flee_crowd(const char* crowd_name,
409  float distance,
410  int danger_level = 50);
411 
412  /*l
413  *b Description:
414  **
415  ** This is a shortcut for calling
416  ** diguyCharacter::agent_flee_location() for all members of the crowd.
417  **
418  ** This function will implicitly put agents into the flee behavior.
419  **
420  ** Neither the current focus character nor group will be changed by
421  ** this function.
422  **
423  *b Returns:
424  **
425  ** 0 on success, -1 on failure
426  */
427  int agents_flee_location(float x, float y, float z,
428  float distance,
429  int danger_level = 50);
430 
431  /*l
432  *b Description:
433  **
434  ** This is a shortcut for calling
435  ** diguyCharacter::agent_remove_all_flee_objects() for all members of
436  ** the crowd.
437  **
438  *b Returns:
439  **
440  ** 0 on success, -1 on failure
441  **
442  *b Available as Decision Bead/Event
443  */
444  void agents_remove_all_flee_objects();
445 
452  /*l
453  *b Description:
454  **
455  ** This is a shortcut for calling
456  ** diguyCharacter::agent_mingle_in_region() for all members of the
457  ** crowd.
458  **
459  ** This function will implicitly put agents into the mingle behavior.
460  **
461  ** Neither the current focus character nor group will be changed by
462  ** this function.
463  **
464  *b Returns:
465  **
466  ** 0 on success, -1 on failure
467  **
468  *b Available as Decision Bead/Event
469  */
470  int agents_mingle_in_region( const char* region_name = NULL, const char* subregion = NULL );
471 
478  /*l
479  *b Description:
480  **
481  ** This is a shortcut for calling
482  ** diguyCharacter::agent_pursue_character() for all members of the
483  ** crowd.
484  **
485  ** This function will implicitly put agents into the pursue behavior.
486  **
487  ** The current focus character will be set the specified character.
488  ** Pass NULL or the empty string ("") to not change the focus
489  ** character, but still change to the pursue behavior.
490  **
491  ** The current focus group will be un-set.
492  **
493  *b Returns:
494  **
495  ** 0 on success, -1 on failure
496  **
497  *b Available as Decision Bead/Event
498  */
499  int agents_pursue_character(const char* character_name);
500 
501  /*l
502  *b Description:
503  **
504  ** This is a shortcut for calling diguyCharacter::agent_pursue_group()
505  ** for all members of the crowd.
506  **
507  ** This function will implicitly put agents into the pursue behavior.
508  **
509  ** The current focus group will be set to the specified group. Pass
510  ** NULL or the empty string ("") to not change the focus group, but
511  ** still change to the pursue behavior.
512  **
513  ** The current focus character will be un-set.
514  **
515  *b Returns:
516  **
517  ** 0 on success, -1 on failure
518  **
519  *b Available as Decision Bead/Event
520  */
521  int agents_pursue_group(const char* group_name);
522 
523  /*l
524  *b Description:
525  **
526  ** This causes all members of the crowd to start pursuing the
527  ** individual that is closer to the leader then they are.
528  **
529  ** This function will implicitly put all agents except the leader into
530  ** the pursue behavior.
531  **
532  ** The current focus character will be set to the next nearest
533  ** character.
534  **
535  *b Returns:
536  **
537  ** 0 on success, -1 on failure
538  **
539  *b Available as Decision Bead/Event
540  */
541  int agents_chain_pursue(const char* leader_name);
542 
549  /*l
550  *b Description:
551  **
552  ** This is a shortcut for calling
553  ** diguyCharacter::agent_travel_behavior_path() for all members of the
554  ** crowd.
555  **
556  ** This function will implicitly put agents into the travel behavior.
557  **
558  ** Neither the current focus character nor group will be changed by
559  ** this function.
560  **
561  *b Returns:
562  **
563  ** 0 on success, -1 on failure
564  **
565  *b Available as Decision Bead/Event
566  */
567  int agents_travel_behavior_path(const char* direction = NULL,
568  const char* at_end = NULL,
569  int waypoint_index = -1,
570  float offset_y = 0.5f);
571 
572  /*l
573  *b Description:
574  **
575  ** This is a shortcut for calling
576  ** diguyCharacter::agent_travel_path_shape() for all members of the
577  ** crowd.
578  **
579  ** This function will implicitly put agents into the travel behavior.
580  **
581  ** Neither the current focus character nor group will be changed by
582  ** this function.
583  **
584  *b Returns:
585  **
586  ** 0 on success, -1 on failure
587  **
588  *b Available as Decision Bead/Event
589  */
590  int agents_travel_path_shape(const char* path_shape_name,
591  const char* direction = NULL,
592  const char* at_end = NULL,
593  int waypoint_index = -1,
594  float offset_y = 0.5f);
595 
596  /*l
597  *b Description:
598  **
599  ** This is a shortcut for calling
600  ** diguyCharacter::agent_travel_region_border() for all members of the
601  ** crowd.
602  **
603  ** This function will implicitly put agents into the travel behavior.
604  **
605  ** Neither the current focus character nor group will be changed by
606  ** this function.
607  **
608  *b Returns:
609  **
610  ** 0 on success, -1 on failure
611  **
612  *b Available as Decision Bead/Event
613  */
614  int agents_travel_region_border(const char* region_name,
615  const char* subregion = NULL);
616 
623  /*l
624  *b Description:
625  **
626  ** This is a shortcut for calling
627  ** diguyCharacter::agent_wander_region() for all members of the crowd.
628  **
629  ** This function will implicitly put agents into the wander behavior.
630  **
631  ** Neither the current focus character nor group will be changed by
632  ** this function.
633  **
634  *b Returns:
635  **
636  ** 0 on success, -1 on failure
637  **
638  *b Available as Decision Bead/Event
639  */
640  int agents_wander_region(const char* region_name = NULL, // NULL -> populate region
641  const char* subregion = NULL);
642 
649  /*l
650  *b Description:
651  **
652  ** This is a shortcut for calling
653  ** diguyCharacter::agent_stop_behavior() for all members of the crowd.
654  **
655  ** This function will implicitly put agents into the none behavior.
656  **
657  ** Neither the current focus character nor group will be changed by
658  ** this function.
659  **
660  *b Returns:
661  **
662  ** 0 on success, -1 on failure
663  **
664  *b Available as Decision Bead/Event
665  */
666  int agents_stop_behavior();
667 
668  /*l
669  *b Description:
670  **
671  ** This is a shortcut for calling
672  ** diguyCharacter::set_current_behavior() for all members of the
673  ** crowd.
674  **
675  ** It's recommended that one of the higher level functions above that
676  ** set behavior, for example agent_wander_region(), is used. These
677  ** functions allow for setting the most common parameters that affect
678  ** the behavior in one function call.
679  **
680  *b Returns:
681  **
682  ** 0 on success, -1 on failure
683  **
684  *b Available as Decision Bead/Event
685  */
686  int set_current_behavior(const char* behavior_name);
687 
688  /*l
689  *b Description:
690  **
691  ** Returns the current behavior used by crowd, expressed as a string
692  ** (e.g. "travel").
693  **
694  *b Returns:
695  **
696  ** string describing current crowd behavior, NULL on error
697  */
698  const char* get_current_behavior(int member_index = 0);
699 
700  /*l
701  *b Description:
702  **
703  ** Similar to diguyAgentParams::set_behavior_path_shape(). This is a
704  ** shortcut for setting the current behavior path shape for all
705  ** characters in the crowd.
706  **
707  *b Returns:
708  **
709  ** 0 on success, -1 on failure
710  **
711  *b Available as Decision Bead/Event
712  */
713  int set_current_behavior_path_shape(const char* behavior_path_shape_name,
714  float max_time_until_move_on = 0.0f);
715 
716  /*l
717  *b Description:
718  **
719  ** Similar to diguyAgentParams::set_behavior_region(). This is a
720  ** shortcut for setting the current behavior region for all characters
721  ** in the crowd.
722  **
723  ** This function does take an additional argument,
724  ** max_time_until_move_on. Setting this to 0 will cause all agents
725  ** that occasionally pause their movement (for example, characters in
726  ** the wander behavior) to move on to the new behavior region
727  ** immediately. Passing a higher number will allow agents to finish
728  ** their "natural" wait interval before moving on to the new region.
729  **
730  *b Returns:
731  **
732  ** 0 on success, -1 on failure
733  **
734  *b Available as Decision Bead/Event
735  */
736  int set_current_behavior_region(const char* behavior_region_name,
737  const char* subregion = NULL,
738  float max_time_until_move_on = 0.0f);
739 
740  /*l
741  *b Description:
742  **
743  ** Similar to diguyAgentParams::set_focus_character(). This is a
744  ** shortcut for setting the current focus character for all characters
745  ** in the crowd.
746  **
747  ** The current focus group will not be affected by this function.
748  **
749  *b Returns:
750  **
751  ** 0 on success, -1 on failure
752  **
753  *b Available as Decision Bead/Event
754  */
755  int set_current_focus_character(const char* focus_character_name);
756 
757  /*l
758  *b Description:
759  **
760  ** Similar to diguyAgentParams::set_focus_group(). This is a shortcut
761  ** for setting the current focus group for all characters in the
762  ** crowd.
763  **
764  ** The current focus character will not be affected by this function.
765  **
766  *b Returns:
767  **
768  ** 0 on success, -1 on failure
769  **
770  *b Available as Decision Bead/Event
771  */
772  int set_current_focus_group(const char* focus_group_name);
773 
774  /*l
775  *b Description:
776  **
777  ** This is a shortcut for calling
778  ** diguyCharacter::agent_set_current_params_from_profile() for all
779  ** members of the crowd.
780  **
781  ** This will affect most of the parameters of agents in this crowd,
782  ** including behavior, posture and variant, etc. Focus character and
783  ** group by default are changed, but can be left alone by passing 0
784  ** for retain_focus_objects.
785  **
786  *b Arguments:
787  **
788  *a profile_name - name of crowd profile whose default parameters
789  *a should be used
790  *a retain_focus_objects - pass 1 to change focus objects to those
791  *a of the named profile, 0 to retain existing
792  *a settings
793  *a retain_navigation_values - keeps path_shape, region, subregion, path planner
794  *a cost values and rules the same
795  **
796  *b Returns:
797  **
798  ** 0 on success, -1 on failure
799  **
800  *b Available as Decision Bead/Event
801  */
802  int set_current_params_from_profile(const char* profile_name,
803  int retain_focus_objects = 1,
804  int retain_navigation_values = 1);
805 
806  /*l
807  *b Description:
808  **
809  ** This is a shortcut for calling
810  ** diguyCharacter::agent_set_current_behavior_region_border_is_solid()
811  ** for all members of the crowd.
812  **
813  ** Sets whether the walls of the region the agent is in are solid. If
814  ** they are, the agent will treat the walls as if they are solid walls
815  ** in the environment. If not, the agent is free to walk through
816  ** them.
817  **
818  ** Pass 1 to make border walls solid, 0 to make them
819  ** freely passable.
820  **
821  *b Available as Decision Bead/Event
822  */
823  void set_current_behavior_region_border_is_solid(int is_solid);
824 
825  /*l
826  *b Description:
827  **
828  ** Sets the posture of all members of the crowd and restarts their
829  ** behaviors.
830  */
831  void set_current_postures(diguyMotionPosture posture);
832 
833  /*l
834  *b Description:
835  **
836  ** Sets the variant of all members of the crowd and restarts their
837  ** behaviors.
838  */
839  void set_current_variants(diguyMotionVariant variant);
840 
841  /*l
842  *b Description:
843  **
844  ** This function is similar to set_current_params_from_profile(), but
845  ** instead sets initial params.
846  **
847  *b Arguments:
848  **
849  *a profile_name - name of crowd profile whose default parameters
850  *a should be used
851  **
852  *b Returns:
853  **
854  ** 0 on success, -1 on failure
855  */
856  int set_initial_params_from_profile(const char* profile_name);
857 
858 
859 /*****************************************************************************/
865  /*l
866  *b Description:
867  **
868  ** This is a query function meant to allow for flexible behavior when
869  ** dealing with a crowd. If more than threshold ratio are doing
870  ** behavior_name then the function will return 1. The default 0.5
871  ** yields a simple majority check.
872  **
873  *b Returns:
874  **
875  ** 1 if true, 0 if false
876  **
877  *b Available as Decision Bead/Event
878  */
879  int is_current_behavior(const char* behavior_name,
880  float threshold = 0.5f);
881 
882  /*l
883  *b Description:
884  **
885  ** Similar to is_current_behavior(), but checks both behavior and
886  ** focus character.
887  */
888  int is_current_behavior_and_focus_character(const char* behavior_name,
889  const char* focus_character_name,
890  float threshold = 0.5f);
891 
892  /*l
893  *b Description:
894  **
895  ** Similar to is_current_behavior(), but checks both behavior and
896  ** focus group.
897  */
898  int is_current_behavior_and_focus_group(const char* behavior_name,
899  const char* group_name,
900  float threshold = 0.5f);
901 
902  /*l
903  *b Description:
904  **
905  ** Similar to is_current_behavior(), but checks whether characters are
906  ** dead.
907  */
908  int is_crowd_dead(float threshold = 0.5f);
909 
910 
911 /*****************************************************************************/
917  /*l
918  *b Description:
919  **
920  ** This function makes the specified crowd a "companion crowd" of this
921  ** crowd. Crowd members of companion crowds know about each other and
922  ** will attempt to avoid each other.
923  **
924  ** If two crowds are not companions, their respective crowd members
925  ** will make no attempt to avoid each other.
926  **
927  *b Arguments:
928  **
929  *a companion_crowd - name of crowd to become a companion
930  **
931  *b Returns:
932  **
933  ** 0 on success, -1 on failure
934  */
935  int add_companion_crowd(diguyCrowd* companion_crowd);
936 
937  /*l
938  *b Description:
939  **
940  ** This function removes the specified crowd as a companion crowd.
941  **
942  *b Arguments:
943  **
944  *a companion_crowd - name of former companion
945  **
946  *b Returns:
947  **
948  ** 0 on success, -1 on failure
949  */
950  int remove_companion_crowd(diguyCrowd* companion_crowd);
951 
952 
953 /*****************************************************************************/
963  /*l
964  *b Description:
965  **
966  ** This function sets the dynamic avoidance method that members of
967  ** this crowd will use to avoid each other. Dynamic objects are
968  ** objects that are moving around; these are almost always characters.
969  **
970  ** The enumeration is defined in diguy_constants.h.
971  **
972  *b Arguments:
973  **
974  *a method - avoidance method to use
975  **
976  *b Returns:
977  **
978  ** 0 on success, -1 on failure
979  */
980  void set_dynamic_object_avoidance_method(diguyDynamicAvoidanceMethod method);
981 
982  /*l
983  *b Returns:
984  **
985  ** current dynamic object avoidance method;
986  ** see set_dynamic_object_avoidance_method()
987  */
988  diguyDynamicAvoidanceMethod get_dynamic_object_avoidance_method();
989 
990  /*l
991  *b Description:
992  **
993  ** This function sets the static avoidance method that members of this
994  ** crowd will use to avoid walking through fixed walls and objects.
995  ** Usually these are scene objects and fixed props.
996  **
997  ** The enumeration is defined in diguy_constants.h.
998  **
999  *b Arguments:
1000  **
1001  *a method - avoidance method to use
1002  **
1003  *b Returns:
1004  **
1005  ** 0 on success, -1 on failure
1006  */
1007  void set_static_object_avoidance_method(diguyStaticAvoidanceMethod method);
1008 
1009  /*l
1010  *b Returns:
1011  **
1012  ** current static object avoidance method;
1013  ** see set_static_object_avoidance_method()
1014  */
1015  diguyStaticAvoidanceMethod get_static_object_avoidance_method();
1016 
1017 
1018 /*****************************************************************************/
1028  /*l
1029  *b Description:
1030  **
1031  ** Many of the diguyCrowd callbacks set a callback character which
1032  ** represents if there was a particular character that the callback
1033  ** relates to. A few of the callbacks do not set this value.
1034  **
1035  *b Returns:
1036  **
1037  ** pointer of type diguyCharacter; NULL if there was no associated
1038  ** character
1039  */
1040  diguyCharacter* get_callback_character();
1041 
1042  /*l
1043  *b Description:
1044  **
1045  ** Many of the diguyCrowd callbacks set a callback impact which
1046  ** represents if there was impact that the callback relates to. A few
1047  ** of the callbacks do not set this value.
1048  **
1049  *b Returns:
1050  **
1051  ** pointer of type diguyImpact; NULL if there was no associated
1052  ** impact
1053  */
1054  diguyImpact* get_callback_impact();
1056  /*l
1057  *b Description:
1058  **
1059  ** This is an enumeration of the different callbacks that can be
1060  ** registered with add_callback() and add_callback_script().
1061  **
1062  *i CALLBACK_ID_CREATE
1063  **
1064  ** This callback will be called when a new crowd is created.
1065  **
1066  ** Note that this callback can only be added by calling
1067  ** diguyScenario::add_default_crowd_callback(); adding it
1068  ** with diguyCrowd::add_callback() will have no effect, as
1069  ** by that time the crowd has already been created.
1070  ** There is no associated callback character.
1071  **
1072  *i CALLBACK_ID_DESTROY
1073  **
1074  ** This callback will be called when a crowd is destroyed. There
1075  ** is no associated callback character.
1076  **
1077  *i CALLBACK_ID_CROWD_MEMBER_KILLED
1078  **
1079  ** This callback will be called when a member of the crowd is
1080  ** killed.
1081  **
1082  *- - The callback character is the crowd member that was killed.
1083  *- - The callback impact contains the impact information.
1084  **
1085  *i CALLBACK_ID_CROWD_MEMBER_IMPACT
1086  **
1087  ** Similar to diguyCharacter::CALLBACK_ID_IMPACT, this callback will
1088  ** be called when a member of the crowd is hit by a detonation. If
1089  ** this callback isn't present the impacted character automatically
1090  ** will die. Handling this callback allows for the implementation
1091  ** of custom damage models at a crowd level.
1092  **
1093  *- - The callback character is the crowd member that was hit.
1094  *- - The callback impact contains the impact information.
1095  **
1096  *i CALLBACK_ID_NEARBY_SCENE_OBJECT_IMPACT
1097  **
1098  ** This callback will be called when a detonation occurs within the
1099  ** awareness radius (as set by set_awareness_radius()) of the
1100  ** crowd's current bounds.
1101  **
1102  *- - The callback character is the character that caused the
1103  *- detonation.
1104  *- - The callback impact contains the impact information.
1105  **
1106  *i CALLBACK_ID_NEARBY_WEAPON_FIRED
1107  **
1108  ** This callback will be called when a weapon is fired within the
1109  ** awareness radius (as set by set_awareness_radius()) of the
1110  ** crowd's current bounds.
1111  **
1112  *- - The callback character is the character that fired the weapon.
1113  **
1114  ** Callbacks return a value of type diguyCallbackReturn,
1115  ** which will be DIGUY_CALLBACK_STOP or DIGUY_CALLBACK_CONTINUE.
1116  ** If the callback returns DIGUY_CALLBACK_STOP, the default handler
1117  ** of the function will not be called; the callback is asserting
1118  ** that it has done everything necessary for the function call.
1119  ** If the callback returns DIGUY_CALLBACK_CONTINUE, the default
1120  ** handler for the function will be called after the callback.
1121  **
1122  *b Usable From:
1123  **
1124  *- - C++
1125  *- - Script
1126  */
1127  enum {
1128  CALLBACK_ID_CREATE = 1,
1129  CALLBACK_ID_DESTROY,
1130  CALLBACK_ID_CROWD_MEMBER_KILLED,
1131  CALLBACK_ID_CROWD_MEMBER_IMPACT,
1132  CALLBACK_ID_NEARBY_SCENE_OBJECT_IMPACT,
1133  CALLBACK_ID_NEARBY_WEAPON_FIRED,
1134 // CALLBACK_ID_RENAME,
1135  CALLBACK_ID_SETPUBLISHED
1136  };
1137 
1138 #ifdef CPLUSPLUS_ONLY
1139 
1140  /*l
1141  *b Description:
1142  **
1143  ** This function adds a user callback. Callbacks can be removed with
1144  ** remove_callback() or remove_callback_with_user_data().
1145  **
1146  *b Arguments:
1147  **
1148  *a callback - pointer to function with prototype
1149  *a diguyCrowdRegionCallback (typedefed above)
1150  *a callback_id - integer id of when this callback is to be called
1151  *a callback_params - not currently used; pass NULL
1152  *a callback_user_data - pointer for user's own use; DI-Guy will
1153  *a do nothing to the contents of this pointer
1154  *a beyond passing it back when the callback is
1155  *a invoked
1156  **
1157  *b Returns:
1158  **
1159  ** 0 on success, -1 on failure
1160  **
1161  *b Callable From:
1162  **
1163  *- - C++
1164  */
1165  int add_callback(int callback_id,
1166  diguyCrowdCallback* callback,
1167  void* callback_params = 0,
1168  void* callback_user_data = 0);
1169 
1170  /*l
1171  *b Description:
1172  **
1173  ** This function removes a user callback. All callbacks matching
1174  ** the specified callback_id and callback function will be removed.
1175  **
1176  *b Arguments:
1177  **
1178  *a callback_id - integer id of when this callback is to be called
1179  *a callback - pointer to function with prototype
1180  *a diguyCrowdCallback (typedefed above)
1181  **
1182  *b Returns:
1183  **
1184  ** 0 on success, -1 on failure
1185  */
1186  int remove_callback(int callback_id,
1187  diguyCrowdCallback* callback);
1188 
1189  /*l
1190  *b Description:
1191  **
1192  ** This function removes a user callback. All callbacks matching the
1193  ** specified callback_id and callback_user_data pointer will be
1194  ** removed.
1195  **
1196  *b Arguments:
1197  **
1198  *a callback_id - integer id of when this callback is to be called
1199  *a callback_user_data - pointer for user's own use
1200  **
1201  *b Returns:
1202  **
1203  ** 0 on success, -1 on failure
1204  */
1205  int remove_callback_with_user_data(int callback_id,
1206  void* callback_user_data);
1207 
1208 #endif
1209 
1210  /*l
1211  *b Description:
1212  **
1213  ** This function adds a user callback script. Callback scripts can be
1214  ** removed with remove_callback_script().
1215  **
1216  ** See diguyCharacter::add_callback_script() for an example of use.
1217  **
1218  *b Arguments:
1219  **
1220  *a callback_id - integer id of the callback
1221  *a callback_script - script text of callback to be added
1222  *a callback_script_type - the type of script contained in
1223  *a callback_script
1224  **
1225  ** If NULL is passed for callback_script_type, a default script type
1226  ** will be derived based on the default script interpreter of the
1227  ** scenario.
1228  **
1229  *i lua specific:
1230  **
1231  ** When the script is called, the object for which it is being called
1232  ** will be in the callback_object global.
1233  **
1234  ** To pass NULL when calling from a lua script, use nil.
1235  **
1236  *b Returns:
1237  **
1238  ** 0 on success, -1 on failure
1239  */
1240  int add_callback_script(int callback_id,
1241  const char* callback_script,
1242  const char* callback_script_type = NULL);
1243 
1244  /*l
1245  *b Description:
1246  **
1247  ** This function removes a user callback script previously added with
1248  ** add_callback_script().
1249  **
1250  ** See diguyCharacter::remove_callback_script() for an example of use.
1251  **
1252  *b Arguments:
1253  **
1254  *a callback_id - integer id of the callback
1255  *a callback_script - script text of callback previously added
1256  *a callback_script_type - the type of script contained in
1257  *a callback_script
1258  **
1259  ** If NULL is passed for callback_script, all callback scripts whose
1260  ** ids match callback_id and whose types match callback_script_type
1261  ** will be removed.
1262  **
1263  ** If NULL is passed for callback_script_type, a default script type
1264  ** will be derived based on the default script interpreter of the
1265  ** scenario.
1266  **
1267  *i lua specific:
1268  **
1269  ** To pass NULL when calling from a lua script, use nil.
1270  **
1271  *b Returns:
1272  **
1273  ** 0 on success, -1 on failure
1274  */
1275  int remove_callback_script(int callback_id,
1276  const char* callback_script,
1277  const char* callback_script_type = NULL);
1278 
1279 #ifdef CPLUSPLUS_ONLY
1280 
1281  /*l
1282  *b Description:
1283  **
1284  ** Equivalent to calling diguyCharacter::add_callback() for all
1285  ** members of the crowd.
1286  **
1287  ** *Note*: callback_id should be a *diguyCharacter* id, not a
1288  ** diguyCrowd id.
1289  **
1290  *b Callable From:
1291  **
1292  *- - C++
1293  */
1294  void all_members_add_character_callback(int callback_id,
1295  diguyCharacterCallback* callback,
1296  void* callback_params = NULL,
1297  void* callback_user_data = NULL);
1298 
1299  /*l
1300  *b Description:
1301  **
1302  ** Equivalent to calling diguyCharacter::remove_callback() for all
1303  ** members of the crowd.
1304  **
1305  ** *Note*: callback_id should be a *diguyCharacter* id, not a
1306  ** diguyCrowd id.
1307  **
1308  *b Callable From:
1309  **
1310  *- - C++
1311  */
1312  void all_members_remove_character_callback(int callback_id,
1313  diguyCharacterCallback* callback);
1314 
1315  /*l
1316  *b Description:
1317  **
1318  ** Equivalent to calling diguyCharacter::remove_callback_with_user_data()
1319  ** for all members of the crowd.
1320  **
1321  ** *Note*: callback_id should be a *diguyCharacter* id, not a
1322  ** diguyCrowd id.
1323  **
1324  *b Callable From:
1325  **
1326  *- - C++
1327  */
1328  void all_members_remove_character_callback_with_user_data(int callback_id,
1329  void* callback_user_data);
1330 
1331 #endif
1332 
1333  /*l
1334  *b Description:
1335  **
1336  ** Equivalent to calling diguyCharacter::add_callback_script() for all
1337  ** members of the crowd.
1338  **
1339  ** *Note*: callback_id should be a *diguyCharacter* id, not a
1340  ** diguyCrowd id.
1341  */
1342  void all_members_add_character_callback_script(int callback_id,
1343  const char* callback_script,
1344  const char* callback_script_type = NULL);
1345 
1346  /*l
1347  *b Description:
1348  **
1349  ** Equivalent to calling diguyCharacter::remove_callback_script() for
1350  ** all members of the crowd.
1351  **
1352  ** *Note*: callback_id should be a *diguyCharacter* id, not a
1353  ** diguyCrowd id.
1354  */
1355  void all_members_remove_character_callback_script(int callback_id,
1356  const char* callback_script,
1357  const char* callback_script_type = NULL);
1358 
1359 
1360 
1361 /*****************************************************************************/
1371  /*l
1372  *b Description:
1373  **
1374  ** This function maps the event handler with the given name to a
1375  ** callback id. This mapping will be saved in the .dss file and
1376  ** restored when the .dss file is loaded.
1377  **
1378  ** Mappings can also be made via the DI-Guy Scenario UI.
1379  **
1380  ** The event handler is one of the following:
1381  **
1382  *- - a scene object callback function registered by
1383  *- diguyScenario::register_crowd_event_handler() or
1384  *- diguyScenario::register_crowd_event_handler_from_library()
1385  *- - a script registered by
1386  *- diguyScenario::register_crowd_event_handler_script()
1387  *- - a Script, Decision, or Library Function in the scenario
1388  *- whose "Event Type" is "Crowd"
1389  **
1390  *b Arguments:
1391  **
1392  *a callback_id - integer id of callback
1393  *a handler_name - name of the event handler to map
1394  **
1395  *b Returns:
1396  **
1397  ** 0 on success, -1 on failure
1398  */
1399  int map_event_handler_to_callback_id(int callback_id,
1400  const char* handler_name);
1401 
1402  /*l
1403  *b Description:
1404  **
1405  ** This function unmaps the event handler with the given name from a
1406  ** callback id.
1407  **
1408  *b Arguments:
1409  **
1410  *a callback_id - integer id of callback
1411  *a handler_name - name of the event handler to map
1412  *a unmap_all_matches - pass 0 to unmap only the first match,
1413  *a pass 1 to unmap all matches
1414  **
1415  *b Returns:
1416  **
1417  ** 0 on success, -1 on failure
1418  */
1419  int unmap_event_handler_from_callback_id(int callback_id,
1420  const char* handler_name,
1421  int unmap_all_matches = 0);
1422 
1423 
1424 /*****************************************************************************/
1434  /*l
1435  *b Returns:
1436  **
1437  ** diguyRegion associated with the crowd; will be created if it
1438  ** doesn't currently exist
1439  */
1440  diguyRegion* find_or_create_region();
1441 
1442  /*l
1443  *b Returns:
1444  **
1445  ** diguyRegion associated with the crowd; may be NULL
1446  */
1447  diguyRegion* get_region();
1448 
1449 
1450 /*****************************************************************************/
1460  /*l
1461  *b Description:
1462  **
1463  ** Equivalent to calling diguyCharacter::agent_accept_message() for
1464  ** all members of the crowd.
1465  **
1466  *b Arguments:
1467  **
1468  *a message_type - what type of message is being sent
1469  *a message - the message string
1470  *a message_params - optional parameter string
1471  */
1472  void send_message_to_all_members(const char* message_type,
1473  const char* message,
1474  const char* message_params = NULL);
1475 
1476 
1477 /*****************************************************************************/
1482  void set_unit_type(diguyTacticsUnitType tut);
1484  diguyTacticsUnitType get_unit_type();
1485 
1487  int set_unit_leader(diguyCharacter* leader);
1488  diguyCharacter* get_unit_leader();
1489 
1490 
1491 /*****************************************************************************/
1496  /*l
1497  *b Description:
1498  **
1499  ** This function sets the Marking Text for crowds that are
1500  ** published to the network by DI-Guy Networking. The default
1501  ** network marking is the empty string "".
1502  **
1503  ** This function should only be called for published crowds.
1504  ** The Marking Text is set internally for reflected crowds.
1505  **
1506  *b Returns:
1507  **
1508  ** 0 on success, -1 on failure
1509  **
1510  *b Callable For Networked Entities That Are:
1511  **
1512  *- - DIS published
1513  *- - HLA published
1514  */
1515  int set_network_marking(const char* network_marking);
1516 
1517  /*l
1518  *b Description:
1519  **
1520  ** This function gets the Marking Text for crowds.
1521  **
1522  ** For published crowds this value will be what was most
1523  ** recently set by set_network_marking().
1524  **
1525  ** For reflected crowds this value will be read from the
1526  ** reflected crowds' entity state information.
1527  **
1528  *b Returns:
1529  **
1530  ** Crowds's Marking Text; will never be NULL
1531  **
1532  *b Callable For Networked Entities That Are:
1533  **
1534  *- - DIS published and reflected
1535  *- - HLA published and reflected
1536  */
1537  const char* get_network_marking();
1538 
1539  /*l
1540  *b Description:
1541  **
1542  ** This function sets whether this crowd will be published
1543  ** by DI-Guy Networking. This value is persistent, and does
1544  ** not depend on whether there actually *is* currently a
1545  ** network connection.
1546  **
1547  ** The default is 0, the crowd is *not* published.
1548  **
1549  ** This function should *not* be called for reflected crowds.
1550  ** It affects to both DIS and HLA networking.
1551  **
1552  *b Returns:
1553  **
1554  ** 0 on success, -1 on failure
1555  **
1556  *b Callable For Networked Entities That Are:
1557  **
1558  *- - DIS published
1559  *- - HLA published
1560  */
1561  int set_is_network_published(int is_network_published);
1562 
1563  /*l
1564  *b Description:
1565  **
1566  ** This function returns whether the crowd is published
1567  ** by DI-Guy Networking. It will always return 0 for reflected
1568  ** crowds.
1569  **
1570  ** This function can be called for any crowd.
1571  **
1572  *b Returns:
1573  **
1574  ** 1 if published, 0 if not
1575  **
1576  *b Available as Decision Bead/Event
1577  **
1578  *b Callable For Networked Entities That Are:
1579  **
1580  *- - DIS published and reflected
1581  *- - HLA published and reflected
1582  */
1583  int get_is_network_published();
1584 
1585  /*l
1586  *b Description:
1587  **
1588  ** Experimental function that returns a vrlink entity state repository,
1589  ** useful for adding additional information to a diguy that we don't usually
1590  ** model.
1591  */
1592  DtAggregateStateRepository * get_vrlink_entity_state_repository();
1593 
1594  /*l
1595  *b Description:
1596  **
1597  ** This function returns whether the crowd is a
1598  ** reflected crowd created by DI-Guy Networking.
1599  **
1600  ** This function can be called for any crowd.
1601  **
1602  *b Returns:
1603  **
1604  ** 1 if reflected, 0 if not
1605  **
1606  *b Available as Decision Bead/Event
1607  **
1608  *b Callable For Networked Entities That Are:
1609  **
1610  *- - DIS published and reflected
1611  *- - HLA published and reflected
1612  */
1613  int get_is_network_reflected();
1614 
1615  /*l
1616  *b Description:
1617  **
1618  ** This function returns whether this crowd is in a
1619  ** "paused" state. This will only be true for reflected
1620  ** crowds.
1621  **
1622  ** A reflected crowd will be paused if the network
1623  ** entity it is representing is paused; i.e., its personal
1624  ** timeline is not advancing. The most common case of this
1625  ** is when this crowd is reflecting a published crowd
1626  ** of a DI-Guy Scenario application that is in a paused or
1627  ** stopped state.
1628  **
1629  ** If DI-Guy Scenario, paused crowds will remain frozen
1630  ** in their current postures.
1631  **
1632  *b Returns:
1633  **
1634  ** 1 if paused, 0 if not
1635  **
1636  *b Available as Decision Bead/Event
1637  */
1638  int get_is_network_paused();
1639 
1640  /*l
1641  *b Description:
1642  **
1643  ** Overrides built-in logic for network pausing, becomes end user's responsibility
1644  ** to manage
1645  */
1646  int set_is_network_paused(int paused);
1647 
1648  /*l
1649  *b Description:
1650  **
1651  ** This function returns the crowd's "network entity number".
1652  ** This number is valid and persistent regardless of whether the
1653  ** crowd is currently published.
1654  **
1655  ** This number is primarily used internally by DI-Guy Networking
1656  ** for creating entity IDs.
1657  **
1658  *b Returns:
1659  **
1660  ** crowd's network entity number
1661  **
1662  *b Callable For Networked Entities That Are:
1663  **
1664  *- - DIS published and reflected
1665  *- - HLA published and reflected
1666  */
1667  int get_network_entity_number();
1668 
1669 /****************************************************************************/
1670 /****************************************************************************/
1671 /****************************************************************************/
1678 /****************************************************************************/
1679 /****************************************************************************/
1680 /****************************************************************************/
1681 
1682 
1687 #ifdef CPLUSPLUS_ONLY
1688 
1689  bdiScenarioCrowd* get_scripted_object() { return m_scripted_object; }
1690 
1691 private:
1692 
1693  /*l
1694  ** A private constructor.
1695  */
1696  diguyCrowd( bdiScenarioCrowd* scripted_object );
1697 
1698  /*l
1699  ** A private destructor.
1700  */
1701  virtual ~diguyCrowd();
1702 
1703  /*l
1704  ** A pointer to internal data.
1705  */
1706  bdiScenarioCrowd* m_scripted_object;
1707 
1708  friend class bdiScenarioCrowd;
1709 
1710 #endif
1711 
1712 };
Definition: diguyVehicleNearCollision.h:33
A two-and-a-half-dimensional surface that represents either a navigation mesh or an area that's been ...
Definition: diguyRegion.h:50
diguyCallbackReturn diguyCharacterCallback(diguyCharacter *character, int callback_id, void *callback_params, void *callback_user_data)
Definition: diguy_typedefs.h:51
Represents a scriptable api wrapping a diguy path shape, a curve defined by with a number of waypoint...
Definition: diguyPathShape.h:36
A class that represents a bullet impact in the world, often used by AIs to make reaction decisions...
Definition: diguyImpact.h:39
diguyStaticAvoidanceMethod
This enumeration lists the methods available for collision detection and avoidance against static obj...
Definition: diguy_constants.h:1064
Contains the diguyMotionVariant enumeration and utility function declarations.
A group of DI-Guy characters, useful for organizing your scenarios.
Definition: diguyCharacterGroup.h:38
The class that represents a DI-Guy Entity in the world.
Definition: diguyCharacter.h:81
Contains the diguyMotionPosture enumeration and utility function declarations.
diguyCallbackReturn diguyCrowdCallback(diguyCrowd *crowd, int callback_id, void *callback_params, void *callback_user_data)
Definition: diguy_typedefs.h:169
diguyTacticsUnitType
Definition: diguy_constants.h:1618
diguyMotionVariant
Definition: diguyMotionVariant.h:28
diguyDynamicAvoidanceMethod
This enumeration lists the methods available for collision detection and avoidance against dynamic ob...
Definition: diguy_constants.h:1035
The class that represents a DI-Guy Crowd, DI-Guy AI agents can be given orders at an individual level...
Definition: diguyCrowd.h:48
diguyMotionPosture
Definition: diguyMotionPosture.h:28