Jump to content
kal

Ruby/RGSS3 questions that don't deserve their own thread

Recommended Posts

Oddly enough, I got it to work. I just needed to put the A in apostrophes.

It works like this:

$game_self_switches[[24,16,'A']] == false

Thank you guys for your responses!

Share this post


Link to post
Share on other sites

Hey!

 

Quick question, I'm using Yanfly's common event shop, and want to have certain shop items be hidden dependent on a veritable. (Hope this is the right place for this...)

 

This is the notetag I have to set up

 

<shop show eval>
  string
  string
</shop show eval>

 

How would I write a line of code to check if a variable is higher than (or equal to) x? 

Share this post


Link to post
Share on other sites
13 hours ago, Vis_Mage said:

Hey!

 

Quick question, I'm using Yanfly's common event shop, and want to have certain shop items be hidden dependent on a veritable. (Hope this is the right place for this...)

 

This is the notetag I have to set up

 


<shop show eval>
  string
  string
</shop show eval>

 

How would I write a line of code to check if a variable is higher than (or equal to) x? 

 

Something like this should work

 

<shop show eval>

    $game_variables[23] >= x

</shop show eval>

 

 

Share this post


Link to post
Share on other sites
1 hour ago, Shiggy said:

 

Something like this should work

 

<shop show eval>

    $game_variables[23] >= x

</shop show eval>

 

 

Yup, works like a charm! Thank you! :)

Share this post


Link to post
Share on other sites

I'm working on a Quest Window Script.

So far I'm working on the "Difficulty Window" where 5 stars are shown.

If you were to accept an easy 1-star quest, I want to eventually have it updated so that only 1 of the 5 stars appears, but APPARENTLY my rect doesn't want me to do that!

 

Inside is my Difficulty Window method. I have a BKaminari_Quest Module where contants like STAR_HEIGHT and such are already defined.

The main problem is I've tested this code in and out and my "@width" is working fine. The "@rect" rectangle I made should take a portion of my bitmap, "@stars" and width-wise, start at 0 and take enough space for 1 star (50px). Shouldn't contents.blt print only 1 star and not the entire width (250px) of my bitmap?

 

Spoiler

module BKaminari_Quest
  QUEST = "Quest"
  
  QUEST_TITLE = [
  ["Grab an Apple","Grab an Apple from a Tree"],
  ["Find my Ball","find his balls"],
  ["Stop That Guy","beat em up"],
  ["Eat this","I wouldn't"],
  ["To North","Go to The Mountain"],
  ] # ~ end QUEST_TITLE
  
  DESCRIPTIONS = [
  #(1)difficulty,(2)exp earned,(3)rewards,(4)location,(5)condition,(6)description
  
  ] # ~end DESCRIPTIONS
  
  module DIFFICULTY
    FILENAME = Cache.picture("difficulty.png") #~ each star is 50px x 50px, 250px x 500px total
    STAR_WIDTH = 50
    STAR_HEIGHT = 50
    #~~~~~~~~~~~~~~~~~~
    module TYPE #you can define the x coordinate for the difficulty you want
      GREY        = STAR_HEIGHT*1
      LIGHT_BLUE  = STAR_HEIGHT*2
    end # ~ end TYPE
    #~~~~~~~~~~~~~~~~~~
    module RANK #the y coordinate for level of difficulty is assigned.
      BEGINNER  = STAR_WIDTH*1
      EXPERT    = STAR_WIDTH*2
      MASTER    = STAR_WIDTH*3
      KING      = STAR_WIDTH*4
      SLAYER    = STAR_WIDTH*5
    end # ~ end RANK
  end # ~ end DIFFICULTY
  
  QUESTS = [
    [DIFFICULTY::TYPE::GREY,  DIFFICULTY::RANK::BEGINNER, 1],
    [DIFFICULTY::TYPE::GREY,  DIFFICULTY::RANK::EXPERT,   2],
    [DIFFICULTY::TYPE::GREY,  DIFFICULTY::RANK::MASTER,   3],
    [DIFFICULTY::TYPE::GREY,  DIFFICULTY::RANK::KING,     4],
    [DIFFICULTY::TYPE::GREY,  DIFFICULTY::RANK::SLAYER,   5],
    
    ] # ~ end QUESTS
  ACTIVE = []
  
  module REWARDS
  
  GOLD_ICON = 1
  GOLD = [
  ] # ~ end GOLD
  ITEMS = [
  #Quest 1
  ] # ~ end ITEMS
  ARMORS = [
  #Quest 1
  ] # ~ end ARMORS
  WEAPONS = [
  #Quest 1
  ] # ~ end WEAPONS
  
  end #~ end REWARDS
  
  
  attr_accessor :current_quest
  def self.current_quest
    @current_quest
  end
