じ☆ve冰风 发表于 2026-7-16 16:33:55

(Relatively) Simple Steal System Plugin for MZ

Update 05/09/2023 - This plugin is outdated and superceded by my much less buggy and much easier to use new steal plugin AUTMOUSE_Steal.js. Please use it instead.
---------------------------

Hello everyone. This is the first plugin I am releasing. I made it using CoffeeScript and have tested it on both an active project and a fresh project.

This plugin allows you to set up a steal skill that is powered by a common event. You create you steal lists per enemy using note tags. I went looking for a steal system but couldn't find any that were not part of larger systems so I decided to make my own.

It was hard! I learned so much, and I think it is a pretty useful little plugin. Let me know if you have questions. I am going to make a video tutorial for it this weekend. I am also thinking of making a video for those who are interested in making plugins using CoffeeScript. CoffeeScript is Ruby like and may be easier for some than js. It is for me.

                JavaScript:       
// Generated by CoffeeScript 2.7.0

//=============================================================================
// Simple Steal System for RPG Maker MZ
// penny_steal.js
// Copyright (c) 2022
//=============================================================================
/*:
* @target MZ
* @plugindesc Allows for the creation of a steal or mug skill.
* @author Penny Gautreaux
*
* @help AMMZ_Steal.js
*
* This plugin is some assembly required.
* Create a steal skill and configure it however you like.
* In the damage formula use the following:
* $gameVariables.setValue(20, b.enemyId()); ammzSteal.target = b; ammzSteal.user = a; (a.atk * 4 - b.def * 2) * 0.5
* Replace the number 20 with the number you set to targetVariable parameter
* The damage at the end (a.atk * 4 - b.def * 2) * 0.5 is optional.
* Change or remove it to change or remove damage output from the skill.
* the stuff before the final semicolon is required!
* Under actions have the skill run a common event.
*
* The Common Event should be set to Trigger None
* In the common event set the variable you used for Parameter targetItemVariable
* to choose a random number between 0 and 3
* The add a script event on page three with the following in the script:
* ammzSteal.steal()
*
* Next create two states a rareStealState and a alreadyStolenFrom state.
* You can call them whatever but make sure they correspond to the id you set in
* the parameters, e.g. if parameter says 32 it needs to be state 32.
*
* Rare stealing is ignored by default but you can enable by having an item or equip
* apply the state to the character using the steal skill.
*
* Lastly put notetags on every entry in your Enemies database.
* Even things that are not really enemies. It will crash if you don't
*
* <stealList:x,x,x,x> where x is a database id for an item.
* or
* <rareStealList:y,y,y,y> where y is a database id for an item that you want to be on the rare steal list.
*
* Examples
* <stealList:-1,-1,-1,-1> means nothing to steal
* <stealList:7,7,7,7> means only stealable item is item 7 in the database
* <rareStealList:23,23,24,24> means item 23 or 24 in the database may be stolen but only if rare steal is on.
*
*
*
* -License
* This plugin is distributed under the MIT license.
* Feel free to use it.
* http://opensource.org/licenses/mit-license.php
*
* @param targetVariable
* @type number
* @desc Choose a variable that will hold the id of the target of the skill.
* @text Variable to store target ID to.
* @default 20
*
* @param targetItemVariable
* @type number
* @desc Choose a variable that will hold the id of item being stolen.
* @text Variable to store stolen item ID to.
* @default 19
*
* @param rareStealState
* @type number
* @desc State that enables stealing from the rare steal list.
* @text Rare Steal State
* @default 33
*
* @param alreadyStolenFromState
* @type number
* @desc state for enemies that says they have already been stolen from.
* @text Already stolen from state
* @default 32
*/
var ammzSteal;

ammzSteal = ammzSteal || {};

ammzSteal.parameters = PluginManager.parameters('AMMZ_Steal');

ammzSteal.stealList = ;

ammzSteal.rareStealList = ;

ammzSteal.tempArray = ;

ammzSteal.tempArray2 = ;

ammzSteal.rareStealState = 33;

ammzSteal.alreadyStolenFromState = 32;
(function () {
ammzSteal.setupSteal = function () {
    var counter, enemy, i, j, k, len, len1, len2, purse, ref, ref1, results;
    // Create an array of strings from meta tags in database
    counter = 1;
    for (i = 0, len = $dataEnemies.length; i < len; i++) {
      enemy = $dataEnemies;
      if (enemy !== null) {
      ammzSteal.tempArray.push(enemy.meta.stealList.split(','));
      ammzSteal.tempArray2.push(enemy.meta.rareStealList.split(','));
      }
    }
    ref = ammzSteal.tempArray;

    // Add enemy purses to Steal List
    for (j = 0, len1 = ref.length; j < len1; j++) {
      purse = ref;
      if (purse !== null) {
      ammzSteal.stealList.push(purse);
      }
    }
    ref1 = ammzSteal.tempArray2;

    // Add enemy purses to Rare Steal List
    results = [];
    for (k = 0, len2 = ref1.length; k < len2; k++) {
      purse = ref1;
      if (purse !== null) {
      results.push(ammzSteal.rareStealList.push(purse));
      } else {
      results.push(void 0);
      }
    }
    return results;
};

ammzSteal.steal = function () {
    // Get steal list from enemy
    ammzSteal.whichMonster = $gameVariables.value(parseInt(ammzSteal.parameters.targetVariable));
    ammzSteal.whichItem = $gameVariables.value(parseInt(ammzSteal.parameters.targetItemVariable));
    ammzSteal.rareStealState = parseInt(ammzSteal.parameters.rareStealState);
    ammzSteal.alreadyStolenFromState = parseInt(ammzSteal.parameters.alreadyStolenFromState);
    if (ammzSteal.user.isStateAffected(ammzSteal.rareStealState)) {
      ammzSteal.item = ammzSteal.rareStealList;
    } else {
      ammzSteal.item = ammzSteal.stealList;
    }
    ammzSteal.stealChance = Math.randomInt(101);
    if (ammzSteal.target.isStateAffected(ammzSteal.alreadyStolenFromState)) {
      $gameMessage.add("The enemy doesn't have anything else to steal.");
    } else if (ammzSteal.stealChance <= 50) {
      if (ammzSteal.item !== -1) {
      $gameParty.gainItem($dataItems, 1);
      $gameMessage.add('You stole a ' + $dataItems.name + '!');
      ammzSteal.target.addState(ammzSteal.alreadyStolenFromState);
      } else {
      $gameMessage.add("Nothing to steal...");
      }
    } else {
      $gameMessage.add('You were unable to grab anything.');
    }
};

}).call(this);




本贴来自国际rpgmaker官方论坛作者:cetra777处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/relatively-simple-steal-system-plugin-for-mz.153818/
页: [1]
查看完整版本: (Relatively) Simple Steal System Plugin for MZ