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.

Error with Job System

Actually, my job system works fine, I just want to make jobs exclusive to different actors. So I added a 'user'=>1 to the array, so I ended up with something like:
Code:
 Jobs = [
  {'name'=>"Scout", 'user'=>1,
  'max_lvl'=>5, 'lvl1'=>10, 'lvl2'=>30, 'lvl3'=>58, 'lvl4'=>98, 'lvl5'=>189,
  'HP'=>30,'SP'=>0,'STR'=>5,'DEX'=>10,'INT'=>0,'AGI'=>10,
  'job_needed'=>nil, 'lvl_needed'=>nil, 'gender'=>'Male',
  'desc'=>"Scout"
  }
]
and it works fine. But later on when making the list of jobs to display on Scene_Professions, I did: (note: I'm not pasting the entire class)
Code:
class Scene_Professions
  
  def initialize(actor_pos)
    @actor_pos = actor_pos
    @actor = $game_party.actors[actor_pos]
  end
  
  
    def main
    y = $game_party.job_ad.clone
    @job_list = []
    for i in 0...(y.size)
      job = y[i]
      if job['user'] == @actor.id
        @job_list.push(y[i])
      else
        @job_list.push(y[0])
        end
    end
And so on and so forth. I put the else in there just so it'd be able to make a window if the if statement failed.. which it has. $game_party.job_ad is an array of jobs that are available, so y should be the same thing. y should be just one job, then (which it is since @job_list.push(y[1]) works fine and is displays in my Scene_Professions the way I want.

The problem is, no matter if i use @actor.id or 3 or @actor_id, the if doesn't work and I get a million Scouts in my window. Does anyone know what I'm doing wrong?
 
Bumped with second question!

Say I have a window that's 300 x 300. How do I set it up so that I can draw text/bitmap/whatever in that 300 x 300 area instead of it randomly cutting off places?
 
For the first question, when the job's user doesn't equal the right one it adds the first job to the list.
Instead of:
Code:
      if job['user'] == @actor.id
        @job_list.push(y[i])
      else
        @job_list.push(y[0])
      end
Use:
Code:
      if job['user'] == @actor.id
        @job_list.push(y[i])
      end

As for your second question what do you mean randomly cutting off in places?
 
I used
Code:
      if job['user'] == @actor.id
        @job_list.push(y[i])
      end
but it didn't add anything to the list and I'd have errors when going into Scene_Professions (bitmap can't create since the array had no contents, etc etc) so I added the else to ensure something was in the array. And as expected, all the conditionals failed.

As for the second question, I'm using an edit of Catchm's FFX-2 menu, which mostly uses png files to represent windows with 0 opacity. On the equip screen, the png file has the names of the equipment slots hard-printed onto them, but I'm using a Multi-slot script to I'm able to move those slots the way I want. So... I changed the code and picture so that the script itself wrote the slot names in those places, but the window restriction cuts it off since it's too close to the edge, yet it's still in the window's range.
 
What is the point of having a job system without jobs? Well if you want to push an empty job on if there are none put this after the job adding loop:
Code:
      if @job_list == []
        @job_list.push('')
      end
As for your second problem try editing the line which looks something like:
Code:
self.contents = Bitmap.new(width - 32, @item_max * 32)
 
No, no. I'm trying to make it so that it only lists the jobs meant for that particular person. It's a huge job system which ends up with about 25 jobs per person. With 6 actors I don't want each list to have every single job, especially since they can't use the ones not meant for them.

That's why I added the 'user' part of the hash, which works when checking if they can use the job of not, but it seems to fail when I'm pushing the jobs into @job_list

I don't want to add the else to it, but there's no real 'unemployed' job as there was in your original script, so without it @job_list would be empty (until the conditional worked, at least.)

EDIT: I changed the code to:
Code:
    for i in 0...(y.size)
      job = y[i]
      if @actor.actor_qualified(y[i])
        @job_list.push(y[i])
        end
    end
and made a method called actor_qualified which was pretty much the same thing as the conditional. It works fine now, I just worry about the framerate of the game with my messy scripts. Now to edit the equip window...
 

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