ID:141452
 
Code:
            Throw()
set src in usr.contents
usr<<"You have thrown a pokeball"
var/A = new/obj/Pokeball
A:name = "[usr]"
A:loc=usr.loc
A:Gowner=usr
A:dir = usr.dir
walk(A,usr.dir)


Problem description:If I add a del proc for the one inside contents,the new pokeball won't be created.

                if(M.hp >= 50)
if(!M.client)
M.loc = src
world<<"[src] captured [M]"
walk(src,0)
M:Owner = "[src]"
src.Capture = "[M]"
src.name = "Pokeball [Capture]"
return
else
world << "[src] captured [M]"
src.Capture = "[M]"
M:Owner = "[src]"
src.name = "Pokeball [Capture]"
walk(src,0)
return


Problem description:Well....if I place the M in the pokeball-s contents it will just walk out,if I freeze M it will still walk out,and If I create another pokemon inside everything will work but the code will stop at the point where it has to create the pokemon,so the new pokemon won't be created.

How do I define that the pokeball returns to the user (Gowner)? The capture thingy is under Bump() so there is no usr there.
Don't ever use :, use a combination of . and typecasting instead. If you do not know what typecasting is, go read the DM guide, I'm pretty sure it has a chapter on typecasting.
In response to Jeff8500
There's also this wonderful little article :D I learned type casting from this myself.

http://www.byond.com/members/ DreamMakers?command=view_post&post=39514
In response to Spunky_Girl
Okay....I made it actually catch a pokemon,and send it out....but there are still a few problems

mob
proc
NPCAI()
var/mob/player/M
if(src.NPC == 2)
return
while(src)
if(src.Logblock == 1)
return
if(M in oview(5))
if(M.NPC == 0)
sleep(20) //This I guess has no meaning since I'm supposed to remove it....gonna do that later xD
walk_to(src,M,1,10) //This is supposed to be stopped with Logblock but it's not
if(M in oview(1)) //This is blocked by Logblock
step_towards(src,M) //This is also blocked
Eevee_defence() //And this is blocked
else
walk_rand(src,15) //This is blocked too
break
else
walk_rand(src,15) // Blocked
for(M in view(src))
break
sleep(5)
spawn(2)
NPCAI()


When you catch M it's Logblock turns 1....so I wrote inside what won't work. (AI is stopped cept for the part if the player is in range of 5,so if any player shows up it will run after it)

And here is one more problem.

        Bump(A)
if(ismob(A))
var/mob/M = A
var/mob/L = src.Gowner
if(Gowner == A)
del(src)
if(M.hp >= 50)
if(!M.client)
M.loc = src
world<<"[src] captured [M]"
M.Logblock = 1
M.Owner = "[src]"
src.Capture = "[M]"
src.name = "Pokeball [Capture]"
walk(src,0)
src.loc = L
return
else
world << "[src] captured [M]"
src.Capture = "[M]"
M.Owner = "[src]"
src.name = "Pokeball [Capture]"
walk(src,0)
src.loc = L
return
else
world << "The pokemon broke out"
return


Well....it catches it,but if it catches it while it was walking or doing something,then the AI that is above won't stop,so it will walk out of src (Pokeball) and go ahead attacking me. (And as for making a new mob of the same type....i only would know it with the repedative code of

if(mob.name = "name")
//create that mob
So,Is there any way to like make a duplicate of M and put it in the pokeball (since this way of just putting M inside would shortly clean out the world of NPC pokemon ^^)
In response to Destrojer
Ok,I fixed the AI problem by implementing another walk_to(src,src,0) at Logblock

Still....how do i create a copy of the pokemon that i caught...so that the one bumped is not inside.....that he gets deleted and a copy of him is made in the pokeball...that i don't have to define for every pokemon with if(M.name = "name")....(this should also fix the problem with the pokemon walking out of pokeball)
In response to Destrojer
Ok....got another problem with Return

runtime error: Cannot modify null.mob.
proc name: Return (/mob/enemy/Eevee/verb/Return)
source file: NPC-s.dm,46
usr: Wild Eevee (/mob/enemy/Eevee)
src: Wild Eevee (/mob/enemy/Eevee)
call stack:
Wild Eevee (/mob/enemy/Eevee): Return()
Destrojer was found

And the code is:

            verb
Return()
for(var/mob/M in world)
if(usr.Owner == M.name)
M.Logblock = 1 //Here Logblock is used to stop the mob from disconecting or going into the Login screen
usr<<"[M] was found"
usr.client.mob = M //Line 46 like in the error
M.Logblock = 0
for(var/obj/Pokeball/O in M.contents)
if(O.Capture == usr.name)
usr.loc = O


Well....I use return and it just shows me a black screen after,like i have no mob (location(0,0,0))...So why can't it modify the mob that I'm returning to?
In response to Destrojer
Becuase you're setting "usr.loc = O", which puts the user inside the pokeball...
In response to Immibis
Well.....when i capture him he goes into the pokeball....then i have send out which sets his position on the same as users and the client changes from trainer to the sent out pokemon. But in this return...i want to change control from pokemon back to trainer and send the pokemon back to the pokeball,but it returns the pokemon back to the ball and makes my client null.


[EDIT] Ummm.......i started over and tried the return thingy again and it works? x_x