This commit is contained in:
aozhiwei 2023-11-16 12:07:22 +08:00
parent d19d9daa8f
commit ae5047a3c0
2 changed files with 43 additions and 2 deletions

View File

@ -21,6 +21,7 @@
#include "loot.h"
#include "car.h"
#include "roomobstacle.h"
#include "weapon.h"
#include "mt/Hero.h"
#include "mt/Equip.h"
@ -1449,3 +1450,44 @@ behaviac::EBTStatus HeroAgent::Pickup()
};
return StartCoroutine(co);
}
bool HeroAgent::CanThrowItem(int slot)
{
if (owner_->downed) {
return false;
}
if (owner_->IsCar()) {
return false;
}
if (owner_->HasBuffEffect(kBET_Jump) ||
owner_->HasBuffEffect(kBET_Fly)) {
return false;
}
if (owner_->GetActionType() == AT_Reload ||
owner_->GetActionType() == AT_Rescue ||
owner_->GetActionType() == AT_UseItem ||
owner_->GetActionType() == AT_Relive) {
return false;
}
if (!(slot == IS_FRAG || slot == IS_SMOKE || slot == IS_MOLOTOR_COCKTAIL)) {
return false;
}
if (slot > 0 && slot < owner_->weapons.size()) {
Weapon& weapon = owner_->weapons[slot];
if (weapon.weapon_idx != 0 &&
weapon.meta &&
weapon.ammo > 0) {
return true;
}
}
return false;
}
behaviac::EBTStatus HeroAgent::ThrowItem(int slot)
{
if (!CanThrowItem(slot)) {
return behaviac::BT_FAILURE;
}
return behaviac::BT_FAILURE;
}

View File

@ -92,9 +92,7 @@ public:
int SearchPickupObj();
bool PickupObjIsValid();
void AbandonPickup(int min_time, int max_time);
bool HasThrowItem(int slot);
bool CanThrowItem(int slot);
bool ThrowItem(int slot);
behaviac::EBTStatus RegisterEvents(behaviac::vector<BtEvent_e> events);
behaviac::EBTStatus ClearEvents();
@ -103,6 +101,7 @@ public:
behaviac::EBTStatus DebugOut(std::string msg, int arg0, int arg1, int arg2);
behaviac::EBTStatus RandomSafeZonePoint(int try_count, int step_len);
behaviac::EBTStatus Pickup();
behaviac::EBTStatus ThrowItem(int slot);
behaviac::EBTStatus CoIdle(int min_val, int max_val);
behaviac::EBTStatus CoMoveCurrentTargetRaycast();