ID:1290785
 
(See the best response by LordAndrew.)
Code:
        name = text_prompt("What is your name?")
class = prompt("What character class would you like to be?", "Knight", "Ranger", "Mage")
loc = locate(17, 35, 1)
camera.pixel_x = 24

if (class == "Knight")
get_item(new /item/health_potion(2))
get_item(new /item/mana_potion(2))
get_item(new /item/armor())
get_item(new /item/helmet())
equip(get_item(new /item/sword()))
abilities += new /Ability/MeleeAttack()
base_speed = 3
set_money(20)

if (class == "Archer")
get_item(new /item/health_potion(2))
get_item(new /item/armor())
get_item(new /item/helmet())
get_item(new /item/dagger())
abilities += new /Ability/ShootArrow()
base_speed = 5
set_money(20)

if (class == "Mage")
get_item(new /item/health_potion(2))
get_item(new /item/mana_potion(2))
get_item(new /item/armor())
get_item(new /item/helmet())
get_item(new /item/dagger())
abilities += new /Ability/Fireball()
base_speed = 4
set_money(20)


Problem description:
Hello, I am posting here because I can't get class selection to work properly. I am trying to get it so that each class starts off with set amount of items and certain skills. But the I seem to be doing this wrong. Could anyone help?
Best response
Your indention appears to be off. You need to tab over the get_item(), abilities += etc, and so forth under the if (class == "Class") lines.
Thanks, I didn't know something so simple would be my failure. :) Thank you for your help.


- Fixed and is now working.-
Err not sure if i am allowed to double post or not so sorry in advance :3

    name = text_prompt("What is your name?")
class = prompt("What character class would you like to be?", "Knight", "Archer", "Mage")
loc = locate(17, 35, 1)
camera.pixel_x = 24
if (class == "Knight")
class = prompt("What type?", "Beserker", "Warrior", "Paladin")
if (class == "Beserker")
get_item(new /item/health_potion(2))
get_item(new /item/mana_potion(2))
get_item(new /item/armor())
get_item(new /item/helmet())
equip(get_item(new /item/sword()))
abilities += new /Ability/MeleeAttack()
base_speed = 3
set_money(20)
if (class == "Warrior")
get_item(new /item/health_potion(2))
get_item(new /item/mana_potion(2))
get_item(new /item/armor())
get_item(new /item/helmet())
equip(get_item(new /item/sword()))
abilities += new /Ability/MeleeAttack()
base_speed = 3
set_money(20)
if (class == "Paladin")
get_item(new /item/health_potion(2))
get_item(new /item/mana_potion(2))
get_item(new /item/armor())
get_item(new /item/helmet())
equip(get_item(new /item/sword()))
abilities += new /Ability/MeleeAttack()
base_speed = 3
set_money(20)


