1
This commit is contained in:
parent
e658c5018d
commit
c7a15819a9
@ -117,6 +117,16 @@ void Human::Shot(Vector2D& target_dir)
|
|||||||
if (!curr_weapon->meta) {
|
if (!curr_weapon->meta) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (curr_weapon->weapon_idx != 0 &&
|
||||||
|
curr_weapon->ammo <= 0) {
|
||||||
|
AutoLoadingBullet();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
float fly_distance = 5;
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
::google::protobuf::RepeatedPtrField<::cs::MFShot>* shots = nullptr;
|
::google::protobuf::RepeatedPtrField<::cs::MFShot>* shots = nullptr;
|
||||||
{
|
{
|
||||||
@ -136,6 +146,10 @@ void Human::Shot(Vector2D& target_dir)
|
|||||||
shot->set_offhand(true);
|
shot->set_offhand(true);
|
||||||
shot->set_bullskin(10001);
|
shot->set_bullskin(10001);
|
||||||
}
|
}
|
||||||
|
for (auto& tuple : curr_weapon->meta->bullet_born_offset) {
|
||||||
|
Vector2D bullet_born_offset = Vector2D(std::get<0>(tuple), std::get<1>(tuple));
|
||||||
|
bullet_born_offset.Rotate(attack_dir.CalcAngle(Vector2D::UP));
|
||||||
|
Vector2D bullet_born_pos = pos + bullet_born_offset;
|
||||||
::google::protobuf::RepeatedPtrField<::cs::MFBullet>* bullets = nullptr;
|
::google::protobuf::RepeatedPtrField<::cs::MFBullet>* bullets = nullptr;
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@ -151,12 +165,62 @@ void Human::Shot(Vector2D& target_dir)
|
|||||||
cs::MFBullet* bullet = bullets->Add();
|
cs::MFBullet* bullet = bullets->Add();
|
||||||
bullet->set_player_id(entity_uniid);
|
bullet->set_player_id(entity_uniid);
|
||||||
bullet->set_bullet_id(curr_weapon->meta->i->use_bullet());
|
bullet->set_bullet_id(curr_weapon->meta->i->use_bullet());
|
||||||
pos.ToPB(bullet->mutable_pos());
|
bullet_born_pos.ToPB(bullet->mutable_pos());
|
||||||
target_dir.ToPB(bullet->mutable_dir());
|
attack_dir.ToPB(bullet->mutable_dir());
|
||||||
bullet->set_bulletskin(10001);
|
bullet->set_bulletskin(10001);
|
||||||
bullet->set_gun_id(curr_weapon->meta->i->id());
|
bullet->set_gun_id(curr_weapon->meta->i->id());
|
||||||
|
bullet->set_fly_distance(fly_distance);
|
||||||
}
|
}
|
||||||
room->CreateBullet(this, curr_weapon->meta, pos, target_dir, 0);
|
room->CreateBullet(this, curr_weapon->meta, bullet_born_pos, attack_dir, fly_distance);
|
||||||
|
}
|
||||||
|
--curr_weapon->ammo;
|
||||||
|
int slot_id = curr_weapon->meta->i->_inventory_slot();
|
||||||
|
switch (slot_id) {
|
||||||
|
case 5:
|
||||||
|
{
|
||||||
|
//手雷
|
||||||
|
if (inventory[slot_id] > 0) {
|
||||||
|
--inventory[slot_id];
|
||||||
|
++curr_weapon->ammo;
|
||||||
|
} else {
|
||||||
|
int weapon_idx = curr_weapon->weapon_idx;
|
||||||
|
*curr_weapon = Weapon();
|
||||||
|
curr_weapon->weapon_idx = weapon_idx;
|
||||||
|
if (weapons[SMOKE_SLOT].weapon_id != 0) {
|
||||||
|
curr_weapon = &weapons[SMOKE_SLOT];
|
||||||
|
} else {
|
||||||
|
curr_weapon = &weapons[0];
|
||||||
|
}
|
||||||
|
AutoLoadingBullet();
|
||||||
|
}
|
||||||
|
need_sync_active_player = true;
|
||||||
|
SyncAroundPlayers();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
{
|
||||||
|
//烟雾弹
|
||||||
|
if (inventory[slot_id] > 0) {
|
||||||
|
--inventory[slot_id];
|
||||||
|
++curr_weapon->ammo;
|
||||||
|
} else {
|
||||||
|
int weapon_idx = curr_weapon->weapon_idx;
|
||||||
|
*curr_weapon = Weapon();
|
||||||
|
curr_weapon->weapon_idx = weapon_idx;
|
||||||
|
if (weapons[FRAG_SLOT].weapon_id != 0) {
|
||||||
|
curr_weapon = &weapons[FRAG_SLOT];
|
||||||
|
} else {
|
||||||
|
curr_weapon = &weapons[0];
|
||||||
|
}
|
||||||
|
AutoLoadingBullet();
|
||||||
|
}
|
||||||
|
need_sync_active_player = true;
|
||||||
|
SyncAroundPlayers();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
last_shot_frameno_ = room->frame_no;
|
||||||
|
need_sync_active_player = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::RecalcSelfCollider()
|
void Human::RecalcSelfCollider()
|
||||||
@ -413,5 +477,5 @@ void Human::DecHP(float dec_hp, int killer_id, const std::string& killer_name)
|
|||||||
if (health <= 0.0001f) {
|
if (health <= 0.0001f) {
|
||||||
BeKill(killer_id, killer_name);
|
BeKill(killer_id, killer_name);
|
||||||
}
|
}
|
||||||
need_sync_active_player = true;
|
SyncAroundPlayers();
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,8 @@ class Human : public Entity
|
|||||||
void BeKill(int killer_id, const std::string& killer_name);
|
void BeKill(int killer_id, const std::string& killer_name);
|
||||||
void DecHP(float dec_hp, int killer_id, const std::string& killer_name);
|
void DecHP(float dec_hp, int killer_id, const std::string& killer_name);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
long long last_shot_frameno_ = 0;
|
||||||
private:
|
private:
|
||||||
CircleCollider* self_collider_ = nullptr;
|
CircleCollider* self_collider_ = nullptr;
|
||||||
|
|
||||||
|
@ -799,6 +799,7 @@ void Player::FillMFActivePlayerData(cs::MFActivePlayerData* player_data)
|
|||||||
player_data->set_backpack(backpack);
|
player_data->set_backpack(backpack);
|
||||||
player_data->set_helmet(helmet);
|
player_data->set_helmet(helmet);
|
||||||
player_data->set_chest(chest);
|
player_data->set_chest(chest);
|
||||||
|
player_data->set_health(health);
|
||||||
player_data->set_cur_weapon_idx(curr_weapon->weapon_idx);
|
player_data->set_cur_weapon_idx(curr_weapon->weapon_idx);
|
||||||
player_data->set_cur_scope(curr_scope_idx);
|
player_data->set_cur_scope(curr_scope_idx);
|
||||||
for (auto& weapon : weapons) {
|
for (auto& weapon : weapons) {
|
||||||
|
@ -97,7 +97,6 @@ class Player : public Human
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int send_update_msg_times = 0;
|
int send_update_msg_times = 0;
|
||||||
long long last_shot_frameno_ = 0;
|
|
||||||
cs::SMUpdate* update_msg = nullptr;
|
cs::SMUpdate* update_msg = nullptr;
|
||||||
long long last_sync_gas_frameno = 0;
|
long long last_sync_gas_frameno = 0;
|
||||||
void MakeUpdateMsg();
|
void MakeUpdateMsg();
|
||||||
|
@ -354,6 +354,8 @@ message MFActivePlayerData
|
|||||||
optional int32 helmet = 32; //头盔
|
optional int32 helmet = 32; //头盔
|
||||||
optional int32 chest = 33; //防弹衣
|
optional int32 chest = 33; //防弹衣
|
||||||
|
|
||||||
|
optional float health = 34; //血量
|
||||||
|
|
||||||
optional int32 cur_scope = 10; //当前视野倍数 1 2 4 8 15
|
optional int32 cur_scope = 10; //当前视野倍数 1 2 4 8 15
|
||||||
/*
|
/*
|
||||||
0: 9mm
|
0: 9mm
|
||||||
|
Loading…
x
Reference in New Issue
Block a user