void AGOSEngine::o_chance() { // 23: chance int16 a = getVarOrWord(); if (a == 0) { setScriptCondition(false); return; } if (a == 100) { setScriptCondition(true); return; } a += _chanceModifier; if (a <= 0) { _chanceModifier = 0; setScriptCondition(false); } else if ((int16)_rnd.getRandomNumber(99) < a) { if (_chanceModifier <= 0) _chanceModifier -= 5; else _chanceModifier = 0; setScriptCondition(true); } else { if (_chanceModifier >= 0) _chanceModifier += 5; else _chanceModifier = 0; setScriptCondition(false); } }
void AGOSEngine_Feeble::off_ifTime() { // 124: if time uint a = getVarOrWord(); uint32 t = getTime() - _gameStoppedClock - a; if (t >= _timeStore) setScriptCondition(true); else setScriptCondition(false); }
void AGOSEngine_Feeble::off_isAdjNoun() { // 165: item unk1 unk2 is Item *item = getNextItemPtr(); int16 a = getNextWord(), b = getNextWord(); if (item->adjective == a && item->noun == b) setScriptCondition(true); else if (a == -1 && item->noun == b) setScriptCondition(true); else setScriptCondition(false); }
void AGOSEngine_Elvira2::oe2_ifDoorOpen() { // 148: if door open Item *i = getNextItemPtr(); uint16 d = getVarOrByte(); if (getGameType() == GType_WW) { // WORKAROUND bug #2686883: A NULL item can occur when // walking through Jack the Ripper scene if (i == NULL) { setScriptCondition(false); return; } } setScriptCondition(getDoorState(i, d) == 1); }
void AGOSEngine_Elvira2::oe2_ifExitOpen() { // 171: if exit open Item *i = getNextItemPtr(); uint16 n = getVarOrWord(); uint16 d = getVarOrByte(); setScriptCondition(getExitState(i, n, d) == 1); }
void AGOSEngine_Elvira2::oe2_ifExitLocked() { // 173: if exit locked Item *i = getNextItemPtr(); uint16 n = getVarOrWord(); uint16 d = getVarOrByte(); setScriptCondition(getExitState(i, n, d) == 3); }
void AGOSEngine_Elvira2::oe2_isAdjNoun() { // 179: item unk1 unk2 is Item *item = getNextItemPtr(); int16 a = getNextWord(); int16 n = getNextWord(); if (getGameType() == GType_ELVIRA2 && item == NULL) { // WORKAROUND bug #1745996: A NULL item can occur when // interacting with items in the dinning room setScriptCondition(false); return; } assert(item); setScriptCondition(item->adjective == a && item->noun == n); }
void AGOSEngine::o_eq() { // 13: equal uint tmp = getNextVarContents(); uint tmp2 = getVarOrWord(); #ifdef __DS__ // HACK: Skip attempt to read Calypso's letter manually, // due to speech segment been too large to fit into memory if (getGameType() == GType_SIMON1 && (getFeatures() & GF_TALKIE) && getPlatform() == Common::kPlatformWindows && _currentTable) { if (_currentTable->id == 71 && tmp == 1 && tmp2 == 1) { setScriptCondition(false); return; } } #endif setScriptCondition(tmp == tmp2); }
void AGOSEngine_Feeble::off_chance() { // 23 uint16 a = getVarOrWord(); if (a == 0) { setScriptCondition(false); return; } if (a == 100) { setScriptCondition(true); return; } if (_rnd.getRandomNumber(99) < a) setScriptCondition(true); else setScriptCondition(false); }
void AGOSEngine_Elvira2::oe2_bNotZero() { // 156: is bit set uint bit = getVarWrapper(); // WORKAROUND: Enable copy protection again, in cracked version. if (getGameType() == GType_SIMON1 && _currentTable && _currentTable->id == 2962 && bit == 63) { bit = 50; } setScriptCondition(getBitFlag(bit)); }
int AGOSEngine::runScript() { bool flag; if (shouldQuit()) return 1; do { if (DebugMan.isDebugChannelEnabled(kDebugOpcode)) dumpOpcode(_codePtr); if (getGameType() == GType_ELVIRA1) { _opcode = getVarOrWord(); if (_opcode == 10000) return 0; } else { _opcode = getByte(); if (_opcode == 0xFF) return 0; } if (_runScriptReturn1) return 1; /* Invert condition? */ flag = false; if (getGameType() == GType_ELVIRA1) { if (_opcode == 203) { flag = true; _opcode = getVarOrWord(); if (_opcode == 10000) return 0; } } else { if (_opcode == 0) { flag = true; _opcode = getByte(); if (_opcode == 0xFF) return 0; } } setScriptCondition(true); setScriptReturn(0); if (_opcode > _numOpcodes) error("Invalid opcode '%d' encountered", _opcode); executeOpcode(_opcode); } while (getScriptCondition() != flag && !getScriptReturn() && !shouldQuit()); return (shouldQuit()) ? 1 : getScriptReturn(); }
void AGOSEngine::o_freezeZones() { // 138: freeze zones freezeBottom(); if (!_copyProtection && !(getFeatures() & GF_TALKIE) && _currentTable) { if ((getGameType() == GType_SIMON1 && _currentTable->id == 2924) || (getGameType() == GType_SIMON2 && _currentTable->id == 1322)) { _variableArray[134] = 3; _variableArray[135] = 3; setBitFlag(135, 1); setScriptCondition(0); } } }
void AGOSEngine_Elvira2::oe2_bZero() { // 155: is bit clear setScriptCondition(!getBitFlag(getVarWrapper())); }
void AGOSEngine_Elvira2::oe2_ifDoorLocked() { // 150: if door locked Item *i=getNextItemPtr(); uint16 d = getVarOrByte(); setScriptCondition(getDoorState(i, d) == 3); }
void AGOSEngine_Elvira2::oe2_ifDoorClosed() { // 149: if door closed Item *i = getNextItemPtr(); uint16 d = getVarOrByte(); setScriptCondition(getDoorState(i, d) == 2); }
void AGOSEngine::o_here() { // 125: item is sibling with item 1 Item *item = getNextItemPtr(); setScriptCondition(me()->parent == item->parent); }
void AGOSEngine::o_isBox() { // 142: is box dead setScriptCondition(isBoxDead(getVarOrWord())); }
void AGOSEngine_Elvira2::oe2_b2Zero() { // 182: is bit2 clear uint bit = getVarOrByte(); setScriptCondition((_bitArrayTwo[bit / 16] & (1 << (bit & 15))) == 0); }
void AGOSEngine::o_isClass() { // 115: item has flag Item *item = getNextItemPtr(); setScriptCondition((item->classFlags & (1 << getVarOrByte())) != 0); }
void AGOSEngine_Feeble::off_b3Zero() { // 198: is bit3 clear uint8 bit = getVarOrByte(); setScriptCondition((_bitArrayThree[bit / 16] & (1 << (bit & 15))) == 0); }
void AGOSEngine::o_notCarried() { // 6: parent isnot 1 setScriptCondition(getNextItemPtr()->parent != getItem1ID()); }
void AGOSEngine::o_notZero() { // 12: isnot zero setScriptCondition(getNextVarContents() != 0); }
void AGOSEngine::o_zero() { // 11: is zero setScriptCondition(getNextVarContents() == 0); }
void AGOSEngine_Feeble::off_b3NotZero() { // 199: is bit3 set uint8 bit = getVarOrByte(); setScriptCondition((_bitArrayThree[bit / 16] & (1 << (bit & 15))) != 0); }
void AGOSEngine::o_carried() { // 5: parent is 1 setScriptCondition(getNextItemPtr()->parent == getItem1ID()); }
void AGOSEngine_Simon2::os2_isShortText() { // 188: string2 is uint i = getVarOrByte(); uint str = getNextStringID(); setScriptCondition(str < _numTextBoxes && _shortText[i] == str); }
void AGOSEngine::o_notAt() { // 2: ptrA parent is not setScriptCondition(me()->parent != getNextItemID()); }
void AGOSEngine_Elvira2::oe2_isCalled() { // 79: childstruct fr2 is Item *i = getNextItemPtr(); uint stringId = getNextStringID(); setScriptCondition(i->itemName == stringId); }
void AGOSEngine_Elvira2::oe2_b2NotZero() { // 183: is bit2 set uint bit = getVarOrByte(); setScriptCondition((_bitArrayTwo[bit / 16] & (1 << (bit & 15))) != 0); }
void AGOSEngine::o_isAt() { // 7: parent is Item *item = getNextItemPtr(); setScriptCondition(item->parent == getNextItemID()); }