Untitled
unknown
plain_text
a year ago
7.7 kB
5
Indexable
case 11: // collect object { string name_ = pInfo(peer)->world; if (p_->x < 0 || p_->y < 0) break; bool displaybox = true; World world_ = get_world(name_); for (int i_ = 0; i_ < world_.drop.size(); i_++) { if (world_.drop[i_].id == 0 or world_.drop[i_].x / 32 < 0 or world_.drop[i_].x / 32 > 99 or world_.drop[i_].y / 32 < 0 or world_.drop[i_].y / 32 > 59) continue; WorldBlock block_ = world_.blocks[world_.drop[i_].x / 32 + (world_.drop[i_].y / 32 * 100)]; if (world_.drop[i_].uid == p_->plantingTree) { if (block_.fg == 1422 || block_.fg == 2488) { displaybox = false; if (pInfo(peer)->adminLevel == 7 || pInfo(peer)->adminLevel == 6 || pInfo(peer)->adminLevel == 5 || pInfo(peer)->adminLevel == 4 || pInfo(peer)->adminLevel == 3 || pInfo(peer)->adminLevel == 2 || pInfo(peer)->adminLevel == 1 || world_.open_to_public || world_.owner_name == "" || world_.owner_name == pInfo(peer)->tankIDName || find(world_.admins.begin(), world_.admins.end(), pInfo(peer)->tankIDName) != world_.admins.end()) displaybox = true; } if (abs((int)p_->x / 32 - world_.drop[i_].x / 32) > 1 || abs((int)p_->x - world_.drop[i_].x) >= 32 or abs((int)p_->y - world_.drop[i_].y) >= 32) displaybox = false; if (displaybox) { int c_ = world_.drop[i_].count; if (world_.drop[i_].id == world_.special_event_item && world_.special_event && world_.drop[i_].special) { world_.special_event_item_taken++; if (items[world_.special_event_item].event_total == world_.special_event_item_taken) { gamepacket_t p, p3; p.Insert("OnAddNotification"), p.Insert("interface/large/special_event.rttex"), p.Insert("`2" + items[world_.special_event_item].event_name + ":`` `oSuccess! " + (items[world_.special_event_item].event_total == 1 ? "`2" + pInfo(peer)->tankIDName + "`` found it!``" : "All items found!``") + ""), p.Insert("audio/cumbia_horns.wav"), p.Insert(0); p3.Insert("OnConsoleMessage"), p3.Insert("`2" + items[world_.special_event_item].event_name + ":`` `oSuccess!`` " + (items[world_.special_event_item].event_total == 1 ? "`2" + pInfo(peer)->tankIDName + "`` `ofound it!``" : "All items found!``") + ""); for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) { if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL or pInfo(currentPeer)->world != name_) continue; if (items[world_.special_event_item].event_total != 1) { gamepacket_t p2; p2.Insert("OnConsoleMessage"), p2.Insert("`2" + items[world_.special_event_item].event_name + ":`` `0" + pInfo(peer)->tankIDName + "`` found a " + items[world_.special_event_item].name + "! (" + to_string(world_.special_event_item_taken) + "/" + to_string(items[world_.special_event_item].event_total) + ")``"), p2.CreatePacket(currentPeer); } p.CreatePacket(currentPeer); p3.CreatePacket(currentPeer); } world_.last_special_event = 0, world_.special_event_item = 0, world_.special_event_item_taken = 0, world_.special_event = false; } else { gamepacket_t p2; p2.Insert("OnConsoleMessage"), p2.Insert("`2" + items[world_.special_event_item].event_name + ":`` `0" + pInfo(peer)->tankIDName + "`` found a " + items[world_.special_event_item].name + "! (" + to_string(world_.special_event_item_taken) + "/" + to_string(items[world_.special_event_item].event_total) + ")``"); for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) { if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL or pInfo(currentPeer)->world != name_) continue; p2.CreatePacket(currentPeer); } } } if (modify_inventory(peer, world_.drop[i_].id, c_, false, true) == 0 or world_.drop[i_].id == 112) { PlayerMoving data_{}; data_.effect_flags_check = 1, data_.packetType = 14, data_.netID = pInfo(peer)->netID, data_.plantingTree = world_.drop[i_].uid; BYTE* raw = packPlayerMoving(&data_); if (world_.drop[i_].id == 112) pInfo(peer)->gems += c_; else { add_cctv(peer, "took", to_string(world_.drop[i_].count) + " " + items[world_.drop[i_].id].name); gamepacket_t p; p.Insert("OnConsoleMessage"), p.Insert("Collected `w" + to_string(world_.drop[i_].count) + "" + (items[world_.drop[i_].id].blockType == BlockTypes::FISH ? "lb." : "") + " " + items[world_.drop[i_].id].ori_name + "``." + (items[world_.drop[i_].id].rarity > 363 ? "" : " Rarity: `w" + to_string(items[world_.drop[i_].id].rarity) + "``") + ""), p.CreatePacket(peer); } for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) { if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL or pInfo(currentPeer)->world != name_) continue; send_raw(currentPeer, 4, raw, 56, ENET_PACKET_FLAG_RELIABLE); } delete[]raw; world_.drop[i_].id = 0, world_.drop[i_].x = -1, world_.drop[i_].y = -1; } else { if (c_ < 200 and world_.drop[i_].count >(200 - c_)) { int b_ = 200 - c_; world_.drop[i_].count -= b_; if (modify_inventory(peer, world_.drop[i_].id, b_, false) == 0) { add_cctv(peer, "took", to_string(world_.drop[i_].count) + " " + items[world_.drop[i_].id].name); WorldDrop drop_{}; drop_.id = world_.drop[i_].id, drop_.count = world_.drop[i_].count, drop_.uid = uint16_t(world_.drop.size()) + 1, drop_.x = world_.drop[i_].x, drop_.y = world_.drop[i_].y; world_.drop.push_back(drop_); gamepacket_t p; p.Insert("OnConsoleMessage"); p.Insert("Collected `w" + to_string(200 - c_) + " " + items[world_.drop[i_].id].ori_name + "``." + (items[world_.drop[i_].id].rarity > 363 ? "" : " Rarity: `w" + to_string(items[world_.drop[i_].id].rarity) + "``") + ""); PlayerMoving data_{}; data_.packetType = 14, data_.netID = -1, data_.plantingTree = world_.drop[i_].id, data_.x = world_.drop[i_].x, data_.y = world_.drop[i_].y; int32_t item = -1; float val = world_.drop[i_].count; BYTE* raw = packPlayerMoving(&data_); data_.plantingTree = world_.drop[i_].id; memcpy(raw + 8, &item, 4); memcpy(raw + 16, &val, 4); val = 0; data_.netID = pInfo(peer)->netID; data_.plantingTree = world_.drop[i_].uid; data_.x = 0, data_.y = 0; BYTE* raw2 = packPlayerMoving(&data_); BYTE val2 = 0; memcpy(raw2 + 8, &item, 4); memcpy(raw2 + 16, &val, 4); memcpy(raw2 + 1, &val2, 1); world_.drop[i_].id = 0, world_.drop[i_].x = -1, world_.drop[i_].y = -1; for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) { if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL or pInfo(currentPeer)->world != name_) continue; send_raw(currentPeer, 4, raw, 56, ENET_PACKET_FLAG_RELIABLE); if (pInfo(currentPeer)->netID == pInfo(peer)->netID) p.CreatePacket(currentPeer); send_raw(currentPeer, 4, raw2, 56, ENET_PACKET_FLAG_RELIABLE); } delete[]raw, raw2; } } } } } } break; }
Editor is loading...