Beispiel #1
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);
}
Beispiel #2
0
void ScummEngine_v0::o_getBitVar() {
	getResultPos();
	byte flag = getVarOrDirectByte(PARAM_1);
	byte mask = getVarOrDirectByte(PARAM_2);

	setResult((_bitVars[flag] & (1 << mask)) ? 1 : 0);

	debug(0, "o_getBitVar (%d, %d %d)", flag, mask, _bitVars[flag] & (1 << mask));
}
Beispiel #3
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));
}
Beispiel #4
0
void ScummEngine_v0::o_setBitVar() {
	byte flag = getVarOrDirectByte(PARAM_1);
	byte mask = getVarOrDirectByte(PARAM_2);
	byte mod = getVarOrDirectByte(PARAM_3);

	if (mod)
		_bitVars[flag] |= (1 << mask);
	else
		_bitVars[flag] &= ~(1 << mask);

	debug(0, "o_setBitVar (%d, %d %d)", flag, mask, mod);
}
Beispiel #5
0
void ScummEngine_v0::o_getClosestActor() {
	int act, check_act;
	int dist;

	// This code can't detect any actors farther away than 255 units
	// (pixels in newer games, characters in older ones.) But this is
	// perfectly OK, as it is exactly how the original behaved.

	int closest_act = 0xFF, closest_dist = 0xFF;

	getResultPos();

	act = getVarOrDirectByte(PARAM_1);
	check_act = (_opcode & PARAM_2) ? 25 : 7;

	do {
		dist = getObjActToObjActDist(actorToObj(act), actorToObj(check_act));
		if (dist < closest_dist) {
			closest_dist = dist;
			closest_act = check_act;
		}
	} while (--check_act);

	setResult(closest_act);
}
Beispiel #6
0
void ScummEngine_v0::o_getActorMoving() {
	getResultPos();
	int act = getVarOrDirectByte(PARAM_1);
	Actor *a = derefActor(act, "o_getActorMoving");

	setResult(a->_moving);
}
Beispiel #7
0
void ScummEngine_v0::o_setOwnerOf() {
	int obj, owner;

	obj = getVarOrDirectWord(PARAM_1);
	owner = getVarOrDirectByte(PARAM_2);

	if (!obj)
		obj = _cmdObject;

	setOwnerOf(obj, owner);
}
Beispiel #8
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);
}
Beispiel #9
0
void ScummEngine_v0::o_walkActorToObject() {
	int actor = getVarOrDirectByte(PARAM_1);
	int objId = fetchScriptByte();
	int obj;

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

	if (whereIsObject(obj) != WIO_NOT_FOUND) {
		walkActorToObject(actor, obj);
	}
}
Beispiel #10
0
void ScummEngine_v4::o4_ifState() {
	int a = getVarOrDirectWord(PARAM_1);
	int b = getVarOrDirectByte(PARAM_2);

	// WORKAROUND bug #3306145 (also occurs in original): Some old versions of
	// Indy3 sometimes fail to allocate IQ points correctly. To quote:
	// "About the points error leaving Castle Brunwald: It seems to "reversed"!
	// When you get caught, free yourself and escape, you get 25 IQ points even
	// though you're not supposed to. However if you escape WITHOUT getting
	// caught, you get 0 IQ points (supposed to get 25 IQ points)."
	// This workaround is meant to address that.
	if (_game.id == GID_INDY3 && a == 367 &&
	    vm.slot[_currentScript].number == 363 && _currentRoom == 25) {
		b = 0;
	}

	jumpRelative(getState(a) == b);
}
Beispiel #11
0
void ScummEngine_v0::o_lights() {
	int a;

	a = getVarOrDirectByte(PARAM_1);
	// Convert older light mode values into
	// equivalent values.of later games
	// 0 Darkness
	// 1 Flashlight
	// 2 Lighted area
	if (a == 2)
		_currentLights = 11;
	else if (a == 1)
		_currentLights = 4;
	else
		_currentLights = 0;

	_fullRedraw = true;
}
Beispiel #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);
}
Beispiel #13
0
void ScummEngine_v4::o4_ifNotState() {
	int a = getVarOrDirectWord(PARAM_1);
	int b = getVarOrDirectByte(PARAM_2);

	jumpRelative(getState(a) != b);
}
Beispiel #14
0
void ScummEngine_v0::o_loadRoom() {
	int resid = getVarOrDirectByte(PARAM_1);
	ensureResourceLoaded(rtRoom, resid);
}
Beispiel #15
0
void ScummEngine_v0::o_loadCostume() {
	int resid = getVarOrDirectByte(PARAM_1);
	ensureResourceLoaded(rtCostume, resid);
}
Beispiel #16
0
int ScummEngine_v0::getVarOrDirectWord(byte mask) {
	return getVarOrDirectByte(mask);
}