Skip to content

Commit

Permalink
BLADERUNNER: added all scene scripts, esper script, kia script, vk sc…
Browse files Browse the repository at this point in the history
…ript, completed init script. Added decoding of lights from VQA. Moved view from scene.
  • Loading branch information
peterkohaut authored and sev- committed Sep 29, 2016
1 parent b67bca2 commit bf44e97
Show file tree
Hide file tree
Showing 143 changed files with 35,615 additions and 1,531 deletions.
6 changes: 5 additions & 1 deletion engines/bladerunner/actor.cpp
Expand Up @@ -186,6 +186,10 @@ void Actor::setAtWaypoint(int waypointId, int angle, int moving, bool retired)
setAtXYZ(waypointPosition, angle, true, moving, retired);
}

void Actor::loopWalkToXYZ(float x, float y, float z, int a4, int a5, int a6, int a7) {
this->loopWalkToXYZ(Vector3(x, y, z));
}

void Actor::loopWalkToXYZ(Vector3 destination)
{
int unk1;
Expand Down Expand Up @@ -660,7 +664,7 @@ void Actor::setGoal(int goalNumber) {

//TODO: _vm->actorScript->GoalChanged(_id, _goalNumber, goalNumber);

_vm->_script->SceneActorChangedGoal(_id, goalNumber, _goalNumber, _vm->_scene->getSetId() == _setId);
_vm->_script->ActorChangedGoal(_id, goalNumber, _goalNumber, _vm->_scene->getSetId() == _setId);
}

int Actor::getGoal() {
Expand Down
1 change: 1 addition & 0 deletions engines/bladerunner/actor.h
Expand Up @@ -121,6 +121,7 @@ class Actor {
void setFPS(int fps);

void loopWalkToXYZ(Vector3 destination);
void loopWalkToXYZ(float x, float y, float z, int a4, int a5, int a6, int a7);
void loopWalkToSceneObject(const char *objectName, int destinationOffset = 0);

bool tick(bool forceUpdate);
Expand Down
2 changes: 1 addition & 1 deletion engines/bladerunner/audio_player.cpp
Expand Up @@ -166,7 +166,7 @@ void AudioPlayer::fadeAndStopTrack(Track *track, int time)
int AudioPlayer::playAud(const Common::String &name, int volume, int panFrom, int panTo, int priority, byte flags) {
/* Find first available track or, alternatively, the lowest priority playing track */
Track *track = NULL;
int lowestPriority;
int lowestPriority = INT_MAX;
Track *lowestPriorityTrack = NULL;

for (int i = 0; i != 6; ++i) {
Expand Down
67 changes: 49 additions & 18 deletions engines/bladerunner/bladerunner.cpp
Expand Up @@ -555,7 +555,7 @@ void BladeRunnerEngine::gameTick() {

if (_settings->getNewScene() == -1 || _script->_inScriptCounter /* || in_ai */) {

_sliceRenderer->setView(_scene->_view);
_sliceRenderer->setView(*_view);

// Tick and draw all actors in current set
for (int i = 0, end = _gameInfo->getActorCount(); i != end; ++i) {
Expand Down Expand Up @@ -611,29 +611,66 @@ void BladeRunnerEngine::handleMouseClick(int x, int y) {
int isTarget;

int sceneObjectId = _sceneObjects->findByXYZ(&isClickable, &isObstacle, &isTarget, mousePosition.x, mousePosition.y, mousePosition.z, 1, 0, 1);
int exitType = _scene->_exits->getTypeAtXY(x, y);
int exitIndex = _scene->_exits->getTypeAtXY(x, y);

debug("%d %d", sceneObjectId, exitType);
debug("%d %d", sceneObjectId, exitIndex);

if ((sceneObjectId < 0 || sceneObjectId > 73) && exitType >= 0) {
// clickedOnExit(exitType, x, y);
debug("clicked on exit %d %d %d", exitType, x, y);
if ((sceneObjectId < 0 || sceneObjectId > 73) && exitIndex >= 0) {
handleMouseClickExit(x, y, exitIndex);
return;
}

int regionIndex = _scene->_regions->getRegionAtXY(x, y);
if (regionIndex >= 0) {
debug("clicked on region %d %d %d", regionIndex, x, y);
_script->ClickedOn2DRegion(regionIndex);
handleMouseClickRegion(x, y, regionIndex);
return;
}

if (sceneObjectId >= 198 && sceneObjectId <= 293) {
const char *objectName = _scene->objectGetName(sceneObjectId - 198);
debug("%s", objectName);
_script->ClickedOn3DObject(objectName);
if (sceneObjectId == -1) {
debug("Clicked on nothing");
return;
} else if (sceneObjectId >= 0 && sceneObjectId <= 73) {
handleMouseClickActor(x, y, sceneObjectId);
return;
} else if (sceneObjectId >= 74 && sceneObjectId <= 197) {
handleMouseClickItem(x, y, sceneObjectId - 74);
return;
} else if (sceneObjectId >= 198 && sceneObjectId <= 293) {
handleMouseClick3DObject(x, y, sceneObjectId - 198, isClickable, isTarget);
return;
}
}

void BladeRunnerEngine::handleMouseClickExit(int x, int y, int exitIndex)
{
// clickedOnExit(exitType, x, y);
debug("clicked on exit %d %d %d", exitIndex, x, y);
_script->ClickedOnExit(exitIndex);
}

void BladeRunnerEngine::handleMouseClickRegion(int x, int y, int regionIndex)
{
debug("clicked on region %d %d %d", regionIndex, x, y);
_script->ClickedOn2DRegion(regionIndex);
}

void BladeRunnerEngine::handleMouseClick3DObject(int x, int y, int objectId, bool isClickable, bool isTarget)
{
const char *objectName = _scene->objectGetName(objectId);
debug("Clicked on object %s", objectName);
_script->ClickedOn3DObject(objectName, false);
}

void BladeRunnerEngine::handleMouseClickItem(int x, int y, int itemId)
{
debug("Clicked on item %d", itemId);
_script->ClickedOnItem(itemId, false);
}

void BladeRunnerEngine::handleMouseClickActor(int x, int y, int actorId)
{
debug("Clicked on actor %d", actorId);
_script->ClickedOnActor(actorId);
}

void BladeRunnerEngine::gameWaitForActive() {
Expand All @@ -655,12 +692,6 @@ void BladeRunnerEngine::loopActorSpeaking() {
playerGainsControl();
}

void BladeRunnerEngine::loopActorWalkToXYZ(int actorId, float x, float y, float z, int a4, int a5, int a6, int a7) {
Actor *actor = _actors[actorId];

actor->loopWalkToXYZ(Vector3(x, y, z));
}

void BladeRunnerEngine::outtakePlay(int id, bool noLocalization, int container) {
Common::String name = _gameInfo->getOuttake(id);

Expand Down
7 changes: 5 additions & 2 deletions engines/bladerunner/bladerunner.h
Expand Up @@ -143,11 +143,14 @@ class BladeRunnerEngine : public Engine {
void gameTick();
void handleEvents();
void handleMouseClick(int x, int y);
void handleMouseClickExit(int x, int y, int exitIndex);
void handleMouseClickRegion(int x, int y, int regionIndex);
void handleMouseClickItem(int x, int y, int itemId);
void handleMouseClickActor(int x, int y, int actorId);
void handleMouseClick3DObject(int x, int y, int objectId, bool isClickable, bool isTarget);
void gameWaitForActive();
void loopActorSpeaking();

void loopActorWalkToXYZ(int actorId, float x, float y, float z, int a4, int a5, int a6, int a7);

void outtakePlay(int id, bool no_localization, int container = -1);

bool openArchive(const Common::String &name);
Expand Down
33 changes: 32 additions & 1 deletion engines/bladerunner/light.cpp
Expand Up @@ -48,8 +48,39 @@ void Light::read(Common::ReadStream* stream, int framesCount, int frame, int ani
setupFrame(frame);
}

void Light::readVqa(Common::ReadStream* stream)
void Light::readVqa(Common::ReadStream* stream, int framesCount, int frame, int animated)
{
_framesCount = framesCount;
_animated = animated;

_animatedParameters = stream->readUint32LE();

int size = stream->readUint32LE();

_animationData = new float[size / sizeof(float)];
stream->read(_animationData, size);

_m11ptr = _animationData;
_m12ptr = _m11ptr + (_animatedParameters & 0x1 ? framesCount : 1);
_m13ptr = _m12ptr + (_animatedParameters & 0x2 ? framesCount : 1);
_m14ptr = _m13ptr + (_animatedParameters & 0x4 ? framesCount : 1);
_m21ptr = _m14ptr + (_animatedParameters & 0x8 ? framesCount : 1);
_m22ptr = _m21ptr + (_animatedParameters & 0x10 ? framesCount : 1);
_m23ptr = _m22ptr + (_animatedParameters & 0x20 ? framesCount : 1);
_m24ptr = _m23ptr + (_animatedParameters & 0x40 ? framesCount : 1);
_m31ptr = _m24ptr + (_animatedParameters & 0x80 ? framesCount : 1);
_m32ptr = _m31ptr + (_animatedParameters & 0x100 ? framesCount : 1);
_m33ptr = _m32ptr + (_animatedParameters & 0x200 ? framesCount : 1);
_m34ptr = _m33ptr + (_animatedParameters & 0x400 ? framesCount : 1);
_colorRPtr = _m34ptr + (_animatedParameters & 0x800 ? framesCount : 1);
_colorGPtr = _colorRPtr + (_animatedParameters & 0x1000 ? framesCount : 1);
_colorBPtr = _colorGPtr + (_animatedParameters & 0x2000 ? framesCount : 1);
_field16ptr = _colorGPtr + (_animatedParameters & 0x4000 ? framesCount : 1);
_field17ptr = _field16ptr + (_animatedParameters & 0x8000 ? framesCount : 1);
_field18ptr = _field17ptr + (_animatedParameters & 0x10000 ? framesCount : 1);
_field19ptr = _field18ptr + (_animatedParameters & 0x20000 ? framesCount : 1);

setupFrame(frame);
}

void Light::setupFrame(int frame)
Expand Down
2 changes: 1 addition & 1 deletion engines/bladerunner/light.h
Expand Up @@ -77,7 +77,7 @@ class Light
~Light();

void read(Common::ReadStream *stream, int framesCount, int frame, int animated);
void readVqa(Common::ReadStream *stream);
void readVqa(Common::ReadStream *stream, int framesCount, int frame, int animated);

void setupFrame(int frame);

Expand Down
65 changes: 60 additions & 5 deletions engines/bladerunner/lights.cpp
Expand Up @@ -19,7 +19,7 @@ Lights::~Lights()
reset();
}

void Lights::read(Common::ReadStream* stream, int framesCount)
void Lights::read(Common::ReadStream *stream, int framesCount)
{
_ambientLightColor.r = stream->readFloatLE();
_ambientLightColor.g = stream->readFloatLE();
Expand Down Expand Up @@ -58,11 +58,66 @@ void Lights::read(Common::ReadStream* stream, int framesCount)
}
}

void Lights::readVqa(Common::ReadStream* stream)
void Lights::removeAnimated()
{
reset();
//int framesCount = stream->readUint32LE();
//int count = stream->readUint32LE();
Light **nextLight;
Light *light;

nextLight = &this->_lights;
light = this->_lights;
if (light)
{
do
{
if (light->_animated)
{
*nextLight = light->_next;
delete light;
}
else
{
nextLight = &light->_next;
}
light = *nextLight;
} while (*nextLight);
}
}

void Lights::readVqa(Common::ReadStream *stream)
{
removeAnimated();
if (stream->eos())
return;

int framesCount = stream->readUint32LE();
int count = stream->readUint32LE();
for (int i = 0; i < count; i++) {
int lightType = stream->readUint32LE();
Light* light;
switch(lightType)
{
case 5:
light = new Light5();
break;
case 4:
light = new Light4();
break;
case 3:
light = new Light3();
break;
case 2:
light = new Light2();
break;
case 1:
light = new Light1();
break;
default:
light = new Light();
}
light->readVqa(stream, framesCount, _frame, 1);
light->_next = _lights;
_lights = light;
}
}

void Lights::setupFrame(int frame)
Expand Down
2 changes: 2 additions & 0 deletions engines/bladerunner/lights.h
Expand Up @@ -52,6 +52,8 @@ class Lights {
void reset();

void setupFrame(int frame);
private:
void removeAnimated();
};

} // End of namespace BladeRunner
Expand Down

0 comments on commit bf44e97

Please sign in to comment.