The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: Xionixx on September 11, 2007, 03:39:34 PM

Title: [RESOLVED] Side View Arrangement
Post by: Xionixx on September 11, 2007, 03:39:34 PM
As you can see, with the screenshot I took of my game, I can place ONE battler in the side part of the screen. To do this heres what's in my script.

Spoiler for:
#--------------------------------------------------------------------------
  # * Get Battle Screen X-Coordinate
  #--------------------------------------------------------------------------
  def screen_x
    # Return after calculating x-coordinate by order of members in party
    if self.index != nil
      return self.index * -200 + -100
    else
      return 0
    end
  end
  #--------------------------------------------------------------------------
  # * Get Battle Screen Y-Coordinate
  #--------------------------------------------------------------------------
  def screen_y
    if self.index != nil
      return self.index * 5 + 390
    else
      return 0
    end
  end

And the problem with that is that it messes with the direct positioning of the battlers. Is there a way I can make the battlers appear in the red boxes I have drawn into the screenshot? Just in the same places as the boxes, not necessarily exactly in them.
Title: Re: Side View Arrangement
Post by: modern algebra on September 11, 2007, 06:49:55 PM
Well, you can just calculate the x's and y's to be based more on the index of the position that that character has in the battle. I think that is what you are doing, but your x is too drastic, multiplying index by -200 will quickly move succesive characters off screen. I would keep that one fairly low, and I also would not do it with minuses. I would start at or a relatively low number and go up by maybe 50 or so. As for the y, it's too low, in my opinion. Only 5 pixels of each actor will show up behind the character before them.

It might be better to have something like this:

Code: [Select]
#--------------------------------------------------------------------------
  # * Get Battle Screen X-Coordinate
  #--------------------------------------------------------------------------
  def screen_x
    # Return after calculating x-coordinate by order of members in party
    if self.index != nil
      return self.index*(60) + 50
    else
      return 0
    end
  end
  #--------------------------------------------------------------------------
  # * Get Battle Screen Y-Coordinate
  #--------------------------------------------------------------------------
  def screen_y
    # Return after calculating y-coordinate by order of members in party
    if self.index != nil
      return self.index*(-50) + 320
    else
      return 0
    end
  end
Title: Re: Side View Arrangement
Post by: Xionixx on September 11, 2007, 08:41:21 PM
I tried putting in what you said, and as you can see by the screenshot, it only moved the second party member to the center, and if you take out everyone but the main character it just moves the player's battler to the center.
Title: Re: Side View Arrangement
Post by: modern algebra on September 11, 2007, 09:14:29 PM
put a print statement displaying self.index right above 'return self.index*(60) + 50' so that it looks like this:

p self.index
return self.index*(60) + 50

And if that returns as 0 the first time and as 1 the second time, give me the specifications of the pictures (i.e. size in pixels vertical and horizontal). Also, test for 3-4 players as well and tell me the results.

Title: Re: Side View Arrangement
Post by: Xionixx on September 11, 2007, 09:26:10 PM
Yeah it kept popping up the number 0 for one member in the party, but every time I clicked OK on the window that popped up, it'd shift from the center of the field to the left. With 2 members they were somewhat organized but still moved left to right. This time 0 and 1 would pop up.

At 3 members, the battlers still moved left and right but less, and 0, 1 and 2 popped up. At 4 members, they didnt shift anymore but 0, 1, 2, and 3 kept popping up, which I understand was the point right?

I took a screenshot of it, and I think the third and fourth battlers are a little too high.
Title: Re: Side View Arrangement
Post by: Falcon on September 11, 2007, 09:35:29 PM
You could always use an if statement? Or just edit some windows for more room?
Title: Re: Side View Arrangement
Post by: Xionixx on September 11, 2007, 09:46:43 PM
How exactly would that work? I'm not much of a scripter, if I can call myself that at all.
Title: Re: Side View Arrangement
Post by: Kokowam on September 11, 2007, 10:05:18 PM
Probably something along the lines of if $game_actors.party.actors = 1, then put him somewhere. if $game_actors.party.actors = 2, put someone here, put someone there, etc. Something like that?
Title: Re: Side View Arrangement
Post by: Shinami on September 11, 2007, 10:21:34 PM
Code: [Select]
  def screen_x
    # Return after calculating x-coordinate by order of members in party
    if self.index != nil
      return self.index == 0 ? 75 : self.index == 1 ? 165 : self.index == 2 ? 255 : self.index == 3 ? 345 : 0
    else
      return 0
    end
  end
I think that's what Moo meant but this wasn't actually tested to be properly alligned like you want and probably isn't. The way I did it though is an advanced way of using conditional branches. Here's an explanation on advanced "if" branches and a simpler explanation below it.

Code: [Select]
condition ? True : False
Condition is what you're checking. It could be something like "self.id != 0" or "@actors[index] != nil".
True is what'll happen if condition returns true.
False is what'll happen if condition returns false.

Basically what I did in the first code box I posted is that I used the advanced "if" branch to avoid a long, drawn out method that might lag the battles to no end. Lag in a battle is the one of the quickest ways to tick off a player.

