Remove sold items from equipment slots and loadout slots if they exist there so they no longer linger. Relase Build 7870. Game Version 0.4.2

This commit is contained in:
sigonasr2 2024-03-01 17:03:31 -06:00
parent 75fd63dbcd
commit a8ec34c12b
9 changed files with 33 additions and 20 deletions

1
.gitignore vendored
View File

@ -399,3 +399,4 @@ test.cpp
/Adventures in Lestoria/packkey.cpp
/x64/Release/Adventures in Lestoria.zip
/x64/Release/Adventures in Lestoria_web.zip
/x64/Release/AdventuresInLestoria_web.zip

View File

@ -3228,7 +3228,7 @@ const std::weak_ptr<Item>AiL::GetLoadoutItem(int slot){
void AiL::RestockLoadoutItems(){
for(int i=0;i<GetLoadoutSize();i++){
if(!ISBLANK(GetLoadoutItem(i))){
SetLoadoutItem(i,GetLoadoutItem(i).lock()->ActualName);
SetLoadoutItem(i,GetLoadoutItem(i).lock()->ActualName());
}
}
}

View File

@ -843,6 +843,7 @@ void Inventory::UnequipItem(EquipSlot slot){
game->GetPlayer()->RecalculateEquipStats();
};
EquipSlot Inventory::GetSlotEquippedIn(const std::weak_ptr<Item>it){
if(it.expired()||!it.lock()->IsEquippable())return EquipSlot::NONE;
for(int i=int(EquipSlot::HELMET);i<=int(EquipSlot::RING2);i<<=1){
EquipSlot slot=EquipSlot(i);
std::weak_ptr<Item>equip=GetEquip(slot);

View File

@ -205,9 +205,30 @@ void Merchant::SellItem(std::weak_ptr<Item>item,uint32_t amt){
}
totalCost=item.lock()->SellValue()*amt;
//If the item is equipped on our character, remove it.
EquipSlot equippedItemSlot=Inventory::GetSlotEquippedIn(item);
if(equippedItemSlot!=EquipSlot::NONE)Inventory::UnequipItem(equippedItemSlot);
int foundLoadoutSlot=-1;
//If the item exists in our loadout, remove it.
for(int i=0;i<game->GetLoadoutSize();i++){
if(!ISBLANK(game->GetLoadoutItem(i))&&game->GetLoadoutItem(i).lock()->ActualName()==item.lock()->ActualName()){
game->ClearLoadoutItem(i);
if(foundLoadoutSlot!=-1)ERR("WARNING! Found two loadout item slots with the same item! THIS SHOULD NOT BE HAPPENING!")
foundLoadoutSlot=i;
}
}
std::string itemName=item.lock()->ActualName(); //We need the item name since our reference to the item is about to be deleted.
Inventory::RemoveItem(item,amt);
game->GetPlayer()->SetMoney(game->GetPlayer()->GetMoney()+totalCost);
//If we still have some in our inventory, we'll add them back in.
if(Inventory::GetItemCount(itemName)>0){
game->SetLoadoutItem(foundLoadoutSlot,itemName);
}
sellFunctionPrimed=false;
};

View File

@ -568,20 +568,6 @@ void Player::Update(float fElapsedTime){
#pragma region Warrior
switch(GetState()){
case State::SWING_SWORD:{
switch(GetFacingDirection()){
case UP:{
UpdateAnimation("WARRIOR_SWINGSWORD_N");
}break;
case DOWN:{
UpdateAnimation("WARRIOR_SWINGSWORD_S");
}break;
case LEFT:{
UpdateAnimation("WARRIOR_SWINGSWORD_W");
}break;
case RIGHT:{
UpdateAnimation("WARRIOR_SWINGSWORD_E");
}break;
}
SetSwordSwingTimer(GetSwordSwingTimer()-fElapsedTime);
if(GetSwordSwingTimer()<=0){
SetSwordSwingTimer(0);

View File

@ -34,3 +34,4 @@ Gorbit99's viewport PGEX
Original Nico Sprite
Inventory scroll bar doesn't reset its size
Address selling of items that are in equipment slots and loadout slots.

View File

@ -38,8 +38,8 @@ All rights reserved.
#pragma once
#define VERSION_MAJOR 0
#define VERSION_MINOR 4
#define VERSION_PATCH 1
#define VERSION_BUILD 7857
#define VERSION_PATCH 2
#define VERSION_BUILD 7870
#define stringify(a) stringify_(a)
#define stringify_(a) #a

View File

@ -80,13 +80,16 @@ bool Warrior::AutoAttack(){
}
if(closest!=nullptr){
closest->Hurt(int(GetAttack()*"Warrior.Auto Attack.DamageMult"_F),OnUpperLevel(),GetZ());
float dirToEnemy=geom2d::line<float>(GetPos(),closest->GetPos()).vector().polar().y;
SetAnimationBasedOnTargetingDirection(dirToEnemy);
}else{
float dirToMouse=geom2d::line<float>(GetPos(),GetWorldAimingLocation()).vector().polar().y;
SetAnimationBasedOnTargetingDirection(dirToMouse);
}
attack_cooldown_timer=ATTACK_COOLDOWN-GetAttackRecoveryRateReduction();
swordSwingTimer="Warrior.Auto Attack.SwordSwingTime"_F;
float dirToEnemy=geom2d::line<float>(GetPos(),closest->GetPos()).vector().polar().y;
SetState(State::SWING_SWORD);
SetAnimationBasedOnTargetingDirection(dirToEnemy);
SoundEffect::PlaySFX("Warrior Auto Attack",SoundEffect::CENTERED);
}
return true;