end

 

class BKami_Difficulty_Window < Window_Base
  def initialize()
    
    super(Graphics.width/2, 0, Graphics.width/2, Graphics.height/4)
    draw_text_ex(contents.width/3,0,"Difficulty")
    @active = BKaminari_Quest::ACTIVE
    @current_quest = 
      if @active.empty? 
        0
      else
        @active[0][2] -1
      end
    @stars = Sprite.new()
    @stars.bitmap = BKaminari_Quest::DIFFICULTY::FILENAME
    @stars.x = Graphics.width/2
    #-----------
    @stars.y = contents.height*3/8
    @width   = 0
    @height  = 0
    @startY  = 0
    @stars.zoom_x = Graphics.width/2.to_f / @stars.bitmap.width
    @stars.zoom_y = Graphics.height/2.to_f / @stars.bitmap.height
    @height = BKaminari_Quest::DIFFICULTY::STAR_HEIGHT
    @stars.visible = false
    set_visibility
    set_src_values
    @rect = Rect.new(@stars.x,@startY,@width,@height)
    contents.blt(0, @stars.y, @stars.bitmap, @rect) if @stars.visible
  end
  
  def set_visibility # ~ BKaminari_Quest::QUESTS
    BKaminari_Quest::QUESTS.size.times do |quest|
      if @active.include?(BKaminari_Quest::QUESTS[quest])
        @stars.visible = true
        break
      end
    end    
  end
  
  def set_src_values
    if @active.empty?
      @startY = 0
    else
      @startY = (@active[@current_quest-1][1].to_f / (@stars.bitmap.height/BKaminari_Quest::DIFFICULTY::STAR_HEIGHT)) * @stars.bitmap.height
    end 
    if @active.empty?
      @width = 0
    else
      @width = @active[@current_quest-1][1]
    end
  end
  
  
  def update
    @active = BKaminari_Quest::ACTIVE
    #Setting up SRC values
    set_src_values
    set_visibility
    #Making the SRC rectangle
    #@stars.src_rect.set(@stars.x,@startY,@width,@height)
    @rect.set(0,@startY,@width,@height) if @stars.visible
    contents.blt(0, @stars.y, @stars.bitmap, @rect) if @stars.visible
  end
end

 

pt3-difficulty.JPG

pt2-difficulty.JPG

pt1-difficulty.JPG

Share this post


Link to post
Share on other sites

In Window_Status, where equipments are drawn, I simply want to "hide" the weapon. I don't want the game to unequip anyone or anything, but just not show the equipped weapon (in my project, weapons are actually armors, because actual weapons set the character's animations, it's complicated).

 

@actor.equips.each_with_index do |item, i| 
  draw_item_name(item, x + 340, 48 + line_height * i)
end

^ This is the code in question, which lists all of the actor's equipment. How would I get this to simply not show the first result in the batch of results that it pulls?

Share this post


Link to post
Share on other sites
4 hours ago, WCouillard said:

^ This is the code in question, which lists all of the actor's equipment. How would I get this to simply not show the first result in the batch of results that it pulls?

 

