-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
282 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* xoreos - A reimplementation of BioWare's Aurora engine | ||
* | ||
* xoreos is the legal property of its developers, whose names | ||
* can be found in the AUTHORS file distributed with this source | ||
* distribution. | ||
* | ||
* xoreos 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 3 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* xoreos 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 xoreos. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/** @file | ||
* An item in a Neverwinter Nights 2 area. | ||
*/ | ||
|
||
#include "src/common/scopedptr.h" | ||
|
||
#include "src/aurora/gff3file.h" | ||
|
||
#include "src/engines/aurora/util.h" | ||
|
||
#include "src/engines/nwn2/item.h" | ||
|
||
namespace Engines { | ||
|
||
namespace NWN2 { | ||
|
||
Item::Item(const Aurora::GFF3Struct &item) : Object(kObjectTypeItem), | ||
_stackSize(1), _droppable(true), _identified(true), _pickpocketable(true) { | ||
|
||
load(item); | ||
} | ||
|
||
Item::~Item() { | ||
} | ||
|
||
void Item::load(const Aurora::GFF3Struct &item) { | ||
Common::UString temp = item.getString("TemplateResRef"); | ||
|
||
Common::ScopedPtr<Aurora::GFF3File> uti; | ||
if (!temp.empty()) | ||
uti.reset(loadOptionalGFF3(temp, Aurora::kFileTypeUTD, MKTAG('U', 'T', 'I', ' '))); | ||
|
||
load(item, uti ? &uti->getTopLevel() : 0); | ||
} | ||
|
||
void Item::load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint) { | ||
|
||
if (blueprint) | ||
loadProperties(*blueprint); // Blueprint | ||
loadProperties(instance); // Instance | ||
} | ||
|
||
void Item::loadProperties(const Aurora::GFF3Struct &gff) { | ||
|
||
// Object properties | ||
_tag = gff.getString("Tag", _tag); | ||
_name = gff.getString("LocalizedName", _name); | ||
_description = gff.getString("Description", _description); | ||
|
||
// Item properties | ||
_icon = gff.getUint("Icon", _icon); | ||
_cost = gff.getUint("Cost", _cost); | ||
_modifyCost = gff.getSint("ModifyCost", _modifyCost); | ||
_baseItem = (ItemType) gff.getUint("BaseItem", (uint) _baseItem); | ||
_stackSize = gff.getUint("StackSize", _stackSize); | ||
|
||
// Booleans | ||
_plot = gff.getBool("Plot", _plot); | ||
_cursed = gff.getBool("Cursed", _cursed); | ||
_stolen = gff.getBool("Stolen", _stolen); | ||
_droppable = gff.getBool("Dropable", _droppable); | ||
_identified = gff.getBool("Identified", _identified); | ||
_pickpocketable = gff.getBool("Pickpocketable", _pickpocketable); | ||
} | ||
|
||
} // End of namespace NWN2 | ||
|
||
} // End of namespace Engines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* xoreos - A reimplementation of BioWare's Aurora engine | ||
* | ||
* xoreos is the legal property of its developers, whose names | ||
* can be found in the AUTHORS file distributed with this source | ||
* distribution. | ||
* | ||
* xoreos 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 3 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* xoreos 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 xoreos. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/** @file | ||
* An item in a Neverwinter Nights 2 area. | ||
*/ | ||
|
||
#ifndef ENGINES_NWN2_ITEM_H | ||
#define ENGINES_NWN2_ITEM_H | ||
|
||
#include "src/engines/nwn2/types.h" | ||
#include "src/engines/nwn2/object.h" | ||
|
||
namespace Engines { | ||
|
||
namespace NWN2 { | ||
|
||
class Item : public Object { | ||
public: | ||
Item(const Aurora::GFF3Struct &item); | ||
~Item(); | ||
|
||
private: | ||
uint32 _icon; ///< Icon number for inventory UI. | ||
uint32 _cost; ///< Base price in gp. | ||
int32 _modifyCost; ///< Adjustment to price in gp. | ||
uint16 _stackSize; ///< Stack size. | ||
ItemType _baseItem; ///< Base item type. | ||
|
||
bool _plot; ///< Is this a plot item? | ||
bool _cursed; ///< Is the item cursed? | ||
bool _stolen; ///< Was the item stolen? | ||
bool _droppable; ///< Is the item dropped as loot? | ||
bool _identified; ///< Have the item's properties been identified? | ||
bool _pickpocketable; ///< Can the item be pick-pocketed? | ||
|
||
/* Load from an item instance. */ | ||
void load(const Aurora::GFF3Struct &item); | ||
void load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint); | ||
void loadProperties(const Aurora::GFF3Struct &gff); | ||
}; | ||
|
||
} // End of namespace NWN2 | ||
|
||
} // End of namespace Engines | ||
|
||
#endif // ENGINES_NWN2_ITEM_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters