添加空投处理

This commit is contained in:
aozhiwei 2021-10-26 11:57:08 +08:00
parent 285b0cea65
commit 0853244c99
5 changed files with 43 additions and 5 deletions

View File

@ -59,9 +59,11 @@ static void InternalCreateBullet(BulletInfo& bullet_info)
}
}
if (bullet_info.recoil_force > 0) {
c->DoRecoilForce(bullet_info.recoil_force);
bullet_info.bullet_born_pos = bullet_info.bullet_born_pos -
(bullet_info.bullet_dir * bullet_info.recoil_force);
if (c->GetCurrWeapon()->ammo <= 0) {
c->DoRecoilForce(bullet_info.recoil_force);
bullet_info.bullet_born_pos = bullet_info.bullet_born_pos -
(bullet_info.bullet_dir * bullet_info.recoil_force);
}
}
int bullet_uniid = 0;
if (MetaMgr::Instance()->prebattle_can_use_skill ||

View File

@ -866,6 +866,39 @@ namespace MetaData
void AirDrop::Init()
{
{
int total_weight = 0;
std::vector<std::string> strings;
a8::Split(i->drop_id(), strings, '|');
for (const std::string& str : strings) {
std::vector<std::string> strings2;
a8::Split(str, strings2, ':');
assert(strings2.size() == 2);
int drop_id = a8::XValue(strings2[0]);
int weight = a8::XValue(strings2[1]);
total_weight += weight;
drop.push_back
(std::make_tuple(
drop_id,
total_weight
)
);
}
}
}
int AirDrop::RandDrop()
{
if (HasDrop()) {
int total_weight = std::get<1>(drop[drop.size() - 1]);
int rnd = rand() % total_weight;
for (auto& tuple : drop) {
if (rnd < std::get<1>(tuple)) {
return std::get<0>(tuple);
}
}
}
return 0;
}
void AirRaid::Init()

View File

@ -200,8 +200,11 @@ namespace MetaData
struct AirDrop
{
const metatable::AirDrop* i = nullptr;
std::vector<std::tuple<int, int>> drop;
bool HasDrop() { return !drop.empty();};
void Init();
int RandDrop();
};
struct AirRaid

View File

@ -1637,7 +1637,7 @@ void Room::InitAirDrop()
a8::XParams()
.SetSender(this)
.SetParam1(air_drop.i->appear_time())
.SetParam2(air_drop.i->drop_id())
.SetParam2(air_drop.RandDrop())
.SetParam3(air_drop.i->id()),
[] (const a8::XParams& param)
{

View File

@ -326,7 +326,7 @@ message AirDrop
optional int32 id = 1;
optional int32 time = 2;
optional int32 appear_time = 3;
optional int32 drop_id = 4;
optional string drop_id = 4;
}
message AirRaid