添加伤害公式
This commit is contained in:
parent
ccda49a1d7
commit
f362689a6e
@ -104,8 +104,11 @@ void Bullet::OnHit(std::set<Entity*>& objects)
|
|||||||
#else
|
#else
|
||||||
if (!hum->dead && (hum->team_id == 0 || hum->team_id != player->team_id)) {
|
if (!hum->dead && (hum->team_id == 0 || hum->team_id != player->team_id)) {
|
||||||
#endif
|
#endif
|
||||||
player->stats.damage_amount += 10;
|
float dmg = gun_meta->i->atk();
|
||||||
hum->DecHP(10, player->entity_uniid, player->name);
|
float def = hum->def;
|
||||||
|
float finaly_dmg = dmg * (1 - def/MetaMgr::Instance()->K);
|
||||||
|
player->stats.damage_amount += finaly_dmg;
|
||||||
|
hum->DecHP(finaly_dmg, player->entity_uniid, player->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -113,7 +116,12 @@ void Bullet::OnHit(std::set<Entity*>& objects)
|
|||||||
{
|
{
|
||||||
Obstacle* obstacle = (Obstacle*)target;
|
Obstacle* obstacle = (Obstacle*)target;
|
||||||
if (!obstacle->dead && obstacle->meta->i->attack_type() == 1) {
|
if (!obstacle->dead && obstacle->meta->i->attack_type() == 1) {
|
||||||
obstacle->health = std::max(0.0f, obstacle->health - 10);
|
float dmg = gun_meta->i->atk();
|
||||||
|
float def = 0;
|
||||||
|
float finaly_dmg = dmg * (1 - def/MetaMgr::Instance()->K);
|
||||||
|
player->stats.damage_amount += finaly_dmg;
|
||||||
|
|
||||||
|
obstacle->health = std::max(0.0f, obstacle->health - finaly_dmg);
|
||||||
obstacle->dead = obstacle->health <= 0.01f;
|
obstacle->dead = obstacle->health <= 0.01f;
|
||||||
obstacle->dead_frameno = room->frame_no;
|
obstacle->dead_frameno = room->frame_no;
|
||||||
if (obstacle->dead) {
|
if (obstacle->dead) {
|
||||||
|
@ -826,3 +826,16 @@ bool Human::CanSee(Human* hum)
|
|||||||
{
|
{
|
||||||
return room->grid_service.InView(grid_id, hum->grid_id);
|
return room->grid_service.InView(grid_id, hum->grid_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Human::RecalcAttr()
|
||||||
|
{
|
||||||
|
def = meta->i->def();
|
||||||
|
MetaData::Equip* chest_meta = MetaMgr::Instance()->GetEquip(chest);
|
||||||
|
if (chest_meta) {
|
||||||
|
def += chest_meta->i->def();
|
||||||
|
}
|
||||||
|
MetaData::Equip* helmet_meta = MetaMgr::Instance()->GetEquip(helmet);
|
||||||
|
if (helmet_meta) {
|
||||||
|
def += helmet_meta->i->def();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -86,6 +86,9 @@ class Human : public Entity
|
|||||||
long long jump_frameno = 0;
|
long long jump_frameno = 0;
|
||||||
|
|
||||||
long long send_msg_times = 0;
|
long long send_msg_times = 0;
|
||||||
|
|
||||||
|
float def = 0.0f;
|
||||||
|
|
||||||
Human();
|
Human();
|
||||||
virtual ~Human() override;
|
virtual ~Human() override;
|
||||||
virtual void Initialize() override;
|
virtual void Initialize() override;
|
||||||
@ -128,6 +131,7 @@ class Human : public Entity
|
|||||||
void FillMFActivePlayerData(cs::MFActivePlayerData* player_data);
|
void FillMFActivePlayerData(cs::MFActivePlayerData* player_data);
|
||||||
void FillMFGasData(cs::MFGasData* gas_data);
|
void FillMFGasData(cs::MFGasData* gas_data);
|
||||||
bool CanSee(Human* hum);
|
bool CanSee(Human* hum);
|
||||||
|
void RecalcAttr();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
long long last_shot_frameno_ = 0;
|
long long last_shot_frameno_ = 0;
|
||||||
|
@ -71,6 +71,10 @@ public:
|
|||||||
{
|
{
|
||||||
MetaMgr::Instance()->gas_inactive_time = MetaMgr::Instance()->GetSysParamAsInt("gas_inactive_time");
|
MetaMgr::Instance()->gas_inactive_time = MetaMgr::Instance()->GetSysParamAsInt("gas_inactive_time");
|
||||||
MetaMgr::Instance()->jump_time = MetaMgr::Instance()->GetSysParamAsFloat("jump_time");
|
MetaMgr::Instance()->jump_time = MetaMgr::Instance()->GetSysParamAsFloat("jump_time");
|
||||||
|
MetaMgr::Instance()->K = MetaMgr::Instance()->GetSysParamAsFloat("K");
|
||||||
|
if (MetaMgr::Instance()->K < 0.01f) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ class MetaMgr : public a8::Singleton<MetaMgr>
|
|||||||
|
|
||||||
int gas_inactive_time = 10;
|
int gas_inactive_time = 10;
|
||||||
int jump_time = 10;
|
int jump_time = 10;
|
||||||
|
float K = 100.0f;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MetaDataLoader* loader_ = nullptr;
|
MetaDataLoader* loader_ = nullptr;
|
||||||
|
@ -675,6 +675,7 @@ void Player::LootInteraction(Loot* entity)
|
|||||||
room->DropItem(pos, old_item_meta->i->id(), 1);
|
room->DropItem(pos, old_item_meta->i->id(), 1);
|
||||||
}
|
}
|
||||||
chest = item_meta->i->id();
|
chest = item_meta->i->id();
|
||||||
|
RecalcAttr();
|
||||||
} else if (item_meta->i->equip_subtype() == 2) {
|
} else if (item_meta->i->equip_subtype() == 2) {
|
||||||
//头盔
|
//头盔
|
||||||
MetaData::Equip* old_item_meta = MetaMgr::Instance()->GetEquip(helmet);
|
MetaData::Equip* old_item_meta = MetaMgr::Instance()->GetEquip(helmet);
|
||||||
@ -685,6 +686,7 @@ void Player::LootInteraction(Loot* entity)
|
|||||||
room->DropItem(pos, old_item_meta->i->id(), 1);
|
room->DropItem(pos, old_item_meta->i->id(), 1);
|
||||||
}
|
}
|
||||||
helmet = item_meta->i->id();
|
helmet = item_meta->i->id();
|
||||||
|
RecalcAttr();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -78,6 +78,7 @@ message Player
|
|||||||
optional float radius = 2; //半径
|
optional float radius = 2; //半径
|
||||||
optional int32 health = 3; //初始血量
|
optional int32 health = 3; //初始血量
|
||||||
optional int32 move_speed = 4; //移动速度
|
optional int32 move_speed = 4; //移动速度
|
||||||
|
optional float def = 5; //防御
|
||||||
}
|
}
|
||||||
|
|
||||||
message Skill
|
message Skill
|
||||||
|
Loading…
x
Reference in New Issue
Block a user