ULTIMA8: Add Crusader fire type data

This commit is contained in:
Matthew Duggan 2020-07-20 14:33:20 +09:00
parent bd642b73ca
commit 84eebe3e7d
7 changed files with 368 additions and 8 deletions

View File

@ -533,6 +533,8 @@ MODULE_OBJS := \
ultima8/world/egg.o \
ultima8/world/egg_hatcher_process.o \
ultima8/world/fireball_process.o \
ultima8/world/fire_type.o \
ultima8/world/fire_type_table.o \
ultima8/world/get_object.o \
ultima8/world/glob_egg.o \
ultima8/world/gravity_process.o \

View File

@ -31,6 +31,7 @@
#include "ultima/ultima8/graphics/fonts/font_shape_archive.h"
#include "ultima/ultima8/graphics/gump_shape_archive.h"
#include "ultima/ultima8/world/map_glob.h"
#include "ultima/ultima8/world/fire_type_table.h"
#include "ultima/ultima8/world/actors/npc_dat.h"
#include "ultima/ultima8/world/actors/combat_dat.h"
#include "ultima/ultima8/graphics/palette_manager.h"
@ -503,6 +504,10 @@ const CombatDat *GameData::getCombatDat(uint16 entry) const {
return nullptr;
}
const FireType *GameData::getFireType(uint16 type) const {
return FireTypeTable::get(type);
}
void GameData::loadRemorseData() {
FileSystem *filesystem = FileSystem::get_instance();
@ -655,14 +660,6 @@ void GameData::loadRemorseData() {
}
delete combatflexrs;
}
// TODO: What's in this flex file? Descriptions of combat tactics?
// 14 objects with contents:
// [ 16 Byte Name ]
// [ 4 * 16 bit numbers, alway 44, xx, 77, 78 ]
// [ 20 bytes of 0s ]
// [ variable number of bytes of data ]
//_combat = new CombatDat();
//_combat->load(combatflex);
delete combatflex;

View File

@ -41,6 +41,7 @@ class MusicFlex;
class WpnOvlayDat;
class NPCDat;
class CombatDat;
class FireType;
class ShapeFrame;
class SoundFlex;
class SpeechFlex;
@ -98,6 +99,8 @@ public:
const CombatDat *getCombatDat(uint16 entry) const;
const FireType *getFireType(uint16 type) const;
Std::string translate(const Std::string &text);
FrameID translate(FrameID frame);

View File

@ -0,0 +1,156 @@
/* 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/world/sprite_process.h"
#include "ultima/ultima8/world/fire_type.h"
#include "ultima/ultima8/kernel/kernel.h"
#include "ultima/ultima8/audio/audio_process.h"
namespace Ultima {
namespace Ultima8 {
FireType::FireType(uint16 typeNo, uint16 minDamage, uint16 maxDamage, uint8 range,
uint8 numShots, uint16 shieldCost, uint8 shieldMask, uint8 accurate,
uint16 cellsPerRound, uint16 roundDuration, uint8 nearSprite) :
_typeNo(typeNo), _minDamage(minDamage), _maxDamage(maxDamage),
_range(range), _numShots(numShots), _shieldCost(shieldCost),
_shieldMask(shieldMask), _accurate(accurate),
_cellsPerRound(cellsPerRound), _roundDuration(roundDuration),
_nearSprite(nearSprite) {
}
uint16 FireType::getRandomDamage() const {
return _minDamage + (getRandom() % (_maxDamage - _minDamage));
}
// TODO: This is all hard coded values for No Remorse. These should probably
// be moved into ini file settings so that it can be swapped out for No Regret.
static const int16 FIRESOUND_1[] = { 0x26, 0x27, 0x41, 0x42, 0x45, 0x46 };
static const int16 FIRESOUND_3[] = { 0x1c, 0x6c, 0x3e };
static const int16 FIRESOUND_7[] = { 0x48, 0x5 };
static const int16 FIRESHAPE_3[] = { 0x326, 0x320, 0x321 };
static const int16 FIRESHAPE_10[] = { 0x31c, 0x31f, 0x322 };
void FireType::makeBulletSplashShapeAndPlaySound(int32 x, int32 y, int32 z) const {
int16 sfxno = 0;
int16 shape = 0;
// First randomize the sprite and sound
switch (_typeNo) {
case 1:
case 0xb:
shape = 0x1d8;
sfxno = FIRESOUND_1[getRandom() % 6];
break;
case 2:
shape = 0x1d8;
break;
case 3:
case 4:
shape = FIRESHAPE_3[getRandom() % 3];
sfxno = FIRESOUND_3[getRandom() % 3];
break;
case 5:
shape = 0x573;
break;
case 6:
shape = 0x578;
break;
case 7:
shape = 0x537;
sfxno = FIRESOUND_7[getRandom() % 2];
break;
case 10:
shape = FIRESHAPE_10[getRandom() % 3];
sfxno = FIRESOUND_3[getRandom() % 3];
break;
case 0xd:
shape = 0x1d8;
sfxno = FIRESOUND_1[getRandom() % 6];
break;
case 0xe:
shape = 0x56b;
break;
case 0xf:
shape = 0x59b;
sfxno = FIRESOUND_7[getRandom() % 2];
break;
case 9:
default:
shape = 0x537;
break;
}
int16 firstframe = 0;
int16 lastframe = 0x27;
// now randomize frames
switch (shape) {
case 0x56b:
firstframe = (getRandom() % 3) * 6;
lastframe = firstframe + 5;
break;
case 0x537:
lastframe = 10;
case 0x578:
firstframe = (getRandom() % 3) * 6;
lastframe = firstframe + 4;
case 0x59b:
firstframe = (getRandom() % 2) * 4;
lastframe = firstframe + 3;
case 0x1d8: {
switch (getRandom() % 4) {
case 0:
lastframe = 4;
break;
case 1:
firstframe = 5;
lastframe = 8;
break;
case 2:
firstframe = 9;
lastframe = 0xc;
break;
case 3:
firstframe = 0xd;
lastframe = 0x10;
break;
}
break;
}
}
SpriteProcess *sprite = new SpriteProcess(shape, firstframe, lastframe, 1, 3, x, y, z);
Kernel::get_instance()->addProcess(sprite);
AudioProcess *audio = AudioProcess::get_instance();
if (sfxno && audio) {
audio->playSFX(sfxno, 0x10, 0, 1, false);
}
}
}
}

View File

@ -0,0 +1,103 @@
/* 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 ULTIMA8_WORLD_FIRETYPE_H
#define ULTIMA8_WORLD_FIRETYPE_H
namespace Ultima {
namespace Ultima8 {
/**
* A structure to hold data about the fire that comes from various weapons
*/
class FireType {
public:
FireType(uint16 typeNo, uint16 minDamage, uint16 maxDamage, uint8 range,
uint8 numShots, uint16 shieldCost, uint8 shieldMask, uint8 accurate,
uint16 cellsPerRound, uint16 roundDuration, uint8 nearSprite);
uint16 getTypeNo() const {
return _typeNo;
}
uint16 getMinDamage() const {
return _minDamage;
}
uint16 getMaxDamage() const {
return _maxDamage;
}
uint8 getRange() const {
return _range;
}
uint8 getNumShots() const {
return _numShots;
}
uint16 getShieldCost() const {
return _shieldCost;
}
uint8 getShieldMask() const {
return _shieldMask;
}
uint8 getAccurate() const {
return _accurate;
}
uint16 getCellsPerRound() const {
return _cellsPerRound;
}
uint16 getRoundDuration() const {
return _roundDuration;
}
uint8 getNearSprite() const {
return _nearSprite;
}
uint16 getRandomDamage() const;
void makeBulletSplashShapeAndPlaySound(int32 x, int32 y, int32 z) const;
private:
uint16 _typeNo;
uint16 _minDamage;
uint16 _maxDamage;
uint8 _range;
uint8 _numShots;
uint16 _shieldCost;
uint8 _shieldMask;
uint8 _accurate;
uint16 _cellsPerRound;
uint16 _roundDuration;
uint8 _nearSprite;
};
}
}
#endif

