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

[制作教程] [Ace] Custom Stats Overhaul (scripting)

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

    连续签到: 2 天

    [LV.7]常住居民III

    4461

    主题

    864

    回帖

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 前天 14:07 | 显示全部楼层 |阅读模式
    Background:
    Stats are the element of a game that has a big role. Everything on gameplay are driven by stats and their number. The default engine provides a wonderful tools to tweak it. However, when you want to extend the usability, you can't help but to search what people offers to you and dependent on any script that had been released. While you can easily tweak it if you know how the stats works on default script.

    For example, you want to make a weapon increase the stat by 10 ONLY when an actor has a certain state, and 5 when it's not. It is not possible within the default editor that you have to resort to request a custom script for that. This tutorial exist to help you with that so (I hope) you can help yourself.

    I'm not native English speaker, so I'll try my best to explain.

    Disclaimer!
    This tutorial means to be used as guide to make your game. It does not mean to be used to write a proper script to be released for other people to use. As it requires a careful written script that can ensure compatibility, bugs, and many things. Even if you do, you take all the responsibility of the script you're releasing.

    Requirements:

    • Know most if not all the basic functions of RM (if you don't, please watch / read other's tutorial)
    • A basic sense of math
    • A basic sense of true/false logic
    • A basic Ruby/RGSS3 scripting knowledge would be a plus
    How stat is calculated?
    First, let's take a peek on the default script, Game_BattlerBase > Line 267




    These chunks of codes tell you the formula of how the stat is calculated. To make it more understandable in human language, I'm gonna tell you in simpler version.

    • First, the game fetch the stats from Database > Class. Say the ATK is 20 in database.
    • Then 20 is added by permanent modifier. Something like, when you make an item or event that can permanently add stats. e.g, You eat a power pill, your attack increased by +5 permanently. It also comes from flat stat boost from equipment that is equipped to your actor.
    • Once addition it's done, it's multiplied by many modifiers. For example, a state that boost ATK by 200%, now you have ATK value = 50
    • Then the game caps the stat to a certain value. For ATK, it has the ceiling cap equal to 999 and the bottom cap equal to 1.
    Thus the formula can be written like this:
                    Code:        
    1. final_stat = (base + plus) * rate_modifier
    复制代码


    Knowing this is important. Because, where you change the formula could affect the final outcome. Like, would you like to modify the final value? or rather the base value? Both will result a different outcome.

    Say, Base value is 20. You changed that and it becomes 25. Multiplied by 200%, it becomes 50. If you modify the final value, then it will be 20 * 200% + 5 = 45

    The fun part!
    Let's get straight to the point of how you gonna modify these formula. But before we proceed, I need you to know the param id. This is important to know which stat you're going to modify.

    • 0 = MaxHP
    • 1 = MaxMP
    • 2 = ATK
    • 3 = DEF
    • 4 = MAT
    • 5 = MDF
    • 6 = AGI
    • 7 = LUK
    I'm going to use the example I wrote on the background section. We're making the weapon ID 1 increase stat by 10 when an actor has state id 10. We're going to change the base.

    First, you create a slot on your editor that I expect you already know how to do it if you know how to install script. Write this.
                    Code:        
    1. class Game_Actor
    2.   def param_base(param_id)
    3.     value = self.class.params[param_id, @level]
    4.     # We're going to insert the codes here
    5.     return value
    6.   end
    7. end
    复制代码


    Next, we need to check the state. Check if equipment is equipped, and we use param ID 2 (Attack).
    To check if state ID 10 is present, we can use this.
                    Code:        
    1. state?(10)
    复制代码

    To check equipment, we can use this.
                    Code:        
    1. equips.include?($data_weapons[1])
    复制代码

    To filter the parameter so that it only affect atk, we need this
                    Code:        
    1. param_id == 2
    复制代码

    Ignoring the filter and it will be applied to all stats.

    We're going to increase the stat by 10 while the actor is equipping the weapon and has the state. If the state is not present, it will only increase it by 5
                    Code:        
    1. class Game_Actor
    2.   def param_base(param_id)
    3.     value = self.class.params[param_id, @level]
    4.     #-----------------------------------------------------------
    5.     if param_id == 2 # <-- Modify only attack stat
    6.       if equips.include?($data_weapons[1]) # <-- Check equip first
    7.         if state?(10) # <-- after equip, check state
    8.           value += 10
    9.         else
    10.           value += 5
    11.         end
    12.       end
    13.     end
    14.     #-----------------------------------------------------------
    15.     return value
    16.   end
    17. end
    复制代码


    What if you want to change into a multiplicative one instead of additive? Say, increase the ATK stat by +20%, and +10% otherwise?
    You can change the code like this.
                    Code:        
    1. class Game_Actor
    2.   def param_base(param_id)
    3.     value = self.class.params[param_id, @level]
    4.     #-----------------------------------------------------------
    5.     if param_id == 2 # <-- Modify only attack stat
    6.       if equips.include?($data_weapons[1]) # <-- Check equip first
    7.         if state?(10) # <-- after equip, check state
    8.           value *= 1.2
    9.         else
    10.           value *= 1.1
    11.         end
    12.       end
    13.     end
    14.     #-----------------------------------------------------------
    15.     return value
    16.   end
    17. end
    复制代码


    That is if we want to change the base. If we're changing from the final stat, use this instead
                    Code:        
    1. class Game_Actor
    2.   def param(param_id)
    3.     value = super(param_id)
    4.     # Insert the code here
    5.     return value
    6.   end
    7. end
    复制代码


    Be creative!
    This custom stat overhaul has limitless possibilities. Don't let my example limits your creativity. You can make the stat affected by weather if you managed to get weather check. Or stat affected by game variables, or even it only affect a certain actor.

    Some handy symbols to use if you want to some conditions
    SpoilerTrue/False check

    • == Equal as
    • < Lesser than
    • > Bigger than
    • >= Bigger or equal than
    • <= Lesser or equal than
    • != Is not the same as
    Basic operations

    • += add
    • -= substract
    • *= multiply
    • /= division
    • %= modulo (remainder of a division)





    Limitation
    There're too many possibilities can be made using this method that I have no time writing them all. Besides it will be too long to write them all here. I might want to update this tutorial for more tips and trick of overhauling the stats system later time. But as for now, I will leave it like this.

    If you have question of how to make custom stat overhaul or more suggestions, feel free to post!


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

    本帖子中包含更多资源

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

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

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-7-14 16:52 , Processed in 0.065896 second(s), 58 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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