1
This commit is contained in:
parent
1efbf7783e
commit
a46c6c47be
@ -470,7 +470,10 @@ float Car::GetMaxOil()
|
|||||||
void Car::DropItems(Obstacle* obstacle)
|
void Car::DropItems(Obstacle* obstacle)
|
||||||
{
|
{
|
||||||
if (obstacle->meta->HasDrop()) {
|
if (obstacle->meta->HasDrop()) {
|
||||||
room->ScatterDrop(obstacle->GetPos().ToGlmVec3(), obstacle->meta->RandDrop());
|
std::vector<int> drops = obstacle->meta->RandDrop();
|
||||||
|
for (int drop_id : drops) {
|
||||||
|
room->ScatterDrop(obstacle->GetPos().ToGlmVec3(), drop_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,9 +301,8 @@ std::string Hero::GetName()
|
|||||||
void Hero::DropItems(Obstacle* obstacle)
|
void Hero::DropItems(Obstacle* obstacle)
|
||||||
{
|
{
|
||||||
bool is_treasure_box = false;
|
bool is_treasure_box = false;
|
||||||
int drop_id = obstacle->meta->RandDrop();
|
std::vector<int> drops = obstacle->meta->RandDrop();
|
||||||
if (drop_id == 0) {
|
for (int drop_id : drops) {
|
||||||
return;
|
room->ScatterDrop(obstacle->GetPos().ToGlmVec3(), drop_id);
|
||||||
}
|
}
|
||||||
room->ScatterDrop(obstacle->GetPos().ToGlmVec3(), drop_id);
|
|
||||||
}
|
}
|
||||||
|
@ -1903,15 +1903,10 @@ void Human::DecItem(int item_id, int item_num)
|
|||||||
void Human::DropItems(Obstacle* obstacle)
|
void Human::DropItems(Obstacle* obstacle)
|
||||||
{
|
{
|
||||||
bool is_treasure_box = false;
|
bool is_treasure_box = false;
|
||||||
int drop_id = obstacle->meta->RandDrop();
|
std::vector<int> drops = obstacle->meta->RandDrop();
|
||||||
if (drop_id == 0) {
|
for (int drop_id : drops) {
|
||||||
return;
|
room->ScatterDrop(obstacle->GetPos().ToGlmVec3(), drop_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drop_id == 0) {
|
|
||||||
drop_id = obstacle->meta->RandDrop();
|
|
||||||
}
|
|
||||||
room->ScatterDrop(obstacle->GetPos().ToGlmVec3(), drop_id);
|
|
||||||
if (is_treasure_box) {
|
if (is_treasure_box) {
|
||||||
++box_drop_times_;
|
++box_drop_times_;
|
||||||
} else {
|
} else {
|
||||||
|
@ -120,18 +120,22 @@ namespace mt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int MapThing::RandDrop() const
|
std::vector<int> MapThing::RandDrop() const
|
||||||
{
|
{
|
||||||
if (HasDrop()) {
|
if (HasDrop()) {
|
||||||
int total_weight = std::get<1>(_drop[_drop.size() - 1]);
|
int total_weight = std::get<1>(_drop[_drop.size() - 1]);
|
||||||
int rnd = rand() % total_weight;
|
int rnd = rand() % total_weight;
|
||||||
for (auto& tuple : _drop) {
|
for (auto& tuple : _drop) {
|
||||||
if (rnd < std::get<1>(tuple)) {
|
if (rnd < std::get<1>(tuple)) {
|
||||||
|
#if 0
|
||||||
return std::get<0>(tuple);
|
return std::get<0>(tuple);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ namespace mt
|
|||||||
bool HasDrop() const { return !_drop.empty();};
|
bool HasDrop() const { return !_drop.empty();};
|
||||||
|
|
||||||
void Init1();
|
void Init1();
|
||||||
int RandDrop() const;
|
std::vector<int> RandDrop() const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -224,7 +224,10 @@ void Obstacle::OnExplosionHit(Explosion* e)
|
|||||||
if (IsDead(e->GetRoom())) {
|
if (IsDead(e->GetRoom())) {
|
||||||
ProcDieExplosion(e->GetRoom());
|
ProcDieExplosion(e->GetRoom());
|
||||||
if (meta->HasDrop()) {
|
if (meta->HasDrop()) {
|
||||||
e->GetRoom()->ScatterDrop(GetPos().ToGlmVec3(), meta->RandDrop());
|
std::vector<int> drops = meta->RandDrop();
|
||||||
|
for (int drop_id : drops) {
|
||||||
|
e->GetRoom()->ScatterDrop(GetPos().ToGlmVec3(), drop_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (meta->thing_type() == kObstacleOilBucket) {
|
if (meta->thing_type() == kObstacleOilBucket) {
|
||||||
const mt::MapThing* bomb_meta = mt::MapThing::GetById(meta->_int_param1);
|
const mt::MapThing* bomb_meta = mt::MapThing::GetById(meta->_int_param1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user