Customizable messages for displaying in battle.

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent ce547a34b8
commit a0651b308d
  1. BIN
      C++ProjectTemplate
  2. 13
      battle.h
  3. 1
      item.h
  4. 38
      main.cpp

Binary file not shown.

@ -43,13 +43,14 @@ namespace Battle{
int channelTime=0; //The amount of frames to channel the spell.
bool friendly=false; //Target allies instead.
Effect*eff=nullptr;
std::wstring attackMsg;
//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){}
Move(std::string name,std::string desc,int baseDmg,int randomDmg,int PPCost,int range,std::array<int,4>composition,std::wstring attackMsg = L"$USER uses $POWER",Effect*eff=nullptr,bool pctDamage=false,std::vector<std::pair<Property,int>> properties={})
:Move(name,desc,0,baseDmg,randomDmg,PPCost,range,0,false,composition,attackMsg,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,std::wstring attackMsg = L"$USER uses $POWER",Effect*eff=nullptr,bool pctDamage=false,std::vector<std::pair<Property,int>> properties={})
:Move(name,desc,0,baseDmg,randomDmg,PPCost,range,channelTime,friendly,composition,attackMsg,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,std::wstring attackMsg = L"$USER uses $POWER",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),attackMsg(attackMsg),composition(composition),pctDamage(pctDamage),properties(properties){}
};
}
#endif

@ -8,6 +8,7 @@ enum class ItemName{
EGG,
PIZZA,
CRACKED_BAT,
TEE_BALL_BAT,
LIGHT_JACKET,
KEY_TO_THE_PALACE,
};

@ -264,10 +264,11 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
for (int i=0;i<20;i++) {
AddItemToPlayerInventory(ItemName::COOKIE);
}
AddItemToPlayerInventory(ItemName::CRACKED_BAT);
for (int i=0;i<8;i++) {
AddItemToPlayerInventory(ItemName::PIZZA);
}
AddItemToPlayerInventory(ItemName::CRACKED_BAT);
AddItemToPlayerInventory(ItemName::TEE_BALL_BAT);
return true;
}
@ -683,7 +684,6 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
}
}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;
@ -977,7 +977,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
if (ACTIONKEYPRESSED) {
ITEM_REQUIRES_EQUIPPING=true;
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove=MOVELIST[BattleMoveName::BASH];
BATTLE_STATE=BattleState::TARGET_SELECT;
SetupTargetSelect();
}
}break;
}
@ -1110,13 +1110,13 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
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) {
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) {
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);
}
@ -1351,9 +1351,13 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
SetDrawTarget(layer::INTERFACE);
std::wstring label=L"";
if (CURRENT_TURN<0) {
label=transform_to<std::wstring>(PARTY_MEMBER_OBJ[-CURRENT_TURN-1]->name)+L" uses "+transform_to<std::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"");
std::wstring baseStr = PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->attackMsg;
label=baseStr.replace(baseStr.find(L"$USER"),5,transform_to<std::wstring>(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->obj->name))
.replace(baseStr.find(L"$POWER"),6,transform_to<std::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=transform_to<std::wstring>(BATTLE_ENCOUNTER->objs[CURRENT_TURN]->obj->name)+L" uses "+transform_to<std::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"");
std::wstring baseStr = BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->attackMsg;
label=baseStr.replace(baseStr.find(L"$USER"),5,transform_to<std::wstring>(BATTLE_ENCOUNTER->objs[CURRENT_TURN]->obj->name))
.replace(baseStr.find(L"$POWER"),6,transform_to<std::wstring>((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});
}
@ -1917,10 +1921,10 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
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::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},L"$USER uses $POWER",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},L"$USER uses $POWER",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},L"$USER uses $POWER",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},L"$USER uses $POWER",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});
@ -1931,7 +1935,8 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
ITEMLIST[ItemName::COOKIE]=new Item("Cookie","A delightful little treat. Restores 40 HP.",{hpRecovery:40,consumable:true});
ITEMLIST[ItemName::EGG]=new Item("Egg","Did it come before or after the chicken? Restores 60 HP.",{hpRecovery:60,consumable:true});
ITEMLIST[ItemName::PIZZA]=new Item("Pizza","A scrumptious meal filled with lots of cheese. Restores 200 HP.",{hpRecovery:200,consumable:true});
ITEMLIST[ItemName::CRACKED_BAT]=new Item("Cracked Bat","Has some dents in it, but you can probably still dent things with it yourself.",{attack:4,equip:EquipSlot::WEAPON});
ITEMLIST[ItemName::CRACKED_BAT]=new Item("Cracked Bat","Has some dents in it, but you can probably still dent things with it yourself.",{attack:10,equip:EquipSlot::WEAPON});
ITEMLIST[ItemName::TEE_BALL_BAT]=new Item("Tee Ball Bat","Great for playing some ball! Also great for beating your foes!",{attack:40,equip:EquipSlot::WEAPON});
ITEMLIST[ItemName::LIGHT_JACKET]=new Item("Light Jacket","Fits just fine.",{defense:2,equip:EquipSlot::ARMOR});
ITEMLIST[ItemName::KEY_TO_THE_PALACE]=new Item("Key to the Palace","Lets you access a Palace.",{important:true});
}
@ -3230,9 +3235,16 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
int CalculateDamage(Entity*attacker,Entity*defender) {
int finalDamage = 0;
int equipDamage = 0;
for (int i=0;i<attacker->equipment.size();i++) {
if (attacker->equipment[i]!=nullptr) {
equipDamage+=attacker->equipment[i]->stats.attack;
}
}
int attackerDamage = (attacker->selectedMove->baseDmg+
((rand()%attacker->selectedMove->randomDmg>0)?rand()%attacker->selectedMove->randomDmg:0)
+attacker->baseAtk);
+attacker->baseAtk
+equipDamage);
finalDamage += attackerDamage;
if (defender->selectedMove==MOVELIST[BattleMoveName::DEFEND]) {
finalDamage*=0.4;

Loading…
Cancel
Save