Project1

标题: 有没有办法可以将测试图的战斗小人换成立绘的方法 [打印本页]

作者: yekongrs    时间: 2025-4-20 21:33
标题: 有没有办法可以将测试图的战斗小人换成立绘的方法
请教各位大佬,有没有办法可以将测试图的战斗小人换成固定立绘的方法啊,跪求
作者: 无忧谷主幻    时间: 2025-4-21 04:13
用AI跑一下试试?
作者: yekongrs    时间: 2025-4-21 13:11
无忧谷主幻 发表于 2025-4-21 04:13
用AI跑一下试试?

DeepSeek给到的方法都有点不太好
作者: sunhihi    时间: 2025-4-21 14:00
你是要把側面視角的SV圖換成靜態圖嗎?
作者: yekongrs    时间: 2025-4-21 21:41
sunhihi 发表于 2025-4-21 14:00
你是要把側面視角的SV圖換成靜態圖嗎?

嗯啊,是的,不知道可以吗?
作者: sunhihi    时间: 2025-4-21 22:30
yekongrs 发表于 2025-4-21 21:41
嗯啊,是的,不知道可以吗?

我的簽名檔
類似的功能我寫在
Sun_1_ActorParameterEx 角色參數擴充
作者: yekongrs    时间: 2025-4-23 10:38
sunhihi 发表于 2025-4-21 22:30
我的簽名檔
類似的功能我寫在
Sun_1_ActorParameterEx 角色參數擴充

谢谢谢谢,我看下,我自己这两天也找到一个办法实现了,我也看看您的插件,肯定比我的专业
作者: 北国爬山    时间: 6 天前
= =这玩意我拿哈基米写了一堆。奇怪为啥不支持上传JS文件。
复制给你了。
/*:
* @plugindesc Displays an image on the right side of the screen based on the party leader's HP.
* @author Your Name
*
* @param Image Full HP
* @desc Image file name (in img/pictures) for Full/High HP.
* @default
* @require 1
* @dir img/pictures/
* @type file
*
* @param Threshold Medium HP
* @desc HP percentage threshold (0-100) below which Medium HP image is shown.
* @default 50
* @type number
* @min 0
* @max 100
*
* @param Image Medium HP
* @desc Image file name (in img/pictures) for Medium HP.
* @default
* @require 1
* @dir img/pictures/
* @type file
*
* @param Threshold Low HP
* @desc HP percentage threshold (0-100) below which Low HP image is shown.
* @default 25
* @type number
* @min 0
* @max 100
*
* @param Image Low HP
* @desc Image file name (in img/pictures) for Low HP.
* @default
* @require 1
* @dir img/pictures/
* @type file
*
* @param Threshold Critical HP
* @desc HP percentage threshold (0-100) below which Critical HP image is shown.
* @default 10
* @type number
* @min 0
* @max 100
*
* @param Image Critical HP
* @desc Image file name (in img/pictures) for Critical HP.
* @default
* @require 1
* @dir img/pictures/
* @type file
*
* @param Image Zero HP
* @desc Image file name (in img/pictures) for Zero HP (optional).
* @default
* @require 1
* @dir img/pictures/
* @type file
*
* @param Offset X
* @desc Horizontal offset from the right edge of the screen.
* @default 0
* @type number
*
* @param Offset Y
* @desc Vertical offset from the top of the screen.
* @default 0
* @type number
*
* @help
* This plugin displays an image on the right side of the screen during map
* movement and battles. The image changes based on the HP percentage of
* the party leader (first actor in the party).
*
* The image is hidden when the system menu or any other menu scene is open.
*
* Place your images in the img/pictures folder.
*
* Configure the HP thresholds and corresponding image file names in the
* plugin parameters. The thresholds are checked from lowest to highest.
*
* Example:
* - If HP is exactly 0, show Zero HP image (if specified).
* - Else if HP% is < Threshold Critical, show Critical image.
* - Else if HP% is < Threshold Low, show Low image.
* - Else if HP% is < Threshold Medium, show Medium image.
* - Else, show Full HP image.
*
* The image is positioned relative to the top-right corner of the screen
* based on the X and Y offsets. X is offset *from* the right edge.
*
* Plugin Command: None.
*
*/

