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

[转载发布] KSortGroup XP

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

    连续签到: 2 天

    [LV.7]常住居民III

    4469

    主题

    864

    回帖

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 5 天前 | 显示全部楼层 |阅读模式
    KSortGroup XP

    by Kyonides Arkantes



    Introduction

    Just as I've been doing lately, I've posted another scriptlet to let you get stuff done the easy way.
    At least that's what I think...

    What it does it to let you fetch the heroes or the enemies based on how strong or weak they are.


    How did I define what's strong or weak there?

    Well, I used some script calls that handle a specific stat per call.

    Following a single script call model you get any stat like this:

                    Code:       
    $game_party.members_by(:low_hp)$game_troop.members_by(:high_int)


    The former list will return a list of heroes sorted by HP in increasing order while the latter will offer you all troopers sorted by INT in decreasing order. Returns an empty list if no living member was found.

                    Code:       
    $game_party.member_by(:low_hp)$game_troop.member_by(:high_int)


    These calls let you do the same for their first member only, if that member is ALIVE.
    Otherwise it returns nil for all members are already dead.


    ? You say you need to keep that data at hand. Well, go assign it to any variable! XP

                    Code:       
    my_variable = $game_party.member_by(:low_hp)


    By the way, you've got 16 different options as I've explained in the Comments section of my script.


    The Script

                    Code:       
    # * KSortGroup XP#   Scripter : Kyonides Arkanthes# This is a scriptlet that should let you fetch a sorted list of actors based on# a specific stat like HP or PDEF, etc.# Warning!#   It won't work on the Title and File Loading scenes obviously. :P#   Here mana stands for SP in RMXP but MP in other versions.#   It will automatically pick living heroes or troopers during battles.#   It will return all heroes sorted by stat while on the map.#   It might return an empty array with no Hero or Trooper.#   Or it might return no Hero or Trooper but nil aka nothing.# * Script Call Section *# To get all members of your party or enemies#   $game_party.actors   ## Already included in RM#   $game_troop.enemies  ## Already included in RM# To get all DEAD members of your party or enemies#   $game_party.dead_members#   $game_troop.dead_members# To sort Heroes or Troopers by some basic stat using the script calls mentioned# below, use any of the following  Code  options:#   :low_hp    :high_hp    :low_mana  :high_mana#   :low_str   :high_str   :low_int   :high_int#   :low_agi   :high_agi   :low_dex   :high_dex#   :low_pdef  :high_pdef  :low_mdef  :high_mdef# To get all LIVING members of your party or enemies#   $game_party.members_by(Code)#   $game_troop.members_by(Code)# To get the FIRST member on that list# Option 1#   Add [0] to the end of your favorite script call. No spaces included!# Option 2#   Add .first to the end of your favorite script call. No spaces included!# Option 3 - The calls do the job for you.#   $game_party.member_by(Code)#   $game_troop.member_by(Code)module KSort  def self.group(type, list)    case type    when :low_hp      list.sort{|a, b| a.hp < b.hp }    when :high_hp      list.sort{|a, b| a.hp > b.hp }    when :low_mana      list.sort{|a, b| a.sp < b.sp }    when :high_mana      list.sort{|a, b| a.sp > b.sp }    when :low_str      list.sort{|a, b| a.str < b.str }    when :high_str      list.sort{|a, b| a.str > b.str }    when :low_int      list.sort{|a, b| a.int < b.int }    when :high_int      list.sort{|a, b| a.int > b.int }    when :low_agi      list.sort{|a, b| a.agi < b.agi }    when :high_agi      list.sort{|a, b| a.agi > b.agi }    when :low_dex      list.sort{|a, b| a.dex < b.dex }    when :high_dex      list.sort{|a, b| a.dex > b.dex }    when :low_pdef      list.sort{|a, b| a.pdef < b.pdef }    when :high_pdef      list.sort{|a, b| a.pdef > b.pdef }    when :low_mdef      list.sort{|a, b| a.mdef < b.mdef }    when :high_mdef      list.sort{|a, b| a.mdef > b.mdef }    end  endendclass Game_Party  def dead_members    @actors.select{|a| a.hp == 0 and !a.hidden }  end  def living_members    @actors.select{|a| a.hp > 0 and !a.hidden }  end  def members_by(type)    list = $game_temp.in_battle ? living_members : @actors    KSort.group(type, list)  end  def member_by(type)    members_by(type)[0]  endendclass Game_Troop  def dead_members    @enemies.select{|a| a.hp == 0 and !a.hidden }  end  def living_members    @enemies.select{|a| a.hp > 0 and !a.hidden }  end  def members_by(type)    KSort.group(type, living_members)  end  def member_by(type)    members_by(type)[0]  endend


    Terms & Conditions

    Free for use in any kind of game.
    Include my nickname in your game credits.
    Mention this forum in your game credits as well.
    Give me a free copy of your completed game if you include at least 2 of my scripts!



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

    本帖子中包含更多资源

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

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

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-7-14 17:54 , Processed in 0.066038 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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