58 lines
1.2 KiB
C++
58 lines
1.2 KiB
C++
#include "precompile.h"
|
|
|
|
#include "weapon.h"
|
|
#include "cs_proto.pb.h"
|
|
#include "metamgr.h"
|
|
#include "creature.h"
|
|
#include "battledatacontext.h"
|
|
|
|
void Weapon::Clear()
|
|
{
|
|
weapon_uniid = 0;
|
|
weapon_id = 0;
|
|
ammo = 0;
|
|
meta = 0;
|
|
bullet_meta = nullptr;
|
|
}
|
|
|
|
void Weapon::ToPB(Creature* c, cs::MFWeapon* pb_obj)
|
|
{
|
|
pb_obj->set_weapon_uniid(a8::XValue(weapon_uniid).GetString());
|
|
pb_obj->set_weapon_id(weapon_id);
|
|
pb_obj->set_weapon_lv(1);
|
|
pb_obj->set_ammo(ammo);
|
|
pb_obj->set_volume(GetClipVolume(c));
|
|
}
|
|
|
|
void Weapon::Recalc()
|
|
{
|
|
bullet_meta = MetaMgr::Instance()->GetEquip(meta->i->use_bullet());
|
|
}
|
|
|
|
int Weapon::GetClipVolume(Creature* c)
|
|
{
|
|
if (c->GetBattleContext()) {
|
|
return c->GetBattleContext()->GetClipVolume(c, this);
|
|
} else {
|
|
return meta ? meta->i->clip_volume() :0;
|
|
}
|
|
}
|
|
|
|
int Weapon::GetFireRate(Creature* c)
|
|
{
|
|
if (c->GetBattleContext()) {
|
|
return c->GetBattleContext()->GetFireRate(c, this);
|
|
} else {
|
|
return meta ? meta->i->fire_rate() :0;
|
|
}
|
|
}
|
|
|
|
int Weapon::GetReloadTime(Creature* c)
|
|
{
|
|
if (c->GetBattleContext()) {
|
|
return c->GetBattleContext()->GetReloadTime(c, this);
|
|
} else {
|
|
return meta ? meta->i->reload_time() :0;
|
|
}
|
|
}
|