完成shot改造

This commit is contained in:
aozhiwei 2020-07-27 14:18:06 +08:00
parent eb7c60e2ce
commit 9578fe6f06
3 changed files with 64 additions and 215 deletions

View File

@ -30,31 +30,16 @@ const int kReviveTimeAdd = 12;
const int kSkinNum = 4;
const int kREVIVE_BUFF_ID = 0;
static void InternalShot(Human* hum, MetaData::Equip* bullet_meta, int skill_id, bool& shot_ok)
void InternalShot(Human* hum,
MetaData::Equip* weapon_meta,
MetaData::EquipUpgrade* weapon_upgrade_meta,
MetaData::Equip* bullet_meta,
int weapon_lv,
int skill_id,
float fly_distance,
bool is_tank_skin)
{
shot_ok = false;
if (!bullet_meta) {
return;
}
#if 0
if (curr_weapon->weapon_idx != 0 &&
curr_weapon->ammo <= 0) {
AutoLoadingBullet();
return;
}
if ((room->GetFrameNo() - last_shot_frameno_) * (1000 / SERVER_FRAME_RATE) <
curr_weapon->GetAttrValue(kHAT_FireRate)
) {
return;
}
#endif
#if 1
float fly_distance = 5;
#endif
for (auto& tuple : bullet_meta->bullet_born_offset) {
for (auto& tuple : weapon_meta->bullet_born_offset) {
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
bullet_born_offset.Rotate(hum->attack_dir.CalcAngle(a8::Vec2::UP));
a8::Vec2 bullet_born_pos = hum->GetPos() + bullet_born_offset;
@ -63,14 +48,14 @@ static void InternalShot(Human* hum, MetaData::Equip* bullet_meta, int skill_id,
}
}
hum->room->frame_event.AddShot(hum);
for (auto& tuple : bullet_meta->bullet_born_offset) {
for (auto& tuple : weapon_meta->bullet_born_offset) {
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
bullet_born_offset.Rotate(hum->attack_dir.CalcAngle(a8::Vec2::UP));
a8::Vec2 bullet_born_pos = hum->GetPos() + bullet_born_offset;
a8::Vec2 bullet_dir = hum->attack_dir;
float bullet_angle = std::get<2>(tuple);
if (bullet_meta->i->bullet_angle() >= 0.10f) {
int angle = (int)bullet_meta->i->bullet_angle() * 1000;
if (weapon_meta->i->bullet_angle() >= 0.10f) {
int angle = (int)weapon_meta->i->bullet_angle() * 1000;
#if 0
if (curr_weapon->GetUpgradeMeta()) {
angle -= curr_weapon->GetAttrValue(kHAT_BulletAngle) * 1000;
@ -81,72 +66,22 @@ static void InternalShot(Human* hum, MetaData::Equip* bullet_meta, int skill_id,
}
}
bullet_dir.Rotate(bullet_angle / 180.0f);
if (hum->GetCar().car_id != 0) {
bullet_born_pos.x += MetaMgr::Instance()->horse_shoot_x;
bullet_born_pos.y += MetaMgr::Instance()->horse_shoot_y;
}
hum->room->frame_event.AddBullet(hum, bullet_born_pos, bullet_dir, fly_distance);
#if 0
hum->room->CreateBullet(hum, curr_weapon, bullet_born_pos, bullet_dir, fly_distance);
#endif
}
#if 0
--curr_weapon->ammo;
#endif
int slot_id = bullet_meta->i->_inventory_slot();
switch (slot_id) {
case 5:
{
//手雷
if (hum->GetInventory(slot_id) > 0) {
hum->DecInventory(slot_id, 1);
#if 0
++curr_weapon->ammo;
#endif
} else {
#if 0
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];
}
#endif
hum->AutoLoadingBullet();
}
hum->need_sync_active_player = true;
hum->SyncAroundPlayers(__FILE__, __LINE__, __func__);
if (hum->room->BattleStarted()) {
hum->room->CreateBullet(hum,
weapon_meta,
weapon_upgrade_meta,
bullet_meta,
bullet_born_pos,
bullet_dir,
fly_distance,
is_tank_skin);
}
break;
case 6:
{
//烟雾弹
if (hum->GetInventory(slot_id) > 0) {
hum->DecInventory(slot_id, 1);
#if 0
++curr_weapon->ammo;
#endif
} else {
#if 0
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];
}
#endif
hum->AutoLoadingBullet();
}
hum->need_sync_active_player = true;
hum->SyncAroundPlayers(__FILE__, __LINE__, __func__);
}
break;
}
hum->last_shot_frameno_ = hum->room->GetFrameNo();
if (!hum->need_sync_active_player) {
hum->room->frame_event.AddBulletNumChg(hum);
}
shot_ok = true;
}
Human::Human():MoveableEntity()
@ -458,43 +393,15 @@ void Human::Shot(a8::Vec2& target_dir, bool& shot_ok)
return;
}
#if 1
float fly_distance = 5;
#endif
for (auto& tuple : curr_weapon->meta->bullet_born_offset) {
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
bullet_born_offset.Rotate(attack_dir.CalcAngle(a8::Vec2::UP));
a8::Vec2 bullet_born_pos = GetPos() + bullet_born_offset;
if (room->OverBorder(bullet_born_pos, 0)) {
return;
}
}
room->frame_event.AddShot(this);
for (auto& tuple : curr_weapon->meta->bullet_born_offset) {
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
bullet_born_offset.Rotate(attack_dir.CalcAngle(a8::Vec2::UP));
a8::Vec2 bullet_born_pos = GetPos() + bullet_born_offset;
a8::Vec2 bullet_dir = attack_dir;
float bullet_angle = std::get<2>(tuple);
if (curr_weapon->meta->i->bullet_angle() >= 0.10f) {
int angle = (int)curr_weapon->meta->i->bullet_angle() * 1000;
if (curr_weapon->GetUpgradeMeta()) {
angle -= curr_weapon->GetAttrValue(kHAT_BulletAngle) * 1000;
}
if (angle > 0) {
bullet_angle += (rand() % angle) / 1000.0f * (rand() % 2 == 0 ? 1 : -1);
}
}
bullet_dir.Rotate(bullet_angle / 180.0f);
room->frame_event.AddBullet(this, bullet_born_pos, bullet_dir, fly_distance);
room->CreateBullet(this,
curr_weapon->meta,
curr_weapon->GetUpgradeMeta(),
curr_weapon->bullet_meta,
bullet_born_pos,
bullet_dir,
fly_distance);
}
InternalShot(this,
curr_weapon->meta,
curr_weapon->GetUpgradeMeta(),
curr_weapon->bullet_meta,
curr_weapon->weapon_lv,
0,
5,
false);
--curr_weapon->ammo;
int slot_id = curr_weapon->meta->i->_inventory_slot();
switch (slot_id) {
@ -560,43 +467,16 @@ void Human::TankShot(a8::Vec2& target_dir)
if (tank_weapon.ammo <= 0) {
return;
}
for (auto& tuple : tank_weapon.meta->bullet_born_offset) {
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
bullet_born_offset.Rotate(attack_dir.CalcAngle(a8::Vec2::UP));
a8::Vec2 bullet_born_pos = GetPos() + bullet_born_offset;
if (room->OverBorder(bullet_born_pos, 0)) {
return;
}
}
room->frame_event.AddShot(this);
for (auto& tuple : tank_weapon.meta->bullet_born_offset) {
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
bullet_born_offset.Rotate(attack_dir.CalcAngle(a8::Vec2::UP));
a8::Vec2 bullet_born_pos = GetPos() + bullet_born_offset;
a8::Vec2 bullet_dir = attack_dir;
float bullet_angle = std::get<2>(tuple);
if (tank_weapon.meta->i->bullet_angle() >= 0.01f) {
int angle = (int)tank_weapon.meta->i->bullet_angle() * 1000;
if (tank_weapon.GetUpgradeMeta()) {
angle -= tank_weapon.GetAttrValue(kHAT_BulletAngle) * 1000;
}
if (angle > 0) {
bullet_angle += (rand() % angle) / 1000.0f * (rand() % 2 == 0 ? 1 : -1);
}
}
bullet_dir.Rotate(bullet_angle / 180.0f);
room->frame_event.AddBullet(this, bullet_born_pos, bullet_dir, fly_distance);
if (room->BattleStarted()) {
room->CreateBullet(this,
tank_weapon.meta,
tank_weapon.GetUpgradeMeta(),
tank_weapon.bullet_meta,
bullet_born_pos,
bullet_dir,
fly_distance,
true);
}
}
InternalShot(this,
tank_weapon.meta,
tank_weapon.GetUpgradeMeta(),
tank_weapon.bullet_meta,
tank_weapon.weapon_lv,
0,
5,
true);
--tank_weapon.ammo;
last_shot_frameno_ = room->GetFrameNo();
room->frame_event.AddTankBulletNumChg(this);

View File

@ -286,6 +286,7 @@ class Human : public MoveableEntity
void ChangeToRace(RaceType_e race, int level);
void ChangeToRaceAndNotify(RaceType_e race, int level);
void WinExp(Human* sender, int exp);
HumanCar& GetCar() { return car_; }
protected:
void _InternalUpdateMove(float speed);
@ -404,3 +405,12 @@ private:
friend class FrameMaker;
friend class FrameEvent;
};
void InternalShot(Human* hum,
MetaData::Equip* weapon_meta,
MetaData::EquipUpgrade* weapon_upgrade_meta,
MetaData::Equip* bullet_meta,
int weapon_lv,
int skill_id,
float fly_distance,
bool is_tank_skin);

