优化weapon
This commit is contained in:
parent
17ac94132b
commit
42a28a190e
@ -662,7 +662,7 @@ int AndroidAI::GetAttackTimes()
|
|||||||
{
|
{
|
||||||
Human* myself = (Human*)owner;
|
Human* myself = (Human*)owner;
|
||||||
if (myself->GetCurrWeapon()) {
|
if (myself->GetCurrWeapon()) {
|
||||||
return std::min(ai_meta->i->attack_times(), myself->GetCurrWeapon()->GetClipVolume());
|
return std::min(ai_meta->i->attack_times(), myself->GetCurrWeapon()->GetClipVolume(myself));
|
||||||
} else {
|
} else {
|
||||||
return ai_meta->i->attack_times();
|
return ai_meta->i->attack_times();
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ void Buff::ProcBecome()
|
|||||||
weapon->weapon_lv = 1;
|
weapon->weapon_lv = 1;
|
||||||
weapon->meta = weapon_meta;
|
weapon->meta = weapon_meta;
|
||||||
weapon->Recalc();
|
weapon->Recalc();
|
||||||
weapon->ammo = weapon->GetClipVolume();
|
weapon->ammo = weapon->GetClipVolume(owner);
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
caster_.Get()->SetCurrWeapon(weapon);
|
caster_.Get()->SetCurrWeapon(weapon);
|
||||||
}
|
}
|
||||||
@ -931,7 +931,7 @@ void Buff::ProcMachineGun()
|
|||||||
weapon->weapon_lv = 1;
|
weapon->weapon_lv = 1;
|
||||||
weapon->meta = weapon_meta;
|
weapon->meta = weapon_meta;
|
||||||
weapon->Recalc();
|
weapon->Recalc();
|
||||||
weapon->ammo = weapon->GetClipVolume();
|
weapon->ammo = weapon->GetClipVolume(owner);
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
caster_.Get()->SetCurrWeapon(weapon);
|
caster_.Get()->SetCurrWeapon(weapon);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ void Car::Initialize()
|
|||||||
weapon.weapon_lv = 1;
|
weapon.weapon_lv = 1;
|
||||||
weapon.meta = weapon_meta;
|
weapon.meta = weapon_meta;
|
||||||
weapon.Recalc();
|
weapon.Recalc();
|
||||||
weapon.ammo = weapon.GetClipVolume();
|
weapon.ammo = weapon.GetClipVolume(this);
|
||||||
SetCurrWeapon(&weapon);
|
SetCurrWeapon(&weapon);
|
||||||
}
|
}
|
||||||
born_frameno_ = room->GetFrameNo();
|
born_frameno_ = room->GetFrameNo();
|
||||||
|
@ -1180,7 +1180,7 @@ void Creature::ProcBuffEffect(Creature* caster, Buff* buff)
|
|||||||
second_weapon.weapon_lv = 1;
|
second_weapon.weapon_lv = 1;
|
||||||
second_weapon.meta = spec_weapon_meta;
|
second_weapon.meta = spec_weapon_meta;
|
||||||
second_weapon.Recalc();
|
second_weapon.Recalc();
|
||||||
second_weapon.ammo = second_weapon.GetClipVolume();
|
second_weapon.ammo = second_weapon.GetClipVolume(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1784,14 +1784,14 @@ void Creature::Shot(a8::Vec2& target_dir, bool& shot_ok, float fly_distance)
|
|||||||
if (IsCar()) {
|
if (IsCar()) {
|
||||||
if (room->GetFrameNo() - last_shot_frameno_ > 0) {
|
if (room->GetFrameNo() - last_shot_frameno_ > 0) {
|
||||||
if ((room->GetFrameNo() - last_shot_frameno_) * (1000 / SERVER_FRAME_RATE) <
|
if ((room->GetFrameNo() - last_shot_frameno_) * (1000 / SERVER_FRAME_RATE) <
|
||||||
GetCurrWeapon()->GetAttrValue(kHAT_FireRate)
|
GetCurrWeapon()->GetFireRate(this)
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((room->GetFrameNo() - last_shot_frameno_) * (1000 / SERVER_FRAME_RATE) <
|
if ((room->GetFrameNo() - last_shot_frameno_) * (1000 / SERVER_FRAME_RATE) <
|
||||||
GetCurrWeapon()->GetAttrValue(kHAT_FireRate)
|
GetCurrWeapon()->GetFireRate(this)
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1938,7 +1938,7 @@ void Creature::AutoLoadingBullet(bool manual)
|
|||||||
}
|
}
|
||||||
if (p_weapon->weapon_idx != 0 &&
|
if (p_weapon->weapon_idx != 0 &&
|
||||||
(p_weapon->ammo <= 0 ||
|
(p_weapon->ammo <= 0 ||
|
||||||
(manual && p_weapon->ammo < p_weapon->GetClipVolume()))
|
(manual && p_weapon->ammo < p_weapon->GetClipVolume(this)))
|
||||||
) {
|
) {
|
||||||
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(p_weapon->meta->i->use_bullet());
|
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(p_weapon->meta->i->use_bullet());
|
||||||
if (bullet_meta &&
|
if (bullet_meta &&
|
||||||
@ -1949,11 +1949,8 @@ void Creature::AutoLoadingBullet(bool manual)
|
|||||||
if (on_loading_bullet) {
|
if (on_loading_bullet) {
|
||||||
on_loading_bullet();
|
on_loading_bullet();
|
||||||
}
|
}
|
||||||
int duration_time = p_weapon->GetAttrValue(kHAT_ReloadTime) *
|
int duration_time = p_weapon->GetReloadTime(this) *
|
||||||
(1 + GetAbility()->GetAttrRate(kHAT_WeaponReloadTime));
|
(1 + GetAbility()->GetAttrRate(kHAT_WeaponReloadTime));
|
||||||
#if 0
|
|
||||||
duration_time = 1000 * 5;
|
|
||||||
#endif
|
|
||||||
StartAction(AT_Reload,
|
StartAction(AT_Reload,
|
||||||
duration_time,
|
duration_time,
|
||||||
p_weapon->weapon_id,
|
p_weapon->weapon_id,
|
||||||
|
@ -56,9 +56,9 @@ void FrameEvent::AddShot(CreatureWeakPtr& sender)
|
|||||||
|
|
||||||
p.set_player_id(sender.Get()->GetUniId());
|
p.set_player_id(sender.Get()->GetUniId());
|
||||||
if (sender.Get()->second_weapon.meta) {
|
if (sender.Get()->second_weapon.meta) {
|
||||||
sender.Get()->second_weapon.ToPB(p.mutable_weapon());
|
sender.Get()->second_weapon.ToPB(sender.Get(), p.mutable_weapon());
|
||||||
} else {
|
} else {
|
||||||
sender.Get()->GetCurrWeapon()->ToPB(p.mutable_weapon());
|
sender.Get()->GetCurrWeapon()->ToPB(sender.Get(), p.mutable_weapon());
|
||||||
}
|
}
|
||||||
if (sender.Get()->IsCar()) {
|
if (sender.Get()->IsCar()) {
|
||||||
p.set_hole(sender.Get()->shot_hole);
|
p.set_hole(sender.Get()->shot_hole);
|
||||||
|
@ -526,7 +526,7 @@ int HeroAI::GetAttackTimes()
|
|||||||
{
|
{
|
||||||
Hero* myself = (Hero*)owner;
|
Hero* myself = (Hero*)owner;
|
||||||
if (myself->GetCurrWeapon()) {
|
if (myself->GetCurrWeapon()) {
|
||||||
return std::min(ai_meta->i->attack_times(), myself->GetCurrWeapon()->GetClipVolume());
|
return std::min(ai_meta->i->attack_times(), myself->GetCurrWeapon()->GetClipVolume(myself));
|
||||||
} else {
|
} else {
|
||||||
return ai_meta->i->attack_times();
|
return ai_meta->i->attack_times();
|
||||||
}
|
}
|
||||||
|
@ -342,15 +342,6 @@ void Human::Initialize()
|
|||||||
RecalcSelfCollider();
|
RecalcSelfCollider();
|
||||||
volume_ = meta->volume;
|
volume_ = meta->volume;
|
||||||
observers_.insert(this);
|
observers_.insert(this);
|
||||||
#if 0
|
|
||||||
for (auto& weapon : spec_weapons) {
|
|
||||||
if (weapon.meta) {
|
|
||||||
float hp = GetHP();
|
|
||||||
hp += weapon.meta ? weapon.GetAttrValue(kHAT_MaxHp) : 0;
|
|
||||||
SetHP(hp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
SetCurrWeapon(&weapons[0]);
|
SetCurrWeapon(&weapons[0]);
|
||||||
SetOxygen(MetaMgr::Instance()->dive_oxygen_total);
|
SetOxygen(MetaMgr::Instance()->dive_oxygen_total);
|
||||||
}
|
}
|
||||||
@ -446,7 +437,7 @@ void Human::FillMFObjectLess(Room* room, Human* hum, cs::MFPlayerFull* full_data
|
|||||||
p->set_chest(chest);
|
p->set_chest(chest);
|
||||||
p->set_shoot_offset_x(shoot_offset.x);
|
p->set_shoot_offset_x(shoot_offset.x);
|
||||||
p->set_shoot_offset_y(shoot_offset.y);
|
p->set_shoot_offset_y(shoot_offset.y);
|
||||||
GetCurrWeapon()->ToPB(p->mutable_weapon());
|
GetCurrWeapon()->ToPB(this, p->mutable_weapon());
|
||||||
GetAbility()->FillMFAttrAdditionList(room, this, p->mutable_attr_addition());
|
GetAbility()->FillMFAttrAdditionList(room, this, p->mutable_attr_addition());
|
||||||
if (GetCar()) {
|
if (GetCar()) {
|
||||||
p->set_car_uniid(GetCar()->car_uniid);
|
p->set_car_uniid(GetCar()->car_uniid);
|
||||||
@ -478,7 +469,7 @@ void Human::FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data
|
|||||||
p->set_backpack(backpack);
|
p->set_backpack(backpack);
|
||||||
p->set_helmet(helmet);
|
p->set_helmet(helmet);
|
||||||
p->set_chest(chest);
|
p->set_chest(chest);
|
||||||
GetCurrWeapon()->ToPB(p->mutable_weapon());
|
GetCurrWeapon()->ToPB(this, p->mutable_weapon());
|
||||||
p->set_energy_shield(energy_shield);
|
p->set_energy_shield(energy_shield);
|
||||||
p->set_shoot_offset_x(shoot_offset.x);
|
p->set_shoot_offset_x(shoot_offset.x);
|
||||||
p->set_shoot_offset_y(shoot_offset.y);
|
p->set_shoot_offset_y(shoot_offset.y);
|
||||||
@ -1586,7 +1577,7 @@ void Human::FillMFActivePlayerData(cs::MFActivePlayerData* player_data)
|
|||||||
}
|
}
|
||||||
for (auto& weapon : weapons) {
|
for (auto& weapon : weapons) {
|
||||||
auto p = player_data->add_weapons();
|
auto p = player_data->add_weapons();
|
||||||
weapon.ToPB(p);
|
weapon.ToPB(this, p);
|
||||||
}
|
}
|
||||||
for (auto& inv : GetInventoryData()) {
|
for (auto& inv : GetInventoryData()) {
|
||||||
player_data->add_inventory(inv.num);
|
player_data->add_inventory(inv.num);
|
||||||
@ -3031,20 +3022,20 @@ void Human::ProcReloadAction()
|
|||||||
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(p_weapon->meta->i->use_bullet());
|
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(p_weapon->meta->i->use_bullet());
|
||||||
if (bullet_meta) {
|
if (bullet_meta) {
|
||||||
int ammo = p_weapon->ammo;
|
int ammo = p_weapon->ammo;
|
||||||
if (ammo < p_weapon->GetClipVolume()) {
|
if (ammo < p_weapon->GetClipVolume(this)) {
|
||||||
if (bullet_meta->i->_inventory_slot() >= 0 &&
|
if (bullet_meta->i->_inventory_slot() >= 0 &&
|
||||||
bullet_meta->i->_inventory_slot() < IS_END) {
|
bullet_meta->i->_inventory_slot() < IS_END) {
|
||||||
if (GetInventory(bullet_meta->i->_inventory_slot()) > 0) {
|
if (GetInventory(bullet_meta->i->_inventory_slot()) > 0) {
|
||||||
int add_num = 0;
|
int add_num = 0;
|
||||||
if (GetInventory(bullet_meta->i->_inventory_slot()) <=
|
if (GetInventory(bullet_meta->i->_inventory_slot()) <=
|
||||||
p_weapon->GetClipVolume() - ammo) {
|
p_weapon->GetClipVolume(this) - ammo) {
|
||||||
add_num = GetInventory(bullet_meta->i->_inventory_slot());
|
add_num = GetInventory(bullet_meta->i->_inventory_slot());
|
||||||
if (p_weapon->meta->i->reloadtype() == 1) {
|
if (p_weapon->meta->i->reloadtype() == 1) {
|
||||||
add_num = 1;
|
add_num = 1;
|
||||||
}
|
}
|
||||||
DecInventory(bullet_meta->i->_inventory_slot(), add_num);
|
DecInventory(bullet_meta->i->_inventory_slot(), add_num);
|
||||||
} else {
|
} else {
|
||||||
add_num = p_weapon->GetClipVolume() - ammo;
|
add_num = p_weapon->GetClipVolume(this) - ammo;
|
||||||
if (p_weapon->meta->i->reloadtype() == 1) {
|
if (p_weapon->meta->i->reloadtype() == 1) {
|
||||||
add_num = 1;
|
add_num = 1;
|
||||||
}
|
}
|
||||||
|
@ -1337,53 +1337,6 @@ namespace MetaData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dress::Init()
|
|
||||||
{
|
|
||||||
for (int j = 0; j < i->max_lv(); ++j) {
|
|
||||||
std::array<float, kHAT_End>& attrs = a8::FastAppend(level_attrs);
|
|
||||||
for (size_t k = 0; k < kHAT_End; ++k) {
|
|
||||||
attrs[k] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{
|
|
||||||
std::vector<std::string> strings;
|
|
||||||
a8::Split(i->attr_type(), strings, '|');
|
|
||||||
for (auto& str : strings) {
|
|
||||||
std::vector<std::string> strings2;
|
|
||||||
a8::Split(str, strings2, ':');
|
|
||||||
if (strings2.size() != 3) {
|
|
||||||
A8_ABORT();
|
|
||||||
}
|
|
||||||
int attr_type = a8::XValue(strings2[0]);
|
|
||||||
int attr_level = a8::XValue(strings2[1]);
|
|
||||||
float attr_value = a8::XValue(strings2[2]).GetDouble();
|
|
||||||
if (attr_type < kHAT_End) {
|
|
||||||
if (attr_level >= 0 && attr_level < i->max_lv()) {
|
|
||||||
for (int j = 1; j < i->max_lv(); ++j) {
|
|
||||||
if (j % attr_type == 0) {
|
|
||||||
level_attrs[j][attr_type] = attr_value * (j / attr_level);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float Dress::GetAttrValue(int level, int attr_type)
|
|
||||||
{
|
|
||||||
if (level < 1) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (level > (int)level_attrs.size()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (attr_type < kHAT_End) {
|
|
||||||
return level_attrs[level][attr_type];
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RankReward::Init()
|
void RankReward::Init()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -315,17 +315,6 @@ namespace MetaData
|
|||||||
void Init();
|
void Init();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Dress
|
|
||||||
{
|
|
||||||
const metatable::Dress* i = nullptr;
|
|
||||||
|
|
||||||
void Init();
|
|
||||||
float GetAttrValue(int level, int attr_type);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<std::array<float, kHAT_End>> level_attrs;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct RankReward
|
struct RankReward
|
||||||
{
|
{
|
||||||
const metatable::RankReward* i = nullptr;
|
const metatable::RankReward* i = nullptr;
|
||||||
|
@ -169,8 +169,6 @@ public:
|
|||||||
std::list<MetaData::AirRaid> airraid_list;
|
std::list<MetaData::AirRaid> airraid_list;
|
||||||
std::list<metatable::AirLine> airline_meta_list;
|
std::list<metatable::AirLine> airline_meta_list;
|
||||||
std::list<MetaData::AirLine> airline_list;
|
std::list<MetaData::AirLine> airline_list;
|
||||||
std::list<metatable::Dress> dress_meta_list;
|
|
||||||
std::list<MetaData::Dress> dress_list;
|
|
||||||
std::list<metatable::Skill> skill_meta_list;
|
std::list<metatable::Skill> skill_meta_list;
|
||||||
std::list<MetaData::Skill> skill_list;
|
std::list<MetaData::Skill> skill_list;
|
||||||
std::list<metatable::SkillNumber> skill_number_meta_list;
|
std::list<metatable::SkillNumber> skill_number_meta_list;
|
||||||
@ -221,8 +219,6 @@ public:
|
|||||||
std::map<std::string, std::list<metatable::MapLayerJson>> layer_meta_hash;
|
std::map<std::string, std::list<metatable::MapLayerJson>> layer_meta_hash;
|
||||||
std::map<std::string, std::list<metatable::MapBlockJson>> block_meta_hash;
|
std::map<std::string, std::list<metatable::MapBlockJson>> block_meta_hash;
|
||||||
std::map<std::string, std::vector<MetaData::MapTplThing>> maptpl_hash;
|
std::map<std::string, std::vector<MetaData::MapTplThing>> maptpl_hash;
|
||||||
std::map<int, MetaData::Dress*> dress_hash;
|
|
||||||
std::vector<MetaData::Dress*> dress_vec;
|
|
||||||
std::map<int, MetaData::Skill*> skill_hash;
|
std::map<int, MetaData::Skill*> skill_hash;
|
||||||
std::map<int, MetaData::SkillNumber*> skill_number_hash;
|
std::map<int, MetaData::SkillNumber*> skill_number_hash;
|
||||||
std::map<int, MetaData::Buff*> buff_hash;
|
std::map<int, MetaData::Buff*> buff_hash;
|
||||||
@ -282,7 +278,6 @@ public:
|
|||||||
f8::ReadCsvMetaFile(res_path + "airraid@airraid.csv", airraid_meta_list);
|
f8::ReadCsvMetaFile(res_path + "airraid@airraid.csv", airraid_meta_list);
|
||||||
f8::ReadCsvMetaFile(res_path + "airline@airline.csv", airline_meta_list);
|
f8::ReadCsvMetaFile(res_path + "airline@airline.csv", airline_meta_list);
|
||||||
f8::ReadJsonMetaFile(res_path + "maps.json", building_meta_list);
|
f8::ReadJsonMetaFile(res_path + "maps.json", building_meta_list);
|
||||||
f8::ReadCsvMetaFile(res_path + "dress@dress.csv", dress_meta_list);
|
|
||||||
f8::ReadCsvMetaFile(res_path + "skill@skill.csv", skill_meta_list);
|
f8::ReadCsvMetaFile(res_path + "skill@skill.csv", skill_meta_list);
|
||||||
f8::ReadCsvMetaFile(res_path + "skillNumber@skillNumber.csv", skill_number_meta_list);
|
f8::ReadCsvMetaFile(res_path + "skillNumber@skillNumber.csv", skill_number_meta_list);
|
||||||
f8::ReadCsvMetaFile(res_path + "attr@attr.csv", attr_meta_list);
|
f8::ReadCsvMetaFile(res_path + "attr@attr.csv", attr_meta_list);
|
||||||
@ -843,13 +838,6 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& meta : dress_meta_list) {
|
|
||||||
MetaData::Dress& item = a8::FastAppend(dress_list);
|
|
||||||
item.i = &meta;
|
|
||||||
dress_hash[item.i->id()] = &item;
|
|
||||||
dress_vec.push_back(&item);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto& meta : attr_meta_list) {
|
for (auto& meta : attr_meta_list) {
|
||||||
MetaData::Attr& item = a8::FastAppend(attr_list);
|
MetaData::Attr& item = a8::FastAppend(attr_list);
|
||||||
item.i = &meta;
|
item.i = &meta;
|
||||||
@ -1177,26 +1165,12 @@ MetaData::Attr* MetaMgr::GetAttrByName(const std::string& attr_name)
|
|||||||
return itr != loader_->attr_name_hash.end() ? itr->second : nullptr;
|
return itr != loader_->attr_name_hash.end() ? itr->second : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaData::Dress* MetaMgr::GetDress(int dress_id)
|
|
||||||
{
|
|
||||||
auto itr = loader_->dress_hash.find(dress_id);
|
|
||||||
return itr != loader_->dress_hash.end() ? itr->second : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
MetaData::RankReward* MetaMgr::GetRankReward(int rank)
|
MetaData::RankReward* MetaMgr::GetRankReward(int rank)
|
||||||
{
|
{
|
||||||
auto itr = loader_->rankreward_hash.find(rank);
|
auto itr = loader_->rankreward_hash.find(rank);
|
||||||
return itr != loader_->rankreward_hash.end() ? itr->second : nullptr;
|
return itr != loader_->rankreward_hash.end() ? itr->second : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaData::Dress* MetaMgr::RandDress()
|
|
||||||
{
|
|
||||||
if (loader_->dress_vec.empty()) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return loader_->dress_vec[rand() % loader_->dress_vec.size()];
|
|
||||||
}
|
|
||||||
|
|
||||||
float MetaMgr::GetRankRewardParam(int rank)
|
float MetaMgr::GetRankRewardParam(int rank)
|
||||||
{
|
{
|
||||||
auto itr = loader_->rankreward_hash.find(rank);
|
auto itr = loader_->rankreward_hash.find(rank);
|
||||||
|
@ -49,8 +49,6 @@ class MetaMgr : public a8::Singleton<MetaMgr>
|
|||||||
MetaData::Buff* GetBuff(int buff_id);
|
MetaData::Buff* GetBuff(int buff_id);
|
||||||
MetaData::Attr* GetAttrById(int attr_id);
|
MetaData::Attr* GetAttrById(int attr_id);
|
||||||
MetaData::Attr* GetAttrByName(const std::string& attr_name);
|
MetaData::Attr* GetAttrByName(const std::string& attr_name);
|
||||||
MetaData::Dress* GetDress(int dress_id);
|
|
||||||
MetaData::Dress* RandDress();
|
|
||||||
MetaData::RankReward* GetRankReward(int rank);
|
MetaData::RankReward* GetRankReward(int rank);
|
||||||
MetaData::GunTalentGrow* GetTalent(int talent_id, int talent_lv);
|
MetaData::GunTalentGrow* GetTalent(int talent_id, int talent_lv);
|
||||||
MetaData::PveGemini* GetPveGemini(int gemini_id);
|
MetaData::PveGemini* GetPveGemini(int gemini_id);
|
||||||
|
@ -61,7 +61,7 @@ void Player::Initialize()
|
|||||||
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(GetCurrWeapon()->meta->i->use_bullet());
|
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(GetCurrWeapon()->meta->i->use_bullet());
|
||||||
if (bullet_meta) {
|
if (bullet_meta) {
|
||||||
int add_num = GetInventory(bullet_meta->i->_inventory_slot());
|
int add_num = GetInventory(bullet_meta->i->_inventory_slot());
|
||||||
add_num = GetCurrWeapon()->GetClipVolume();
|
add_num = GetCurrWeapon()->GetClipVolume(this);
|
||||||
GetCurrWeapon()->ammo = add_num;
|
GetCurrWeapon()->ammo = add_num;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ void Player::Initialize()
|
|||||||
weapon->weapon_lv = spec_weapon.weapon_lv;
|
weapon->weapon_lv = spec_weapon.weapon_lv;
|
||||||
weapon->meta = item_meta;
|
weapon->meta = item_meta;
|
||||||
weapon->Recalc();
|
weapon->Recalc();
|
||||||
weapon->ammo = weapon->GetClipVolume();
|
weapon->ammo = weapon->GetClipVolume(this);
|
||||||
SetCurrWeapon(&weapons[GUN_SLOT1]);
|
SetCurrWeapon(&weapons[GUN_SLOT1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -329,7 +329,7 @@ void Player::UpdateShot()
|
|||||||
if (last_shot_frameno_ == 0 ||
|
if (last_shot_frameno_ == 0 ||
|
||||||
(
|
(
|
||||||
(room->GetFrameNo() - last_shot_frameno_) * (1000 / SERVER_FRAME_RATE)) >=
|
(room->GetFrameNo() - last_shot_frameno_) * (1000 / SERVER_FRAME_RATE)) >=
|
||||||
p_weapon->GetAttrValue(kHAT_FireRate)
|
p_weapon->GetFireRate(this)
|
||||||
) {
|
) {
|
||||||
Shot();
|
Shot();
|
||||||
}
|
}
|
||||||
|
@ -3105,34 +3105,6 @@ void Room::AddPlayerPostProc(Player* hum)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
|
||||||
xtimer.AddRepeatTimerAndAttach
|
|
||||||
(SERVER_FRAME_RATE * 5,
|
|
||||||
a8::XParams()
|
|
||||||
.SetSender(hum),
|
|
||||||
[] (const a8::XParams& param)
|
|
||||||
{
|
|
||||||
Human* hum = (Human*)param.sender.GetUserData();
|
|
||||||
std::string debugmsg = a8::Format("weapon_id:%d weapon_lv:%d atk:%f fire_rate:%f "
|
|
||||||
"volume:%d maxhp:%f hp:%f curr_hp:%f curr_max_hp:%f "
|
|
||||||
"base_reload_time:%f grow_reload_time:%f finaly_reload_time:%f",
|
|
||||||
{
|
|
||||||
hum->GetCurrWeapon()->weapon_id,
|
|
||||||
hum->GetCurrWeapon()->weapon_lv,
|
|
||||||
hum->GetCurrWeapon()->GetAttrValue(kHAT_Atk),
|
|
||||||
hum->GetCurrWeapon()->GetAttrValue(kHAT_FireRate),
|
|
||||||
hum->GetCurrWeapon()->GetAttrValue(kHAT_Volume),
|
|
||||||
hum->GetCurrWeapon()->GetAttrValue(kHAT_MaxHp),
|
|
||||||
hum->GetCurrWeapon()->GetAttrValue(kHAT_Hp),
|
|
||||||
hum->GetHP(),
|
|
||||||
hum->GetMaxHP(),
|
|
||||||
hum->GetCurrWeapon()->meta->i->reload_time(),
|
|
||||||
hum->GetCurrWeapon()->GetAttrValue(kHAT_ReloadTime)
|
|
||||||
});
|
|
||||||
hum->SendDebugMsg(debugmsg);
|
|
||||||
},
|
|
||||||
&hum->xtimer_attacher.timer_list_);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::AddToEntityHash(Entity* entity)
|
void Room::AddToEntityHash(Entity* entity)
|
||||||
|
@ -14,13 +14,13 @@ void Weapon::Clear()
|
|||||||
bullet_meta = nullptr;
|
bullet_meta = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Weapon::ToPB(cs::MFWeapon* pb_obj)
|
void Weapon::ToPB(Creature* c, cs::MFWeapon* pb_obj)
|
||||||
{
|
{
|
||||||
pb_obj->set_weapon_uniid(a8::XValue(weapon_uniid).GetString());
|
pb_obj->set_weapon_uniid(a8::XValue(weapon_uniid).GetString());
|
||||||
pb_obj->set_weapon_id(weapon_id);
|
pb_obj->set_weapon_id(weapon_id);
|
||||||
pb_obj->set_weapon_lv(weapon_lv);
|
pb_obj->set_weapon_lv(weapon_lv);
|
||||||
pb_obj->set_ammo(ammo);
|
pb_obj->set_ammo(ammo);
|
||||||
pb_obj->set_volume(GetClipVolume());
|
pb_obj->set_volume(GetClipVolume(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Weapon::Recalc()
|
void Weapon::Recalc()
|
||||||
@ -28,43 +28,17 @@ void Weapon::Recalc()
|
|||||||
bullet_meta = MetaMgr::Instance()->GetEquip(meta->i->use_bullet());
|
bullet_meta = MetaMgr::Instance()->GetEquip(meta->i->use_bullet());
|
||||||
}
|
}
|
||||||
|
|
||||||
int Weapon::GetClipVolume()
|
int Weapon::GetClipVolume(Creature* c)
|
||||||
{
|
{
|
||||||
return GetAttrValue(kHAT_Volume);
|
return meta->i->clip_volume();
|
||||||
}
|
}
|
||||||
|
|
||||||
float Weapon::GetAttrValue(HumanAttrType_e attr_type)
|
int Weapon::GetFireRate(Creature* c)
|
||||||
{
|
{
|
||||||
if (!meta) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
switch (attr_type) {
|
|
||||||
case kHAT_Atk:
|
|
||||||
{
|
|
||||||
return meta->i->atk();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case kHAT_FireRate:
|
|
||||||
{
|
|
||||||
return meta->i->fire_rate();
|
return meta->i->fire_rate();
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case kHAT_Volume:
|
int Weapon::GetReloadTime(Creature* c)
|
||||||
{
|
{
|
||||||
return meta->i->clip_volume();
|
return meta->i->reload_time();
|
||||||
}
|
|
||||||
break;
|
|
||||||
case kHAT_MaxHp:
|
|
||||||
{
|
|
||||||
return meta->i->max_hp();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case kHAT_ReloadTime:
|
|
||||||
{
|
|
||||||
return meta->i->reload_time();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
namespace cs
|
namespace cs
|
||||||
{
|
{
|
||||||
class MFWeapon;
|
class MFWeapon;
|
||||||
class MFSkin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace MetaData
|
namespace MetaData
|
||||||
@ -11,6 +10,7 @@ namespace MetaData
|
|||||||
struct Equip;
|
struct Equip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Creature;
|
||||||
struct Weapon
|
struct Weapon
|
||||||
{
|
{
|
||||||
long long weapon_uniid = 0;
|
long long weapon_uniid = 0;
|
||||||
@ -22,8 +22,9 @@ struct Weapon
|
|||||||
MetaData::Equip* bullet_meta = nullptr;
|
MetaData::Equip* bullet_meta = nullptr;
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
void ToPB(cs::MFWeapon* pb_obj);
|
void ToPB(Creature* c, cs::MFWeapon* pb_obj);
|
||||||
void Recalc();
|
void Recalc();
|
||||||
int GetClipVolume();
|
int GetClipVolume(Creature* c);
|
||||||
float GetAttrValue(HumanAttrType_e attr_type);
|
int GetFireRate(Creature* c);
|
||||||
|
int GetReloadTime(Creature* c);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user