DynRPG v0.32 Unofficial
Plugin SDK
Public Member Functions | Public Attributes | List of all members
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...

#include <Character.h>

Inheritance diagram for RPG::Character:
RPG::Event RPG::Hero RPG::Vehicle

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)
 
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)
 
int moveRoutePosition
 Position in move route.
 
bool moveRouteDone
 Has the move route finished?
 
bool isHidden
 Only works on hero. Determine if hidden.
 
bool slipThrough
 
bool stopAnimation
 
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
 Internally used, for movement frequency.
 
bool eventJumping
 Is the event jumping?
 
int beforeJumpX
 Map's X value Before jumping.
 
int beforeJumpY
 Map's Y value Before jumping.
 
bool isFlying
 Flying flag for airship.
 
DStringPtr charsetFilename
 Filename of the current charset.
 
int charsetId
 ID of the current charset.
 
bool eventUpdatedThisFrame
 Was the character's event updated this frame?
 
int flashR
 The red value for sprite flashing.
 
int flashG
 The green value for sprite flashing.
 
int flashB
 The blue value for sprite flashing.
 
int flashIntensity
 This is not the same as strength/power.
 
int flashTimer
 The flash timer. Starts at time*6 & decreases each frame.
 

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

◆ doStep()

void RPG::Character::doStep ( RPG::Direction direction)

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

◆ getName()

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)

◆ isMovePossible()

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.

◆ move()

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));
void move(const char *data, int length, bool repeatPattern=false, bool ignoreImpossible=true, int frequency=8)
Moves a character.
RPG::Hero *& hero
The hero (which moves around on the map, similar to an event)

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 += 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());
Map *& map
The current map environment (camera, events, etc.)
@ MT_PLAY_SE
Plays a sound effect.
Definition MoveType.h:78
std::string encode(int value)
Encodes a numerical value for use with RPG::Character::move.
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

◆ setAnimationType()

void RPG::Character::setAnimationType ( RPG::AnimationType type)

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

◆ setFixedStep()

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

◆ setNormalStep()

void RPG::Character::setNormalStep ( )

Removes a fixed step position and goes back to normal.

See also
setFixedStep

◆ stop()

void RPG::Character::stop ( )

Stops the current movement.

Warning
This is an experimental function.
See also
move

Member Data Documentation

◆ animationType

AnimationType_T RPG::Character::animationType

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

◆ customExactSpeed

char RPG::Character::customExactSpeed

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.

◆ movementFramesLeft

int RPG::Character::movementFramesLeft

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.

◆ offsetX

char RPG::Character::offsetX

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.

◆ step

int RPG::Character::step

Current step value (see details)

Possible values:

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

The stepping frame of the charset graphic


The documentation for this class was generated from the following file: