From a4ba6091316f8f50ea40d4dfd42bd26d419b1206 Mon Sep 17 00:00:00 2001 From: Thomas Fach-Pedersen Date: Sat, 2 May 2015 22:31:07 +0200 Subject: BLADERUNNER: Add beginnings of Actor class and move actor drawing to Scene --- engines/bladerunner/actor.cpp | 121 ++++++++++++++++++++++++++++++++++++ engines/bladerunner/actor.h | 94 ++++++++++++++++++++++++++++ engines/bladerunner/bladerunner.cpp | 23 ++++--- engines/bladerunner/bladerunner.h | 5 ++ engines/bladerunner/module.mk | 1 + engines/bladerunner/scene.cpp | 7 ++- 6 files changed, 238 insertions(+), 13 deletions(-) create mode 100644 engines/bladerunner/actor.cpp create mode 100644 engines/bladerunner/actor.h diff --git a/engines/bladerunner/actor.cpp b/engines/bladerunner/actor.cpp new file mode 100644 index 0000000000..f483263f76 --- /dev/null +++ b/engines/bladerunner/actor.cpp @@ -0,0 +1,121 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "bladerunner/actor.h" + +#include "bladerunner/bladerunner.h" + +#include "bladerunner/boundingbox.h" +#include "bladerunner/gameinfo.h" +#include "bladerunner/slice_renderer.h" + +namespace BladeRunner { + +Actor::Actor(BladeRunnerEngine *vm, int actorId) { + _vm = vm; + _id = actorId; + + // TODO: Construct Walkinfo + + _bbox = new BoundingBox(); + + // TODO: Construct _clues ((actorId && actor != 99) ? 2 : 4) + + // TODO: Construct _movementTrack + + _friendlinessToOther = new int[_vm->_gameInfo->getActorCount()]; +} + +Actor::~Actor() { + delete[] _friendlinessToOther; + delete _bbox; + // delete _clues; + // delete _movementTrack; +} + +void Actor::setup(int actorId) { + _id = actorId; + _set = -1; + + _position = Vector3(0.0, 0.0, 0.0); + _facing = 512; + _walkboxId = -1; + + _walkboxId = -1; + _animationId = 0; + _animationFrame = 0; + _fps = 15; + _frame_ms = 1000 / _fps; + + _isTargetable = false; + _isInvisible = false; + _isImmuneToObstacles = false; + + _width = 0; + _height = 0; + + for (int i = 0; i != 7; ++i) { + _timersRemain[i] = 0; + _timersBegan[i] = _vm->getTotalPlayTime(); + } + + _scale = 1.0; + + _honesty = 50; + _intelligence = 50; + _combatAggressiveness = 50; + _stability = 50; + + _currentHP = 50; + _maxHP = 50; + _goalNumber = -1; + + _timersRemain[4] = 60000; + _animationMode = -1; + // TODO: screen rect = { -1, -1, -1, -1 }; + + int actorCount = (int)_vm->_gameInfo->getActorCount(); + for (int i = 0; i != actorCount; ++i) + _friendlinessToOther[i] = 50; + + // TODO: Setup clues + + // TODO: Flush movement track +} + +void Actor::set_at_xyz(Vector3 pos, int facing) { + _position = pos; + _facing = facing; +} + +void Actor::draw() { + Vector3 draw_position(_position.x, -_position.z, _position.y + 2.0); + float draw_facing = _facing * M_PI / 512.0; + // float draw_scale = _scale; + + // TODO: Handle SHORTY mode + + _vm->_sliceRenderer->setupFrame(19, 1, draw_position, M_PI - draw_facing); + _vm->_sliceRenderer->drawFrame(_vm->_surface2, _vm->_zBuffer2); +} + +} // End of namespace BladeRunner diff --git a/engines/bladerunner/actor.h b/engines/bladerunner/actor.h new file mode 100644 index 0000000000..b51bc3fefb --- /dev/null +++ b/engines/bladerunner/actor.h @@ -0,0 +1,94 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef BLADERUNNER_ACTOR_H +#define BLADERUNNER_ACTOR_H + +#include "bladerunner/bladerunner.h" + +#include "bladerunner/vector.h" + +namespace BladeRunner { + +class BladeRunnerEngine; +class BoundingBox; + +class Actor { + BladeRunnerEngine *_vm; + +private: + BoundingBox *_bbox; + // MovementTrack *_movementTrack; + + int _honesty; + int _intelligence; + int _stability; + int _combatAggressiveness; + int _goalNumber; + int *_friendlinessToOther; + + int _currentHP; + int _maxHP; + + // Clues _clues; + + int _id; + int _set; + Vector3 _position; + int _facing; // [0, 1024) + int _walkboxId; + + // Flags + bool _isTargetable; + bool _isInvisible; + bool _isImmuneToObstacles; + + // Animation + int _width; + int _height; + int _animationMode; + int _fps; + int _frame_ms; + int _animationId; + int _animationFrame; + + // WalkInfo _walkInfo; + + int _timersRemain[7]; + int _timersBegan[7]; + + float _scale; + +public: + Actor(BladeRunnerEngine *_vm, int actorId); + ~Actor(); + + void setup(int actorId); + + void set_at_xyz(Vector3 pos, int facing); + + void draw(); +}; + +} // End of namespace BladeRunner + +#endif diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp index d44a0d891e..ca83ac9a19 100644 --- a/engines/bladerunner/bladerunner.cpp +++ b/engines/bladerunner/bladerunner.cpp @@ -23,6 +23,7 @@ #include "bladerunner/bladerunner.h" +#include "bladerunner/actor.h" #include "bladerunner/ambient_sounds.h" #include "bladerunner/audio_player.h" #include "bladerunner/audio_speech.h" @@ -201,11 +202,15 @@ bool BladeRunnerEngine::startup(bool hasSavegames) { _zBuffer1 = new uint16[640 * 480]; _zBuffer2 = new uint16[640 * 480]; - // TODO: Actors - - // TODO: Player 99 (VO actor) + int actorCount = (int)_gameInfo->getActorCount(); + assert(actorCount < 99); + for (int i = 0; i != actorCount; ++i) { + _actors[i] = new Actor(this, i); + } + _voiceoverActor = new Actor(this, 99); + _playerActor = _actors[_gameInfo->getPlayerId()]; - // TODO: McCoy setup + // TODO: set _playerActor countdown timer 6 // TODO: Set actor ids (redundant?) @@ -511,19 +516,13 @@ void BladeRunnerEngine::gameTick() { // TODO: Tick and draw all actors in current set (drawing works in Replicant) - // Hardcode McCoy in place to test the slice renderer - Vector3 pos = _scene->_actorStartPosition; - Vector3 draw_pos(pos.x, -pos.z, pos.y + 2); - float facing = -1.570796f; - + // HACK to draw McCoy _sliceRenderer->setView(_scene->_view); - _sliceRenderer->setupFrame(19, 1, draw_pos, facing); - _sliceRenderer->drawFrame(_surface2, _zBuffer2); + _playerActor->draw(); // TODO: Draw items (drawing works in Replicant) // TODO: Draw item pickup (understood, drawing works in Replicant) // TODO: Draw dialogue menu - // TODO: Draw mouse (understood) Common::Point p = _eventMan->getMousePos(); _mouse->draw(_surface2, p.x, p.y); diff --git a/engines/bladerunner/bladerunner.h b/engines/bladerunner/bladerunner.h index 634386838e..d0ded00b76 100644 --- a/engines/bladerunner/bladerunner.h +++ b/engines/bladerunner/bladerunner.h @@ -36,6 +36,7 @@ namespace BladeRunner { +class Actor; class AmbientSounds; class AudioPlayer; class AudioSpeech; @@ -83,6 +84,10 @@ public: Common::Array _shapes; + Actor *_actors[99]; + Actor *_voiceoverActor; + Actor *_playerActor; + int in_script_counter; Graphics::Surface _surface1; diff --git a/engines/bladerunner/module.mk b/engines/bladerunner/module.mk index 8cd9ba4054..7ec48f6a7e 100644 --- a/engines/bladerunner/module.mk +++ b/engines/bladerunner/module.mk @@ -1,6 +1,7 @@ MODULE := engines/bladerunner MODULE_OBJS = \ + actor.o \ adpcm_decoder.o \ ambient_sounds.o \ archive.o \ diff --git a/engines/bladerunner/scene.cpp b/engines/bladerunner/scene.cpp index 8ec8b59d1b..925c86afba 100644 --- a/engines/bladerunner/scene.cpp +++ b/engines/bladerunner/scene.cpp @@ -23,6 +23,8 @@ #include "bladerunner/scene.h" #include "bladerunner/bladerunner.h" + +#include "bladerunner/actor.h" #include "bladerunner/chapters.h" #include "bladerunner/gameinfo.h" #include "bladerunner/script/script.h" @@ -81,9 +83,12 @@ bool Scene::open(int setId, int sceneId, bool isLoadingGame) { } // TODO: set VQADecoder parameters + // TODO: Set actor position from scene info + _vm->_playerActor->set_at_xyz(_actorStartPosition, _actorStartFacing); + // TODO: Set actor set - // TODO: call SCRIPT_Scene_Loaded + _vm->_script->SceneLoaded(); #if 0 -- cgit v1.2.3