game2006/server/gameserver/battledatacontext.h
aozhiwei e9a68efa3d 1
2022-12-23 13:53:14 +08:00

106 lines
2.6 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include "weakptr.h"
/*
子弹命中逻辑
1、计算总攻击力
2、计算普通伤害
3、判断是否暴击(百分比系数),对方是否闪避(系数)
4、得到实际伤害
免伤后伤害=实际伤害*1-免伤率)
吸血值=吸血系数*实际伤害
*/
namespace MetaData
{
struct Equip;
}
class Creature;
class Obstacle;
class Explosion;
class Weapon;
struct PlayerStats;
class HeroAbility;
class WeaponAbility;
struct BattleDataContext
{
std::shared_ptr<cs::CMJoin> join_msg;
long long battle_uuid = 0;
int is_valid_battle = 0;
std::string payload;
int errcode = 0;
std::string errmsg;
std::shared_ptr<a8::XObject> hero_dto;
std::shared_ptr<a8::XObject> weapon_dto1;
std::shared_ptr<a8::XObject> weapon_dto2;
BattleDataContext();
void GetHeroLvQuality(int& hero_lv, int& quality);
void GetWeaponLvQuality(int& weapon_lv, int& quality);
void ParseResult(a8::XObject& obj);
void CalcBattleStat(struct PlayerStats* stats);
float CalcDmg(Creature* target, IBullet* bullet);
float CalcDmg(Obstacle* target, IBullet* bullet);
float CalcDmg(Explosion* e);
bool IsCrit();
float GetCritDmg();
float GetHP();
float GetMaxHP();
float GetDef();
void ForceInit(long long hero_uniid,
const mt::Hero* hum_meta,
long long weapon1_uniid,
const mt::Equip* weapon1_meta,
long long weapon2_uniid,
const mt::Equip* weapon2_meta);
void Init(Creature* c);
void GetSkillList(std::vector<int>& skill_list);
int GetClipVolume(Creature* c, Weapon* weapon);
int GetFireRate(Creature* c, Weapon* weapon);
int GetReloadTime(Creature* c, Weapon* weapon);
float GetHeroTotalAtk();
float GetExtRecoverHp();
void SetReviveCoin(int num);
int GetReviveCoin();
void SetMatchMode(int match_mode);
int GetMatchMode();
private:
void Clear();
float GetTotalAtk(IBullet* bullet);
float GetWeaponAtk(IBullet* bullet);
bool IsCrit(IBullet* bullet);
float GetCrit(IBullet* bullet);
float GetCritRate(IBullet* bullet);
bool IsDodge(IBullet* bullet);
float GetDodge(IBullet* bullet);
float GetDodgeRuduce(IBullet* bullet);
std::shared_ptr<WeaponAbility> GetWeaponByUniId(long long weapon_uniid);
private:
CreatureWeakPtr owner_;
int revive_coin_ = 0;
int match_mode_ = 0;
std::shared_ptr<HeroAbility> hero_ability_;
std::shared_ptr<WeaponAbility> weapon1_ability_;
std::shared_ptr<WeaponAbility> weapon2_ability_;
int skill1_lv = 1;
int skill2_lv = 1;
int skill3_lv = 1;
};