diff options
author | Peter Kohaut | 2015-09-15 20:26:46 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-09-29 22:33:40 +0200 |
commit | 479d2f5b6293af2ae84fbdc718348a6e1126efb0 (patch) | |
tree | dfd6fd1a84b379aad003e005c0f47c8e211669b0 /engines/bladerunner/actor.cpp | |
parent | 6672e443a870963354ee43298c75164d382a5636 (diff) | |
download | scummvm-rg350-479d2f5b6293af2ae84fbdc718348a6e1126efb0.tar.gz scummvm-rg350-479d2f5b6293af2ae84fbdc718348a6e1126efb0.tar.bz2 scummvm-rg350-479d2f5b6293af2ae84fbdc718348a6e1126efb0.zip |
BLADERUNNER: still adding structures... and implementing some of script methods...
Diffstat (limited to 'engines/bladerunner/actor.cpp')
-rw-r--r-- | engines/bladerunner/actor.cpp | 363 |
1 files changed, 321 insertions, 42 deletions
diff --git a/engines/bladerunner/actor.cpp b/engines/bladerunner/actor.cpp index af9cef7258..d95c6529e0 100644 --- a/engines/bladerunner/actor.cpp +++ b/engines/bladerunner/actor.cpp @@ -27,6 +27,9 @@ #include "bladerunner/boundingbox.h" #include "bladerunner/gameinfo.h" #include "bladerunner/slice_renderer.h" +#include "bladerunner/waypoints.h" +#include "bladerunner/scene.h" +#include "bladerunner/items.h" namespace BladeRunner { @@ -34,33 +37,35 @@ Actor::Actor(BladeRunnerEngine *vm, int actorId) { _vm = vm; _id = actorId; - // TODO: Construct Walkinfo - - _bbox = new BoundingBox(); - - _clues = new ActorClues(vm, ((actorId && actorId != 99) ? 2 : 4)); - - // TODO: Construct _movementTrack + _walkInfo = new ActorWalk(vm); + _movementTrack = new MovementTrack(); + _clues = new ActorClues(vm, (actorId && actorId != 99) ? 2 : 4); + _bbox = new BoundingBox(); + _combatInfo = new ActorCombat(vm); _friendlinessToOther = new int[_vm->_gameInfo->getActorCount()]; } Actor::~Actor() { + delete[] _friendlinessToOther; + delete _combatInfo; delete _bbox; - // delete _clues; - // delete _movementTrack; + delete _clues; + delete _movementTrack; + delete _walkInfo; + } void Actor::setup(int actorId) { _id = actorId; - _set = -1; + _setId = -1; - _position = Vector3(0.0, 0.0, 0.0); - _facing = 512; - _walkboxId = -1; + _position = Vector3(0.0, 0.0, 0.0); + _facing = 512; + _targetFacing = -1; + _walkboxId = -1; - _walkboxId = -1; _animationId = 0; _animationFrame = 0; _fps = 15; @@ -72,8 +77,10 @@ void Actor::setup(int actorId) { _isRetired = false; - _width = 0; - _height = 0; + _width = 0; + _height = 0; + _retiredWidth = 0; + _retiredHeight = 0; for (int i = 0; i != 7; ++i) { _timersRemain[i] = 0; @@ -104,32 +111,30 @@ void Actor::setup(int actorId) { // TODO: Flush movement track } -void Actor::set_at_xyz(Vector3 pos, int facing) { - _position = pos; - _facing = facing; - - -// this->x = x; -// this->y = y; -// this->z = z; -// actor::set_angle(this, angle, addOrSet); -// if (scene::get_sceneId(Scene) == this->sceneId) -// this->walkboxId = set::findWalkbox(Scene->set, x, z); -// else -// this->walkboxId = -1; -// actor::setBoundingBox(this, x, y, z, retired); -// sceneObjects::removeScreneObject(SceneObjects, this->id); -// scene = this->sceneId; -// if (scene == scene::get_sceneId(Scene)) -// sceneObjects::addActor( -// SceneObjects, -// this->id, -// this->boundingBox, -// &this->screenRect, -// 1, -// a7, -// this->targetable, -// retired); +void Actor::set_at_xyz(Vector3 position, int facing, bool halfOrSet, int moving, bool retired) { + _position = position; + setFacing(facing, halfOrSet); + + if(_vm->_scene->_setId == _setId) { + _walkboxId = _vm->_scene->_set->findWalkbox(position.x, position.y); + }else { + _walkboxId = -1; + } + + setBoundingBox(position, retired); + + _vm->_sceneObjects->remove(_id); + + if(_vm->_scene->getSetId() == _setId) { + _vm->_sceneObjects->addActor(_id, _bbox, &_screenRectangle, 1, moving, _isTargetable, retired); + } +} + + +void Actor::set_at_waypoint(int waypointId, int angle, int unknown, bool retired) { + Vector3 waypointPosition; + _vm->_waypoints->getXyz(waypointId, &waypointPosition.x, &waypointPosition.y, &waypointPosition.z); + set_at_xyz(waypointPosition, angle, true, unknown, retired); } void Actor::draw() { @@ -144,4 +149,278 @@ void Actor::draw() { _vm->_sliceRenderer->drawFrame(_vm->_surface2, _vm->_zBuffer2); } + +int Actor::getSetId() { + return _setId; +} + +void Actor::setSetId(int setId) { + if (_setId == setId) { + return; + } + + int i; + + if(_setId > 0) { + for (i = 0; i < (int)_vm->_gameInfo->getActorCount(); i++) { + if (_vm->_actors[i]->_id != _id && _vm->_actors[i]->_setId == _setId) { + //actorScript->OtherAgentExitedThisScene( i, _id); + } + } + } + _setId = setId; + //actorScript->EnteredScene(_id, set); + if (_setId > 0) { + for (i = 0; i < (int)_vm->_gameInfo->getActorCount(); i++) { + if (_vm->_actors[i]->_id != _id && _vm->_actors[i]->_setId == _setId) { + //actorScript->OtherAgentEnteredThisScene(i, _id); + } + } + } +} + + +void Actor::setFacing(int facing, bool halfOrSet) { + if (facing < 0 || facing >= 1024) { + return; + } + + if (halfOrSet) { + _facing = facing; + return; + } + + int cw; + int ccw; + int offset; + + if (facing > _facing) { + cw = facing - _facing; + ccw = _facing + 1024 - facing; + } else { + ccw = _facing - facing; + cw = facing + 1024 - _facing; + } + if (cw < ccw) { + if (cw <= 32) { + offset = cw; + } else { + offset = cw / 2; + } + } else { + if (ccw <= 32) { + offset = -ccw; + } else { + offset = -ccw / 2; + } + } + _facing = (_facing + offset) % 1024; +} + +void Actor::setBoundingBox(Vector3 position, bool retired) { + if(retired) { + + }else { + _bbox->setXyz(position.x - 12.0f, position.y + 6.0f, position.z - 12.0f, position.x + 12.0f, position.y + 72.0f, position.z + 12.0f); + } +} + + +void Actor::changeAnimationMode(int animationMode, int force) { + if (force == 1) { + _animationMode = -1; + } + if(animationMode != _animationMode) { + //TODO: _vm->actorScript->ChangeAnimationMode(_id, animationMode); + _animationMode = animationMode; + } + +} + +bool Actor::isWalking() { + return _walkInfo->isWalking(); +} + +void Actor::stopWalking(int value) { + if (value == 1 && _id == 0) { + _vm->_playerActorIdle = true; + } + + if(isWalking()) { + _walkInfo->stop(_id, 1, _combatAnimationMode, 0); + } else if(inCombat()) { + changeAnimationMode(_combatAnimationMode, 0); + } else { + changeAnimationMode(0, 0); + } +} + +void Actor::faceActor(int otherActorId, bool animate) { + if (_setId != _vm->_scene->_setId) { + return; + } + + Actor *otherActor = _vm->_actors[otherActorId]; + + if (_setId != otherActor->_setId) { + return; + } + + faceXYZ(otherActor->_position.x, otherActor->_position.y, otherActor->_position.z, animate); +} + +void Actor::faceObject(char *objectName, bool animate) { + int objectId = _vm->_scene->findObject(objectName); + if (objectId == -1) { + return; + } + + BoundingBox boundingBox; + _vm->_scene->objectGetBoundingBox(objectId, &boundingBox); + + float x0, y0, z0, x1, y1, z1; + boundingBox.getXyz(&x0, &y0, &z0, &x1, &y1, &z1); + + float x = (x1 + x0) / 2.0f; + float z = (z1 + z0) / 2.0f; + faceXYZ(x, y0, z, animate); +} + +void Actor::faceItem(int itemId, bool animate) { + float x, y, z; + _vm->_items->getXyz(itemId, &x, &y, &z); + faceXYZ(x, y, z, animate); +} + +void Actor::faceWaypoint(int waypointId, bool animate) { + float x, y, z; + _vm->_waypoints->getXyz(waypointId, &x, &y, &z); + faceXYZ(x, y, z, animate); +} + +void Actor::faceXYZ(float x, float y, float z, bool animate) { + if (isWalking()) { + stopWalking(0); + } + if (x == _position.x && z == _position.z) { + return; + } + + int heading = int(512.0f * atan2f(_position.x - x, _position.z - z) / M_PI) % 1024; + faceHeading(heading, animate); +} + +void Actor::faceCurrentCamera(bool animate) { + faceXYZ(_vm->_view->_cameraPosition.x, _vm->_view->_cameraPosition.y, -_vm->_view->_cameraPosition.z, animate); +} + +void Actor::faceHeading(int heading, bool animate) { + if (heading != _facing) { + if (animate) { + _targetFacing = heading; + } + else { + setFacing(heading, true); + } + } +} + +int Actor::getFriendlinessToOther(int otherActorId) { + return _friendlinessToOther[otherActorId]; +} + +void Actor::modifyFriendlinessToOther(int otherActorId, signed int change) { + _friendlinessToOther[otherActorId] = MIN(MAX(_friendlinessToOther[otherActorId] + change, 0), 100); +} + +void Actor::setFriendlinessToOther(int otherActorId, int friendliness) { + _friendlinessToOther[otherActorId] = friendliness; +} + +void Actor::setHonesty(int honesty) { + _honesty = honesty; +} + +void Actor::setIntelligence(int intelligence) { + _intelligence = intelligence; +} + +void Actor::setStability(int stability) { + _stability = stability; +} + +void Actor::setCombatAggressiveness(int combatAggressiveness) { + _combatAggressiveness = combatAggressiveness; +} + +int Actor::getCurrentHP() { + return _currentHP; +} + +int Actor::getMaxHP() { + return _maxHP; +} + +int Actor::getCombatAggressiveness() { + return _combatAggressiveness; +} + +int Actor::getHonesty() { + return _honesty; +} + +int Actor::getIntelligence() { + return _intelligence; +} + +int Actor::getStability() { + return _stability; +} + +void Actor::modifyCurrentHP(signed int change) { + _currentHP = MIN(MAX(_currentHP + change, 0), 100); + if (_currentHP > 0) + retire(0, 0, 0, -1); +} + +void Actor::modifyMaxHP(signed int change) { + _maxHP = MIN(MAX(_maxHP + change, 0), 100); +} + +void Actor::modifyCombatAggressiveness(signed int change) { + _combatAggressiveness = MIN(MAX(_combatAggressiveness + change, 0), 100); +} + +void Actor::modifyHonesty(signed int change) { + _honesty = MIN(MAX(_honesty + change, 0), 100); +} + +void Actor::modifyIntelligence(signed int change) { + _intelligence = MIN(MAX(_intelligence + change, 0), 100); +} + +void Actor::modifyStability(signed int change) { + _stability = MIN(MAX(_stability + change, 0), 100); +} + +void Actor::setFlagDamageAnimIfMoving(bool value) { + _damageAnimIfMoving = value; +} + +bool Actor::getFlagDamageAnimIfMoving() { + return _damageAnimIfMoving; +} + +void Actor::retire(bool isRetired, int width, int height, int retiredByActorId) { + _isRetired = isRetired; + _retiredWidth = MAX(width, 0); + _retiredHeight = MAX(height, 0); + if(_id == 0 && isRetired) { + _vm->playerLosesControl(); + _vm->_playerDead = true; + } + if(isRetired) { + //TODO: _vm->actorScript->Retired(_id, retiredByActorId); + } +} } // End of namespace BladeRunner |