bool CKing::isValidMove(int BDx, int BDy) { if(BDx == tileX && BDy == tileY) return false; bool ICP = isClearPath(BDx, BDy); if( ( ((tileX+1)==BDx) || ((tileX-1)==BDx) ) && ( ((tileY+1)==BDy) || ((tileY-1)==BDy) ) ) { if (ICP) { return !containsFriendlyPiece(BDx, BDy); } else { return false; }; } else if( ( (tileX == BDx && (BDy == tileY+1 || BDy == tileY-1)) || (tileY == BDy && (tileX == BDx-1 || tileX == BDx+1) ) ) && ICP) { return !containsFriendlyPiece(BDx, BDy); } else { return false; }; }
bool CQueen::isValidMove(int BDx, int BDy) { if(BDx == tileX && BDy == tileY) return false; return isClearPath(BDx, BDy) && !containsFriendlyPiece(BDx, BDy); }
bool CBiship::isValidMove(int BDx, int BDy) { if(tileX == BDx && tileY == BDy) return false; bool ICP = isClearPath(BDx, BDy); if(absolute((BDx-tileX))==absolute((BDy-tileY))) { if (ICP) { return !containsFriendlyPiece(BDx, BDy); } else { return false; }; } else { return false; }; }
bool CRook::isValidMove(int BDx, int BDy) { bool ICP = isClearPath(BDx, BDy); if(BDx == tileX && BDy == tileY) return false; if((tileX == BDx || tileY == BDy) && ICP) { return !containsFriendlyPiece(BDx, BDy); } else { return false; } }
bool CPawn::isValidMove(int BDx, int BDy) { //only fails if it moves one place forwards with a piece on the destination //OR if it moves two and is obstructed if(BDx == tileX && BDy == tileY) return false; if((tileX==2 && BDx==4 && tileY == BDy) || (tileX == 7 && BDx == 5 && tileY == BDy)) { return isClearPath(BDx, BDy); }; if(side == LEFT) { if(tileX+1 == BDx && tileY == BDy) { return !theGame->isOccupied(BDx, BDy); } else if(tileX+1 == BDx && (tileY+1 == BDy || tileY-1 == BDy)) { return theGame->isOccupied(BDx, BDy) && !containsFriendlyPiece(BDx, BDy); } else { return false; }; } else { if(tileX-1 == BDx && tileY == BDy) { return true; } else if(tileX-1 == BDx && (tileY+1 == BDy || tileY-1 == BDy)) { return theGame->isOccupied(BDx, BDy) && !containsFriendlyPiece(BDx, BDy); } else { return false; }; }; }
bool CKnight::isValidMove(int BDx, int BDy) { if(tileX == BDx && tileY == BDy) return false; bool ICP = isClearPath(BDx, BDy); //if(!ICP) return false; if((tileX-2 == BDx || tileX+2 == BDx) && (tileY+1 == BDy || tileY-1 == BDy)) { return !containsFriendlyPiece(BDx, BDy); } else if((tileX-1 == BDx || tileX+1 == BDx) && (tileY+2 == BDy || tileY-2 == BDy)) { return !containsFriendlyPiece(BDx, BDy); } else { return false; }; }
//Callbacks local void PPKCB(Player *p, struct C2SPosition *pos) { PlayerData *pdata = getPlayerData(p); ArenaData *adata = getArenaData(p->arena); if (p->flags.is_dead) //Reset dead players' blink and return { pdata->blinkActivated = false; pdata->blinkDirection = 0; return; } if (pdata->blinkActivated == true) { double theta; theta = (((40 - (pos->rotation + 30) % 40) * 9) + pdata->blinkDirection) * (M_PI / 180); //Reset variables pdata->blinkActivated = false; pdata->blinkDirection = 0; int numAwers = getNumberOfAwers(p); int dist = pdata->blinkDistance + numAwers * pdata->blinkAWEffect; if (dist < pdata->blinkMin) dist = pdata->blinkMin; int x = pos->x + dist * cos(theta); int y = pos->y + dist * -sin(theta); if (pdata->blinkIgnoreWalls == false) { Coordinates pathEnd = isClearPath(p->arena, pos->x, pos->y, x, y, (adata->shipconfig[p->p_ship].radius + pdata->blinkRadius)); x = pathEnd.x; y = pathEnd.y; if (x == pos->x && y == pos->y) //Useless blink, don't do it. { chat->SendMessage(p, "Unable to blink. Try moving into open space."); return; } } //'restart' blink delay and warp player pdata->lastBlink = current_ticks(); WarpPlayerWithFlash(p, x, y, pos->xspeed, pos->yspeed, pos->rotation, 0); //Play LVZ at start location Target t; t.type = T_ARENA; t.u.arena = p->arena; objs->Move(&t, adata->currentID, pos->x + adata->lvzConfig.xOffset, pos->y + adata->lvzConfig.yOffset, 0, 0); objs->Toggle(&t,adata->currentID,1); adata->currentID++; if (adata->currentID > adata->lvzConfig.endID) adata->currentID = adata->lvzConfig.startID; //Play LVZ at end location objs->Move(&t, adata->currentID, x + adata->lvzConfig.xOffset, y + adata->lvzConfig.yOffset, 0, 0); objs->Toggle(&t,adata->currentID,1); adata->currentID++; if (adata->currentID > adata->lvzConfig.endID) adata->currentID = adata->lvzConfig.startID; } }