ID:1004382
 
Code:
mob
proc
NatureChoose()
var/list/n = new()
n += "Attack"
n += "Defense"
n += "Special Attack"
n += "Special Defense"
n += "Speed"
n += "All are equil"
var/R = input("Which stat do you depend on the most?", "Choose", null) in n
if(R == "Attack")
src.CH1 = "atk"
src.N2()
return
if(R == "Defence")
src.CH1 = "def"
src.N2()
return
if(R == "Special Attack")
src.CH1 = "specatk"
src.N2()
return
if(R == "Special Defence")
src.CH1 = "specdef"
src.N2()
return
if(R == "Speed")
src.CH1 = "spd"
src.N2()
return
if(R == "All are equil")
src.CH1 = "all1"
src.N2()
return

N2()
var/list/n = new()
if(src.CH1 == "atk")
n += "Defence"
n += "Special Attack"
n += "Special Defence"
n += "Speed"
n += "All are equil"
if(src.CH1 == "def")
n += "Attack"
n += "Special Attack"
n += "Special Defence"
n += "Speed"
n += "All are equil"
if(src.CH1 == "specatk")
n += "Attack"
n += "Defence"
n += "Special Defence"
n += "Speed"
n += "All are equil"
if(src.CH1 == "specdef")
n += "Attack"
n += "Defence"
n += "Special Attack"
n += "Speed"
n += "All are equil"
if(src.CH1 == "spd")
n += "Attack"
n += "Defence"
n += "Special Attack"
n += "Special Defence"
n += "All are equil"
if(src.CH1 == "all1")
n += "Attack"
n += "Defence"
n += "Special Attack"
n += "Special Defence"
n += "Speed"
n += "All are equil"
var/R = input("Which stat do you depend on the least?", "Choose", null) in n
if(R == "Attack")
src.CH2 = "atk"
src.NatureCheck()
return
if(R == "Defence")
src.CH2 = "def"
src.NatureCheck()
return
if(R == "Special Attack")
src.CH2 = "specatk"
src.NatureCheck()
return
if(R == "Special Defence")
src.CH2 = "specdef"
src.NatureCheck()
return
if(R == "Speed")
src.CH2 = "spd"
src.NatureCheck()
return
if(R == "All are equil")
src.CH2 = "all2"
src.NatureCheck()
return

NatureCheck()
if(src.CH1 == "atk")
if(src.CH2 == "def")
src.Nature = "Lonely"
return
if(src.CH2 == "specatk")
src.Nature = "Adamant"
return
if(src.CH2 == "specdef")
src.Nature = "Naughty"
return
if(src.CH2 == "spd")
src.Nature = "Brave"
return
if(src.CH1 == "def")
if(src.CH2 == "atk")
src.Nature = "Bold"
return
if(src.CH2 == "specatk")
src.Nature = "Impish"
return
if(src.CH2 == "specdef")
src.Nature = "Lax"
return
if(src.CH2 == "spd")
src.Nature = "Relaxed"
return
if(src.CH1 == "specatk")
if(src.CH2 == "atk")
src.Nature = "Modest"
return
if(src.CH2 == "def")
src.Nature = "Mild"
return
if(src.CH2 == "specdef")
src.Nature = "Rash"
return
if(src.CH2 == "spd")
src.Nature = "Quiet"
return
if(src.CH1 == "specdef")
if(src.CH2 == "atk")
src.Nature = "Calm"
return
if(src.CH2 == "def")
src.Nature = "Gentle"
return
if(src.CH2 == "specatk")
src.Nature = "Careful"
return
if(src.CH2 == "spd")
src.Nature = "Sassy"
return
if(src.CH1 == "spd")
if(src.CH2 == "atk")
src.Nature = "Timid"
return
if(src.CH2 == "def")
src.Nature = "Hasty"
return
if(src.CH2 == "specatk")
src.Nature = "Jolly"
return
if(src.CH2 == "specdef")
src.Nature = "Naive"
return
if(src.CH1 == "all1")
var/f = rand(1,5)
if(f == 1)
src.Nature = "Hardy"
return
if(f == 2)
src.Nature = "Docile"
return
if(f == 3)
src.Nature = "Serious"
return
if(f == 4)
src.Nature = "Bashful"
return
if(f == 5)
src.Nature = "Quirky"
return


Problem description:
I am trying to make a proc that is launched once you have chosen which pokemon you want to be, so far it is working perfectly. After you pick your pokemon, it runs this smoothly. My only issue is that, sometimes it does not want to launch after you have chosen the first answer...i need help with 2 things, 1: If possible, making this shorter and sweeter. and 2: Help figuring out why it sometimes does not want to load the second list of options for you to choose.

