# define OLC_PGE_APPLICATION
# include "pixelGameEngine.h"
# define OLC_PGEX_SPLASHSCREEN
# include "splash.h"
# define OLC_SOUNDWAVE
# include "defines.h"
# include "soundwaveEngine.h"
# include "tiles.h"
# include "references.h"
# include "states.h"
# include "flags.h"
# include <assert.h>
# include "cutscene.h"
# include "encounters.h"
# include "particle.h"
# include "effect.h"
# define ㅎ
# define ㅍ
# define 아
# define α 0x391
# define β 0x392
# define γ 0x3b3
# define Ω 0x3a3
# define Σ 0x3a9
# define AddAsyncCutsceneAction(AsyncClass) \
if ( ! ( ( AsyncClass * ) CurrentCutscene - > GetAction ( ) ) - > InQueue ( ) ) { \
CUTSCENE_QUEUE . push_back ( CurrentCutscene - > GetAction ( ) ) ; \
} \
( ( AsyncClass * ) CurrentCutscene - > GetAction ( ) ) - > SetQueued ( ) ; \
CurrentCutscene - > AdvanceAction ( ) ; \
# define 액션 (CutsceneAction*)new
std : : vector < Object * > OBJECTS ;
const vd2d NO_NEIGHBOR = { - 999 , - 999 } ;
using namespace olc ;
enum {
ALPHA = α ,
BETA = β ,
GAMMA = γ ,
OMEGA = Ω ,
SIGMA = Σ ,
} ;
namespace layer {
enum layer {
INTERFACE , //Interface items should be on this layer. On top of everything.
COLLISION , //Collision checking layer. This layer is
HIGH ,
DYNAMIC ,
GROUND ,
BACKGROUND ,
OBJECT , //The object layer doesn't actually exist, it's used to tell the editor we are adding an object instead.
ENCOUNTER , //The encounter layer doesn't actually exist, it's used to tell the editor we are adding encounters instead.
} ;
}
class Animation {
public :
Decal * spr ;
int frames = 1 ;
int width = 0 ;
Animation ( Decal * spr , int width ) {
this - > frames = spr - > sprite - > width / width ;
this - > width = width ;
this - > spr = spr ;
}
} ;
vd2d cameraPos = { 0 , 0 } ;
PixelGameEngine * GAME ;
class Object {
private :
vd2d scale = { 1 , 1 } ;
vd2d pos ;
public :
int id ;
Animation * spr ;
int frameIndex = 0 ;
int frameCount = 0 ;
int animationSpd = 12 ; //How many frames to wait between each frame. Setting to 0 pauses the animation.
std : : string name ;
Pixel color = WHITE ;
vd2d originPoint = { 0 , 0 } ;
bool drawn = false ;
Flag disableFlag = Flag : : NONE ;
Flag enableFlag = Flag : : NONE ;
int objArrElement ; //Which element in the object array this object is located in. For sorting purposes.
bool temp = false ; //If set to true, it's marked for deletion after cutscene handling.
bool enc = false ; //If set to true, it's not included in the main list of entities for map saving because it's from an encounter.
bool dead = false ; //If set to true, this object was properly part of an Entity and got declared as dead.
int blinkFrames = 0 ; //Frame count of how much time is left for the image to be blinking. Used when enemies take damage.
//animationSpd is how long to wait before switching frames.
bool highlighted = false ; //Whether or not this object has been declared as highlighted by a target range selector.
bool Collision ( vd2d pos ) {
GAME - > SetDrawTarget ( layer : : COLLISION ) ;
Pixel collisionData = GAME - > GetDrawTarget ( ) - > GetPixel ( ( int ) pos . x - cameraPos . x , ( int ) pos . y - cameraPos . y ) ;
return collisionData ! = MAGENTA ;
}
//A grid version of the constructor. used ONLY for battle setups.
Object ( int id , std : : string name , int gridx , int gridy , Animation * spr , vd2d scale = { 1 , 1 } , Pixel color = WHITE , int animationSpd = 1 , bool temp = false )
: Object ( id , name , { gridx * 32 - ( spr - > width * 0.5 ) * ( scale . x - 1 ) , gridy * 32 - ( spr - > spr - > sprite - > height - 4 ) * ( scale . y - 1 ) } , spr , scale , color , animationSpd , temp ) { }
Object ( int id , std : : string name , vd2d pos , Animation * spr , vd2d scale = { 1 , 1 } , Pixel color = WHITE , int animationSpd = 1 , bool temp = false ) {
this - > spr = spr ;
this - > pos = pos ;
this - > id = id ;
this - > name = name ;
this - > color = color ;
this - > animationSpd = animationSpd ;
SetScale ( scale ) ;
this - > temp = temp ;
}
void SetScale ( vd2d scale ) {
this - > scale = scale ;
this - > originPoint = { spr - > width / 2 * scale . x , ( spr - > spr - > sprite - > height - 4 ) * scale . y } ;
}
vd2d GetScale ( ) {
return scale ;
}
vd2d GetPos ( ) {
return pos ;
}
void Move ( vd2d move ) {
if ( move . y = = 0 ) {
pos + = move ;
return ;
} else {
if ( move . y < 0 ) {
while ( objArrElement > 0 & & OBJECTS [ objArrElement - 1 ] - > pos . y + OBJECTS [ objArrElement - 1 ] - > originPoint . y > pos . y + originPoint . y + move . y ) {
//printf("%p(%s)<->%p(%s)\n",OBJECTS[objArrElement],OBJECTS[objArrElement]->name.c_str(),OBJECTS[objArrElement-1],OBJECTS[objArrElement-1]->name.c_str());
OBJECTS [ objArrElement ] = OBJECTS [ objArrElement - 1 ] ;
//printf(" %p(%s)<->%p(%s)\n",OBJECTS[objArrElement],OBJECTS[objArrElement]->name.c_str(),OBJECTS[objArrElement-1],OBJECTS[objArrElement-1]->name.c_str());
OBJECTS [ objArrElement - 1 ] = this ;
//printf(" %p(%s)<->%p(%s)\n",OBJECTS[objArrElement],OBJECTS[objArrElement]->name.c_str(),OBJECTS[objArrElement-1],OBJECTS[objArrElement-1]->name.c_str());
OBJECTS [ objArrElement ] - > objArrElement = objArrElement ;
//printf(" %p(%s)(%d)<->%p(%s)(%d)\n",OBJECTS[objArrElement],OBJECTS[objArrElement]->name.c_str(),OBJECTS[objArrElement]->objArrElement,OBJECTS[objArrElement-1],OBJECTS[objArrElement-1]->name.c_str(),objArrElement-1);
objArrElement - - ;
}
} else {
while ( objArrElement < OBJECTS . size ( ) - 1 & & OBJECTS [ objArrElement + 1 ] - > pos . y + OBJECTS [ objArrElement + 1 ] - > originPoint . y < pos . y + originPoint . y + move . y ) {
//printf("%p(%s)<->%p(%s)\n",OBJECTS[objArrElement],OBJECTS[objArrElement]->name.c_str(),OBJECTS[objArrElement+1],OBJECTS[objArrElement+1]->name.c_str());
OBJECTS [ objArrElement ] = OBJECTS [ objArrElement + 1 ] ;
//printf(" %p(%s)<->%p(%s)\n",OBJECTS[objArrElement],OBJECTS[objArrElement]->name.c_str(),OBJECTS[objArrElement+1],OBJECTS[objArrElement+1]->name.c_str());
OBJECTS [ objArrElement + 1 ] = this ;
//printf(" %p(%s)<->%p(%s)\n",OBJECTS[objArrElement],OBJECTS[objArrElement]->name.c_str(),OBJECTS[objArrElement+1],OBJECTS[objArrElement+1]->name.c_str());
OBJECTS [ objArrElement ] - > objArrElement = objArrElement ;
//printf(" %p(%s)(%d)<->%p(%s)(%d)\n",OBJECTS[objArrElement],OBJECTS[objArrElement]->name.c_str(),OBJECTS[objArrElement]->objArrElement,OBJECTS[objArrElement+1],OBJECTS[objArrElement+1]->name.c_str(),objArrElement+1);
objArrElement + + ;
}
}
pos + = move ;
}
}
void SetPos ( vd2d pos ) {
Move ( pos - this - > pos ) ;
}
vd2d GetPosWithOrigin ( ) {
return GetPos ( ) + originPoint ;
}
bool SmoothMove ( vd2d move ) {
const int wiggleRoom = 5 ;
vd2d originPos = { pos . x + originPoint . x , pos . y - 1 + originPoint . y } ;
if ( ! Collision ( originPos + move ) ) {
Move ( move ) ;
return true ;
} else
if ( move . x ! = 0 & & ! Collision ( { originPos . x + move . x , originPos . y } ) ) {
Move ( { move . x , 0 } ) ;
return true ;
} else
if ( move . y ! = 0 & & ! Collision ( { originPos . x , originPos . y + move . y } ) ) {
Move ( { 0 , move . y } ) ;
return true ;
}
else
if ( move . x > 0 ) {
for ( int i = 0 ; i < wiggleRoom ; i + + ) { //Search Up.
if ( ! Collision ( { originPos . x + move . x , originPos . y - i } ) ) {
//There is potentially to move up-right here, so we will do so.
Move ( { 0 , - 1 } ) ;
originPos . y + = - 1 ;
return true ;
}
}
for ( int i = 0 ; i < wiggleRoom ; i + + ) { //Search Down.
if ( ! Collision ( { originPos . x + move . x , originPos . y + i } ) ) {
//There is potentially to move down-right here, so we will do so.
Move ( { 0 , 1 } ) ;
return true ;
}
}
} else
if ( move . x < 0 ) {
for ( int i = 0 ; i < wiggleRoom ; i + + ) { //Search Up.
if ( ! Collision ( { originPos . x + move . x , originPos . y - i } ) ) {
//There is potentially to move up-left here, so we will do so.
Move ( { 0 , - 1 } ) ;
return true ;
}
}
for ( int i = 0 ; i < wiggleRoom ; i + + ) { //Search Down.
if ( ! Collision ( { originPos . x + move . x , originPos . y + i } ) ) {
//There is potentially to move down-left here, so we will do so.
Move ( { 0 , 1 } ) ;
return true ;
}
}
}
if ( move . y > 0 ) {
for ( int i = 0 ; i < wiggleRoom ; i + + ) { //Search Left.
if ( ! Collision ( { originPos . x - i , originPos . y + move . y } ) ) {
//There is potentially to move down-left here, so we will do so.
Move ( { - 1 , 0 } ) ;
return true ;
}
}
for ( int i = 0 ; i < wiggleRoom ; i + + ) { //Search Right.
if ( ! Collision ( { originPos . x + i , originPos . y + move . y } ) ) {
//There is potentially to move down-right here, so we will do so.
Move ( { 1 , 0 } ) ;
return true ;
}
}
} else
if ( move . y < 0 ) {
for ( int i = 0 ; i < wiggleRoom ; i + + ) { //Search Left.
if ( ! Collision ( { originPos . x - i , originPos . y + move . y } ) ) {
//There is potentially to move up-left here, so we will do so.
Move ( { - 1 , 0 } ) ;
return true ;
}
}
for ( int i = 0 ; i < wiggleRoom ; i + + ) { //Search Right.
if ( ! Collision ( { originPos . x + i , originPos . y + move . y } ) ) {
//There is potentially to move up-right here, so we will do so.
Move ( { 1 , 0 } ) ;
return true ;
}
}
}
return false ;
}
} ;
enum class Resistance {
WET ,
DRY ,
COLD ,
HEAT ,
} ;
enum class Property {
PETRIFY ,
PARALYZE ,
DIAMONDIZE ,
CRYING ,
SLOW ,
MUSHROOMIZED ,
CONFUSE ,
POISON ,
REGEN ,
DEFENSE_UP ,
REVIVE ,
} ;
enum class BattleMoveName {
TESTMOVE1 ,
TESTMOVE2 ,
TESTMOVE3 ,
BASH ,
HAILSTORM_A ,
HAILSTORM_B ,
HAILSTORM_G ,
HAILSTORM_O ,
HURRICANE_A ,
HURRICANE_B ,
HURRICANE_G ,
HURRICANE_O ,
METEORRAIN_A ,
METEORRAIN_B ,
METEORRAIN_G ,
METEORRAIN_O ,
PKFREEZE_A ,
PKFREEZE_B ,
PKFREEZE_G ,
PKFREEZE_O ,
PKSHIELD_A ,
PKSHIELD_B ,
PKSHIELD_O ,
PKSHIELD_S ,
PKLIFEUP_A ,
PKLIFEUP_B ,
PKLIFEUP_G ,
PKLIFEUP_O ,
PKFUN_A ,
PKFUN_B ,
PKFUN_G ,
PKFUN_O ,
PKFIRE_A ,
PKFIRE_B ,
PKFIRE_G ,
PKFIRE_O ,
} ;
using convert_t = std : : codecvt_utf8 < wchar_t > ;
std : : wstring_convert < convert_t , wchar_t > strconverter ;
std : : string to_string ( std : : wstring wstr )
{
return strconverter . to_bytes ( wstr ) ;
}
std : : wstring to_wstring ( std : : string str )
{
return strconverter . from_bytes ( str ) ;
}
namespace Battle {
class Move {
public :
std : : string name ;
std : : string desc ;
std : : array < int , 4 > composition ;
int baseDmg ; //The base damage of the attack.
int randomDmg ; //Additional random roll damage to add onto the base damage.
bool pctDamage ; //Uses % damage for the base damage instead of flat damage.
std : : vector < std : : pair < Property , int > > properties ; //The int is used to determine the chance of something occurring.
//Properties order is WET, DRY, COLD, HEAT
int PPCost = 0 ;
int grade = 0 ; //If the name of a move name match, then the grade helps sort it into the same category on menus.
int range = 1 ; //The range of this ability in tiles.
int channelTime = 0 ; //The amount of frames to channel the spell.
bool friendly = false ; //Target allies instead.
Effect * eff = nullptr ;
//Assumes friendly is false.
Move ( std : : string name , std : : string desc , int baseDmg , int randomDmg , int PPCost , int range , std : : array < int , 4 > composition , Effect * eff = nullptr , bool pctDamage = false , std : : vector < std : : pair < Property , int > > properties = { } )
: Move ( name , desc , 0 , baseDmg , randomDmg , PPCost , range , 0 , false , composition , eff , pctDamage , properties ) { } ;
Move ( std : : string name , std : : string desc , int baseDmg , int randomDmg , int PPCost , int range , int channelTime , bool friendly , std : : array < int , 4 > composition , Effect * eff = nullptr , bool pctDamage = false , std : : vector < std : : pair < Property , int > > properties = { } )
: Move ( name , desc , 0 , baseDmg , randomDmg , PPCost , range , channelTime , friendly , composition , eff , pctDamage , properties ) { } ;
Move ( std : : string name , std : : string desc , int grade , int baseDmg , int randomDmg , int PPCost , int range , int channelTime , bool friendly , std : : array < int , 4 > composition , Effect * eff = nullptr , bool pctDamage = false , std : : vector < std : : pair < Property , int > > properties = { } )
: name ( name ) , grade ( grade ) , PPCost ( PPCost ) , desc ( desc ) , randomDmg ( randomDmg ) , baseDmg ( baseDmg ) , range ( range ) , friendly ( friendly ) , eff ( eff ) , channelTime ( channelTime ) , composition ( composition ) , pctDamage ( pctDamage ) , properties ( properties ) {
this - > channelTime = 180 ;
}
} ;
}
class Entity {
private :
int HP = 0 ;
int targetHP = 0 ;
public :
int maxHP = 0 ;
int PP = 0 ;
int targetPP = 0 ;
int maxPP = 0 ;
std : : array < int , 4 > resistances = { 0 , 0 , 0 , 0 } ;
int speed = 0 ;
int baseAtk = 0 ;
int damageReduction = 0 ; //A percentage of how much damage to reduce.
bool smart = false ;
bool dumb = false ;
int atb = 0 ; //When this value reaches 1000, it's this entity's turn.
Object * obj ;
std : : vector < Battle : : Move * > moveSet ;
int selectedTarget = 0 ;
Battle : : Move * selectedMove = nullptr ; //The index of the selected move.
int channelTimeRemaining = 0 ; //The amount of channel time left until move can be performed.
vd2d channelPos = { 0 , 0 } ; //Where are channel is happening.
//Used for initializing players.
Entity ( int HP , int maxHP , int PP , int maxPP , int baseAtk , std : : array < int , 4 > resistances , int speed , std : : vector < Battle : : Move * > moveSet , int damageReduction = 0 , bool smart = false , bool dumb = false )
: Entity ( nullptr , HP , maxHP , PP , maxPP , baseAtk , resistances , speed , moveSet , damageReduction , smart , dumb ) { }
//Use this for initializing enemies as it lets you specify an object.
Entity ( Object * obj , int HP , int maxHP , int PP , int maxPP , int baseAtk , std : : array < int , 4 > resistances , int speed , std : : vector < Battle : : Move * > moveSet , int damageReduction = 0 , bool smart = false , bool dumb = false )
: obj ( obj ) , HP ( HP ) , maxHP ( maxHP ) , PP ( PP ) , maxPP ( maxPP ) , baseAtk ( baseAtk ) , speed ( speed ) , moveSet ( moveSet ) , damageReduction ( damageReduction ) , smart ( smart ) , dumb ( dumb ) {
for ( int i = 0 ; i < 4 ; i + + ) {
this - > resistances [ i ] = resistances [ i ] ;
}
this - > targetHP = HP ;
this - > targetPP = PP ;
}
//Get the HP that the rolling counter is moving towards.
int GetTargetHP ( ) {
return targetHP ;
}
//Gets the current actual health of the target.
int GetHP ( ) {
return HP ;
}
//Sets the rolling counter target to this health value.
void SetTargetHP ( int hp ) {
targetHP = hp ;
}
//Subtracts from the rolling counter target from this health value.
void SubtractHP ( int hp ) {
targetHP - = hp ;
}
//Adds to the rolling counter target from this health value.
void AddHP ( int hp ) {
targetHP = std : : clamp ( targetHP + hp , 0 , maxHP ) ;
}
//THIS IS FOR SPECIAL USE CASES ONLY! Normally you want to touch the rolling counter amount instead using SetTargetHP()!
void _SetDirectHP ( int hp ) {
HP = hp ;
}
} ;
class Encounter {
public :
vd2d pos ;
int chance ; //Chance of the encounter existing.
std : : vector < Entity * > objs ;
std : : array < vd2d , 4 > playerPos ;
int id ;
Encounter ( int id , vd2d pos , std : : array < vd2d , 4 > playerPos , std : : vector < Entity * > objs , int chance = 25 )
: id ( id ) , pos ( pos ) , objs ( objs ) , chance ( chance ) , playerPos ( playerPos ) { }
bool IsEncounterAlive ( ) {
for ( int i = 0 ; i < objs . size ( ) ; i + + ) {
if ( objs [ i ] - > GetHP ( ) > 0 ) {
return true ;
}
}
return false ;
}
bool IsInRange ( vd2d pos ) {
vd2d diff = pos - this - > pos ;
return diff . x > = 0 & & diff . x < = WIDTH & & diff . y > = 0 & & diff . y < = HEIGHT ;
}
} ;
class Map {
public :
std : : string filename ;
std : : string l2filename ;
std : : string l3filename ;
std : : string l4filename ;
std : : string l5filename ;
Decal * tileset ;
std : : vector < Encounter * > encounters ;
Map ( std : : string fname , std : : string layer2_fname , std : : string layer3_fname , std : : string layer4_fname , std : : string layer5_fname , Decal * tileset ) {
this - > filename = fname ;
this - > l2filename = layer2_fname ;
this - > l3filename = layer3_fname ;
this - > l4filename = layer4_fname ;
this - > l5filename = layer5_fname ;
this - > tileset = tileset ;
}
} ;
class DamageNumber {
public :
int damage ; //If it's negative then it's a healing number.
vd2d pos ;
int timer ;
DamageNumber ( int damage , vd2d pos , int timer = 90 )
: damage ( damage ) , pos ( pos ) , timer ( timer ) { }
} ;
class SeasonI : public PixelGameEngine
{
public :
SeasonI ( )
{
sAppName = " Season I: Winters of Loneliness " ;
}
public :
int frameCount = 0 ;
float elapsedTime = 0 ;
const float TARGET_RATE = 1 / 60.0 ;
int MAP_WIDTH = - 1 ;
int MAP_HEIGHT = - 1 ;
Map * CURRENT_MAP ;
Map * MAP_ONETT ;
int GAME_STATE = GameState : : EDITOR ;
vi2d SELECTED_TILE = { 0 , 0 } ;
vi2d HIGHLIGHTED_TILE = { 0 , 0 } ;
int EDITING_LAYER = layer : : DYNAMIC ;
int SELECTED_OBJ_ID = PLAYER ;
int OBJ_DISPLAY_OFFSET = 0 ;
bool GAME_FLAGS [ 128 ] = { } ;
std : : array < Object * , 4 > PARTY_MEMBER_OBJ ;
std : : array < int , 4 > PARTY_MEMBER_ID ;
std : : array < Entity * , 7 > PARTY_MEMBER_STATS ;
bool messageBoxVisible = false ;
std : : string messageBoxText = " " ;
std : : string targetText = " " ;
std : : string messageBoxFinalText = " " ;
int messageBoxMarker = 0 ;
int messageBoxStartMarker = 0 ; //Start of text display.
int messageBoxStopMarker = 0 ; //End of text display for current printout.
int messageBoxFrameWaitTime = 1 ;
bool messageBoxLoad = false ; //Set to true when ready to load a message in.
std : : map < int , vi2d > additionalChars ;
Cutscene * TestCutscene ;
Cutscene * CurrentCutscene = nullptr ;
ActionType CurrentAction = ActionType : : NONE ;
double CUTSCENE_FADE_VALUE = 0 ;
std : : vector < CutsceneAction * > CUTSCENE_QUEUE ;
std : : map < BattleMoveName , Battle : : Move * > MOVELIST ;
std : : array < vd2d , PARTY_TRAIL_LENGTH > partyTrail = { vd2d { 0 , 0 } } ;
int PARTY_MEMBER_COUNT = 1 ;
int ENCOUNTER_SELECTED = 0 ;
int ENCOUNTER_OFFSET = 0 ;
std : : vector < Encounter * > ENCOUNTER_LIST ;
Encounter * EDITING_ENCOUNTER = nullptr ;
Encounter * BATTLE_ENCOUNTER = nullptr ;
int BATTLE_STATE = BattleState : : MOVE_CAMERA ;
int CAMERA_WAIT_TIMER = 0 ;
int player_rollhp_counter [ 4 ] [ 3 ] = { { 0 , 0 , 0 } , { 0 , 0 , 0 } , { 0 , 0 , 0 } , { 0 , 0 , 0 } } ;
int player_rollpp_counter [ 4 ] [ 3 ] = { { 0 , 0 , 0 } , { 0 , 0 , 0 } , { 0 , 0 , 0 } , { 0 , 0 , 0 } } ;
int player_rollhp_display [ 4 ] [ 3 ] = { { 0 , 0 , 0 } , { 0 , 0 , 0 } , { 0 , 0 , 0 } , { 0 , 0 , 0 } } ;
int player_rollpp_display [ 4 ] [ 3 ] = { { 0 , 0 , 0 } , { 0 , 0 , 0 } , { 0 , 0 , 0 } , { 0 , 0 , 0 } } ;
int player_rollwait_counter [ 4 ] = { 0 , 0 , 0 , 0 } ;
int SELECTED_TARGET = 0 ; //Battle target that is selected.
int BATTLE_TARGET = - 99 ; //Negative numbers for players and positive numbers for enemy targets.
int CURRENT_TURN = - 99 ; //Who's turn we are enacting.
int BATTLE_SELECTION_CURSOR = 0 ;
int POWER_SELECTION_CURSOR [ 4 ] = { 0 , 0 , 0 , 0 } ;
int POWER_GRADE_CURSOR [ 4 ] = { 0 , 0 , 0 , 0 } ;
int TARGET_SELECTION_CURSOR = 0 ;
bool ANYKEYPRESSED = false ;
bool ACTIONKEYPRESSED = false ;
std : : vector < std : : vector < Battle : : Move * > > BATTLE_MOVELIST_DISPLAY ;
std : : map < int , int > ADDITIONAL_FONT_VALS = {
{ α , 0 } , { β , 1 } , { γ , 2 } , { Ω , 3 } , { Σ , 4 } ,
} ;
int POWER_SELECTION_OFFSET [ 4 ] = { 0 , 0 , 0 , 0 } ;
int BATTLE_ANIMATION_TIMER = 0 ;
int BATTLE_ROLLING_COUNTER_WAITTIME = 0 ; //Number of frames to wait for each rolling counter.
int BATTLE_HIT_SCREENSHAKE = 0 ; //Amount of time the screen will rapidly shake as getting hit.
bool MOUSE_PRESSED_DOWN = false , MOUSE_DOWN = false , MOUSE_RELEASED = false ; //TODO Implement Mouse things.
std : : vector < std : : vector < TILE * > > MAP ; //The foreground layer.
std : : vector < std : : vector < TILE * > > MAP2 ;
std : : vector < std : : vector < TILE * > > MAP3 ;
std : : vector < std : : vector < TILE * > > MAP4 ;
std : : vector < std : : vector < TILE * > > MAP5 ; //Collision Layer
std : : map < std : : string , Decal * > SPRITES ;
std : : map < std : : string , Animation * > ANIMATIONS ;
std : : map < int , Object * > OBJ_INFO ;
std : : vector < Particle * > PARTICLES ;
std : : vector < DamageNumber * > DAMAGE_NUMBERS ;
std : : map < std : : pair < int , int > , vd2d > MOVEMENT_GRID ;
vi2d SELECTED_MOVE_SQUARE ;
Effect * CURRENT_EFFECT = nullptr ;
bool OnUserCreate ( ) override
{
srand ( time ( NULL ) ) ;
GAME = this ;
for ( int i = 1 ; i < 6 ; i + + ) {
CreateLayer ( ) ;
EnableLayer ( i , true ) ;
}
SetPixelMode ( Pixel : : ALPHA ) ;
ConsoleCaptureStdOut ( true ) ;
// Called once at the start, so create things here
FOUNTAIN_EFFECT = new FountainEffect ( 250 , 200 ) ;
EnableLayer ( layer : : COLLISION , false ) ;
SetupMoveList ( ) ;
SetupPartyMemberStats ( ) ;
SetupAnimations ( ) ;
SetupObjectInfo ( ) ;
SetupEncounters ( ) ;
SetGameFlag ( Flag : : TEST_FLAG1 , false ) ;
SetGameFlag ( Flag : : TEST_FLAG2 , false ) ;
SetGameFlag ( Flag : : TEST_FLAG3 , false ) ;
SetGameFlag ( Flag : : HAS_MAIN , true ) ;
SetGameFlag ( Flag : : HAS_NESS , true ) ;
SetGameFlag ( Flag : : HAS_PAULA , true ) ;
SetGameFlag ( Flag : : HAS_ANNA , true ) ;
additionalChars [ α ] = { 0 , 0 } ;
additionalChars [ β ] = { 8 , 0 } ;
additionalChars [ Ω ] = { 16 , 0 } ;
additionalChars [ Σ ] = { 24 , 0 } ;
additionalChars [ γ ] = { 32 , 0 } ;
MAP_ONETT = new Map ( " map0 " , " map0_2 " , " map0_3 " , " map0_4 " , " map0_5 " , SPRITES [ " terrainmap.png " ] ) ;
CURRENT_MAP = MAP_ONETT ;
//OBJ_INFO["PLAYER"]=PLAYER_ANIMATION;
LoadMap ( MAP_ONETT ) ;
TestCutscene = new Cutscene ( {
액 션 Fade ( ) ,
액 션 CreateObjects ( {
new Object ( PLAYER , " player " , { 64 , 64 } , ANIMATIONS [ " player.png " ] , { 1 , 1 } , MAGENTA ) ,
new Object ( PLAYER , " player " , { 136 , 136 } , ANIMATIONS [ " player.png " ] , { 1 , 1 } , RED ) ,
new Object ( PLAYER , " player " , { 96 , 96 } , ANIMATIONS [ " player.png " ] , { 1 , 1 } , DARK_GREEN ) ,
} ) ,
액 션 Fade ( true ) ,
액 션 SetFlagWhenCutsceneEnds ( Flag : : TEST_FLAG1 ) ,
액 션 PanCamera ( { 128 , 128 } , BOTH , 1 ) ,
액 션 MoveCutsceneObjectAsync ( 1 , { 80 , 64 } , 5 ) ,
액 션 PanCamera ( { 64 , 0 } , BOTH ) ,
액 션 DialogBoxAsync ( R " (Hello!
This is a test message that lets us trigger straight from a cutscene ! Cool ! ) " ),
액 션 ModifyObject ( 0 , ANIMATIONS [ " player.png " ] , { 5 , 5 } , MAGENTA ) ,
액 션 MoveCutsceneObject ( 1 , { 320 , 64 } , 1 ) , } ) ;
/*DisplayMessageBox(R"(Hello World!
This is a rather long message , but I hope it reaches you well
in some form or capacity or another . Even though it
goes on a very long time , I hope you can understand this is only for testing purposes !
) " );*/
return true ;
}
bool OnUserUpdate ( float fElapsedTime ) override
{
elapsedTime + = fElapsedTime ;
while ( elapsedTime > TARGET_RATE ) {
elapsedTime - = TARGET_RATE ;
updateGame ( ) ;
}
keyUpdates ( ) ;
SetDrawTarget ( nullptr ) ;
Clear ( BLANK ) ;
SetDrawTarget ( layer : : COLLISION ) ;
if ( EDITING_LAYER ! = layer : : COLLISION ) {
Clear ( MAGENTA ) ;
} else {
Clear ( BLANK ) ;
}
SetDrawTarget ( layer : : HIGH ) ;
Clear ( BLANK ) ;
SetDrawTarget ( layer : : DYNAMIC ) ;
Clear ( BLANK ) ;
SetDrawTarget ( layer : : GROUND ) ;
Clear ( BLANK ) ;
SetDrawTarget ( layer : : BACKGROUND ) ;
Clear ( BLANK ) ;
drawGame ( ) ;
return true ;
}
void GetAnyKeyPress ( ) override {
if ( messageBoxVisible ) {
if ( messageBoxMarker = = messageBoxFinalText . length ( ) ) {
if ( messageBoxStartMarker + messageBoxStopMarker < targetText . length ( ) ) {
messageBoxStartMarker + = messageBoxStopMarker ;
messageBoxStopMarker = 0 ;
messageBoxFinalText = " " ;
messageBoxText = " " ;
messageBoxMarker = 0 ;
messageBoxLoad = true ;
} else {
messageBoxVisible = false ;
}
} else {
while ( messageBoxMarker < messageBoxFinalText . length ( ) ) {
AdvanceMessageBox ( ) ;
}
}
} else {
ANYKEYPRESSED = true ;
if ( ! UpPressed ( ) & & ! DownPressed ( ) & & ! LeftPressed ( ) & & ! RightPressed ( ) ) {
ACTIONKEYPRESSED = true ;
}
}
}
void updateGame ( ) {
frameCount + + ;
for ( auto obj : OBJECTS ) {
if ( obj - > animationSpd ! = 0 & & obj - > frameCount + + > obj - > animationSpd ) {
obj - > frameCount = 0 ;
obj - > frameIndex + + ;
}
}
for ( int i = 0 ; i < DAMAGE_NUMBERS . size ( ) ; i + + ) {
DamageNumber * numb = DAMAGE_NUMBERS [ i ] ;
if ( numb - > timer > 0 ) {
numb - > pos . y - = ( numb - > timer / 180.0F ) ;
numb - > timer - - ;
} else {
delete numb ;
DAMAGE_NUMBERS . erase ( DAMAGE_NUMBERS . begin ( ) + i - - ) ;
continue ;
}
}
for ( int i = 0 ; i < PARTICLES . size ( ) ; i + + ) {
if ( ! PARTICLES [ i ] - > update ( ) ) {
delete PARTICLES [ i ] ;
PARTICLES . erase ( PARTICLES . begin ( ) + i ) ;
i - - ;
continue ;
}
PARTICLES [ i ] - > particleUpdate ( ) ;
}
if ( CURRENT_EFFECT ! = nullptr ) {
if ( ! CURRENT_EFFECT - > update ( ) ) {
CURRENT_EFFECT = nullptr ;
for ( int i = 0 ; i < PARTICLES . size ( ) ; i + + ) {
delete PARTICLES [ i ] ;
}
PARTICLES . clear ( ) ;
}
}
if ( GetCurrentCutsceneAction ( ) ! = ActionType : : NONE ) {
CurrentAction = GetCurrentCutsceneAction ( ) ;
CurrentCutscene - > LockAction ( ) ;
}
HandleBattle ( ) ;
HandleCutscenes ( ) ;
switch ( GAME_STATE ) {
case GameState : : TILE_SELECT : {
if ( ! TabHeld ( ) ) {
GAME_STATE = GameState : : EDITOR ;
}
if ( GetMouse ( 0 ) . bHeld ) {
int selectedTileX = GetMouseX ( ) / TILEMAP_EDITOR_TILESIZE ;
int selectedTileY = GetMouseY ( ) / TILEMAP_EDITOR_TILESIZE ;
if ( selectedTileX * TILEMAP_EDITOR_DRAW_MULT > = 0 & & selectedTileX * TILEMAP_EDITOR_DRAW_MULT < TILEMAP_SIZE_X & & selectedTileY * TILEMAP_EDITOR_DRAW_MULT < TILEMAP_SIZE_Y & & selectedTileY * TILEMAP_EDITOR_DRAW_MULT > = 0 ) {
SELECTED_TILE = { selectedTileX , selectedTileY } ;
}
}
} break ;
case GameState : : ENCOUNTER_SELECT : {
if ( ! GetKey ( SHIFT ) . bHeld ) {
GAME_STATE = GameState : : EDITOR ;
}
} break ;
case GameState : : GAME_WORLD : {
if ( PlayerCanMove ( ) ) {
bool moved = false ;
vd2d movementComponents = { 0 , 0 } ;
if ( UpHeld ( ) ) {
movementComponents . y - = 1 ;
}
if ( DownHeld ( ) ) {
movementComponents . y + = 1 ;
}
if ( LeftHeld ( ) ) {
movementComponents . x - = 1 ;
}
if ( RightHeld ( ) ) {
movementComponents . x + = 1 ;
}
if ( movementComponents . mag ( ) > 0 ) {
if ( PARTY_MEMBER_OBJ [ 0 ] - > SmoothMove ( movementComponents ) ) {
UpdatePlayerTrail ( movementComponents ) ;
moved = true ;
}
}
if ( moved ) {
vi2d cameraOffset = { WIDTH / 2 , HEIGHT / 2 } ;
cameraPos = PARTY_MEMBER_OBJ [ 0 ] - > GetPos ( ) - cameraOffset ;
}
if ( moved & & BATTLE_ENCOUNTER = = nullptr ) {
for ( int i = 0 ; i < CURRENT_MAP - > encounters . size ( ) ; i + + ) {
if ( CURRENT_MAP - > encounters [ i ] - > IsEncounterAlive ( ) & & CURRENT_MAP - > encounters [ i ] - > IsInRange ( PARTY_MEMBER_OBJ [ 0 ] - > GetPos ( ) ) ) {
BATTLE_STATE = BattleState : : MOVE_CAMERA ;
BATTLE_ENCOUNTER = CURRENT_MAP - > encounters [ i ] ;
break ;
}
}
}
}
} break ;
case GameState : : EDITOR : {
if ( IsTextEntryEnabled ( ) ) {
return ;
}
if ( TabHeld ( ) ) {
GAME_STATE = GameState : : TILE_SELECT ;
}
if ( GetKey ( SHIFT ) . bHeld ) {
GAME_STATE = GameState : : ENCOUNTER_SELECT ;
}
if ( PlayerCanMove ( ) ) {
if ( GetKey ( I ) . bHeld ) {
if ( PARTY_MEMBER_OBJ [ 0 ] - > SmoothMove ( { 0 , - 1 } ) ) {
UpdatePlayerTrail ( { 0 , - 1 } ) ;
}
}
if ( GetKey ( K ) . bHeld ) {
if ( PARTY_MEMBER_OBJ [ 0 ] - > SmoothMove ( { 0 , 1 } ) ) {
UpdatePlayerTrail ( { 0 , 1 } ) ;
}
}
if ( GetKey ( J ) . bHeld ) {
if ( PARTY_MEMBER_OBJ [ 0 ] - > SmoothMove ( { - 1 , 0 } ) ) {
UpdatePlayerTrail ( { - 1 , 0 } ) ;
}
}
if ( GetKey ( L ) . bHeld ) {
if ( PARTY_MEMBER_OBJ [ 0 ] - > SmoothMove ( { 1 , 0 } ) ) {
UpdatePlayerTrail ( { 1 , 0 } ) ;
}
}
}
int selectedTileX = ( GetMouseX ( ) + cameraPos . x ) / 32 ;
int selectedTileY = ( GetMouseY ( ) + cameraPos . y ) / 32 ;
if ( selectedTileX < MAP_WIDTH & & selectedTileY < MAP_HEIGHT & & selectedTileX > = 0 & & selectedTileY > = 0 ) {
HIGHLIGHTED_TILE = { selectedTileX , selectedTileY } ;
}
if ( GetMouse ( 0 ) . bHeld ) {
switch ( EDITING_LAYER ) {
case layer : : COLLISION : {
TILE * tile = MAP5 [ HIGHLIGHTED_TILE . y ] [ HIGHLIGHTED_TILE . x ] ;
tile - > tileX = SELECTED_TILE . x ;
tile - > tileY = SELECTED_TILE . y ;
} break ;
case layer : : HIGH : {
TILE * tile = MAP [ HIGHLIGHTED_TILE . y ] [ HIGHLIGHTED_TILE . x ] ;
tile - > tileX = SELECTED_TILE . x ;
tile - > tileY = SELECTED_TILE . y ;
} break ;
case layer : : DYNAMIC : {
TILE * tile = MAP2 [ HIGHLIGHTED_TILE . y ] [ HIGHLIGHTED_TILE . x ] ;
tile - > tileX = SELECTED_TILE . x ;
tile - > tileY = SELECTED_TILE . y ;
} break ;
case layer : : GROUND : {
TILE * tile = MAP3 [ HIGHLIGHTED_TILE . y ] [ HIGHLIGHTED_TILE . x ] ;
tile - > tileX = SELECTED_TILE . x ;
tile - > tileY = SELECTED_TILE . y ;
} break ;
case layer : : BACKGROUND : {
TILE * tile = MAP4 [ HIGHLIGHTED_TILE . y ] [ HIGHLIGHTED_TILE . x ] ;
tile - > tileX = SELECTED_TILE . x ;
tile - > tileY = SELECTED_TILE . y ;
} break ;
}
} else
if ( GetMouse ( 1 ) . bHeld ) {
switch ( EDITING_LAYER ) {
case layer : : COLLISION : {
TILE * tile = MAP5 [ HIGHLIGHTED_TILE . y ] [ HIGHLIGHTED_TILE . x ] ;
tile - > tileX = tile - > tileY = 15 ;
} break ;
case layer : : HIGH : {
TILE * tile = MAP [ HIGHLIGHTED_TILE . y ] [ HIGHLIGHTED_TILE . x ] ;
tile - > tileX = tile - > tileY = 15 ;
} break ;
case layer : : DYNAMIC : {
TILE * tile = MAP2 [ HIGHLIGHTED_TILE . y ] [ HIGHLIGHTED_TILE . x ] ;
tile - > tileX = tile - > tileY = 15 ;
} break ;
case layer : : GROUND : {
TILE * tile = MAP3 [ HIGHLIGHTED_TILE . y ] [ HIGHLIGHTED_TILE . x ] ;
tile - > tileX = tile - > tileY = 15 ;
} break ;
case layer : : BACKGROUND : {
TILE * tile = MAP4 [ HIGHLIGHTED_TILE . y ] [ HIGHLIGHTED_TILE . x ] ;
tile - > tileX = tile - > tileY = 15 ;
} break ;
}
}
} break ;
}
if ( messageBoxVisible ) {
AdvanceMessageBox ( ) ;
}
//CAMERA UPDATES MUST BE LAST!!! COLLISIONS RELY ON THE GAME POSITION STATES REMAINING THE SAME!
cameraUpdate ( ) ;
}
void AdvanceMessageBox ( ) {
if ( messageBoxLoad ) {
const int MESSAGE_BORDER_X = 4 ;
const int MESSAGE_BORDER_Y = 4 ;
bool charsWritten = false ;
while ( messageBoxStartMarker + messageBoxStopMarker < targetText . length ( ) & & GetTextSizeProp ( messageBoxFinalText ) . y < HEIGHT / 4 - MESSAGE_BORDER_Y ) {
while ( messageBoxStartMarker + messageBoxStopMarker < targetText . length ( ) & & GetTextSizeProp ( messageBoxFinalText ) . x < WIDTH / 2 - MESSAGE_BORDER_X ) {
if ( ! charsWritten & & targetText [ messageBoxStopMarker + messageBoxStartMarker ] ! = ' ' ) {
messageBoxFinalText + = targetText [ messageBoxStopMarker + + + messageBoxStartMarker ] ;
charsWritten = true ;
} else
if ( charsWritten ) {
messageBoxFinalText + = targetText [ messageBoxStopMarker + + + messageBoxStartMarker ] ;
} else {
messageBoxStartMarker + + ;
}
}
if ( GetTextSizeProp ( messageBoxFinalText ) . x > = WIDTH / 2 - MESSAGE_BORDER_X ) {
while ( messageBoxFinalText [ messageBoxStopMarker ] ! = ' ' ) {
messageBoxStopMarker - - ;
} ;
messageBoxFinalText . erase ( messageBoxFinalText . begin ( ) + messageBoxStopMarker , messageBoxFinalText . end ( ) ) ;
messageBoxFinalText + = ' \n ' ;
charsWritten = false ;
}
}
messageBoxLoad = false ;
} else {
if ( messageBoxMarker < messageBoxFinalText . length ( ) ) {
messageBoxText + = messageBoxFinalText [ messageBoxMarker + + ] ;
}
}
}
//CAMERA UPDATES MUST BE LAST!!! COLLISIONS RELY ON THE GAME POSITION STATES REMAINING THE SAME!
void cameraUpdate ( ) {
switch ( GAME_STATE ) {
case GameState : : EDITOR : {
//CAMERA MOVEMENTS MUST BE LAST!!!
if ( UpHeld ( ) ) {
cameraPos . y - = CAMERA_MOVESPD ;
}
if ( RightHeld ( ) ) {
cameraPos . x + = CAMERA_MOVESPD ;
}
if ( LeftHeld ( ) ) {
cameraPos . x - = CAMERA_MOVESPD ;
}
if ( DownHeld ( ) ) {
cameraPos . y + = CAMERA_MOVESPD ;
}
} break ;
}
}
void OnTextEntryComplete ( const std : : string & text ) override {
if ( EDITING_LAYER = = layer : : ENCOUNTER & & EDITING_ENCOUNTER ! = nullptr ) {
int numb = 0 ;
for ( int i = 0 ; i < text . size ( ) ; i + + ) {
numb * = 10 ;
numb + = text [ i ] - ' 0 ' ;
}
EDITING_ENCOUNTER - > chance = numb ;
}
}
void keyUpdates ( ) {
if ( GetKey ( F1 ) . bPressed ) {
ConsoleShow ( F1 , false ) ;
}
if ( GetKey ( O ) . bPressed ) {
StartEffect ( FOUNTAIN_EFFECT ) ;
}
if ( BATTLE_ENCOUNTER ! = nullptr & & ! messageBoxVisible ) {
switch ( BATTLE_STATE ) {
case BattleState : : SELECT_ACTION : {
if ( CURRENT_TURN < 0 ) {
if ( UpPressed ( ) | | DownPressed ( ) ) {
if ( BATTLE_SELECTION_CURSOR % 2 = = 0 ) {
BATTLE_SELECTION_CURSOR + + ;
} else {
BATTLE_SELECTION_CURSOR - - ;
}
}
if ( RightPressed ( ) ) {
BATTLE_SELECTION_CURSOR = ( BATTLE_SELECTION_CURSOR + 2 ) % 6 ;
}
if ( LeftPressed ( ) ) {
BATTLE_SELECTION_CURSOR - = 2 ;
if ( BATTLE_SELECTION_CURSOR < 0 ) {
BATTLE_SELECTION_CURSOR + = 6 ;
}
}
if ( ACTIONKEYPRESSED ) {
switch ( BATTLE_SELECTION_CURSOR ) {
case 0 : { //Power selected.
BATTLE_STATE = BattleState : : POWER_SELECT ;
BATTLE_MOVELIST_DISPLAY . clear ( ) ;
Entity * member = PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] ;
Object * obj = PARTY_MEMBER_OBJ [ - CURRENT_TURN - 1 ] ;
for ( int i = 0 ; i < member - > moveSet . size ( ) ; i + + ) {
Battle : : Move * move = member - > moveSet [ i ] ;
bool exists = false ;
for ( int j = 0 ; j < BATTLE_MOVELIST_DISPLAY . size ( ) ; j + + ) {
if ( BATTLE_MOVELIST_DISPLAY [ j ] [ 0 ] - > name . compare ( move - > name ) = = 0 ) {
bool found = false ;
for ( int k = 0 ; k < BATTLE_MOVELIST_DISPLAY [ j ] . size ( ) ; k + + ) {
if ( ADDITIONAL_FONT_VALS [ move - > grade ] < ADDITIONAL_FONT_VALS [ BATTLE_MOVELIST_DISPLAY [ j ] [ k ] - > grade ] ) {
BATTLE_MOVELIST_DISPLAY [ j ] . insert ( BATTLE_MOVELIST_DISPLAY [ j ] . begin ( ) + i , move ) ;
found = true ;
break ;
}
}
if ( ! found ) {
BATTLE_MOVELIST_DISPLAY [ j ] . push_back ( move ) ;
}
exists = true ;
break ;
}
}
if ( ! exists ) {
std : : vector < Battle : : Move * > vec ;
vec . push_back ( move ) ;
BATTLE_MOVELIST_DISPLAY . push_back ( vec ) ;
}
}
} break ;
case 1 : { //Attack selected.
BATTLE_STATE = BattleState : : TARGET_SELECT ;
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove = MOVELIST [ BattleMoveName : : BASH ] ;
SetupTargetSelect ( ) ;
} break ;
case 2 : { //Items selected.
DisplayMessageBox ( " Not implemented yet. " ) ;
//BATTLE_STATE=BattleState::ITEM_SELECT;
} break ;
case 3 : { //Defend selected.
DisplayMessageBox ( " Not implemented yet. " ) ;
} break ;
case 4 : { //Move selected.
//DisplayMessageBox("Not implemented yet.");
BATTLE_STATE = BattleState : : MOVE_SELECT ;
SELECTED_MOVE_SQUARE = { 0 , 0 } ;
PopulateMovementGrid ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > obj - > GetPosWithOrigin ( ) , PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > speed / 2 ) ;
} break ;
case 5 : { //Run selected.
DisplayMessageBox ( " Not implemented yet. " ) ;
} break ;
}
}
}
} break ;
case BattleState : : POWER_SELECT : {
if ( CURRENT_TURN < 0 ) {
if ( DownPressed ( ) ) {
if ( POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] = = ( int ) BATTLE_MOVELIST_DISPLAY . size ( ) - 1 ) {
POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] = 0 ;
POWER_SELECTION_OFFSET [ - CURRENT_TURN - 1 ] = 0 ;
} else {
POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] = std : : clamp ( POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] + 1 , 0 , ( int ) BATTLE_MOVELIST_DISPLAY . size ( ) - 1 ) ;
if ( POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] - POWER_SELECTION_OFFSET [ - CURRENT_TURN - 1 ] > = 4 ) {
POWER_SELECTION_OFFSET [ - CURRENT_TURN - 1 ] + + ;
}
}
}
if ( UpPressed ( ) ) {
if ( POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] = = 0 ) {
POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] = ( int ) BATTLE_MOVELIST_DISPLAY . size ( ) - 1 ;
POWER_SELECTION_OFFSET [ - CURRENT_TURN - 1 ] = std : : clamp ( POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] - 3 , 0 , ( int ) BATTLE_MOVELIST_DISPLAY . size ( ) - 1 ) ;
} else {
POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] = std : : clamp ( POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] - 1 , 0 , ( int ) BATTLE_MOVELIST_DISPLAY . size ( ) - 1 ) ;
if ( POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] < POWER_SELECTION_OFFSET [ - CURRENT_TURN - 1 ] ) {
POWER_SELECTION_OFFSET [ - CURRENT_TURN - 1 ] - - ;
}
}
}
if ( LeftPressed ( ) ) {
BATTLE_STATE = BattleState : : SELECT_ACTION ;
}
if ( ACTIONKEYPRESSED | | RightPressed ( ) ) {
BATTLE_STATE = BattleState : : GRADE_SELECT ;
}
}
} break ;
case BattleState : : GRADE_SELECT : {
if ( CURRENT_TURN < 0 ) {
if ( RightPressed ( ) ) {
POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] = ( POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] + 1 ) % BATTLE_MOVELIST_DISPLAY [ POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] ] . size ( ) ;
}
if ( DownPressed ( ) | | UpPressed ( ) | | LeftPressed ( ) & & POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] = = 0 ) {
if ( UpPressed ( ) ) {
if ( POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] = = 0 ) {
POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] = ( int ) BATTLE_MOVELIST_DISPLAY . size ( ) - 1 ;
POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] = std : : clamp ( POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] , 0 , ( int ) BATTLE_MOVELIST_DISPLAY [ POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] ] . size ( ) - 1 ) ;
POWER_SELECTION_OFFSET [ - CURRENT_TURN - 1 ] = std : : clamp ( POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] - 3 , 0 , ( int ) BATTLE_MOVELIST_DISPLAY . size ( ) - 1 ) ;
} else {
POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] = std : : clamp ( POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] - 1 , 0 , ( int ) BATTLE_MOVELIST_DISPLAY . size ( ) - 1 ) ;
POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] = std : : clamp ( POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] , 0 , ( int ) BATTLE_MOVELIST_DISPLAY [ POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] ] . size ( ) - 1 ) ;
if ( POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] < POWER_SELECTION_OFFSET [ - CURRENT_TURN - 1 ] ) {
POWER_SELECTION_OFFSET [ - CURRENT_TURN - 1 ] - - ;
}
}
} else
if ( DownPressed ( ) ) {
if ( POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] = = ( int ) BATTLE_MOVELIST_DISPLAY . size ( ) - 1 ) {
POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] = 0 ;
POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] = 0 ;
POWER_SELECTION_OFFSET [ - CURRENT_TURN - 1 ] = 0 ;
} else {
POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] = std : : clamp ( POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] + 1 , 0 , ( int ) BATTLE_MOVELIST_DISPLAY . size ( ) - 1 ) ;
POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] = std : : clamp ( POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] , 0 , ( int ) BATTLE_MOVELIST_DISPLAY [ POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] ] . size ( ) - 1 ) ;
if ( POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] - POWER_SELECTION_OFFSET [ - CURRENT_TURN - 1 ] > = 4 ) {
POWER_SELECTION_OFFSET [ - CURRENT_TURN - 1 ] + + ;
}
}
} else {
POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] = 0 ;
BATTLE_STATE = BattleState : : POWER_SELECT ;
}
} else
if ( LeftPressed ( ) ) {
POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] = std : : clamp ( POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] - 1 , 0 , ( int ) ( BATTLE_MOVELIST_DISPLAY [ POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] ] . size ( ) ) - 1 ) ;
}
if ( ACTIONKEYPRESSED ) {
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove = BATTLE_MOVELIST_DISPLAY [ POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] ] [ POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] ] ;
SetupTargetSelect ( ) ;
}
}
} break ;
case BattleState : : TARGET_SELECT : {
if ( LeftPressed ( ) ) {
if ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > friendly ) {
do {
SELECTED_TARGET + + ;
if ( SELECTED_TARGET = = 0 ) {
SELECTED_TARGET = - 4 ;
}
} while ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - SELECTED_TARGET - 1 ] ] - > GetHP ( ) < = 0 & & ! getProperty ( Property : : REVIVE , PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove ) ) ;
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > channelPos = PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - SELECTED_TARGET - 1 ] ] - > obj - > GetPosWithOrigin ( ) ;
} else {
do {
SELECTED_TARGET - - ;
if ( SELECTED_TARGET < 0 ) {
SELECTED_TARGET = BATTLE_ENCOUNTER - > objs . size ( ) - 1 ;
}
} while ( BATTLE_ENCOUNTER - > objs [ SELECTED_TARGET ] - > GetHP ( ) < = 0 ) ;
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > channelPos = BATTLE_ENCOUNTER - > objs [ SELECTED_TARGET ] - > obj - > GetPosWithOrigin ( ) ;
}
for ( int i = 0 ; i < PARTY_MEMBER_COUNT ; i + + ) {
PARTY_MEMBER_OBJ [ i ] - > highlighted = false ;
}
for ( int i = 0 ; i < BATTLE_ENCOUNTER - > objs . size ( ) ; i + + ) {
BATTLE_ENCOUNTER - > objs [ i ] - > obj - > highlighted = false ;
}
for ( auto & ent : GetEntitiesInRange ( SELECTED_TARGET , PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > channelPos , PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove ) ) {
ent - > obj - > highlighted = true ;
}
}
if ( RightPressed ( ) ) {
if ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > friendly ) {
do {
SELECTED_TARGET - = 1 ;
if ( SELECTED_TARGET < - PARTY_MEMBER_COUNT ) {
SELECTED_TARGET = - 1 ;
}
} while ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - SELECTED_TARGET - 1 ] ] - > GetHP ( ) < = 0 & & ! getProperty ( Property : : REVIVE , PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove ) ) ;
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > channelPos = PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - SELECTED_TARGET - 1 ] ] - > obj - > GetPosWithOrigin ( ) ;
} else {
do {
SELECTED_TARGET = ( SELECTED_TARGET + 1 ) % BATTLE_ENCOUNTER - > objs . size ( ) ;
} while ( BATTLE_ENCOUNTER - > objs [ SELECTED_TARGET ] - > GetHP ( ) < = 0 ) ;
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > channelPos = BATTLE_ENCOUNTER - > objs [ SELECTED_TARGET ] - > obj - > GetPosWithOrigin ( ) ;
}
for ( int i = 0 ; i < PARTY_MEMBER_COUNT ; i + + ) {
PARTY_MEMBER_OBJ [ i ] - > highlighted = false ;
}
for ( int i = 0 ; i < BATTLE_ENCOUNTER - > objs . size ( ) ; i + + ) {
BATTLE_ENCOUNTER - > objs [ i ] - > obj - > highlighted = false ;
}
for ( auto & ent : GetEntitiesInRange ( SELECTED_TARGET , PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > channelPos , PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove ) ) {
ent - > obj - > highlighted = true ;
}
}
if ( UpPressed ( ) ) {
if ( BATTLE_SELECTION_CURSOR = = 0 ) { //Power was selected, so go back to the powers menu.
BATTLE_STATE = BattleState : : GRADE_SELECT ;
} else { //This was a standard attack, go back to main menu.
BATTLE_STATE = BattleState : : SELECT_ACTION ;
}
for ( int i = 0 ; i < PARTY_MEMBER_COUNT ; i + + ) {
PARTY_MEMBER_OBJ [ i ] - > highlighted = false ;
}
for ( int i = 0 ; i < BATTLE_ENCOUNTER - > objs . size ( ) ; i + + ) {
BATTLE_ENCOUNTER - > objs [ i ] - > obj - > highlighted = false ;
}
}
if ( ACTIONKEYPRESSED ) {
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedTarget = SELECTED_TARGET ;
if ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove = = nullptr ) { //We have to check for this because other actions will need a target select and will override this.
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove = BATTLE_MOVELIST_DISPLAY [ POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] ] [ POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] ] ;
}
for ( int i = 0 ; i < PARTY_MEMBER_COUNT ; i + + ) {
PARTY_MEMBER_OBJ [ i ] - > highlighted = false ;
}
for ( int i = 0 ; i < BATTLE_ENCOUNTER - > objs . size ( ) ; i + + ) {
BATTLE_ENCOUNTER - > objs [ i ] - > obj - > highlighted = false ;
}
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > channelTimeRemaining = PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > channelTime ;
BATTLE_STATE = BattleState : : WAIT ;
}
} break ;
case BattleState : : MOVE_SELECT : {
if ( LeftPressed ( ) ) {
for ( int i = 1 ; i < = 3 ; i + + ) {
if ( MOVEMENT_GRID . count ( { SELECTED_MOVE_SQUARE . x - i , SELECTED_MOVE_SQUARE . y } ) ) {
SELECTED_MOVE_SQUARE . x - = i ;
break ;
}
}
}
if ( RightPressed ( ) ) {
for ( int i = 1 ; i < = 8 ; i + + ) {
if ( MOVEMENT_GRID . count ( { SELECTED_MOVE_SQUARE . x + i , SELECTED_MOVE_SQUARE . y } ) ) {
SELECTED_MOVE_SQUARE . x + = i ;
break ;
}
}
}
if ( UpPressed ( ) ) {
for ( int i = 1 ; i < = 8 ; i + + ) {
if ( MOVEMENT_GRID . count ( { SELECTED_MOVE_SQUARE . x , SELECTED_MOVE_SQUARE . y - i } ) ) {
SELECTED_MOVE_SQUARE . y - = i ;
break ;
}
}
}
if ( DownPressed ( ) ) {
for ( int i = 1 ; i < = 8 ; i + + ) {
if ( MOVEMENT_GRID . count ( { SELECTED_MOVE_SQUARE . x , SELECTED_MOVE_SQUARE . y + i } ) ) {
SELECTED_MOVE_SQUARE . y + = i ;
break ;
}
}
}
if ( ACTIONKEYPRESSED ) {
BATTLE_ENCOUNTER - > playerPos [ - CURRENT_TURN - 1 ] = ( BATTLE_ENCOUNTER - > playerPos [ - CURRENT_TURN - 1 ] / 32 + SELECTED_MOVE_SQUARE ) * 32 ;
BATTLE_STATE = BattleState : : MOVE_CAMERA ;
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > atb = 400 ;
}
} break ;
}
}
switch ( GAME_STATE ) {
case GameState : : TILE_SELECT : {
if ( UpPressed ( ) ) {
SELECTED_TILE . y = SELECTED_TILE . y - 1 ;
if ( SELECTED_TILE . y < 0 ) {
SELECTED_TILE . y = TILEMAP_SIZE_Y / 32 - 1 ;
}
}
if ( RightPressed ( ) ) {
SELECTED_TILE . x = ( SELECTED_TILE . x + 1 ) % ( TILEMAP_SIZE_X / 32 ) ;
}
if ( LeftPressed ( ) ) {
SELECTED_TILE . x = SELECTED_TILE . x - 1 ;
if ( SELECTED_TILE . x < 0 ) {
SELECTED_TILE . x = TILEMAP_SIZE_X / 32 - 1 ;
}
}
if ( DownPressed ( ) ) {
SELECTED_TILE . y = ( SELECTED_TILE . y + 1 ) % ( TILEMAP_SIZE_Y / 32 ) ;
}
} break ;
case GameState : : GAME_WORLD : {
if ( GetKey ( F5 ) . bPressed ) {
GAME_STATE = GameState : : EDITOR ;
}
} break ;
case GameState : : EDITOR : {
if ( IsTextEntryEnabled ( ) ) {
return ;
}
if ( GetKey ( F2 ) . bPressed ) {
SaveMap ( CURRENT_MAP ) ;
printf ( " Map Saved \n " ) ;
}
if ( GetKey ( F5 ) . bPressed ) {
GAME_STATE = GameState : : GAME_WORLD ;
EDITING_LAYER = layer : : DYNAMIC ;
}
if ( GetKey ( K1 ) . bPressed ) {
EDITING_LAYER = layer : : COLLISION ;
EnableLayer ( layer : : COLLISION , true ) ;
SetLayerTint ( layer : : COLLISION , { 255 , 0 , 0 , 215 } ) ;
}
if ( GetKey ( K2 ) . bPressed ) {
EDITING_LAYER = layer : : HIGH ;
EnableLayer ( layer : : COLLISION , false ) ;
}
if ( GetKey ( K3 ) . bPressed ) {
EDITING_LAYER = layer : : DYNAMIC ;
EnableLayer ( layer : : COLLISION , false ) ;
}
if ( GetKey ( K4 ) . bPressed ) {
EDITING_LAYER = layer : : GROUND ;
EnableLayer ( layer : : COLLISION , false ) ;
}
if ( GetKey ( K5 ) . bPressed ) {
EDITING_LAYER = layer : : BACKGROUND ;
EnableLayer ( layer : : COLLISION , false ) ;
}
if ( GetKey ( ESCAPE ) . bPressed ) {
GAME_STATE = GameState : : OBJ_SELECT ;
}
if ( EDITING_LAYER = = layer : : ENCOUNTER & & GetMouse ( 0 ) . bPressed ) {
for ( int i = 0 ; i < CURRENT_MAP - > encounters . size ( ) ; i + + ) {
if ( CURRENT_MAP - > encounters [ i ] - > pos = = HIGHLIGHTED_TILE * 32 ) {
EDITING_ENCOUNTER = CURRENT_MAP - > encounters [ i ] ;
TextEntryEnable ( true ) ;
break ;
}
}
} else
if ( EDITING_LAYER = = layer : : ENCOUNTER & & GetMouse ( 0 ) . bPressed ) {
LoadEncounter ( CURRENT_MAP , HIGHLIGHTED_TILE * 32 , ENCOUNTER_LIST [ ENCOUNTER_SELECTED ] - > chance , ENCOUNTER_SELECTED , true ) ;
} else
if ( EDITING_LAYER = = layer : : ENCOUNTER & & GetMouse ( 1 ) . bPressed ) {
for ( int i = 0 ; i < CURRENT_MAP - > encounters . size ( ) ; i + + ) {
if ( CURRENT_MAP - > encounters [ i ] - > pos = = HIGHLIGHTED_TILE * 32 ) {
for ( int j = 0 ; j < CURRENT_MAP - > encounters [ i ] - > objs . size ( ) ; j + + ) {
int index = CURRENT_MAP - > encounters [ i ] - > objs [ j ] - > obj - > objArrElement ;
delete OBJECTS [ index ] ;
OBJECTS . erase ( OBJECTS . begin ( ) + index ) ;
for ( int k = 0 ; k < OBJECTS . size ( ) ; k + + ) {
OBJECTS [ k ] - > objArrElement = k ;
}
}
delete CURRENT_MAP - > encounters [ i ] ;
CURRENT_MAP - > encounters . erase ( CURRENT_MAP - > encounters . begin ( ) + i - - ) ;
continue ;
}
}
} else
if ( EDITING_LAYER = = layer : : OBJECT & & GetMouse ( 0 ) . bPressed ) {
AddObjectToWorld ( CreateObject ( SELECTED_OBJ_ID , HIGHLIGHTED_TILE * 32 ) ) ;
} else
if ( EDITING_LAYER = = layer : : OBJECT & & GetMouse ( 1 ) . bReleased ) {
for ( int i = 0 ; i < OBJECTS . size ( ) ; i + + ) {
if ( OBJECTS [ i ] - > GetPos ( ) = = HIGHLIGHTED_TILE * 32 ) {
delete OBJECTS [ i ] ;
OBJECTS . erase ( OBJECTS . begin ( ) + i - - ) ;
} else {
OBJECTS [ i ] - > objArrElement = i ;
}
}
}
} break ;
case GameState : : OBJ_SELECT : {
if ( GetKey ( ESCAPE ) . bPressed ) {
GAME_STATE = GameState : : EDITOR ;
}
if ( ( GetMouseWheel ( ) < 0 | | GetKey ( PGDN ) . bHeld ) & & OBJ_DISPLAY_OFFSET + ( WIDTH / 16 ) < OBJ_INFO . size ( ) ) {
OBJ_DISPLAY_OFFSET + = WIDTH / 16 ;
} else
if ( ( GetMouseWheel ( ) > 0 | | GetKey ( PGUP ) . bHeld ) & & OBJ_DISPLAY_OFFSET - ( WIDTH / 16 ) > = 0 ) {
OBJ_DISPLAY_OFFSET - = WIDTH / 16 ;
}
} break ;
}
ANYKEYPRESSED = ACTIONKEYPRESSED = false ;
}
void drawGame ( ) {
for ( auto & obj : OBJECTS ) {
obj - > drawn = false ;
}
if ( BATTLE_ENCOUNTER ! = nullptr ) {
SetDrawTarget ( layer : : DYNAMIC ) ;
for ( int i = 0 ; i < PARTY_MEMBER_COUNT ; i + + ) {
if ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > selectedMove ! = nullptr & & PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > channelTimeRemaining > 0 & & PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > selectedMove - > friendly ) {
DrawTargetRangeGrid ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > channelPos , PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > selectedMove - > range ,
Pixel ( 0 , 128 , 0 , 255 ) , Pixel ( 0 , 128 , 0 , 64 ) , Pixel ( 90 , 200 , 90 , 64 ) , true ) ;
}
}
for ( int i = 0 ; i < BATTLE_ENCOUNTER - > objs . size ( ) ; i + + ) {
if ( BATTLE_ENCOUNTER - > objs [ i ] - > selectedMove ! = nullptr & & BATTLE_ENCOUNTER - > objs [ i ] - > channelTimeRemaining > 0 & & ! BATTLE_ENCOUNTER - > objs [ i ] - > selectedMove - > friendly ) {
DrawTargetRangeGrid ( BATTLE_ENCOUNTER - > objs [ i ] - > channelPos , BATTLE_ENCOUNTER - > objs [ i ] - > selectedMove - > range ,
Pixel ( 128 , 0 , 0 , 255 ) , Pixel ( 128 , 0 , 0 , 64 ) , Pixel ( 200 , 90 , 90 , 64 ) , true ) ;
}
}
if ( BATTLE_STATE = = BattleState : : MOVE_SELECT ) {
DrawMovementGrid ( YELLOW , BLUE , BLUE ) ;
}
}
switch ( GAME_STATE ) {
case GameState : : GAME_WORLD : {
DrawGameWorld ( ) ;
} break ;
case GameState : : EDITOR : {
DrawGameWorld ( ) ;
SetDrawTarget ( nullptr ) ;
DrawRectDecal ( ( HIGHLIGHTED_TILE ) * 32 - cameraPos , { 32 , 32 } , YELLOW ) ;
if ( EDITING_LAYER = = layer : : ENCOUNTER ) {
if ( IsTextEntryEnabled ( ) ) {
DrawStringPropDecal ( { 2 , 2 } , " Input Chance: " + TextEntryGetString ( ) + " % " , YELLOW ) ;
} else {
DrawStringPropDecal ( { 2 , 2 } , " Editing Encounters " ) ;
}
for ( auto & enc : CURRENT_MAP - > encounters ) {
FillRectDecal ( enc - > pos - cameraPos , { WIDTH , HEIGHT } , Pixel ( 255 , 0 , 0 , 64 ) ) ;
DrawRectDecal ( enc - > pos - cameraPos , { WIDTH , HEIGHT } , YELLOW ) ;
vi2d textOffset = { 2 , 2 } ;
DrawStringDecal ( enc - > pos - cameraPos + textOffset , std : : to_string ( enc - > chance ) + " % " ) ;
}
} else
if ( EDITING_LAYER = = layer : : OBJECT ) {
DrawStringPropDecal ( { 2 , 2 } , " Editing Objects " ) ;
} else {
DrawStringPropDecal ( { 2 , 2 } , " Editing Layer " + std : : to_string ( EDITING_LAYER ) ) ;
}
} break ;
case GameState : : TILE_SELECT : {
//14x14 pixels per tile.
DrawDecal ( { 0 , 0 } , SPRITES [ " terrainmap.png " ] , { TILEMAP_EDITOR_DRAW_MULT , TILEMAP_EDITOR_DRAW_MULT } ) ;
DrawRectDecal ( SELECTED_TILE * ( TILEMAP_EDITOR_TILESIZE ) , { TILEMAP_EDITOR_TILESIZE , TILEMAP_EDITOR_TILESIZE } , RED ) ;
} break ;
case GameState : : OBJ_SELECT : {
vd2d drawpos = { 0 , 0 } ;
int counter = 0 ;
for ( std : : map < int , Object * > : : const_iterator it = OBJ_INFO . cbegin ( ) ; it ! = OBJ_INFO . cend ( ) ; + + it ) {
if ( counter < OBJ_DISPLAY_OFFSET ) {
counter + + ;
continue ;
}
if ( drawpos . y > HEIGHT ) {
break ;
}
Object * obj = it - > second ;
if ( GetMouse ( 0 ) . bHeld & &
GetMousePos ( ) . x > = drawpos . x & &
GetMousePos ( ) . x < drawpos . x + 16 & &
GetMousePos ( ) . y > = drawpos . y & &
GetMousePos ( ) . y < drawpos . y + 24 ) {
SELECTED_OBJ_ID = obj - > id ;
EDITING_LAYER = layer : : OBJECT ;
EnableLayer ( layer : : COLLISION , false ) ;
}
FillRectDecal ( drawpos , { 16 , 24 } , VERY_DARK_GREY ) ;
DrawPartialDecal ( { ( float ) drawpos . x , ( float ) drawpos . y + 8 } , { 16 , 16 } , obj - > spr - > spr , { ( float ) ( ( obj - > frameIndex % obj - > spr - > frames ) * obj - > spr - > width ) , 0 } , { ( float ) obj - > spr - > width , ( float ) obj - > spr - > spr - > sprite - > height } , obj - > color ) ;
DrawStringDecal ( { ( float ) ( drawpos . x + 2 ) , ( float ) ( drawpos . y ) } , obj - > name , WHITE , { ( float ) ( 12.0 / GetTextSize ( obj - > name ) . x ) , 1.0 } ) ;
if ( SELECTED_OBJ_ID = = obj - > id ) {
DrawRectDecal ( drawpos , { 16 , 24 } , YELLOW ) ;
}
drawpos . x + = 16 ;
if ( drawpos . x > = WIDTH ) {
drawpos . x = 0 ;
drawpos . y + = 24 ;
}
counter + + ;
}
} break ;
case GameState : : ENCOUNTER_SELECT : {
vd2d drawpos = { 0 , 0 } ;
int counter = 0 ;
for ( int i = 0 ; i < ENCOUNTER_LIST . size ( ) ; i + + ) {
if ( counter < ENCOUNTER_OFFSET ) {
counter + + ;
continue ;
}
if ( drawpos . y > HEIGHT ) {
break ;
}
Encounter * enc = ENCOUNTER_LIST [ i ] ;
if ( GetMouse ( 0 ) . bHeld & &
GetMousePos ( ) . x > = drawpos . x & &
GetMousePos ( ) . x < drawpos . x + 16 & &
GetMousePos ( ) . y > = drawpos . y & &
GetMousePos ( ) . y < drawpos . y + 24 ) {
ENCOUNTER_SELECTED = enc - > id ;
EDITING_LAYER = layer : : ENCOUNTER ;
EnableLayer ( layer : : COLLISION , false ) ;
}
FillRectDecal ( drawpos , { 16 , 24 } , VERY_DARK_GREY ) ;
for ( int i = 0 ; i < enc - > objs . size ( ) ; i + = 2 ) {
DrawPartialDecal ( { ( float ) ( drawpos . x + ( ( double ) 8 / ( enc - > objs . size ( ) ) ) * i - 4 ) , ( float ) ( drawpos . y ) } , { 16 , 16 } , enc - > objs [ i ] - > obj - > spr - > spr , { ( float ) ( ( enc - > objs [ i ] - > obj - > frameIndex % enc - > objs [ i ] - > obj - > spr - > frames ) * enc - > objs [ i ] - > obj - > spr - > width ) , 0 } , { ( float ) ( enc - > objs [ i ] - > obj - > spr - > width ) , ( float ) ( enc - > objs [ i ] - > obj - > spr - > spr - > sprite - > height ) } , enc - > objs [ i ] - > obj - > color ) ;
}
for ( int i = 1 ; i < enc - > objs . size ( ) ; i + = 2 ) {
DrawPartialDecal ( { ( float ) ( drawpos . x + ( ( double ) 8 / ( enc - > objs . size ( ) ) ) * i - 4 ) , ( float ) ( drawpos . y + 6 ) } , { 16 , 16 } , enc - > objs [ i ] - > obj - > spr - > spr , { ( float ) ( ( enc - > objs [ i ] - > obj - > frameIndex % enc - > objs [ i ] - > obj - > spr - > frames ) * enc - > objs [ i ] - > obj - > spr - > width ) , 0 } , { ( float ) ( enc - > objs [ i ] - > obj - > spr - > width ) , ( float ) ( enc - > objs [ i ] - > obj - > spr - > spr - > sprite - > height ) } , enc - > objs [ i ] - > obj - > color ) ;
}
if ( ENCOUNTER_SELECTED = = enc - > id ) {
DrawRectDecal ( drawpos , { 16 , 24 } , YELLOW ) ;
}
DrawStringDecal ( { ( float ) ( drawpos . x + 2 ) , ( float ) ( drawpos . y + 24 - GetTextSize ( std : : to_string ( enc - > id ) ) . y ) } , std : : to_string ( enc - > id ) , WHITE , { ( float ) ( 12.0 / GetTextSize ( std : : to_string ( enc - > id ) ) . x ) , 1.0 } ) ;
drawpos . x + = 16 ;
if ( drawpos . x > = WIDTH ) {
drawpos . x = 0 ;
drawpos . y + = 24 ;
}
counter + + ;
}
} break ;
}
if ( BATTLE_ENCOUNTER ! = nullptr ) {
SetDrawTarget ( layer : : HIGH ) ;
if ( BATTLE_STATE = = BattleState : : SELECT_ACTION | | BATTLE_STATE = = BattleState : : POWER_SELECT | | BATTLE_STATE = = BattleState : : GRADE_SELECT | | BATTLE_STATE = = BattleState : : ITEM_SELECT ) {
DrawDialogBox ( { 1 , 1 } , { ( int ) ( WIDTH * 0.75 ) , HEIGHT / 6 } , Pixel ( 70 , 33 , 105 , 128 ) , Pixel ( 62 , 54 , 69 , 128 ) , Pixel ( 185 , 148 , 255 , 128 ) ) ;
const std : : string labels [ 6 ] = { " Power " , " Attack " , " Item " , " Defend " , " Move " , " Run " } ;
for ( int i = 0 ; i < 6 ; i + = 2 ) {
DrawStringPropDecal ( { 3 + 8 + i / 2 * 64 , 9 } , labels [ i ] ) ;
DrawStringPropDecal ( { 3 + 8 + i / 2 * 64 , 23 } , labels [ i + 1 ] ) ;
}
DrawDecal ( { BATTLE_SELECTION_CURSOR / 2 * 64 + 3 , 9 + ( ( BATTLE_SELECTION_CURSOR % 2 = = 0 ) ? 0 : 14 ) } , SPRITES [ " cursor.png " ] ) ;
}
if ( BATTLE_STATE = = BattleState : : POWER_SELECT | | BATTLE_STATE = = BattleState : : GRADE_SELECT ) {
SetDrawTarget ( layer : : INTERFACE ) ;
DrawDialogBox ( { 1 , 1 } , { ( int ) ( WIDTH / 2 ) , HEIGHT / 4 } , Pixel ( 70 , 33 , 105 , 128 ) , Pixel ( 62 , 54 , 69 , 128 ) , Pixel ( 185 , 148 , 255 , 128 ) ) ;
vd2d descBoxPos = { WIDTH - ( int ) ( WIDTH / 2.5 ) - 2 , 1 } ;
vi2d textStartingOffset = { 4 , 4 } ;
DrawDialogBox ( descBoxPos , { ( int ) ( WIDTH / 2.5 ) , HEIGHT / 4 } , Pixel ( 70 , 33 , 105 , 128 ) , Pixel ( 62 , 54 , 69 , 128 ) , Pixel ( 185 , 148 , 255 , 128 ) ) ;
DrawStringPropDecal ( descBoxPos + textStartingOffset , Wrap ( BATTLE_MOVELIST_DISPLAY [ POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] ] [ 0 ] - > desc , ( ( int ) ( WIDTH / 2.5 - 8 ) ) , true , { 0.8 , 0.8 } ) , WHITE , { 0.8 , 0.8 } ) ;
vd2d ppCostBoxPos = { WIDTH - WIDTH / 3 - 2 , HEIGHT / 4 + 2 } ;
DrawDialogBox ( ppCostBoxPos , { ( int ) ( WIDTH / 6 ) , HEIGHT / 8 } , Pixel ( 70 , 33 , 105 , 128 ) , Pixel ( 62 , 54 , 69 , 128 ) , Pixel ( 185 , 148 , 255 , 128 ) ) ;
DrawStringPropDecal ( ppCostBoxPos + textStartingOffset , " PP Cost " , WHITE , { 0.7 , 0.8 } ) ;
std : : string label = std : : to_string ( BATTLE_MOVELIST_DISPLAY [ POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] ] [ POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] ] - > PPCost ) ;
DrawStringPropDecal ( { ppCostBoxPos . x + textStartingOffset . x + ( WIDTH / 6 ) - 8 - GetTextSizeProp ( label ) . x * 1.5 , ppCostBoxPos . y + textStartingOffset . y + 8 } , label , WHITE , { 1.5 , 1.5 } ) ;
vd2d damageBoxPos = { WIDTH - WIDTH / 3 + WIDTH / 6 - 1 , HEIGHT / 4 + 2 } ;
DrawStringPropDecal ( damageBoxPos + textStartingOffset , " Damage " , WHITE , { 0.7 , 0.8 } ) ;
label = ( BATTLE_MOVELIST_DISPLAY [ POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] ] [ POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] ] - > baseDmg ! = 0 ) ? std : : to_string ( BATTLE_MOVELIST_DISPLAY [ POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] ] [ POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] ] - > baseDmg + PARTY_MEMBER_STATS [ - CURRENT_TURN - 1 ] - > baseAtk ) + " ~ " + std : : to_string ( BATTLE_MOVELIST_DISPLAY [ POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] ] [ POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] ] - > randomDmg + BATTLE_MOVELIST_DISPLAY [ POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] ] [ POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] ] - > baseDmg + PARTY_MEMBER_STATS [ - CURRENT_TURN - 1 ] - > baseAtk ) : " N/A " ;
DrawStringPropDecal ( { damageBoxPos . x + textStartingOffset . x + ( WIDTH / 6 ) - 8 - GetTextSizeProp ( label ) . x * ( std : : min ( ( double ) ( ( WIDTH / 6 ) - 8 ) / GetTextSizeProp ( label ) . x , 1.5 ) ) , damageBoxPos . y + textStartingOffset . y + 8 } , label , WHITE , { std : : min ( ( double ) ( ( WIDTH / 6 ) - 8 ) / GetTextSizeProp ( label ) . x , 1.5 ) , 1.5 } ) ;
DrawDialogBox ( { WIDTH - WIDTH / 3 + WIDTH / 6 - 1 , HEIGHT / 4 + 2 } , { ( int ) ( WIDTH / 6 ) , HEIGHT / 8 } , Pixel ( 70 , 33 , 105 , 128 ) , Pixel ( 62 , 54 , 69 , 128 ) , Pixel ( 185 , 148 , 255 , 128 ) ) ;
vd2d rangeBoxPos = { WIDTH - WIDTH / 3 + WIDTH / 6 - 1 , HEIGHT / 4 + HEIGHT / 8 + 3 } ;
DrawStringPropDecal ( rangeBoxPos + textStartingOffset , " Range " , WHITE , { 0.7 , 0.8 } ) ;
label = std : : to_string ( BATTLE_MOVELIST_DISPLAY [ POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] ] [ POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] ] - > range ) ;
DrawStringPropDecal ( { rangeBoxPos . x + textStartingOffset . x + ( WIDTH / 6 ) - 8 - GetTextSizeProp ( label ) . x * ( std : : min ( ( double ) ( ( WIDTH / 6 ) - 8 ) / GetTextSizeProp ( label ) . x , 1.5 ) ) , rangeBoxPos . y + textStartingOffset . y + 8 } , label , WHITE , { std : : min ( ( double ) ( ( WIDTH / 6 ) - 8 ) / GetTextSizeProp ( label ) . x , 1.5 ) , 1.5 } ) ;
DrawDialogBox ( { WIDTH - WIDTH / 3 + WIDTH / 6 - 1 , HEIGHT / 4 + HEIGHT / 8 + 3 } , { ( int ) ( WIDTH / 6 ) , HEIGHT / 8 } , Pixel ( 70 , 33 , 105 , 128 ) , Pixel ( 62 , 54 , 69 , 128 ) , Pixel ( 185 , 148 , 255 , 128 ) ) ;
vd2d channelTimeBoxPos = { WIDTH - WIDTH / 3 - 1 , HEIGHT / 4 + HEIGHT / 8 + 3 } ;
DrawStringPropDecal ( channelTimeBoxPos + textStartingOffset , " Cast " , WHITE , { 0.7 , 0.8 } ) ;
label = std : : to_string ( ( float ) BATTLE_MOVELIST_DISPLAY [ POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] ] [ POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] ] - > channelTime / 60 ) . erase ( 3 ) ;
DrawStringPropDecal ( { channelTimeBoxPos . x + textStartingOffset . x + ( WIDTH / 6 ) - 8 - GetTextSizeProp ( label ) . x * ( std : : min ( ( double ) ( ( WIDTH / 6 ) - 8 ) / GetTextSizeProp ( label ) . x , 1.5 ) ) , channelTimeBoxPos . y + textStartingOffset . y + 8 } , label , WHITE , { std : : min ( ( double ) ( ( WIDTH / 6 ) - 8 ) / GetTextSizeProp ( label ) . x , 1.5 ) , 1.5 } ) ;
DrawDialogBox ( { WIDTH - WIDTH / 3 - 1 , HEIGHT / 4 + HEIGHT / 8 + 3 } , { ( int ) ( WIDTH / 6 ) , HEIGHT / 8 } , Pixel ( 70 , 33 , 105 , 128 ) , Pixel ( 62 , 54 , 69 , 128 ) , Pixel ( 185 , 148 , 255 , 128 ) ) ;
int counter = 0 ;
int displayLimit = 0 ;
for ( int i = 0 ; i < BATTLE_MOVELIST_DISPLAY . size ( ) ; i + + ) {
if ( counter > = POWER_SELECTION_OFFSET [ - CURRENT_TURN - 1 ] & & counter < = POWER_SELECTION_OFFSET [ - CURRENT_TURN - 1 ] + 3 ) {
int displayYOffset = - POWER_SELECTION_OFFSET [ - CURRENT_TURN - 1 ] * 12 ;
std : : vector < Battle : : Move * > moves = BATTLE_MOVELIST_DISPLAY [ i ] ;
std : : string name = moves [ 0 ] - > name ;
if ( GetTextSizeProp ( name ) . x > WIDTH / 4 ) {
DrawStringPropDecal ( { 12 , 12 * counter + 8 + displayYOffset } , name , WHITE , { ( WIDTH / 4 ) / ( float ) GetTextSizeProp ( name ) . x , 1 } ) ;
} else {
DrawStringPropDecal ( { 12 , 12 * counter + 8 + displayYOffset } , name ) ;
}
for ( int i = 0 ; i < moves . size ( ) ; i + + ) {
if ( BATTLE_STATE = = BattleState : : GRADE_SELECT & & POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] = = counter ) {
if ( POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] = = i ) {
DrawFancyStringDecal ( { 8 + WIDTH / 4 + 12 + i * 8 , 12 * counter + 8 + displayYOffset } , std : : wstring ( 1 , moves [ i ] - > grade ) ) ;
} else {
DrawFancyStringDecal ( { 8 + WIDTH / 4 + 12 + i * 8 , 12 * counter + 8 + displayYOffset } , std : : wstring ( 1 , moves [ i ] - > grade ) , DARK_GREY ) ;
}
} else {
DrawFancyStringDecal ( { 8 + WIDTH / 4 + 12 + i * 8 , 12 * counter + 8 + displayYOffset } , std : : wstring ( 1 , moves [ i ] - > grade ) ) ;
}
}
}
+ + counter ;
}
if ( BATTLE_STATE = = BattleState : : POWER_SELECT ) {
DrawDecal ( { 4 , 12 * ( POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] - POWER_SELECTION_OFFSET [ - CURRENT_TURN - 1 ] ) + 8 } , SPRITES [ " cursor.png " ] ) ;
} else {
DrawDecal ( { WIDTH / 4 + 4 + POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] * 8 + 8 , 12 * ( POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] - POWER_SELECTION_OFFSET [ - CURRENT_TURN - 1 ] ) + 8 } , SPRITES [ " cursor.png " ] ) ;
}
if ( BATTLE_MOVELIST_DISPLAY . size ( ) > 4 ) {
if ( POWER_SELECTION_OFFSET [ - CURRENT_TURN - 1 ] > 0 ) {
DrawRotatedDecal ( { WIDTH / 2 - 16 , 7 } , SPRITES [ " cursor.png " ] , - M_PI_2 , { 4 , 4 } ) ;
}
if ( POWER_SELECTION_OFFSET [ - CURRENT_TURN - 1 ] + 3 < BATTLE_MOVELIST_DISPLAY . size ( ) - 1 ) {
DrawRotatedDecal ( { WIDTH / 2 - 16 , HEIGHT / 4 - 7 } , SPRITES [ " cursor.png " ] , M_PI_2 , { 4 , 4 } ) ;
}
}
}
if ( BATTLE_STATE = = BattleState : : TARGET_SELECT ) {
SetDrawTarget ( layer : : GROUND ) ;
if ( SELECTED_TARGET < 0 ) {
vd2d scale = { PARTY_MEMBER_OBJ [ - SELECTED_TARGET - 1 ] - > spr - > width / ( double ) SPRITES [ " targetCircle.png " ] - > sprite - > width , PARTY_MEMBER_OBJ [ - SELECTED_TARGET - 1 ] - > spr - > spr - > sprite - > height / ( double ) SPRITES [ " targetCircle.png " ] - > sprite - > height } ;
vi2d size = { SPRITES [ " targetCircle.png " ] - > sprite - > width , SPRITES [ " targetCircle.png " ] - > sprite - > height } ;
DrawDecal ( PARTY_MEMBER_OBJ [ - SELECTED_TARGET - 1 ] - > GetPosWithOrigin ( ) - cameraPos - size / 2 * scale , SPRITES [ " targetCircle.png " ] , { PARTY_MEMBER_OBJ [ - SELECTED_TARGET - 1 ] - > spr - > width / ( double ) SPRITES [ " targetCircle.png " ] - > sprite - > width , PARTY_MEMBER_OBJ [ - SELECTED_TARGET - 1 ] - > spr - > spr - > sprite - > height / ( double ) SPRITES [ " targetCircle.png " ] - > sprite - > height } , GREEN ) ;
DrawTargetRangeGrid ( PARTY_MEMBER_OBJ [ - SELECTED_TARGET - 1 ] - > GetPosWithOrigin ( ) , PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > range ) ;
} else {
vd2d scale = { BATTLE_ENCOUNTER - > objs [ SELECTED_TARGET ] - > obj - > spr - > width / ( double ) SPRITES [ " targetCircle.png " ] - > sprite - > width , BATTLE_ENCOUNTER - > objs [ SELECTED_TARGET ] - > obj - > spr - > spr - > sprite - > height / ( double ) SPRITES [ " targetCircle.png " ] - > sprite - > height } ;
vi2d size = { SPRITES [ " targetCircle.png " ] - > sprite - > width , SPRITES [ " targetCircle.png " ] - > sprite - > height } ;
DrawDecal ( BATTLE_ENCOUNTER - > objs [ SELECTED_TARGET ] - > obj - > GetPosWithOrigin ( ) - cameraPos - size / 2 * scale , SPRITES [ " targetCircle.png " ] , scale , YELLOW ) ;
DrawTargetRangeGrid ( BATTLE_ENCOUNTER - > objs [ SELECTED_TARGET ] - > obj - > GetPosWithOrigin ( ) , PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > range ) ;
}
}
if ( BATTLE_STATE = = BattleState : : WAIT_ANIMATION ) {
SetDrawTarget ( layer : : INTERFACE ) ;
std : : wstring label = L " " ;
if ( CURRENT_TURN < 0 ) {
label = to_wstring ( PARTY_MEMBER_OBJ [ - CURRENT_TURN - 1 ] - > name ) + L " uses " + to_wstring ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > name ) + L " " + ( ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > grade ! = 0 ) ? std : : wstring ( 1 , PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > grade ) : L " " ) ;
} else {
label = to_wstring ( BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > obj - > name ) + L " uses " + to_wstring ( BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove - > name ) + L " " + ( ( BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove - > grade ! = 0 ) ? std : : wstring ( 1 , BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove - > grade ) : L " " ) ;
}
DrawFancyStringDecal ( { 2 , 2 } , Wrap ( label , ScreenWidth ( ) - 2 , false , { 2 , 2 } ) , WHITE , { 2 , 2 } ) ;
}
if ( BATTLE_STATE ! = BattleState : : MOVE_CAMERA ) {
SetDrawTarget ( layer : : INTERFACE ) ;
vi2d screenShakeOffset = { 0 , 0 } ;
cameraPos = BATTLE_ENCOUNTER - > pos ;
if ( BATTLE_HIT_SCREENSHAKE > 0 ) {
BATTLE_HIT_SCREENSHAKE - - ;
if ( BATTLE_HIT_SCREENSHAKE % 2 = = 0 ) {
screenShakeOffset = { 0 , 2 } ;
} else {
screenShakeOffset = { 0 , - 2 } ;
}
}
cameraPos + = screenShakeOffset ;
std : : vector < Entity * > attackedAllies ;
if ( CURRENT_TURN > = 0 & & BATTLE_STATE = = BattleState : : WAIT_ANIMATION & & BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedTarget < 0 ) {
attackedAllies = GetEntitiesInRange ( BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedTarget , BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > channelPos , BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove ) ;
}
for ( int i = 0 ; i < PARTY_MEMBER_COUNT ; i + + ) {
Entity * member = PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] ;
Object * obj = PARTY_MEMBER_OBJ [ i ] ;
vi2d box = { ( 128 - 32 * PARTY_MEMBER_COUNT ) + i * 64 , 160 } ;
box + = screenShakeOffset ;
if ( CURRENT_TURN = = - i - 1 ) {
box . y - = 20 ;
}
bool underAttack = false ;
for ( int j = 0 ; j < attackedAllies . size ( ) ; j + + ) {
if ( attackedAllies [ j ] - > obj = = PARTY_MEMBER_OBJ [ i ] ) {
underAttack = true ;
break ;
}
}
if ( CURRENT_TURN > = 0 & & BATTLE_STATE = = BattleState : : WAIT_ANIMATION & & underAttack ) {
drawCheckerboardBox ( box , { 59 , 59 } , Pixel ( 180 , 159 , 194 ) , Pixel ( 200 , 179 , 214 ) , { 6 , 6 } , RED , DARK_RED ) ;
} else {
drawCheckerboardBox ( box , { 59 , 59 } , Pixel ( 180 , 159 , 194 ) , Pixel ( 200 , 179 , 214 ) , { 6 , 6 } ) ;
}
if ( member - > selectedMove = = nullptr ) {
DrawStringDecal ( { ( float ) ( box . x + 6 ) , ( float ) ( box . y + 6 ) } , obj - > name , BLACK ) ;
} else {
DrawStringDecal ( { ( float ) ( box . x + 6 ) , ( float ) ( box . y + 4 ) } , obj - > name , BLACK , { 1 , 0.8 } ) ;
}
DrawPartialDecal ( { ( float ) ( box . x + 4 ) , ( float ) ( box . y + 5 + 8 + 2 ) } , SPRITES [ " atbbar_back.png " ] , { 0 , 0 } , { member - > atb / 1000.0 * SPRITES [ " atbbar_back.png " ] - > sprite - > width , SPRITES [ " atbbar_back.png " ] - > sprite - > height } ) ;
DrawDecal ( { ( float ) ( box . x + 4 ) , ( float ) ( box . y + 5 + 8 + 2 ) } , SPRITES [ " atbbar_front.png " ] ) ;
if ( member - > selectedMove ! = nullptr ) {
DrawPartialDecal ( { ( float ) ( box . x + 4 ) , ( float ) ( box . y + 5 + 8 + 2 ) } , SPRITES [ " atbbar_back.png " ] , { 0 , 0 } , { ( 1 - ( ( float ) member - > channelTimeRemaining / member - > selectedMove - > channelTime ) ) * SPRITES [ " atbbar_back.png " ] - > sprite - > width , SPRITES [ " atbbar_back.png " ] - > sprite - > height } , { 1 , 1 } , GREEN * 0.7 ) ;
std : : wstring label = to_wstring ( member - > selectedMove - > name ) ;
label + = L " " ;
if ( member - > selectedMove - > grade ! = 0 ) {
label + = member - > selectedMove - > grade ;
}
vd2d textOffset = GetTextSize ( to_string ( label ) ) * 0.6 ;
textOffset . y + = 10 ;
vd2d barPos = { ( float ) ( box . x + 4 ) , ( float ) ( box . y + 5 + 8 + 2 ) } ;
DrawFancyStringDecal ( barPos - textOffset / 2 , label , BLACK , { std : : min ( ( float ) 54 / GetTextSize ( to_string ( label ) ) . x , ( float ) 1 ) , 0.6 } ) ;
}
const vi2d hpTextPos = { box . x + 5 , box . y + 25 } ;
for ( int x = - 1 ; x < = 1 ; x + + ) {
for ( int y = - 1 ; y < = 1 ; y + + ) {
if ( x ! = 0 & & y ! = 0 ) {
DrawStringDecal ( { ( float ) ( hpTextPos . x + x ) , ( float ) ( hpTextPos . y + y ) } , " HP " , olc : : WHITE ) ;
}
}
}
DrawStringDecal ( hpTextPos , " HP " , BLACK ) ;
DrawRollingCounter ( hpTextPos , member - > GetHP ( ) , player_rollhp_display [ i ] , player_rollhp_counter [ i ] ) ;
const vi2d mpTextPos = { box . x + 5 , hpTextPos . y + 17 } ;
for ( int x = - 1 ; x < = 1 ; x + + ) {
for ( int y = - 1 ; y < = 1 ; y + + ) {
if ( x ! = 0 & & y ! = 0 ) {
DrawStringDecal ( { ( float ) ( mpTextPos . x + x ) , ( float ) ( mpTextPos . y + y ) } , " PP " , olc : : WHITE ) ;
}
}
}
DrawStringDecal ( mpTextPos , " PP " , BLACK ) ;
DrawRollingCounter ( mpTextPos , member - > PP , player_rollpp_display [ i ] , player_rollpp_counter [ i ] ) ;
}
for ( int i = 0 ; i < BATTLE_ENCOUNTER - > objs . size ( ) ; i + + ) {
Entity * obj = BATTLE_ENCOUNTER - > objs [ i ] ;
if ( obj - > GetHP ( ) > 0 & & obj - > selectedMove ! = nullptr ) {
vi2d barOffset = { - SPRITES [ " atbbar_front.png " ] - > sprite - > width / 2 , 8 } ;
DrawPartialDecal ( obj - > obj - > GetPos ( ) + obj - > obj - > originPoint - cameraPos + barOffset , SPRITES [ " atbbar_back.png " ] , { 0 , 0 } , { ( 1 - ( ( float ) obj - > channelTimeRemaining / obj - > selectedMove - > channelTime ) ) * SPRITES [ " atbbar_back.png " ] - > sprite - > width , SPRITES [ " atbbar_back.png " ] - > sprite - > height } , { 1 , 1 } , YELLOW * 0.8 ) ;
DrawDecal ( obj - > obj - > GetPos ( ) + obj - > obj - > originPoint - cameraPos + barOffset , SPRITES [ " atbbar_front.png " ] ) ;
std : : wstring label = to_wstring ( obj - > selectedMove - > name ) ;
if ( obj - > selectedMove - > grade ! = 0 ) {
label + = L " " ;
label + = obj - > selectedMove - > grade ;
}
vd2d textOffset = GetTextSize ( to_string ( label ) ) * 0.6 ;
textOffset . y - = 6 ;
vi2d shadowOffset = { 1 , 1 } ;
DrawFancyStringDecal ( obj - > obj - > GetPos ( ) + obj - > obj - > originPoint - cameraPos + barOffset - textOffset / 2 + shadowOffset , label , BLACK , { 0.6 , 0.6 } ) ;
DrawFancyStringDecal ( obj - > obj - > GetPos ( ) + obj - > obj - > originPoint - cameraPos + barOffset - textOffset / 2 , label , WHITE , { 0.6 , 0.6 } ) ;
}
}
}
}
//////////////////INTERFACE LAYER.
SetDrawTarget ( layer : : INTERFACE ) ;
if ( BATTLE_ENCOUNTER ! = nullptr & & BATTLE_STATE = = BattleState : : MOVE_SELECT ) {
vd2d cursorOffset = { - 2 , - 2 } ;
vd2d cursorScale = { 1 , 1 } ;
if ( ( cos ( frameCount * M_PI / 20 ) / 2 + 0.5 ) > 0.8 ) {
cursorScale = { 1.08F , 1.08F } ;
cursorOffset . x - = 36 * 0.08 ;
cursorOffset . y - = 36 * 0.08 ;
}
cursorOffset + = SELECTED_MOVE_SQUARE * 32 ;
DrawDecal ( ( vi2d ) ( ( PARTY_MEMBER_OBJ [ - CURRENT_TURN - 1 ] - > GetPosWithOrigin ( ) - cameraPos ) / 32 ) * 32 + cursorOffset , SPRITES [ " crosshair.png " ] , cursorScale ) ;
DrawArrow ( ) ;
}
for ( auto numb : DAMAGE_NUMBERS ) {
vd2d shadowOffset = { 1 , 1 } ;
vd2d textSize = GetTextSizeProp ( ( numb - > damage > = 0 ) ? " - " + std : : to_string ( numb - > damage ) : " + " + std : : to_string ( - numb - > damage ) ) ;
DrawStringPropDecal ( numb - > pos + shadowOffset - cameraPos - textSize / 2 , ( numb - > damage > = 0 ) ? " - " + std : : to_string ( numb - > damage ) : " + " + std : : to_string ( - numb - > damage ) , BLACK , { 1 , 2 } ) ;
DrawStringPropDecal ( numb - > pos - cameraPos - textSize / 2 , ( numb - > damage > = 0 ) ? " - " + std : : to_string ( numb - > damage ) : " + " + std : : to_string ( - numb - > damage ) , ( numb - > damage > = 0 ) ? RED : GREEN , { 1 , 2 } ) ;
DrawStringPropDecal ( numb - > pos - cameraPos - textSize / 2 , ( numb - > damage > = 0 ) ? " - " + std : : to_string ( numb - > damage ) : " + " + std : : to_string ( - numb - > damage ) , Pixel ( 255 , 255 , 255 , abs ( sin ( ( M_PI * frameCount ) / 30 ) * 128 ) ) , { 1 , 2 } ) ;
}
if ( messageBoxVisible ) {
DrawDialogBox ( { 1 , 1 } , { WIDTH / 2 , HEIGHT / 4 } , Pixel ( 70 , 33 , 105 , 128 ) , Pixel ( 62 , 54 , 69 , 128 ) , Pixel ( 185 , 148 , 255 , 128 ) ) ;
DrawStringPropDecal ( { 6 , 6 } , messageBoxText ) ;
}
for ( int i = 0 ; i < PARTICLES . size ( ) ; i + + ) {
PARTICLES [ i ] - > render ( this ) ;
}
FillRectDecal ( { 0 , 0 } , { WIDTH , HEIGHT } , Pixel ( 0 , 0 , 0 , ( int ) CUTSCENE_FADE_VALUE ) ) ;
} ;
void DrawGameWorld ( ) {
for ( int y = - 1 ; y < HEIGHT / 32 + 2 ; y + + ) {
int yTileOffset = cameraPos . y / 32 ;
for ( auto & obj : OBJECTS ) {
if ( ! obj - > drawn & & ( ! obj - > dead | | EDITING_LAYER = = layer : : ENCOUNTER ) & & obj - > GetPos ( ) . y + obj - > originPoint . y > ( y + yTileOffset ) * 32 & & obj - > GetPos ( ) . y + obj - > originPoint . y < = ( y + yTileOffset + 1 ) * 32 ) {
obj - > drawn = true ;
if ( obj - > blinkFrames > 0 ) {
obj - > blinkFrames - - ;
}
if ( obj - > blinkFrames = = 0 | | obj - > blinkFrames > 0 & & obj - > blinkFrames % 3 = = 0 ) {
if ( obj - > highlighted ) {
SetDrawTarget ( layer : : HIGH ) ;
Pixel * data = obj - > spr - > spr - > sprite - > GetData ( ) ;
double accX = 0 ;
double accY = 0 ;
int pixelOffsetX = 0 ;
int pixelOffsetY = 0 ;
for ( int xx = 0 ; xx < obj - > spr - > width ; xx + + ) {
accX + = obj - > GetScale ( ) . x ;
for ( int yy = 0 ; yy < obj - > spr - > spr - > sprite - > height ; yy + + ) {
accY + = obj - > GetScale ( ) . y ;
Pixel col = data [ yy * 96 + xx + ( ( obj - > frameIndex % obj - > spr - > frames ) * obj - > spr - > width ) ] ;
while ( accY > = 1 ) {
for ( int xxx = 0 ; xxx < accX ; xxx + + ) {
if ( col . a > 64 ) {
GetDrawTarget ( ) - > SetPixel ( obj - > GetPos ( ) . x - cameraPos . x + pixelOffsetX + xxx , obj - > GetPos ( ) . y - cameraPos . y + pixelOffsetY , Pixel ( 255 , 255 , 255 , abs ( sin ( M_PI / 60 * frameCount ) * 210 ) ) ) ;
}
}
accY - = 1 ;
pixelOffsetY + + ;
}
}
while ( accX > = 1 ) {
accX - = 1 ;
pixelOffsetX + + ;
}
pixelOffsetY = 0 ;
}
SetDrawTarget ( layer : : DYNAMIC ) ;
DrawPartialDecal ( obj - > GetPos ( ) - cameraPos , obj - > spr - > spr , { ( float ) ( ( obj - > frameIndex % obj - > spr - > frames ) * obj - > spr - > width ) , 0 } , { ( float ) obj - > spr - > width , ( float ) obj - > spr - > spr - > sprite - > height } , obj - > GetScale ( ) , obj - > color ) ;
} else {
SetDrawTarget ( layer : : DYNAMIC ) ;
DrawPartialDecal ( obj - > GetPos ( ) - cameraPos , obj - > spr - > spr , { ( float ) ( ( obj - > frameIndex % obj - > spr - > frames ) * obj - > spr - > width ) , 0 } , { ( float ) obj - > spr - > width , ( float ) obj - > spr - > spr - > sprite - > height } , obj - > GetScale ( ) , obj - > color ) ;
}
}
}
}
for ( int x = - 1 ; x < WIDTH / 32 + 2 ; x + + ) {
int xTileOffset = cameraPos . x / 32 ;
if ( x + xTileOffset > = 0 & & x + xTileOffset < MAP_WIDTH & & y + yTileOffset > = 0 & & y + yTileOffset < MAP_HEIGHT ) {
if ( MAP5 [ y + yTileOffset ] [ x + xTileOffset ] - > tileX * MAP5 [ y + yTileOffset ] [ x + xTileOffset ] - > tileY ! = 225 ) {
SetDrawTarget ( layer : : COLLISION ) ;
DrawPartialSprite ( { ( int ) ( x * 32 - fmod ( cameraPos . x , 32 ) ) , ( int ) ( y * 32 - fmod ( cameraPos . y , 32 ) ) } , SPRITES [ " terrainmap.png " ] - > sprite , { ( int ) ( MAP5 [ y + yTileOffset ] [ x + xTileOffset ] - > tileX * 32 ) , ( int ) ( MAP5 [ y + yTileOffset ] [ x + xTileOffset ] - > tileY * 32 ) } , { 32 , 32 } ) ;
}
if ( MAP4 [ y + yTileOffset ] [ x + xTileOffset ] - > tileX * MAP4 [ y + yTileOffset ] [ x + xTileOffset ] - > tileY ! = 225 ) {
SetDrawTarget ( layer : : BACKGROUND ) ;
DrawPartialDecal ( { ( float ) ( x * 32 - fmod ( cameraPos . x , 32 ) ) , ( float ) ( y * 32 - fmod ( cameraPos . y , 32 ) ) } , SPRITES [ " terrainmap.png " ] , { ( float ) ( MAP4 [ y + yTileOffset ] [ x + xTileOffset ] - > tileX * 32 ) , ( float ) ( MAP4 [ y + yTileOffset ] [ x + xTileOffset ] - > tileY * 32 ) } , { 32 , 32 } ) ;
}
if ( MAP3 [ y + yTileOffset ] [ x + xTileOffset ] - > tileX * MAP3 [ y + yTileOffset ] [ x + xTileOffset ] - > tileY ! = 225 ) {
SetDrawTarget ( layer : : GROUND ) ;
DrawPartialDecal ( { ( float ) ( x * 32 - fmod ( cameraPos . x , 32 ) ) , ( float ) ( y * 32 - fmod ( cameraPos . y , 32 ) ) } , SPRITES [ " terrainmap.png " ] , { ( float ) ( MAP3 [ y + yTileOffset ] [ x + xTileOffset ] - > tileX * 32 ) , ( float ) ( MAP3 [ y + yTileOffset ] [ x + xTileOffset ] - > tileY * 32 ) } , { 32 , 32 } ) ;
}
if ( MAP2 [ y + yTileOffset ] [ x + xTileOffset ] - > tileX * MAP2 [ y + yTileOffset ] [ x + xTileOffset ] - > tileY ! = 225 ) {
SetDrawTarget ( layer : : DYNAMIC ) ;
DrawPartialDecal ( { ( float ) ( x * 32 - fmod ( cameraPos . x , 32 ) ) , ( float ) ( y * 32 - fmod ( cameraPos . y , 32 ) ) } , SPRITES [ " terrainmap.png " ] , { ( float ) ( MAP2 [ y + yTileOffset ] [ x + xTileOffset ] - > tileX * 32 ) , ( float ) ( MAP2 [ y + yTileOffset ] [ x + xTileOffset ] - > tileY * 32 ) } , { 32 , 32 } ) ;
}
if ( MAP [ y + yTileOffset ] [ x + xTileOffset ] - > tileX * MAP [ y + yTileOffset ] [ x + xTileOffset ] - > tileY ! = 225 ) {
SetDrawTarget ( layer : : HIGH ) ;
DrawPartialDecal ( { ( float ) ( x * 32 - fmod ( cameraPos . x , 32 ) ) , ( float ) ( y * 32 - fmod ( cameraPos . y , 32 ) ) } , SPRITES [ " terrainmap.png " ] , { ( float ) ( MAP [ y + yTileOffset ] [ x + xTileOffset ] - > tileX * 32 ) , ( float ) ( MAP [ y + yTileOffset ] [ x + xTileOffset ] - > tileY * 32 ) } , { 32 , 32 } ) ;
}
}
}
}
}
void DrawFancyStringDecal ( const olc : : vf2d & pos , const std : : wstring & sText , const Pixel col = olc : : WHITE , const olc : : vf2d & scale = { 1.0f , 1.0f } ) {
vf2d newpos = pos ;
for ( int i = 0 ; i < sText . length ( ) ; i + + ) {
if ( sText [ i ] > = 128 ) {
DrawPartialDecal ( newpos , SPRITES [ " additionalFont.png " ] , additionalChars [ sText [ i ] ] , { 8 , 8 } , scale , col ) ;
newpos . x + = 8 * scale . x ;
} else
if ( sText [ i ] ! = ' \n ' ) {
DrawStringDecal ( newpos , std : : string ( 1 , sText [ i ] ) , col , scale ) ;
newpos . x + = 8 * scale . x ;
} else
if ( sText [ i ] = = ' \n ' ) {
DrawStringDecal ( newpos , std : : string ( 1 , sText [ i ] ) , col , scale ) ;
newpos . x = pos . x ;
newpos . y + = 8 * scale . y ;
}
}
}
void LoadMap ( Map * map ) {
std : : ifstream f ( " assets/maps/ " + map - > filename , std : : ios : : binary ) ;
std : : ifstream f2 ( " assets/maps/ " + map - > l2filename , std : : ios : : binary ) ;
std : : ifstream f3 ( " assets/maps/ " + map - > l3filename , std : : ios : : binary ) ;
std : : ifstream f4 ( " assets/maps/ " + map - > l4filename , std : : ios : : binary ) ;
std : : ifstream f5 ( " assets/maps/ " + map - > l5filename , std : : ios : : binary ) ;
for ( int i = 0 ; i < MAP . size ( ) ; i + + ) {
for ( int j = 0 ; j < MAP [ i ] . size ( ) ; j + + ) {
delete MAP [ i ] [ j ] ;
}
MAP [ i ] . clear ( ) ;
}
for ( int i = 0 ; i < MAP . size ( ) ; i + + ) {
for ( int j = 0 ; j < MAP [ i ] . size ( ) ; j + + ) {
delete MAP2 [ i ] [ j ] ;
}
MAP2 [ i ] . clear ( ) ;
}
for ( int i = 0 ; i < MAP . size ( ) ; i + + ) {
for ( int j = 0 ; j < MAP [ i ] . size ( ) ; j + + ) {
delete MAP3 [ i ] [ j ] ;
}
MAP3 [ i ] . clear ( ) ;
}
for ( int i = 0 ; i < MAP . size ( ) ; i + + ) {
for ( int j = 0 ; j < MAP [ i ] . size ( ) ; j + + ) {
delete MAP4 [ i ] [ j ] ;
}
MAP4 [ i ] . clear ( ) ;
}
for ( int i = 0 ; i < MAP . size ( ) ; i + + ) {
for ( int j = 0 ; j < MAP [ i ] . size ( ) ; j + + ) {
delete MAP5 [ i ] [ j ] ;
}
MAP5 [ i ] . clear ( ) ;
}
MAP_WIDTH = - 1 ;
MAP_HEIGHT = - 1 ;
MAP . clear ( ) ;
for ( int i = 0 ; i < OBJECTS . size ( ) ; i + + ) {
delete OBJECTS [ i ] ;
}
OBJECTS . clear ( ) ;
for ( int i = 0 ; i < 4 ; i + + ) {
PARTY_MEMBER_OBJ [ i ] = nullptr ;
PARTY_MEMBER_ID [ i ] = 0 ;
}
std : : string data ;
while ( f . good ( ) ) {
f > > data ;
if ( MAP_WIDTH = = - 1 ) {
MAP_WIDTH = data . length ( ) / 2 ;
}
if ( data . find ( " OBJECT " ) ! = std : : string : : npos | | data . find ( " ENCOUNTER " ) ! = std : : string : : npos ) {
int marker = data . find_first_of ( ' ; ' ) ;
int lastMarker = marker ;
std : : stringstream split1 ( ( data . find ( " OBJECT " ) ! = std : : string : : npos ) ? data . substr ( 6 , marker - 6 ) : data . substr ( 9 , marker - 9 ) ) ;
marker = data . find_first_of ( ' ; ' , marker + 1 ) ;
std : : stringstream split2 ( data . substr ( lastMarker + 1 , marker - lastMarker - 1 ) ) ;
lastMarker = marker ;
marker = data . find_first_of ( ' ; ' , marker + 1 ) ;
std : : stringstream split3 ( data . substr ( lastMarker + 1 , marker - lastMarker - 1 ) ) ;
lastMarker = marker ;
double x , y ;
split1 > > x ;
split2 > > y ;
int id ;
split3 > > id ;
if ( data . find ( " OBJECT " ) ! = std : : string : : npos ) {
bool enabled = true ;
if ( OBJ_INFO [ id ] - > disableFlag ! = Flag : : NONE ) {
if ( GetGameFlag ( OBJ_INFO [ id ] - > disableFlag ) ) {
enabled = false ;
}
}
if ( OBJ_INFO [ id ] - > enableFlag ! = Flag : : NONE ) {
if ( ! GetGameFlag ( OBJ_INFO [ id ] - > enableFlag ) ) {
enabled = false ;
}
}
if ( enabled ) {
AddObjectToWorld ( CreateObject ( id , { x , y } ) ) ;
}
printf ( " Object %s Loaded. \n " , OBJ_INFO [ id ] - > name . c_str ( ) ) ;
} else
if ( data . find ( " ENCOUNTER " ) ! = std : : string : : npos ) {
marker = data . find_first_of ( ' ; ' , marker + 1 ) ;
std : : stringstream split4 ( data . substr ( lastMarker + 1 , marker - lastMarker - 1 ) ) ;
lastMarker = marker ;
int pct = id ;
split4 > > id ;
LoadEncounter ( map , { x , y } , pct , id , rand ( ) % 100 < pct ) ;
printf ( " Encounter %d (%d \ %) Loaded. \n " , id , pct ) ;
}
} else {
std : : vector < TILE * > tiles ;
printf ( " %s \n " , data . c_str ( ) ) ;
for ( int i = 0 ; i < data . length ( ) ; i + = 2 ) {
unsigned char tileX , tileY ;
tileX = data [ i ] - ' 0 ' ;
tileY = data [ i + 1 ] - ' 0 ' ;
tiles . push_back ( new TILE ( tileX , tileY ) ) ;
}
MAP . push_back ( tiles ) ;
MAP_HEIGHT + + ;
}
}
while ( f2 . good ( ) ) {
f2 > > data ;
std : : vector < TILE * > tiles ;
for ( int i = 0 ; i < data . length ( ) ; i + = 2 ) {
unsigned char tileX , tileY ;
tileX = data [ i ] - ' 0 ' ;
tileY = data [ i + 1 ] - ' 0 ' ;
tiles . push_back ( new TILE ( tileX , tileY ) ) ;
}
MAP2 . push_back ( tiles ) ;
}
while ( f3 . good ( ) ) {
f3 > > data ;
std : : vector < TILE * > tiles ;
for ( int i = 0 ; i < data . length ( ) ; i + = 2 ) {
unsigned char tileX , tileY ;
tileX = data [ i ] - ' 0 ' ;
tileY = data [ i + 1 ] - ' 0 ' ;
tiles . push_back ( new TILE ( tileX , tileY ) ) ;
}
MAP3 . push_back ( tiles ) ;
}
while ( f4 . good ( ) ) {
f4 > > data ;
std : : vector < TILE * > tiles ;
for ( int i = 0 ; i < data . length ( ) ; i + = 2 ) {
unsigned char tileX , tileY ;
tileX = data [ i ] - ' 0 ' ;
tileY = data [ i + 1 ] - ' 0 ' ;
tiles . push_back ( new TILE ( tileX , tileY ) ) ;
}
MAP4 . push_back ( tiles ) ;
}
while ( f5 . good ( ) ) {
f5 > > data ;
std : : vector < TILE * > tiles ;
for ( int i = 0 ; i < data . length ( ) ; i + = 2 ) {
unsigned char tileX , tileY ;
tileX = data [ i ] - ' 0 ' ;
tileY = data [ i + 1 ] - ' 0 ' ;
tiles . push_back ( new TILE ( tileX , tileY ) ) ;
}
MAP5 . push_back ( tiles ) ;
}
MAP_WIDTH = MAP [ 0 ] . size ( ) ;
MAP_HEIGHT = MAP . size ( ) ;
printf ( " Loaded map %s. \n " , map - > filename . c_str ( ) ) ;
f . close ( ) ;
f2 . close ( ) ;
f3 . close ( ) ;
f4 . close ( ) ;
f5 . close ( ) ;
}
void SaveMap ( Map * map ) {
std : : ofstream f ( " assets/maps/ " + map - > filename , std : : ios : : binary ) ;
std : : ofstream f2 ( " assets/maps/ " + map - > l2filename , std : : ios : : binary ) ;
std : : ofstream f3 ( " assets/maps/ " + map - > l3filename , std : : ios : : binary ) ;
std : : ofstream f4 ( " assets/maps/ " + map - > l4filename , std : : ios : : binary ) ;
std : : ofstream f5 ( " assets/maps/ " + map - > l5filename , std : : ios : : binary ) ;
printf ( " Map width: %d, Map Height: %d:: \n " , MAP_WIDTH , MAP_HEIGHT ) ;
for ( int y = 0 ; y < MAP_HEIGHT ; y + + ) {
for ( int x = 0 ; x < MAP_WIDTH ; x + + ) {
f . put ( MAP [ y ] [ x ] - > tileX + ' 0 ' ) ; f . put ( MAP [ y ] [ x ] - > tileY + ' 0 ' ) ;
f2 . put ( MAP2 [ y ] [ x ] - > tileX + ' 0 ' ) ; f2 . put ( MAP2 [ y ] [ x ] - > tileY + ' 0 ' ) ;
f3 . put ( MAP3 [ y ] [ x ] - > tileX + ' 0 ' ) ; f3 . put ( MAP3 [ y ] [ x ] - > tileY + ' 0 ' ) ;
f4 . put ( MAP4 [ y ] [ x ] - > tileX + ' 0 ' ) ; f4 . put ( MAP4 [ y ] [ x ] - > tileY + ' 0 ' ) ;
f5 . put ( MAP5 [ y ] [ x ] - > tileX + ' 0 ' ) ; f5 . put ( MAP5 [ y ] [ x ] - > tileY + ' 0 ' ) ;
}
if ( y ! = MAP_HEIGHT - 1 ) {
f . put ( ' \n ' ) ;
f2 . put ( ' \n ' ) ;
f3 . put ( ' \n ' ) ;
f4 . put ( ' \n ' ) ;
f5 . put ( ' \n ' ) ;
}
}
for ( int i = 0 ; i < OBJECTS . size ( ) ; i + + ) {
bool allowed = true ;
for ( int j = 1 ; j < PARTY_MEMBER_COUNT ; j + + ) {
if ( OBJECTS [ i ] = = PARTY_MEMBER_OBJ [ j ] ) {
allowed = false ;
break ;
}
}
if ( OBJECTS [ i ] - > temp | | OBJECTS [ i ] - > enc ) {
continue ;
}
if ( ! allowed ) {
continue ;
}
f . put ( ' \n ' ) ;
const std : : string obj = " OBJECT " + std : : to_string ( OBJECTS [ i ] - > GetPos ( ) . x ) + " ; " + std : : to_string ( OBJECTS [ i ] - > GetPos ( ) . y ) + " ; " + std : : to_string ( OBJECTS [ i ] - > id ) ;
for ( int j = 0 ; j < obj . length ( ) ; j + + ) {
f . put ( obj [ j ] ) ;
}
}
for ( int i = 0 ; i < map - > encounters . size ( ) ; i + + ) {
f . put ( ' \n ' ) ;
const std : : string enc = " ENCOUNTER " + std : : to_string ( map - > encounters [ i ] - > pos . x ) + " ; " + std : : to_string ( map - > encounters [ i ] - > pos . y ) + " ; " + std : : to_string ( map - > encounters [ i ] - > chance ) + " ; " + std : : to_string ( map - > encounters [ i ] - > id ) ;
for ( int j = 0 ; j < enc . length ( ) ; j + + ) {
f . put ( enc [ j ] ) ;
}
}
f . close ( ) ;
f2 . close ( ) ;
f3 . close ( ) ;
f4 . close ( ) ;
f5 . close ( ) ;
}
Decal * CreateSprite ( std : : string spriteName ) {
SPRITES [ spriteName ] = new Decal ( new Sprite ( " assets/ " + spriteName ) ) ;
return SPRITES [ spriteName ] ;
}
//You're probably trying to add an object to the world. Use this function inside of AddObjectToWorld(CreateObject(...))
//You only need to use this function if you want to create an object from pre-defined OBJ_INFO variables.
Object * CreateObject ( int id , vd2d pos ) {
return new Object ( id , OBJ_INFO [ id ] - > name , pos , OBJ_INFO [ id ] - > spr , OBJ_INFO [ id ] - > GetScale ( ) , OBJ_INFO [ id ] - > color , OBJ_INFO [ id ] - > animationSpd ) ;
}
Object * CreateObjectInfo ( Reference ref , std : : string name , vd2d pos , std : : string spriteFileName , int sprWidth , vd2d scale = { 1 , 1 } , Pixel tint = WHITE , Flag enableFlag = Flag : : NONE , Flag disableFlag = Flag : : NONE , int animationDelay = 1 ) {
if ( ! ANIMATIONS . count ( spriteFileName ) ) {
ANIMATIONS [ spriteFileName ] = new Animation ( SPRITES [ spriteFileName ] = CreateSprite ( spriteFileName ) , 32 ) ;
}
Object * newObj = new Object ( ref , name , pos , ANIMATIONS [ spriteFileName ] , scale , tint , animationDelay ) ;
newObj - > disableFlag = disableFlag ;
newObj - > enableFlag = enableFlag ;
OBJ_INFO [ ref ] = newObj ;
return newObj ;
}
void SetupPartyMemberStats ( ) {
for ( int i = 0 ; i < 7 ; i + + ) {
PARTY_MEMBER_STATS [ i ] = new Entity ( 120 , 120 , 30 , 30 , 8 , { 0 , 0 , 0 , 0 } , 8 , { MOVELIST [ BattleMoveName : : TESTMOVE1 ] } ) ;
}
PARTY_MEMBER_STATS [ PLAYER ] - > moveSet = {
MOVELIST [ BattleMoveName : : HAILSTORM_A ] ,
MOVELIST [ BattleMoveName : : HAILSTORM_B ] ,
MOVELIST [ BattleMoveName : : HURRICANE_A ] ,
MOVELIST [ BattleMoveName : : HURRICANE_B ] ,
MOVELIST [ BattleMoveName : : HURRICANE_G ] ,
MOVELIST [ BattleMoveName : : HURRICANE_O ] ,
MOVELIST [ BattleMoveName : : METEORRAIN_A ] ,
MOVELIST [ BattleMoveName : : PKFUN_A ] ,
MOVELIST [ BattleMoveName : : PKLIFEUP_A ] ,
MOVELIST [ BattleMoveName : : PKFREEZE_A ] ,
MOVELIST [ BattleMoveName : : PKSHIELD_A ] } ;
PARTY_MEMBER_STATS [ NESS ] - > moveSet = {
MOVELIST [ BattleMoveName : : PKFUN_A ] ,
MOVELIST [ BattleMoveName : : PKFUN_B ] ,
MOVELIST [ BattleMoveName : : PKLIFEUP_A ] ,
MOVELIST [ BattleMoveName : : PKLIFEUP_B ] ,
MOVELIST [ BattleMoveName : : PKLIFEUP_G ] ,
MOVELIST [ BattleMoveName : : PKLIFEUP_O ] , } ;
PARTY_MEMBER_STATS [ PAULA ] - > moveSet = {
MOVELIST [ BattleMoveName : : PKFREEZE_A ] ,
MOVELIST [ BattleMoveName : : PKFREEZE_B ] ,
MOVELIST [ BattleMoveName : : PKFREEZE_G ] ,
MOVELIST [ BattleMoveName : : PKFREEZE_O ] ,
MOVELIST [ BattleMoveName : : PKFIRE_A ] ,
MOVELIST [ BattleMoveName : : PKFIRE_B ] , } ;
PARTY_MEMBER_STATS [ ANNA ] - > moveSet = {
MOVELIST [ BattleMoveName : : PKFREEZE_A ] ,
MOVELIST [ BattleMoveName : : PKSHIELD_A ] ,
MOVELIST [ BattleMoveName : : PKSHIELD_B ] ,
MOVELIST [ BattleMoveName : : PKLIFEUP_A ] , } ;
}
void SetupMoveList ( ) {
MOVELIST [ BattleMoveName : : TESTMOVE1 ] = new Battle : : Move ( " Test Move 1 " , " An attack " , 30 , 5 , ㅍ 0 , 1 , 0 , false , { 0 , 0 , 0 , 0 } ) ;
MOVELIST [ BattleMoveName : : TESTMOVE2 ] = new Battle : : Move ( " Test Move 2 " , " An attack " , 40 , 10 , ㅍ 0 , 1 , 0 , false , { 0 , 0 , 0 , 0 } ) ;
MOVELIST [ BattleMoveName : : TESTMOVE3 ] = new Battle : : Move ( " Test Move 3 " , " An attack " , 25 , 5 , ㅍ 0 , 3 , 0 , false , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : BASH ] = new Battle : : Move ( " Bash " , " Regular attack. " , 5 , 5 , ㅍ 0 , 1 , 0 , false , { 0 , 0 , 0 , 0 } ) ;
MOVELIST [ BattleMoveName : : HAILSTORM_A ] = new Battle : : Move ( " Hailstorm " , " Causes heavy ice rocks to crash " , ALPHA , 40 , 20 , ㅍ 4 , 4 , 0 , false , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : HAILSTORM_B ] = new Battle : : Move ( " Hailstorm " , " Causes heavy ice rocks to crash " , BETA , 80 , 20 , ㅍ 12 , 4 , 0 , false , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : HAILSTORM_G ] = new Battle : : Move ( " Hailstorm " , " Causes heavy ice rocks to crash " , GAMMA , 120 , 20 , ㅍ 28 , 4 , 0 , false , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : HAILSTORM_O ] = new Battle : : Move ( " Hailstorm " , " Causes heavy ice rocks to crash " , OMEGA , 210 , 50 , ㅍ 69 , 4 , 0 , false , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : HURRICANE_A ] = new Battle : : Move ( " Hurricane " , " Scatters seeds, causes heavy rains and winds " , ALPHA , 25 , 5 , ㅍ 7 , 6 , 0 , false , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : HURRICANE_B ] = new Battle : : Move ( " Hurricane " , " Scatters seeds, causes heavy rains and winds " , BETA , 45 , 5 , ㅍ 13 , 6 , 0 , false , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : HURRICANE_G ] = new Battle : : Move ( " Hurricane " , " Scatters seeds, causes heavy rains and winds " , GAMMA , 75 , 10 , ㅍ 25 , 8 , 0 , false , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : HURRICANE_O ] = new Battle : : Move ( " Hurricane " , " Scatters seeds, causes heavy rains and winds " , OMEGA , 125 , 20 , ㅍ 55 , 8 , 0 , false , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : METEORRAIN_A ] = new Battle : : Move ( " Meteor Rain " , " Causes fiery rocks to fall from the skies. Chance to burn trees. " , ALPHA , 60 , 10 , ㅍ 10 , 2 , 0 , false , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : METEORRAIN_B ] = new Battle : : Move ( " Meteor Rain " , " Causes fiery rocks to fall from the skies. Chance to burn trees. " , BETA , 110 , 30 , ㅍ 22 , 2 , 0 , false , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : METEORRAIN_G ] = new Battle : : Move ( " Meteor Rain " , " Causes fiery rocks to fall from the skies. Chance to burn trees. " , GAMMA , 200 , 50 , ㅍ 47 , 2 , 0 , false , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : METEORRAIN_O ] = new Battle : : Move ( " Meteor Rain " , " Causes fiery rocks to fall from the skies. Chance to burn trees. " , OMEGA , 390 , 60 , ㅍ 98 , 2 , 0 , false , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : PKFREEZE_A ] = new Battle : : Move ( " PK Freeze " , " A powerful chilling attack causing frostbite and slow. " , ALPHA , 80 , 10 , ㅍ 4 , 1 , 0 , false , { 0 , 0 , 20 , 10 } ) ;
MOVELIST [ BattleMoveName : : PKFREEZE_B ] = new Battle : : Move ( " PK Freeze " , " A powerful chilling attack causing frostbite and slow. " , BETA , 120 , 20 , ㅍ 8 , 1 , 0 , false , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : PKFREEZE_G ] = new Battle : : Move ( " PK Freeze " , " A powerful chilling attack causing frostbite and slow. " , GAMMA , 240 , 40 , ㅍ 12 , 1 , 0 , false , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : PKFREEZE_O ] = new Battle : : Move ( " PK Freeze " , " A powerful chilling attack causing frostbite and slow. " , OMEGA , 480 , 50 , ㅍ 22 , 1 , 0 , false , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : PKSHIELD_A ] = new Battle : : Move ( " PK Shield " , " Protects against physical attacks. " , ALPHA , 0 , 0 , ㅍ 12 , 1 , 0 , true , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : PKSHIELD_B ] = new Battle : : Move ( " PK Shield " , " Protects against physical attacks. " , BETA , 0 , 0 , ㅍ 20 , 1 , 0 , true , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : PKSHIELD_O ] = new Battle : : Move ( " PK Shield " , " Protects against physical attacks. " , OMEGA , 0 , 0 , ㅍ 59 , 4 , 0 , true , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : PKSHIELD_S ] = new Battle : : Move ( " PK Shield " , " Protects against physical attacks. " , SIGMA , 0 , 0 , ㅍ 80 , 10 , 0 , true , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : PKLIFEUP_A ] = new Battle : : Move ( " PK Lifeup " , " Restores a small amount of health. " , ALPHA , 80 , 10 , ㅍ 4 , 1 , 0 , true , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : PKLIFEUP_B ] = new Battle : : Move ( " PK Lifeup " , " Restores a moderate amount of health. " , BETA , 240 , 60 , ㅍ 9 , 1 , 0 , true , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : PKLIFEUP_G ] = new Battle : : Move ( " PK Lifeup " , " Restores a large amount of health. " , GAMMA , 400 , 50 , ㅍ 21 , 3 , 0 , true , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : PKLIFEUP_O ] = new Battle : : Move ( " PK Lifeup " , " Restores a great amount of health to all allies. " , OMEGA , 800 , 100 , ㅍ 64 , 6 , 0 , true , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : PKFUN_A ] = new Battle : : Move ( " PK Fun " , " A very fun barrage. Hits for large damage. " , ALPHA , 100 , 10 , ㅍ 15 , 6 , 0 , false , { 0 , 0 , 20 , 0 } , FOUNTAIN_EFFECT ) ;
MOVELIST [ BattleMoveName : : PKFUN_B ] = new Battle : : Move ( " PK Fun " , " A very fun barrage. Hits for large damage. " , BETA , 240 , 40 , ㅍ 30 , 6 , 0 , false , { 0 , 0 , 20 , 0 } , FOUNTAIN_EFFECT ) ;
MOVELIST [ BattleMoveName : : PKFUN_G ] = new Battle : : Move ( " PK Fun " , " A very fun barrage. Hits for large damage. " , GAMMA , 360 , 80 , ㅍ 45 , 7 , 0 , false , { 0 , 0 , 20 , 0 } , FOUNTAIN_EFFECT ) ;
MOVELIST [ BattleMoveName : : PKFUN_O ] = new Battle : : Move ( " PK Fun " , " A very fun barrage. Hits for large damage. " , OMEGA , 590 , 100 , ㅍ 90 , 8 , 0 , false , { 0 , 0 , 20 , 0 } , FOUNTAIN_EFFECT ) ;
MOVELIST [ BattleMoveName : : PKFIRE_A ] = new Battle : : Move ( " PK Fire " , " Causes extreme heat to burn foes and scorch trees " , ALPHA , 60 , 20 , ㅍ 6 , 3 , 0 , false , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : PKFIRE_B ] = new Battle : : Move ( " PK Fire " , " Causes extreme heat to burn foes and scorch trees " , BETA , 120 , 40 , ㅍ 12 , 4 , 0 , false , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : PKFIRE_G ] = new Battle : : Move ( " PK Fire " , " Causes extreme heat to burn foes and scorch trees " , GAMMA , 190 , 50 , ㅍ 20 , 5 , 0 , false , { 0 , 0 , 20 , 0 } ) ;
MOVELIST [ BattleMoveName : : PKFIRE_O ] = new Battle : : Move ( " PK Fire " , " Causes extreme heat to burn foes and scorch trees " , OMEGA , 360 , 100 , ㅍ 32 , 7 , 0 , false , { 0 , 0 , 20 , 0 } ) ;
}
void SetupAnimations ( ) {
CreateSprite ( " terrainmap.png " ) ;
CreateSprite ( " additionalFont.png " ) ;
CreateSprite ( " rollingcounter.png " ) ;
CreateSprite ( " atbbar_back.png " ) ;
CreateSprite ( " atbbar_front.png " ) ;
CreateSprite ( " cursor.png " ) ;
CreateSprite ( " targetCircle.png " ) ;
CreateSprite ( " targetRange.png " ) ;
CreateSprite ( " crosshair.png " ) ;
CreateSprite ( " arrow_connector.png " ) ;
}
void SetupObjectInfo ( ) {
CreateObjectInfo ( PLAYER , " player " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , WHITE ) ;
CreateObjectInfo ( NESS , " Ness " , { 0 , 0 } , " player.png " , 32 , { 1 , 1 } , YELLOW ) ;
CreateObjectInfo ( PAULA , " Paula " , { 0 , 0 } , " player.png " , 32 , { 1 , 1 } , MAGENTA ) ;
CreateObjectInfo ( JEFF , " Jeff " , { 0 , 0 } , " player.png " , 32 , { 1 , 1 } , DARK_GREEN ) ;
CreateObjectInfo ( ANNA , " Anna " , { 0 , 0 } , " player.png " , 32 , { 1 , 1 } , DARK_MAGENTA ) ;
CreateObjectInfo ( KING , " King " , { 0 , 0 } , " player.png " , 32 , { 1 , 1 } , GREY ) ;
CreateObjectInfo ( POO , " Poo " , { 0 , 0 } , " player.png " , 32 , { 1 , 1 } , DARK_GREY ) ;
CreateObjectInfo ( NPC1 , " npc1 " , { 0 , 0 } , " player.png " , 32 , { 1 , 1 } , RED , Flag : : NONE , Flag : : NONE , 60 ) ;
CreateObjectInfo ( NPC2 , " npc2 " , { 0 , 0 } , " player.png " , 32 , { 1 , 1 } , GREEN , Flag : : NONE , Flag : : NONE , 2 ) ;
CreateObjectInfo ( NPC3 , " npc3 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC4 , " npc4 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC5 , " npc5 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC6 , " npc6 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC7 , " npc7 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC8 , " npc8 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC9 , " npc9 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC10 , " npc10 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC11 , " npc11 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC12 , " npc12 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC13 , " npc13 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC13 , " npc14 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC14 , " npc15 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC15 , " npc16 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC16 , " npc17 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC17 , " npc18 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC18 , " npc19 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC19 , " npc20 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC1_2 , " npc1_2 " , { 0 , 0 } , " player.png " , 32 , { 1 , 1 } , RED , Flag : : NONE , Flag : : NONE , 60 ) ;
CreateObjectInfo ( NPC2_2 , " npc2_2 " , { 0 , 0 } , " player.png " , 32 , { 1 , 1 } , GREEN , Flag : : NONE , Flag : : NONE , 2 ) ;
CreateObjectInfo ( NPC3_2 , " npc3_2 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC4_2 , " npc4_2 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC5_2 , " npc5_2 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC6_2 , " npc6_2 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC7_2 , " npc7_2 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC8_2 , " npc8_2 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC9_2 , " npc9_2 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC10_2 , " npc10_2 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC11_2 , " npc11_2 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC12_2 , " npc12_2 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC13_2 , " npc13_2 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC13_2 , " npc14_2 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC14_2 , " npc15_2 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC15_2 , " npc16_2 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC16_2 , " npc17_2 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC17_2 , " npc18_2 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC18_2 , " npc19_2 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC19_2 , " npc20_2 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC1_3 , " npc1_3 " , { 0 , 0 } , " player.png " , 32 , { 1 , 1 } , RED , Flag : : NONE , Flag : : NONE , 60 ) ;
CreateObjectInfo ( NPC2_3 , " npc2_3 " , { 0 , 0 } , " player.png " , 32 , { 1 , 1 } , GREEN , Flag : : NONE , Flag : : NONE , 2 ) ;
CreateObjectInfo ( NPC3_3 , " npc3_3 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC4_3 , " npc4_3 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC5_3 , " npc5_3 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC6_3 , " npc6_3 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC7_3 , " npc7_3 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC8_3 , " npc8_3 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC9_3 , " npc9_3 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC10_3 , " npc10_3 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC11_3 , " npc11_3 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC12_3 , " npc12_3 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC13_3 , " npc13_3 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC13_3 , " npc14_3 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC14_3 , " npc15_3 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC15_3 , " npc16_3 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC16_3 , " npc17_3 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC17_3 , " npc18_3 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC18_3 , " npc19_3 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC19_3 , " npc20_3 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC1_4 , " npc1_4 " , { 0 , 0 } , " player.png " , 32 , { 1 , 1 } , RED , Flag : : NONE , Flag : : NONE , 60 ) ;
CreateObjectInfo ( NPC2_4 , " npc2_4 " , { 0 , 0 } , " player.png " , 32 , { 1 , 1 } , GREEN , Flag : : NONE , Flag : : NONE , 2 ) ;
CreateObjectInfo ( NPC3_4 , " npc3_4 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC4_4 , " npc4_4 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC5_4 , " npc5_4 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC6_4 , " npc6_4 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC7_4 , " npc7_4 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC8_4 , " npc8_4 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC9_4 , " npc9_4 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC10_4 , " npc10_4 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC11_4 , " npc11_4 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC12_4 , " npc12_4 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC13_4 , " npc13_4 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC13_4 , " npc14_4 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC14_4 , " npc15_4 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC15_4 , " npc16_4 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC16_4 , " npc17_4 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC17_4 , " npc18_4 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC18_4 , " npc19_4 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC19_4 , " npc20_4 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC1_5 , " npc1_5 " , { 0 , 0 } , " player.png " , 32 , { 1 , 1 } , RED , Flag : : NONE , Flag : : NONE , 60 ) ;
CreateObjectInfo ( NPC2_5 , " npc2_5 " , { 0 , 0 } , " player.png " , 32 , { 1 , 1 } , GREEN , Flag : : NONE , Flag : : NONE , 2 ) ;
CreateObjectInfo ( NPC3_5 , " npc3_5 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC4_5 , " npc4_5 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC5_5 , " npc5_5 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC6_5 , " npc6_5 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC7_5 , " npc7_5 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC8_5 , " npc8_5 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC9_5 , " npc9_5 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC10_5 , " npc10_5 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC11_5 , " npc11_5 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC12_5 , " npc12_5 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC13_5 , " npc13_5 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC13_5 , " npc14_5 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC14_5 , " npc15_5 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC15_5 , " npc16_5 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC16_5 , " npc17_5 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC17_5 , " npc18_5 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC18_5 , " npc19_5 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC19_5 , " npc20_5 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC1_6 , " npc1_6 " , { 0 , 0 } , " player.png " , 32 , { 1 , 1 } , RED , Flag : : NONE , Flag : : NONE , 60 ) ;
CreateObjectInfo ( NPC2_6 , " npc2_6 " , { 0 , 0 } , " player.png " , 32 , { 1 , 1 } , GREEN , Flag : : NONE , Flag : : NONE , 2 ) ;
CreateObjectInfo ( NPC3_6 , " npc3_6 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC4_6 , " npc4_6 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC5_6 , " npc5_6 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC6_6 , " npc6_6 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC7_6 , " npc7_6 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC8_6 , " npc8_6 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC9_6 , " npc9_6 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC10_6 , " npc10_6 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC11_6 , " npc11_6 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC12_6 , " npc12_6 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC13_6 , " npc13_6 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC13_6 , " npc14_6 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC14_6 , " npc15_6 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC15_6 , " npc16_6 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC16_6 , " npc17_6 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC17_6 , " npc18_6 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC18_6 , " npc19_6 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC19_6 , " npc20_6 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC1_7 , " npc1_7 " , { 0 , 0 } , " player.png " , 32 , { 1 , 1 } , RED , Flag : : NONE , Flag : : NONE , 60 ) ;
CreateObjectInfo ( NPC2_7 , " npc2_7 " , { 0 , 0 } , " player.png " , 32 , { 1 , 1 } , GREEN , Flag : : NONE , Flag : : NONE , 2 ) ;
CreateObjectInfo ( NPC3_7 , " npc3_7 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC4_7 , " npc4_7 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC5_7 , " npc5_7 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC6_7 , " npc6_7 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC7_7 , " npc7_7 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC8_7 , " npc8_7 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC9_7 , " npc9_7 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC10_7 , " npc10_7 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC11_7 , " npc11_7 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC12_7 , " npc12_7 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC13_7 , " npc13_7 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC13_7 , " npc14_7 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC14_7 , " npc15_7 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC15_7 , " npc16_7 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC16_7 , " npc17_7 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC17_7 , " npc18_7 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC18_7 , " npc19_7 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC19_7 , " npc20_7 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC1_8 , " npc1_8 " , { 0 , 0 } , " player.png " , 32 , { 1 , 1 } , RED , Flag : : NONE , Flag : : NONE , 60 ) ;
CreateObjectInfo ( NPC2_8 , " npc2_8 " , { 0 , 0 } , " player.png " , 32 , { 1 , 1 } , GREEN , Flag : : NONE , Flag : : NONE , 2 ) ;
CreateObjectInfo ( NPC3_8 , " npc3_8 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC4_8 , " npc4_8 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC5_8 , " npc5_8 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC6_8 , " npc6_8 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC7_8 , " npc7_8 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC8_8 , " npc8_8 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC9_8 , " npc9_8 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC10_8 , " npc10_8 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC11_8 , " npc11_8 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC12_8 , " npc12_8 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC13_8 , " npc13_8 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC13_8 , " npc14_8 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC14_8 , " npc15_8 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC15_8 , " npc16_8 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC16_8 , " npc17_8 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC17_8 , " npc18_8 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC18_8 , " npc19_8 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
CreateObjectInfo ( NPC19_8 , " npc20_8 " , { 0 , 0 } , " player.png " , 32 , { 2 , 2 } , BLUE , Flag : : NONE , Flag : : NONE , 0 ) ;
}
void SetupEncounters ( ) {
ENCOUNTER_LIST . push_back ( new Encounter ( encounter : : ENCOUNTER_1 , { 0 , 0 } , std : : array < vd2d , 4 > { vd2d
{ grid ( 1 , 2 ) } , { grid ( 2 , 2 ) } , { grid ( 3 , 2 ) } , { grid ( 4 , 2 ) } } ,
std : : vector < Entity * > {
new Entity ( new Object (
NPC1_4 , " Test Obj " , 3 , 2 , ANIMATIONS [ " player.png " ] ) ,
ㅎ 70 , ㅎ 70 , ㅍ 10 , ㅍ 10 , 아 14 , std : : array < int , 4 > { 0 , 0 , 0 , 0 } , 0 , std : : vector < Battle : : Move * > {
MOVELIST [ BattleMoveName : : TESTMOVE1 ] ,
MOVELIST [ BattleMoveName : : TESTMOVE2 ] ,
MOVELIST [ BattleMoveName : : TESTMOVE3 ] ,
} ) ,
new Entity ( new Object (
NPC1_4 , " Test Obj 2 " , 1 , 3 , ANIMATIONS [ " player.png " ] ) ,
ㅎ 70 , ㅎ 70 , ㅍ 10 , ㅍ 10 , 아 14 , std : : array < int , 4 > { 0 , 0 , 0 , 0 } , 0 , std : : vector < Battle : : Move * > {
MOVELIST [ BattleMoveName : : TESTMOVE1 ] ,
MOVELIST [ BattleMoveName : : TESTMOVE2 ] ,
MOVELIST [ BattleMoveName : : TESTMOVE3 ] ,
} ) ,
new Entity ( new Object (
NPC1_4 , " Test Obj 3 " , 2 , 2 , ANIMATIONS [ " player.png " ] ) ,
ㅎ 70 , ㅎ 70 , ㅍ 10 , ㅍ 10 , 아 14 , std : : array < int , 4 > { 0 , 0 , 0 , 0 } , 0 , std : : vector < Battle : : Move * > {
MOVELIST [ BattleMoveName : : TESTMOVE1 ] ,
MOVELIST [ BattleMoveName : : TESTMOVE2 ] ,
MOVELIST [ BattleMoveName : : TESTMOVE3 ] ,
} ) ,
} ) ) ; //ENCOUNTER_1
ENCOUNTER_LIST . push_back ( new Encounter ( encounter : : ENCOUNTER_2 , { 0 , 0 } , std : : array < vd2d , 4 > { vd2d
{ grid ( 1 , 1 ) } , { grid ( 2 , 2 ) } , { grid ( 3 , 2 ) } , { grid ( 4 , 2 ) } } ,
std : : vector < Entity * > {
new Entity ( new Object (
NPC1_4 , " Test Obj " , 1 , 4 , ANIMATIONS [ " player.png " ] , { 2 , 2 } , GREEN ) ,
ㅎ 70 , ㅎ 70 , ㅍ 10 , ㅍ 10 , 아 14 , std : : array < int , 4 > { 0 , 0 , 0 , 0 } , 5 , std : : vector < Battle : : Move * > {
MOVELIST [ BattleMoveName : : TESTMOVE1 ] ,
MOVELIST [ BattleMoveName : : TESTMOVE2 ] ,
MOVELIST [ BattleMoveName : : TESTMOVE3 ] ,
} ) ,
new Entity ( new Object (
NPC1_4 , " Test Obj 2 " , 1 , 2 , ANIMATIONS [ " player.png " ] , { 2 , 2 } , GREEN ) ,
ㅎ 70 , ㅎ 70 , ㅍ 10 , ㅍ 10 , 아 14 , std : : array < int , 4 > { 0 , 0 , 0 , 0 } , 5 , std : : vector < Battle : : Move * > {
MOVELIST [ BattleMoveName : : TESTMOVE1 ] ,
MOVELIST [ BattleMoveName : : TESTMOVE2 ] ,
MOVELIST [ BattleMoveName : : TESTMOVE3 ] ,
} ) ,
new Entity ( new Object (
NPC1_4 , " Test Obj 3 " , 2 , 1 , ANIMATIONS [ " player.png " ] , { 2 , 2 } , GREEN ) ,
ㅎ 70 , ㅎ 70 , ㅍ 10 , ㅍ 10 , 아 14 , std : : array < int , 4 > { 0 , 0 , 0 , 0 } , 5 , std : : vector < Battle : : Move * > {
MOVELIST [ BattleMoveName : : TESTMOVE1 ] ,
MOVELIST [ BattleMoveName : : TESTMOVE2 ] ,
MOVELIST [ BattleMoveName : : TESTMOVE3 ] ,
} ) ,
} ) ) ; //ENCOUNTER_2
ENCOUNTER_LIST . push_back ( new Encounter ( encounter : : ENCOUNTER_3 , { 0 , 0 } , std : : array < vd2d , 4 > { vd2d
{ grid ( 1 , 1 ) } , { grid ( 2 , 2 ) } , { grid ( 3 , 2 ) } , { grid ( 4 , 2 ) } } ,
std : : vector < Entity * > {
new Entity ( new Object (
NPC1_4 , " Test Obj " , 1 , 2 , ANIMATIONS [ " player.png " ] , { 1 , 1 } , MAGENTA ) ,
ㅎ 70 , ㅎ 70 , ㅍ 10 , ㅍ 10 , 아 14 , std : : array < int , 4 > { 0 , 0 , 0 , 0 } , 0 , std : : vector < Battle : : Move * > {
MOVELIST [ BattleMoveName : : TESTMOVE1 ] ,
MOVELIST [ BattleMoveName : : TESTMOVE2 ] ,
MOVELIST [ BattleMoveName : : TESTMOVE3 ] ,
} ) ,
} ) ) ; //ENCOUNTER_3
ENCOUNTER_LIST . push_back ( new Encounter ( encounter : : ENCOUNTER_4 , { 0 , 0 } , std : : array < vd2d , 4 > { vd2d
{ grid ( 1 , 2 ) } , { grid ( 2 , 2 ) } , { grid ( 3 , 2 ) } , { grid ( 4 , 2 ) } } ,
std : : vector < Entity * > {
new Entity ( new Object (
NPC1_4 , " Test Obj " , 6 , 2 , ANIMATIONS [ " player.png " ] , { 1 , 1 } , MAGENTA ) ,
ㅎ 70 , ㅎ 70 , ㅍ 10 , ㅍ 10 , 아 14 , std : : array < int , 4 > { 0 , 0 , 0 , 0 } , 0 , std : : vector < Battle : : Move * > {
MOVELIST [ BattleMoveName : : TESTMOVE1 ] ,
MOVELIST [ BattleMoveName : : TESTMOVE2 ] ,
MOVELIST [ BattleMoveName : : TESTMOVE3 ] ,
} ) ,
new Entity ( new Object (
NPC1_4 , " Test Obj " , 7 , 2 , ANIMATIONS [ " player.png " ] , { 1 , 1 } , MAGENTA ) ,
ㅎ 70 , ㅎ 70 , ㅍ 10 , ㅍ 10 , 아 14 , std : : array < int , 4 > { 0 , 0 , 0 , 0 } , 0 , std : : vector < Battle : : Move * > {
MOVELIST [ BattleMoveName : : TESTMOVE1 ] ,
MOVELIST [ BattleMoveName : : TESTMOVE2 ] ,
MOVELIST [ BattleMoveName : : TESTMOVE3 ] ,
} ) ,
new Entity ( new Object (
NPC1_4 , " Test Obj " , 3 , 5 , ANIMATIONS [ " player.png " ] , { 1 , 1 } , MAGENTA ) ,
ㅎ 70 , ㅎ 70 , ㅍ 10 , ㅍ 10 , 아 14 , std : : array < int , 4 > { 0 , 0 , 0 , 0 } , 0 , std : : vector < Battle : : Move * > {
MOVELIST [ BattleMoveName : : TESTMOVE1 ] ,
MOVELIST [ BattleMoveName : : TESTMOVE2 ] ,
MOVELIST [ BattleMoveName : : TESTMOVE3 ] ,
} ) ,
} ) ) ; //ENCOUNTER_4
}
Object * AddObjectToWorld ( Object * obj ) {
std : : vector < Object * > : : const_iterator it = OBJECTS . begin ( ) ;
if ( obj - > id = = PLAYER & & ! obj - > temp ) {
PARTY_MEMBER_OBJ [ 0 ] = obj ;
PARTY_MEMBER_ID [ 0 ] = 0 ;
PARTY_MEMBER_OBJ [ 0 ] - > name = " PLAYER " ;
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ 0 ] ] - > obj = PARTY_MEMBER_OBJ [ 0 ] ;
for ( int i = toint ( Flag : : HAS_MAIN ) + 1 ; i < = toint ( Flag : : HAS_POO ) ; i + + ) {
if ( GetGameFlag ( i ) ) {
PARTY_MEMBER_ID [ PARTY_MEMBER_COUNT ] = toint ( PLAYER ) + i - toint ( Flag : : HAS_MAIN ) ;
PARTY_MEMBER_OBJ [ PARTY_MEMBER_COUNT ] = AddObjectToWorld ( CreateObject ( toint ( PLAYER ) + i - toint ( Flag : : HAS_MAIN ) , PARTY_MEMBER_OBJ [ 0 ] - > GetPos ( ) ) ) ;
switch ( toint ( PLAYER ) + i - toint ( Flag : : HAS_MAIN ) ) {
case 0 : { PARTY_MEMBER_OBJ [ PARTY_MEMBER_COUNT ] - > name = " PLAYER " ; } break ;
case 1 : { PARTY_MEMBER_OBJ [ PARTY_MEMBER_COUNT ] - > name = " NESS " ; } break ;
case 2 : { PARTY_MEMBER_OBJ [ PARTY_MEMBER_COUNT ] - > name = " PAULA " ; } break ;
case 3 : { PARTY_MEMBER_OBJ [ PARTY_MEMBER_COUNT ] - > name = " JEFF " ; } break ;
case 4 : { PARTY_MEMBER_OBJ [ PARTY_MEMBER_COUNT ] - > name = " ANNA " ; } break ;
case 5 : { PARTY_MEMBER_OBJ [ PARTY_MEMBER_COUNT ] - > name = " KING " ; } break ;
case 6 : { PARTY_MEMBER_OBJ [ PARTY_MEMBER_COUNT ] - > name = " POO " ; } break ;
}
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ PARTY_MEMBER_COUNT ] ] - > obj = PARTY_MEMBER_OBJ [ PARTY_MEMBER_COUNT ] ;
PARTY_MEMBER_COUNT + + ;
if ( PARTY_MEMBER_COUNT = = 4 ) {
break ;
}
}
}
}
bool inserted = false ;
for ( int i = 0 ; i < OBJECTS . size ( ) ; i + + ) {
if ( ! inserted & & OBJECTS [ i ] - > GetPos ( ) . y + OBJECTS [ i ] - > originPoint . y > obj - > GetPos ( ) . y + obj - > originPoint . y ) {
OBJECTS . insert ( it , obj ) ;
obj - > objArrElement = i ;
inserted = true ;
break ;
}
it + + ;
}
if ( ! inserted ) {
obj - > objArrElement = OBJECTS . size ( ) ;
OBJECTS . push_back ( obj ) ;
} else {
for ( int i = 0 ; i < OBJECTS . size ( ) ; i + + ) {
OBJECTS [ i ] - > objArrElement = i ;
}
}
//printf("OBJECTS (%d):\n",OBJECTS.size());
for ( int i = 0 ; i < OBJECTS . size ( ) ; i + + ) {
if ( i ! = OBJECTS [ i ] - > objArrElement ) {
printf ( " %d :: Object %s - %d (%lf,%lf) \n " , i , OBJECTS [ i ] - > name . c_str ( ) , OBJECTS [ i ] - > objArrElement , OBJECTS [ i ] - > GetPos ( ) . x , OBJECTS [ i ] - > GetPos ( ) . y ) ;
}
assert ( i = = OBJECTS [ i ] - > objArrElement ) ;
}
return obj ;
//printf("\n");
}
bool TabHeld ( ) {
return GetKey ( TAB ) . bHeld ;
}
bool UpPressed ( ) {
return GetKey ( W ) . bPressed | | GetKey ( UP ) . bPressed | | GetKey ( NP8 ) . bPressed | | MOUSE_PRESSED_DOWN & & GetMouseY ( ) < = HEIGHT - 128 + 32 & & GetMouseY ( ) > = HEIGHT - 128 & & GetMouseX ( ) < = HEIGHT - 128 ;
}
bool DownPressed ( ) {
return GetKey ( S ) . bPressed | | GetKey ( DOWN ) . bPressed | | GetKey ( NP5 ) . bPressed | | GetKey ( NP2 ) . bPressed | | MOUSE_PRESSED_DOWN & & GetMouseY ( ) < = HEIGHT & & GetMouseY ( ) > = HEIGHT - 32 & & GetMouseX ( ) < = HEIGHT - 128 ;
}
bool LeftPressed ( ) {
return GetKey ( A ) . bPressed | | GetKey ( LEFT ) . bPressed | | GetKey ( NP4 ) . bPressed | | MOUSE_PRESSED_DOWN & & GetMouseX ( ) < = 32 & & GetMouseX ( ) > = 0 & & GetMouseY ( ) > = HEIGHT - 128 ;
}
bool RightPressed ( ) {
return GetKey ( D ) . bPressed | | GetKey ( RIGHT ) . bPressed | | GetKey ( NP6 ) . bPressed | | MOUSE_PRESSED_DOWN & & GetMouseX ( ) < = 128 & & GetMouseX ( ) > = 96 & & GetMouseY ( ) > = HEIGHT - 128 ;
}
bool UpHeld ( ) {
return GetKey ( W ) . bHeld | | GetKey ( UP ) . bHeld | | GetKey ( NP8 ) . bHeld | | MOUSE_DOWN & & GetMouseY ( ) < = HEIGHT - 128 + 32 & & GetMouseY ( ) > = HEIGHT - 128 & & GetMouseX ( ) < = HEIGHT - 128 ;
}
bool DownHeld ( ) {
return GetKey ( S ) . bHeld | | GetKey ( DOWN ) . bHeld | | GetKey ( NP5 ) . bHeld | | GetKey ( NP2 ) . bHeld | | MOUSE_DOWN & & GetMouseY ( ) < = HEIGHT & & GetMouseY ( ) > = HEIGHT - 32 & & GetMouseX ( ) < = HEIGHT - 128 ;
}
bool LeftHeld ( ) {
return GetKey ( A ) . bHeld | | GetKey ( LEFT ) . bHeld | | GetKey ( NP4 ) . bHeld | | MOUSE_DOWN & & GetMouseX ( ) < = 32 & & GetMouseX ( ) > = 0 & & GetMouseY ( ) > = HEIGHT - 128 ;
}
bool RightHeld ( ) {
return GetKey ( D ) . bHeld | | GetKey ( RIGHT ) . bHeld | | GetKey ( NP6 ) . bHeld | | MOUSE_DOWN & & GetMouseX ( ) < = 128 & & GetMouseX ( ) > = 96 & & GetMouseY ( ) > = HEIGHT - 128 ;
}
bool UpReleased ( ) {
return GetKey ( W ) . bReleased | | GetKey ( UP ) . bReleased | | GetKey ( NP8 ) . bReleased | | MOUSE_RELEASED & & GetMouseY ( ) < = HEIGHT - 128 + 32 & & GetMouseY ( ) > = HEIGHT - 128 & & GetMouseX ( ) < = HEIGHT - 128 ;
}
bool DownReleased ( ) {
return GetKey ( S ) . bReleased | | GetKey ( DOWN ) . bReleased | | GetKey ( NP5 ) . bReleased | | GetKey ( NP2 ) . bReleased | | MOUSE_RELEASED & & GetMouseY ( ) < = HEIGHT & & GetMouseY ( ) > = HEIGHT - 32 & & GetMouseX ( ) < = HEIGHT - 128 ;
}
bool LeftReleased ( ) {
return GetKey ( A ) . bReleased | | GetKey ( LEFT ) . bReleased | | GetKey ( NP4 ) . bReleased | | MOUSE_RELEASED & & GetMouseX ( ) < = 32 & & GetMouseX ( ) > = 0 & & GetMouseY ( ) > = HEIGHT - 128 ;
}
bool RightReleased ( ) {
return GetKey ( D ) . bReleased | | GetKey ( RIGHT ) . bReleased | | GetKey ( NP6 ) . bReleased | | MOUSE_RELEASED & & GetMouseX ( ) < = 128 & & GetMouseX ( ) > = 96 & & GetMouseY ( ) > = HEIGHT - 128 ;
}
bool PlayerCanMove ( ) {
return BATTLE_ENCOUNTER = = nullptr & & ! IsTextEntryEnabled ( ) & & ! messageBoxVisible & & PARTY_MEMBER_OBJ [ 0 ] ! = nullptr ;
}
void DisplayMessageBox ( std : : string targetText ) {
this - > targetText = targetText ;
messageBoxText = " " ;
messageBoxFinalText = " " ;
messageBoxLoad = true ;
messageBoxVisible = true ;
messageBoxMarker = 0 ;
messageBoxStartMarker = 0 ;
messageBoxStopMarker = 0 ;
}
void DrawDialogBox ( const vi2d & pos , const vi2d & size , Pixel p = WHITE , Pixel p2 = DARK_GREY , Pixel p3 = VERY_DARK_GREY ) {
FillRect ( { ( int ) pos . x , ( int ) pos . y } , size , p2 ) ;
FillRect ( { ( int ) pos . x + 1 , ( int ) pos . y + 1 } , { ( int ) size . x - 2 , ( int ) size . y - 2 } , p ) ;
FillRect ( { ( int ) pos . x + 2 , ( int ) pos . y + 2 } , { ( int ) size . x - 4 , ( int ) size . y - 4 } , p3 ) ;
FillRect ( { ( int ) pos . x + 3 , ( int ) pos . y + 3 } , { ( int ) size . x - 5 , ( int ) size . y - 5 } , p ) ;
Draw ( { pos . x , pos . y } , Pixel ( 77 , 51 , 125 ) ) ;
Draw ( { pos . x + size . x - 1 , pos . y + size . y - 1 } , Pixel ( 77 , 51 , 125 ) ) ;
Draw ( { pos . x + size . x - 1 , pos . y } , Pixel ( 77 , 51 , 125 ) ) ;
Draw ( { pos . x , pos . y + size . y - 1 } , Pixel ( 77 , 51 , 125 ) ) ;
}
void StartCutscene ( Cutscene * cutscene ) {
CurrentCutscene = cutscene ;
}
ActionType GetCurrentCutsceneAction ( ) {
return ( CurrentCutscene = = nullptr ) ? ActionType : : NONE : CurrentCutscene - > CurrentAction ( ) ;
}
bool MoveCameraTowardsPoint ( vd2d targetPos , PriorityDirection dir , double spd , bool secondRun = false ) {
bool reachedPosition = true ;
if ( dir = = HORZ_FIRST | | dir = = BOTH ) {
if ( cameraPos . x ! = targetPos . x ) {
if ( cameraPos . x < targetPos . x ) {
cameraPos . x + = spd ;
if ( cameraPos . x > targetPos . x ) {
cameraPos . x = targetPos . x ;
}
} else {
cameraPos . x - = spd ;
if ( cameraPos . x < targetPos . x ) {
cameraPos . x = targetPos . x ;
}
}
reachedPosition = false ;
} else
if ( ! secondRun & & dir ! = BOTH ) {
MoveCameraTowardsPoint ( targetPos , dir , spd , true ) ;
}
}
if ( dir = = VERT_FIRST | | dir = = BOTH ) {
if ( cameraPos . y ! = targetPos . y ) {
if ( cameraPos . y < targetPos . y ) {
cameraPos . y + = spd ;
if ( cameraPos . y > targetPos . y ) {
cameraPos . y = targetPos . y ;
}
} else {
cameraPos . y - = spd ;
if ( cameraPos . y < targetPos . y ) {
cameraPos . y = targetPos . y ;
}
}
reachedPosition = false ;
} else
if ( ! secondRun & & dir ! = BOTH ) {
MoveCameraTowardsPoint ( targetPos , dir , spd , true ) ;
}
}
return reachedPosition ;
}
bool MoveObjectTowardsPoint ( Object * obj , vd2d targetPos , PriorityDirection dir , double moveSpd , bool secondRun = false ) {
bool reachedPosition = true ;
if ( dir = = HORZ_FIRST | | dir = = BOTH ) {
if ( obj - > GetPos ( ) . x ! = targetPos . x ) {
if ( obj - > GetPos ( ) . x < targetPos . x ) {
obj - > Move ( { moveSpd , 0 } ) ;
if ( obj - > GetPos ( ) . x > targetPos . x ) {
obj - > SetPos ( { targetPos . x , obj - > GetPos ( ) . y } ) ;
}
} else {
obj - > Move ( { - moveSpd , 0 } ) ;
if ( obj - > GetPos ( ) . x < targetPos . x ) {
obj - > SetPos ( { targetPos . x , obj - > GetPos ( ) . y } ) ;
}
}
reachedPosition = false ;
} else
if ( ! secondRun & & dir ! = BOTH ) {
MoveObjectTowardsPoint ( obj , targetPos , dir , moveSpd , true ) ;
}
}
if ( dir = = VERT_FIRST | | dir = = BOTH ) {
if ( obj - > GetPos ( ) . y ! = targetPos . y ) {
if ( obj - > GetPos ( ) . y < targetPos . y ) {
obj - > Move ( { 0 , moveSpd } ) ;
if ( obj - > GetPos ( ) . y > targetPos . y ) {
obj - > SetPos ( { obj - > GetPos ( ) . x , targetPos . y } ) ;
}
} else {
obj - > Move ( { 0 , - moveSpd } ) ;
if ( obj - > GetPos ( ) . y < targetPos . y ) {
obj - > SetPos ( { obj - > GetPos ( ) . x , targetPos . y } ) ;
}
}
reachedPosition = false ;
} else
if ( ! secondRun & & dir ! = BOTH ) {
MoveObjectTowardsPoint ( obj , targetPos , dir , moveSpd , true ) ;
}
}
return reachedPosition ;
}
void SetGameFlag ( Flag flag , bool val ) {
GAME_FLAGS [ toint ( flag ) ] = val ;
}
bool GetGameFlag ( int flag ) {
return GAME_FLAGS [ flag ] ;
}
bool GetGameFlag ( Flag flag ) {
return GAME_FLAGS [ toint ( flag ) ] ;
}
void LoadEncounter ( Map * map , vd2d pos , int chance , int id , bool successful ) {
std : : vector < Entity * > ents ;
for ( int i = 0 ; i < ENCOUNTER_LIST [ id ] - > objs . size ( ) ; i + + ) {
Entity * ent = ENCOUNTER_LIST [ id ] - > objs [ i ] ;
Object * newObj = new Object ( ent - > obj - > id , ent - > obj - > name , ent - > obj - > GetPos ( ) , ent - > obj - > spr , ent - > obj - > GetScale ( ) , ent - > obj - > color , ent - > obj - > animationSpd , ent - > obj - > temp ) ;
ents . push_back ( new Entity ( newObj , ent - > GetHP ( ) , ent - > maxHP , ent - > PP , ent - > maxPP , ent - > baseAtk , ent - > resistances , ent - > speed , ent - > moveSet , ent - > damageReduction , ent - > smart , ent - > dumb ) ) ;
}
Encounter * data = new Encounter ( id , pos , ENCOUNTER_LIST [ id ] - > playerPos , ents , chance ) ;
data - > chance = chance ;
data - > id = id ;
for ( int i = 0 ; i < data - > objs . size ( ) ; i + + ) {
data - > objs [ i ] - > obj - > enc = true ;
if ( ! successful ) {
data - > objs [ i ] - > _SetDirectHP ( 0 ) ;
data - > objs [ i ] - > obj - > dead = true ;
}
}
map - > encounters . push_back ( data ) ;
for ( int i = 0 ; i < data - > objs . size ( ) ; i + + ) {
AddObjectToWorld ( data - > objs [ i ] - > obj ) ;
data - > objs [ i ] - > obj - > SetPos ( data - > objs [ i ] - > obj - > GetPos ( ) + pos ) ;
}
}
void UpdatePlayerTrail ( vd2d newMovement ) {
for ( int i = PARTY_TRAIL_LENGTH - 1 ; i > 0 ; i - - ) {
partyTrail [ i ] = partyTrail [ i - 1 ] ;
}
partyTrail [ 0 ] = { PARTY_MEMBER_OBJ [ 0 ] - > GetPos ( ) . x - newMovement . x + PARTY_MEMBER_OBJ [ 0 ] - > spr - > width * 0.5 * ( PARTY_MEMBER_OBJ [ 0 ] - > GetScale ( ) . x - 1 ) ,
PARTY_MEMBER_OBJ [ 0 ] - > GetPos ( ) . y - newMovement . y + ( PARTY_MEMBER_OBJ [ 0 ] - > spr - > spr - > sprite - > height - 4 ) * ( PARTY_MEMBER_OBJ [ 0 ] - > GetScale ( ) . y - 1 ) } ;
for ( int i = 1 ; i < PARTY_MEMBER_COUNT ; i + + ) {
PARTY_MEMBER_OBJ [ i ] - > SetPos ( partyTrail [ PARTY_TRAIL_LENGTH * ( ( double ) i / 4 ) ] ) ;
}
}
void drawBox ( const olc : : vi2d & pos , const olc : : vi2d & size , olc : : Pixel p = olc : : WHITE , olc : : Pixel p2 = olc : : DARK_GREY , olc : : Pixel p3 = olc : : VERY_DARK_GREY ) {
FillRectDecal ( { ( float ) ( pos . x + 3 ) , ( float ) ( pos . y + 3 ) } , { ( float ) ( size . x - 5 ) , ( float ) ( size . y - 5 ) } , p ) ;
DrawRect ( { pos . x , pos . y } , size , p2 ) ;
DrawRect ( { pos . x + 2 , pos . y + 2 } , { size . x - 4 , size . y - 4 } , p3 ) ;
DrawRect ( { pos . x + 1 , pos . y + 1 } , { size . x - 2 , size . y - 2 } , p ) ;
Draw ( { pos . x , pos . y } , olc : : BLACK ) ;
Draw ( { pos . x + size . x , pos . y + size . y } , olc : : BLACK ) ;
Draw ( { pos . x + size . x , pos . y } , olc : : BLACK ) ;
Draw ( { pos . x , pos . y + size . y } , olc : : BLACK ) ;
}
void drawCheckerboardBox ( const olc : : vi2d & pos , const olc : : vi2d & size , olc : : Pixel p = olc : : WHITE , olc : : Pixel alternatingCol = olc : : WHITE , const olc : : vi2d & checkerboardSize = { 3 , 3 } , olc : : Pixel p2 = olc : : DARK_GREY , olc : : Pixel p3 = olc : : VERY_DARK_GREY ) {
drawBox ( pos , size , p , p2 , p3 ) ;
for ( int x = 3 ; x < size . x ; x + = checkerboardSize . x * 2 ) {
for ( int y = 3 ; y < size . y ; y + = checkerboardSize . y * 2 ) {
if ( x + checkerboardSize . x < size . x & & y + checkerboardSize . y < size . y ) {
FillRectDecal ( { ( float ) ( x + pos . x ) , ( float ) ( y + pos . y ) } , { ( float ) checkerboardSize . x , ( float ) checkerboardSize . y } , alternatingCol ) ;
}
}
}
}
void DrawRollingCounter ( const olc : : vi2d & pos , int val , int * rollcounter , int * rolloffset ) {
FillRectDecal ( { ( float ) ( pos . x + 20 ) , ( float ) ( pos . y - 3 ) } , { 30 , 13 } , olc : : DARK_GREY ) ;
FillRectDecal ( { ( float ) ( pos . x + 21 ) , ( float ) ( pos . y - 2 ) } , { 28 , 11 } , olc : : GREY ) ;
DrawLineDecal ( { ( float ) ( pos . x + 30 ) , ( float ) ( pos . y - 3 ) } , { ( float ) ( pos . x + 30 ) , ( float ) ( pos . y + 10 ) } , olc : : DARK_GREY ) ;
DrawLineDecal ( { ( float ) ( pos . x + 40 ) , ( float ) ( pos . y - 3 ) } , { ( float ) ( pos . x + 40 ) , ( float ) ( pos . y + 10 ) } , olc : : DARK_GREY ) ;
DrawPartialDecal ( { ( float ) ( pos . x + 22 ) , ( float ) ( pos . y - 1 ) } , { 7 , 9 } , SPRITES [ " rollingcounter.png " ] , { 0 , ( float ) ( rollcounter [ 2 ] * 13 + rolloffset [ 2 ] + 13 ) } , { 7 , 9 } ) ;
DrawPartialDecal ( { ( float ) ( pos . x + 31 ) , ( float ) ( pos . y - 1 ) } , { 7 , 9 } , SPRITES [ " rollingcounter.png " ] , { 0 , ( float ) ( rollcounter [ 1 ] * 13 + rolloffset [ 1 ] + 13 ) } , { 7 , 9 } ) ;
DrawPartialDecal ( { ( float ) ( pos . x + 41 ) , ( float ) ( pos . y - 1 ) } , { 7 , 9 } , SPRITES [ " rollingcounter.png " ] , { 0 , ( float ) ( rollcounter [ 0 ] * 13 + rolloffset [ 0 ] + 13 ) } , { 7 , 9 } ) ;
}
void ResetBattleState ( ) {
CAMERA_WAIT_TIMER = 0 ;
}
std : : string Wrap ( std : : string str , int width , bool proportional , vd2d scale ) {
return to_string ( Wrap ( to_wstring ( str ) , width , proportional , scale ) ) ;
}
std : : wstring Wrap ( std : : wstring str , int width , bool proportional , vd2d scale ) {
int marker = 0 ;
std : : wstring newStr = L " " ;
bool firstChar = false ;
while ( marker < str . length ( ) ) {
if ( firstChar | | ! firstChar & & str [ marker ] ! = ' ' ) {
newStr + = str [ marker ] ;
}
vd2d siz ;
if ( proportional ) {
siz = { GetTextSizeProp ( to_string ( newStr ) ) . x * scale . x , GetTextSizeProp ( to_string ( newStr ) ) . y * scale . y } ;
} else {
siz = { GetTextSize ( to_string ( newStr ) ) . x * scale . x , GetTextSize ( to_string ( newStr ) ) . y * scale . y } ;
}
if ( siz . x > width ) {
do {
if ( newStr [ newStr . length ( ) - 1 ] ! = ' ' ) {
marker - - ;
//printf("%s\n",newStr.c_str());
}
newStr . erase ( newStr . end ( ) - 1 ) ;
} while ( newStr [ newStr . length ( ) - 1 ] ! = ' ' ) ;
//newStr.erase(newStr.end()-1);
newStr + = ' \n ' ;
firstChar = false ;
} else {
firstChar = true ;
marker + + ;
}
}
return newStr ;
}
//Returns 0 if not found.
int getProperty ( Property prop , Battle : : Move * move ) {
for ( int i = 0 ; i < move - > properties . size ( ) ; i + + ) {
std : : pair < Property , int > p = move - > properties [ i ] ;
if ( p . first = = prop ) {
return p . second ;
}
}
return 0 ;
}
void HandleBattle ( ) {
if ( BATTLE_ENCOUNTER ! = nullptr ) {
for ( int i = 0 ; i < PARTY_MEMBER_COUNT ; i + + ) {
if ( player_rollwait_counter [ i ] > 0 ) {
if ( BATTLE_ROLLING_COUNTER_WAITTIME = = 0 ) {
player_rollwait_counter [ i ] = 0 ;
} else {
player_rollwait_counter [ i ] - - ;
}
}
Entity * member = PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] ;
if ( member - > GetHP ( ) > std : : clamp ( member - > GetTargetHP ( ) , 0 , member - > GetTargetHP ( ) ) ) {
if ( player_rollhp_counter [ i ] [ 0 ] < = 0 & & player_rollwait_counter [ i ] = = 0 ) {
player_rollhp_display [ i ] [ 0 ] - - ;
player_rollhp_counter [ i ] [ 0 ] = 13 ;
member - > _SetDirectHP ( member - > GetHP ( ) - 1 ) ;
if ( player_rollhp_display [ i ] [ 0 ] < 0 ) {
player_rollhp_display [ i ] [ 0 ] = 9 ;
player_rollhp_counter [ i ] [ 0 ] = 13 ;
player_rollhp_display [ i ] [ 1 ] - - ;
player_rollhp_counter [ i ] [ 1 ] = 13 ;
if ( player_rollhp_display [ i ] [ 1 ] < 0 ) {
player_rollhp_display [ i ] [ 1 ] = 9 ;
player_rollhp_counter [ i ] [ 1 ] = 13 ;
player_rollhp_display [ i ] [ 2 ] - - ;
player_rollhp_counter [ i ] [ 2 ] = 13 ;
}
}
}
if ( player_rollhp_counter [ i ] [ 0 ] > 0 ) {
if ( member - > GetTargetHP ( ) < - member - > maxHP ) {
player_rollhp_counter [ i ] [ 0 ] - = HEALTH_ROLLING_SPEED + ( member - > maxHP - member - > GetTargetHP ( ) ) / 10 ;
} else
if ( member - > GetTargetHP ( ) < 0 ) {
player_rollhp_counter [ i ] [ 0 ] - = HEALTH_ROLLING_SPEED + ( member - > maxHP - member - > GetTargetHP ( ) ) / 20 ;
} else {
player_rollhp_counter [ i ] [ 0 ] - = HEALTH_ROLLING_SPEED ;
}
}
if ( player_rollhp_counter [ i ] [ 1 ] > 0 ) {
player_rollhp_counter [ i ] [ 1 ] - - ;
}
if ( player_rollhp_counter [ i ] [ 2 ] > 0 ) {
player_rollhp_counter [ i ] [ 2 ] - - ;
}
} else
if ( member - > GetHP ( ) < member - > GetTargetHP ( ) ) {
if ( player_rollhp_counter [ i ] [ 0 ] > = 0 & & player_rollwait_counter [ i ] = = 0 ) {
player_rollhp_display [ i ] [ 0 ] + + ;
player_rollhp_counter [ i ] [ 0 ] = - 13 ;
member - > _SetDirectHP ( member - > GetHP ( ) + 1 ) ;
if ( player_rollhp_display [ i ] [ 0 ] > 9 ) {
player_rollhp_display [ i ] [ 0 ] = 0 ;
player_rollhp_counter [ i ] [ 0 ] = - 13 ;
player_rollhp_display [ i ] [ 1 ] + + ;
player_rollhp_counter [ i ] [ 1 ] = - 13 ;
if ( player_rollhp_display [ i ] [ 1 ] > 9 ) {
player_rollhp_display [ i ] [ 1 ] = 0 ;
player_rollhp_counter [ i ] [ 1 ] = - 13 ;
player_rollhp_display [ i ] [ 2 ] + + ;
player_rollhp_counter [ i ] [ 2 ] = - 13 ;
}
}
}
if ( player_rollhp_counter [ i ] [ 0 ] < 0 ) {
player_rollhp_counter [ i ] [ 0 ] + = HEALTH_ROLLING_SPEED ;
}
if ( player_rollhp_counter [ i ] [ 1 ] < 0 ) {
player_rollhp_counter [ i ] [ 1 ] + + ;
}
if ( player_rollhp_counter [ i ] [ 2 ] < 0 ) {
player_rollhp_counter [ i ] [ 2 ] + + ;
}
} else {
if ( player_rollhp_counter [ i ] [ 0 ] < 0 ) {
player_rollhp_counter [ i ] [ 0 ] + + ;
}
if ( player_rollhp_counter [ i ] [ 1 ] < 0 ) {
player_rollhp_counter [ i ] [ 1 ] + + ;
}
if ( player_rollhp_counter [ i ] [ 2 ] < 0 ) {
player_rollhp_counter [ i ] [ 2 ] + + ;
}
if ( player_rollhp_counter [ i ] [ 0 ] > 0 ) {
player_rollhp_counter [ i ] [ 0 ] - - ;
}
if ( player_rollhp_counter [ i ] [ 1 ] > 0 ) {
player_rollhp_counter [ i ] [ 1 ] - - ;
}
if ( player_rollhp_counter [ i ] [ 2 ] > 0 ) {
player_rollhp_counter [ i ] [ 2 ] - - ;
}
}
if ( player_rollwait_counter [ i ] = = 0 ) {
player_rollwait_counter [ i ] = BATTLE_ROLLING_COUNTER_WAITTIME * 13 ;
}
}
switch ( BATTLE_STATE ) {
case BattleState : : MOVE_CAMERA : {
bool allDone = true ;
if ( ! MoveCameraTowardsPoint ( BATTLE_ENCOUNTER - > pos , PriorityDirection : : BOTH , BATTLE_CAMERA_MOVESPD ) ) {
allDone = false ;
}
for ( int i = 0 ; i < PARTY_MEMBER_COUNT ; i + + ) {
if ( ! MoveObjectTowardsPoint ( PARTY_MEMBER_OBJ [ i ] ,
{ BATTLE_ENCOUNTER - > playerPos [ i ] . x + BATTLE_ENCOUNTER - > pos . x - PARTY_MEMBER_OBJ [ i ] - > spr - > width * 0.5 * ( PARTY_MEMBER_OBJ [ i ] - > GetScale ( ) . x - 1 ) ,
BATTLE_ENCOUNTER - > playerPos [ i ] . y + BATTLE_ENCOUNTER - > pos . y - ( PARTY_MEMBER_OBJ [ i ] - > spr - > spr - > sprite - > height - 4 ) * 1 * ( PARTY_MEMBER_OBJ [ i ] - > GetScale ( ) . y - 1 ) } ,
PriorityDirection : : BOTH , BATTLE_CAMERA_MOVESPD ) ) {
allDone = false ;
}
}
if ( allDone ) {
CAMERA_WAIT_TIMER + + ;
if ( CAMERA_WAIT_TIMER > = CAMERA_WAIT_TIME ) {
for ( int i = 0 ; i < PARTY_MEMBER_COUNT ; i + + ) {
Entity * member = PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] ;
for ( int j = 0 ; j < 3 ; j + + ) {
switch ( j ) {
case 0 : {
player_rollhp_display [ i ] [ j ] = member - > GetHP ( ) % 10 ;
player_rollpp_display [ i ] [ j ] = member - > PP % 10 ;
} break ;
case 1 : {
player_rollhp_display [ i ] [ j ] = member - > GetHP ( ) / 10 % 10 ;
player_rollpp_display [ i ] [ j ] = member - > PP / 10 % 10 ;
} break ;
case 2 : {
player_rollhp_display [ i ] [ j ] = member - > GetHP ( ) / 100 % 10 ;
player_rollpp_display [ i ] [ j ] = member - > PP / 100 % 10 ;
} break ;
}
}
BATTLE_STATE = BattleState : : WAIT ;
}
}
}
} break ;
case BattleState : : WAIT : {
BATTLE_ROLLING_COUNTER_WAITTIME = 0 ;
bool done = false ;
if ( ! done ) {
for ( int i = 0 ; i < 4 ; i + + ) {
if ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > GetHP ( ) > 0 ) {
if ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > selectedMove ! = nullptr ) {
if ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > channelTimeRemaining > 0 ) {
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > channelTimeRemaining - - ;
} else {
//Attack is being done.
printf ( " %s performs %s. \n " , PARTY_MEMBER_OBJ [ i ] - > name . c_str ( ) , PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > selectedMove - > name . c_str ( ) ) ;
BATTLE_STATE = BattleState : : WAIT_ANIMATION ;
BATTLE_ANIMATION_TIMER = 0 ;
CURRENT_TURN = - i - 1 ;
done = true ;
break ;
}
}
} else {
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > selectedMove = nullptr ;
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > channelTimeRemaining = 0 ;
}
}
}
if ( ! done ) {
for ( int i = 0 ; i < BATTLE_ENCOUNTER - > objs . size ( ) ; i + + ) {
if ( BATTLE_ENCOUNTER - > objs [ i ] - > GetHP ( ) > 0 ) {
if ( BATTLE_ENCOUNTER - > objs [ i ] - > selectedMove ! = nullptr ) {
if ( BATTLE_ENCOUNTER - > objs [ i ] - > channelTimeRemaining > 0 ) {
BATTLE_ENCOUNTER - > objs [ i ] - > channelTimeRemaining - - ;
} else {
CURRENT_TURN = i ;
printf ( " %s performs %s. \n " , BATTLE_ENCOUNTER - > objs [ i ] - > obj - > name . c_str ( ) , BATTLE_ENCOUNTER - > objs [ i ] - > selectedMove - > name . c_str ( ) ) ;
BATTLE_STATE = BattleState : : WAIT_ANIMATION ;
BATTLE_ANIMATION_TIMER = 0 ;
done = true ;
break ;
}
}
} else {
BATTLE_ENCOUNTER - > objs [ i ] - > selectedMove = nullptr ;
BATTLE_ENCOUNTER - > objs [ i ] - > channelTimeRemaining = 0 ;
}
}
}
if ( ! done ) {
for ( int i = 0 ; i < 4 ; i + + ) {
if ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > GetHP ( ) > 0 ) {
if ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > selectedMove = = nullptr ) {
if ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > atb > = 1000 ) {
printf ( " %s ready. \n " , PARTY_MEMBER_OBJ [ i ] - > name . c_str ( ) ) ;
CURRENT_TURN = - i - 1 ;
BATTLE_STATE = BattleState : : SELECT_ACTION ;
BATTLE_SELECTION_CURSOR = 0 ;
POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] = 0 ;
done = true ;
break ;
} else {
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > atb + = PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > speed ;
}
}
} else {
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > atb = 0 ;
}
}
}
if ( ! done ) {
for ( int i = 0 ; i < BATTLE_ENCOUNTER - > objs . size ( ) ; i + + ) {
if ( BATTLE_ENCOUNTER - > objs [ i ] - > GetHP ( ) > 0 ) {
if ( BATTLE_ENCOUNTER - > objs [ i ] - > selectedMove = = nullptr ) {
if ( BATTLE_ENCOUNTER - > objs [ i ] - > atb > = 1000 ) {
printf ( " %s (%d) ready. \n " , BATTLE_ENCOUNTER - > objs [ i ] - > obj - > name . c_str ( ) , i ) ;
CURRENT_TURN = i ;
//Enemy picks a random move from the movelist. And a random target.
BATTLE_ENCOUNTER - > objs [ i ] - > selectedMove = BATTLE_ENCOUNTER - > objs [ i ] - > moveSet [ rand ( ) % BATTLE_ENCOUNTER - > objs [ i ] - > moveSet . size ( ) ] ;
BATTLE_ENCOUNTER - > objs [ i ] - > channelTimeRemaining = BATTLE_ENCOUNTER - > objs [ i ] - > selectedMove - > channelTime ;
if ( BATTLE_ENCOUNTER - > objs [ i ] - > selectedMove - > friendly ) {
do {
BATTLE_ENCOUNTER - > objs [ i ] - > selectedTarget = rand ( ) % BATTLE_ENCOUNTER - > objs . size ( ) ;
} while ( BATTLE_ENCOUNTER - > objs [ BATTLE_ENCOUNTER - > objs [ i ] - > selectedTarget ] - > GetHP ( ) < = 0 ) ;
BATTLE_ENCOUNTER - > objs [ i ] - > channelPos = BATTLE_ENCOUNTER - > objs [ BATTLE_ENCOUNTER - > objs [ i ] - > selectedTarget ] - > obj - > GetPosWithOrigin ( ) ;
} else {
bool playerAlive = false ;
for ( int i = 0 ; i < PARTY_MEMBER_COUNT ; i + + ) {
if ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > GetHP ( ) > 0 ) {
playerAlive = true ;
break ;
}
}
if ( playerAlive ) {
do {
BATTLE_ENCOUNTER - > objs [ i ] - > selectedTarget = - ( rand ( ) % PARTY_MEMBER_COUNT ) - 1 ;
} while ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - BATTLE_ENCOUNTER - > objs [ i ] - > selectedTarget - 1 ] ] - > GetHP ( ) < = 0 ) ;
BATTLE_ENCOUNTER - > objs [ i ] - > channelPos = PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - BATTLE_ENCOUNTER - > objs [ i ] - > selectedTarget - 1 ] ] - > obj - > GetPosWithOrigin ( ) ;
printf ( " Selected Target: %d \n " , BATTLE_ENCOUNTER - > objs [ i ] - > selectedTarget ) ;
}
}
printf ( " %s chose move %s. \n " , BATTLE_ENCOUNTER - > objs [ i ] - > obj - > name . c_str ( ) , BATTLE_ENCOUNTER - > objs [ i ] - > selectedMove - > name . c_str ( ) ) ;
BATTLE_STATE = BattleState : : WAIT ;
BATTLE_SELECTION_CURSOR = 0 ;
done = true ;
break ;
} else {
BATTLE_ENCOUNTER - > objs [ i ] - > atb + = BATTLE_ENCOUNTER - > objs [ i ] - > speed ;
}
}
} else {
BATTLE_ENCOUNTER - > objs [ i ] - > atb = 0 ;
}
}
}
} break ;
case BattleState : : WAIT_ANIMATION : {
BATTLE_ROLLING_COUNTER_WAITTIME = 5 ;
BATTLE_ANIMATION_TIMER + + ;
if ( BATTLE_ANIMATION_TIMER = = 30 ) {
Effect * eff = ( CURRENT_TURN < 0 ) ? PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > eff : BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove - > eff ;
if ( eff ! = nullptr ) {
StartEffect ( eff ) ;
}
}
if ( CURRENT_EFFECT = = nullptr & & BATTLE_ANIMATION_TIMER = = 90 | | CURRENT_EFFECT ! = nullptr & & BATTLE_ANIMATION_TIMER > CURRENT_EFFECT - > maxLifeTime ) {
if ( CURRENT_TURN < 0 ) {
if ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > friendly ) {
if ( PARTY_MEMBER_STATS [ - PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedTarget - 1 ] - > GetHP ( ) > 0 ) {
for ( auto & ent : GetEntitiesInRange ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedTarget , PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > channelPos , PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove ) ) {
int healAmt = PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > baseDmg +
( ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > randomDmg > 0 ) ? rand ( ) % PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > randomDmg : 0 )
+ PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > baseAtk ;
if ( ent - > GetHP ( ) > 0 ) {
std : : cout < < PARTY_MEMBER_OBJ [ - CURRENT_TURN - 1 ] - > name < < " uses " < < PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > name < < " " < < PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > grade < < " on " < < ent - > obj - > name < < " recovering " < < healAmt < < " health. \n " ;
ent - > AddHP ( healAmt ) ;
int memberID = getMemberIDComparingObject ( ent - > obj ) ;
vi2d box = { ( 128 - 32 * PARTY_MEMBER_COUNT ) + memberID * 64 + 29 , 170 } ;
DAMAGE_NUMBERS . push_back ( new DamageNumber ( - healAmt , box + cameraPos ) ) ;
}
}
} else {
std : : cout < < PARTY_MEMBER_OBJ [ - CURRENT_TURN - 1 ] - > name < < " uses " < < PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > name < < " " < < PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > grade < < " on " < < PARTY_MEMBER_OBJ [ - PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedTarget - 1 ] - > name < < " but it failed. \n " ;
}
} else {
if ( BATTLE_ENCOUNTER - > objs [ PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedTarget ] - > GetHP ( ) > 0 ) {
//Enemies have their health directly set.
for ( auto & ent : GetEntitiesInRange ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedTarget , PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > channelPos , PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove ) ) {
int dmgAmt = PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > baseDmg +
( ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > randomDmg > 0 ) ? rand ( ) % PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > randomDmg : 0 )
+ PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > baseAtk ;
if ( ent - > GetHP ( ) > 0 ) {
std : : cout < < PARTY_MEMBER_OBJ [ - CURRENT_TURN - 1 ] - > name < < " uses " < < PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > name < < " " < < PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > grade < < " on " < < ent - > obj - > name < < " dealing " < < dmgAmt < < " health. \n " ;
ent - > _SetDirectHP ( ent - > GetHP ( ) - dmgAmt ) ;
ent - > obj - > blinkFrames = 35 ;
if ( ent - > GetHP ( ) < = 0 ) {
ent - > obj - > dead = true ;
}
DAMAGE_NUMBERS . push_back ( new DamageNumber ( dmgAmt , ent - > obj - > GetPosWithOrigin ( ) ) ) ;
}
}
} else {
std : : cout < < PARTY_MEMBER_OBJ [ - CURRENT_TURN - 1 ] - > name < < " uses " < < PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > name < < " " < < PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > grade < < " on " < < BATTLE_ENCOUNTER - > objs [ PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedTarget ] - > obj - > name < < " but it failed. \n " ;
}
}
} else {
if ( BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove - > friendly ) {
if ( BATTLE_ENCOUNTER - > objs [ BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedTarget ] - > GetHP ( ) > 0 ) {
for ( auto & ent : GetEntitiesInRange ( BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedTarget , BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > channelPos , BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove ) ) {
int healAmt = BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove - > baseDmg +
( ( rand ( ) % BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove - > randomDmg > 0 ) ? rand ( ) % BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove - > randomDmg : 0 )
+ BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > baseAtk ;
if ( ent - > GetHP ( ) > 0 ) {
std : : cout < < BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > obj - > name < < " uses " < < BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove - > name < < " " < < BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove - > grade < < " on " < < ent - > obj - > name < < " recovering " < < healAmt < < " health. \n " ;
ent - > AddHP ( healAmt ) ;
DAMAGE_NUMBERS . push_back ( new DamageNumber ( - healAmt , ent - > obj - > GetPosWithOrigin ( ) ) ) ;
}
}
} else {
std : : cout < < BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > obj - > name < < " uses " < < BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove - > name < < " " < < BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove - > grade < < " on " < < BATTLE_ENCOUNTER - > objs [ BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedTarget ] - > obj - > name < < " but it failed. \n " ;
}
} else {
if ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedTarget - 1 ] ] - > GetHP ( ) > 0 ) {
for ( auto & ent : GetEntitiesInRange ( BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedTarget , BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > channelPos , BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove ) ) {
int dmgAmt = BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove - > baseDmg +
( ( rand ( ) % BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove - > randomDmg > 0 ) ? rand ( ) % BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove - > randomDmg : 0 )
+ BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > baseAtk ;
if ( ent - > GetHP ( ) > 0 ) {
std : : cout < < BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > obj - > name < < " uses " < < BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove - > name < < " " < < BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove - > grade < < " on " < < ent - > obj - > name < < " dealing " < < dmgAmt < < " health. \n " ;
ent - > SubtractHP ( dmgAmt ) ;
if ( ent - > GetTargetHP ( ) < 0 ) {
BATTLE_HIT_SCREENSHAKE = 75 ;
} else {
BATTLE_HIT_SCREENSHAKE = 25 ;
}
int memberID = getMemberIDComparingObject ( ent - > obj ) ;
vi2d box = { ( 128 - 32 * PARTY_MEMBER_COUNT ) + memberID * 64 + 29 , 170 } ;
DAMAGE_NUMBERS . push_back ( new DamageNumber ( dmgAmt , box + cameraPos ) ) ;
}
}
} else {
std : : cout < < BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > obj - > name < < " uses " < < BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove - > name < < " " < < BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove - > grade < < " on " < < PARTY_MEMBER_OBJ [ - BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedTarget - 1 ] - > name < < " but it failed. \n " ;
}
}
}
} else
if ( CURRENT_EFFECT = = nullptr & & BATTLE_ANIMATION_TIMER > 120 | | CURRENT_EFFECT ! = nullptr & & BATTLE_ANIMATION_TIMER > CURRENT_EFFECT - > maxLifeTime + 30 ) {
//Turn's done!
if ( CURRENT_TURN < 0 ) {
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove = nullptr ;
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > atb = 0 ;
BATTLE_STATE = BattleState : : WAIT ;
CURRENT_TURN = - 99 ;
} else {
BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove = nullptr ;
BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > atb = 0 ;
BATTLE_STATE = BattleState : : WAIT ;
}
bool enemyStillAlive = false ;
for ( int i = 0 ; i < BATTLE_ENCOUNTER - > objs . size ( ) ; i + + ) {
if ( BATTLE_ENCOUNTER - > objs [ i ] - > GetHP ( ) > 0 ) {
enemyStillAlive = true ;
break ;
}
}
if ( ! enemyStillAlive ) {
BATTLE_ENCOUNTER = nullptr ;
BATTLE_STATE = BattleState : : MOVE_CAMERA ;
for ( int i = 0 ; i < PARTY_MEMBER_COUNT ; i + + ) {
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > atb = 0 ;
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > selectedMove = nullptr ;
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > channelTimeRemaining = 0 ;
if ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > GetTargetHP ( ) > PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > GetHP ( ) ) {
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > _SetDirectHP ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > GetTargetHP ( ) ) ;
} else {
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > SetTargetHP ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > GetHP ( ) ) ;
}
}
}
}
} break ;
case BattleState : : SELECT_ACTION :
case BattleState : : ITEM_SELECT :
case BattleState : : GRADE_SELECT :
case BattleState : : TARGET_SELECT :
case BattleState : : POWER_SELECT : {
BATTLE_ROLLING_COUNTER_WAITTIME = 5 ;
} break ;
}
}
}
void HandleCutscenes ( ) {
switch ( CurrentAction ) {
case ActionType : : SET_FLAG_WHEN_CUTSCENE_ENDS : {
CurrentCutscene - > SetupEndingCutsceneFlag ( ( ( SetFlagWhenCutsceneEnds * ) CurrentCutscene - > GetAction ( ) ) - > GetCutsceneEndingFlag ( ) , ( ( SetFlagWhenCutsceneEnds * ) CurrentCutscene - > GetAction ( ) ) - > GetCutsceneEndingVal ( ) ) ;
CurrentCutscene - > AdvanceAction ( ) ;
} break ;
case ActionType : : PAN_CAMERA : {
PanCamera * cam = ( PanCamera * ) CurrentCutscene - > GetAction ( ) ;
if ( MoveCameraTowardsPoint ( cam - > GetCameraTargetPos ( ) , cam - > GetPriorityDirection ( ) , cam - > GetCameraSpeed ( ) ) ) {
CurrentCutscene - > AdvanceAction ( ) ;
}
} break ;
case ActionType : : PAN_CAMERA_ASYNC : {
AddAsyncCutsceneAction ( PanCameraAsync ) ;
} break ;
case ActionType : : MOVE_CUTSCENE_OBJ : {
if ( MoveObjectTowardsPoint ( CurrentCutscene - > GetCutsceneObjects ( ) [ ( ( MoveCutsceneObject * ) CurrentCutscene - > GetAction ( ) ) - > GetObjectID ( ) ] , ( ( MoveCutsceneObject * ) CurrentCutscene - > GetAction ( ) ) - > GetTargetPos ( ) , ( ( MoveCutsceneObject * ) CurrentCutscene - > GetAction ( ) ) - > GetMovement ( ) , ( ( MoveCutsceneObject * ) CurrentCutscene - > GetAction ( ) ) - > GetMoveSpd ( ) ) ) {
CurrentCutscene - > AdvanceAction ( ) ;
}
} break ;
case ActionType : : MOVE_CUTSCENE_OBJ_ASYNC : {
AddAsyncCutsceneAction ( MoveCutsceneObjectAsync ) ;
} break ;
case ActionType : : CREATE_OBJECTS : {
for ( auto & obj : ( ( CreateObjects * ) CurrentCutscene - > GetAction ( ) ) - > GetObjects ( ) ) {
obj - > temp = true ;
AddObjectToWorld ( CurrentCutscene - > AddCutsceneObject ( new Object ( obj - > id , obj - > name , obj - > GetPos ( ) , obj - > spr , obj - > GetScale ( ) , obj - > color , obj - > animationSpd , true ) ) ) ;
}
CurrentCutscene - > AdvanceAction ( ) ;
} break ;
case ActionType : : CLEANUP : {
if ( CUTSCENE_QUEUE . size ( ) = = 0 ) {
for ( int i = 0 ; i < OBJECTS . size ( ) ; i + + ) {
if ( OBJECTS [ i ] - > temp ) {
delete OBJECTS [ i ] ;
OBJECTS . erase ( OBJECTS . begin ( ) + i - - ) ;
} else {
OBJECTS [ i ] - > objArrElement = i ;
}
}
CurrentCutscene - > CleanupCutscene ( ) ;
CurrentCutscene - > ResetCutscene ( ) ;
SetGameFlag ( CurrentCutscene - > GetEndingCutsceneFlag ( ) , CurrentCutscene - > GetEndingCutsceneVal ( ) ) ;
CurrentCutscene = nullptr ;
CurrentAction = ActionType : : NONE ;
}
} break ;
case ActionType : : FADE : {
if ( ( ( Fade * ) CurrentCutscene - > GetAction ( ) ) - > FadeIn ( ) & & CUTSCENE_FADE_VALUE > 0 ) {
CUTSCENE_FADE_VALUE = std : : clamp ( CUTSCENE_FADE_VALUE - ( ( Fade * ) CurrentCutscene - > GetAction ( ) ) - > GetFadeSpd ( ) , 0.0 , 255.0 ) ;
if ( CUTSCENE_FADE_VALUE = = 0 ) {
CurrentCutscene - > AdvanceAction ( ) ;
}
} else
if ( ! ( ( Fade * ) CurrentCutscene - > GetAction ( ) ) - > FadeIn ( ) & & CUTSCENE_FADE_VALUE < 255 ) {
CUTSCENE_FADE_VALUE = std : : clamp ( CUTSCENE_FADE_VALUE + ( ( Fade * ) CurrentCutscene - > GetAction ( ) ) - > GetFadeSpd ( ) , 0.0 , 255.0 ) ;
if ( CUTSCENE_FADE_VALUE = = 255 ) {
CurrentCutscene - > AdvanceAction ( ) ;
}
}
} break ;
case ActionType : : FADE_ASYNC : {
AddAsyncCutsceneAction ( FadeAsync ) ;
} break ;
case ActionType : : DIALOG : {
if ( ! ( ( DialogBox * ) CurrentCutscene - > GetAction ( ) ) - > MessageHasBeenShown ( ) ) {
DisplayMessageBox ( ( ( DialogBox * ) CurrentCutscene - > GetAction ( ) ) - > GetMessage ( ) ) ;
( ( DialogBox * ) CurrentCutscene - > GetAction ( ) ) - > SetMessageBoxVisible ( ) ;
} else
if ( ! messageBoxVisible ) {
CurrentCutscene - > AdvanceAction ( ) ;
}
} break ;
case ActionType : : DIALOG_ASYNC : {
DisplayMessageBox ( ( ( DialogBox * ) CurrentCutscene - > GetAction ( ) ) - > GetMessage ( ) ) ;
CurrentCutscene - > AdvanceAction ( ) ;
} break ;
case ActionType : : MODIFY_OBJECT : {
ModifyObject * action = ( ModifyObject * ) CurrentCutscene - > GetAction ( ) ;
Object * obj = CurrentCutscene - > GetCutsceneObjects ( ) [ action - > GetCutsceneObjID ( ) ] ;
obj - > SetScale ( action - > GetObjScale ( ) ) ;
obj - > color = action - > GetObjCol ( ) ;
obj - > spr = action - > GetObjSpr ( ) ;
if ( action - > GetFrameIndex ( ) ! = - 1 ) {
obj - > frameIndex = action - > GetFrameIndex ( ) ;
}
obj - > animationSpd = action - > GetAnimationSpeed ( ) ;
CurrentCutscene - > AdvanceAction ( ) ;
} break ;
}
for ( int i = 0 ; i < CUTSCENE_QUEUE . size ( ) ; i + + ) {
switch ( CUTSCENE_QUEUE [ i ] - > GetActionType ( ) ) {
case ActionType : : PAN_CAMERA_ASYNC : {
PanCameraAsync * cam = ( PanCameraAsync * ) CUTSCENE_QUEUE [ i ] ;
if ( MoveCameraTowardsPoint ( cam - > GetCameraTargetPos ( ) , cam - > GetPriorityDirection ( ) , cam - > GetCameraSpeed ( ) ) ) {
CUTSCENE_QUEUE . erase ( CUTSCENE_QUEUE . begin ( ) + i - - ) ;
}
} break ;
case ActionType : : MOVE_CUTSCENE_OBJ_ASYNC : {
if ( MoveObjectTowardsPoint ( CurrentCutscene - > GetCutsceneObjects ( ) [ ( ( MoveCutsceneObjectAsync * ) CUTSCENE_QUEUE [ i ] ) - > GetObjectID ( ) ] , ( ( MoveCutsceneObjectAsync * ) CUTSCENE_QUEUE [ i ] ) - > GetTargetPos ( ) , ( ( MoveCutsceneObjectAsync * ) CUTSCENE_QUEUE [ i ] ) - > GetMovement ( ) , ( ( MoveCutsceneObjectAsync * ) CUTSCENE_QUEUE [ i ] ) - > GetMoveSpd ( ) ) ) {
CUTSCENE_QUEUE . erase ( CUTSCENE_QUEUE . begin ( ) + i - - ) ;
}
} break ;
case ActionType : : FADE_ASYNC : {
if ( ( ( FadeAsync * ) CUTSCENE_QUEUE [ i ] ) - > FadeIn ( ) & & CUTSCENE_FADE_VALUE > 0 ) {
CUTSCENE_FADE_VALUE = std : : clamp ( CUTSCENE_FADE_VALUE - ( ( FadeAsync * ) CUTSCENE_QUEUE [ i ] ) - > GetFadeSpd ( ) , 0.0 , 255.0 ) ;
if ( CUTSCENE_FADE_VALUE = = 0 ) {
CUTSCENE_QUEUE . erase ( CUTSCENE_QUEUE . begin ( ) + i - - ) ;
}
} else
if ( ! ( ( FadeAsync * ) CUTSCENE_QUEUE [ i ] ) - > FadeIn ( ) & & CUTSCENE_FADE_VALUE < 255 ) {
CUTSCENE_FADE_VALUE = std : : clamp ( CUTSCENE_FADE_VALUE + ( ( FadeAsync * ) CUTSCENE_QUEUE [ i ] ) - > GetFadeSpd ( ) , 0.0 , 255.0 ) ;
if ( CUTSCENE_FADE_VALUE = = 255 ) {
CUTSCENE_QUEUE . erase ( CUTSCENE_QUEUE . begin ( ) + i - - ) ;
}
}
} break ;
}
}
}
void SetupTargetSelect ( ) {
BATTLE_STATE = BattleState : : TARGET_SELECT ;
//Set Default Target.
if ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > friendly ) {
for ( int i = 0 ; i < PARTY_MEMBER_COUNT ; i + + ) {
if ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > GetHP ( ) > 0 | | getProperty ( Property : : REVIVE , PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove ) ) {
SELECTED_TARGET = - i - 1 ;
break ;
}
}
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > channelPos = PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - SELECTED_TARGET - 1 ] ] - > obj - > GetPosWithOrigin ( ) ;
} else {
for ( int i = 0 ; i < BATTLE_ENCOUNTER - > objs . size ( ) ; i + + ) {
if ( BATTLE_ENCOUNTER - > objs [ i ] - > GetHP ( ) > 0 ) {
SELECTED_TARGET = i ;
break ;
}
}
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > channelPos = BATTLE_ENCOUNTER - > objs [ SELECTED_TARGET ] - > obj - > GetPosWithOrigin ( ) ;
}
for ( auto & ent : GetEntitiesInRange ( SELECTED_TARGET , PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > channelPos , PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove ) ) {
ent - > obj - > highlighted = true ;
}
}
std : : vector < Entity * > GetEntitiesInRange ( int targetEnt , vd2d channelPos , Battle : : Move * move ) {
std : : vector < Entity * > ents ;
if ( targetEnt < 0 ) {
for ( int i = 0 ; i < PARTY_MEMBER_COUNT ; i + + ) {
//See if this target is also in range.
vi2d diff = ( vi2d ) PARTY_MEMBER_OBJ [ i ] - > GetPosWithOrigin ( ) / 32 - ( vi2d ) channelPos / 32 ;
if ( abs ( diff . x ) + abs ( diff . y ) < = move - > range - 1 ) {
ents . push_back ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] ) ;
}
}
} else {
for ( int i = 0 ; i < BATTLE_ENCOUNTER - > objs . size ( ) ; i + + ) {
//See if this target is also in range.
vi2d diff = ( vi2d ) BATTLE_ENCOUNTER - > objs [ i ] - > obj - > GetPosWithOrigin ( ) / 32 - ( vi2d ) channelPos / 32 ;
if ( abs ( diff . x ) + abs ( diff . y ) < = move - > range - 1 ) {
ents . push_back ( BATTLE_ENCOUNTER - > objs [ i ] ) ;
}
}
}
return ents ;
}
void DrawTargetRangeGrid ( vd2d pos , int range , Pixel outlinecol , Pixel box1col , Pixel box2col , bool connectedborder ) {
vi2d gridCenter = ( vi2d ) pos / 32 * 32 ;
for ( int x = - range + 1 ; x < range ; x + + ) {
for ( int y = - range + 1 ; y < range ; y + + ) {
int dist = abs ( x ) + abs ( y ) ;
if ( dist < range ) {
vi2d offset = { x , y } ;
//FillRectDecal(gridCenter-cameraPos+offset*32,{32,32},Pixel(255,255,0,128));
GradientFillRectDecal ( gridCenter - cameraPos + offset * 32 , { 32 , 32 } , box1col , box2col , box1col , box2col ) ;
const vi2d outlineOffset = { 1 , 1 } ;
if ( ! connectedborder ) {
DrawRectDecal ( gridCenter - cameraPos + offset * 32 , { 32 , 32 } , outlinecol ) ;
DrawRectDecal ( gridCenter - cameraPos + offset * 32 + outlineOffset , { 30 , 30 } , outlinecol ) ;
} else {
vd2d pos = gridCenter - cameraPos + offset * 32 ;
vd2d pos2 = gridCenter - cameraPos + offset * 32 + outlineOffset ;
vd2d size = { 32 , 32 } ;
vd2d size2 = { 30 , 30 } ;
if ( abs ( x ) + abs ( y - 1 ) > = range ) {
DrawLineDecal ( pos , { pos . x + size . x , pos . y } , outlinecol ) ; //Top
DrawLineDecal ( pos2 , { pos2 . x + size2 . x , pos2 . y } , outlinecol ) ; //Top
}
if ( abs ( x - 1 ) + abs ( y ) > = range ) {
DrawLineDecal ( { pos . x , pos . y } , { pos . x , pos . y + size . y } , outlinecol ) ; //Left
DrawLineDecal ( { pos2 . x , pos2 . y } , { pos2 . x , pos2 . y + size2 . y } , outlinecol ) ; //Left
}
if ( abs ( x ) + abs ( y + 1 ) > = range ) {
DrawLineDecal ( { pos . x , pos . y + size . y } , { pos . x + size . x , pos . y + size . y } , outlinecol ) ; //Bottom
DrawLineDecal ( { pos2 . x , pos2 . y + size2 . y } , { pos2 . x + size2 . x , pos2 . y + size2 . y } , outlinecol ) ; //Bottom
}
if ( abs ( x + 1 ) + abs ( y ) > = range ) {
DrawLineDecal ( { pos . x + size . x , pos . y } , { pos . x + size . x , pos . y + size . y } , outlinecol ) ; //Right
DrawLineDecal ( { pos2 . x + size2 . x , pos2 . y } , { pos2 . x + size2 . x , pos2 . y + size2 . y } , outlinecol ) ; //Right
}
}
}
}
}
}
void DrawTargetRangeGrid ( vd2d pos , int range ) {
DrawTargetRangeGrid ( pos , range , Pixel ( abs ( cos ( M_PI / 240 * frameCount ) * 128 ) , 200 , 0 , 255 ) , Pixel ( 0 , 161 , 255 , abs ( sin ( M_PI / 240 * frameCount ) * 32 ) ) , Pixel ( 139 , 234 , 255 , abs ( sin ( M_PI / 240 * frameCount ) * 64 ) ) , false ) ;
}
void DrawMovementGrid ( Pixel outlinecol , Pixel box1col , Pixel box2col ) {
for ( std : : map < std : : pair < int , int > , vd2d > : : const_iterator it = MOVEMENT_GRID . cbegin ( ) ; it ! = MOVEMENT_GRID . cend ( ) ; + + it ) {
if ( it - > second ! = NO_NEIGHBOR ) {
GradientFillRectDecal ( MOVEMENT_GRID [ it - > first ] , { 32 , 32 } , box1col , box2col , box1col , box2col ) ;
const vi2d outlineOffset = { 1 , 1 } ;
DrawRectDecal ( MOVEMENT_GRID [ it - > first ] , { 32 , 32 } , outlinecol ) ;
DrawRectDecal ( MOVEMENT_GRID [ it - > first ] + outlineOffset , { 30 , 30 } , outlinecol ) ;
}
}
}
void CheckGrid ( int x , int y , vd2d pos , int lifetime ) {
if ( pos . x < 0 | | pos . x > = WIDTH | | pos . y < 0 | | pos . y > = HEIGHT - 64 ) {
return ;
}
for ( int xx = 0 ; xx < 32 ; xx + + ) {
for ( int yy = 0 ; yy < 32 ; yy + + ) {
vi2d offset = { xx , yy } ;
if ( Collision ( pos + offset ) ) {
std : : cout < < x < < " , " < < y < < " \n " ;
return ;
}
}
}
bool nonSolid = false ; //Ran into a non-solid instance, which means we can't mark the tile, but we can continue moving through.
for ( int i = 0 ; i < PARTY_MEMBER_COUNT ; i + + ) {
if ( CURRENT_TURN ! = - i - 1 & & pos = = ( vi2d ) ( PARTY_MEMBER_OBJ [ i ] - > GetPosWithOrigin ( ) - cameraPos ) / 32 * 32 ) {
nonSolid = true ;
break ;
}
}
if ( ! nonSolid ) {
for ( int i = 0 ; i < BATTLE_ENCOUNTER - > objs . size ( ) ; i + + ) {
if ( pos = = ( vi2d ) ( BATTLE_ENCOUNTER - > objs [ i ] - > obj - > GetPosWithOrigin ( ) - cameraPos ) / 32 * 32 ) {
nonSolid = true ;
break ;
}
}
}
if ( ! nonSolid ) {
MOVEMENT_GRID [ { x , y } ] = pos ;
}
if ( lifetime > 0 ) {
vi2d offsetLeft = { - 32 , 0 } ;
CheckGrid ( x - 1 , y , pos + offsetLeft , lifetime - 1 ) ;
vi2d offsetRight = { 32 , 0 } ;
CheckGrid ( x + 1 , y , pos + offsetRight , lifetime - 1 ) ;
vi2d offsetUp = { 0 , - 32 } ;
CheckGrid ( x , y - 1 , pos + offsetUp , lifetime - 1 ) ;
vi2d offsetDown = { 0 , 32 } ;
CheckGrid ( x , y + 1 , pos + offsetDown , lifetime - 1 ) ;
}
}
void PopulateMovementGrid ( vd2d pos , int range ) {
vi2d gridCenter = ( vi2d ) pos / 32 * 32 ;
MOVEMENT_GRID . clear ( ) ;
CheckGrid ( 0 , 0 , gridCenter - cameraPos , range ) ;
}
vi2d grid ( int x , int y ) {
return { x * 32 , y * 32 } ;
}
void StartEffect ( Effect * eff ) {
CURRENT_EFFECT = eff ;
eff - > create ( PARTICLES ) ;
}
int getMemberIDComparingObject ( Object * obj ) {
int memberID = 0 ;
for ( int i = 0 ; i < PARTY_MEMBER_COUNT ; i + + ) {
if ( obj = = PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > obj ) {
memberID = i ;
break ;
}
}
return memberID ;
}
bool Collision ( vd2d pos ) {
SetDrawTarget ( layer : : COLLISION ) ;
Pixel collisionData = GAME - > GetDrawTarget ( ) - > GetPixel ( ( int ) pos . x , ( int ) pos . y ) ;
return collisionData ! = MAGENTA ;
}
void DrawArrow ( ) {
vi2d startingPos = { 0 , 0 } ;
vi2d drawingPos = { ( vi2d ) ( PARTY_MEMBER_OBJ [ - CURRENT_TURN - 1 ] - > GetPosWithOrigin ( ) - cameraPos ) / 32 } ;
vi2d center = { 16 , 16 } ;
bool lastMoveWasX = false ; //When set to true, the previous move was in the X axis. This is used for the elbow connector.
bool flippedX = ( SELECTED_MOVE_SQUARE . x > startingPos . x ) ;
bool flippedY = ( SELECTED_MOVE_SQUARE . y < startingPos . y ) ;
std : : cout < < startingPos < < " // " < < SELECTED_MOVE_SQUARE < < " \n " ;
while ( startingPos ! = SELECTED_MOVE_SQUARE ) {
if ( startingPos . x ! = SELECTED_MOVE_SQUARE . x ) {
DrawPartialRotatedDecal ( ( drawingPos + startingPos ) * 32 + center , SPRITES [ " arrow_connector.png " ] , M_PI_2 , { 16 , 16 } , { 0 , 0 } , { 32 , 32 } ) ;
startingPos . x + = SELECTED_MOVE_SQUARE . x > startingPos . x ? 1 : - 1 ;
lastMoveWasX = true ;
continue ;
}
if ( startingPos . y ! = SELECTED_MOVE_SQUARE . y ) {
if ( lastMoveWasX ) {
//Elbow Connector
if ( SELECTED_MOVE_SQUARE . y > startingPos . y ) {
DrawPartialRotatedDecal ( ( drawingPos + startingPos ) * 32 + center , SPRITES [ " arrow_connector.png " ] , ( flippedX ) ? M_PI : M_PI_2 , { 16 , 16 } , { 32 , 0 } , { 32 , 32 } ) ;
} else {
DrawPartialRotatedDecal ( ( drawingPos + startingPos ) * 32 + center , SPRITES [ " arrow_connector.png " ] , ( flippedX ) ? M_PI_2 * 3 : 0 , { 16 , 16 } , { 32 , 0 } , { 32 , 32 } ) ;
}
lastMoveWasX = false ;
} else {
//Straight Connector.
DrawPartialRotatedDecal ( ( drawingPos + startingPos ) * 32 + center , SPRITES [ " arrow_connector.png " ] , 0 , { 16 , 16 } , { 0 , 0 } , { 32 , 32 } ) ;
}
startingPos . y + = SELECTED_MOVE_SQUARE . y > startingPos . y ? 1 : - 1 ;
continue ;
}
}
if ( SELECTED_MOVE_SQUARE . x ! = 0 | | SELECTED_MOVE_SQUARE . y ! = 0 ) {
if ( SELECTED_MOVE_SQUARE . y = = 0 ) {
DrawPartialRotatedDecal ( ( SELECTED_MOVE_SQUARE + drawingPos ) * 32 + center , SPRITES [ " arrow_connector.png " ] , ( flippedX ) ? M_PI_2 * 3 : M_PI_2 , { 16 , 16 } , { 64 , 0 } , { 32 , 32 } ) ;
} else {
DrawPartialRotatedDecal ( ( SELECTED_MOVE_SQUARE + drawingPos ) * 32 + center , SPRITES [ " arrow_connector.png " ] , ( flippedY ) ? M_PI : 0 , { 16 , 16 } , { 64 , 0 } , { 32 , 32 } ) ;
}
}
}
} ;
int main ( )
{
SeasonI demo ;
if ( demo . Construct ( WIDTH , HEIGHT , 4 , 4 ) )
demo . Start ( ) ;
return 0 ;
}