完善子弹luoj
This commit is contained in:
parent
9493d04527
commit
1288ebfc20
@ -11,6 +11,7 @@
|
|||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "perfmonitor.h"
|
#include "perfmonitor.h"
|
||||||
#include "smoke_mitask.h"
|
#include "smoke_mitask.h"
|
||||||
|
#include "creature.h"
|
||||||
|
|
||||||
Bullet::Bullet():MoveableEntity()
|
Bullet::Bullet():MoveableEntity()
|
||||||
{
|
{
|
||||||
@ -77,8 +78,10 @@ void Bullet::OnHit(std::set<Entity*>& objects)
|
|||||||
hum->GetAttrAbs(kHAT_Def);
|
hum->GetAttrAbs(kHAT_Def);
|
||||||
float finaly_dmg = dmg * (1 - def/MetaMgr::Instance()->K);
|
float finaly_dmg = dmg * (1 - def/MetaMgr::Instance()->K);
|
||||||
finaly_dmg = std::max(finaly_dmg, 0.0f);
|
finaly_dmg = std::max(finaly_dmg, 0.0f);
|
||||||
|
#if 0
|
||||||
sender->stats.damage_amount_out += finaly_dmg;
|
sender->stats.damage_amount_out += finaly_dmg;
|
||||||
hum->DecHP(finaly_dmg, sender->GetEntityUniId(), sender->name, gun_meta->i->id());
|
#endif
|
||||||
|
hum->DecHP(finaly_dmg, sender->GetEntityUniId(), sender->GetName(), gun_meta->i->id());
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
sender->SendDebugMsg(a8::Format("bullet weapon_id:%d atk:%f",
|
sender->SendDebugMsg(a8::Format("bullet weapon_id:%d atk:%f",
|
||||||
{
|
{
|
||||||
|
@ -11,6 +11,7 @@ namespace MetaData
|
|||||||
|
|
||||||
class Human;
|
class Human;
|
||||||
class Obstacle;
|
class Obstacle;
|
||||||
|
class Creature;
|
||||||
class CircleCollider;
|
class CircleCollider;
|
||||||
class MovementComponent;
|
class MovementComponent;
|
||||||
class Bullet : public MoveableEntity
|
class Bullet : public MoveableEntity
|
||||||
@ -20,7 +21,7 @@ class Bullet : public MoveableEntity
|
|||||||
MetaData::Equip* gun_meta = nullptr;
|
MetaData::Equip* gun_meta = nullptr;
|
||||||
MetaData::EquipUpgrade* gun_upgrade_meta = nullptr;
|
MetaData::EquipUpgrade* gun_upgrade_meta = nullptr;
|
||||||
MetaData::Equip* meta = nullptr;
|
MetaData::Equip* meta = nullptr;
|
||||||
Human* sender = nullptr;
|
Creature* sender = nullptr;
|
||||||
a8::Vec2 dir;
|
a8::Vec2 dir;
|
||||||
a8::Vec2 born_pos;
|
a8::Vec2 born_pos;
|
||||||
a8::Vec2 born_dir;
|
a8::Vec2 born_dir;
|
||||||
|
@ -756,3 +756,39 @@ bool Creature::CanSee(const Creature* c) const
|
|||||||
{
|
{
|
||||||
return room->grid_service->InView(GetGridId(), c->GetGridId());
|
return room->grid_service->InView(GetGridId(), c->GetGridId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Creature::GetAttrAbs(int attr_id)
|
||||||
|
{
|
||||||
|
float attr_abs_val = GetBuffAttrAbs(attr_id);
|
||||||
|
if (attr_id == kHAT_Atk || attr_id == kHAT_Def) {
|
||||||
|
Buff* buff = GetBuffByEffectId(kBET_Car);
|
||||||
|
if (buff) {
|
||||||
|
MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(buff->meta->param4);
|
||||||
|
if (equip_meta) {
|
||||||
|
switch (attr_id) {
|
||||||
|
case kHAT_Atk:
|
||||||
|
{
|
||||||
|
attr_abs_val += equip_meta->i->atk();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case kHAT_Def:
|
||||||
|
{
|
||||||
|
attr_abs_val += equip_meta->i->def();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return attr_abs_val;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Creature::GetAttrRate(int attr_id)
|
||||||
|
{
|
||||||
|
float attr_rate_val = GetBuffAttrRate(attr_id);
|
||||||
|
return attr_rate_val;
|
||||||
|
}
|
||||||
|
@ -13,6 +13,7 @@ namespace MetaData
|
|||||||
|
|
||||||
struct xtimer_list;
|
struct xtimer_list;
|
||||||
class Skill;
|
class Skill;
|
||||||
|
class Obstacle;
|
||||||
class Creature : public MoveableEntity
|
class Creature : public MoveableEntity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -66,12 +67,20 @@ class Creature : public MoveableEntity
|
|||||||
|
|
||||||
virtual void CancelAction() {};
|
virtual void CancelAction() {};
|
||||||
virtual void ResetAction() {};
|
virtual void ResetAction() {};
|
||||||
|
virtual std::string GetName() { return "";};
|
||||||
|
virtual void SendDebugMsg(const std::string& debug_msg);
|
||||||
|
virtual void DropItems(Obstacle* obstacle) {};
|
||||||
|
virtual bool IsPlayer() const { return false;};
|
||||||
|
virtual bool IsAndroid() const { return false;};
|
||||||
|
|
||||||
|
RaceType_e GetRace() { return race_; }
|
||||||
|
float GetAttrAbs(int attr_id);
|
||||||
|
float GetAttrRate(int attr_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
virtual void AddBuffPostProc(Creature* caster, Buff* buff);
|
virtual void AddBuffPostProc(Creature* caster, Buff* buff);
|
||||||
virtual void OnBuffRemove(const Buff& buff);
|
virtual void OnBuffRemove(const Buff& buff);
|
||||||
virtual void SendDebugMsg(const std::string& debug_msg);
|
|
||||||
virtual void DoSkillPreProc(int skill_id, int target_id, const a8::Vec2& target_pos);
|
virtual void DoSkillPreProc(int skill_id, int target_id, const a8::Vec2& target_pos);
|
||||||
virtual void DoSkillPostProc(bool used, int skill_id, int target_id, const a8::Vec2& target_pos);
|
virtual void DoSkillPostProc(bool used, int skill_id, int target_id, const a8::Vec2& target_pos);
|
||||||
virtual void _UpdateMove(int speed) {};
|
virtual void _UpdateMove(int speed) {};
|
||||||
@ -84,6 +93,9 @@ private:
|
|||||||
Skill* GetPassiveSkill(int skill_id);
|
Skill* GetPassiveSkill(int skill_id);
|
||||||
void RemovePassiveSkill(int skill_id);
|
void RemovePassiveSkill(int skill_id);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
RaceType_e race_ = kHumanRace;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::array<float, kHAT_End> buff_attr_abs_ = {};
|
std::array<float, kHAT_End> buff_attr_abs_ = {};
|
||||||
std::array<float, kHAT_End> buff_attr_rate_ = {};
|
std::array<float, kHAT_End> buff_attr_rate_ = {};
|
||||||
|
@ -119,7 +119,7 @@ void FrameEvent::AddExplosion(Bullet* bullet, int item_id, a8::Vec2 bomb_pos)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameEvent::AddExplosionEx(Human* sender, int item_id, a8::Vec2 bomb_pos, int effect)
|
void FrameEvent::AddExplosionEx(Creature* sender, int item_id, a8::Vec2 bomb_pos, int effect)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
auto& tuple = a8::FastAppend(explosions_);
|
auto& tuple = a8::FastAppend(explosions_);
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
float fly_distance);
|
float fly_distance);
|
||||||
void AddExplosion(Bullet* bullet, int item_id, a8::Vec2 bomb_pos);
|
void AddExplosion(Bullet* bullet, int item_id, a8::Vec2 bomb_pos);
|
||||||
void AddSmoke(Bullet* bullet, int item_id, a8::Vec2 pos);
|
void AddSmoke(Bullet* bullet, int item_id, a8::Vec2 pos);
|
||||||
void AddExplosionEx(Human* sender, int item_id, a8::Vec2 bomb_pos, int effect);
|
void AddExplosionEx(Creature* sender, int item_id, a8::Vec2 bomb_pos, int effect);
|
||||||
void AddBulletNumChg(Human* hum);
|
void AddBulletNumChg(Human* hum);
|
||||||
void AddHpChg(Human* hum);
|
void AddHpChg(Human* hum);
|
||||||
void AddWeaponAmmoChg(Human* hum);
|
void AddWeaponAmmoChg(Human* hum);
|
||||||
@ -39,9 +39,9 @@ private:
|
|||||||
::google::protobuf::RepeatedPtrField<::cs::MFAirDrop> airdrops_;
|
::google::protobuf::RepeatedPtrField<::cs::MFAirDrop> airdrops_;
|
||||||
std::vector<std::tuple<Creature*, ::cs::MFShot>> shots_;
|
std::vector<std::tuple<Creature*, ::cs::MFShot>> shots_;
|
||||||
std::vector<std::tuple<Creature*, ::cs::MFBullet>> bullets_;
|
std::vector<std::tuple<Creature*, ::cs::MFBullet>> bullets_;
|
||||||
std::vector<std::tuple<Human*, ::cs::MFExplosion>> explosions_;
|
std::vector<std::tuple<Creature*, ::cs::MFExplosion>> explosions_;
|
||||||
std::vector<std::tuple<Human*, ::cs::MFSmoke>> smokes_;
|
std::vector<std::tuple<Creature*, ::cs::MFSmoke>> smokes_;
|
||||||
std::vector<std::tuple<Human*, ::cs::MFEmote>> emotes_;
|
std::vector<std::tuple<Creature*, ::cs::MFEmote>> emotes_;
|
||||||
std::vector<std::tuple<Human*, ::cs::MFBuffChg>> chged_buffs_;
|
std::vector<std::tuple<Human*, ::cs::MFBuffChg>> chged_buffs_;
|
||||||
std::vector<std::tuple<Human*, int, int>> chged_items_;
|
std::vector<std::tuple<Human*, int, int>> chged_items_;
|
||||||
std::vector<Human*> chged_bullet_nums_;
|
std::vector<Human*> chged_bullet_nums_;
|
||||||
|
@ -2935,42 +2935,6 @@ void Human::DecItem(int item_id, int item_num)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float Human::GetAttrAbs(int attr_id)
|
|
||||||
{
|
|
||||||
float attr_abs_val = GetBuffAttrAbs(attr_id);
|
|
||||||
if (attr_id == kHAT_Atk || attr_id == kHAT_Def) {
|
|
||||||
Buff* buff = GetBuffByEffectId(kBET_Car);
|
|
||||||
if (buff) {
|
|
||||||
MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(buff->meta->param4);
|
|
||||||
if (equip_meta) {
|
|
||||||
switch (attr_id) {
|
|
||||||
case kHAT_Atk:
|
|
||||||
{
|
|
||||||
attr_abs_val += equip_meta->i->atk();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case kHAT_Def:
|
|
||||||
{
|
|
||||||
attr_abs_val += equip_meta->i->def();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return attr_abs_val;
|
|
||||||
}
|
|
||||||
|
|
||||||
float Human::GetAttrRate(int attr_id)
|
|
||||||
{
|
|
||||||
float attr_rate_val = GetBuffAttrRate(attr_id);
|
|
||||||
return attr_rate_val;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Human::IsPlayer() const
|
bool Human::IsPlayer() const
|
||||||
{
|
{
|
||||||
return IsEntitySubType(EST_Player);
|
return IsEntitySubType(EST_Player);
|
||||||
|
@ -239,11 +239,9 @@ class Human : public Creature
|
|||||||
int GetItemNum(int item_id);
|
int GetItemNum(int item_id);
|
||||||
void AddItem(int item_id, int item_num);
|
void AddItem(int item_id, int item_num);
|
||||||
void DecItem(int item_id, int item_num);
|
void DecItem(int item_id, int item_num);
|
||||||
float GetAttrAbs(int attr_id);
|
virtual bool IsPlayer() const override;
|
||||||
float GetAttrRate(int attr_id);
|
virtual bool IsAndroid() const override;
|
||||||
bool IsPlayer() const;
|
virtual void DropItems(Obstacle* obstacle) override;
|
||||||
bool IsAndroid() const;
|
|
||||||
void DropItems(Obstacle* obstacle);
|
|
||||||
void ProcNewBieLogic();
|
void ProcNewBieLogic();
|
||||||
void OnEnable();
|
void OnEnable();
|
||||||
void OnDisable();
|
void OnDisable();
|
||||||
@ -253,7 +251,6 @@ class Human : public Creature
|
|||||||
bool HasSpecMove();
|
bool HasSpecMove();
|
||||||
void _UpdateSpecMove();
|
void _UpdateSpecMove();
|
||||||
virtual void _UpdateMove(int speed) override;
|
virtual void _UpdateMove(int speed) override;
|
||||||
RaceType_e GetRace() { return race_; }
|
|
||||||
void ChangeToRace(RaceType_e race, int level);
|
void ChangeToRace(RaceType_e race, int level);
|
||||||
void ChangeToRaceAndNotify(RaceType_e race, int level);
|
void ChangeToRaceAndNotify(RaceType_e race, int level);
|
||||||
void WinExp(Human* sender, int exp);
|
void WinExp(Human* sender, int exp);
|
||||||
@ -263,6 +260,7 @@ class Human : public Creature
|
|||||||
void SetSeat(int seat) { seat_ = seat; }
|
void SetSeat(int seat) { seat_ = seat; }
|
||||||
void DeadDrop();
|
void DeadDrop();
|
||||||
bool IsEnemy(Human* hum);
|
bool IsEnemy(Human* hum);
|
||||||
|
virtual std::string GetName() override { return name;};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _InternalUpdateMove(float speed);
|
void _InternalUpdateMove(float speed);
|
||||||
@ -349,7 +347,6 @@ protected:
|
|||||||
int seat_ = 0;
|
int seat_ = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RaceType_e race_ = kHumanRace;
|
|
||||||
CircleCollider* self_collider_ = nullptr;
|
CircleCollider* self_collider_ = nullptr;
|
||||||
long long last_sync_gas_frameno = 0;
|
long long last_sync_gas_frameno = 0;
|
||||||
std::map<int, int> items_;
|
std::map<int, int> items_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user