swordmaster2k/rpgwizard

Activation KEYPRESS events not restoring previously global assigned key handlers

swordmaster2k opened this issue · 0 comments

It is possible to overwrite a global key handler such as the swordslash in the action battle system using a KEYPRESS based event. Once the event has finished running the key handler is not being restored.

The bug occurs in the character.js code:

    events.forEach(function (event) {
        if (event.program) {
            if (event.type.toUpperCase() === "OVERLAP") {
                rpgwizard.runProgram(PATH_PROGRAM.concat(event.program), object);
            } else if (event.type.toUpperCase() === "KEYPRESS") {
                if (event.key) {
                    entity.previousKeyHandler = {
                        key: event.key,
                        callback: rpgwizard.keyboardHandler.downHandlers[event.key]
                    };
                    var callback = function () {
                        rpgcode.unregisterKeyDown(event.key, true);
                        rpgwizard.runProgram(PATH_PROGRAM.concat(event.program), object);
                    };
                    rpgcode.registerKeyDown(event.key, callback, true);
                }
            }
        }
    });