Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Help: There must be an easier way..., 960 if/then statements...
Rimrook
post Apr 29 2011, 03:35 PM
Post #1


Level 2
Group Icon

Group: Member
Posts: 25
Type: Developer
RM Skill: Advanced




Lets layout what I am working with first.

I have 96 skills. Each one has 10 levels. Which makes 960 skills overall in the skills data base. Each skill has a variable to control the level. I have a common event to check the variables and learn/unlearn the skills respectfully.

That common event has 960 if/then statements filled with learning/unlearning commands.

Like
if Vindicate level is 5, unlearn Vindicate skills level 1 through 4, learn Vindicate level 5, unlearn Vindicate level 6 through 10.

Of course there are 960 of these statements which I have to do myself by hand. I can't seem to find a dynamic way of processing this stuff with event commands.

Which brings me to ask for a scripting solution. Can I get a bit of help on this or am I to suffer removing this boulder using a needle? I will provide more info if you need it.


__________________________
Currently working on: "PX"
■□□□□□□□□□ Maps
■□□□□□□□□□ Characters
■■□□□□□□□□ Graphics
■■■■■■■■■□ Music
■■□□□□□□□□ Sound
■■■■■■■■■■ Story
■■■■■■■■■□ Systems
Go to the top of the page
 
+Quote Post
   
Sailerius
post Apr 29 2011, 09:52 PM
Post #2


Blue Blue Glass Moon
Group Icon

Group: Revolutionary
Posts: 881
Type: Developer
RM Skill: Beginner




One way to make it more stomachable is a switch statement. Unfortunately, unless there's some pattern to the skills, it seems like that's the best way to do it.


__________________________
Go to the top of the page
 
+Quote Post
   
kellessdee
post Apr 29 2011, 10:39 PM
Post #3



Group Icon

Group: Member
Posts: 1
Type: Scripter
RM Skill: Undisclosed




ohmy.gif That's what I call effort, 960 skills wooweee

Does every skill in the game have different levels?
What is the difference between levels?

Either way, I think your best bet would be to modify the skill class to include a level attribute, and set up the modifications within the class.
Through events, the way you are currently doing it is really the only way. if you wanted to process this stuff more dynamically you would definitely need some kind of script modification.

Lemme know if you'd rather go that route because I can give ya a hand


__________________________
"Some people never go crazy, What truly horrible lives they must live." -- Charles Bukowski
Go to the top of the page
 
+Quote Post
   
Knot
post Apr 30 2011, 12:14 AM
Post #4


Level 25
Group Icon

Group: Revolutionary
Posts: 555
Type: Artist
RM Skill: Skilled




Well, this shouldn't be that hard to do once I know exactly what you're after, nor will you have to modify any scripts.

What my understanding right now is:
You have 96 skills represented by 10 levels each. in the database, skills 1-10 are the varying levels of
skill 1, 11-20 are the varying levels of skill 2 etc...
You also have 96 variables. You want it so that when variable[1] is set to 5, then the character will learn
skill1.lvl5 and forget any other variants of skill1.
if variable[28] is 10 then the character will learn skill28.lvl10 and forgot all other variants of skill28.
You want this to be done by calling a common event.

Correct so far?

My only real question is if your game only has one character or more than one. If there's more than one, how do you want the system to choose the right character?

Assuming these factors:
-you have only 1 character, the first in the database.
-the skills are represented in the order above and are the first 96.
-the 96 variables are the first 96 (i.e 1-96).

This is what I would do:
In your common event, on the 3rd window of the event screen select "script" and copy/paste this exactly:

@actor=$game_actors[1]
for @y in 1..96
for @x in 1..10
@x=@x+((@y-1)*10)
@actor.forget_skill(@x)
@s=$game_variables[@y]+((@y-1)*10)
@actor.learn_skill(@s)
end
end

It probably isn't the prettiest or simplest way of doing it, but it should work assuming what I said above is true. If you were looking for something else or if you DO want to define which character is going to learn the skill, some work will need to be done.

In effect how it works is as follows:
It chooses the actor to learn the skill.
it selects the 96 variables.
it gives each one a group of 10.
this group is unlearnt by the actor.
the skill in the variable is learnt by the actor.

