Quote from: game_guy on June 13, 2009, 06:20:10 pm
Ok I'm making a summoning/capturing script for my game and I am in need of help...
class Scene_Battle
alias remove_summoned_monsters update_phase5
def update_phase5
for i in 0...$capture.smonsters.size
$capture.smonsters.delete(i)
$game_party.remove_actor(i)
end
remove_summoned_monsters
end
end
I can summon monsters just fine and it adds the id of the summon into $capture.smonsters now my problem is in the above code. I want the summons to be removed from the party at the end of every battle and it doesnt remove them. Is something wrong with my code?
maybe I'm wrong, but, when you do this:
class Scene_Battle
alias remove_summoned_monsters update_phase5
def update_phase5
for i in 0...$capture.smonsters.size
$capture.smonsters.delete(i)
$game_party.remove_actor(i)
end
remove_summoned_monsters
end
end
for i in 0... blah blah
That means that "i" is a number. $capture.smonsters.delete(i)....you're deleting a number, right? Not a monster? Unless the monster "goes by" the number. In order for that to work, you'd have to go
for i in $capture.smonsters
$capture.smonsters.delete(i)
end
EDIT:
Never mind, I've got one better. Change .delete to .delete_at, then tell me what happens. I think that'll solve your problem.
EDIT AGAIN: Ok, just saw another problem. Try using this instead:
class Scene_Battle
alias remove_summoned_monsters update_phase5
def update_phase5
for i in 0...$capture.smonsters.size
$capture.smonsters.delete_at(i)
index = $game_party.index($capture.smonsters(i))
$game_party.remove_actor(index)
end
remove_summoned_monsters
end
end
Plus, you were trying to delete the monster in the party at the same index as the captured ones. If you had ANY others in the party, it'd delete the wrong one. That's why I gave you that ^^^.