设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 99|回复: 0

[转载发布] CanLose - Control Defeat Behavior

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    7959

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    29925
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    38778

    灌水之王

    发表于 4 天前 | 显示全部楼层 |阅读模式

    Can Lose 1.0



    By Tairo



             


    Introduction


            Changes the default lose behavior from game over to just continuing. (i.e. Makes all battles act like an event battle with the "Can Lose" box checked).


             


    Features


            - All losses continue game by default (Plug and Play)


            - You can choose a common event to run after each loss, and easily change it on-the-fly using commands.


            - A switch can be used to determine the default loss behavior (either continue the game, or normal RPG Maker behavior).


             


    How to Use


            Add it to your plugins folder (file name: CanLose.js).


             


            (Optional) Enter the ID of the common event you want to run by default and the ID of the switch you want to use as parameters, or enter in 0 if you don't want to use one (or either) of them.


             


    Plugin Commands


    SpoilerMakes losing the current battle result in a game-over.

                            CanLose false          # Makes it so a loss causes the game over event               
    Click to expand...




                                            Makes losing the current battle just continue the game (to undo the previous command, if desired).

                            CanLose true           # Makes it so a loss does not cause a game over               
    Click to expand...




                                            Changes the ID of the common event to run after a loss.

                            CanLose eventID 2      # Sets the event ID to 2, and prints in the console               
    Click to expand...




                                            Returns the ID of the switch used as a parameter, and prints it's value into the console (if one is selected).

                            CanLose checkSwitch    # Returns ID of the switch & prints it in the console               
    Click to expand...









             


    Demo


    Download from Dropbox


             


    Plugin Code


    Download from pastebin


    Spoiler                Code:       
    1.                                 //=============================================================================
    2.                                 // Can Lose
    3.                                 // by Tairo
    4.                                 // Last Updated: 2016.8.17
    5.                                 //=============================================================================                                               
    6.                                 /*:
    7.                                  * @plugindesc Allows player to lose all battles, including random battles, with no game over.
    8.                                  * @author Tairo
    9.                                  *
    10.                                  * @param Lose Common Event
    11.                                  * @desc The ID of the common event you want to run after each lost battle.
    12.                                  * @default 0
    13.                                  *
    14.                                  * @param Allow Game Over Switch
    15.                                  * @desc Switch ID to turn on and allow a game over (on = default RPG Maker behavior).
    16.                                  * @default 0
    17.                                  *
    18.                                  * @help
    19.                                  * ============================================================================
    20.                                  * How To Use
    21.                                  * ============================================================================
    22.                                  *
    23.                                  * This plugin causes all battles (random or event) to not cause a game over
    24.                                  * event after a loss, by default. No commands or parameters needed for the
    25.                                  * basic function, they're just for more control.
    26.                                  *
    27.                                  * The plugin is designed for those who wish to allow the player to lose a
    28.                                  * random encounter, just like an event battle.
    29.                                  *
    30.                                  * The first parameter also allows you to run a common event after a loss, or use
    31.                                  * a value of 0 to have no common event run.
    32.                                  *
    33.                                  * The second parameter is a switch for if you want to control the default
    34.                                  * behavior. Off for no game over default, on for normal RPG Maker behavior.
    35.                                  * Use 0 if you don't want to use a switch, so it always allow losses.
    36.                                  *
    37.                                  * The plugin commands are for when you want to change whether or not a game
    38.                                  * over will occur upon a loss in the middle of a battle, or to make certain
    39.                                  * troops/encounters (like bosses) cause a game over if lost to.
    40.                                  *
    41.                                  * Plugin Command:
    42.                                  *   CanLose false          # Makes it so a loss causes the game over event
    43.                                  *   CanLose true           # Makes it so a loss does not cause a game over
    44.                                  *   CanLose eventID 2      # Sets the event ID to 2, and prints in the console
    45.                                  *   CanLose checkSwitch    # Prints current value of the switch in the console
    46.                                  *
    47.                                  * ============================================================================
    48.                                  * Terms Of Use
    49.                                  * ============================================================================
    50.                                  * Free to use and modify for commercial and noncommercial games, with credit.
    51.                                  * ============================================================================
    52.                                  * Credits
    53.                                  * ============================================================================
    54.                                  * Tairo
    55.                                  */                                               
    56.                                 (function() {
    57.                                     
    58.                                     var parameters = PluginManager.parameters('CanLose');
    59.                                     var loseEvent = Number(parameters['Lose Common Event'] || 0);
    60.                                     var allowSwitch = Number(parameters['Allow Game Over Switch'] || 0);
    61.                                     
    62.                                     var _BattleManager_setup = BattleManager.setup;
    63.                                     BattleManager.setup = function(troopId, canEscape, canLose) {
    64.                                         if(allowSwitch == 0 || $gameSwitches.value(allowSwitch) == false) {
    65.                                             _BattleManager_setup.call(this, troopId, canEscape, true);
    66.                                         }
    67.                                         else {
    68.                                             _BattleManager_setup.call(this, troopId, canEscape, canLose);
    69.                                         }
    70.                                         /*this.initMembers();
    71.                                         this._canEscape = canEscape;*/
    72.                                         //this._canLose = true;//canLose;
    73.                                         /*$gameTroop.setup(troopId);
    74.                                         $gameScreen.onBattleStart();
    75.                                         this.makeEscapeRatio();*/
    76.                                     };
    77.                                     
    78.                                     var _BattleManager_processDefeat = BattleManager.processDefeat;
    79.                                     BattleManager.processDefeat = function() {
    80.                                         _BattleManager_processDefeat.call(this);
    81.                                         if (loseEvent !== 0) {
    82.                                             $gameTemp.reserveCommonEvent(loseEvent);
    83.                                         }
    84.                                     };
    85.                                     
    86.                                     var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    87.                                     Game_Interpreter.prototype.pluginCommand = function(command, args) {
    88.                                         _Game_Interpreter_pluginCommand.call(this, command, args);
    89.                                         if (command === 'CanLose') {
    90.                                             switch (args[0]) {
    91.                                             case 'false':
    92.                                                 BattleManager._canLose = false;
    93.                                                 console.log("Current fight will cause game-over if lost.");
    94.                                                 break;
    95.                                             case 'true':
    96.                                                 BattleManager._canLose = true;
    97.                                                 console.log("Current fight will not cause a game-over if lost.");
    98.                                                 break;
    99.                                             case 'eventID':
    100.                                                 loseEvent = Number(args[1]);
    101.                                                 parameters['Lose Common Event'] = Number(args[1]);
    102.                                                 console.log("Event in Parameter: " + parameters['Lose Common Event'] + " & Event in code: " + loseEvent);
    103.                                                 break;
    104.                                             case 'checkSwitch':
    105.                                                 return allowSwitch;
    106.                                                 console.log("Switch " + allowSwitch + " is " + $gameSwitches.value(Number(parameters['Allow Game Over Switch'])) + " " + $gameSwitches.value(allowSwitch));
    107.                                                 break;
    108.                                             }
    109.                                         }
    110.                                     };
    111.                                     
    112.                                   /* This function can be found in rpg_managers.js
    113.                                  
    114.                                     BattleManager.setup = function(troopId, canEscape, canLose) {
    115.                                     this.initMembers();
    116.                                     this._canEscape = canEscape;
    117.                                     this._canLose = canLose;
    118.                                     $gameTroop.setup(troopId);
    119.                                     $gameScreen.onBattleStart();
    120.                                     this.makeEscapeRatio();
    121.                                     };                                               
    122.                                   */                                               
    123.                                 })();
    复制代码







             


    FAQ


            Q: Do I have to use the plugin commands?


            A: No, they are not needed for the basic function of making all battles act as though you checked the "Can Lose" box on an event battle. In that sense, it's sort-of 'plug-and-play'. However, the commands do allow more customization/control, like easily making certain fights (like bosses) or even skills change the behavior (like maybe an assassin's 'kill' ability, or something).


             


            Q: Why not flip a switch after a loss, instead of limiting it only to a common event?


            A: There is already another plugin which does that (along with any other result of a battle), which is Battle Result Switches by Shaz (click for his forum post), but his plugin doesn't allow lost battles to random encounters. The reason for me just using common events is to differentiate my plugin from his, and because you'd probably only use a common event for most scenarios where you'd want the player to not game-over after a lost battle anyway.


             

    Credit and Thanks


            - Tairo


             



    Terms of Use


                    Free for commercial and non-commercial use, with credit.


    本贴来自国际rpgmaker官方论坛作者:Tairo处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/canlose-control-defeat-behavior.67022/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-1 06:36 , Processed in 0.114787 second(s), 54 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表