car oil ok
This commit is contained in:
parent
e987129307
commit
baa21030b7
@ -43,6 +43,7 @@ void Car::Initialize()
|
||||
ability.hp = hero_meta_->i->health();
|
||||
ability.max_hp = std::max(ability.hp, ability.max_hp);
|
||||
TryAddBuff(this, meta->car_deactive_buff_id);
|
||||
cur_oil_ = meta->i->max_oil();
|
||||
}
|
||||
|
||||
void Car::FillMFObjectPart(Room* room, Human* hum, cs::MFObjectPart* part_data)
|
||||
@ -72,6 +73,8 @@ void Car::FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data)
|
||||
p->set_dead(dead);
|
||||
p->set_health(GetHP());
|
||||
p->set_max_health(GetMaxHP());
|
||||
p->set_oil(cur_oil_);
|
||||
p->set_max_oil(meta->i->max_oil());
|
||||
FillBuffList(hum, p->mutable_buff_list());
|
||||
}
|
||||
|
||||
@ -403,3 +406,14 @@ void Car::SetAttackDir(const a8::Vec2& attack_dir)
|
||||
{
|
||||
Creature::SetAttackDir(attack_dir);
|
||||
}
|
||||
|
||||
void Car::DecOil(float dec_oil)
|
||||
{
|
||||
cur_oil_ -= dec_oil;
|
||||
cur_oil_ = std::max(0.0f, cur_oil_);
|
||||
}
|
||||
|
||||
float Car::GetMaxOil()
|
||||
{
|
||||
return meta->i->max_oil();
|
||||
}
|
||||
|
@ -34,6 +34,10 @@ class Car : public Creature
|
||||
void SwitchSeat(Human* passenger, int seat);
|
||||
bool CanShot(Human* passenger);
|
||||
void SyncPos();
|
||||
float GetCurOil() { return cur_oil_; };
|
||||
float GetMaxOil();
|
||||
bool HasOil() { return cur_oil_ >= 0.00000001f; };
|
||||
void DecOil(float dec_oil);
|
||||
virtual float GetRadius() override;
|
||||
virtual float GetSpeed() override;
|
||||
virtual void DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id) override;
|
||||
@ -52,4 +56,5 @@ class Car : public Creature
|
||||
std::set<Human*> passengers_;
|
||||
int cur_buff_id_ = 0;
|
||||
int cur_buff_idx_ = -1;
|
||||
float cur_oil_ = 0;
|
||||
};
|
||||
|
@ -256,6 +256,7 @@ enum PropertyType_e
|
||||
kPropSkillLeftTime = 24,
|
||||
kPropSkillCurrTimes = 25,
|
||||
kPropSkillMaxTimes = 26,
|
||||
kPropCarOil = 27,
|
||||
};
|
||||
|
||||
enum MapObjectType_e
|
||||
|
@ -366,6 +366,32 @@ void FrameEvent::AddCarChg(CreatureWeakPtr& sender)
|
||||
});
|
||||
}
|
||||
|
||||
void FrameEvent::AddPropChg(CreatureWeakPtr& sender, int type, int subtype, float value, bool only_self)
|
||||
{
|
||||
if (!sender.Get()) {
|
||||
return;
|
||||
}
|
||||
auto& p = a8::FastAppend(chged_props_);
|
||||
std::get<0>(p) = sender;
|
||||
std::get<1>(p).set_obj_id(sender.Get()->GetUniId());
|
||||
std::get<1>(p).set_property_type(type);
|
||||
std::get<1>(p).set_property_subtype(subtype);
|
||||
std::get<1>(p).set_value(value);
|
||||
int idx = chged_props_.size() - 1;
|
||||
if (only_self) {
|
||||
if (sender.Get()->IsHuman()) {
|
||||
sender.Get()->AsHuman()->chged_props_.push_back(idx);
|
||||
}
|
||||
} else {
|
||||
sender.Get()->TraverseAllLayerHumanList
|
||||
(
|
||||
[idx] (Human* hum, bool& stop)
|
||||
{
|
||||
hum->chged_props_.push_back(idx);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void FrameEvent::Clear()
|
||||
{
|
||||
if (!explosions_.empty()) {
|
||||
@ -422,4 +448,7 @@ void FrameEvent::Clear()
|
||||
if (!chged_cars_.empty()) {
|
||||
chged_cars_.clear();
|
||||
}
|
||||
if (!chged_props_.empty()) {
|
||||
chged_props_.clear();
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
void AddDead(CreatureWeakPtr& sender, int revive_time);
|
||||
void AddRevive(CreatureWeakPtr& sender);
|
||||
void AddCarChg(CreatureWeakPtr& sender);
|
||||
void AddPropChg(CreatureWeakPtr& sender, int type, int subtype, float value, bool only_self = false);
|
||||
|
||||
void Clear();
|
||||
private:
|
||||
@ -58,6 +59,7 @@ private:
|
||||
std::vector<CreatureWeakPtr> chged_zombieids_;
|
||||
std::vector<CreatureWeakPtr> chged_cars_;
|
||||
std::vector<std::tuple<int, int, int>> dead_alive_objs_;
|
||||
std::vector<std::tuple<CreatureWeakPtr, ::cs::MFPropertyChg>> chged_props_;
|
||||
|
||||
friend class FrameMaker;
|
||||
};
|
||||
|
@ -308,6 +308,15 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
}
|
||||
}
|
||||
}
|
||||
for (size_t idx : hum->chged_props_) {
|
||||
if (idx < room->frame_event.chged_props_.size()) {
|
||||
auto& p = room->frame_event.chged_props_[idx];
|
||||
auto& target = std::get<0>(p);
|
||||
if (target.Get()) {
|
||||
*msg->add_chged_property_list() = std::get<1>(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (room->GetRoomMode() == kZombieMode && room->BattleStarted()) {
|
||||
room->FillObjectPositions((Human*)hum, *msg);
|
||||
}
|
||||
|
@ -2052,6 +2052,9 @@ void Human::ClearFrameData()
|
||||
if (!chged_cars_.empty()) {
|
||||
chged_cars_.clear();
|
||||
}
|
||||
if (!chged_props_.empty()) {
|
||||
chged_props_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void Human::GenBattleReportData(a8::MutableXObject* params)
|
||||
|
@ -319,6 +319,7 @@ protected:
|
||||
std::vector<int> chged_zombieid_;
|
||||
std::vector<int> dead_alive_objs_;
|
||||
std::vector<int> chged_cars_;
|
||||
std::vector<int> chged_props_;
|
||||
Human* follow_target_ = nullptr;
|
||||
bool follow_synced_active_player = false;
|
||||
Car* car_ = nullptr;
|
||||
|
@ -152,8 +152,13 @@ void Player::UpdateMove()
|
||||
if (HasBuffEffect(kBET_Vertigo)) {
|
||||
return;
|
||||
}
|
||||
if (GetCar() && GetCar()->HasBuffEffect(kBET_Vertigo)) {
|
||||
return;
|
||||
if (GetCar()) {
|
||||
if (GetCar()->HasBuffEffect(kBET_Vertigo)) {
|
||||
return;
|
||||
}
|
||||
if (!GetCar()->HasOil()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (HasBuffEffect(kBET_Passenger)) {
|
||||
return;
|
||||
@ -167,6 +172,7 @@ void Player::UpdateMove()
|
||||
moved_frames = 0;
|
||||
return;
|
||||
}
|
||||
a8::Vec2 old_pos = GetPos();
|
||||
if (GetCar() && GetCar()->IsDriver(this)) {
|
||||
_UpdateMove(std::max(1, (int)GetCar()->GetSpeed()));
|
||||
} else {
|
||||
@ -177,6 +183,12 @@ void Player::UpdateMove()
|
||||
}
|
||||
if (GetCar() && GetCar()->IsDriver(this)) {
|
||||
GetCar()->SyncPos();
|
||||
float dec_oil = old_pos.Distance(GetPos()) * GetCar()->meta->i->average_oil() / 100;
|
||||
GetCar()->DecOil(dec_oil);
|
||||
room->frame_event.AddPropChg(GetCar()->GetWeakPtrRef(),
|
||||
kPropCarOil,
|
||||
GetCar()->GetCurOil(),
|
||||
GetCar()->GetMaxOil());
|
||||
}
|
||||
#ifdef DEBUG
|
||||
room->CheckPartObjects();
|
||||
|
@ -126,7 +126,7 @@ message Equip
|
||||
optional int32 through_teammate = 54;
|
||||
optional int32 text_icon = 55;
|
||||
optional string special_damage_type = 56;
|
||||
optional int32 max_oil = 57;
|
||||
optional float max_oil = 57;
|
||||
optional float average_oil = 58;
|
||||
|
||||
optional string inventory_slot = 31; //库存槽位
|
||||
|
Loading…
x
Reference in New Issue
Block a user