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.

GTBS v1.5.1.4 - A FFT Styled Battle System (5/19/2010)

Maus

Member

Update: The spriteset battle error is solved, but the save game error is still rampant: I can't save after a fight has taken place without the error coming up. I love this script, I think it's sensational and I'd love to implement it in my game... any help at all is greatly appreciated!!!!
 
Ruben52, Shining Force Style TBS Movement
kaze-no-ou, you would be best to resolved your passage issues on the normal map before calling battle.  Its likely because you applied an invisible tile over the walls that doesnt have restricted movement, cause it looks top down when deciding where you can move.
p-doran,
1. no, its not possible
4. not at this time
5. $scene.remove_battler - see the help file
6. I wrote a per actor bgm change a little while ago.. look back in the thread, I am sure you will find it.
bradleydfc, $game_system.cust_battle = 'TEAM'
Maus, please stop adding new post.  There is an edit button!  Please provide me a demo of the save problem and I will take a look. 
 
Gubid, ty so much for the shining force style tbs movement. I have a few quick questions if you don't mind me asking.

1. Is there anyway to have it where when the mov tiles are displayed the event becomes the hero so it could allow for less choppy and smoother movement? Basically so you can move freely within the tiles  and feel more realistic when moving. I'm asking this also because my game has 8 direc movement and it would be cool to show if off in the movement. Thats why if you could just move the character freely, it would be awesome.

2. When you hit escape, you have the tiles dissappear and the event teleport back to its original position. Can you have him walk back to the original position?

3. And finally i noticed there is a anim frames and it is set to false, what exactly does it do if set to true.

Thanks a bunch man. Your awesome!
 
1. No, but you could update the move commands to be by press instead of repeat?  Its under the Scene_Map section at the bottom.  Just look for '.repeat?' and replace with '.press?'.  Then update the event to have a faster movement speed/frequency.  Works just like the player.
2. Sure I could.. but I wasnt going for extravigant here.  I would look at the enemy_detection script(included with gtbs) to find out how I had them return to their position when the target(player) moves out of range. 
3. Its from gtbs.. to animate the tiles if desired.  if ISO is false it loads in the image and cycles through 4 frames.. and repeats.  If iso it does the same thing, but uses iso placement instead of normal 32,32 placement.
 
Thanks Gubid, the moving looks a lot smoother now with .press instead of .repeat. That was the main thing i was concerned with. Everything works pretty flawlessly. I just have a few more questions for ya then ill leave ya alone, because you have already helped me more than you could imagine. I noticed unpassable terrain is already set and that is freaken amazing, where if i place something the hero can't walk through the tiles wont show up there. Awesome coding there :). I was just wondering is there any terrain checkers in the code? Like if there was sand on the ground it would reduce the movement for the tiles in that area. If not, doesn't really matter. Not that important and probably not hard to implement. :)

The other thing i was gonna ask was this. In the script you have:

if Input.press?(Input::DOWN)
        if @move_pos.include?([char.x, char.y+1])
          char.move_down unless char.moving?

what would be the input.press? syntax if i wanted to do diagonal directions. Like downleft for example. I figured it would be something along the lines of:

if Input.press?(Input::DOWN & Input::LEFT)
  if @move_pos.include?([char.x-1, char.y+1])
    char.move_down & char.move_left unless char.moving?

would it be something as simple as that, or is there a little more too it?

Finally, does the Anime_Tiles = true only work for iso, because whenever i put try it gives me the error unable to find file
(eval):1 in `initialize`Graphics/Pictures/GTBS/BLUE_range.

This is the last i will ask ya because i know i've been a royal pain in the ass. Thank you so much and i'm already working you into the credits of my game.
 

Maus

Member

Sorry about the posts, I was a bit brain-dead from a very tiring day.

I'll post the demo tonight after moving into my new apartment. Thank you for your time, Gubid.
 