Until you mentioned that all your armor were weapons, I would've suggested just excluding any RPG::Weapons from being drawn. But if all you want to do is nix the first line, you can just do this:

draw_item_name(item, x + 340, 48 + line_height * i) unless i == 0

Two problems: one, it will blank out the first line, but everything else will still be drawn in the usual place (i.e. the second item will still be drawn at position [48 + line_height * 1] instead of [48 + line_height * 0]). So if you wanted the second item to be shown in the original position of the first, you'll have to pull up the whole thing by line_height ("48 + line_height * (i - 1)).

 

Second problem - if you have a dual-wielding actor, this will prevent the first weapon from being drawn, but the second weapon will still be drawn because, well, it's the second item on the list. You're going to need to make an extra check for whether the actor is dual-wielding and then blank both first and second lines if they are. And then pull up the list by two line_heights if you wanted the first armor to be at the top of the list.

 

Of course this only works if your "weapons" are the first/second items on the list. If they're meant to be an arbitrary position down the equipment list you're going to run into trouble, because then you'll need to distinguish them from your armor somehow - and then you'll have to forgive me for wondering why you didn't just make your armor, well, armor and needed them to be weapons instead.

Edited by Traverse

Share this post


Link to post
Share on other sites

Another quick question!

 

I'm looking to revamp and clean up how I program field of vision for a certain event.

I've come to the conclusion that maybe using terrain tags would be an effective, versatile way to mark where walls and other obstacles are that would hide the player.

 

The set up would essentially be something like:

Is $game_map.events[1] facing left?

Is $game_player.x less than $game_map.events[1].x ?

Is terrain tag #1 greater than $game_player.x and terrain tag #1 less than $game_map.events[1].x ?

Is terrain tag #1's Y coordinate equal to $game_player.y ?

If so, then player is hidden.

 

Basically, it checks to see that when the enemy is facing left and the player is in front of them, is there a terrain tag of #1 between the player and the enemy, and is there a terrain tag #1 on the same Y coordinate as the player.

 

My problem is, is that I'm struggling to find the right script calls that relate to terrain tags. How would I call a specific terrain tag? How would I call to check its coordinates?

I've found script calls like "$game_player.terrain_tag" and "$game_map.terrain_tag", but the neither seem to return the # of the terrain tag, or the x/y position of that specific terrain tag.

 

I'm making up things like "$game_map.terrain_tag[1].x" to see if they work, but nothing has for the time being.

 

Thank you for your time!

Share this post


Link to post
Share on other sites
1 hour ago, Zen Blood said:

My problem is, is that I'm struggling to find the right script calls that relate to terrain tags. How would I call a specific terrain tag? How would I call to check its coordinates?

I've found script calls like "$game_player.terrain_tag" and "$game_map.terrain_tag", but the neither seem to return the # of the terrain tag, or the x/y position of that specific terrain tag.

 

The usages of $game_player.terrain_tag and $game_map.terrain_tag are different. They're separate methods - $game_player's version originates from Game_CharacterBase, but $game_map's originates in Game_Map.

 

Using "$game_player.terrain_tag" will return you the terrain ID of the tile the player is standing on. On the other hand "$game_map.terrain_tag" needs to be provided with an argument, its correct usage is "$game_map.terrain_tag(x, y)". You provide the x/y tile coordinates as arguments and it will return you the terrain ID of that tile.

 

AFAIK, there is no inbuilt method for retrieving the every tile coordinate for all tiles of a specific terrain tag. You will need to code that yourself (by running the terrain check on every applicable tile) if you want to find out. In your case, that's every tile in between the player and your target assuming you only want a straight line LoS and don't care about diagonals.

Edited by Traverse

Share this post


Link to post
Share on other sites

Thank you, Traverse. I think I may understand how to proceed now!

 

Edit: Lord have mercy on my sad little soul, I confused terrain tags with region IDs:unsure: 

I'll probably run into a similar problem, so I think the advice still helps. Thank you again.

 

