Class by Questionnaire

I’m wanting to make a system where the class of characters is chosen randomly after the player answer a questionnaire, and in accordance with the answers, his class is chosen by the system. But do not know where to start, can anyone help me?

Sure, I could write a script if you really wanted, it would be in QB64 and not the prettiest, but it would work I guess. Now if you are looking for direction of how you would do it, then I am willing to explain it to you.

This is a unique idea first of all, glad to see someone knowing how to do this!  😄

I will say, I would never have thought of doing this, but it is simple, just ask and I’ll explain or give you a code.

Only way I see this happening is if you make a “If you answered mostly A” type questionnaire.

Make a global variable Answer(1 to MAX_QUESTIONS) as byte

and make constants like this

Public Const MAX_QUESTIONS as byte = 10 ’ This is how many questions you will be asking.

Public Const Answer_A as byte = 1

Public Const Answer_B as byte = 2

Public Const Answer_C as byte = 3

Every time the player answers a question, store it into a variable like

Answer(CurrentQuestionNumber) = AnswerNumber

Then in the end, you need to figure out how many A’s, B’s and C’s were answered in total. So in the sub where you want that to be handled, make variables like this

dim NumberOf(1 to 3) as byte, i as byte

Then, make a for loop.

For I = 1 to MAX_QUESTIONS

NumberOf(Answer(i)) = NumberOf(Answer(i)) + 1

next

Then figure out which one is the biggest using simple If logic.

If NumberOf(Answer_A) > NumberOf(Answer_B) and NumberOf(Answer_A) > NumberOf(Answer_C) then

Player(index).class = Whatever_you_want_it_to_be

end if

Then clear out the stored answers

For I = 1 to MAX_QUESTIONS

Answer(i) = 0

next

Fancy, I don’t understand any of this code but looks good.  😄

Ok, let me make a script for this, I can’t stand looking at that one, though some pieces are good, others… Lol, no offence intended Matt.

Fancy, I don’t understand any of this code but looks good.  😄

Me too xD

If you have an event system, you can do this easily. Spawn the player in a black room or wherever, then make them walk into an event. The Event has a ton of conditional branches and choices, and then, depending what they chose, the event changes their class and spells accordingly. Hope this helped someone

That will work, but when you have that many conditionals… It really lags your game, and it gets way to confusing, it is easier to write a program that opens at the title right after you create your character. And I’m still working on my program, it’s annoying while I’m multitasking…

Ok, let me make a script for this, I can’t stand looking at that one, though some pieces are good, others… Lol, no offence intended Matt.

Wohoah big boy. Post your code if you’re such a pro 😜

That will work, but when you have that many conditionals… It really lags your game, and it gets way to confusing, it is easier to write a program that opens at the title right after you create your character. And I’m still working on my program, it’s annoying while I’m multitasking…

Yeah show your code so i can copy it xD

That will work, but when you have that many conditionals… It really lags your game, and it gets way to confusing, it is easier to write a program that opens at the title right after you create your character. And I’m still working on my program, it’s annoying while I’m multitasking…

LOL It doesn’t lag your game half as much as I believe you think it does.

I think we have a solution to this already.

OK, dang that took awhile to get out all the kinks (though there is work needed so that people cant press different keys besides the ones you want…) but here is the code, not as short as I intended but it gets the job done nicely.

(Please Note – This code was made for QB64 and was made to work in its own window, not as part of a game. If you want it to work on Eclipse, you will need to edit it so it is in the correct language (VB6) and so that it is linked to the game instead of being independent)

