void Script::remoteRoomViewSetup(uint16 v1, uint16 v2, uint16 v3) { Hotspot *player = Resources::getReference().getActiveHotspot(PLAYER_ID); player->setTickProc(NULL_TICK_PROC_ID); Resources::getReference().fieldList().setField(OLD_ROOM_NUMBER, player->roomNumber()); }
void Script::pauseRatpouch(uint16 v1, uint16 v2, uint16 v3) { Resources &res = Resources::getReference(); Hotspot *ratpouch = res.getActiveHotspot(RATPOUCH_ID); assert(ratpouch); ratpouch->setCharacterMode(CHARMODE_PAUSED); ratpouch->setDelayCtr(0x7fff); }
void Script::startSpeakingToNoone(uint16 characterId, uint16 stringId, uint16 v3) { Resources &res = Resources::getReference(); Hotspot *charHotspot = res.getActiveHotspot(characterId); assert(charHotspot); charHotspot->converse(NOONE_ID, stringId, true); }
void Script::cutSack(uint16 hotspotId, uint16 v2, uint16 v3) { Resources &res = Resources::getReference(); HotspotData *data = res.getHotspot(SACK_ID); data->startY = 138; Hotspot *activeHotspot = res.getActiveHotspot(SACK_ID); if (activeHotspot) activeHotspot->setPosition(data->startX, data->startY); }
void Script::resetPathfinder(uint16 v1, uint16 v2, uint16 v3) { // Reset the pathfinding for any characters Resources &res = Resources::getReference(); for (uint16 charId = PLAYER_ID + 1; charId < FIRST_NONCHARACTER_ID; ++charId) { Hotspot *charHotspot = res.getActiveHotspot(charId); if (charHotspot) charHotspot->pathFinder().clear(); } }
Hotspot *Resources::getActiveHotspot(uint16 hotspotId) { HotspotList::iterator i; for (i = _activeHotspots.begin(); i != _activeHotspots.end(); ++i) { Hotspot *rec = (*i).get(); if (rec->hotspotId() == hotspotId) return rec; } return NULL; }
void Script::setNewSupportData(uint16 index, uint16 hotspotId, uint16 v3) { Resources &res = Resources::getReference(); uint16 dataId = res.getCharOffset(index); CharacterScheduleEntry *entry = res.charSchedules().getEntry(dataId); Hotspot *h = res.getActiveHotspot(hotspotId); h->setBlockedFlag(false); h->currentActions().addFront(DISPATCH_ACTION, entry, h->roomNumber()); h->setActionCtr(0); }
void Script::moveCharacterToPlayer(uint16 characterId, uint16 v2, uint16 v3) { Resources &res = Resources::getReference(); Hotspot *playerHotspot = res.getActiveHotspot(PLAYER_ID); Hotspot *charHotspot = res.getActiveHotspot(characterId); assert(charHotspot); // If character in same room as player, then no need to do anything if (!charHotspot->currentActions().isEmpty() && (charHotspot->currentActions().top().roomNumber() == playerHotspot->roomNumber())) return; uint16 destRoom = playerHotspot->roomNumber(); const RoomTranslationRecord *rec; for (rec = &roomTranslations[0]; rec->srcRoom != 0; ++rec) { if (rec->srcRoom == destRoom) { destRoom = rec->destRoom; break; } } if (charHotspot->currentActions().isEmpty()) charHotspot->currentActions().addFront(DISPATCH_ACTION, destRoom); else charHotspot->currentActions().top().setRoomNumber(destRoom); }
void Script::setBlockingHotspotScript(uint16 charId, uint16 scriptIndex, uint16 v3) { Resources &r = Resources::getReference(); uint16 offset = r.getHotspotScript(scriptIndex); if (charId == PLAYER_ID) Room::getReference().setCursorState(CS_SEQUENCE); Hotspot *hs = r.getActiveHotspot(charId); hs->setHotspotScript(offset); hs->currentActions().top().setAction(EXEC_HOTSPOT_SCRIPT); hs->setOccupied(true); }
void Script::barmanServe(uint16 v1, uint16 v2, uint16 v3) { Resources &res = Resources::getReference(); Hotspot *player = res.getActiveHotspot(PLAYER_ID); BarEntry &barEntry = res.barmanLists().getDetails(player->roomNumber()); for (int index = 0; index < NUM_SERVE_CUSTOMERS; ++index) { if (barEntry.customers[index].hotspotId == PLAYER_ID) { barEntry.customers[index].serveFlags |= 5; break; } } }
void Script::ratpouchPushBricks(uint16 v1, uint16 v2, uint16 v3) { Resources &res = Resources::getReference(); // Mark the bricks exit as now open RoomExitJoinData *joinRec = res.getExitJoin(BRICKS_ID); joinRec->blocked = 0; // Set Ratpouch moving through the new exit to room #7 Hotspot *ratpouchHotspot = res.getActiveHotspot(RATPOUCH_ID); ratpouchHotspot->setActions(0); // Make sure he can't be interrupted ratpouchHotspot->currentActions().clear(); ratpouchHotspot->currentActions().addBack(DISPATCH_ACTION, 7); }
void Script::setHotspotScript(uint16 hotspotId, uint16 scriptIndex, uint16 v3) { Resources &res = Resources::getReference(); uint16 offset = res.getHotspotScript(scriptIndex); Hotspot *hotspot = res.getActiveHotspot(hotspotId); if (hotspot != NULL) { hotspot->setHotspotScript(offset); } else { HotspotData *hs = res.getHotspot(hotspotId); assert(hs); hs->hotspotScriptOffset = offset; } }
void Script::transformPlayer(uint16 v1, uint16 v2, uint16 v3) { Resources &res = Resources::getReference(); HotspotData *hotspot = res.getHotspot(TRANSFORM_ID); HotspotData *player = res.getHotspot(PLAYER_ID); hotspot->roomNumber = player->roomNumber; hotspot->startX = player->startX - 14; hotspot->startY = player->startY - 10; Hotspot *activeHotspot = res.activateHotspot(TRANSFORM_ID); activeHotspot->setActionCtr(0); activeHotspot->setHotspotScript(0x630); }
void FightsManager::setupSkorlFight() { Resources &res = Resources::getReference(); Hotspot *player = res.getActiveHotspot(PLAYER_ID); FighterRecord &rec = getDetails(PLAYER_ID); setupPigFight(); rec.fwenemy_ad = SKORL_FIGHTER_ID; rec.fwweapon = 0x445; rec.fwtrue_x = 282; rec.fwtrue_y = 136; player->setPosition(282, 136); player->resource()->colorOffset = 96; }
void Resources::deactivateHotspot(uint16 hotspotId, bool isDestId) { HotspotList::iterator i = _activeHotspots.begin(); while (i != _activeHotspots.end()) { Hotspot *h = (*i).get(); if ((!isDestId && (h->hotspotId() == hotspotId)) || (isDestId && (h->destHotspotId() == hotspotId) && (h->hotspotId() == 0xffff))) { _activeHotspots.erase(i); break; } i++; } }
void Script::fixGoewin(uint16 v1, uint16 v2, uint16 v3) { Resources &res = Resources::getReference(); Hotspot *hotspot = res.getActiveHotspot(GOEWIN_ID); assert(hotspot); hotspot->setTickProc(STANDARD_CHARACTER_TICK_PROC); CharacterScheduleEntry *entry = res.charSchedules().getEntry(GOEWIN_STANDARD_SUPPORT_ID); assert(entry); hotspot->currentActions().clear(); hotspot->currentActions().addFront(DISPATCH_ACTION, entry, hotspot->roomNumber()); hotspot->setActions(hotspot->resource()->actions & ~(1 << (TELL - 1))); hotspot->setActionCtr(0); hotspot->setDelayCtr(0); hotspot->setCharacterMode(CHARMODE_NONE); }
void Script::makeGoewinFollow(uint16 v1, uint16 v2, uint16 v3) { Resources &res = Resources::getReference(); Hotspot *hotspot = res.getActiveHotspot(GOEWIN_ID); hotspot->setTickProc(FOLLOWER_TICK_PROC_2); hotspot->currentActions().clear(); CharacterScheduleEntry *entry = res.charSchedules().getEntry(GOEWIN_CAVE_SUPPORT_ID); hotspot->currentActions().addFront(DISPATCH_ACTION, entry, ROOMNUM_CAVE); hotspot->setActions(hotspot->resource()->actions | (1 << (TELL - 1))); hotspot->setActionCtr(0); hotspot->setDelayCtr(0); hotspot->setCharacterMode(CHARMODE_NONE); }
void Script::setSupportData(uint16 hotspotId, uint16 index, uint16 v3) { Resources &res = Resources::getReference(); // WORKAROUND: In room #45, the script for the Skorl noticing you gets // the parameters back to front. If this the case, just ignore it if (index == CASTLE_SKORL_ID) return; uint16 dataId = res.getCharOffset(index); CharacterScheduleEntry *entry = res.charSchedules().getEntry(dataId); assert(entry != NULL); Hotspot *h = res.getActiveHotspot(hotspotId); assert(h); assert(!h->currentActions().isEmpty()); h->currentActions().pop(); h->currentActions().addFront(DISPATCH_ACTION, entry, h->roomNumber()); }
Hotspot *Resources::addHotspot(uint16 hotspotId) { HotspotData *hData = getHotspot(hotspotId); assert(hData); Hotspot *hotspot = new Hotspot(hData); _activeHotspots.push_back(HotspotList::value_type(hotspot)); if (hotspotId < FIRST_NONCHARACTER_ID) { // Default characters to facing upwards until they start moving hotspot->setDirection(UP); hotspot->setCharRectY(0); // When reactivating an NPC, ensure that their previous state wasn't PROCESSING_PATH, since // the pause has destroyed the previously decided destination position if (!hData->npcSchedule.isEmpty() && (hData->npcSchedule.top().action() == PROCESSING_PATH)) hData->npcSchedule.top().setAction(DISPATCH_ACTION); } return hotspot; }
void GlobeGame::handleInput(const Input &input, const Hotspot *cursorSpot) { Common::Point where; input.getInputLocation(where); Hotspot *spot = g_allHotspots.findHotspot(where); if (((PegasusEngine *)g_engine)->_cursor->isVisible() && spot != 0 && spot->getObjectID() == kNorad79SiloAreaSpotID && findClickedSilo(input) != -1) { _targetHighlightUpperLeft.show(); _targetHighlightUpperRight.show(); _targetHighlightLowerLeft.show(); _targetHighlightLowerRight.show(); } else { _targetHighlightUpperLeft.hide(); _targetHighlightUpperRight.hide(); _targetHighlightLowerLeft.hide(); _targetHighlightLowerRight.hide(); } // Interrupt certain inputs to prevent player from switching modes. InputHandler::handleInput(input, cursorSpot); }
void FightsManager::setupPigFight() { Resources &res = Resources::getReference(); Hotspot *player = res.getActiveHotspot(PLAYER_ID); player->setSkipFlag(false); player->resource()->colorOffset = 16; player->setTickProc(PLAYER_FIGHT_TICK_PROC_ID); player->setSize(48, 53); player->setAnimationIndex(PLAYER_FIGHT_ANIM_INDEX); player->resource()->width = 48; player->resource()->height = 53; player->setOccupied(false); player->setPosition(262, 94); FighterRecord &rec = getDetails(PLAYER_ID); rec.fwhits = 0; rec.fwtrue_x = 262; rec.fwtrue_y = 53; rec.fwseq_ad = FIGHT_PLAYER_INIT; rec.fwenemy_ad = PIG_ID; }
void Script::makeGoewinWork(uint16 v1, uint16 v2, uint16 v3) { Resources &res = Resources::getReference(); Hotspot *goewin = res.getActiveHotspot(GOEWIN_ID); assert(goewin); goewin->updateMovement(); goewin->currentActions().addBack(EXEC_HOTSPOT_SCRIPT, 34); goewin->setHotspotScript(0x616); goewin->setDelayCtr(1500); goewin->setTickProc(GOEWIN_SHOP_TICK_PROC); // Set walk to position for Goewin whilst she's working goewin->resource()->walkX = 179; goewin->resource()->walkY = 138; }
void NoradDelta::init() { Norad::init(); // Little fix for the retinal scan zoom in spot... Hotspot *hotspot = _vm->getAllHotspots().findHotspotByID(kNorad68WestSpotID); hotspot->setMaskedHotspotFlags(kZoomInSpotFlag, kZoomInSpotFlag | kZoomOutSpotFlag); hotspot = _vm->getAllHotspots().findHotspotByID(kNorad79WestSpotID); hotspot->setMaskedHotspotFlags(kZoomInSpotFlag, kZoomInSpotFlag | kZoomOutSpotFlag); hotspot = _vm->getAllHotspots().findHotspotByID(kDelta59RobotShieldBiochipSpotID); hotspot->setMaskedHotspotFlags(kPickUpBiochipSpotFlag, kPickUpBiochipSpotFlag); HotspotInfoTable::Entry *hotspotEntry = findHotspotEntry(kDelta59RobotShieldBiochipSpotID); hotspotEntry->hotspotItem = kShieldBiochip; hotspot = _vm->getAllHotspots().findHotspotByID(kDelta59RobotOpMemBiochipSpotID); hotspot->setMaskedHotspotFlags(kPickUpBiochipSpotFlag, kPickUpBiochipSpotFlag); hotspotEntry = findHotspotEntry(kDelta59RobotOpMemBiochipSpotID); hotspotEntry->hotspotItem = kOpticalBiochip; hotspot = _vm->getAllHotspots().findHotspotByID(kDelta59RobotRetinalBiochipSpotID); hotspot->setMaskedHotspotFlags(kPickUpBiochipSpotFlag, kPickUpBiochipSpotFlag); hotspotEntry = findHotspotEntry(kDelta59RobotRetinalBiochipSpotID); hotspotEntry->hotspotItem = kRetinalScanBiochip; hotspot = _vm->getAllHotspots().findHotspotByID(kDelta60RobotShieldBiochipSpotID); hotspot->setMaskedHotspotFlags(kPickUpBiochipSpotFlag, kPickUpBiochipSpotFlag); hotspotEntry = findHotspotEntry(kDelta60RobotShieldBiochipSpotID); hotspotEntry->hotspotItem = kShieldBiochip; hotspot = _vm->getAllHotspots().findHotspotByID(kDelta60RobotOpMemBiochipSpotID); hotspot->setMaskedHotspotFlags(kPickUpBiochipSpotFlag, kPickUpBiochipSpotFlag); hotspotEntry = findHotspotEntry(kDelta60RobotOpMemBiochipSpotID); hotspotEntry->hotspotItem = kOpticalBiochip; hotspot = _vm->getAllHotspots().findHotspotByID(kDelta60RobotRetinalBiochipSpotID); hotspot->setMaskedHotspotFlags(kPickUpBiochipSpotFlag, kPickUpBiochipSpotFlag); hotspotEntry = findHotspotEntry(kDelta60RobotRetinalBiochipSpotID); hotspotEntry->hotspotItem = kRetinalScanBiochip; }
void Script::normalGoewin(uint16 v1, uint16 v2, uint16 v3) { Resources &res = Resources::getReference(); Hotspot *hotspot = res.getActiveHotspot(GOEWIN_ID); assert(hotspot); if (!hotspot->currentActions().isEmpty()) hotspot->currentActions().top().setAction(DISPATCH_ACTION); hotspot->setCharacterMode(CHARMODE_NONE); hotspot->setDirection(UP); hotspot->setTickProc(STANDARD_CHARACTER_TICK_PROC); // Clear walk to position for Goewin so player must walk up to her when interacting hotspot->resource()->walkX = 0; hotspot->resource()->walkY = 0; }
void FightsManager::fighterAnimHandler(Hotspot &h) { FighterRecord &fighter = getDetails(h.hotspotId()); FighterRecord &opponent = getDetails(fighter.fwenemy_ad); FighterRecord &player = getDetails(PLAYER_ID); fetchFighterDistance(fighter, opponent); if (fighter.fwseq_ad) { fightHandler(h, fighter.fwseq_ad); return; } uint16 seqNum = 0; if (fighter.fwdist != FIGHT_DISTANCE) { seqNum = getFighterMove(fighter, fighter.fwnot_near); } else { uint16 offset = (fighter.fwhits * fighter.fwdef_len) + fighter.fwdefend_adds + 4; // Scan for the given sequence uint16 v = getWord(offset); while ((v != 0) && (v != player.fwseq_no)) { offset += 4; v = getWord(offset); } if (v == 0) { // No sequence match found seqNum = getFighterMove(fighter, fighter.fwattack_table); } else { v = getWord(offset + 2); seqNum = getFighterMove(fighter, fighter.fwdefend_table); if (seqNum == 0) seqNum = getFighterMove(fighter, fighter.fwattack_table); else if (seqNum == 0xff) seqNum = v; } } // Set the sequence and pass onto the fight handler fighter.fwseq_no = seqNum; fighter.fwseq_ad = getWord(FIGHT_TBL_1 + (seqNum << 1)); }
void Script::displayMessage2(uint16 messageId, uint16 hotspotId, uint16 v3) { Hotspot *hotspot = Resources::getReference().getActiveHotspot(hotspotId); assert(hotspot); hotspot->showMessage(messageId); }
void Script::startOilBurner(uint16 v1, uint16 v2, uint16 v3) { Hotspot *hotspot = Resources::getReference().getActiveHotspot(OIL_BURNER_ID); assert(hotspot); hotspot->setPosition(152, hotspot->y()); hotspot->setTickProc(STANDARD_ANIM_TICK_PROC); }
void Script::setVillageSkorlTickProc(uint16 v1, uint16 v2, uint16 v3) { Resources &res = Resources::getReference(); Hotspot *skorlHotspot = res.getActiveHotspot(WAYNE_ID); assert(skorlHotspot); skorlHotspot->setTickProc(JAILOR_TICK_PROC_ID); }
void Script::npcWait(uint16 hotspotId, uint16 v2, uint16 v3) { Hotspot *hotspot = Resources::getReference().getActiveHotspot(hotspotId); assert(hotspot); hotspot->setCharacterMode(CHARMODE_WAIT_FOR_INTERACT); hotspot->setDelayCtr(130); }
void Script::displayMessage(uint16 messageId, uint16 characterId, uint16 destCharacterId) { Hotspot *hotspot = Resources::getReference().getActiveHotspot(characterId); if (hotspot != NULL) hotspot->showMessage(messageId, destCharacterId); }