void FightsManager::enemyKilled() { Resources &res = Resources::getReference(); Hotspot *playerHotspot = res.getActiveHotspot(PLAYER_ID); FighterRecord &playerRec = getDetails(PLAYER_ID); playerHotspot->setTickProc(PLAYER_TICK_PROC_ID); playerRec.fwhits = GENERAL_MAGIC_ID; playerHotspot->resource()->colorOffset = 128; playerHotspot->setSize(32, 48); playerHotspot->resource()->width = 32; playerHotspot->resource()->height = 48; playerHotspot->setAnimationIndex(PLAYER_ANIM_INDEX); playerHotspot->setPosition(playerHotspot->x(), playerHotspot->y() + 5); playerHotspot->setDirection(LEFT); if (playerHotspot->roomNumber() == 6) { Dialog::show(0xc9f); HotspotData *axeHotspot = res.getHotspot(0x2738); axeHotspot->roomNumber = PLAYER_ID; axeHotspot->flags |= HOTSPOTFLAG_FOUND; // Prevent the weapon animation being drawn axeHotspot = res.getHotspot(0x440); axeHotspot->layer = 0; } }
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::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::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 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 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 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); }
bool Debugger::cmd_showAnim(int argc, const char **argv) { Resources &res = Resources::getReference(); if (argc < 2) { DebugPrintf("showAnim animId [[frame_width frame_height] | list]\n"); return true; } // Get the animation Id int animId = strToInt(argv[1]); HotspotAnimData *data = res.getAnimation(animId); if (data == NULL) { DebugPrintf("No such animation Id exists\n"); return true; } // Figure out the total size of the animation - this will be used for guestimating // frame sizes, or validating that a specified frame size is correct MemoryBlock *src = Disk::getReference().getEntry(data->animId); int numFrames = READ_LE_UINT16(src->data()); uint16 *headerEntry = (uint16 *) (src->data() + 2); assert((numFrames >= 1) && (numFrames < 100)); // Calculate total needed size for output and create memory block to hold it uint32 totalSize = 0; for (uint16 ctr = 0; ctr < numFrames; ++ctr, ++headerEntry) { totalSize += (READ_LE_UINT16(headerEntry) + 31) / 32; } totalSize = (totalSize + 0x81) << 4; MemoryBlock *dest = Memory::allocate(totalSize); uint32 srcStart = (numFrames + 1) * sizeof(uint16) + 6; uint32 destSize = AnimationDecoder::decode_data(src, dest, srcStart) - 0x40; // Figure out the frame size int frameSize; if ((data->flags & PIXELFLAG_HAS_TABLE) != 0) { // Table based animation, so get frame size from frame 1 offset frameSize = READ_LE_UINT16(src->data()); } else { // Get frame size from dividing uncompressed size by number of frames frameSize = destSize / numFrames; } // Free up the data delete src; delete dest; int width, height; if (argc == 4) { // Width and height specified width = strToInt(argv[2]); height = strToInt(argv[3]); if ((width * height) != (frameSize * 2)) { DebugPrintf("Warning: Total size = %d, Frame size (%d,%d) * %d frames = %d bytes\n", destSize, width, height, numFrames, width * height * numFrames / 2); } } else { // Guestimate a frame size frameSize = destSize / numFrames; // Figure out the approximate starting point of a width 3/4 the frame size width = frameSize * 3 / 4; bool descFlag = (argc == 3); if (descFlag) DebugPrintf("Target size = %d\n", frameSize * 2); while ((width > 0) && (descFlag || (((frameSize * 2) % width) != 0))) { if (((frameSize * 2) % width) == 0) DebugPrintf("Frame size (%d,%d) found\n", width, frameSize * 2 / width); --width; } if (argc == 3) { DebugPrintf("Done\n"); return true; } else if (width == 0) { DebugPrintf("Total size = %d, # frames = %d, frame Size = %d - No valid frame dimensions\n", destSize, numFrames, frameSize); return true; } height = (frameSize * 2) / width; DebugPrintf("# frames = %d, guestimated frame size = (%d,%d)\n", numFrames, width, height); } // Bottle object is used as a handy hotspot holder that doesn't have any // tick proc behavior that we need to worry about Hotspot *hotspot = res.activateHotspot(BOTTLE_HOTSPOT_ID); hotspot->setLayer(0xfe); hotspot->setSize(width, height); Hotspot *player = res.activateHotspot(PLAYER_ID); hotspot->setColorOffset(player->resource()->colorOffset); hotspot->setAnimation(animId); DebugPrintf("Done\n"); return true; }