(function() {

    const parameters = PluginManager.parameters('YourPluginName'); // <<< IMPORTANT: Replace 'YourPluginName' with your actual file name!
    const imageFull = String(parameters['Image Full HP'] || '');
    const thresholdMedium = Number(parameters['Threshold Medium HP'] || 50);
    const imageMedium = String(parameters['Image Medium HP'] || '');
    const thresholdLow = Number(parameters['Threshold Low HP'] || 25);
    const imageLow = String(parameters['Image Low HP'] || '');
    const thresholdCritical = Number(parameters['Threshold Critical HP'] || 10);
    const imageCritical = String(parameters['Image Critical HP'] || '');
    const imageZero = String(parameters['Image Zero HP'] || '');
    const offsetX = Number(parameters['Offset X'] || 0);
    const offsetY = Number(parameters['Offset Y'] || 0);

    // --- Custom Sprite Class ---
    // This sprite will handle displaying the image and updating itself
    function Sprite_LeaderImage() {
        this.initialize(...arguments);
    }

    Sprite_LeaderImage.prototype = Object.create(Sprite.prototype);
    Sprite_LeaderImage.prototype.constructor = Sprite_LeaderImage;

    Sprite_LeaderImage.prototype.initialize = function() {
        Sprite.prototype.initialize.call(this);
        this._currentHpState = null; // Tracks the current HP state ('full', 'medium', etc.)
        this._lastLeaderHp = -1; // Tracks the leader's last known HP
        this._lastLeaderMhp = -1; // Tracks the leader's last known MHP
        this.anchor.x = 1; // Set anchor point to the right edge of the sprite
        this.anchor.y = 0; // Set anchor point to the top edge of the sprite
        this.x = Graphics.width - offsetX; // Position from the right edge
        this.y = offsetY; // Position from the top edge
        this.visible = false; // Start hidden
    };

    // Update method called every frame
    Sprite_LeaderImage.prototype.update = function() {
        Sprite.prototype.update.call(this);
        this.updateVisibility(); // Check if the sprite should be visible
        if (this.visible) {
            this.updateImage(); // If visible, check and update the image
        } else {
             // If not visible, ensure the bitmap is cleared to save memory/prevent drawing issues
             if (this.bitmap) {
                 this.bitmap = null;
                 this._currentHpState = null; // Reset state when hidden
             }
        }
    };

    // Determines if the sprite should be visible based on the current scene
    Sprite_LeaderImage.prototype.updateVisibility = function() {
        const scene = SceneManager._scene;
        // Visible in Map and Battle scenes
        let shouldBeVisible = (scene instanceof Scene_Map || scene instanceof Scene_Battle);

        // Hide if no party leader exists
        if (!$gameParty.members()[0]) {
            shouldBeVisible = false;
        }

        this.visible = shouldBeVisible;
    };

    // Checks the leader's HP and updates the displayed image if necessary
    Sprite_LeaderImage.prototype.updateImage = function() {
        const leader = $gameParty.members()[0];
        if (!leader) {
            // Should already be handled by updateVisibility, but double check
            this._currentHpState = null;
            this.bitmap = null;
            return;
        }

        const hp = leader.hp;
        const mhp = leader.mhp;

        // Only update the image if HP or MHP has changed since the last check
        if (hp === this._lastLeaderHp && mhp === this._lastLeaderMhp && this._currentHpState !== null) {
             // No change, do nothing
             return;
        }
        this._lastLeaderHp = hp;
        this._lastLeaderMhp = mhp;

        let newState = null;
        let imageName = '';

        if (hp <= 0) { // Handle 0 HP specifically first
             newState = 'zero';
             imageName = imageZero;
        } else if (mhp > 0) { // Calculate percentage only if MHP is valid
            const hpPercent = (hp / mhp) * 100;

            if (hpPercent < thresholdCritical) {
                newState = 'critical';
                imageName = imageCritical;
            } else if (hpPercent < thresholdLow) {
                newState = 'low';
                imageName = imageLow;
            } else if (hpPercent < thresholdMedium) {
                newState = 'medium';
                imageName = imageMedium;
            } else {
                newState = 'full';
                imageName = imageFull;
            }
        } else { // Handle case where MHP is 0 (e.g., actor not properly initialized)
             newState = 'zero'; // Or some other default state
             imageName = imageZero; // Or a default empty image
        }


        // Load the new image only if the determined state has changed
        if (newState !== this._currentHpState) {
            this._currentHpState = newState;
            if (imageName) {
                 // Load the new bitmap from the pictures folder
                 this.bitmap = ImageManager.loadPicture(imageName);
            } else {
                // If no image name is set for this state, clear the bitmap
                this.bitmap = null;
            }
        }
    };

    // --- Alias Spriteset_Map and Spriteset_Battle to add the sprite ---

    // Alias the createUpperLayer method in Spriteset_Map
    const _Spriteset_Map_createUpperLayer = Spriteset_Map.prototype.createUpperLayer;
    Spriteset_Map.prototype.createUpperLayer = function() {
        _Spriteset_Map_createUpperLayer.call(this); // Call the original method
        this.createLeaderImageSprite(); // Add our custom sprite
    };

    // Alias the createUpperLayer method in Spriteset_Battle
    const _Spriteset_Battle_createUpperLayer = Spriteset_Battle.prototype.createUpperLayer;
    Spriteset_Battle.prototype.createUpperLayer = function() {
        _Spriteset_Battle_createUpperLayer.call(this); // Call the original method
        this.createLeaderImageSprite(); // Add our custom sprite
    };

    // Helper function to create and add the sprite (shared by Map and Battle spritesets)
    Spriteset_Base.prototype.createLeaderImageSprite = function() {
         // Check if the sprite already exists to avoid adding duplicates
         if (!this._leaderImageSprite) {
            this._leaderImageSprite = new Sprite_LeaderImage();
            // Add it to the Spriteset's children
            this.addChild(this._leaderImageSprite);
         }
    };

})();

切记文件名一定是YourPluginName 我也不知道为什么换个名字就失效了。




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1