DI-Guy C++ SDK Reference  13.0
 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-2014 VT MAK
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 
28 class bdiScenarioCrowd;
29 class diguyCharacter;
31 class diguyCrowd;
32 class diguyImpact;
33 class diguyPathShape;
34 class diguyRegion;
36 
37 
38 #endif
39 
40 
41 #include <declspec_diguy.h>
42 
43 /****************************************************************************/
44 class BDI_DECLSPEC_diguy diguyCrowd
45 {
46 /*****************************************************************************/
56 public:
57 
58  /*l
59  *b Returns:
60  **
61  ** name of this object; this value will never be NULL
62  */
63  const char* get_name();
64 
65  /*l
66  *b Description:
67  **
68  ** This function sets the name of this object.
69  **
70  *b Returns:
71  **
72  ** 0 on success, -1 on failure
73  */
74  int set_name(const char* name);
75 
76  /*l
77  *b Returns:
78  **
79  ** UI name of this object; this value will never be NULL
80  */
81  const char* get_ui_name();
82 
83  /*l
84  *b Description:
85  **
86  ** This function sets the UI name of this object. The UI name is what
87  ** shows up in user interface windows that show information about this
88  ** crowd.
89  **
90  ** For example, the crowd name may be "crowd_squad1", the UI name may
91  ** be "Squad 1".
92  **
93  ** By default the UI name matches the internal name.
94  **
95  *b Returns:
96  **
97  ** 0 on success, -1 on failure
98  */
99  int set_ui_name(const char* ui_name);
100 
101  /*l
102  *b Description:
103  **
104  ** Returns the type name of the object. This pointer will never be
105  ** NULL.
106  **
107  *b Returns:
108  **
109  ** type name of the object
110  */
111  const char* get_type_name();
112 
113  /*l
114  *b Description:
115  **
116  ** This function enables or disables the crowd.
117  **
118  ** Disabling a crowd does not disable or hide the members of the
119  ** crowd. It does turn off any effects the crowd may have on agent
120  ** actions, position, orientation, etc. To enable or disable all
121  ** agents in the crowd, use set_all_members_enabled() instead.
122  **
123  ** Disabled crowds also will not interact with companion crowds.
124  **
125  *b Returns:
126  **
127  ** 0 on success, -1 on failure
128  **
129  *b Available as Decision Bead/Event
130  */
131  int set_enabled(int enabled);
132 
133  /*l
134  *b Returns:
135  **
136  ** 1 if enabled, 0 if not
137  **
138  *b Available as Decision Bead/Event
139  */
140  int get_enabled();
141 
142  /*l
143  *b Description:
144  **
145  ** This function enables or disables all agents in the crowd. This is
146  ** the equivalent to calling diguyCharacter::set_enabled() for all
147  ** members of the crowd.
148  **
149  *b Returns:
150  **
151  ** 0 on success, -1 on failure
152  **
153  *b Available as Decision Bead/Event
154  */
155  void set_all_members_enabled(int enabled);
156 
157  /*l
158  **
159  *b Returns:
160  **
161  ** The size of the radius around the crowd's character that certain
162  ** callbacks will be triggered within. Callbacks such as:
163  ** CALLBACK_ID_NEARBY_SCENE_OBJECT_IMPACT, and
164  ** CALLBACK_ID_NEARBY_WEAPON_FIRED, are affected by this value.
165  */
166  float get_awareness_radius();
167 
168  /*l
169  **
170  *b Description:
171  **
172  ** Sets the crowd awareness radius. See get_awareness_radius().
173  **
174  *b Returns:
175  **
176  ** 0 on success, -1 on failure
177  */
178  int set_awareness_radius(float radius);
179 
180 
181 /*****************************************************************************/
191  /*l
192  *b Description:
193  **
194  ** Adds the passed character to the crowd if not already in it.
195  **
196  *b Returns:
197  **
198  ** 0 if the character is now a part of the crowd;
199  ** -1 if not
200  */
201  int add_member(diguyCharacter* character);
202 
203  /*l
204  *b Description:
205  **
206  ** Adds all characters of the group as members of the crowd.
207  **
208  *b Returns:
209  **
210  ** Always return 0.
211  */
212  int add_all_characters_in_group(diguyCharacterGroup* group);
213 
214  /*l
215  *b Description:
216  **
217  ** Removes the passed character from the crowd if it is a member.
218  **
219  *b Returns:
220  **
221  ** 0 if the character was part of the crowd and removed;
222  ** -1 if not
223  */
224  int remove_member(diguyCharacter* character);
225 
226  /*l
227  *b Description:
228  **
229  ** Removes all members of the crowd.
230  **
231  *b Returns:
232  **
233  ** Always return 0.
234  */
235  int remove_all_members();
236 
237  /*l
238  *b Returns:
239  **
240  ** 1 if the passed character is a member of the crowd; 0 if not
241  */
242  int is_member(diguyCharacter* character);
243 
244  /*l
245  *b Returns:
246  **
247  ** number of member characters in crowd
248  */
249  int get_num_members();
250 
251  /*l
252  *b Returns:
253  **
254  ** crowd member at specified index; NULL if no character at specified
255  ** index
256  */
257  diguyCharacter* get_member_at_index(int index);
258 
259  /*l
260  *b Returns:
261  **
262  ** index of crowd member; -1 if not a member of the crowd
263  */
264  int get_index_of_member(diguyCharacter* member);
265 
266  /*l
267  *b Returns:
268  **
269  ** diguyCharacterGroup associated with the crowd
270  */
271  diguyCharacterGroup* get_associated_group();
272 
273 
274 /*****************************************************************************/
290  /*l
291  *b Description:
292  **
293  ** This is a shortcut for calling
294  ** diguyCharacter::agent_attack_character() for all members of the
295  ** crowd.
296  **
297  ** This function will implicitly put agents into the attack behavior.
298  **
299  ** The current focus character will be set the specified character.
300  ** Pass NULL or the empty string ("") to not change the focus
301  ** character, but still change to the pursue behavior.
302  **
303  ** The current focus group will be un-set.
304  **
305  *b Returns:
306  **
307  ** 0 on success, -1 on failure
308  **
309  *b Available as Decision Bead/Event
310  */
311  int agents_attack_character(const char* character_name);
312 
313  /*l
314  *b Description:
315  **
316  ** This is a shortcut for calling diguyCharacter::agent_attack_group()
317  ** for all members of the crowd.
318  **
319  ** This function will implicitly put agents into the attack behavior.
320  **
321  ** The current focus group will be set the specified group. Pass NULL
322  ** or the empty string ("") to not change the focus group, but still
323  ** change to the pursue behavior.
324  **
325  ** The current focus character will be un-set.
326  **
327  *b Returns:
328  **
329  ** 0 on success, -1 on failure
330  **
331  *b Available as Decision Bead/Event
332  */
333  int agents_attack_group(const char* group_name);
334 
341  /*l
342  *b Description:
343  **
344  ** This is a shortcut for calling
345  ** diguyCharacter::agent_flee_character() for all members of the
346  ** crowd.
347  **
348  ** This function will implicitly put agents into the flee behavior.
349  **
350  ** Neither the current focus character nor group will be changed by
351  ** this function.
352  **
353  *b Returns:
354  **
355  ** 0 on success, -1 on failure
356  **
357  *b Available as Decision Bead/Event
358  */
359  int agents_flee_character(const char* character_name,
360  float distance,
361  int danger_level = 50);
362 
363  /*l
364  *b Description:
365  **
366  ** This is a shortcut for calling diguyCharacter::agent_flee_group()
367  ** for all members of the crowd.
368  **
369  ** This function will implicitly put agents into the flee behavior.
370  **
371  ** Neither the current focus character nor group will be changed by
372  ** this function.
373  **
374  *b Returns:
375  **
376  ** 0 on success, -1 on failure
377  **
378  *b Available as Decision Bead/Event
379  */
380  int agents_flee_group(const char* group_name,
381  float distance,
382  int danger_level = 50);
383 
384  /*l
385  *b Description:
386  **
387  ** This is a shortcut for calling diguyCharacter::agent_flee_crowd()
388  ** for all members of the crowd.
389  **
390  ** This function will implicitly put agents into the flee behavior.
391  **
392  ** Neither the current focus character nor group will be changed by
393  ** this function.
394  **
395  *b Returns:
396  **
397  ** 0 on success, -1 on failure
398  **
399  *b Available as Decision Bead/Event
400  */
401  int agents_flee_crowd(const char* crowd_name,
402  float distance,
403  int danger_level = 50);
404 
405  /*l
406  *b Description:
407  **
408  ** This is a shortcut for calling
409  ** diguyCharacter::agent_flee_location() for all members of the crowd.
410  **
411  ** This function will implicitly put agents into the flee behavior.
412  **
413  ** Neither the current focus character nor group will be changed by
414  ** this function.
415  **
416  *b Returns:
417  **
418  ** 0 on success, -1 on failure
419  */
420  int agents_flee_location(float x, float y, float z,
421  float distance,
422  int danger_level = 50);
423 
424  /*l
425  *b Description:
426  **
427  ** This is a shortcut for calling
428  ** diguyCharacter::agent_remove_all_flee_objects() for all members of
429  ** the crowd.
430  **
431  *b Returns:
432  **
433  ** 0 on success, -1 on failure
434  **
435  *b Available as Decision Bead/Event
436  */
437  void agents_remove_all_flee_objects();
438 
445  /*l
446  *b Description:
447  **
448  ** This is a shortcut for calling
449  ** diguyCharacter::agent_mingle_in_region() for all members of the
450  ** crowd.
451  **
452  ** This function will implicitly put agents into the mingle behavior.
453  **
454  ** Neither the current focus character nor group will be changed by
455  ** this function.
456  **
457  *b Returns:
458  **
459  ** 0 on success, -1 on failure
460  **
461  *b Available as Decision Bead/Event
462  */
463  int agents_mingle_in_region(const char* region_name = NULL,
464  const char* subregion = NULL);
465 
472  /*l
473  *b Description:
474  **
475  ** This is a shortcut for calling
476  ** diguyCharacter::agent_pursue_character() for all members of the
477  ** crowd.
478  **
479  ** This function will implicitly put agents into the pursue behavior.
480  **
481  ** The current focus character will be set the specified character.
482  ** Pass NULL or the empty string ("") to not change the focus
483  ** character, but still change to the pursue behavior.
484  **
485  ** The current focus group will be un-set.
486  **
487  *b Returns:
488  **
489  ** 0 on success, -1 on failure
490  **
491  *b Available as Decision Bead/Event
492  */
493  int agents_pursue_character(const char* character_name);
494 
495  /*l
496  *b Description:
497  **
498  ** This is a shortcut for calling diguyCharacter::agent_pursue_group()
499  ** for all members of the crowd.
500  **
501  ** This function will implicitly put agents into the pursue behavior.
502  **
503  ** The current focus group will be set to the specified group. Pass
504  ** NULL or the empty string ("") to not change the focus group, but
505  ** still change to the pursue behavior.
506  **
507  ** The current focus character will be un-set.
508  **
509  *b Returns:
510  **
511  ** 0 on success, -1 on failure
512  **
513  *b Available as Decision Bead/Event
514  */
515  int agents_pursue_group(const char* group_name);
516 
517  /*l
518  *b Description:
519  **
520  ** This causes all members of the crowd to start pursuing the
521  ** individual that is closer to the leader then they are.
522  **
523  ** This function will implicitly put all agents except the leader into
524  ** the pursue behavior.
525  **
526  ** The current focus character will be set to the next nearest
527  ** character.
528  **
529  *b Returns:
530  **
531  ** 0 on success, -1 on failure
532  **
533  *b Available as Decision Bead/Event
534  */
535  int agents_chain_pursue(const char* leader_name);
536 
543  /*l
544  *b Description:
545  **
546  ** This is a shortcut for calling
547  ** diguyCharacter::agent_travel_behavior_path() for all members of the
548  ** crowd.
549  **
550  ** This function will implicitly put agents into the travel behavior.
551  **
552  ** Neither the current focus character nor group will be changed by
553  ** this function.
554  **
555  *b Returns:
556  **
557  ** 0 on success, -1 on failure
558  **
559  *b Available as Decision Bead/Event
560  */
561  int agents_travel_behavior_path(const char* direction = NULL,
562  const char* at_end = NULL,
563  int waypoint_index = -1,
564  float offset_y = 0.5f);
565 
566  /*l
567  *b Description:
568  **
569  ** This is a shortcut for calling
570  ** diguyCharacter::agent_travel_path_shape() for all members of the
571  ** crowd.
572  **
573  ** This function will implicitly put agents into the travel behavior.
574  **
575  ** Neither the current focus character nor group will be changed by
576  ** this function.
577  **
578  *b Returns:
579  **
580  ** 0 on success, -1 on failure
581  **
582  *b Available as Decision Bead/Event
583  */
584  int agents_travel_path_shape(const char* path_shape_name,
585  const char* direction = NULL,
586  const char* at_end = NULL,
587  int waypoint_index = -1,
588  float offset_y = 0.5f);
589 
590  /*l
591  *b Description:
592  **
593  ** This is a shortcut for calling
594  ** diguyCharacter::agent_travel_region_border() for all members of the
595  ** crowd.
596  **
597  ** This function will implicitly put agents into the travel behavior.
598  **
599  ** Neither the current focus character nor group will be changed by
600  ** this function.
601  **
602  *b Returns:
603  **
604  ** 0 on success, -1 on failure
605  **
606  *b Available as Decision Bead/Event
607  */
608  int agents_travel_region_border(const char* region_name,
609  const char* subregion = NULL);
610 
617  /*l
618  *b Description:
619  **
620  ** This is a shortcut for calling
621  ** diguyCharacter::agent_wander_region() for all members of the crowd.
622  **
623  ** This function will implicitly put agents into the wander behavior.
624  **
625  ** Neither the current focus character nor group will be changed by
626  ** this function.
627  **
628  *b Returns:
629  **
630  ** 0 on success, -1 on failure
631  **
632  *b Available as Decision Bead/Event
633  */
634  int agents_wander_region(const char* region_name = NULL, // NULL -> populate region
635  const char* subregion = NULL);
636 
643  /*l
644  *b Description:
645  **
646  ** This is a shortcut for calling
647  ** diguyCharacter::agent_stop_behavior() for all members of the crowd.
648  **
649  ** This function will implicitly put agents into the none behavior.
650  **
651  ** Neither the current focus character nor group will be changed by
652  ** this function.
653  **
654  *b Returns:
655  **
656  ** 0 on success, -1 on failure
657  **
658  *b Available as Decision Bead/Event
659  */
660  int agents_stop_behavior();
661 
662  /*l
663  *b Description:
664  **
665  ** This is a shortcut for calling
666  ** diguyCharacter::set_current_behavior() for all members of the
667  ** crowd.
668  **
669  ** It's recommended that one of the higher level functions above that
670  ** set behavior, for example agent_wander_region(), is used. These
671  ** functions allow for setting the most common parameters that affect
672  ** the behavior in one function call.
673  **
674  *b Returns:
675  **
676  ** 0 on success, -1 on failure
677  **
678  *b Available as Decision Bead/Event
679  */
680  int set_current_behavior(const char* behavior_name);
681 
682  /*l
683  *b Description:
684  **
685  ** Returns the current behavior used by crowd, expressed as a string
686  ** (e.g. "travel").
687  **
688  *b Returns:
689  **
690  ** string describing current crowd behavior, NULL on error
691  */
692  const char* get_current_behavior(int member_index = 0);
693 
694  /*l
695  *b Description:
696  **
697  ** Similar to diguyAgentParams::set_behavior_path_shape(). This is a
698  ** shortcut for setting the current behavior path shape for all
699  ** characters in the crowd.
700  **
701  *b Returns:
702  **
703  ** 0 on success, -1 on failure
704  **
705  *b Available as Decision Bead/Event
706  */
707  int set_current_behavior_path_shape(const char* behavior_path_shape_name,
708  float max_time_until_move_on = 0.0f);
709 
710  /*l
711  *b Description:
712  **
713  ** Similar to diguyAgentParams::set_behavior_region(). This is a
714  ** shortcut for setting the current behavior region for all characters
715  ** in the crowd.
716  **
717  ** This function does take an additional argument,
718  ** max_time_until_move_on. Setting this to 0 will cause all agents
719  ** that occasionally pause their movement (for example, characters in
720  ** the wander behavior) to move on to the new behavior region
721  ** immediately. Passing a higher number will allow agents to finish
722  ** their "natural" wait interval before moving on to the new region.
723  **
724  *b Returns:
725  **
726  ** 0 on success, -1 on failure
727  **
728  *b Available as Decision Bead/Event
729  */
730  int set_current_behavior_region(const char* behavior_region_name,
731  const char* subregion = NULL,
732  float max_time_until_move_on = 0.0f);
733 
734  /*l
735  *b Description:
736  **
737  ** Similar to diguyAgentParams::set_focus_character(). This is a
738  ** shortcut for setting the current focus character for all characters
739  ** in the crowd.
740  **
741  ** The current focus group will not be affected by this function.
742  **
743  *b Returns:
744  **
745  ** 0 on success, -1 on failure
746  **
747  *b Available as Decision Bead/Event
748  */
749  int set_current_focus_character(const char* focus_character_name);
750 
751  /*l
752  *b Description:
753  **
754  ** Similar to diguyAgentParams::set_focus_group(). This is a shortcut
755  ** for setting the current focus group for all characters in the
756  ** crowd.
757  **
758  ** The current focus character will not be affected by this function.
759  **
760  *b Returns:
761  **
762  ** 0 on success, -1 on failure
763  **
764  *b Available as Decision Bead/Event
765  */
766  int set_current_focus_group(const char* focus_group_name);
767 
768  /*l
769  *b Description:
770  **
771  ** This is a shortcut for calling
772  ** diguyCharacter::agent_set_current_params_from_profile() for all
773  ** members of the crowd.
774  **
775  ** This will affect most of the parameters of agents in this crowd,
776  ** including behavior, posture and variant, etc. Focus character and
777  ** group by default are changed, but can be left alone by passing 0
778  ** for retain_focus_objects.
779  **
780  *b Arguments:
781  **
782  *a profile_name - name of crowd profile whose default parameters
783  *a should be used
784  *a retain_focus_objects - pass 1 to change focus objects to those
785  *a of the named profile, 0 to retain existing
786  *a settings
787  *a retain_navigation_values - keeps path_shape, region, subregion, path planner
788  *a cost values and rules the same
789  **
790  *b Returns:
791  **
792  ** 0 on success, -1 on failure
793  **
794  *b Available as Decision Bead/Event
795  */
796  int set_current_params_from_profile(const char* profile_name,
797  int retain_focus_objects = 1,
798  int retain_navigation_values = 1);
799 
800  /*l
801  *b Description:
802  **
803  ** This is a shortcut for calling
804  ** diguyCharacter::agent_set_current_behavior_region_border_is_solid()
805  ** for all members of the crowd.
806  **
807  ** Sets whether the walls of the region the agent is in are solid. If
808  ** they are, the agent will treat the walls as if they are solid walls
809  ** in the environment. If not, the agent is free to walk through
810  ** them.
811  **
812  ** Pass 1 to make border walls solid, 0 to make them
813  ** freely passable.
814  **
815  *b Available as Decision Bead/Event
816  */
817  void set_current_behavior_region_border_is_solid(int is_solid);
818 
819  /*l
820  *b Description:
821  **
822  ** Sets the posture of all members of the crowd and restarts their
823  ** behaviors.
824  */
825  void set_current_postures(diguyMotionPosture posture);
826 
827  /*l
828  *b Description:
829  **
830  ** Sets the variant of all members of the crowd and restarts their
831  ** behaviors.
832  */
833  void set_current_variants(diguyMotionVariant variant);
834 
835  /*l
836  *b Description:
837  **
838  ** This function is similar to set_current_params_from_profile(), but
839  ** instead sets initial params.
840  **
841  *b Arguments:
842  **
843  *a profile_name - name of crowd profile whose default parameters
844  *a should be used
845  **
846  *b Returns:
847  **
848  ** 0 on success, -1 on failure
849  */
850  int set_initial_params_from_profile(const char* profile_name);
851 
852 
853 /*****************************************************************************/
859  /*l
860  *b Description:
861  **
862  ** This is a query function meant to allow for flexible behavior when
863  ** dealing with a crowd. If more than threshold ratio are doing
864  ** behavior_name then the function will return 1. The default 0.5
865  ** yields a simple majority check.
866  **
867  *b Returns:
868  **
869  ** 1 if true, 0 if false
870  **
871  *b Available as Decision Bead/Event
872  */
873  int is_current_behavior(const char* behavior_name,
874  float threshold = 0.5f);
875 
876  /*l
877  *b Description:
878  **
879  ** Similar to is_current_behavior(), but checks both behavior and
880  ** focus character.
881  */
882  int is_current_behavior_and_focus_character(const char* behavior_name,
883  const char* focus_character_name,
884  float threshold = 0.5f);
885 
886  /*l
887  *b Description:
888  **
889  ** Similar to is_current_behavior(), but checks both behavior and
890  ** focus group.
891  */
892  int is_current_behavior_and_focus_group(const char* behavior_name,
893  const char* group_name,
894  float threshold = 0.5f);
895 
896  /*l
897  *b Description:
898  **
899  ** Similar to is_current_behavior(), but checks whether characters are
900  ** dead.
901  */
902  int is_crowd_dead(float threshold = 0.5f);
903 
904 
905 /*****************************************************************************/
911  /*l
912  *b Description:
913  **
914  ** This function makes the specified crowd a "companion crowd" of this
915  ** crowd. Crowd members of companion crowds know about each other and
916  ** will attempt to avoid each other.
917  **
918  ** If two crowds are not companions, their respective crowd members
919  ** will make no attempt to avoid each other.
920  **
921  *b Arguments:
922  **
923  *a companion_crowd - name of crowd to become a companion
924  **
925  *b Returns:
926  **
927  ** 0 on success, -1 on failure
928  */
929  int add_companion_crowd(diguyCrowd* companion_crowd);
930 
931  /*l
932  *b Description:
933  **
934  ** This function removes the specified crowd as a companion crowd.
935  **
936  *b Arguments:
937  **
938  *a companion_crowd - name of former companion
939  **
940  *b Returns:
941  **
942  ** 0 on success, -1 on failure
943  */
944  int remove_companion_crowd(diguyCrowd* companion_crowd);
945 
946 
947 /*****************************************************************************/
957  /*l
958  *b Description:
959  **
960  ** This function sets the dynamic avoidance method that members of
961  ** this crowd will use to avoid each other. Dynamic objects are
962  ** objects that are moving around; these are almost always characters.
963  **
964  ** The enumeration is defined in diguy_constants.h.
965  **
966  *b Arguments:
967  **
968  *a method - avoidance method to use
969  **
970  *b Returns:
971  **
972  ** 0 on success, -1 on failure
973  */
974  void set_dynamic_object_avoidance_method(diguyDynamicAvoidanceMethod method);
975 
976  /*l
977  *b Returns:
978  **
979  ** current dynamic object avoidance method;
980  ** see set_dynamic_object_avoidance_method()
981  */
982  diguyDynamicAvoidanceMethod get_dynamic_object_avoidance_method();
983 
984  /*l
985  *b Description:
986  **
987  ** This function sets the static avoidance method that members of this
988  ** crowd will use to avoid walking through fixed walls and objects.
989  ** Usually these are scene objects and fixed props.
990  **
991  ** The enumeration is defined in diguy_constants.h.
992  **
993  *b Arguments:
994  **
995  *a method - avoidance method to use
996  **
997  *b Returns:
998  **
999  ** 0 on success, -1 on failure
1000  */
1001  void set_static_object_avoidance_method(diguyStaticAvoidanceMethod method);
1002 
1003  /*l
1004  *b Returns:
1005  **
1006  ** current static object avoidance method;
1007  ** see set_static_object_avoidance_method()
1008  */
1009  diguyStaticAvoidanceMethod get_static_object_avoidance_method();
1010 
1011 
1012 /*****************************************************************************/
1022  /*l
1023  *b Description:
1024  **
1025  ** Many of the diguyCrowd callbacks set a callback character which
1026  ** represents if there was a particular character that the callback
1027  ** relates to. A few of the callbacks do not set this value.
1028  **
1029  *b Returns:
1030  **
1031  ** pointer of type diguyCharacter; NULL if there was no associated
1032  ** character
1033  */
1034  diguyCharacter* get_callback_character();
1035 
1036  /*l
1037  *b Description:
1038  **
1039  ** Many of the diguyCrowd callbacks set a callback impact which
1040  ** represents if there was impact that the callback relates to. A few
1041  ** of the callbacks do not set this value.
1042  **
1043  *b Returns:
1044  **
1045  ** pointer of type diguyImpact; NULL if there was no associated
1046  ** impact
1047  */
1048  diguyImpact* get_callback_impact();
1049 
1050  /*l
1051  *b Description:
1052  **
1053  ** This is an enumeration of the different callbacks that can be
1054  ** registered with add_callback() and add_callback_script().
1055  **
1056  *i CALLBACK_ID_CREATE
1057  **
1058  ** This callback will be called when a new crowd is created.
1059  **
1060  ** Note that this callback can only be added by calling
1061  ** diguyScenario::add_default_crowd_callback(); adding it
1062  ** with diguyCrowd::add_callback() will have no effect, as
1063  ** by that time the crowd has already been created.
1064  ** There is no associated callback character.
1065  **
1066  *i CALLBACK_ID_DESTROY
1067  **
1068  ** This callback will be called when a crowd is destroyed. There
1069  ** is no associated callback character.
1070  **
1071  *i CALLBACK_ID_CROWD_MEMBER_KILLED
1072  **
1073  ** This callback will be called when a member of the crowd is
1074  ** killed.
1075  **
1076  *- - The callback character is the crowd member that was killed.
1077  *- - The callback impact contains the impact information.
1078  **
1079  *i CALLBACK_ID_CROWD_MEMBER_IMPACT
1080  **
1081  ** Similar to diguyCharacter::CALLBACK_ID_IMPACT, this callback will
1082  ** be called when a member of the crowd is hit by a detonation. If
1083  ** this callback isn't present the impacted character automatically
1084  ** will die. Handling this callback allows for the implementation
1085  ** of custom damage models at a crowd level.
1086  **
1087  *- - The callback character is the crowd member that was hit.
1088  *- - The callback impact contains the impact information.
1089  **
1090  *i CALLBACK_ID_NEARBY_SCENE_OBJECT_IMPACT
1091  **
1092  ** This callback will be called when a detonation occurs within the
1093  ** awareness radius (as set by set_awareness_radius()) of the
1094  ** crowd's current bounds.
1095  **
1096  *- - The callback character is the character that caused the
1097  *- detonation.
1098  *- - The callback impact contains the impact information.
1099  **
1100  *i CALLBACK_ID_NEARBY_WEAPON_FIRED
1101  **
1102  ** This callback will be called when a weapon is fired within the
1103  ** awareness radius (as set by set_awareness_radius()) of the
1104  ** crowd's current bounds.
1105  **
1106  *- - The callback character is the character that fired the weapon.
1107  **
1108  ** Callbacks return a value of type diguyCallbackReturn,
1109  ** which will be DIGUY_CALLBACK_STOP or DIGUY_CALLBACK_CONTINUE.
1110  ** If the callback returns DIGUY_CALLBACK_STOP, the default handler
1111  ** of the function will not be called; the callback is asserting
1112  ** that it has done everything necessary for the function call.
1113  ** If the callback returns DIGUY_CALLBACK_CONTINUE, the default
1114  ** handler for the function will be called after the callback.
1115  **
1116  *b Usable From:
1117  **
1118  *- - C++
1119  *- - Script
1120  */
1121  enum {
1122  CALLBACK_ID_CREATE = 1,
1123  CALLBACK_ID_DESTROY,
1124  CALLBACK_ID_CROWD_MEMBER_KILLED,
1125  CALLBACK_ID_CROWD_MEMBER_IMPACT,
1126  CALLBACK_ID_NEARBY_SCENE_OBJECT_IMPACT,
1127  CALLBACK_ID_NEARBY_WEAPON_FIRED,
1128 
1129  };
1130 
1131 #ifdef CPLUSPLUS_ONLY
1132 
1133  /*l
1134  *b Description:
1135  **
1136  ** This function adds a user callback. Callbacks can be removed with
1137  ** remove_callback() or remove_callback_with_user_data().
1138  **
1139  *b Arguments:
1140  **
1141  *a callback - pointer to function with prototype
1142  *a diguyCrowdRegionCallback (typedefed above)
1143  *a callback_id - integer id of when this callback is to be called
1144  *a callback_params - not currently used; pass NULL
1145  *a callback_user_data - pointer for user's own use; DI-Guy will
1146  *a do nothing to the contents of this pointer
1147  *a beyond passing it back when the callback is
1148  *a invoked
1149  **
1150  *b Returns:
1151  **
1152  ** 0 on success, -1 on failure
1153  **
1154  *b Callable From:
1155  **
1156  *- - C++
1157  */
1158  int add_callback(int callback_id,
1159  diguyCrowdCallback* callback,
1160  void* callback_params = 0,
1161  void* callback_user_data = 0);
1162 
1163  /*l
1164  *b Description:
1165  **
1166  ** This function removes a user callback. All callbacks matching
1167  ** the specified callback_id and callback function will be removed.
1168  **
1169  *b Arguments:
1170  **
1171  *a callback_id - integer id of when this callback is to be called
1172  *a callback - pointer to function with prototype
1173  *a diguyCrowdCallback (typedefed above)
1174  **
1175  *b Returns:
1176  **
1177  ** 0 on success, -1 on failure
1178  */
1179  int remove_callback(int callback_id,
1180  diguyCrowdCallback* callback);
1181 
1182  /*l
1183  *b Description:
1184  **
1185  ** This function removes a user callback. All callbacks matching the
1186  ** specified callback_id and callback_user_data pointer will be
1187  ** removed.
1188  **
1189  *b Arguments:
1190  **
1191  *a callback_id - integer id of when this callback is to be called
1192  *a callback_user_data - pointer for user's own use
1193  **
1194  *b Returns:
1195  **
1196  ** 0 on success, -1 on failure
1197  */
1198  int remove_callback_with_user_data(int callback_id,
1199  void* callback_user_data);
1200 
1201 #endif
1202 
1203  /*l
1204  *b Description:
1205  **
1206  ** This function adds a user callback script. Callback scripts can be
1207  ** removed with remove_callback_script().
1208  **
1209  ** See diguyCharacter::add_callback_script() for an example of use.
1210  **
1211  *b Arguments:
1212  **
1213  *a callback_id - integer id of the callback
1214  *a callback_script - script text of callback to be added
1215  *a callback_script_type - the type of script contained in
1216  *a callback_script
1217  **
1218  ** If NULL is passed for callback_script_type, a default script type
1219  ** will be derived based on the default script interpreter of the
1220  ** scenario.
1221  **
1222  *i lua specific:
1223  **
1224  ** When the script is called, the object for which it is being called
1225  ** will be in the callback_object global.
1226  **
1227  ** To pass NULL when calling from a lua script, use nil.
1228  **
1229  *b Returns:
1230  **
1231  ** 0 on success, -1 on failure
1232  */
1233  int add_callback_script(int callback_id,
1234  const char* callback_script,
1235  const char* callback_script_type = NULL);
1236 
1237  /*l
1238  *b Description:
1239  **
1240  ** This function removes a user callback script previously added with
1241  ** add_callback_script().
1242  **
1243  ** See diguyCharacter::remove_callback_script() for an example of use.
1244  **
1245  *b Arguments:
1246  **
1247  *a callback_id - integer id of the callback
1248  *a callback_script - script text of callback previously added
1249  *a callback_script_type - the type of script contained in
1250  *a callback_script
1251  **
1252  ** If NULL is passed for callback_script, all callback scripts whose
1253  ** ids match callback_id and whose types match callback_script_type
1254  ** will be removed.
1255  **
1256  ** If NULL is passed for callback_script_type, a default script type
1257  ** will be derived based on the default script interpreter of the
1258  ** scenario.
1259  **
1260  *i lua specific:
1261  **
1262  ** To pass NULL when calling from a lua script, use nil.
1263  **
1264  *b Returns:
1265  **
1266  ** 0 on success, -1 on failure
1267  */
1268  int remove_callback_script(int callback_id,
1269  const char* callback_script,
1270  const char* callback_script_type = NULL);
1271 
1272 #ifdef CPLUSPLUS_ONLY
1273 
1274  /*l
1275  *b Description:
1276  **
1277  ** Equivalent to calling diguyCharacter::add_callback() for all
1278  ** members of the crowd.
1279  **
1280  ** *Note*: callback_id should be a *diguyCharacter* id, not a
1281  ** diguyCrowd id.
1282  **
1283  *b Callable From:
1284  **
1285  *- - C++
1286  */
1287  void all_members_add_character_callback(int callback_id,
1288  diguyCharacterCallback* callback,
1289  void* callback_params = NULL,
1290  void* callback_user_data = NULL);
1291 
1292  /*l
1293  *b Description:
1294  **
1295  ** Equivalent to calling diguyCharacter::remove_callback() for all
1296  ** members of the crowd.
1297  **
1298  ** *Note*: callback_id should be a *diguyCharacter* id, not a
1299  ** diguyCrowd id.
1300  **
1301  *b Callable From:
1302  **
1303  *- - C++
1304  */
1305  void all_members_remove_character_callback(int callback_id,
1306  diguyCharacterCallback* callback);
1307 
1308  /*l
1309  *b Description:
1310  **
1311  ** Equivalent to calling diguyCharacter::remove_callback_with_user_data()
1312  ** for all members of the crowd.
1313  **
1314  ** *Note*: callback_id should be a *diguyCharacter* id, not a
1315  ** diguyCrowd id.
1316  **
1317  *b Callable From:
1318  **
1319  *- - C++
1320  */
1321  void all_members_remove_character_callback_with_user_data(int callback_id,
1322  void* callback_user_data);
1323 
1324 #endif
1325 
1326  /*l
1327  *b Description:
1328  **
1329  ** Equivalent to calling diguyCharacter::add_callback_script() for all
1330  ** members of the crowd.
1331  **
1332  ** *Note*: callback_id should be a *diguyCharacter* id, not a
1333  ** diguyCrowd id.
1334  */
1335  void all_members_add_character_callback_script(int callback_id,
1336  const char* callback_script,
1337  const char* callback_script_type = NULL);
1338 
1339  /*l
1340  *b Description:
1341  **
1342  ** Equivalent to calling diguyCharacter::remove_callback_script() for
1343  ** all members of the crowd.
1344  **
1345  ** *Note*: callback_id should be a *diguyCharacter* id, not a
1346  ** diguyCrowd id.
1347  */
1348  void all_members_remove_character_callback_script(int callback_id,
1349  const char* callback_script,
1350  const char* callback_script_type = NULL);
1351 
1352 
1353 
1354 /*****************************************************************************/
1364  /*l
1365  *b Description:
1366  **
1367  ** This function maps the event handler with the given name to a
1368  ** callback id. This mapping will be saved in the .dss file and
1369  ** restored when the .dss file is loaded.
1370  **
1371  ** Mappings can also be made via the DI-Guy Scenario UI.
1372  **
1373  ** The event handler is one of the following:
1374  **
1375  *- - a scene object callback function registered by
1376  *- diguyScenario::register_crowd_event_handler() or
1377  *- diguyScenario::register_crowd_event_handler_from_library()
1378  *- - a script registered by
1379  *- diguyScenario::register_crowd_event_handler_script()
1380  *- - a Script, Decision, or Library Function in the scenario
1381  *- whose "Event Type" is "Crowd"
1382  **
1383  *b Arguments:
1384  **
1385  *a callback_id - integer id of callback
1386  *a handler_name - name of the event handler to map
1387  **
1388  *b Returns:
1389  **
1390  ** 0 on success, -1 on failure
1391  */
1392  int map_event_handler_to_callback_id(int callback_id,
1393  const char* handler_name);
1394 
1395  /*l
1396  *b Description:
1397  **
1398  ** This function unmaps the event handler with the given name from a
1399  ** callback id.
1400  **
1401  *b Arguments:
1402  **
1403  *a callback_id - integer id of callback
1404  *a handler_name - name of the event handler to map
1405  *a unmap_all_matches - pass 0 to unmap only the first match,
1406  *a pass 1 to unmap all matches
1407  **
1408  *b Returns:
1409  **
1410  ** 0 on success, -1 on failure
1411  */
1412  int unmap_event_handler_from_callback_id(int callback_id,
1413  const char* handler_name,
1414  int unmap_all_matches = 0);
1415 
1416 
1417 /*****************************************************************************/
1427  /*l
1428  *b Returns:
1429  **
1430  ** diguyRegion associated with the crowd; will be created if it
1431  ** doesn't currently exist
1432  */
1433  diguyRegion* find_or_create_region();
1434 
1435  /*l
1436  *b Returns:
1437  **
1438  ** diguyRegion associated with the crowd; may be NULL
1439  */
1440  diguyRegion* get_region();
1441 
1442 
1443 /*****************************************************************************/
1453  /*l
1454  *b Description:
1455  **
1456  ** Equivalent to calling diguyCharacter::agent_accept_message() for
1457  ** all members of the crowd.
1458  **
1459  *b Arguments:
1460  **
1461  *a message_type - what type of message is being sent
1462  *a message - the message string
1463  *a message_params - optional parameter string
1464  */
1465  void send_message_to_all_members(const char* message_type,
1466  const char* message,
1467  const char* message_params = NULL);
1468 
1469 
1470 /*****************************************************************************/
1475 
1476  void set_unit_type(diguyTacticsUnitType tut);
1477  diguyTacticsUnitType get_unit_type();
1478 
1480  int set_unit_leader(diguyCharacter* leader);
1481  diguyCharacter* get_unit_leader();
1482 
1483 
1484 /****************************************************************************/
1485 /****************************************************************************/
1486 /****************************************************************************/
1493 /****************************************************************************/
1494 /****************************************************************************/
1495 /****************************************************************************/
1496 
1497 
1502 #ifdef CPLUSPLUS_ONLY
1503 
1504  bdiScenarioCrowd* get_scripted_object() {return m_scripted_object;}
1505 
1506 private:
1507 
1508  /*l
1509  ** A private constructor.
1510  */
1511  diguyCrowd(bdiScenarioCrowd* scripted_object);
1512 
1513  /*l
1514  ** A private destructor.
1515  */
1516  virtual ~diguyCrowd();
1517 
1518  /*l
1519  ** A pointer to internal data.
1520  */
1521  bdiScenarioCrowd* m_scripted_object;
1522 
1523  friend class bdiScenarioCrowd;
1524 
1525 #endif
1526 
1527 };
1528 
1529 
1530 #endif /* __diguyCrowd_H */
1531 
1532 
1533 /*********************************************************************
1534  ** Copyright (c) 1992-2014 VT MAK
1535  ** All rights reserved.
1536  *********************************************************************/
1537