aozhiwei 0ff5409773 1
2023-03-03 17:38:56 +08:00

56 lines
1.1 KiB
C++

#include "precompile.h"
#include "weapon.h"
#include "creature.h"
#include "battledatacontext.h"
#include "pbutils.h"
#include "human.h"
#include "mt/Equip.h"
void Weapon::Clear()
{
weapon_uniid = 0;
weapon_id = 0;
ammo = 0;
meta = nullptr;
bullet_meta = nullptr;
skill_meta = nullptr;
}
void Weapon::Recalc()
{
bullet_meta = mt::Equip::GetById(meta->use_bullet());
}
int Weapon::GetClipVolume(Creature* c)
{
if (c->GetBattleContext()) {
return c->GetBattleContext()->GetClipVolume(c, this);
} else {
if (c->IsHuman() && meta->_inventory_slot() > 0) {
return c->AsHuman()->GetVolume(meta->_inventory_slot());
} else {
return meta ? meta->clip_volume() :0;
}
}
}
int Weapon::GetFireRate(Creature* c)
{
if (c->GetBattleContext()) {
return c->GetBattleContext()->GetFireRate(c, this);
} else {
return meta ? meta->fire_rate() :0;
}
}
int Weapon::GetReloadTime(Creature* c)
{
if (c->GetBattleContext()) {
return c->GetBattleContext()->GetReloadTime(c, this);
} else {
return meta ? meta->reload_time() :0;
}
}