Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

What am I doing wrong?!?!

I am trying to create a battle in which the actors are between an enemy pincer attack. So I need to change the position the actors start the battle in (from the right, to the middle).

My attempt was to alias Game_Actor screen_x, but only have it alias if a variable was at a certain value. I was thinking that I would equate the variable right before the battle (to activate the aliasing) and then after the battle set the value so that the aliasing would no longer be active.

Here is the code:
class Game_Actor < Game_Battler

if $game_variable[4] == 1
alias old_screen_x screen_x

def screen_x
if $game_party.actors.size == 1
if self.index == 0
return 200
end
end
if $game_party.actors.size == 2
if self.index == 0
return 200
end
if self.index == 1
return 200
end
end
if $game_party.actors.size == 3
if self.index == 0
return 200
end
if self.index == 1
return 200
end
if self.index == 2
return 200
end
end
if $game_party.actors.size == 4
if self.index == 0
return 200
end
if self.index == 1
return 200
end
if self.index == 2
return 200
end
if self.index == 3
return 200
end
end
end
end

end
I put it right above Main and tried to run it, but got this error:
Script 'Bridge_Battle_Setup' line 3: NoMethodError occurred
undefined method `[]' for nil:NilClass

I could be going about this all wrong, not really sure. So if anyone could provide some insight I would be very appreciative :biggrin:
 
:biggrin:
Awesome! Thank you for the help Daniel!

I found out that the $game_variables had to actually go in def screen_x. Like this:
class Game_Actor < Game_Battler
alias old_screen_x screen_x
def screen_x
if $game_variables[4] == 1
if $game_party.actors.size == 1
if self.index == 0
return 200
end
end
if $game_party.actors.size == 2
if self.index == 0
return 200
end
if self.index == 1
return 200
end
end
if $game_party.actors.size == 3
if self.index == 0
return 200
end
if self.index == 1
return 200
end
if self.index == 2
return 200
end
end
if $game_party.actors.size == 4
if self.index == 0
return 200
end
if self.index == 1
return 200
end
if self.index == 2
return 200
end
if self.index == 3
return 200
end
end
else
if $game_party.actors.size == 1
if self.index == 0
return 440
end
end
if $game_party.actors.size == 2
if self.index == 0
return 430
end
if self.index == 1
return 455
end
end
if $game_party.actors.size == 3
if self.index == 0
return 430
end
if self.index == 1
return 460
end
if self.index == 2
return 440
end
end
if $game_party.actors.size == 4
if self.index == 0
return 420
end
if self.index == 1
return 460
end
if self.index == 2
return 440
end
if self.index == 3
return 405
end
end
end
end
end
That way I can still alias the method and leave the default Game_Actor script as is.

I figure that I will call the variable "Enemy Pincer" and initiate it on Turn 0 / Battle and then turn it off after the battle is over. Now anyone should be able to set the screen_x, screen_y values the way they want them, call the variable, and achieve a myriad of formations! (I hope anyway. I haven't tested it yet, but it sounds good in theory).

Thanks again! and I will update what I find
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top