generated from sigonasr2/CPlusPlusProjectTemplate
Complete processing of equipping weapons/armor/accessories during fights
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
7caf140c1b
commit
3d7d26927d
Binary file not shown.
@ -14,6 +14,7 @@ using namespace olc;
|
|||||||
#define CAMERA_WAIT_TIME 60
|
#define CAMERA_WAIT_TIME 60
|
||||||
#define HEALTH_ROLLING_SPEED 2
|
#define HEALTH_ROLLING_SPEED 2
|
||||||
#define NO_TARGET -99
|
#define NO_TARGET -99
|
||||||
|
#define DEFAULT_CHANNELPOS {-99,-99}
|
||||||
|
|
||||||
#define ㅎ
|
#define ㅎ
|
||||||
#define ㅍ
|
#define ㅍ
|
||||||
|
@ -39,7 +39,7 @@ class Entity{
|
|||||||
int selectedTarget = NO_TARGET;
|
int selectedTarget = NO_TARGET;
|
||||||
Battle::Move*selectedMove = nullptr; //The index of the selected move.
|
Battle::Move*selectedMove = nullptr; //The index of the selected move.
|
||||||
int channelTimeRemaining = 0; //The amount of channel time left until move can be performed.
|
int channelTimeRemaining = 0; //The amount of channel time left until move can be performed.
|
||||||
vd2d channelPos = {0,0}; //Where our channel is happening.
|
vd2d channelPos = DEFAULT_CHANNELPOS; //Where our channel is happening.
|
||||||
std::vector<Item*> inventory; //Used mostly for enemy spoils.
|
std::vector<Item*> inventory; //Used mostly for enemy spoils.
|
||||||
std::array<Item*,3> equipment = {nullptr,nullptr,nullptr}; //Equipment this character is using.
|
std::array<Item*,3> equipment = {nullptr,nullptr,nullptr}; //Equipment this character is using.
|
||||||
bool isPlayer=false; //Whether or not this is a player entity.
|
bool isPlayer=false; //Whether or not this is a player entity.
|
||||||
|
2
item.h
2
item.h
@ -10,6 +10,8 @@ enum class ItemName{
|
|||||||
CRACKED_BAT,
|
CRACKED_BAT,
|
||||||
TEE_BALL_BAT,
|
TEE_BALL_BAT,
|
||||||
LIGHT_JACKET,
|
LIGHT_JACKET,
|
||||||
|
HEAVY_JACKET,
|
||||||
|
COPPER_BRACELET,
|
||||||
KEY_TO_THE_PALACE,
|
KEY_TO_THE_PALACE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
40
main.cpp
40
main.cpp
@ -141,6 +141,7 @@ public:
|
|||||||
int BATTLE_ROLLING_COUNTER_WAITTIME = 0; //Number of frames to wait for each rolling counter.
|
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.
|
int BATTLE_HIT_SCREENSHAKE = 0; //Amount of time the screen will rapidly shake as getting hit.
|
||||||
bool ITEM_REQUIRES_EQUIPPING=false;
|
bool ITEM_REQUIRES_EQUIPPING=false;
|
||||||
|
std::wstring EQUIP_$ITEM_DISPLAY=L" "; //Use this to change the $ITEM tag modifier for abilities.
|
||||||
|
|
||||||
bool MOUSE_PRESSED_DOWN=false,MOUSE_DOWN=false,MOUSE_RELEASED=false; //TODO Implement Mouse things.
|
bool MOUSE_PRESSED_DOWN=false,MOUSE_DOWN=false,MOUSE_RELEASED=false; //TODO Implement Mouse things.
|
||||||
|
|
||||||
@ -221,6 +222,10 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
|
|||||||
액션 ModifyObject(0,ANIMATIONS["player.png"],{5,5},MAGENTA),
|
액션 ModifyObject(0,ANIMATIONS["player.png"],{5,5},MAGENTA),
|
||||||
액션 MoveCutsceneObject(1,{320,64},1),});
|
액션 MoveCutsceneObject(1,{320,64},1),});
|
||||||
|
|
||||||
|
AddItemToPlayerInventory(ItemName::LIGHT_JACKET);
|
||||||
|
AddItemToPlayerInventory(ItemName::LIGHT_JACKET);
|
||||||
|
AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
|
||||||
|
AddItemToPlayerInventory(ItemName::COPPER_BRACELET);
|
||||||
for (int i=0;i<20;i++) {
|
for (int i=0;i<20;i++) {
|
||||||
AddItemToPlayerInventory(ItemName::COOKIE);
|
AddItemToPlayerInventory(ItemName::COOKIE);
|
||||||
}
|
}
|
||||||
@ -936,8 +941,15 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
|
|||||||
}
|
}
|
||||||
if (ACTIONKEYPRESSED) {
|
if (ACTIONKEYPRESSED) {
|
||||||
ITEM_REQUIRES_EQUIPPING=true;
|
ITEM_REQUIRES_EQUIPPING=true;
|
||||||
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove=MOVELIST[BattleMoveName::BASH_CHANGE];
|
EQUIP_$ITEM_DISPLAY=transform_to<std::wstring>(PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->name);
|
||||||
SetupTargetSelect();
|
if (PARTY_INVENTORY[ITEM_SELECTION_CURSOR]->stats.equip==EquipSlot::WEAPON) {
|
||||||
|
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove=MOVELIST[BattleMoveName::BASH_CHANGE];
|
||||||
|
SetupTargetSelect();
|
||||||
|
} else {
|
||||||
|
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove=MOVELIST[BattleMoveName::EQUIP_ARMOR];
|
||||||
|
ConfirmPlayerTargetSelection();
|
||||||
|
BATTLE_STATE=BattleState::WAIT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
@ -1320,7 +1332,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
|
|||||||
label=label.replace(label.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""));
|
label=label.replace(label.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""));
|
||||||
}
|
}
|
||||||
if (label.find(L"$ITEM")!=std::string::npos) {
|
if (label.find(L"$ITEM")!=std::string::npos) {
|
||||||
label=label.replace(label.find(L"$ITEM"),5,transform_to<std::wstring>(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->equipment[EquipSlot::WEAPON]->name));
|
label=label.replace(label.find(L"$ITEM"),5,EQUIP_$ITEM_DISPLAY);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::wstring baseStr = BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->attackMsg;
|
std::wstring baseStr = BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->attackMsg;
|
||||||
@ -1332,7 +1344,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
|
|||||||
label=label.replace(label.find(L"$POWER"),6,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""));
|
label=label.replace(label.find(L"$POWER"),6,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""));
|
||||||
}
|
}
|
||||||
if (label.find(L"$ITEM")!=std::string::npos) {
|
if (label.find(L"$ITEM")!=std::string::npos) {
|
||||||
label=label.replace(label.find(L"$ITEM"),5,transform_to<std::wstring>(BATTLE_ENCOUNTER->objs[CURRENT_TURN]->equipment[EquipSlot::WEAPON]->name));
|
label=label.replace(label.find(L"$ITEM"),5,EQUIP_$ITEM_DISPLAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vd2d text={2,2};
|
vd2d text={2,2};
|
||||||
@ -1877,7 +1889,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
|
|||||||
MOVELIST[BattleMoveName::BASH]=new Battle::Move("Bash","Regular attack.",5,5,ㅍ 0,1,0,false,{0,0,0,0});
|
MOVELIST[BattleMoveName::BASH]=new Battle::Move("Bash","Regular attack.",5,5,ㅍ 0,1,0,false,{0,0,0,0});
|
||||||
MOVELIST[BattleMoveName::BASH_CHANGE]=new Battle::Move(MOVELIST[BattleMoveName::BASH]->name,"Regular attack.",MOVELIST[BattleMoveName::BASH]->baseDmg,MOVELIST[BattleMoveName::BASH]->randomDmg,ㅍ MOVELIST[BattleMoveName::BASH]->PPCost,MOVELIST[BattleMoveName::BASH]->range,MOVELIST[BattleMoveName::BASH]->composition,L"$USER equipped the $ITEM instead and attacks.",MOVELIST[BattleMoveName::BASH]->eff,MOVELIST[BattleMoveName::BASH]->pctDamage,MOVELIST[BattleMoveName::BASH]->properties);
|
MOVELIST[BattleMoveName::BASH_CHANGE]=new Battle::Move(MOVELIST[BattleMoveName::BASH]->name,"Regular attack.",MOVELIST[BattleMoveName::BASH]->baseDmg,MOVELIST[BattleMoveName::BASH]->randomDmg,ㅍ MOVELIST[BattleMoveName::BASH]->PPCost,MOVELIST[BattleMoveName::BASH]->range,MOVELIST[BattleMoveName::BASH]->composition,L"$USER equipped the $ITEM instead and attacks.",MOVELIST[BattleMoveName::BASH]->eff,MOVELIST[BattleMoveName::BASH]->pctDamage,MOVELIST[BattleMoveName::BASH]->properties);
|
||||||
MOVELIST[BattleMoveName::DEFEND]=new Battle::Move("Defend","Defend.",0,0,ㅍ 0,1,5*60,true,{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::EQUIP_ARMOR]=new Battle::Move("Defend","Defend.",0,0,ㅍ 0,1,5*60,true,{0,0,0,0});
|
MOVELIST[BattleMoveName::EQUIP_ARMOR]=new Battle::Move("Equip Armor","Equip Armor.",0,0,ㅍ 0,1,0,true,{0,0,0,0},L"$USER equips the $ITEM");
|
||||||
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_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_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});
|
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});
|
||||||
@ -1918,7 +1930,9 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
|
|||||||
ITEMLIST[ItemName::PIZZA]=new Item("Pizza","A scrumptious meal filled with lots of cheese. Restores 200 HP.",{hpRecovery:200,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:10,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::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::LIGHT_JACKET]=new Item("Light Jacket","Fits just fine.",{defense:10,equip:EquipSlot::ARMOR});
|
||||||
|
ITEMLIST[ItemName::HEAVY_JACKET]=new Item("Heavy Jacket","Are you sure this is good for your shoulders?",{defense:25,equip:EquipSlot::ARMOR});
|
||||||
|
ITEMLIST[ItemName::COPPER_BRACELET]=new Item("Copper Bracelet","It's not quite as shiny as a diamond, but it still makes you look good.",{defense:5,equip:EquipSlot::ACCESSORY});
|
||||||
ITEMLIST[ItemName::KEY_TO_THE_PALACE]=new Item("Key to the Palace","Lets you access a Palace.",{important:true});
|
ITEMLIST[ItemName::KEY_TO_THE_PALACE]=new Item("Key to the Palace","Lets you access a Palace.",{important:true});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2802,6 +2816,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
|
|||||||
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove=nullptr;
|
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove=nullptr;
|
||||||
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget=NO_TARGET;
|
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget=NO_TARGET;
|
||||||
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->atb=0;
|
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->atb=0;
|
||||||
|
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelPos=DEFAULT_CHANNELPOS;
|
||||||
BATTLE_STATE=BattleState::WAIT;
|
BATTLE_STATE=BattleState::WAIT;
|
||||||
if (previousEquip[-CURRENT_TURN-1]!=-1) {
|
if (previousEquip[-CURRENT_TURN-1]!=-1) {
|
||||||
Item*PrevEquip=PARTY_INVENTORY[previousEquip[-CURRENT_TURN-1]];
|
Item*PrevEquip=PARTY_INVENTORY[previousEquip[-CURRENT_TURN-1]];
|
||||||
@ -2813,6 +2828,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
|
|||||||
BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove=nullptr;
|
BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove=nullptr;
|
||||||
BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget=NO_TARGET;
|
BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget=NO_TARGET;
|
||||||
BATTLE_ENCOUNTER->objs[CURRENT_TURN]->atb=0;
|
BATTLE_ENCOUNTER->objs[CURRENT_TURN]->atb=0;
|
||||||
|
BATTLE_ENCOUNTER->objs[CURRENT_TURN]->channelPos=DEFAULT_CHANNELPOS;
|
||||||
BATTLE_STATE=BattleState::WAIT;
|
BATTLE_STATE=BattleState::WAIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3214,10 +3230,10 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
|
|||||||
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->EquipItem(ITEM_SELECTION_CURSOR);
|
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->EquipItem(ITEM_SELECTION_CURSOR);
|
||||||
printf("Equipped item: %s\n",PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->equipment[SelectedItem->stats.equip]->name.c_str());
|
printf("Equipped item: %s\n",PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->equipment[SelectedItem->stats.equip]->name.c_str());
|
||||||
ITEM_REQUIRES_EQUIPPING=false;
|
ITEM_REQUIRES_EQUIPPING=false;
|
||||||
ITEM_SELECTION_CURSOR=std::clamp(ITEM_SELECTION_CURSOR,0,(int)PARTY_INVENTORY.size()-1);
|
if (ITEM_SELECTION_CURSOR>=PARTY_INVENTORY.size()&&prevPartyInvenSize&1&&PARTY_INVENTORY.size()==prevPartyInvenSize-1) {
|
||||||
if (prevPartyInvenSize&1&&PARTY_INVENTORY.size()==prevPartyInvenSize-1) {
|
|
||||||
ITEM_SELECTION_OFFSET-=2;
|
ITEM_SELECTION_OFFSET-=2;
|
||||||
}
|
}
|
||||||
|
ITEM_SELECTION_CURSOR=std::clamp(ITEM_SELECTION_CURSOR,0,(int)PARTY_INVENTORY.size()-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3234,6 +3250,14 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
|
|||||||
+attacker->baseAtk
|
+attacker->baseAtk
|
||||||
+equipDamage);
|
+equipDamage);
|
||||||
finalDamage += attackerDamage;
|
finalDamage += attackerDamage;
|
||||||
|
|
||||||
|
int equipDefense = 0;
|
||||||
|
for (int i=0;i<defender->equipment.size();i++) {
|
||||||
|
if (defender->equipment[i]!=nullptr) {
|
||||||
|
equipDefense+=defender->equipment[i]->stats.defense;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finalDamage=std::max(1,finalDamage-equipDefense);
|
||||||
if (defender->selectedMove==MOVELIST[BattleMoveName::DEFEND]) {
|
if (defender->selectedMove==MOVELIST[BattleMoveName::DEFEND]) {
|
||||||
finalDamage*=0.4;
|
finalDamage*=0.4;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user