@ -273,6 +273,7 @@ enum class BattleMoveName{
TESTMOVE2 ,
TESTMOVE3 ,
BASH ,
DEFEND ,
HAILSTORM_A ,
HAILSTORM_B ,
HAILSTORM_G ,
@ -343,9 +344,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 , 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 ;
}
: 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 ) { }
} ;
}
@ -1041,7 +1040,10 @@ goes on a very long time, I hope you can understand this is only for testing pur
//BATTLE_STATE=BattleState::ITEM_SELECT;
} break ;
case 3 : { //Defend selected.
DisplayMessageBox ( " Not implemented yet. " ) ;
//DisplayMessageBox("Not implemented yet.");
PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove = MOVELIST [ BattleMoveName : : DEFEND ] ;
ConfirmPlayerTargetSelection ( ) ;
BATTLE_STATE = BattleState : : WAIT ;
} break ;
case 4 : { //Move selected.
//DisplayMessageBox("Not implemented yet.");
@ -1202,16 +1204,7 @@ 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 ;
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 ;
ConfirmPlayerTargetSelection ( ) ;
BATTLE_STATE = BattleState : : WAIT ;
}
} break ;
@ -2191,6 +2184,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
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 : : DEFEND ] = new Battle : : Move ( " Defend " , " Defend. " , 0 , 0 , ㅍ 0 , 1 , 5 * 60 , true , { 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 } ) ;
@ -3081,6 +3075,15 @@ goes on a very long time, I hope you can understand this is only for testing pur
case BattleState : : WAIT_ANIMATION : {
BATTLE_ROLLING_COUNTER_WAITTIME = 5 ;
BATTLE_ANIMATION_TIMER + + ;
if ( CURRENT_TURN < 0 ) {
if ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] - > selectedMove = = MOVELIST [ BattleMoveName : : DEFEND ] ) {
BATTLE_ANIMATION_TIMER = 999 ;
}
} else {
if ( BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] - > selectedMove = = MOVELIST [ BattleMoveName : : DEFEND ] ) {
BATTLE_ANIMATION_TIMER = 999 ;
}
}
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 ) {
@ -3110,9 +3113,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
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 ;
int dmgAmt = CalculateDamage ( PARTY_MEMBER_STATS [ PARTY_MEMBER_ID [ - CURRENT_TURN - 1 ] ] , ent ) ;
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 ) ;
@ -3146,9 +3147,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
} 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 ;
int dmgAmt = CalculateDamage ( BATTLE_ENCOUNTER - > objs [ CURRENT_TURN ] , ent ) ;
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 ) ;
@ -3557,6 +3556,29 @@ goes on a very long time, I hope you can understand this is only for testing pur
}
}
}
//Can run this after target selection to reset states.
void ConfirmPlayerTargetSelection ( ) {
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 ;
}
int CalculateDamage ( Entity * attacker , Entity * defender ) {
int finalDamage = 0 ;
int attackerDamage = ( attacker - > selectedMove - > baseDmg +
( ( rand ( ) % attacker - > selectedMove - > randomDmg > 0 ) ? rand ( ) % attacker - > selectedMove - > randomDmg : 0 )
+ attacker - > baseAtk ) ;
finalDamage + = attackerDamage ;
if ( defender - > selectedMove = = MOVELIST [ BattleMoveName : : DEFEND ] ) {
finalDamage * = 0.4 ;
}
return finalDamage ;
}
} ;