Note: i hope the code posts correctly, first time ever doing so :/
Here's how I would do it:

mob
proc
NatureChoose()
var/list/n = new()
n += "Attack"
n += "Defense"
n += "Special Attack"
n += "Special Defense"
n += "Speed"
n += "All are equal"
var/R = input("Which stat do you depend on the most?", "Choose", "Attack") in n

src.CH1 = R

N2()

N2()
var/list/n = new()
n += "Attack"
n += "Defense"
n += "Special Attack"
n += "Special Defense"
n += "Speed"
n += "All are equal"

n -= src.CH1 //remove first choice from list

var/R = input("Which stat do you depend on the least?", "Choose", Attack) in n

src.CH2 = R

NatureCheck()
var/list/L = list(CH1,CH2)
switch(L)
if(list("Attack", "Defense"))
src.Nature = "Lonely"
return
if(list("Attack", "Special Attack"))
src.Nature = "Adamant"
return
if(list("Attack", "Special Defense"))
src.Nature = "Naughty"
return
if(list("Attack", "Speed"))
src.Nature = "Brave"
return


I have never tried using lists in a switch block but I think it will work :D. It won't save that much typing however - I can't think of a good way to do that without just having a long list of possibilities. Anyway, I'm not sure why your N2() proc isn't getting called. I have to think about it more
i will give it a try, i can easily replace my code and then turn it back once i have finished trying it out, thanks for the help :D
ok, after rewriting my code to yours and adding my own stuff including what you left out i ended up with this:
mob
proc
NatureChoose()
var/list/n = new()
n += "Attack"
n += "Defense"
n += "Special Defense"
n += "Special Attack"
n += "Speed"
n += "None"
var/R = input("Which stat do you depend on the most?", "Choose", null)in n

src.CH1 = R

N2()

N2()
var/list/n = new()
n += "Attack"
n += "Defence"
n += "Special Attack"
n += "Special Defence"
n += "Speed"
n += "None"
if(src.CH1 != "None")
n -= src.CH1

var/R = input("Which stat do you depend on the least?", "Choose", null)in n

src.CH2 = R
src.NatureCheck()

NatureCheck()
var/list/L = list(src.CH1,src.CH2)
switch(L)
if(list("Attack", "Defense"))
src.Nature = "Lonely"
return
if(list("Attack", "Speed"))
src.Nature = "Brave"
return
if(list("Attack", "Special Attack"))
src.Nature = "Adamant"
return
if(list("Attack", "Special Defense"))
src.Nature = "Naughty"
return
if(list("Defense", "Attack"))
src.Nature = "Bold"
return
if(list("Defense", "Speed"))
src.Nature = "Relaxed"
return
if(list("Defense", "Special Attack"))
src.Nature = "Impish"
return
if(list("Defense", "Special Defense"))
src.Nature = "Lax"
return
if(list("Speed", "Attack"))
src.Nature = "Timid"
return
if(list("Speed", "Defense"))
src.Nature = "Hasty"
return
if(list("Speed", "Special Attack"))
src.Nature = "Jolly"
return
if(list("Speed", "Special Defense"))
src.Nature = "Naive"
return
if(list("Special Attack", "Attack"))
src.Nature = "Modest"
return
if(list("Special Attack", "Defense"))
src.Nature = "Mild"
return
if(list("Special Attack", "Speed"))
src.Nature = "Quiet"
return
if(list("Special Attack", "Special Defense"))
src.Nature = "Rash"
return
if(list("Special Defense", "Attack"))
src.Nature = "Calm"
return
if(list("Special Defense", "Defense"))
src.Nature = "Gentle"
return
if(list("Special Defense", "Speed"))
src.Nature = "Sassy"
return
if(list("Special Defense", "Special Attack"))
src.Nature = "Careful"
return

if(src.CH1 == "None")
var/f = rand(1,5)
if(f == 1)
src.Nature = "Hardy"
return
if(f == 2)
src.Nature = "Docile"
return
if(f == 3)
src.Nature = "Serious"
return
if(f == 4)
src.Nature = "Bashful"
return
if(f == 5)
src.Nature = "Quirky"
return
if(src.CH2 == "None")
var/f = rand(1,5)
if(f == 1)
src.Nature = "Hardy"
return
if(f == 2)
src.Nature = "Docile"
return
if(f == 3)
src.Nature = "Serious"
return
if(f == 4)
src.Nature = "Bashful"
return
if(f == 5)
src.Nature = "Quirky"
return

now my issue is: it is not setting my nature at all, it goes through the lists properly, but i assume it is not launching the NatureCheck()

one more thing, i am attempting to make a verb that is accessable through the commands tab AND right clicking the other player, called Set Target. my current code:
mob/verb/SetTarget(var/mob/M in oview(5,usr)) src.Target = M

