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