1
This commit is contained in:
parent
a46c6c47be
commit
7ea8b20145
@ -39,7 +39,7 @@ namespace mt
|
||||
std::vector<std::string> strings2;
|
||||
a8::Split(str, strings2, ':');
|
||||
int drop_id = a8::XValue(strings2[0]);
|
||||
int weight = strings2.size() > 1 ? a8::XValue(strings2[1]).GetInt() : 10000;
|
||||
int weight = strings2.size() > 1 ? a8::XValue(strings2[1]).GetInt() : -1;
|
||||
total_weight += weight;
|
||||
_drop.push_back
|
||||
(std::make_tuple(
|
||||
@ -48,6 +48,7 @@ namespace mt
|
||||
)
|
||||
);
|
||||
}
|
||||
total_weight = std::max(total_weight, 1);
|
||||
}
|
||||
{
|
||||
std::vector<std::string> strings;
|
||||
@ -122,20 +123,21 @@ namespace mt
|
||||
|
||||
std::vector<int> MapThing::RandDrop() const
|
||||
{
|
||||
std::vector<int> drops;
|
||||
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)) {
|
||||
#if 0
|
||||
return std::get<0>(tuple);
|
||||
#endif
|
||||
if (std::get<1>(tuple) < 0){
|
||||
drops.push_back(std::get<0>(tuple));
|
||||
} else {
|
||||
if (rnd < std::get<1>(tuple)) {
|
||||
drops.push_back(std::get<0>(tuple));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
return 0;
|
||||
#endif
|
||||
return drops;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user