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