i am not sure what is wrong or even how to do it :/, but this is as close to what i would think is correct...
nvm about the target verb, i think i figured it out:
mob
verb
Set_Target(var/mob/M in view(usr))
if(M != src)
src.Target = M
view(usr) << "[usr] targets [M]"
else
usr << "You cannot target yourself"
return
Instead of doing all of that for picking natures, I'd prefer something like this:
var/list/natures=list("Lonely"=list("Attack","Defense"),"Brave"=list("Attack", "Speed"))
// you get the idea

mob/proc
picknature()
var/x=input("pick nature fool","natures")as null|anything in natures
if(x)
nature=natures[natures.Find(x)]
src<<"Your nature is [nature]."
highstat=natures[nature][1]
lowstat=natures[nature][2]
src<<"Your primary stat will be [highstat]. Low-end stat will be: [lowstat]."
else src<<"y u no like natures?"


It seems much simpler than that wall of text you currently have and potentially does the exact same thing.
i need some help with another matter...i am trying to get it to add an attack depending on what level you are...just like in the original pokemon games...my code:
mob
Attacks
verb
Struggle()
set category = "Moves"
for(var/mob/M in oview(1,src))
if(M == src.Target)
src.Attacking = 1
src.attackstr = src.attack * 5
src.acc = 100
src.AttackType = "normal"
var/a = src.attackstr + src.attack + src.attackstrgain
var/b = a - M.defense
var/c = src.acc + src.speed / 2
var/d = M.speed / 2
var/e = c - d
var/f = prob(e)
if(!f)
view(src) << "[src] used Struggle on [M] but missed"
src.Attacking = 0
src.attackstr = 0
src.AttackType = null
return
else
if(b <= 0)
usr << "[M] has more defense than your attack can handle"
view(src) << "[src] used Struggle on [M] for 1 damage"
M.hp -= 1
src.Attacking = 0
src.attackstr = 0
src.AttackType = null
src.hp -= src.attack
src.acc = 0
return

else
if(M.Type == "Ghost" | M.Type2 == "Ghost")
view(src) << "[src] used Struggle on [M] but was unaffected"
src << "Ghost type pokemon are immune to normal attacks"
src.Attacking = 0
src.attackstr = 0
src.AttackType = null
src.acc = 0
return
if(M.Type == "Rock" | M.Type2 == "Rock" | M.Type == "Steel" | M.Type2 == "Steel")
if(M.Type == "Rock" && M.Type2 == "Steel")
var/g = b * 0.3
view(src) << "[src] used Struggle on [M] for [f] damage, it wasn't very effective"
M.hp -= g
src.Attacking = 0
src.attackstr = 0
src.AttackType = null
src.hp -= src.attack
src.acc = 0
return
if(M.Type == "Steel" && M.Type2 == "Rock")
var/g = b * 0.3
view(src) << "[src] used Struggle on [M] for [f] damage, it wasn't very effective"
M.hp -= g
src.Attacking = 0
src.attackstr = 0
src.AttackType = null
src.hp -= src.attack
src.acc = 0
return
else
var/g = b * 0.6
view(src) << "[src] used Struggle on [M] for [f] damage, it wasn't very effective"
M.hp -= g
src.Attacking = 0
src.attackstr = 0
src.AttackType = null
src.hp -= src.attack
src.acc = 0
return
else
view(src) << "[src] used Struggle on [M] for [b] damage"
M.hp -= b
src.Attacking = 0
src.attackstr = 0
src.AttackType = null
src.hp -= src.attack
src.acc = 0
return

Tackle()
set category = "Moves"
for(var/mob/M in oview(1,src))
if(M == src.Target)
src.Attacking = 1
src.attackstr = 35
src.AttackType = "normal"
src.acc = 95
var/a = src.attackstr + src.attack + src.attackstrgain
var/b = a - M.defense
var/c = src.acc + src.speed / 2
var/d = M.speed / 2
var/e = c - d
var/f = prob(e)
if(!f)
view(src) << "[src] used Tackle on [M] but missed"
src.Attacking = 0
src.attackstr = 0
src.AttackType = null
return
else
if(b <= 0)
usr << "[M] has more defense than your attack can handle"
view(src) << "[src] used Tackle on [M] for 1 damage"
M.hp -= 1
src.Attacking = 0
src.attackstr = 0
src.AttackType = null
src.acc = 0
return

