Example #1
0
void KyraRpgEngine::timerProcessDoors(int timerNum) {
	for (int i = 0; i < 3; i++) {
		uint16 b = _openDoorState[i].block;
		if (!b)
			continue;

		int v = _openDoorState[i].state;
		int c = _openDoorState[i].wall;

		_levelBlockProperties[b].walls[c] += v;
		_levelBlockProperties[b].walls[c ^ 2] += v;

		int snd = 3;
		int flg = _wllWallFlags[_levelBlockProperties[b].walls[c]];
		if (flg & 0x20)
			snd = 5;
		else if (v == -1)
			snd = 4;

		if (_flags.gameID == GI_LOL) {
			if (!(_updateFlags & 1)) {
				snd_processEnvironmentalSoundEffect(snd + 28, b);
				if (!checkSceneUpdateNeed(b))
					updateEnvironmentalSfx(0);
			}
		} else {
			checkSceneUpdateNeed(b);
			updateEnvironmentalSfx(snd);
		}

		if (flg & 0x30)
			_openDoorState[i].block = 0;
	}
}
Example #2
0
int LoLEngine::deleteMonstersFromBlock(int block) {
	int i = _levelBlockProperties[block].assignedObjects;
	int cnt = 0;
	uint16 next = 0;

	while (i) {
		next = findObject(i)->nextAssignedObject;
		if (!(i & 0x8000)) {
			i = next;
			continue;
		}

		LoLMonster *m = &_monsters[i & 0x7fff];

		cnt++;
		setMonsterMode(m, 14);

		checkSceneUpdateNeed(m->block);

		placeMonster(m, 0, 0);

		i = next;
	}
	return cnt;
}
Example #3
0
void LoLEngine::setItemPosition(Item item, uint16 x, uint16 y, int flyingHeight, int moveable) {
	if (!flyingHeight) {
		x = (x & 0xffc0) | 0x40;
		y = (y & 0xffc0) | 0x40;
	}

	uint16 block = calcBlockIndex(x, y);
	_itemsInPlay[item].x = x;
	_itemsInPlay[item].y = y;
	_itemsInPlay[item].block = block;
	_itemsInPlay[item].flyingHeight = flyingHeight;

	if (moveable)
		_itemsInPlay[item].shpCurFrame_flg |= 0x4000;
	else
		_itemsInPlay[item].shpCurFrame_flg &= 0xbfff;


	assignItemToBlock(&_levelBlockProperties[block].assignedObjects, item);
	reassignDrawObjects(_currentDirection, item, &_levelBlockProperties[block], false);

	if (moveable)
		runLevelScriptCustom(block, 0x80, -1, item, 0, 0);

	checkSceneUpdateNeed(block);
}
Example #4
0
void LoLEngine::processObjectFlight(FlyingObject *t, int x, int y) {
	int bl = calcBlockIndex(t->x, t->y);
	LevelBlockProperty *l = &_levelBlockProperties[bl];
	removeAssignedObjectFromBlock(l, t->item);
	removeDrawObjectFromBlock(l, t->item);
	t->x = x;
	t->y = y;
	updateObjectFlightPosition(t);
	checkSceneUpdateNeed(bl);
}
Example #5
0
void LoLEngine::updateObjectFlightPosition(FlyingObject *t) {
	if (t->objectType == 0) {
		setItemPosition(t->item, t->x, t->y, t->flyingHeight, (t->flyingHeight == 0) ? 1 : 0);
	} else if (t->objectType == 1) {
		if (t->flyingHeight == 0) {
			deleteItem(t->item);
			checkSceneUpdateNeed(calcBlockIndex(t->x, t->y));
		} else {
			setItemPosition(t->item, t->x, t->y, t->flyingHeight, 0);
		}
	}
}
Example #6
0
void LoLEngine::setMonsterMode(LoLMonster *monster, int mode) {
	if (monster->mode == 13 && mode != 14)
		return;

	if (mode == 7) {
		monster->destX = _partyPosX;
		monster->destY = _partyPosY;
	}

	if (monster->mode == 1 && mode == 7) {
		for (int i = 0; i < 30; i++) {
			if (monster->mode != 1)
				continue;
			monster->mode = mode;
			monster->fightCurTick = 0;
			monster->destX = _partyPosX;
			monster->destY = _partyPosY;
			setMonsterDirection(monster, calcMonsterDirection(monster->x, monster->y, monster->destX, monster->destY));
		}
	} else {
		monster->mode = mode;
		monster->fightCurTick = 0;
		if (mode == 14)
			monster->hitPoints = 0;
		if (mode == 13 && (monster->flags & 0x20)) {
			monster->mode = 0;
			monsterDropItems(monster);
			if (_currentLevel != 29)
				setMonsterMode(monster, 14);
			runLevelScriptCustom(0x404, -1, monster->id, monster->id, 0, 0);
			checkSceneUpdateNeed(monster->block);
			if (monster->mode == 14)
				placeMonster(monster, 0, 0);
		}
	}
}