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

[转载发布] Party Stealer

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

    连续签到: 2 天

    [LV.7]常住居民III

    9071

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 2026-8-2 13:39:27 | 显示全部楼层 |阅读模式
    Date: Feb 21, 2020
    Script Name:
    Author: Harosata/Dramatic Lightning Co

    Introduction:
    This script will allow an event to "borrow" a party member (usually the leader).  Using the script calls will turn on/off the D self-switch for that event.

    Update:
    Feb 22 - Added more functions.  You can remove first or last follower.  You can also see if event holds an actor, if any actor is missing on current/any map, and retrieving actors from current/any map.

    How to Use:
    1. Use the party_steal(state_id = 0, actor_id = 0) in your Event's script call to take away your party member. By default, your leader will be captured, but you can add a "display state" and you can take away a specific actor instead.

    2. Use the party_return(state_id = 0) to return an actor to your party. The display state will be removed, but you can also add a new state upon their release. This does nothing if the event hasn't captured a party member. You can also use Add Party Member with similar results.

    3. Use the party_relocate(actor_id, state_id = -1) to transfer the party member from one event to another. You can set the state_id to replace (or 0 to erase) the display state.  This does nothing if the actor is not in another event.

    4. Comment <ActorReplace> inside that event's page and the event can look like your borrowed party member. If you have a graphic-change script, it makes the state_ids above have more worth.

    Additional:
    -You can also script call $game_map.events[id].party_***** should you feel like certain events on the map can use this.
    -You should be able to use a follower-touch script like Himework's Follower Touch Event to have the event take your followers instead.

    Terms and Credit:
    Free to use, nice to credit.

                    Ruby:       
    1. =begin
    2. =begin
    3. #===============================================================================
    4. Title: Party Stealer
    5. Author: Dramatic Lightning Co
    6. Date: Feb 21, 2020
    7. --------------------------------------------------------------------------------
    8. Changelog:
    9. -Feb 21, 2020 - Extended script
    10. -- Using -1 or -2 as the actor id for party_steal lets you take the first/last
    11.     follower if event touches player.
    12. -- holds_member?(actor_id) returns true if the actor is assigned to that event.
    13. -- lost_members?(all_map = false) returns true if the map has any lost members.
    14. -- retrieve_lost_members(all_map = false) will add all members from that map.
    15.   (if all_map is true, returns true if any member is considered missing or
    16.    adds all missing members depending on the function)
    17. --------------------------------------------------------------------------------
    18. This script will use Self-Switch D.  If an event doesn't use the script calls,
    19. you can still use this self-switch normally.  Also, note that the party
    20. cannot be stolen if the party size is at 1.
    21. When you use this script, use a party_steal script-call from a map event
    22. or $game_map.events[id].party_steal to have that event "steal" your party leader
    23. (with Himework's Follower Event Touch or similar, the event can steal a follower).
    24. You can extend this with party_steal(state_id) to change the stolen member's
    25. state (if you use a state-dependent character graphic script) and
    26. party_steal(state_id, actor_id) if you want to steal a specifc actor instead.
    27. (state_id can be set to 0 if you don't want to apply a state)
    28. --------------------------------------------------------------------------------
    29. You can use party_return or $game_map.events[id].party_return to return
    30. the stolen member back to your party and remove their display state.
    31. You can extend this with party_return(state_id) to add a new state upon
    32. their release.  Alternatively, adding that character back with Add Actor
    33. will reset the association with that event.
    34. You can also use party_relocate(actor_id) or
    35. $game_map.events[id].party_relocate(actor_id) to reassign the actor to that
    36. event.  You can extend this with party_relocate(actor_id, state_id) if you want
    37. to replace their display state (or remove that state with 0).
    38. --------------------------------------------------------------------------------
    39. You can also comment the "D" Event Page with <ActorReplace> to replace
    40. the event's graphic with your character.  As stated above, you can use a
    41. state-dependent character graphic script on your actor to affect that event's
    42. appearance.  If you opt not to use this tag, the event's own appearance
    43. will be used instead.
    44. #===============================================================================
    45. =end
    46. module RPG
    47.   class Event::Page
    48.     def actor_replace
    49.       @list.each {|cmd|
    50.         if cmd.code == 108 && res = cmd.parameters[0].match(/<ActorReplace>/i)
    51.           return true
    52.         end
    53.       }
    54.       return false
    55.     end
    56.   end
    57. end
    58. class Game_Interpreter
    59.   def party_steal(playerstate = 0,playerid = 0)
    60.     $game_map.events[@event_id].party_steal(playerstate, playerid)
    61.   end
    62.   def party_return(playerstate = 0)
    63.     $game_map.events[@event_id].party_return(playerstate)
    64.   end
    65.   def party_relocate(playerid, replace_state = -1)
    66.     $game_map.events[@event_id].party_relocate(playerid, replace_state)
    67.   end
    68.   def holds_member?(actorid)
    69.     return $game_map.events[@event_id].holds_member?(actorid)
    70.   end
    71.   def lost_members?(all_map = false)
    72.     $game_party.lost_members?(all_map)
    73.   end
    74.   def retrieve_lost_members(all_map = false)
    75.     $game_party.retrieve_lost_members(all_map)
    76.   end
    77. end
    78. class Game_Party < Game_Unit
    79.   attr_accessor :owned
    80.   alias :dl_party_steal_initialize :initialize
    81.   def initialize
    82.     @owned = []
    83.     dl_party_steal_initialize
    84.   end
    85.   alias :dl_party_steal_add_actor :add_actor
    86.   def add_actor(actor_id)
    87.     dl_party_steal_add_actor(actor_id)
    88.     @owned.each_index do |i|
    89.       a = $game_party.owned[i]
    90.       next if a == nil
    91.       if a[2] == actor_id
    92.         $game_self_switches[[a[0], a[1],"D"]] = false
    93.         $game_actors[a[2]].remove_state(a[3]) if a[3] > 0
    94.         $game_party.owned[i] = nil
    95.       end
    96.     end
    97.   end
    98.   def lost_members?(all_map = false)
    99.     if all_map
    100.       return @owned.size > 0
    101.     else
    102.       return @owned.any? {|a| a[0] == $game_map.map_id}
    103.     end
    104.   end
    105.   def retrieve_lost_members(all_map = false)
    106.     $game_party.owned.each_index do |i|
    107.       a = $game_party.owned[i]
    108.       next if a == nil
    109.       $game_party.add_actor(a[2]) if a[0] == $game_map.map_id or all_map
    110.     end
    111.      $game_party.owned = $game_party.owned.compact
    112.   end
    113. end
    114. class Game_Event < Game_Character
    115.   def holds_member?(actor_id)
    116.     $game_party.owned.each_index do |i|
    117.       a = $game_party.owned[i]
    118.       next if a == nil
    119.       return true if a[0] == @map_id and a[1] == @id and a[2] == actor_id
    120.     end
    121.     return false
    122.   end
    123.   def party_relocate(playerid, playerstate = -1)
    124.     $game_party.owned.each_index do |i|
    125.       a = $game_party.owned[i]
    126.       next if a == nil
    127.       if a[2] == playerid
    128.         $game_self_switches[[a[0], a[1],"D"]] = false
    129.         $game_actors[a[2]].remove_state(a[3]) if playerstate >= 0 and playerstate != a[3] and a[3] > 0
    130.         if playerstate > 0 and playerstate != a[3]
    131.           $game_actors[a[2]].add_state(playerstate)
    132.           a[3] = playerstate
    133.         end
    134.         $game_party.owned[i] = [@map_id, @id, playerid, a[3]]
    135.         $game_self_switches[[@map_id, @id,"D"]] = true
    136.       end
    137.     end
    138.     $game_party.owned = $game_party.owned.compact
    139.   end
    140.   def party_return(playerstate = 0)
    141.     $game_party.owned.each_index do |i|
    142.       a = $game_party.owned[i]
    143.       next if a == nil
    144.       if a[0] == @map_id and a[1] == @id
    145.         $game_actors[a[2]].add_state(playerstate) if playerstate > 0
    146.         $game_party.add_actor(a[2])
    147.       end
    148.     end
    149.     $game_party.owned = $game_party.owned.compact
    150.   end
    151.   def character_name
    152.     if @page and @page.actor_replace
    153.       $game_party.owned.each_index do |i|
    154.         a = $game_party.owned[i]
    155.         next if a == nil
    156.         if a[0] == @map_id and a[1] == @id
    157.           return $game_actors[a[2]].character_name
    158.         end
    159.       end
    160.     end
    161.     @character_name
    162.   end
    163.   def character_index
    164.     if @page and @page.actor_replace
    165.       $game_party.owned.each_index do |i|
    166.         a = $game_party.owned[i]
    167.         next if a == nil
    168.         if a[0] == @map_id and a[1] == @id
    169.           return $game_actors[a[2]].character_index
    170.         end
    171.       end
    172.     end
    173.     @character_index
    174.   end
    175.   def party_steal(playerstate = 0, playerid = 0)
    176.     return unless $game_party.members.size > 1
    177.     return if playerid < -2
    178.     return if $game_party.owned.compact.any? {|a| a[0] == @map_id and a[1] == @id}
    179.     if playerid == 0
    180.       if in_front($game_player.x, $game_player.y)
    181.         $game_party.owned << [@map_id, @id, $game_player.actor.id, playerstate]
    182.         $game_player.actor.add_state(playerstate) if playerstate > 0
    183.         $game_party.remove_actor($game_player.actor.id)
    184.         $game_self_switches[[@map_id, @id,"D"]] = true
    185.       end
    186.       if $data_system.opt_followers
    187.         $game_player.followers.each do |follower|
    188.           if in_front(follower.x, follower.y)
    189.             $game_party.owned << [@map_id, @id,follower.actor.id, playerstate]
    190.             follower.actor.add_state(playerstate) if playerstate > 0
    191.             $game_party.remove_actor(follower.actor.id)
    192.             $game_self_switches[[@map_id, @id,"D"]] = true
    193.             break
    194.           end
    195.         end
    196.       end
    197.     elsif playerid < 0
    198.       follower = $game_player.followers[0]
    199.       follower = $game_player.followers[-1] if playerid == -2
    200.       if in_front($game_player.x, $game_player.y)
    201.         $game_party.owned << [@map_id, @id,follower.actor.id, playerstate]
    202.         follower.actor.add_state(playerstate) if playerstate > 0
    203.         $game_party.remove_actor(follower.actor.id)
    204.         $game_self_switches[[@map_id, @id,"D"]] = true
    205.       end
    206.     else
    207.       $game_party.owned << [@map_id, @id, playerid, playerstate]
    208.       $game_actors[playerid].add_state(playerstate) if playerstate > 0
    209.       $game_party.remove_actor(playerid)
    210.       $game_self_switches[[@map_id, @id,"D"]] = true
    211.     end
    212.     $game_party.owned = $game_party.owned.compact
    213.   end
    214.    
    215.   def in_front(thisx, thisy)
    216.     bob = distance_x_from(thisx).abs + distance_y_from(thisy).abs <= 1 #Diamont Direction 531
    217.     bob = false if @direction == 2 and distance_y_from(thisy) >= 0
    218.     bob = false if @direction == 4 and distance_x_from(thisx) <= 0
    219.     bob = false if @direction == 6 and distance_x_from(thisx) >= 0
    220.     bob = false if @direction == 8 and distance_y_from(thisy) <= 0
    221.     return bob
    222.   end
    223. end
    复制代码


    Examples:
    The classic "leave your party behind to watch" trick.


    本贴来自国际rpgmaker官方论坛作者:Harosata处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/party-stealer.118462/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-8-17 11:37 , Processed in 0.097317 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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