126 e.
add(
"Can't load module \"%s\"", module.
c_str());
138 hasXP |=
ConfigMan.getBool(
"NWN2_hasXP1") ? 1 : 0;
139 hasXP |=
ConfigMan.getBool(
"NWN2_hasXP2") ? 2 : 0;
140 hasXP |=
ConfigMan.getBool(
"NWN2_hasXP3") ? 4 : 0;
144 for (
int i = 0; i < 16; i++, xp >>= 1, hasXP >>= 1)
145 if ((xp & 1) && !(hasXP & 1))
146 throw Common::Exception(
"Module requires expansion %d and we don't have it", i + 1);
150 const std::vector<Common::UString> &haks =
_ifo.
getHAKs();
152 for (std::vector<Common::UString>::const_iterator h = haks.begin(); h != haks.end(); ++h)
153 if (!
ResMan.hasArchive(*h +
".hak"))
201 float entryX, entryY, entryZ, entryDirX, entryDirY;
205 const float entryAngle = -
Common::rad2deg(atan2(entryDirX, entryDirY));
219 if (!startMovie.
empty())
227 CameraMan.setPosition(entryX, entryY, entryZ + 1.8f);
228 CameraMan.setOrientation(90.0f, 0.0f, entryAngle);
283 if (area ==
_areas.end() || !area->second) {
325 if (now < action->timestamp)
330 action->owner, action->triggerer);
373 const std::vector<Common::UString> &haks =
_ifo.
getHAKs();
377 for (
size_t i = 0; i < haks.size(); i++)
382 std::vector<Common::ChangeID>::iterator hak;
390 status(
"Loading areas...");
392 const std::vector<Common::UString> &areas =
_ifo.
getAreas();
393 for (
size_t i = 0; i < areas.size(); i++) {
394 status(
"Loading area \"%s\" (%d / %d)", areas[i].c_str(), (
int)i, (
int)areas.size() - 1);
396 std::pair<AreaMap::iterator, bool> result;
398 result =
_areas.insert(std::make_pair(areas[i], (
Area *) 0));
403 result.first->second =
new Area(*
this, areas[i].c_str());
405 e.
add(
"Can't load area \"%s\"", areas[i].c_str());
451 AreaMap::iterator a =
_areas.find(area);
504 action.
state = state;
505 action.
owner = owner;
Handling version V3.2/V3.3 of BioWare's GFFs (generic file format).
#define ResMan
Shortcut for accessing the sound manager.
#define MKTAG(a0, a1, a2, a3)
A wrapper macro used around four character constants, like 'DATA', to ensure portability.
Creature * _pc
The player character we use.
bool isSave() const
Is the module a save file?
void playVideo(const Common::UString &video)
Play this video resource.
void unloadHAKs()
Unload the HAKs required by the module.
Generic Aurora engines resource utility functions.
void add(const char *s,...) GCC_PRINTF(2
Module(::Engines::Console &console)
bool isLoaded() const
Is a module currently loaded and ready to run?
#define TalkMan
Shortcut for accessing the talk manager.
const Common::UString & getTLK() const
Return the custom TLK table this module uses.
A class holding an UTF-8 string.
Area * getArea() const
Return the area this object is currently in.
The global config manager.
void leave()
Leave the running module, quitting it.
void unload()
Unload a currently loaded IFO.
An area in Neverwinter Nights 2, holding all objects, room tiles and terrain within, as well as general area properties like the current background music and ambient sounds.
bool _ranPCSpawn
Did we run the PC spawn script?
const Common::UString & getDescription() const
Return the object's description.
void delayScript(const Common::UString &script, const Aurora::NWScript::ScriptState &state, Aurora::NWScript::Object *owner, Aurora::NWScript::Object *triggerer, uint32 delay)
The context holding a Neverwinter Nights 2 area.
void addEvent(const Events::Event &event)
Add a single event for consideration into the event queue.
A simple streaming file reading class.
void loadAreas()
Load the areas.
void show()
Show the area.
void processEventQueue()
Process the current event queue.
const GFF3Struct & getTopLevel() const
Returns the top-level struct.
void unloadModule()
Unload the module.
const Common::UString & getName()
Return the area's localized name.
void getEntryDirection(float &x, float &y) const
Return the entry direction.
std::vector< Common::ChangeID > _resHAKs
Resources added by the HAKs of the module.
void loadModel()
Load the creature's model.
Common::UString _name
The object's display name.
An object within a NWN2 area.
void readVarTable(const Aurora::GFF3List &varTable)
Read the object's variable table.
Aurora::NWScript::ObjectReference triggerer
const Common::UString & getString(Language language, LanguageGender gender=kLanguageGenderCurrent) const
Get the string of that language.
Exception that provides a stack of explanations.
void load(const Common::UString &module)
Load a module.
void loadModule(const Common::UString &module)
Load the actual module.
Area * _currentArea
The current area.
void deindexResources(Common::ChangeID &changeID)
Remove previously added resources from the ResourceManager.
void addEvent(const Events::Event &event)
Add a single event for consideration into the area event queue.
bool operator<(const Action &s) const
The context needed to run a Neverwinter Nights 2 module.
const Common::UString & getName() const
Return the module's name.
const std::vector< Common::UString > & getHAKs() const
Return the list of required HAK files.
Basic exceptions to throw.
void load(Common::SeekableReadStream *stream, bool repairNWNPremium=false)
Take over this stream and load an IFO out of it.
A creature in a Neverwinter Nights 2 area.
void indexMandatoryArchive(const Common::UString &file, uint32 priority, const std::vector< byte > &password, Common::ChangeID *changeID)
const char * c_str() const
Return the (utf8 encoded) string data.
Aurora::NWScript::ScriptState state
void removeObject(NWN2::Object &object)
Remove an object from this container.
#define ConfigMan
Shortcut for accessing the config manager.
void readScripts(const Aurora::GFF3Struct &gff)
Utility templates and functions.
An IFO (module information) file, describing global module properties in many Aurora games...
void hide()
Hide the creature's model.
void loadHAKs()
Load the HAKs required by the module.
The global events manager.
A GFF (generic file format) V3.2/V3.3 file, found in all Aurora games except Sonic Chronicles: The Da...
void unload()
Unload the whole shebang.
void addObject(NWN2::Object &object)
Add an object to this container.
Handling BioWare's ERFs (encapsulated resource file).
bool _exit
Should we exit the module?
const std::vector< Common::UString > & getAreas() const
Return the list of areas in the module.
Common::UString _newArea
The new area to enter.
bool empty() const
Is the string empty?
void unloadTLK()
Unload the TLK used by the module.
Generic Aurora engines (debug) console.
Fake value for a module object.
const Common::UString & getResRef()
Return the area's resref (resource ID).
Common::UString _newModule
The module we should change to.
void movePC(const Common::UString &area)
Move the player character to this area.
void warning(const char *s,...)
virtual void enter()
The cursor entered the object.
const Common::UString & getName() const
Return the object's name.
void replaceModule()
Actually replace the currently running module.
#define EventMan
Shortcut for accessing the events manager.
void clear()
Clear the whole context.
Implementing the stream reading interfaces for files.
Common::ChangeID _resTLK
Resources added for the custom TLK.
void processEventQueue()
Process the current event queue.
void loadTLK()
Load the TLK used by the module.
Aurora::IFOFile _ifo
The module's IFO.
void unloadPC()
Unload the PC.
Class to hold resource data of an ERF archive file.
const GFF3Struct * getGFF() const
Return the IFO's GFF struct.
The global talk manager for Aurora strings.
AreaMap _areas
The areas in the current module.
const LocString & getName() const
Return the name of the module.
Area * getCurrentArea()
Return the area the PC is currently in.
void status(const char *s,...)
void unloadAreas()
Unload the areas.
virtual void getPosition(float &x, float &y, float &z) const
Return the object's position within its area.
void printf(const char *s,...) GCC_PRINTF(2
void show()
Show the creature's model.
bool _running
Are we currently running a module?
#define CameraMan
Shortcut for accessing the camera manager.
Common::UString getString(const Common::UString &field, const Common::UString &def="") const
bool isRunning() const
Is a module currently running?
static float rad2deg(float rad)
void setArea(Area *)
Set the area this object is currently in.
Generic Aurora engines utility functions.
::Engines::Console * _console
bool runScript(Script script, const Aurora::NWScript::ObjectReference owner=Aurora::NWScript::ObjectReference(), const Aurora::NWScript::ObjectReference triggerer=Aurora::NWScript::ObjectReference())
ActionQueue _delayedActions
bool _hasModule
Do we have a module?
Creature * getPC()
Return the currently playing PC.
void checkHAKs()
Do we have all HAKs needed for the module?
const Aurora::IFOFile & getIFO() const
Return the IFO of the currently loaded module.
const Common::UString & getTag() const
Return the module's tag.
uint16 getExpansions() const
Return the list of required expansions.
void getEntryPosition(float &x, float &y, float &z) const
Return the entry position.
void setOrientation(float x, float y, float z, float angle)
Set the creature's orientation.
const Common::UString & getDisplayName()
Return the area's localized display name.
const Common::UString & getEntryArea() const
Return the entry area.
Common::ChangeID _resModule
Resources added by the module.
Aurora::NWScript::ObjectReference owner
void clear()
Clear the string's contents.
void checkXPs()
Do we have all expansions needed for the module?
const Common::UString & getStartMovie() const
Return the starting movie.
void changeModule(const Common::UString &module)
Schedule a change to a new module.
const Common::UString & getDescription() const
Return the module's description.
void movedPC()
Notify the module that the PC was moved.
void setPosition(float x, float y, float z)
Set the creature's position.
The global resource manager for Aurora resources.
void hide()
Hide the area.
void enterArea()
Enter a new area.