One more edit: I can't believe it- I got it to work!! Now I don't have to be committed to setting obstacles that block off LoS. I can just stick a Region ID tag on them. This is too good to be true.

Edited by Zen Blood

Share this post


Link to post
Share on other sites

Okay, I have a question.

 

How can I reference an enemy battler within a script that will execute during battle? I want to play an animation and then deal damage to an enemy whose index is defined with a game variable, but I don't know the syntax for actually accessing enemy battlers.

 

It'd be something like this for examle:

 

 X.animation_id = 34

 

where "X" is something like $game_data.troops.index(4) or something...But I don't actually know what that something is.

Share this post


Link to post
Share on other sites
On 6/23/2018 at 3:28 AM, dailyminerals said:

Okay, I have a question.

 

How can I reference an enemy battler within a script that will execute during battle? I want to play an animation and then deal damage to an enemy whose index is defined with a game variable, but I don't know the syntax for actually accessing enemy battlers.

 

It'd be something like this for examle:

 

 X.animation_id = 34

 

where "X" is something like $game_data.troops.index(4) or something...But I don't actually know what that something is.

I believe to access which enemy is indexed in a troop, it's $data_troops[troop_index].members[index].

Unfortunately, the objects in the @enemies array in the members method in Game_Troop are NOT enemy objects, but they do give out the index of the enemy in database.

To find that enemy, use $data_enemies[$data_troops[troop_index].members[index].enemy_id]

 

And then for your animation thingy, you can set up an if statement.

@enemyy = $data_enemies[$data_troops[troop_index].members[index].enemy_id]

if @enemyy.name == "GIANT MUTANT SPIDER"

   #use whatever animation_id that burns house down

end

Share this post


Link to post
Share on other sites

Real easy question this time.

I'm just trying to change the max level. I looked up solutions and thought it would be easy, but even other people's scripts aren't working. I'm not sure if it's because of how my specific VX Ace is set up, but here it is:

image.png.bcf6a587610ab450644acc085c7c8157.png

 

and yet I get this error:

image.png.1d284a9410942cf859526139ca9d914d.png

 

and it takes me here:

image.png.c9a141a9feeb299bdc0075c884a790c6.png

 

is there anything else I need to change or change this up differently? As you can see, I want a max level of 150. ;~;

Share this post


Link to post
Share on other sites

The problem with that is that the lookup tables for what stats you get per level only go up to level 99. If you are past level 99 it will give that error when trying to look up stats because there is no data there and will return nil. Only way to fix it is to either import your own larger table, or recode it to use a formula.

Share this post


Link to post
Share on other sites
On 10/26/2018 at 6:02 PM, AeghtyAteKees said:

I can use

 

$game_map.display_name

 

to access the display name for the map I'm on, but how do I access the display name of any map?

I got you my boy.

This script is unfinished because of the method "on_map_ok", as I don't know what you want to do now with this information :)

----------------------

Spoiler

#=======================================================
#=======================================================
#------Brandon Kaminari: Road Maps v 1.0--------
#------Use: Commercial or Non-Commercial
#------ Instructions: 
#       - place Script over "Main".
#       - use script call (Events, 3rd page), load_routemap(???) as such:
#         - @example = 14,15,13,20
#         - load_routemap(@example)
#=======================================================
module BKami_MAPS
  LOAD = [] # LEAVE BLANK
end

class MapWindow < Window_Selectable
  def initialize
    super(0,0,window_width,window_height)
    data = []
    self.index = 0
    activate
    refresh
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    Graphics.width - 160
  end
  #--------------------------------------------------------------------------
  # * Get Window Height
  #--------------------------------------------------------------------------
  def window_height
    fitting_height(BKami_MAPS::LOAD[0].size)
  end
  
  def refresh
    contents.clear
    make_item_list
    create_contents
    draw_all_items
  end
  
  def item_max
    @data ? @data.size : 1
  end
  
  def item #actor
    @data && index >= 0 ? @data[index] : nil
  end
  
  def make_item_list
    @listy = []
    @load = BKami_MAPS::LOAD
    @load[0].size.times do |ccc|
      @map_id = @load[0][ccc]
      @map = load_data(sprintf("Data/Map%03d.rvdata2", @map_id))
      @listy[@listy.size] = @map.display_name
    end
    @data = @listy
  end
  
  def draw_item(index)
    item = @data[index]
    if item
      draw_text_ex(0, line_height*index, item)
    else
      draw_text_ex(0, line_height*index, "Error :c")
    end
  end
end

class Game_Interpreter
  def load_routemap(xxx)
    return unless xxx.is_a?(Array)
    BKami_MAPS::LOAD[BKami_MAPS::LOAD.size] = xxx
    SceneManager.call(BKamiRoadMapScene)
  end
end

#==============================================================================
# ** Scene_Base
#------------------------------------------------------------------------------
#  This is a super class of all scenes within the game.
#==============================================================================

class BKamiRoadMapScene < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
    super
    @roadmap = MapWindow.new
    @roadmap.set_handler(:ok,     method(:on_map_ok))
    @roadmap.set_handler(:cancel, method(:return_scene))
  end
  
  def on_map_ok
    # WHAT DO YOU WANNA DO NOW? :)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super
  end
end

 

 

Edited by Rikifive
Put the code in a spoiler

Share this post


Link to post
Share on other sites

That script above needed a spoiler tag.

 

Anyway...

There's this odd thing involving Victory Engine, specifically, it's Direct Command.

Spoiler

<direct skill: x, y>
# Add direct command skill to the actor list
# x : skill id
# y : condition, should be equal usable or learned. optional

 

 

What it is I struggle with is how the conditions work. I don't know exactly how to make a valid condition here.

Share this post


Link to post
Share on other sites

Instead of 'y' put usable or learned or don't put 'y' argument at all to make it display the skill all the time even when not having that learned, think of making another command similar to "Guard".

A4tdzXW.png

Share this post


Link to post
Share on other sites

OK, so, I am trying to pull the target's name during a damage formula method, and compare it against a list of names stored in a global variable. When the target's name matches any of the names stored, a little something extra gets added to the damage formula's output. A state is also required on the user of the attack (that part works fine already). I don't seem to be getting the proper syntax, but I've tried a whole bunch. Looking for some help on this one.

if a.state?(968) && ??????
  modded_damage_value = damage_value *+ 1.5
end

Where the ?????? is, that's where I'd need to put the proper syntax to compare the enemy's name (I'm assuming we'd begin with b.name) to the list stored in the global variable, like so:

$enemy_human   = [
                  "Captain",
                  "Goblin",
                  "Soldier",
                 ]

What it is aiming to do is increase damage output by a certain amount if the user has a certain state and is targeting an enemy of a certain type (in this case, a human enemy, which are all listed inside that global variable).

Share this post


Link to post
Share on other sites

Of the top of my head, I think you want to do

 

$enemy_human.include?(a.original_name)

 

Though you might want to check if the target is in fact an enemy or else it won't work.

 

I think you should use a note tag of some sort rather then a list of names though, it makes things so much easier in the long run not to have to update the code when you add new enemies. But if you don't want to bother with figuring out the regex stuff for parsing notetags, I understand. Personally I just use one script to do all of my note stuff, but that means a lot of my scripts rely on that one. Oh well...

Edited by Kayzee

Share this post


Link to post
Share on other sites

Worked like a charm! Thank you.

 

The list of names is kept in its own script, so it's about as much work as typing out a notetag would be,  anyway. One of these day's I'll move into using them, though.

Share this post


Link to post
Share on other sites

Hehe, glad I can help! *sprinkles fairy dust on you*

 

I just think it's easier to have all an enemy's properties in one place so you don't have to edit the script every time you add or change something in the database. I couldn't say if it is actually less work overall, but it's much less of a hassle to edit later.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×