bool DrasculaEngine::verify2() { int l; if (_menuScreen) { if (pickupObject()) return true; } else { if (!strcmp(textName, "hacker") && _hasName) { if (checkAction(50)) return true; } else { for (l = 0; l < numRoomObjs; l++) { if (mouseX > x1[l] && mouseY > y1[l] && mouseX < x2[l] && mouseY < y2[l] && visible[l] == 1) { trackFinal = trackObj[l]; walkToObject = 1; gotoObject(roomObjX[l], roomObjY[l]); if (checkAction(objectNum[l])) return true; if (currentChapter == 4) break; } } } } return false; }
void Bat::handleAction(RemoteAction *action, BALL* objectBall) { if (action->typeCode == BatMoveAction::CODE) { // If we are in the same room as the bat and are closer to it than the reporting player, // then we ignore reports and trust our internal state. // Otherwise, use the reported state. BatMoveAction* nextMove = (BatMoveAction*)action; if ((room != objectBall->room) || (objectBall->distanceTo(x, y) > nextMove->distance)) { room = nextMove->room; x = nextMove->posx; y = nextMove->posy; movementX = nextMove->velx; movementY = nextMove->vely; } } else if (action->typeCode == BatPickupAction::CODE) { BatPickupAction* nextPickup = (BatPickupAction*)action; if (nextPickup->dropObject != OBJECT_NONE) { OBJECT* droppedObject = lookupObject(nextPickup->dropObject); droppedObject->x = nextPickup->dropX; droppedObject->y = nextPickup->dropY; } pickupObject(nextPickup->pickupObject, NULL); } }
void Bat::moveOneTurn(Sync* sync, BALL* objectBall) { static int flapTimer = 0; if (++flapTimer >= 0x04) { state = (state == 0) ? 1 : 0; flapTimer = 0; } if ((linkedObject != OBJECT_NONE) && (batFedUpTimer < MAX_FEDUP)) ++batFedUpTimer; if (batFedUpTimer >= 0xff) { // Get the bat's current extents int batX, batY, batW, batH; CalcSpriteExtents(&batX, &batY, &batW, &batH); // Enlarge the bat extent by 7 pixels for the proximity checks below // (doing the bat once is faster than doing each object and the results are the same) batX-=7; batY+=7; batW+=7*2; batH+=7*2; // Go through the bat's object matrix const int* matrixP = batMatrix; do { // Get the object it is seeking const OBJECT* seekObject = lookupObject(*matrixP); if ((seekObject->room == room) && (linkedObject != *matrixP)) { int seekX = seekObject->x; int seekY = seekObject->y; // Set the movement int newMoveX = 0; int newMoveY = 0; // horizontal axis if (x < seekX) { newMoveX = BAT_SPEED; } else if (x > seekX) { newMoveX = -BAT_SPEED; } // vertical axis if (y < seekY) { newMoveY = BAT_SPEED; } else if (y > seekY) { newMoveY = -BAT_SPEED; } bool sendMessage = ((newMoveX != movementX) || (newMoveY != movementY)); movementX = newMoveX; movementY = newMoveY; if (sendMessage) { broadcastMoveAction(sync, objectBall); } // If the bat is within 7 pixels of the seek object it can pick the object up // The bat extents have already been expanded by 7 pixels above, so a simple // rectangle intersection test is good enought here int objX, objY, objW, objH; seekObject->CalcSpriteExtents(&objX, &objY, &objW, &objH); if (Board::HitTestRects(batX, batY, batW, batH, objX, objY, objW, objH)) { // Hit something we want pickupObject(*matrixP, sync); } // break since we found something break; } } while (*(++matrixP)); } }