else
if(M.Type == "Ghost" | M.Type2 == "Ghost")
view(src) << "[src] used Tackle on [M] but was unaffected"
src << "Ghost type pokemon are immune to normal attacks"
src.Attacking = 0
src.attackstr = 0
src.AttackType = null
src.acc = 0
return
if(M.Type == "Rock" | M.Type2 == "Rock" | M.Type == "Steel" | M.Type2 == "Steel")
if(M.Type == "Rock" && M.Type2 == "Steel")
var/g = b * 0.3
view(src) << "[src] used Tackle on [M] for [f] damage, it wasn't very effective"
M.hp -= g
src.Attacking = 0
src.attackstr = 0
src.AttackType = null
src.acc = 0
return
if(M.Type == "Steel" && M.Type2 == "Rock")
var/g = b * 0.3
view(src) << "[src] used Tackle on [M] for [f] damage, it wasn't very effective"
M.hp -= g
src.Attacking = 0
src.attackstr = 0
src.AttackType = null
src.acc = 0
return
else
var/g = b * 0.6
view(src) << "[src] used Tackle on [M] for [f] damage, it wasn't very effective"
M.hp -= g
src.Attacking = 0
src.attackstr = 0
src.AttackType = null
src.acc = 0
return
else
view(src) << "[src] used Tackle on [M] for [b] damage"
M.hp -= b
src.Attacking = 0
src.attackstr = 0
src.AttackType = null
src.acc = 0
return

Growl()
set category = "Moves"
for(var/mob/M in oview(3,src))
if(M == src.Target)
src.Attacking = 1
src.AttackType = "normal"
src.acc = 100
var/a = src.acc + src.speed / 2
var/b = M.speed / 2
var/c = a - b
var/d = prob(c)
if(!d)
view(src) << "[src] used Growl on [M] but missed"
src.Attacking = 0
src.AttackType = null
src.acc = 0
return
else
var/f = M.attack / 2
M.attack -= f
view(src) << "[src] used growl and lowered [M]'s attack by [f]"
spawn(50) M.attack += f
src.Attacking = 0
src.AttackType = null
src.acc = 0
return

mob
proc
AttackGain()
START
if(src.level >= 1)
src.verbs += /mob/Attacks/verb/Struggle/
usr << "You learn Struggle"
if(src.icon_state == "1")
if(src.level >= 1)
src.verbs += /mob/Attacks/verb/Tackle/
usr << "You learn Tackle"
return
if(src.level >= 3)
src.verbs += /mob/Attacks/verb/Growl/
usr << "You learn Growl"
return
spawn(10) goto START

my new issues are 1. It stops at Struggle when the proc AttackGain() initiates, this is fixable by removing return on all the lines, but once i do that, it keeps repeating "you have learned (insert move here)" over and over again. I only want it to say it once and once only, but i want this proc to repeat to make sure the player always has the correct attacks. 2. When you relog, you lose all the verbs you have gained through the proc, and somehow, you don't get them back...is there a way to save/load verbs? i tried F["Verbs"] << src.verbs in a save() proc i made, that works well, but it isnt working :/ is there a way to save/load verbs from a specific category? the path is /mob/Attacks/verb/ any help would be nice :D
Never use goto.
Also look up while loops. http://www.byond.com/docs/ref/info.html#/proc/while

You don't even need a loop for learning new skills. Just create the procedure for gaining new skills then call it in a LevelUp procedure which would usually be called when a player gains experience.

I'd also prefer to use a datum for a skill system. It would make things a lot more manageable. http://www.byond.com/forum/?post=35530
how would i impliment while() and switch() into my proc? I cannot see how, but i will inevitably attempt it...
In response to CJDinoBoy94
while(variable)
[action]
sleep(delay)
var/t="Example of switch"
switch(t)
if("Example of switch")
[action]
if("Not an example of switch")
[action2]

while([variable]) will loop until the variable is no longer positive(equals null|0|FALSE|"")), so it's best to put a delay on loops that will last awhile.
switch() takes a variable and uses it to compair with the following if() statements, allowing you to compair one variable with multiple posibilities without having to constantly check back for the variable you're attempting to compair.

You've already been given examples and a link to the referance about the while() proc, so if you still don't understand what's happening, you should take a step back and learn DM before attempting to make a game.

[EDIT] Because we aren't here to do your work for you, if you want someone to do that, goto the Classified Ads section. [END EDIT]
var/list/n = new()
n += "Attack"
n += "Defense"
n += "Special Attack"
n += "Special Defense"
n += "Speed"
n += "All are equil"

Don't know why you adding the the list like that, it's not needed...

var/list/n = list("Attack","Defense","Special Attack", "Special Defense", "Speed", "All are equil")
OP: You really need to stop repeating code like that. That lengthy if-else chain could be reduced to a single test. Like, give each pokemon a list of weaknesses and immunities. Then use the "in" operator to check for them.

OR ELSEE