View File

@ -0,0 +1,60 @@
/* 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/world/fire_type_table.h"
#include "ultima/ultima8/world/fire_type.h"
namespace Ultima {
namespace Ultima8 {
static FireType FIRE_TYPE_TABLE_REM[] = {
// Extracted from CRUSADER.EXE 1478:252a
FireType(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0),
FireType(0x1, 0x12, 0x19, 0x0, 0x1, 0x82, 0x7, 0x0, 0xc, 0x3e8, 0x0),
FireType(0x2, 0xa, 0x11, 0x0, 0x8, 0x50, 0x7, 0x0, 0xc, 0x3e8, 0x0),
FireType(0x3, 0xc8, 0xc8, 0xa, 0x1, 0x0, 0x0, 0x1, 0x3, 0x3e8, 0x1),
FireType(0x4, 0x96, 0x96, 0xa, 0x1, 0x0, 0x0, 0x0, 0x1, 0x3e8, 0x1),
FireType(0x5, 0x19, 0x2d, 0x0, 0x1, 0x190, 0x6, 0x0, 0x4, 0x3e8, 0x1),
FireType(0x6, 0xf, 0x23, 0x0, 0x1, 0x177, 0x6, 0x1, 0x4, 0x3e8, 0x1),
FireType(0x7, 0x5, 0x5, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x3e8, 0x1),
FireType(0x8, 0x5, 0x5, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x3e8, 0x0),
FireType(0x9, 0xa, 0xf, 0x0, 0x1, 0x12c, 0x6, 0x1, 0x1, 0x64, 0x1),
FireType(0xa, 0x2d, 0x50, 0xa, 0x3, 0x0, 0x0, 0x0, 0x3, 0x64, 0x1),
FireType(0xb, 0xe, 0x14, 0x0, 0x1, 0x50, 0x7, 0x0, 0xc, 0x3e8, 0x0),
FireType(0xc, 0x5, 0x5, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x3e8, 0x0),
FireType(0xd, 0xa, 0x11, 0x0, 0x5, 0x50, 0x7, 0x0, 0xc, 0x3e8, 0x0),
FireType(0xe, 0xfa, 0xfa, 0x4, 0x1, 0x9c4, 0x4, 0x1, 0x3, 0x3e8, 0x1),
FireType(0xf, 0x23, 0x37, 0x4, 0x1, 0x2ee, 0x4, 0x0, 0x3, 0x3e8, 0x1),
};
static const int FIRE_TYPE_TABLE_LEN = 16;
const FireType *FireTypeTable::get(uint16 type) {
if (type >= FIRE_TYPE_TABLE_LEN)
return nullptr;
return &FIRE_TYPE_TABLE_REM[type];
}
} // End of namespace Ultima8
} // End of namespace Ultima

View File

@ -0,0 +1,39 @@
/* 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 ULTIMA8_WORLD_FIRETYPETABLE_H
#define ULTIMA8_WORLD_FIRETYPETABLE_H
namespace Ultima {
namespace Ultima8 {
class FireType;
class FireTypeTable {
public:
static const FireType *get(uint16 firetype);
};
}
}
#endif