DynRPG v0.32 Unofficial
Plugin SDK
|
Used for movable entities on the map, i.e. events, the hero (and vehicles, but they are not supported yet) More...
#include <Character.h>
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) | |
MoveRoute * | moveRoute |
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. | |
Used for movable entities on the map, i.e. events, the hero (and vehicles, but they are not supported yet)
void RPG::Character::doStep | ( | RPG::Direction | direction | ) |
Does one step (moves the character one tile into a certain direction)
direction | Direction to move into |
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.
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.
fromX | X coordinate (tiles) of the source position |
fromY | Y coordinate (tiles) of the source position |
toX | X coordinate (tiles) of the destination position |
toY | Y coordinate (tiles) of the destination position |
true
if the move is possible, otherwise false
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:
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:
data | Pointer to the movement data |
length | Length of the movement data |
repeatPattern | true if the pattern should be repeated until stop is called |
ignoreImpossible | Should impossible movements be ignored? |
frequency | Frequency of the movement |
void RPG::Character::setAnimationType | ( | RPG::AnimationType | type | ) |
Sets the animation type.
This function sets the animationType and fixedDirection members to the correct values.
type | New animation type |
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.
newStep | New step position, for possible values see step |
void RPG::Character::setNormalStep | ( | ) |
Removes a fixed step position and goes back to normal.
void RPG::Character::stop | ( | ) |
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.
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.
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.
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.
int RPG::Character::step |
Current step value (see details)
Possible values:
0
: Left 1
: Middle 2
: Right 3
: MiddleThe stepping frame of the charset graphic