DynRPG  v0.14a
RM2k3 Plugin SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | Public Attributes
RPG::Character Class Reference

Used for movable entities on the map, i.e. events, the hero (and vehicles, but they are not supported yet) More...

Inherited by RPG::Event, and RPG::Hero.

List of all members.

Public Member Functions

int getScreenX ()
 Returns the current X screen coordinate.
int getScreenY ()
 Returns the current Y screen coordinate.
void setFixedStep (int newStep)
 Sets a fixed step.
void setNormalStep ()
 Removes a fixed step position and goes back to normal.
void setAnimationType (RPG::AnimationType type)
 Sets the animation type.
bool isMovePossible (int fromX, int fromY, int toX, int toY)
 Checks whether a certain move is possible.
std::string getName ()
 Returns the name of the character.
void move (const char *data, int length, bool repeatPattern=false, bool ignoreImpossible=true, int frequency=8)
 Moves a character.
void stop ()
 Stops the current movement.
void doStep (RPG::Direction direction)
 Does one step (moves the character one tile into a certain direction)

Public Attributes

int id
 ID of the event (zero if not an ordinary event)
bool enabled
 Is the event visible and enabled?
int mapId
 Map ID (only relevant for vehicles which are not supported yet)
int x
 X coordinate (tiles)
int y
 Y coordinate (tiles)
Direction_T direction
 Direction for moving (see RPG::Direction)
Facing_T facing
 Direction for facing (see RPG::Facing)
int step
 Current step value (see details)
int transparency
 Transparency value, between 0 (completely visible) to 8 (completely invisible)
int movementFramesLeft
 Frames left until movement is completed (see details)
int frequency
 Current movement frequency (1 to 8)
int originalFrequency
 Original movement frequency (use for "Move event" commands with a frequency different from the current one)
Layer_T layer
 Layer (below/same level as/above hero, see RPG::Layer)
bool forbidEventOverlap
 true if the event cannot move onto a tile occupied by another event
AnimationType_T animationType
 Animation type of the event (see details and RPG::AnimationType)
bool fixedDirection
 Is the facing direction (facing) fixed?
int speed
 Current speed of the character (1 to 6, see also customExactSpeed)
MoveRoutemoveRoute
 Current move route (can also be set by "Move Event" commands)
bool moving
 Is the character currently moving?
char offsetX
 Horizontal offset for drawing the event graphic (see details)
char offsetY
 Vertical offset for drawing the event graphic (see offsetX)
char customExactSpeed
 Custom exact speed (see details)
bool phasing
 Is the "phasing mode" on?
int stepFrameCounter
 Internally used, for stepping.
int stepTimer
 Internally used, for stepping (-1 if a fixed step is used, see setFixedStep)
int frequencyTimer
 Internall used, for movement frequency.
DStringPtr charsetFilename
 Filename of the current charset.
int charsetId
 ID of the current charset.

Detailed Description

Used for movable entities on the map, i.e. events, the hero (and vehicles, but they are not supported yet)

See also:
RPG::Event
RPG::Map::events
RPG::Hero
RPG::hero
RPG::Direction
RPG::Facing
RPG::Layer
RPG::AnimationType
RPG::MoveRoute

Member Function Documentation

Does one step (moves the character one tile into a certain direction)

Parameters:
directionDirection to move into
Warning:
This is an experimental function.
See also:
move
std::string RPG::Character::getName ( )

Returns the name of the character.

This function returns the event name which was set in the event editor or the name of the first actor in the party in case the character is the hero.

Returns:
The name of the character (event or hero name)

Returns the current X screen coordinate.

Returns the current Y screen coordinate.

bool RPG::Character::isMovePossible ( int  fromX,
int  fromY,
int  toX,
int  toY 
)

Checks whether a certain move is possible.

This function if the character will be able to complete a certain move, taking event layer, forbidEventOverlap, other blocking events and the tileset attributes into account.

Parameters:
fromXX coordinate (tiles) of the source position
fromYY coordinate (tiles) of the source position
toXX coordinate (tiles) of the destination position
toYY coordinate (tiles) of the destination position
Returns:
true if the move is possible, otherwise false
Warning:
This is an experimental function.
void RPG::Character::move ( const char *  data,
int  length,
bool  repeatPattern = false,
bool  ignoreImpossible = true,
int  frequency = 8 
)

Moves a character.

This function will move a character (event or hero) the same way the "Move event" command does.

The data parameter is a pointer to a char array containing the encoded data. You can find a list of possible movement commands at the RPG::MoveType documentation. For most movement commands, you will just use one byte containing the move type.

Example:

char moves[] = {RPG::MT_MOVE_UP, RPG::MT_MOVE_RIGHT, RPG::MT_MOVE_RIGHT, RPG::MT_TURN_RANDOMLY, RPG::MT_MOVE_FORWARD};
RPG::hero->move(moves, sizeof(moves));

