aboutsummaryrefslogtreecommitdiff
path: root/engines/lastexpress/fight/fighter_milos.cpp
diff options
context:
space:
mode:
authorLittleboy2011-06-22 02:20:15 -0400
committerLittleboy2011-06-22 19:31:32 -0400
commit434a2e66b1fc59e1b7732591cfefd7e389905817 (patch)
tree7af6d4f7f39bd908c8771d33f1dd93211f3b7273 /engines/lastexpress/fight/fighter_milos.cpp
parent3c2a9b292f5a851529fb0196eab662fd9996a459 (diff)
downloadscummvm-rg350-434a2e66b1fc59e1b7732591cfefd7e389905817.tar.gz
scummvm-rg350-434a2e66b1fc59e1b7732591cfefd7e389905817.tar.bz2
scummvm-rg350-434a2e66b1fc59e1b7732591cfefd7e389905817.zip
LASTEXPRESS: Refactor Fight class
- Replace structs holding function pointers by proper classes - Move each fighter functions to separate files
Diffstat (limited to 'engines/lastexpress/fight/fighter_milos.cpp')
-rw-r--r--engines/lastexpress/fight/fighter_milos.cpp221
1 files changed, 221 insertions, 0 deletions
diff --git a/engines/lastexpress/fight/fighter_milos.cpp b/engines/lastexpress/fight/fighter_milos.cpp
new file mode 100644
index 0000000000..46e4bde7a6
--- /dev/null
+++ b/engines/lastexpress/fight/fighter_milos.cpp
@@ -0,0 +1,221 @@
+/* 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 "lastexpress/fight/fighter_milos.h"
+
+#include "lastexpress/data/cursor.h"
+#include "lastexpress/data/sequence.h"
+
+#include "lastexpress/game/sound.h"
+
+#include "lastexpress/helpers.h"
+#include "lastexpress/lastexpress.h"
+#include "lastexpress/resource.h"
+
+namespace LastExpress {
+
+//////////////////////////////////////////////////////////////////////////
+// Player
+//////////////////////////////////////////////////////////////////////////
+FighterPlayerMilos::FighterPlayerMilos(LastExpressEngine *engine) : Fighter(engine) {
+ _sequences.push_back(loadSequence("2001cr.seq"));
+ _sequences.push_back(loadSequence("2001cdl.seq"));
+ _sequences.push_back(loadSequence("2001cdr.seq"));
+ _sequences.push_back(loadSequence("2001cdm.seq"));
+ _sequences.push_back(loadSequence("2001csgr.seq"));
+ _sequences.push_back(loadSequence("2001csgl.seq"));
+ _sequences.push_back(loadSequence("2001dbk.seq"));
+}
+
+void FighterPlayerMilos::handleAction(FightAction action) {
+ switch (action) {
+ default:
+ Fighter::handleAction(action);
+ return;
+
+ case kFightAction1:
+ if (_sequenceIndex != 1 || checkFrame(4)) {
+ setSequenceAndDraw(6, kFightSequenceType1);
+ _opponent->setSequenceAndDraw(3, kFightSequenceType1);
+
+ _opponent->handleAction(kFightAction103);
+ update();
+ } else {
+ _field_34++;
+ }
+ break;
+
+ case kFightAction2:
+ if ((_sequenceIndex != 2 && _sequenceIndex != 3) || checkFrame(4)) {
+ setSequenceAndDraw(6, kFightSequenceType1);
+ _opponent->setSequenceAndDraw(4, kFightSequenceType1);
+
+ _opponent->handleAction(kFightAction103);
+ update();
+ } else {
+ _field_34++;
+ }
+ break;
+
+ case kFightAction128:
+ if (_sequenceIndex != 1 || checkFrame(4) || _opponent->getSequenceIndex() != 1) {
+ switch (_opponent->getSequenceIndex()) {
+ default:
+ setSequenceAndDraw(rnd(3) + 1, kFightSequenceType0);
+ break;
+
+ case 1:
+ setSequenceAndDraw(1, kFightSequenceType0);
+ break;
+
+ case 2:
+ setSequenceAndDraw(3, kFightSequenceType0);
+ break;
+ }
+ } else {
+ setSequenceAndDraw(4, kFightSequenceType1);
+ update();
+ }
+ break;
+ }
+}
+
+void FighterPlayerMilos::update() {
+ if (_frame && checkFrame(2)) {
+
+ // Draw sequences
+ if (_opponent->getCountdown() <= 0) {
+ setSequenceAndDraw(5, kFightSequenceType1);
+ _opponent->setSequenceAndDraw(6, kFightSequenceType1);
+
+ getSound()->removeFromQueue(kEntityTables0);
+ getSound()->playSound(kEntityTrain, "MUS029", SoundManager::kFlagDefault);
+
+ handleAction(kFightActionWin);
+ }
+
+ if (_sequenceIndex == 4) {
+ _opponent->handleAction(kFightAction4);
+ _fight->setEndType(Fight::kFightEndLost);
+ }
+ }
+
+ Fighter::update();
+}
+
+bool FighterPlayerMilos::canInteract(FightAction action) {
+ if (action != kFightAction128
+ || _sequenceIndex != 1
+ || !_frame
+ || checkFrame(4)
+ || _opponent->getSequenceIndex() != 1) {
+ return Fighter::canInteract();
+ }
+
+ _engine->getCursor()->setStyle(kCursorHand);
+
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Opponent
+//////////////////////////////////////////////////////////////////////////
+FighterOpponentMilos::FighterOpponentMilos(LastExpressEngine *engine) : Opponent(engine) {
+ _sequences.push_back(loadSequence("2001or.seq"));
+ _sequences.push_back(loadSequence("2001oal.seq"));
+ _sequences.push_back(loadSequence("2001oam.seq"));
+ _sequences.push_back(loadSequence("2001okl.seq"));
+ _sequences.push_back(loadSequence("2001okm.seq"));
+ _sequences.push_back(loadSequence("2001dbk.seq"));
+ _sequences.push_back(loadSequence("2001wbk.seq"));
+
+ getSound()->playSound(kEntityTables0, "MUS027", SoundManager::kFlagDefault);
+
+ _field_38 = 35;
+}
+
+void FighterOpponentMilos::handleAction(FightAction action) {
+ if (action == kFightAction4) {
+ setSequenceAndDraw(5, kFightSequenceType1);
+ _opponent->handleAction(kFightAction103);
+ } else {
+ if (action != kFightAction131)
+ Fighter::handleAction(action);
+ }
+}
+
+void FighterOpponentMilos::update() {
+ if (!_field_38 && canInteract(kFightAction1) && !_sequenceIndex2) {
+
+ if (_opponent->getField34() >= 2) {
+ switch (rnd(5)) {
+ default:
+ break;
+
+ case 0:
+ setSequenceAndDraw(1, kFightSequenceType0);
+ break;
+
+ case 1:
+ setSequenceAndDraw(2, kFightSequenceType0);
+ break;
+
+ case 2:
+ setSequenceAndDraw(2, kFightSequenceType0);
+ setSequenceAndDraw(2, kFightSequenceType1);
+ break;
+
+ case 3:
+ setSequenceAndDraw(1, kFightSequenceType0);
+ setSequenceAndDraw(2, kFightSequenceType2);
+ break;
+
+ case 4:
+ setSequenceAndDraw(1, kFightSequenceType0);
+ setSequenceAndDraw(1, kFightSequenceType2);
+ break;
+ }
+ } else {
+ setSequenceAndDraw(2, kFightSequenceType0);
+ }
+
+ // Update field_38
+ if (_opponent->getField34() < 5)
+ _field_38 = 6 * (5 - _opponent->getField34());
+ else
+ _field_38 = 0;
+ }
+
+ if (_frame && checkFrame(2)) {
+ if (_sequenceIndex == 1 || _sequenceIndex == 2)
+ _opponent->handleAction((FightAction)_sequenceIndex);
+
+ if (_opponent->getCountdown() <= 0) {
+ getSound()->removeFromQueue(kEntityTables0);
+ handleAction(kFightActionLost);
+ }
+ }
+
+ Fighter::update();
+}
+
+} // End of namespace LastExpress