Exemple #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;
}
Exemple #2
0
void ScummEngine_v2::o2_getObjPreposition() {
	getResultPos();
	int obj = getVarOrDirectWord(PARAM_1);

	if (whereIsObject(obj) != WIO_NOT_FOUND) {
		byte *ptr = getOBCDFromObject(obj) + 12;
		setResult(*ptr >> 5);
	} else {
Exemple #3
0
int ScummEngine::whereIsObjectInventory(int object) {
	int res = 0;
	_v0ObjectInInventory = true;
	res = whereIsObject(object);
	_v0ObjectInInventory = false;

	return res;
}
Exemple #4
0
void ScummEngine_v2::o2_setObjPreposition() {
	int obj = getVarOrDirectWord(PARAM_1);
	int unk = fetchScriptByte();

	if (_game.platform == Common::kPlatformNES)
		return;

	if (whereIsObject(obj) != WIO_NOT_FOUND) {
		// FIXME: this might not work properly the moment we save and restore the game.
		byte *ptr = getOBCDFromObject(obj) + 12;
		*ptr &= 0x1F;
		*ptr |= unk << 5;
	}
}
Exemple #5
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);
	}
}
Exemple #6
0
void ScummEngine::clearOwnerOf(int obj) {
	int i;

	// Stop the associated object script code (else crashes might occurs)
	stopObjectScript(obj);

	// If the object is "owned" by a the current room, we scan the
	// object list and (only if it's a floating object) nuke it.
	if (getOwner(obj) == OF_OWNER_ROOM) {
		for (i = 0; i < _numLocalObjects; i++)  {
			if (_objs[i].obj_nr == obj && _objs[i].fl_object_index) {
				// Removing an flObject from a room means we can nuke it
				_res->nukeResource(rtFlObject, _objs[i].fl_object_index);
				_objs[i].obj_nr = 0;
				_objs[i].fl_object_index = 0;
			}
		}
	} else {

		// Alternatively, scan the inventory to see if the object is in there...
		for (i = 0; i < _numInventory; i++) {
			if (_inventory[i] == obj) {
				if (_game.version == 0)
					assert(WIO_INVENTORY == whereIsObjectInventory(obj));
				else
					assert(WIO_INVENTORY == whereIsObject(obj));

				// Found the object! Nuke it from the inventory.
				_res->nukeResource(rtInventory, i);
				_inventory[i] = 0;

				// Now fill up the gap removing the object from the inventory created.
				for (i = 0; i < _numInventory - 1; i++) {
					if (!_inventory[i] && _inventory[i+1]) {
						_inventory[i] = _inventory[i+1];
						_inventory[i+1] = 0;
						// FIXME FIXME FIXME: This is incomplete, as we do not touch flags, status... BUG
						_res->_types[rtInventory][i]._address = _res->_types[rtInventory][i + 1]._address;
						_res->_types[rtInventory][i]._size = _res->_types[rtInventory][i + 1]._size;
						_res->_types[rtInventory][i + 1]._address = NULL;
						_res->_types[rtInventory][i + 1]._size = 0;
					}
				}
				break;
			}
		}
	}
}
Exemple #7
0
void ScummEngine_v0::o_pickupObject() {
	int obj = fetchScriptByte();
	if (!obj)
		obj = _cmdObject;

	/* Don't take an object twice */
	if (whereIsObject(obj) == WIO_INVENTORY)
		return;

	addObjectToInventory(obj, _roomResource);
	markObjectRectAsDirty(obj);
	putOwner(obj, VAR(VAR_EGO));
	putState(obj, getState(obj) | kObjectState_08 | kObjectStateUntouchable);
	clearDrawObjectQueue();

	runInventoryScript(1);
}
Exemple #8
0
void ScummEngine_v4::o4_pickupObject() {
	int obj = getVarOrDirectWord(PARAM_1);

	if (obj < 1) {
		error("pickupObjectOld received invalid index %d (script %d)", obj, vm.slot[_currentScript].number);
	}

	if (getObjectIndex(obj) == -1)
		return;

	if (whereIsObject(obj) == WIO_INVENTORY)	// Don't take an object twice
		return;

	// debug(0, "adding %d from %d to inventoryOld", obj, _currentRoom);
	addObjectToInventory(obj, _roomResource);
	markObjectRectAsDirty(obj);
	putOwner(obj, VAR(VAR_EGO));
	putClass(obj, kObjectClassUntouchable, 1);
	putState(obj, 1);
	clearDrawObjectQueue();
	runInventoryScript(1);
}
Exemple #9
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);
}