Update display names for target select when using consumables. Properly dispose of consumables for items that use a special battle move.

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 9d2cdaf3d1
commit ed6f4c7f4d
  1. BIN
      C++ProjectTemplate
  2. 7
      entity.h
  3. 16
      main.cpp

Binary file not shown.

@ -7,6 +7,8 @@
extern std::vector<Item*>PARTY_INVENTORY; extern std::vector<Item*>PARTY_INVENTORY;
extern int INVENTORY_CONSUMABLE_OFFSET[4]; extern int INVENTORY_CONSUMABLE_OFFSET[4];
extern int ITEM_SELECTION_CURSOR;
extern int ITEM_SELECTION_OFFSET;
using namespace olc; using namespace olc;
@ -224,6 +226,7 @@ class Entity{
} }
void RemoveItem(int index) { void RemoveItem(int index) {
int prevPartyInvenSize=PARTY_INVENTORY.size();
if (isPlayer) { if (isPlayer) {
for (int i=0;i<4;i++) { for (int i=0;i<4;i++) {
if (index<INVENTORY_CONSUMABLE_OFFSET[i]) { if (index<INVENTORY_CONSUMABLE_OFFSET[i]) {
@ -234,6 +237,10 @@ class Entity{
} else { } else {
inventory.erase(inventory.begin()+index); inventory.erase(inventory.begin()+index);
} }
if (ITEM_SELECTION_CURSOR>=PARTY_INVENTORY.size()&&prevPartyInvenSize&1&&PARTY_INVENTORY.size()==prevPartyInvenSize-1) {
ITEM_SELECTION_OFFSET-=2;
}
ITEM_SELECTION_CURSOR=std::clamp(ITEM_SELECTION_CURSOR,0,(int)PARTY_INVENTORY.size()-1);
} }
//If index is -1, the item is inserted at the end of the list. Otherwise it's going to overwrite a certain slot. Be certain you swap the item before doing this! //If index is -1, the item is inserted at the end of the list. Otherwise it's going to overwrite a certain slot. Be certain you swap the item before doing this!

@ -2173,7 +2173,6 @@ void SeasonI::keyUpdates() {
} }
if (ACTIONKEYPRESSED) { if (ACTIONKEYPRESSED) {
if (OVERWORLD_ITEM_BEING_USED) { //Equipping an item. if (OVERWORLD_ITEM_BEING_USED) { //Equipping an item.
int prevPartyInvenSize=PARTY_INVENTORY.size();
if (PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->stats.equip!=EquipSlot::NONE) { if (PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->stats.equip!=EquipSlot::NONE) {
DisplayMessageBox(PARTY_MEMBER_OBJ[OVERWORLD_TARGET_SELECTION]->name+" equipped the "+PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->name+"."); DisplayMessageBox(PARTY_MEMBER_OBJ[OVERWORLD_TARGET_SELECTION]->name+" equipped the "+PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->name+".");
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[OVERWORLD_TARGET_SELECTION]]->EquipItem(ITEM_SELECTION_CURSOR); PARTY_MEMBER_STATS[PARTY_MEMBER_ID[OVERWORLD_TARGET_SELECTION]]->EquipItem(ITEM_SELECTION_CURSOR);
@ -2245,10 +2244,6 @@ void SeasonI::keyUpdates() {
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[OVERWORLD_TARGET_SELECTION]]->RemoveItem(ITEM_SELECTION_CURSOR); PARTY_MEMBER_STATS[PARTY_MEMBER_ID[OVERWORLD_TARGET_SELECTION]]->RemoveItem(ITEM_SELECTION_CURSOR);
} }
} }
if (ITEM_SELECTION_CURSOR>=PARTY_INVENTORY.size()&&prevPartyInvenSize&1&&PARTY_INVENTORY.size()==prevPartyInvenSize-1) {
ITEM_SELECTION_OFFSET-=2;
}
ITEM_SELECTION_CURSOR=std::clamp(ITEM_SELECTION_CURSOR,0,(int)PARTY_INVENTORY.size()-1);
OVERWORLD_ITEM_BEING_USED=false; OVERWORLD_ITEM_BEING_USED=false;
GAME_STATE=GameState::OVERWORLD_ITEMS_MENU; GAME_STATE=GameState::OVERWORLD_ITEMS_MENU;
} else { //Using a power instead. } else { //Using a power instead.
@ -4136,7 +4131,11 @@ void SeasonI::SetupTargetSelect() {
for (auto&ent:GetEntitiesInRange(SELECTED_TARGET,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelPos,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove)) { for (auto&ent:GetEntitiesInRange(SELECTED_TARGET,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelPos,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove)) {
ent->obj->highlighted=true; ent->obj->highlighted=true;
} }
DISPLAY_TARGET_MESSAGE="Use "+PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->GetPowerName()+" on..."; 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]) {
DISPLAY_TARGET_MESSAGE="Use "+EQUIP_$ITEM_DISPLAY+" on...";
} else {
DISPLAY_TARGET_MESSAGE="Use "+PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->GetPowerName()+" on...";
}
} }
void SeasonI::ConfirmPlayerTargetSelection() { void SeasonI::ConfirmPlayerTargetSelection() {
@ -4148,7 +4147,6 @@ void SeasonI::ConfirmPlayerTargetSelection() {
} }
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;
int prevPartyInvenSize=PARTY_INVENTORY.size();
if (ITEM_REQUIRES_EQUIPPING) { if (ITEM_REQUIRES_EQUIPPING) {
Item*SelectedItem=PARTY_INVENTORY[ITEM_SELECTION_CURSOR]; 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. 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.
@ -4174,10 +4172,6 @@ void SeasonI::ConfirmPlayerTargetSelection() {
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->RemoveItem(ITEM_SELECTION_CURSOR); 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;
}
ITEM_SELECTION_CURSOR=std::clamp(ITEM_SELECTION_CURSOR,0,(int)PARTY_INVENTORY.size()-1);
} }
std::vector<Entity*> SeasonI::GetEntitiesInRange(int targetEnt, vd2d channelPos, Battle::Move*move) { std::vector<Entity*> SeasonI::GetEntitiesInRange(int targetEnt, vd2d channelPos, Battle::Move*move) {

Loading…
Cancel
Save