ID:141470
 
Code:
obj
Pokeball
var/Gowner = "nobody"
var/Capture = "nobody"
name = "Pokeball"
icon = 'Pokeballs.dmi'
icon_state = "Pokeball"
density = 1
New()
..()
verb
Drop()
for(var/obj/Pokeball/O in usr.contents)
if(O.ammount<=0)
del(src)
else
var/drop = input("How many pokeballs do you wish to drop?")as num
if(src.ammount<drop)
usr<<"You don't have that many to drop."
return
if(drop<=0)
usr<<"You cannot do that."
return
if(src.ammount>=drop)
src.ammount-=drop
var/obj/Pokeball/B = new/obj/Pokeball
B.loc=locate(usr.x,usr.y-1,usr.z)
B.ammount=drop
view(usr)<<"[usr] drops [drop] a pokeball."
O.name = "Pokeball"
O.name= "[O.name]: [O.ammount]"
usr.Save()
Get()
set src in oview(1)
usr<<"You picked up [src]"
for(var/obj/Pokeball/O in usr.contents)
counter+=1
if(counter<=0)
Move(usr)
else
for(var/obj/Pokeball/O in usr.contents)
O.ammount+=src.ammount
O.name = "Pokeball"
O.name= "[O.name]: [O.ammount]"
del(src)
Throw()
set src in usr.contents
usr<<"You have throwed a pokeball"
var/obj/Pokeball/A = new/obj/Pokeball
A.loc=locate(usr.x,usr.y,usr.z)
A.Gowner=usr
A.dir = usr.dir
walk(A,usr.dir)
Sent_out(mob/M in world)
if(M.name == "[Capture]")
M.loc = locate(usr.x,usr.y,usr.z)
else
return
Bump(A)
if(ismob(A))
var/mob/M = A
if(Gowner == A)
del(src)
if(M.hp >= 50)
usr.random = rand(1,10)
if(usr.random == 10)
world << "[usr] captured [M]"
src.Capture = "[M]"
src.name = "Pokeball [Capture]"
src.loc = usr
else
world << "The pokemon broke out"
return
if(M.hp <= 49)
usr.random = rand(1,3)
if(usr.random == 3)
world << "[usr] captured [M]"
src.Capture = "[M]"
src.name = "Pokeball [Capture]"
src.loc = usr
else
world << "The pokemon broke out"
return
if(istype(A,/turf/))
del(src)
if(istype(A,/obj/))
del(src)


Problem description:The pokeball won't move,it just stands still.How do I put that Bump under Throw command if i try, it just says Proc definition not allowed inside another proc for the line below bump, and is there a better way to do this thing?

walk(A,usr.dir)

Shouldn't the second argument be the number of steps?
In response to Immibis
...If you're unsure, shouldn't you take a couple of seconds of your time to look it up before posting?
To answer the question, it's indeed the direction to walk in (though even if it actually was the number of steps, it'd have partially worked as dirs are numerical).
There are so many things wrong with this code...but none of the ones I can see seem to be the problem.

(By the way, a[b]m[/b]ount has one 'm')
(Why is there one pokeball object with an amount? Why not multiple pokeballs?)
        New()
..()

Why?
        verb
Drop()
for(var/obj/Pokeball/O in usr.contents)

Use locate() if they will only ever have one /obj/Pokeball.
                    if(O.ammount<=0)
del(src)
else
var/drop = input("How many pokeballs do you wish to drop?")as num
if(src.ammount<drop)
usr<<"You don't have that many to drop."
return
if(drop<=0)
usr<<"You cannot do that."
return
if(src.ammount>=drop)
src.ammount-=drop

So if they drop all their pokeballs, they get a pokeball with 0 amount? Which is deleted the [b]next[/b] time they try to drop it?
view(usr)<<"[usr] drops [drop] a pokeball."

That should be "[usr] drops [drop] pokeball[drop != 1?"s":""]." Don't you know how to speak English?
                            O.name = "Pokeball"
O.name= "[O.name]: [O.ammount]"

So you change the name to "Pokeball", then change it to the pokeball's name and amount. Why?
                usr<<"You have throwed a pokeball"

That should be throw[b]n[/b], not throw[b]ed[/b]
                var/obj/Pokeball/A = new/obj/Pokeball

The second "/obj/Pokeball" is redundant.
                A.loc=locate(usr.x,usr.y,usr.z)

A.loc=usr.loc
<dm>
M.loc = locate(usr.x,usr.y,usr.z)

Again, M.loc = usr.loc
                else
return

Redundant, since when the end of the verb/proc is reached, it returns anyway
                    usr.random = rand(1,10)

NO USR IN PROCS! Also you should make a local variable, ie var/random
Now think about it:
What is A or M? Whoever this pokeball bumped
What is src? This pokeball
What is usr? Most likely null, which will cause a runtime error.
                        src.Capture = "[M]"

Horrible.
                        src.loc = usr

Again, what should you use instead of usr?
                if(M.hp <= 49)

heard of else?
                    usr.random = rand(1,3)
if(usr.random == 3)
world << "[usr] captured [M]"
src.Capture = "[M]"
src.name = "Pokeball [Capture]"
src.loc = usr
else
world << "The pokemon broke out"
return

Same problems as before.
In response to Immibis
I know it's crappy coding,and I'm gonna fix that,but first I need to find where the problem is for the walk,as for the pokeball i tested it so that it bumps into me,capturing works ok but sent out is obviously messed up since i suddenly start attacking for no reason,and you have to search for the mob in that selection screen. xD
In response to Destrojer
Tried a few things but still can't make the pokeball move >.>

Is a problem maybe here?

obj/var/tmp
walk = 0
walkm = 7
Owner
haveowner = 0
speeding
Move_Delay = 0
move = 1


obj/Move()
if(!src.move)
return
if(src.speeding <= 0)
src.speeding = 1
..()
sleep(src.Move_Delay)
src.speeding = 0


I mean i have 1 attack that involves the object moving,and it works....but this for some reason won't work and i can't figure it out.As for the rest i know how to fix,just this walk thingy >.<

In response to Destrojer
finally.....Fixed. ^^