fdhgayporn
unknown
c_cpp
a year ago
6.7 kB
9
Indexable
void autofarming(ENetPeer* peer) { long long ms_time = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count(); try { if (autofarm_delay - ms_time <= 0) { autofarm_delay = ms_time + 400; if (pInfo(peer)->autofarm_tile_x == 0 && pInfo(peer)->autofarm_tile_y == 0) return; int farmable = pInfo(peer)->farmable; int c_ = 0; int isRemote = 0; modify_inventory(peer, farmable, c_); modify_inventory(peer, 5640, isRemote); if (pInfo(peer)->save_time + 20 < (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count()) { if (pInfo(peer)->save_time != 0) { if (pInfo(peer)->autofarm == 1) { if ((farmable == 13720 || farmable == 13722 || farmable == 13724) && isRemote == 0) { if (c_ > 0) { if (pInfo(peer)->y / 32 == pInfo(peer)->y / 32) { edit_tile(peer, pInfo(peer)->autofarm_tile_x + (pInfo(peer)->state == 16 ? -1 : 1), pInfo(peer)->autofarm_tile_y, pInfo(peer)->farmable); edit_tile(peer, pInfo(peer)->autofarm_tile_x + (pInfo(peer)->state == 16 ? -1 : 1), pInfo(peer)->autofarm_tile_y, 18); edit_tile(peer, pInfo(peer)->autofarm_tile_x + (pInfo(peer)->state == 16 ? -1 : 1), pInfo(peer)->autofarm_tile_y, 18); edit_tile(peer, pInfo(peer)->autofarm_tile_x + (pInfo(peer)->state == 16 ? -1 : 1), pInfo(peer)->autofarm_tile_y, 18); } } else { pInfo(peer)->autofarm = 0, pInfo(peer)->farmable = 0; gamepacket_t ps; ps.Insert("OnTalkBubble"), ps.Insert(pInfo(peer)->netID), ps.Insert("`4Autofarm Stopped! `oYou don't have enough block to farm!"), ps.CreatePacket(peer); } } else if (farmable == 5640 && isRemote == 1 && c_ == 0) { string name_ = pInfo(peer)->world; vector<World>::iterator p = find_if(worlds.begin(), worlds.end(), [name_](const World& a) { return a.name == name_; }); if (p != worlds.end()) { World* world_ = &worlds[p - worlds.begin()]; if (pInfo(peer)->x != -1 and pInfo(peer)->y != -1) { if (pInfo(peer)->x != -1 and pInfo(peer)->y != -1) { int x_ = (pInfo(peer)->state == 16 ? (int)pInfo(peer)->x / 32 : round((double)pInfo(peer)->x / 32)); int y_ = (int)pInfo(peer)->y / 32; WorldBlock* block_ = &world_->blocks[x_ + (y_ * 100)]; for (int i_ = 0; i_ < world_->machines.size(); i_++) { WorldMachines machine = world_->machines[i_]; if (machine.x == pInfo(peer)->magnetron_x and machine.y == pInfo(peer)->magnetron_y and machine.id == 5638) { if (machine.enabled) { WorldBlock* itemas = &world_->blocks[machine.x + (machine.y * 100)]; if (itemas->magnetron and itemas->id == pInfo(peer)->magnetron_id) { int items22 = itemas->id; if (block_->fg == 0 && block_->bg == 0) { if (pInfo(peer)->autofarm == 1) { if (pInfo(peer)->magnetron_id == 13720 || pInfo(peer)->magnetron_id == 13722 || pInfo(peer)->magnetron_id == 13724) { if (itemas->pr > 0) { if (pInfo(peer)->hand == 2952 || pInfo(peer)->hand == 9522 || pInfo(peer)->hand == 9520 || has_playmod(pInfo(peer), "Hit Potion!")) { if (pInfo(peer)->y / 32 == pInfo(peer)->y / 32) { itemas->pr--; edit_tile(peer, pInfo(peer)->autofarm_tile_x + (pInfo(peer)->state == 16 ? -1 : 1), pInfo(peer)->autofarm_tile_y, items22); edit_tile(peer, pInfo(peer)->autofarm_tile_x + (pInfo(peer)->state == 16 ? -1 : 1), pInfo(peer)->autofarm_tile_y, 18); } } else { if (pInfo(peer)->y / 32 == pInfo(peer)->y / 32) { itemas->pr--; edit_tile(peer, pInfo(peer)->autofarm_tile_x + (pInfo(peer)->state == 16 ? -1 : 1), pInfo(peer)->autofarm_tile_y, items22); edit_tile(peer, pInfo(peer)->autofarm_tile_x + (pInfo(peer)->state == 16 ? -1 : 1), pInfo(peer)->autofarm_tile_y, 18); edit_tile(peer, pInfo(peer)->autofarm_tile_x + (pInfo(peer)->state == 16 ? -1 : 1), pInfo(peer)->autofarm_tile_y, 18); edit_tile(peer, pInfo(peer)->autofarm_tile_x + (pInfo(peer)->state == 16 ? -1 : 1), pInfo(peer)->autofarm_tile_y, 18); } } } else { pInfo(peer)->autofarm = 0, pInfo(peer)->farmable = 0; gamepacket_t ps; ps.Insert("OnTalkBubble"), ps.Insert(pInfo(peer)->netID), ps.Insert("`4Autofarm Stopped! `oYou don't have enough block to farm!"), ps.CreatePacket(peer); PlayerMoving data_{}; data_.packetType = 5, data_.punchX = machine.x, data_.punchY = machine.y, data_.characterState = 0x8; BYTE* raw = packPlayerMoving(&data_, 112 + alloc_(world_, itemas)); BYTE* blc = raw + 56; form_visual(blc, *itemas, *world_, NULL, false); for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) { if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL) continue; if (pInfo(currentPeer)->world == world_->name) { send_raw(currentPeer, 4, raw, 112 + alloc_(world_, itemas), ENET_PACKET_FLAG_RELIABLE); } } delete[] raw, blc; } } } } } } } } } } } } else { pInfo(peer)->autofarm = 0, pInfo(peer)->farmable = 0; gamepacket_t p1; p1.Insert("OnTalkBubble"), p1.Insert(pInfo(peer)->netID), p1.Insert("`4You have REMOTE and BLOCK in the same time!"), p1.CreatePacket(peer); } } } } pInfo(peer)->save_time = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count(); } } catch (out_of_range) { for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) { if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL) continue; save_player(pInfo(currentPeer), false); for (int i = 0; i < worlds.size(); i++) { string world_name = worlds[i].name; save_world(world_name, false); } } save_guilds(); return; } }
Editor is loading...