Completed item/equipment implementation in combat

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 03285edba4
commit 849bfb6576
  1. BIN
      C++ProjectTemplate
  2. 15
      item.h
  3. 72
      main.cpp

Binary file not shown.

@ -43,6 +43,7 @@ enum class ItemAction{
PPRECOVERY,
ATKINCREASE,
HPINCREASE,
PPINCREASE,
SPDINCREASE,
LEARNMOVE,
};
@ -53,6 +54,7 @@ struct ItemStatsStruct{
int atkIncrease=0;
int spdIncrease=0;
int hpIncrease=0;
int ppIncrease=0;
Battle::Move*learnAbility=nullptr;
int damage=0;
int rollDmg=0;
@ -64,8 +66,8 @@ struct ItemStatsStruct{
};
struct CustomItemMessage{
std::wstring s;
ItemAction a;
std::wstring s=L"";
ItemAction a=ItemAction::HPRECOVERY;
};
class Item{
@ -75,13 +77,14 @@ class Item{
Battle::Move*battlemove=nullptr;
ItemStatsStruct stats;
std::vector<CustomItemMessage> messages;
Item(std::string name,std::string desc,ItemStatsStruct stats={hpRecovery:0,ppRecovery:0,atkIncrease:0,spdIncrease:0,hpIncrease:0,learnAbility:nullptr,damage:0,rollDmg:0,attack:0,defense:0,equip:EquipSlot::NONE,important:false,consumable:Consumable::NOT_A_CONSUMABLE},Battle::Move*battlemove=nullptr)
Item(std::string name,std::string desc,ItemStatsStruct stats={hpRecovery:0,ppRecovery:0,atkIncrease:0,spdIncrease:0,hpIncrease:0,ppIncrease:0,learnAbility:nullptr,damage:0,rollDmg:0,attack:0,defense:0,equip:EquipSlot::NONE,important:false,consumable:Consumable::NOT_A_CONSUMABLE},Battle::Move*battlemove=nullptr)
:name(name),description(desc),stats(stats),battlemove(battlemove){
if (stats.hpRecovery) {messages.push_back({L"$USER recovers "+std::to_wstring(stats.hpRecovery)+L" HP.",ItemAction::HPRECOVERY});}
if (stats.ppRecovery) {messages.push_back({L"$USER recovers "+std::to_wstring(stats.ppRecovery)+L" PP.",ItemAction::PPRECOVERY});}
if (stats.atkIncrease) {messages.push_back({L"$USER gains "+std::to_wstring(stats.atkIncrease)+L" point"+(stats.atkIncrease==1?L"":L"s")+L".",ItemAction::ATKINCREASE});}
if (stats.hpIncrease) {messages.push_back({L"$USER gains "+std::to_wstring(stats.hpIncrease)+L" point"+(stats.hpIncrease==1?L"":L"s")+L".",ItemAction::HPINCREASE});}
if (stats.spdIncrease) {messages.push_back({L"$USER gains "+std::to_wstring(stats.spdIncrease)+L" point"+(stats.spdIncrease==1?L"":L"s")+L".",ItemAction::SPDINCREASE});}
if (stats.atkIncrease) {messages.push_back({L"$USER gains "+std::to_wstring(stats.atkIncrease)+L" ATK point"+(stats.atkIncrease==1?L"":L"s")+L".",ItemAction::ATKINCREASE});}
if (stats.hpIncrease) {messages.push_back({L"$USER gains "+std::to_wstring(stats.hpIncrease)+L" HP point"+(stats.hpIncrease==1?L"":L"s")+L".",ItemAction::HPINCREASE});}
if (stats.ppIncrease) {messages.push_back({L"$USER gains "+std::to_wstring(stats.ppIncrease)+L" PP point"+(stats.ppIncrease==1?L"":L"s")+L".",ItemAction::PPINCREASE});}
if (stats.spdIncrease) {messages.push_back({L"$USER gains "+std::to_wstring(stats.spdIncrease)+L" SPD point"+(stats.spdIncrease==1?L"":L"s")+L".",ItemAction::SPDINCREASE});}
if (stats.learnAbility!=nullptr) {messages.push_back({L"$USER gains the ability to use "+transform_to<std::wstring>(stats.learnAbility->name)+L" "+((stats.learnAbility->grade!=0)?std::wstring(1,stats.learnAbility->grade):L"")+L"!",ItemAction::LEARNMOVE});}
}
};

@ -143,6 +143,7 @@ public:
std::vector<CustomItemMessage> BATTLE_CUSTOM_MSGS; //Used for displaying additional information during battles.
CustomItemMessage BATTLE_CURRENT_CUSTOM_MSG;
int BATTLE_CUSTOM_MESSAGE_WAIT_TIME=0;
Item*BATTLE_CUSTOM_ITEM;
bool MOUSE_PRESSED_DOWN=false,MOUSE_DOWN=false,MOUSE_RELEASED=false; //TODO Implement Mouse things.
@ -227,6 +228,13 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
AddItemToPlayerInventory(ItemName::LIGHT_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
AddItemToPlayerInventory(ItemName::COPPER_BRACELET);
AddItemToPlayerInventory(ItemName::MIRACLE_FOOD_LUNCH);
AddItemToPlayerInventory(ItemName::MIRACLE_FOOD_LUNCH);
AddItemToPlayerInventory(ItemName::MIRACLE_FOOD_LUNCH);
AddItemToPlayerInventory(ItemName::BOMB);
AddItemToPlayerInventory(ItemName::BOMB);
AddItemToPlayerInventory(ItemName::BOMB);
AddItemToPlayerInventory(ItemName::BOMB);
for (int i=0;i<20;i++) {
AddItemToPlayerInventory(ItemName::COOKIE);
}
@ -948,7 +956,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
SetupTargetSelect();
} else
if (PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->stats.consumable!=Consumable::NOT_A_CONSUMABLE) {
if (PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->stats.consumable==Consumable::FRIENDLY) {
if (PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->stats.consumable==Consumable::FRIENDLY||PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->stats.consumable==Consumable::FRIENDLY_PERMANENT) {
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove=MOVELIST[BattleMoveName::CONSUMABLE];
} else {
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove=MOVELIST[BattleMoveName::CONSUMABLE_ENEMY];
@ -1931,8 +1939,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:Consumable::FRIENDLY});
ITEMLIST[ItemName::EGG]=new Item("Egg","Did it come before or after the chicken? Restores 60 HP.",{hpRecovery:60,consumable:Consumable::FRIENDLY});
ITEMLIST[ItemName::PIZZA]=new Item("Pizza","A scrumptious meal filled with lots of cheese. Restores 200 HP.",{hpRecovery:200,consumable:Consumable::FRIENDLY});
ITEMLIST[ItemName::MIRACLE_FOOD_LUNCH]=new Item("Miracle Food Lunch","It doesn't taste very good, but it's said to have miracoulous powers when consumed.",{hpRecovery:30,ppRecovery:10,atkIncrease:30,spdIncrease:6,hpIncrease:150,learnAbility:MOVELIST[BattleMoveName::PKFIRE_O],consumable:Consumable::FRIENDLY_PERMANENT});
ITEMLIST[ItemName::BOMB]=new Item("Bomb","A small explosive device. Deals around 120 damage.",{damage:110,rollDmg:30,consumable:Consumable::FRIENDLY});
ITEMLIST[ItemName::MIRACLE_FOOD_LUNCH]=new Item("Miracle Food Lunch","It doesn't taste very good, but it's said to have miracoulous powers when consumed.",{hpRecovery:30,ppRecovery:10,atkIncrease:30,spdIncrease:6,hpIncrease:150,ppIncrease:100,learnAbility:MOVELIST[BattleMoveName::PKFIRE_O],consumable:Consumable::FRIENDLY_PERMANENT});
ITEMLIST[ItemName::BOMB]=new Item("Bomb","A small explosive device. Deals around 120 damage.",{damage:110,rollDmg:30,consumable:Consumable::ENEMY});
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:10,equip:EquipSlot::ARMOR});
@ -2734,8 +2742,48 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
StartEffect(eff);
}
}
if (CURRENT_TURN>=120&&(CURRENT_TURN-120)%90==0) {
BATTLE_CURRENT_CUSTOM_MSG=BATTLE_CUSTOM_MSGS[(CURRENT_TURN-120)/90];
if (BATTLE_ANIMATION_TIMER>=120&&(BATTLE_ANIMATION_TIMER-120)%90==0) {
int index = (BATTLE_ANIMATION_TIMER-120)/90;
if (index<BATTLE_CUSTOM_MSGS.size()) {
BATTLE_CURRENT_CUSTOM_MSG=BATTLE_CUSTOM_MSGS[index];
Entity*target = PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget-1]];
switch (BATTLE_CURRENT_CUSTOM_MSG.a) {
case ItemAction::HPRECOVERY:{
//
}break;
case ItemAction::PPRECOVERY:{
target->AddPP(BATTLE_CUSTOM_ITEM->stats.ppRecovery);
}break;
case ItemAction::ATKINCREASE:{
target->baseAtk+=BATTLE_CUSTOM_ITEM->stats.atkIncrease;
}break;
case ItemAction::HPINCREASE:{
target->maxHP+=BATTLE_CUSTOM_ITEM->stats.hpIncrease;
target->AddHP(BATTLE_CUSTOM_ITEM->stats.hpIncrease);
}break;
case ItemAction::PPINCREASE:{
target->maxPP+=BATTLE_CUSTOM_ITEM->stats.ppIncrease;
target->AddPP(BATTLE_CUSTOM_ITEM->stats.ppIncrease);
}break;
case ItemAction::SPDINCREASE:{
target->speed+=BATTLE_CUSTOM_ITEM->stats.spdIncrease;
}break;
case ItemAction::LEARNMOVE:{
bool moveLearned=false;
for (int i=0;i<target->moveSet.size();i++) {
if (BATTLE_CUSTOM_ITEM->stats.learnAbility==target->moveSet[i]) {
moveLearned=true;
break;
}
}
if (!moveLearned) {
target->moveSet.push_back(BATTLE_CUSTOM_ITEM->stats.learnAbility);
} else {
BATTLE_CURRENT_CUSTOM_MSG.s=L"Failed to learn "+transform_to<std::wstring>(BATTLE_CUSTOM_ITEM->stats.learnAbility->name);
}
}break;
}
}
}
if (CURRENT_EFFECT==nullptr&&BATTLE_ANIMATION_TIMER==90||CURRENT_EFFECT!=nullptr&&BATTLE_ANIMATION_TIMER>CURRENT_EFFECT->maxLifeTime) {
if (CURRENT_TURN<0) {
@ -2866,6 +2914,8 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
CURRENT_TURN=-99;
BATTLE_CUSTOM_MESSAGE_WAIT_TIME=0;
BATTLE_CUSTOM_MSGS.clear();
BATTLE_CURRENT_CUSTOM_MSG={};
}
}break;
case BattleState::SELECT_ACTION:
@ -3241,18 +3291,20 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
ITEM_REQUIRES_EQUIPPING=false;
}
if ((PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove==MOVELIST[BattleMoveName::CONSUMABLE]||
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove==MOVELIST[BattleMoveName::CONSUMABLE_ENEMY])&&
(PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->stats.consumable==Consumable::FRIENDLY||PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->stats.consumable==Consumable::ENEMY)) {
if (PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->stats.consumable==Consumable::FRIENDLY) {
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove==MOVELIST[BattleMoveName::CONSUMABLE_ENEMY])) {
BATTLE_CUSTOM_ITEM=PARTY_INVENTORY[ITEM_SELECTION_CURSOR];
if (PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->stats.consumable==Consumable::FRIENDLY||PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->stats.consumable==Consumable::FRIENDLY_PERMANENT) {
MOVELIST[BattleMoveName::CONSUMABLE]->baseDmg=PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->stats.hpRecovery;
MOVELIST[BattleMoveName::CONSUMABLE]->randomDmg=0;
BATTLE_CUSTOM_MESSAGE_WAIT_TIME=PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->messages.size();
BATTLE_CUSTOM_MESSAGE_WAIT_TIME=PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->messages.size()*90;
BATTLE_CUSTOM_MSGS=PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->messages;
} else {
MOVELIST[BattleMoveName::CONSUMABLE_ENEMY]->baseDmg=PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->stats.damage;
MOVELIST[BattleMoveName::CONSUMABLE_ENEMY]->randomDmg=PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->stats.rollDmg;
}
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->RemoveItem(ITEM_SELECTION_CURSOR);
if ((PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->stats.consumable==Consumable::FRIENDLY||PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->stats.consumable==Consumable::ENEMY)) {
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->RemoveItem(ITEM_SELECTION_CURSOR);
}
}
if (ITEM_SELECTION_CURSOR>=PARTY_INVENTORY.size()&&prevPartyInvenSize&1&&PARTY_INVENTORY.size()==prevPartyInvenSize-1) {
ITEM_SELECTION_OFFSET-=2;

Loading…
Cancel
Save