Adonthell  0.4
mapcharacter.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 1999/2000/2001 Alexandre Courbot
3  Part of the Adonthell Project <http://adonthell.nongnu.org>
4 
5  Adonthell is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  Adonthell is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with Adonthell. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 
20 
21 /**
22  * @file mapcharacter.h
23  *
24  * @author Alexandre Courbot <alexandrecourbot@linuxgames.com>
25  * @brief Declares the mapcharacter class.
26  */
27 
28 
29 
30 #ifndef MAPCHARACTER_H_
31 #define MAPCHARACTER_H_
32 
33 /**
34  * Where mapcharacter files resides.
35  *
36  */
37 #define MAPCHAR_DIR "gfx/mapcharacters/"
38 
39 #include "animation.h"
40 #include "character_base.h"
41 #include "path.h"
42 #include "text_bubble.h"
43 #include "event_list.h"
44 
45 class landmap;
46 class path;
47 
48 /**
49  * @name mapcharacter moves.
50  *
51  */
52 //@{
53 
54 /**
55  * Standing North.
56  *
57  */
58 #define STAND_NORTH 0
59 
60 /**
61  * Standing South.
62  *
63  */
64 #define STAND_SOUTH 1
65 
66 /**
67  * Standing West.
68  *
69  */
70 #define STAND_WEST 2
71 
72 /**
73  * Standing East.
74  *
75  */
76 #define STAND_EAST 3
77 
78 /**
79  * Walking North.
80  *
81  */
82 #define WALK_NORTH 4
83 
84 /**
85  * Walking South.
86  *
87  */
88 #define WALK_SOUTH 5
89 
90 /**
91  * Walking West.
92  *
93  */
94 #define WALK_WEST 6
95 
96 /**
97  * Walking East.
98  *
99  */
100 #define WALK_EAST 7
101 
102 /**
103  * Total number of moves.
104  *
105  */
106 #define NBR_MOVES 8
107 
108 /**
109  * No move.
110  *
111  */
112 #define NO_MOVE 65535
113 
114 //@}
115 
116 class mapview;
117 
118 
119 
120 /**
121  * Representation of characters on a landmap.
122  *
123  * Like mapobjects, mapcharacters are a set of animations (one for every movment)
124  * and a grid of mapsquare_walkables. This grid represents the map area the mapcharacter
125  * physically occupies, which means that a mapcharacter can occupies several tiles.
126  *
127  * During the execution of Python scripts, some mapcharacter-local variables are
128  * available:
129  * @li myself is a pointer to the character holding this mapcharacter (can of course
130  * serve as a mapcharacter pointer, as character inheritates from mapcharacter).
131  * @li mymap, if defined, points to the landmap the mapcharacter is on.
132  *
133  * These Python variables are available both for schedules and actions.
134  *
135  * In supplement, actions have an extra variable available:
136  * @li requester, which points to the mapcharacter that requested the action.
137  *
138  */
140 {
141 public:
142 
143  /**
144  * Default constructor.
145  *
146  */
147  mapcharacter ();
148 
149  /**
150  * Destructor.
151  *
152  */
153  ~mapcharacter ();
154 
155  /**
156  * Puts the mapcharacter back to it's post-constructor state.
157  *
158  */
159  void clear ();
160 
161  /**
162  * Returns the current file name of the mapcharacter.
163  *
164  *
165  * @return filename of the mapcharacter.
166  */
167  string filename () const
168  {
169  return filename_;
170  }
171 
172  /**
173  * @name State updating
174  *
175  */
176  //@{
177 
178  /**
179  * Updates the mapcharacter's state and launchs his schedule.
180  *
181  */
182  bool update ();
183 
184  //@}
185 
186 
187  /**
188  * @name Drawing methods
189  *
190  */
191  //@{
192 
193  void draw (s_int16 x, s_int16 y, const drawing_area * da_opt = NULL, surface * target = NULL) const;
194  void draw_bubble (s_int16 x, s_int16 y, const drawing_area * da_opt = NULL, surface * target = NULL) const;
195 
196  //@}
197 
198 
199  /**
200  * @name Loading/Saving methods
201  *
202  * @note You can't save mapcharacters with this class.
203  */
204  //@{
205 
206  /**
207  * Loads a mapcharacter from an opened file.
208  * @param file the opened file from which to load.
209  * @return 0 in case of success, error code otherwise.
210  *
211  */
212  s_int8 get (igzstream& file);
213 
214  /**
215  * Loads a mapcharacter from it's filename.
216  *
217  * @param fname the name of the file to load.
218  *
219  * @return 0 in case of success, error code otherwise.
220  */
221  s_int8 load (string fname);
222 
223  /** Saves an mapcharacter into an opened file, in %game format, with
224  * alpha and mask values.
225  * @warning as the mapcharacter which is saved comes from a %screen's depth
226  * surface, it will be slightly altered during the save.
227  * If you want a class capable of saving mapcharacters with full
228  * truecolor quality, use mapcharacter_edit instead.
229  * @param file opened file where to save into.
230  * @return
231  * @li 0 in case of success.
232  * @li -1 in case of error.
233  * @sa save ()
234  */
235  s_int8 put (ogzstream& file) const;
236 
237  /** Saves an mapcharacter into an file, in %game format, with
238  * alpha and mask values.
239  * @warning as the mapcharacter which is saved comes from a %screen's depth
240  * surface, it will be slightly altered during the save.
241  * If you want a class capable of saving mapcharacters with full
242  * truecolor quality, use mapcharacter_edit instead.
243  * @param fname file name where to save into.
244  * @return
245  * @li 0 in case of success.
246  * @li -1 in case of error.
247  * @sa put ()
248  */
249  s_int8 save (string fname) const;
250  //@}
251 
252 
253  /**
254  * @name State loading/saving methods
255  *
256  */
257  //@{
258 
259  /**
260  * Restore the mapcharacter's state from an opened file.
261  *
262  * @param file the opened file from which to load the state.
263  *
264  * @return 0 in case of success, error code otherwise.
265  */
266  s_int8 get_state (igzstream& file);
267 
268  /**
269  * Saves the mapcharacter's state into an opened file.
270  *
271  * @param file the opened file where to the state.
272  *
273  * @return 0 in case of success, error code otherwise.
274  */
275  s_int8 put_state (ogzstream& file) const;
276 
277  //@}
278 
279 
280 
281  /**
282  * @name Landmap assignment
283  *
284  */
285  //@{
286 
287  /**
288  * Puts the mapcharacter on a landmap.
289  * This methods can only be applied if the mapcharacter isn't on any landmap
290  * when it is called, otherwise nothing will occur.
291  *
292  * @warning Be aware that once this methods is called, the mapcharacter has NO
293  * position on the landmap. You MUST call jump_to () after this method to actually
294  * have placed the character on the map.
295  *
296  * @param m pointer to the landmap the mapcharacter should be on.
297  */
298  void set_map (landmap * m);
299 
300  /**
301  * Removes the mapcharacter from the landmap he was on (if any).
302  *
303  */
304  void remove_from_map ();
305 
306  /**
307  * Returns a pointer to the landmap the mapcharacter is on.
308  *
309  *
310  * @return pointer to the landmap the mapcharacter is on (NULL if none).
311  */
312  landmap * mymap () const
313  {
314  return refmap;
315  }
316 
317  //@}
318 
319  /**
320  * @name High-level control
321  *
322  * These methods provide a simple way to control the mapcharacter on the map he's on.
323  * They cover "normal" moves like walking or looking into a direction, plus tests to
324  * know whether a move is possible or not.
325  *
326  */
327  //@{
328 
329  /**
330  * Look to North.
331  *
332  */
333  void stand_north ();
334 
335  /**
336  * Look to South.
337  *
338  */
339  void stand_south ();
340 
341  /**
342  * Look to East.
343  *
344  */
345  void stand_east ();
346 
347  /**
348  * Look to West.
349  *
350  */
351  void stand_west ();
352 
353  /**
354  * Stand to the current direction.
355  *
356  * @note This method only serves to abord an expected waking movment.
357  *
358  */
359  void stand ();
360 
361  /**
362  * Walk to North (if possible).
363  *
364  * This method asks the mapcharacter to walk one square to North. If the
365  * movment isn't possible (non-walkable mapsquare or map limit), the
366  * character will stand_north () instead.
367  *
368  * @note Each time update () is called, the mapcharacter will continue advancing,
369  * until he reaches the next mapsquare.
370  *
371  */
372  bool go_north ();
373 
374  /**
375  * Walk to South (if possible).
376  *
377  * This method asks the mapcharacter to walk one square to South. If the
378  * movment isn't possible (non-walkable mapsquare or map limit), the
379  * character will stand_south () instead.
380  *
381  * @note Each time update () is called, the mapcharacter will continue advancing,
382  * until he reaches the next mapsquare.
383  *
384  */
385  bool go_south ();
386 
387  /**
388  * Walk to East (if possible).
389  *
390  * This method asks the mapcharacter to walk one square to East. If the
391  * movment isn't possible (non-walkable mapsquare or map limit), the
392  * character will stand_east () instead.
393  *
394  * @note Each time update () is called, the mapcharacter will continue advancing,
395  * until he reaches the next mapsquare.
396  *
397  */
398  bool go_east ();
399 
400  /**
401  * Walk to West (if possible).
402  *
403  * This method asks the mapcharacter to walk one square to West. If the
404  * movment isn't possible (non-walkable mapsquare or map limit), the
405  * character will stand_west () instead.
406  *
407  * @note Each time update () is called, the mapcharacter will continue advancing,
408  * until he reaches the next mapsquare.
409  *
410  */
411  bool go_west ();
412 
413  /**
414  * Returns whether it is possible or not to go to North from
415  * the current mapcharacter's position.
416  *
417  *
418  * @return \c true if it is possible to go to North, \c false otherwise.
419  */
420  bool can_go_north () const;
421 
422  /**
423  * Returns whether it is possible or not to go to South from
424  * the current mapcharacter's position.
425  *
426  *
427  * @return \c true if it is possible to go to South, \c false otherwise.
428  */
429  bool can_go_south () const;
430 
431  /**
432  * Returns whether it is possible or not to go to East from
433  * the current mapcharacter's position.
434  *
435  *
436  * @return \c true if it is possible to go to East, \c false otherwise.
437  */
438  bool can_go_east ()const;
439 
440  /**
441  * Returns whether it is possible or not to go to West from
442  * the current mapcharacter's position.
443  *
444  *
445  * @return \c true if it is possible to go to West, \c false otherwise.
446  */
447  bool can_go_west () const;
448 
449  /**
450  * Look at the opposite position of p.
451  *
452  * This method is usefull for dialogues, when we want two
453  * characters to face each other.
454  *
455  *
456  * @param p opposite position of the position to look at. Can be
457  * \c STAND_NORTH, \c STAND_SOUTH, \c STAND_EAST or \c STAND_WEST.
458  */
459  void look_invert (u_int16 p);
460 
461  /**
462  * Return a pointer to the mapcharacter that is right next to this
463  * mapcharacter, i.e the mapcharacter that is on the square this
464  * mapcharacter is looking at.
465  *
466  * If no mapcharacter is next to this one, NULL will be returned.
467  *
468  *
469  * @return pointer to the mapcharacter next to this mapcharacter.
470  */
471  mapcharacter *whosnext () const;
472 
473  void speak (const string & text);
474 
475  bool is_speaking ()
476  {
477  return (saying != NULL);
478  }
479 
480  text_bubble * get_bubble ()
481  {
482  return saying;
483  }
484  //@}
485 
486 
487  /**
488  * @name Low-level controls
489  *
490  * If you need to do non-conventionnal or special things (like
491  * teleport a character from a position to another), or need
492  * to override the walkable mechanism, use these methods.
493  *
494  * You are also provided with various informative methods.
495  *
496  */
497  //@{
498 
499  /**
500  * Sets the offset of the mapcharacter on it's current mapsquare.
501  *
502  * @param x X offset.
503  * @param y Y offset.
504  */
506  {
507  offx_ = x;
508  offy_ = y;
509  }
510 
511  /**
512  * Removes the mapcharacter from the place he was on the map.
513  *
514  */
515  void remove_from_pos ();
516 
517  /**
518  * Remove the mapcharacter from it's current place and put him to a new one.
519  *
520  * @param smap index of the submap to jump to.
521  * @param x X offset to to.
522  * @param y Y offset to to.
523  * @param pos Position to adopt once placed.
524  */
525  void jump_to (u_int16 smap, u_int16 x, u_int16 y, u_int16 pos = NO_MOVE);
526 
527  /**
528  * Returns the index of the submap where the mapcharacter is.
529  *
530  *
531  * @return the index of the submap where the mapcharacter is.
532  */
533  u_int16 submap () const
534  {
535  return submap_;
536  }
537 
538  /**
539  * Returns the X position of the mapcharacter.
540  *
541  *
542  * @return the X position of the mapcharacter on his map.
543  */
544  u_int16 posx () const
545  {
546  return posx_;
547  }
548 
549  /**
550  * Returns the Y position of the mapcharacter.
551  *
552  *
553  * @return the Y position of the mapcharacter on his map.
554  */
555  u_int16 posy () const
556  {
557  return posy_;
558  }
559 
560  /**
561  * Returns the X offset of the mapcharacter.
562  *
563  *
564  * @return the X offset of the mapcharacter on his map.
565  */
566  s_int8 offx () const
567  {
568  return offx_;
569  }
570 
571  /**
572  * Returns the Y offset of the mapcharacter.
573  *
574  *
575  * @return the Y offset of the mapcharacter on his map.
576  */
577  s_int8 offy () const
578  {
579  return offy_;
580  }
581 
582  /**
583  * Returns the current move of the mapcharacter.
584  *
585  *
586  * @return current mapcharacter's move (STAND_NORTH, WALK_SOUTH, etc...).
587  */
589  {
590  return current_move;
591  }
592 
593  bool set_goal (u_int16 x, u_int16 y, u_int16 dir = NO_MOVE);
594  void set_callback (PyObject *callback, PyObject *args = NULL);
595  bool follow_path ();
596  bool goal_reached ();
597  void stop_moving ();
598 
599  void time_callback (string delay, PyObject *cb, PyObject *args = NULL);
600  void time_callback_string (string delay, string cb, PyObject *args = NULL);
601  //@}
602 
603 
604  /**
605  * Schedule control.
606  *
607  */
608 
609  //@{
610 
611  /**
612  * Assign a schedule to the mapcharacter.
613  *
614  * The schedule's filename will be \e "scripts/schedules/mapcharacters/<file>.py".
615  *
616  * @param file name of the schedule to use.
617  * @param args Python tuple containing extra arguments passed to the class constructor.
618  *
619  * @warning the args tuple argument MUST ONLY contain strings or integers, as it will
620  * be saved with the mapcharacter state by python::put_tuple ().
621  *
622  */
623  void set_schedule (string file, PyObject * args = NULL);
624 
625  /**
626  * Returns the name of the mapcharacter's current schedule.
627  *
628  *
629  * @return name of the mapcharacter's current schedule.
630  */
631  string schedule_file () const
632  {
633  return schedule_file_;
634  }
635 
636  /**
637  * Returns whether the schedule is activated or not.
638  *
639  *
640  * @return \c true if the schedule is activated, \c false otherwise.
641  */
642  bool is_schedule_activated () const
643  {
644  return schedule_activated;
645  }
646 
647  /**
648  * Sets whether the schedule is active or not.
649  *
650  * @param a \c true if the schedule should be activated, \c false otherwise.
651  */
652  void set_schedule_active (bool a)
653  {
654  if (a && !schedule.has_attribute ("run")) return;
655  schedule_activated = a;
656  }
657 
658  /**
659  * Tell the character to do something. Will execute the given method
660  * of the current schedule with the given arguments.
661  *
662  * @param method The method of the schedule to call.
663  * @param args The arguments to pass to the method.
664  *
665  * @return \c true if the method has been called, \c false otherwise.
666  */
667  bool do_stuff (string method, PyObject *args = NULL);
668  //@}
669 
670 
671  /**
672  * Action control.
673  *
674  */
675 
676  //@{
677 
678  /**
679  * Assign a action to the mapcharacter.
680  *
681  * The action's filename will be \e "scripts/actions/<file>.py".
682  *
683  * @param file name of the action to use.
684  * @param args Python tuple containing extra arguments passed to the class constructor.
685  *
686  * @warning the args tuple argument MUST ONLY contain strings or integers, as it will
687  * be saved with the mapcharacter state by python::put_tuple ().
688  *
689  */
690  void set_action (string file, PyObject * args = NULL);
691 
692  /**
693  * Returns the name of the mapcharacter's current action.
694  *
695  *
696  * @return name of the mapcharacter's current action.
697  */
698  string action_file () const
699  {
700  return action_file_;
701  }
702 
703  /**
704  * Returns whether the action is activated or not.
705  *
706  *
707  * @return \c true if the action is activated, \c false otherwise.
708  */
709  bool is_action_activated () const
710  {
711  return action_activated;
712  }
713 
714  /**
715  * Sets whether the action is active or not.
716  *
717  * @param a \c true if the action should be activated, \c false otherwise.
718  */
719  void set_action_active (bool a)
720  {
721  action_activated = a;
722  }
723 
724  /**
725  * Run the mapcharacter's action, passing requester as the "requester" parameter
726  * for the action's Python script.
727  *
728  * @param requester pointer to the mapcharacter that requested the action, which
729  * is passed to the Python run () method.
730  */
731  void launch_action (mapcharacter * requester);
732 
733  //@}
734 
735 
736  /**
737  * Returns a pointer to an animation corresponding
738  * to a movment.
739  *
740  * @param nbr index of the animation to get.
741  *
742  * @return pointer to the \e nbr animation.
743  */
745  {
746  return anim[nbr];
747  }
748 
749 #ifndef SWIG
750  /**
751  * Mapcharacter copy (similar to copy ()).
752  *
753  * @attention Not available from Python. Use copy () from Python instead.
754  * @sa copy ()
755  */
757 #endif // SWIG
758 
759  /**
760  * Synonym of operator = to guarantee its access from Python.
761  *
762  * @sa operator =
763  */
764  void copy (const mapcharacter& src)
765  {
766  *this = src;
767  }
768 
769 private:
770  /**
771  * Forbid value passing.
772  *
773  */
774  mapcharacter (const mapcharacter & src);
775 
776  /**
777  * Makes the mapcharacter physically occupy an area.
778  *
779  * The given parameters are considered to be where
780  * the mapcharacter's base square will be.
781  *
782  * @param smap submap where to occupy.
783  * @param px X position where to occupy.
784  * @param py Y position where to occupy.
785  */
786  void occupy (u_int16 smap, u_int16 px, u_int16 py);
787 
788  /**
789  * Makes the mapcharacter physically leave an area previously occupied
790  * with occupy ().
791  *
792  * The given parameters are considered to be where
793  * the mapcharacter's base square were be.
794  *
795  * @param smap submap where to leave.
796  * @param px X position where to leave.
797  * @param py Y position where to leave.
798  */
799  void leave (u_int16 smap, u_int16 px, u_int16 py);
800 
801  void leave_position ();
802 
803  /**
804  * Sets the position of the mapcharacter on the map.
805  *
806  * This sets the mapcharacter's position to the parameters,
807  * and occupy () the corresponding region.
808  *
809  * @warning Don't forget to leave () the region when moving!
810  *
811  * @param smap index of the submap where the mapcharacter should be.
812  * @param x X position on the submap.
813  * @param y Y position on the submap.
814  */
815  void set_pos (u_int16 smap, u_int16 x, u_int16 y);
816 
817  /**
818  * Updates the movment of the mapcharacter.
819  *
820  */
821  void update_move ();
822 
823 
824  /**
825  * Path used for the mapcharacter to have realistic movments.
826  *
827  */
828  path mypath;
829 
830  /**
831  * Used to count the position on the path
832  *
833  */
834  u_int16 pathindex;
835 
836  u_int16 current_move;
837  u_int16 previous_move;
838  u_int16 submap_;
839  u_int16 posx_, posy_;
840  s_int8 offx_, offy_;
841  vector <animation *> anim;
842  landmap *refmap;
843 
844  py_object schedule;
845  py_object action;
846 
847  string filename_;
848 
849  text_bubble * saying;
850 
851  bool schedule_activated;
852  bool action_activated;
853  bool goal_reached_;
854 
855  PyObject * schedule_args;
856  PyObject * action_args;
857 
858  string schedule_file_;
859  string action_file_;
860 
861  py_callback *callback;
862 
863 #ifndef SWIG
864  friend class landmap;
865 #endif
866 };
867 
868 #endif
s_int8 offy() const
Returns the Y offset of the mapcharacter.
Definition: mapcharacter.h:577
Class to write data from a Gzip compressed file.
Definition: fileops.h:227
s_int8 put_state(ogzstream &file) const
Saves the mapcharacter&#39;s state into an opened file.
#define NO_MOVE
No move.
Definition: mapcharacter.h:112
Displays neat little text speech bubbles.
Definition: text_bubble.h:46
Class to read data from a Gzip compressed file.
Definition: fileops.h:135
void set_schedule_active(bool a)
Sets whether the schedule is active or not.
Definition: mapcharacter.h:652
Declares the animationframe and animation classes.
~mapcharacter()
Destructor.
Definition: mapcharacter.cc:59
Python object class.
Definition: py_object.h:45
s_int8 offx() const
Returns the X offset of the mapcharacter.
Definition: mapcharacter.h:566
#define u_int16
16 bits long unsigned integer
Definition: types.h:38
u_int16 posx() const
Returns the X position of the mapcharacter.
Definition: mapcharacter.h:544
animation * get_animation(u_int16 nbr)
Returns a pointer to an animation corresponding to a movment.
Definition: mapcharacter.h:744
Declares the character_base class.
Declares the text_bubble class.
Class where drawables can actually be drawn to.
Definition: surface.h:85
bool go_south()
Walk to South (if possible).
s_int8 save(string fname) const
Saves an mapcharacter into an file, in game format, with alpha and mask values.
mapcharacter * whosnext() const
Return a pointer to the mapcharacter that is right next to this mapcharacter, i.e the mapcharacter th...
void look_invert(u_int16 p)
Look at the opposite position of p.
bool can_go_west() const
Returns whether it is possible or not to go to West from the current mapcharacter&#39;s position...
bool is_schedule_activated() const
Returns whether the schedule is activated or not.
Definition: mapcharacter.h:642
void stand_south()
Look to South.
bool update()
Updates the mapcharacter&#39;s state and launchs his schedule.
void set_action_active(bool a)
Sets whether the action is active or not.
Definition: mapcharacter.h:719
bool can_go_south() const
Returns whether it is possible or not to go to South from the current mapcharacter&#39;s position...
void remove_from_map()
Removes the mapcharacter from the landmap he was on (if any).
Base character class containing attributes and dialog stuff.
void jump_to(u_int16 smap, u_int16 x, u_int16 y, u_int16 pos=NO_MOVE)
Remove the mapcharacter from it&#39;s current place and put him to a new one.
string filename() const
Returns the current file name of the mapcharacter.
Definition: mapcharacter.h:167
mapcharacter()
Default constructor.
Definition: mapcharacter.cc:37
Allows you to display a landmap on a specified area of a surface.
Definition: mapview.h:48
landmap * mymap() const
Returns a pointer to the landmap the mapcharacter is on.
Definition: mapcharacter.h:312
void stand()
Stand to the current direction.
bool can_go_north() const
Returns whether it is possible or not to go to North from the current mapcharacter&#39;s position...
Implements "drawing zones" for drawing operations.
Definition: drawing_area.h:54
void stand_east()
Look to East.
void stand_west()
Look to West.
#define s_int16
16 bits long signed integer
Definition: types.h:47
u_int16 submap() const
Returns the index of the submap where the mapcharacter is.
Definition: mapcharacter.h:533
void clear()
Puts the mapcharacter back to it&#39;s post-constructor state.
Definition: mapcharacter.cc:67
bool is_action_activated() const
Returns whether the action is activated or not.
Definition: mapcharacter.h:709
A* pathfinding algorithm implementation class.
Definition: path.h:52
Declares the path class.
Map where the world takes place.
Definition: landmap.h:56
bool go_east()
Walk to East (if possible).
void set_map(landmap *m)
Puts the mapcharacter on a landmap.
void remove_from_pos()
Removes the mapcharacter from the place he was on the map.
Representation of characters on a landmap.
Definition: mapcharacter.h:139
mapcharacter & operator=(const mapcharacter &m)
Mapcharacter copy (similar to copy ()).
Area of mapsquare_walkables, for use with mapcharacter and mapobject classes.
Stores the C++ <-> Python callback binding.
Definition: py_callback.h:41
bool go_west()
Walk to West (if possible).
bool go_north()
Walk to North (if possible).
u_int16 posy() const
Returns the Y position of the mapcharacter.
Definition: mapcharacter.h:555
Class that handles animated elements, their update and their playback.
Definition: animation.h:312
s_int8 load(string fname)
Loads a mapcharacter from it&#39;s filename.
bool do_stuff(string method, PyObject *args=NULL)
Tell the character to do something.
u_int16 currentmove() const
Returns the current move of the mapcharacter.
Definition: mapcharacter.h:588
Base class for objects that want to register events.
Definition: event_list.h:56
string action_file() const
Returns the name of the mapcharacter&#39;s current action.
Definition: mapcharacter.h:698
Declares the event_list class.
void launch_action(mapcharacter *requester)
Run the mapcharacter&#39;s action, passing requester as the "requester" parameter for the action&#39;s Python...
s_int8 put(ogzstream &file) const
Saves an mapcharacter into an opened file, in game format, with alpha and mask values.
#define s_int8
8 bits long signed integer
Definition: types.h:44
void stand_north()
Look to North.
void copy(const mapcharacter &src)
Synonym of operator = to guarantee its access from Python.
Definition: mapcharacter.h:764
void set_offset(s_int8 x, s_int8 y)
Sets the offset of the mapcharacter on it&#39;s current mapsquare.
Definition: mapcharacter.h:505
void draw(s_int16 x, s_int16 y, const drawing_area *da_opt=NULL, surface *target=NULL) const
Draw the object on the screen.
s_int8 get_state(igzstream &file)
Restore the mapcharacter&#39;s state from an opened file.
void set_schedule(string file, PyObject *args=NULL)
Schedule control.
bool can_go_east() const
Returns whether it is possible or not to go to East from the current mapcharacter&#39;s position...
void set_action(string file, PyObject *args=NULL)
Action control.
string schedule_file() const
Returns the name of the mapcharacter&#39;s current schedule.
Definition: mapcharacter.h:631
bool has_attribute(const std::string &name)
Tests whether the object contains a certain attribute (i.e.
Definition: py_object.cc:134