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

[转载发布] CityShrimp's Tint Event

[复制链接]
累计送礼:
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 天前 | 显示全部楼层 |阅读模式
    CS_TintEvent v1.0.1
            CityShrimp

    Introduction
            This plugin allows you to add tint to events, players, and followers.  This is very similar to S_Rank_Crazy's Event Highlighting script, but with different features.

    Features
            - Tint remains until manually removed with another command (or change of event page).


            - Tint can constantly fade in and out


            - Tint can be applied to players and followers.


            - Fade speed can be adjusted

    Screenshots




    How to Use


    • Download CS_FogOfWar.js
    • Place it into your project's Plugin list
    • Check description in file for latest Parameter, Notetag/Comments, and Plugin Commands


    Demo










    Script:


    Download v1.0.1

    Spoiler/*=============================================================================
    * CityShrimp's Tint Event
    * CS_TintEvent.js
    * Version: 1.0.1
    * Free for commercial and non commercial use.
    *=============================================================================*/

    /*:
    * @plugindesc This plugin provides a way to tint events
    *            
    * @author CityShrimp
    *
    * ===Parameter List===
    *
    * @param Default Tone
    * @desc Default tone of the tint that is applied if no [tone] is specified
    * @default 60, 60, 60, 0
    *
    * @param Fade Speed
    * @desc Number of frames for tint to fade in and fade out again.  1 = Immediate
    * @default 1
    *
    * @param Flicker
    * @desc Whether tint will constantly fade in and out for all events and characters.
    * @default false
    *
    * ===Event/Comment Notetag===
    *
    * <cste_tone [tone]>
    * desc: Event will be tinted with the given tone.  Example [tone]: 30,30,30,0.  (No spaces allowed)
    *
    * <cste_fade_speed: (value)>
    * desc: Number of frames for tint to fade in and fade out again.  0 = Constant tint
    *
    * <cste_flicker: (bool)>
    * desc: When true, the event's tint will constantly fade in and out.
    *
    * Note: Event tag will overwrite any Comment tags
    *
    * ===Plugin Commands===
    *
    * cs_te <target> <command>
    *
    * <target>:
    * - all_events: all events
    * - event <id>: event with given id
    * - player: player's character
    * - follower <index>: follow with given index
    * - party: entire player's party
    *
    * <command>:
    * - apply_tint [tone]: Apply tint on the specified target.
    * [tone] is optional. If none are specified, the default is used. Example [tone]: 30,30,30,0. (No spaces allowed)
    * - remove_tint: Remove tint from specified target.
    * - fade_speed <speed>: Set the fade speed on specified target.
    * <speed> is required.  It must be an integer that's >= 0.  A fade_speed of 0 will cause tint to appear/remove instantly.
    * - flicker <bool>: Set the flicker property for specified target.
    * <bool> is required, can be true or false.
    *
    * Examples:
    * cs_te all_event apply_tint
    * This will apply default tint to all events
    *
    * cs_te event 1 apply_tint 60,0,0,0
    * This will apply a red tint to event #1.
    *
    * cs_te player remove_tint
    * This will remove tint from the player
    *
    * cs_te party fade_speed 30
    * This will change the entire party's fade speed to 30 - meaning it will take 30 frames to apply or remove tint.
    *
    * cs_te follower 0 flicker true
    * This will cause follower #1's tint to constantly fade in and out.
    *
    * @help
    * ============================================================================
    * Latest Version
    * ============================================================================
    *
    * Get the latest version of this script on
    * https://github.com/cityshrimp/rmmv_fow/blob/master/CS_TintEvent.js
    *
    *=============================================================================
    */

    var Imported = Imported || {};
    Imported['CS_TintEvent'] = "1.0.1";

    var CS_TintEvent = CS_TintEvent || {};

    // ===MVCommons Module (taken from SuperOrangeMovementEX) ===
    if (Imported['MVCommons'] === undefined) {
      var MVC = MVC || {};

      (function($) {
        $.getProp = function(meta, propName) {
            if (meta === undefined)
                return undefined;
            if (meta[propName] !== undefined)
                if (typeof meta[propName] === 'string')
                    return meta[propName].trim();
                else
                    return meta[propName];
            for (var key in meta) {
                if (key.toLowerCase() == propName.toLowerCase()) {
                    return meta[key].trim();
                }
            }
            return undefined;
        };
      })(MVC);

      Number.prototype.fix = function() {return (parseFloat(this.toPrecision(12)));};
      Number.prototype.floor = function() {return Math.floor(this.fix());};
      Number.prototype.ceil = function() {return Math.ceil(this.fix());};
      Number.prototype.abs = function() {return Math.abs(this);};
    }
    // ===End SuperOrangeMovementEX's MVCommons Module===

    (function($) {
        "use strict";

        $.parseTone = function(tone) {
            var tone_array = tone.split(',');
            if (tone_array.length != 4)
                return false;
            for (var i = 0; i < tone_array.length; i++) {
                tone_array = parseFloat(tone_array.trim());
                if (Number.isNaN(tone_array))
                    return false;
            }
            return tone_array;
        }

        // Load parameters
        $.parameters = PluginManager.parameters("CS_TintEvent") || {};
        var temp = $.parseTone($.parameters['Default Tone']);
        $.default_tone = (temp) ? temp : [0,0,0,0];
        $.fade_speed = Number($.parameters['Fade Speed'] || 0);
        $.flicker = ($.parameters['Flicker'] === 'true') ? true : false;

        // ===Alias Sprite_Character===
        var old_Sprite_Character_update = Sprite_Character.prototype.update;
        Sprite_Character.prototype.update = function() {
            old_Sprite_Character_update.call(this);
            this.updateTone();
        };

        Sprite_Character.prototype.updateTone = function() {
            if (this._character.tone()) {
                this.setColorTone(this._character.tone());
            } else {
                this.setColorTone([0, 0, 0, 0]);
            }
        };

        // ===Alias Game_CharacterBase===
        var old_Game_CharacterBase_initialize = Game_CharacterBase.prototype.initialize;
        Game_CharacterBase.prototype.initialize = function() {
            old_Game_CharacterBase_initialize.call(this);

            // Load default values
            this._tone = [0, 0, 0, 0];
            this._target_tone = [0, 0, 0, 0];
            this._original_tone = [0, 0, 0, 0];
            this._fade_speed = $.fade_speed;
            this._flicker = $.flicker;
            this._stop = false;
        };

        var old_Game_CharacterBase_update = Game_CharacterBase.prototype.update;
        Game_CharacterBase.prototype.update = function() {
            old_Game_CharacterBase_update.call(this);

            this.updateTone();
        };

        Game_CharacterBase.prototype.tone = function() {
            return this._tone;
        }

        Game_CharacterBase.prototype.setTone = function(tone) {
            this._stop = false;
            this._original_tone = this._tone.slice();
            this._target_tone = tone;
        }

        Game_CharacterBase.prototype.removeTone = function() {
            this._stop = true;
            this.setTone([0,0,0,0]);
        }

        Game_CharacterBase.prototype.setFadeSpeed = function(fade_speed) {
            this._fade_speed = (fade_speed >= 1) ? fade_speed : 1;
        }

        Game_CharacterBase.prototype.setFlicker = function(flicker) {
            this._flicker = flicker;
            this._tone = this._target_tone.slice();
            this._original_tone = [0,0,0,0];
        }

        Game_CharacterBase.prototype.updateTone = function() {
            if (this._tone == undefined)
                return;

            var over = 0;
            for (var i = 0; i < 4; i++) {
                if ((this._target_tone >= this._original_tone
                   && this._tone >= this._target_tone)
                   || (this._target_tone <= this._original_tone
                   && this._tone <= this._target_tone)) {
                    over++;
                }
            }

            if (over == 4) {
                if (!this._flicker) {
                    this._tone = this._target_tone.slice();
                } else {
                    // Flip the origin and target
                    var temp = this._target_tone;
                    this._target_tone = this._original_tone;
                    this._original_tone = temp;
                }

                if (this._stop) {
                    this._tone = [0,0,0,0];
                    this._original_tone = [0,0,0,0];
                    this._target_tone = [0,0,0,0];
                    this._stop = false;
                }
            } else {
                var step = 1.0 / this._fade_speed;   
                for (var i = 0; i < 4; i++) {
                    var amount = (this._target_tone - this._original_tone) * step;
                    this._tone += amount;
                }
            }
        }

        // ===Alia Game_Event===
        var old_Game_Event_initialize = Game_Event.prototype.initialize;
        Game_Event.prototype.initialize = function(mapId, eventId) {
            old_Game_Event_initialize.call(this, mapId, eventId);

            var data_e = $dataMap.events[eventId];
            var fade_speed = parseFloat(MVC.getProp(data_e.meta, 'cste_fade_speed'));
            if (!Number.isNaN(fade_speed))
                this.setFadeSpeed(fade_speed);
            if (MVC.getProp(data_e.meta, 'cste_flicker') === 'true')
                this._flicker = true;
            else if (MVC.getProp(data_e.meta, 'cste_flicker') === 'false')
                this._flicker = false;

            // Load event notetag values
            if (MVC.getProp(data_e.meta, 'cste_tone') != undefined) {
                var temp = $.parseTone(MVC.getProp(data_e.meta, 'cste_tone'));
                this.setTone(this._tone.slice());
            }

            this.loadComments();
        }

        Game_Event.prototype.searchComment = function(term) {
            var comment = "";
            if(!this.page())
                return false;
            var pagelist = this.page().list;
            for (var cmd of pagelist) {
                if(cmd.code == 108)   comment += cmd.parameters[0] + "\n";
                if(cmd.code == 408)   comment += cmd.parameters[0] + "\n";
            }
            var temp = comment.split("<" + term);
            if (temp.length > 1) {
                temp = temp[1].split(">")[0];
                if (temp.includes(":")) {
                    return temp.split(":")[1].trim();
                } else {
                    return true;
                }
            } else {
                return false;
            }

            return false;
        }

        var Old_Game_Event_setupPageSettings = Game_Event.prototype.setupPageSettings;
        Game_Event.prototype.setupPageSettings = function() {
            Old_Game_Event_setupPageSettings.call(this);

            this.loadComments();
        };

        Game_Event.prototype.loadComments = function() {
            var fade_speed = parseFloat(this.searchComment('cste_fade_speed'));
            if (!Number.isNaN(fade_speed))
                this.setFadeSpeed(fade_speed);

            if (this.searchComment('cste_flicker') === 'true')
                this._flicker = true;
            else if (this.searchComment('cste_flicker') === 'false')
                this._flicker = false;

            if (this.searchComment('cste_tone') === true) {
                this.setTone($.default_tone.slice());
            } else if (this.searchComment('cste_tone')) {
                var temp = $.parseTone(this.searchComment('cste_tone'));
                if (temp)
                    this.setTone(temp);
            } else {
                this.setTone([0,0,0,0]);
            }
        }
        // ===End Alia Game_Event===

        // ===Game Interpreter prototype===
        var old_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
        Game_Interpreter.prototype.pluginCommand = function(command, args) {
            old_Game_Interpreter_pluginCommand.call(this, command, args);

            command = command.toLowerCase();
            if(command === 'cs_te' && args[0]) {
                var target = args[0].toLowerCase().trim();
                switch (target) {
                    case 'follower':
                    case 'event':
                        var index = parseInt(args[1]);
                        var action = args[2].toLowerCase();
                        var option = args[3];
                        break;
                    case 'party':
                    case 'player':
                    case 'all_events':
                        var action = args[1].toLowerCase();
                        var option = args[2];
                        break;
                }

                switch (action) {
                    case 'apply_tint':
                        var tone = (option != undefined) ? $.parseTone(option) : $.default_tone;
                        tone = (tone) ? tone : $.default_tone;
                        switch (target) {
                            case 'all_events':
                                for (var event of $gameMap.events())
                                     event.setTone(tone);
                                break;
                            case 'player':
                                $gamePlayer.setTone(tone);
                                break;
                            case 'party':
                                $gamePlayer.setTone(tone);
                                for (var f of $gamePlayer.followers()._data)
                                    f.setTone(tone);
                                break;
                            case 'follower':
                                var f = $gamePlayer.followers().follower(index);
                                if (f != undefined)
                                    f.setTone(tone);
                                break;
                            default:
                                var event = $gameMap.event(index);
                                if (event != undefined)
                                    event.setTone(tone);
                                else
                                    throw "Apply Tint: Specified event doesn't exist."
                        }
                        break;
                    case 'remove_tint':
                        switch (target) {
                            case 'all_events':
                                for (var event of $gameMap.events())
                                     event.removeTone();
                                break;
                            case 'player':
                                $gamePlayer.removeTone();
                                break;
                            case 'party':
                                $gamePlayer.removeTone();
                                for (var f of $gamePlayer.followers()._data)
                                    f.removeTone();
                                break;
                            case 'follower':
                                var f = $gamePlayer.followers().follower(index);
                                if (f != undefined)
                                    f.removeTone();
                                break;
                            default:
                                var event = $gameMap.event(index);
                                if (event != undefined)
                                    event.removeTone();
                                else
                                    throw "Remove Tint: Specified event doesn't exist."
                        }
                        break;
                    case 'fade_speed':
                        var speed = parseInt(option);
                        if (! Number.isInteger(speed))
                            throw "Fade Speed needs to be an integer.";
                        var speed = parseInt(option);
                        switch (target) {
                            case 'all_events':
                                for (var event of $gameMap.events())
                                     event.setFadeSpeed(speed);
                                break;
                            case 'player':
                                $gamePlayer.setFadeSpeed(speed);
                                break;
                            case 'party':
                                $gamePlayer.setFadeSpeed(speed);
                                for (var f of $gamePlayer.followers()._data)
                                    f.setFadeSpeed(speed);
                                break;
                            case 'follower':
                                var f = $gamePlayer.followers().follower(index);
                                if (f != undefined)
                                    f.setFadeSpeed(speed);
                                break;
                            default:
                                var event = $gameMap.event(index);
                                if (event != undefined)
                                    event.setFadeSpeed(speed);
                                else
                                    throw "Apply Tint: Specified event doesn't exist."
                        }
                        break;
                    case 'flicker':
                        if (option === 'true')
                            option = true;
                        else
                            option = false;
                        switch (target) {
                            case 'all_events':
                                for (var event of $gameMap.events())
                                     event.setFlicker(option);
                                break;
                            case 'player':
                                $gamePlayer.setFlicker(option);
                                break;
                            case 'party':
                                $gamePlayer.setFlicker(option);
                                for (var f of $gamePlayer.followers()._data)
                                    f.setFlicker(option);
                                break;
                            case 'follower':
                                var f = $gamePlayer.followers().follower(index);
                                if (f != undefined)
                                    f.setFlicker(option);
                                break;
                            default:
                                var event = $gameMap.event(index);
                                if (event != undefined)
                                    event.setFlicker(option);
                                else
                                    throw "Apply Tint: Specified event doesn't exist."
                        }
                        break;
                }
            }
        }
        // ===End Game Interpreter prototype===   

    })(CS_TintEvent);









    Credit and Thanks
            CityShrimp


            The MV Secret Team - for MVC script


    Notes and Limitations


            - Event tint applied via Plugin Commands will persist after save/load, but will not persist if map changes.


            - Player and followers tint will always persist.



    本贴来自国际rpgmaker官方论坛作者:cityshrimp处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/cityshrimps-tint-event.72128/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-8-1 07:32 , Processed in 0.074298 second(s), 58 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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