@ -1,3 +1,4 @@
# include "item.h"
# define OLC_PGE_APPLICATION
# define OLC_PGE_APPLICATION
# include "pixelGameEngine.h"
# include "pixelGameEngine.h"
# define OLC_PGEX_SPLASHSCREEN
# define OLC_PGEX_SPLASHSCREEN
@ -22,6 +23,7 @@ const vd2d NO_NEIGHBOR = {-999,-999};
vd2d cameraPos = { 0 , 0 } ;
vd2d cameraPos = { 0 , 0 } ;
PixelGameEngine * GAME ;
PixelGameEngine * GAME ;
std : : vector < Item * > PARTY_INVENTORY ;
enum {
enum {
ALPHA = α ,
ALPHA = α ,
@ -158,6 +160,7 @@ public:
int player_rollhp_display [ 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_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 player_rollwait_counter [ 4 ] = { 0 , 0 , 0 , 0 } ;
int previousEquip [ 4 ] = { - 1 , - 1 , - 1 , - 1 } ;
int SELECTED_TARGET = 0 ; //Battle target that is selected.
int SELECTED_TARGET = 0 ; //Battle target that is selected.
int BATTLE_TARGET = - 99 ; //Negative numbers for players and positive numbers for enemy targets.
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 CURRENT_TURN = - 99 ; //Who's turn we are enacting.
@ -170,7 +173,6 @@ public:
bool ANYKEYPRESSED = false ;
bool ANYKEYPRESSED = false ;
bool ACTIONKEYPRESSED = false ;
bool ACTIONKEYPRESSED = false ;
std : : vector < std : : vector < Battle : : Move * > > BATTLE_MOVELIST_DISPLAY ;
std : : vector < std : : vector < Battle : : Move * > > BATTLE_MOVELIST_DISPLAY ;
std : : vector < Item * > PARTY_INVENTORY ;
std : : map < int , int > ADDITIONAL_FONT_VALS = {
std : : map < int , int > ADDITIONAL_FONT_VALS = {
{ α , 0 } , { β , 1 } , { γ , 2 } , { Ω , 3 } , { Σ , 4 } ,
{ α , 0 } , { β , 1 } , { γ , 2 } , { Ω , 3 } , { Σ , 4 } ,
} ;
} ;
@ -178,6 +180,7 @@ public:
int BATTLE_ANIMATION_TIMER = 0 ;
int BATTLE_ANIMATION_TIMER = 0 ;
int BATTLE_ROLLING_COUNTER_WAITTIME = 0 ; //Number of frames to wait for each rolling counter.
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.
int BATTLE_HIT_SCREENSHAKE = 0 ; //Amount of time the screen will rapidly shake as getting hit.
bool ITEM_REQUIRES_EQUIPPING = false ;
bool MOUSE_PRESSED_DOWN = false , MOUSE_DOWN = false , MOUSE_RELEASED = false ; //TODO Implement Mouse things.
bool MOUSE_PRESSED_DOWN = false , MOUSE_DOWN = false , MOUSE_RELEASED = false ; //TODO Implement Mouse things.
@ -686,7 +689,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
} break ;
} break ;
case 2 : { //Items selected.
case 2 : { //Items selected.
BATTLE_STATE = BattleState : : ITEM_SELECT ;
BATTLE_STATE = BattleState : : ITEM_SELECT ;
ITEM_SELECTION_CURSOR = 0 ;
//ITEM_SELECTION_CURSOR=0;
} break ;
} break ;
case 3 : { //Defend selected.
case 3 : { //Defend selected.
//DisplayMessageBox("Not implemented yet.");
//DisplayMessageBox("Not implemented yet.");
@ -844,6 +847,9 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
if ( UpPressed ( ) ) {
if ( UpPressed ( ) ) {
if ( BATTLE_SELECTION_CURSOR = = 0 ) { //Power was selected, so go back to the powers menu.
if ( BATTLE_SELECTION_CURSOR = = 0 ) { //Power was selected, so go back to the powers menu.
BATTLE_STATE = BattleState : : GRADE_SELECT ;
BATTLE_STATE = BattleState : : GRADE_SELECT ;
} else
if ( BATTLE_SELECTION_CURSOR = = 2 ) { //Item was selected, go back to item menu.
BATTLE_STATE = BattleState : : ITEM_SELECT ;
} else { //This was a standard attack, go back to main menu.
} else { //This was a standard attack, go back to main menu.
BATTLE_STATE = BattleState : : SELECT_ACTION ;
BATTLE_STATE = BattleState : : SELECT_ACTION ;
}
}
@ -854,6 +860,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
BATTLE_ENCOUNTER - > objs [ i ] - > obj - > highlighted = false ;
BATTLE_ENCOUNTER - > objs [ i ] - > obj - > highlighted = false ;
}
}
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove = nullptr ;
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove = nullptr ;
ITEM_REQUIRES_EQUIPPING = false ;
}
}
if ( ACTIONKEYPRESSED ) {
if ( ACTIONKEYPRESSED ) {
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedTarget = SELECTED_TARGET ;
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedTarget = SELECTED_TARGET ;
@ -965,7 +972,12 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
if ( LeftPressed ( ) & & ! ( ITEM_SELECTION_CURSOR & 1 ) ) {
if ( LeftPressed ( ) & & ! ( ITEM_SELECTION_CURSOR & 1 ) ) {
BATTLE_STATE = BattleState : : SELECT_ACTION ;
BATTLE_STATE = BattleState : : SELECT_ACTION ;
} else {
} else {
HandleInventoryMenu ( ) ;
HandleInventoryNavigation ( ) ;
}
if ( ACTIONKEYPRESSED ) {
ITEM_REQUIRES_EQUIPPING = true ;
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove = MOVELIST [ BattleMoveName : : BASH ] ;
BATTLE_STATE = BattleState : : TARGET_SELECT ;
}
}
} break ;
} break ;
}
}
@ -2800,6 +2812,12 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove = nullptr ;
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove = nullptr ;
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > atb = 0 ;
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > atb = 0 ;
BATTLE_STATE = BattleState : : WAIT ;
BATTLE_STATE = BattleState : : WAIT ;
if ( previousEquip [ - CURRENT_TURN - 1 ] ! = - 1 ) {
Item * PrevEquip = PARTY_INVENTORY [ previousEquip [ - CURRENT_TURN - 1 ] ] ;
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > EquipItem ( previousEquip [ - CURRENT_TURN - 1 ] ) ;
printf ( " Equipped item: %s \n " , PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > equipment [ PrevEquip - > stats . equip ] - > name . c_str ( ) ) ;
previousEquip [ - CURRENT_TURN - 1 ] = - 1 ;
}
CURRENT_TURN = - 99 ;
CURRENT_TURN = - 99 ;
} else {
} else {
BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove = nullptr ;
BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove = nullptr ;
@ -3193,6 +3211,21 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
BATTLE_ENCOUNTER - > objs [ i ] - > obj - > highlighted = false ;
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 ;
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > channelTimeRemaining = PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > channelTime ;
if ( ITEM_REQUIRES_EQUIPPING ) {
Item * SelectedItem = PARTY_INVENTORY [ ITEM_SELECTION_CURSOR ] ;
if ( SelectedItem - > stats . equip = = EquipSlot : : WEAPON & & PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > equipment [ SelectedItem - > stats . equip ] ! = nullptr ) { //Only swap back to the previous equip when there was nothing equipped to begin with.
previousEquip [ - CURRENT_TURN - 1 ] = ITEM_SELECTION_CURSOR ;
}
int prevPartyInvenSize = PARTY_INVENTORY . size ( ) ;
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > EquipItem ( ITEM_SELECTION_CURSOR ) ;
printf ( " Equipped item: %s \n " , PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > equipment [ SelectedItem - > stats . equip ] - > name . c_str ( ) ) ;
ITEM_REQUIRES_EQUIPPING = false ;
ITEM_SELECTION_CURSOR = std : : clamp ( ITEM_SELECTION_CURSOR , 0 , ( int ) PARTY_INVENTORY . size ( ) - 1 ) ;
if ( prevPartyInvenSize & 1 & & PARTY_INVENTORY . size ( ) = = prevPartyInvenSize - 1 ) {
ITEM_SELECTION_OFFSET - = 2 ;
}
}
}
}
int CalculateDamage ( Entity * attacker , Entity * defender ) {
int CalculateDamage ( Entity * attacker , Entity * defender ) {
@ -3213,7 +3246,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
void RemoveItemFromPlayerInventory ( int slot ) {
void RemoveItemFromPlayerInventory ( int slot ) {
PARTY_INVENTORY . erase ( PARTY_INVENTORY . begin ( ) + slot ) ;
PARTY_INVENTORY . erase ( PARTY_INVENTORY . begin ( ) + slot ) ;
}
}
void HandleInventoryMenu ( ) {
void HandleInventoryNavigation ( ) {
if ( LeftPressed ( ) | | RightPressed ( ) ) {
if ( LeftPressed ( ) | | RightPressed ( ) ) {
ITEM_SELECTION_CURSOR + = ITEM_SELECTION_CURSOR & 1 ? - 1 : 1 ;
ITEM_SELECTION_CURSOR + = ITEM_SELECTION_CURSOR & 1 ? - 1 : 1 ;
if ( ITEM_SELECTION_CURSOR > = PARTY_INVENTORY . size ( ) ) {
if ( ITEM_SELECTION_CURSOR > = PARTY_INVENTORY . size ( ) ) {
@ -3361,7 +3394,6 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
}
}
} ;
} ;
int main ( )
int main ( )
{
{
SeasonI demo ;
SeasonI demo ;