! CLS
! GOSUB First.Question
! GOSUB Second.Question
! GOSUB Third.Question
! GOSUB Fourth.Question
! GOSUB Fifth.Question
! GOSUB Sixth.Question
! GOSUB Seventh.Question
! GOSUB Eighth.Question
! GOSUB Nineth.Question
! GOSUB Tenth.Question
! ’ You Can Add More if You Want
! PRINT "Your Class is "; Class$
! END
! First.Question:
! CLS
! PRINT "-This is Where You Put Your First Question.- "
! PRINT "-This is Where You Put Your First A Answer.- Answer A "
! PRINT “-This is Where You Put Your First B Answer.- Answer B”
! PRINT “-This is Where You Put Your First C Answer.- Answer C”
! PRINT “-This is Where You Put Your First D Answer.- Answer D”
! INPUT "Please Pick Your Answer ", CharControl$
! GOSUB Counter
! RETURN
! Second.Question:
! CLS
! PRINT "-This is Where You Put Your Second Question.- "
! PRINT "-This is Where You Put Your First A Answer.- Answer A "
! PRINT “-This is Where You Put Your First B Answer.- Answer B”
! PRINT “-This is Where You Put Your First C Answer.- Answer C”
! PRINT “-This is Where You Put Your First D Answer.- Answer D”
! INPUT "Please Pick Your Answer ", CharControl$
! GOSUB Counter
! RETURN
! Third.Question:
! CLS
! PRINT "-This is Where You Put Your Third Question.- "
! PRINT "-This is Where You Put Your First A Answer.- Answer A "
! PRINT “-This is Where You Put Your First B Answer.- Answer B”
! PRINT “-This is Where You Put Your First C Answer.- Answer C”
! PRINT “-This is Where You Put Your First D Answer.- Answer D”
! INPUT "Please Pick Your Answer ", CharControl$
! GOSUB Counter
! RETURN
! Fourth.Question:
! CLS
! PRINT "-This is Where You Put Your Fourth Question.- "
! PRINT "-This is Where You Put Your First A Answer.- Answer A "
! PRINT “-This is Where You Put Your First B Answer.- Answer B”
! PRINT “-This is Where You Put Your First C Answer.- Answer C”
! PRINT “-This is Where You Put Your First D Answer.- Answer D”
! INPUT "Please Pick Your Answer ", CharControl$
! GOSUB Counter
! RETURN
! Fifth.Question:
! CLS
! PRINT "-This is Where You Put Your Fifth Question.- "
! PRINT "-This is Where You Put Your First A Answer.- Answer A "
! PRINT “-This is Where You Put Your First B Answer.- Answer B”
! PRINT “-This is Where You Put Your First C Answer.- Answer C”
! PRINT “-This is Where You Put Your First D Answer.- Answer D”
! INPUT "Please Pick Your Answer ", CharControl$
! GOSUB Counter
! RETURN
! Sixth.Question:
! CLS
! PRINT "-This is Where You Put Your Sixth Question.- "
! PRINT "-This is Where You Put Your First A Answer.- Answer A "
! PRINT “-This is Where You Put Your First B Answer.- Answer B”
! PRINT “-This is Where You Put Your First C Answer.- Answer C”
! PRINT “-This is Where You Put Your First D Answer.- Answer D”
! INPUT "Please Pick Your Answer ", CharControl$
! GOSUB Counter
! RETURN
! Seventh.Question:
! CLS
! PRINT "-This is Where You Put Your Seventh Question.- "
! PRINT "-This is Where You Put Your First A Answer.- Answer A "
! PRINT “-This is Where You Put Your First B Answer.- Answer B”
! PRINT “-This is Where You Put Your First C Answer.- Answer C”
! PRINT “-This is Where You Put Your First D Answer.- Answer D”
! INPUT "Please Pick Your Answer ", CharControl$
! GOSUB Counter
! RETURN
! Eighth.Question:
! CLS
! PRINT "-This is Where You Put Your Eighth Question.- "
! PRINT "-This is Where You Put Your First A Answer.- Answer A "
! PRINT “-This is Where You Put Your First B Answer.- Answer B”
! PRINT “-This is Where You Put Your First C Answer.- Answer C”
! PRINT “-This is Where You Put Your First D Answer.- Answer D”
! INPUT "Please Pick Your Answer ", CharControl$
! GOSUB Counter
! RETURN
! Nineth.Question:
! CLS
! PRINT "-This is Where You Put Your Nineth Question.- "
! PRINT "-This is Where You Put Your First A Answer.- Answer A "
! PRINT “-This is Where You Put Your First B Answer.- Answer B”
! PRINT “-This is Where You Put Your First C Answer.- Answer C”
! PRINT “-This is Where You Put Your First D Answer.- Answer D”
! INPUT "Please Pick Your Answer ", CharControl$
! GOSUB Counter
! RETURN
! Tenth.Question:
! CLS
! PRINT "-This is Where You Put Your Tenth Question.- "
! PRINT "-This is Where You Put Your First A Answer.- Answer A "
! PRINT “-This is Where You Put Your First B Answer.- Answer B”
! PRINT “-This is Where You Put Your First C Answer.- Answer C”
! PRINT “-This is Where You Put Your First D Answer.- Answer D”
! INPUT "Please Pick Your Answer ", CharControl$
! GOSUB Counter
! RETURN
! Tie.Breaker.Question:
! CLS
! PRINT "-This is Where You Put Your Eleventh Question.- "
! PRINT "-This is Where You Put Your First A Answer.- Answer A "
! PRINT “-This is Where You Put Your First B Answer.- Answer B”
! PRINT “-This is Where You Put Your First C Answer.- Answer C”
! PRINT “-This is Where You Put Your First D Answer.- Answer D”
! INPUT "Please Pick Your Answer ", CharControl$
! Control = 1
! GOSUB Counter
! RETURN
! Tie.Breaker.Question2:
! CLS
! PRINT "-This is Where You Put Your Twelveth Question.- "
! PRINT "-This is Where You Put Your First A Answer.- Answer A "
! PRINT “-This is Where You Put Your First B Answer.- Answer B”
! PRINT “-This is Where You Put Your First C Answer.- Answer C”
! PRINT “-This is Where You Put Your First D Answer.- Answer D”
! INPUT "Please Pick Your Answer ", CharControl$
! Control = 2
! GOSUB Counter
! RETURN
! Tie.Breaker.Question3:
! CLS
! PRINT "-This is Where You Put Your Thirteenth Question.- "
! PRINT "-This is Where You Put Your First A Answer.- Answer A "
! PRINT “-This is Where You Put Your First B Answer.- Answer B”
! PRINT “-This is Where You Put Your First C Answer.- Answer C”
! PRINT “-This is Where You Put Your First D Answer.- Answer D”
! INPUT "Please Pick Your Answer ", CharControl$
! Control = 3
! GOSUB Counter
! RETURN
! Tie.Breaker.Question4:
! CLS
! PRINT "-This is Where You Put Your Fourteenth Question.- "
! PRINT "-This is Where You Put Your First A Answer.- Answer A "
! PRINT “-This is Where You Put Your First B Answer.- Answer B”
! PRINT “-This is Where You Put Your First C Answer.- Answer C”
! PRINT “-This is Where You Put Your First D Answer.- Answer D”
! INPUT "Please Pick Your Answer ", CharControl$
! Control = 4
! GOSUB Counter
! RETURN
! Tie.Breaker.Question5:
! CLS
! PRINT "-This is Where You Put Your Fifthteenth Question.- "
! PRINT "-This is Where You Put Your First A Answer.- Answer A "
! PRINT “-This is Where You Put Your First B Answer.- Answer B”
! PRINT “-This is Where You Put Your First C Answer.- Answer C”
! PRINT “-This is Where You Put Your First D Answer.- Answer D”
! INPUT "Please Pick Your Answer ", CharControl$
! Control = 5
! GOSUB Counter
! RETURN
! Counter:
! Counter = Counter + 1
! IF CharControl$ = “A” THEN
! Count.A = Count.A + 1
! ELSE
! IF CharControl$ = “B” THEN
! Count.B = Count.B + 1
! END IF
! IF CharControl$ = “C” THEN
! Count.C = Count.C + 1
! END IF
! IF CharControl$ = “D” THEN
! Count.D = Count.D + 1
! END IF
! END IF
! IF Counter >= 10 THEN
! IF Count.A > ControlAmount THEN
! ControlAmount = Count.A
! END IF
! IF Count.B > ControlAmount THEN
! ControlAmount = Count.B
! END IF
! IF Count.C > ControlAmount THEN
! ControlAmount = Count.C
! END IF
! IF Count.D > ControlAmount THEN
! ControlAmount = Count.D
! END IF
! IF Count.A > Count.B AND Count.A > Count.C AND Count.A > Count.D THEN
! Class$ = “Warrior”
! ELSE
! END IF
! IF Count.B > Count.A AND Count.B > Count.C AND Count.B > Count.D THEN
! Class$ = “Mage”
! ELSE
! END IF
! IF Count.C > Count.A AND Count.C > Count.B AND Count.C > Count.D THEN
! Class$ = “Paladin”
! ELSE
! END IF
! IF Count.D > Count.A AND Count.D > Count.B AND Count.D > Count.C THEN
! Class$ = “Rouge”
! ELSE
! END IF
! IF ControlAmount = Count.A AND ControlAmount = Count.B OR ControlAmount = Count.A AND ControlAmount = Count.C OR ControlAmount = Count.A AND ControlAmount = Count.D OR ControlAmount = Count.B AND ControlAmount = Count.C OR ControlAmount = Count.B AND ControlAmount = Count.D OR ControlAmount = Count.C AND ControlAmount = Count.D THEN
! IF Control = 0 THEN
! GOSUB Tie.Breaker.Question
! GOTO Counter
! END IF
! IF Control = 1 THEN
! GOSUB Tie.Breaker.Question2
! GOTO Counter
! END IF
! IF Control = 2 THEN
! GOSUB Tie.Breaker.Question3
! GOTO Counter
! END IF
! IF Control = 3 THEN
! GOSUB Tie.Breaker.Question4
! GOTO Counter
! END IF
! IF Control = 4 THEN
! GOSUB Tie.Breaker.Question5
! GOTO Counter
! END IF
! ELSE
! END IF
! ELSE
! END IF
! IF Counter >= 15 THEN
! Class$ = “Cleric”
! ELSE
! END IF
! RETURN

