@ -100,6 +100,7 @@ class Object{
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 Collision ( vd2d pos ) {
GAME - > SetDrawTarget ( layer : : COLLISION ) ;
@ -340,9 +341,7 @@ namespace Battle{
Move ( std : : string name , std : : string desc , int baseDmg , int randomDmg , int PPCost , int range , int channelTime , bool friendly , std : : array < int , 4 > composition , bool pctDamage = false , std : : vector < std : : pair < Property , int > > properties = { } )
: Move ( name , desc , 0 , baseDmg , randomDmg , PPCost , range , channelTime , friendly , composition , 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 , 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 ) , channelTime ( channelTime ) , composition ( composition ) , pctDamage ( pctDamage ) , properties ( properties ) {
this - > channelTime = 300 ;
}
: name ( name ) , grade ( grade ) , PPCost ( PPCost ) , desc ( desc ) , randomDmg ( randomDmg ) , baseDmg ( baseDmg ) , range ( range ) , friendly ( friendly ) , channelTime ( channelTime ) , composition ( composition ) , pctDamage ( pctDamage ) , properties ( properties ) { }
} ;
}
@ -397,7 +396,7 @@ class Entity{
}
//Adds to the rolling counter target from this health value.
void AddHP ( int hp ) {
targetHP = std : : clamp ( HP + hp , 0 , maxHP ) ;
targetHP = std : : clamp ( target HP+ 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 ) {
@ -521,6 +520,7 @@ public:
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.
@ -955,15 +955,19 @@ goes on a very long time, I hope you can understand this is only for testing pur
} 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.
BATTLE_STATE = BattleState : : ITEM_SELECT ;
DisplayMessageBox ( " Not implemented yet. " ) ;
//BATTLE_STATE=BattleState::ITEM_SELECT;
} break ;
case 3 : { //Defend selected.
DisplayMessageBox ( " Not implemented yet. " ) ;
} break ;
case 4 : { //Move selected.
BATTLE_STATE = BattleState : : MOVE_SELECT ;
DisplayMessageBox ( " Not implemented yet. " ) ;
//BATTLE_STATE=BattleState::MOVE_SELECT;
} break ;
case 5 : { //Run selected.
DisplayMessageBox ( " Not implemented yet. " ) ;
@ -1044,35 +1048,20 @@ goes on a very long time, I hope you can understand this is only for testing pur
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 ) {
BATTLE_STATE = BattleState : : TARGET_SELECT ;
//Set Default Target.
if ( BATTLE_MOVELIST_DISPLAY [ POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] ] [ POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] ] - > friendly ) {
for ( int i = 0 ; i < PARTY_MEMBER_COUNT ; i + + ) {
if ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] - > GetHP ( ) > 0 | | getProperty ( Property : : REVIVE , BATTLE_MOVELIST_DISPLAY [ POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] ] [ POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] ] ) ) {
SELECTED_TARGET = - i - 1 ;
break ;
}
}
} 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 ] ] - > 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 ( BATTLE_MOVELIST_DISPLAY [ POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] ] [ POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] ] - > friendly ) {
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 , BATTLE_MOVELIST_DISPLAY [ POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] ] [ POWER_GRADE_CURSOR [ - CURRENT_TURN - 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 ) ) ;
} else {
do {
SELECTED_TARGET - - ;
@ -1083,13 +1072,13 @@ goes on a very long time, I hope you can understand this is only for testing pur
}
}
if ( RightPressed ( ) ) {
if ( BATTLE_MOVELIST_DISPLAY [ POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] ] [ POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] ] - > friendly ) {
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 , BATTLE_MOVELIST_DISPLAY [ POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] ] [ POWER_GRADE_CURSOR [ - CURRENT_TURN - 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 ) ) ;
} else {
do {
SELECTED_TARGET = ( SELECTED_TARGET + 1 ) % BATTLE_ENCOUNTER - > objs . size ( ) ;
@ -1105,8 +1094,10 @@ goes on a very long time, I hope you can understand this is only for testing pur
}
if ( ACTIONKEYPRESSED ) {
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedTarget = SELECTED_TARGET ;
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > channelTimeRemaining = BATTLE_MOVELIST_DISPLAY [ POWER_SELECTION_CURSOR [ - CURRENT_TURN - 1 ] ] [ POWER_GRADE_CURSOR [ - CURRENT_TURN - 1 ] ] - > channelTime ;
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 ] ] ;
}
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 ;
@ -1175,6 +1166,15 @@ goes on a very long time, I hope you can understand this is only for testing pur
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
@ -1195,15 +1195,6 @@ goes on a very long time, I hope you can understand this is only for testing pur
}
}
} else
if ( EDITING_LAYER = = layer : : ENCOUNTER & & GetMouse ( 2 ) . 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 : : OBJECT & & GetMouse ( 0 ) . bPressed ) {
AddObjectToWorld ( CreateObject ( SELECTED_OBJ_ID , HIGHLIGHTED_TILE * 32 ) ) ;
} else
@ -1402,12 +1393,12 @@ goes on a very long time, I hope you can understand this is only for testing pur
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 + 4 + i * 8 , 12 * counter + 8 + displayYOffset } , std : : wstring ( 1 , moves [ i ] - > grade ) ) ;
DrawFancyStringDecal ( { 8 + WIDTH / 4 + 12 + i * 8 , 12 * counter + 8 + displayYOffset } , std : : wstring ( 1 , moves [ i ] - > grade ) ) ;
} else {
DrawFancyStringDecal ( { 8 + WIDTH / 4 + 4 + i * 8 , 12 * counter + 8 + displayYOffset } , std : : wstring ( 1 , moves [ i ] - > grade ) , DARK_GREY ) ;
DrawFancyStringDecal ( { 8 + WIDTH / 4 + 12 + i * 8 , 12 * counter + 8 + displayYOffset } , std : : wstring ( 1 , moves [ i ] - > grade ) , DARK_GREY ) ;
}
} else {
DrawFancyStringDecal ( { 8 + WIDTH / 4 + 4 + i * 8 , 12 * counter + 8 + displayYOffset } , std : : wstring ( 1 , moves [ i ] - > grade ) ) ;
DrawFancyStringDecal ( { 8 + WIDTH / 4 + 12 + i * 8 , 12 * counter + 8 + displayYOffset } , std : : wstring ( 1 , moves [ i ] - > grade ) ) ;
}
}
}
@ -1449,35 +1440,50 @@ goes on a very long time, I hope you can understand this is only for testing pur
}
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 ;
for ( int i = 0 ; i < PARTY_MEMBER_COUNT ; i + + ) {
Entity * member = PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ i ] ] ;
Object * obj = PARTY_MEMBER_OBJ [ i ] ;
olc : : vi2d box = { ( 128 - 32 * PARTY_MEMBER_COUNT ) + i * 64 , 160 } ;
vi2d box = { ( 128 - 32 * PARTY_MEMBER_COUNT ) + i * 64 , 160 } ;
box + = screenShakeOffset ;
if ( CURRENT_TURN = = - i - 1 ) {
box . y - = 20 ;
}
drawCheckerboardBox ( box , { 59 , 59 } , olc : : Pixel ( 180 , 159 , 194 ) , olc : : Pixel ( 200 , 179 , 214 ) , { 6 , 6 } ) ;
if ( CURRENT_TURN > = 0 & & BATTLE_STATE = = BattleState : : WAIT_ANIMATION & & BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedTarget = = - i - 1 ) {
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 , olc : : BLACK ) ;
DrawStringDecal ( { ( float ) ( box . x + 6 ) , ( float ) ( box . y + 6 ) } , obj - > name , BLACK ) ;
} else {
DrawStringDecal ( { ( float ) ( box . x + 6 ) , ( float ) ( box . y + 4 ) } , obj - > name , olc : : BLACK , { 1 , 0.8 } ) ;
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 ) ;
if ( member - > selectedMove - > grade ! = 0 ) {
label + = L " " ;
if ( member - > selectedMove - > grade ! = 0 ) {
label + = member - > selectedMove - > grade ;
}
vd2d textOffset = GetTextSize ( to_string ( label ) ) * 0.6 ;
textOffset . y + = 10 ;
textOffset . x + = 5 ;
vd2d barPos = { ( float ) ( box . x + 4 ) , ( float ) ( box . y + 5 + 8 + 2 ) } ;
DrawFancyStringDecal ( barPos - textOffset / 2 , label , BLACK , { ( float ) 54 / GetTextSize ( to_string ( label ) ) . x , 0.6 } ) ;
DrawFancyStringDecal ( barPos - textOffset / 2 , label , BLACK , { std : : min ( ( float ) 54 / GetTextSize ( to_string ( label ) ) . x , ( float ) 1 ) , 0.6 } ) ;
}
const olc : : vi2d hpTextPos = { box . x + 5 , box . y + 25 } ;
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 ) {
@ -1485,9 +1491,9 @@ goes on a very long time, I hope you can understand this is only for testing pur
}
}
}
DrawStringDecal ( hpTextPos , " HP " , olc : : BLACK ) ;
DrawStringDecal ( hpTextPos , " HP " , BLACK ) ;
DrawRollingCounter ( hpTextPos , member - > GetHP ( ) , player_rollhp_display [ i ] , player_rollhp_counter [ i ] ) ;
const olc : : vi2d mpTextPos = { box . x + 5 , hpTextPos . y + 17 } ;
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 ) {
@ -1495,7 +1501,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
}
}
}
DrawStringDecal ( mpTextPos , " PP " , olc : : BLACK ) ;
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 + + ) {
@ -1533,10 +1539,15 @@ goes on a very long time, I hope you can understand this is only for testing pur
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 ) {
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 ) {
@ -1569,17 +1580,17 @@ goes on a very long time, I hope you can understand this is only for testing pur
vf2d newpos = pos ;
for ( int i = 0 ; i < sText . length ( ) ; i + + ) {
if ( sText [ i ] > = 128 ) {
newpos . x + = 8 * scale . x ;
DrawPartialDecal ( newpos , SPRITES [ " additionalFont.png " ] , additionalChars [ sText [ i ] ] , { 8 , 8 } , scale , col ) ;
newpos . x + = 8 * scale . x ;
} else
if ( sText [ i ] ! = ' \n ' ) {
newpos . x + = 8 * scale . x ;
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 ;
DrawStringDecal ( newpos , std : : string ( 1 , sText [ i ] ) , col , scale ) ;
}
}
}
@ -2152,6 +2163,31 @@ goes on a very long time, I hope you can understand this is only for testing pur
MOVELIST [ BattleMoveName : : TESTMOVE3 ] ,
} ) ,
} ) ) ; //ENCOUNTER_3
ENCOUNTER_LIST . push_back ( new Encounter ( encounter : : ENCOUNTER_4 , { 0 , 0 } , std : : array < vd2d , 4 > { vd2d
{ 10 , 24 } , { 30 , 24 } , { 50 , 24 } , { 70 , 24 } } ,
std : : vector < Entity * > {
new Entity ( new Object (
NPC1_4 , " Test Obj " , { 170 , 48 } , 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 " , { 200 , 48 } , 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 " , { 100 , 160 } , 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 ) {
@ -2489,7 +2525,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
return newStr ;
}
//Returns -1 if not found.
//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 ] ;
@ -2497,7 +2533,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
return p . second ;
}
}
return - 1 ;
return 0 ;
}
void HandleBattle ( ) {
@ -2767,11 +2803,17 @@ goes on a very long time, I hope you can understand this is only for testing pur
( ( 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 ;
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 < < " dealing " < < dmgAmt < < " health. \n " ;
BATTLE_ENCOUNTER - > objs [ PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedTarget ] - > _SetDirectHP (
BATTLE_ENCOUNTER - > objs [ PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedTarget ] - > GetHP ( ) - dmgAmt
) ; //Enemies have their health directly set.
if ( BATTLE_ENCOUNTER - > objs [ PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedTarget ] - > GetHP ( ) < = 0 ) {
BATTLE_ENCOUNTER - > objs [ PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedTarget ] - > obj - > dead = true ;
//Enemies have their health directly set.
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 - > GetPos ( ) / 32 - ( vi2d ) BATTLE_ENCOUNTER - > objs [ PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedTarget ] - > obj - > GetPos ( ) / 32 ;
if ( abs ( diff . x ) + abs ( diff . y ) < = PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove - > range ) {
BATTLE_ENCOUNTER - > objs [ i ] - > _SetDirectHP ( BATTLE_ENCOUNTER - > objs [ i ] - > GetHP ( ) - dmgAmt ) ;
BATTLE_ENCOUNTER - > objs [ i ] - > obj - > blinkFrames = 35 ;
if ( BATTLE_ENCOUNTER - > objs [ i ] - > GetHP ( ) < = 0 ) {
BATTLE_ENCOUNTER - > objs [ i ] - > obj - > dead = true ;
}
}
}
} 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 " ;
@ -2795,6 +2837,11 @@ goes on a very long time, I hope you can understand this is only for testing pur
+ BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > baseAtk ;
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 < < " dealing " < < dmgAmt < < " health. \n " ;
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedTarget - 1 ] ] - > SubtractHP ( dmgAmt ) ;
if ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedTarget - 1 ] ] - > GetTargetHP ( ) < 0 ) {
BATTLE_HIT_SCREENSHAKE = 75 ;
} else {
BATTLE_HIT_SCREENSHAKE = 25 ;
}
} 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 " ;
}
@ -2970,6 +3017,26 @@ goes on a very long time, I hope you can understand this is only for testing pur
}
}
}
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 ;
}
}
} else {
for ( int i = 0 ; i < BATTLE_ENCOUNTER - > objs . size ( ) ; i + + ) {
if ( BATTLE_ENCOUNTER - > objs [ i ] - > GetHP ( ) > 0 ) {
SELECTED_TARGET = i ;
break ;
}
}
}
}
} ;