diff options
author | uruk | 2014-06-07 19:44:16 +0200 |
---|---|---|
committer | uruk | 2014-06-07 19:44:16 +0200 |
commit | acb81c5e74ac2b54fc9b430d439389fb82233069 (patch) | |
tree | ab1b957a7771e2d3b958a82734f78963e8219e1f | |
parent | 23d40712c6c7af0977fe2d38751f922e30a8b3b6 (diff) | |
download | scummvm-rg350-acb81c5e74ac2b54fc9b430d439389fb82233069.tar.gz scummvm-rg350-acb81c5e74ac2b54fc9b430d439389fb82233069.tar.bz2 scummvm-rg350-acb81c5e74ac2b54fc9b430d439389fb82233069.zip |
CGE2: Fully implement caveUp().
Also implement connected parts of Hero.
-rw-r--r-- | engines/cge2/cge2_main.cpp | 16 | ||||
-rw-r--r-- | engines/cge2/hero.cpp | 51 |
2 files changed, 57 insertions, 10 deletions
diff --git a/engines/cge2/cge2_main.cpp b/engines/cge2/cge2_main.cpp index a37abbceed..a5456477c8 100644 --- a/engines/cge2/cge2_main.cpp +++ b/engines/cge2/cge2_main.cpp @@ -368,9 +368,19 @@ void CGE2Engine::caveUp(int cav) { _spare->takeCave(_now); openPocket(); - warning("STUB: CGE2Engine::caveUp()"); - // TODO: Implement "Hero" things here! - + for (int i = 0; i < 2; i++) { + Hero *h = _heroTab[i]->_ptr; + if (h && h->_scene == _now) { + V2D p = *_heroTab[i]->_posTab[_now]; + h->gotoxyz(V3D(p.x, 0, p.y)); + h->clrHide(); + _vga->_showQ->insert(h); + h->park(); + h->setCurrent(); + h->setContact(); + } + } + _sound->stop(); _fx->clear(); diff --git a/engines/cge2/hero.cpp b/engines/cge2/hero.cpp index 04ff05ce93..3e22d72942 100644 --- a/engines/cge2/hero.cpp +++ b/engines/cge2/hero.cpp @@ -222,8 +222,19 @@ void Hero::hStep() { } Sprite *Hero::setContact() { - warning("STUB: Hero::setContact()"); - return this; + Sprite *spr; + int md = _maxDist << 1; + for (spr = _vm->_vga->_showQ->first(); spr; spr = spr->_next) { + if (spr->_actionCtrl[kNear]._cnt && (spr->_ref & 255) != 255) { + if (distance(spr) <= md) { + if (spr == _contact) + return nullptr; + else + break; + } + } + } + return (_contact = spr); } void Hero::tick() { @@ -231,13 +242,29 @@ void Hero::tick() { } int Hero::distance(V3D pos) { - warning("STUB: Hero::distance()"); - return 0; + V3D di = _pos3D - pos; + long x = V2D::round(di._x); + long z = V2D::round(di._z); + return ((x * x + z * z) * (x * x + z * z)); } int Hero::distance(Sprite *spr) { - warning("STUB: Hero::distance()"); - return 0; + V3D pos = spr->_pos3D; + int mdx = (spr->_siz.x >> 1) + (_siz.x >> 1); + int dx = V2D::round(_pos3D._x - spr->_pos3D._x); + if (dx < 0) { + mdx = -mdx; + if (dx > mdx) + pos._x = _pos3D._x; + else + pos._x += mdx; + } else { + if (dx < mdx) + pos._x = _pos3D._x; + else + pos._x += mdx; + } + return distance(pos); } void Hero::turn(Dir d) { @@ -245,7 +272,17 @@ void Hero::turn(Dir d) { } void Hero::park() { - warning("STUB: Hero::park()"); + if (_dir != kNoDir) { + step(8 + 5 * _dir); + _dir = kNoDir; + _trace[0] = _pos3D; + _tracePtr = -1; + setCurrent(); + _flags._zmov = true; + } + _ignoreMap = false; + if (_time == 0) + ++_time; } bool Hero::lower(Sprite * spr) { |