Adonthell
0.4
|
Representation of characters on a landmap. More...
#include <mapcharacter.h>
Public Member Functions | |
mapcharacter () | |
Default constructor. | |
~mapcharacter () | |
Destructor. | |
void | clear () |
Puts the mapcharacter back to it's post-constructor state. | |
string | filename () const |
Returns the current file name of the mapcharacter. | |
animation * | get_animation (u_int16 nbr) |
Returns a pointer to an animation corresponding to a movment. | |
mapcharacter & | operator= (const mapcharacter &m) |
Mapcharacter copy (similar to copy ()). | |
void | copy (const mapcharacter &src) |
Synonym of operator = to guarantee its access from Python. | |
State updating | |
bool | update () |
Updates the mapcharacter's state and launchs his schedule. | |
Drawing methods | |
void | draw (s_int16 x, s_int16 y, const drawing_area *da_opt=NULL, surface *target=NULL) const |
Draw the object on the screen. | |
void | draw_bubble (s_int16 x, s_int16 y, const drawing_area *da_opt=NULL, surface *target=NULL) const |
Loading/Saving methods | |
| |
s_int8 | get (igzstream &file) |
Loads a mapcharacter from an opened file. | |
s_int8 | load (string fname) |
Loads a mapcharacter from it's filename. | |
s_int8 | put (ogzstream &file) const |
Saves an mapcharacter into an opened file, in game format, with alpha and mask values. | |
s_int8 | save (string fname) const |
Saves an mapcharacter into an file, in game format, with alpha and mask values. | |
State loading/saving methods | |
s_int8 | get_state (igzstream &file) |
Restore the mapcharacter's state from an opened file. | |
s_int8 | put_state (ogzstream &file) const |
Saves the mapcharacter's state into an opened file. | |
Landmap assignment | |
void | set_map (landmap *m) |
Puts the mapcharacter on a landmap. | |
void | remove_from_map () |
Removes the mapcharacter from the landmap he was on (if any). | |
landmap * | mymap () const |
Returns a pointer to the landmap the mapcharacter is on. | |
High-level control | |
These methods provide a simple way to control the mapcharacter on the map he's on. They cover "normal" moves like walking or looking into a direction, plus tests to know whether a move is possible or not. | |
void | stand_north () |
Look to North. | |
void | stand_south () |
Look to South. | |
void | stand_east () |
Look to East. | |
void | stand_west () |
Look to West. | |
void | stand () |
Stand to the current direction. | |
bool | go_north () |
Walk to North (if possible). | |
bool | go_south () |
Walk to South (if possible). | |
bool | go_east () |
Walk to East (if possible). | |
bool | go_west () |
Walk to West (if possible). | |
bool | can_go_north () const |
Returns whether it is possible or not to go to North from the current mapcharacter's position. | |
bool | can_go_south () const |
Returns whether it is possible or not to go to South from the current mapcharacter's position. | |
bool | can_go_east () const |
Returns whether it is possible or not to go to East from the current mapcharacter's position. | |
bool | can_go_west () const |
Returns whether it is possible or not to go to West from the current mapcharacter's position. | |
void | look_invert (u_int16 p) |
Look at the opposite position of p. | |
mapcharacter * | whosnext () const |
Return a pointer to the mapcharacter that is right next to this mapcharacter, i.e the mapcharacter that is on the square this mapcharacter is looking at. | |
void | speak (const string &text) |
bool | is_speaking () |
text_bubble * | get_bubble () |
Low-level controls | |
If you need to do non-conventionnal or special things (like teleport a character from a position to another), or need to override the walkable mechanism, use these methods. You are also provided with various informative methods. | |
void | set_offset (s_int8 x, s_int8 y) |
Sets the offset of the mapcharacter on it's current mapsquare. | |
void | remove_from_pos () |
Removes the mapcharacter from the place he was on the map. | |
void | jump_to (u_int16 smap, u_int16 x, u_int16 y, u_int16 pos=NO_MOVE) |
Remove the mapcharacter from it's current place and put him to a new one. | |
u_int16 | submap () const |
Returns the index of the submap where the mapcharacter is. | |
u_int16 | posx () const |
Returns the X position of the mapcharacter. | |
u_int16 | posy () const |
Returns the Y position of the mapcharacter. | |
s_int8 | offx () const |
Returns the X offset of the mapcharacter. | |
s_int8 | offy () const |
Returns the Y offset of the mapcharacter. | |
u_int16 | currentmove () const |
Returns the current move of the mapcharacter. | |
bool | set_goal (u_int16 x, u_int16 y, u_int16 dir=NO_MOVE) |
void | set_callback (PyObject *callback, PyObject *args=NULL) |
bool | follow_path () |
bool | goal_reached () |
void | stop_moving () |
void | time_callback (string delay, PyObject *cb, PyObject *args=NULL) |
void | time_callback_string (string delay, string cb, PyObject *args=NULL) |
void | set_schedule (string file, PyObject *args=NULL) |
Schedule control. | |
string | schedule_file () const |
Returns the name of the mapcharacter's current schedule. | |
bool | is_schedule_activated () const |
Returns whether the schedule is activated or not. | |
void | set_schedule_active (bool a) |
Sets whether the schedule is active or not. | |
bool | do_stuff (string method, PyObject *args=NULL) |
Tell the character to do something. | |
void | set_action (string file, PyObject *args=NULL) |
Action control. | |
string | action_file () const |
Returns the name of the mapcharacter's current action. | |
bool | is_action_activated () const |
Returns whether the action is activated or not. | |
void | set_action_active (bool a) |
Sets whether the action is active or not. | |
void | launch_action (mapcharacter *requester) |
Run the mapcharacter's action, passing requester as the "requester" parameter for the action's Python script. | |
Friends | |
class | landmap |
Representation of characters on a landmap.
Like mapobjects, mapcharacters are a set of animations (one for every movment) and a grid of mapsquare_walkables. This grid represents the map area the mapcharacter physically occupies, which means that a mapcharacter can occupies several tiles.
During the execution of Python scripts, some mapcharacter-local variables are available:
These Python variables are available both for schedules and actions.
In supplement, actions have an extra variable available:
Definition at line 135 of file mapcharacter.h.
Default constructor.
Definition at line 33 of file mapcharacter.cc.
Destructor.
Definition at line 55 of file mapcharacter.cc.
void mapcharacter::clear | ( | ) |
Puts the mapcharacter back to it's post-constructor state.
Reimplemented from event_list.
Definition at line 63 of file mapcharacter.cc.
string mapcharacter::filename | ( | ) | const [inline] |
Returns the current file name of the mapcharacter.
Definition at line 163 of file mapcharacter.h.
bool mapcharacter::update | ( | ) | [virtual] |
Updates the mapcharacter's state and launchs his schedule.
Reimplemented from drawable.
Definition at line 799 of file mapcharacter.cc.
void mapcharacter::draw | ( | s_int16 | x, |
s_int16 | y, | ||
const drawing_area * | da_opt = NULL , |
||
surface * | target = NULL |
||
) | const [virtual] |
Draw the object on the screen.
x | X position where to draw. |
y | Y position where to draw. |
da_opt | optional drawing_area to use during the drawing operation. |
target | pointer to the surface where to draw the drawable. If NULL, draw on the screen. |
Implements mapsquare_walkable_area.
Definition at line 834 of file mapcharacter.cc.
s_int8 mapcharacter::get | ( | igzstream & | file | ) |
Loads a mapcharacter from an opened file.
file | the opened file from which to load. |
Reimplemented from mapsquare_walkable_area.
Definition at line 90 of file mapcharacter.cc.
s_int8 mapcharacter::load | ( | string | fname | ) |
Loads a mapcharacter from it's filename.
fname | the name of the file to load. |
Definition at line 105 of file mapcharacter.cc.
s_int8 mapcharacter::put | ( | ogzstream & | file | ) | const |
Saves an mapcharacter into an opened file, in game format, with alpha and mask values.
file | opened file where to save into. |
Reimplemented from mapsquare_walkable_area.
Definition at line 123 of file mapcharacter.cc.
s_int8 mapcharacter::save | ( | string | fname | ) | const |
Saves an mapcharacter into an file, in game format, with alpha and mask values.
fname | file name where to save into. |
Definition at line 137 of file mapcharacter.cc.
s_int8 mapcharacter::get_state | ( | igzstream & | file | ) |
Restore the mapcharacter's state from an opened file.
file | the opened file from which to load the state. |
Reimplemented from character_base.
Definition at line 154 of file mapcharacter.cc.
s_int8 mapcharacter::put_state | ( | ogzstream & | file | ) | const |
Saves the mapcharacter's state into an opened file.
file | the opened file where to the state. |
Reimplemented from event_list.
Definition at line 214 of file mapcharacter.cc.
void mapcharacter::set_map | ( | landmap * | m | ) |
Puts the mapcharacter on a landmap.
This methods can only be applied if the mapcharacter isn't on any landmap when it is called, otherwise nothing will occur.
m | pointer to the landmap the mapcharacter should be on. |
Definition at line 259 of file mapcharacter.cc.
void mapcharacter::remove_from_map | ( | ) |
Removes the mapcharacter from the landmap he was on (if any).
Definition at line 268 of file mapcharacter.cc.
landmap* mapcharacter::mymap | ( | ) | const [inline] |
Returns a pointer to the landmap the mapcharacter is on.
Definition at line 308 of file mapcharacter.h.
void mapcharacter::stand_north | ( | ) |
Look to North.
Definition at line 330 of file mapcharacter.cc.
void mapcharacter::stand_south | ( | ) |
Look to South.
Definition at line 336 of file mapcharacter.cc.
void mapcharacter::stand_east | ( | ) |
Look to East.
Definition at line 342 of file mapcharacter.cc.
void mapcharacter::stand_west | ( | ) |
Look to West.
Definition at line 348 of file mapcharacter.cc.
void mapcharacter::stand | ( | ) |
Stand to the current direction.
Definition at line 321 of file mapcharacter.cc.
bool mapcharacter::go_north | ( | ) |
Walk to North (if possible).
This method asks the mapcharacter to walk one square to North. If the movment isn't possible (non-walkable mapsquare or map limit), the character will stand_north () instead.
Definition at line 487 of file mapcharacter.cc.
bool mapcharacter::go_south | ( | ) |
Walk to South (if possible).
This method asks the mapcharacter to walk one square to South. If the movment isn't possible (non-walkable mapsquare or map limit), the character will stand_south () instead.
Definition at line 501 of file mapcharacter.cc.
bool mapcharacter::go_east | ( | ) |
Walk to East (if possible).
This method asks the mapcharacter to walk one square to East. If the movment isn't possible (non-walkable mapsquare or map limit), the character will stand_east () instead.
Definition at line 515 of file mapcharacter.cc.
bool mapcharacter::go_west | ( | ) |
Walk to West (if possible).
This method asks the mapcharacter to walk one square to West. If the movment isn't possible (non-walkable mapsquare or map limit), the character will stand_west () instead.
Definition at line 529 of file mapcharacter.cc.
bool mapcharacter::can_go_north | ( | ) | const |
Returns whether it is possible or not to go to North from the current mapcharacter's position.
true
if it is possible to go to North, false
otherwise. Definition at line 354 of file mapcharacter.cc.
bool mapcharacter::can_go_south | ( | ) | const |
Returns whether it is possible or not to go to South from the current mapcharacter's position.
true
if it is possible to go to South, false
otherwise. Definition at line 387 of file mapcharacter.cc.
bool mapcharacter::can_go_east | ( | ) | const |
Returns whether it is possible or not to go to East from the current mapcharacter's position.
true
if it is possible to go to East, false
otherwise. Definition at line 421 of file mapcharacter.cc.
bool mapcharacter::can_go_west | ( | ) | const |
Returns whether it is possible or not to go to West from the current mapcharacter's position.
true
if it is possible to go to West, false
otherwise. Definition at line 454 of file mapcharacter.cc.
void mapcharacter::look_invert | ( | u_int16 | p | ) |
Look at the opposite position of p.
This method is usefull for dialogues, when we want two characters to face each other.
p | opposite position of the position to look at. Can be STAND_NORTH , STAND_SOUTH , STAND_EAST or STAND_WEST . |
Definition at line 678 of file mapcharacter.cc.
mapcharacter * mapcharacter::whosnext | ( | ) | const |
Return a pointer to the mapcharacter that is right next to this mapcharacter, i.e the mapcharacter that is on the square this mapcharacter is looking at.
If no mapcharacter is next to this one, NULL will be returned.
Definition at line 697 of file mapcharacter.cc.
void mapcharacter::set_offset | ( | s_int8 | x, |
s_int8 | y | ||
) | [inline] |
Sets the offset of the mapcharacter on it's current mapsquare.
x | X offset. |
y | Y offset. |
Definition at line 501 of file mapcharacter.h.
void mapcharacter::remove_from_pos | ( | ) |
Removes the mapcharacter from the place he was on the map.
Definition at line 281 of file mapcharacter.cc.
Remove the mapcharacter from it's current place and put him to a new one.
smap | index of the submap to jump to. |
x | X offset to to. |
y | Y offset to to. |
pos | Position to adopt once placed. |
Definition at line 286 of file mapcharacter.cc.
u_int16 mapcharacter::submap | ( | ) | const [inline] |
Returns the index of the submap where the mapcharacter is.
Definition at line 529 of file mapcharacter.h.
u_int16 mapcharacter::posx | ( | ) | const [inline] |
Returns the X position of the mapcharacter.
Definition at line 540 of file mapcharacter.h.
u_int16 mapcharacter::posy | ( | ) | const [inline] |
Returns the Y position of the mapcharacter.
Definition at line 551 of file mapcharacter.h.
s_int8 mapcharacter::offx | ( | ) | const [inline] |
Returns the X offset of the mapcharacter.
Definition at line 562 of file mapcharacter.h.
s_int8 mapcharacter::offy | ( | ) | const [inline] |
Returns the Y offset of the mapcharacter.
Definition at line 573 of file mapcharacter.h.
u_int16 mapcharacter::currentmove | ( | ) | const [inline] |
Returns the current move of the mapcharacter.
Definition at line 584 of file mapcharacter.h.
void mapcharacter::set_schedule | ( | string | file, |
PyObject * | args = NULL |
||
) |
Schedule control.
Assign a schedule to the mapcharacter.
The schedule's filename will be "scripts/schedules/mapcharacters/<file>.py".
file | name of the schedule to use. |
args | Python tuple containing extra arguments passed to the class constructor. |
Definition at line 733 of file mapcharacter.cc.
string mapcharacter::schedule_file | ( | ) | const [inline] |
Returns the name of the mapcharacter's current schedule.
Definition at line 627 of file mapcharacter.h.
bool mapcharacter::is_schedule_activated | ( | ) | const [inline] |
Returns whether the schedule is activated or not.
true
if the schedule is activated, false
otherwise. Definition at line 638 of file mapcharacter.h.
void mapcharacter::set_schedule_active | ( | bool | a | ) | [inline] |
Sets whether the schedule is active or not.
a | true if the schedule should be activated, false otherwise. |
Definition at line 648 of file mapcharacter.h.
bool mapcharacter::do_stuff | ( | string | method, |
PyObject * | args = NULL |
||
) |
Tell the character to do something.
Will execute the given method of the current schedule with the given arguments.
method | The method of the schedule to call. |
args | The arguments to pass to the method. |
true
if the method has been called, false
otherwise. Definition at line 725 of file mapcharacter.cc.
void mapcharacter::set_action | ( | string | file, |
PyObject * | args = NULL |
||
) |
Action control.
Assign a action to the mapcharacter.
The action's filename will be "scripts/actions/<file>.py".
file | name of the action to use. |
args | Python tuple containing extra arguments passed to the class constructor. |
Definition at line 768 of file mapcharacter.cc.
string mapcharacter::action_file | ( | ) | const [inline] |
Returns the name of the mapcharacter's current action.
Definition at line 694 of file mapcharacter.h.
bool mapcharacter::is_action_activated | ( | ) | const [inline] |
Returns whether the action is activated or not.
true
if the action is activated, false
otherwise. Definition at line 705 of file mapcharacter.h.
void mapcharacter::set_action_active | ( | bool | a | ) | [inline] |
Sets whether the action is active or not.
a | true if the action should be activated, false otherwise. |
Definition at line 715 of file mapcharacter.h.
void mapcharacter::launch_action | ( | mapcharacter * | requester | ) |
Run the mapcharacter's action, passing requester as the "requester" parameter for the action's Python script.
requester | pointer to the mapcharacter that requested the action, which is passed to the Python run () method. |
Definition at line 826 of file mapcharacter.cc.
animation* mapcharacter::get_animation | ( | u_int16 | nbr | ) | [inline] |
Returns a pointer to an animation corresponding to a movment.
nbr | index of the animation to get. |
Definition at line 740 of file mapcharacter.h.
mapcharacter & mapcharacter::operator= | ( | const mapcharacter & | m | ) |
Mapcharacter copy (similar to copy ()).
Definition at line 858 of file mapcharacter.cc.
void mapcharacter::copy | ( | const mapcharacter & | src | ) | [inline] |
Synonym of operator = to guarantee its access from Python.
Definition at line 760 of file mapcharacter.h.