Now, if you wish to see how this code functions without you having to copy and paste the code into QB64, then HERE is the download for the .EXE

(Note – You will have to type in Capital letters of, A, B, C, or D)

Looks good.

I dont understand the code xD

Thanks for the replies, but I am new to programming. I tried to understand and implement yours codes, but not getting good results. If you can teach me step by step would be very grateful.

OK, dang that took awhile to get out all the kinks (though there is work needed so that people cant press different keys besides the ones you want…) but here is the code, not as short as I intended but it gets the job done nicely.

(Please Note – This code was made for QB64 and was made to work in its own window, not as part of a game. If you want it to work on Eclipse, you will need to edit it so it is in the correct language (VB6) and so that it is linked to the game instead of being independent)

Now, if you wish to see how this code functions without you having to copy and paste the code into QB64, then HERE is the download for the .EXE

(Note – You will have to type in Capital letters of, A, B, C, or D)

What? xD Mate, your QB64 code is object oriented and not event oriented like the Eclipse engine.

Thanks for the replies, but I am new to programming. I tried to understand and implement yours codes, but not getting good results. If you can teach me step by step would be very grateful.

Unfortunately, I can only help so much. I don’t know how you want to design the questionnaire. What I recommend is looking up some tutorials online for VB6 just to get a small understanding for the language. Trust me, it will help you so much 🙂

Unfortunately, I can only help so much. I don’t know how you want to design the questionnaire. What I recommend is looking up some tutorials online for VB6 just to get a small understanding for the language. Trust me, it will help you so much 🙂

I intend to make the questionnaire in the character creation menu, and work as follows: if the player responded more “A” than “B” it would be the Mage class, but responded more “B” than “A” it would be a Knight, for example.

Log in to reply