Fighter* Projectile::checkHits(Fighter* other) { Hitbox temp = hit; Hitbox atkbox; vector<Circle> circles = temp.getCircles(); for (uint8 n = 0; n < circles.size(); n++) { Circle current = circles[n]; Circle newcircright(current.getX() + x, current.getY() + y, current.getRadius(), current.getKnockback(), current.damage); Circle newcircleft(64 - current.getX() + x, current.getY() + y, current.getRadius(), current.getKnockback(), current.damage); if (dx < 0) atkbox.addCircle(newcircright); else atkbox.addCircle(newcircleft); } if(TYPE == THUNDER1 || TYPE == THUNDER2 || TYPE == THUNDER3 || TYPE == THUNDER4) { vector<Projectile> projs = *((vector<Projectile>*)getProj()); for(int n = 0; n < (int)projs.size(); n++) { if(projs[n].owner == owner && (projs[n].TYPE == THUNDER1 || projs[n].TYPE == THUNDER2 || projs[n].TYPE == THUNDER3 || projs[n].TYPE == THUNDER4)) { if(!projs[n].enabled) enabled = false; } } } if (!enabled) { if(TYPE == THUNDER1 || TYPE == THUNDER2 || TYPE == THUNDER3 || TYPE == THUNDER4) { vector<Projectile> projs = *((vector<Projectile>*)getProj()); for(int n = 0; n < (int)projs.size(); n++) { if(projs[n].owner == owner && (projs[n].TYPE == THUNDER1 || projs[n].TYPE == THUNDER2 || projs[n].TYPE == THUNDER3 || projs[n].TYPE == THUNDER4)) { projs[n].enabled = false; } } } return other; } if (other -> respawntimer > 0) return other; if (other -> invincibility > 0) return other; if(atkbox.hits(other -> getAtkbox())) { if(atkbox.getHitCircle(other -> getAtkbox()).priority < other -> getAtkbox().getHitCircle(atkbox).priority) { if (dx < 0) other -> takeDamage(atkbox.getHitCircle(other -> getDefbox(PA_GetSpriteAnimFrame(MAIN_SCREEN, other -> SPRITENUM))), 1, owner, 0); else other -> takeDamage(atkbox.getHitCircle(other -> getDefbox(PA_GetSpriteAnimFrame(MAIN_SCREEN, other -> SPRITENUM))), -1, owner, 0); } else if(atkbox.getHitCircle(other -> getAtkbox()).priority == other -> getAtkbox().getHitCircle(atkbox).priority) { removeProj(num); } else { removeProj(num); return other; // they win priority } } else if(atkbox.hits(other -> getDefbox(PA_GetSpriteAnimFrame(MAIN_SCREEN, other -> SPRITENUM)))) { if(other -> MYCHAR == KIRBY && PA_GetSpriteAnimFrame(MAIN_SCREEN, other -> SPRITENUM) == 189) { if(TYPE != THUNDER1 && TYPE != THUNDER2 && TYPE != THUNDER3 && TYPE != THUNDER4 && TYPE != IKESWORD) removeProj(num); else atkbox.enabled = false; } else if (other -> action == AIRDODGE || other -> action == ROLL || other -> action == DODGE) { /*doesn't hit*/ } else if (other -> action == SHIELD) { other -> shieldstr -= (int)((atkbox.getHitCircle(other -> getDefbox(PA_GetSpriteAnimFrame(MAIN_SCREEN, other -> SPRITENUM))).damage)); if(TYPE != THUNDER1 && TYPE != THUNDER2 && TYPE != THUNDER3 && TYPE != THUNDER4 && TYPE != IKESWORD) removeProj(num); else atkbox.enabled = false; if(TYPE == THUNDER1 || TYPE == THUNDER2 || TYPE == THUNDER3 || TYPE == THUNDER4) { vector<Projectile> projs = *((vector<Projectile>*)getProj()); for(int n = 0; n < (int)projs.size(); n++) { if(projs[n].owner == owner && (projs[n].TYPE == THUNDER1 || projs[n].TYPE == THUNDER2 || projs[n].TYPE == THUNDER3 || projs[n].TYPE == THUNDER4)) projs[n].enabled = false; } } } else if(other -> COUNTER) { if(TYPE != THUNDER1 && TYPE != THUNDER2 && TYPE != THUNDER3 && TYPE != THUNDER4 && TYPE != IKESWORD) removeProj(num); else atkbox.enabled = false; other -> COUNTER = false; if(other -> MYCHAR == IKE && (PA_GetSpriteAnimFrame(MAIN_SCREEN, other -> SPRITENUM) == 139 || PA_GetSpriteAnimFrame(MAIN_SCREEN, other -> SPRITENUM) == 140)) { PA_StartSpriteAnimEx(MAIN_SCREEN, other -> SPRITENUM, 143, 144, 10, ANIM_LOOP, -1); other -> action = ATTACK; other -> delay = 60/10 * 2; other -> freeze(30); other -> dx = 0; PA_StartSpriteAnimEx(MAIN_SCREEN, other -> SPRITENUM, 139, 139, 1, ANIM_LOOP, -1); } if(TYPE == THUNDER1 || TYPE == THUNDER2 || TYPE == THUNDER3 || TYPE == THUNDER4) { vector<Projectile> projs = *((vector<Projectile>*)getProj()); for(int n = 0; n < (int)projs.size(); n++) { if(projs[n].owner == owner && (projs[n].TYPE == THUNDER1 || projs[n].TYPE == THUNDER2 || projs[n].TYPE == THUNDER3 || projs[n].TYPE == THUNDER4)) projs[n].enabled = false; } } } else if(other -> CAPE) { dx *= -1; owner = other -> charnum; vector<Circle> temp = hit.getCircles(); hit.reset(); for(int n = 0; n < (int)temp.size();n++) { hit.addCircle(Circle(temp[n].getX(), temp[n].getY(), temp[n].getRadius(), Knockback(temp[n].getKnockback().dx * -1, temp[n].getKnockback().dy, temp[n].getKnockback().length), temp[n].damage)); } if(dx > 0) PA_SetSpriteHflip(MAIN_SCREEN, num, 0); if(dx < 0) PA_SetSpriteHflip(MAIN_SCREEN, num, 1); } else if (other -> ABSORB && (TYPE != IKESWORD)) { other -> percentage -= atkbox.getHitCircle(other -> getDefbox(PA_GetSpriteAnimFrame(MAIN_SCREEN, other -> SPRITENUM))).damage; if(other -> percentage < 0) other -> percentage = 0; if(TYPE != THUNDER1 && TYPE != THUNDER2 && TYPE != THUNDER3 && TYPE != THUNDER4) removeProj(num); else atkbox.enabled = false; if(TYPE == THUNDER1 || TYPE == THUNDER2 || TYPE == THUNDER3 || TYPE == THUNDER4) { vector<Projectile> projs = *((vector<Projectile>*)getProj()); for(int n = 0; n < (int)projs.size(); n++) { if(projs[n].owner == owner && (projs[n].TYPE == THUNDER1 || projs[n].TYPE == THUNDER2 || projs[n].TYPE == THUNDER3 || projs[n].TYPE == THUNDER4)) projs[n].enabled = false; } } } else { other -> takeDamage(atkbox.getHitCircle(other -> getDefbox(PA_GetSpriteAnimFrame(MAIN_SCREEN, other -> SPRITENUM))), 1, owner, 0); if (TYPE != FINALCUTTER && TYPE != IKESWORD && TYPE != THUNDER1 && TYPE != THUNDER2 && TYPE != THUNDER3 && TYPE != THUNDER4) removeProj(num); else enabled = false; if(TYPE == THUNDER1 || TYPE == THUNDER2 || TYPE == THUNDER3 || TYPE == THUNDER4) { vector<Projectile> projs = *((vector<Projectile>*)getProj()); for(int n = 0; n < (int)projs.size(); n++) { if(projs[n].owner == owner && (projs[n].TYPE == THUNDER1 || projs[n].TYPE == THUNDER2 || projs[n].TYPE == THUNDER3 || projs[n].TYPE == THUNDER4)) projs[n].enabled = false; } } } } return other; }
StatusWith<Message> downconvertFindCommandRequest(const RemoteCommandRequest& request) { const auto& cmdObj = request.cmdObj; const NamespaceString nss(request.dbname, cmdObj.firstElement().String()); if (!nss.isValid()) { return {ErrorCodes::InvalidNamespace, str::stream() << "Invalid collection name: " << nss.ns()}; } const std::string& ns = nss.ns(); // It is a little heavy handed to use QueryRequest to convert the command object to // query() arguments but we get validation and consistent behavior with the find // command implementation on the remote server. auto qrStatus = QueryRequest::makeFromFindCommand(nss, cmdObj, false); if (!qrStatus.isOK()) { return qrStatus.getStatus(); } auto qr = std::move(qrStatus.getValue()); // We are downconverting a find command, and find command can only have ntoreturn // if it was generated by mongos. invariant(!qr->getNToReturn()); Query query(qr->getFilter()); if (!qr->getSort().isEmpty()) { query.sort(qr->getSort()); } if (!qr->getHint().isEmpty()) { query.hint(qr->getHint()); } if (!qr->getMin().isEmpty()) { query.minKey(qr->getMin()); } if (!qr->getMax().isEmpty()) { query.minKey(qr->getMax()); } if (qr->isExplain()) { query.explain(); } if (qr->isSnapshot()) { query.snapshot(); } const int nToReturn = qr->getLimit().value_or(0) * -1; const int nToSkip = qr->getSkip().value_or(0); const BSONObj* fieldsToReturn = &qr->getProj(); int queryOptions = qr->getOptions(); // non-const so we can set slaveOk if we need to const int batchSize = qr->getBatchSize().value_or(0); const int nextBatchSize = [batchSize, nToReturn]() { if (nToReturn == 0) return batchSize; if (batchSize == 0) return nToReturn; return batchSize < nToReturn ? batchSize : nToReturn; }(); // We can't downconvert all metadata, since we aren't sending a command, but we do need to // downconvert $secondaryOk to the slaveOK bit. auto ssm = rpc::ServerSelectionMetadata::readFromMetadata( request.metadata.getField(rpc::ServerSelectionMetadata::fieldName())); if (!ssm.isOK()) { return ssm.getStatus(); } if (ssm.getValue().isSecondaryOk()) { queryOptions |= mongo::QueryOption_SlaveOk; } Message message; assembleQueryRequest( ns, query.obj, nextBatchSize, nToSkip, fieldsToReturn, queryOptions, message); return {std::move(message)}; }