This commit is contained in:
aozhiwei 2021-04-09 16:28:23 +08:00
commit 6d76bf63cd
11 changed files with 129 additions and 111 deletions

View File

@ -226,8 +226,8 @@ void AndroidNewAI::UpdateNewBieNpc()
hum->SetMoveDir(move_dir);
}
hum->attack_dir = hum->GetMoveDir();
if (hum->curr_weapon->weapon_idx != 0) {
hum->curr_weapon->ammo = MetaMgr::Instance()->newbie_first_robot_ammo;
if (hum->GetCurrWeapon()->weapon_idx != 0) {
hum->GetCurrWeapon()->ammo = MetaMgr::Instance()->newbie_first_robot_ammo;
}
} else if (hum->room->GetFrameNo() - hum->enable_frameno < SERVER_FRAME_RATE * 1.5) {
int speed = std::max(1, (int)hum->GetSpeed());
@ -262,8 +262,8 @@ void AndroidNewAI::UpdateLastNpc()
hum->SetMoveDir(move_dir);
}
hum->attack_dir = hum->GetMoveDir();
if (hum->curr_weapon->weapon_idx != 0) {
hum->curr_weapon->ammo = MetaMgr::Instance()->newbie_first_robot_ammo * 2;
if (hum->GetCurrWeapon()->weapon_idx != 0) {
hum->GetCurrWeapon()->ammo = MetaMgr::Instance()->newbie_first_robot_ammo * 2;
}
} else if (hum->room->GetFrameNo() - hum->enable_frameno < SERVER_FRAME_RATE * 1.5) {
int speed = std::max(1, (int)hum->GetSpeed());
@ -730,8 +730,8 @@ float AndroidNewAI::GetAttackRange()
{
float attack_range = 0;
Human* myself = (Human*)owner;
if (myself->curr_weapon && myself->curr_weapon->meta) {
attack_range = myself->curr_weapon->meta->i->range();
if (myself->GetCurrWeapon() && myself->GetCurrWeapon()->meta) {
attack_range = myself->GetCurrWeapon()->meta->i->range();
}
attack_range = std::min(ai_meta->i->attack_range(), (int)attack_range);
return attack_range;
@ -780,8 +780,8 @@ void AndroidNewAI::DoShotNewAI()
int AndroidNewAI::GetAttackTimes()
{
Human* myself = (Human*)owner;
if (myself->curr_weapon) {
return std::min(ai_meta->i->attack_times(), myself->curr_weapon->GetClipVolume());
if (myself->GetCurrWeapon()) {
return std::min(ai_meta->i->attack_times(), myself->GetCurrWeapon()->GetClipVolume());
} else {
return ai_meta->i->attack_times();
}

View File

@ -81,7 +81,7 @@ void Android::GiveEquip()
weapons[GUN_SLOT1].ammo = 0;
weapons[GUN_SLOT1].meta = weapon_meta;
weapons[GUN_SLOT1].Recalc();
curr_weapon = &weapons[GUN_SLOT1];
SetCurrWeapon(&weapons[GUN_SLOT1]);
}
sex = robot_meta->i->sex();
if (sex == 0) {

View File

@ -1077,18 +1077,18 @@ void Creature::UpdatePoisoning()
void Creature::Shot(a8::Vec2& target_dir, bool& shot_ok, float fly_distance)
{
shot_ok = false;
if (!curr_weapon->meta) {
if (!GetCurrWeapon()->meta) {
return;
}
if (downed) {
return;
}
if (!curr_weapon->meta) {
if (!GetCurrWeapon()->meta) {
return;
}
if (curr_weapon->weapon_idx != 0 &&
curr_weapon->ammo <= 0) {
if (GetCurrWeapon()->weapon_idx != 0 &&
GetCurrWeapon()->ammo <= 0) {
AutoLoadingBullet();
return;
}
@ -1104,42 +1104,42 @@ void Creature::Shot(a8::Vec2& target_dir, bool& shot_ok, float fly_distance)
}
if ((room->GetFrameNo() - last_shot_frameno_) * (1000 / SERVER_FRAME_RATE) <
curr_weapon->GetAttrValue(kHAT_FireRate)
GetCurrWeapon()->GetAttrValue(kHAT_FireRate)
) {
return;
}
InternalShot(this,
curr_weapon->meta,
curr_weapon->GetUpgradeMeta(),
curr_weapon->bullet_meta,
curr_weapon->weapon_lv,
GetCurrWeapon()->meta,
GetCurrWeapon()->GetUpgradeMeta(),
GetCurrWeapon()->bullet_meta,
GetCurrWeapon()->weapon_lv,
0,
fly_distance,
false);
if (curr_weapon->weapon_idx != 0) {
--curr_weapon->ammo;
if (GetCurrWeapon()->weapon_idx != 0) {
--GetCurrWeapon()->ammo;
}
int slot_id = curr_weapon->meta->i->_inventory_slot();
int slot_id = GetCurrWeapon()->meta->i->_inventory_slot();
#ifdef DEBUG
if (IsPlayer()) {
SendDebugMsg(a8::Format("使用武器 %s slot:%d", {curr_weapon->meta->i->name(), slot_id}));
SendDebugMsg(a8::Format("使用武器 %s slot:%d", {GetCurrWeapon()->meta->i->name(), slot_id}));
}
#endif
switch (slot_id) {
case IS_FRAG: //手雷
case IS_SMOKE: //烟雾弹
{
if (curr_weapon->ammo <= 0) {
if (GetCurrWeapon()->ammo <= 0) {
if (GetInventory(slot_id) > 0) {
DecInventory(slot_id, 1);
++curr_weapon->ammo;
++GetCurrWeapon()->ammo;
} else {
int weapon_idx = curr_weapon->weapon_idx;
*curr_weapon = Weapon();
curr_weapon->weapon_idx = weapon_idx;
curr_weapon = ChooseNextWeapon(slot_id, SPEC1_IS_BEGIN, SPEC1_IS_END);
int weapon_idx = GetCurrWeapon()->weapon_idx;
*GetCurrWeapon() = Weapon();
GetCurrWeapon()->weapon_idx = weapon_idx;
SetCurrWeapon(ChooseNextWeapon(slot_id, SPEC1_IS_BEGIN, SPEC1_IS_END));
AutoLoadingBullet();
}
}
@ -1152,15 +1152,15 @@ void Creature::Shot(a8::Vec2& target_dir, bool& shot_ok, float fly_distance)
case IS_TRAP: //陷井
case IS_MINE: //地雷
{
if (curr_weapon->ammo <= 0) {
if (GetCurrWeapon()->ammo <= 0) {
if (GetInventory(slot_id) > 0) {
DecInventory(slot_id, 1);
++curr_weapon->ammo;
++GetCurrWeapon()->ammo;
} else {
int weapon_idx = curr_weapon->weapon_idx;
*curr_weapon = Weapon();
curr_weapon->weapon_idx = weapon_idx;
curr_weapon = ChooseNextWeapon(slot_id, SPEC2_IS_BEGIN, SPEC2_IS_END);
int weapon_idx = GetCurrWeapon()->weapon_idx;
*GetCurrWeapon() = Weapon();
GetCurrWeapon()->weapon_idx = weapon_idx;
SetCurrWeapon(ChooseNextWeapon(slot_id, SPEC2_IS_BEGIN, SPEC2_IS_END));
AutoLoadingBullet();
}
}
@ -1173,8 +1173,8 @@ void Creature::Shot(a8::Vec2& target_dir, bool& shot_ok, float fly_distance)
}
break;
}
if (curr_weapon->weapon_idx != 0 &&
curr_weapon->ammo <= 0) {
if (GetCurrWeapon()->weapon_idx != 0 &&
GetCurrWeapon()->ammo <= 0) {
AutoLoadingBullet();
}
last_shot_frameno_ = room->GetFrameNo();
@ -1186,7 +1186,7 @@ void Creature::Shot(a8::Vec2& target_dir, bool& shot_ok, float fly_distance)
void Creature::AutoLoadingBullet(bool manual)
{
Weapon* p_weapon = curr_weapon;
Weapon* p_weapon = GetCurrWeapon();
if (car_weapon.meta) {
p_weapon = &car_weapon;
}
@ -1403,13 +1403,13 @@ CreatureWeakPtr Creature::AllocWeakPtr()
Weapon* Creature::AutoChgWeapon()
{
if (weapons[GUN_SLOT1].weapon_id != 0) {
curr_weapon = &weapons[GUN_SLOT1];
SetCurrWeapon(&weapons[GUN_SLOT1]);
} else if (weapons[GUN_SLOT2].weapon_id != 0) {
curr_weapon = &weapons[GUN_SLOT2];
SetCurrWeapon(&weapons[GUN_SLOT2]);
} else {
curr_weapon = &weapons[0];
SetCurrWeapon(&weapons[0]);
}
return curr_weapon;
return GetCurrWeapon();
}
Weapon* Creature::ChooseNextWeapon(int curr_weapon_slot_id, int begin_slot_id, int end_slot_id)
@ -1438,3 +1438,19 @@ Weapon* Creature::ChooseNextWeapon(int curr_weapon_slot_id, int begin_slot_id, i
}
return next_weapon ? next_weapon : AutoChgWeapon();
}
void Creature::SetCurrWeapon(Weapon* weapon)
{
#ifdef DEBUG
bool found = false;
for (auto& p : weapons) {
if (&p == weapon) {
found = true;
}
}
if (!found) {
abort();
}
#endif
curr_weapon_ = weapon;
}

View File

@ -46,7 +46,6 @@ class Creature : public MoveableEntity
bool poisoning = false;
long long poisoning_time = 0;
Weapon* curr_weapon = nullptr;
Weapon car_weapon;
bool need_sync_active_player = false;
@ -137,6 +136,8 @@ class Creature : public MoveableEntity
CreatureWeakPtr AllocWeakPtr();
Weapon* AutoChgWeapon();
Weapon* ChooseNextWeapon(int curr_weapon_slot_id, int begin_slot_id, int end_slot_id);
Weapon* GetCurrWeapon() { return curr_weapon_; };
void SetCurrWeapon(Weapon* weapon);
private:
@ -165,6 +166,7 @@ protected:
long long cell_flags_ = 0;
private:
Weapon* curr_weapon_ = nullptr;
CreatureWeakPtrChunk weak_ptr_chunk_;
std::array<float, kHAT_End> buff_attr_abs_ = {};
std::array<float, kHAT_End> buff_attr_rate_ = {};

View File

@ -49,7 +49,7 @@ void FrameEvent::AddShot(Creature* sender)
if (sender->car_weapon.meta) {
sender->car_weapon.ToPB(p.mutable_weapon());
} else {
sender->curr_weapon->ToPB(p.mutable_weapon());
sender->GetCurrWeapon()->ToPB(p.mutable_weapon());
}
}
{
@ -197,12 +197,12 @@ void FrameEvent::AddHpChg(Human* sender)
void FrameEvent::AddWeaponAmmoChg(Human* hum)
{
if (hum->curr_weapon) {
if (hum->GetCurrWeapon()) {
chged_weapon_ammo_.push_back
(
std::make_tuple(hum,
hum->curr_weapon->weapon_idx,
hum->curr_weapon->ammo
hum->GetCurrWeapon()->weapon_idx,
hum->GetCurrWeapon()->ammo
)
);
int idx = chged_weapon_ammo_.size() - 1;

View File

@ -115,11 +115,11 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
for (size_t idx : hum->chged_bullet_nums_) {
if (idx < room->frame_event.chged_bullet_nums_.size()) {
Human* target = room->frame_event.chged_bullet_nums_[idx];
if (target->curr_weapon) {
if (target->GetCurrWeapon()) {
auto p = msg->add_chged_property_list();
p->set_obj_id(target->GetEntityUniId());
p->set_property_type(kPropBulletNum);
p->set_value(target->curr_weapon->ammo);
p->set_value(target->GetCurrWeapon()->ammo);
}
}
}
@ -127,7 +127,7 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
for (size_t idx : hum->chged_tank_bullet_nums_) {
if (idx < room->frame_event.chged_tank_bullet_nums_.size()) {
Human* target = room->frame_event.chged_tank_bullet_nums_[idx];
if (target->curr_weapon) {
if (target->GetCurrWeapon()) {
auto p = msg->add_chged_property_list();
p->set_obj_id(target->GetEntityUniId());
p->set_property_type(kPropTankBulletNum);

View File

@ -360,8 +360,8 @@ float HeroAI::GetAttackRange()
{
float attack_range = 0;
Hero* myself = (Hero*)owner;
if (myself->curr_weapon && myself->curr_weapon->meta) {
attack_range = myself->curr_weapon->meta->i->range();
if (myself->GetCurrWeapon() && myself->GetCurrWeapon()->meta) {
attack_range = myself->GetCurrWeapon()->meta->i->range();
}
attack_range = std::min(ai_meta->i->attack_range(), (int)attack_range);
return attack_range;
@ -410,8 +410,8 @@ void HeroAI::DoShotAI()
int HeroAI::GetAttackTimes()
{
Hero* myself = (Hero*)owner;
if (myself->curr_weapon) {
return std::min(ai_meta->i->attack_times(), myself->curr_weapon->GetClipVolume());
if (myself->GetCurrWeapon()) {
return std::min(ai_meta->i->attack_times(), myself->GetCurrWeapon()->GetClipVolume());
} else {
return ai_meta->i->attack_times();
}

View File

@ -49,7 +49,7 @@ Human::Human():Creature()
skin.skin_lv = 1;
}
weapons[0] = default_weapon;
curr_weapon = &weapons[0];
SetCurrWeapon(&weapons[0]);
}
Human::~Human()
@ -88,8 +88,8 @@ float Human::GetSpeed()
return meta->i->move_speed3();
} else {
if (shot_hold) {
if (curr_weapon->weapon_idx == GUN_SLOT1 ||
curr_weapon->weapon_idx == GUN_SLOT2) {
if (GetCurrWeapon()->weapon_idx == GUN_SLOT1 ||
GetCurrWeapon()->weapon_idx == GUN_SLOT2) {
if (action_type != AT_Reload) {
return meta->i->shot_speed();
}
@ -143,7 +143,7 @@ void Human::FillMFObjectLess(Room* room, Human* hum, cs::MFPlayerFull* full_data
p->set_backpack(backpack);
p->set_helmet(helmet);
p->set_chest(chest);
curr_weapon->ToPB(p->mutable_weapon());
GetCurrWeapon()->ToPB(p->mutable_weapon());
}
void Human::FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data)
@ -168,7 +168,7 @@ void Human::FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data
p->set_backpack(backpack);
p->set_helmet(helmet);
p->set_chest(chest);
curr_weapon->ToPB(p->mutable_weapon());
GetCurrWeapon()->ToPB(p->mutable_weapon());
p->set_energy_shield(energy_shield);
#if 1
{
@ -1276,7 +1276,7 @@ void Human::FillMFActivePlayerData(cs::MFActivePlayerData* player_data)
player_data->set_chest(chest);
player_data->set_health(GetHP());
player_data->set_max_health(GetMaxHP());
player_data->set_cur_weapon_idx(curr_weapon->weapon_idx);
player_data->set_cur_weapon_idx(GetCurrWeapon()->weapon_idx);
player_data->set_cur_scope(curr_scope_idx);
for (auto& weapon : weapons) {
auto p = player_data->add_weapons();
@ -2274,7 +2274,7 @@ void Human::DeadDrop()
}
}
{
curr_weapon = &weapons[0];
SetCurrWeapon(&weapons[0]);
}
}
{
@ -3044,7 +3044,7 @@ void Human::OnMetaChange()
default_weapon.meta = weapon_meta;
default_weapon.Recalc();
weapons[0] = default_weapon;
curr_weapon = &weapons[0];
SetCurrWeapon(&weapons[0]);
}
}
ability.hp = meta->i->health();
@ -3114,7 +3114,7 @@ void Human::OnChgToTerminator()
void Human::ProcReloadAction()
{
Weapon* p_weapon = curr_weapon;
Weapon* p_weapon = GetCurrWeapon();
if (car_weapon.meta) {
p_weapon = &car_weapon;
}
@ -3226,7 +3226,7 @@ void Human::NextReload(int prev_weapon_id, int prev_weapon_idx)
if (action_type != AT_None) {
return;
}
Weapon* p_weapon = curr_weapon;
Weapon* p_weapon = GetCurrWeapon();
if (car_weapon.meta) {
p_weapon = &car_weapon;
}

View File

@ -190,7 +190,7 @@ void Player::UpdateShot()
Shot();
return;
}
Weapon* p_weapon = curr_weapon;
Weapon* p_weapon = GetCurrWeapon();
if (car_weapon.meta) {
p_weapon = &car_weapon;
}
@ -216,10 +216,10 @@ void Player::UpdateShot()
void Player::UpdateSelectWeapon()
{
if (selected_weapon_idx >= 0 && selected_weapon_idx < weapons.size()) {
Weapon* old_weapon = curr_weapon;
Weapon* old_weapon = GetCurrWeapon();
Weapon* weapon = &weapons[selected_weapon_idx];
if (weapon->weapon_id != 0) {
curr_weapon = weapon;
SetCurrWeapon(weapon);
ResetAction();
need_sync_active_player = true;
SyncAroundPlayers(__FILE__, __LINE__, __func__);
@ -517,14 +517,14 @@ void Player::LootInteraction(Loot* entity)
if (weapons[GUN_SLOT1].weapon_id == 0) {
weapon = &weapons[GUN_SLOT1];
weapon->weapon_idx = GUN_SLOT1;
if (curr_weapon != &weapons[GUN_SLOT2]) {
curr_weapon = &weapons[GUN_SLOT1];
if (GetCurrWeapon() != &weapons[GUN_SLOT2]) {
SetCurrWeapon(&weapons[GUN_SLOT1]);
}
} else if (weapons[GUN_SLOT2].weapon_id == 0) {
weapon = &weapons[GUN_SLOT2];
weapon->weapon_idx = GUN_SLOT2;
if (curr_weapon != &weapons[GUN_SLOT1]) {
curr_weapon = &weapons[GUN_SLOT2];
if (GetCurrWeapon() != &weapons[GUN_SLOT1]) {
SetCurrWeapon(&weapons[GUN_SLOT2]);
}
}
if (!weapon) {
@ -773,14 +773,14 @@ void Player::ProcPrepareItems(const ::google::protobuf::RepeatedField< ::google:
if (weapons[GUN_SLOT1].weapon_id == 0) {
weapon = &weapons[GUN_SLOT1];
weapon->weapon_idx = GUN_SLOT1;
if (curr_weapon != &weapons[GUN_SLOT2]) {
curr_weapon = &weapons[GUN_SLOT1];
if (GetCurrWeapon() != &weapons[GUN_SLOT2]) {
SetCurrWeapon(&weapons[GUN_SLOT1]);
}
} else if (weapons[GUN_SLOT2].weapon_id == 0) {
weapon = &weapons[GUN_SLOT2];
weapon->weapon_idx = GUN_SLOT2;
if (curr_weapon != &weapons[GUN_SLOT1]) {
curr_weapon = &weapons[GUN_SLOT2];
if (GetCurrWeapon() != &weapons[GUN_SLOT1]) {
SetCurrWeapon(&weapons[GUN_SLOT2]);
}
}
if (weapon) {
@ -891,12 +891,12 @@ void Player::ProcPrepareItems(const ::google::protobuf::RepeatedField< ::google:
}
}
}//end for
if (curr_weapon) {
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(curr_weapon->meta->i->use_bullet());
if (GetCurrWeapon()) {
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(GetCurrWeapon()->meta->i->use_bullet());
if (bullet_meta) {
int add_num = GetInventory(bullet_meta->i->_inventory_slot());
add_num = curr_weapon->GetClipVolume();
curr_weapon->ammo = add_num;
add_num = GetCurrWeapon()->GetClipVolume();
GetCurrWeapon()->ammo = add_num;
}
}
for (auto& spec_weapon : spec_weapons) {
@ -916,7 +916,7 @@ void Player::ProcPrepareItems(const ::google::protobuf::RepeatedField< ::google:
weapon->ammo = spec_weapon.ammo;
weapon->meta = item_meta;
weapon->Recalc();
curr_weapon = &weapons[GUN_SLOT1];
SetCurrWeapon(&weapons[GUN_SLOT1]);
}
}
}
@ -1110,48 +1110,48 @@ void Player::UpdateDropWeapon()
drop_ok = true;
*weapon = Weapon();
weapon->weapon_idx = drop_weapon_idx;
if (curr_weapon == weapon) {
if (GetCurrWeapon() == weapon) {
if (weapons[GUN_SLOT2].weapon_id != 0) {
curr_weapon = &weapons[GUN_SLOT2];
SetCurrWeapon(&weapons[GUN_SLOT2]);
} else {
curr_weapon = &weapons[0];
SetCurrWeapon(&weapons[0]);
}
}
} else if (weapon->weapon_idx == GUN_SLOT2) {
drop_ok = true;
*weapon = Weapon();
weapon->weapon_idx = drop_weapon_idx;
if (curr_weapon == weapon) {
if (GetCurrWeapon() == weapon) {
if (weapons[GUN_SLOT1].weapon_id != 0) {
curr_weapon = &weapons[GUN_SLOT1];
SetCurrWeapon(&weapons[GUN_SLOT1]);
} else {
curr_weapon = &weapons[0];
SetCurrWeapon(&weapons[0]);
}
}
} else if (weapon->weapon_idx == FRAG_SLOT) {
drop_ok = true;
*weapon = Weapon();
weapon->weapon_idx = drop_weapon_idx;
if (curr_weapon == weapon) {
if (GetCurrWeapon() == weapon) {
if (weapons[GUN_SLOT1].weapon_id != 0) {
curr_weapon = &weapons[GUN_SLOT1];
SetCurrWeapon(&weapons[GUN_SLOT1]);
} else if (weapons[GUN_SLOT2].weapon_id != 0) {
curr_weapon = &weapons[GUN_SLOT2];
SetCurrWeapon(&weapons[GUN_SLOT2]);
} else {
curr_weapon = &weapons[0];
SetCurrWeapon(&weapons[0]);
}
}
} else if (weapon->weapon_idx == SMOKE_SLOT) {
drop_ok = true;
*weapon = Weapon();
weapon->weapon_idx = drop_weapon_idx;
if (curr_weapon == weapon) {
if (GetCurrWeapon() == weapon) {
if (weapons[GUN_SLOT1].weapon_id != 0) {
curr_weapon = &weapons[GUN_SLOT1];
SetCurrWeapon(&weapons[GUN_SLOT1]);
} else if (weapons[GUN_SLOT2].weapon_id != 0) {
curr_weapon = &weapons[GUN_SLOT2];
SetCurrWeapon(&weapons[GUN_SLOT2]);
} else {
curr_weapon = &weapons[0];
SetCurrWeapon(&weapons[0]);
}
}
}

View File

@ -2577,7 +2577,7 @@ void Room::ProcDieAndroid(int die_time, int die_num)
if (killer && ((rand() % 100 < 70) || !gas_data_.old_area_meta)) {
hum->BeKill(killer->GetEntityUniId(),
killer->name,
killer->curr_weapon->weapon_id);
killer->GetCurrWeapon()->weapon_id);
a8::UnSetBitFlag(hum->status, HS_Disable);
} else {
hum->BeKill(VP_SafeArea,
@ -2643,7 +2643,7 @@ void Room::CheckAutoDie(Human* target,
a8::UnSetBitFlag(target->status, HS_Disable);
target->BeKill(killer->GetEntityUniId(),
killer->name,
killer->curr_weapon->weapon_id);
killer->GetCurrWeapon()->weapon_id);
} else {
a8::UnSetBitFlag(target->status, HS_Disable);
target->BeKill(VP_SafeArea,
@ -2942,20 +2942,20 @@ void Room::AddPlayerPostProc(Player* hum)
"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->curr_weapon->weapon_id,
hum->curr_weapon->weapon_lv,
hum->curr_weapon->GetAttrValue(kHAT_Atk),
hum->curr_weapon->GetAttrValue(kHAT_FireRate),
hum->curr_weapon->GetAttrValue(kHAT_Volume),
hum->curr_weapon->GetAttrValue(kHAT_MaxHp),
hum->curr_weapon->GetAttrValue(kHAT_Hp),
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->curr_weapon->meta->i->reload_time(),
hum->curr_weapon->GetUpgradeMeta() ?
hum->curr_weapon->GetUpgradeMeta()->GetAttrValue
(hum->curr_weapon->weapon_lv, kHAT_ReloadTime) : 0,
hum->curr_weapon->GetAttrValue(kHAT_ReloadTime)
hum->GetCurrWeapon()->meta->i->reload_time(),
hum->GetCurrWeapon()->GetUpgradeMeta() ?
hum->GetCurrWeapon()->GetUpgradeMeta()->GetAttrValue
(hum->GetCurrWeapon()->weapon_lv, kHAT_ReloadTime) : 0,
hum->GetCurrWeapon()->GetAttrValue(kHAT_ReloadTime)
});
hum->SendDebugMsg(debugmsg);
},

View File

@ -417,8 +417,8 @@ float ZombieModeAI::GetAttackRange()
{
float attack_range = 0;
Human* myself = (Human*)owner;
if (myself->curr_weapon && myself->curr_weapon->meta) {
attack_range = myself->curr_weapon->meta->i->range() + 10;
if (myself->GetCurrWeapon() && myself->GetCurrWeapon()->meta) {
attack_range = myself->GetCurrWeapon()->meta->i->range() + 10;
} else {
abort();
}
@ -486,8 +486,8 @@ int ZombieModeAI::GetAttackTimes()
{
Human* myself = (Human*)owner;
int attack_times = 0;
if (myself->curr_weapon) {
attack_times = std::min(node_->ai_meta->i->attack_times(), myself->curr_weapon->GetClipVolume());
if (myself->GetCurrWeapon()) {
attack_times = std::min(node_->ai_meta->i->attack_times(), myself->GetCurrWeapon()->GetClipVolume());
} else {
attack_times = node_->ai_meta->i->attack_times();
}