mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:23:52 +00:00
added Enable/DisableCollision instructions
This commit is contained in:
parent
0a832f2d23
commit
bb34f6e7fc
4 changed files with 40 additions and 2 deletions
|
@ -7,6 +7,8 @@
|
|||
#include <components/interpreter/runtime.hpp>
|
||||
#include <components/interpreter/opcodes.hpp>
|
||||
|
||||
#include "../mwworld/player.hpp"
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
@ -35,10 +37,32 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
class OpSetCollision : public Interpreter::Opcode0
|
||||
{
|
||||
bool mEnable;
|
||||
|
||||
public:
|
||||
|
||||
OpSetCollision (bool enable)
|
||||
: mEnable (enable)
|
||||
{}
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
InterpreterContext& context
|
||||
= static_cast<InterpreterContext&> (runtime.getContext());
|
||||
|
||||
context.getWorld().getPlayer().setCollisionMode (mEnable);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
const int numberOfControls = 7;
|
||||
|
||||
const int opcodeEnable = 0x200007e;
|
||||
const int opcodeDisable = 0x2000085;
|
||||
const int opcodeEnableCollision = 0x2000130;
|
||||
const int opcodeDisableCollision = 0x2000131;
|
||||
|
||||
const char *controls[numberOfControls] =
|
||||
{
|
||||
|
@ -56,6 +80,9 @@ namespace MWScript
|
|||
extensions.registerInstruction (enable + controls[i], "", opcodeEnable+i);
|
||||
extensions.registerInstruction (disable + controls[i], "", opcodeDisable+i);
|
||||
}
|
||||
|
||||
extensions.registerInstruction ("enablecollision", "", opcodeEnableCollision);
|
||||
extensions.registerInstruction ("disablecollision", "", opcodeDisableCollision);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
|
@ -65,6 +92,9 @@ namespace MWScript
|
|||
interpreter.installSegment5 (opcodeEnable+i, new OpSetControl (controls[i], true));
|
||||
interpreter.installSegment5 (opcodeDisable+i, new OpSetControl (controls[i], false));
|
||||
}
|
||||
|
||||
interpreter.installSegment5 (opcodeEnableCollision, new OpSetCollision (true));
|
||||
interpreter.installSegment5 (opcodeDisableCollision, new OpSetCollision (false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,4 +101,6 @@ op 0x20000c4-0x20000de: SetSkill
|
|||
op 0x20000df-0x20000f9: SetSkill, explicit reference
|
||||
op 0x20000fa-0x2000114: ModSkill
|
||||
op 0x2000115-0x200012f: ModSKill, explicit reference
|
||||
op 0x2000130: EnableCollision
|
||||
op 0x2000131: DisableCollision
|
||||
opcodes 0x2000130-0x3ffffff unused
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace MWWorld
|
||||
{
|
||||
Player::Player (MWRender::Player *renderer, const ESM::NPC *player, MWWorld::World& world) :
|
||||
mCellStore (0), mRenderer (renderer), mWorld (world), mClass (0)
|
||||
mCellStore (0), mRenderer (renderer), mWorld (world), mClass (0), mCollisionMode (true)
|
||||
{
|
||||
mPlayer.base = player;
|
||||
mName = player->name;
|
||||
|
@ -49,7 +49,7 @@ namespace MWWorld
|
|||
relZ = pos[1];
|
||||
|
||||
// TODO: Collision detection must be used to find the REAL new
|
||||
// position.
|
||||
// position, if mCollisionMode==true
|
||||
|
||||
// Set the position
|
||||
setPos(relX, relY, relZ);
|
||||
|
|
|
@ -29,6 +29,7 @@ namespace MWWorld
|
|||
std::string mRace;
|
||||
std::string mBirthsign;
|
||||
ESM::Class *mClass;
|
||||
bool mCollisionMode;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -102,6 +103,11 @@ namespace MWWorld
|
|||
{
|
||||
return *mClass;
|
||||
}
|
||||
|
||||
void setCollisionMode (bool enable)
|
||||
{
|
||||
mCollisionMode = enable;
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue