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)

GubiD, sorry to ask, but do you have any reference book or "how to program in RGSS2"? I'm actually trying to make my way into it but I do not have any kind of documentation to help me =\



1 - About the ISOMETRIC STUFF

There is an "easy way" to calculate which "tile"(x,y) in the "mother map" belongs as what tile (x,y) location to the "child map"? You know, its pretty hard to assemble an isometric map when he is actually 2 maps! >.<
I really need a feedback on that so this "work" can be something else then a "make and try"



0 - Hum... I'll try to add some "fixed Battle tower" and I will tell you if it does work XD

2 - I need a change in this part of your script, could you help me? (I mean, do it for me cuz im a noob!)
Actually the "Set Battle_scene" is based on the map_id, but i do need it to be based on a variable (I will have a lot of battles comming from a single map, and I will lose too much maps if I do "change the map" for every different battle_scene... =\

Something like THAT

Code:
  #-------------------------------------------------------------
  # Sets battle_scene to change if called from specified map, otherwise it is self
  #-------------------------------------------------------------
  def self.battle_map(game_variable)
    case game_variable
    when 1; map = 1 
    else; map = map_id
    end
    return map
  end

I know its not "right" but the idea is close to it, instead of using "case map_id" I want to use:
case game_variable
when "variable = 1" then map = 1
when "variable = 2" then map =2
else; map = actual map_id
end
return map
end

(this "game_variable" is one of those variables that I can access using the events "set variable to", ok?) I do apreciate your help and all your efforts to make it good as it is :)
 
lucas..
1. Ok.. here is the best way i can tell you.. take the child map, count the y tiles. Open the parent(the iso map) count down y tiles from the child /2 and that is where the x,y(max) will start at height 0.  If its higher, adjust 8 pixels up for every height level.  You can also count the child y tiles in on the x to get the 0,0 position on the map for 0 height.  Hope that makes sense.
2. You can do.. case $game_variables[VAR_ID].. when 1; map = 1 etc.  hope that helps

Silencher .. what is the line exactly?  sorry, so many reponses to read.

As I did it.. I created a variable in the spriteset called tile_sprites.. then pushed each sprite_range to it.  Then just added a update routine.  Sprite_range has its own initialize method, please review it for instructions.
 
