Skip to content

Commit

Permalink
NWN2: Load trap information from the traps.2da file
Browse files Browse the repository at this point in the history
  • Loading branch information
rjshae authored and DrMcCoy committed Nov 23, 2018
1 parent da3f846 commit 395112d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/engines/nwn2/trap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
*/

#include "src/aurora/gff3file.h"
#include "src/aurora/2dafile.h"
#include "src/aurora/2dareg.h"

#include "src/engines/nwn2/trap.h"

Expand Down Expand Up @@ -231,6 +233,10 @@ bool Trap::triggerTrap(Object *object) {
void Trap::load(const Aurora::GFF3Struct &gff) {
_isTrapActive = true; // Default for a trigger trap

// Load the traps.2da information
_trapType = gff.getUint("TrapType", _trapType);
loadTrap2da(TwoDAReg.get2DA("traps"), _trapType);

_isTrap = gff.getBool("TrapFlag", _isTrap);
_isDetectable = gff.getBool("TrapDetectable", _isDetectable);
_isDisarmable = gff.getBool("TrapDisarmable", _isDisarmable);
Expand All @@ -249,7 +255,17 @@ void Trap::load(const Aurora::GFF3Struct &gff) {

/** Load the trap information from a traps.2da row */
void Trap::load(const uint8 type, const Creature *creator) {
// TODO
// Load the traps.2da information
_trapType = type;
loadTrap2da(TwoDAReg.get2DA("traps"), _trapType);
_createdBy = creator->getID();
}

/** Load base trap information from the traps.2da file */
void Trap::loadTrap2da(const Aurora::TwoDAFile &twoda, uint32 id) {
_onTrapTriggered = twoda.getRow(id).getString("TrapScript");
_detectDC = twoda.getRow(id).getInt("DetectDCMod");
_disarmDC = twoda.getRow(id).getInt("DisarmDCMod");
}

} // End of namespace NWN2
Expand Down
1 change: 1 addition & 0 deletions src/engines/nwn2/trap.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class Trap {

void load(const Aurora::GFF3Struct &trap);
void load(const uint8 type, const Creature *creator);
void loadTrap2da(const Aurora::TwoDAFile &twoda, uint32 id);
};

} // End of namespace NWN2
Expand Down

0 comments on commit 395112d

Please sign in to comment.