I had a conflict with the scene map that I worked out, and it turns out I had missed a few lines. here is the updated script, which now gets you to an empty battle process. pne major change i made from gubid's tutorial was that instead of the long name method alias, i redefined the update_events method of the game_map class to an if statement saying "if in battle, do nothing". this, i believe achieves the same effect.
revised battle system
###new map entry to force battle to stay on map
class Scene_Map < Scene_Base
# * Switch to Battle Screen
if @in_battle == nil @spriteset.update Graphics.update $game_player.make_encounter_count $game_player.straighten $game_temp.map_bgm = RPG::BGM.last $game_temp.map_bgs = RPG::BGS.last RPG::BGM.stop RPG::BGS.stop $game_system.battle_bgm.play #$game_temp.next_scene = nil @in_battle = true p "1" else p "2" update_battle_routine end
def update_battle_routine setup_battle if @battle_setup == nil while @in_battle update_basic update_battle
def in_battle(value = true) @in_battle = value if value == true @pose = 0 if @name.include?("actor") index = @name.downcase.delete("actor").to_i - 1 actor = $game_party.members[index] @tile_id = 0 @character_name = actor.character_name @character_index = actor.character_index
else if @name.include?("neutral") index = @name.downcase.delete("neutral").to_i actor = $game_actors[index] @tile_id = 0 @character_name = actor.character_name @character_index = actor.character_index
class Game_Character def character_name name = @character_name if $game_temp.in_battle == true return name + "_" + "walk" if moving? name = name + "_" + "wait" if @pose == 0 ## name = name + "_" + "skill" if @pose == 1 ##name = name + "_" + "attack" if @pose == 2 end return name
def turn_to(who) retun if !who sx = @x - who.x sy = @y - who.y if sx.abs > sy.abs sx > 0 ? @direction = 4 : @direction = 6 return sx.abs else sy > 0 ? @direction = 0 : @direction = 2 return sy.abs end
def goto_xy(x,y) if $game_map.valid?(x,y)
@x = x @y = y end
class Game_Map def update_events if @in_battle == nil for event in @events.values event.update end for common_event in @common_events.values common_event.update end else
end end end
class Game_Player < Game_Character
def hide @character_name = "" @character_index = 0 end
class Position attr_accessor :x, :y def initialize(x,y) @x, @y = x,y
if you have any suggestions at this point on how to finish constructing the Action Time system. I believe gubid refered to it as both at and ct I decided to use the AT terminology to define that timer, that is what I'm tackling first. A small problem. I think at this point I want to either take it to a strict menu based battle or go to a button menu. i'm leaning towards the button menu. thank you to anyone that checked this out, I was able to correct the many errors, but if you see any way of reorganizing this i'd appreciate it. I think that the call_battle changes might end up as their own script as a foundation for the engine. again, any suggestions appreciated. This is something I haven't been able to find, I am not a programmer, just hoping to shed light on the subject for other users.
I liked gubid's approach because he is manipulating existing methods to suit his needs, though it is an incomplete tutorial of constructing the battle system. the particular challenge he tackles is succeeding in stopping the traditional battle scene to initialize, and setting up the battle process, which is definitely the hardest part. I think the added challenge of a button menu makes this system a little more functional and different from what is already out there for rpg maker. plus it fulfills my expectations in a battle system.
food for thought.
Apr 14 2012, 01:01 PM
So, here is where I am at today... I have done a few minor corrections to the code, I added a Position class to create a position on the events so that when the actors move towards their respective events they turn to them. In most cases this will be a sufficient way of setting up battle, but i want them also to then face the enemy, as in some cases the enemy will not be in the direction they are facing. So, I have outlined methods in the Game_Battler class that establish a position for the battler, the distance to the battle from an x,y; and the distance to another specified battler. Those methods are here:
# sets battler base position def set_base_position(x, y) @base_x = x @base_y = y end
# returns distance to battler def distance_to_battler(battler) return distance_to_position(battler.screen_x, battler.screen_y) end
# turn to the specified coordinates def turn_pos(x, y) sx = @real_x - x sy = @real_y - y if sx.abs > sy.abs # if next long distance is more @direction = sx > 0 ? 4 : 6 # turn to these directions else # if same vertical distance @direction = sy > 0 ? 8 : 2 # is long or more, turn to one of these end
so, now... my question is, do these methods then make my position class irrelevent if I designate that all battlers set their base positions to their respective events? I know that the "game_actor" and "game_enemy" are subclassed game_battler classes, and these attr_accessors are inherited values to their subclasses, but I don't know how to invoke them outside of the class method. Basically at the start of battle, when "update_battle" runs its "upd_goto_position" method, I want each battler to set their base position to their own event. then after the "all_at_pos" boolean returns true, the actors and enemies face eachother's base position. I believe that in doing this i also set up coordinates for attack and skill movement. So say a character attacks, they check the target's base position and see if is above/below/beside and moves to the last tile between them and their target, attacks and returns to their own base position.
in the situation where the actors themselves turn to their event when they walk to them they are invoked by a series of commands:
for event in @actors x, y = event.x, event.y event.moveto($game_player.x, $game_player.y) event.goto_xy(x,y) end
if i were to implement my game_battler methods, would it be in a similar way and how do i specify which event to which battler? it seems to be that i address it the same, addressing the "event" in @actors or @enemies and specifying that x, y = equals their respective events. but then do i say that a) the event should "set_base_position" of the game_battler to event.x and event.y? or do I say the battler should "set_base_position" to the event.x and event.y? to me they say the same thing, but i don't know how to address those accessors we defined. here's the way i envision it:
for event in @enemies x, y = event.x, event.y event.set_base_position($game_battler.x, $game_battler.y) event.turn_pos(x,y) end
even if you guys don't respond and just read, i appreciate the time spent to review these concepts. for me, writing it out here and explaining what is going on helps me identify the problems i am creating and how to solve them. again, I'm not much of a programmer, just someone who has taken an interest in this system and its lack of development. I feel that in time it is a feat I can accomplish if I don't rush things. the biggest challenge is writing clean code, and though gubid does a great job of writing it up on the fly, there are elements that I dont think are necessary, like this difference in assigning location flags. in his video he creates the position class and then removes its method implementation, leaving that class useless in the script. It is my feeling that if these game_battler methods can achieve the same goal as the move_to/turn_to methods then I dont need them either, i merely need to say, set_base_positions to the event, turn to those and then turn to your enemy. again, any suggestions, comments or input is appreciated.
Apr 14 2012, 04:45 PM
alright, so instead of tackling that problem I decided to take on a different one today; that was, to make the battle process only pull in events labeled in our event list that were within a certain distance of the event or player. I decided that ultimately the distance from the player and the battle event were/are the same x,y value at the initialization of the battle process. so, i outlined this method which i believe will achieve that result.
this method rests inside the class Scene_map > Scene Base.
def check_player_distance @distance_from_player = nil for event in $game_map.events.values x, y = event.x, event.y if (x - $game_player.x) >= 5 distance_from_player = false else if (x - $game_player.x) <= 5 @distance_from_player = true
if (y - $game_player.y) >= 5 @distance_from_player = false else if (y - $game_player.y) <= 5 @distance_from_player = true
so, at the point of sorting the events for battle, i would insert the "check_player_distance" method for each instance that it checks the $game_map.events.values for events with the listed prefixes we defined. so, it would call the method which checks all events that are within a range of 5 to it's x or y value and return a boolean stating, yes these events are in range. then it takes all events in range and asks, "is there a listed prefix in the event name?" and any that are in range and that listed prefix are assigned to their respective indexes.
i am running a syntax error which leades me to the class Game_Player, which i think is telling me that it is not able to access those values? or perhaps that i have incorrectly referenced them?
if anyone knows a more direct method of doing this, I'd appreciate the help.
Apr 16 2012, 12:04 AM
this is solved! here is the code i used to process only events within a distance of the player.
for event in $game_map.events.values x, y = event.x, event.y dist = 5 case when (x - $game_player.x).abs - (y - $game_player.y).abs < dist
im thinking that this equation could be reversed to turn the actor events towards the enemy, and instead of before where i was invoking a method within the setup method to determine it, which i think may have worked if i knew what i was doing but was still wrong. you guys are too nice to call me a noob. thank you.
and if anyone wants to see the script and where it's at now, let me know and I'll update it.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.