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.

Problem with Skillsystem

bukai

Member

Hey,
l'm working on a Skillsystem, you get 1 point per lvlup and learn skills through it.

the update whenever l spend one point seems not to work.
Code:
  def skill_update(member_index = 0)

    actor = $game_party.members[member_index]

    points = actor.points

    @gesetzt1 = 0    # @gesetzt1 = counter 

    if Input.trigger?(Input::C) and actor.points > 0

      case @command_index

      when 0 

        if @gesetzt1 == 0

          Sound.play_decision

          actor.points -= 1

          @gesetzt1 += 1

          actor.learn_skill(5)

        elsif @gesetzt == 1

          Sound.play_decision

          actor.points -= 1

          @gesetzt += 1

          actor.learn_skill(6)

          actor.forget_skill(5)

        elsif @gesetzt == 2

          Sound.play_decision

          actor.points -= 1

          @gesetzt += 1

          actor.learn_skill(7)

          actor.forget_skill(6)

        elsif @gesetzt == 3

          Sound.play_decision

          actor.points -= 1

          @gesetzt += 1

          actor.learn_skill(8)

          actor.forget_skill(7)

        elsif @gesetzt == 4

          Sound.play_decision

          actor.points -= 1

          @gesetzt += 1

          actor.learn_skill(9)  

          actor.forget_skill(8)

        elsif actor.points = 0 or @gesetzt1 == 5

          Sound.play_cancel

        end

      end

    end

  end

end
the similar code for each index...
now when l open the skilltree, and press Enter l can spend points like hell.
and only learn the first skill.
need help, it's important D:
 
Hey there,

Ok, 1) This is the internet. It's an amateur game-making forum. Believe me, NOTHING here is "important"! :scruff:

Now that we got that cleared up....

Syntax errors:
You need to spell variables the same throughout. gesetzt is not the same as gesetzt1
elsif actor.points = 0 or @gesetzt1 == 5 # = should be ==. the first statement will always return true if you can write to 'points'

Logic errors:
You can only learn the first skill because you are initializing gesetzt1 to 0.
It looks like you should be setting gesetzt1 to the actor's level. (at level 0 learn skill(5), at level 1 learn skill(6)....)

If the player advances several levels before 'buying' new skills, he needs to gain the skill for that level, and forget the skill from the previous level he was at (not necessarily the skill for current_level - 1). So, you should probably save the previous level, rather than trying to add & remove the skill for every level up to the current one.

Where are you calling this from?

Be Well
 

bukai

Member

thanks for your reply.

Syntax errors:
You need to spell variables the same throughout. gesetzt is not the same as gesetzt1
elsif actor.points = 0 or @gesetzt1 == 5 # = should be ==. the first statement will always return true if you can write to 'points'

my bad! l copied the script from an older demo and haven't fixed the typos. sorry.
lt didn't work, either.

Logic errors:
You can only learn the first skill because you are initializing gesetzt1 to 0.
It looks like you should be setting gesetzt1 to the actor's level. (at level 0 learn skill(5), at level 1 learn skill(6)....)

l think l got what you mean..

But this:
If the player advances several levels before 'buying' new skills, he needs to gain the skill for that level, and forget the skill from the previous level he was at (not necessarily the skill for current_level - 1). So, you should probably save the previous level, rather than trying to add & remove the skill for every level up to the current one.

So l should add a skillcheck, which skill is learned?

The Skilltree is supposed to work like this:
a couple of various skills can be learned by spending points.
e.g.:
Improved Bloodslash (0/5) # 0 for actual slvl, 5 for maxslvl)
Now l'm putting one point in it, and the actor's Bloodslash
ATK coefficient is increased with each level by 25%.

Other skills will require 5/5 in Improved Bloodslash,
otherwise you can't put points in it.

l'm calling it from my Scene, added to the menu.

l'm gonna sleep now.
cu
 
Yes, if the skills are in succession, and the user only has one in a series at a time, you could just check to see which one he currently has to determine which level he left off at. (which one to remove).
If it's a relatively small list, you could just remove them all, then add the 1 for the current level.

Let me know how it goes.
 

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