This is what you can do if you didn't understand the above explanation.
Code: [Select]
  def screen_x
    # Return after calculating x-coordinate by order of members in party
    if self.index != nil
      if self.index == 0
        return 50
      if self.index == 1
        return 40
      if self.index == 2
        return 30
      if self.index == 3
        return 20
    else
      return 0
    end
  end

If you're still unclear on anything, don't hesitate to ask.

@moo
Why in the world would you use $game_actors.party.actors when self.index means the same thing? After all, you would have to use $game_actor[index].screen_x/y/z to call the method anyways. The reason self works is because self is refering to the actor's index you used when you called the method.
Title: Re: Side View Arrangement
Post by: Xionixx on September 11, 2007, 10:48:11 PM
Ok, using what Shinami told me to do, and I messed around a little with the numbers and I managed to get the first screenshot.

Now, let's say I wanted to move them down a little, could I just use this code for Y just replacing the Xs with Ys?
Code: [Select]
def screen_x
    # Return after calculating x-coordinate by order of members in party
    if self.index != nil
      return self.index == 0 ? 75 : self.index == 1 ? 165 : self.index == 2 ? 255 : self.index == 3 ? 345 : 0
    else
      return 0
    end
  end

Also, the positions don't seem to be fixed I guess you could say. It works just fine if there's a full party of four, but as you can see from the second screenshot, it moves them back to the center once you take out the other ones. Is there a way to set the slots in the party to a particular spot in the screen?
Title: Re: Side View Arrangement
Post by: Falcon on September 11, 2007, 10:52:23 PM
Why don't I throw this in requests, since it seems all you're doing is playing with numbers.
Title: Re: Side View Arrangement
Post by: Shinami on September 11, 2007, 11:12:08 PM
Post your screen_x and screen_y methods from Game Actor and Window_BattleStatus please?
Title: Re: Side View Arrangement
Post by: Xionixx on September 11, 2007, 11:32:04 PM
Post your screen_x and screen_y methods from Game Actor and Window_BattleStatus please?

Here's what I have for the screen coordinates for Game_Actor. I haven't changed anything in Window_BattleStatus, so I don't know what to do there but after messin' with the values, it ended up like shown. See, the code itself as is now will only look good when used with 3 members in the party, any more or less looks horrid.

Code: [Select]
#--------------------------------------------------------------------------
  # * Get Battle Screen X-Coordinate
  #--------------------------------------------------------------------------
  def screen_x
    # Return after calculating x-coordinate by order of members in party
    if self.index != nil
      return self.index == 0 ? 0 : self.index == 1 ? 50 : self.index == 2 ? 100 : self.index == 3 ? 150 : 0
    else
      return 0
    end
  end
  #--------------------------------------------------------------------------
  # * Get Battle Screen Y-Coordinate
  #--------------------------------------------------------------------------
  def screen_y
    # Return after calculating y-coordinate by order of members in party
    if self.index != nil
      return self.index == 0 ? 350 : self.index == 1 ? 300 : self.index == 2 ? 250 : self.index == 3 ? 200 : 0
    else
      return 0
    end
  end
Title: Re: Side View Arrangement
Post by: Kokowam on September 11, 2007, 11:36:55 PM
@moo
Why in the world would you use $game_actors.party.actors when self.index means the same thing? After all, you would have to use $game_actor[index].screen_x/y/z to call the method anyways. The reason self works is because self is refering to the actor's index you used when you called the method.
Because I wasn't paying attention at all to the script or anything. Lol.
Title: Re: Side View Arrangement
Post by: Shinami on September 12, 2007, 06:09:21 AM
Are you using any other scripts? Please post them if you are. The screen_x/y methods you posted aren't at fault. I use similar methods in a CBS so I know that for sure.
Title: Re: Side View Arrangement
Post by: Xionixx on September 12, 2007, 07:50:12 AM
Are you using any other scripts? Please post them if you are. The screen_x/y methods you posted aren't at fault. I use similar methods in a CBS so I know that for sure.

Tons of Add-Ons Script by Blizzard, which I think is interfering. I think it's the one that centers your battlers when only using one or two members in the party that could be affecting it.

Here, I'll put it up.

EDIT: Argh! It's too big. But I'm sure you know the one I'm talking about.
Title: Re: Side View Arrangement
Post by: Shinami on September 12, 2007, 08:21:11 AM
Disable the addon you think is interfering. From the way you described it, that sounds like the culprit.
Title: Re: Side View Arrangement
Post by: Falcon on September 12, 2007, 09:37:42 AM
From now on, please tell us what other scripts you are using! (Also read the request rules when you get a chance)
Title: Re: Side View Arrangement
Post by: Xionixx on September 12, 2007, 05:54:51 PM
From now on, please tell us what other scripts you are using! (Also read the request rules when you get a chance)

I never intended for this to be a request. You moved it from Scripts Help.

Damnit you guys, sorry I didn't mention the other script, but yeah that was it! Thanks a lot for sticking around to help me.
Title: Re: [RESOLVED] Side View Arrangement
Post by: Falcon on September 12, 2007, 08:52:36 PM
Don't worry about it.

This topic is resolved, so I think I'll lock it.