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

[制作教程] Mad Skills I -Ver 1.0-

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

    连续签到: 2 天

    [LV.7]常住居民III

    4446

    主题

    864

    回帖

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 3 天前 | 显示全部楼层 |阅读模式
    Mad Skills I

    By: Rinobi

    !warning! OVER 3,000 WORDS !warning!

    So I thought I’d do a simple tutorial on setting up advanced skills in RPG Maker as a way to give back to the community that has helped me come this far. I’m writing this guide under the assumption that my readers are familiar with the basics of RPG Maker. This guide will require a bit of Ruby programming (I’ll walk you through those parts), and a lot of algebra. I recommend starting up a new project so that you may reference your work later.[/SIZE]

    Part one will cover the basics required to make these skills work. In part two we’ll dive into some interesting skills available to this setup, as well as setting up a custom turn management system for combat. Where I go from there will depend on demand I guess.[/SIZE]

    RequirementsRPG Maker Basics, High School Algebra[/SIZE]

    Recommendations: (Check these out if you haven’t.)[/SIZE]

    Damage Formula Reference Guide[/SIZE]

    How To Make The Most Of Custom Formulae Part 1[/SIZE]

    Skill Ideas You Can Do With Custom Formula[/SIZE]

    Warmup[/SIZE]

    First we’ll cover the damage formula basics. This is more of a refresher and I won’t bother going into great detail as there are already informative tutorials out there. In fact, we’ll just briefly talk about the default formulas available when you start a new project, and how you can improve upon them. [/SIZE]

    Default Attack: [/SIZE]

    a.atk * 4 – b.def * 2Nothing really wrong with this approach, it’s straightforward and easy to understand, but let’s explore another simplistic option.[/SIZE]

    Alternate Attack: [/SIZE]

    a.atk * (a.atk / b.def.to_f)This formula uses a multiplier for the user’s ATK value. If the user’s ATK is greater than the Target’s DEF, the multiplier increases. If the reverse is true, the multiplier decreases, reducing the damage output. The cool thing about this formula is that damage will pretty much never hit 0 (it can, but very unlikely). The downside is that damage values can get pretty insane when there’s a huge difference between ATK and DEF. If you’re going to use this, I’d recommend writing in a damage limiter.[/SIZE]

    Alt Attack 2: [/SIZE]

    x = a.atk / b.def.to_f ; x > 4 ? x = 4 : x ; a.atk * xNow the User’s attacks will never deal more than four times damage. You will find that the more you develop your formulas, the more complex they tend to get. Don’t be discouraged by this mess of symbols, numbers and letters, they all start from simple ideas. Now before we get to the cool stuff, let’s cover a few basics that will definitely help you in the long run. If you’re already familiar with programming basics, feel free to skip ahead to “Localized Damage Formulas”.[/SIZE]

    Separator[/SIZE]

    The “ ; “ semicolon here basically acts as a separator for your code in situations where you can’t or don’t want to hit ENTER and start typing on a new line. It allows you to make some additional calculations without having Ruby just spit the code out as is. You only have one line to work with within a skill’s formula box so keep this in mind. It’ll make more sense once you’ve used it a few times.[/SIZE]

    Local Variables[/SIZE]

    In the formula above, did you note the use of x? That’s a local variable, kinda like those used in your algebra class, except instead of solving for x, we control what x is. There are different types of variables, such as Instance, Class, and Global, but let’s keep things simple. x as I’ve defined it in the previous formula will only work within the scope of that formula at the moment the skill is used. Even if say, an enemy or party member uses that same skill, the value of x will differ based on the ATK and DEF values the moment it's used. Also you don’t have to use x, you can use any letter, combination of letters/numbers, or words that you wish, so long as they’re lower case. Uppercase ‘variables’ in Ruby are called Constants… they’re not really variables at all… moving on.[/SIZE]

    Local variables can be used in a lot of ways, and it’s imperative that you develop a keen understanding of how they work. More on that in a moment.[/SIZE]

    Note: If you’re going to use numbers in your variables, make sure that they come directly after a letter: x1. Ruby will get mad if you try it the other way around.[/SIZE]

    Boolean Logic[/SIZE]

    Funny name right? Well Boolean is serious business so learn it if you don’t know already. Instead of just crunching numbers, Boolean deals in what is true and what is false. In the previous formula, I made use of simple Boolean to help me limit the amount of damage a skill can do. There’s a lot of different ways to write it, but let’s just cover the simple IF statement.[/SIZE]

    Here’s the scenario: The hero of your game has a unique skill for dealing with especially tough enemies. It works like a normal attack, but if the enemy manages to resist the damage entirely, it deals 100 times your character’s level as damage instead. How do we make this skill a reality?[/SIZE]

    Firstly “It works like a normal attack”, so we use whatever your default attack is.[/SIZE]

    a.atk * 4 – b.def * 2Next “It deals 100 times your character’s level as damage.” Simple enough.[/SIZE]

    100 * a.level (enemy’s do not have levels by default, so it won’t work for them.)

    Since we're dealing with two separate formulas, we may as well store them within local variables.[/SIZE]

    x = a.atk * 4 - b.def * 2 ; y = 100 * a.level ; Now apply the Boolean![/SIZE]

    if x <= 0 then y ; else x endLearn how to say it out loud! “X equals the user’s attack stat times four, minus the target’s defense stat times two. Y equals one hundred times the user’s level. If X is greater than or equal to zero, then return Y, otherwise return X”. Remember those math word problems from the fourth grade? Similar concept.[/SIZE]

    End result? : [/SIZE]

    x = a.atk * 4 - b.def * 2 ; y = 100 * a.level ; if x <= 0 then y ; else x endThere’s more than one way to write this exact formula, so I’ll list a few.[/SIZE]

    a.atk * 4 - b.def  * 2  <= 0 ? a.level * 100 : a.atk * 4 - b.def * 2                                      Code:        
    1. x = (a.atk * 4 - b.def  * 2) ; x  <= 0 ? a.level * 100 : x
    复制代码

                    Code:        
    1. x = (a.atk * 4 - b.def  * 2) ; y = a.level * 100; x <= 0 ? y : x
    复制代码

                    Code:        
    1. x = a.atk * 4 - b.def * 2y = a.level * 100if x <= 0  yelse  xend
    复制代码

                    Code:        
    1. x = a.atk * 4 - b.def * 2y = a.level * 100x = y if x <= 0 ; x
    复制代码

    You get the idea… If you really need the extra characters in your skill’s formula box, keep in mind that the spaces are largely unnecessary, they just looks cleaner.[/SIZE]

    Integers, Floats, and Strings[/SIZE]

    Integer: A number like 4 or 17…[/SIZE]

    Float: A number with decimal points. Ex: 1.46586[/SIZE]

    String: Text of some kind. Usually between these “” quotations. Most things can be returned as a string. Just know that strings aren’t evaluated the same way as variables and numbers.[/SIZE]

    .to_i     .to_f    .to_s    (to integer, to float, to string)[/SIZE]

    There’s quite a bit more to it than the above, but you’ll need to read up on it if you really need to know more. When Ruby errors or other programmers mention things like this, just think of what I’ve listed above as a very basic understanding.[/SIZE]

    So, why are we talking about these? Well… you’ll be dealing with floats and integers quite often when writing damage formulas, so let’s return to a previous example.[/SIZE]

    a.atk * (a.atk / b.def.to_f)If we were to remove “.to_f”, the formula would fail to properly perform in situations where DEF is greater than ATK. Instead we’d get a multiplier rounded to 1 or 0. Let’s replace these stats with numbers to give you a visual of what I mean.[/SIZE]

    Assume: a.atk = 20, b.def = 30[/SIZE]

    Without Float: 20 * (20 / 30) = 20[/SIZE]

    With Float: 20 * (20 / 30.to_f) = 13 - rounded[/SIZE]

    One more time: a.atk = 45, b.def = 300[/SIZE]

    Without Float: 45 * (45 / 300) = 0[/SIZE]

    With Float: 45 * (45 / 300.to_f) = 7 - rounded[/SIZE]

    Localized Damage Formulas[/SIZE]

    Now that the basics are out of the way, let’s get into the good stuff. If you’re going to be using the same formula over and over again with slight variations (practically every game), then it’s a good idea to simply use the same formula rather than repeating yourself for each skill. Not only is this more convenient… it opens up a lot of possibilities for some awesome and unique skills! This requires a little coding, but again, I’ll walk you through it.[/SIZE]

    [/url]

    First, open up your script editor and insert (literally press ‘Insert’ on your keyboard) below Materials and above Main near the bottom of the list. Then click within the blank text field on the right and type this:[/SIZE]

    class Game_Battler < Game_BattlerBaseendNow we’re going to create a method “damage”, you can name yours whatever you want, just make sure it looks something like mine.[/SIZE]

    class Game_Battler < Game_BattlerBase  def damage(a,   endendBelieve it or not, the coding part is pretty much out of the way (not really). Let’s say for whatever reason, we want to do things the same way that they’re done by default, except using this localized formula. In order for us to do that, we need to see what differs from skill to skill. First thing’s first though, let’s test this to see if it works.[/SIZE]

    We’ll be using: a.atk * 4 - b.def *2[/SIZE]

    Add it to your code like so.[/SIZE]

    class Game_Battler < Game_BattlerBase  def damage(a,     a.atk * 4 - b.def * 2  endendNow insert the a.damage(a, b )[/SIZE] (or whatever you came up with) into your formula textbox. And test it in-game to see if it’s working. It’s a good idea to test your code often as you build it. Remember to save your game beforehand, so that the new script loads.[/SIZE]

    [url=https://forums.rpgmakerweb.com/attachments/tms1-png.23602/]


    Okay, so we want this code to be flexible enough to easily formulate any of the default skills. We’ll add flexibility two steps at a time to speed things up. If we scroll down the skill list a little we see that the Breath attacks and the Vampire skill have differing formulas. We’re going to need to add a few additional features to our damage method.[/SIZE]

    Return to the script editor and modify your method like so that it looks something like this: damage(a, b, o, d, t). We’re allowing our method to accept three new arguments. Again, you can name these what you like, but I’d recommend keeping things as short and straightforward as possible. You can also use them anyway you like, however, an example is more informative so…[/SIZE]

    O = offense[/SIZE]

    D = defense[/SIZE]

    T = type[/SIZE]

    We’re going to use these just like local variables. Set up your formula so that it looks like this. Remember to save![/SIZE]

    #===============================================================================# Mad Skills I## a = user# b = target# o = offense# d = defense# t = type#===============================================================================class Game_Battler < Game_BattlerBase  def damage(a, b, o, d, t)    t = 0    a.atk * o - b.def * d  endendNote: This "#" symbol is used to create comments within your code. Ruby will ignore anything after it, but on the same line.

    The plot thickens… We’ll get to ‘type’ in a moment, let’s test this out first. Change the formula of the Attack skill to look like this: a.damage(a, b, 4, 2, 0). See what I did there? We’re setting up the values of the variables we used in our formula. This should work the same as the normal attack. Visit the Breath attacks and change them to look like this: a.damage(a, b, 1, 0, 0). Keep in mind that we’re multiplying, so b.def * 0 is always 0. We just created an attack that bypasses defenses. Finally move on to Vampire… Change the value appropriately and test it out. This attack drains hp, but you’ll find that our custom formula works as an exact replacement here as well. [/SIZE]

    [/url][url=https://forums.rpgmakerweb.com/attachments/tms3-png.23604/][url=https://forums.rpgmakerweb.com/attachments/tms4-png.23606/][/url]

    I’m sure you get the gist of it by now, so we’ll start moving things along. Although you can also use this for healing, I’d recommend creating a separate method for such things, it’ll save you some trouble in the future.[/SIZE]

    Alright, RPG Maker VX Ace comes with 123 stock skills, let’s account for them all. We’ll ignore healing for now, which brings us to magic attacks. These attack measure MAT against MDF along with an additional flat damage value. Let’s go ahead and write that in, you know the drill. [/SIZE]

    damage(a, b, f, o, d, t)[/SIZE]

    I’ve added an additional argument to our method, and we’re actually going to be using ‘type’ this time around. Before that though, Boolean needs to have a word with us. You see, Boolean isn’t all IF statements, and it would prefer that we don’t use them if we really don’t need to. In a situation like this, it’s better to use ‘case’ and ‘when’. Set it up like this.[/SIZE]

    case twhen 1 then #physicalwhen 2 then #magicalelse # bacon saverendThis is a bit neater than typing multiple IF statements or one long IF statement. However, if you want to know what that would look like anyway.[/SIZE]

    if t == 1  # physicalelsif t == 2  # magicalelse  # bacon saverendOr[/SIZE]

    if t == 1 then # physicalelsif t== 2 then # magicalelse # bacon saverendOr[/SIZE]

    if t == 1 then \formula\ endif t == 2 then \formula\ end# your bacon is mine!Or[/SIZE]

    t == 1 ? \physical\ : \bacon saver\t == 2 ? \magical\ : \bacon saver\Although I’d recommend sticking with ‘case’, these IF statements will do as well. Except the last one since the code is read from top to bottom… Let’s not get too far off topic; back to our code…[/SIZE]

    Curious about the 'bacon saver'? All it does is return the default physical attack formula should we set 't' incorrectly. This can admittedly be a bad thing since you probably won't even notice that you've set a skill type incorrectly. Use it or don't, up to you.

    Okay so we’re going to need to re-write our formula. You know how this goes, so just take look at my example: ‘x = f + a.atk * 0 - b.def * d’. Note that we’re using the local variable ‘x’ to store the result of our formula. There’s a few good reasons for this that will hopefully become apparent later. f = flat damage, meaning it’s not influenced by the user’s stats. That’s how I remember it anyway, call it what you will. The reason we’re doing this is to account for magic damage. Check this out:[/SIZE]

    #===============================================================================# Mad Skills I## a = user# b = target# f = flat damage# o = offense# d = defense# t = type#===============================================================================class Game_Battler < Game_BattlerBase  def damage(a, b, f, o, d, t)        case t # Skill Type    when 1 then x = f + a.atk * o - b.def * d # physical    when 2 then x = f + a.mat * o - b.mdf * d # magical    else x = f + a.atk * o - b.def * d # your bacon is secure    end        x # Result  endendDO NOT FORGET TO SAVE! Alright, I have a bit of bad news for ya. You’re going to need to go back and update your old skills to include the new arguments. If you don’t, Ruby will either throw errors in a blind rage, or your skills won’t work at all. If you want your normal attack to work again for example: a.damage(a, b, 0, 4, 2, 1). Anyway, let’s get to the magic. Now I believe the first magic attack that deals damage based on MAT is Life Drain. It compares MAT to MDF and deals an extra 200 flat damage. So we set it up like this: a.damage(a, b, 200, 4, 2, 2). The rest of the magic attacks have a similar setup, so feel free to experiment at this point, but… don’t set them all just in case we change our formula again.[/SIZE]

    Certainly interesting, but what’s the point of this? What have we done that can’t already be accomplished just setting the formulas individually? I’ll try to answer that now before we finish our setup. Let’s try another scenario…[/SIZE]

    Scenario: A scout class character joins your party. He’s not very strong, but he does have a very useful skill: ‘Expose Flaws’. For 8 turns, the affected enemy has an additional 50% chance to receive critical hits.[/SIZE]

    No complicated common events, and no fake critical by doubling or tripling damage. Let’s do this right.[/SIZE]

    First, create a state that lasts 8 turns. I’ll call mine ‘exposed’.[/SIZE]

    Second, create the skill which applies the state to a single enemy. 'Exploit Flaws'[/SIZE]

    (No screenshots! You know this!)

    Now we’re heading back into our damage formula for a bit of coding.[/SIZE]

    #===============================================================================# Mad Skills I## a = user# b = target# f = flat damage# o = offense# d = defense# t = type#===============================================================================class Game_Battler < Game_BattlerBase  def damage(a, b, f, o, d, t)        case t # Skill Type    when 1 then x = f + a.atk * o - b.def * d # physical    when 2 then x = f + a.mat * o - b.mdf * d # magical    else x = f + a.atk * o - b.def * d # your bacon is secure    end        if b.state?(26) # exploit state id      ext = 1+rand(99)      b.result.critical = true if ext < 51    end        x # Result  endendThat’s all there is to it… Since this formula will manage all damage dealt in battle, the skill will work the same way no matter who uses it.[/SIZE]

    Alright, let’s finish our setup, we want a formula that can correctly manage all of RPG Maker’s stock damage dealing skills. We’ve covered spells, so let’s move on to some of the more unique skills. The first thing that comes to mind is ‘Tackle’. This attack deals damage based on the user’s ATK and DEF. Instead of adding another argument to our method, let’s just make a unique skill type. The original formula is: a.atk * 4 + a.def * 2 – b.def * 2. We’ll simply take advantage of the fact that the defense value is half that of attack.[/SIZE]

    when 3 then x = f + a.atk * o + (a.def * (o / 2)) - b.def * 2 # atk/defSkill Formula: a.damage(a, b, 0, 4, 2, 3)[/SIZE]

    Aura Blade deals damage based on the user’s ATK and MAT, and the target’s DEF and MDF. The original formula: a.atk * 4 + a.mat * 3 – b.def – b.mdf. Again, it’d be easier to just make a new skill type.[/SIZE]

    when 4 then x = f + a.atk * o + (a.mat * (o * 0.75)) - (b.def + b.mdf) * dSkill Formula: a.damage(a, b, 0, 4, 1, 4)[/SIZE]

    Radiant Blade is very similar to Aura Blade. In situation like this, it’s best to just use the same formula as aura blade, or adjust the formula so that it fits Radiant Blade. Not worth making a new skill type here, but you can if you want.[/SIZE]

    Triple Shot relies on the AGI stat in pretty much the same way as tackle. The setup is the similar.[/SIZE]

    when 5 then x = f + a.atk * o + (a.agi * (o / 2)) - b.def * d # atk/agiThousand arrows is very similar to Triple Shot, and not really worth another skill type.[/SIZE]

    Assassin’s Edge and Valiant Edge rely on the LUK stat, and you’d set up a new skill type the same as above.[/SIZE]

    when 6 then x = f + a.atk * o + (a.luk * (o * 2)) - b.def * d # atk/lukThat's it! We now have a localized damage formula that accounts for all of the stock damage dealing skills. In part 2, we’ll get into some of the amazing skills you can easily put together using this setup. That ends part one. Here’s a final look at our code. Until next time![/SIZE]

                    Code:        
    1. #===============================================================================# Mad Skills I## a = user# b = target# f = flat damage# o = offense# d = defense# t = type#===============================================================================class Game_Battler < Game_BattlerBase  def damage(a, b, f, o, d, t)        case t # Skill Type    when 1 then x = f + a.atk * o - b.def * d # physical    when 2 then x = f + a.mat * o - b.mdf * d # magical    when 3 then x = f + a.atk * o + (a.def * (o / 2)) - b.def * d # atk/def    when 4 then x = f + a.atk * o + (a.mat * (o * 0.75)) - (b.def + b.mdf) * d    when 5 then x = f + a.atk * o + (a.agi * (o / 2)) - b.def * d # atk/agi    when 6 then x = f + a.atk * o + (a.luk * (o * 2)) - b.def * d # atk/luk    else x = f + a.atk * o - b.def * d # your bacon is secure    end        if b.state?(26) # exploit state id      ext = 1+rand(99)      b.result.critical = true if ext < 51    end        x # Result  endend
    复制代码




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

    本帖子中包含更多资源

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

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

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-7-14 14:20 , Processed in 0.091256 second(s), 56 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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