is there a way to go about doing this? ( the code I posed above isn't working. )
In response to Kenpachl
Sure thing. Use a switch statement.

the format is:
switch(class)
if("Knight")
//give knight items
if("Berserker")
//give berserker items


Also the reason your code isn't working (from what I can tell is that you seem to be indenting when you don't have a need to.

For instance :
camera.pixel_x = 24
if (class == "Knight")


and

class = prompt("What type?", "Beserker", "Warrior", "Paladin")
if (class == "Beserker")


/ and an indentation are the same thing when it comes to DM.

You would only need an indentation in certain circumstances.

If you wanted to create a class selection code segment you would only need to indent like so given if you used a switch statement
switch(class)
if("Knight")
//do stuff
if("Archer")
//do stuff
if("Mage")
//do stuff


If when to use an indent is still unclear to you, you could check out the first 2-3 chapters of the Guide, its covered there.
Alright i will give that a try.
Er, I reread your reply once again before I tried this and I think you are still trying to help my OP.

My current class selection code works thanks to LordAndrew but what I am trying to achieve now is sub classes such as Support / Tank / DPS after the user chooses the main class such as this..
i.e : if I choose a Knight I would be redirected to another class prompt to choose what subclass I wanted to be.

Knight :
Beserker > DPS / Tank
Warrior > DPS
Paladin > Tank
switch(class)
if("Knight")
//give knight items
//ask sub class choice
if("Berserker")
//give berserker items
//ask sub class choice
In response to Dariuc
Dariuc wrote:
> switch(class)
> if("Knight")
> //give knight items
> //ask sub class choice
> if("Berserker")
> //give berserker items
> //ask sub class choice
>

Doesn't Seem to be working ( though I may have messed up somewhere =/ )
What I put :
        name = text_prompt("What is your name?")
class = prompt("What character class would you like to be?", "Knight", "Archer", "Mage")
loc = locate(17, 35, 1)
camera.pixel_x = 24

if ("Knight")
switch(class)
class = prompt("What type?", "Warrior", "Berserker ")
if(class == "Warrior")
get_item(new /item/health_potion(2))
get_item(new /item/mana_potion(2))
get_item(new /item/armor())
get_item(new /item/helmet())
equip(get_item(new /item/sword()))
abilities += new /Ability/MeleeAttack()
base_speed = 3
set_money(20)

if(class == "Berserker")
get_item(new /item/health_potion(2))
get_item(new /item/mana_potion(2))
get_item(new /item/armor())
get_item(new /item/helmet())
equip(get_item(new /item/sword()))
abilities += new /Ability/MeleeAttack()
base_speed = 3
set_money(20)


It gives an error called ' Bad argument definition '
Don't you have to treat switch as if it were an if() in terms of indention?
In response to Kenpachl

Once again it's a problem with your indentation.
Also you aren't using the switch statement properly.

In response to Kenpachl
var/choice=prompt("What class do you want to be?","Knight","And so on")
switch(choice)
if("Knight")
usr<<"You've chosen to be a knight."
var/sub_choice=prompt("What sub-class would you like to be?","Berserker","And so on")
switch(sub_choice)
if("Berserker")
//do berserker stuff.
if("And so on")
//do other stuff.

I've been told that we will not be using Sub classes for the sake of more coding for now. ( will most likely be in the future though. ) Thank you @Dariuc and @LordAndrew for your help. Though I didn't end up using the last method I have learned a thing or two ;) I will be sure to check my indention's before asking for help.


In response to Kenpachl
N/p good luck.
You can use inheritance to simply how you add starting bonuses, and then the logic is defined on the class too.

Creating New of Class:
var/classes    = list("Knight","Mage")
var/mage_sub = list("Warlock","Troll")
var/knight_sub = list("Beserker","Defender")

client/proc/create_new()
var/class = input("Please Select a Class") in list("Knight","Mage")
var/subclass

switch(class)
if("Knight")
subclass = input("Please Select a Sub-Class") in knight_sub
if("Mage")
subclass = input("Please Select a Sub-Class") in mage_sub

var/mob/player/hero = new text2path("/mob/player/hero/[class]/[subclass]")
hero.WelcomePackage()
src.mob = hero //this will call hero.login()


Defining what they get:
mob/player/hero
var/base_speed = 1

proc/WelcomePackage()
get_item(new /item/health_potion(2))
get_item(new /item/mana_potion(2))
set_money(20)

mob/player/hero/Knight
base_speed = 3
WelcomePackage()
get_item(new /item/armor())
get_item(new /item/helmet())
abilities += new /Ability/MeleeAttack()
equip(get_item(new /item/sword()))
..()

mob/player/hero/Mage
base_speed = 5
WelcomePackage()
get_item(new /item/dress())
get_item(new /item/funnyhat())
abilities += new /Ability/poof()
equip(get_item(new /item/stick()))
..()


mob/player/hero/Mage/Warlock
WelcomePackage()
abilities += new /Ability/ConjureDemon()
..() //call the default

mob/player/hero/Mage/Troll
WelcomePackage()
abilities += new /Ability/Curse()
..() //call the default

mob/player/hero/Knight/Beserker
WelcomePackage()
abilities += new /Ability/GoBeserk()
..() //call the default

mob/player/hero/Knight/Defender
WelcomePackage()
equip(get_item(new /item/shield()))
..() //call the default
Is it possible to give the selected class certain stats? If so how would this be implemented?
mob/var
Str=10 //Strength
Def=10 //Defense
Agil=10 //Agility
Magic=10
Mana=10
//etc

mob/proc
Class()
var/class = input("Please Select a Class") in list("Knight","Mage")
switch(class)//If I don't put this, it'll cause errors
if("Knight")
src.Str=100
src.Def=100
src.Agil=100
if("Mage")
src.Magic=100
src.Mana=100
Using the same basis as I did above, I overwrote the value of base_speed for mages like so:

mob/player/hero/Mage
base_speed = 5


This uses the default for all except children of Mage, in which it uses the new value of 5.