1
This commit is contained in:
parent
7b5cefb0b5
commit
a0e26e3dab
@ -96,7 +96,8 @@ void MapInstance::CreateThings()
|
||||
case kMOT_Object:
|
||||
{
|
||||
{
|
||||
int thing_id = thing_tpl.RandThing();
|
||||
int num = 0;
|
||||
int thing_id = thing_tpl.RandThing(num);
|
||||
if (MetaMgr::Instance()->level0room_spec_things_set.find(thing_id) !=
|
||||
MetaMgr::Instance()->level0room_spec_things_set.end()) {
|
||||
level0room_spec_things_.push_back(&thing_tpl);
|
||||
@ -323,7 +324,8 @@ void MapInstance::CreateBlock()
|
||||
|
||||
void MapInstance::CreateMapObject(MetaData::MapTplThing& thing_tpl)
|
||||
{
|
||||
int thing_id = thing_tpl.RandThing();
|
||||
int num = 0;
|
||||
int thing_id = thing_tpl.RandThing(num);
|
||||
MetaData::MapThing* thing_meta = MetaMgr::Instance()->GetMapThing(thing_id);
|
||||
if (thing_meta) {
|
||||
if (thing_meta->i->is_house()) {
|
||||
|
@ -672,25 +672,30 @@ namespace MetaData
|
||||
for (auto& str : strings) {
|
||||
std::vector<std::string> strings2;
|
||||
a8::Split(str, strings2, ':');
|
||||
assert(strings2.size() == 2);
|
||||
assert(strings2.size() >= 2);
|
||||
rand_space += a8::XValue(strings2[1]).GetInt();
|
||||
int num = strings2.size() > 2 ? a8::XValue(strings2[2]).GetInt() : 1;
|
||||
num = std::max(num, 1);
|
||||
things.push_back(std::make_tuple(
|
||||
a8::XValue(strings2[0]),
|
||||
rand_space
|
||||
rand_space,
|
||||
num
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int MapTplThing::RandThing()
|
||||
int MapTplThing::RandThing(int& num)
|
||||
{
|
||||
num = 0;
|
||||
if (rand_space <= 0) {
|
||||
return 0;
|
||||
}
|
||||
int rnd = rand() % rand_space;
|
||||
for (auto& tuple : things) {
|
||||
if (std::get<1>(tuple) > rnd) {
|
||||
num = std::get<2>(tuple);
|
||||
return std::get<0>(tuple);
|
||||
}
|
||||
}
|
||||
|
@ -159,9 +159,9 @@ namespace MetaData
|
||||
const metatable::MapTplThingJson* i = nullptr;
|
||||
|
||||
void Init();
|
||||
int RandThing();
|
||||
int RandThing(int& num);
|
||||
|
||||
std::vector<std::tuple<int, int>> things;
|
||||
std::vector<std::tuple<int, int, int>> things;
|
||||
std::vector<int> heros;
|
||||
int param1_int = 0;
|
||||
int rand_space = 0;
|
||||
|
@ -2143,7 +2143,8 @@ void Room::CreateLoots()
|
||||
{
|
||||
std::vector<std::tuple<MetaData::Equip*, MetaData::MapTplThing*>> car_equips;
|
||||
for (auto& thing_tpl : *loots_) {
|
||||
int thing_id = thing_tpl->RandThing();
|
||||
int num = 0;
|
||||
int thing_id = thing_tpl->RandThing(num);
|
||||
MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(thing_id);
|
||||
if (equip_meta) {
|
||||
if (equip_meta->i->equip_type() == EQUIP_TYPE_CAR) {
|
||||
@ -2156,7 +2157,7 @@ void Room::CreateLoots()
|
||||
thing_tpl->i->x(),
|
||||
thing_tpl->i->y()
|
||||
),
|
||||
1,
|
||||
num,
|
||||
1
|
||||
);
|
||||
}
|
||||
@ -3416,7 +3417,8 @@ void Room::CreateLevel0RoomSpecThings()
|
||||
{
|
||||
if (level0room_spec_things_) {
|
||||
for (auto& thing_tpl : *level0room_spec_things_) {
|
||||
int thing_id = thing_tpl->RandThing();
|
||||
int num = 0;
|
||||
int thing_id = thing_tpl->RandThing(num);
|
||||
MetaData::MapThing* thing_meta = MetaMgr::Instance()->GetMapThing(thing_id);
|
||||
if (thing_meta) {
|
||||
InternalCreateObstacle(thing_id, thing_tpl->i->x(), thing_tpl->i->y(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user