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