Hey Gubid, sorry for bothering you man. I looked through all of your sprite_range script, and then i looked through your  module sdk and i still can't figure out how to call on the sprite_range script to display the tiles where around one of my events. I can't figure out what the call command is to display them. :(
 
Gubid i made an event and used the call script command. I put this in this command in:
@spriteset.tile_sprites.push(Sprite_Range.new(@spriteset.viewport1, 255, 5, 5, visible))

It gave me a error:  NoMethodError occured while running the script: undefined method 'tile_sprites' for nil:nilclass

I know i'm probably am just being a newb. I really don't understand much when it comes to scripting.
 
Basically I changed the following bits of code to try to get the downed sprites to all be the same for enemies and for actors. Currently the enemies work perfectly, but downed actors come back as a blank sprite even though they (I think) are attached to the same exact template. Am I not doing something right in one of the following pieces of code?

Code:
class Game_Actor < Game_Battler
  def hide_info?
    return false
  end
  
  def character_name
    return @character_name if !$game_temp.in_battle
    return "$slime.png" if dead? and !animated? # beauner alteration
    return @character_name #defines character sprite in battle
  end
      
  def base_move_range
    return GTBS.move_range(@class_id)
  end
  
  def ai_level
    return $game_system.ai_level
  end
  
  def weapon_range
    if GTBS::USING_ENHANCED_WEAPONS
      weapon = $data_weapons[@weapon_id]
      if weapon.is_a?(Enhanced_Weapon)
        return GTBS.w_range(weapon.ref_id)
      else
        return GTBS.w_range(@weapon_id)
      end
    end
    return GTBS.w_range(@weapon_id)
  end
  
  def attack_skill_range
    getrange = []
    for i in @skills
      skill = $data_skills[i]
      if skill.scope < 7
        rng = GTBS::skill_range(i)
        getrange.push(rng[0] + rng[1])
      end
    end
    if getrange.size == 0
      range = -1
      return range
    else
      getrange.sort!
      getrange.reverse!
      range = getrange[0]
      return range
    end
  end
  
  def help_skill_range
    getrange = []
    for i in @skills
      skill = $data_skills[i]
      if skill.scope > 6
        rng = GTBS::skill_range(i)
        getrange.push(rng[0] + rng[1])
      end
    end
    if getrange.size == 0
      range = -1
      return range
    else
      getrange.sort!
      getrange.reverse!
      range = getrange[0]
      return range
    end
  end
  def down_x
    return GTBS.down_x(@id, "actor")
  end
  
  def down_y
    return GTBS.down_y(@id, "actor")
  end
end



Code:
[code]module GTBS
  #=============================================================#
  #               Character/Enemy Death Options                 #
  #=============================================================#  
  
  #------------------------------------------------------------
  # Check Death Action
  #------------------------------------------------------------
  # This section allows you to identify common events upon death for what map 
  # you are fighting on by the id of the actor/enemy
  def self.check_death_action(map_id, type = 0)
    case map_id
    when 1
      return {1=>6} if type == 0 #actors
      return {} #enemy death
    when 3
      return {1=>7} if type == 0 #actors
      return {36=>8}
    else
      return {} if type == 0 #actors
      return {} #enemies
    end
  end
  
  #-----------------------------------------------------------
  # DownSets by Nick - create a battlername_down file for each character to display
  # other than a downed soldier.
  #-----------------------------------------------------------
  # Downsets are only used if you are not using Animated Battlers or Remove Dead
  #-----------------------------------------------------------
  def self.down_graphic(type, battler_name = "")
    if FileTest.exist?("Graphics/Characters/#{battler_name}_down.png")
      return "$slime.png"
    else
      if type == "enemy" ; return "$slime.png"
      elsif type == "actor" 
        # This little code gets the downset from the prefix.
        pre = battler_name.split("-")[0].to_i
        if pre >= 1 and pre <= 16 ; return "$slime.png"
        elsif pre >= 17 and pre <= 32 ; return "$slime.png"
        elsif pre >= 33 and pre <= 48 ; return "$slime.png"
        else ; return "$slime.png"
        end
      end
    end
  end
  def self.down_x(id, type = "enemy")
    # The X of the downset here. To add enemy, add below "enemy", else add below "else"
    case type
    when "enemy"
      case id
      when 5 ; r = 1
      else ; r = 0
      end
    else
      case id
      when 1 ; r = 0
      when 2 ; r = 1
      when 4 ; r = 2
      when 5 ; r = 1
      when 6 ; r = 2
      when 8 ; r = 1
      else ; r = 0
      end
    end
    return r
  end
  def self.down_y(id, type = "enemy")
    list = []
    # The Y of the downset here. To add enemy, add below "enemy", else add below "else"
    case type
    when "enemy"
      case id
      when 0 ; r = 0
      else ; r = 0
      end
    else
      case id
      when 1 ; r = 0
      when 2 ; r = 2
      when 3 ; r = 3
      when 5 ; r = 1
      when 6 ; r = 1
      when 7 ; r = 3
      when 8 ; r = 1
      else ; r = 0
      end
    end
    return r
  end
  #-----------------------------------------------------------
  # End Downsets by Nick
  #-----------------------------------------------------------
end
[/code]
 
Ruben52":1u2vcxfp said:
Gubid i made an event and used the call script command. I put this in this command in:
@spriteset.tile_sprites.push(Sprite_Range.new(@spriteset.viewport1, 255, 5, 5, visible))

It gave me a error:  NoMethodError occured while running the script: undefined method 'tile_sprites' for nil:nilclass

I know i'm probably am just being a newb. I really don't understand much when it comes to scripting.
First when you create your scene you have to call a spriteset.. which will draw the map or hold all the sprites etc.  I used my own variation of the spriteset_map, so that the map still draws, but has additional functionality and reduced functionality in some area's.  My variation of the spriteset creates a @tile_sprites = [].. and makes it available via attr_reader at the top in order to have other classes able to see it and add to it.  Hence the previous line I gave you. 

  def character_name
    return @character_name if !$game_temp.in_battle
    return "$slime.png" if dead? and !animated? # beauner alteration
    return @character_name #defines character sprite in battle
  end
This should be doing the trick.  What exactly happens when they die?  Do they disappear for a minute.. then turn to the down pose?

As for the downsets.. and that part of the code.  You can simply remove it.  I dont use it anywhere in the new classes.  It is old code.  The only thing I use is the character_name and add a _down if they are dead.  Let me know if you continue to have problems.
 
no, they disappear and stay gone, its a blank sprite. but if you hover over it the square with a cursor, you can still see the correct character's faceset, their hp (0/whatever), etc. the only thing is the sprite is blank instead of the right one.
 
why not provide me a demo so that we dont have to continue guessing.  I will tell you how to fix it rather than just fixing it for you.
 
Hey Dargor, sorry but im totally lost now with the movement. Would there be anyway that you could supply a demo with just the movement showing on a random map? If not its cool. Basically i keep getting errors left and right no matter how much i play around with your movement scripts.
 
Thanks so much Gubid, this is exactly what i was looking for. Just one other question. How did you determine where the tiles should be displayed and shouldn't be displayed on your movement. For example lets say that your character's move stat is 4 and he can move 4 spaces anywhere around him. How did you determine if there was an unpassable tile around or a move reduction tile around the character you are controlling so it could alter where the tiles were displayed. Here is a screenshot of kinda what i mean. Thanks again!

http://www.fantasyanime.com/shiningforce/images/sf1shot54.png


Btw, sorry for calling you Dargor. Saw him post something and for some reason his name was stuck in my head lol. Thx again man.
 
silenchar.. ok the problem is because the 'index' for the character is greater than 0.. which takes the entire sprite and offsets it.. but the sprite isnt that big.  You can solve the problem in 1 of 2 ways. 
1. You can add the following line to Sprite_Battler_GTBS
Code:
def update_src_rect
    index = @battler.character_index
    index = 0 if @battler.dead?  #<-- THIS ONE
2. You can create a full size sprite sheet with all 8 charsets filled in with the desired image.. and a separate one with just the one if they use a $ in the name.  I would recommend the 1st.. cause its easy, doesnt require spriting changes, and wouldnt require additional code to guess what format to use when drawing the image. 


ruben.. its not problem.  I just thought I would point it out.  Anyway, I use a fairly complex method of path finding in the battle system to determine movable paths.  Its a little complex to wrap your head around when you first look at it, but the process is rather easy.  The part of the code you can find this is Scene Battle TBS called calc_pos.. in particular the type == 'move' section.  Its about 600 lines of code, but thats due to the extra complexity I have added to it.  The general process is this..
You push a starting postion of [x,y].. you then great a route array and a step array and add the index to the position to the step array. and a 0 to the route array (indicating no move to get there).  You then say.. for each position in steps.. get the x,y position.. using the index provided by steps.. You then check each square surrounding position x,y.. and if it is passable.. you add it to positions, you add the direction to route[index] and push the index of the position to the steps array.  This process completes when no further steps can be taken because route[index].size == move_max.  Like I said, rather complex, but still a rather easy concept.  Let me know if that helps.  You can also use something of a A* method to find the paths and movement area, but all that is up to you.  Most of the A* methods were not really available until after I had made much of this. Well, I am sorta mumbling now. Later
 
Thanks gubid, its now working perfectly.

However, is there a way for actors to be kept on the map, but for enemies to be removed from the map? (as if that was enabled in the settings portion, but only in regards to enemies, actors/neutrals would remain on the map with downed images)
 
You weren't kidding Gubid. It does sound pretty complicated!  :dead: Now i give you even more credit. That's just insane lol. I'll tell you what. If you can throw me together one more demo together where it displays the movement tiles on screen based on what a character's movement stat is, then i will be forever greatful, because i have no idea where to even begin with the movement. Also is terrain checking and character checking a part of those 600 lines where it changes the route depending on the terrain and if a character is standing where a piece of terrain should be placed? Now i'm mumbling lol. Either way you have been an outstanding help and will definately get major credit in my upcoming game.
 
Silenchar..
Code:
def update_death
    if @battler.damage == nil and @battler.dead? and !@battler.collapsed?
      if ![4,5].include?(@battler.pose?)#(pain or collapsing... )
        if GTBS::REMOVE_DEAD or @battler.is_a?(Game_Enemy)
You are simply adding the 'or @battler.is_a?(Game_Enemy)'  By doing that it says.. if we are using the remove dead.. or they are an enemy.  This is again, part of sprite_battler

ruben.. I already have a demo! lol  Yeah, currently it takes into consideration the 'cost',battlers,height(iso) and others to move in a specific route.  I could trim it down.  Maybe I will do that later today.
 
Thanks Gubid, I would really appreciate that considering how newbish i am when it comes to scripting. I was thinking about having a shining force style movement system which is just like your system in terms of tile placement and what not. Not sure if you played shining force but the only difference with the movement is instead of moving the cursor around like in final fantasy tactics, you actually move teh character around and they can't exit the parameter of the tiles. Here is a screen.

http://www.fantasyanime.com/shiningforce/images/sf1shot54.png

Thanks again man. You're saving my ass here! =D
 
Nope.. never played it. But I thought about doing it that way.. but then I didnt do it, cause I wanted it to be more like FFT.

Anyway.. silenchar.. I just thought of something.  Adding the or @battler.is_a?(Game_Enemy) will not resolve the problem completely.  It will actually require that PLUS a change to the update_battlers (or process battlers) part of scene_battle. to ensure they actually get removed from the map and everything not just to remove the graphic.
 

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