Skip to content

Commit

Permalink
fix move-trigger execution for TRIGGER_CONTROL
Browse files Browse the repository at this point in the history
  • Loading branch information
Try authored and jsapinat committed May 22, 2024
1 parent 1792206 commit 483e5b4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
11 changes: 8 additions & 3 deletions game/world/objects/interactive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,12 @@ void Interactive::implTick(Pos& p) {

if(state==0 && p.attachMode) {
npc.world().sendPassivePerc(npc,npc,npc,PERC_ASSESSUSEMOB);
emitTriggerEvent();
emitTriggerEvent(TriggerEvent::T_Trigger);
}

if(state==stateNum && p.attachMode && reverseState) {
npc.world().sendPassivePerc(npc,npc,npc,PERC_ASSESSUSEMOB);
emitTriggerEvent(TriggerEvent::T_Untrigger);
}

if(npc.isPlayer() && !loopState && attach) {
Expand Down Expand Up @@ -455,10 +460,10 @@ void Interactive::invokeStateFunc(Npc& npc) {
sc.useInteractive(npc.handlePtr(), func);
}

void Interactive::emitTriggerEvent() const {
void Interactive::emitTriggerEvent(TriggerEvent::Type type) const {
if(triggerTarget.empty())
return;
const TriggerEvent evt(triggerTarget,vobName,TriggerEvent::T_Trigger);
const TriggerEvent evt(triggerTarget,vobName,type);
world.triggerEvent(evt);
}

Expand Down
3 changes: 2 additions & 1 deletion game/world/objects/interactive.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "physics/physicmesh.h"
#include "graphics/mesh/animationsolver.h"
#include "graphics/objvisual.h"
#include "world/triggers/abstracttrigger.h"
#include "game/inventory.h"
#include "utils/keycodec.h"
#include "vob.h"
Expand Down Expand Up @@ -51,7 +52,7 @@ class Interactive : public Vob {
int32_t stateId() const { return state; }
int32_t stateCount() const { return stateNum; }
bool setMobState(std::string_view scheme,int32_t st) override;
void emitTriggerEvent() const;
void emitTriggerEvent(TriggerEvent::Type type) const;
std::string_view schemeName() const;
std::string_view posSchemeName() const;

Expand Down
8 changes: 2 additions & 6 deletions game/world/triggers/movetrigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ MoveTrigger::MoveTrigger(Vob* parent, World& world, const zenkit::VMover& mover,
}

keyframes[i].ticks = std::max(ticksA, ticksB);
if(mover.speed>=100) {
// EVT_RIGHT_GATE_LARGE_01
// keyframes[i].ticks = 0;
}
}

if(!mover.keyframes.empty()) {
Expand Down Expand Up @@ -159,8 +155,8 @@ void MoveTrigger::processTrigger(const TriggerEvent& e, bool onTrigger) {
}
case zenkit::MoverBehavior::TRIGGER_CONTROL: {
if(onTrigger)
state = Open; else
state = Close;
state = Close; else
state = Open;
break;
}
case zenkit::MoverBehavior::OPEN_TIME: {
Expand Down

0 comments on commit 483e5b4

Please sign in to comment.