396 lines
13 KiB
C++
396 lines
13 KiB
C++
#pragma once
|
|
|
|
#include "moveableentity.h"
|
|
#include "cs_proto.pb.h"
|
|
#include "GGListener.h"
|
|
|
|
namespace MetaData
|
|
{
|
|
struct Player;
|
|
struct Equip;
|
|
struct Dress;
|
|
struct Skill;
|
|
struct Buff;
|
|
struct SkillPhase;
|
|
}
|
|
|
|
enum HumanStatus
|
|
{
|
|
HS_AlreadyLordMode = 1,
|
|
HS_Disable = 2,
|
|
HS_NewBieGuideAndroid = 3,
|
|
HS_AlreadyEquip = 5,
|
|
HS_AlreadyProcNewBieLogic = 6,
|
|
HS_LastAndroid = 7,
|
|
HS_End
|
|
};
|
|
|
|
struct xtimer_list;
|
|
class CircleCollider;
|
|
class AabbCollider;
|
|
class Obstacle;
|
|
class Loot;
|
|
class Buff;
|
|
class Human : public MoveableEntity
|
|
{
|
|
public:
|
|
int socket_handle = 0;
|
|
long ip_saddr = 0;
|
|
int team_id = 0;
|
|
std::string account_id;
|
|
std::string session_id;
|
|
std::string from_appid;
|
|
std::string team_uuid;
|
|
bool auto_fill = false;
|
|
int today_enter_times = 0;
|
|
int account_registertime = 0;
|
|
MetaData::Player* meta = nullptr;
|
|
MetaData::Equip* helmet_meta = nullptr;
|
|
MetaData::Equip* chest_meta = nullptr;
|
|
MetaData::Dress* skin_jlf_meta = nullptr;
|
|
MetaData::Equip* skin_tank_meta = nullptr;
|
|
HumanAbility ability;
|
|
|
|
a8::Vec2 move_dir;
|
|
a8::Vec2 attack_dir;
|
|
std::function<void ()> on_loading_bullet;
|
|
std::function<bool ()> on_move_collision;
|
|
|
|
std::string name;
|
|
std::string avatar_url;
|
|
long long user_value1 = 0;
|
|
long long user_value2 = 0;
|
|
long long user_value3 = 0;
|
|
long long last_cmmove_frameno = 0;
|
|
bool downed = false;
|
|
bool disconnected = false;
|
|
int anim_type = 0;
|
|
int anim_seq = 0;
|
|
ActionType_e action_type = AT_None;
|
|
long long action_frameno = 0;
|
|
int action_duration = 0;
|
|
int action_item_id = 0;
|
|
int action_target_id = 0;
|
|
Skin skin_jlf;
|
|
Skin skin_tank;
|
|
int backpack = 0;
|
|
int helmet = 0;
|
|
int chest = 0;
|
|
int energy_shield = 0;
|
|
int max_energy_shield = 0;
|
|
int vip = 0;
|
|
int sdmg = 0;
|
|
bool poisoning = false;
|
|
long long poisoning_time = 0;
|
|
int lethal_weapon = 0;
|
|
long long join_frameno = 0;
|
|
long long enable_frameno = 0;
|
|
int status = 0;
|
|
float atk_add = 0.0f;
|
|
int emoji1 = 0;
|
|
int emoji2 = 0;
|
|
int parachute = 0;
|
|
bool has_pass = 0;
|
|
bool real_dead = false;
|
|
xtimer_list* revive_timer = nullptr;
|
|
int dead_times = 0;
|
|
bool aiming = false;
|
|
bool dead = false;
|
|
long long dead_frameno = 0;
|
|
long long real_dead_frameno = 0;
|
|
|
|
Weapon default_weapon;
|
|
Weapon tank_weapon;
|
|
float tank_oil_value = 0.0f;
|
|
float tank_oil_max = 0.0f;
|
|
std::vector<Weapon> weapons;
|
|
Weapon* curr_weapon = nullptr;
|
|
|
|
int curr_scope_idx = 0;
|
|
|
|
bool need_sync_team_data = false;
|
|
bool need_sync_teammate_data = false;
|
|
bool need_sync_active_player = false;
|
|
|
|
PlayerStats stats;
|
|
|
|
int pain_killer_frameno = 0;
|
|
int pain_killer_lastingtime = 0;
|
|
xtimer_list* pain_killer_timer = nullptr;
|
|
|
|
xtimer_list* downed_timer = nullptr;
|
|
|
|
std::set<Human*>* team_members = nullptr;
|
|
std::set<Human*> kill_humans;
|
|
Human* last_tank_attacker = nullptr;
|
|
long long last_tank_attack_idx = 0;
|
|
BornPoint* born_point = nullptr;
|
|
|
|
bool shot_start = false;
|
|
bool shot_hold = false;
|
|
int series_shot_frames = 0;
|
|
float fly_distance = 0.0f;
|
|
|
|
long long send_msg_times = 0;
|
|
|
|
Weapon spec_weapon;
|
|
Weapon grow_weapon;
|
|
std::map<int, int> weapon_configs;
|
|
std::map<int, int> skin_configs;
|
|
|
|
bool use_skill = false;
|
|
size_t curr_skill_phase = 0;
|
|
int skill_target_id = 0;
|
|
a8::Vec2 skill_dir;
|
|
a8::Vec2 skill_target_pos;
|
|
float skill_param1 = 0;
|
|
bool playing_skill = false;
|
|
xtimer_list* ad_timer_ = nullptr;
|
|
Human* last_human_target = nullptr;
|
|
|
|
int game_times = 0;
|
|
int win_times = 0;
|
|
int kill_times = 0;
|
|
int rank = 0;
|
|
|
|
std::function<void(Human*)> on_grid_chg;
|
|
|
|
Human();
|
|
virtual ~Human() override;
|
|
virtual void Initialize() override;
|
|
virtual float GetSpeed() override;
|
|
virtual float GetSpeed4();
|
|
virtual void FillMFObjectPart(Room* room, Human* hum, cs::MFObjectPart* part_data) override;
|
|
virtual void FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data) override;
|
|
virtual void FillMFPlayerStats(cs::MFPlayerStats* stats);
|
|
virtual void GetAabbBox(AabbCollider& aabb_box);
|
|
virtual bool IsDead(Room* room) override;
|
|
virtual long long GetDeadFrameNo(Room* room) override;
|
|
long long GetRealDeadFrameNo(Room* room);
|
|
void FillMFTeamData(cs::MFTeamData* team_data, bool is_game_over);
|
|
void Shot(a8::Vec2& target_dir, bool& shot_ok);
|
|
void TankShot(a8::Vec2& target_dir);
|
|
void RecalcSelfCollider();
|
|
bool IsCollisionInMapService();
|
|
void FindPathInMapService();
|
|
float GetRadius();
|
|
float GetHP();
|
|
float GetMaxHP();
|
|
void UpdateSkill();
|
|
void UpdatePoisoning();
|
|
void SyncAroundPlayers(const char* file, int line, const char* func);
|
|
void AutoLoadingBullet(bool manual = false);
|
|
void StartAction(ActionType_e action_type,
|
|
int action_duration,
|
|
int item_id,
|
|
int target_id);
|
|
void CancelAction();
|
|
void ResetAction();
|
|
void BeKill(int killer_id, const std::string& killer_name, int weapon_id);
|
|
void DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id);
|
|
void AddToNewObjects(Entity* entity);
|
|
void AddToPartObjects(Entity* entity);
|
|
void RemovePartObjects(Entity* entity);
|
|
bool InPartObjects(Human* target);
|
|
int GetPartObjectsCount();
|
|
void RemoveObjects(Entity* entity);
|
|
void AddOutObjects(Entity* entity);
|
|
void RemoveOutObjects(Entity* entity);
|
|
bool HasLiveTeammate();
|
|
bool HasNoDownedTeammate();
|
|
bool CanUseSkill();
|
|
void DoSkill();
|
|
void DoGetDown();
|
|
void FindLocation();
|
|
void RefreshView();
|
|
void OnGridListChange(std::set<GridCell*>& old_grids,
|
|
std::set<GridCell*>& inc_grids,
|
|
std::set<GridCell*>& dec_grids
|
|
);
|
|
void FillMFActivePlayerData(cs::MFActivePlayerData* player_data);
|
|
void FillMFGasData(cs::MFGasData* gas_data);
|
|
bool CanSee(const Human* hum) const;
|
|
void RecalcVolume();
|
|
void RecalcBaseAttr();
|
|
int GetInventory(int slot_id);
|
|
void AddInventory(int slot_id, int num);
|
|
void DecInventory(int slot_id, int num);
|
|
int GetVolume(int slot_id);
|
|
void RecoverHp(int inc_hp);
|
|
void FillBodyState(::google::protobuf::RepeatedPtrField<::cs::MFBodyState>* states);
|
|
void FillBuffList(::google::protobuf::RepeatedPtrField<::cs::MFBuff>* pb_buff_list);
|
|
void FillItemList(::google::protobuf::RepeatedPtrField<::cs::MFPair>* pb_item_list);
|
|
void SummonHero();
|
|
void AddObserver(Human* observer);
|
|
void RemoveObserver(Human* observer);
|
|
void SendUpdateMsg();
|
|
template <typename T>
|
|
void SendNotifyMsg(T& msg)
|
|
{
|
|
GGListener::Instance()->SendToClient(socket_handle, 0, msg);
|
|
}
|
|
void SendGameOver();
|
|
void FollowTarget(Human* target);
|
|
void SendDebugMsg(const std::string& debug_msg);
|
|
void SendRollMsg(const std::string& roll_msg);
|
|
void UpdateAction();
|
|
void SendUIUpdate();
|
|
void SendWxVoip();
|
|
void SendSysPiaoMsg(const std::string& msg, int color, int duration);
|
|
void SendShowCountdown(const std::string& msg, int countdown);
|
|
int GetWeaponConfigLv(int weapon_id);
|
|
int GetSkinConfigLv(int skin_id);
|
|
void OnDie();
|
|
void FreeDownedTimer();
|
|
void FreeReviveTimer();
|
|
void RandSkin();
|
|
void SetSkin(int idx, int skin_id);
|
|
Skin* GetSkinByIdx(int idx);
|
|
MetaData::Skill* CurrentSkillMeta();
|
|
int GetSkillLeftTime();
|
|
int GetSkillCd();
|
|
int GetSkillLv();
|
|
float GetSkillAtkAdd(int skill_id);
|
|
void TriggerOneObjectBuff(Entity* target, BuffTriggerType_e trigger_type);
|
|
void TriggerBuff(std::set<Entity*>& target_list, BuffTriggerType_e trigger_type);
|
|
void AddBuff(MetaData::Buff* buff_meta, int skill_lv);
|
|
void RemoveBuffById(int buff_id);
|
|
void RemoveBuffByEffectId(int buff_effect_id);
|
|
void ClearBuffList();
|
|
bool HasBuffEffect(int buff_effect_id);
|
|
Buff* GetBuffByEffectId(int effect_id);
|
|
void RecalcBuffAttr();
|
|
void ProcBuffEffect(Buff* buff);
|
|
int GetLevel() {return 1;};
|
|
void OnAttack() {};
|
|
void OnHit() {};
|
|
int GetItemNum(int item_id);
|
|
void AddItem(int item_id, int item_num);
|
|
void DecItem(int item_id, int item_num);
|
|
float GetBuffAttrAbs(int attr_id);
|
|
float GetBuffAttrRate(int attr_id);
|
|
bool IsPlayer() const;
|
|
bool IsAndroid() const;
|
|
void DropItems(Obstacle* obstacle);
|
|
void ProcNewBieLogic();
|
|
void OnEnable();
|
|
void OnDisable();
|
|
Entity* GetLastCollisionDoor() { return last_collision_door_; }
|
|
void SetLastCollisionDoor(Entity* door) { last_collision_door_ = door; }
|
|
ObjectSyncFlags* GetObjectSyncFlags(int obj_uniid);
|
|
void _UpdateMove(int speed);
|
|
RaceType_e GetRace() { return race_; }
|
|
|
|
protected:
|
|
void _InternalUpdateMove(float speed);
|
|
void ProcLootOldSkin(Loot* entity, MetaData::Equip* item_meta);
|
|
void ProcLootSkin(Loot* entity, MetaData::Equip* item_meta);
|
|
void ProcLootCar(Loot* entity, MetaData::Equip* item_meta);
|
|
void ProcCamoutflage(Loot* entity, MetaData::Equip* item_meta);
|
|
void ResetTankSkin();
|
|
void SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& target_list);
|
|
Buff* GetBuffById(int buff_id);
|
|
void ProcSkillPhase(MetaData::SkillPhase* phase);
|
|
void AutoChgWeapon();
|
|
void CancelRevive();
|
|
|
|
private:
|
|
void ClearFrameData();
|
|
void GenBattleReportData(a8::MutableXObject* params);
|
|
void DeadDrop();
|
|
void FillSMGameOver(cs::SMGameOver& msg);
|
|
void SendBattleReport();
|
|
void FindLocationWithTarget(Entity* target);
|
|
void Revive();
|
|
void ClearLordMode();
|
|
void AdjustDecHp(float old_health, float& new_health);
|
|
void ClearPartObjects();
|
|
void GetViewObjects(std::set<Entity*>& view_objects);
|
|
void NotifyObservers(cs::SMUpdate* msg, cs::MFActivePlayerData* active_player_data_pb);
|
|
void ProcIncGridList(std::set<GridCell*>& old_grids,
|
|
std::set<GridCell*>& inc_grids,
|
|
std::set<GridCell*>& dec_grids);
|
|
void ProcDecGridList(std::set<GridCell*>& old_grids,
|
|
std::set<GridCell*>& inc_grids,
|
|
std::set<GridCell*>& dec_grids);
|
|
void RemoveFromScene();
|
|
|
|
protected:
|
|
int level_ = 0;
|
|
int exp_ = 0;
|
|
int zombieid_ = 0;
|
|
long long last_shot_frameno_ = 0;
|
|
long long last_use_skill_frameno_ = 0;
|
|
long long hide_frameno_ = 0;
|
|
long long accelerate_frameno_ = 0;
|
|
long long damageadd_frameno_ = 0;
|
|
long long defadd_frameno_ = 0;
|
|
long long recover_hp_frameno_ = 0;
|
|
long long reflect_damage_frameno_ = 0;
|
|
long long summon_hero_frameno_ = 0;
|
|
long long last_sync_teamdata_frameno_ = 0;
|
|
a8::XTimerAttacher skill_xtimer_attacher_;
|
|
bool leave_ = false;
|
|
long long leave_frameno_ = 0;
|
|
|
|
std::array<int, IS_END - 1> inventory_ = {};
|
|
std::array<int, IS_END> volume_ = {};
|
|
std::set<Entity*> new_objects;
|
|
std::set<Entity*> part_objects;
|
|
std::set<int> del_objects;
|
|
std::set<int> out_objects;
|
|
std::vector<int> shots_;
|
|
std::vector<int> emotes_;
|
|
std::vector<int> bullets_;
|
|
std::vector<int> smokes_;
|
|
std::vector<int> explosions_;
|
|
std::vector<int> chged_buffs_;
|
|
std::set<Human*> observers_;
|
|
std::vector<int> chged_bullet_nums_;
|
|
std::vector<int> chged_tank_bullet_nums_;
|
|
std::vector<int> chged_tank_oil_value_;
|
|
std::vector<int> chged_tank_oil_max_;
|
|
std::vector<int> chged_hps_;
|
|
std::vector<int> chged_skillcds_;
|
|
std::vector<int> chged_items_;
|
|
std::vector<int> chged_weapon_ammo_;
|
|
std::vector<int> chged_level_;
|
|
std::vector<int> chged_exp_;
|
|
std::vector<int> chged_race_;
|
|
std::vector<int> chged_zombieid_;
|
|
std::vector<int> revive_objs_;
|
|
std::vector<int> dead_objs_;
|
|
Human* follow_target_ = nullptr;
|
|
bool follow_synced_active_player = false;
|
|
HumanCar car_;
|
|
|
|
MetaData::Skill* skill_meta_ = nullptr;
|
|
|
|
private:
|
|
RaceType_e race_ = kHumanRace;
|
|
CircleCollider* self_collider_ = nullptr;
|
|
long long last_sync_gas_frameno = 0;
|
|
std::list<Buff> buff_list_;
|
|
std::map<int, int> items_;
|
|
std::set<int> battling_items_;
|
|
size_t normal_drop_times_ = 0;
|
|
size_t box_drop_times_ = 0;
|
|
std::array<Buff*, kBET_End> buff_effect_ = {};
|
|
|
|
std::array<float, kHAT_End> buff_attr_abs_ = {};
|
|
std::array<float, kHAT_End> buff_attr_rate_ = {};
|
|
|
|
std::array<ObjectSyncFlags, FIXED_OBJECT_MAXID> fixed_object_sync_flags_ = {};
|
|
|
|
bool already_report_battle_ = false;
|
|
bool sent_battlereport_ = false;
|
|
bool sent_game_end_ = false;
|
|
|
|
std::vector<Skin> skins;
|
|
|
|
Entity* last_collision_door_ = nullptr;
|
|
|
|
friend class FrameMaker;
|
|
friend class FrameEvent;
|
|
};
|