I hope this helps! And I welcome anyone who wishes to correct any mistakes or offer a simpler solution. I can also explain it further if you'd like, because I understand it looks like a mess and I sure know that I always like to know exactly how everything in my game fits together!

This post has been edited by Knot: Apr 30 2011, 12:19 AM


__________________________
Unclickable!


QUOTE (X-M-O)
Oh no! I've been quoted again! D=



Other cool stuffs to check out! Even if they arn't mine...





Go to the top of the page
 
+Quote Post
   
Rimrook
post Apr 30 2011, 08:42 AM
Post #5


Level 2
Group Icon

Group: Member
Posts: 25
Type: Developer
RM Skill: Advanced




Knot, you have it right for the most part. Here's a little more info, I don't know how it changes things in the script so far.
I tried the script as it is and it just gave me levels on all of them. Its weird. Also if the variable is 0 the skill needs to be completed forgotten.

If you have ever played Diablo 2, its like that skill system. Built it myself smile.gif

Skill levels are set on Variables 30 - 126

Actor 1 is 30 - 54
Actor 2 is 55 - 78
Actor 3 is 79 - 102
Actor 4 is 103 - 126

Essentially each character has a set of 24 unique skills. There are only 4 playable characters in the game. There will only be 96 player skills.

Oh, this is purely cosmetic, but in the skill lists, how do I get it so that a skill with a cost of zero doesn't show the zero on the menu, and in battle, a skill that triggers a common event isn't shown at all? Essentially there is a skill that triggers an event called "Learn New Skills" that takes the player to the skill set up screen. Again its purely a cosmetic thing so it looks proper and solid by design. The ID's for these skills are specifically 961, 962, 963, and 964.

I'm asking a lot of help because I need to clean up the systems that drive my game before I can continue onward. After this, I need to just make resources and map away, everything else is done.

This post has been edited by Rimrook: Apr 30 2011, 09:00 AM


__________________________
Currently working on: "PX"
■□□□□□□□□□ Maps
■□□□□□□□□□ Characters
■■□□□□□□□□ Graphics
■■■■■■■■■□ Music
■■□□□□□□□□ Sound
■■■■■■■■■■ Story
■■■■■■■■■□ Systems
Go to the top of the page
 
+Quote Post
   
Knot
post Apr 30 2011, 02:20 PM
Post #6


Level 25
Group Icon

Group: Revolutionary
Posts: 555
Type: Artist
RM Skill: Skilled




Ah, well that simplifies things a bit. Since you arn't using the first 96 variables I had to change some of the numbers. I also split it into 4, using 1 for each actor.

Here's the link to the project file. It'll probably be easiest just to go in to the database and copy the common event across.

If you actually play the game, you can click on the square to the left to see the system working.

Good luck and tell me if you have any problems!


This post has been edited by Knot: Apr 30 2011, 02:22 PM


__________________________
Unclickable!


QUOTE (X-M-O)
Oh no! I've been quoted again! D=



Other cool stuffs to check out! Even if they arn't mine...





Go to the top of the page
 
+Quote Post
   
Rimrook
post Apr 30 2011, 04:08 PM
Post #7


Level 2
Group Icon

Group: Member
Posts: 25
Type: Developer
RM Skill: Advanced




Got an error.

NoMethodError occured while running script.
undefined method 'forget_skill' for nil:NilClass

This was when I pasted it over into my project.
:[

This post has been edited by Rimrook: Apr 30 2011, 05:29 PM


__________________________
Currently working on: "PX"
■□□□□□□□□□ Maps
■□□□□□□□□□ Characters
■■□□□□□□□□ Graphics
■■■■■■■■■□ Music
■■□□□□□□□□ Sound
■■■■■■■■■■ Story
■■■■■■■■■□ Systems
Go to the top of the page
 
+Quote Post
   
Knot
post Apr 30 2011, 06:28 PM
Post #8


Level 25
Group Icon

Group: Revolutionary
Posts: 555
Type: Artist
RM Skill: Skilled




Have you changed any of your scripts? If not, could you send me your project so that I can check what's going on?


__________________________
Unclickable!


QUOTE (X-M-O)
Oh no! I've been quoted again! D=



Other cool stuffs to check out! Even if they arn't mine...





Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 22nd May 2013 - 10:00 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker