Party Stealer
Date: Feb 21, 2020Script 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.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:
=begin
=begin
#===============================================================================
Title: Party Stealer
Author: Dramatic Lightning Co
Date: Feb 21, 2020
--------------------------------------------------------------------------------
Changelog:
-Feb 21, 2020 - Extended script
-- Using -1 or -2 as the actor id for party_steal lets you take the first/last
follower if event touches player.
-- holds_member?(actor_id) returns true if the actor is assigned to that event.
-- lost_members?(all_map = false) returns true if the map has any lost members.
-- retrieve_lost_members(all_map = false) will add all members from that map.
(if all_map is true, returns true if any member is considered missing or
adds all missing members depending on the function)
--------------------------------------------------------------------------------
This script will use Self-Switch D.If an event doesn't use the script calls,
you can still use this self-switch normally.Also, note that the party
cannot be stolen if the party size is at 1.
When you use this script, use a party_steal script-call from a map event
or $game_map.events.party_steal to have that event "steal" your party leader
(with Himework's Follower Event Touch or similar, the event can steal a follower).
You can extend this with party_steal(state_id) to change the stolen member's
state (if you use a state-dependent character graphic script) and
party_steal(state_id, actor_id) if you want to steal a specifc actor instead.
(state_id can be set to 0 if you don't want to apply a state)
--------------------------------------------------------------------------------
You can use party_return or $game_map.events.party_return to return
the stolen member back to your party and remove their display state.
You can extend this with party_return(state_id) to add a new state upon
their release.Alternatively, adding that character back with Add Actor
will reset the association with that event.
You can also use party_relocate(actor_id) or
$game_map.events.party_relocate(actor_id) to reassign the actor to that
event.You can extend this with party_relocate(actor_id, state_id) if you want
to replace their display state (or remove that state with 0).
--------------------------------------------------------------------------------
You can also comment the "D" Event Page with <ActorReplace> to replace
the event's graphic with your character.As stated above, you can use a
state-dependent character graphic script on your actor to affect that event's
appearance.If you opt not to use this tag, the event's own appearance
will be used instead.
#===============================================================================
=end
module RPG
class Event::Page
def actor_replace
@list.each {|cmd|
if cmd.code == 108 && res = cmd.parameters.match(/<ActorReplace>/i)
return true
end
}
return false
end
end
end
class Game_Interpreter
def party_steal(playerstate = 0,playerid = 0)
$game_map.events[@event_id].party_steal(playerstate, playerid)
end
def party_return(playerstate = 0)
$game_map.events[@event_id].party_return(playerstate)
end
def party_relocate(playerid, replace_state = -1)
$game_map.events[@event_id].party_relocate(playerid, replace_state)
end
def holds_member?(actorid)
return $game_map.events[@event_id].holds_member?(actorid)
end
def lost_members?(all_map = false)
$game_party.lost_members?(all_map)
end
def retrieve_lost_members(all_map = false)
$game_party.retrieve_lost_members(all_map)
end
end
class Game_Party < Game_Unit
attr_accessor :owned
alias :dl_party_steal_initialize :initialize
def initialize
@owned = []
dl_party_steal_initialize
end
alias :dl_party_steal_add_actor :add_actor
def add_actor(actor_id)
dl_party_steal_add_actor(actor_id)
@owned.each_index do |i|
a = $game_party.owned
next if a == nil
if a == actor_id
$game_self_switches[, a,"D"]] = false
$game_actors].remove_state(a) if a > 0
$game_party.owned = nil
end
end
end
def lost_members?(all_map = false)
if all_map
return @owned.size > 0
else
return @owned.any? {|a| a == $game_map.map_id}
end
end
def retrieve_lost_members(all_map = false)
$game_party.owned.each_index do |i|
a = $game_party.owned
next if a == nil
$game_party.add_actor(a) if a == $game_map.map_id or all_map
end
$game_party.owned = $game_party.owned.compact
end
end
class Game_Event < Game_Character
def holds_member?(actor_id)
$game_party.owned.each_index do |i|
a = $game_party.owned
next if a == nil
return true if a == @map_id and a == @id and a == actor_id
end
return false
end
def party_relocate(playerid, playerstate = -1)
$game_party.owned.each_index do |i|
a = $game_party.owned
next if a == nil
if a == playerid
$game_self_switches[, a,"D"]] = false
$game_actors].remove_state(a) if playerstate >= 0 and playerstate != a and a > 0
if playerstate > 0 and playerstate != a
$game_actors].add_state(playerstate)
a = playerstate
end
$game_party.owned = [@map_id, @id, playerid, a]
$game_self_switches[[@map_id, @id,"D"]] = true
end
end
$game_party.owned = $game_party.owned.compact
end
def party_return(playerstate = 0)
$game_party.owned.each_index do |i|
a = $game_party.owned
next if a == nil
if a == @map_id and a == @id
$game_actors].add_state(playerstate) if playerstate > 0
$game_party.add_actor(a)
end
end
$game_party.owned = $game_party.owned.compact
end
def character_name
if @page and @page.actor_replace
$game_party.owned.each_index do |i|
a = $game_party.owned
next if a == nil
if a == @map_id and a == @id
return $game_actors].character_name
end
end
end
@character_name
end
def character_index
if @page and @page.actor_replace
$game_party.owned.each_index do |i|
a = $game_party.owned
next if a == nil
if a == @map_id and a == @id
return $game_actors].character_index
end
end
end
@character_index
end
def party_steal(playerstate = 0, playerid = 0)
return unless $game_party.members.size > 1
return if playerid < -2
return if $game_party.owned.compact.any? {|a| a == @map_id and a == @id}
if playerid == 0
if in_front($game_player.x, $game_player.y)
$game_party.owned << [@map_id, @id, $game_player.actor.id, playerstate]
$game_player.actor.add_state(playerstate) if playerstate > 0
$game_party.remove_actor($game_player.actor.id)
$game_self_switches[[@map_id, @id,"D"]] = true
end
if $data_system.opt_followers
$game_player.followers.each do |follower|
if in_front(follower.x, follower.y)
$game_party.owned << [@map_id, @id,follower.actor.id, playerstate]
follower.actor.add_state(playerstate) if playerstate > 0
$game_party.remove_actor(follower.actor.id)
$game_self_switches[[@map_id, @id,"D"]] = true
break
end
end
end
elsif playerid < 0
follower = $game_player.followers
follower = $game_player.followers[-1] if playerid == -2
if in_front($game_player.x, $game_player.y)
$game_party.owned << [@map_id, @id,follower.actor.id, playerstate]
follower.actor.add_state(playerstate) if playerstate > 0
$game_party.remove_actor(follower.actor.id)
$game_self_switches[[@map_id, @id,"D"]] = true
end
else
$game_party.owned << [@map_id, @id, playerid, playerstate]
$game_actors.add_state(playerstate) if playerstate > 0
$game_party.remove_actor(playerid)
$game_self_switches[[@map_id, @id,"D"]] = true
end
$game_party.owned = $game_party.owned.compact
end
def in_front(thisx, thisy)
bob = distance_x_from(thisx).abs + distance_y_from(thisy).abs <= 1 #Diamont Direction 531
bob = false if @direction == 2 and distance_y_from(thisy) >= 0
bob = false if @direction == 4 and distance_x_from(thisx) <= 0
bob = false if @direction == 6 and distance_x_from(thisx) >= 0
bob = false if @direction == 8 and distance_y_from(thisy) <= 0
return bob
end
end
Examples:
The classic "leave your party behind to watch" trick.
本贴来自国际rpgmaker官方论坛作者:Harosata处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/party-stealer.118462/
页:
[1]