75 lines
1.5 KiB
C++
75 lines
1.5 KiB
C++
#include "precompile.h"
|
|
|
|
#include "weapon.h"
|
|
#include "creature.h"
|
|
#include "netdata.h"
|
|
#include "pbutils.h"
|
|
#include "human.h"
|
|
#include "ability.h"
|
|
|
|
#include "mt/Equip.h"
|
|
|
|
void Weapon::Clear()
|
|
{
|
|
weapon_uniid = 0;
|
|
weapon_id = 0;
|
|
weapon_lv = 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->GetNetData()) {
|
|
return c->GetNetData()->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)
|
|
{
|
|
int rate = 0;
|
|
if (c->GetNetData()) {
|
|
rate = c->GetNetData()->GetFireRate(c, this);
|
|
} else {
|
|
rate = meta ? meta->fire_rate() : 0;
|
|
}
|
|
return rate * (1.0f + c->GetAbility()->GetAttrRuduce(kHVAT_FireRate));
|
|
}
|
|
|
|
int Weapon::GetReloadTime(Creature* c)
|
|
{
|
|
if (c->GetNetData()) {
|
|
return c->GetNetData()->GetReloadTime(c, this);
|
|
} else {
|
|
return meta ? meta->reload_time() :0;
|
|
}
|
|
}
|
|
|
|
int Weapon::GetWeaponBattleLv(Creature* c)
|
|
{
|
|
if (c) {
|
|
if (c->GetCurrWeapon() == this) {
|
|
#if 1
|
|
//888
|
|
return 1;
|
|
#else
|
|
return c->GetCompose()->GetNum() + 1;
|
|
#endif
|
|
}
|
|
}
|
|
return 1;
|
|
}
|