[XP] Summoning Script

Started by G_G, June 13, 2009, 06:20:10 pm

Previous topic - Next topic

G_G

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?

Ryex

print $capture.smonsters for me you may need to screen shot the print window
   
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Seox

June 18, 2009, 03:18:43 pm #2 Last Edit: June 18, 2009, 03:34:19 pm by Seox
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 ^^^.
... (<<<<<<<<<<<<<<< TEH DOTS OF DOOM. Hey, kinda catchy. :naughty:)

Ryex

Um seox did you even LOOK at the game party class? because his code is right, it SHOULD work, the only two things i see that might be wrong is that he isn't storing what he thinks he's storing, or they're are being added back after he removes them.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Seox

June 18, 2009, 04:21:27 pm #4 Last Edit: June 18, 2009, 04:24:46 pm by Seox
Quote from: Ryexander on June 18, 2009, 04:16:31 pm
Um seox did you even LOOK at the game party class? because his code is right, it SHOULD work, the only two things i see that might be wrong is that he isn't storing what he thinks he's storing, or they're are being added back after he removes them.


My thinking is that his code SHOULD work, but isn't, because something in the code is should or shouldn't be there that isn't. I'm just trying to suggest something that I think will help, due to the nature of the class.

I just looked at it, and, you're right. I'm used to, say, referencing the party using $game_party.actors, which would return the actor in that position. The remove_actor method goes by ID, which works fine. I still think that the top bit of code, with delete_at would work. Just thinking. Thanks for the correction, Ryex. ^_^

I agree with you in saying that he probably isn't storing what he thinks he is, in that the things held in $capture.smonsters are probably not numbers, which is what he's deleting from the array. He's wanting to delete each one using the for loop, which goes through the numbers 0 to the amount of monsters. Therefore, I assume that, on each iteration, he wants to delete the respective monster. He's deleting anything in the array which is equal to i, which is a number. To delete the ones which are in that position, he needs .delete_at.


So, GG, try this:

class Scene_Battle
 alias remove_summoned_monsters update_phase5
 def update_phase5
   for i in 0...$capture.smonsters.size
     $capture.smonsters.delete_at(i)
     $game_party.remove_actor(i)
   end
   remove_summoned_monsters
 end
end
... (<<<<<<<<<<<<<<< TEH DOTS OF DOOM. Hey, kinda catchy. :naughty:)