添加散弹枪处理
This commit is contained in:
parent
68d2d372d0
commit
7399c136b8
@ -106,6 +106,7 @@ void AndroidAI::DoMove()
|
|||||||
|
|
||||||
void AndroidAI::DoAttack()
|
void AndroidAI::DoAttack()
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
Human* hum = (Human*)owner;
|
Human* hum = (Human*)owner;
|
||||||
if (a8::HasBitFlag(hum->status, HS_Fly) ||
|
if (a8::HasBitFlag(hum->status, HS_Fly) ||
|
||||||
a8::HasBitFlag(hum->status, HS_Jump)) {
|
a8::HasBitFlag(hum->status, HS_Jump)) {
|
||||||
@ -123,4 +124,5 @@ void AndroidAI::DoAttack()
|
|||||||
sender->Shot(shot_dir);
|
sender->Shot(shot_dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ void FrameEvent::AddShot(Human* hum)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameEvent::AddBullet(Human* hum, Vector2D born_pos, float fly_distance)
|
void FrameEvent::AddBullet(Human* hum, Vector2D born_pos, Vector2D dir, float fly_distance)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
auto& tuple = a8::FastAppend(bullets_);
|
auto& tuple = a8::FastAppend(bullets_);
|
||||||
@ -65,7 +65,7 @@ void FrameEvent::AddBullet(Human* hum, Vector2D born_pos, float fly_distance)
|
|||||||
p.set_player_id(hum->entity_uniid);
|
p.set_player_id(hum->entity_uniid);
|
||||||
p.set_bullet_id(hum->curr_weapon->meta->i->use_bullet());
|
p.set_bullet_id(hum->curr_weapon->meta->i->use_bullet());
|
||||||
born_pos.ToPB(p.mutable_pos());
|
born_pos.ToPB(p.mutable_pos());
|
||||||
hum->attack_dir.ToPB(p.mutable_dir());
|
dir.ToPB(p.mutable_dir());
|
||||||
p.set_bulletskin(10001);
|
p.set_bulletskin(10001);
|
||||||
p.set_gun_id(hum->curr_weapon->meta->i->id());
|
p.set_gun_id(hum->curr_weapon->meta->i->id());
|
||||||
p.set_fly_distance(fly_distance);
|
p.set_fly_distance(fly_distance);
|
||||||
|
@ -10,7 +10,7 @@ public:
|
|||||||
void AddAirDrop(int appear_time, int box_id, Vector2D box_pos);
|
void AddAirDrop(int appear_time, int box_id, Vector2D box_pos);
|
||||||
void AddEmote(Human* hum, int emote_id);
|
void AddEmote(Human* hum, int emote_id);
|
||||||
void AddShot(Human* hum);
|
void AddShot(Human* hum);
|
||||||
void AddBullet(Human* hum, Vector2D born_pos, float fly_distance);
|
void AddBullet(Human* hum, Vector2D born_pos, Vector2D dir, float fly_distance);
|
||||||
void AddExplosion(Bullet* bullet, int item_id, Vector2D bomb_pos);
|
void AddExplosion(Bullet* bullet, int item_id, Vector2D bomb_pos);
|
||||||
void AddSmoke(Bullet* bullet, int item_id, Vector2D pos);
|
void AddSmoke(Bullet* bullet, int item_id, Vector2D pos);
|
||||||
void AddExplosionEx(Human* sender, int item_id, Vector2D bomb_pos, int effect);
|
void AddExplosionEx(Human* sender, int item_id, Vector2D bomb_pos, int effect);
|
||||||
|
@ -166,7 +166,7 @@ void Human::Shot(Vector2D& target_dir)
|
|||||||
Vector2D bullet_born_offset = Vector2D(std::get<0>(tuple), std::get<1>(tuple));
|
Vector2D bullet_born_offset = Vector2D(std::get<0>(tuple), std::get<1>(tuple));
|
||||||
bullet_born_offset.Rotate(attack_dir.CalcAngle(Vector2D::UP));
|
bullet_born_offset.Rotate(attack_dir.CalcAngle(Vector2D::UP));
|
||||||
Vector2D bullet_born_pos = pos + bullet_born_offset;
|
Vector2D bullet_born_pos = pos + bullet_born_offset;
|
||||||
room->frame_event.AddBullet(this, bullet_born_pos, fly_distance);
|
room->frame_event.AddBullet(this, bullet_born_pos, attack_dir, fly_distance);
|
||||||
room->CreateBullet(this, curr_weapon->meta, bullet_born_pos, attack_dir, fly_distance);
|
room->CreateBullet(this, curr_weapon->meta, bullet_born_pos, attack_dir, fly_distance);
|
||||||
}
|
}
|
||||||
--curr_weapon->ammo;
|
--curr_weapon->ammo;
|
||||||
|
@ -52,10 +52,11 @@ namespace MetaData
|
|||||||
for (auto& str : strings) {
|
for (auto& str : strings) {
|
||||||
std::vector<std::string> strings2;
|
std::vector<std::string> strings2;
|
||||||
a8::Split(str, strings2, ':');
|
a8::Split(str, strings2, ':');
|
||||||
assert(strings2.size() == 2);
|
assert(strings2.size() >= 2);
|
||||||
bullet_born_offset.push_back(std::make_tuple(
|
bullet_born_offset.push_back(std::make_tuple(
|
||||||
a8::XValue(strings2[0]).GetDouble(),
|
a8::XValue(strings2[0]).GetDouble(),
|
||||||
a8::XValue(strings2[1]).GetDouble()
|
a8::XValue(strings2[1]).GetDouble(),
|
||||||
|
strings2.size() > 2 ? a8::XValue(strings2[2]).GetDouble() : 0
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ namespace MetaData
|
|||||||
{
|
{
|
||||||
const metatable::Equip* i = nullptr;
|
const metatable::Equip* i = nullptr;
|
||||||
|
|
||||||
std::vector<std::tuple<float, float>> bullet_born_offset;
|
std::vector<std::tuple<float, float, float>> bullet_born_offset;
|
||||||
std::array<int, IS_END> volume = {};
|
std::array<int, IS_END> volume = {};
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
@ -447,8 +447,14 @@ void Player::Shot()
|
|||||||
Vector2D bullet_born_offset = Vector2D(std::get<0>(tuple), std::get<1>(tuple));
|
Vector2D bullet_born_offset = Vector2D(std::get<0>(tuple), std::get<1>(tuple));
|
||||||
bullet_born_offset.Rotate(attack_dir.CalcAngle(Vector2D::UP));
|
bullet_born_offset.Rotate(attack_dir.CalcAngle(Vector2D::UP));
|
||||||
Vector2D bullet_born_pos = pos + bullet_born_offset;
|
Vector2D bullet_born_pos = pos + bullet_born_offset;
|
||||||
room->frame_event.AddBullet(this, bullet_born_pos, fly_distance);
|
Vector2D bullet_dir = attack_dir;
|
||||||
room->CreateBullet(this, curr_weapon->meta, bullet_born_pos, attack_dir, fly_distance);
|
float bullet_angle = std::get<0>(tuple);
|
||||||
|
if (curr_weapon->meta->i->bullet_angle() >= 1.0f) {
|
||||||
|
bullet_angle += (rand() % (int)curr_weapon->meta->i->bullet_angle()) * (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, bullet_born_pos, bullet_dir, fly_distance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (curr_weapon->weapon_idx != 0) {
|
if (curr_weapon->weapon_idx != 0) {
|
||||||
|
@ -125,6 +125,16 @@ float Vector2D::CalcAngle(const Vector2D& b)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2D Vector2D::FromAngle(float angle)
|
||||||
|
{
|
||||||
|
Vector2D vec2;
|
||||||
|
float hu = angle * 3.1415926f / 180.0f;
|
||||||
|
vec2.x = cos(hu);
|
||||||
|
vec2.y = sin(hu);
|
||||||
|
vec2.Normalize();
|
||||||
|
return vec2;
|
||||||
|
}
|
||||||
|
|
||||||
Vector2D Vector2D::Perp()
|
Vector2D Vector2D::Perp()
|
||||||
{
|
{
|
||||||
return Vector2D(y, -x);
|
return Vector2D(y, -x);
|
||||||
|
@ -18,6 +18,7 @@ struct Vector2D
|
|||||||
void Normalize();
|
void Normalize();
|
||||||
void Rotate(float angle);
|
void Rotate(float angle);
|
||||||
float CalcAngle(const Vector2D& b);
|
float CalcAngle(const Vector2D& b);
|
||||||
|
static Vector2D FromAngle(float angle);
|
||||||
|
|
||||||
bool operator == (const Vector2D& b) const;
|
bool operator == (const Vector2D& b) const;
|
||||||
Vector2D operator + (const Vector2D& b) const;
|
Vector2D operator + (const Vector2D& b) const;
|
||||||
|
@ -75,6 +75,7 @@ message Equip
|
|||||||
optional int32 bullet_rad = 20; //子弹半径
|
optional int32 bullet_rad = 20; //子弹半径
|
||||||
optional int32 group_num = 21; //每组数量
|
optional int32 group_num = 21; //每组数量
|
||||||
optional string bullet_born_offset = 30; //子弹出生偏移
|
optional string bullet_born_offset = 30; //子弹出生偏移
|
||||||
|
optional float bullet_angle = 34; //子弹浮动方向
|
||||||
|
|
||||||
optional string inventory_slot = 31; //库存槽位
|
optional string inventory_slot = 31; //库存槽位
|
||||||
optional int32 _inventory_slot = 32; //库存槽位
|
optional int32 _inventory_slot = 32; //库存槽位
|
||||||
|
Loading…
x
Reference in New Issue
Block a user