Ruben, this currently does just standard passability checking, so nothing special.  To do that you would have to implement a cost array to go along with it.  As for the directions.. you can add another if input press within the current directions such as this..
Code:
if Input.press?(Input::DOWN)
        if @move_pos.include?([char.x, char.y+1])
          if Input.press?(Input::LEFT)
            if @move_pos.include?([char.x-1, char.y+1])
              unless char.moving?
                char.move_down 
                char.move_left
              end
            end
          elsif Input.press?(Input::RIGHT)
            if @move_pos.include?([char.x+1, char.y+1])
              unless char.moving?
                char.move_down 
                char.move_right
              end
            end
          else
            char.move_down unless char.moving?
          end
        end
      end
      if Input.press?(Input::UP)
        if @move_pos.include?([char.x, char.y-1])
          if Input.press?(Input::LEFT)
            if @move_pos.include?([char.x-1, char.y-1])
              unless char.moving?
                char.move_up
                char.move_left
              end
            end
          elsif Input.press?(Input::RIGHT)
            if @move_pos.include?([char.x+1, char.y-1])
              unless char.moving?
                char.move_up
                char.move_right
              end
            end
          else
            char.move_up unless char.moving?
          end
        end
      end
      if Input.press?(Input::LEFT)
        if @move_pos.include?([char.x-1, char.y])
          char.move_left unless char.moving?
        end
      end
      if Input.press?(Input::RIGHT)
        if @move_pos.include?([char.x+1, char.y])
          char.move_right unless char.moving?
        end
      end
or you could use Input.dir8,.. in which it would probably be something like.
Code:
case Input.dir8
when 1 #down-left
  unless char.moving? or !@move_pos.include?([char.x-1, char.y-1])
    char.move_lowerleft
  end
when 2 #down
#...
end
The anim this is because it has to load in a bitmap to animate.. if it animated what it normally loads you would get 1/4 the normal image as it cycles.  Kinda usesless.  It calls upon gtbs because that is what is in the script.  You are free to redirect it to whatever.

maus, cool.  Just whenever.
 
Alright Gubid, thank you so much. I really appreciate you taking the time making me a demo and helping me out. Enjoy the rest of your day.
 
Gubid":1bs63n8q said:
6. I wrote a per actor bgm change a little while ago.. look back in the thread, I am sure you will find it.
I found the post, but you didn't write a per-actor bgm change though.