There are, however, a few commands which take parameters: RPG::MT_SWITCH_ON, RPG::MT_SWITCH_OFF, RPG::MT_CHANGE_GRAPHIC and RPG::MT_PLAY_SE. If you want to use these commands, you better use a std::string. You need to add the parameters to the string right after the command byte, using the functions RPG::encode(int) for numerical parameters and RPG::encode(std::string) for string parameters.

Example:

std::string moves = "";
moves += (char)RPG::MT_MOVE_UP;
moves += (char)RPG::MT_FACE_DOWN;
moves += (char)RPG::MT_PLAY_SE;
moves += RPG::encode("chicken"); // filename
moves += RPG::encode(100); // volume
moves += RPG::encode(100); // speed
moves += RPG::encode(50); // pan
moves += (char)RPG::MT_WAIT;
moves += (char)RPG::MT_TURN_AROUND;
RPG::hero->move(moves.c_str(), moves.length());
Parameters:
dataPointer to the movement data
lengthLength of the movement data
repeatPatterntrue if the pattern should be repeated until stop is called
ignoreImpossibleShould impossible movements be ignored?
frequencyFrequency of the movement
Note:
RPG::MT_INCREASE_FREQUENCY and RPG::MT_DECREASE_FREQUENCY commands will not take permanent effect after the movement ended unless the movement was started with the same frequency as in the frequency member of the character.
Warning:
This is an experimental function.
See also:
RPG::MoveType
stop
doStep

Sets the animation type.

This function sets the animationType and fixedDirection members to the correct values.

Parameters:
typeNew animation type
See also:
animationType
RPG::AnimationType
void RPG::Character::setFixedStep ( int  newStep)

Sets a fixed step.

You can use this function to set a fixed step position and keep it until setNormalStep is called.

Parameters:
newStepNew step position, for possible values see step
Note:
This is a special feature of the DynRPG Patch.
See also:
setNormalStep
step

Removes a fixed step position and goes back to normal.

See also:
setFixedStep

Stops the current movement.

Warning:
This is an experimental function.
See also:
move

Member Data Documentation

Animation type of the event (see details and RPG::AnimationType)

This member is used for the animation type as defined in the event editor. However, it does not control whether the facing is locked or not, i.e. if you set it to RPG::ANI_FIXED_GRAPHIC, the event may still not have locked facing. Thus, you should use the setAnimationType function which automatically sets the fixedDirection member to the correct value.

See also:
setAnimationType
RPG::AnimationType

Filename of the current charset.

ID of the current charset.

Custom exact speed (see details)

You can the speed of a character in a finer way than the normal six speed values provide. One speed unit means 3.75 pixels per second (or 1/16 pixel per frame). For example customExactSpeed = 20 will set the speed to 75 pixels per second (1.25 pixels per frame).

If you set customExactSpeed to 0, the speed which is set in speed will be used.

Note:
This is a special feature of the DynRPG patch.

Direction for moving (see RPG::Direction)

Is the event visible and enabled?

Direction for facing (see RPG::Facing)

Is the facing direction (facing) fixed?

true if the event cannot move onto a tile occupied by another event

Current movement frequency (1 to 8)

Internall used, for movement frequency.

ID of the event (zero if not an ordinary event)

Layer (below/same level as/above hero, see RPG::Layer)

Map ID (only relevant for vehicles which are not supported yet)

Frames left until movement is completed (see details)

This value is zero if the movement is completed. Otherwise it means the frames left until it is completed. This value, together with direction, is used to calculate the current screen coordinates.

Current move route (can also be set by "Move Event" commands)

Is the character currently moving?

Horizontal offset for drawing the event graphic (see details)

The offsetX and offsetY members can be used to control the screen coordinates on which the event is drawn. You specify an offset value which will be added to the normal value.

For example, you might set offsetX = 8 and offsetY = -16 - and then the event will always be drawn 8 pixels to the right and 16 pixels higher than it would normally be. This way, you can do a finer movement and even do a "fake" pixel movement.

Note:
This is a special feature of the DynRPG patch.

Vertical offset for drawing the event graphic (see offsetX)

Original movement frequency (use for "Move event" commands with a frequency different from the current one)

Is the "phasing mode" on?

Current speed of the character (1 to 6, see also customExactSpeed)

Current step value (see details)

Possible values:

  • 0: Left
  • 1: Middle
  • 2: Right
  • 3: Middle

Internally used, for stepping.

Internally used, for stepping (-1 if a fixed step is used, see setFixedStep)

Transparency value, between 0 (completely visible) to 8 (completely invisible)

X coordinate (tiles)

Y coordinate (tiles)

 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator