add other object

This commit is contained in:
aozhiwei 2019-03-18 15:14:37 +08:00
parent 02e39e1cc0
commit 7b8ecf7e39
22 changed files with 26 additions and 4 deletions

View File

@ -98,7 +98,8 @@ void AndroidAI::DoAttack()
if (owner->updated_times % 2 == 0) {
Human* enemy = owner->room->SearchEnemy((Human*)owner);
if (enemy) {
Human* sender = (Human*)owner;
sender->Shot(enemy->pos, 10.0);
}
}
}

View File

View File

View File

View File

View File

View File

View File

@ -54,3 +54,22 @@ void Human::FillMFObjectFull(cs::MFObjectFull* full_data)
p->set_vip(vip);
p->set_sdmg(sdmg);
}
void Human::Shot(Vector2D& target_point, float speed)
{
{
cs::MFShot* shot = frame_data.shots.Add();
shot->set_player_id(entity_uniid);
shot->set_weapon_id(10001);
shot->set_offhand(true);
shot->set_bullskin(10001);
}
{
cs::MFBullet* bullet = frame_data.bullets.Add();
bullet->set_player_id(entity_uniid);
bullet->set_bullet_id(10001);
target_point.ToPB(bullet->mutable_pos());
(pos - target_point).Normalize().ToPB(bullet->mutable_dir());
bullet->set_bulletskin(10001);
}
}

View File

@ -51,5 +51,6 @@ class Human : public Entity
virtual float GetSpeed() override;
virtual void FillMFObjectPart(cs::MFObjectPart* part_data) override;
virtual void FillMFObjectFull(cs::MFObjectFull* full_data) override;
void Shot(Vector2D& target_point, float speed);
};

View File

0
server/gameserver/loot.h Normal file
View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

@ -11,12 +11,13 @@ void Vector2D::ToPB(cs::MFVector2D* pb_obj)
pb_obj->set_y(y);
}
void Vector2D::Normalize()
Vector2D& Vector2D::Normalize()
{
Eigen::Vector2f v(x, y);
v.normalize();
x = v[0];
y = v[1];
return *this;
}
bool Vector2D::operator == (const Vector2D& b)

View File

@ -22,7 +22,7 @@ struct Vector2D
Vector2D(float _x = 0.0f, float _y = 0.0f):x(_x), y(_y) {};
void ToPB(cs::MFVector2D* pb_obj);
void Normalize();
Vector2D& Normalize();
bool operator == (const Vector2D& b);
Vector2D operator + (const Vector2D& b);

View File

@ -392,7 +392,7 @@ message MFBullet
optional MFVector2D pos = 3;
optional MFVector2D dir = 4;
optional float variance_t = 5;
optional int32 bullskin = 6;
optional int32 bulletskin = 6;
optional bool crit = 7;
optional int32 reflect_count = 8;
optional int32 reflect_objid = 9;