(p.s.:so twilight's a fan of SRW too.)

Edit: never mind, that wasn't the right post. I can't find the post you mentioned.
 
Ep, sorry Gubid one more. I set ANIM_TILES to true, copied the BLUE_range picture to the pictures folder, and ANIM_FRAMES is still set to 4, but for some reason i'm still getting the error:  Unable to find file (eval):1:in `initialize`Graphics/Pictures/TBS Movement/Blue_range. I realize that the Blue_range pic you made is made for iso but it was more of a test to see if it works. In GTBS, i tried the same set ANIM_TILES to true and even the regular non iso battles loaded the bitmap. Any idea what's wrong? Here is your code in sprite_range...

#----------------------------------------------------------------------------
# Sprite Range - Used to display all "RANGES" during battle
#----------------------------------------------------------------------------
class Sprite_Range < RPG::Sprite
  attr_accessor   :eek:x
  attr_accessor   :eek:y
  #----------------------------------------------------------------------------
  #Constants
  #----------------------------------------------------------------------------
  ANIM_FRAMES = 4
  ANIM_TILES = true
 
  ATTACK_COLOR = 'RED'
  MOVE_COLOR = 'BLUE'
  HELP_SKILL_COLOR = 'GREEN'
  ATTACK_SKILL_COLOR = 'YELLOW'
  #----------------------------------------------------------------------------
  # Object initialization
  #----------------------------------------------------------------------------
  #   type = 1-7, passed by 'def draw_ranges' from Scene_Battle_TBS
  #----------------------------------------------------------------------------
  def initialize(viewport, type, x, y, visible = true)
    super(viewport)
    self.visible = visible
    self.bitmap = Bitmap.new(32,32)
    self.opacity = 100
    @wait = 6
    @pattern = [0,1,2,3]
    @p_index = 0 #pattern index
    @h = 0
    @type = type
    @x = x, @y = y
    @oy = y; @ox = x
    @iso = $game_map.iso? rescue @iso = false
    @anim = ANIM_TILES
    moveto(@ox, @oy)
    refresh 
  end
  #----------------------------------------------------------------------------
  # Get Color for tile
  #----------------------------------------------------------------------------
  def get_color(color)
    case color
    when "RED"
      return Color.new(255,0,0,255)
    when "BLUE"
      return Color.new(0,0,255,255)
    when "GREEN"
      return Color.new(0,255,0,255)
    when "YELLOW"
      return Color.new(255,255,0,255)
    when "PURPLE"
      return Color.new(128,0,255,255)
    when "ORANGE"
      return Color.new(255,128,0,255)
    when "BROWN"
      return Color.new(128,64,0,255)
    when "BLACK"
      return Color.new(0,0,0,255)
    when "WHITE"
      return Color.new(255,255,255,255)
    when "PINK"
      return Color.new(255,128,255,255)
    when "TAN"
      return Color.new(200,200,110,255)
    end
  end
  #----------------------------------------------------------------------------
  # Map is Iso?
  #----------------------------------------------------------------------------
  def iso?
    return @iso
  end
  #----------------------------------------------------------------------------
  # Refresh - Process to update/set the bitmap for the object
  #----------------------------------------------------------------------------
  def refresh
    #create rectangle to fill is not using a picture
    rect = Rect.new(1, 1, 30, 30)
    if iso?
      case @type
      when 1; self.bitmap = RPG::Cache.picture(sprintf("TBS Movement/#{ATTACK_COLOR}_iso_range"))
      when 2; self.bitmap = RPG::Cache.picture(sprintf("TBS Movement/#{MOVE_COLOR}_iso_range"))
      when 3; self.bitmap = RPG::Cache.picture(sprintf("TBS Movement/#{HELP_SKILL_COLOR}_iso_range"))
      when 4; self.bitmap = RPG::Cache.picture(sprintf("TBS Movement/#{ATTACK_SKILL_COLOR}_iso_range"))
      when 5; self.bitmap = RPG::Cache.picture(sprintf("TBS Movement/#{ATTACK_SKILL_COLOR}_iso_range"))
      when 6; self.bitmap = RPG::Cache.picture(sprintf("TBS Movement/#{HELP_SKILL_COLOR}_iso_range"))       
      when 7; self.bitmap = RPG::Cache.picture(sprintf("TBS Movement/#{ATTACK_COLOR}_iso_range"))
      end
    else #non iso
      if @anim
        case @type
        when 1; self.bitmap = RPG::Cache.picture(sprintf("TBS Movement/#{ATTACK_COLOR}_range"))
        when 2; self.bitmap = RPG::Cache.picture(sprintf("TBS Movement/#{MOVE_COLOR}_range"))
        when 3; self.bitmap = RPG::Cache.picture(sprintf("TBS Movement/#{HELP_SKILL_COLOR}_range"))
        when 4; self.bitmap = RPG::Cache.picture(sprintf("TBS Movement/#{ATTACK_SKILL_COLOR}_range"))
        when 5; self.bitmap = RPG::Cache.picture(sprintf("TBS Movement/#{ATTACK_SKILL_COLOR}_range"))
        when 6; self.bitmap = RPG::Cache.picture(sprintf("TBS Movement/#{HELP_SKILL_COLOR}_range"))       
        when 7; self.bitmap = RPG::Cache.picture(sprintf("TBS Movement/#{ATTACK_COLOR}_range"))
        end
      else
        case @type
        when 1; self.bitmap.fill_rect(rect, get_color(ATTACK_COLOR))
        when 2; self.bitmap.fill_rect(rect, get_color(MOVE_COLOR))
        when 3; self.bitmap.fill_rect(rect, get_color(HELP_SKILL_COLOR))
        when 4; self.bitmap.fill_rect(rect, get_color(ATTACK_SKILL_COLOR))
        when 5; self.bitmap.fill_rect(rect, get_color(ATTACK_SKILL_COLOR))
        when 6; self.bitmap.fill_rect(rect, get_color(HELP_SKILL_COLOR))     
        when 7; self.bitmap.fill_rect(rect, get_color(ATTACK_COLOR))
        end
      end
    end
    if [5,6,7].include?(@type)
      self.opacity = 255
    end
    if @anim
      @cw = self.bitmap.width / ANIM_FRAMES
    else
      @cw = self.bitmap.width
    end
    @ch = self.bitmap.height
    self.opacity = 0 if visible == false
    update
  end
  #----------------------------------------------------------------------------
  # Dispose process
  #----------------------------------------------------------------------------
  def dispose
    unless self.bitmap == nil
      self.bitmap.dispose
      self.bitmap = nil
    end
    super
  end
  #----------------------------------------------------------------------------
  # MoveTo - sets the current X,Y location on the map
  #----------------------------------------------------------------------------
  def moveto(x, y)
    @ox = x; @oy = y
    @x = x % $game_map.width
    @y = y % $game_map.height
    @real_x = @x * 128
    @real_y = @y * 128
  end
  #----------------------------------------------------------------------------
  # Get X Coords
  #----------------------------------------------------------------------------
  def screen_x
    if iso?
      return  ((@real_x - @real_y)/4 + 32*$game_map.height - 0 - $game_map.display_x/4)-27
    else
      return (@real_x - $game_map.display_x + 3) / 4
    end
  end
  #----------------------------------------------------------------------------
  # Get Y Coords
  #----------------------------------------------------------------------------
  def screen_y
    if iso?
      y = ((@real_y + @real_x) / 8 + 24 - $game_map.display_y / 4 - (@h) * 8) - 25
      return y
    else
      y = (@real_y - $game_map.display_y + 3) / 4
      return y
    end
  end
  #----------------------------------------------------------------------------
  # Get Z coords
  #----------------------------------------------------------------------------
  def screen_z(height = @h)
    if iso?
      z = (0 + (height * 64))
      z = z < 0 ? 0 : z
      return z
    else
      return 0
    end
  end
  #----------------------------------------------------------------------------
  # Get the current screen Tile Height
  #----------------------------------------------------------------------------
  def screen_th
    return 0 if !iso?
    tile_id = $game_map.map.data[self.ox,self.oy,0]
    return 0 if tile_id == nil
    t_x = (tile_id - 384) % 8     
    t_y = (tile_id - 384) / 8
    th = t_x + t_y * 8
    return th
  end
  #----------------------------------------------------------------------------
  # Update Process
  #----------------------------------------------------------------------------
  def update
    super unless self.disposed?
    update_animation
    update_bitmap
    update_height
    update_location
  end
  #----------------------------------------------------------------------------
  # Update animation - used to progress the animation frame index
  #----------------------------------------------------------------------------
  def update_animation
    if @wait != 0
      @wait -= 1
      if @wait == 0
        @wait = 6
        #update frame every six updates
        @p_index += 1
        if @p_index == @pattern.size
          @p_index = 0
        end
      end
    end
  end
  #----------------------------------------------------------------------------
  # Updates the height to that of the tile it is over
  #----------------------------------------------------------------------------
  def update_height
    if @h != screen_th
      @h = screen_th
    end
  end
  #----------------------------------------------------------------------------
  # Update bitmap based on pattern
  #----------------------------------------------------------------------------
  def update_bitmap
    if @anim
      sx = @pattern[@p_index] * @cw rescue sx = 0
      self.src_rect.set(sx, 0, @cw, @ch)
    else #if not using animated tiles, but using ISO, use first frame only.
      if iso?
        self.src_rect.set(0, 0, @cw, @ch)
      end
    end
  end
  #----------------------------------------------------------------------------
  # Updates X, Y, Z coords
  #----------------------------------------------------------------------------
  def update_location
    self.x = screen_x unless self.disposed?
    self.y = screen_y unless self.disposed?
    self.z = screen_z unless self.disposed?
  end
end

   

Anyone else is free to answer too if they see the problem. Gubid has already done so much for me and i don't want to kill him lol.
 
Did you name it correctly?  If its looking for 'BLUE_range' and you dont have that exactly in the folder you can get that error.

Hmm.. I thought I did it already, oh well.  Guess I get to write it again!  YAY.  Give me a day or 2.
 
Never mind Gubid, i figured it out. You had the command

when 2; self.bitmap = RPG::Cache.picture(sprintf("GTBS#{MOVE_COLOR}_range"))

It was giving the error because of the GTBS. I just removed the words GTBS and it worked fine. I should be fine now. Thank you
 

GRUNGE

Member

Hi Gubid, how are you?
I was testing my project when occurred an error while enemy was in "thinking time".

I´ve opened the script and this was there:

_Game_battler (line 870). :

if @move_route.size > 0
      run_path unless moving?
end

Do you know what it means?
thanks!!!!
 
You are going to have to provide me a little more information.  What was the error that you encountered?  Which line did it jump to in the script editor?  What were you doing at the time the error occurred?
 
Gubid, i've been checking out your tbs engine and i must say that it's rather impressive. I have a question about your enemy ai movement as im slightly curious as to how it works. What kind of pathfinding logic are you using to determine where an enemy should move. In other words, there might be a player event who is the shortest distance away from the enemy, however the enemy can't reach him because he is behind an unpassable blocks. For the enemy to be able to attack him, he would have to walk all the way around the unpassable blocks(river). Now that's not impossible to do as there are many pathfinding scripts out there and what not that would lead the enemy to the player event. However, let's say that there is another player event on the same side of the river as the enemy. Well logic would suggest that he go after that player event instead and ignore the player event on the other side of the river. See my screenshot and you will see what i mean.

http://img381.imageshack.us/img381/2176/pathql8.th.jpg[/img]http://img381.imageshack.us/images/thpix.gif[/img]
 
maus: Ok you have a couple things going on.  the first is a problem with your standard scripts.  I am not sure why it was changed but that is the root of the 'version_id' error.  Anyway, you can fix it by removing the extra line from scene_file under def write_save_data(file) - compare it with a new project to see what is different. As for the marshal dump thing.. its a little wierd, but you can fix it by adding this to the gtbs terminate section at the very bottom of scene_battle_tbs.  Replace it with the following
Code:
def terminate
    @spriteset.dispose
    $game_system.tactics_enemies.clear
    $game_system.tactics_neutral.clear
    $game_system.tactics_actors.clear
    $game_system.tactics_dead.clear
    $game_system.acted.clear
    $game_system.battle_events.clear  #<--- This is the new line
    $game_troop.reset
    for actor in $game_party.members
      actor.set_direction(2)
      actor.blink = false
      actor.remove_state(GTBS::DOOM_ID)
    end
    for i in 1..999
      actor = $game_actors[i]
      next if actor == nil
      actor.remove_state(GTBS::DOOM_ID)
    end
  end

dario: The path finding finds the fastest route to reach the 'enemy/actor' that it would like to hit.  There are some situations in which the path finding will have some issues but in your represented situation, the enemy should attempt to attack who they can.. if they cannot, then they will approach that of which they would LIKE to attack, based on their hp/def ratio to the other close enemy/actor.
 
Um Gubid, how can I activate a common event when I defeat all enemies?
tbs_victory(nil, nil, 4) doesn't seem to work,
neither does
tbs_victory("nil", nil, 4), and tbs_victory(nil,nil,4)
 
Ah i see what your saying Gubid, so you kind of in a sense have to simulate the movement before actually moving. So the Psuedo (general) code would look something like...

Enemy's Turn
Check if anyone is in attack range

If No One is in attack range
Simulate Movement (based on spaces enemy can move) towards target the enemy would like to attack
     If the simulated movement took more steps to reach the enemy's target then the mov stat he has avaliable
      Find new target
     else
      Move to that target


I figure it would be something of that general idea. One other question is when you are moving an enemy, he can obviously move through his own teammates. How do you determine where to move him if another enemy is already occupying the space he is supposed to move to. I figure you use the distance formula to determine which actor is closest to the enemy and thats how you determine most of your movement. :)

       
 

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