[Scummvm-git-logs] scummvm master -> 128ee5ea9764ae52e6372ea0be1986362728ac1c
mduggan
mgithub at guarana.org
Fri Jun 26 06:18:34 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
128ee5ea97 ULTIMA8: Implement surrender process
Commit: 128ee5ea9764ae52e6372ea0be1986362728ac1c
https://github.com/scummvm/scummvm/commit/128ee5ea9764ae52e6372ea0be1986362728ac1c
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2020-06-26T15:18:23+09:00
Commit Message:
ULTIMA8: Implement surrender process
Changed paths:
A engines/ultima/ultima8/world/actors/surrender_process.cpp
A engines/ultima/ultima8/world/actors/surrender_process.h
engines/ultima/module.mk
engines/ultima/ultima8/world/actors/actor.cpp
engines/ultima/ultima8/world/actors/animation.h
diff --git a/engines/ultima/module.mk b/engines/ultima/module.mk
index 0a9ca13870..96ebd7b901 100644
--- a/engines/ultima/module.mk
+++ b/engines/ultima/module.mk
@@ -564,6 +564,7 @@ MODULE_OBJS := \
ultima8/world/actors/quick_avatar_mover_process.o \
ultima8/world/actors/resurrection_process.o \
ultima8/world/actors/scheduler_process.o \
+ ultima8/world/actors/surrender_process.o \
ultima8/world/actors/targeted_anim_process.o \
ultima8/world/actors/teleport_to_egg_process.o
diff --git a/engines/ultima/ultima8/world/actors/actor.cpp b/engines/ultima/ultima8/world/actors/actor.cpp
index e1486e0607..88ae4ae711 100644
--- a/engines/ultima/ultima8/world/actors/actor.cpp
+++ b/engines/ultima/ultima8/world/actors/actor.cpp
@@ -47,6 +47,7 @@
#include "ultima/ultima8/graphics/shape.h"
#include "ultima/ultima8/world/actors/loiter_process.h"
#include "ultima/ultima8/world/actors/combat_process.h"
+#include "ultima/ultima8/world/actors/surrender_process.h"
#include "ultima/ultima8/audio/audio_process.h"
#include "ultima/ultima8/world/sprite_process.h"
#include "ultima/ultima8/world/actors/main_actor.h"
@@ -584,8 +585,7 @@ uint16 Actor::setActivityCru(int activity) {
// Does nothing in game..
break;
case 7:
- perr << "Actor::setActivityCru TODO: Implement new SurrenderProcess(this);" << Std::endl;
- return Kernel::get_instance()->addProcess(new LoiterProcess(this));
+ return Kernel::get_instance()->addProcess(new SurrenderProcess(this));
break;
case 8:
perr << "Actor::setActivityCru TODO: Implement new GuardProcess(this);" << Std::endl;
diff --git a/engines/ultima/ultima8/world/actors/animation.h b/engines/ultima/ultima8/world/actors/animation.h
index c37a808ef1..3e6f7169cd 100644
--- a/engines/ultima/ultima8/world/actors/animation.h
+++ b/engines/ultima/ultima8/world/actors/animation.h
@@ -110,7 +110,8 @@ enum Sequence {
stopRunningAndDrawWeapon = 39,
kneelAndFire2 = 42,
kneelAndFire3 = 43,
- runWithLargeWeapon = 50
+ runWithLargeWeapon = 50,
+ surrender = 57
};
enum Result {
diff --git a/engines/ultima/ultima8/world/actors/surrender_process.cpp b/engines/ultima/ultima8/world/actors/surrender_process.cpp
new file mode 100644
index 0000000000..329b4dfbaa
--- /dev/null
+++ b/engines/ultima/ultima8/world/actors/surrender_process.cpp
@@ -0,0 +1,132 @@
+/* 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 "ultima/ultima8/misc/pent_include.h"
+#include "ultima/ultima8/audio/audio_process.h"
+#include "ultima/ultima8/world/actors/surrender_process.h"
+#include "ultima/ultima8/world/actors/actor.h"
+#include "ultima/ultima8/world/actors/main_actor.h"
+#include "ultima/ultima8/world/actors/actor_anim_process.h"
+#include "ultima/ultima8/kernel/kernel.h"
+#include "ultima/ultima8/kernel/delay_process.h"
+#include "ultima/ultima8/kernel/core_app.h"
+#include "ultima/ultima8/world/get_object.h"
+
+namespace Ultima {
+namespace Ultima8 {
+
+// p_dynamic_cast stuff
+DEFINE_RUNTIME_CLASSTYPE_CODE(SurrenderProcess)
+
+static const uint16 SUIT_SUR_SNDS[] = {0xe9, 0xe0, 0xeb, 0xe1, 0xea};
+static const uint16 CHEMSUIT_SUR_SNDS[] = {0xb4, 0xc5, 0xc6, 0xe8};
+static const uint16 SCIENTIST_SUR_SNDS[] = {0xe3, 0xe4, 0xec, 0xf6};
+static const uint16 HARDHAT_SUR_SNDS[] = {0xde, 0xdf, 0x8a, 0x8b};
+static const uint16 FEMALE_SUR_SNDS[] = {0xd6, 0xff, 0xd7};
+
+static const uint16 NUM_SUIT_SUR_SNDS = 5;
+static const uint16 NUM_CHEMSUIT_SUR_SNDS = 4;
+static const uint16 NUM_SCIENTIST_SUR_SNDS = 4;
+static const uint16 NUM_HARDHAT_SUR_SNDS = 4;
+static const uint16 NUM_FEMALE_SUR_SNDS = 3;
+
+SurrenderProcess::SurrenderProcess() : Process(), _playedSound(false) {
+}
+
+SurrenderProcess::SurrenderProcess(Actor *actor) : _playedSound(false) {
+ assert(actor);
+ _itemNum = actor->getObjId();
+
+ actor->doAnim(Animation::surrender, actor->getDir());
+
+ _type = 0x25f; // CONSTANT!
+}
+
+void SurrenderProcess::run() {
+ Actor *a = getActor(_itemNum);
+ MainActor *main = getMainActor();
+ if (!a || a->isDead() || !main) {
+ // dead?
+ terminate();
+ return;
+ }
+
+ int animating = Kernel::get_instance()->getNumProcesses(_itemNum, ActorAnimProcess::ACTOR_ANIM_PROC_TYPE);
+ if (animating) {
+ // already busy.
+ return;
+ }
+
+ int16 curdir = a->getDir();
+ int16 direction = a->getDirToItemCentre(*main);
+
+ if (curdir != direction) {
+ int stepDelta;
+ Animation::Sequence turnanim;
+ if ((curdir - direction + 8) % 8 < 4) {
+ stepDelta = -1;
+ turnanim = Animation::lookLeft;
+ } else {
+ stepDelta = 1;
+ turnanim = Animation::lookRight;
+ }
+ ProcId animpid = a->doAnim(turnanim, curdir + stepDelta);
+ waitFor(animpid);
+ return;
+ }
+
+ if (_playedSound || a->getRangeIfVisible(*main) == 0)
+ return;
+
+ int16 soundno = -1;
+
+ switch (a->getShape()) {
+ case 0x2f7: // suit
+ soundno = SUIT_SUR_SNDS[getRandom() % NUM_SUIT_SUR_SNDS];
+ case 0x2f5: // hardhat
+ soundno = HARDHAT_SUR_SNDS[getRandom() % NUM_HARDHAT_SUR_SNDS];
+ case 0x2f6: // chemsuit
+ soundno = CHEMSUIT_SUR_SNDS[getRandom() % NUM_CHEMSUIT_SUR_SNDS];
+ case 0x344: // chemsuit
+ soundno = SCIENTIST_SUR_SNDS[getRandom() % NUM_SCIENTIST_SUR_SNDS];
+ case 0x597: // female office worker
+ soundno = FEMALE_SUR_SNDS[getRandom() % NUM_FEMALE_SUR_SNDS];
+ }
+
+ AudioProcess *audio = AudioProcess::get_instance();
+ if (audio)
+ audio->playSFX(soundno, 0x80, _itemNum, 1);
+}
+
+void SurrenderProcess::saveData(Common::WriteStream *ws) {
+ Process::saveData(ws);
+ ws->writeByte(_playedSound ? 1 : 0);
+}
+
+bool SurrenderProcess::loadData(Common::ReadStream *rs, uint32 version) {
+ if (!Process::loadData(rs, version)) return false;
+ _playedSound = rs->readByte() != 0;
+ return true;
+}
+
+} // End of namespace Ultima8
+} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/world/actors/surrender_process.h b/engines/ultima/ultima8/world/actors/surrender_process.h
new file mode 100644
index 0000000000..7dbcab8daa
--- /dev/null
+++ b/engines/ultima/ultima8/world/actors/surrender_process.h
@@ -0,0 +1,53 @@
+/* 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 WORLD_ACTORS_SURRENDERPROCESS_H
+#define WORLD_ACTORS_SURRENDERPROCESS_H
+
+#include "ultima/ultima8/kernel/process.h"
+
+namespace Ultima {
+namespace Ultima8 {
+
+class Actor;
+
+class SurrenderProcess : public Process {
+public:
+ SurrenderProcess();
+ SurrenderProcess(Actor *actor);
+
+ // p_dynamic_cast stuff
+ ENABLE_RUNTIME_CLASSTYPE()
+
+ void run() override;
+
+ bool loadData(Common::ReadStream *rs, uint32 version);
+ void saveData(Common::WriteStream *ws) override;
+
+protected:
+ bool _playedSound;
+};
+
+} // End of namespace Ultima8
+} // End of namespace Ultima
+
+#endif
More information about the Scummvm-git-logs
mailing list