I'm using the Player: Swap Dead Actor script by Kain Nobel and I was curious as to how I could get it so when player 1 is alive again they are automatically shifted back into first position?
#===============================================================================
# ** Player : Swap Dead Actor
# By : Kain Nobel
# Date : 12/10/2008
# Versio : 2.5
#===============================================================================
#-------------------------------------------------------------------------------
# * SDK Log
#-------------------------------------------------------------------------------
SDK.log('Player.SwapDeadActor', 'Kain Nobel ©', 2.5, '12.10.2008')
#-------------------------------------------------------------------------------
# * SDK Enabled Test : BEGIN
#-------------------------------------------------------------------------------
if SDK.enabled?('Player.SwapDeadActor')
#===============================================================================
# ** Scene_Map
#===============================================================================
class Scene_Map < SDK::Scene_Base
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :swap_dead_leader_scene_map_update, :update
#-----------------------------------------------------------------------------
# * Update
#-----------------------------------------------------------------------------
def update
swap_dead_leader_scene_map_update
unless $game_party.actors.empty?
if ($game_party.actors[0].hp).zero?
unless $game_party.all_dead?
$game_party.actors << $game_party.actors.shift
$game_player.refresh
else ; $game_temp.gameover = true
end
end
end
end
end
#-------------------------------------------------------------------------------
# * SDK Enabled Test : END
#-------------------------------------------------------------------------------
end
(http://www.mustangworld.com/forums/images/smilies/bump.gif)
(http://www.mustangworld.com/forums/images/smilies/bump.gif)
(http://www.mustangworld.com/forums/images/smilies/bump.gif)
(http://www.mustangworld.com/forums/images/smilies/bump.gif)
#===============================================================================
# ** Player : Swap Dead Actor
# By : Kain Nobel
# Date : 12/10/2008
# Versio : 2.5
#===============================================================================
#-------------------------------------------------------------------------------
# * SDK Log
#-------------------------------------------------------------------------------
SDK.log('Player.SwapDeadActor', 'Kain Nobel ©', 2.5, '12.10.2008')
#-------------------------------------------------------------------------------
# * SDK Enabled Test : BEGIN
#-------------------------------------------------------------------------------
if SDK.enabled?('Player.SwapDeadActor')
#===============================================================================
# ** Game_Player
#===============================================================================
class Game_Player
def refresh(leader=0)
# If party members = 0
if $game_party.actors.size == 0
# Clear character file name and hue
@character_name = ""
@character_hue = 0
# End method
return
end
# Get lead actor
if leader != 0
actor = $game_actors[leader]
else
actor = $game_party.actors[0]
end
# Set character file name and hue
@character_name = actor.character_name
@character_hue = actor.character_hue
# Initialize opacity level and blending method
@opacity = 255
@blend_type = 0
end
end
#===============================================================================
# ** Scene_Map
#===============================================================================
class Scene_Map < SDK::Scene_Base
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :swap_dead_leader_scene_map_update, :update
#-----------------------------------------------------------------------------
# * Update
#-----------------------------------------------------------------------------
def update
swap_dead_leader_scene_map_update
unless $game_party.actors.empty?
@leader = $game_party.actors[0]
if (@leader.hp).zero?
unless $game_party.all_dead?
for actor in $game_party.actors
if actor.hp != 0
new_leader = actor
break
end
end
if @temp_leader != new_leader
@temp_leader = new_leader
end
$game_player.refresh(@temp_leader.id)
else
$game_temp.gameover = true
end
else
$game_player.refresh(@leader.id)
end
end
end
end
#-------------------------------------------------------------------------------
# * SDK Enabled Test : END
#-------------------------------------------------------------------------------
end
Tell me how good this works for you. I didn't test it a lot, but it does it's job.
Could you remove the SDK support from it. I'm trying to get my game away from that entirely. I just forgot to update my first post. Thanks for helping out though.
#===============================================================================
# ** Player : Swap Dead Actor
# By : Kain Nobel
# Date : 12/10/2008
# Version : 2.5
# SDK-Free Edit by KK20
#===============================================================================
#===============================================================================
# ** Game_Player
#===============================================================================
class Game_Player
def refresh(leader=0)
# If party members = 0
if $game_party.actors.size == 0
# Clear character file name and hue
@character_name = ""
@character_hue = 0
# End method
return
end
# Get lead actor
if leader != 0
actor = $game_actors[leader]
else
actor = $game_party.actors[0]
end
# Set character file name and hue
@character_name = actor.character_name
@character_hue = actor.character_hue
# Initialize opacity level and blending method
@opacity = 255
@blend_type = 0
end
end
#===============================================================================
# ** Scene_Map
#===============================================================================
class Scene_Map
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias swap_dead_leader_scene_map_update update
#-----------------------------------------------------------------------------
# * Update
#-----------------------------------------------------------------------------
def update
swap_dead_leader_scene_map_update
unless $game_party.actors.empty?
@leader = $game_party.actors[0]
if (@leader.hp).zero?
unless $game_party.all_dead?
for actor in $game_party.actors
if actor.hp != 0
new_leader = actor
break
end
end
if @temp_leader != new_leader
@temp_leader = new_leader
end
$game_player.refresh(@temp_leader.id)
else
$game_temp.gameover = true
end
else
$game_player.refresh(@leader.id)
end
end
end
end
Wasn't much to delete actually...just realized that. Anyways, the character that's displayed on the field is whomever is closest to the front of the party. I removed the whole "shift the party up and throw the dead actors at the bottom of the party" function.
Quote from: JanraeMendoza on September 06, 2011, 05:15:14 pm
Quote from: l0rdph0enix on September 06, 2011, 04:40:02 pm
Could you remove the SDK support from it.
Well actually this does not need any scripting (in my own opinion) because this is actually possible in eventing and common events. The thing is, it needs A LOT of eventing, which I myself, am bored to create at times. This may also depend if you are using a Caterpillar script, which your events depends on it. My tip, create a new State change. =)
I'm using the Caterpillar system from ToA ;).
@KK20
Thanks for taking the SDK out, but when the main characters is 'knocked out' their position isn't shifted to where they aren't the leader anymore. But when they are 'recovered' they are back to being the leader again. Any ideas?
Now that you mention you are using a caterpillar script, I can probably see why it wouldn't work. My script edit assumes that you are using the default "one actor" on the field.
Quote...when the main characters is 'knocked out' their position isn't shifted to where they aren't the leader anymore.
Not sure exactly what you mean. The script assumes that whoever is closest to the front of the party and is still alive is the controllable actor. Like I said previously, it
does not shift the order of the party. If you want that to happen, I'm going to have to edit the script again.
Just stick this in the editor below the default classes. It will work automatically.
class Game_Party
alias zer0_dead_actor_swap_setup setup_starting_members
def setup_starting_members
zer0_dead_actor_swap_setup
set_preferred_order
end
def set_preferred_order
@preferred_order = @actors.collect {|actor| actor.id }
end
def refresh_order
@actors.sort! {|a, b|
if a.dead? && b.dead?
return @preferred_order.index(a.id) <=> @preferred_order.index(b.id)
else
return a.dead? ? -1 : 1
end
}
end
alias zer0_dead_swap_add add_actor
def add_actor(id)
@actors = @preferred_order.collect {|id| $game_actors[id] }
zer0_dead_swap_add(id)
set_preferred_order
refresh_order
end
alias zer0_dead_swap_remove remove_actor
def remove_actor(id)
@actors = @preferred_order.collect {|id| $game_actors[id] }
zer0_dead_swap_remove(id)
set_preferred_order
refresh_order
end
end
class Game_Actor
alias zer0_dead_swap_remove_state remove_state
def remove_state(state_id)
zer0_dead_swap_remove_state(state_id)
$game_party.refresh_order
end
end
Not being rude or anything, but...I don't get what your script 'actually' does. Perhaps it's because there's an error in it or something. I just tried using an event where I remove Aluxes from the party and add Dorothy. What happened was that it kept removing the last actor in the party one-by-one until it was only Aluxes in the party. Then, I finally got Dorothy in the party (but all by herself).
Like I said, just throwing my...observation skills... :uhm:
Oops, you are right. I changed something at the the last second with the add/remove actor methods and never tested it. Here's the fix for that:
class Game_Party
alias zer0_dead_actor_swap_setup setup_starting_members
def setup_starting_members
zer0_dead_actor_swap_setup
set_preferred_order
end
def set_preferred_order
@preferred_order = @actors.collect {|actor| actor.id }
end
def refresh_order
@actors.sort! {|a, b|
if a.dead? && b.dead?
return @preferred_order.index(a.id) <=> @preferred_order.index(b.id)
else
return a.dead? ? -1 : 1
end
}
end
alias zer0_dead_swap_add add_actor
def add_actor(id)
zer0_dead_swap_add(id)
@preferred_order.push(id) unless @preferred_order.include?(id)
refresh_order
end
alias zer0_dead_swap_remove remove_actor
def remove_actor(id)
zer0_dead_swap_remove(id)
@preferred_order -= [id]
refresh_order
end
end
class Game_Actor
alias zer0_dead_swap_remove_state remove_state
def remove_state(state_id)
zer0_dead_swap_remove_state(state_id)
$game_party.refresh_order
end
end
Blah! I still don't get it! :O.o:
Is def refresh_order suppose to change the actor's positions in the party? Because it's not and I think that's what he wanted. I am also assuming that he wants the actor that you control on the field to change as well (if $game_party.actor[0] is dead, make the next person in line be the controllable character). And after doing some lolstalking I found out he's using a Multi-Party/Party Switcher script. Suddenly I'm starting to think that the only way it is possible to solve this problem is if we had the demo.
:wacko: I'll just...do something else until he replies back with what he wants. -lies down-
It does this:
Actor 1 dies, he goes to back of party (all dead actors are still sorted by the "preferred" order)
The second preferred actor is moved up to take his place.
If dead actor returns to life, the party is reordered and Actor 1 returns to being the party leader.
Its for use with the caterpillar script that he is using, and it works. I can supply you with a demo of it working if you still do not understand.
It's probably because I don't have the caterpillar script he has; that's why I can't exactly test it. :facepalm:
WOOT! ForeverZer0 your script did the trick :up: it works like a charm now. KK20 if you still would like me to post a demo of my game I can ( was going to anyway ;) ) but thanks for your help with this as well. KK20 you will be added to my games credits, ForeverZer0 you're already there for multiple reasons :^_^':. This topic is now solved thanks to everyones help.