mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-25 16:43:33 +00:00
implement water script functions and save water height in CellStore
This commit is contained in:
parent
f497813043
commit
5a19d4ec45
@ -133,11 +133,62 @@ namespace MWScript
|
||||
}
|
||||
};
|
||||
|
||||
class OpGetWaterLevel : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
InterpreterContext& context
|
||||
= static_cast<InterpreterContext&> (runtime.getContext());
|
||||
|
||||
const ESM::Cell *cell = context.getWorld().getPlayer().getPlayer().getCell()->cell;
|
||||
runtime.push (cell->water);
|
||||
}
|
||||
};
|
||||
|
||||
class OpSetWaterLevel : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
InterpreterContext& context
|
||||
= static_cast<InterpreterContext&> (runtime.getContext());
|
||||
|
||||
Interpreter::Type_Float level = runtime[0].mFloat;
|
||||
|
||||
MWWorld::Ptr::CellStore *cell = context.getWorld().getPlayer().getPlayer().getCell();
|
||||
cell->mWaterLevel = level;
|
||||
context.getEnvironment().mWorld->setWaterHeight(cell->mWaterLevel);
|
||||
}
|
||||
};
|
||||
|
||||
class OpModWaterLevel : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
InterpreterContext& context
|
||||
= static_cast<InterpreterContext&> (runtime.getContext());
|
||||
|
||||
Interpreter::Type_Float level = runtime[0].mFloat;
|
||||
|
||||
MWWorld::Ptr::CellStore *cell = context.getWorld().getPlayer().getPlayer().getCell();
|
||||
cell->mWaterLevel +=level;
|
||||
context.getEnvironment().mWorld->setWaterHeight(cell->mWaterLevel);
|
||||
}
|
||||
};
|
||||
|
||||
const int opcodeCellChanged = 0x2000000;
|
||||
const int opcodeCOC = 0x2000026;
|
||||
const int opcodeCOE = 0x200008e;
|
||||
const int opcodeGetInterior = 0x2000131;
|
||||
const int opcodeGetPCCell = 0x2000136;
|
||||
const int opcodeGetWaterLevel = 0x2000141;
|
||||
const int opcodeSetWaterLevel = 0x2000142;
|
||||
const int opcodeModWaterLevel = 0x2000143;
|
||||
|
||||
void registerExtensions (Compiler::Extensions& extensions)
|
||||
{
|
||||
@ -146,8 +197,11 @@ namespace MWScript
|
||||
extensions.registerInstruction ("centeroncell", "S", opcodeCOC);
|
||||
extensions.registerInstruction ("coe", "ll", opcodeCOE);
|
||||
extensions.registerInstruction ("centeronexterior", "ll", opcodeCOE);
|
||||
extensions.registerInstruction ("setwaterlevel", "f", opcodeSetWaterLevel);
|
||||
extensions.registerInstruction ("modwaterlevel", "f", opcodeModWaterLevel);
|
||||
extensions.registerFunction ("getinterior", 'l', "", opcodeGetInterior);
|
||||
extensions.registerFunction ("getpccell", 'l', "c", opcodeGetPCCell);
|
||||
extensions.registerFunction ("getwaterlevel", 'f', "", opcodeGetWaterLevel);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
@ -157,6 +211,9 @@ namespace MWScript
|
||||
interpreter.installSegment5 (opcodeCOE, new OpCOE);
|
||||
interpreter.installSegment5 (opcodeGetInterior, new OpGetInterior);
|
||||
interpreter.installSegment5 (opcodeGetPCCell, new OpGetPCCell);
|
||||
interpreter.installSegment5 (opcodeGetWaterLevel, new OpGetWaterLevel);
|
||||
interpreter.installSegment5 (opcodeSetWaterLevel, new OpSetWaterLevel);
|
||||
interpreter.installSegment5 (opcodeModWaterLevel, new OpModWaterLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -123,4 +123,7 @@ op 0x200013d: FadeOut
|
||||
op 0x200013e: FadeTo
|
||||
op 0x200013f: GetCurrentWeather
|
||||
op 0x2000140: ChangeWeather
|
||||
opcodes 0x2000141-0x3ffffff unused
|
||||
op 0x2000141: GetWaterLevel
|
||||
op 0x2000142: SetWaterLevel
|
||||
op 0x2000143: ModWaterLevel
|
||||
opcodes 0x2000142-0x3ffffff unused
|
||||
|
@ -95,12 +95,17 @@ namespace ESMS
|
||||
State_Unloaded, State_Preloaded, State_Loaded
|
||||
};
|
||||
|
||||
CellStore (const ESM::Cell *cell_) : cell (cell_), mState (State_Unloaded) {}
|
||||
CellStore (const ESM::Cell *cell_) : cell (cell_), mState (State_Unloaded)
|
||||
{
|
||||
mWaterLevel = cell->water;
|
||||
}
|
||||
|
||||
const ESM::Cell *cell;
|
||||
State mState;
|
||||
std::vector<std::string> mIds;
|
||||
|
||||
float mWaterLevel;
|
||||
|
||||
// Lists for each individual object type
|
||||
CellRefList<Activator, D> activators;
|
||||
CellRefList<Potion, D> potions;
|
||||
|
Loading…
x
Reference in New Issue
Block a user