View File

@ -344,57 +344,16 @@ void Player::Shot()
action_type == AT_Relive) {
CancelAction();
}
#if 1
if (true) {
#else
if (room->gas_data.gas_mode != GasInactive &&
!a8::HasBitFlag(status, HS_Fly) &&
!a8::HasBitFlag(status, HS_Jump)
) {
#endif
for (auto& tuple : curr_weapon->meta->bullet_born_offset) {
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
bullet_born_offset.Rotate(attack_dir.CalcAngle(a8::Vec2::UP));
a8::Vec2 bullet_born_pos = GetPos() + bullet_born_offset;
if (room->OverBorder(bullet_born_pos, 0)) {
return;
}
}
room->frame_event.AddShot(this);
for (auto& tuple : curr_weapon->meta->bullet_born_offset) {
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
bullet_born_offset.Rotate(attack_dir.CalcAngle(a8::Vec2::UP));
a8::Vec2 bullet_born_pos = GetPos() + bullet_born_offset;
a8::Vec2 bullet_dir = attack_dir;
float bullet_angle = std::get<2>(tuple);
if (curr_weapon->meta->i->bullet_angle() >= 0.01f) {
int angle = (int)curr_weapon->meta->i->bullet_angle() * 1000;
if (curr_weapon->GetUpgradeMeta()) {
angle -= curr_weapon->GetAttrValue(kHAT_BulletAngle) * 1000;
}
if (angle > 0) {
bullet_angle += (rand() % angle) / 1000.0f * (rand() % 2 == 0 ? 1 : -1);
}
}
bullet_dir.Rotate(bullet_angle / 180.0f);
if (car_.car_id != 0) {
bullet_born_pos.x += MetaMgr::Instance()->horse_shoot_x;
bullet_born_pos.y += MetaMgr::Instance()->horse_shoot_y;
}
room->frame_event.AddBullet(this, bullet_born_pos, bullet_dir, fly_distance);
if (room->BattleStarted()) {
room->CreateBullet(this,
curr_weapon->meta,
curr_weapon->GetUpgradeMeta(),
curr_weapon->bullet_meta,
bullet_born_pos,
bullet_dir,
fly_distance);
}
}
} else {
return;
}
InternalShot(this,
curr_weapon->meta,
curr_weapon->GetUpgradeMeta(),
curr_weapon->bullet_meta,
curr_weapon->weapon_lv,
0,
fly_distance,
false);
if (curr_weapon->weapon_idx != 0) {
--curr_weapon->ammo;
}