Ejemplo n.º 1
0
int ScummEngine::getObjectOrActorXY(int object, int &x, int &y) {
	Actor *act;

	if (object < _numActors) {
		act = derefActorSafe(object, "getObjectOrActorXY");
		if (act && act->isInCurrentRoom()) {
			x = act->getRealPos().x;
			y = act->getRealPos().y;
			return 0;
		} else
			return -1;
	}

	switch (whereIsObject(object)) {
	case WIO_NOT_FOUND:
		return -1;
	case WIO_INVENTORY:
		if (_objectOwnerTable[object] < _numActors) {
			act = derefActor(_objectOwnerTable[object], "getObjectOrActorXY(2)");
			if (act && act->isInCurrentRoom()) {
				x = act->getRealPos().x;
				y = act->getRealPos().y;
				return 0;
			}
		}
		return -1;
	}
	getObjectXYPos(object, x, y);
	return 0;
}
Ejemplo n.º 2
0
void ScummEngine_v0::o_getActorMoving() {
	getResultPos();
	int act = getVarOrDirectByte(PARAM_1);
	Actor *a = derefActor(act, "o_getActorMoving");

	setResult(a->_moving);
}
Ejemplo n.º 3
0
void ScummEngine_v0::verbExec() {
	_sentenceNum = 0;
	_sentenceNestedCount = 0;

	if (_activeVerb == kVerbWhatIs)
		return;

	if (!(_activeVerb == kVerbWalkTo && _activeObject == 0)) {
		doSentence(_activeVerb, _activeObject, _activeObject2);
		if (_activeVerb != kVerbWalkTo) {
			_activeVerb = kVerbWalkTo;
			_activeObject = 0;
			_activeObject2 = 0;
		}
		_walkToObjectState = kWalkToObjectStateDone;
		return;
	}

	Actor_v0 *a = (Actor_v0 *)derefActor(VAR(VAR_EGO), "verbExec");
	int x = _virtualMouse.x / V12_X_MULTIPLIER;
	int y = _virtualMouse.y / V12_Y_MULTIPLIER;
	//actorSetPosInBox();

	// 0xB31
	VAR(6) = x;
	VAR(7) = y;

	if (a->_miscflags & kActorMiscFlagFreeze)
		return;

	a->stopActorMoving();
	a->startWalkActor(VAR(6), VAR(7), -1);
}
Ejemplo n.º 4
0
void ScummEngine_v0::o_animateActor() {
	int act = getVarOrDirectByte(PARAM_1);
	int anim = getVarOrDirectByte(PARAM_2);
	int8 repeat = (int8) fetchScriptByte();

	Actor_v0 *a = (Actor_v0*) derefActor(act, "o_animateActor");

	a->_animFrameRepeat = repeat;

	switch (anim) {

		case 0xFE:
			// 0x6993
			a->_speaking = 0x80;	// Enabled, but not switching
			return;

		case 0xFD:
			// 0x69A3
			a->_speaking = 0x00;
			return;

		case 0xFF:
			a->stopActorMoving();
			return;
	}

	a->animateActor(anim);
}
Ejemplo n.º 5
0
void ScummEngine_v70he::o70_getActorRoom() {
	int act = pop();

	if (act < _numActors) {
		Actor *a = derefActor(act, "o70_getActorRoom");
		push(a->_room);
	} else
		push(getObjectRoom(act));
}
Ejemplo n.º 6
0
void ScummEngine_v0::o_getActorBitVar() {
	getResultPos();
	byte act = getVarOrDirectByte(PARAM_1);
	byte mask = getVarOrDirectByte(PARAM_2);

	Actor_v0 *a = (Actor_v0 *)derefActor(act, "o_getActorBitVar");
	setResult((a->_miscflags & mask) ? 1 : 0);

	debug(0, "o_getActorBitVar(%d, %d, %d)", act, mask, (a->_miscflags & mask));
}
Ejemplo n.º 7
0
void ScummEngine::actorFollowCamera(int act) {
	if (!(_game.features & GF_NEW_CAMERA)) {
		int old;

		old = camera._follows;
		setCameraFollows(derefActor(act, "actorFollowCamera"));
		if (camera._follows != old)
			runInventoryScript(0);

		camera._movingToActor = false;
	}
}
Ejemplo n.º 8
0
bool ScummEngine::isCostumeInUse(int cost) const {
	int i;
	Actor *a;

	if (_roomResource != 0)
		for (i = 1; i < _numActors; i++) {
			a = derefActor(i);
			if (a->isInCurrentRoom() && a->_costume == cost)
				return true;
		}

	return false;
}
Ejemplo n.º 9
0
void ScummEngine_v0::drawSentenceLine() {
	_redrawSentenceLine = false;

	if (!(_userState & USERSTATE_IFACE_SENTENCE))
		return;

	clearSentenceLine();

	if (_activeVerb == kVerbNewKid) {
		_sentenceBuf = "";
		for (int i = 0; i < 3; ++i) {
			const char *actorName;
			int actorId = VAR(97 + i);
			if (actorId == 0) {
				// after usage of the radiation suit, kid vars are set to 0
				actorName = " ";
			} else {
				Actor *a = derefActor(actorId, "drawSentenceLine");
				actorName = (const char *)a->getActorName();
			}
			_sentenceBuf += Common::String::format("%-13s", actorName);
		}
		flushSentenceLine();
		return;
	}

	// Current Verb
	if (_activeVerb == kVerbNone)
		_activeVerb = kVerbWalkTo;

	char *verbName = (char *)getResourceAddress(rtVerb, _activeVerb);
	assert(verbName);
	_sentenceBuf = verbName;

	if (_activeObject) {
		// Draw the 1st active object
		drawSentenceObject(_activeObject);

		// Append verb preposition
		int sentencePrep = activeVerbPrep();
		if (sentencePrep) {
			drawPreposition(sentencePrep);

			// Draw the 2nd active object
			if (_activeObject2)
				drawSentenceObject(_activeObject2);
		}
	}

	flushSentenceLine();
}
Ejemplo n.º 10
0
void ScummEngine_v0::o_loadRoomWithEgo() {
	Actor_v0 *a;
	int obj, room, x, y, dir;

	obj = fetchScriptByte();
	room = fetchScriptByte();

	a = (Actor_v0 *)derefActor(VAR(VAR_EGO), "o_loadRoomWithEgo");

	//0x634F
	if (a->_miscflags & kActorMiscFlagFreeze) {
		stopObjectCode();
		return;
	}

	// The original interpreter sets the actors new room X/Y to the last rooms X/Y
	// This fixes a problem with MM: script 158 in room 12, the 'Oomph!' script
	// This scripts runs before the actor position is set to the correct room entry location
	a->putActor(a->getPos().x, a->getPos().y, room);
	_egoPositioned = false;

	startScene(a->_room, a, obj);

	getObjectXYPos(obj, x, y, dir);
	AdjustBoxResult r = a->adjustXYToBeInBox(x, y);
	x = r.x;
	y = r.y;
	a->putActor(x, y, _currentRoom);

	camera._dest.x = camera._cur.x = a->getPos().x;
	setCameraAt(a->getPos().x, a->getPos().y);
	setCameraFollows(a);

	_fullRedraw = true;

	resetSentence();

	if (x >= 0 && y >= 0) {
		a->startWalkActor(x, y, -1);
	}
}
Ejemplo n.º 11
0
void ScummEngine_v0::o_setActorBitVar() {
	byte act = getVarOrDirectByte(PARAM_1);
	byte mask = getVarOrDirectByte(PARAM_2);
	byte mod = getVarOrDirectByte(PARAM_3);

	// 0x63ED
	if (act >= _numActors)
		return;

	Actor_v0 *a = (Actor_v0 *)derefActor(act, "o_setActorBitVar");

	if (mod)
		a->_miscflags |= mask;
	else
		a->_miscflags &= ~mask;

	// This flag causes the actor to stop moving (used by script #158, Green Tentacle 'Oomph!')
	if (a->_miscflags & kActorMiscFlagFreeze)
		a->stopActorMoving();

	debug(0, "o_setActorBitVar(%d, %d, %d)", act, mask, mod);
}
Ejemplo n.º 12
0
void ScummEngine_v0::o_putActorAtObject() {
	int obj, x, y;
	Actor *a;

	a = derefActor(getVarOrDirectByte(PARAM_1), "o_putActorAtObject");

	int objId = fetchScriptByte();
	if (_opcode & 0x40)
		obj = OBJECT_V0(objId, kObjectV0TypeBG);
	else
		obj = OBJECT_V0(objId, kObjectV0TypeFG);

	if (whereIsObject(obj) != WIO_NOT_FOUND) {
		getObjectXYPos(obj, x, y);
		AdjustBoxResult r = a->adjustXYToBeInBox(x, y);
		x = r.x;
		y = r.y;
	} else {
		x = 30;
		y = 60;
	}

	a->putActor(x, y);
}
Ejemplo n.º 13
0
void ScummEngine_v0::checkExecVerbs() {
	Actor_v0 *a = (Actor_v0 *)derefActor(VAR(VAR_EGO), "checkExecVerbs");
	VirtScreen *zone = findVirtScreen(_mouse.y);

	bool execute = false;

	if (_mouseAndKeyboardStat & MBS_MOUSE_MASK) {
		int over = findVerbAtPos(_mouse.x, _mouse.y);
		// click region: verbs
		if (over) {
			if (_activeVerb != over) { // new verb
				// keep first object if no preposition is used yet
				if (activeVerbPrep())
					_activeObject = 0;
				_activeObject2 = 0;
				_activeVerb = over;
				_redrawSentenceLine = true;
			} else {
				// execute sentence if complete
				if (checkSentenceComplete())
					execute = true;
			}
		}
	}

	if (a->_miscflags & kActorMiscFlagHide) {
		if (_activeVerb != kVerbNewKid) {
			_activeVerb = kVerbNone;
		}
	}

	if (_currentMode != kModeCutscene) {
		if (_currentMode == kModeKeypad) {
			_activeVerb = kVerbPush;
		}

		if (_mouseAndKeyboardStat > 0 && _mouseAndKeyboardStat < MBS_MAX_KEY) {
			// keys already checked by input handler
		} else if ((_mouseAndKeyboardStat & MBS_MOUSE_MASK) || _activeVerb == kVerbWhatIs) {
			// click region: sentence line
			if (zone->number == kVerbVirtScreen && _mouse.y <= zone->topline + 8) {
				if (_activeVerb == kVerbNewKid) {
					if (_currentMode == kModeNormal) {
						int kid;
						int lineX = _mouse.x >> V12_X_SHIFT;
						if (lineX < 11)
							kid = 0;
						else if (lineX < 25)
							kid = 1;
						else
							kid = 2;
						_activeVerb = kVerbWalkTo;
						_redrawSentenceLine = true;
						drawSentenceLine();
						switchActor(kid);
					}
					_activeVerb = kVerbWalkTo;
					_redrawSentenceLine = true;
					return;
				} else {
					// execute sentence if complete
					if (checkSentenceComplete())
						execute = true;
				}
			// click region: inventory or main screen
			} else if ((zone->number == kVerbVirtScreen && _mouse.y > zone->topline + 32) ||
Ejemplo n.º 14
0
void ScummEngine_v7::moveCamera() {
	Common::Point old = camera._cur;
	Actor *a = NULL;

	if (camera._follows) {
		a = derefActor(camera._follows, "moveCamera");
		if (ABS(camera._cur.x - a->_pos.x) > VAR(VAR_CAMERA_THRESHOLD_X) ||
				ABS(camera._cur.y - a->_pos.y) > VAR(VAR_CAMERA_THRESHOLD_Y)) {
			camera._movingToActor = true;
			if (VAR(VAR_CAMERA_THRESHOLD_X) == 0)
				camera._cur.x = a->_pos.x;
			if (VAR(VAR_CAMERA_THRESHOLD_Y) == 0)
				camera._cur.y = a->_pos.y;
			clampCameraPos(&camera._cur);
		}
	} else {
		camera._movingToActor = false;
	}

	if (camera._movingToActor) {
		VAR(VAR_CAMERA_DEST_X) = camera._dest.x = a->_pos.x;
		VAR(VAR_CAMERA_DEST_Y) = camera._dest.y = a->_pos.y;
	}

	assert(camera._cur.x >= (_screenWidth / 2) && camera._cur.y >= (_screenHeight / 2));

	clampCameraPos(&camera._dest);

	if (camera._cur.x < camera._dest.x) {
		camera._cur.x += (short) VAR(VAR_CAMERA_SPEED_X);
		if (camera._cur.x > camera._dest.x)
			camera._cur.x = camera._dest.x;
	}

	if (camera._cur.x > camera._dest.x) {
		camera._cur.x -= (short) VAR(VAR_CAMERA_SPEED_X);
		if (camera._cur.x < camera._dest.x)
			camera._cur.x = camera._dest.x;
	}

	if (camera._cur.y < camera._dest.y) {
		camera._cur.y += (short) VAR(VAR_CAMERA_SPEED_Y);
		if (camera._cur.y > camera._dest.y)
			camera._cur.y = camera._dest.y;
	}

	if (camera._cur.y > camera._dest.y) {
		camera._cur.y -= (short) VAR(VAR_CAMERA_SPEED_Y);
		if (camera._cur.y < camera._dest.y)
			camera._cur.y = camera._dest.y;
	}

	if (camera._cur.x == camera._dest.x && camera._cur.y == camera._dest.y) {

		camera._movingToActor = false;
		camera._accel.x = camera._accel.y = 0;
		VAR(VAR_CAMERA_SPEED_X) = VAR(VAR_CAMERA_SPEED_Y) = 0;
	} else {

		camera._accel.x += (short) VAR(VAR_CAMERA_ACCEL_X);
		camera._accel.y += (short) VAR(VAR_CAMERA_ACCEL_Y);

		VAR(VAR_CAMERA_SPEED_X) += camera._accel.x / 100;
		VAR(VAR_CAMERA_SPEED_Y) += camera._accel.y / 100;

		if (VAR(VAR_CAMERA_SPEED_X) < 8)
			VAR(VAR_CAMERA_SPEED_X) = 8;

		if (VAR(VAR_CAMERA_SPEED_Y) < 8)
			VAR(VAR_CAMERA_SPEED_Y) = 8;

	}

	cameraMoved();

	if (camera._cur.x != old.x || camera._cur.y != old.y) {
		VAR(VAR_CAMERA_POS_X) = camera._cur.x;
		VAR(VAR_CAMERA_POS_Y) = camera._cur.y;

		if (VAR(VAR_SCROLL_SCRIPT))
			runScript(VAR(VAR_SCROLL_SCRIPT), 0, 0, 0);
	}
}
Ejemplo n.º 15
0
void ScummEngine::moveCamera() {
	int pos = camera._cur.x;
	int actorx, t;
	Actor *a = NULL;

	camera._cur.x &= 0xFFF8;

	if (VAR_CAMERA_MIN_X != 0xFF && camera._cur.x < VAR(VAR_CAMERA_MIN_X)) {
		if (VAR_CAMERA_FAST_X != 0xFF && VAR(VAR_CAMERA_FAST_X))
			camera._cur.x = (short) VAR(VAR_CAMERA_MIN_X);
		else
			camera._cur.x += 8;
		cameraMoved();
		return;
	}

	if (VAR_CAMERA_MAX_X != 0xFF && camera._cur.x > VAR(VAR_CAMERA_MAX_X)) {
		if (VAR_CAMERA_FAST_X != 0xFF && VAR(VAR_CAMERA_FAST_X))
			camera._cur.x = (short) VAR(VAR_CAMERA_MAX_X);
		else
			camera._cur.x -= 8;
		cameraMoved();
		return;
	}

	if (camera._mode == kFollowActorCameraMode) {
		a = derefActor(camera._follows, "moveCamera");

		actorx = a->_pos.x;
		t = actorx / 8 - _screenStartStrip;

		if (t < camera._leftTrigger || t > camera._rightTrigger) {
			if (VAR_CAMERA_FAST_X != 0xFF && VAR(VAR_CAMERA_FAST_X)) {
				if (t > 35)
					camera._dest.x = actorx + 80;
				if (t < 5)
					camera._dest.x = actorx - 80;
			} else
				camera._movingToActor = true;
		}
	}

	if (camera._movingToActor) {
		a = derefActor(camera._follows, "moveCamera(2)");
		camera._dest.x = a->_pos.x;
	}

	if (VAR_CAMERA_MIN_X != 0xFF && camera._dest.x < VAR(VAR_CAMERA_MIN_X))
		camera._dest.x = (short) VAR(VAR_CAMERA_MIN_X);

	if (VAR_CAMERA_MAX_X != 0xFF && camera._dest.x > VAR(VAR_CAMERA_MAX_X))
		camera._dest.x = (short) VAR(VAR_CAMERA_MAX_X);

	if (VAR_CAMERA_FAST_X != 0xFF && VAR(VAR_CAMERA_FAST_X)) {
		camera._cur.x = camera._dest.x;
	} else {
		if (camera._cur.x < camera._dest.x)
			camera._cur.x += 8;
		if (camera._cur.x > camera._dest.x)
			camera._cur.x -= 8;
	}

	/* a is set a bit above */
	if (camera._movingToActor && (camera._cur.x / 8) == (a->_pos.x / 8)) {
		camera._movingToActor = false;
	}

	cameraMoved();

	if (VAR_SCROLL_SCRIPT != 0xFF && VAR(VAR_SCROLL_SCRIPT) && pos != camera._cur.x) {
		VAR(VAR_CAMERA_POS_X) = camera._cur.x;
		runScript(VAR(VAR_SCROLL_SCRIPT), 0, 0, 0);
	}
}
Ejemplo n.º 16
0
void ScummEngine_v71he::o71_kernelSetFunctions() {
	int args[29];
	int num;
	ActorHE *a;

	num = getStackList(args, ARRAYSIZE(args));

	switch (args[0]) {
	case 1:
		// Used to restore images when decorating cake in
		// Fatty Bear's Birthday Surprise
		virtScreenLoad(args[1], args[2], args[3], args[4], args[5]);
		break;
	case 20: // HE72+
		a = (ActorHE *)derefActor(args[1], "o71_kernelSetFunctions: 20");
		queueAuxBlock(a);
		break;
	case 21:
		_skipDrawObject = 1;
		break;
	case 22:
		_skipDrawObject = 0;
		break;
	case 23:
		clearCharsetMask();
		_fullRedraw = true;
		break;
	case 24:
		_skipProcessActors = 1;
		redrawAllActors();
		break;
	case 25:
		_skipProcessActors = 0;
		redrawAllActors();
		break;
	case 26:
		a = (ActorHE *)derefActor(args[1], "o71_kernelSetFunctions: 26");
		a->_auxBlock.r.left = 0;
		a->_auxBlock.r.right = -1;
		a->_auxBlock.r.top = 0;
		a->_auxBlock.r.bottom = -2;
		break;
	case 30:
		a = (ActorHE *)derefActor(args[1], "o71_kernelSetFunctions: 30");
		a->_clipOverride.bottom = args[2];
		break;
	case 42:
		_wiz->_rectOverrideEnabled = true;
		_wiz->_rectOverride.left = args[1];
		_wiz->_rectOverride.top = args[2];
		_wiz->_rectOverride.right = args[3];
		_wiz->_rectOverride.bottom = args[4];
		adjustRect(_wiz->_rectOverride);
		break;
	case 43:
		_wiz->_rectOverrideEnabled = false;
		break;
	default:
		error("o71_kernelSetFunctions: default case %d (param count %d)", args[0], num);
	}
}