diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index f1be30b5..93522885 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -3876,9 +3876,11 @@ void entityclass::settemprect( int t ) rectset(tempx, tempy, tempw, temph); } -int entityclass::checktrigger() +int entityclass::checktrigger(int* block_idx) { //Returns an int player entity (rule 0) collides with a trigger + //Also returns the index of the block + *block_idx = -1; for(size_t i=0; i < entities.size(); i++) { if(entities[i].rule==0) @@ -3894,6 +3896,7 @@ int entityclass::checktrigger() if (blocks[j].type == TRIGGER && help.intersects(blocks[j].rect, temprect)) { activetrigger = blocks[j].trigger; + *block_idx = j; return blocks[j].trigger; } } @@ -4816,9 +4819,20 @@ void entityclass::entitycollisioncheck() // WARNING: If updating this code, don't forget to update Map.cpp mapclass::twoframedelayfix() activetrigger = -1; - if (checktrigger() > -1) + int block_idx = -1; + if (checktrigger(&block_idx) > -1 && block_idx > -1) { - game.state = activetrigger; + if (blocks[block_idx].script != "") + { + game.startscript = true; + game.newscript = blocks[block_idx].script; + removetrigger(activetrigger); + game.state = 0; + } + else + { + game.state = activetrigger; + } game.statedelay = 0; } } diff --git a/desktop_version/src/Entity.h b/desktop_version/src/Entity.h index 2cdb1b99..8702e000 100644 --- a/desktop_version/src/Entity.h +++ b/desktop_version/src/Entity.h @@ -105,7 +105,7 @@ public: void settemprect(int t); - int checktrigger(); + int checktrigger(int* block_idx); int checkactivity(); diff --git a/desktop_version/src/Map.cpp b/desktop_version/src/Map.cpp index 5a96f941..5eec819f 100644 --- a/desktop_version/src/Map.cpp +++ b/desktop_version/src/Map.cpp @@ -2062,16 +2062,18 @@ void mapclass::twoframedelayfix() // and when the script gets loaded script.run() has already ran for that frame, too. // A bit kludge-y, but it's the least we can do without changing the frame ordering. + int block_idx = -1; if (game.glitchrunnermode || game.deathseq != -1 - // obj.checktrigger() sets obj.activetrigger - || obj.checktrigger() <= -1 + // obj.checktrigger() sets obj.activetrigger and block_idx + || obj.checktrigger(&block_idx) <= -1 + || block_idx <= -1 || obj.activetrigger < 300) { return; } - game.newscript = "custom_" + game.customscript[obj.activetrigger - 300]; + game.newscript = obj.blocks[block_idx].script; obj.removetrigger(obj.activetrigger); game.state = 0; game.statedelay = 0;